command_tower 0.21.1 → 0.22.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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/concerns/command_tower/execution/http_boundary.rb +2 -1
  3. data/docs/api_reference.md +7 -3
  4. data/docs/bootstrap/11-auth-client-path.md +2 -0
  5. data/docs/extending.md +1 -1
  6. data/docs/messaging_integration_guide.md +2 -0
  7. data/docs/ui.md +138 -0
  8. data/docs/upgrades/0.22.0.md +29 -0
  9. data/docs/upgrades/README.md +1 -0
  10. data/lib/command_tower/configuration/config.rb +6 -0
  11. data/lib/command_tower/configuration/ui/config.rb +47 -0
  12. data/lib/command_tower/current.rb +1 -0
  13. data/lib/command_tower/execution.rb +2 -1
  14. data/lib/command_tower/ui/builder/frame.rb +19 -0
  15. data/lib/command_tower/ui/builder/item_builder.rb +27 -0
  16. data/lib/command_tower/ui/builder/token_resolver.rb +54 -0
  17. data/lib/command_tower/ui/builder.rb +157 -0
  18. data/lib/command_tower/ui/catalog.rb +18 -0
  19. data/lib/command_tower/ui/composer.rb +45 -0
  20. data/lib/command_tower/ui/document.rb +167 -0
  21. data/lib/command_tower/ui/email/layout.rb +95 -0
  22. data/lib/command_tower/ui/email/renderer/containers.rb +72 -0
  23. data/lib/command_tower/ui/email/renderer/inline_nodes.rb +70 -0
  24. data/lib/command_tower/ui/email/renderer/styling.rb +91 -0
  25. data/lib/command_tower/ui/email/renderer/text_nodes.rb +78 -0
  26. data/lib/command_tower/ui/email/renderer.rb +89 -0
  27. data/lib/command_tower/ui/email/styles.rb +77 -0
  28. data/lib/command_tower/ui/fragment.rb +54 -0
  29. data/lib/command_tower/ui/fragments/cta_group.rb +60 -0
  30. data/lib/command_tower/ui/fragments/fact_row.rb +20 -0
  31. data/lib/command_tower/ui/fragments/facts.rb +35 -0
  32. data/lib/command_tower/ui/fragments/header.rb +51 -0
  33. data/lib/command_tower/ui/fragments/notice_frame.rb +36 -0
  34. data/lib/command_tower/ui/hardening.rb +73 -0
  35. data/lib/command_tower/ui/hostname.rb +124 -0
  36. data/lib/command_tower/ui/legacy_mapping.rb +66 -0
  37. data/lib/command_tower/ui/limits.rb +19 -0
  38. data/lib/command_tower/ui/nodes/action.rb +53 -0
  39. data/lib/command_tower/ui/nodes/avatar.rb +35 -0
  40. data/lib/command_tower/ui/nodes/badge.rb +17 -0
  41. data/lib/command_tower/ui/nodes/banner.rb +17 -0
  42. data/lib/command_tower/ui/nodes/base.rb +125 -0
  43. data/lib/command_tower/ui/nodes/button.rb +34 -0
  44. data/lib/command_tower/ui/nodes/card.rb +19 -0
  45. data/lib/command_tower/ui/nodes/code.rb +28 -0
  46. data/lib/command_tower/ui/nodes/component.rb +39 -0
  47. data/lib/command_tower/ui/nodes/divider.rb +11 -0
  48. data/lib/command_tower/ui/nodes/facts.rb +14 -0
  49. data/lib/command_tower/ui/nodes/image.rb +41 -0
  50. data/lib/command_tower/ui/nodes/instant.rb +59 -0
  51. data/lib/command_tower/ui/nodes/key_value.rb +63 -0
  52. data/lib/command_tower/ui/nodes/span.rb +76 -0
  53. data/lib/command_tower/ui/nodes/stack.rb +24 -0
  54. data/lib/command_tower/ui/nodes/stat_tile.rb +20 -0
  55. data/lib/command_tower/ui/nodes/text.rb +24 -0
  56. data/lib/command_tower/ui/text_derivation.rb +89 -0
  57. data/lib/command_tower/ui/time_formatter.rb +59 -0
  58. data/lib/command_tower/ui/tokens/ui_token_mapping.json +277 -0
  59. data/lib/command_tower/ui/tokens.rb +56 -0
  60. data/lib/command_tower/ui/zone_abbreviation.rb +130 -0
  61. data/lib/command_tower/ui.rb +80 -0
  62. data/lib/command_tower/version.rb +1 -1
  63. data/lib/command_tower.rb +1 -0
  64. data/lib/tasks/ui.rake +16 -0
  65. metadata +67 -1
@@ -0,0 +1,80 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "command_tower/error"
4
+
5
+ module CommandTower
6
+ # Server-driven UI documents: schema, tokens and validation. Pure Ruby; no DB,
7
+ # no Messaging. Authoring reference lives in docs/ui.md.
8
+ module UI
9
+ CATALOG = 2
10
+ SCHEMA = "ui_document"
11
+
12
+ # `details` is an array of { path:, code: } hashes. Paths and codes only,
13
+ # never values (design section 8).
14
+ class InvalidDocumentError < CommandTower::Error
15
+ attr_reader :details
16
+
17
+ def initialize(message = nil, details: [])
18
+ super(message)
19
+ @details = details.freeze
20
+ end
21
+ end
22
+
23
+ class InvalidTokenError < CommandTower::Error; end
24
+ class InvalidFragmentError < CommandTower::Error; end
25
+
26
+ # Builds a Document with the Builder DSL. The block must add exactly one
27
+ # root node. The result is not validated: call `validate!` (Composer does).
28
+ def self.document(text_fallback: nil)
29
+ builder = Builder.new
30
+ yield builder
31
+ roots = builder.roots
32
+ unless roots.one?
33
+ code = roots.empty? ? "root_required" : "multiple_roots"
34
+ raise InvalidDocumentError.new("Invalid UI document: root:#{code}", details: [{ path: "root", code: }])
35
+ end
36
+
37
+ Document.new(root: roots.first, text_fallback:)
38
+ end
39
+ end
40
+ end
41
+
42
+ require "command_tower/ui/hostname"
43
+ require "command_tower/ui/tokens"
44
+ require "command_tower/ui/zone_abbreviation"
45
+ require "command_tower/ui/time_formatter"
46
+ require "command_tower/ui/catalog"
47
+ require "command_tower/ui/limits"
48
+ require "command_tower/ui/hardening"
49
+ require "command_tower/ui/nodes/base"
50
+ require "command_tower/ui/nodes/action"
51
+ require "command_tower/ui/nodes/span"
52
+ require "command_tower/ui/nodes/stack"
53
+ require "command_tower/ui/nodes/card"
54
+ require "command_tower/ui/nodes/divider"
55
+ require "command_tower/ui/nodes/text"
56
+ require "command_tower/ui/nodes/instant"
57
+ require "command_tower/ui/nodes/key_value"
58
+ require "command_tower/ui/nodes/badge"
59
+ require "command_tower/ui/nodes/button"
60
+ require "command_tower/ui/nodes/image"
61
+ require "command_tower/ui/nodes/banner"
62
+ require "command_tower/ui/nodes/avatar"
63
+ require "command_tower/ui/nodes/stat_tile"
64
+ require "command_tower/ui/nodes/code"
65
+ require "command_tower/ui/nodes/component"
66
+ require "command_tower/ui/nodes/facts"
67
+ require "command_tower/ui/document"
68
+ require "command_tower/ui/builder"
69
+ require "command_tower/ui/text_derivation"
70
+ require "command_tower/ui/legacy_mapping"
71
+ require "command_tower/ui/fragment"
72
+ require "command_tower/ui/composer"
73
+ require "command_tower/ui/fragments/header"
74
+ require "command_tower/ui/fragments/fact_row"
75
+ require "command_tower/ui/fragments/cta_group"
76
+ require "command_tower/ui/fragments/notice_frame"
77
+ require "command_tower/ui/fragments/facts"
78
+ require "command_tower/ui/email/styles"
79
+ require "command_tower/ui/email/layout"
80
+ require "command_tower/ui/email/renderer"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module CommandTower
4
- VERSION = "0.21.1"
4
+ VERSION = "0.22.0"
5
5
  end
data/lib/command_tower.rb CHANGED
@@ -15,6 +15,7 @@ require "command_tower/logging/subscriber"
15
15
 
16
16
  require "command_tower/version"
17
17
  require "command_tower/engine"
18
+ require "command_tower/ui"
18
19
  require "command_tower/configuration/config"
19
20
  require "command_tower/install/baseline"
20
21
  require "command_tower/install/doctor"
data/lib/tasks/ui.rake ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :command_tower do
4
+ namespace :ui do
5
+ desc "Regenerate zoneAbbreviations, ambiguousAbbreviations and tzdataVersion in ui_token_mapping.json " \
6
+ "(does not boot :environment; needs tzdata). YEAR=2026 pins the generation year."
7
+ task :zone_abbreviations do # rubocop:disable Rails/RakeEnvironment -- deliberately avoids booting the app
8
+ require File.expand_path("../command_tower/ui/zone_abbreviation", __dir__)
9
+
10
+ year = ENV.fetch("YEAR") { Time.now.utc.year }.to_i
11
+ generated = CommandTower::UI::ZoneAbbreviation.write!(year: year)
12
+ puts "zone abbreviations: #{generated.fetch('zoneAbbreviations').size} zones, " \
13
+ "#{generated.fetch('ambiguousAbbreviations').size} ambiguous, tzdata #{generated.fetch('tzdataVersion')}"
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: command_tower
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.21.1
4
+ version: 0.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - matt-taylor
@@ -170,6 +170,20 @@ dependencies:
170
170
  - - "~>"
171
171
  - !ruby/object:Gem::Version
172
172
  version: '3.0'
173
+ - !ruby/object:Gem::Dependency
174
+ name: tzinfo
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - "~>"
178
+ - !ruby/object:Gem::Version
179
+ version: '2.0'
180
+ type: :runtime
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - "~>"
185
+ - !ruby/object:Gem::Version
186
+ version: '2.0'
173
187
  description: CommandTower is the Base API to handle all the things you don't want
174
188
  to for a Rails API only backend serving a Dedicated frontend
175
189
  email:
@@ -855,6 +869,7 @@ files:
855
869
  - docs/principal_capabilities.md
856
870
  - docs/sensitive_routes.md
857
871
  - docs/testing.md
872
+ - docs/ui.md
858
873
  - docs/upgrades/0.10.0.md
859
874
  - docs/upgrades/0.11.0.md
860
875
  - docs/upgrades/0.11.1.md
@@ -869,6 +884,7 @@ files:
869
884
  - docs/upgrades/0.19.0.md
870
885
  - docs/upgrades/0.20.0.md
871
886
  - docs/upgrades/0.21.0.md
887
+ - docs/upgrades/0.22.0.md
872
888
  - docs/upgrades/README.md
873
889
  - lib/command_tower.rb
874
890
  - lib/command_tower/admin_scope.rb
@@ -943,6 +959,7 @@ files:
943
959
  - lib/command_tower/configuration/signup_session/config.rb
944
960
  - lib/command_tower/configuration/signup_session/email_availability.rb
945
961
  - lib/command_tower/configuration/signup_session/rate_limits.rb
962
+ - lib/command_tower/configuration/ui/config.rb
946
963
  - lib/command_tower/configuration/user/config.rb
947
964
  - lib/command_tower/configuration/username/check.rb
948
965
  - lib/command_tower/configuration/username/config.rb
@@ -981,11 +998,60 @@ files:
981
998
  - lib/command_tower/signup/authorization_helper.rb
982
999
  - lib/command_tower/spec_helper.rb
983
1000
  - lib/command_tower/testing.rb
1001
+ - lib/command_tower/ui.rb
1002
+ - lib/command_tower/ui/builder.rb
1003
+ - lib/command_tower/ui/builder/frame.rb
1004
+ - lib/command_tower/ui/builder/item_builder.rb
1005
+ - lib/command_tower/ui/builder/token_resolver.rb
1006
+ - lib/command_tower/ui/catalog.rb
1007
+ - lib/command_tower/ui/composer.rb
1008
+ - lib/command_tower/ui/document.rb
1009
+ - lib/command_tower/ui/email/layout.rb
1010
+ - lib/command_tower/ui/email/renderer.rb
1011
+ - lib/command_tower/ui/email/renderer/containers.rb
1012
+ - lib/command_tower/ui/email/renderer/inline_nodes.rb
1013
+ - lib/command_tower/ui/email/renderer/styling.rb
1014
+ - lib/command_tower/ui/email/renderer/text_nodes.rb
1015
+ - lib/command_tower/ui/email/styles.rb
1016
+ - lib/command_tower/ui/fragment.rb
1017
+ - lib/command_tower/ui/fragments/cta_group.rb
1018
+ - lib/command_tower/ui/fragments/fact_row.rb
1019
+ - lib/command_tower/ui/fragments/facts.rb
1020
+ - lib/command_tower/ui/fragments/header.rb
1021
+ - lib/command_tower/ui/fragments/notice_frame.rb
1022
+ - lib/command_tower/ui/hardening.rb
1023
+ - lib/command_tower/ui/hostname.rb
1024
+ - lib/command_tower/ui/legacy_mapping.rb
1025
+ - lib/command_tower/ui/limits.rb
1026
+ - lib/command_tower/ui/nodes/action.rb
1027
+ - lib/command_tower/ui/nodes/avatar.rb
1028
+ - lib/command_tower/ui/nodes/badge.rb
1029
+ - lib/command_tower/ui/nodes/banner.rb
1030
+ - lib/command_tower/ui/nodes/base.rb
1031
+ - lib/command_tower/ui/nodes/button.rb
1032
+ - lib/command_tower/ui/nodes/card.rb
1033
+ - lib/command_tower/ui/nodes/code.rb
1034
+ - lib/command_tower/ui/nodes/component.rb
1035
+ - lib/command_tower/ui/nodes/divider.rb
1036
+ - lib/command_tower/ui/nodes/facts.rb
1037
+ - lib/command_tower/ui/nodes/image.rb
1038
+ - lib/command_tower/ui/nodes/instant.rb
1039
+ - lib/command_tower/ui/nodes/key_value.rb
1040
+ - lib/command_tower/ui/nodes/span.rb
1041
+ - lib/command_tower/ui/nodes/stack.rb
1042
+ - lib/command_tower/ui/nodes/stat_tile.rb
1043
+ - lib/command_tower/ui/nodes/text.rb
1044
+ - lib/command_tower/ui/text_derivation.rb
1045
+ - lib/command_tower/ui/time_formatter.rb
1046
+ - lib/command_tower/ui/tokens.rb
1047
+ - lib/command_tower/ui/tokens/ui_token_mapping.json
1048
+ - lib/command_tower/ui/zone_abbreviation.rb
984
1049
  - lib/command_tower/version.rb
985
1050
  - lib/generators/command_tower/configure/USAGE
986
1051
  - lib/generators/command_tower/configure/configure_generator.rb
987
1052
  - lib/tasks/auto_annotate_models.rake
988
1053
  - lib/tasks/install.rake
1054
+ - lib/tasks/ui.rake
989
1055
  - lib/tasks/users.rake
990
1056
  - spec/factories/entity.rb
991
1057
  - spec/factories/impersonation_session.rb