Module: InlineFormsSchemaEdit::BatchExport
- Defined in:
- lib/inline_forms_schema_edit/batch_export.rb
Overview
Serializes a frozen SchemaBatch for transport to the CI/dev side, sealed with a content digest. The digest is computed over the canonical JSON of the ordered intent list only (not timestamps/ids), so the same logical batch always digests identically; SchemaBatch#submit! stores it and BatchImport re-verifies it before replaying.
Constant Summary collapse
- FORMAT =
1
Class Method Summary collapse
Class Method Details
.digest_for(batch) ⇒ Object
17 18 19 20 |
# File 'lib/inline_forms_schema_edit/batch_export.rb', line 17 def digest_for(batch) canonical = JSON.generate(batch.intents.reload.map(&:as_export)) "sha256:#{Digest::SHA256.hexdigest(canonical)}" end |
.payload(batch) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/inline_forms_schema_edit/batch_export.rb', line 22 def payload(batch) { "format" => FORMAT, "batch" => { "id" => batch.id, "status" => batch.status, "requested_by" => batch.requested_by, "submitted_at" => batch.submitted_at&.iso8601, "window_at" => batch.window_at&.iso8601 }, "intents" => batch.intents.map(&:as_export), "digest" => batch.content_digest || digest_for(batch) } end |
.to_json(batch) ⇒ Object
37 38 39 |
# File 'lib/inline_forms_schema_edit/batch_export.rb', line 37 def to_json(batch) JSON.pretty_generate(payload(batch)) end |