farseer-cli 1.11.1 → 1.12.0
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/README.md +60 -0
- package/dist/commands/app.js +56 -6
- package/dist/commands/app.js.map +2 -2
- package/dist/commands/dashboards.js +16 -2
- package/dist/commands/dashboards.js.map +2 -2
- package/dist/commands/sheets.js +46 -34
- package/dist/commands/sheets.js.map +2 -2
- package/dist/commands/variables.js +7 -1
- package/dist/commands/variables.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +2 -0
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/tools/appTools.js +56 -6
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +79 -69
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +48 -59
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/utils/helpers.js +39 -5
- package/dist/mcp/utils/helpers.js.map +2 -2
- package/dist/services/appSyncService.js +33 -1
- package/dist/services/appSyncService.js.map +2 -2
- package/dist/services/apps.js +199 -9
- package/dist/services/apps.js.map +3 -3
- package/dist/services/farseerService.js +11 -0
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/modelExport.js +4 -2
- package/dist/services/modelExport.js.map +2 -2
- package/dist/utils/entityResolver.js +114 -28
- package/dist/utils/entityResolver.js.map +2 -2
- package/dist/utils/helpers.js +5 -5
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/{appResolver.js → nameResolver.js} +23 -23
- package/dist/utils/nameResolver.js.map +7 -0
- package/docs/cli-guide.md +16 -0
- package/package.json +1 -1
- package/dist/utils/appResolver.js.map +0 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/appSyncService.ts"],
|
|
4
|
-
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { RemoteApp, AppArgument, AppArgumentDataType } from './apps';\nimport type { FarseerService } from './farseerService';\nimport { getTenantAppsDir, ensureDirectoryExists, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\nimport { formatClientError } from '../utils/errorFormatter';\n\n// Local app config format (stored in apps/*.json) \u2014 mirrors AppArgument so\n// pull/push round-trips don't drop any axis.\nexport interface LocalAppConfig {\n name: string;\n description: string;\n entrypoint: string | null; // Script filename (e.g., \"index.ts\")\n arguments: {\n name: string;\n // `dataType` defaults to 'string' on legacy configs that pre-date typed\n // parameters. Without round-tripping the full axes (`dataType`,\n // `fixed`, `options`), a pull \u2192 push cycle silently demoted a boolean /\n // dropdown / locked arg back to a plain string variable.\n dataType?: AppArgumentDataType;\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }[];\n _remote?: {\n id: number;\n reference: string;\n };\n}\n\nexport interface AppSyncResult {\n created: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n}\n\nexport interface AppSyncStatus {\n newLocal: string[]; // Local apps not on remote\n newRemote: string[]; // Remote apps not locally\n modified: string[]; // Apps that differ\n synced: string[]; // Apps in sync\n}\n\n/**\n * Sanitize Croatian diacritics and other special characters to ASCII equivalents\n */\nfunction sanitizeDiacritics(text: string): string {\n const diacriticMap: Record<string, string> = {\n // Croatian\n \u010D: 'c',\n \u010C: 'C',\n \u0107: 'c',\n \u0106: 'C',\n \u0161: 's',\n \u0160: 'S',\n \u017E: 'z',\n \u017D: 'Z',\n \u0111: 'd',\n \u0110: 'D',\n // German/Other common\n \u00E4: 'a',\n \u00C4: 'A',\n \u00F6: 'o',\n \u00D6: 'O',\n \u00FC: 'u',\n \u00DC: 'U',\n \u00DF: 'ss',\n // Polish\n \u0105: 'a',\n \u0104: 'A',\n \u0119: 'e',\n \u0118: 'E',\n \u0142: 'l',\n \u0141: 'L',\n \u0144: 'n',\n \u0143: 'N',\n \u00F3: 'o',\n \u00D3: 'O',\n \u015B: 's',\n \u015A: 'S',\n \u017A: 'z',\n \u0179: 'Z',\n \u017C: 'z',\n \u017B: 'Z',\n // French/Spanish\n \u00E0: 'a',\n \u00E1: 'a',\n \u00E2: 'a',\n \u00E8: 'e',\n \u00E9: 'e',\n \u00EA: 'e',\n \u00EB: 'e',\n \u00EC: 'i',\n \u00ED: 'i',\n \u00EE: 'i',\n \u00EF: 'i',\n \u00F2: 'o',\n \u00F4: 'o',\n \u00F9: 'u',\n \u00FA: 'u',\n \u00FB: 'u',\n \u00F1: 'n',\n \u00D1: 'N',\n \u00E7: 'c',\n \u00C7: 'C',\n };\n\n return text\n .split('')\n .map((char) => diacriticMap[char] || char)\n .join('');\n}\n\n/**\n * Migrate legacy `type: 'variable' | 'constant' | 'boolean' | 'dropdown'` on\n * pre-PR pulls to the orthogonal-axes shape used by `localToUpdate` and\n * `areAppsEqual`. Idempotent \u2014 leaves new-shape entries untouched.\n *\n * Without this, a push immediately after upgrade silently demoted locked\n * args (`type: 'constant'` \u2192 no `fixed`) because the new code ignores the\n * legacy `type` key when building the wire payload. `areAppsEqual` flagged\n * the diff but didn't block, so the silent demote slipped through.\n */\nfunction migrateLegacyArguments(config: { arguments?: unknown[] } & Record<string, unknown>): Record<string, unknown> {\n if (!Array.isArray(config.arguments)) return config as Record<string, unknown>;\n config.arguments = config.arguments.map((raw) => {\n if (raw === null || typeof raw !== 'object') return raw;\n const a = raw as Record<string, unknown>;\n if (a.dataType !== undefined || a.type === undefined) return a;\n const legacyType = a.type;\n const rest: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(a)) {\n if (k !== 'type') rest[k] = v;\n }\n switch (legacyType) {\n case 'constant':\n return { ...rest, dataType: 'string', fixed: true };\n case 'boolean':\n return { ...rest, dataType: 'boolean' };\n case 'dropdown':\n case 'variable':\n default:\n return { ...rest, dataType: 'string' };\n }\n });\n return config as Record<string, unknown>;\n}\n\n/**\n * Service for syncing app configurations between local JSON files and remote Farseer instance\n */\nexport class AppSyncService {\n private api: FarseerService;\n private appsDir: string;\n\n constructor(tenant: string, api: FarseerService) {\n this.api = api;\n this.appsDir = getTenantAppsDir(tenant);\n }\n\n /**\n * Get filename for an app (keep original name, just sanitize for filesystem)\n */\n private getAppFilename(name: string): string {\n return (\n sanitizeDiacritics(name)\n .replace(/[<>:\"/\\\\|?*]/g, '') // Remove invalid filename characters\n .trim() + '.json'\n );\n }\n\n /**\n * Names of locally-tracked apps the next `pull` would delete because\n * remote no longer has them. Uses only `listApps` (no per-app fetch),\n * so pull can preview deletions for the destructive-action prompt\n * without paying for getStatus's full per-app round-trip.\n *\n * Mirrors the deletion gate in `pull()` (`local._remote && !remoteApps.has(key)`):\n * apps the user never pulled (`_remote` undefined) are kept untouched\n * by pull, so they don't belong in this list.\n */\n async getRemoteDeletions(): Promise<string[]> {\n const localApps = this.loadLocalApps();\n const remoteAppList = await this.api.listApps();\n const remoteNames = new Set(remoteAppList.map((a) => a.name.toLowerCase()));\n const deleted: string[] = [];\n for (const [key, local] of localApps) {\n if (local._remote && !remoteNames.has(key)) {\n deleted.push(local.name);\n }\n }\n return deleted;\n }\n\n /**\n * Load all local app configs\n */\n loadLocalApps(): Map<string, LocalAppConfig> {\n const apps = new Map<string, LocalAppConfig>();\n\n if (!fs.existsSync(this.appsDir)) {\n return apps;\n }\n\n const files = fs.readdirSync(this.appsDir).filter((f) => f.endsWith('.json'));\n\n for (const file of files) {\n try {\n const content = fs.readFileSync(path.join(this.appsDir, file), 'utf-8');\n const config = migrateLegacyArguments(JSON.parse(content)) as LocalAppConfig;\n apps.set(config.name.toLowerCase(), config);\n } catch {\n // Skip invalid files\n }\n }\n\n return apps;\n }\n\n /**\n * Save a local app config\n */\n saveLocalApp(config: LocalAppConfig): void {\n ensureDirectoryExists(this.appsDir);\n const filename = this.getAppFilename(config.name);\n const filePath = path.join(this.appsDir, filename);\n fs.writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8');\n }\n\n /**\n * Delete a local app config\n */\n deleteLocalApp(name: string): boolean {\n const filename = this.getAppFilename(name);\n const filePath = path.join(this.appsDir, filename);\n\n if (fs.existsSync(filePath)) {\n fs.unlinkSync(filePath);\n return true;\n }\n return false;\n }\n\n /**\n * Convert remote app to local config format\n */\n private remoteToLocal(remote: RemoteApp, reference: string): LocalAppConfig {\n const scriptFiles = remote.scriptFiles ?? [];\n const mainScript = scriptFiles.find((s) => s.id === remote.mainScriptFileId);\n\n // \"No default\" canonical shape locally is `defaultValue: ''` (empty\n // string), NOT an omitted key. The OpenAPI schema makes the field\n // optional, so the backend can emit either; if we passed `undefined`\n // through verbatim, a user who added `defaultValue: ''` locally\n // would see `areAppsEqual` say \"match\" (both normalise to '') but\n // the next pull would strip the key again \u2014 the on-disk JSON would\n // oscillate forever and never reach a steady state. type is treated\n // the same way ('variable' is the implicit default), secret only\n // appears when explicitly true on the backend (boolean is a clear\n // tri-state: true/false/unset, and \"unset\" reads as false anyway).\n return {\n name: remote.name,\n description: remote.description || '',\n entrypoint: mainScript?.name || null,\n arguments: remote.expectedArguments.map((a) => {\n // Pin a steady-state shape so two pulls back-to-back don't\n // oscillate. `defaultValue` is normalized to '' when omitted \u2014\n // a user-edited `defaultValue: ''` locally must compare equal\n // to a remote that omits the field. `dataType` defaults to\n // 'string' (the implicit pre-fix shape). All other axes\n // (`fixed`, `options`, `secret`) are only emitted when the\n // remote populated them, to keep the JSON minimal.\n const arg: LocalAppConfig['arguments'][number] = {\n name: a.name,\n defaultValue: a.defaultValue ?? '',\n dataType: a.dataType ?? 'string',\n };\n if (a.fixed !== undefined) arg.fixed = a.fixed;\n if (a.options !== undefined) arg.options = a.options;\n if (a.secret !== undefined) arg.secret = a.secret;\n return arg;\n }),\n _remote: {\n id: remote.id,\n reference: reference,\n },\n };\n }\n\n /**\n * Check if local and remote app configs are equivalent\n */\n private areAppsEqual(local: LocalAppConfig, remote: RemoteApp): boolean {\n // Compare name\n if (local.name !== remote.name) return false;\n\n // Compare description\n if ((local.description || '') !== (remote.description || '')) return false;\n\n // Compare entrypoint\n const remoteScriptFiles = remote.scriptFiles ?? [];\n const remoteEntrypoint = remoteScriptFiles.find((s) => s.id === remote.mainScriptFileId)?.name || null;\n if (local.entrypoint !== remoteEntrypoint) return false;\n\n // Compare arguments. Order matters here: backend renders args in the\n // saved order in the UI, so we treat reordering as a real change.\n // Missing `dataType` defaults to 'string' (the implicit pre-fix value);\n // missing scalar defaults are normalized so '' vs undefined doesn't\n // show up as a spurious diff. All four axes (dataType, fixed, options,\n // defaultValue, secret) are compared so a pull\u2192push round-trip\n // detects changes on any of them.\n if (local.arguments.length !== remote.expectedArguments.length) return false;\n for (let i = 0; i < local.arguments.length; i++) {\n const l = local.arguments[i];\n const r = remote.expectedArguments[i];\n if (l.name !== r.name) return false;\n if ((l.dataType ?? 'string') !== (r.dataType ?? 'string')) return false;\n if (Boolean(l.fixed) !== Boolean(r.fixed)) return false;\n if (JSON.stringify(l.options ?? []) !== JSON.stringify(r.options ?? [])) return false;\n if ((l.defaultValue ?? '') !== (r.defaultValue ?? '')) return false;\n if (Boolean(l.secret) !== Boolean(r.secret)) return false;\n }\n\n return true;\n }\n\n /**\n * Pull apps from remote and save locally\n */\n async pull(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n logger.dim(`Fetching ${remoteAppList.length} apps in parallel...`);\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item, index) => {\n const app = await this.api.getApp(item.reference);\n // Show progress every 10 apps\n if ((index + 1) % 10 === 0 || index === remoteAppList.length - 1) {\n const stream = process.env.FARSEER_MCP === '1' ? process.stderr : process.stdout;\n stream.write(`\\r Progress: ${index + 1}/${remoteAppList.length} apps`);\n }\n return { app, reference: item.reference };\n },\n 15,\n );\n // Clear progress line\n if (remoteAppList.length > 0) {\n const stream = process.env.FARSEER_MCP === '1' ? process.stderr : process.stdout;\n stream.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Process remote apps\n for (const [key, { app, reference }] of remoteApps) {\n const localConfig = this.remoteToLocal(app, reference);\n const existingLocal = localApps.get(key);\n\n if (!existingLocal) {\n // New app from remote\n this.saveLocalApp(localConfig);\n result.created.push(app.name);\n } else if (!this.areAppsEqual(existingLocal, app)) {\n // App changed on remote - update local\n this.saveLocalApp(localConfig);\n result.updated.push(app.name);\n } else {\n result.unchanged.push(app.name);\n }\n }\n\n // Check for apps deleted on remote\n for (const [key, local] of localApps) {\n if (!remoteApps.has(key) && local._remote) {\n // App was synced before but now deleted on remote\n this.deleteLocalApp(local.name);\n result.deleted.push(local.name);\n }\n }\n\n return result;\n }\n\n /**\n * Push local apps to remote\n */\n async push(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15,\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Get available scripts for ID lookup\n // Build maps for both path-based and filename-based lookup (backward compatibility)\n const availableScripts = await this.api.getScriptFiles();\n const scriptIdByPath = new Map<string, string>();\n const scriptIdByName = new Map<string, string>();\n\n for (const s of availableScripts) {\n // s.name now contains full path (e.g., \"Scripts/test.ts\")\n const pathKey = s.name.toLowerCase();\n const filenameKey = s.name.split('/').pop()?.toLowerCase() || pathKey;\n\n scriptIdByPath.set(pathKey, s.id);\n // For filename lookup, only set if not already set (first match wins for ambiguous names)\n if (!scriptIdByName.has(filenameKey)) {\n scriptIdByName.set(filenameKey, s.id);\n }\n }\n\n // Helper to find script ID by path or filename\n const findScriptId = (scriptRef: string): string | undefined => {\n const key = scriptRef.toLowerCase();\n // Try exact path match first\n const byPath = scriptIdByPath.get(key);\n if (byPath) return byPath;\n // Try with Scripts/ prefix\n const withPrefix = scriptIdByPath.get(`scripts/${key}`);\n if (withPrefix) return withPrefix;\n // Fall back to filename match\n return scriptIdByName.get(key.split('/').pop() || key);\n };\n\n // Process local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n // New local app - create on remote\n try {\n const created = await this.api.createApp(local.name);\n\n // Update with config (API requires name and description)\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n await this.api.updateApp(created.id.toString(), update, created);\n\n // Update local with remote ID\n local._remote = {\n id: created.id,\n reference: created.id.toString(),\n };\n this.saveLocalApp(local);\n\n result.created.push(local.name);\n } catch (error) {\n logger.error(`Failed to create app ${local.name}: ${await formatClientError(error)}`);\n }\n } else if (!this.areAppsEqual(local, remote.app)) {\n // App differs - update remote\n try {\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n\n await this.api.updateApp(remote.reference, update, remote.app);\n result.updated.push(local.name);\n } catch (error) {\n logger.error(`Failed to update app ${local.name}: ${await formatClientError(error)}`);\n }\n } else {\n result.unchanged.push(local.name);\n }\n }\n\n // Note: We don't auto-delete remote apps when deleted locally\n // User must use \"farseer app delete\" explicitly\n\n return result;\n }\n\n /**\n * Build update payload for API\n */\n private buildUpdatePayload(\n local: LocalAppConfig,\n findScriptId: (scriptRef: string) => string | undefined,\n ): {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n } {\n const update: {\n name?: string;\n description?: string;\n expectedArguments?: AppArgument[];\n mainScriptFileId?: string | null;\n } = {};\n\n // Arguments \u2014 preserve all axes. `dataType` defaults to 'string' for\n // older app json files that pre-date typed parameters. Always sent\n // (even when empty): the local config is authoritative for the sync\n // path, so an app whose args were cleared locally must push that\n // emptiness through, otherwise `mergeAppUpdate` would keep the remote\n // args and `status` would report the app modified forever.\n update.expectedArguments = local.arguments.map((a) => {\n const arg: AppArgument = {\n name: a.name,\n dataType: a.dataType ?? 'string',\n };\n if (a.fixed !== undefined) arg.fixed = a.fixed;\n if (a.options !== undefined) arg.options = a.options;\n if (a.defaultValue !== undefined) arg.defaultValue = a.defaultValue;\n if (a.secret !== undefined) arg.secret = a.secret;\n return arg;\n });\n\n // Entrypoint - lookup by path or filename\n if (local.entrypoint) {\n const entrypointId = findScriptId(local.entrypoint);\n if (entrypointId) {\n update.mainScriptFileId = entrypointId;\n }\n }\n\n return update;\n }\n\n /**\n * Get sync status without making changes\n */\n async getStatus(): Promise<AppSyncStatus> {\n const status: AppSyncStatus = {\n newLocal: [],\n newRemote: [],\n modified: [],\n synced: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15,\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Check local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n status.newLocal.push(local.name);\n } else if (!this.areAppsEqual(local, remote.app)) {\n status.modified.push(local.name);\n } else {\n status.synced.push(local.name);\n }\n }\n\n // Check for new remote apps\n for (const [key, { app }] of remoteApps) {\n if (!localApps.has(key)) {\n status.newRemote.push(app.name);\n }\n }\n\n return status;\n }\n}\n"],
|
|
5
|
-
"mappings": ";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,\n AppArgument,\n AppArgumentDataType,\n AppUpdateChanges,\n ComputeChoice,\n formatCompute,\n parseComputeChoice,\n} from './apps';\nimport type { FarseerService } from './farseerService';\nimport { getTenantAppsDir, ensureDirectoryExists, fetchWithConcurrency } from '../utils/helpers';\nimport { logger } from '../utils/logger';\nimport { formatClientError } from '../utils/errorFormatter';\n\n// Local app config format (stored in apps/*.json) \u2014 mirrors AppArgument so\n// pull/push round-trips don't drop any axis.\n//\n// The run settings below are managed by key presence, not by value: a file that\n// has the key declares that setting and push enforces it, a file without the key\n// leaves whatever the tenant has. That keeps a config written before these\n// existed from clearing a schedule the first time it is pushed.\n//\n// Two settings are deliberately not in the file, and are set with `app configure`\n// or `farseer_configure_app` instead:\n//\n// - the runner, because the backend assigns one to an unassigned scheduled job\n// by itself and stores it. A file cannot tell that assignment from a choice:\n// pull would write the scheduler's pick in as a pin that travels with the\n// file to other tenants, and push would clear it only for the scheduler to\n// assign it again, so the app never reads as in sync.\n// - predefined actions, because the backend returns their values readable even\n// for arguments marked secret. Writing them to a file puts secrets in the\n// workspace and in git; leaving them out of the file leaves them untouched on\n// the tenant, since an update carries the current actions forward.\nexport interface LocalAppConfig {\n name: string;\n description: string;\n entrypoint: string | null; // Script filename (e.g., \"index.ts\")\n arguments: {\n name: string;\n // `dataType` defaults to 'string' on legacy configs that pre-date typed\n // parameters. Without round-tripping the full axes (`dataType`,\n // `fixed`, `options`), a pull \u2192 push cycle silently demoted a boolean /\n // dropdown / locked arg back to a plain string variable.\n dataType?: AppArgumentDataType;\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n }[];\n schedule?: string | null;\n runnerImage?: string | null;\n compute?: ComputeChoice;\n _remote?: {\n id: number;\n reference: string;\n };\n}\n\nexport interface AppSyncResult {\n created: string[];\n updated: string[];\n deleted: string[];\n unchanged: string[];\n}\n\nexport interface AppSyncStatus {\n newLocal: string[]; // Local apps not on remote\n newRemote: string[]; // Remote apps not locally\n modified: string[]; // Apps that differ\n synced: string[]; // Apps in sync\n}\n\n/**\n * Sanitize Croatian diacritics and other special characters to ASCII equivalents\n */\nfunction sanitizeDiacritics(text: string): string {\n const diacriticMap: Record<string, string> = {\n // Croatian\n \u010D: 'c',\n \u010C: 'C',\n \u0107: 'c',\n \u0106: 'C',\n \u0161: 's',\n \u0160: 'S',\n \u017E: 'z',\n \u017D: 'Z',\n \u0111: 'd',\n \u0110: 'D',\n // German/Other common\n \u00E4: 'a',\n \u00C4: 'A',\n \u00F6: 'o',\n \u00D6: 'O',\n \u00FC: 'u',\n \u00DC: 'U',\n \u00DF: 'ss',\n // Polish\n \u0105: 'a',\n \u0104: 'A',\n \u0119: 'e',\n \u0118: 'E',\n \u0142: 'l',\n \u0141: 'L',\n \u0144: 'n',\n \u0143: 'N',\n \u00F3: 'o',\n \u00D3: 'O',\n \u015B: 's',\n \u015A: 'S',\n \u017A: 'z',\n \u0179: 'Z',\n \u017C: 'z',\n \u017B: 'Z',\n // French/Spanish\n \u00E0: 'a',\n \u00E1: 'a',\n \u00E2: 'a',\n \u00E8: 'e',\n \u00E9: 'e',\n \u00EA: 'e',\n \u00EB: 'e',\n \u00EC: 'i',\n \u00ED: 'i',\n \u00EE: 'i',\n \u00EF: 'i',\n \u00F2: 'o',\n \u00F4: 'o',\n \u00F9: 'u',\n \u00FA: 'u',\n \u00FB: 'u',\n \u00F1: 'n',\n \u00D1: 'N',\n \u00E7: 'c',\n \u00C7: 'C',\n };\n\n return text\n .split('')\n .map((char) => diacriticMap[char] || char)\n .join('');\n}\n\n/**\n * Migrate legacy `type: 'variable' | 'constant' | 'boolean' | 'dropdown'` on\n * pre-PR pulls to the orthogonal-axes shape used by `localToUpdate` and\n * `areAppsEqual`. Idempotent \u2014 leaves new-shape entries untouched.\n *\n * Without this, a push immediately after upgrade silently demoted locked\n * args (`type: 'constant'` \u2192 no `fixed`) because the new code ignores the\n * legacy `type` key when building the wire payload. `areAppsEqual` flagged\n * the diff but didn't block, so the silent demote slipped through.\n */\nfunction migrateLegacyArguments(config: { arguments?: unknown[] } & Record<string, unknown>): Record<string, unknown> {\n if (!Array.isArray(config.arguments)) return config as Record<string, unknown>;\n config.arguments = config.arguments.map((raw) => {\n if (raw === null || typeof raw !== 'object') return raw;\n const a = raw as Record<string, unknown>;\n if (a.dataType !== undefined || a.type === undefined) return a;\n const legacyType = a.type;\n const rest: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(a)) {\n if (k !== 'type') rest[k] = v;\n }\n switch (legacyType) {\n case 'constant':\n return { ...rest, dataType: 'string', fixed: true };\n case 'boolean':\n return { ...rest, dataType: 'boolean' };\n case 'dropdown':\n case 'variable':\n default:\n return { ...rest, dataType: 'string' };\n }\n });\n return config as Record<string, unknown>;\n}\n\n// The run settings a config file governs by key presence. A file written before\n// they existed has none of them, which `areAppsEqual` reads as \"in sync\" \u2014 so\n// pull would never add them and the app could never adopt the feature. Rewriting\n// such a file once costs nothing: the values it gains are the tenant's own.\nconst RUN_SETTING_KEYS = ['schedule', 'runnerImage', 'compute'] as const;\n\n// Written by builds that still synced them. Pull removes them, so a secret\n// action value or a scheduler-assigned runner does not stay behind in the file.\nconst RETIRED_KEYS = ['runner', 'predefinedActions'] as const;\n\n/** A file pull has to rewrite even when every value it holds is current. */\nfunction fileNeedsRewrite(local: LocalAppConfig): boolean {\n return !RUN_SETTING_KEYS.every((key) => key in local) || RETIRED_KEYS.some((key) => key in local);\n}\n\n/**\n * Service for syncing app configurations between local JSON files and remote Farseer instance\n */\nexport class AppSyncService {\n private api: FarseerService;\n private appsDir: string;\n\n constructor(tenant: string, api: FarseerService) {\n this.api = api;\n this.appsDir = getTenantAppsDir(tenant);\n }\n\n /**\n * Get filename for an app (keep original name, just sanitize for filesystem)\n */\n private getAppFilename(name: string): string {\n return (\n sanitizeDiacritics(name)\n .replace(/[<>:\"/\\\\|?*]/g, '') // Remove invalid filename characters\n .trim() + '.json'\n );\n }\n\n /**\n * Names of locally-tracked apps the next `pull` would delete because\n * remote no longer has them. Uses only `listApps` (no per-app fetch),\n * so pull can preview deletions for the destructive-action prompt\n * without paying for getStatus's full per-app round-trip.\n *\n * Mirrors the deletion gate in `pull()` (`local._remote && !remoteApps.has(key)`):\n * apps the user never pulled (`_remote` undefined) are kept untouched\n * by pull, so they don't belong in this list.\n */\n async getRemoteDeletions(): Promise<string[]> {\n const localApps = this.loadLocalApps();\n const remoteAppList = await this.api.listApps();\n const remoteNames = new Set(remoteAppList.map((a) => a.name.toLowerCase()));\n const deleted: string[] = [];\n for (const [key, local] of localApps) {\n if (local._remote && !remoteNames.has(key)) {\n deleted.push(local.name);\n }\n }\n return deleted;\n }\n\n /**\n * Load all local app configs\n */\n loadLocalApps(): Map<string, LocalAppConfig> {\n const apps = new Map<string, LocalAppConfig>();\n\n if (!fs.existsSync(this.appsDir)) {\n return apps;\n }\n\n const files = fs.readdirSync(this.appsDir).filter((f) => f.endsWith('.json'));\n\n for (const file of files) {\n try {\n const content = fs.readFileSync(path.join(this.appsDir, file), 'utf-8');\n const config = migrateLegacyArguments(JSON.parse(content)) as LocalAppConfig;\n apps.set(config.name.toLowerCase(), config);\n } catch {\n // Skip invalid files\n }\n }\n\n return apps;\n }\n\n /**\n * Save a local app config\n */\n saveLocalApp(config: LocalAppConfig): void {\n ensureDirectoryExists(this.appsDir);\n const filename = this.getAppFilename(config.name);\n const filePath = path.join(this.appsDir, filename);\n fs.writeFileSync(filePath, JSON.stringify(config, null, 2), 'utf-8');\n }\n\n /**\n * Delete a local app config\n */\n deleteLocalApp(name: string): boolean {\n const filename = this.getAppFilename(name);\n const filePath = path.join(this.appsDir, filename);\n\n if (fs.existsSync(filePath)) {\n fs.unlinkSync(filePath);\n return true;\n }\n return false;\n }\n\n /**\n * Convert remote app to local config format\n */\n private remoteToLocal(remote: RemoteApp, reference: string): LocalAppConfig {\n const scriptFiles = remote.scriptFiles ?? [];\n const mainScript = scriptFiles.find((s) => s.id === remote.mainScriptFileId);\n\n // \"No default\" canonical shape locally is `defaultValue: ''` (empty\n // string), NOT an omitted key. The OpenAPI schema makes the field\n // optional, so the backend can emit either; if we passed `undefined`\n // through verbatim, a user who added `defaultValue: ''` locally\n // would see `areAppsEqual` say \"match\" (both normalise to '') but\n // the next pull would strip the key again \u2014 the on-disk JSON would\n // oscillate forever and never reach a steady state. type is treated\n // the same way ('variable' is the implicit default), secret only\n // appears when explicitly true on the backend (boolean is a clear\n // tri-state: true/false/unset, and \"unset\" reads as false anyway).\n return {\n name: remote.name,\n description: remote.description || '',\n entrypoint: mainScript?.name || null,\n arguments: remote.expectedArguments.map((a) => {\n // Pin a steady-state shape so two pulls back-to-back don't\n // oscillate. `defaultValue` is normalized to '' when omitted \u2014\n // a user-edited `defaultValue: ''` locally must compare equal\n // to a remote that omits the field. `dataType` defaults to\n // 'string' (the implicit pre-fix shape). All other axes\n // (`fixed`, `options`, `secret`) are only emitted when the\n // remote populated them, to keep the JSON minimal.\n const arg: LocalAppConfig['arguments'][number] = {\n name: a.name,\n defaultValue: a.defaultValue ?? '',\n dataType: a.dataType ?? 'string',\n };\n if (a.fixed !== undefined) arg.fixed = a.fixed;\n if (a.options !== undefined) arg.options = a.options;\n if (a.secret !== undefined) arg.secret = a.secret;\n return arg;\n }),\n // Written on every pull, including as null / 'local' / [], so the\n // file says what the tenant holds rather than staying silent and\n // reading as \"not managed\" on the next push.\n schedule: remote.schedule || null,\n runnerImage: remote.runnerImage || null,\n compute: formatCompute(remote.compute),\n _remote: {\n id: remote.id,\n reference: reference,\n },\n };\n }\n\n /**\n * Check if local and remote app configs are equivalent\n */\n private areAppsEqual(local: LocalAppConfig, remote: RemoteApp): boolean {\n // Compare name\n if (local.name !== remote.name) return false;\n\n // Compare description\n if ((local.description || '') !== (remote.description || '')) return false;\n\n // Compare entrypoint\n const remoteScriptFiles = remote.scriptFiles ?? [];\n const remoteEntrypoint = remoteScriptFiles.find((s) => s.id === remote.mainScriptFileId)?.name || null;\n if (local.entrypoint !== remoteEntrypoint) return false;\n\n // Compare arguments. Order matters here: backend renders args in the\n // saved order in the UI, so we treat reordering as a real change.\n // Missing `dataType` defaults to 'string' (the implicit pre-fix value);\n // missing scalar defaults are normalized so '' vs undefined doesn't\n // show up as a spurious diff. All four axes (dataType, fixed, options,\n // defaultValue, secret) are compared so a pull\u2192push round-trip\n // detects changes on any of them.\n if (local.arguments.length !== remote.expectedArguments.length) return false;\n for (let i = 0; i < local.arguments.length; i++) {\n const l = local.arguments[i];\n const r = remote.expectedArguments[i];\n if (l.name !== r.name) return false;\n if ((l.dataType ?? 'string') !== (r.dataType ?? 'string')) return false;\n if (Boolean(l.fixed) !== Boolean(r.fixed)) return false;\n if (JSON.stringify(l.options ?? []) !== JSON.stringify(r.options ?? [])) return false;\n if ((l.defaultValue ?? '') !== (r.defaultValue ?? '')) return false;\n if (Boolean(l.secret) !== Boolean(r.secret)) return false;\n }\n\n // Only what the file declares. A config written before these fields\n // existed omits them, and comparing an absent key against a populated\n // tenant would report that app modified forever.\n if ('schedule' in local && (local.schedule || null) !== (remote.schedule || null)) return false;\n if ('runnerImage' in local && (local.runnerImage || null) !== (remote.runnerImage || null)) return false;\n // Compare on what push would actually send. A local `compute` push cannot\n // express \u2014 `null`, or a string parseComputeChoice rejects \u2014 is drift no\n // push could ever close, so counting it leaves the app modified forever.\n const declaredCompute = 'compute' in local && local.compute ? parseComputeChoice(local.compute) : null;\n if (declaredCompute && formatCompute(declaredCompute) !== formatCompute(remote.compute)) return false;\n\n return true;\n }\n\n /**\n * Pull apps from remote and save locally\n */\n async pull(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n logger.dim(`Fetching ${remoteAppList.length} apps in parallel...`);\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item, index) => {\n const app = await this.api.getApp(item.reference);\n // Show progress every 10 apps\n if ((index + 1) % 10 === 0 || index === remoteAppList.length - 1) {\n const stream = process.env.FARSEER_MCP === '1' ? process.stderr : process.stdout;\n stream.write(`\\r Progress: ${index + 1}/${remoteAppList.length} apps`);\n }\n return { app, reference: item.reference };\n },\n 15,\n );\n // Clear progress line\n if (remoteAppList.length > 0) {\n const stream = process.env.FARSEER_MCP === '1' ? process.stderr : process.stdout;\n stream.write('\\r' + ' '.repeat(50) + '\\r');\n }\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Process remote apps\n for (const [key, { app, reference }] of remoteApps) {\n const localConfig = this.remoteToLocal(app, reference);\n const existingLocal = localApps.get(key);\n\n if (!existingLocal) {\n // New app from remote\n this.saveLocalApp(localConfig);\n result.created.push(app.name);\n } else if (!this.areAppsEqual(existingLocal, app) || fileNeedsRewrite(existingLocal)) {\n // App changed on remote, or the file's shape is out of date: it\n // predates the run settings and would never gain them \u2014\n // areAppsEqual ignores keys the file omits \u2014 or it still carries\n // one that is no longer synced.\n this.saveLocalApp(localConfig);\n result.updated.push(app.name);\n } else {\n result.unchanged.push(app.name);\n }\n }\n\n // Check for apps deleted on remote\n for (const [key, local] of localApps) {\n if (!remoteApps.has(key) && local._remote) {\n // App was synced before but now deleted on remote\n this.deleteLocalApp(local.name);\n result.deleted.push(local.name);\n }\n }\n\n return result;\n }\n\n /**\n * Push local apps to remote\n */\n async push(): Promise<AppSyncResult> {\n const result: AppSyncResult = {\n created: [],\n updated: [],\n deleted: [],\n unchanged: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15,\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Get available scripts for ID lookup\n // Build maps for both path-based and filename-based lookup (backward compatibility)\n const availableScripts = await this.api.getScriptFiles();\n const scriptIdByPath = new Map<string, string>();\n const scriptIdByName = new Map<string, string>();\n\n for (const s of availableScripts) {\n // s.name now contains full path (e.g., \"Scripts/test.ts\")\n const pathKey = s.name.toLowerCase();\n const filenameKey = s.name.split('/').pop()?.toLowerCase() || pathKey;\n\n scriptIdByPath.set(pathKey, s.id);\n // For filename lookup, only set if not already set (first match wins for ambiguous names)\n if (!scriptIdByName.has(filenameKey)) {\n scriptIdByName.set(filenameKey, s.id);\n }\n }\n\n // Helper to find script ID by path or filename\n const findScriptId = (scriptRef: string): string | undefined => {\n const key = scriptRef.toLowerCase();\n // Try exact path match first\n const byPath = scriptIdByPath.get(key);\n if (byPath) return byPath;\n // Try with Scripts/ prefix\n const withPrefix = scriptIdByPath.get(`scripts/${key}`);\n if (withPrefix) return withPrefix;\n // Fall back to filename match\n return scriptIdByName.get(key.split('/').pop() || key);\n };\n\n // Process local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n // New local app - create on remote\n try {\n const created = await this.api.createApp(local.name);\n\n // Update with config (API requires name and description)\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n await this.api.updateApp(created.id.toString(), update, created);\n\n // Update local with remote ID\n local._remote = {\n id: created.id,\n reference: created.id.toString(),\n };\n this.saveLocalApp(local);\n\n result.created.push(local.name);\n } catch (error) {\n logger.error(`Failed to create app ${local.name}: ${await formatClientError(error)}`);\n }\n } else if (!this.areAppsEqual(local, remote.app)) {\n // App differs - update remote\n try {\n const update = this.buildUpdatePayload(local, findScriptId);\n update.name = local.name;\n update.description = local.description;\n\n await this.api.updateApp(remote.reference, update, remote.app);\n result.updated.push(local.name);\n } catch (error) {\n logger.error(`Failed to update app ${local.name}: ${await formatClientError(error)}`);\n }\n } else {\n result.unchanged.push(local.name);\n }\n }\n\n // Note: We don't auto-delete remote apps when deleted locally\n // User must use \"farseer app delete\" explicitly\n\n return result;\n }\n\n /**\n * Build update payload for API\n */\n private buildUpdatePayload(\n local: LocalAppConfig,\n findScriptId: (scriptRef: string) => string | undefined,\n ): AppUpdateChanges {\n const update: AppUpdateChanges = {};\n\n // Arguments \u2014 preserve all axes. `dataType` defaults to 'string' for\n // older app json files that pre-date typed parameters. Always sent\n // (even when empty): the local config is authoritative for the sync\n // path, so an app whose args were cleared locally must push that\n // emptiness through, otherwise `mergeAppUpdate` would keep the remote\n // args and `status` would report the app modified forever.\n update.expectedArguments = local.arguments.map((a) => {\n const arg: AppArgument = {\n name: a.name,\n dataType: a.dataType ?? 'string',\n };\n if (a.fixed !== undefined) arg.fixed = a.fixed;\n if (a.options !== undefined) arg.options = a.options;\n if (a.defaultValue !== undefined) arg.defaultValue = a.defaultValue;\n if (a.secret !== undefined) arg.secret = a.secret;\n return arg;\n });\n\n // Entrypoint - lookup by path or filename\n if (local.entrypoint) {\n const entrypointId = findScriptId(local.entrypoint);\n if (entrypointId) {\n update.mainScriptFileId = entrypointId;\n }\n }\n\n // Key presence is the contract: a declared setting is enforced, an\n // absent one is left to whatever the tenant already holds.\n if ('schedule' in local) {\n update.schedule = local.schedule || null;\n }\n if ('runnerImage' in local) {\n update.runnerImage = local.runnerImage || null;\n }\n if ('compute' in local && local.compute) {\n const compute = parseComputeChoice(local.compute);\n if (compute) {\n update.compute = compute;\n } else {\n logger.warning(\n `Ignoring unknown compute \"${local.compute}\" for app ${local.name}: expected local, batch or batch:<size>.`,\n );\n }\n }\n\n return update;\n }\n\n /**\n * Get sync status without making changes\n */\n async getStatus(): Promise<AppSyncStatus> {\n const status: AppSyncStatus = {\n newLocal: [],\n newRemote: [],\n modified: [],\n synced: [],\n };\n\n // Load local apps\n const localApps = this.loadLocalApps();\n\n // Fetch remote apps\n const remoteAppList = await this.api.listApps();\n const remoteApps = new Map<string, { app: RemoteApp; reference: string }>();\n\n // Fetch app details in parallel with concurrency limit\n const appDetails = await fetchWithConcurrency(\n remoteAppList,\n async (item) => {\n const app = await this.api.getApp(item.reference);\n return { app, reference: item.reference };\n },\n 15,\n );\n\n for (const { app, reference } of appDetails) {\n if (app) {\n remoteApps.set(app.name.toLowerCase(), { app, reference });\n }\n }\n\n // Check local apps\n for (const [key, local] of localApps) {\n const remote = remoteApps.get(key);\n\n if (!remote) {\n status.newLocal.push(local.name);\n } else if (!this.areAppsEqual(local, remote.app)) {\n status.modified.push(local.name);\n } else {\n status.synced.push(local.name);\n }\n }\n\n // Check for new remote apps\n for (const [key, { app }] of remoteApps) {\n if (!localApps.has(key)) {\n status.newRemote.push(app.name);\n }\n }\n\n return status;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,kBAQO;AAEP,qBAA8E;AAC9E,oBAAuB;AACvB,4BAAkC;AAgElC,SAAS,mBAAmB,MAAsB;AAC9C,QAAM,eAAuC;AAAA;AAAA,IAEzC,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA;AAAA,IAEH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA;AAAA,IAEH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QAAG;AAAA,IACH,QA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AM,IAAI;AAAA,MACjC;AAAA,IACJ;AAGA,eAAW,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,YAAY;AACrC,UAAI,CAAC,UAAU,IAAI,GAAG,GAAG;AACrB,eAAO,UAAU,KAAK,IAAI,IAAI;AAAA,MAClC;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/services/apps.js
CHANGED
|
@@ -28,29 +28,141 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var apps_exports = {};
|
|
30
30
|
__export(apps_exports, {
|
|
31
|
+
APP_COMPUTE_CHOICES: () => APP_COMPUTE_CHOICES,
|
|
32
|
+
APP_COMPUTE_SIZES: () => APP_COMPUTE_SIZES,
|
|
31
33
|
AppDeleteRefusedError: () => AppDeleteRefusedError,
|
|
34
|
+
CLEAR_SETTING: () => CLEAR_SETTING,
|
|
32
35
|
REMOTE_JOB_ITEM_TYPE: () => REMOTE_JOB_ITEM_TYPE,
|
|
36
|
+
SECRET_PLACEHOLDER: () => SECRET_PLACEHOLDER,
|
|
37
|
+
applyRunSettings: () => applyRunSettings,
|
|
33
38
|
applySourceFolderChange: () => applySourceFolderChange,
|
|
34
39
|
findScriptInFolder: () => findScriptInFolder,
|
|
40
|
+
formatCompute: () => formatCompute,
|
|
35
41
|
mergeAppUpdate: () => mergeAppUpdate,
|
|
42
|
+
parseComputeChoice: () => parseComputeChoice,
|
|
43
|
+
redactActionValues: () => redactActionValues,
|
|
36
44
|
remoteJobReverseReferences: () => remoteJobReverseReferences,
|
|
37
|
-
resolveAppItemNodeId: () => resolveAppItemNodeId
|
|
45
|
+
resolveAppItemNodeId: () => resolveAppItemNodeId,
|
|
46
|
+
resolveRunnerImage: () => resolveRunnerImage,
|
|
47
|
+
restoreRedactedValues: () => restoreRedactedValues
|
|
38
48
|
});
|
|
39
49
|
module.exports = __toCommonJS(apps_exports);
|
|
40
50
|
var import_chalk = __toESM(require("chalk"));
|
|
41
51
|
var farseer = __toESM(require("farseer-client"));
|
|
52
|
+
const SECRET_PLACEHOLDER = "<secret>";
|
|
53
|
+
function secretNames(args) {
|
|
54
|
+
return new Set(args.filter((a) => a.secret).map((a) => a.name));
|
|
55
|
+
}
|
|
56
|
+
function redactActionValues(actions, args) {
|
|
57
|
+
const secret = secretNames(args);
|
|
58
|
+
return actions.map((action) => ({
|
|
59
|
+
name: action.name,
|
|
60
|
+
runArguments: Object.fromEntries(
|
|
61
|
+
Object.entries(action.runArguments ?? {}).map(([name, value]) => [
|
|
62
|
+
name,
|
|
63
|
+
secret.has(name) ? SECRET_PLACEHOLDER : value
|
|
64
|
+
])
|
|
65
|
+
)
|
|
66
|
+
}));
|
|
67
|
+
}
|
|
68
|
+
function restoreRedactedValues(incoming, current) {
|
|
69
|
+
const named = (actions2, name) => actions2.filter((a) => a.name === name);
|
|
70
|
+
const actions = [];
|
|
71
|
+
for (const action of incoming) {
|
|
72
|
+
const stored = named(current, action.name);
|
|
73
|
+
const ambiguous = stored.length > 1 || named(incoming, action.name).length > 1;
|
|
74
|
+
const runArguments = {};
|
|
75
|
+
for (const [name, value] of Object.entries(action.runArguments ?? {})) {
|
|
76
|
+
if (value !== SECRET_PLACEHOLDER) {
|
|
77
|
+
runArguments[name] = value;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (ambiguous) {
|
|
81
|
+
return {
|
|
82
|
+
error: `Action "${action.name}" sends ${SECRET_PLACEHOLDER} for "${name}", but more than one action is named "${action.name}", so which stored value it stands for is unknown \u2014 give the real value.`
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const kept = stored[0]?.runArguments?.[name];
|
|
86
|
+
if (kept === void 0) {
|
|
87
|
+
return {
|
|
88
|
+
error: `Action "${action.name}" sends ${SECRET_PLACEHOLDER} for "${name}", but no stored action named exactly "${action.name}" has a value for it \u2014 give the real value.`
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
runArguments[name] = kept;
|
|
92
|
+
}
|
|
93
|
+
actions.push({ name: action.name, runArguments });
|
|
94
|
+
}
|
|
95
|
+
return { actions };
|
|
96
|
+
}
|
|
97
|
+
const APP_COMPUTE_SIZES = ["s", "m", "l", "xl"];
|
|
98
|
+
const APP_COMPUTE_CHOICES = [
|
|
99
|
+
"local",
|
|
100
|
+
"batch",
|
|
101
|
+
...APP_COMPUTE_SIZES.map((size) => `batch:${size}`)
|
|
102
|
+
];
|
|
42
103
|
function mergeAppUpdate(current, changes) {
|
|
43
|
-
|
|
104
|
+
const payload = {
|
|
44
105
|
name: changes.name ?? current.name,
|
|
45
106
|
description: changes.description ?? current.description ?? "",
|
|
46
107
|
expectedArguments: changes.expectedArguments ?? current.expectedArguments ?? [],
|
|
47
|
-
mainScriptFileId: changes.mainScriptFileId
|
|
48
|
-
sourceFolderId: changes.sourceFolderId
|
|
49
|
-
schedule: changes.schedule
|
|
50
|
-
runnerName: changes.runnerName
|
|
51
|
-
runnerImage: changes.runnerImage
|
|
52
|
-
predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? []
|
|
108
|
+
mainScriptFileId: ("mainScriptFileId" in changes ? changes.mainScriptFileId : current.mainScriptFileId) ?? null,
|
|
109
|
+
sourceFolderId: ("sourceFolderId" in changes ? changes.sourceFolderId : current.sourceFolderId) ?? null,
|
|
110
|
+
schedule: ("schedule" in changes ? changes.schedule : current.schedule) ?? null,
|
|
111
|
+
runnerName: ("runnerName" in changes ? changes.runnerName : current.runnerName) ?? null,
|
|
112
|
+
runnerImage: ("runnerImage" in changes ? changes.runnerImage : current.runnerImage) ?? null,
|
|
113
|
+
predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? [],
|
|
114
|
+
icon: ("icon" in changes ? changes.icon : current.icon) ?? null
|
|
53
115
|
};
|
|
116
|
+
const compute = changes.compute ?? current.compute;
|
|
117
|
+
if (compute) {
|
|
118
|
+
payload.compute = compute;
|
|
119
|
+
}
|
|
120
|
+
return payload;
|
|
121
|
+
}
|
|
122
|
+
function parseComputeChoice(value) {
|
|
123
|
+
const choice = value.trim().toLowerCase();
|
|
124
|
+
if (choice === "local") {
|
|
125
|
+
return { type: "local" };
|
|
126
|
+
}
|
|
127
|
+
if (choice === "batch") {
|
|
128
|
+
return { type: "batch" };
|
|
129
|
+
}
|
|
130
|
+
const size = choice.startsWith("batch:") ? choice.slice("batch:".length) : null;
|
|
131
|
+
if (size && APP_COMPUTE_SIZES.includes(size)) {
|
|
132
|
+
return { type: "batch", options: { size } };
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
function formatCompute(compute) {
|
|
137
|
+
if (compute?.type !== "batch") {
|
|
138
|
+
return "local";
|
|
139
|
+
}
|
|
140
|
+
return compute.options?.size ? `batch:${compute.options.size}` : "batch";
|
|
141
|
+
}
|
|
142
|
+
function resolveRunnerImage(value, registry) {
|
|
143
|
+
const known = registry.repositories.join(", ") || "(none configured)";
|
|
144
|
+
const prefix = registry.registryPrefix ? `${registry.registryPrefix}/` : "";
|
|
145
|
+
const rest = prefix && value.startsWith(prefix) ? value.slice(prefix.length) : value;
|
|
146
|
+
if (rest.includes("/")) {
|
|
147
|
+
return {
|
|
148
|
+
error: `Runner image must be "<repository>:<tag>" or start with ${registry.registryPrefix}/. Available repositories: ${known}`
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
const colonIndex = rest.indexOf(":");
|
|
152
|
+
if (colonIndex === -1) {
|
|
153
|
+
return {
|
|
154
|
+
error: `Runner image must include a tag, e.g. "${registry.repositories[0] ?? "runner-typescript"}:latest"`
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
const repository = rest.slice(0, colonIndex);
|
|
158
|
+
const tag = rest.slice(colonIndex + 1);
|
|
159
|
+
if (!registry.repositories.includes(repository)) {
|
|
160
|
+
return { error: `Unknown runner image repository "${repository}". Available repositories: ${known}` };
|
|
161
|
+
}
|
|
162
|
+
if (!tag) {
|
|
163
|
+
return { error: `Runner image must include a tag, e.g. "${repository}:latest"` };
|
|
164
|
+
}
|
|
165
|
+
return { image: `${prefix}${repository}:${tag}` };
|
|
54
166
|
}
|
|
55
167
|
function findScriptInFolder(folderScripts, name) {
|
|
56
168
|
return folderScripts.find((s) => s.name === name);
|
|
@@ -112,6 +224,74 @@ async function applySourceFolderChange(client, app, changes, options, caller) {
|
|
|
112
224
|
}
|
|
113
225
|
return null;
|
|
114
226
|
}
|
|
227
|
+
const CLEAR_SETTING = "none";
|
|
228
|
+
function isCleared(value) {
|
|
229
|
+
return value.trim() === "" || value.trim().toLowerCase() === CLEAR_SETTING;
|
|
230
|
+
}
|
|
231
|
+
async function applyRunSettings(client, app, changes, settings) {
|
|
232
|
+
const warnings = [];
|
|
233
|
+
const resolved = {};
|
|
234
|
+
if (settings.schedule !== void 0) {
|
|
235
|
+
resolved.schedule = isCleared(settings.schedule) ? null : settings.schedule.trim();
|
|
236
|
+
}
|
|
237
|
+
if (settings.compute !== void 0) {
|
|
238
|
+
const compute = parseComputeChoice(settings.compute);
|
|
239
|
+
if (!compute) {
|
|
240
|
+
return {
|
|
241
|
+
error: `Unknown compute selection "${settings.compute}". Valid values: ${APP_COMPUTE_CHOICES.join(", ")}.`
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
resolved.compute = compute;
|
|
245
|
+
}
|
|
246
|
+
if (settings.runner !== void 0) {
|
|
247
|
+
resolved.runnerName = isCleared(settings.runner) ? null : settings.runner.trim();
|
|
248
|
+
}
|
|
249
|
+
if (settings.runnerImage !== void 0) {
|
|
250
|
+
if (isCleared(settings.runnerImage)) {
|
|
251
|
+
resolved.runnerImage = null;
|
|
252
|
+
} else {
|
|
253
|
+
const registry = await client.getRunnerImageRepositories();
|
|
254
|
+
const outcome = resolveRunnerImage(settings.runnerImage.trim(), registry);
|
|
255
|
+
if ("error" in outcome) {
|
|
256
|
+
return outcome;
|
|
257
|
+
}
|
|
258
|
+
resolved.runnerImage = outcome.image;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
if ("runnerName" in resolved || "compute" in resolved) {
|
|
262
|
+
const runnerName = ("runnerName" in resolved ? resolved.runnerName : app.runnerName) ?? null;
|
|
263
|
+
const compute = "compute" in resolved ? resolved.compute : app.compute;
|
|
264
|
+
warnings.push(...await runnerWarnings(client, runnerName, compute));
|
|
265
|
+
}
|
|
266
|
+
Object.assign(changes, resolved);
|
|
267
|
+
return { warnings };
|
|
268
|
+
}
|
|
269
|
+
async function runnerWarnings(client, runnerName, compute) {
|
|
270
|
+
let runners;
|
|
271
|
+
try {
|
|
272
|
+
runners = await client.getRunners();
|
|
273
|
+
} catch {
|
|
274
|
+
return [];
|
|
275
|
+
}
|
|
276
|
+
if (runnerName && !runners.some((runner) => runner.name === runnerName)) {
|
|
277
|
+
const connected = runners.map((runner) => runner.name).join(", ") || "(none)";
|
|
278
|
+
return [`No jobrunner named "${runnerName}" is connected. Currently connected: ${connected}`];
|
|
279
|
+
}
|
|
280
|
+
if (!compute) {
|
|
281
|
+
return [];
|
|
282
|
+
}
|
|
283
|
+
const answering = runnerName ? runners.filter((runner) => runner.name === runnerName) : runners;
|
|
284
|
+
if (answering.length === 0) {
|
|
285
|
+
return [];
|
|
286
|
+
}
|
|
287
|
+
const engine = compute.type;
|
|
288
|
+
if (answering.some((runner) => (runner.engines ?? ["local"]).includes(engine))) {
|
|
289
|
+
return [];
|
|
290
|
+
}
|
|
291
|
+
const who = runnerName ? `Jobrunner "${runnerName}" does not offer` : "No connected jobrunner offers";
|
|
292
|
+
const what = engine === "batch" ? "a machine per run" : "runs on the shared runner";
|
|
293
|
+
return [`${who} ${what}. The setting is saved; runs will fail until one does.`];
|
|
294
|
+
}
|
|
115
295
|
const REMOTE_JOB_ITEM_TYPE = farseer.FolderItemType.RemoteJob;
|
|
116
296
|
function remoteJobReverseReferences(remoteJobIds) {
|
|
117
297
|
return remoteJobIds.map((reference) => ({ reference, type: REMOTE_JOB_ITEM_TYPE }));
|
|
@@ -138,12 +318,22 @@ function resolveAppItemNodeId(remoteJobId, items) {
|
|
|
138
318
|
}
|
|
139
319
|
// Annotate the CommonJS export names for ESM import in node:
|
|
140
320
|
0 && (module.exports = {
|
|
321
|
+
APP_COMPUTE_CHOICES,
|
|
322
|
+
APP_COMPUTE_SIZES,
|
|
141
323
|
AppDeleteRefusedError,
|
|
324
|
+
CLEAR_SETTING,
|
|
142
325
|
REMOTE_JOB_ITEM_TYPE,
|
|
326
|
+
SECRET_PLACEHOLDER,
|
|
327
|
+
applyRunSettings,
|
|
143
328
|
applySourceFolderChange,
|
|
144
329
|
findScriptInFolder,
|
|
330
|
+
formatCompute,
|
|
145
331
|
mergeAppUpdate,
|
|
332
|
+
parseComputeChoice,
|
|
333
|
+
redactActionValues,
|
|
146
334
|
remoteJobReverseReferences,
|
|
147
|
-
resolveAppItemNodeId
|
|
335
|
+
resolveAppItemNodeId,
|
|
336
|
+
resolveRunnerImage,
|
|
337
|
+
restoreRedactedValues
|
|
148
338
|
});
|
|
149
339
|
//# sourceMappingURL=apps.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/services/apps.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Apps (Remote Jobs): their shape, and the rules over it.\n *\n * What belongs here is decided by dependency direction, not by I/O: nothing in\n * this module constructs a client or reads a credential. applySourceFolderChange\n * does make a call, but through an injected one-method resolver, so it stays\n * testable without one.\n */\n\nimport chalk from 'chalk';\nimport * as farseer from 'farseer-client';\n\nexport type AppArgumentDataType = 'string' | 'boolean';\n\nexport interface AppArgument {\n name: string;\n dataType: AppArgumentDataType;\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n}\n\nexport interface AppScriptFile {\n id: string;\n name: string;\n}\n\n// A resolved source folder: its node id (to set on the app) plus the script\n// files it contains (to validate an entrypoint lives inside it).\nexport interface SourceFolderResolution {\n id: number;\n scripts: AppScriptFile[];\n}\n\nexport interface RemoteApp {\n id: number;\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n status: string;\n lastHeartbeat: string;\n mainScriptFileId: string | null;\n scriptFiles?: AppScriptFile[];\n sourceFolderId?: number;\n schedule?: string | null;\n runnerName?: string | null;\n runnerImage?: string | null;\n predefinedActions: unknown[];\n}\n\n// The fields a Remote Job update writes. The backend PUT replaces the whole\n// row, so any field omitted here is reset to its default (args/predefined \u2192\n// empty, the rest \u2192 null). `mergeAppUpdate` exists so a caller that only wants\n// to touch one field doesn't silently wipe the others.\nexport interface UpdateAppPayload {\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n mainScriptFileId: string | null;\n sourceFolderId: number | null;\n schedule: string | null;\n runnerName: string | null;\n runnerImage: string | null;\n predefinedActions: unknown[];\n}\n\n// `scriptFileIds` is accepted from callers for backwards compatibility but is\n// never sent \u2014 the backend ignores it (scripts derive from the source folder).\nexport type AppUpdateChanges = Partial<UpdateAppPayload> & { scriptFileIds?: string[] };\n\n/**\n * Overlay a caller's changes onto an app's current state to build a full,\n * non-destructive update payload. Every field the caller leaves out keeps its\n * current value \u2014 so changing one setting never clears the others.\n */\nexport function mergeAppUpdate(current: RemoteApp, changes: AppUpdateChanges): UpdateAppPayload {\n return {\n name: changes.name ?? current.name,\n description: changes.description ?? current.description ?? '',\n expectedArguments: changes.expectedArguments ?? current.expectedArguments ?? [],\n mainScriptFileId: changes.mainScriptFileId ?? current.mainScriptFileId ?? null,\n sourceFolderId: changes.sourceFolderId ?? current.sourceFolderId ?? null,\n schedule: changes.schedule ?? current.schedule ?? null,\n runnerName: changes.runnerName ?? current.runnerName ?? null,\n runnerImage: changes.runnerImage ?? current.runnerImage ?? null,\n predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? [],\n };\n}\n\n/**\n * Find a script in a source folder's file list by its exact name. Farseer file\n * names are case-sensitive \u2014 two files differing only in case can coexist in a\n * folder \u2014 so matching is exact, never case-folded, to avoid resolving an\n * entrypoint to the wrong file. Resolution is folder-scoped, never tenant-wide,\n * so a same-named file in another folder can't be picked by accident. Returns\n * undefined when the name isn't in the folder.\n */\nexport function findScriptInFolder(folderScripts: AppScriptFile[], name: string): AppScriptFile | undefined {\n return folderScripts.find((s) => s.name === name);\n}\n\n// The one client capability applySourceFolderChange needs. Kept minimal (not the\n// whole client) so it is trivial to unit-test with a fake resolver.\nexport interface SourceFolderResolver {\n resolveSourceFolder(relativePath: string): Promise<SourceFolderResolution | null>;\n}\n\n// Selects only how an error is presented \u2014 dimming, and `--flag` (CLI) vs param\n// (MCP) wording. It is a pure UX knob: the decision, the ids written to `changes`,\n// and the success/failure outcome are identical for both values. Never branch\n// functionality on it.\nexport type ConfigureCaller = 'cli' | 'mcp';\n\n/**\n * Resolve the source-folder / entrypoint settings for an `app configure` and\n * write the resulting ids into `changes`, applying the rule that an app's\n * scripts derive from its source folder and the entrypoint must be a file in\n * that folder. `sourceFolder` (a path under Files/) switches the folder;\n * otherwise the entrypoint is validated against the app's current folder. Moving\n * the folder must not orphan the entrypoint: if the current entrypoint isn't in\n * the new folder and the caller didn't supply one, the request is rejected \u2014 the\n * entrypoint is never silently cleared or relocated.\n *\n * Returns an error message for the caller to surface (and `changes` is left\n * untouched), or null once the ids have been written. The decision lives here so\n * the CLI and MCP paths can't drift.\n */\nexport async function applySourceFolderChange(\n client: SourceFolderResolver,\n app: Pick<RemoteApp, 'scriptFiles' | 'mainScriptFileId'>,\n changes: AppUpdateChanges,\n options: { sourceFolder?: string; entrypoint?: string },\n caller: ConfigureCaller,\n): Promise<string | null> {\n const cli = caller === 'cli';\n // Secondary guidance lines are dimmed in the terminal; plain for the MCP tool.\n const hint = (text: string) => (cli ? chalk.dim(text) : text);\n\n let folderScripts = app.scriptFiles ?? [];\n let sourceFolderId: number | undefined;\n\n if (options.sourceFolder) {\n // A failed request is deliberately not caught: \"no such folder\" is an\n // answer, and a 500 or a dropped connection is not one. Both callers\n // surface the throw with the status intact.\n const resolved = await client.resolveSourceFolder(options.sourceFolder);\n if (!resolved) {\n return [\n `Source folder not found under Files/: ${options.sourceFolder}`,\n hint('Use a path relative to Files/, e.g. \"Scripts/MyApp\".'),\n ].join('\\n');\n }\n sourceFolderId = resolved.id;\n folderScripts = resolved.scripts;\n\n // Moving the folder must not leave the entrypoint pointing outside it.\n if (!options.entrypoint && app.mainScriptFileId) {\n const stillThere = folderScripts.some((s) => s.id === app.mainScriptFileId);\n if (!stillThere) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n return [\n \"The app's current entrypoint is not in the new source folder.\",\n hint(\n cli\n ? 'Pass --entrypoint <script> (a file in the new folder) in the same command.'\n : 'Pass \"entrypoint\" (a file in the new folder) in the same call.',\n ),\n hint(`Files in this folder: ${files}`),\n ].join('\\n');\n }\n }\n }\n\n let mainScriptFileId: string | undefined;\n if (options.entrypoint) {\n const match = findScriptInFolder(folderScripts, options.entrypoint);\n if (!match) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n const lines = [\n `Entrypoint not found in the source folder: ${options.entrypoint}`,\n hint(`Files in this folder: ${files}`),\n ];\n if (!options.sourceFolder) {\n lines.push(\n hint(\n cli\n ? 'To use a file from another folder, set it first with --source-folder <path>.'\n : 'To use a file from another folder, pass sourceFolder first.',\n ),\n );\n }\n return lines.join('\\n');\n }\n mainScriptFileId = match.id;\n }\n\n // Apply only after every check passes, so a rejected request never partially\n // mutates `changes`.\n if (sourceFolderId !== undefined) {\n changes.sourceFolderId = sourceFolderId;\n }\n if (mainScriptFileId !== undefined) {\n changes.mainScriptFileId = mainScriptFileId;\n }\n return null;\n}\n\n// `reference` (the Remote Job id) is deliberately the only id here \u2014 apps also\n// have a folder-item id, in an overlapping number space, and carrying both is\n// what let `app delete` destroy unrelated objects.\nexport interface AppListItem {\n name: string;\n type: string;\n reference: string;\n}\n\nexport const REMOTE_JOB_ITEM_TYPE = farseer.FolderItemType.RemoteJob;\n\n// A `folders.resolveItems` result: `id` is the folder-item id, `reference` the\n// id in the item's own domain (for REMOTE_JOB, the Remote Job id).\nexport interface ResolvedFolderItem {\n id: number;\n name: string;\n type: string;\n reference: string;\n}\n\nexport function remoteJobReverseReferences(remoteJobIds: readonly string[]): farseer.ReverseReference[] {\n return remoteJobIds.map((reference) => ({ reference, type: REMOTE_JOB_ITEM_TYPE }));\n}\n\n// A deliberate refusal from the delete guard, as distinct from a transport\n// failure. Callers surface it as a validation error, not a retryable one:\n// nothing was deleted and retrying cannot change that.\nexport class AppDeleteRefusedError extends Error {}\n\n/**\n * Pick the folder-item id to delete for an app, from the `resolveItems` response.\n *\n * Remote Job ids and folder-item ids overlap \u2014 the low folder ids are the roots\n * (13 = Files, 15 = Apps) \u2014 so posting a Remote Job id to `deleteItems` deletes\n * whichever unrelated node owns that number. `resolveItems` is type-scoped\n * server-side; these checks make sure a server change can't widen that.\n */\nexport function resolveAppItemNodeId(remoteJobId: string, items: readonly ResolvedFolderItem[]): number {\n const matches = items.filter((item) => item.reference === remoteJobId);\n\n if (matches.length === 0) {\n throw new AppDeleteRefusedError(`No app found for Remote Job id ${remoteJobId} \u2014 nothing was deleted.`);\n }\n if (matches.length > 1) {\n throw new AppDeleteRefusedError(\n `Remote Job id ${remoteJobId} resolved to ${matches.length} folder items \u2014 refusing to delete.`,\n );\n }\n\n const item = matches[0];\n if (item.type !== REMOTE_JOB_ITEM_TYPE) {\n throw new AppDeleteRefusedError(\n `Refusing to delete: Remote Job id ${remoteJobId} resolved to a ${item.type} ` +\n `(\"${item.name}\"), not an app.`,\n );\n }\n\n return item.id;\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAkB;AAClB,cAAyB;
|
|
6
|
-
"names": ["chalk", "item"]
|
|
4
|
+
"sourcesContent": ["/**\n * Apps (Remote Jobs): their shape, and the rules over it.\n *\n * What belongs here is decided by dependency direction, not by I/O: nothing in\n * this module constructs a client or reads a credential. applySourceFolderChange\n * does make a call, but through an injected one-method resolver, so it stays\n * testable without one.\n */\n\nimport chalk from 'chalk';\nimport * as farseer from 'farseer-client';\n\nexport type AppArgumentDataType = 'string' | 'boolean';\n\nexport interface AppArgument {\n name: string;\n dataType: AppArgumentDataType;\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n}\n\nexport interface AppScriptFile {\n id: string;\n name: string;\n}\n\n// A resolved source folder: its node id (to set on the app) plus the script\n// files it contains (to validate an entrypoint lives inside it).\nexport interface SourceFolderResolution {\n id: number;\n scripts: AppScriptFile[];\n}\n\nexport interface AppPredefinedAction {\n name: string;\n runArguments: Record<string, string>;\n}\n\n/**\n * Shown in place of an action's value for an argument marked secret.\n *\n * The backend returns action values readable even for secret arguments \u2014 its\n * masking covers only defaults \u2014 so every surface that displays an action masks\n * it here. Sent back unchanged in a whole-list update, it means \"keep the value\n * the tenant has\", which is what lets an agent edit one action without having\n * to know, or wipe, another's secret.\n */\nexport const SECRET_PLACEHOLDER = '<secret>';\n\n// Exact names, as the backend holds them: `Token` and `token` are two arguments.\nfunction secretNames(args: AppArgument[]): Set<string> {\n return new Set(args.filter((a) => a.secret).map((a) => a.name));\n}\n\n/** The actions with every secret argument's value replaced by the placeholder. */\nexport function redactActionValues(actions: AppPredefinedAction[], args: AppArgument[]): AppPredefinedAction[] {\n const secret = secretNames(args);\n return actions.map((action) => ({\n name: action.name,\n runArguments: Object.fromEntries(\n Object.entries(action.runArguments ?? {}).map(([name, value]) => [\n name,\n secret.has(name) ? SECRET_PLACEHOLDER : value,\n ]),\n ),\n }));\n}\n\n/**\n * Put the tenant's own values back wherever an incoming action carries the\n * placeholder.\n *\n * Actions have no id, so the stored action a placeholder stands for is the one\n * with exactly its name, and only while that name is unique on both sides: the\n * backend accepts `Daily` beside `daily`, and two actions both named `Daily`,\n * and picking one of those would write its secret into the other. Anything\n * else is refused \u2014 an ambiguous name, a new action, an argument the action\n * did not preset \u2014 since sending the placeholder on would store it as the\n * secret.\n */\nexport function restoreRedactedValues(\n incoming: AppPredefinedAction[],\n current: AppPredefinedAction[],\n): { actions: AppPredefinedAction[] } | { error: string } {\n const named = (actions: AppPredefinedAction[], name: string) => actions.filter((a) => a.name === name);\n const actions: AppPredefinedAction[] = [];\n for (const action of incoming) {\n const stored = named(current, action.name);\n const ambiguous = stored.length > 1 || named(incoming, action.name).length > 1;\n const runArguments: Record<string, string> = {};\n for (const [name, value] of Object.entries(action.runArguments ?? {})) {\n if (value !== SECRET_PLACEHOLDER) {\n runArguments[name] = value;\n continue;\n }\n if (ambiguous) {\n return {\n error: `Action \"${action.name}\" sends ${SECRET_PLACEHOLDER} for \"${name}\", but more than one action is named \"${action.name}\", so which stored value it stands for is unknown \u2014 give the real value.`,\n };\n }\n const kept = stored[0]?.runArguments?.[name];\n if (kept === undefined) {\n return {\n error: `Action \"${action.name}\" sends ${SECRET_PLACEHOLDER} for \"${name}\", but no stored action named exactly \"${action.name}\" has a value for it \u2014 give the real value.`,\n };\n }\n runArguments[name] = kept;\n }\n actions.push({ name: action.name, runArguments });\n }\n return { actions };\n}\n\n// Where a run executes: 'local' is a container on the jobrunner's own machine,\n// 'batch' is a machine created for that one run. Sizes name hardware the\n// jobrunner deployment picks, so 'batch' with no size means its default.\nexport type AppComputeSize = 's' | 'm' | 'l' | 'xl';\n\nexport type AppCompute = { type: 'local' } | { type: 'batch'; options?: { size?: AppComputeSize } | null };\n\n// The same vocabulary the UI's compute selector uses, so one job reads the same\n// whichever surface configured it.\nexport type ComputeChoice = 'local' | 'batch' | `batch:${AppComputeSize}`;\n\n// Hand-written because the generated `RemoteJobComputeSize` enum is not in the\n// client SDK release this CLI pins. The other copy of this vocabulary is\n// `frontend/src/features/remoteJobs/computeChoices.ts`, which does derive from\n// that enum \u2014 a size added to the API reaches the UI and not this list, so add\n// it in both places until the pin can be bumped.\nexport const APP_COMPUTE_SIZES: readonly AppComputeSize[] = ['s', 'm', 'l', 'xl'];\n\nexport const APP_COMPUTE_CHOICES: readonly ComputeChoice[] = [\n 'local',\n 'batch',\n ...APP_COMPUTE_SIZES.map((size) => `batch:${size}` as const),\n];\n\nexport interface RemoteApp {\n id: number;\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n status: string;\n lastHeartbeat: string;\n mainScriptFileId: string | null;\n scriptFiles?: AppScriptFile[];\n sourceFolderId?: number;\n schedule?: string | null;\n runnerName?: string | null;\n runnerImage?: string | null;\n predefinedActions: AppPredefinedAction[];\n compute?: AppCompute;\n /** Base64, as the backend returns it. */\n icon?: string | null;\n}\n\n// The fields a Remote Job update writes. The backend PUT replaces the whole\n// row, so any field omitted here is reset to its default (args/predefined \u2192\n// empty, the rest \u2192 null). `mergeAppUpdate` exists so a caller that only wants\n// to touch one field doesn't silently wipe the others.\n//\n// `compute` is the exception: the backend reads an absent one as \"leave it\" and\n// an explicit null as \"reset to local\", so it is optional here and sent only\n// when there is a value to send.\nexport interface UpdateAppPayload {\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n mainScriptFileId: string | null;\n sourceFolderId: number | null;\n schedule: string | null;\n runnerName: string | null;\n runnerImage: string | null;\n predefinedActions: AppPredefinedAction[];\n compute?: AppCompute;\n icon: string | null;\n}\n\n// `scriptFileIds` is accepted from callers for backwards compatibility but is\n// never sent \u2014 the backend ignores it (scripts derive from the source folder).\nexport type AppUpdateChanges = Partial<UpdateAppPayload> & { scriptFileIds?: string[] };\n\n/**\n * Overlay a caller's changes onto an app's current state to build a full,\n * non-destructive update payload. Every field the caller leaves out keeps its\n * current value \u2014 so changing one setting never clears the others.\n *\n * Nullable fields key off presence, not nullishness: passing `null` is how a\n * caller clears a schedule or a runner, and `??` would read that as \"not\n * specified\" and put the current value straight back.\n */\nexport function mergeAppUpdate(current: RemoteApp, changes: AppUpdateChanges): UpdateAppPayload {\n const payload: UpdateAppPayload = {\n name: changes.name ?? current.name,\n description: changes.description ?? current.description ?? '',\n expectedArguments: changes.expectedArguments ?? current.expectedArguments ?? [],\n mainScriptFileId: ('mainScriptFileId' in changes ? changes.mainScriptFileId : current.mainScriptFileId) ?? null,\n sourceFolderId: ('sourceFolderId' in changes ? changes.sourceFolderId : current.sourceFolderId) ?? null,\n schedule: ('schedule' in changes ? changes.schedule : current.schedule) ?? null,\n runnerName: ('runnerName' in changes ? changes.runnerName : current.runnerName) ?? null,\n runnerImage: ('runnerImage' in changes ? changes.runnerImage : current.runnerImage) ?? null,\n predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? [],\n icon: ('icon' in changes ? changes.icon : current.icon) ?? null,\n };\n\n const compute = changes.compute ?? current.compute;\n if (compute) {\n payload.compute = compute;\n }\n\n return payload;\n}\n\n/**\n * Read a `--compute` value into the shape the API stores. Returns null when the\n * value isn't one of `APP_COMPUTE_CHOICES`, for the caller to report.\n */\nexport function parseComputeChoice(value: string): AppCompute | null {\n const choice = value.trim().toLowerCase();\n if (choice === 'local') {\n return { type: 'local' };\n }\n if (choice === 'batch') {\n return { type: 'batch' };\n }\n const size = choice.startsWith('batch:') ? choice.slice('batch:'.length) : null;\n if (size && (APP_COMPUTE_SIZES as readonly string[]).includes(size)) {\n return { type: 'batch', options: { size: size as AppComputeSize } };\n }\n return null;\n}\n\n/**\n * Render a stored compute selection as the choice a caller would type. An app\n * the backend didn't report one for reads as 'local', which is the default a\n * run gets.\n */\nexport function formatCompute(compute: AppCompute | undefined): ComputeChoice {\n if (compute?.type !== 'batch') {\n return 'local';\n }\n return compute.options?.size ? `batch:${compute.options.size}` : 'batch';\n}\n\nexport interface RunnerImageRepositories {\n registryPrefix: string;\n repositories: string[];\n}\n\n// A jobrunner currently connected to the tenant. `engines` is what it will run:\n// an empty list means it can run nothing for this tenant.\nexport interface ConnectedRunner {\n name: string;\n engines?: AppCompute['type'][];\n}\n\n/**\n * Expand a `--runner-image` value to the full registry reference the backend\n * stores. Accepts `<repository>:<tag>` and expands it with the tenant's registry\n * prefix, or takes an already-prefixed reference as given. Mirrors the backend's\n * own validation so a typo fails here rather than as a 400.\n */\nexport function resolveRunnerImage(\n value: string,\n registry: RunnerImageRepositories,\n): { image: string } | { error: string } {\n const known = registry.repositories.join(', ') || '(none configured)';\n const prefix = registry.registryPrefix ? `${registry.registryPrefix}/` : '';\n const rest = prefix && value.startsWith(prefix) ? value.slice(prefix.length) : value;\n\n if (rest.includes('/')) {\n return {\n error: `Runner image must be \"<repository>:<tag>\" or start with ${registry.registryPrefix}/. Available repositories: ${known}`,\n };\n }\n\n const colonIndex = rest.indexOf(':');\n if (colonIndex === -1) {\n return {\n error: `Runner image must include a tag, e.g. \"${registry.repositories[0] ?? 'runner-typescript'}:latest\"`,\n };\n }\n\n const repository = rest.slice(0, colonIndex);\n const tag = rest.slice(colonIndex + 1);\n if (!registry.repositories.includes(repository)) {\n return { error: `Unknown runner image repository \"${repository}\". Available repositories: ${known}` };\n }\n if (!tag) {\n return { error: `Runner image must include a tag, e.g. \"${repository}:latest\"` };\n }\n\n return { image: `${prefix}${repository}:${tag}` };\n}\n\n/**\n * Find a script in a source folder's file list by its exact name. Farseer file\n * names are case-sensitive \u2014 two files differing only in case can coexist in a\n * folder \u2014 so matching is exact, never case-folded, to avoid resolving an\n * entrypoint to the wrong file. Resolution is folder-scoped, never tenant-wide,\n * so a same-named file in another folder can't be picked by accident. Returns\n * undefined when the name isn't in the folder.\n */\nexport function findScriptInFolder(folderScripts: AppScriptFile[], name: string): AppScriptFile | undefined {\n return folderScripts.find((s) => s.name === name);\n}\n\n// The one client capability applySourceFolderChange needs. Kept minimal (not the\n// whole client) so it is trivial to unit-test with a fake resolver.\nexport interface SourceFolderResolver {\n resolveSourceFolder(relativePath: string): Promise<SourceFolderResolution | null>;\n}\n\n// Selects only how an error is presented \u2014 dimming, and `--flag` (CLI) vs param\n// (MCP) wording. It is a pure UX knob: the decision, the ids written to `changes`,\n// and the success/failure outcome are identical for both values. Never branch\n// functionality on it.\nexport type ConfigureCaller = 'cli' | 'mcp';\n\n/**\n * Resolve the source-folder / entrypoint settings for an `app configure` and\n * write the resulting ids into `changes`, applying the rule that an app's\n * scripts derive from its source folder and the entrypoint must be a file in\n * that folder. `sourceFolder` (a path under Files/) switches the folder;\n * otherwise the entrypoint is validated against the app's current folder. Moving\n * the folder must not orphan the entrypoint: if the current entrypoint isn't in\n * the new folder and the caller didn't supply one, the request is rejected \u2014 the\n * entrypoint is never silently cleared or relocated.\n *\n * Returns an error message for the caller to surface (and `changes` is left\n * untouched), or null once the ids have been written. The decision lives here so\n * the CLI and MCP paths can't drift.\n */\nexport async function applySourceFolderChange(\n client: SourceFolderResolver,\n app: Pick<RemoteApp, 'scriptFiles' | 'mainScriptFileId'>,\n changes: AppUpdateChanges,\n options: { sourceFolder?: string; entrypoint?: string },\n caller: ConfigureCaller,\n): Promise<string | null> {\n const cli = caller === 'cli';\n // Secondary guidance lines are dimmed in the terminal; plain for the MCP tool.\n const hint = (text: string) => (cli ? chalk.dim(text) : text);\n\n let folderScripts = app.scriptFiles ?? [];\n let sourceFolderId: number | undefined;\n\n if (options.sourceFolder) {\n // A failed request is deliberately not caught: \"no such folder\" is an\n // answer, and a 500 or a dropped connection is not one. Both callers\n // surface the throw with the status intact.\n const resolved = await client.resolveSourceFolder(options.sourceFolder);\n if (!resolved) {\n return [\n `Source folder not found under Files/: ${options.sourceFolder}`,\n hint('Use a path relative to Files/, e.g. \"Scripts/MyApp\".'),\n ].join('\\n');\n }\n sourceFolderId = resolved.id;\n folderScripts = resolved.scripts;\n\n // Moving the folder must not leave the entrypoint pointing outside it.\n if (!options.entrypoint && app.mainScriptFileId) {\n const stillThere = folderScripts.some((s) => s.id === app.mainScriptFileId);\n if (!stillThere) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n return [\n \"The app's current entrypoint is not in the new source folder.\",\n hint(\n cli\n ? 'Pass --entrypoint <script> (a file in the new folder) in the same command.'\n : 'Pass \"entrypoint\" (a file in the new folder) in the same call.',\n ),\n hint(`Files in this folder: ${files}`),\n ].join('\\n');\n }\n }\n }\n\n let mainScriptFileId: string | undefined;\n if (options.entrypoint) {\n const match = findScriptInFolder(folderScripts, options.entrypoint);\n if (!match) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n const lines = [\n `Entrypoint not found in the source folder: ${options.entrypoint}`,\n hint(`Files in this folder: ${files}`),\n ];\n if (!options.sourceFolder) {\n lines.push(\n hint(\n cli\n ? 'To use a file from another folder, set it first with --source-folder <path>.'\n : 'To use a file from another folder, pass sourceFolder first.',\n ),\n );\n }\n return lines.join('\\n');\n }\n mainScriptFileId = match.id;\n }\n\n // Apply only after every check passes, so a rejected request never partially\n // mutates `changes`.\n if (sourceFolderId !== undefined) {\n changes.sourceFolderId = sourceFolderId;\n }\n if (mainScriptFileId !== undefined) {\n changes.mainScriptFileId = mainScriptFileId;\n }\n return null;\n}\n\n// What a caller passes to clear a setting that can be unset. An empty string\n// does the same, so a shell variable that resolved to nothing reads as \"clear\"\n// rather than as a runner named ''.\nexport const CLEAR_SETTING = 'none';\n\nfunction isCleared(value: string): boolean {\n return value.trim() === '' || value.trim().toLowerCase() === CLEAR_SETTING;\n}\n\nexport interface RunSettings {\n schedule?: string;\n runner?: string;\n runnerImage?: string;\n compute?: string;\n}\n\n// The client capabilities applyRunSettings needs, kept minimal so tests can pass\n// a fake in place of a whole client.\nexport interface RunSettingsResolver {\n getRunnerImageRepositories(): Promise<RunnerImageRepositories>;\n getRunners(): Promise<ConnectedRunner[]>;\n}\n\n/**\n * Resolve the where-and-when settings for an `app configure` and write them into\n * `changes`. Returns an error string to report and abort on, or the warnings to\n * print alongside a successful update.\n *\n * Warnings rather than errors for anything that depends on a runner being\n * connected right now: these settings outlive any one connection, so a runner\n * that is merely restarting must not block configuring the job that needs it.\n */\nexport async function applyRunSettings(\n client: RunSettingsResolver,\n app: RemoteApp,\n changes: AppUpdateChanges,\n settings: RunSettings,\n): Promise<{ error: string } | { warnings: string[] }> {\n const warnings: string[] = [];\n const resolved: AppUpdateChanges = {};\n\n // Passed through as written. The CLI is one of three ways to set a schedule\n // and the only one that could check it here, so checking here would make the\n // same expression valid or invalid depending on where it was typed. The check\n // belongs in the backend, which every surface goes through.\n if (settings.schedule !== undefined) {\n resolved.schedule = isCleared(settings.schedule) ? null : settings.schedule.trim();\n }\n\n if (settings.compute !== undefined) {\n const compute = parseComputeChoice(settings.compute);\n if (!compute) {\n return {\n error: `Unknown compute selection \"${settings.compute}\". Valid values: ${APP_COMPUTE_CHOICES.join(', ')}.`,\n };\n }\n resolved.compute = compute;\n }\n\n if (settings.runner !== undefined) {\n resolved.runnerName = isCleared(settings.runner) ? null : settings.runner.trim();\n }\n\n if (settings.runnerImage !== undefined) {\n if (isCleared(settings.runnerImage)) {\n resolved.runnerImage = null;\n } else {\n const registry = await client.getRunnerImageRepositories();\n const outcome = resolveRunnerImage(settings.runnerImage.trim(), registry);\n if ('error' in outcome) {\n return outcome;\n }\n resolved.runnerImage = outcome.image;\n }\n }\n\n if ('runnerName' in resolved || 'compute' in resolved) {\n // Both sides fall back to what the job already holds, so the check sees\n // the configuration the job ends up with rather than only the half of it\n // this call happened to touch.\n const runnerName = ('runnerName' in resolved ? resolved.runnerName : app.runnerName) ?? null;\n const compute = 'compute' in resolved ? resolved.compute : app.compute;\n warnings.push(...(await runnerWarnings(client, runnerName, compute)));\n }\n\n Object.assign(changes, resolved);\n return { warnings };\n}\n\nasync function runnerWarnings(\n client: RunSettingsResolver,\n runnerName: string | null,\n compute: AppCompute | undefined,\n): Promise<string[]> {\n let runners: ConnectedRunner[];\n try {\n runners = await client.getRunners();\n } catch {\n // The settings are still valid; only the reassurance is missing.\n return [];\n }\n\n if (runnerName && !runners.some((runner) => runner.name === runnerName)) {\n const connected = runners.map((runner) => runner.name).join(', ') || '(none)';\n return [`No jobrunner named \"${runnerName}\" is connected. Currently connected: ${connected}`];\n }\n\n if (!compute) {\n return [];\n }\n\n const answering = runnerName ? runners.filter((runner) => runner.name === runnerName) : runners;\n if (answering.length === 0) {\n return [];\n }\n // A runner that reported no engines predates the field and runs in process only.\n const engine = compute.type;\n if (answering.some((runner) => (runner.engines ?? ['local']).includes(engine))) {\n return [];\n }\n\n const who = runnerName ? `Jobrunner \"${runnerName}\" does not offer` : 'No connected jobrunner offers';\n // \"shared runner\" and \"a machine per run\" are the labels the UI's compute\n // selector uses, so one job reads the same whichever surface configured it.\n const what = engine === 'batch' ? 'a machine per run' : 'runs on the shared runner';\n return [`${who} ${what}. The setting is saved; runs will fail until one does.`];\n}\n\n// `reference` (the Remote Job id) is deliberately the only id here \u2014 apps also\n// have a folder-item id, in an overlapping number space, and carrying both is\n// what let `app delete` destroy unrelated objects.\nexport interface AppListItem {\n name: string;\n type: string;\n reference: string;\n}\n\nexport const REMOTE_JOB_ITEM_TYPE = farseer.FolderItemType.RemoteJob;\n\n// A `folders.resolveItems` result: `id` is the folder-item id, `reference` the\n// id in the item's own domain (for REMOTE_JOB, the Remote Job id).\nexport interface ResolvedFolderItem {\n id: number;\n name: string;\n type: string;\n reference: string;\n}\n\nexport function remoteJobReverseReferences(remoteJobIds: readonly string[]): farseer.ReverseReference[] {\n return remoteJobIds.map((reference) => ({ reference, type: REMOTE_JOB_ITEM_TYPE }));\n}\n\n// A deliberate refusal from the delete guard, as distinct from a transport\n// failure. Callers surface it as a validation error, not a retryable one:\n// nothing was deleted and retrying cannot change that.\nexport class AppDeleteRefusedError extends Error {}\n\n/**\n * Pick the folder-item id to delete for an app, from the `resolveItems` response.\n *\n * Remote Job ids and folder-item ids overlap \u2014 the low folder ids are the roots\n * (13 = Files, 15 = Apps) \u2014 so posting a Remote Job id to `deleteItems` deletes\n * whichever unrelated node owns that number. `resolveItems` is type-scoped\n * server-side; these checks make sure a server change can't widen that.\n */\nexport function resolveAppItemNodeId(remoteJobId: string, items: readonly ResolvedFolderItem[]): number {\n const matches = items.filter((item) => item.reference === remoteJobId);\n\n if (matches.length === 0) {\n throw new AppDeleteRefusedError(`No app found for Remote Job id ${remoteJobId} \u2014 nothing was deleted.`);\n }\n if (matches.length > 1) {\n throw new AppDeleteRefusedError(\n `Remote Job id ${remoteJobId} resolved to ${matches.length} folder items \u2014 refusing to delete.`,\n );\n }\n\n const item = matches[0];\n if (item.type !== REMOTE_JOB_ITEM_TYPE) {\n throw new AppDeleteRefusedError(\n `Refusing to delete: Remote Job id ${remoteJobId} resolved to a ${item.type} ` +\n `(\"${item.name}\"), not an app.`,\n );\n }\n\n return item.id;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAkB;AAClB,cAAyB;AAuClB,MAAM,qBAAqB;AAGlC,SAAS,YAAY,MAAkC;AACnD,SAAO,IAAI,IAAI,KAAK,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC;AAClE;AAGO,SAAS,mBAAmB,SAAgC,MAA4C;AAC3G,QAAM,SAAS,YAAY,IAAI;AAC/B,SAAO,QAAQ,IAAI,CAAC,YAAY;AAAA,IAC5B,MAAM,OAAO;AAAA,IACb,cAAc,OAAO;AAAA,MACjB,OAAO,QAAQ,OAAO,gBAAgB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,MAAM,KAAK,MAAM;AAAA,QAC7D;AAAA,QACA,OAAO,IAAI,IAAI,IAAI,qBAAqB;AAAA,MAC5C,CAAC;AAAA,IACL;AAAA,EACJ,EAAE;AACN;AAcO,SAAS,sBACZ,UACA,SACsD;AACtD,QAAM,QAAQ,CAACA,UAAgC,SAAiBA,SAAQ,OAAO,CAAC,MAAM,EAAE,SAAS,IAAI;AACrG,QAAM,UAAiC,CAAC;AACxC,aAAW,UAAU,UAAU;AAC3B,UAAM,SAAS,MAAM,SAAS,OAAO,IAAI;AACzC,UAAM,YAAY,OAA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
|
|
401
401
|
return app;
|
|
402
402
|
}
|
|
403
|
+
async getRunnerImageRepositories() {
|
|
404
|
+
const response = await this.apiRequest("/remoteJobs/runnerImages", "GET");
|
|
405
|
+
return {
|
|
406
|
+
registryPrefix: response?.registryPrefix ?? "",
|
|
407
|
+
repositories: response?.repositories ?? []
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
async getRunners() {
|
|
411
|
+
const response = await this.apiRequest("/remoteJobs/runners", "GET");
|
|
412
|
+
return response?.runners ?? [];
|
|
413
|
+
}
|
|
403
414
|
// Never swallow a failure into an empty array: `resolveAppItemNodeId` reads
|
|
404
415
|
// "no match" as "this app doesn't exist".
|
|
405
416
|
async resolveRemoteJobItems(remoteJobIds) {
|