farseer-cli 1.19.0 → 1.20.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 +31 -8
- package/dist/commands/app.js +42 -3
- package/dist/commands/app.js.map +1 -1
- package/dist/commands/cells.js +120 -85
- package/dist/commands/cells.js.map +1 -1
- package/dist/commands/dashboards.js +246 -12
- package/dist/commands/dashboards.js.map +1 -1
- package/dist/commands/dimensions.js +52 -27
- package/dist/commands/dimensions.js.map +1 -1
- package/dist/commands/docs.js +82 -0
- package/dist/commands/docs.js.map +6 -0
- package/dist/commands/files.js +49 -0
- package/dist/commands/files.js.map +2 -2
- package/dist/commands/folders.js +76 -0
- package/dist/commands/folders.js.map +6 -0
- package/dist/commands/formula.js +38 -30
- package/dist/commands/formula.js.map +1 -1
- package/dist/commands/install.js +32 -30
- package/dist/commands/install.js.map +2 -2
- package/dist/commands/model.js +30 -5
- package/dist/commands/model.js.map +2 -2
- package/dist/commands/push.js +5 -3
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/sheets.js +289 -52
- package/dist/commands/sheets.js.map +1 -1
- package/dist/commands/skills.js +157 -0
- package/dist/commands/skills.js.map +6 -0
- package/dist/commands/variables.js +246 -82
- package/dist/commands/variables.js.map +1 -1
- package/dist/index.js +93 -13
- package/dist/index.js.map +1 -1
- package/dist/mcp/resources/documentation.js +19 -12
- package/dist/mcp/resources/documentation.js.map +1 -1
- package/dist/mcp/tools/appTools.js +1 -7
- package/dist/mcp/tools/appTools.js.map +1 -1
- package/dist/mcp/tools/cellTools.js +6 -19
- package/dist/mcp/tools/cellTools.js.map +1 -1
- package/dist/mcp/tools/dashboardTools.js +30 -412
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +15 -146
- package/dist/mcp/tools/dataTools.js.map +1 -1
- package/dist/mcp/tools/folderTools.js +12 -78
- package/dist/mcp/tools/folderTools.js.map +1 -1
- package/dist/mcp/tools/modelTools.js +23 -372
- package/dist/mcp/tools/modelTools.js.map +1 -1
- package/dist/mcp/tools/pipelineContract.js +5 -1
- package/dist/mcp/tools/pipelineContract.js.map +1 -1
- package/dist/mcp/tools/runTools.js +8 -69
- package/dist/mcp/tools/runTools.js.map +1 -1
- package/dist/mcp/tools/sheetTools.js +14 -264
- package/dist/mcp/tools/sheetTools.js.map +1 -1
- package/dist/mcp/tools/syncTools.js +5 -1
- package/dist/mcp/tools/syncTools.js.map +1 -1
- package/dist/mcp/utils/operationResponse.js +41 -0
- package/dist/mcp/utils/operationResponse.js.map +6 -0
- package/dist/operations/cells.js +444 -0
- package/dist/operations/cells.js.map +6 -0
- package/dist/operations/dashboards.js +357 -0
- package/dist/operations/dashboards.js.map +6 -0
- package/dist/operations/data.js +206 -0
- package/dist/operations/data.js.map +6 -0
- package/dist/operations/errors.js +64 -0
- package/dist/operations/errors.js.map +6 -0
- package/dist/operations/exportModel.js +59 -0
- package/dist/operations/exportModel.js.map +6 -0
- package/dist/operations/folderPath.js +128 -0
- package/dist/operations/folderPath.js.map +6 -0
- package/dist/operations/folders.js +80 -0
- package/dist/operations/folders.js.map +6 -0
- package/dist/operations/install.js +109 -0
- package/dist/operations/install.js.map +6 -0
- package/dist/operations/model.js +271 -0
- package/dist/operations/model.js.map +6 -0
- package/dist/operations/sheets.js +428 -0
- package/dist/operations/sheets.js.map +6 -0
- package/dist/pipeline/failStep.js +43 -0
- package/dist/pipeline/failStep.js.map +6 -0
- package/dist/pipeline/generated-reference.json +10 -10
- package/dist/pipeline/queryWorker.js +3 -1
- package/dist/pipeline/queryWorker.js.map +1 -1
- package/dist/pipeline/requests.js +3 -32
- package/dist/pipeline/requests.js.map +1 -1
- package/dist/pipeline/service.js +46 -2
- package/dist/pipeline/service.js.map +1 -1
- package/dist/services/appSyncService.js +59 -9
- package/dist/services/appSyncService.js.map +1 -1
- package/dist/services/apps.js +10 -0
- package/dist/services/apps.js.map +1 -1
- package/dist/services/farseerService.js +28 -6
- package/dist/services/farseerService.js.map +1 -1
- package/dist/skills/bundled.js +106 -0
- package/dist/skills/bundled.js.map +6 -0
- package/dist/skills/install.js +257 -0
- package/dist/skills/install.js.map +6 -0
- package/dist/skills/pipeline.js +10 -18
- package/dist/skills/pipeline.js.map +1 -1
- package/dist/utils/agentSandbox.js +1 -1
- package/dist/utils/entityResolver.js +72 -25
- package/dist/utils/entityResolver.js.map +1 -1
- package/dist/utils/errorFormatter.js +13 -0
- package/dist/utils/errorFormatter.js.map +1 -1
- package/dist/utils/formulaFilters.js +11 -2
- package/dist/utils/formulaFilters.js.map +1 -1
- package/dist/utils/operationCli.js +102 -0
- package/dist/utils/operationCli.js.map +6 -0
- package/docs/cli-guide.md +181 -1
- package/docs/pipeline-reference.md +13 -7
- package/docs/troubleshooting.md +18 -0
- package/package.json +1 -1
- package/skills/farseer-app-dev/SKILL.md +131 -0
- package/skills/farseer-app-dev/assignments.md +185 -0
- package/skills/farseer-app-dev/farseer-client-api-guide.md +907 -0
- package/skills/farseer-app-dev/farseer-client-release-notes.md +212 -0
- package/skills/farseer-app-dev/working-patterns.md +876 -0
- package/skills/farseer-authenticate-to-tenant/SKILL.md +60 -0
- package/skills/farseer-authenticate-to-tenant/app-authentication.md +91 -0
- package/skills/farseer-author-import-job/SKILL.md +114 -0
- package/skills/farseer-author-import-job/cell-writes.md +530 -0
- package/skills/farseer-author-import-job/deploying-a-farseer-app.md +383 -0
- package/skills/farseer-author-import-job/import-job-pattern.md +232 -0
- package/skills/farseer-build-model/SKILL.md +122 -0
- package/skills/farseer-build-model/formula-grain-alignment.md +612 -0
- package/skills/farseer-build-model/naming-conventions.md +435 -0
- package/skills/farseer-build-model/sparse-formulas-pattern.md +330 -0
- package/skills/farseer-build-pipeline/SKILL.md +190 -0
- package/skills/farseer-build-pipeline/erp-sales/README.md +108 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_invoice_lines.yaml +23 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_invoice_lines_raw.yaml +23 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_item_product_map.yaml +17 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/bronze/erp_sales_item_product_map_raw.yaml +11 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/gold/erp_sales_cells.yaml +40 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_lines.yaml +35 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_recon.yaml +43 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/Models/silver/erp_sales_unmapped_items.yaml +28 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-etl/main.py +49 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/in/erp_sales_cells.yaml +17 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/in/erp_sales_cells_raw.yaml +14 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/Models/load/erp_sales_to_model.yaml +47 -0
- package/skills/farseer-build-pipeline/erp-sales/erp-sales-load/main.py +44 -0
- package/skills/farseer-build-pipeline/erp-sales/item_to_product.csv +5 -0
- package/skills/farseer-build-pipeline/pipeline-app-failure-report-pattern.md +103 -0
- package/skills/farseer-build-pipeline/pipeline-source-encoding.md +68 -0
- package/skills/farseer-dashboards/SKILL.md +1 -1
- package/skills/farseer-help-center/SKILL.md +66 -0
- package/skills/farseer-modify-model/SKILL.md +158 -0
- package/skills/farseer-modify-model/model-validation-pattern.md +251 -0
- package/skills/farseer-optimize-model/SKILL.md +314 -0
- package/skills/farseer-optimize-model/stats-dump.ts +139 -0
- package/skills/farseer-pnl/SKILL.md +220 -0
- package/skills/farseer-review-model/SKILL.md +172 -0
- package/skills/farseer-run-apps/SKILL.md +102 -0
- package/skills/pipeline-authoring/SKILL.md +4 -4
- package/skills/pipeline-authoring/practices.md +15 -3
- package/dist/services/agentApprovalFetch.js +0 -90
- package/dist/services/agentApprovalFetch.js.map +0 -6
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
# Cell writes — what works, what silently fails
|
|
2
|
+
|
|
3
|
+
Programmatic cell writes are the single most accident-prone area of the
|
|
4
|
+
Farseer SDK. Several SDK methods return success codes (200 / 204) without
|
|
5
|
+
persisting any data, the legacy `/cells/update` route answers 501 (`farseer cells update` writes through `/model/updateCells` instead), and
|
|
6
|
+
`model.updateCells` quietly broadcasts when called with multi-dim filters.
|
|
7
|
+
This page is the canonical reference — what to use, what to avoid, why,
|
|
8
|
+
and how to verify.
|
|
9
|
+
|
|
10
|
+
The patterns below are **empirically verified** on live tenants
|
|
11
|
+
between 2026-04-25 and 2026-05-02.
|
|
12
|
+
Where possible, dates of verification are noted. If platform behaviour
|
|
13
|
+
changes, this page must be re-validated.
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Pick the right write path
|
|
18
|
+
|
|
19
|
+
Three write paths, three lifecycles. Pick deliberately — they are not
|
|
20
|
+
interchangeable.
|
|
21
|
+
|
|
22
|
+
| Path | Use for |
|
|
23
|
+
|---|---|
|
|
24
|
+
| **INSERT** — `client.model.updateCells({...})` | Tests, one-off corrections, scaffold dev, small programmatic adjustments. Atomic, no audit-trail noise. **Pin every grain dimension in the selector formula and leave `filters: []`** — that writes one cell on multi-dimensional variables too (re-measured 2026-10-03); the `filters` field is what misbehaved. |
|
|
25
|
+
| **IMPORT** — `client.createImportJob(...)` | Bulk loads, recurring ETL, anything the customer should see in the audit trail and be able to undo. The platform's high-throughput path. |
|
|
26
|
+
| **`POST /sheets/setData`** (raw) | The fallback when INSERT/IMPORT can't address what you need — multi-dim leaf-cell writes, deletes via `value: null`, FC-flag init. The endpoint the Farseer UI itself uses. |
|
|
27
|
+
|
|
28
|
+
The decision table:
|
|
29
|
+
|
|
30
|
+
| Use case | Path |
|
|
31
|
+
|---|---|
|
|
32
|
+
| Test seeding a handful of cells — any number of grain dimensions, with or without a sheet row | **INSERT** — `model.updateCells` (every grain dimension pinned to a leaf, `filters: []`, read back; re-measured 2026-10-03; check the active-version precondition below first) |
|
|
33
|
+
| A locked cell refuses INSERT (`Unable to write locked cell`) | **IMPORT** — see the INSERT constraints below for the two causes |
|
|
34
|
+
| Single planner correction triggered by a UI action | **INSERT** |
|
|
35
|
+
| FC-flag init for a scaffold | **`/sheets/setData`** |
|
|
36
|
+
| Monthly GL → BS load (1000s of rows) | **IMPORT** |
|
|
37
|
+
| Initial historical data load at project go-live | **IMPORT** |
|
|
38
|
+
| Recurring nightly ETL feed | **IMPORT** |
|
|
39
|
+
| Cross-version copy (Actual → Plan) | **IMPORT** (export-formula → row-import) |
|
|
40
|
+
| Mass clear of cells under a filter | **`/sheets/setData`** with `value: null` |
|
|
41
|
+
|
|
42
|
+
(Reminder: INSERT pins its cell in the **selector formula** — every grain
|
|
43
|
+
dimension at a leaf, `filters: []`. It is the `filters` field that misbehaves:
|
|
44
|
+
it is OR-logic, so a multi-dim "pin" put there resolves as a broad scope and
|
|
45
|
+
triggers the top-down splice. See the splice section below. Until 2026-10-03
|
|
46
|
+
this page called INSERT single-dim only — that was the `filters` problem, not a
|
|
47
|
+
limit of the path.)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Precondition — an inactive `Versions` member silently swallows writes
|
|
52
|
+
|
|
53
|
+
Before seeding **any** cells on a `Versions` member, assert the member is
|
|
54
|
+
`active: true`:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
farseer model <tenant> --table Versions --json # read the ACTIVE column
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
An **inactive** `Versions` member is not a sandbox — **it is a black hole.**
|
|
61
|
+
Measured live: an import job targeting an `active: false` version resolved
|
|
62
|
+
every member and variable cleanly (`handleMissingTags: "DISALLOW"` never
|
|
63
|
+
fired), `commit()` reported success — and **zero cells landed**. Nothing on
|
|
64
|
+
the write path warns; the failure presents as a green run.
|
|
65
|
+
|
|
66
|
+
This precondition applies to every path on this page (INSERT, IMPORT,
|
|
67
|
+
`/sheets/setData`). If the only "safe" versions on a tenant are inactive,
|
|
68
|
+
that is an escalation, not a workaround.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## INSERT — `model.updateCells`
|
|
73
|
+
|
|
74
|
+
The right path for **small writes on any variable** — a test's seed, a
|
|
75
|
+
one-off correction — as long as the selector pins **every grain dimension at a
|
|
76
|
+
leaf** and `filters` stays `[]`. `filters` is OR-logic (see the last
|
|
77
|
+
constraint below): pinning there instead of in the selector causes fanout.
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
await client.model.updateCells({
|
|
81
|
+
filters: [],
|
|
82
|
+
cellUpdates: [
|
|
83
|
+
{
|
|
84
|
+
formula: `sum("Revenue", "Versions">"Plan", "Years">"Y2025", "Months">"M3")`,
|
|
85
|
+
value: 1234,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
formula: `sum("Revenue", "Versions">"Plan", "Years">"Y2025", "Months">"M4")`,
|
|
89
|
+
value: 5678,
|
|
90
|
+
},
|
|
91
|
+
],
|
|
92
|
+
});
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
The `formula` is a **selector** — a `sum(variable, dim>member, …)`
|
|
96
|
+
expression that pins exactly one cell. Same syntax used for reading;
|
|
97
|
+
here it denotes the target. `value: null` clears the cell. Dimension
|
|
98
|
+
names with spaces / special characters stay quoted (`"Half years">"H1"`).
|
|
99
|
+
|
|
100
|
+
**Constraints:**
|
|
101
|
+
|
|
102
|
+
- The cell must be writable. **`400 BadRequest "Unable to write locked
|
|
103
|
+
cell"` has two causes** — check both:
|
|
104
|
+
1. **`@readonly true` on the variable** — use the pattern's intended IN
|
|
105
|
+
channel, an import job, or flip the flag around the write
|
|
106
|
+
(measured safe 2026-10-15: nothing but the targeted cells changes).
|
|
107
|
+
2. **A tenant-wide global lock rule** — `farseer model --variable` shows
|
|
108
|
+
`Readonly: false` and the `.fsl` shows nothing, because the lock is not
|
|
109
|
+
on the variable: it covers a region (version × year × month, or one
|
|
110
|
+
variable × a dimension slice). Read it with
|
|
111
|
+
`await client.settings.getGlobalLocks()` (present in SDK
|
|
112
|
+
1.4.5 already) and resolve the member gids to see which slice is locked.
|
|
113
|
+
Each rule is model-wide (`dimensions: [{ tableGid, include | selectAll }]`)
|
|
114
|
+
or scoped to one `variableGid`; a rule with `enabled: false` is switched
|
|
115
|
+
off (the field is typed from SDK 1.8.19 on — 1.4.5 dropped it). **Do not lift it yourself**:
|
|
116
|
+
`settings.setGlobalLocks(rules)` replaces the WHOLE rule array for every
|
|
117
|
+
user, so an unlock–write–relock needs the user's explicit confirmation and a
|
|
118
|
+
`try/finally`; otherwise write only the unlocked slice or have the user
|
|
119
|
+
toggle the lock around the run.
|
|
120
|
+
|
|
121
|
+
Cells written by an import job are **not** a third cause: `updateCells`
|
|
122
|
+
with a value or `null` succeeds on them, with the job alive and after it is
|
|
123
|
+
deleted with `undoData: false` (measured on a sandbox tenant 2026-10-15).
|
|
124
|
+
- **One locked cell rejects the whole batch.** Measured on a sandbox tenant
|
|
125
|
+
2026-10-15: a single locked cell anywhere in a `cellUpdates` array — first,
|
|
126
|
+
middle or last — rejects the call and **nothing** is written, also when
|
|
127
|
+
that cell's update is `value: null`. The error does not name the cell.
|
|
128
|
+
Split writes that may touch a lock region so one locked cell cannot sink
|
|
129
|
+
the rest, or check the locks before the call.
|
|
130
|
+
- **A writability probe can destroy data.** Writing a sentinel and then
|
|
131
|
+
`null` to "test" a cell deletes the value that was there. Snapshot the
|
|
132
|
+
cells you will touch first and write them back after.
|
|
133
|
+
- The selector must resolve to **exactly one cell**. A `sum()` over a
|
|
134
|
+
range collapses to the rolled-up coordinate, which probably isn't where
|
|
135
|
+
you intended.
|
|
136
|
+
- Leave `filters: []` and pin **every** grain dimension in the selector.
|
|
137
|
+
Re-measured 2026-10-03: a fully pinned selector wrote exactly one cell on a
|
|
138
|
+
variable with two business dimensions, and a three-statement model's
|
|
139
|
+
multi-dimensional inputs were all loaded this way. Earlier advice was to avoid `updateCells`
|
|
140
|
+
for variables with **two or more non-time/non-version grain
|
|
141
|
+
dimensions**, because the `filters` field is OR-logic, not AND-pinning — see the splice section below for the
|
|
142
|
+
symptom.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## IMPORT — `createImportJob`
|
|
147
|
+
|
|
148
|
+
The right path for bulk and audited loads. Full pipeline: title,
|
|
149
|
+
description, columns spec, undo/redo, audit trail.
|
|
150
|
+
|
|
151
|
+
```typescript
|
|
152
|
+
const importJob = await client.createImportJob({
|
|
153
|
+
title: `Monthly GL load — ${new Date().toISOString()}`,
|
|
154
|
+
description: "Importing GL actuals from source X",
|
|
155
|
+
columns: [
|
|
156
|
+
{ type: "DIMENSION_TABLE", dimensionTableName: "Date", columnName: "Date" },
|
|
157
|
+
{ type: "DIMENSION_TABLE", dimensionTableName: "Account", columnName: "Account" },
|
|
158
|
+
{ type: "VARIABLE", variableName: "IMPORT_GL_Period_activity_net" },
|
|
159
|
+
],
|
|
160
|
+
labels: ["actuals-load", "2025-Q4"],
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
for (const row of sourceData) {
|
|
164
|
+
await importJob.addRow([row.date, row.account, row.amount]);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
await importJob.flushRows();
|
|
168
|
+
await importJob.detectDimensions(); // commit() runs it too; over raw HTTP commit fails without it (import-job-pattern.md §5)
|
|
169
|
+
await importJob.commit();
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
(farseer-client 1.4.5: the column type is `DIMENSION_TABLE` with `dimensionTableName`;
|
|
173
|
+
`DIMENSION_TABLE_COLUMN` / `dimensionTable`, as an earlier revision of this example had
|
|
174
|
+
it, is rejected with 400 — re-measured 2026-10-03.)
|
|
175
|
+
|
|
176
|
+
**The order of values in `addRow([...])` must match the order of the `columns` array.** Column-order mismatch is the most common cause of silently-wrong imports.
|
|
177
|
+
|
|
178
|
+
**An import job writes INTO globally locked cells.** Global lock rules
|
|
179
|
+
(`settings.getGlobalLocks()`) stop `updateCells` and the UI, but an import
|
|
180
|
+
job commits into a locked region without a refusal — measured 2026-10-08 on
|
|
181
|
+
a sandbox tenant, an import landed in the locked `Actual` version. So the
|
|
182
|
+
lock is not a guard for an import script: **before importing into a region
|
|
183
|
+
that may be locked (closed Actual periods, a frozen version), read
|
|
184
|
+
`getGlobalLocks()` and refuse — or ask — if the target slice is covered.**
|
|
185
|
+
|
|
186
|
+
**`undoPrevious()` acts on the jobs listed when `createImportJob` ran.** It
|
|
187
|
+
deletes, with their cells, every job whose labels included all of these
|
|
188
|
+
labels at that moment. That is a superset match: a coarser label set (a
|
|
189
|
+
yearly `["GL","2025"]`) also deletes every finer-scoped job
|
|
190
|
+
(`["GL","2025","1"]`, …) and its cells. The list is taken before the new job is created, so the new job is
|
|
191
|
+
never in it, and with a label set no prior job carries `undoPrevious()` does
|
|
192
|
+
nothing. (Distinct trap from `undoPrevious()` + an **empty**
|
|
193
|
+
commit → HTTP 400.)
|
|
194
|
+
|
|
195
|
+
For full IMPORT mechanics (dimension discrimination, progress logging,
|
|
196
|
+
incremental testing, dry-run), see the relevant section in
|
|
197
|
+
[`working-patterns.md`](../farseer-app-dev/working-patterns.md).
|
|
198
|
+
|
|
199
|
+
---
|
|
200
|
+
|
|
201
|
+
## `POST /sheets/setData` — the path the UI uses
|
|
202
|
+
|
|
203
|
+
The reliable path for multi-dim leaf writes, FC-flag init, and the cleanup
|
|
204
|
+
case (`value: null`). Verified working on a sandbox tenant (2026-05-02) where
|
|
205
|
+
every other SDK cell-write path silently failed.
|
|
206
|
+
|
|
207
|
+
> **Note on the SDK method.** `client.sheets.setData(SetDataSheetRequest)`
|
|
208
|
+
> exists on the SDK and is the typed equivalent of this endpoint. **The
|
|
209
|
+
> verified-working path is raw `fetch`**. Whether the SDK wrapper has the same silent-fail behavior as
|
|
210
|
+
> the `cells.*` SDK methods has not been independently tested. Default to
|
|
211
|
+
> raw fetch; if you try the SDK wrapper, verify cells actually persist
|
|
212
|
+
> via a follow-up export. Re-evaluate when Farseer's SDK status changes.
|
|
213
|
+
|
|
214
|
+
```http
|
|
215
|
+
POST <baseUrl>/sheets/setData
|
|
216
|
+
X-API-KEY: <apiKey>
|
|
217
|
+
X-TENANT-ID: <tenantId>
|
|
218
|
+
Content-Type: application/json
|
|
219
|
+
|
|
220
|
+
{
|
|
221
|
+
"sheetId": 0,
|
|
222
|
+
"config": { ...standard sheet config... },
|
|
223
|
+
"cells": [
|
|
224
|
+
{
|
|
225
|
+
"rowStackKey": "0_<sheetRowId>-0",
|
|
226
|
+
"columnKey": "timeline-<yearId>-<versionId>-months:<monthId>",
|
|
227
|
+
"value": <number | null>
|
|
228
|
+
}
|
|
229
|
+
],
|
|
230
|
+
"sheetRows": [], "sheetRowDimensions": [],
|
|
231
|
+
"dimensions": [], "dimensionColumns": [],
|
|
232
|
+
"connections": [], "freezeCells": [], "setGoal": []
|
|
233
|
+
}
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Cell address format — important nuance:**
|
|
237
|
+
|
|
238
|
+
- `rowStackKey = 0_<id>-0` where `<id>` is the **sheet-row ID** (returned
|
|
239
|
+
by `sheetRows.create`), **not** the variable ID. A subtle trap: a UI
|
|
240
|
+
capture may show e.g. `0_106-0`, which looks like the variable ID, but
|
|
241
|
+
is actually the sheet-row reference. Writes targeting a stale or
|
|
242
|
+
unrelated sheet-row ID return 204 OK without persisting.
|
|
243
|
+
- `columnKey = timeline-<yearId>-<versionId>-months:<monthId>` carries
|
|
244
|
+
the time + version axis. Even single-dim variables (e.g.
|
|
245
|
+
`FC_ONE_ALWAYS { Versions }`) accept this format because the UI columns
|
|
246
|
+
always show year/month context — only the relevant parts of the address
|
|
247
|
+
are used per variable.
|
|
248
|
+
- `value: null` deletes the cell; `value: <number>` sets it.
|
|
249
|
+
- **Implication:** to write programmatically, the variable must already
|
|
250
|
+
have a sheet row pointing to it. Scaffold deploy orchestrators that
|
|
251
|
+
initialise FC flags must run sheet creation **before** flag init.
|
|
252
|
+
|
|
253
|
+
**Auth headers are NOT Bearer.** Use `X-API-KEY` + `X-TENANT-ID`. The
|
|
254
|
+
values come from `farseer config show <tenant>` (CLI output).
|
|
255
|
+
|
|
256
|
+
**Open question:** the `rowStackKey` format for multi-dim variables (e.g.
|
|
257
|
+
`PL_Plan_IN { Account, CostCenter, ... }`) likely involves additional
|
|
258
|
+
`_<memberId>:<order>` segments. Inspect a UI cell write on a multi-dim
|
|
259
|
+
sheet via the browser's network tab to capture the exact encoding.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
## SDK methods that silently fail
|
|
264
|
+
|
|
265
|
+
Verified empirically on a sandbox tenant (2026-05-02). The table below is the
|
|
266
|
+
state of the world as of that date — re-validate before assuming each
|
|
267
|
+
row still holds.
|
|
268
|
+
|
|
269
|
+
| HTTP path | SDK method | HTTP behaviour | Cells actually persist? |
|
|
270
|
+
|---|---|---|---|
|
|
271
|
+
| `POST /cells` | `cells.create` | placeholder response `{id:0}` | **no** |
|
|
272
|
+
| `POST /cells/batch` | `cells.updateBatch` | 204 OK | **no** |
|
|
273
|
+
| `POST /cells/batch` | raw fetch (bypass SDK) | 204 OK | **no** |
|
|
274
|
+
| `POST /cells/delete` | `cells.deleteCells` | 204 OK | **no** |
|
|
275
|
+
| `POST /cells/update` | `cells.update2` | 400 silent | **no** |
|
|
276
|
+
| `POST /cells/search` | `cells.search` | returns 0 always | n/a |
|
|
277
|
+
| `POST /model/updateCells` | `model.updateCells` (every grain pinned in the selector, `filters: []` — single- or multi-dim) | 204 OK | **yes ✓** |
|
|
278
|
+
| `POST /model/updateCells` | `model.updateCells` (multi-dim pinning put in `filters`) | 204 OK | partial — broadcasts (OR-filter, see splice) |
|
|
279
|
+
| **`POST /sheets/setData`** | (raw fetch only) | 204 OK | **yes ✓** |
|
|
280
|
+
|
|
281
|
+
**Re-validated 2026-10-03 on a V7 sandbox:** `cells.updateBatch`, `cells.deleteCells`
|
|
282
|
+
and `cells.query` (and `copyCells`) now answer **501 Not Implemented** rather than
|
|
283
|
+
204; `model.updateCells` with a fully pinned selector persists on multi-dimensional
|
|
284
|
+
variables, and `value: null` in it clears a cell.
|
|
285
|
+
|
|
286
|
+
**`farseer cells query` reads through `/evaluate`, and `farseer cells update`
|
|
287
|
+
writes through `/model/updateCells`** (it previews the slice it writes unless
|
|
288
|
+
`-y` is given). Only the legacy `/cells/query` and `/cells/update` routes
|
|
289
|
+
answer **HTTP 501 Not Implemented**. Always verify cell writes by reading
|
|
290
|
+
the written cells back ([Verifying writes](#verifying-writes--read-back-count-and-assert)).
|
|
291
|
+
|
|
292
|
+
These are not payload-shape problems — same payload, same headers, same
|
|
293
|
+
auth, different endpoint, different result. Could be backend gating,
|
|
294
|
+
deprecated endpoints not yet sunset, or a server-side issue. **`/sheets/setData`** is what the UI itself uses, which is why it's the canonical
|
|
295
|
+
"always works" path.
|
|
296
|
+
|
|
297
|
+
---
|
|
298
|
+
|
|
299
|
+
## Creating a dimension table (DTAB) — `entities.mutate` has NO working path
|
|
300
|
+
|
|
301
|
+
`entities.mutate` with `type: "DTAB"` cannot create a dimension table.
|
|
302
|
+
Two failure shapes measured live, on different deployments:
|
|
303
|
+
|
|
304
|
+
- **`400 Bad Request: "Invalid parent id"`** — regardless of the
|
|
305
|
+
`parentId` value supplied (null, 0, numeric folder id, string id, nested
|
|
306
|
+
in `properties`, nested in `meta`), and through every calling path (MCP
|
|
307
|
+
create-table tool, SDK `client.entities.mutate()`, raw `fetch`, raw
|
|
308
|
+
Python HTTP). The endpoint works for other entity types (DCOL, DMEM) but
|
|
309
|
+
not DTAB.
|
|
310
|
+
- **SILENT NO-OP** (re-verified live 2026-09-12 on a different deployment):
|
|
311
|
+
the same mutate returns success with empty
|
|
312
|
+
`{"created":[],"updated":[],"deleted":[]}` and creates **nothing** —
|
|
313
|
+
`entities.search` finds no such DTAB afterwards.
|
|
314
|
+
|
|
315
|
+
**`model.load` is the only way to create a DTAB programmatically** — the
|
|
316
|
+
canonical payload is documented at
|
|
317
|
+
[`working-patterns.md` §"Create or update model objects"](../farseer-app-dev/working-patterns.md#create-or-update-model-objects);
|
|
318
|
+
use that, don't re-derive it.
|
|
319
|
+
|
|
320
|
+
One adjacent trap when building the `model.load` payload from an export:
|
|
321
|
+
**never round-trip variables through export → load.** The export emits
|
|
322
|
+
variable formulas as unquoted text, which the RQL parser on load rejects
|
|
323
|
+
(`Expected end of input @ pos 1`). When you are only adding/updating
|
|
324
|
+
tables, send `variables: []` with `clear: false` — safe, nothing is
|
|
325
|
+
deleted.
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## Top-down splice — aggregate-level writes fan out
|
|
330
|
+
|
|
331
|
+
The single biggest footgun on any cell-write path. Farseer treats
|
|
332
|
+
**any write at less-than-leaf grain** as a planning operation — it
|
|
333
|
+
distributes the value across leaf cells:
|
|
334
|
+
|
|
335
|
+
- **Leaf cells in scope have existing values** ("template"): the new
|
|
336
|
+
value is distributed **proportionally** to those existing values,
|
|
337
|
+
preserving the shape.
|
|
338
|
+
- **Leaf cells in scope are all empty**: the value is split **equally**
|
|
339
|
+
across every leaf cell. E.g. `value=1000` over an empty grain of 680
|
|
340
|
+
cells → each leaf gets `1000 / 680 = 1.47`.
|
|
341
|
+
|
|
342
|
+
**Intentional use** — top-down planning. Planner enters total revenue
|
|
343
|
+
target at year level; system splices to monthly grain proportionally to
|
|
344
|
+
historical seasonality. The Farseer UI surfaces a confirm dialog
|
|
345
|
+
("Are you sure you want to write at aggregate?") before doing this.
|
|
346
|
+
|
|
347
|
+
**Accidental use** — programmatic writes that don't pin every grain dim
|
|
348
|
+
to a leaf member. Symptoms:
|
|
349
|
+
|
|
350
|
+
- Cell values are suspiciously fractional (1.47 instead of 1000).
|
|
351
|
+
- Variable export suddenly shows 100s / 1000s of cells from one apparent
|
|
352
|
+
write.
|
|
353
|
+
- Fractional values match `intended_value / leaf_cell_count` exactly.
|
|
354
|
+
|
|
355
|
+
**`model.updateCells.filters` is OR-logic, not AND-pinning** (observed 2026-05-02; **not reproducible on V7** — re-measured 2026-10-03, the documented `filters` shape below is rejected with "Invalid filter … parse failed", and so were two RQL-string variants. Pin in the selector formula instead.) Sending
|
|
356
|
+
`filters: [["Account", "4500"], ["CostCenter", "OPS"], ["Versions", "Plan"]]`
|
|
357
|
+
resolves as "Account=4500 OR CC=OPS OR Versions=Plan" — a broad scope, not
|
|
358
|
+
a single-cell pin. Symptom: `value=9999` fanned out as `9.80` across 1020
|
|
359
|
+
cells (= 9999 / 1020).
|
|
360
|
+
|
|
361
|
+
**Don't use `model.updateCells` *filters* for multi-dim grain writes.** Pin every dimension in the selector formula (works on V7), or use one of:
|
|
362
|
+
|
|
363
|
+
- `POST /sheets/setData` with full `rowStackKey` + `columnKey` addressing.
|
|
364
|
+
- `createImportJob` + import rows (canonical bulk-load path).
|
|
365
|
+
|
|
366
|
+
**Always think "is this a one-cell write or a top-down splice?"** before
|
|
367
|
+
calling the API. After every write, read the written cells back
|
|
368
|
+
([Verifying writes](#verifying-writes--read-back-count-and-assert)): a slice that reads more than you
|
|
369
|
+
wrote means you spliced — fix the address.
|
|
370
|
+
|
|
371
|
+
### Sheet prerequisite for multi-dim writes
|
|
372
|
+
|
|
373
|
+
When writing to a multi-dim variable via `/sheets/setData`, the sheet row
|
|
374
|
+
must drill **all** non-time/non-version grain dims, not just one.
|
|
375
|
+
A single-dim drill (e.g. `table: "Account"` only on a variable with grain
|
|
376
|
+
`{Account, CostCenter, …}`) leaves the planner — and any programmatic
|
|
377
|
+
write — at the aggregate row, where every write triggers splice.
|
|
378
|
+
|
|
379
|
+
```typescript
|
|
380
|
+
// Sheet row spec for PL_Plan_IN { Account, CostCenter, Versions, Years, Months }
|
|
381
|
+
{
|
|
382
|
+
name: "PL_Plan_IN",
|
|
383
|
+
variable: "PL_Plan_IN",
|
|
384
|
+
table: "Account", // outer drill
|
|
385
|
+
order: 0,
|
|
386
|
+
children: [
|
|
387
|
+
{ name: "CostCenter", table: "CostCenter", order: 0 }, // inner drill
|
|
388
|
+
],
|
|
389
|
+
}
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
Order of nesting: typically the larger dim (more members) outer, finer
|
|
393
|
+
dim inner — Account outer (200-2000 codes), CostCenter inner (5-50
|
|
394
|
+
members). Pick per project, document.
|
|
395
|
+
|
|
396
|
+
---
|
|
397
|
+
|
|
398
|
+
## Test discipline — pre-clear before write
|
|
399
|
+
|
|
400
|
+
When writing automated tests that verify formulas via cell writes,
|
|
401
|
+
**always clear the relevant cells first.** Otherwise leftover values
|
|
402
|
+
from prior runs, UI edits, or accidental splices accumulate and make
|
|
403
|
+
"did the formula compute correctly?" undecidable.
|
|
404
|
+
|
|
405
|
+
The pattern (the helpers below are **your project's own wrappers**
|
|
406
|
+
around raw `POST /sheets/setData` — not part of the SDK):
|
|
407
|
+
|
|
408
|
+
```typescript
|
|
409
|
+
// Define once per project — see reference impls below.
|
|
410
|
+
async function writeCellViaSheetSetData(c, { variable, sheetRowId, columnKey, value }) { /* ... */ }
|
|
411
|
+
async function deleteCellsViaSheetSetData(c, { variable, filters }) { /* ... */ }
|
|
412
|
+
|
|
413
|
+
// Test prologue — pre-clear our scope
|
|
414
|
+
await deleteCellsViaSheetSetData(c, {
|
|
415
|
+
variable: "TestVar",
|
|
416
|
+
filters: [/* narrow scope: one Account × one CC × Plan version */],
|
|
417
|
+
});
|
|
418
|
+
|
|
419
|
+
// Now write known test values
|
|
420
|
+
await writeCellViaSheetSetData(c, { ... });
|
|
421
|
+
|
|
422
|
+
// Then read back and verify
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
**Why:**
|
|
426
|
+
|
|
427
|
+
- Farseer cells persist across pushes — `model.load` does not wipe data.
|
|
428
|
+
- Concurrent UI edits from a human exploring the same tenant leave noisy
|
|
429
|
+
values that look like test results.
|
|
430
|
+
- Past `model.updateCells` calls with broad filters may have spliced
|
|
431
|
+
thousands of cells; those stick around forever and pollute exports.
|
|
432
|
+
- "Did my write persist?" is hard to answer when the export shows
|
|
433
|
+
2000+ rows from prior runs.
|
|
434
|
+
|
|
435
|
+
**Scope deletions narrowly** when sandboxes are shared with humans —
|
|
436
|
+
filter on one Account × one CC × one Versions slice, not "all cells of
|
|
437
|
+
this var".
|
|
438
|
+
|
|
439
|
+
This is discipline parallel to test isolation in unit testing — each test
|
|
440
|
+
run starts from a known-empty state. Document it in the test script's
|
|
441
|
+
prologue: "Pre-clears cells X, Y, Z before running."
|
|
442
|
+
|
|
443
|
+
---
|
|
444
|
+
|
|
445
|
+
## Cross-version cell copy (Actual → Plan / Forecast)
|
|
446
|
+
|
|
447
|
+
The standard pattern for FC-preparation workflows: copy a variable's
|
|
448
|
+
cells from one Versions member to another (e.g. Actual → Plan, Actual →
|
|
449
|
+
Q1F). Use **export-formula + import-job**, **not** `cells.copyAllCells`
|
|
450
|
+
(see the VERIFY note below).
|
|
451
|
+
|
|
452
|
+
```typescript
|
|
453
|
+
// 1) Read source via formula export
|
|
454
|
+
const blob = await client.export.exportFormula({
|
|
455
|
+
formula: `sum("${varName}", "Y${year}", "Versions">"${sourceVersion}")`,
|
|
456
|
+
format: ExportRequestFormatEnum.Csv,
|
|
457
|
+
});
|
|
458
|
+
const csv = await blob.text();
|
|
459
|
+
|
|
460
|
+
// 2) Transform CSV: swap the Versions column from sourceVersion to targetVersion.
|
|
461
|
+
const rows = transformRows(csv, sourceVersion, targetVersion);
|
|
462
|
+
|
|
463
|
+
// 3) Write via import job. ImportJobMetadata requires four fields together —
|
|
464
|
+
// columnMetas + handleMissingTags + importZeros + overwriteCells. Omitting
|
|
465
|
+
// any of them fails at compile time (TS) or at POST time (runtime 400).
|
|
466
|
+
const job = await client.createImportJob({
|
|
467
|
+
title: `Copy ${varName} ${sourceVersion} → ${targetVersion}`,
|
|
468
|
+
metadata: {
|
|
469
|
+
columnMetas: [
|
|
470
|
+
/* identifier dim columns + value column tagged with applyTagsIds */
|
|
471
|
+
],
|
|
472
|
+
handleMissingTags: "DISALLOW", // or "USE_DEFAULT" / "SKIP_ROW"
|
|
473
|
+
importZeros: false,
|
|
474
|
+
overwriteCells: true,
|
|
475
|
+
},
|
|
476
|
+
labels: ["fc-preparation", targetVersion, `Y${year}`, varName.replace(/[^A-Za-z0-9_-]/g, "_")],
|
|
477
|
+
});
|
|
478
|
+
|
|
479
|
+
// addRows in chunks of ≤ 50k → flushRows → undoPrevious → importDimensions → commit
|
|
480
|
+
// Wrap commit in retry-with-backoff (3 attempts).
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
The `metadata` overload is what real fc-preparation apps use; the simpler
|
|
484
|
+
`columns: [...]` overload from
|
|
485
|
+
[`working-patterns.md`](../farseer-app-dev/working-patterns.md#import-data--basic) is also
|
|
486
|
+
valid and sufficient when you don't need the full metadata controls.
|
|
487
|
+
|
|
488
|
+
`labels` is what makes `undoPrevious()` idempotent on re-run — the import
|
|
489
|
+
job locates its own previous run by label match.
|
|
490
|
+
|
|
491
|
+
**Why not `cells.copyAllCells`** (VERIFY before relying on this): per
|
|
492
|
+
memory, the call was observed to return 204 OK and write zero cells on
|
|
493
|
+
a live tenant (2026-04-25). The SDK exposes the method on both
|
|
494
|
+
`CellsApi` (`client.cells.copyAllCells(CopyAllCellsRequest)`) and as a
|
|
495
|
+
friendlier `client.copyAllCells({ mappings, filters, ... })` wrapper —
|
|
496
|
+
which one was tested isn't recorded. If you have a use case where it
|
|
497
|
+
would simplify things, repro the test on the target tenant before
|
|
498
|
+
committing to a workaround.
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
## Verifying writes — read back, count, and assert
|
|
503
|
+
|
|
504
|
+
After any cell-write path, read the cells you wrote back with
|
|
505
|
+
`client.evaluator.evaluate`, one formula per written cell or slice (a model
|
|
506
|
+
export carries no cell values: `CELL` is ignored):
|
|
507
|
+
|
|
508
|
+
```typescript
|
|
509
|
+
const cells = await client.evaluator.evaluate({
|
|
510
|
+
filters: [],
|
|
511
|
+
cellQueries: [{ type: "VARIABLE", formula: `sum("Var", "Versions">"Plan", "Months">"Jan")` }],
|
|
512
|
+
});
|
|
513
|
+
// cells[i].value answers query i: compare each with what you wrote.
|
|
514
|
+
```
|
|
515
|
+
|
|
516
|
+
If a slice reads more than you wrote → you spliced; fix the address. If it
|
|
517
|
+
matches but values look wrong → check `formatString` drift (PERCENTAGE
|
|
518
|
+
without `%`, etc.).
|
|
519
|
+
If the cells read back empty → stop and report it with the request you sent.
|
|
520
|
+
Don't send the write again, or through another path, without the user: the
|
|
521
|
+
silent-fail SDK methods above are the usual cause, and a second write can
|
|
522
|
+
double or overwrite the first.
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
## Cross-references
|
|
527
|
+
|
|
528
|
+
- [`working-patterns.md`](../farseer-app-dev/working-patterns.md) — general SDK patterns;
|
|
529
|
+
`/sheets/setData` is documented here as the canonical write path,
|
|
530
|
+
superseding the older `model.updateCells` recommendation.
|