hecks 2.1.0 → 2.3.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: 07b56eefa1dd5cd2cc6308fa35aab4b8aba8af59da9418283d98a1235268e3c4
4
+ data.tar.gz: cc996a57a43dc3652a062c6af748545ec5846d50c08a43d372224e402c60fbf7
5
5
  SHA512:
6
- metadata.gz: 7738a1869d51907dce7b981d7f0d3d1977f73a8baae57d947d2667155830495f9e19163a4c1fe5785e79fa262a7733c6d1d31086b6bc0ed85191bd31d6ad829b
7
- data.tar.gz: f3506ffdc5133c083030ac87f0056a1373de5802520116956b0e30c00ea3d473e1e55f9fa62e813048e98c063aa05446a44e61ff49540dcc266e74546d6da7fa
6
+ metadata.gz: aab93180168cb073c8f65b05697cfe8c94f68d43a0516e2f8540d0c457d2ff238173fc223006f72e1681b870dcdd86b1ae65d1883d7d5375f62207b2b4a08b6d
7
+ data.tar.gz: 941f1214a2f1f7a144c57e8c0fc780d5444133973170afbc1d5dd6e646c0456feaaf73ac58da9382fc0b229af37a929e15eb8b77dd0dc36216187fd2341d8e04
@@ -32,9 +32,24 @@ 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
+ # Sending an issue to the confirmed subscribers: the decision to send
36
+ # and the record of each email handed to the mail provider. A separate
37
+ # capability from `NEWSLETTER` so a chapter that only takes signups
38
+ # declares nothing more; rust/host serves the send route only when a
39
+ # chapter declares this one as well.
40
+ NEWSLETTER_ISSUES = "newsletter_issues".freeze
41
+
42
+ # Taking a payment through an external processor: start one, then
43
+ # hear the processor's verdict — recognised by declaration, not the
44
+ # literal chapter name "Payments". rust/host's checkout and webhook
45
+ # routes dispatch these verbs and read the paying aggregate's
46
+ # instances off `initiate`. The two verdicts are hecksagon port
47
+ # operations (the processor's webhook, translated into this chapter's
48
+ # vocabulary), not commands.
49
+ PAYMENTS = "payments".freeze
35
50
 
36
51
  CONTRACTS = {
37
- AUTHORIZATION => {
52
+ AUTHORIZATION => {
38
53
  # every assignment an actor holds, current or historical
39
54
  assignments: :query,
40
55
  # the command that grants an actor a role
@@ -42,7 +57,7 @@ module Hecks
42
57
  # every grant of one role acting as another
43
58
  transitions: :query
44
59
  }.freeze,
45
- MEMBERSHIP => {
60
+ MEMBERSHIP => {
46
61
  # recognize a person who may eventually sign in
47
62
  admit: :command,
48
63
  # grant an admitted person a role (the access-grant half)
@@ -50,7 +65,7 @@ module Hecks
50
65
  # every admitted person, for the admin listing
51
66
  people: :query
52
67
  }.freeze,
53
- IDENTITY => {
68
+ IDENTITY => {
54
69
  # mint a stable identity, independent of how it authenticated
55
70
  register: :command,
56
71
  # associate an (issuer, subject) pair with that identity
@@ -58,7 +73,7 @@ module Hecks
58
73
  # look up the identity an authenticated pair resolves to
59
74
  resolve: :query
60
75
  }.freeze,
61
- NEWSLETTER => {
76
+ NEWSLETTER => {
62
77
  # a guest signs up; the aggregate it names is the subscriber
63
78
  subscribe: :command,
64
79
  # attach a display name to an existing subscriber
@@ -67,6 +82,21 @@ module Hecks
67
82
  confirm: :command,
68
83
  # a subscriber leaves from the emailed link
69
84
  unsubscribe: :command
85
+ }.freeze,
86
+ NEWSLETTER_ISSUES => {
87
+ # mark an issue sent; the issue aggregate is the one it names
88
+ send_issue: :command,
89
+ # record one email handed to the mail provider; the delivery
90
+ # aggregate is the one it names
91
+ record_delivery: :command
92
+ }.freeze,
93
+ PAYMENTS => {
94
+ # start a payment; the aggregate it names is the payment
95
+ initiate: :command,
96
+ # the processor reports the money arrived
97
+ succeeded: :port_operation,
98
+ # the processor reports the payment failed or expired
99
+ failed: :port_operation
70
100
  }.freeze
71
101
  }.freeze
72
102
  end
@@ -296,6 +296,15 @@ 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"
306
+ member keyword: "provides", context: "Bluebook", at: "", named: "send_issue", kind: "text", required: "false", fills: "provides"
307
+ member keyword: "provides", context: "Bluebook", at: "", named: "record_delivery", kind: "text", required: "false", fills: "provides"
299
308
  member keyword: "aggregate", context: "Bluebook", at: "1", named: "", kind: "text", required: "true", fills: "name"
300
309
  member keyword: "read_model", context: "Bluebook", at: "1", named: "", kind: "text", required: "true", fills: "name"
301
310
  member keyword: "policy", context: "Bluebook", at: "1", named: "", kind: "text", required: "true", fills: "name"
@@ -202,6 +202,60 @@ module Hecks
202
202
  }
203
203
  end
204
204
 
205
+ # Which chapter answers sending a newsletter issue
206
+ # (`Registry#newsletter_issues_provider_for`), with its declared verbs
207
+ # qualified and the issue and delivery aggregates named off them.
208
+ # rust/host's send route reads this instead of naming
209
+ # Newsletter::Issue.Send and Newsletter::Delivery.Record. `{}` when
210
+ # nothing this domain attaches provides newsletter_issues.
211
+ # @param registry [Runtime::Registry] the booted registry `domain_name` is loaded in
212
+ # @param domain_name [String] the domain to export the issue-sending binding for
213
+ # @return [Hash{Symbol => String, nil}] `:provider` (name), `:send_issue`,
214
+ # `:record_delivery` (qualified verbs), `:issue_aggregate` and `:delivery_aggregate`
215
+ # (each verb's own leading qualified aggregate name); `{}` if nothing this domain
216
+ # attaches provides newsletter_issues
217
+ def newsletter_issues(registry, domain_name)
218
+ provider = registry.newsletter_issues_provider_for(domain_name)
219
+ return {} unless provider
220
+
221
+ capability = Bluebook::Capabilities::NEWSLETTER_ISSUES
222
+ send_issue = provider.provided_verb(capability, :send_issue)
223
+ record_delivery = provider.provided_verb(capability, :record_delivery)
224
+ {
225
+ provider: provider.name,
226
+ send_issue: send_issue,
227
+ record_delivery: record_delivery,
228
+ issue_aggregate: send_issue&.split(".")&.first,
229
+ delivery_aggregate: record_delivery&.split(".")&.first
230
+ }
231
+ end
232
+
233
+ # Same seam as `newsletter` — which chapter takes payments
234
+ # (`Registry#payments_provider_for`), with its declared verbs
235
+ # qualified and the paying aggregate named off `initiate`. rust/host
236
+ # reads this instead of naming Payments::Payment.Initiate and the
237
+ # PaymentGateway operations. `{}` when nothing this domain attaches
238
+ # provides payments.
239
+ # @param registry [Runtime::Registry] the booted registry `domain_name` is loaded in
240
+ # @param domain_name [String] the domain to export the payments binding for
241
+ # @return [Hash{Symbol => String, nil}] `:provider` (name), `:initiate`, `:succeeded`,
242
+ # `:failed` (qualified verbs), and `:aggregate` (`:initiate`'s own leading qualified
243
+ # aggregate name); `{}` if nothing this domain attaches provides payments
244
+ def payments(registry, domain_name)
245
+ provider = registry.payments_provider_for(domain_name)
246
+ return {} unless provider
247
+
248
+ capability = Bluebook::Capabilities::PAYMENTS
249
+ initiate = provider.provided_verb(capability, :initiate)
250
+ {
251
+ provider: provider.name,
252
+ initiate: initiate,
253
+ succeeded: provider.provided_verb(capability, :succeeded),
254
+ failed: provider.provided_verb(capability, :failed),
255
+ aggregate: initiate&.split(".")&.first
256
+ }
257
+ end
258
+
205
259
  # Translation IR, always as an array, with each aggregate's
206
260
  # precompiled SQL attached (`compiled_translation_aggregate`) —
207
261
  # this is the export a consumer embeds (`ir.json`'s `translations`
@@ -392,6 +392,31 @@ module Hecks
392
392
  vendored_provider_for(domain, Bluebook::Capabilities::NEWSLETTER)
393
393
  end
394
394
 
395
+ # The chapter that answers sending a newsletter issue for `domain` —
396
+ # resolved the same way as `newsletter_provider_for`, by what it
397
+ # declares (`provides "newsletter_issues"`). Nil when none does.
398
+ #
399
+ # @param domain [String, Symbol] the domain whose issue-sending chapter is being resolved
400
+ # @return [Bluebook::Chapter, nil] the chapter that answers `domain`'s issue sending,
401
+ # or nil if none does
402
+ def newsletter_issues_provider_for(domain)
403
+ vendored_provider_for(domain, Bluebook::Capabilities::NEWSLETTER_ISSUES)
404
+ end
405
+
406
+ # The chapter that takes payments for `domain` — the domain's own
407
+ # chapter, a framework member, or a vendored embryonaut bluebook it
408
+ # attaches, that declares `provides "payments"`. Nil when none does.
409
+ # Payments is recognised by what it declares (Initiate and the
410
+ # processor's two verdicts), so a chapter that declares the same
411
+ # thing is recognised the same way.
412
+ #
413
+ # @param domain [String, Symbol] the domain whose payments chapter is being resolved
414
+ # @return [Bluebook::Chapter, nil] the chapter that takes `domain`'s payments, or nil
415
+ # if none does
416
+ def payments_provider_for(domain)
417
+ vendored_provider_for(domain, Bluebook::Capabilities::PAYMENTS)
418
+ end
419
+
395
420
  # The chapter that provides `capability` for `domain`: the domain's
396
421
  # own chapter, any framework member its hecksagon attaches, or any
397
422
  # 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.3.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.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Young