@datarails-ai/dr-cli 0.0.1-locked → 1.6.71

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.
Files changed (58) hide show
  1. package/README.md +608 -0
  2. package/dist/chunk-DWMCBGQH.js +242 -0
  3. package/dist/cli.js +64468 -0
  4. package/dist/kb-6UWI7Q32.js +21 -0
  5. package/dist/scopes-map.json +4412 -0
  6. package/dist/skills/connector-sandbox/SKILL.md +95 -0
  7. package/dist/skills/datarails-connect-workato/SKILL.md +140 -0
  8. package/dist/skills/datarails-connectors-onboard-connector/SKILL.md +813 -0
  9. package/dist/skills/dr-cli/SKILL.md +659 -0
  10. package/dist/skills/dr-cli/reference/admin.md +796 -0
  11. package/dist/skills/dr-cli/reference/budget-builder.md +151 -0
  12. package/dist/skills/dr-cli/reference/calc-vals.md +73 -0
  13. package/dist/skills/dr-cli/reference/calcmodels.md +76 -0
  14. package/dist/skills/dr-cli/reference/cash.md +61 -0
  15. package/dist/skills/dr-cli/reference/dashboards-widgets.md +85 -0
  16. package/dist/skills/dr-cli/reference/datamappers.md +150 -0
  17. package/dist/skills/dr-cli/reference/desk.md +472 -0
  18. package/dist/skills/dr-cli/reference/filebox-documents.md +373 -0
  19. package/dist/skills/dr-cli/reference/forecast.md +51 -0
  20. package/dist/skills/dr-cli/reference/integrations.md +57 -0
  21. package/dist/skills/dr-cli/reference/lookups.md +168 -0
  22. package/dist/skills/dr-cli/reference/metrics.md +512 -0
  23. package/dist/skills/dr-cli/reference/multi-product.md +180 -0
  24. package/dist/skills/dr-cli/reference/reconciliation-mec.md +76 -0
  25. package/dist/skills/dr-cli/reference/rh-config.md +84 -0
  26. package/dist/skills/dr-cli/reference/safety.md +143 -0
  27. package/dist/skills/dr-cli/reference/spend-control.md +206 -0
  28. package/dist/skills/dr-cli/reference/templates.md +163 -0
  29. package/dist/skills/dr-cli/reference/workflows.md +137 -0
  30. package/dist/skills/dr-error-enrichment/SKILL.md +80 -0
  31. package/dist/skills/dr-error-enrichment/reference/core.md +257 -0
  32. package/dist/skills/dr-error-enrichment/reference/groundcover.md +84 -0
  33. package/dist/skills/dr-error-enrichment/reference/jira-bugs.md +219 -0
  34. package/dist/skills/dr-error-enrichment/reference/safety-backup.md +122 -0
  35. package/dist/skills/dr-error-enrichment-author/SKILL.md +219 -0
  36. package/dist/skills/dr-error-enrichment-improve/SKILL.md +218 -0
  37. package/dist/skills/dr-error-enrichment-maintain/SKILL.md +237 -0
  38. package/dist/skills/dr-error-enrichment-reconcile/SKILL.md +167 -0
  39. package/dist/skills/dr-filebox-api-setup/SKILL.md +170 -0
  40. package/dist/skills/dr-switch-user/SKILL.md +395 -0
  41. package/dist/skills/dr-validate/SKILL.md +392 -0
  42. package/dist/skills/dr-validate/report-template.html +950 -0
  43. package/dist/skills/fx-conversion-matrix/SKILL.md +763 -0
  44. package/dist/skills/fx-conversion-matrix/scripts/_args.mjs +52 -0
  45. package/dist/skills/fx-conversion-matrix/scripts/_xlsx.mjs +241 -0
  46. package/dist/skills/fx-conversion-matrix/scripts/build-matrix.mjs +366 -0
  47. package/dist/skills/fx-conversion-matrix/scripts/gen-mappers.mjs +171 -0
  48. package/dist/skills/fx-conversion-matrix/scripts/rates-to-xlsx.mjs +172 -0
  49. package/dist/skills/fx-onboard/SKILL.md +325 -0
  50. package/dist/skills/mec-table-validation/SKILL.md +383 -0
  51. package/dist/skills/plugins.json +24 -0
  52. package/dist/skills/validate-workato-migration/SKILL.md +167 -0
  53. package/dist/skills/validate-workato-migration/reference/gotchas.md +16 -0
  54. package/dist/skills/validate-workato-migration/reference/staging-orgs.md +26 -0
  55. package/dist/skills/validate-workato-migration/scripts/compare_files.py +255 -0
  56. package/dist/zendeskKb-JPSHVOPH.js +243 -0
  57. package/package.json +56 -9
  58. package/scripts/postinstall.mjs +91 -0
@@ -0,0 +1,237 @@
1
+ ---
2
+ name: dr-error-enrichment-maintain
3
+ description: Recurring health pass over the integration error-enrichment rules — aggregate hits and feedback across servers, review and approve high-hit draft rules one at a time, and fix the rules users are voting down. Use when the user wants to know whether the readable-error messages are any good, or to clear the backlog of unapproved rules. Triggers - "approve enrichment rules", "high-hit rules with no message", "which rules are getting thumbs down", "review the draft enrichment rules", "error enrichment health check", "are our error messages any good".
4
+ ---
5
+
6
+ # dr-error-enrichment-maintain — maintenance pass
7
+
8
+ Use for the recurring "are our error messages any good" pass over rules that
9
+ already exist. For errors that have **no** rule at all, use
10
+ `dr-error-enrichment-improve`; for authoring a specific rule, use
11
+ `dr-error-enrichment-author`.
12
+
13
+ ## Read first
14
+
15
+ - [../dr-error-enrichment/reference/core.md](../dr-error-enrichment/reference/core.md)
16
+ — what rules are, permissions, the full command surface, how matching works.
17
+ - [../dr-error-enrichment/reference/safety-backup.md](../dr-error-enrichment/reference/safety-backup.md)
18
+ — target-server confirmation, backup-first, revert path, write gating, batch
19
+ etiquette. This flow ends in writes to prod; back up before the first one:
20
+
21
+ ```bash
22
+ dr error-enrichments export --all-servers --out /tmp/ee-backup/
23
+ ```
24
+
25
+ With a sweep, `--out` is a **directory** and you get one `<SERVER>.csv` per
26
+ server, with unreachable servers reported rather than silently skipped. Check
27
+ the list of files against the servers you are about to write to before the
28
+ first write.
29
+
30
+ ## 1. Read the fleet — two commands, two different jobs
31
+
32
+ Run both. They are not alternatives, and mixing up which one answers which
33
+ question is the classic failure of this pass.
34
+
35
+ ```bash
36
+ dr error-enrichments list --all-servers --json > /tmp/ee-fleet.json # the data you rank on
37
+ dr error-enrichments stats --all-servers --json # the per-server narrative
38
+ ```
39
+
40
+ **`list --all-servers --json` is the source for everything in step 2.** It
41
+ returns whole rules — including `re_pattern`, and `hits` / `thumbs_up` /
42
+ `thumbs_down` for **every** rule, not a top-N slice. It is the only source of the
43
+ roll-up key and of a complete thumbs-down ranking, and it is the same source
44
+ `dr-error-enrichment-reconcile` keys on. With a sweep the JSON is one bucket per
45
+ server (`{server: {rules|skipped|error}}`); read each server's `rules` array and
46
+ carry the server name with it.
47
+
48
+ **`stats --all-servers --json` is the per-server triage narrative** — what each
49
+ region looks like today, and what you quote in the step-5 report:
50
+
51
+ | Field | What it gives you |
52
+ |---|---|
53
+ | `needs_attention` | high `hits` **and** `approved: false` — the drafts users are hitting today |
54
+ | `top_hits` | busiest rules; the ones whose wording matters most |
55
+ | `most_helpful` | best `thumbs_up`; your style reference for new wording |
56
+ | `approved_pct` | share of the table that is production-reviewed |
57
+ | per-vendor rollups | which `integration_type` carries the backlog |
58
+
59
+ Do **not** try to build the fleet roll-up out of those digests. They are compact
60
+ summaries — `id, rank, integration_type, description, classification, approved,
61
+ hits, thumbs_up, thumbs_down` — with **no `re_pattern`**, so there is nothing to
62
+ key on across servers; and there is no thumbs-down digest at all (`most_helpful`
63
+ ranks by `thumbs_up`), so a badly-rated rule that is neither a high-hit draft nor
64
+ a top-hit rule never appears in any of them.
65
+
66
+ Servers with no stored login are skipped with a warning by both commands — log in
67
+ or say the fleet picture is partial before ranking work across regions. A
68
+ non-zero exit on either means a server errored: the picture is partial, so
69
+ investigate before ranking off it.
70
+
71
+ ## 2. Roll the per-server rules up into one fleet ranking
72
+
73
+ `stats` answers per server. Ranking off per-server lists directly works the same
74
+ rule three times, or works it last: a rule that is a 400-hit draft on US, 300 on
75
+ UK and 200 on CA is the single highest-value item on the fleet and appears
76
+ mid-list in each of the three reports.
77
+
78
+ So before touching anything, combine the `list` output from step 1:
79
+
80
+ 1. Key every rule by **`(integration_type, re_pattern)`** — the same key the
81
+ reconcile flow and `core.md` use. Never by `id`: ids are per-server database
82
+ ids and collide across regions by coincidence. Never by `description` either:
83
+ two rules can share one, and a rule reworded on a single region would split
84
+ into two keys.
85
+ 2. Sum `hits`, `thumbs_up`, and `thumbs_down` across servers for each key, and
86
+ keep the per-server breakdown next to the total — you need `(server, id)` to
87
+ write, and the split is what tells you whether a rule is approved in one
88
+ region and a draft in another.
89
+ 3. Rank on the **fleet totals**, and note which servers each key is present on.
90
+ Two rankings come out of this, and the sections below use one each: the
91
+ `approved: false` keys by fleet `hits` (§3), and every key by fleet
92
+ `thumbs_down` (§4).
93
+
94
+ Work the sections below off that fleet ranking, and carry the per-server id list
95
+ for each key so one review produces the write for every region that has the rule.
96
+ A key that is approved on some servers and a draft on others is a
97
+ `dr-error-enrichment-reconcile` job as much as an approval one — the approved
98
+ version is the review baseline.
99
+
100
+ ## 3. Approve the drafts — one at a time
101
+
102
+ An unapproved rule is a **draft that has not been reviewed for production**, and
103
+ a draft steals the hit while showing the user nothing (core.md, matching rule 4).
104
+ A high-hit draft is therefore an active user-facing gap, not a backlog item. This
105
+ is the highest-value work in this skill.
106
+
107
+ Work the fleet-ranked drafts from step 2 **highest fleet hits first, one rule per
108
+ cycle**:
109
+
110
+ 1. **Pull the whole rule**: `dr error-enrichments get <id> --server <S>`.
111
+ 2. **Show the user** its `re_pattern`, `description`, and `resolution_steps`, with
112
+ its `hits` and feedback — they are reviewing a production message, so they
113
+ need to read it, not a summary of it.
114
+ 3. **Pull two or three approved siblings** for the same vendor as the style
115
+ baseline:
116
+ `dr error-enrichments list --server <S> --integration-type <T> --approved true --json`
117
+ 4. **Compare the draft against them**, and say which way it falls:
118
+ - *Style* — same voice and length as the approved set; no stack traces, no
119
+ internal identifiers, no raw vendor error codes standing in for a message.
120
+ - *Content accuracy* — does the `description` actually describe what this
121
+ pattern matches (not a neighbouring error), and are the `resolution_steps`
122
+ something the customer or a CSM can genuinely act on?
123
+ 5. **Prove the pattern against a real error before approving it.** Style review
124
+ cannot catch a wrong pattern: `.*TIMEOUT.*` with the description "NetSuite
125
+ rejected your login credentials" reads perfectly and, once approved, shows
126
+ that message to every customer hitting a NetSuite timeout. So get a real
127
+ sample of the error this rule claims to explain — the rule's own `examples`
128
+ if it has any, otherwise the raw text off a tenant that hit it
129
+ (`integrations get <id> --json`, or
130
+ `integrations query-status --query-id <n> --json` for the failing query) — and
131
+ run it through the server's own matcher together with a neighbouring error
132
+ that must **not** match:
133
+
134
+ ```bash
135
+ dr error-enrichments test-regex --server <S> --pattern '<the draft pattern>' \
136
+ --sample '<real error this rule is for>' \
137
+ --sample '<neighbouring error that must not match>'
138
+ ```
139
+
140
+ The sample must match and the neighbour must not. If it matches the
141
+ neighbour, the pattern is too broad for the message and the fix is a
142
+ narrower pattern, not an approval.
143
+
144
+ **If no real sample can be obtained, say so and treat approval as blocked** —
145
+ report the rule as "needs a real sample" and move to the next one. Hits are
146
+ not evidence: they prove the pattern matched *something*, which is the very
147
+ thing in question.
148
+ 6. **State a verdict and the exact edits you would make** — not "looks fine".
149
+ 7. **Get the user's confirmation on that rule**, then either
150
+ - `dr error-enrichments update <id> --approved true --server <S>` when it is
151
+ already right, or
152
+ - fix the wording with `update` first and approve once the text is agreed.
153
+
154
+ **Never approve a list of drafts in one sweep because their hit counts are high.**
155
+ A hit count says the rule matches something; it says nothing about whether the
156
+ message is correct — and approving a wrong message publishes it to customers.
157
+
158
+ Once several drafts have each been reviewed, pattern-tested and confirmed
159
+ individually, flipping them together is fine and is what the batch form is for —
160
+ it is the closing step of this protocol, and this skill owns it:
161
+
162
+ ```bash
163
+ dr error-enrichments update 12 19 27 --approved true --server <S>
164
+ ```
165
+
166
+ One plan, one token, one server. The batch token binds the ids **and** the values
167
+ being written, so if the set changes after the plan — you drop a rule the user
168
+ had second thoughts about — re-run the plan step and relay the new plan. Read the
169
+ summary table afterwards rather than the exit code: per-item failures do not stop
170
+ the run. If only one rule survived the review, that line is a single-target
171
+ update — you get the one-line success message and, on failure, the server's own
172
+ error, with no table to read (core.md, *Execution semantics*).
173
+
174
+ ## 4. Fix the disliked rules
175
+
176
+ Rank on the fleet totals from step 2, by **both** `thumbs_down` and
177
+ `thumbs_down / (thumbs_up + thumbs_down)` — 2 down out of 2 is a worse message
178
+ than 3 down out of 90, and raw counts alone hide it behind the busy rules. The
179
+ ratio ranking is the reason step 2 is built off `list` and not the `stats`
180
+ digests: a 2-down-out-of-2 rule with modest traffic is in no digest at all. A rule
181
+ disliked in one region is usually the same text in the others, so fix it once and
182
+ carry the fix to every server that shares the key.
183
+
184
+ The two usual causes, and their fixes:
185
+
186
+ | Cause | Fix |
187
+ |---|---|
188
+ | Pattern matches too broadly, so one message answers several distinct errors | Split into narrower rules, the specific ones ranked above the general one |
189
+ | `resolution_steps` don't actually resolve it | Rewrite the steps with the user; check them against `most_helpful` rules for the same vendor |
190
+
191
+ Re-validate any pattern change server-side before writing it — including a sample
192
+ that must *not* match, so you can see what the narrowed rule gave up:
193
+
194
+ ```bash
195
+ dr error-enrichments test-regex --server <S> --pattern '.*NEEDLE.*' \
196
+ --sample '<real error that must match>' --sample '<neighbour that must not>'
197
+ ```
198
+
199
+ Splitting a rule keeps the original's counters only on the original row; a rule
200
+ created from a split starts at zero hits and zero feedback. Say so before you
201
+ propose deleting the parent.
202
+
203
+ ## 5. Report and hand off
204
+
205
+ Report against the fleet ranking from step 2, then per server: which drafts were
206
+ approved, which rules were reworded or split, and what is still open with the
207
+ reason it was left (usually "needs a real sample" or "user has not agreed the
208
+ wording"). A rule left unapproved because no sample could be found is a result to
209
+ state plainly, not a gap to gloss.
210
+
211
+ Then close the loop:
212
+
213
+ - A fix that should reach the other regions is a **reconcile** job — offer
214
+ `dr-error-enrichment-reconcile` rather than repeating the review per server.
215
+ Maintenance findings are the most common source of drift worth propagating.
216
+ - Errors with **no rule at all** are out of scope here — hand off to
217
+ `dr-error-enrichment-improve`, which mines groundcover for unmatched errors and
218
+ proposes new rules.
219
+
220
+ ## Pitfalls
221
+
222
+ | Pitfall | Fix |
223
+ |---|---|
224
+ | Bulk-approving `needs_attention` because the hits are high | Hits prove the pattern matches, not that the message is right — review one at a time |
225
+ | Approving a draft without ever testing its pattern | Style review passes a broad pattern with the wrong message — `test-regex` a real sample plus a neighbour that must not match |
226
+ | Approving anyway when no real sample can be found | Approval is blocked, not confirmed — report "needs a real sample" and move on |
227
+ | Ranking work off each server's `stats` list separately | Roll the servers up by `(integration_type, re_pattern)` and rank on fleet totals, or the biggest rule gets worked three times or last |
228
+ | Building the fleet roll-up out of the `stats` digests | They carry no `re_pattern` to key on and no thumbs-down list — roll up from `list --all-servers --json` |
229
+ | Keying the fleet roll-up by `id`, or by `description` | Ids are per-server and cross-server matches are coincidences; descriptions merge distinct rules and split reworded ones |
230
+ | Treating an unapproved rule as harmless until reviewed | It consumes the hit and shows the user nothing; it is the gap, not a placeholder |
231
+ | Judging the draft's wording in isolation | Compare against approved rules for the same `integration_type`; the fleet has a house voice |
232
+ | Ranking thumbs-down by raw count only | Also rank by the down ratio — a 2/2 rule is worse than a 3/90 one |
233
+ | Rewriting a pattern without `test-regex` | The server runs the real `re.match` + newline stripping; local reasoning is not evidence |
234
+ | Deleting a broadly-matching rule to replace it | Deletion drops its feedback history; re-point it with `update` where you can |
235
+ | Recomputing a *single server's* triage narrative from `list --json` | `stats` already returns `needs_attention`, `top_hits`, `most_helpful` per server — but the *fleet* roll-up is the other way round, and must come from `list --all-servers --json` |
236
+ | Fixing a rule on one server and stopping | Per-server drift is the problem the tooling exists to fix — offer the reconcile skill |
237
+ | Reaching for `import` to apply a batch of approvals | It wipes the table and zeroes every counter, destroying the feedback this pass runs on |
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: dr-error-enrichment-reconcile
3
+ description: Diff the integration error-enrichment rules across Datarails servers and reconcile the drift — collect every server's rules, key them by (integration_type, re_pattern), report what is missing, divergent, or server-only, and propagate the user's chosen version with batch create/update writes (never import). Use when rules have drifted between regions or a rule needs to reach the rest of the fleet. Triggers - "compare enrichment rules across servers", "reconcile the enrichment rules", "which servers are missing this rule", "why does UK show a different error message than US", "propagate this rule to the other servers", "are the error rules the same everywhere".
4
+ ---
5
+
6
+ # dr-error-enrichment-reconcile — diff and reconcile across servers
7
+
8
+ Rules live per server in each region's own database. There is no global table and
9
+ no cross-server sync, so the same rule can exist on US and be missing — or wrong —
10
+ on UK. This skill closes that gap.
11
+
12
+ ## Read first
13
+
14
+ - [../dr-error-enrichment/reference/core.md](../dr-error-enrichment/reference/core.md)
15
+ — what a rule is, permissions, the full command surface, how matching works.
16
+ - [../dr-error-enrichment/reference/safety-backup.md](../dr-error-enrichment/reference/safety-backup.md)
17
+ — target-server confirmation, backup-first, revert path, write gating, import
18
+ policy, batch-write etiquette.
19
+
20
+ Back up **every** reachable server before the first write, not just the target: a
21
+ reconcile session usually touches more than one, and the backup doubles as the
22
+ diff baseline. That is one command:
23
+
24
+ ```bash
25
+ dr error-enrichments export --all-servers --out /tmp/ee-backup/
26
+ ```
27
+
28
+ With a sweep, `--out` is a **directory** and each server lands as its own
29
+ `<SERVER>.csv`; add `--servers A,B` to narrow it and `--include-test` if test
30
+ servers are in scope. Servers that fail are reported, not swallowed — read that
31
+ list and confirm every server you intend to write to has a file before the first
32
+ write.
33
+
34
+ ## 1. Collect
35
+
36
+ ```bash
37
+ dr error-enrichments list --all-servers --json > /tmp/ee-all.json
38
+ ```
39
+
40
+ Add `--include-test` only if test servers are genuinely in scope.
41
+
42
+ Servers with no stored login are **skipped with a warning** — log in and re-run,
43
+ or get the user to accept the gap explicitly, before calling the diff complete. A
44
+ skipped server is invisible in every bucket below, so an unnoticed skip reads as
45
+ "already consistent".
46
+
47
+ A **non-zero exit** means a server errored. The data is partial; investigate
48
+ before diffing it.
49
+
50
+ ## 2. Key by `(integration_type, re_pattern)`
51
+
52
+ Never by `id`. Ids are per-server database ids — the same rule has a different id
53
+ on every server, and `id` collisions across servers are coincidences, not matches.
54
+
55
+ ## 3. Report three buckets
56
+
57
+ - **Missing** — present on some servers, absent on others. The default action is
58
+ to create it on the servers that lack it.
59
+ - **Divergent** — same key, differing `description`, `resolution_steps`, `rank`,
60
+ `classification`, or `approved`. The action is to patch the outliers to the
61
+ canonical version.
62
+ - **Server-only** — exists on exactly one server. Often a deliberate regional
63
+ rule; ask before propagating rather than assuming drift.
64
+
65
+ Include per-server `hits` in the report. The version living on the server with
66
+ real traffic is the battle-tested one, and an approved-on-one/draft-on-another
67
+ split is the most common divergence worth fixing — a draft steals the hit and
68
+ shows the user nothing, so those users currently see no explanation at all while
69
+ the other region does.
70
+
71
+ ## 4. The user picks the canonical version
72
+
73
+ Per rule, never auto-pick. "Newest `updated_at`" is not the same as "correct" —
74
+ the newest edit is as likely to be the one that broke the pattern. Show the
75
+ competing versions side by side with their hits and feedback and let the user
76
+ choose.
77
+
78
+ ## 5. Propagate with batch writes
79
+
80
+ Assemble the chosen versions into **batch writes, one server per run**, each
81
+ through its own confirm cycle: run without `--confirm-token`, relay the printed
82
+ plan (it lists every affected rule) to the user, then re-run with the token.
83
+
84
+ For rules that already exist on the target — an array of per-rule patches, each
85
+ carrying that server's own `id`:
86
+
87
+ ```bash
88
+ cat > /tmp/uk-patches.json <<'JSON'
89
+ [
90
+ {"id": 41, "description": "...", "resolution_steps": ["...", "..."], "approved": true},
91
+ {"id": 58, "rank": 3}
92
+ ]
93
+ JSON
94
+ dr error-enrichments update --payload-file /tmp/uk-patches.json --server UK
95
+ ```
96
+
97
+ For rules missing on the target — an array of full rule objects:
98
+
99
+ ```bash
100
+ cat > /tmp/uk-new.json <<'JSON'
101
+ [
102
+ {"integration_type": "...", "rank": 4, "re_pattern": ".*INVALID_LOGIN.*",
103
+ "description": "...", "resolution_steps": ["..."], "classification": "DataSource",
104
+ "approved": true}
105
+ ]
106
+ JSON
107
+ dr error-enrichments create --payload-file /tmp/uk-new.json --server UK
108
+ ```
109
+
110
+ Batch writes are sequential and a per-item failure does not abort the run: read
111
+ the summary table afterwards for exactly which rules landed (with their new ids
112
+ for `create`) and which failed, and retry only the failures. A zero exit means
113
+ every write in the run returned 2xx — nothing more. It does not mean the fleet
114
+ converged: a bulk `create` shifts sibling ranks on the target, and every
115
+ divergence you did not include in this run is still there. Convergence is proven
116
+ only by step 6.
117
+
118
+ Three mechanics to keep the plan honest:
119
+
120
+ - The batch confirm token binds the targets **and** the values being written, so
121
+ editing the patch file after the plan is printed invalidates the token. If the
122
+ user changes their mind about one rule, re-run the plan step and relay the new
123
+ plan — do not edit the file and reuse the printed token.
124
+ - Array entries are type-validated before anything is sent, and a repeated `id`
125
+ across entries is rejected; the error names the entry by its position in the
126
+ file (`entry 3: …`). Merge the two
127
+ patches for that rule into one entry rather than listing the id twice.
128
+ - `--rank` is rejected on a multi-id shared patch (`update 41 58 --rank 3`) —
129
+ ranks are per rule. Set a rank one rule at a time, or give each entry its own
130
+ `rank` in the array payload as above.
131
+
132
+ **`import` is never the reconcile mechanism.** It is wipe-and-replace: it would
133
+ delete every rule on that server — including its server-only rules, which are the
134
+ one bucket you explicitly decided not to touch — and zero `hits`, `thumbs_up`,
135
+ and `thumbs_down` on everything it recreates, destroying the exact traffic
136
+ evidence you used in step 4 to pick a winner. It also reassigns every id, which
137
+ invalidates the patch files you just built. Reconcile is many `update`s and
138
+ `create`s, and nothing else.
139
+
140
+ If the user asks for `import` by name anyway, follow the import policy in
141
+ safety-backup.md: state the analytics loss and the id reassignment, get explicit
142
+ confirmation, and only then run it.
143
+
144
+ ## 6. Prove convergence
145
+
146
+ Re-run step 1 and re-diff. Report per server what changed, what failed, and which
147
+ divergences the user deliberately left in place — a knowingly-kept regional
148
+ difference is a result, not an omission.
149
+
150
+ ## Pitfalls
151
+
152
+ | Mistake | Fix |
153
+ |---|---|
154
+ | Matching rules across servers by `id` | Key on `(integration_type, re_pattern)` |
155
+ | Treating a skipped (not-logged-in) server as consistent | It appears in no bucket — log in or record the gap before reporting |
156
+ | Diffing after a non-zero exit from `list --all-servers` | A server errored; the data is partial |
157
+ | Using `import` to push one server's table onto another | Wipes server-only rules and zeroes all counters — batch `create`/`update` instead |
158
+ | Auto-picking the newest `updated_at` as canonical | Newest is not correct; the user chooses per rule |
159
+ | Propagating a server-only rule without asking | It is often a deliberate regional rule |
160
+ | Reusing the source server's `id` in a target patch file | Patch ids must be the **target** server's ids |
161
+ | Assuming a batch write is all-or-nothing | Per-item failures are recorded and the run continues — read the summary table |
162
+ | Reading a zero exit as "the fleet converged" | It only means every write returned 2xx — re-collect and re-diff |
163
+ | Editing the patch file and reusing the printed token | The batch token binds the values too — re-plan and relay the new plan |
164
+ | Listing the same target `id` in two array entries | Rejected by index — merge them into one entry |
165
+ | Hand-rolling a shell loop to back up each server | `export --all-servers --out <dir>` reports failures instead of swallowing them |
166
+ | One `--confirm-token` cycle for several servers | Writes are one server per run, each with its own plan and token |
167
+ | Declaring convergence from the write output alone | Re-run the collect step and re-diff |
@@ -0,0 +1,170 @@
1
+ ---
2
+ name: dr-filebox-api-setup
3
+ description: Enable "Upload via API" (support_api) on one or more Datarails fileboxes and configure a Workato/WorkatoBased data-query connection with object type and date range. Use when the user wants to set up API upload access and a data connection on a filebox or a set of fileboxes in a folder. Triggers - "turn on upload via API", "enable API upload", "set the data connection", "set up the data query", "configure the filebox API settings", "set start date and end date on the filebox".
4
+ ---
5
+
6
+ # dr-filebox-api-setup — Enable API upload + configure data-query on fileboxes
7
+
8
+ ## What this skill does
9
+
10
+ Automates the two-step filebox setup that enables external systems (e.g. Workato, Oracle) to push data into Datarails fileboxes via API:
11
+
12
+ 1. **Enable Upload via API** — turns on `support_api` on each target filebox (`dr documents support-api set <id> --on`). Returns the filebox UUID, which is the identifier used in API upload calls.
13
+ 2. **Set the data-query** — configures the Workato/WorkatoBased connection, object type, and date range on each filebox (`dr filebox data-query set <id> --payload-file`).
14
+
15
+ Both steps are run for every target filebox. Fileboxes can be specified directly by ID/name or resolved from a parent folder.
16
+
17
+ ---
18
+
19
+ ## Inputs to gather before running
20
+
21
+ Before issuing any commands, confirm the following with the user if not already clear from context:
22
+
23
+ | Input | How to resolve |
24
+ |---|---|
25
+ | **Target fileboxes** | IDs/names, or a folder name to expand — run `dr filebox list --server <S>` and filter by parent folder ID |
26
+ | **Server** | Ask if not obvious from context (`US`, `US2`, `UK`, `CA`, `EU`, `DEV`, `DEV-1`, `TEST`, `TEST-1`, `TEST-2`, `TEST-3`, `TEST-4`, `TEST-5`, `TEST-6`, `TEST-7`, `DEMO`) |
27
+ | **Connection** | Run `dr integrations list --server <S>` and show the WorkatoBased options; ask the user to pick |
28
+ | **Object type** | Ask — commonly `table`; surface the value from a reference filebox if one exists |
29
+ | **Start date / End date** | Ask — commonly "start of month" / "end of month", which maps to `{{date_tag|somonth}}` / `{{date_tag|eomonth}}` |
30
+ | **Reference filebox** | Optional — if another filebox in the same folder is already configured correctly, copy its data-query shape instead of building from scratch |
31
+
32
+ ---
33
+
34
+ ## Step 1 — Resolve target fileboxes
35
+
36
+ If the user names a folder (e.g. "Account Analysis"), find its filebox ID first:
37
+
38
+ ```bash
39
+ dr filebox list --json --server <S> > fb_list.json
40
+ ```
41
+
42
+ Then filter in PowerShell to find the folder and its children:
43
+
44
+ ```powershell
45
+ $data = Get-Content fb_list.json | ConvertFrom-Json
46
+ # Find the folder ID
47
+ $folder = $data | Where-Object { $_.name -like "*Account Analysis*" -and $_.is_folder -eq $true }
48
+ # List children
49
+ $data | Where-Object { $_.parent -eq $folder.id } | Select-Object id, name, is_folder, scenario
50
+ ```
51
+
52
+ Confirm the list with the user before proceeding.
53
+
54
+ ---
55
+
56
+ ## Step 2 — Check for a reference filebox
57
+
58
+ Before building the payload manually, check whether any filebox in the same folder already has a correctly configured data-query — this is the most reliable source of truth for the payload shape:
59
+
60
+ ```bash
61
+ dr filebox data-query get <candidate_id> --json --server <S>
62
+ ```
63
+
64
+ If a valid reference is found, copy its `connection`, `config`, `sync_only_changes`, `sync_interval`, and `sync_offset_array` exactly. Only substitute fields the user explicitly wants to change.
65
+
66
+ If no reference exists, build the payload from the gathered inputs (see Step 4).
67
+
68
+ ---
69
+
70
+ ## Step 3 — Enable Upload via API on all target fileboxes
71
+
72
+ Run in parallel for efficiency. This is a prod write — confirm with the user before running on `US`, `US2`, `UK`, `CA`, `EU`, `DEMO`.
73
+
74
+ ```bash
75
+ dr documents support-api set <id1> --on --server <S> &
76
+ dr documents support-api set <id2> --on --server <S> &
77
+ # … one per filebox
78
+ ```
79
+
80
+ After enabling, collect the UUID for each filebox from the saved `fb_list.json`:
81
+
82
+ ```powershell
83
+ $ids = @(<id1>, <id2>, ...)
84
+ $data | Where-Object { $ids -contains $_.id } | Select-Object id, name, uuid
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Step 4 — Build the data-query payload
90
+
91
+ Write the payload to a temp file. The canonical shape for a WorkatoBased connection with start-of-month / end-of-month date range:
92
+
93
+ ```json
94
+ {
95
+ "connection": <integration_id>,
96
+ "config": {
97
+ "query": {
98
+ "startDate": "{{date_tag|somonth}}",
99
+ "endDate": "{{date_tag|eomonth}}"
100
+ },
101
+ "objectType": "table",
102
+ "type": null
103
+ },
104
+ "sync_only_changes": true,
105
+ "sync_interval": "",
106
+ "sync_offset_array": [0, -1]
107
+ }
108
+ ```
109
+
110
+ **Date range tokens:**
111
+
112
+ | UI label | Token |
113
+ |---|---|
114
+ | Start of month | `{{date_tag|somonth}}` |
115
+ | End of month | `{{date_tag|eomonth}}` |
116
+
117
+ **`objectType`** — use `"table"` unless the user specifies otherwise.
118
+
119
+ Save to a temp file (avoid spaces in the path on Windows):
120
+
121
+ ```powershell
122
+ $payload | ConvertTo-Json -Depth 5 | Out-File -Encoding utf8 "C:\Users\<user>\dq_payload.json"
123
+ ```
124
+
125
+ ---
126
+
127
+ ## Step 5 — Set the data-query on all target fileboxes
128
+
129
+ Run in parallel. Quote the file path to handle spaces:
130
+
131
+ ```bash
132
+ dr filebox data-query set <id1> --payload-file "C:\path\to\dq_payload.json" --server <S> &
133
+ dr filebox data-query set <id2> --payload-file "C:\path\to\dq_payload.json" --server <S> &
134
+ # … one per filebox
135
+ ```
136
+
137
+ Each success line prints: `Saved data-query #<N> (connection=<id>) on filebox <id>.`
138
+
139
+ ---
140
+
141
+ ## Step 6 — Return results
142
+
143
+ Present a summary table of filebox name → UUID for all configured fileboxes:
144
+
145
+ | Filebox Name | UUID |
146
+ |---|---|
147
+ | Example Filebox | `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` |
148
+
149
+ Offer to export the table as a CSV if the user wants it.
150
+
151
+ ---
152
+
153
+ ## Guard rails
154
+
155
+ - **Prod confirmation required.** `support_api` and `data-query set` are writes. On `US`, `US2`, `UK`, `CA`, `EU`, `DEMO`, confirm in-chat before running.
156
+ - **Never read out tokens or JWTs.** The UUID returned is not a secret, but session tokens are — do not surface them.
157
+ - **Always verify the integration ID from `dr integrations list`** — do not guess or reuse IDs from a prior session without confirming they match the current tenant.
158
+ - **Always quote file paths** in `--payload-file` on Windows to handle spaces in directory names.
159
+ - **Use `--json` when parsing** — never parse the human-readable table output.
160
+
161
+ ---
162
+
163
+ ## Common mistakes
164
+
165
+ | Mistake | Fix |
166
+ |---|---|
167
+ | Unquoted path with spaces in `--payload-file` | Always quote: `--payload-file "C:\path with spaces\file.json"` |
168
+ | Reusing an integration ID from a different tenant | Run `dr integrations list --server <S>` on the target tenant to confirm |
169
+ | Setting data-query before `support_api` | Either order works — the two are independent — but do `support_api` first so you can surface the UUID earlier |
170
+ | Forgetting to check for a reference filebox | A sibling filebox with the right config is the most reliable payload source — always check before building manually |