foobara-aws 0.2.0 → 0.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: 4d08fb1f5a14798c744facb5a4f0a3986b544482f486b3962b90d8248b20bfab
4
- data.tar.gz: 568943fcb7e647eb2fd620b0430076a173065bc8760ce8c0d6ec7cc7f89a8017
3
+ metadata.gz: 16a858ce4e2944711259dacbf844fd258a1715018aaa7df98364e45739ec33de
4
+ data.tar.gz: 995b9e3af507e6cb53e3fd581945d27b9251f9559f0151c9151e5fa5bb277191
5
5
  SHA512:
6
- metadata.gz: aae339846f621a18ccb328143d5543aa6b3cc42ab8e0f8429cbb8c2f69c156bf7000286fa6e3fa488a838cec557244581de972229320f38c5ea6d9cd28123f00
7
- data.tar.gz: d02982c0c6f67749b548f411f246f614778f59af62043bd529f4227006ed83b06c9302af32271e388b60a90866be94104947859cc4a066f442a7dc28960745b5
6
+ metadata.gz: a328cae1d9959faa1efc89dc399f007005673493704ae20dbe9e02904b85949f7eb76debefeff09830f2a367315efac9bde77981c660690299aced88f5871464
7
+ data.tar.gz: a0cb8f25daa37b5ea097d5bf13e145c0a7df3a27b2d6faa801e426dafb3f8f00def81a55093d7c95818cd2caf32b2d7bbe7c6f3864248993b099f749d1218d52
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.3.0] - 2026-08-04
4
+
5
+ - `Foobara::AWS.plan_from_connector(connector)` — build a plan by inspecting a live connector instead of a
6
+ manifest. No HTTP, no running server, and no snapshot on disk to go stale.
7
+ - It takes a CONNECTOR rather than a set of command classes, because `requires_authentication` is decided at
8
+ `connect` time and lives on the transformed command. The command classes alone cannot say which commands are
9
+ public, which is the one thing a deployment most needs to know.
10
+ - It adapts each command into the shape `plan` already reads, so there is a single derivation and the two routes
11
+ cannot drift — asserted by a spec comparing the plans they produce.
12
+
3
13
  ## [0.2.0] - 2026-08-04
4
14
 
5
15
  - `Foobara::AWS::Check` — checks a DEPLOYED API against the plan it was deployed from. It asserts the few things
data/README.md CHANGED
@@ -15,6 +15,22 @@ service = Foobara::AWS::CDK::Service.new(self, "Api", plan: plan, code_root: "bu
15
15
  posts_table.grant_read_write_data(service.function("posts"))
16
16
  ```
17
17
 
18
+ ## Where a plan comes from
19
+
20
+ ```ruby
21
+ Foobara::AWS.plan(manifest) # a manifest, however you obtained it
22
+ Foobara::AWS.plan_from_connector(connector) # a live connector, no server needed
23
+ Foobara::AWS::Plan.load(JSON.parse(json)) # one that has been through JSON
24
+ ```
25
+
26
+ `plan_from_connector` is usually what a build step wants: it reads the objects
27
+ directly, so there is no server to start and no snapshot to go stale. It takes a
28
+ **connector**, not a set of command classes — `requires_authentication` is
29
+ decided at `connect` time and lives on the transformed command, so the classes
30
+ alone cannot say which commands are public.
31
+
32
+ All three produce the same `Plan`, and a spec asserts the first two agree.
33
+
18
34
  ## Two halves, on purpose
19
35
 
20
36
  ```ruby
@@ -85,6 +85,28 @@ module Foobara
85
85
  Plan.new(mount: mount, granularity: granularity, units: units.sort_by(&:name))
86
86
  end
87
87
 
88
+ # Build a {Plan} by inspecting a live connector instead of a manifest.
89
+ #
90
+ # The same information by a shorter route: no HTTP, no running server, and
91
+ # no snapshot on disk to go stale. It needs the application loaded, so it
92
+ # belongs in a build step rather than in a CDK app — which is the whole
93
+ # reason a {Plan} can also travel as JSON.
94
+ #
95
+ # A CONNECTOR, not a set of command classes. `requires_authentication` is
96
+ # decided at `connect` time and lives on the transformed command, so the
97
+ # command classes alone cannot say which commands are public — which is the
98
+ # one thing a deployment most needs to know.
99
+ #
100
+ # It adapts each command into the shape {plan} already reads, so there is
101
+ # one implementation and the two routes cannot drift.
102
+ def plan_from_connector(connector, **)
103
+ commands = connector.command_registry.all_transformed_command_classes.to_h do |transformed|
104
+ [transformed.command_class.full_command_name, describe_command(transformed)]
105
+ end
106
+
107
+ plan({ "command" => commands }, **)
108
+ end
109
+
88
110
  # Foobara's own commands — its auth domain and anything else it registers —
89
111
  # are infrastructure, not the application, and deploying them is never what
90
112
  # anyone means. Matched on the command's full name, which is where that
@@ -97,6 +119,35 @@ module Foobara
97
119
 
98
120
  private
99
121
 
122
+ # Manifest-shaped, so {plan} cannot tell the difference. Only the fields
123
+ # planning reads — a manifest carries much more, and none of the rest
124
+ # matters here.
125
+ def describe_command(transformed)
126
+ command_class = transformed.command_class
127
+
128
+ {
129
+ "domain" => domain_name(command_class),
130
+ "organization" => organization_name(command_class),
131
+ "scoped_full_path" => Array(command_class.scoped_full_path),
132
+ "requires_authentication" => transformed.requires_authentication,
133
+ "depends_on" => Array(command_class.depends_on).map(&:to_s),
134
+ # The AWSLambda DSL, when the command extends it.
135
+ "aws_lambda" => (command_class.aws_lambda_manifest if command_class.respond_to?(:aws_lambda_manifest))
136
+ }.compact
137
+ end
138
+
139
+ def domain_name(command_class)
140
+ command_class.domain.scoped_full_name
141
+ rescue StandardError
142
+ ""
143
+ end
144
+
145
+ def organization_name(command_class)
146
+ command_class.organization.scoped_full_name
147
+ rescue StandardError
148
+ ""
149
+ end
150
+
100
151
  def app_commands(manifest, exclude)
101
152
  manifest.fetch("command").reject do |name, _command|
102
153
  exclude.any? { |prefix| name.to_s.start_with?(prefix) }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Foobara
4
4
  module AWS
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-aws
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Omar Qureshi