farseer-cli 1.19.0 → 1.21.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 +32 -9
- 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 +72 -31
- 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 +474 -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 +102 -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 +33 -371
- 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 +275 -0
- package/dist/operations/model.js.map +6 -0
- package/dist/operations/sheets.js +766 -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 +11 -11
- 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/dimensionMembers.js +54 -0
- package/dist/utils/dimensionMembers.js.map +6 -0
- package/dist/utils/entityResolver.js +74 -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 +195 -1
- package/docs/pipeline-reference.md +138 -24
- package/docs/troubleshooting.md +18 -0
- package/package.json +2 -2
- 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 +222 -20
- package/skills/farseer-dashboards/cards.md +59 -0
- package/skills/farseer-dashboards/charts.md +245 -0
- package/skills/farseer-dashboards/check.md +91 -0
- package/skills/farseer-dashboards/measures.md +88 -0
- package/skills/farseer-dashboards/page.md +99 -0
- package/skills/farseer-dashboards/reporting-period.md +82 -0
- package/skills/farseer-dashboards/standard-set.md +182 -0
- package/skills/farseer-dashboards/tables.md +174 -0
- 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 +17 -4
- package/dist/services/agentApprovalFetch.js +0 -90
- package/dist/services/agentApprovalFetch.js.map +0 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Pipeline YAML reference: engine 3.
|
|
1
|
+
# Pipeline YAML reference: engine 3.5.0
|
|
2
2
|
|
|
3
3
|
Generated file. Regenerate with `tools/pipeline/generate_docs.py`.
|
|
4
4
|
|
|
@@ -130,8 +130,8 @@ Unknown fields are rejected.
|
|
|
130
130
|
| `schema_version` | integer | no | `1` | minimum=`1` |
|
|
131
131
|
| `name` | string | yes | none | |
|
|
132
132
|
| `type` | [StepType](#steptype) | yes | none | |
|
|
133
|
-
| `deps` | array of string | no | none |
|
|
134
|
-
| `description` | string | no | `""` |
|
|
133
|
+
| `deps` | array of string | no | none | Qualified names of the datasets this step reads, each produced by a step of this pipeline, which runs first. On a transform, `<name>@published` reads the published version of a dataset instead: it does not order the steps, and it can name the step's own dataset (see TransformConfig). |
|
|
134
|
+
| `description` | string | no | `""` | For the client, who reads it in the step's panel on the Pipeline tab: what the step does, and any rule needed to judge its result. Plain words, at most about 300 characters, no build details. |
|
|
135
135
|
| `extract` | [ExtractConfig](#extractconfig) or null | no | `null` | |
|
|
136
136
|
| `parse` | [ParseConfig](#parseconfig) or null | no | `null` | |
|
|
137
137
|
| `transform` | [TransformConfig](#transformconfig) or null | no | `null` | |
|
|
@@ -141,8 +141,10 @@ Unknown fields are rejected.
|
|
|
141
141
|
| `quality_rules` | array of [QualityRuleEntry](#qualityruleentry) | no | none | |
|
|
142
142
|
| `write_mode` | [WriteMode](#writemode) | no | `"overwrite"` | |
|
|
143
143
|
| `merge_keys` | array of string | no | none | |
|
|
144
|
+
| `sort_by` | array of string | no | none | |
|
|
145
|
+
| `max_file_size` | string or integer or null | no | `null` | |
|
|
144
146
|
|
|
145
|
-
Runtime-derived; do not set in YAML: `qualified_name`, `namespace`, `source_path`, `render_context`.
|
|
147
|
+
Runtime-derived; do not set in YAML: `qualified_name`, `namespace`, `source_path`, `render_context`, `published_deps`, `query_template`.
|
|
146
148
|
|
|
147
149
|
## BusinessCentralExtractConfig
|
|
148
150
|
|
|
@@ -661,21 +663,19 @@ this target writes a single, user-readable report to a path the author
|
|
|
661
663
|
picks (`file_path`, relative to the Files root — the leading `Files/`
|
|
662
664
|
is implied, exactly like the extractor's `file:`).
|
|
663
665
|
|
|
664
|
-
**Parquet
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
the
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
opt-in for the "download and open outside Farseer" case, with the
|
|
678
|
-
lossiness documented at that point.
|
|
666
|
+
**Parquet unless `format: xlsx`.** Parquet reproduces the DataFrame
|
|
667
|
+
exactly: it stores dtypes, float precision, null-vs-NaN, datetimes and
|
|
668
|
+
leading-zero string codes in the file's own metadata, and the Files page
|
|
669
|
+
previews it with those types. `format: xlsx` writes a workbook instead,
|
|
670
|
+
for a client who downloads the file and opens it in Excel: one sheet
|
|
671
|
+
holding the table, named and headed by the `xlsx:` block as on the
|
|
672
|
+
SharePoint export. Excel keeps at most 15 significant digits of a
|
|
673
|
+
number, so an integer of more than 15 digits, such as a long
|
|
674
|
+
source-system ID, opens in Excel as a different number, without an error;
|
|
675
|
+
keep such a column as text in the step that feeds the export. A
|
|
676
|
+
sheet holds at most 1,048,576 rows, its header included, and a larger
|
|
677
|
+
source fails the step before anything is written. `file_path` ends in
|
|
678
|
+
the format's extension, `.parquet` or `.xlsx`.
|
|
679
679
|
|
|
680
680
|
`source_dataset` names the single dep whose DataFrame is written to the
|
|
681
681
|
file -- the same source-naming field SharePoint export uses. An export
|
|
@@ -690,6 +690,8 @@ Unknown fields are rejected.
|
|
|
690
690
|
| `file_path` | string | yes | none | Path under Files, ending in the file name. The folder must already exist: the export does not create folders. |
|
|
691
691
|
| `conflict_behavior` | [ConflictBehavior](#conflictbehavior) | no | `"fail"` | |
|
|
692
692
|
| `farseer_credentials` | [TenantCredentialsConfig](#tenantcredentialsconfig) or null | no | `null` | |
|
|
693
|
+
| `format` | `"parquet"`, `"xlsx"` | no | `"parquet"` | |
|
|
694
|
+
| `xlsx` | [XlsxWriteOptions](#xlsxwriteoptions) or null | no | `null` | |
|
|
693
695
|
|
|
694
696
|
## FarseerFilesExtractConfig
|
|
695
697
|
|
|
@@ -1965,9 +1967,10 @@ after-image delta process may, can keep the older one. It is wrong for
|
|
|
1965
1967
|
sources that send differences. `key` has to equal the `merge_keys` of the
|
|
1966
1968
|
parse step reading the extract.
|
|
1967
1969
|
|
|
1968
|
-
`deletes` is the rule for SAP's delete records. `
|
|
1969
|
-
|
|
1970
|
-
the
|
|
1970
|
+
`deletes` is the rule for SAP's delete records. `apply` is the default: a
|
|
1971
|
+
delete removes the keyed row, so the dataset mirrors the source's current
|
|
1972
|
+
state. `ignore` drops the delete and counts it and keeps the row, for
|
|
1973
|
+
retaining history the source purges, as the cursor does.
|
|
1971
1974
|
|
|
1972
1975
|
`reset_subscription_until` and `release_until` are lifecycle steps, each
|
|
1973
1976
|
in effect until the instant it names and refused after it, so a copied
|
|
@@ -1985,7 +1988,7 @@ Unknown fields are rejected.
|
|
|
1985
1988
|
| YAML field | Type | Required | Default | Constraints / description |
|
|
1986
1989
|
| --- | --- | --- | --- | --- |
|
|
1987
1990
|
| `key` | array of string | yes | none | minItems=`1` |
|
|
1988
|
-
| `deletes` | `"ignore"` |
|
|
1991
|
+
| `deletes` | `"ignore"`, `"apply"` | no | `"apply"` | |
|
|
1989
1992
|
| `reset_subscription_until` | string or null | no | `null` | string: format=`"date-time"` |
|
|
1990
1993
|
| `release_until` | string or null | no | `null` | string: format=`"date-time"` |
|
|
1991
1994
|
|
|
@@ -2251,7 +2254,10 @@ For `engine: duckdb`:
|
|
|
2251
2254
|
the SQL as views named by their leaf name. Output is always parquet.
|
|
2252
2255
|
`sql_file` (a `.sql` file in `Code/`) exists for engine-run pipelines but
|
|
2253
2256
|
is refused for authored pipelines, which are validated before any source
|
|
2254
|
-
is read; use `query`.
|
|
2257
|
+
is read; use `query`. A query that should stop because the data isn't
|
|
2258
|
+
what the step needs calls `fail_step('…')` with what is wrong and what the
|
|
2259
|
+
client does next, not `error()`: the client reads `fail_step`'s message as
|
|
2260
|
+
the step's failure, and `error()` only as the app's own code failing.
|
|
2255
2261
|
|
|
2256
2262
|
For `engine: ibis`:
|
|
2257
2263
|
|
|
@@ -2290,6 +2296,114 @@ Whatever the engine, the output is parquet, so there is no format to set:
|
|
|
2290
2296
|
a transform's output is typed and read back by scanning it, and neither
|
|
2291
2297
|
survives csv or json.
|
|
2292
2298
|
|
|
2299
|
+
Reading a published version (`@published`):
|
|
2300
|
+
|
|
2301
|
+
A `deps` entry `<name>@published` reads the published version of a
|
|
2302
|
+
dataset, not the version this run writes. It does not order the steps, so
|
|
2303
|
+
a step can name its own dataset. For its own dataset the step reads exactly
|
|
2304
|
+
the version its new version replaces, and if another run publishes first,
|
|
2305
|
+
the publication of this run fails. For another dataset of the pipeline, it
|
|
2306
|
+
reads the version published before the run, also under `ON_COMPLETE`,
|
|
2307
|
+
which publishes each step when it finishes. For a dataset of another
|
|
2308
|
+
pipeline, it reads the version published when the step starts, so two
|
|
2309
|
+
steps that read it can see different versions if that pipeline publishes
|
|
2310
|
+
during the run; when they must agree, read it in one step and pass that
|
|
2311
|
+
step's output on as an ordinary dep. The name is the qualified name: in
|
|
2312
|
+
`Models/silver/`, the step `history` reads its own version as
|
|
2313
|
+
`silver.history@published`. SQL reads the entry as the view
|
|
2314
|
+
`"<leaf>@published"` (quoted); a script function takes it in a `**`
|
|
2315
|
+
parameter, under the same key. Only the Datasets and Iceberg stores keep
|
|
2316
|
+
versions, and a step reads only datasets of the store the pipeline runs
|
|
2317
|
+
on; the Farseer Files store refuses the entry.
|
|
2318
|
+
|
|
2319
|
+
A dataset with no published version has no relation, and SQL that reads it
|
|
2320
|
+
fails. `is_published('<name>')` is true when the dependency has a version on
|
|
2321
|
+
this run, so guard the part of the query that reads it. The rows of
|
|
2322
|
+
`customers` that are new or changed since the last publication:
|
|
2323
|
+
|
|
2324
|
+
deps: [customers, customers@published]
|
|
2325
|
+
query: >
|
|
2326
|
+
SELECT * FROM customers
|
|
2327
|
+
{{ 'EXCEPT SELECT * FROM "customers@published"'
|
|
2328
|
+
if is_published('customers') else '' }}
|
|
2329
|
+
|
|
2330
|
+
`run_time()` is the instant the run started, in UTC, as text for
|
|
2331
|
+
`TIMESTAMP '{{ run_time() }}'`.
|
|
2332
|
+
|
|
2333
|
+
SCD type 2 history (`scd2()`):
|
|
2334
|
+
|
|
2335
|
+
name: customers_history
|
|
2336
|
+
type: transform
|
|
2337
|
+
deps: [customers, customers_history@published]
|
|
2338
|
+
transform:
|
|
2339
|
+
engine: duckdb
|
|
2340
|
+
query: >
|
|
2341
|
+
{{ scd2(snapshot='customers', key=['customer_id'],
|
|
2342
|
+
track=['region', 'sales_rep']) }}
|
|
2343
|
+
|
|
2344
|
+
The step publishes the snapshot's columns plus `__valid_from` and
|
|
2345
|
+
`__valid_to` (UTC `TIMESTAMP`; `__valid_to` is empty on the open row of a
|
|
2346
|
+
key) and `__is_current` (`BOOLEAN`, true on that open row). A change of
|
|
2347
|
+
a tracked column closes the open row and opens a new one at `run_time()`.
|
|
2348
|
+
An untracked column changes on the open row only. A key that leaves the
|
|
2349
|
+
snapshot closes (`close_missing=False` keeps it open), and a new or
|
|
2350
|
+
returning key opens at `run_time()`. The first run opens every row at
|
|
2351
|
+
`initial_valid_from` (default `'1900-01-01 00:00:00'`). A NULL key value
|
|
2352
|
+
or a repeated key in the snapshot fails the step. An empty string is a key
|
|
2353
|
+
value: reject it in the snapshot step if it means no key. A tracked column
|
|
2354
|
+
that the snapshot does not have fails the step, and so does a column that
|
|
2355
|
+
the snapshot and the history both have with two types, also when only the
|
|
2356
|
+
case of its name changed. A run fails when the published history holds a
|
|
2357
|
+
time later than its own start, usually because a run that started later
|
|
2358
|
+
published first. A later run fails when the snapshot has no rows and the
|
|
2359
|
+
history has open rows, because a source read that returned nothing would
|
|
2360
|
+
close every key: `allow_empty=True` lets one run close them. The step logs
|
|
2361
|
+
how many rows it opened and closed. The step must declare its own `<name>@published` and keep
|
|
2362
|
+
`write_mode: overwrite`, because it writes the whole history on every run.
|
|
2363
|
+
A `schema:` on the history step must declare the key and the tracked
|
|
2364
|
+
columns, and the three history columns by their exact names, because a
|
|
2365
|
+
step with a `schema:` keeps only the columns it declares. An `initial_valid_from` later than the run's start
|
|
2366
|
+
is refused.
|
|
2367
|
+
|
|
2368
|
+
The snapshot must hold the complete population: a key that is missing
|
|
2369
|
+
closes. Put quality rules on every dataset that the snapshot reads, so
|
|
2370
|
+
that a partial read fails before the history sees it: a minimum on the
|
|
2371
|
+
key (`custom__distinct_count` with `min`), a format rule on the key (for
|
|
2372
|
+
example `str_length`), and `not_null` on columns that come from a joined
|
|
2373
|
+
table.
|
|
2374
|
+
A dataset restore returns the history to an earlier version, and does not
|
|
2375
|
+
undo writes to the planning model. Never feed a shared history from a
|
|
2376
|
+
partial snapshot, such as an incremental window kept with `overwrite` or a
|
|
2377
|
+
run narrowed to one company or period: every key outside it closes. Do not
|
|
2378
|
+
overlap history runs: an earlier run fails only when a later one published
|
|
2379
|
+
first and opened or closed a row. A later first run, a run with no change
|
|
2380
|
+
or a run that changed only untracked values writes no such time, so the
|
|
2381
|
+
earlier run still publishes its older snapshot after the newer one. Build the snapshot
|
|
2382
|
+
with a `LEFT JOIN` from the table that holds the population, deduplicate
|
|
2383
|
+
with a full
|
|
2384
|
+
`ORDER BY`, give each column a fixed type in its `schema:`, and keep the
|
|
2385
|
+
extract and its history in one pipeline. A change of `key` is not
|
|
2386
|
+
detected: start a new history for a new key. A new column is untracked in
|
|
2387
|
+
the run that adds it, because the published history does not have it yet:
|
|
2388
|
+
add it to `track` from the next run. A snapshot column with the name of one
|
|
2389
|
+
of the three history columns, in any letter case, fails the step. A source
|
|
2390
|
+
column such as `valid_from` is ordinary data and can be tracked. Load a
|
|
2391
|
+
dimension from the snapshot, or from the latest row per key, and never with
|
|
2392
|
+
`delete_missing: true` from a history. Facts by date, and the value on a
|
|
2393
|
+
date beside today's:
|
|
2394
|
+
|
|
2395
|
+
SELECT i.*, h.region FROM invoices i
|
|
2396
|
+
LEFT JOIN customers_history h ON h.customer_id = i.customer_id
|
|
2397
|
+
AND i.invoice_date >= CAST(h.__valid_from AS DATE)
|
|
2398
|
+
AND (h.__valid_to IS NULL OR i.invoice_date < CAST(h.__valid_to AS DATE))
|
|
2399
|
+
|
|
2400
|
+
SELECT o.customer_id, o.region AS region_now, d.region AS region_nov_1
|
|
2401
|
+
FROM customers_history o LEFT JOIN customers_history d
|
|
2402
|
+
ON d.customer_id = o.customer_id
|
|
2403
|
+
AND CAST(d.__valid_from AS DATE) <= DATE '2026-11-01'
|
|
2404
|
+
AND (d.__valid_to IS NULL OR DATE '2026-11-01' < CAST(d.__valid_to AS DATE))
|
|
2405
|
+
WHERE o.__is_current
|
|
2406
|
+
|
|
2293
2407
|
Unknown fields are rejected.
|
|
2294
2408
|
|
|
2295
2409
|
| YAML field | Type | Required | Default | Constraints / description |
|
package/docs/troubleshooting.md
CHANGED
|
@@ -108,6 +108,24 @@ const transformed = table.derive({
|
|
|
108
108
|
|
|
109
109
|
---
|
|
110
110
|
|
|
111
|
+
## Sync and authentication
|
|
112
|
+
|
|
113
|
+
When `farseer pull`, `push` or `status` does not do what you expect:
|
|
114
|
+
|
|
115
|
+
1. `farseer whoami`: is the login still valid, and which tenant does this shell target (the argument, else `FARSEER_TENANT`)?
|
|
116
|
+
2. `farseer status <tenant>`: which files are modified, local-only or remote-only.
|
|
117
|
+
3. `farseer diff <tenant> [file]`: what differs, before you decide between pulling (keep remote) and pushing (keep local).
|
|
118
|
+
|
|
119
|
+
| Message | What to do |
|
|
120
|
+
|---|---|
|
|
121
|
+
| `Authentication required.` | `farseer login`, or `farseer config set <tenant> --api-key KEY` |
|
|
122
|
+
| `Remote has changes for N file(s) since last pull` | `farseer pull`, then `farseer push` |
|
|
123
|
+
| Apps not syncing over MCP (`farseer_pull`, `farseer_push`) | Those tools sync apps only with a browser login: `farseer login`. The CLI's `pull` and `push` sync apps with an API key as well. |
|
|
124
|
+
|
|
125
|
+
Without `--force`, pull asks how to resolve each conflict and push refuses while the remote has changes (`farseer docs cli-guide` describes the choices). `farseer pull --force` makes local match remote and `farseer push --force` makes remote match local; both also delete what the other side does not have, and both ask first. If the sync baseline drifts out of step, `farseer refresh <tenant>` rebuilds it.
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
111
129
|
## Debugging Tips
|
|
112
130
|
|
|
113
131
|
### Check existing dimension members
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "farseer-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.21.0",
|
|
4
4
|
"description": "CLI tool for syncing Farseer App scripts between local folder and Farseer instances",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"chalk": "^4.1.2",
|
|
56
56
|
"commander": "^11.1.0",
|
|
57
57
|
"diff": "^5.1.0",
|
|
58
|
-
"farseer-client": "npm:@farseerdev/farseer-client@1.
|
|
58
|
+
"farseer-client": "npm:@farseerdev/farseer-client@1.29.0",
|
|
59
59
|
"inquirer": "^8.2.6",
|
|
60
60
|
"js-yaml": "4.1.1",
|
|
61
61
|
"zod": "^3.25.0"
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: farseer-app-dev
|
|
3
|
+
description: >-
|
|
4
|
+
Use when the user asks to write, modify, or refactor a Farseer app (TypeScript using the `farseer-client` SDK) — import jobs, exports, transforms, reports. Inspects live model via explicit-tenant CLI reads first, follows the SDK working patterns (optimistic auth resolution — never prompt "OAuth or API key?", `error.text()` catch, `exportModel` excluding CELL, named `toRow` helper, validation-before-mutation), tests incrementally. Triggers (match by MEANING, in ANY language): "write a Farseer app", "modify the import script", "I need an app that…".
|
|
5
|
+
metadata:
|
|
6
|
+
version: "1"
|
|
7
|
+
domain: modeling
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Write or Modify a Farseer App
|
|
11
|
+
|
|
12
|
+
## When this skill applies
|
|
13
|
+
|
|
14
|
+
Use for any TypeScript app using the `farseer-client` SDK. A **new recurring import** is not an app: build it as a Simple Pipeline with [`farseer-build-pipeline`](../farseer-build-pipeline/SKILL.md); existing import apps are maintained here. Do not use for model changes or for one-off SQL / data investigations.
|
|
15
|
+
|
|
16
|
+
## Inputs to gather first
|
|
17
|
+
|
|
18
|
+
1. **Farseer CLI logged in** — confirm with `farseer whoami`
|
|
19
|
+
2. **Explicit-tenant reads work** — `farseer model --tables <tenant>` returns data (MCP `farseer_*` last resort only)
|
|
20
|
+
3. **Target tenant** — the tenant the user names (e.g. `acme-dev`)
|
|
21
|
+
4. **App purpose** — import / export / transform / report — and what data it touches
|
|
22
|
+
5. **SDK pin** — a new app installs `"farseer-client": "npm:@farseerdev/farseer-client@1.18.1"`. If an existing app's `package.json` points `farseer-client` at a `storage.googleapis.com` tarball or at `"*"`, fix that first: [the npm move](farseer-client-release-notes.md#an-existing-app-still-on-the-bucket-or-on---fixing-it)
|
|
23
|
+
6. **Reference docs:**
|
|
24
|
+
- [`working-patterns.md`](working-patterns.md) — canonical SDK patterns
|
|
25
|
+
- [`assignments.md`](assignments.md) — data-entry Assignments + labels (per-market rollouts, approver flows)
|
|
26
|
+
- [`farseer-client-api-guide.md`](farseer-client-api-guide.md) — full team guide
|
|
27
|
+
- [`app-authentication.md`](../farseer-authenticate-to-tenant/app-authentication.md) — auth model
|
|
28
|
+
- Existing apps in the same project for style
|
|
29
|
+
|
|
30
|
+
## Procedure
|
|
31
|
+
|
|
32
|
+
### 1. Inspect the current model (explicit-tenant CLI)
|
|
33
|
+
- `farseer model --variables <tenant>` — find target variables
|
|
34
|
+
- `farseer model --variable "<Var>" <tenant>` — get dimensions for each
|
|
35
|
+
- `farseer model --tables <tenant>` — confirm dimension structure + master data tables
|
|
36
|
+
- `farseer model --table "<Dim>" <tenant>` — one dim's members (incl. system dims)
|
|
37
|
+
|
|
38
|
+
### 2. Design the app
|
|
39
|
+
- What inputs does it read (file / variable export / external API)?
|
|
40
|
+
- What transformations apply?
|
|
41
|
+
- What outputs (variable import / file / data quality report)?
|
|
42
|
+
- Idempotency: what does re-running it do?
|
|
43
|
+
|
|
44
|
+
### 3. Follow SDK conventions
|
|
45
|
+
|
|
46
|
+
- **Auth — resolve it silently, in this order. Never ask the user "OAuth or API key?"**
|
|
47
|
+
|
|
48
|
+
1. **Environment first.** `TENANT_ID` set → the app runs under a runner (the tenant's job runner, `farseer run`, `farseer run-script`) → `new FarseerClient()` with **no arguments**; the SDK reads `TENANT_ID` / `FARSEER_URL` / the credential from the environment. Read the tenant from `TENANT_ID` — **no runner sets `FARSEER_TENANT`**.
|
|
49
|
+
2. **Not set → throw**, naming where you looked. No literal tenant default (not even `?? "<dev-tenant>"`), no prompt. On a laptop, run the app through `farseer run` or `farseer run-script`, which set that environment.
|
|
50
|
+
|
|
51
|
+
**Mismatch guard:** if two or more sources name a tenant (env `TENANT_ID`, a requested/confirm tenant, a config file's tenant) and they differ → throw before the first read or write; after constructing the client, print the tenant it is bound to, not the one the code meant.
|
|
52
|
+
|
|
53
|
+
The convention is **optimistic**: take the first source that resolves, transparently, and say nothing about it. Surface a problem **only if none resolves** or the guard fires. Presenting the choice to the user is a **regression** — the user has no basis on which to pick an auth mechanism, and being asked reads as the tooling not knowing its own conventions. Never hand-edit a `.env` for Farseer credentials, and never commit a key. Auth model: [`app-authentication.md`](../farseer-authenticate-to-tenant/app-authentication.md).
|
|
54
|
+
- **Catch block** — Farseer errors carry their message in a lazy `.text()`. Every `main().catch(...)` must call `await error.text()` when present.
|
|
55
|
+
- **Model export** — exclude `CELL` from whole-model exports: `types: ["DTAB", "DMEM", "VAR"] as any`. Including `CELL` fails with "Invalid string length".
|
|
56
|
+
- **Validation before mutation** — every write app first calls `exportModel()` and confirms target variables and dimensions exist with the expected shape. Fail loudly rather than silently create the wrong thing.
|
|
57
|
+
- **Import jobs** — column order in `columns` must match `addRow([...])` order. Use a named `toRow(record): unknown[]` helper. For a **recurring, audited data load** (locked `IMPORT_` targets, scope-encoding labels, idempotent revert-then-commit re-runs), don't hand-roll it here — use the [`farseer-author-import-job`](../farseer-author-import-job/SKILL.md) skill.
|
|
58
|
+
- **Dimension discrimination** — when one source column targets a specific dimension member, use `{ type: "VARIABLE", variableName, dimensionsNames: [{ tableName: "Dim", memberName: "Member" }] }`.
|
|
59
|
+
- **Name matching is case-sensitive** — including spaces, ` IN`/` OUT` suffixes, special characters.
|
|
60
|
+
- **Logging** — structured, step-based.
|
|
61
|
+
- **Dry-run** — support `DRY_RUN=true` to preview without committing. Honour it
|
|
62
|
+
only as the literal `true`/`false`; anything else stays in preview. Print the
|
|
63
|
+
resolved mode before the first write.
|
|
64
|
+
- **Manifest arguments are read BY NAME** from the `FARSEER_ARGS` JSON blob, with the 4-line reader in
|
|
65
|
+
[`deploying-a-farseer-app.md`](../farseer-author-import-job/deploying-a-farseer-app.md#1b-never-read-a-manifest-argument-by-position)
|
|
66
|
+
carried in the app's own files (a tenant app can import only `farseer-client`
|
|
67
|
+
and its own scripts, the ones `farseer app show` lists),
|
|
68
|
+
never off
|
|
69
|
+
`process.argv` by position; fall back only to env vars named after the
|
|
70
|
+
manifest's declared arguments, so the env-var fallback
|
|
71
|
+
cannot sweep credentials out of the environment (`run-script` itself passes
|
|
72
|
+
no arguments; local `farseer run` passes positional argv only — the full
|
|
73
|
+
contract is in [`deploying-a-farseer-app.md`](../farseer-author-import-job/deploying-a-farseer-app.md) "App arguments end to end"). `farseer run` drops an empty optional argument
|
|
74
|
+
from argv instead of passing `""`, so positional reads shift silently — a
|
|
75
|
+
2026-09-20 field report has an explicit `DRY_RUN=false` landing in a
|
|
76
|
+
threshold slot, the app previewing instead of writing, and no diagnostic
|
|
77
|
+
anywhere. Optional arguments go last; names are plain identifiers (no
|
|
78
|
+
spaces, parentheses or `=` — such a name is never passed, silently).
|
|
79
|
+
|
|
80
|
+
### 4. Write the code
|
|
81
|
+
|
|
82
|
+
**File layout**:
|
|
83
|
+
- `app.ts` — main code
|
|
84
|
+
- `README.md` — purpose, inputs, outputs, how to run
|
|
85
|
+
- Optional: helpers, types, tests
|
|
86
|
+
|
|
87
|
+
### 5. Test incrementally
|
|
88
|
+
After the user gives the go-ahead:
|
|
89
|
+
- 10 rows → 100 → 1000 → full dataset
|
|
90
|
+
- `DRY_RUN=true` first
|
|
91
|
+
- `npx tsx app.ts` to run
|
|
92
|
+
- **Definition of done for an app with arguments: one run from the platform
|
|
93
|
+
UI** after deploy, with non-default values (one containing a space), and
|
|
94
|
+
check the arguments it prints. Local runs (`run-script`, `farseer run`) and a
|
|
95
|
+
no-argument schedule never build `FARSEER_ARGS`, so they cannot catch an
|
|
96
|
+
argument-read bug — three production incidents passed them. Locally,
|
|
97
|
+
export the blob yourself — `FARSEER_ARGS='{"Year":"2026"}' farseer run
|
|
98
|
+
<tenant> "<App>"` reaches the script byte-identical (measured 2026-10-15); spell out
|
|
99
|
+
every argument (nothing fills defaults locally) and never send `""`.
|
|
100
|
+
- Entrypoint name unique on the tenant; after the first deploy, `farseer app
|
|
101
|
+
show` must mark it ▶ and list only the app's own scripts.
|
|
102
|
+
|
|
103
|
+
### 6. Push only after explicit confirmation
|
|
104
|
+
|
|
105
|
+
Push to a Farseer tenant only after the user explicitly confirms the push.
|
|
106
|
+
|
|
107
|
+
Mechanics worth flagging:
|
|
108
|
+
- `farseer push` is for tenant-hosted apps.
|
|
109
|
+
- Remote jobs require running the matching `upload*.ts` script — a local edit to `remoteJob*.ts` is not enough.
|
|
110
|
+
|
|
111
|
+
## Tools to invoke
|
|
112
|
+
|
|
113
|
+
- `Bash` for explicit-tenant reads: `farseer model --variables` / `--variable "<Var>"` / `--tables` / `--table "<Dim>"` (+ `<tenant>`), `farseer app list --details` (MCP `farseer_*` last resort only)
|
|
114
|
+
- `Read` on [`working-patterns.md`](working-patterns.md) (mandatory before writing)
|
|
115
|
+
- `Read` on existing apps in the project for style consistency
|
|
116
|
+
- `Bash` to run `npx tsx`, `farseer run`, `farseer push`
|
|
117
|
+
- Check `node_modules/farseer-client/dist/generated/apis/` for SDK methods you're not sure exist
|
|
118
|
+
|
|
119
|
+
## Expected output
|
|
120
|
+
|
|
121
|
+
- The app code (`app.ts` and helpers)
|
|
122
|
+
- README documenting purpose, inputs, outputs, run instructions
|
|
123
|
+
- Explicit request for user confirmation before any push / write operation
|
|
124
|
+
|
|
125
|
+
## Constraints
|
|
126
|
+
|
|
127
|
+
- Do **not** push or run destructive operations without explicit user confirmation.
|
|
128
|
+
- Do **not** guess SDK method names — check `node_modules/farseer-client/dist/generated/apis/` or the team guide.
|
|
129
|
+
- Do **not** commit hard-coded credentials or a hard-coded tenant. Auth resolves from the env vars — see the Auth bullet in step 3.
|
|
130
|
+
- Do **not** ask the user which auth path to use. Resolve it silently; only speak up if nothing resolves or the tenant mismatch guard fires.
|
|
131
|
+
- Do **not** include real data in `app.ts` for testing.
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
# Assignments via the Farseer Client SDK
|
|
2
|
+
|
|
3
|
+
Reference for creating **Assignments** programmatically — structured data-entry tasks that grant a user or user group entry access to a sheet, with an approver, a time interval, and a version scope. Typical use: a per-market / per-entity planning rollout where each market's sheets are duplicated, filtered, shared with the market's user group, and assigned for data entry (see §8).
|
|
4
|
+
|
|
5
|
+
Verified live against a dev tenant on 2026-07-21 with `farseer-client` 1.4.5 (surface identical in 1.8.4). Each claim below is tagged **[live]** (executed against the API) or **[types]** (read from the generated OpenAPI `.d.ts` — trustworthy for shape, not behaviour).
|
|
6
|
+
|
|
7
|
+
> **TL;DR — four things the OpenAPI types don't tell you:**
|
|
8
|
+
>
|
|
9
|
+
> 1. **`useRestrictions: false` is rejected** with a cryptic 400 (`"Share id N is not an assignment…"`) — on `create` *and* on a later `update`. If you don't want time restrictions, you still must send `useRestrictions: true` and simply make the interval as wide as the planning horizon. **[live]**
|
|
10
|
+
> 2. There is **no `Draft` status**. `AssignmentStatus` is `Shared | InProgress | Submitted | Approved | Archived`. Create with `Shared` (immediately visible to the assignee) — older internal notes mentioning `Draft` are wrong. **[live + types]**
|
|
11
|
+
> 3. `itemNodeId` is the **folder item** id of the sheet (from `folders.search` / `getFolderItem`), **not** the sheet id. The folder item's `reference` field holds the sheet id — don't confuse the two. **[live]**
|
|
12
|
+
> 4. A failed `create` is **not atomic** — the error `"Share id N is not an assignment"` means the server already created a plain `DATA_ENTRY` **share** (with `restrictions.active: false`) before the assignment-layer validation failed. The dangling share stays on the sheet; clean it up with `client.shares.deleteBatch({ ids: [N] })` — see §7. Prefer validating inputs up front over create-and-retry loops. **[live]**
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1. Concept
|
|
17
|
+
|
|
18
|
+
An Assignment defines:
|
|
19
|
+
|
|
20
|
+
| What | Field | Notes |
|
|
21
|
+
|---|---|---|
|
|
22
|
+
| Who enters data | `assignee` | `USER`, `USER_GROUP`, or `PUBLIC_KEY` (external link) |
|
|
23
|
+
| Who approves | `approver` | `USER` or `USER_GROUP` |
|
|
24
|
+
| Which sheet | `itemNodeId` | folder item id — see TL;DR #3 |
|
|
25
|
+
| Which period | `data.intervalStart/End` | `M/YYYY`, no leading zero — `'1/2026'`, `'12/2026'` |
|
|
26
|
+
| Which version(s) | `data.versionIds` | DMEM ids from the `Versions` dim table |
|
|
27
|
+
| Categorisation | `labelIds` | labels must exist first — §2 |
|
|
28
|
+
| Auto-expiry | `expirationTime` | JS `Date` |
|
|
29
|
+
| Visibility | `status` | create with `AssignmentStatus.Shared` |
|
|
30
|
+
|
|
31
|
+
The client accessors are `client.assignments` (`AssignmentsApi`) and `client.assignmentLabels` (`AssignmentLabelsApi`). Full method surface **[types]**:
|
|
32
|
+
|
|
33
|
+
- `assignments`: `create`, `createBatch`, `get`, `getByPublicKey`, `search`, `update`, `updateBatch`, `submit`, `approve`, `reject`, `archive`, `remove`, `removeBatch`, `getStats`, `regeneratePublicKeys`
|
|
34
|
+
- `assignmentLabels`: `create`, `createBatch`, `findAll`, `get`, `getBatch`, `update`, `updateBatch`, `remove`, `removeBatch`
|
|
35
|
+
|
|
36
|
+
## 2. Labels — create before you attach **[live]**
|
|
37
|
+
|
|
38
|
+
Labels are name+colour tags used to filter the Assignments view. They must exist before an assignment references them; `findAll` + create-if-missing keeps this idempotent:
|
|
39
|
+
|
|
40
|
+
```ts
|
|
41
|
+
const allLabels = await client.assignmentLabels.findAll();
|
|
42
|
+
let label = allLabels.find(l => l.name === 'North');
|
|
43
|
+
if (!label) {
|
|
44
|
+
label = await client.assignmentLabels.create({ name: 'North', hexColor: '#3A86FF' });
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
In a market rollout you typically want two label axes: one label per market ("North", "South", …) and one per sheet type ("Sales", "Promotion", "Market OPEX", …), and attach one of each to every assignment.
|
|
49
|
+
|
|
50
|
+
## 3. Resolving the prerequisite IDs **[live]**
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
// assignee group + approver user
|
|
54
|
+
const groups = await client.userGroups.list();
|
|
55
|
+
const group = groups.find(g => g.name === 'North');
|
|
56
|
+
|
|
57
|
+
const users = await client.users.list();
|
|
58
|
+
const approver = users.find(u => u.email === 'approver@company.com');
|
|
59
|
+
|
|
60
|
+
// version DMEM id
|
|
61
|
+
const version = await client.getDimensionMember('Versions', 'Plan');
|
|
62
|
+
|
|
63
|
+
// folder item of the target sheet — NOT the sheet id
|
|
64
|
+
const [sheetItem] = await client.folders.search({
|
|
65
|
+
name: 'Market Sales plan', // `name` is required on SearchFolderRequest
|
|
66
|
+
types: [farseer.FolderItemType.Sheet],
|
|
67
|
+
limit: 1,
|
|
68
|
+
});
|
|
69
|
+
// sheetItem.id → itemNodeId; sheetItem.reference → the sheet id (for sheets.get)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`folders.search` with `name: ''` lists all items of the given types — handy for discovery. `client.getFolderItem(folderId, name)` is the alternative when you already hold the parent folder.
|
|
73
|
+
|
|
74
|
+
## 4. Creating an assignment **[live]**
|
|
75
|
+
|
|
76
|
+
```ts
|
|
77
|
+
await client.assignments.create({
|
|
78
|
+
name: `North - Market Sales plan`,
|
|
79
|
+
assignee: { type: 'USER_GROUP', userGroupId: group.id }, // or { type: 'USER', userId }
|
|
80
|
+
approver: { type: 'USER', userId: approver.id }, // or { type: 'USER_GROUP', userGroupId }
|
|
81
|
+
itemNodeId: sheetItem.id,
|
|
82
|
+
data: {
|
|
83
|
+
type: 'SHEET',
|
|
84
|
+
createdCellCount: 0, // always 0 on creation
|
|
85
|
+
intervalStart: '1/2026', // M/YYYY, no leading zero
|
|
86
|
+
intervalEnd: '12/2026',
|
|
87
|
+
versionIds: [version.id],
|
|
88
|
+
useRestrictions: true, // MUST be true — see TL;DR #1
|
|
89
|
+
},
|
|
90
|
+
labelIds: [marketLabel.id, typeLabel.id], // [] is fine
|
|
91
|
+
expirationTime: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000),
|
|
92
|
+
status: farseer.AssignmentStatus.Shared,
|
|
93
|
+
});
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Both assignee shapes verified live (`USER` and `USER_GROUP`). Two representation quirks to expect in the response **[live]**:
|
|
97
|
+
|
|
98
|
+
- the echoed `assignee` on a `USER_GROUP` create can come back as `{ type: 'PUBLIC_KEY', publicKey: '<uuid>' }` — every assignment carries a public key; don't treat the echoed type as a validation of what you sent;
|
|
99
|
+
- `data.allowEntryOnPropertyColumns?: boolean` exists as an optional extra **[types]**.
|
|
100
|
+
|
|
101
|
+
For bulk rollouts use `createBatch(requests[])` — same request shape, array in/out **[types]**.
|
|
102
|
+
|
|
103
|
+
## 5. Reading back — `get` and `search` **[live for get; types for search shape]**
|
|
104
|
+
|
|
105
|
+
```ts
|
|
106
|
+
const a = await client.assignments.get(assignmentId);
|
|
107
|
+
|
|
108
|
+
const res = await client.assignments.search({
|
|
109
|
+
pageIndex: 0,
|
|
110
|
+
pageSize: 50,
|
|
111
|
+
groupBy: farseer.AssignmentGroupingOption.None, // None | Assignee | Approver | Status | Label
|
|
112
|
+
// optional filters:
|
|
113
|
+
nameSearch: 'North',
|
|
114
|
+
itemNodeIds: [sheetItem.id],
|
|
115
|
+
assignmentLabelIds: [label.id],
|
|
116
|
+
statuses: [farseer.AssignmentStatus.Shared],
|
|
117
|
+
});
|
|
118
|
+
const assignments = (res.groups ?? []).flatMap(g => g.items ?? []);
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
The grouped response nests results under `groups[].items` (not `groups[].assignments`); with `groupBy: None` there is a single group.
|
|
122
|
+
|
|
123
|
+
## 6. Update and lifecycle
|
|
124
|
+
|
|
125
|
+
`update` takes the **full** request back (no PATCH semantics) — fetch, spread, override **[live]**:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
const cur = await client.assignments.get(id);
|
|
129
|
+
await client.assignments.update(id, {
|
|
130
|
+
name: cur.name,
|
|
131
|
+
assignee: cur.assignee,
|
|
132
|
+
approver: cur.approver,
|
|
133
|
+
data: { ...cur.data, intervalEnd: '12/2027' },
|
|
134
|
+
labelIds: cur.labelIds,
|
|
135
|
+
expirationTime: cur.expirationTime,
|
|
136
|
+
status: cur.status,
|
|
137
|
+
});
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
Lifecycle verbs `submit(id)` → `reject(id)` / `approve(id)`, plus `archive(id)` and `remove(id)` **[types; remove live]**. Status flow: `Shared → InProgress → Submitted → Approved/rejected-back`, `Archived` for retirement.
|
|
141
|
+
|
|
142
|
+
⚠️ Caution: in our live probe, calling `submit` via an API key on a group-assigned assignment returned the same `"Share id N is not an assignment"` 400 — the submit/approve verbs appear to be meant for the assignee/approver session flow, not for admin scripts. Treat scripted submit/approve as unverified; test on a dev tenant before relying on it.
|
|
143
|
+
|
|
144
|
+
## 7. Cleanup / teardown **[live]**
|
|
145
|
+
|
|
146
|
+
`assignments.remove(id)` and `assignmentLabels.remove(id)` both hard-delete. Our teardown removed assignments first, then labels — that order is verified; removing a still-attached label was not tested.
|
|
147
|
+
|
|
148
|
+
**Dangling shares from failed creates** (TL;DR #4) don't show up in `assignments.search` — they're plain shares. Inspect and delete them via the shares API **[live]**:
|
|
149
|
+
|
|
150
|
+
```ts
|
|
151
|
+
const s = await client.shares.getSingle(shareId); // 404 once gone
|
|
152
|
+
// s: { id, active, type: 'DATA_ENTRY', itemNode: {...}, restrictions: { active: false, ... }, ... }
|
|
153
|
+
await client.shares.deleteBatch({ ids: [134, 136] }); // HTTP DELETE /shares/mutateBatch → 204
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
This also reveals what an Assignment *is* under the hood: a `DATA_ENTRY` share whose restrictions/status/expiration/metadata are all active — which is exactly why the server rejects `useRestrictions: false` (TL;DR #1) instead of storing a restriction-less assignment.
|
|
157
|
+
|
|
158
|
+
## 8. The full rollout pattern
|
|
159
|
+
|
|
160
|
+
The full pattern automates, per market:
|
|
161
|
+
|
|
162
|
+
1. Duplicate a template folder of planning sheets (`sheets.duplicate` into a new `folders.create`).
|
|
163
|
+
2. Rewrite each copy's row filters so it's pre-filtered to the market / company / market-type (`sheets.get` → mutate `rows.filters[].dimensionIds` → `sheets.update`).
|
|
164
|
+
3. Share the new folder hierarchy with the market's user group (`folders.shareHierarchy` + `userGroups.addPermissions` with `ENTITY.ITEM_NODE.VIEW` on ancestor folders so the group can navigate down).
|
|
165
|
+
4. Create one assignment per sheet: assignee = market group, approver = the owner of the plan, labels = market + sheet type, interval = the planning year.
|
|
166
|
+
|
|
167
|
+
Flow summary:
|
|
168
|
+
|
|
169
|
+
```text
|
|
170
|
+
assignmentLabels.findAll / create → labels exist
|
|
171
|
+
users.list / userGroups.list → approver + assignee ids
|
|
172
|
+
getDimensionMember('Versions', name) → version id
|
|
173
|
+
folders.search (type Sheet) → itemNodeId
|
|
174
|
+
assignments.create / createBatch → the assignment
|
|
175
|
+
assignments.search → verify / monitor
|
|
176
|
+
assignments.remove → teardown
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 9. Errors seen live
|
|
180
|
+
|
|
181
|
+
| Symptom | Cause |
|
|
182
|
+
|---|---|
|
|
183
|
+
| 400 `"Share id N is not an assignment - it needs to have status, expiration time, restrictions and assignment metadata"` on create/update | `useRestrictions: false` — send `true` (TL;DR #1). On create this also leaves a dangling share id N — remove it via `shares.deleteBatch` (§7) |
|
|
184
|
+
| Same 400 on `submit`/`approve` from a script | admin API-key session driving the assignee/approver flow — see §6 caution |
|
|
185
|
+
| Generic 400 on `folders.search` | missing `name` — it's required; use `''` to match all |
|