sequent 4.3.0 → 6.0.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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/bin/sequent +1 -1
  3. data/db/sequent_schema.rb +3 -3
  4. data/lib/sequent/configuration.rb +19 -1
  5. data/lib/sequent/core/aggregate_root.rb +2 -6
  6. data/lib/sequent/core/aggregate_roots.rb +2 -6
  7. data/lib/sequent/core/command.rb +8 -12
  8. data/lib/sequent/core/command_record.rb +1 -1
  9. data/lib/sequent/core/command_service.rb +13 -2
  10. data/lib/sequent/core/core.rb +1 -0
  11. data/lib/sequent/core/event.rb +2 -2
  12. data/lib/sequent/core/event_store.rb +15 -2
  13. data/lib/sequent/core/ext/ext.rb +17 -0
  14. data/lib/sequent/core/helpers/attr_matchers/argument_serializer.rb +35 -0
  15. data/lib/sequent/core/helpers/attr_matchers/attr_matchers.rb +10 -0
  16. data/lib/sequent/core/helpers/attr_matchers/dsl.rb +23 -0
  17. data/lib/sequent/core/helpers/attr_matchers/equals.rb +24 -0
  18. data/lib/sequent/core/helpers/attr_matchers/greater_than.rb +24 -0
  19. data/lib/sequent/core/helpers/attr_matchers/greater_than_equals.rb +24 -0
  20. data/lib/sequent/core/helpers/attr_matchers/less_than.rb +24 -0
  21. data/lib/sequent/core/helpers/attr_matchers/less_than_equals.rb +24 -0
  22. data/lib/sequent/core/helpers/attr_matchers/not_equals.rb +24 -0
  23. data/lib/sequent/core/helpers/attribute_support.rb +35 -9
  24. data/lib/sequent/core/helpers/autoset_attributes.rb +5 -5
  25. data/lib/sequent/core/helpers/default_validators.rb +3 -0
  26. data/lib/sequent/core/helpers/message_dispatcher.rb +20 -0
  27. data/lib/sequent/core/helpers/message_handler.rb +62 -8
  28. data/lib/sequent/core/helpers/message_handler_option_registry.rb +59 -0
  29. data/lib/sequent/core/helpers/message_matchers/any.rb +34 -0
  30. data/lib/sequent/core/helpers/message_matchers/argument_coercer.rb +24 -0
  31. data/lib/sequent/core/helpers/message_matchers/argument_serializer.rb +20 -0
  32. data/lib/sequent/core/helpers/message_matchers/dsl.rb +23 -0
  33. data/lib/sequent/core/helpers/message_matchers/except_opt.rb +24 -0
  34. data/lib/sequent/core/helpers/message_matchers/has_attrs.rb +54 -0
  35. data/lib/sequent/core/helpers/message_matchers/instance_of.rb +24 -0
  36. data/lib/sequent/core/helpers/message_matchers/is_a.rb +34 -0
  37. data/lib/sequent/core/helpers/message_matchers/message_matchers.rb +10 -0
  38. data/lib/sequent/core/helpers/message_router.rb +55 -0
  39. data/lib/sequent/core/helpers/param_support.rb +2 -0
  40. data/lib/sequent/core/helpers/string_to_value_parsers.rb +5 -0
  41. data/lib/sequent/core/helpers/time_validator.rb +23 -0
  42. data/lib/sequent/core/helpers/value_validators.rb +11 -0
  43. data/lib/sequent/core/middleware/chain.rb +37 -0
  44. data/lib/sequent/core/middleware/middleware.rb +3 -0
  45. data/lib/sequent/core/projector.rb +3 -11
  46. data/lib/sequent/core/workflow.rb +5 -13
  47. data/lib/sequent/generator/template_project/Rakefile +2 -2
  48. data/lib/sequent/generator/template_project/db/sequent_schema.rb +3 -3
  49. data/lib/sequent/generator/template_project/spec/spec_helper.rb +1 -1
  50. data/lib/sequent/migrations/migrations.rb +1 -0
  51. data/lib/sequent/migrations/projectors.rb +2 -2
  52. data/lib/sequent/migrations/sequent_schema.rb +40 -0
  53. data/lib/sequent/migrations/view_schema.rb +39 -3
  54. data/lib/sequent/rake/migration_tasks.rb +36 -33
  55. data/lib/sequent/support/database.rb +29 -13
  56. data/lib/sequent/test/command_handler_helpers.rb +3 -3
  57. data/lib/sequent/test/database_helpers.rb +20 -0
  58. data/lib/sequent/test/time_comparison.rb +2 -5
  59. data/lib/sequent/test/{event_handler_helpers.rb → workflow_helpers.rb} +24 -10
  60. data/lib/sequent/test.rb +2 -1
  61. data/lib/sequent/util/dry_run.rb +1 -1
  62. data/lib/version.rb +1 -1
  63. metadata +40 -15
  64. data/lib/sequent/rake/tasks.rb +0 -121
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequent
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.3.0
4
+ version: 6.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lars Vonk
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2022-03-21 00:00:00.000000000 Z
15
+ date: 2023-09-01 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: activemodel
@@ -21,9 +21,9 @@ dependencies:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: '5.0'
24
- - - "<="
24
+ - - "<"
25
25
  - !ruby/object:Gem::Version
26
- version: 7.0.2
26
+ version: '7.1'
27
27
  type: :runtime
28
28
  prerelease: false
29
29
  version_requirements: !ruby/object:Gem::Requirement
@@ -31,9 +31,9 @@ dependencies:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '5.0'
34
- - - "<="
34
+ - - "<"
35
35
  - !ruby/object:Gem::Version
36
- version: 7.0.2
36
+ version: '7.1'
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: activerecord
39
39
  requirement: !ruby/object:Gem::Requirement
@@ -41,9 +41,9 @@ dependencies:
41
41
  - - ">="
42
42
  - !ruby/object:Gem::Version
43
43
  version: '5.0'
44
- - - "<="
44
+ - - "<"
45
45
  - !ruby/object:Gem::Version
46
- version: 7.0.2
46
+ version: '7.1'
47
47
  type: :runtime
48
48
  prerelease: false
49
49
  version_requirements: !ruby/object:Gem::Requirement
@@ -51,9 +51,9 @@ dependencies:
51
51
  - - ">="
52
52
  - !ruby/object:Gem::Version
53
53
  version: '5.0'
54
- - - "<="
54
+ - - "<"
55
55
  - !ruby/object:Gem::Version
56
- version: 7.0.2
56
+ version: '7.1'
57
57
  - !ruby/object:Gem::Dependency
58
58
  name: bcrypt
59
59
  requirement: !ruby/object:Gem::Requirement
@@ -119,7 +119,7 @@ dependencies:
119
119
  version: 2.6.5
120
120
  - - "<"
121
121
  - !ruby/object:Gem::Version
122
- version: '3.2'
122
+ version: '3.3'
123
123
  type: :runtime
124
124
  prerelease: false
125
125
  version_requirements: !ruby/object:Gem::Requirement
@@ -129,7 +129,7 @@ dependencies:
129
129
  version: 2.6.5
130
130
  - - "<"
131
131
  - !ruby/object:Gem::Version
132
- version: '3.2'
132
+ version: '3.3'
133
133
  - !ruby/object:Gem::Dependency
134
134
  name: pg
135
135
  requirement: !ruby/object:Gem::Requirement
@@ -304,7 +304,7 @@ email:
304
304
  - bforma@zilverline.com
305
305
  - erozendaal@zilverline.com
306
306
  - mvdiepen@zilverline.com
307
- - svdiepen@zilverline.com
307
+ - stephan@vandiepen.info
308
308
  executables:
309
309
  - sequent
310
310
  extensions: []
@@ -333,6 +333,15 @@ files:
333
333
  - lib/sequent/core/ext/ext.rb
334
334
  - lib/sequent/core/helpers/array_with_type.rb
335
335
  - lib/sequent/core/helpers/association_validator.rb
336
+ - lib/sequent/core/helpers/attr_matchers/argument_serializer.rb
337
+ - lib/sequent/core/helpers/attr_matchers/attr_matchers.rb
338
+ - lib/sequent/core/helpers/attr_matchers/dsl.rb
339
+ - lib/sequent/core/helpers/attr_matchers/equals.rb
340
+ - lib/sequent/core/helpers/attr_matchers/greater_than.rb
341
+ - lib/sequent/core/helpers/attr_matchers/greater_than_equals.rb
342
+ - lib/sequent/core/helpers/attr_matchers/less_than.rb
343
+ - lib/sequent/core/helpers/attr_matchers/less_than_equals.rb
344
+ - lib/sequent/core/helpers/attr_matchers/not_equals.rb
336
345
  - lib/sequent/core/helpers/attribute_support.rb
337
346
  - lib/sequent/core/helpers/autoset_attributes.rb
338
347
  - lib/sequent/core/helpers/boolean_validator.rb
@@ -343,15 +352,30 @@ files:
343
352
  - lib/sequent/core/helpers/equal_support.rb
344
353
  - lib/sequent/core/helpers/helpers.rb
345
354
  - lib/sequent/core/helpers/mergable.rb
355
+ - lib/sequent/core/helpers/message_dispatcher.rb
346
356
  - lib/sequent/core/helpers/message_handler.rb
357
+ - lib/sequent/core/helpers/message_handler_option_registry.rb
358
+ - lib/sequent/core/helpers/message_matchers/any.rb
359
+ - lib/sequent/core/helpers/message_matchers/argument_coercer.rb
360
+ - lib/sequent/core/helpers/message_matchers/argument_serializer.rb
361
+ - lib/sequent/core/helpers/message_matchers/dsl.rb
362
+ - lib/sequent/core/helpers/message_matchers/except_opt.rb
363
+ - lib/sequent/core/helpers/message_matchers/has_attrs.rb
364
+ - lib/sequent/core/helpers/message_matchers/instance_of.rb
365
+ - lib/sequent/core/helpers/message_matchers/is_a.rb
366
+ - lib/sequent/core/helpers/message_matchers/message_matchers.rb
367
+ - lib/sequent/core/helpers/message_router.rb
347
368
  - lib/sequent/core/helpers/param_support.rb
348
369
  - lib/sequent/core/helpers/secret.rb
349
370
  - lib/sequent/core/helpers/string_support.rb
350
371
  - lib/sequent/core/helpers/string_to_value_parsers.rb
351
372
  - lib/sequent/core/helpers/string_validator.rb
373
+ - lib/sequent/core/helpers/time_validator.rb
352
374
  - lib/sequent/core/helpers/type_conversion_support.rb
353
375
  - lib/sequent/core/helpers/uuid_helper.rb
354
376
  - lib/sequent/core/helpers/value_validators.rb
377
+ - lib/sequent/core/middleware/chain.rb
378
+ - lib/sequent/core/middleware/middleware.rb
355
379
  - lib/sequent/core/persistors/active_record_persistor.rb
356
380
  - lib/sequent/core/persistors/persistor.rb
357
381
  - lib/sequent/core/persistors/persistors.rb
@@ -404,10 +428,10 @@ files:
404
428
  - lib/sequent/migrations/migrations.rb
405
429
  - lib/sequent/migrations/planner.rb
406
430
  - lib/sequent/migrations/projectors.rb
431
+ - lib/sequent/migrations/sequent_schema.rb
407
432
  - lib/sequent/migrations/sql.rb
408
433
  - lib/sequent/migrations/view_schema.rb
409
434
  - lib/sequent/rake/migration_tasks.rb
410
- - lib/sequent/rake/tasks.rb
411
435
  - lib/sequent/sequent.rb
412
436
  - lib/sequent/support.rb
413
437
  - lib/sequent/support/database.rb
@@ -415,9 +439,10 @@ files:
415
439
  - lib/sequent/support/view_schema.rb
416
440
  - lib/sequent/test.rb
417
441
  - lib/sequent/test/command_handler_helpers.rb
418
- - lib/sequent/test/event_handler_helpers.rb
442
+ - lib/sequent/test/database_helpers.rb
419
443
  - lib/sequent/test/event_stream_helpers.rb
420
444
  - lib/sequent/test/time_comparison.rb
445
+ - lib/sequent/test/workflow_helpers.rb
421
446
  - lib/sequent/util/dry_run.rb
422
447
  - lib/sequent/util/printer.rb
423
448
  - lib/sequent/util/skip_if_already_processing.rb
@@ -1,121 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'active_record'
4
- require 'rake'
5
- require 'rake/tasklib'
6
-
7
- require 'sequent/support'
8
-
9
- module Sequent
10
- module Rake
11
- class Tasks < ::Rake::TaskLib
12
- include ::Rake::DSL
13
-
14
- DEFAULT_OPTIONS = {
15
- migrations_path: 'db/migrate',
16
- event_store_schema: 'public',
17
- }.freeze
18
-
19
- attr_reader :options
20
-
21
- def initialize(options)
22
- super()
23
- @options = DEFAULT_OPTIONS.merge(options)
24
- end
25
-
26
- def display_deprecation_warning
27
- warn '[DEPRECATED] Sequent::Rake::Tasks is deprecated. Please use Sequent::Rake::MigrationTasks tasks instead.'
28
- end
29
-
30
- def register!
31
- display_deprecation_warning
32
-
33
- register_db_tasks!
34
- register_view_schema_tasks!
35
- end
36
-
37
- def register_db_tasks!
38
- namespace :db do
39
- desc 'Create the database'
40
- task :create do
41
- display_deprecation_warning
42
-
43
- current_environments.each do |env|
44
- env_db = db_config(env)
45
- puts "Create database #{env_db['database']}"
46
- Sequent::Support::Database.create!(env_db)
47
- end
48
- end
49
-
50
- desc 'Drop the database'
51
- task :drop do
52
- display_deprecation_warning
53
-
54
- current_environments.each do |env|
55
- env_db = db_config(env)
56
- puts "Drop database #{env_db['database']}"
57
- Sequent::Support::Database.drop!(env_db)
58
- end
59
- end
60
-
61
- task :establish_connection do
62
- env_db = db_config(options.fetch(:environment))
63
- ActiveRecord::Base.establish_connection(env_db)
64
- end
65
-
66
- desc 'Migrate the database'
67
- task migrate: :establish_connection do
68
- display_deprecation_warning
69
-
70
- database.create_schema!(options.fetch(:event_store_schema))
71
- database.migrate(options.fetch(:migrations_path))
72
- end
73
- end
74
- end
75
-
76
- def register_view_schema_tasks!
77
- namespace :view_schema do
78
- desc 'Build the view schema'
79
- task build: :'db:establish_connection' do
80
- display_deprecation_warning
81
-
82
- if database.schema_exists?(view_projection.schema_name)
83
- puts "View version #{view_projection.version} already exists; no need to build it"
84
- else
85
- database.create_schema!(view_projection.schema_name)
86
- view_projection.build!
87
- end
88
- end
89
-
90
- desc 'Drop the view schema'
91
- task drop: :'db:establish_connection' do
92
- display_deprecation_warning
93
-
94
- database.drop_schema!(view_projection.schema_name)
95
- end
96
- end
97
- end
98
-
99
- private
100
-
101
- def current_environments
102
- environment = options.fetch(:environment)
103
- envs = [environment]
104
- envs << 'test' if environment == 'development'
105
- envs
106
- end
107
-
108
- def database
109
- @database ||= Sequent::Support::Database.new
110
- end
111
-
112
- def db_config(environment)
113
- options.fetch(:db_config_supplier)[environment] or fail "No database config for #{environment}"
114
- end
115
-
116
- def view_projection
117
- options.fetch(:view_projection)
118
- end
119
- end
120
- end
121
- end