qube_rails 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +216 -0
  3. data/README.md +242 -69
  4. data/app/assets/javascripts/qube_rails/question.js +425 -38
  5. data/app/assets/stylesheets/qube_rails.css +1201 -907
  6. data/app/controllers/qube_rails/connections_controller.rb +23 -6
  7. data/app/controllers/qube_rails/questions_controller.rb +39 -7
  8. data/app/controllers/qube_rails/runs_controller.rb +4 -3
  9. data/app/models/qube_rails/connection.rb +22 -2
  10. data/app/models/qube_rails/run.rb +28 -10
  11. data/app/views/qube_rails/_error.html.erb +2 -2
  12. data/app/views/qube_rails/_question.html.erb +4 -1
  13. data/app/views/qube_rails/question/_choice.html.erb +36 -11
  14. data/app/views/qube_rails/question/_exit_button.html.erb +8 -0
  15. data/app/views/qube_rails/question/_field.html.erb +4 -3
  16. data/app/views/qube_rails/question/_footer.html.erb +19 -5
  17. data/app/views/qube_rails/question/_pick.html.erb +8 -3
  18. data/app/views/qube_rails/question/_picks.html.erb +4 -2
  19. data/app/views/qube_rails/question/_question.html.erb +22 -7
  20. data/app/views/qube_rails/question/_submit.html.erb +9 -0
  21. data/app/views/qube_rails/question/fields/_boolean.html.erb +2 -2
  22. data/app/views/qube_rails/question/fields/_number.html.erb +2 -2
  23. data/app/views/qube_rails/question/fields/_rows.html.erb +17 -4
  24. data/app/views/qube_rails/question/fields/_search.html.erb +3 -1
  25. data/app/views/qube_rails/question/fields/_select.html.erb +6 -5
  26. data/app/views/qube_rails/question/fields/_text.html.erb +2 -2
  27. data/app/views/qube_rails/question/rows/_segmented.html.erb +3 -1
  28. data/app/views/qube_rails/run_status/_detail.html.erb +5 -1
  29. data/app/views/qube_rails/run_status/_status.html.erb +5 -2
  30. data/config/locales/en.yml +23 -1
  31. data/db/migrate/20261031000000_add_qube_connection_type_and_run_headline.rb +12 -0
  32. data/lib/generators/qube_rails/templates/initializer.rb.tt +12 -4
  33. data/lib/qube_rails/configuration.rb +3 -2
  34. data/lib/qube_rails/connection_events.rb +3 -0
  35. data/lib/qube_rails/operation.rb +115 -32
  36. data/lib/qube_rails/question_view.rb +235 -29
  37. data/lib/qube_rails/rows_view.rb +18 -5
  38. data/lib/qube_rails/run_status_view.rb +12 -7
  39. data/lib/qube_rails/storyboard/ask_about_add.json +8 -10
  40. data/lib/qube_rails/storyboard/choose.json +8 -5
  41. data/lib/qube_rails/storyboard/enum_select.json +4 -3
  42. data/lib/qube_rails/storyboard/missing_record.json +10 -13
  43. data/lib/qube_rails/storyboard/name_clash.json +10 -18
  44. data/lib/qube_rails/storyboard/near_match.json +12 -14
  45. data/lib/qube_rails/storyboard/number_boolean.json +4 -3
  46. data/lib/qube_rails/storyboard/record_search.json +14 -15
  47. data/lib/qube_rails/storyboard/refusal.json +10 -18
  48. data/lib/qube_rails/storyboard/rows.json +11 -14
  49. data/lib/qube_rails/storyboard.rb +8 -3
  50. data/lib/qube_rails/sync_status.rb +4 -2
  51. data/lib/qube_rails/version.rb +1 -1
  52. data/lib/qube_rails/view_helpers.rb +4 -2
  53. data/lib/qube_rails.rb +2 -2
  54. metadata +5 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: deb2eb2f7213591f12c48f2ecbf23e1eece273630d9b716b233c338fa4572a37
4
- data.tar.gz: eeacddeebc0117e15dd7096d881d9a818eade8485a2d12f0e6565e0a5e015e56
3
+ metadata.gz: 6e7280e11681c6f111e93886324700bde6134f5063e67644184d672014b4bce1
4
+ data.tar.gz: bfb8f73cde8dc4d6d2a9afe5a0023cbec88036542c6146c7722102b0c907e848
5
5
  SHA512:
6
- metadata.gz: 1989097d43b0a33d92b8adf5059d50d360250e5f967ca5bf60aa1e62b7703131fe95d2a21a803a78a1861d71ccb26b7cd5eda8cc8abaff384c70249091d00047
7
- data.tar.gz: b8bc4a5015c9e93dd4433222aedbd842469691ed69c2bcac393d6743156ed792ec7b41fa9cdae571f1b635f48ccb84792264de18846bf5ea2b3b58f4a612eae9
6
+ metadata.gz: f10897c069a8b2dae2cf7ee4eace60fcc5e090db00db39721d0510e4e12dffb7335d35c8e841248ce49cb1835ebd1413bd0bd30aff51f529a2ac3255a169d063
7
+ data.tar.gz: 40338c434f448682fb17b758290b530d17b83035c8c559611e1a7dc4a69140b8b910f35914fb2dd5cf7def7246dfa19469c737cbc0c1a88bf4c29ef440228084
data/CHANGELOG.md CHANGED
@@ -1,5 +1,221 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.1 (2026-11-17)
4
+
5
+ Connections keep their type, so workflows aren't started on standard ones, and run webhooks are
6
+ read as QuBe Sync now sends them. Run `bin/rails qube_rails:install:migrations` and
7
+ `bin/rails db:migrate`.
8
+
9
+ ### Added
10
+
11
+ **Connections and onboarding**
12
+ - `qube_connections.connection_type` (`realtime`, `standard` or `simulated`), set when Connect
13
+ makes the connection and kept up to date by the connection's events; `Connection#standard?` and
14
+ `Connection#refresh_type!` (reads it from QuBe Sync after an upgrade in the dashboard).
15
+ - Connect (`POST quickbooks/connections`) takes `type=realtime` or `type=standard`, else
16
+ `config.connection_type`; any other type answers 422. It sends back through setup only a
17
+ never-connected connection of that type.
18
+
19
+ **Starting workflows**
20
+ - `Operation.start` on a standard connection raises `QubeRails::RealtimeRequired` before writing a
21
+ run or calling QuBe Sync.
22
+ - A start QuBe Sync refuses with 422 `realtime_required` keeps its run, as state
23
+ `realtime_required` with `error` `{code, detail}`, rather than failing it. The run status shows
24
+ the detail and the "Try sending again" button, and `run.retry_start!` (or starting again) sends
25
+ it with the same Idempotency-Key once the connection is upgraded: QuBe Sync stores nothing for
26
+ that refusal.
27
+
28
+ **Questions**
29
+ - A rows field (`add_transaction`'s `ask_missing`) of two records or more asks one record at a
30
+ time: a step count ("1 of 3", `aria-live`), Back and Next in the form's button row (see
31
+ Changed), the question's submit on the last record only, "Set all to:" hidden. Every record
32
+ stays in the form, so the answer is still one POST with every row. It needs the script (see
33
+ Changed). New keys `question.step`, `question.back`, `question.next`; the rows partial carries
34
+ them and the `button` / `button_secondary` classes as `data-qube-*` attributes.
35
+ - The question screen has no horizontal rules: its sections (the details, the choices, the footer,
36
+ each record of a rows field, the "or" between choices) are set apart by space alone.
37
+ - Choices are weighed by the `role` QuBe Sync now sends with each (`pick`, `search`, `decline`,
38
+ `cancel`, `answer`): the offered records as option rows with no heading of their own (the
39
+ question's message says what they are), the first one's "Use this one" the screen's primary button and the
40
+ rest secondary; a search after them, a branch at a time (see below), or a section of its own
41
+ when nothing is offered; decline in the footer; cancel at the start of the footer row, as a ghost. An answer shows by its shape, as before. Without roles (an
42
+ older QuBe Sync), choices show by their shape as before. `ChoiceView#role` and `#cancel?`,
43
+ `QuestionView#roles?`, `#matches?` and `#ui_text` (the one lookup for the engine's new words,
44
+ "Possible matches" and the step line; `RowsView#ui_text` defers to it); forms carry
45
+ `data-qube-choice-role`. New CSS only for cancel's place in the footer row; the heading and
46
+ buttons use classes the stylesheet already styles.
47
+ - Offered records with a search (a chain, `QuestionView#chain?`) show a branch at a time. The
48
+ offered records come first, the footer row holding cancel and "Not this one" / "None of these"
49
+ (new key `question.none_of_these`, `data-qube-branch="search"`); that swaps them for the search,
50
+ with "← Back to the possible match" / "← Back to the %{count} possible matches" above it (new key
51
+ `question.back_to_offered`, `.qube-branch-back`, `data-qube-branch="offered"`), its button row
52
+ holding cancel, the decline and its submit (the footer's forms, through `form=`). Moving to the
53
+ search focuses its box, Back the first record, and what was typed or picked stays. A refusal of
54
+ the search's answer starts on the search. Each part carries `data-qube-branch-part` ("offered" or
55
+ "search"), `hidden` when not on show; `QuestionView#branch`, `#branch_part`, `#shown_part?`,
56
+ `#offered_count`, `#joined_exits`, `#divided?`. Without the script a chain shows the records and
57
+ a footer of cancel and the decline, as forms that post. Other questions are unchanged.
58
+ - Motion for a chain: a branch the person moves to comes in from its side over 200 ms (the
59
+ search from the right, the records from the left; the script sets `data-qube-branch-moved`, so
60
+ a page load is still), and "Use this one" fades in as a match is picked. With reduced motion
61
+ both only fade.
62
+ - A search's button row that also holds the decline puts its end on top and cancel under it in a
63
+ question narrower than 44rem, before and after a pick, so "Use this one" arriving moves nothing.
64
+ - A search's submit ("Use this one") is hidden until a match is picked (`ChoiceView#waits_for_pick?`),
65
+ then shows as the primary button; after a search of two characters or more that finds nothing,
66
+ the decline is the primary button until a pick or a search that finds matches. Until either,
67
+ nothing in that row is primary.
68
+ - `question.step` reads "%{position} of %{count}" ("1 of 2"): the record's block already names its
69
+ kind. A `%{name}` in your own wording still works.
70
+ - The storyboard's questions carry roles and QuBe Sync's current wording ("It's not in QuickBooks",
71
+ "Not listed? Search QuickBooks", "Don't add the invoice").
72
+
73
+ **Run status**
74
+ - `run.headline`, every event's sentence for a person (`qube_runs.headline`), shown for an ended
75
+ run whose reason doesn't already say it (`.qube-run-headline`).
76
+ - `Run#with_errors?`: an outcome such as `push_records`' `pushed_with_errors` reads "Done, but some
77
+ didn't go through" (`status.done_with_errors`) and adds `.qube-run-with-errors`.
78
+
79
+ ### Changed
80
+
81
+ **The question's layout: one button row**
82
+ - A form choice ends in one button row (`.qube-choice-actions`, new `ui_classes` piece
83
+ `choice_actions`): cancel at the start, as a ghost; at the end, the right edge of the fields
84
+ above, the submit with any other exit beside it. When a question has one form, no picks and no
85
+ exit with a description, its exits' buttons join that row and submit their own (hidden, empty)
86
+ forms through the `form` attribute, so it works without the script; new partials
87
+ `question/_submit` and `question/_exit_button`. Otherwise the exits have their own row, laid out
88
+ the same way: cancel at the start, decline and the like at the end, or stacked with cancel last
89
+ when they have descriptions. Cancel is now always at the start (it was at the far right, or the
90
+ left when it had a description).
91
+ - A rows field in steps puts its step count ("2 of 3"), Back and Next in that row, before the
92
+ submit, instead of a step line above the records and a row of its own; the row reads cancel …
93
+ 2 of 3, Back, Next (or the submit on the last record).
94
+ - The question card has sections: a hairline under what it's about, another above the way out
95
+ (the exits' row, or a lone form's button row). A card that is one form is as wide as the form;
96
+ a chain's search keeps the width its offered records had.
97
+ - Beside full-width picks (a near match, a name clash) a form takes the full width too, so its
98
+ submit shares the picks' and exits' right edge.
99
+ - A form's fields and button row share one column (`--qube-form-width`, 36rem; a rows field takes
100
+ the whole width), so the submit lines up with the fields' right edge.
101
+ - On a narrow question (a container under 30rem) the row's end comes first, its buttons filling
102
+ the line, and cancel goes under it.
103
+ - A choice promoted to an option row (name clash's "Use the existing record") ends in a secondary
104
+ "Use this one" button, as an offered record's does, not a link.
105
+ - The question card keeps a gap under the record's status when it follows it.
106
+
107
+ **Decisions from the review**
108
+ - No submit or Next is disabled any more: the browser's own validation (required fields, a search's
109
+ "Pick one of the matches.") says what's missing and focuses it, and Next on an incomplete record
110
+ does the same.
111
+ - A field that isn't required says "(optional)" after its label (`question.optional`); a checkbox
112
+ doesn't.
113
+ - After a cancel is posted the status reads "Cancelling…" (`status.cancelling`, run state
114
+ `cancelling`, the engine's own) until the run's next event; a quiet one offers redelivery as a
115
+ running one does.
116
+ - A rows field needs the script: it and its submit are hidden until the script runs, and a
117
+ `<noscript>` line says answering needs JavaScript (`question.needs_script`). Cancel still works.
118
+ - A ghost button with no `button_ghost` piece takes no host class (it took `button_secondary`'s), so
119
+ cancel and "← Back to the possible match" keep the engine's quiet look.
120
+
121
+ **Styling and Tailwind**
122
+ - The stylesheet sits in the `components` cascade layer, after declaring `@layer theme, base,
123
+ components, utilities;`. Unlayered, the engine's rules beat every Tailwind v4 utility class
124
+ (`ui_classes` couldn't change a padding or a background); now utilities and any unlayered app CSS
125
+ win, and Tailwind v4's preflight (`@layer base`) still doesn't strip the engine's look. Tailwind
126
+ v3's preflight is unlayered and does reset borders, button backgrounds and paddings: give those
127
+ pieces classes, or use v4 (README, "Styling").
128
+ - The generated initializer, `Configuration#ui_classes=` and the README show Tailwind classes first;
129
+ Bootstrap is a second, shorter example (with `form-check-input mt-0`).
130
+ - `qube_rails_assets` adds `data-turbo-track="reload"` to both tags: under Turbo Drive a page kept
131
+ the old script after an update (and the script's once-per-page guard skipped the new one), which
132
+ is how a browser could still show Back and the submit on two rows after that fix.
133
+
134
+
135
+ - A failed run's `error` is QuBe Sync's `{code, type, message, quickbooks_message, hint}`:
136
+ `reason_text` is its message and `error_detail` its hint. An error stored by 0.2.0 (a sentence,
137
+ or code, message and detail) still reads.
138
+ - A run's `cancel_url` is cleared when it ends; `links.decisions` and `links.search` may be absent.
139
+ - A `rows` field's boolean columns answer `true` or `false`, not the text `"true"`.
140
+ - The storyboard's sample prompts drop `options`, which run webhooks no longer carry.
141
+
142
+ ### Fixed
143
+
144
+ - A start keeps the run's `run_url`: it's read from the start answer's `links.self` (a
145
+ `WorkflowRun`'s), falling back to `links.run` (a webhook's). 0.2.0 read only `run`, so it stayed
146
+ nil.
147
+ - A start QuBe Sync refuses with a 4xx (other than 409 and `realtime_required`) keeps why on the
148
+ failed run: `error` is `{code: "refused", message, detail}`, the message a sentence from the
149
+ answer's body (field errors joined, or its sentence) and the detail its status. The run status
150
+ shows it in place of "it couldn't be sent".
151
+ - A search's picked match shows as the selection: a check in the box and an accent edge
152
+ (`data-qube-picked`, set by the script), cleared as soon as the text changes.
153
+ - `link_references` takes add_transaction's new shapes (QuBe Sync's docs/workflow-record-events.md): a
154
+ `records` notification (`data.records`, each with `paths`, `action`, `kind`, `sent` and `record`,
155
+ linked as each pass settles them, with the record's name and edit sequence) or an ending's
156
+ `output.refs` (`{path => {list_id, type}}`). The block still gets the path and an entry
157
+ (`list_id`, `type`, and from a notification `kind`, `action`, `full_name`, `edit_sequence`, `sent`).
158
+ `output.references` is no longer read: QuBe Sync doesn't send it.
159
+ - A search box focused empty (or cleared) lists the first active records of its list (QuBe Sync's
160
+ search with `q` empty), so an account can be picked without knowing its name; the search route
161
+ passes an empty `q` through.
162
+ - A rows column's `default` (QuBe Sync's new prompt key, one of its `enum` values) starts checked or
163
+ selected, and counts for the other columns' `when`, so add_transaction's missing records start at
164
+ "Create it". A blank rows label shows no heading. The storyboards' cancel reads "Cancel adding the
165
+ invoice", with no note.
166
+ - A ghost button's description (Cancel's "Stop here. Nothing is created.") starts where the
167
+ button's text does. The storyboard's missing-records question uses QuBe Sync's new wording.
168
+ - Motion in the question: a pick's check pops in (240ms) and the box's tint eases in; fades only
169
+ under reduced motion.
170
+ - A pick's detail wraps between its parts (`similar name ·`, the email, the phone), each a
171
+ `.qube-detail-part`, so a phone number no longer breaks across lines and no line starts with
172
+ the separator.
173
+ - An exit's hidden form beside a lone form (`detached`) no longer takes a row of the choices' grid,
174
+ which left blank space under the buttons: `.qube-choice` set `display` and won over `hidden`. The
175
+ layer's last rule now hides a `hidden` `.qube-choice`, `.qube-choice-button` and
176
+ `[data-qube-branch-part]` (zero specificity, so it has to come after the rules that set display).
177
+ - A search box with text but no pick shows its error edge once the focus leaves it, not while
178
+ it's being typed in (after a first try it was red through every later search).
179
+ - A search's "No matches" or failed-search note is a line under the box, in flow, not a floating
180
+ list over the buttons below it.
181
+ - On the last record of a rows field, Back and the question's submit share a row: the step nav
182
+ (`data-qube-step-nav`) now sits where the form's submit was and holds it, after Back and Next.
183
+ - After a 409 (or a 400 such as `not_awaiting_input`) for an answer, the run reads as running
184
+ ("Syncing with QuickBooks") rather than "Needs your answer" with no question shown, and the
185
+ message (new key `errors.question_moved_on`) no longer says the page shows the latest. A newer
186
+ question already on the run is left alone. In 0.2.0 too. A one-shot error now shows under the
187
+ status line, inside the status block, not above it.
188
+ - "Use for all N" is now "Use for the other record too" / "Use for the other %{count} records too"
189
+ (`question.use_for_all`, pluralized; a plain string still works), and once pressed it's replaced
190
+ by a note, "Also filled in on the other record." (new key `question.used_for_all`), until the
191
+ value changes. A record filled while hidden in a later step flashes the fill tint as it comes on
192
+ show, so nothing changes out of sight unannounced.
193
+ - A refused answer (422) keeps what was typed: the choice's text, number, select and checkbox
194
+ fields come back filled, marked `aria-invalid` and described by the refusal, which now shows
195
+ inside the question rather than above the run status. The refusal travels in
196
+ `flash[:qube_rails_refusal]` (`token`, `choice`, `message`, `values`), shown only on the question
197
+ it was for; values over 1,000 characters aren't kept (cookie sessions). `_error` takes an `id:`.
198
+ - Phone width: a wrapped button no longer touches its border (`.qube-choice-button` has 8px block
199
+ padding, `box-sizing: border-box`); under 30rem an offered record's "Use this one" goes under its
200
+ text, full width, so an email in its detail isn't broken mid-word; a search match's detail is
201
+ split into `.qube-detail-part`s like a pick's, so a phone number doesn't break at its hyphen.
202
+ - With a host class on the search input (Bootstrap's `form-control`), the picked check no longer
203
+ overlaps the text: the script sets the room for it inline. A segment's label stays centred when
204
+ a reset sets `label { display: inline-block }` (padding and `text-align`, not flex alone).
205
+ - A select starts on "Choose…" (new key `question.choose`) rather than a blank row.
206
+ - A search the route answers 409 (the question changed) says "This question has changed. Reload
207
+ the page to see the latest." (new key `question.search_changed`, `data-qube-text-search-changed`)
208
+ rather than "No matches"; any other failed answer says the search isn't available.
209
+
210
+ ### Compatibility
211
+
212
+ Matches QuBe Sync's reshaped workflow-run webhooks (qube PR #61): the error object, `headline`,
213
+ an `output` per outcome without `output.outcome` (add_transaction's `added` keeps `record` and
214
+ `references`, so `link_references` is unchanged), links only while they work, no
215
+ `prompt.options`, and `summary.changes` in place of `summary.side_effects` (the engine read
216
+ neither). Webhooks in the old shape are still read. The start's 422 `realtime_required` answer is
217
+ the same before and after that change.
218
+
3
219
  ## 0.2.0 (2026-10-27)
4
220
 
5
221
  A rewrite on QuBe Sync's v2 API. The engine now holds the code QuBe Sync's integration kit used to