diff --git a/lib/schema.ex b/lib/schema.ex
index 06a9087..53d267e 100644
--- a/lib/schema.ex
+++ b/lib/schema.ex
@@ -230,6 +230,16 @@ defmodule Schema do
SingleRepo.classes()
end
+ @doc """
+ Returns all event classes (with browser information) filtered by extensions.
+ This is meant for the classes HTML page, which needs browser-only metadata such
+ as :_supersedes. Mirrors objects_filter_extensions/1.
+ """
+ @spec classes_filter_extensions(Utils.string_set_t() | nil) :: map()
+ def classes_filter_extensions(extensions) do
+ SingleRepo.classes() |> Utils.filter_items_by_extensions(extensions)
+ end
+
@spec clean_classes_filter_extensions(Utils.string_set_t() | nil) :: map()
def clean_classes_filter_extensions(extensions) do
SingleRepo.clean_classes() |> Utils.filter_items_by_extensions(extensions)
diff --git a/lib/schema_web/controllers/page_controller.ex b/lib/schema_web/controllers/page_controller.ex
index f3b8c5f..bb1b3f9 100644
--- a/lib/schema_web/controllers/page_controller.ex
+++ b/lib/schema_web/controllers/page_controller.ex
@@ -84,9 +84,11 @@ defmodule SchemaWeb.PageController do
@spec classes(Plug.Conn.t(), any) :: Plug.Conn.t()
def classes(conn, params) do
+ params = Map.put_new(params, "extensions", "")
+
data =
- Map.put_new(params, "extensions", "")
- |> SchemaController.classes()
+ SchemaController.parse_options(SchemaController.extensions(params))
+ |> Schema.classes_filter_extensions()
|> sort_by(:uid)
render(conn, "classes.html",
diff --git a/lib/schema_web/templates/page/class.html.eex b/lib/schema_web/templates/page/class.html.eex
index 9d3973f..f2d2c86 100644
--- a/lib/schema_web/templates/page/class.html.eex
+++ b/lib/schema_web/templates/page/class.html.eex
@@ -51,6 +51,7 @@ limitations under the License.
@@ -120,7 +121,7 @@ limitations under the License.
<%= attribute[:group] %> |
<%= raw format_requirement(constraints, attribute_key, attribute) %> |
<%= raw format_type(@conn, attribute) %> |
-
<%= raw format_attribute_desc(attribute_key, attribute) %> |
+
<%= raw format_attribute_desc(attribute_key, attribute, @conn) %> |
<% end %>
diff --git a/lib/schema_web/templates/page/classes.html.eex b/lib/schema_web/templates/page/classes.html.eex
index 86063a2..bb19138 100644
--- a/lib/schema_web/templates/page/classes.html.eex
+++ b/lib/schema_web/templates/page/classes.html.eex
@@ -44,7 +44,7 @@ limitations under the License.
<% else %>
|
<% end %>
-
<%= raw description(class) %> |
+
<%= raw description(class) %><%= raw format_item_supersedes(@conn, class, "classes") %> |
<% end %>
diff --git a/lib/schema_web/templates/page/data_types.html.eex b/lib/schema_web/templates/page/data_types.html.eex
index 3d231cf..b01ebd3 100644
--- a/lib/schema_web/templates/page/data_types.html.eex
+++ b/lib/schema_web/templates/page/data_types.html.eex
@@ -17,6 +17,12 @@ limitations under the License.
<%= raw @data[:description] %>
+ <%= raw object_references_section([
+ %{
+ url: "https://github.com/ocsf/ocsf-docs/blob/main/articles/OCSF-Storage-Strategies.md#data-type-mappings",
+ description: "Data Type Mappings (storage formats, e.g. Apache Iceberg)"
+ }
+ ]) %>
diff --git a/lib/schema_web/templates/page/dictionary.html.eex b/lib/schema_web/templates/page/dictionary.html.eex
index 9dd8f66..7da7224 100644
--- a/lib/schema_web/templates/page/dictionary.html.eex
+++ b/lib/schema_web/templates/page/dictionary.html.eex
@@ -53,7 +53,7 @@ limitations under the License.
@@ -100,7 +101,7 @@ limitations under the License.
<%= raw format_attribute_caption(@conn, @schema, attribute_key, attribute) %> |
<%= raw format_requirement(constraints, attribute_key, attribute) %> |
<%= raw format_type(@conn, attribute) %> |
-
<%= raw format_attribute_desc(attribute_key, attribute) %> |
+
<%= raw format_attribute_desc(attribute_key, attribute, @conn) %> |
<% end %>
diff --git a/lib/schema_web/templates/page/objects.html.eex b/lib/schema_web/templates/page/objects.html.eex
index 9cceabd..c378a9b 100644
--- a/lib/schema_web/templates/page/objects.html.eex
+++ b/lib/schema_web/templates/page/objects.html.eex
@@ -45,7 +45,7 @@ limitations under the License.
<%= object_key_str %> |
<%= raw format_attribute_caption(@conn, @schema, object_key_str, object, false) %> |
<%= raw object_links(@conn, object[:name], object[:_links], :collapse) %> |
-
<%= raw description(object) %> |
+
<%= raw description(object) %><%= raw format_item_supersedes(@conn, object, "objects") %> |
<% end %>
diff --git a/lib/schema_web/templates/page/profile.html.eex b/lib/schema_web/templates/page/profile.html.eex
index a097304..8c17c08 100644
--- a/lib/schema_web/templates/page/profile.html.eex
+++ b/lib/schema_web/templates/page/profile.html.eex
@@ -80,7 +80,7 @@ limitations under the License.
<%= field[:group] %> |
<%= raw format_requirement(nil, key, field) %> |
<%= raw format_type(@conn, field) %> |
-
<%= raw format_attribute_desc(key, field) %> |
+
<%= raw format_attribute_desc(key, field, @conn) %> |
<% end %>
diff --git a/lib/schema_web/views/page_view.ex b/lib/schema_web/views/page_view.ex
index 15df6e4..76e407f 100644
--- a/lib/schema_web/views/page_view.ex
+++ b/lib/schema_web/views/page_view.ex
@@ -672,20 +672,34 @@ defmodule SchemaWeb.PageView do
end
end
- @spec format_attribute_desc(String.t() | atom(), map()) :: any
- def format_attribute_desc(attribute_key, attribute) do
- append_source_references(
- base_format_attribute_desc(attribute_key, attribute, false),
- "
",
+ @spec format_attribute_desc(String.t() | atom(), map(), Plug.Conn.t() | nil) :: any
+ def format_attribute_desc(attribute_key, attribute, conn \\ nil) do
+ append_supersedes(
+ append_superseded_by(
+ append_source_references(
+ base_format_attribute_desc(attribute_key, attribute, false),
+ "
",
+ attribute
+ ),
+ attribute,
+ conn
+ ),
attribute
)
end
- @spec format_dictionary_attribute_desc(String.t() | atom(), map()) :: any
- def format_dictionary_attribute_desc(attribute_key, attribute) do
- append_source_references(
- base_format_attribute_desc(attribute_key, attribute, true),
- "
",
+ @spec format_dictionary_attribute_desc(String.t() | atom(), map(), Plug.Conn.t() | nil) :: any
+ def format_dictionary_attribute_desc(attribute_key, attribute, conn \\ nil) do
+ append_supersedes(
+ append_superseded_by(
+ append_source_references(
+ base_format_attribute_desc(attribute_key, attribute, true),
+ "
",
+ attribute
+ ),
+ attribute,
+ conn
+ ),
attribute
)
end
@@ -745,6 +759,7 @@ defmodule SchemaWeb.PageView do
Map.get(item, :caption, id),
"
",
append_source_references(description(item), item),
+ format_enum_supersedes(item, enum_values),
"
" | acc
]
end
@@ -820,6 +835,168 @@ defmodule SchemaWeb.PageView do
end
end
+ # Appends a "Supersedes" note when this (non-deprecated) attribute replaces one or
+ # more deprecated attributes. The reverse reference is precomputed by the schema
+ # compiler in browser mode as the :_supersedes marker. Unlike the deprecation notice,
+ # this is shown by default so consumers migrating off a deprecated attribute can
+ # discover its replacement from the live attribute.
+ @spec append_supersedes(any(), map()) :: any()
+ defp append_supersedes(html, attribute) do
+ case attribute[:_supersedes] do
+ supersedes when is_list(supersedes) and supersedes != [] ->
+ [html, format_supersedes(supersedes)]
+
+ _ ->
+ html
+ end
+ end
+
+ @spec format_supersedes([map()]) :: any()
+ defp format_supersedes(supersedes) do
+ names =
+ supersedes
+ |> Enum.map(fn entry -> entry[:type] end)
+ |> Enum.map(fn name ->
+ ["", Phoenix.HTML.html_escape(name) |> Phoenix.HTML.safe_to_string(), ""]
+ end)
+ |> Enum.intersperse(", ")
+
+ [
+ " Supersedes deprecated ",
+ names,
+ "
"
+ ]
+ end
+
+ # Appends a "Replaced by" forward link on a DEPRECATED attribute whose replacement
+ # lives in another object or class (a dotted path in @deprecated.superseded_by, e.g.
+ # "job_action.cmd_line"). Renders each replacement path as a link to the target's
+ # page. conn is required to build URLs; when nil (callers that don't pass it) nothing
+ # is appended. Same-scope replacements are handled by the reverse note instead.
+ @spec append_superseded_by(any(), map(), Plug.Conn.t() | nil) :: any()
+ defp append_superseded_by(html, _attribute, nil), do: html
+
+ defp append_superseded_by(html, attribute, conn) do
+ deprecated = attribute[:"@deprecated"]
+
+ superseded_by =
+ if is_map(deprecated), do: deprecated[:superseded_by], else: nil
+
+ case superseded_by do
+ paths when is_list(paths) and paths != [] ->
+ # Only render forward links for cross-container (dotted path) replacements.
+ cross = Enum.filter(paths, fn p -> String.contains?(to_string(p), ".") end)
+
+ if cross == [] do
+ html
+ else
+ [html, format_superseded_by(cross, conn)]
+ end
+
+ _ ->
+ html
+ end
+ end
+
+ @spec format_superseded_by([String.t()], Plug.Conn.t()) :: any()
+ defp format_superseded_by(paths, conn) do
+ links =
+ paths
+ |> Enum.map(fn path -> superseded_by_link(to_string(path), conn) end)
+ |> Enum.intersperse(", ")
+
+ [
+ " Replaced by ",
+ links,
+ "
"
+ ]
+ end
+
+ # Builds a link to the replacement attribute's containing class or object page.
+ # The path's first segment names the container; if it resolves to a class it links
+ # to /classes/, otherwise to /objects/. The full path is shown as the
+ # link text.
+ @spec superseded_by_link(String.t(), Plug.Conn.t()) :: any()
+ defp superseded_by_link(path, conn) do
+ base = path |> String.split(".") |> hd() |> String.split("[") |> hd()
+ escaped = Phoenix.HTML.html_escape(path) |> Phoenix.HTML.safe_to_string()
+
+ kind = if Schema.class(base) != nil, do: "classes", else: "objects"
+ href = SchemaWeb.Router.Helpers.static_path(conn, "/#{kind}/#{base}")
+ ["", escaped, ""]
+ end
+
+ # Renders a "Supersedes" note for an enum value that replaces one or more deprecated
+ # enum values of the same attribute. The :_supersedes marker (precomputed by the
+ # compiler in browser mode) holds the deprecated enum value keys; enum_values is the
+ # full enum map, used to look up each deprecated value's caption for display.
+ @spec format_enum_supersedes(map(), map() | list()) :: any()
+ defp format_enum_supersedes(item, enum_values) do
+ case item[:_supersedes] do
+ supersedes when is_list(supersedes) and supersedes != [] ->
+ labels =
+ supersedes
+ |> Enum.map(fn entry -> to_string(entry[:type]) end)
+ |> Enum.map(fn key ->
+ caption = enum_value_caption(enum_values, key)
+ escaped = Phoenix.HTML.html_escape(caption) |> Phoenix.HTML.safe_to_string()
+ ["", escaped, " [", key, "]"]
+ end)
+ |> Enum.intersperse(", ")
+
+ [
+ " Supersedes deprecated ",
+ labels,
+ "
"
+ ]
+
+ _ ->
+ ""
+ end
+ end
+
+ @spec enum_value_caption(map() | list(), String.t()) :: String.t()
+ defp enum_value_caption(enum_values, key) do
+ entry =
+ Enum.find_value(enum_values, nil, fn {k, v} ->
+ if to_string(k) == key, do: v, else: nil
+ end)
+
+ case entry do
+ nil -> key
+ value -> Map.get(value, :caption, key)
+ end
+ end
+
+ # Renders a "Supersedes" note for a whole class or object that replaces one or more
+ # deprecated classes/objects. The :_supersedes marker is precomputed by the schema
+ # compiler in browser mode. kind is "classes" or "objects" (the route segment), used
+ # to link each deprecated item to its page. Shown by default on the live item's page.
+ @spec format_item_supersedes(any(), map(), String.t()) :: any()
+ def format_item_supersedes(conn, item, kind) do
+ case item[:_supersedes] do
+ supersedes when is_list(supersedes) and supersedes != [] ->
+ links =
+ supersedes
+ |> Enum.map(fn entry -> entry[:type] end)
+ |> Enum.map(fn name ->
+ path = SchemaWeb.Router.Helpers.static_path(conn, "/#{kind}/#{name}")
+ escaped = Phoenix.HTML.html_escape(name) |> Phoenix.HTML.safe_to_string()
+ ["", escaped, ""]
+ end)
+ |> Enum.intersperse(", ")
+
+ [
+ " Supersedes deprecated ",
+ links,
+ "
"
+ ]
+
+ _ ->
+ ""
+ end
+ end
+
def constraints(rules) do
Enum.reduce(rules, [], fn {name, list}, acc ->
constraints(name, list, acc)
diff --git a/mix.exs b/mix.exs
index a0e4897..ba8e5b5 100644
--- a/mix.exs
+++ b/mix.exs
@@ -10,7 +10,7 @@
defmodule Schema.MixProject do
use Mix.Project
- @version "4.4.0"
+ @version "4.5.0"
def project do
build = System.get_env("GITHUB_RUN_NUMBER") || "SNAPSHOT"
diff --git a/priv/static/css/components.css b/priv/static/css/components.css
index f34a025..ae78222 100644
--- a/priv/static/css/components.css
+++ b/priv/static/css/components.css
@@ -883,3 +883,60 @@ button:hover,
[data-theme="dark"] .deprecated-attr-notice i {
color: #FBBF24;
}
+
+.supersedes-note {
+ display: block;
+ background: rgba(8, 145, 178, 0.06);
+ border-left: 3px solid var(--accent-color);
+ border-radius: var(--radius-md);
+ padding: var(--spacing-xs) var(--spacing-sm);
+ margin-top: var(--spacing-sm);
+ font-size: var(--text-sm);
+ color: var(--text-secondary);
+ line-height: 1.8;
+}
+
+.supersedes-note i {
+ color: var(--accent-color);
+ font-size: var(--text-sm);
+ margin-right: var(--spacing-sm);
+}
+
+.supersedes-note code {
+ background: transparent;
+ padding: 0;
+ white-space: nowrap;
+}
+
+.superseded-by-note {
+ display: block;
+ background: rgba(217, 119, 6, 0.06);
+ border-left: 3px solid var(--warning-color);
+ border-radius: var(--radius-md);
+ padding: var(--spacing-xs) var(--spacing-sm);
+ margin-top: var(--spacing-sm);
+ font-size: var(--text-sm);
+ color: var(--text-secondary);
+ line-height: 1.8;
+}
+
+.superseded-by-note i {
+ color: var(--warning-color);
+ font-size: var(--text-sm);
+ margin-right: var(--spacing-sm);
+}
+
+.superseded-by-note code {
+ background: transparent;
+ padding: 0;
+ white-space: nowrap;
+}
+
+[data-theme="dark"] .superseded-by-note {
+ background: rgba(251, 191, 36, 0.06);
+ border-left-color: #FBBF24;
+}
+
+[data-theme="dark"] .superseded-by-note i {
+ color: #FBBF24;
+}