Module: Ecoportal::API::GraphQL::Input::WorkflowCommand::EditTemplateContainerUid

Defined in:
lib/ecoportal/api/graphql/input/workflow_command/edit_template_container_uid.rb

Overview

WorkflowEditTemplateContainerUidInput { templateContainerUid: String! }.

Sets the template's CROSS-VERSION identity key. Semantics (verified against the backend on 2026-07-31 — see .ai-assistance/code/ecoPortal_architecture/02_data_model.md):

  • Format /\A[a-zA-Z0-9\-_.]{3,20}\z/ — org-scoped, human-authored.
  • Many versions of a template may share one uid, but only ONE may be published (active: true, unarchived) per organization at a time. Publishing another with the same uid UNPUBLISHES the incumbent (a swap, not an error), which is what stops restored UAT backups from colliding with the live PROD template.
  • Rejected with :template_container_uid, :taken when the swap is not permitted.
  • Requires Pages::TemplatePolicy#change_template_container_uid? (required_level: :implement).

The value is REQUIRED and non-null in the schema, so nil is rejected here rather than silently dropped — .compact (as used by the sibling builders) would emit an empty command that the server rejects with a less obvious message.

Constant Summary collapse

SCHEMA_VERSION =
'20260731'.freeze
VALID_KEYS =
%i[templateContainerUid].freeze
UID_FORMAT =
/\A[a-zA-Z0-9\-_.]{3,20}\z/

Class Method Summary collapse

Class Method Details

.build(**kwargs) ⇒ Object

Raises:

  • (ArgumentError)


28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/ecoportal/api/graphql/input/workflow_command/edit_template_container_uid.rb', line 28

def self.build(**kwargs)
  uid = kwargs[:templateContainerUid]
  raise ArgumentError, 'templateContainerUid is required (String!)' if uid.nil?

  unless UID_FORMAT.match?(uid.to_s)
    raise ArgumentError,
          "Invalid templateContainerUid #{uid.inspect}: " \
          'use 3-20 characters (letters, numbers, -, _, . only)'
  end

  { templateContainerUid: uid.to_s }
end