hecks 2.1.0 → 2.2.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: b7e80387e679bdc08c6a48b9c1eabefee28d7f9fd0e28a41f203e1fd9b207c34
4
- data.tar.gz: 455038d69b310e2fc9ae72b30d811623c8c1a85a4a5da118b842b8af7fd082b0
3
+ metadata.gz: 1fad5f64ba40ddec2720f013efc33d54e7ce5ebaf0926bc0670b642f91e53416
4
+ data.tar.gz: a714cad37a3a9c02f2ece530fc2c417e019f3ac47e0f0b76fd2c336416c2d55d
5
5
  SHA512:
6
- metadata.gz: 7738a1869d51907dce7b981d7f0d3d1977f73a8baae57d947d2667155830495f9e19163a4c1fe5785e79fa262a7733c6d1d31086b6bc0ed85191bd31d6ad829b
7
- data.tar.gz: f3506ffdc5133c083030ac87f0056a1373de5802520116956b0e30c00ea3d473e1e55f9fa62e813048e98c063aa05446a44e61ff49540dcc266e74546d6da7fa
6
+ metadata.gz: 3ed37d25061346166c25415b92be46409ecefa3eb762fef81941c4758ecc3a2681241f29a4c819a28ad360ee0267919612f9fedb9c56c1be00d0a9a70d512e6e
7
+ data.tar.gz: 7b6b0df13da60ef2a40a002d2a847b284164518c51363227c01f1d00e548e3d544b25a27d28053ff1af2469c6f802f4a5bd94103b6d2a9a9ed491710b9152217
@@ -32,6 +32,14 @@ module Hecks
32
32
  # "Newsletter". rust/host's newsletter routes dispatch these verbs
33
33
  # and read the subscribing aggregate's instances off `subscribe`.
34
34
  NEWSLETTER = "newsletter".freeze
35
+ # Taking a payment through an external processor: start one, then
36
+ # hear the processor's verdict — recognised by declaration, not the
37
+ # literal chapter name "Payments". rust/host's checkout and webhook
38
+ # routes dispatch these verbs and read the paying aggregate's
39
+ # instances off `initiate`. The two verdicts are hecksagon port
40
+ # operations (the processor's webhook, translated into this chapter's
41
+ # vocabulary), not commands.
42
+ PAYMENTS = "payments".freeze
35
43
 
36
44
  CONTRACTS = {
37
45
  AUTHORIZATION => {
@@ -67,6 +75,14 @@ module Hecks
67
75
  confirm: :command,
68
76
  # a subscriber leaves from the emailed link
69
77
  unsubscribe: :command
78
+ }.freeze,
79
+ PAYMENTS => {
80
+ # start a payment; the aggregate it names is the payment
81
+ initiate: :command,
82
+ # the processor reports the money arrived
83
+ succeeded: :port_operation,
84
+ # the processor reports the payment failed or expired
85
+ failed: :port_operation
70
86
  }.freeze
71
87
  }.freeze
72
88
  end
@@ -296,6 +296,13 @@ Hecks.bluebook "Bluebook", version: "1" do
296
296
  member keyword: "provides", context: "Bluebook", at: "", named: "register", kind: "text", required: "false", fills: "provides"
297
297
  member keyword: "provides", context: "Bluebook", at: "", named: "link", kind: "text", required: "false", fills: "provides"
298
298
  member keyword: "provides", context: "Bluebook", at: "", named: "resolve", kind: "text", required: "false", fills: "provides"
299
+ member keyword: "provides", context: "Bluebook", at: "", named: "subscribe", kind: "text", required: "false", fills: "provides"
300
+ member keyword: "provides", context: "Bluebook", at: "", named: "add_name", kind: "text", required: "false", fills: "provides"
301
+ member keyword: "provides", context: "Bluebook", at: "", named: "confirm", kind: "text", required: "false", fills: "provides"
302
+ member keyword: "provides", context: "Bluebook", at: "", named: "unsubscribe", kind: "text", required: "false", fills: "provides"
303
+ member keyword: "provides", context: "Bluebook", at: "", named: "initiate", kind: "text", required: "false", fills: "provides"
304
+ member keyword: "provides", context: "Bluebook", at: "", named: "succeeded", kind: "text", required: "false", fills: "provides"
305
+ member keyword: "provides", context: "Bluebook", at: "", named: "failed", kind: "text", required: "false", fills: "provides"
299
306
  member keyword: "aggregate", context: "Bluebook", at: "1", named: "", kind: "text", required: "true", fills: "name"
300
307
  member keyword: "read_model", context: "Bluebook", at: "1", named: "", kind: "text", required: "true", fills: "name"
301
308
  member keyword: "policy", context: "Bluebook", at: "1", named: "", kind: "text", required: "true", fills: "name"
@@ -202,6 +202,32 @@ module Hecks
202
202
  }
203
203
  end
204
204
 
205
+ # Same seam as `newsletter` — which chapter takes payments
206
+ # (`Registry#payments_provider_for`), with its declared verbs
207
+ # qualified and the paying aggregate named off `initiate`. rust/host
208
+ # reads this instead of naming Payments::Payment.Initiate and the
209
+ # PaymentGateway operations. `{}` when nothing this domain attaches
210
+ # provides payments.
211
+ # @param registry [Runtime::Registry] the booted registry `domain_name` is loaded in
212
+ # @param domain_name [String] the domain to export the payments binding for
213
+ # @return [Hash{Symbol => String, nil}] `:provider` (name), `:initiate`, `:succeeded`,
214
+ # `:failed` (qualified verbs), and `:aggregate` (`:initiate`'s own leading qualified
215
+ # aggregate name); `{}` if nothing this domain attaches provides payments
216
+ def payments(registry, domain_name)
217
+ provider = registry.payments_provider_for(domain_name)
218
+ return {} unless provider
219
+
220
+ capability = Bluebook::Capabilities::PAYMENTS
221
+ initiate = provider.provided_verb(capability, :initiate)
222
+ {
223
+ provider: provider.name,
224
+ initiate: initiate,
225
+ succeeded: provider.provided_verb(capability, :succeeded),
226
+ failed: provider.provided_verb(capability, :failed),
227
+ aggregate: initiate&.split(".")&.first
228
+ }
229
+ end
230
+
205
231
  # Translation IR, always as an array, with each aggregate's
206
232
  # precompiled SQL attached (`compiled_translation_aggregate`) —
207
233
  # this is the export a consumer embeds (`ir.json`'s `translations`
@@ -392,6 +392,20 @@ module Hecks
392
392
  vendored_provider_for(domain, Bluebook::Capabilities::NEWSLETTER)
393
393
  end
394
394
 
395
+ # The chapter that takes payments for `domain` — the domain's own
396
+ # chapter, a framework member, or a vendored embryonaut bluebook it
397
+ # attaches, that declares `provides "payments"`. Nil when none does.
398
+ # Payments is recognised by what it declares (Initiate and the
399
+ # processor's two verdicts), so a chapter that declares the same
400
+ # thing is recognised the same way.
401
+ #
402
+ # @param domain [String, Symbol] the domain whose payments chapter is being resolved
403
+ # @return [Bluebook::Chapter, nil] the chapter that takes `domain`'s payments, or nil
404
+ # if none does
405
+ def payments_provider_for(domain)
406
+ vendored_provider_for(domain, Bluebook::Capabilities::PAYMENTS)
407
+ end
408
+
395
409
  # The chapter that provides `capability` for `domain`: the domain's
396
410
  # own chapter, any framework member its hecksagon attaches, or any
397
411
  # vendored embryonaut bluebook it attaches, that declares it. Falls
data/lib/hecks/version.rb CHANGED
@@ -12,5 +12,5 @@ module Hecks
12
12
  # it there, or even in the consuming Gemfile, never closed the gap,
13
13
  # because gemspec evaluation happens before anything Bundler
14
14
  # resolves is actually loadable yet.
15
- VERSION = "2.1.0".freeze
15
+ VERSION = "2.2.0".freeze
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hecks
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Young