Library comparison

Use this page when you want to compare two libraries directly, such as Development versus Staging, and produce review-ready payloads with revision IDs attached. This is the SDK entry point for library-wide code review workflows.

Workflowclient.libraries.compare

Compare API

AttributeData typeDescription
compare(current_library_id, baseline_library_id:, property_id:)
LibraryComparison

Compares the top-level rules, data elements, and extensions in two libraries from the same property. Each result entry includes the current and baseline revision IDs, a computed status, and comprehensive review objects that are ready for review tooling.

entries
Array<LibraryComparisonEntry>

Returns the ordered comparison entries. Each entry reports added, removed, modified, or unchanged.

Review workflow

Compare Development against Staging

# LB_DEV = current library ID, usually the library you are reviewing.
# LB_STG = baseline library ID, usually the library you want to compare against.
# PR123 = property ID that owns both libraries.
comparison = client.libraries.compare(
  "LB_DEV",
  baseline_library_id: "LB_STG",
  property_id: "PR123"
)

# Print the library names that anchor the comparison.
puts comparison.current_snapshot.library.name
puts comparison.baseline_snapshot.library.name

# Walk every compared resource in the SDK's deterministic review order.
comparison.entries.each do |entry|
  # rules | data_elements | extensions
  puts entry.resource_type
  # Adobe resource ID, for example RL..., DE..., or EX...
  puts entry.resource_id
  # Human-readable resource name when Adobe provides one.
  puts entry.resource_name
  # added | removed | modified | unchanged
  puts entry.status
  # Revision IDs used for the comparison.
  puts entry.current_revision_id
  puts entry.baseline_revision_id
end

The comparison result is built from LibrarySnapshot, so it stays aligned with the specific two libraries you pass in. That matters for review accuracy because impact analysis and associated records are resolved from each library snapshot, not from the property head.

Sample output

Example comparison summary output

# Example of turning the comparison entries into a simple review summary.
pp comparison.entries.map { |entry|
  {
    resource_type: entry.resource_type,
    resource_id: entry.resource_id,
    resource_name: entry.resource_name,
    status: entry.status,
    current_revision_id: entry.current_revision_id,
    baseline_revision_id: entry.baseline_revision_id
  }
}

Sample output

[
  {
    // Rule exists in both libraries, but the revision changed.
    "resource_type": "rules",
    "resource_id": "RL100",
    "resource_name": "Checkout Rule",
    "status": "modified",
    "current_revision_id": "RE_CUR_RULE",
    "baseline_revision_id": "RE_BASE_RULE"
  },
  {
    // Rule exists only in the current library.
    "resource_type": "rules",
    "resource_id": "RL200",
    "resource_name": "Added Rule",
    "status": "added",
    "current_revision_id": "RE_ADDED",
    "baseline_revision_id": null
  },
  {
    // Data element exists only in the baseline library.
    "resource_type": "data_elements",
    "resource_id": "DE200",
    "resource_name": "Removed Element",
    "status": "removed",
    "current_revision_id": null,
    "baseline_revision_id": "RE_REMOVED"
  },
  {
    // Extension exists in both libraries at the same revision.
    "resource_type": "extensions",
    "resource_id": "EX100",
    "resource_name": "Core",
    "status": "unchanged",
    "current_revision_id": "RE_EX",
    "baseline_revision_id": "RE_EX"
  }
]

Normalized output

Inspect normalized review output for one entry

# LB_DEV = current library ID.
# LB_STG = baseline library ID.
# PR123 = property ID.
comparison = client.libraries.compare(
  "LB_DEV",
  baseline_library_id: "LB_STG",
  property_id: "PR123"
)

entry = comparison.entries.find { |item| item.resource_id == "RL100" }

# Review the status and revision IDs first.
puts entry.status
puts entry.current_revision_id
puts entry.baseline_revision_id

# Then inspect the normalized JSON emitted for each side.
puts entry.current_normalized_json
puts entry.baseline_normalized_json

Example normalized rule payload

{
  // Normalized payload for the current library's version of the rule.
  "kind": "rule",
  "id": "RL100",
  "name": "Checkout Rule",
  "attributes": {
    "enabled": true
  },
  "launch_raw": {
    "id": "RL100",
    "type": "rules",
    "attributes": {
      "name": "Checkout Rule",
      "enabled": true
    }
  },
  "configuration": null,
  "normalization_status": "none",
  "associations": {
    "rule_components": [
      {
        "kind": "rule_component",
        "id": "RC100",
        "name": "Send Event",
        "delegate_descriptor_id": "adobe-alloy::actions::send-event",
        "attributes": {
          "order": 1,
          "rule_order": 10.0
        },
        "configuration": {
          "xdm": {
            "web": {
              "webPageDetails": {
                "name": "%Page Name%"
              }
            }
          }
        },
        "normalization_status": "normalized"
      }
    ]
  }
}

For rule entries, the normalized JSON includes the rule components associated with the rule in each snapshot. For data elements, the payload includes referenced data elements and impacted rules. For extensions, the payload includes dependent data elements, rule components, and rules. That gives the reviewer the surrounding context they usually need without forcing them to reconstruct it manually.

Was this page helpful?