hubbado-sequence 0.4.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 225c967e73e28a28effbc26e9c3bbdfce3357932a8374046dc46056d0dd8dd7d
4
- data.tar.gz: 7a446faedf4bb88018c17a6130f29ec85f1fc354929864aaa2dd55f86753ffca
3
+ metadata.gz: cc373389ca48751e5d60ebc84c00dfd8740b437ec89a53b8d9a1b986ea5c2a48
4
+ data.tar.gz: 7053947aa597354f5b973832083ebc8cc9e60e4de3a1cee23524045f803a63cd
5
5
  SHA512:
6
- metadata.gz: f5ae7e6141a9d45576b0b93a0c25ac23a63a9d3a5b4ea5ba134103a91db20633a17a1dc4e41a7a73570dc6745446d55e4e22612249dd75211d9c2be1c02a3143
7
- data.tar.gz: a741030d0046941b128a18bc8bb0f58f10bdb677cd8941857d8937263e4dd2c58aaaac6fd2c816deac3f8d310a256c67af516dc7e8428aa3e5e29791cafa3676
6
+ metadata.gz: 240dbbf380bea6a9007872456c97d052a6cedf0f5b716fbffe63876362f7c66f89f18accbf51d1cd99f2ee0f3f377376c7161770e46d85f6314548bc07d6549b
7
+ data.tar.gz: ef08b3226afc5465ecac7030ca8e36ad9c3a2ecb967530144bb96aad79a670e2085eda9e74d80b4cc05e4617deab78ac0903150ff5ed6b78f4cf1b58a912d778
data/CHANGELOG.md CHANGED
@@ -4,6 +4,145 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [0.6.0] - Result.failure flat kwargs; Dispatch delegates reads and exposes raise helpers
8
+
9
+ ### Changed (breaking)
10
+
11
+ - **`Result.failure` takes flat kwargs; the `error:` hash wrapper is
12
+ gone.** The previous shape — `Result.failure(ctx, error: { code:,
13
+ data:, ... })` — wrapped its keys in an `error:` hash for no reason
14
+ beyond convention. The fields are now first-class kwargs on
15
+ `Result.failure` and first-class attrs on `Result`:
16
+
17
+ ```ruby
18
+ # before
19
+ Result.failure(ctx, error: { code: :forbidden, data: { policy_result: pr } })
20
+ result.error[:code] # => :forbidden
21
+ result.error[:data][:policy_result]
22
+
23
+ # after
24
+ Result.failure(ctx, code: :forbidden, data: { policy_result: pr })
25
+ result.code # => :forbidden
26
+ result.data[:policy_result]
27
+ ```
28
+
29
+ `Result` exposes `code`, `data`, `step`, `message_override`,
30
+ `i18n_scope`, `i18n_key`, `i18n_args` as readers. `Result#error`
31
+ is removed.
32
+
33
+ Migration: in callers, replace `Result.failure(ctx, error: { code:
34
+ :X })` with `Result.failure(ctx, code: :X)`. Replace `result.error[:X]`
35
+ reads with `result.X`. The `Sequencer#failure(ctx, **error_attrs)`
36
+ helper is unchanged at the call site (it always took flat kwargs).
37
+ Macro substitutes' `fail_with(**error_attrs)` is unchanged at the call
38
+ site; arbitrary extra attrs that used to live in the error hash should
39
+ move into `data:` (`fail_with(code: :forbidden, data: { reason:
40
+ :not_owner })`).
41
+
42
+ - **The per-error `i18n_scope` override path is removed.** Previously a
43
+ caller could put `i18n_scope:` inside the `error:` hash *and* pass a
44
+ separate `i18n_scope:` to the surrounding wrapper, with the per-error
45
+ one winning. With flat kwargs there is one `i18n_scope` slot. The
46
+ `Sequencer#failure` helper still applies the sequencer's auto-derived
47
+ scope when the caller doesn't pass one (`error_attrs[:i18n_scope] ||=
48
+ i18n_scope`), preserving the "caller wins" semantics where it matters
49
+ in practice. `Result#with_i18n_scope` (used to apply a scope to an
50
+ already-built Result) is unchanged.
51
+
52
+ - **`Runner::Dispatch#result` is removed.** Master exposed the wrapped
53
+ Result via `attr_reader :result`, which was the source of the
54
+ `result.result.error.dig(...)` four-hop pattern. With the new
55
+ read-through delegations (`code`, `data`, `step`, `message`,
56
+ `successful_steps`, `ctx`) there's no reason for outcome blocks to
57
+ reach into the inner Result. Any caller still doing
58
+ `result.result.X` from inside a `run_sequence` block will now raise
59
+ `NoMethodError`; replace with the matching delegation on the
60
+ dispatch object itself.
61
+
62
+ - **The `message:` kwarg on `Result.failure` is removed.** It set a
63
+ literal-string fallback returned by `Result#message` when no
64
+ translation matched. No in-tree caller used it (the
65
+ i18n-translation chain plus `humanize_code` fallback covered every
66
+ real case), and the path was test-only. If a caller needs a custom
67
+ message they can supply `i18n_key:` and a matching translation, or
68
+ pass a humanizable `code:` symbol.
69
+
70
+ ### Added
71
+
72
+ - **`Runner::Dispatch` delegates reads to its wrapped `Result`.** Outcome
73
+ blocks can call `result.code`, `result.data`, `result.message`,
74
+ `result.step`, `result.successful_steps`, `result.ctx` on the
75
+ `Dispatch` object (the block argument) without hopping through an
76
+ inner `.result.` reference. The previous `result.result.error.dig(...)`
77
+ pattern collapses to one read.
78
+
79
+ ```ruby
80
+ result.policy_failed do |ctx|
81
+ if result.data[:policy_result].reason == :not_open
82
+ redirect_to public_path(ctx[:job])
83
+ else
84
+ result.raise_policy_failed
85
+ end
86
+ end
87
+ ```
88
+
89
+ - **Public raise helpers on `Runner::Dispatch`:** `raise_policy_failed`,
90
+ `raise_not_found`, and `raise_failed`. They produce the same exceptions
91
+ the safety net would raise, but can be called explicitly from inside an
92
+ outcome block — useful when a caller handles some failure cases inline
93
+ and wants the framework's standard escalation for the rest.
94
+ `enforce_safety_nets!` now delegates to the same helpers, so the
95
+ exception shapes stay aligned whether the caller invokes them directly
96
+ or the runner does it automatically.
97
+
98
+ ## [0.5.0] - Result vocabulary renamed: success/failure and successful_steps
99
+
100
+ ### Changed (breaking)
101
+
102
+ - **`Result.ok` → `Result.success`** and **`Result.fail` → `Result.failure`**.
103
+ Aligns with the wider Ruby railway-oriented vocabulary (dry-monads,
104
+ dry-transaction) and replaces the asymmetric `ok`/`failure?` pair with a
105
+ consistent `success`/`failure` pair.
106
+
107
+ ```ruby
108
+ # before
109
+ Result.ok(ctx)
110
+ Result.fail(ctx, error: { code: :forbidden })
111
+ result.ok?
112
+
113
+ # after
114
+ Result.success(ctx)
115
+ Result.failure(ctx, error: { code: :forbidden })
116
+ result.success?
117
+ ```
118
+
119
+ `result.failure?` is unchanged.
120
+
121
+ Migration: search-and-replace `Result.ok(` → `Result.success(`,
122
+ `Result.fail(` → `Result.failure(`, and `.ok?` → `.success?`. RSpec
123
+ matchers `be_ok` become `be_success`.
124
+
125
+ - **`Result#trail` → `Result#successful_steps`** (and `with_trail` →
126
+ `with_successful_steps`, `trail:` kwarg → `successful_steps:`). The old
127
+ name was confusing because the failing step is *not* in the list — it
128
+ lives on `error[:step]`. The new name says exactly what's there.
129
+
130
+ ```ruby
131
+ # before
132
+ result.trail # => [:find, :build_contract]
133
+ result.with_trail([...])
134
+ Result.ok(ctx, trail: [...])
135
+
136
+ # after
137
+ result.successful_steps # => [:find, :build_contract]
138
+ result.with_successful_steps([...])
139
+ Result.success(ctx, successful_steps: [...])
140
+ ```
141
+
142
+ Migration: search-and-replace `.trail` → `.successful_steps`,
143
+ `with_trail(` → `with_successful_steps(`, and the keyword argument
144
+ `trail:` → `successful_steps:`.
145
+
7
146
  ## [0.4.0] - Inline step blocks removed; Pipeline made internal
8
147
 
9
148
  ### Removed (breaking)