farseer-cli 1.13.0 → 1.14.1
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 +23 -8
- package/dist/commands/pipeline.js +158 -0
- package/dist/commands/pipeline.js.map +7 -0
- package/dist/commands/variables.js +17 -8
- package/dist/commands/variables.js.map +2 -2
- package/dist/index.js +40 -46
- package/dist/index.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +13 -68
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/resources/documentation.js +14 -0
- package/dist/mcp/resources/documentation.js.map +2 -2
- package/dist/mcp/server.js +14 -2
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/skills.js +59 -0
- package/dist/mcp/skills.js.map +7 -0
- package/dist/mcp/tools/appTools.js +4 -0
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +2 -0
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +6 -41
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/pipelineContract.js +317 -0
- package/dist/mcp/tools/pipelineContract.js.map +7 -0
- package/dist/mcp/tools/pipelineTools.js +111 -0
- package/dist/mcp/tools/pipelineTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +2 -0
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +4 -0
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/pipeline/compatibility.js +53 -0
- package/dist/pipeline/compatibility.js.map +7 -0
- package/dist/pipeline/connect.js +139 -0
- package/dist/pipeline/connect.js.map +7 -0
- package/dist/pipeline/create.js +158 -0
- package/dist/pipeline/create.js.map +7 -0
- package/dist/pipeline/errors.js +45 -0
- package/dist/pipeline/errors.js.map +7 -0
- package/dist/pipeline/generated-reference.json +115 -0
- package/dist/pipeline/guide.js +33 -0
- package/dist/pipeline/guide.js.map +7 -0
- package/dist/pipeline/init.js +204 -0
- package/dist/pipeline/init.js.map +7 -0
- package/dist/pipeline/operations.js +103 -0
- package/dist/pipeline/operations.js.map +7 -0
- package/dist/pipeline/query.js +103 -0
- package/dist/pipeline/query.js.map +7 -0
- package/dist/pipeline/queryWorker.js +119 -0
- package/dist/pipeline/queryWorker.js.map +7 -0
- package/dist/pipeline/readiness.js +55 -0
- package/dist/pipeline/readiness.js.map +7 -0
- package/dist/pipeline/reference.js +72 -0
- package/dist/pipeline/reference.js.map +7 -0
- package/dist/pipeline/requests.js +122 -0
- package/dist/pipeline/requests.js.map +7 -0
- package/dist/pipeline/runArguments.js +68 -0
- package/dist/pipeline/runArguments.js.map +7 -0
- package/dist/pipeline/runtime.js +105 -0
- package/dist/pipeline/runtime.js.map +7 -0
- package/dist/pipeline/service.js +967 -0
- package/dist/pipeline/service.js.map +7 -0
- package/dist/services/agentApprovalFetch.js +86 -0
- package/dist/services/agentApprovalFetch.js.map +7 -0
- package/dist/services/configService.js +29 -0
- package/dist/services/configService.js.map +2 -2
- package/dist/services/credentials.js +2 -0
- package/dist/services/credentials.js.map +2 -2
- package/dist/services/farseerService.js +10 -3
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/preflight.js +4 -0
- package/dist/services/preflight.js.map +2 -2
- package/dist/services/syncService.js +6 -0
- package/dist/services/syncService.js.map +2 -2
- package/dist/skills/pipeline.js +71 -0
- package/dist/skills/pipeline.js.map +7 -0
- package/dist/utils/helpers.js +2 -1
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/variableValues.js +78 -0
- package/dist/utils/variableValues.js.map +7 -0
- package/docs/pipeline-client-guide.md +67 -0
- package/docs/pipeline-reference.md +2064 -0
- package/package.json +5 -1
- package/skills/pipeline-authoring/SKILL.md +95 -0
- package/skills/pipeline-authoring/practices.md +325 -0
package/README.md
CHANGED
|
@@ -180,6 +180,16 @@ Either way the organisation is checked against the tenant before any tool runs,
|
|
|
180
180
|
|
|
181
181
|
## Authentication
|
|
182
182
|
|
|
183
|
+
### Agent sandbox credentials
|
|
184
|
+
|
|
185
|
+
Inside the Farseer agent sandbox, each turn passes a short-lived agent key (`agent1.` prefix)
|
|
186
|
+
in `FARSEER_API_KEY`, together with `FARSEER_URL` (backend origin, e.g.
|
|
187
|
+
`http://localhost:3000`) and `FARSEER_TENANT`. CLI commands and `farseer mcp-server` then
|
|
188
|
+
use that key without saving it, ahead of saved keys and browser logins. A missing URL or
|
|
189
|
+
tenant, or a request for another tenant, is refused. Any other `FARSEER_API_KEY`, such as
|
|
190
|
+
the one app scripts and the SDK use, does not change how the CLI logs in. An MCP process
|
|
191
|
+
reads its credentials at launch: restart it when the key rotates.
|
|
192
|
+
|
|
183
193
|
Farseer CLI supports two authentication methods:
|
|
184
194
|
|
|
185
195
|
### Browser Login (JWT) - Recommended
|
|
@@ -758,9 +768,9 @@ AI assistants can read comprehensive documentation:
|
|
|
758
768
|
|
|
759
769
|
Guided workflows for common tasks:
|
|
760
770
|
- **setup_new_tenant** - Setup new tenant from scratch
|
|
761
|
-
- **create_new_app** - Create
|
|
771
|
+
- **create_new_app** - Create a non-pipeline app; routes new pipelines to Simple Pipelines
|
|
762
772
|
- **understand_model** - Explore data model
|
|
763
|
-
- **write_import_script** -
|
|
773
|
+
- **write_import_script** - Maintain an existing TypeScript import or author a new Simple Pipeline
|
|
764
774
|
- **copy_app** - Copy and modify existing app
|
|
765
775
|
- **debug_sync_issues** - Troubleshoot sync problems
|
|
766
776
|
|
|
@@ -769,14 +779,19 @@ Guided workflows for common tasks:
|
|
|
769
779
|
**List apps:**
|
|
770
780
|
> "Show me all my Farseer apps"
|
|
771
781
|
|
|
772
|
-
**Create
|
|
773
|
-
> "Create a
|
|
782
|
+
**Create a pipeline:**
|
|
783
|
+
> "Create a pipeline for Sales Amount that reads from CSV"
|
|
774
784
|
|
|
775
785
|
The AI will:
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
786
|
+
|
|
787
|
+
1. Inspect existing apps and source, and check what dimensions Sales Amount has
|
|
788
|
+
2. Author the new pipeline with Simple Pipelines
|
|
789
|
+
3. Push its source, run it and inspect the result
|
|
790
|
+
|
|
791
|
+
**Maintain an existing TypeScript app:**
|
|
792
|
+
> "Fix the date mapping in our existing Sales import"
|
|
793
|
+
|
|
794
|
+
The AI uses the existing app tools to inspect, run, debug and make targeted fixes in TypeScript. It preserves the app's implementation and configuration; migration to Simple Pipelines requires an explicit migration request. New repeatable pipelines use Simple Pipelines, even when TypeScript is requested. This policy applies per app on tenants with both implementations.
|
|
780
795
|
|
|
781
796
|
**Debug issues:**
|
|
782
797
|
> "Pull latest changes and show me what's different"
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
var pipeline_exports = {};
|
|
30
|
+
__export(pipeline_exports, {
|
|
31
|
+
registerPipelineCommand: () => registerPipelineCommand,
|
|
32
|
+
shellError: () => shellError
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(pipeline_exports);
|
|
35
|
+
var fs = __toESM(require("fs"));
|
|
36
|
+
var import_connect = require("../pipeline/connect");
|
|
37
|
+
var import_operations = require("../pipeline/operations");
|
|
38
|
+
var import_reference = require("../pipeline/reference");
|
|
39
|
+
var import_errors = require("../pipeline/errors");
|
|
40
|
+
var import_service = require("../pipeline/service");
|
|
41
|
+
var import_requests = require("../pipeline/requests");
|
|
42
|
+
var import_pipeline = require("../skills/pipeline");
|
|
43
|
+
var import_helpers = require("../utils/helpers");
|
|
44
|
+
const PROFILE_HELP = "Prepared local profile (default: the one profile under tenant/.pipelines/)";
|
|
45
|
+
const PIPELINE_HELP = "Pipeline folder name; selects tenant/.pipelines/<name>.json";
|
|
46
|
+
function shellError(error) {
|
|
47
|
+
if (!(error instanceof import_errors.PipelineError)) return (0, import_service.redact)(String(error));
|
|
48
|
+
const next = error.nextAction ? `
|
|
49
|
+
Next: ${error.nextAction}` : "";
|
|
50
|
+
return (0, import_service.redact)(`Error: ${error.message}${next}`);
|
|
51
|
+
}
|
|
52
|
+
function registerPipelineCommand(program) {
|
|
53
|
+
const command = program.command("pipeline").description("Prepared pipeline authoring").configureHelp({ visibleCommands: (cmd) => [...cmd.commands] });
|
|
54
|
+
command.command("guide").option("--topic <name>", "method, practices, grammar, or a Pydantic model name", "method").option("--skill-path", "Print the bundled SKILL.md path for native skill installation").action((options) => {
|
|
55
|
+
try {
|
|
56
|
+
console.log(options.skillPath ? import_pipeline.PIPELINE_SKILL_PATH : (0, import_reference.pipelineGuide)(options.topic));
|
|
57
|
+
} catch (error) {
|
|
58
|
+
console.error(shellError(error));
|
|
59
|
+
process.exitCode = 1;
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
command.command("init <org> <tenant> [jobId]").description(
|
|
63
|
+
"Derive a local profile from a prepared job (changes nothing remotely), or with --new create a pipeline from nothing"
|
|
64
|
+
).option("--new <name>", "Create folder, job and profile for a new pipeline named after its folder").option("--workspace <dir>", "Tenant-relative source folder (default: the folder of the job main script)").option("--force", "Overwrite an existing profile for this job").action(async (org, tenant, jobId, options) => {
|
|
65
|
+
try {
|
|
66
|
+
const selection = {
|
|
67
|
+
organisation: org,
|
|
68
|
+
tenant,
|
|
69
|
+
jobId: jobId === void 0 ? void 0 : Number(jobId),
|
|
70
|
+
name: options.new,
|
|
71
|
+
workspace: options.workspace,
|
|
72
|
+
force: options.force
|
|
73
|
+
};
|
|
74
|
+
await (0, import_requests.withPipelineRequests)(async () => {
|
|
75
|
+
const result = await (0, import_operations.runPipelineInit)(
|
|
76
|
+
selection,
|
|
77
|
+
() => (0, import_connect.openPipelineConnection)(org, tenant),
|
|
78
|
+
(0, import_connect.pipelinePaths)(tenant)
|
|
79
|
+
);
|
|
80
|
+
console.log(JSON.stringify(result, null, 2));
|
|
81
|
+
});
|
|
82
|
+
} catch (error) {
|
|
83
|
+
console.error(shellError(error));
|
|
84
|
+
process.exitCode = 1;
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
command.command("runs [org] [tenant]").description("List the runs of the profile job, newest first").option("--profile <path>", PROFILE_HELP).option("--pipeline <name>", PIPELINE_HELP).option("--limit <number>", "Runs to show", "20").action(async (org, tenant, options) => {
|
|
88
|
+
try {
|
|
89
|
+
await (0, import_requests.withPipelineRequests)(async () => {
|
|
90
|
+
const checkout = (0, import_helpers.resolveTenantWithOrgMapping)(org, tenant);
|
|
91
|
+
const service = await (0, import_connect.connectPipeline)(checkout.organisation, checkout.tenant, {
|
|
92
|
+
profile: options.profile,
|
|
93
|
+
pipeline: options.pipeline
|
|
94
|
+
});
|
|
95
|
+
const result = await (0, import_operations.runPipelineOperation)(service, "runs", { limit: Number(options.limit) });
|
|
96
|
+
console.log(JSON.stringify(result, null, 2));
|
|
97
|
+
});
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error(shellError(error));
|
|
100
|
+
process.exitCode = 1;
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
const operations = [...import_operations.PIPELINE_OPERATIONS.filter((o) => o !== "runs"), "recover", "unlock"];
|
|
104
|
+
for (const operation of operations) {
|
|
105
|
+
command.command(`${operation} <org> <tenant>`).option("--profile <path>", PROFILE_HELP).option("--pipeline <name>", PIPELINE_HELP).option("--uuid <uuid>", "Exact run UUID").option("--dataset-id <uuid>", "Dataset identifier").option("--version-id <uuid>", "Retained version identifier").option("--expected-current <uuid>", "Current version observed before restore").option("--import-id <number>", "Import ID from a run observation").option("--offset <number>", "Log offset", "0").option(
|
|
106
|
+
"--arg <NAME=value>",
|
|
107
|
+
"Job argument for this run, by name; repeat for several. Others keep their defaults",
|
|
108
|
+
(value, all) => [...all, value],
|
|
109
|
+
[]
|
|
110
|
+
).option("--bindings <json>", "Version bindings [{name,datasetId,versionId}]", "[]").option("--sql-file <path>", "Local inspection SQL file").action(async (org, tenant, options) => {
|
|
111
|
+
const controller = new AbortController();
|
|
112
|
+
const cancel = () => controller.abort();
|
|
113
|
+
process.once("SIGINT", cancel);
|
|
114
|
+
try {
|
|
115
|
+
await (0, import_requests.withPipelineRequests)(async () => {
|
|
116
|
+
const service = await (0, import_connect.connectPipeline)(org, tenant, {
|
|
117
|
+
profile: options.profile,
|
|
118
|
+
pipeline: options.pipeline
|
|
119
|
+
});
|
|
120
|
+
let result;
|
|
121
|
+
if (operation === "recover") result = await service.recover(options.uuid);
|
|
122
|
+
else if (operation === "unlock") result = service.unlockAbandonedOperation();
|
|
123
|
+
else {
|
|
124
|
+
if (operation === "query" && !options.sqlFile) throw new Error("--sql-file is required");
|
|
125
|
+
result = await (0, import_operations.runPipelineOperation)(
|
|
126
|
+
service,
|
|
127
|
+
operation,
|
|
128
|
+
{
|
|
129
|
+
uuid: options.uuid,
|
|
130
|
+
datasetId: options.datasetId,
|
|
131
|
+
versionId: options.versionId,
|
|
132
|
+
expectedCurrent: options.expectedCurrent,
|
|
133
|
+
importId: options.importId === void 0 ? void 0 : Number(options.importId),
|
|
134
|
+
offset: Number(options.offset),
|
|
135
|
+
args: options.arg,
|
|
136
|
+
bindings: JSON.parse(options.bindings),
|
|
137
|
+
sql: options.sqlFile && fs.readFileSync(options.sqlFile, "utf8")
|
|
138
|
+
},
|
|
139
|
+
controller.signal
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
console.log(JSON.stringify(result, null, 2));
|
|
143
|
+
}, controller.signal);
|
|
144
|
+
} catch (error) {
|
|
145
|
+
console.error(shellError(error));
|
|
146
|
+
process.exitCode = 1;
|
|
147
|
+
} finally {
|
|
148
|
+
process.removeListener("SIGINT", cancel);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
154
|
+
0 && (module.exports = {
|
|
155
|
+
registerPipelineCommand,
|
|
156
|
+
shellError
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=pipeline.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/commands/pipeline.ts"],
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport { connectPipeline, openPipelineConnection, pipelinePaths } from '../pipeline/connect';\nimport { PIPELINE_OPERATIONS, runPipelineInit, runPipelineOperation } from '../pipeline/operations';\nimport { pipelineGuide } from '../pipeline/reference';\nimport { PipelineError } from '../pipeline/errors';\nimport { redact } from '../pipeline/service';\nimport { withPipelineRequests } from '../pipeline/requests';\nimport { PIPELINE_SKILL_PATH } from '../skills/pipeline';\nimport { resolveTenantWithOrgMapping } from '../utils/helpers';\n\nconst PROFILE_HELP = 'Prepared local profile (default: the one profile under tenant/.pipelines/)';\nconst PIPELINE_HELP = 'Pipeline folder name; selects tenant/.pipelines/<name>.json';\n\n/** What a shell user sees for a failed operation: the error, and the next step when it has one. */\nexport function shellError(error: unknown): string {\n if (!(error instanceof PipelineError)) return redact(String(error));\n const next = error.nextAction ? `\\nNext: ${error.nextAction}` : '';\n return redact(`Error: ${error.message}${next}`);\n}\n\nexport function registerPipelineCommand(program: Command) {\n const command = program\n .command('pipeline')\n .description('Prepared pipeline authoring')\n .configureHelp({ visibleCommands: (cmd) => [...cmd.commands] });\n command\n .command('guide')\n .option('--topic <name>', 'method, practices, grammar, or a Pydantic model name', 'method')\n .option('--skill-path', 'Print the bundled SKILL.md path for native skill installation')\n .action((options) => {\n try {\n console.log(options.skillPath ? PIPELINE_SKILL_PATH : pipelineGuide(options.topic));\n } catch (error) {\n console.error(shellError(error));\n process.exitCode = 1;\n }\n });\n command\n .command('init <org> <tenant> [jobId]')\n .description(\n 'Derive a local profile from a prepared job (changes nothing remotely), or with --new create a pipeline from nothing',\n )\n .option('--new <name>', 'Create folder, job and profile for a new pipeline named after its folder')\n .option('--workspace <dir>', 'Tenant-relative source folder (default: the folder of the job main script)')\n .option('--force', 'Overwrite an existing profile for this job')\n .action(async (org, tenant, jobId, options) => {\n try {\n const selection = {\n organisation: org,\n tenant,\n jobId: jobId === undefined ? undefined : Number(jobId),\n name: options.new,\n workspace: options.workspace,\n force: options.force,\n };\n await withPipelineRequests(async () => {\n const result = await runPipelineInit(\n selection,\n () => openPipelineConnection(org, tenant),\n pipelinePaths(tenant),\n );\n console.log(JSON.stringify(result, null, 2));\n });\n } catch (error) {\n console.error(shellError(error));\n process.exitCode = 1;\n }\n });\n command\n .command('runs [org] [tenant]')\n .description('List the runs of the profile job, newest first')\n .option('--profile <path>', PROFILE_HELP)\n .option('--pipeline <name>', PIPELINE_HELP)\n .option('--limit <number>', 'Runs to show', '20')\n .action(async (org, tenant, options) => {\n try {\n await withPipelineRequests(async () => {\n const checkout = resolveTenantWithOrgMapping(org, tenant);\n const service = await connectPipeline(checkout.organisation, checkout.tenant, {\n profile: options.profile,\n pipeline: options.pipeline,\n });\n const result = await runPipelineOperation(service, 'runs', { limit: Number(options.limit) });\n console.log(JSON.stringify(result, null, 2));\n });\n } catch (error) {\n console.error(shellError(error));\n process.exitCode = 1;\n }\n });\n // recover and unlock resolve local state after a crash; they are CLI-only on purpose.\n const operations = [...PIPELINE_OPERATIONS.filter((o) => o !== 'runs'), 'recover', 'unlock'] as const;\n for (const operation of operations) {\n command\n .command(`${operation} <org> <tenant>`)\n .option('--profile <path>', PROFILE_HELP)\n .option('--pipeline <name>', PIPELINE_HELP)\n .option('--uuid <uuid>', 'Exact run UUID')\n .option('--dataset-id <uuid>', 'Dataset identifier')\n .option('--version-id <uuid>', 'Retained version identifier')\n .option('--expected-current <uuid>', 'Current version observed before restore')\n .option('--import-id <number>', 'Import ID from a run observation')\n .option('--offset <number>', 'Log offset', '0')\n .option(\n '--arg <NAME=value>',\n 'Job argument for this run, by name; repeat for several. Others keep their defaults',\n (value: string, all: string[]) => [...all, value],\n [] as string[],\n )\n .option('--bindings <json>', 'Version bindings [{name,datasetId,versionId}]', '[]')\n .option('--sql-file <path>', 'Local inspection SQL file')\n .action(async (org, tenant, options) => {\n const controller = new AbortController();\n const cancel = () => controller.abort();\n process.once('SIGINT', cancel);\n try {\n await withPipelineRequests(async () => {\n const service = await connectPipeline(org, tenant, {\n profile: options.profile,\n pipeline: options.pipeline,\n });\n let result: unknown;\n if (operation === 'recover') result = await service.recover(options.uuid);\n else if (operation === 'unlock') result = service.unlockAbandonedOperation();\n else {\n if (operation === 'query' && !options.sqlFile) throw new Error('--sql-file is required');\n result = await runPipelineOperation(\n service,\n operation,\n {\n uuid: options.uuid,\n datasetId: options.datasetId,\n versionId: options.versionId,\n expectedCurrent: options.expectedCurrent,\n importId: options.importId === undefined ? undefined : Number(options.importId),\n offset: Number(options.offset),\n args: options.arg,\n bindings: JSON.parse(options.bindings),\n sql: options.sqlFile && fs.readFileSync(options.sqlFile, 'utf8'),\n },\n controller.signal,\n );\n }\n console.log(JSON.stringify(result, null, 2));\n }, controller.signal);\n } catch (error) {\n console.error(shellError(error));\n process.exitCode = 1;\n } finally {\n process.removeListener('SIGINT', cancel);\n }\n });\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AACpB,qBAAuE;AACvE,wBAA2E;AAC3E,uBAA8B;AAC9B,oBAA8B;AAC9B,qBAAuB;AACvB,sBAAqC;AACrC,sBAAoC;AACpC,qBAA4C;AAE5C,MAAM,eAAe;AACrB,MAAM,gBAAgB;AAGf,SAAS,WAAW,OAAwB;AAC/C,MAAI,EAAE,iBAAiB,6BAAgB,YAAO,uBAAO,OAAO,KAAK,CAAC;AAClE,QAAM,OAAO,MAAM,aAAa;AAAA,QAAW,MAAM,UAAU,KAAK;AAChE,aAAO,uBAAO,UAAU,MAAM,OAAO,GAAG,IAAI,EAAE;AAClD;AAEO,SAAS,wBAAwB,SAAkB;AACtD,QAAM,UAAU,QACX,QAAQ,UAAU,EAClB,YAAY,6BAA6B,EACzC,cAAc,EAAE,iBAAiB,CAAC,QAAQ,CAAC,GAAG,IAAI,QAAQ,EAAE,CAAC;AAClE,UACK,QAAQ,OAAO,EACf,OAAO,kBAAkB,wDAAwD,QAAQ,EACzF,OAAO,gBAAgB,+DAA+D,EACtF,OAAO,CAAC,YAAY;AACjB,QAAI;AACA,cAAQ,IAAI,QAAQ,YAAY,0CAAsB,gCAAc,QAAQ,KAAK,CAAC;AAAA,IACtF,SAAS,OAAO;AACZ,cAAQ,MAAM,WAAW,KAAK,CAAC;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,qBAAS,UAAM;AAAA,cACX;AAAA,cACA;AAAA,cACA;AAAA,gBACI,MAAM,QAAQ;AAAA,gBACd,WAAW,QAAQ;AAAA,gBACnB,WAAW,QAAQ;AAAA,gBACnB,iBAAiB,QAAQ;AAAA,gBACzB,UAAU,QAAQ,aAAa,SAAY,SAAY,OAAO,QAAQ,QAAQ;AAAA,gBAC9E,QAAQ,OAAO,QAAQ,MAAM;AAAA,gBAC7B,MAAM,QAAQ;AAAA,gBACd,UAAU,KAAK,MAAM,QAAQ,QAAQ;AAAA,gBACrC,KAAK,QAAQ,WAAW,GAAG,aAAa,QAAQ,SAAS,MAAM;AAAA,cACnE;AAAA,cACA,WAAW;AAAA,YACf;AAAA,UACJ;AACA,kBAAQ,IAAI,KAAK,UAAU,QAAQ,MAAM,CAAC,CAAC;AAAA,QAC/C,GAAG,WAAW,MAAM;AAAA,MACxB,SAAS,OAAO;AACZ,gBAAQ,MAAM,WAAW,KAAK,CAAC;AAC/B,gBAAQ,WAAW;AAAA,MACvB,UAAE;AACE,gBAAQ,eAAe,UAAU,MAAM;AAAA,MAC3C;AAAA,IACJ,CAAC;AAAA,EACT;AACJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -37,6 +37,8 @@ var import_logger = require("../utils/logger");
|
|
|
37
37
|
var import_nameResolver = require("../utils/nameResolver");
|
|
38
38
|
var import_authErrors = require("../services/authErrors");
|
|
39
39
|
var import_preflight = require("../services/preflight");
|
|
40
|
+
var import_errorFormatter = require("../utils/errorFormatter");
|
|
41
|
+
var import_variableValues = require("../utils/variableValues");
|
|
40
42
|
var import_modelExport = require("../services/modelExport");
|
|
41
43
|
function registerVariablesCommand(program) {
|
|
42
44
|
const variablesCmd = program.command("variables").description("List and manage variables");
|
|
@@ -121,7 +123,10 @@ function registerVariablesCommand(program) {
|
|
|
121
123
|
handleModelError(error, tenant);
|
|
122
124
|
}
|
|
123
125
|
});
|
|
124
|
-
variablesCmd.command("create [org] [tenant]").description("Create a new variable").requiredOption("--name <name>", "Variable name").option("--dimensions <csv>", "Comma-separated dimension table names").option("--formula <expr>", "Formula expression").option(
|
|
126
|
+
variablesCmd.command("create [org] [tenant]").description("Create a new variable").requiredOption("--name <name>", "Variable name").option("--dimensions <csv>", "Comma-separated dimension table names").option("--formula <expr>", "Formula expression").option(
|
|
127
|
+
"--rollup <type>",
|
|
128
|
+
"Rollup type (Sum, Average, Min, Max, None, Formula, Closing State, Beginning State)"
|
|
129
|
+
).option("--data-type <type>", "Data type (Decimal, Integer)", "Decimal").option("--description <text>", "Variable description").option("--readonly", "Set variable as read-only").action(async (first, second, options) => {
|
|
125
130
|
const { native: nativeClient } = await (0, import_preflight.preflight)(first, second);
|
|
126
131
|
try {
|
|
127
132
|
await nativeClient.initTagMap();
|
|
@@ -141,8 +146,8 @@ function registerVariablesCommand(program) {
|
|
|
141
146
|
},
|
|
142
147
|
variable: {
|
|
143
148
|
tableGids,
|
|
144
|
-
rollupType: options.rollup || "Sum",
|
|
145
|
-
dataType: options.dataType || "Decimal",
|
|
149
|
+
rollupType: (0, import_variableValues.normalizeRollupType)(options.rollup || "Sum"),
|
|
150
|
+
dataType: (0, import_variableValues.normalizeDataType)(options.dataType || "Decimal"),
|
|
146
151
|
readonly: options.readonly || false
|
|
147
152
|
}
|
|
148
153
|
};
|
|
@@ -155,7 +160,7 @@ function registerVariablesCommand(program) {
|
|
|
155
160
|
import_logger.logger.dim(` ID: ${result.created[0].id}`);
|
|
156
161
|
}
|
|
157
162
|
} catch (error) {
|
|
158
|
-
const errorMessage =
|
|
163
|
+
const errorMessage = await (0, import_errorFormatter.formatClientError)(error);
|
|
159
164
|
import_logger.logger.error(`Failed to create variable "${options.name}".`);
|
|
160
165
|
import_logger.logger.dim(errorMessage);
|
|
161
166
|
process.exit(1);
|
|
@@ -173,7 +178,8 @@ function registerVariablesCommand(program) {
|
|
|
173
178
|
if (options.description !== void 0) {
|
|
174
179
|
updateEntity.meta = { name: variable.name, description: options.description };
|
|
175
180
|
}
|
|
176
|
-
const
|
|
181
|
+
const current = await nativeClient.entities.getSingle(variable.id, "VAR");
|
|
182
|
+
const variableUpdate = (0, import_variableValues.writableVariable)(current.variable);
|
|
177
183
|
if (options.dimensions) {
|
|
178
184
|
const tableNames = options.dimensions.split(",").map((s) => s.trim());
|
|
179
185
|
const tableGids = [];
|
|
@@ -183,18 +189,21 @@ function registerVariablesCommand(program) {
|
|
|
183
189
|
}
|
|
184
190
|
variableUpdate.tableGids = tableGids;
|
|
185
191
|
}
|
|
186
|
-
if (options.rollup) variableUpdate.rollupType = options.rollup;
|
|
192
|
+
if (options.rollup) variableUpdate.rollupType = (0, import_variableValues.normalizeRollupType)(options.rollup);
|
|
187
193
|
if (options.readonly !== void 0) variableUpdate.readonly = options.readonly;
|
|
188
194
|
if (Object.keys(variableUpdate).length > 0) {
|
|
189
195
|
updateEntity.variable = variableUpdate;
|
|
190
196
|
}
|
|
191
197
|
if (options.formula !== void 0) {
|
|
192
|
-
updateEntity.calculation = {
|
|
198
|
+
updateEntity.calculation = {
|
|
199
|
+
formula: options.formula,
|
|
200
|
+
type: current.calculation?.type ?? "VARIABLE"
|
|
201
|
+
};
|
|
193
202
|
}
|
|
194
203
|
await nativeClient.entities.mutate({ updated: [updateEntity] });
|
|
195
204
|
import_logger.logger.success(`Updated variable "${options.name}".`);
|
|
196
205
|
} catch (error) {
|
|
197
|
-
const errorMessage =
|
|
206
|
+
const errorMessage = await (0, import_errorFormatter.formatClientError)(error);
|
|
198
207
|
import_logger.logger.error(`Failed to update variable "${options.name}".`);
|
|
199
208
|
import_logger.logger.dim(errorMessage);
|
|
200
209
|
process.exit(1);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/commands/variables.ts"],
|
|
4
|
-
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { matchByName, formatAmbiguous } from '../utils/nameResolver';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport { formatVariableMembers } from '../services/modelExport';\n\nexport function registerVariablesCommand(program: Command): void {\n // farseer variables list\n const variablesCmd = program.command('variables').description('List and manage variables');\n\n variablesCmd\n .command('list [org] [tenant]')\n .description('List all variables')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { tenant, client } = await preflight(first, second);\n\n try {\n // VAR-only \u2014 pulling the full dimension member matrix\n // breaks the response limit on large tenants.\n const model = await client.exportModel({ types: ['VAR'] });\n\n if (options.json) {\n console.log(JSON.stringify(model.variables, null, 2));\n return;\n }\n\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n const flags = [];\n if (variable.readonly) flags.push('readonly');\n if (variable.calculateOnDemand) flags.push('on-demand');\n const flagStr = flags.length > 0 ? chalk.dim(` [${flags.join(', ')}]`) : '';\n\n console.log(` ${chalk.bold(variable.name)}${flagStr}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);\n if (variable.formula) {\n console.log(\n ` Formula: ${chalk.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? '...' : ''}`,\n );\n }\n console.log();\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variable details / export (singular)\n const variableCmd = program.command('variable').description('Variable details and export');\n\n variableCmd\n .command('details <name>')\n .description('Show variable details (dimensions, formula, rollup, etc.)')\n .option('--json', 'Output raw JSON')\n .action(async (name, options) => {\n const { tenant, client } = await preflight();\n\n try {\n const model = await client.exportModel({ types: ['VAR'] });\n const matches = matchByName(model.variables, name);\n if (matches.length > 1) {\n logger.error(formatAmbiguous('variables', name, matches, (v) => String(v.gid ?? v.name)));\n process.exit(1);\n }\n const variable = matches[0];\n\n if (!variable) {\n logger.error(`Variable \"${name}\" not found.`);\n logger.dim('Available variables:');\n model.variables.slice(0, 10).forEach((v) => logger.dim(` - ${v.name}`));\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(variable, null, 2));\n return;\n }\n\n logger.header(`Variable: ${variable.name}`);\n console.log();\n if (variable.description) {\n console.log(` Description: ${variable.description}`);\n }\n if (variable.formula) {\n console.log(` Formula: ${variable.formula}`);\n }\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.members.length > 0) {\n console.log(` Specific members: ${formatVariableMembers(variable.members)}`);\n }\n console.log(` Roll-up type: ${variable.rollupType}`);\n console.log(` Data type: ${variable.dataType}`);\n if (variable.numberFormat) {\n console.log(\n ` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`,\n );\n }\n console.log(` Readonly: ${variable.readonly}`);\n console.log(` Calculate on demand: ${variable.calculateOnDemand}`);\n if (variable.folderPath) {\n console.log(` Folder: ${variable.folderPath.join(' / ')}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variables create [org] [tenant]\n variablesCmd\n .command('create [org] [tenant]')\n .description('Create a new variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'Comma-separated dimension table names')\n .option('--formula <expr>', 'Formula expression')\n .option('--rollup <type>', 'Rollup type (Sum, Average, Min, Max, Last, First, Count)')\n .option('--data-type <type>', 'Data type (Decimal, Integer, Text)', 'Decimal')\n .option('--description <text>', 'Variable description')\n .option('--readonly', 'Set variable as read-only')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n\n // Resolve dimension table names to IDs\n const tableGids: number[] = [];\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n }\n\n const createEntity: any = {\n type: 'VAR',\n meta: {\n name: options.name,\n description: options.description || null,\n },\n variable: {\n tableGids,\n rollupType: options.rollup || 'Sum',\n dataType: options.dataType || 'Decimal',\n readonly: options.readonly || false,\n },\n };\n\n if (options.formula) {\n createEntity.calculation = { formula: options.formula };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created variable \"${options.name}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to create variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n // farseer variables update [org] [tenant]\n variablesCmd\n .command('update [org] [tenant]')\n .description('Update an existing variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'New comma-separated dimension table names (replaces all)')\n .option('--formula <expr>', 'New formula expression')\n .option('--rollup <type>', 'New rollup type')\n .option('--description <text>', 'New description')\n .option('--readonly', 'Set as read-only')\n .option('--no-readonly', 'Set as editable')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n const variable = await nativeClient.getVariable(options.name);\n\n const updateEntity: any = {\n id: variable.id,\n type: 'VAR',\n };\n\n if (options.description !== undefined) {\n updateEntity.meta = { name: variable.name, description: options.description };\n }\n\n const variableUpdate: any = {};\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n const tableGids: number[] = [];\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n variableUpdate.tableGids = tableGids;\n }\n if (options.rollup) variableUpdate.rollupType = options.rollup;\n if (options.readonly !== undefined) variableUpdate.readonly = options.readonly;\n if (Object.keys(variableUpdate).length > 0) {\n updateEntity.variable = variableUpdate;\n }\n\n if (options.formula !== undefined) {\n updateEntity.calculation = { formula: options.formula };\n }\n\n await nativeClient.entities.mutate({ updated: [updateEntity] });\n logger.success(`Updated variable \"${options.name}\".`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to update variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n variableCmd\n .command('export <name>')\n .description('Export variable data to CSV file')\n .option('--output <file>', 'Output file path')\n .option('--format <format>', 'Output format: csv, json, xlsx', 'csv')\n .option('--limit <n>', 'Limit number of rows', parseInt)\n .action(async (name, options) => {\n const { native: nativeClient, tenant } = await preflight();\n\n try {\n logger.info(`Exporting variable \"${name}\" from ${tenant}...`);\n\n const exportRequest: any = {\n formula: `\"${name}\"`,\n format: options.format || 'csv',\n };\n if (options.limit) {\n exportRequest.limit = options.limit;\n }\n\n const blob = await nativeClient.export.exportFormula(exportRequest);\n const content = await blob.text();\n\n const outputFile =\n options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, '_')}.${options.format || 'csv'}`;\n fs.writeFileSync(outputFile, content, 'utf-8');\n\n logger.success(`Exported to ${outputFile}`);\n const lines = content.split('\\n').filter((l) => l.trim()).length;\n logger.dim(`${lines - 1} data rows`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to export variable \"${name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n}\n\nfunction handleModelError(error: unknown, tenant: string): void {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else if (errorMessage.includes('404')) {\n logger.error(`Tenant \"${tenant}\" not found or not accessible.`);\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Failed to fetch model.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,mBAAkB;AAClB,oBAAuB;AACvB,0B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AACA,UAAI,SAAS,SAAS;AAClB,gBAAQ,IAAI,cAAc,SAAS,OAAO,EAAE;AAAA,MAChD;AACA,cAAQ,IAAI,iBAAiB,SAAS,OAAO,KAAK,IAAI,CAAC,EAAE;AACzD,UAAI,SAAS,QAAQ,SAAS,GAAG;AAC7B,gBAAQ,IAAI,2BAAuB,0CAAsB,SAAS,OAAO,CAAC,EAAE;AAAA,MAChF;AACA,cAAQ,IAAI,mBAAmB,SAAS,UAAU,EAAE;AACpD,cAAQ,IAAI,gBAAgB,SAAS,QAAQ,EAAE;AAC/C,UAAI,SAAS,cAAc;AACvB,gBAAQ;AAAA,UACJ,aAAa,SAAS,aAAa,IAAI,GAAG,SAAS,aAAa,eAAe,KAAK,SAAS,aAAa,YAAY,MAAM,EAAE;AAAA,QAClI;AAAA,MACJ;AACA,cAAQ,IAAI,eAAe,SAAS,QAAQ,EAAE;AAC9C,cAAQ,IAAI,0BAA0B,SAAS,iBAAiB,EAAE;AAClE,UAAI,SAAS,YAAY;AACrB,gBAAQ,IAAI,aAAa,SAAS,WAAW,KAAK,KAAK,CAAC,EAAE;AAAA,MAC9D;AAAA,IACJ,SAAS,OAAO;AACZ,uBAAiB,OAAO,MAAM;AAAA,IAClC;AAAA,EACJ,CAAC;AAGL,eACK,QAAQ,uBAAuB,EAC/B,YAAY,uBAAuB,EACnC,eAAe,iBAAiB,eAAe,EAC/C,OAAO,sBAAsB,uCAAuC,EACpE,OAAO,oBAAoB,oBAAoB,EAC/C,
|
|
4
|
+
"sourcesContent": ["import { Command } from 'commander';\nimport * as fs from 'fs';\nimport * as path from 'path';\nimport chalk from 'chalk';\nimport { logger } from '../utils/logger';\nimport { matchByName, formatAmbiguous } from '../utils/nameResolver';\nimport { showLoginPrompt, isAuthError } from '../services/authErrors';\nimport { preflight } from '../services/preflight';\nimport { formatClientError } from '../utils/errorFormatter';\nimport { normalizeDataType, normalizeRollupType, writableVariable } from '../utils/variableValues';\nimport { formatVariableMembers } from '../services/modelExport';\n\nexport function registerVariablesCommand(program: Command): void {\n // farseer variables list\n const variablesCmd = program.command('variables').description('List and manage variables');\n\n variablesCmd\n .command('list [org] [tenant]')\n .description('List all variables')\n .option('--json', 'Output raw JSON')\n .action(async (first, second, options) => {\n const { tenant, client } = await preflight(first, second);\n\n try {\n // VAR-only \u2014 pulling the full dimension member matrix\n // breaks the response limit on large tenants.\n const model = await client.exportModel({ types: ['VAR'] });\n\n if (options.json) {\n console.log(JSON.stringify(model.variables, null, 2));\n return;\n }\n\n logger.header(`Variables (${model.variables.length})`);\n console.log();\n for (const variable of model.variables) {\n const flags = [];\n if (variable.readonly) flags.push('readonly');\n if (variable.calculateOnDemand) flags.push('on-demand');\n const flagStr = flags.length > 0 ? chalk.dim(` [${flags.join(', ')}]`) : '';\n\n console.log(` ${chalk.bold(variable.name)}${flagStr}`);\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n console.log(` Rollup: ${variable.rollupType} | Type: ${variable.dataType}`);\n if (variable.formula) {\n console.log(\n ` Formula: ${chalk.dim(variable.formula.substring(0, 80))}${variable.formula.length > 80 ? '...' : ''}`,\n );\n }\n console.log();\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variable details / export (singular)\n const variableCmd = program.command('variable').description('Variable details and export');\n\n variableCmd\n .command('details <name>')\n .description('Show variable details (dimensions, formula, rollup, etc.)')\n .option('--json', 'Output raw JSON')\n .action(async (name, options) => {\n const { tenant, client } = await preflight();\n\n try {\n const model = await client.exportModel({ types: ['VAR'] });\n const matches = matchByName(model.variables, name);\n if (matches.length > 1) {\n logger.error(formatAmbiguous('variables', name, matches, (v) => String(v.gid ?? v.name)));\n process.exit(1);\n }\n const variable = matches[0];\n\n if (!variable) {\n logger.error(`Variable \"${name}\" not found.`);\n logger.dim('Available variables:');\n model.variables.slice(0, 10).forEach((v) => logger.dim(` - ${v.name}`));\n if (model.variables.length > 10) {\n logger.dim(` ... and ${model.variables.length - 10} more`);\n }\n process.exit(1);\n }\n\n if (options.json) {\n console.log(JSON.stringify(variable, null, 2));\n return;\n }\n\n logger.header(`Variable: ${variable.name}`);\n console.log();\n if (variable.description) {\n console.log(` Description: ${variable.description}`);\n }\n if (variable.formula) {\n console.log(` Formula: ${variable.formula}`);\n }\n console.log(` Dimensions: ${variable.tables.join(', ')}`);\n if (variable.members.length > 0) {\n console.log(` Specific members: ${formatVariableMembers(variable.members)}`);\n }\n console.log(` Roll-up type: ${variable.rollupType}`);\n console.log(` Data type: ${variable.dataType}`);\n if (variable.numberFormat) {\n console.log(\n ` Format: ${variable.numberFormat.type}${variable.numberFormat.formatString ? ` (${variable.numberFormat.formatString})` : ''}`,\n );\n }\n console.log(` Readonly: ${variable.readonly}`);\n console.log(` Calculate on demand: ${variable.calculateOnDemand}`);\n if (variable.folderPath) {\n console.log(` Folder: ${variable.folderPath.join(' / ')}`);\n }\n } catch (error) {\n handleModelError(error, tenant);\n }\n });\n\n // farseer variables create [org] [tenant]\n variablesCmd\n .command('create [org] [tenant]')\n .description('Create a new variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'Comma-separated dimension table names')\n .option('--formula <expr>', 'Formula expression')\n .option(\n '--rollup <type>',\n 'Rollup type (Sum, Average, Min, Max, None, Formula, Closing State, Beginning State)',\n )\n .option('--data-type <type>', 'Data type (Decimal, Integer)', 'Decimal')\n .option('--description <text>', 'Variable description')\n .option('--readonly', 'Set variable as read-only')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n\n // Resolve dimension table names to IDs\n const tableGids: number[] = [];\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n }\n\n const createEntity: any = {\n type: 'VAR',\n meta: {\n name: options.name,\n description: options.description || null,\n },\n variable: {\n tableGids,\n rollupType: normalizeRollupType(options.rollup || 'Sum'),\n dataType: normalizeDataType(options.dataType || 'Decimal'),\n readonly: options.readonly || false,\n },\n };\n\n if (options.formula) {\n createEntity.calculation = { formula: options.formula };\n }\n\n const result = await nativeClient.entities.mutate({ created: [createEntity] });\n logger.success(`Created variable \"${options.name}\".`);\n if ((result as any).created?.length > 0) {\n logger.dim(` ID: ${(result as any).created[0].id}`);\n }\n } catch (error) {\n const errorMessage = await formatClientError(error);\n logger.error(`Failed to create variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n // farseer variables update [org] [tenant]\n variablesCmd\n .command('update [org] [tenant]')\n .description('Update an existing variable')\n .requiredOption('--name <name>', 'Variable name')\n .option('--dimensions <csv>', 'New comma-separated dimension table names (replaces all)')\n .option('--formula <expr>', 'New formula expression')\n .option('--rollup <type>', 'New rollup type')\n .option('--description <text>', 'New description')\n .option('--readonly', 'Set as read-only')\n .option('--no-readonly', 'Set as editable')\n .action(async (first, second, options) => {\n const { native: nativeClient } = await preflight(first, second);\n\n try {\n await nativeClient.initTagMap();\n const variable = await nativeClient.getVariable(options.name);\n\n const updateEntity: any = {\n id: variable.id,\n type: 'VAR',\n };\n\n if (options.description !== undefined) {\n updateEntity.meta = { name: variable.name, description: options.description };\n }\n\n const current = await nativeClient.entities.getSingle(variable.id, 'VAR' as any);\n const variableUpdate: any = writableVariable((current as any).variable);\n if (options.dimensions) {\n const tableNames = options.dimensions.split(',').map((s: string) => s.trim());\n const tableGids: number[] = [];\n for (const tableName of tableNames) {\n const table = await nativeClient.getDimensionTable(tableName);\n tableGids.push(table.id);\n }\n variableUpdate.tableGids = tableGids;\n }\n if (options.rollup) variableUpdate.rollupType = normalizeRollupType(options.rollup);\n if (options.readonly !== undefined) variableUpdate.readonly = options.readonly;\n if (Object.keys(variableUpdate).length > 0) {\n updateEntity.variable = variableUpdate;\n }\n\n if (options.formula !== undefined) {\n updateEntity.calculation = {\n formula: options.formula,\n type: (current as any).calculation?.type ?? 'VARIABLE',\n };\n }\n\n await nativeClient.entities.mutate({ updated: [updateEntity] });\n logger.success(`Updated variable \"${options.name}\".`);\n } catch (error) {\n const errorMessage = await formatClientError(error);\n logger.error(`Failed to update variable \"${options.name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n\n variableCmd\n .command('export <name>')\n .description('Export variable data to CSV file')\n .option('--output <file>', 'Output file path')\n .option('--format <format>', 'Output format: csv, json, xlsx', 'csv')\n .option('--limit <n>', 'Limit number of rows', parseInt)\n .action(async (name, options) => {\n const { native: nativeClient, tenant } = await preflight();\n\n try {\n logger.info(`Exporting variable \"${name}\" from ${tenant}...`);\n\n const exportRequest: any = {\n formula: `\"${name}\"`,\n format: options.format || 'csv',\n };\n if (options.limit) {\n exportRequest.limit = options.limit;\n }\n\n const blob = await nativeClient.export.exportFormula(exportRequest);\n const content = await blob.text();\n\n const outputFile =\n options.output || `${name.replace(/[^a-zA-Z0-9_-]/g, '_')}.${options.format || 'csv'}`;\n fs.writeFileSync(outputFile, content, 'utf-8');\n\n logger.success(`Exported to ${outputFile}`);\n const lines = content.split('\\n').filter((l) => l.trim()).length;\n logger.dim(`${lines - 1} data rows`);\n } catch (error) {\n const errorMessage = error instanceof Error ? error.message : String(error);\n logger.error(`Failed to export variable \"${name}\".`);\n logger.dim(errorMessage);\n process.exit(1);\n }\n });\n}\n\nfunction handleModelError(error: unknown, tenant: string): void {\n const errorMessage = error instanceof Error ? error.message : String(error);\n\n if (isAuthError(error)) {\n showLoginPrompt(tenant);\n } else if (errorMessage.includes('404')) {\n logger.error(`Tenant \"${tenant}\" not found or not accessible.`);\n } else if (errorMessage.includes('ENOTFOUND') || errorMessage.includes('ECONNREFUSED')) {\n logger.error('Failed to connect to Farseer.');\n } else {\n logger.error('Failed to fetch model.');\n logger.dim(errorMessage);\n }\n process.exit(1);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,SAAoB;AAEpB,mBAAkB;AAClB,oBAAuB;A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AAY;AACvB,cAAQ,KAAK,CAAC;AAAA,IAClB;AAAA,EACJ,CAAC;AACT;AAEA,SAAS,iBAAiB,OAAgB,QAAsB;AAC5D,QAAM,eAAe,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAE1E,UAAI,+BAAY,KAAK,GAAG;AACpB,2CAAgB,MAAM;AAAA,EAC1B,WAAW,aAAa,SAAS,KAAK,GAAG;AACrC,yBAAO,MAAM,WAAW,MAAM,gCAAgC;AAAA,EAClE,WAAW,aAAa,SAAS,WAAW,KAAK,aAAa,SAAS,cAAc,GAAG;AACpF,yBAAO,MAAM,+BAA+B;AAAA,EAChD,OAAO;AACH,yBAAO,MAAM,wBAAwB;AACrC,yBAAO,IAAI,YAAY;AAAA,EAC3B;AACA,UAAQ,KAAK,CAAC;AAClB;",
|
|
6
6
|
"names": ["chalk"]
|
|
7
7
|
}
|
package/dist/index.js
CHANGED
|
@@ -26,28 +26,8 @@ var import_commander = require("commander");
|
|
|
26
26
|
var import_chalk = __toESM(require("chalk"));
|
|
27
27
|
var import_constants = require("./utils/constants");
|
|
28
28
|
var import_fileLogger = require("./utils/fileLogger");
|
|
29
|
-
var
|
|
30
|
-
var
|
|
31
|
-
var import_config = require("./commands/config");
|
|
32
|
-
var import_list = require("./commands/list");
|
|
33
|
-
var import_files = require("./commands/files");
|
|
34
|
-
var import_status = require("./commands/status");
|
|
35
|
-
var import_diff = require("./commands/diff");
|
|
36
|
-
var import_pull = require("./commands/pull");
|
|
37
|
-
var import_push = require("./commands/push");
|
|
38
|
-
var import_refresh = require("./commands/refresh");
|
|
39
|
-
var import_run = require("./commands/run");
|
|
40
|
-
var import_install = require("./commands/install");
|
|
41
|
-
var import_whoami = require("./commands/whoami");
|
|
42
|
-
var import_app = require("./commands/app");
|
|
43
|
-
var import_model = require("./commands/model");
|
|
44
|
-
var import_variables = require("./commands/variables");
|
|
45
|
-
var import_dimensions = require("./commands/dimensions");
|
|
46
|
-
var import_mcp_server = require("./commands/mcp-server");
|
|
47
|
-
var import_sheets = require("./commands/sheets");
|
|
48
|
-
var import_dashboards = require("./commands/dashboards");
|
|
49
|
-
var import_cells = require("./commands/cells");
|
|
50
|
-
var import_formula = require("./commands/formula");
|
|
29
|
+
var import_configService = require("./services/configService");
|
|
30
|
+
var import_agentApprovalFetch = require("./services/agentApprovalFetch");
|
|
51
31
|
var import_updateCheck = require("./utils/updateCheck");
|
|
52
32
|
const originalEmit = process.emit;
|
|
53
33
|
process.emit = function(name, data, ...args) {
|
|
@@ -56,15 +36,16 @@ process.emit = function(name, data, ...args) {
|
|
|
56
36
|
}
|
|
57
37
|
return originalEmit.apply(process, [name, data, ...args]);
|
|
58
38
|
};
|
|
39
|
+
(0, import_agentApprovalFetch.installAgentApprovalFetch)();
|
|
59
40
|
import_fileLogger.fileLogger.init();
|
|
60
41
|
import_fileLogger.fileLogger.installCrashHandlers();
|
|
61
|
-
const updateMessagePromise = process.argv.includes("mcp-server") ?
|
|
42
|
+
const updateMessagePromise = !process.env.FARSEER_API_KEY?.startsWith(import_configService.AGENT_API_KEY_PREFIX) && !process.argv.includes("mcp-server") ? (0, import_updateCheck.checkForUpdates)() : null;
|
|
62
43
|
const program = new import_commander.Command();
|
|
63
44
|
program.configureHelp({
|
|
64
45
|
visibleCommands: () => []
|
|
65
46
|
// Hide all commands from default list
|
|
66
47
|
});
|
|
67
|
-
program.name("farseer").description("CLI tool for syncing Farseer App scripts between local folder and Farseer instances").version(import_constants.CLI_VERSION).addHelpText(
|
|
48
|
+
program.name("farseer").usage("[options] [command]").description("CLI tool for syncing Farseer App scripts between local folder and Farseer instances").version(import_constants.CLI_VERSION).addHelpText(
|
|
68
49
|
"after",
|
|
69
50
|
`
|
|
70
51
|
${import_chalk.default.bold.underline("Tenant Resolution")} ${import_chalk.default.dim("(explicit arg > FARSEER_TENANT env > error \u2014 never a global default)")}
|
|
@@ -103,6 +84,10 @@ ${import_chalk.default.bold.underline("Configuration")} ${import_chalk.default.
|
|
|
103
84
|
${import_chalk.default.dim("--remove-folder <path>")} Remove folder
|
|
104
85
|
${import_chalk.default.dim("--clear")} Remove all sync includes
|
|
105
86
|
|
|
87
|
+
${import_chalk.default.bold.underline("Pipeline")}
|
|
88
|
+
pipeline guide Read the prepared-workspace authoring guide
|
|
89
|
+
pipeline <operation> init, check, pull, push, run, runs, inspect, inspect-import, query, versions, restore, terminate, recover, unlock (see --help)
|
|
90
|
+
|
|
106
91
|
${import_chalk.default.bold.underline("Sync Operations")} ${import_chalk.default.dim("(tenant optional if FARSEER_TENANT set)")}
|
|
107
92
|
pull [org] [tenant] Pull files and apps from remote
|
|
108
93
|
${import_chalk.default.dim("--all")} Download every non-hidden, non-blocklisted file (default: developer files (.ts, .js, .py, .yml, .yaml, .md, .json) outside hidden directories and the folder blocklist)
|
|
@@ -233,28 +218,37 @@ ${import_chalk.default.bold.underline("Examples")}
|
|
|
233
218
|
${import_chalk.default.green("$")} farseer dimensions list ${import_chalk.default.dim("List dimension tables")}
|
|
234
219
|
`
|
|
235
220
|
);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
221
|
+
const registrations = [
|
|
222
|
+
[["login"], () => require("./commands/login").registerLoginCommand(program)],
|
|
223
|
+
[["logout"], () => require("./commands/logout").registerLogoutCommand(program)],
|
|
224
|
+
[["config"], () => require("./commands/config").registerConfigCommand(program)],
|
|
225
|
+
[["list"], () => require("./commands/list").registerListCommand(program)],
|
|
226
|
+
[["files"], () => require("./commands/files").registerFilesCommand(program)],
|
|
227
|
+
[["app"], () => require("./commands/app").registerAppCommand(program)],
|
|
228
|
+
[["variables", "variable"], () => require("./commands/variables").registerVariablesCommand(program)],
|
|
229
|
+
[["dimensions", "dimension"], () => require("./commands/dimensions").registerDimensionsCommand(program)],
|
|
230
|
+
[["model"], () => require("./commands/model").registerModelCommand(program)],
|
|
231
|
+
[["status"], () => require("./commands/status").registerStatusCommand(program)],
|
|
232
|
+
[["diff"], () => require("./commands/diff").registerDiffCommand(program)],
|
|
233
|
+
[["pull"], () => require("./commands/pull").registerPullCommand(program)],
|
|
234
|
+
[["push"], () => require("./commands/push").registerPushCommand(program)],
|
|
235
|
+
[["refresh"], () => require("./commands/refresh").registerRefreshCommand(program)],
|
|
236
|
+
[["run", "run-script"], () => require("./commands/run").registerRunCommand(program)],
|
|
237
|
+
[["install"], () => require("./commands/install").registerInstallCommand(program)],
|
|
238
|
+
[["whoami"], () => require("./commands/whoami").registerWhoamiCommand(program)],
|
|
239
|
+
[["sheets"], () => require("./commands/sheets").registerSheetsCommand(program)],
|
|
240
|
+
[["dashboards"], () => require("./commands/dashboards").registerDashboardsCommand(program)],
|
|
241
|
+
[["cells"], () => require("./commands/cells").registerCellsCommand(program)],
|
|
242
|
+
[["formula"], () => require("./commands/formula").registerFormulaCommand(program)],
|
|
243
|
+
[["pipeline"], () => require("./commands/pipeline").registerPipelineCommand(program)],
|
|
244
|
+
[["mcp-server"], () => require("./commands/mcp-server").registerMcpServerCommand(program)]
|
|
245
|
+
];
|
|
246
|
+
const command = process.argv[2] === "help" ? process.argv[3] : process.argv[2];
|
|
247
|
+
const selected = registrations.find(([names]) => names.includes(command));
|
|
248
|
+
if (selected) selected[1]();
|
|
249
|
+
else if (!["--version", "-V", "--help", "-h"].includes(command)) {
|
|
250
|
+
for (const [, register] of registrations) register();
|
|
251
|
+
}
|
|
258
252
|
if (updateMessagePromise) {
|
|
259
253
|
program.hook("postAction", async () => {
|
|
260
254
|
const message = await updateMessagePromise;
|