Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions contracts/mdbase.view/1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
kind: mdbase.contract
contract_type: record
id: mdbase.view
version: 1.0.0
name: Saved view
description: Shared query scope and stable named views executable through the Query profile.
record_schema:
dialect: json-schema-2020-12
ref: ../../schemas/mdbase.view/1.0.0.schema.json
---

# Saved view

A record exposed through `mdbase.view` stores shared query scope and one or more
stable named views. Each named view resolves to the query model in Chapter 11.
Optional `presentation` metadata is advisory and does not alter headless query
results.

Implementing this contract is how a collection declares which of its records
are saved views. A tool that advertises `view_records` discovers and executes
views through this contract's type implementations, not through a reserved type
name, path, or frontmatter value.

This artifact is passive. Implementing it grants no authority to read, execute,
or modify any record.
26 changes: 26 additions & 0 deletions dist/artifacts/contracts/mdbase.view/1.0.0.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
kind: mdbase.contract
contract_type: record
id: mdbase.view
version: 1.0.0
name: Saved view
description: Shared query scope and stable named views executable through the Query profile.
record_schema:
dialect: json-schema-2020-12
ref: ../../schemas/mdbase.view/1.0.0.schema.json
---

# Saved view

A record exposed through `mdbase.view` stores shared query scope and one or more
stable named views. Each named view resolves to the query model in Chapter 11.
Optional `presentation` metadata is advisory and does not alter headless query
results.

Implementing this contract is how a collection declares which of its records
are saved views. A tool that advertises `view_records` discovers and executes
views through this contract's type implementations, not through a reserved type
name, path, or frontmatter value.

This artifact is passive. Implementing it grants no authority to read, execute,
or modify any record.
261 changes: 261 additions & 0 deletions dist/artifacts/schemas/mdbase.view/1.0.0.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,261 @@
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://mdbase.dev/schemas/v0.3/view.schema.json",
"title": "mdbase.view 1.0.0 record contract view",
"description": "The contract view of a saved-view record. A type implements mdbase.view by mapping these fields; the optional type property only lets the canonical view type validate its own membership value.",
"type": "object",
"required": ["id", "version", "name", "views"],
"properties": {
"type": { "type": "string", "minLength": 1 },
"id": { "$ref": "#/$defs/identifier" },
"version": { "type": "integer", "minimum": 1 },
"name": { "type": "string", "minLength": 1 },
"description": { "type": "string" },
"query": { "$ref": "#/$defs/sharedQuery" },
"properties": { "$ref": "#/$defs/propertyMetadataSet" },
"summary_functions": { "$ref": "#/$defs/summaryFunctionSet" },
"views": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/view" }
}
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false,
"$defs": {
"identifier": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9._:-]*$"
},
"typeName": {
"type": "string",
"pattern": "^[A-Za-z][A-Za-z0-9_-]{0,127}$"
},
"fieldName": {
"type": "string",
"pattern": "^[A-Za-z_][A-Za-z0-9_:-]*$"
},
"expression": {
"type": "string",
"minLength": 1
},
"extension": {
"type": "object",
"additionalProperties": true
},
"typeList": {
"type": "array",
"minItems": 1,
"uniqueItems": true,
"items": { "$ref": "#/$defs/typeName" }
},
"sharedQuery": {
"type": "object",
"properties": {
"types": { "$ref": "#/$defs/typeList" },
"where": { "$ref": "#/$defs/expression" },
"context": { "$ref": "#/$defs/viewContext" },
"projections": { "$ref": "#/$defs/projectionSet" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"viewContext": {
"type": "object",
"required": ["this"],
"properties": {
"this": { "$ref": "#/$defs/thisContext" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"thisContext": {
"type": "object",
"properties": {
"on_missing": {
"enum": ["view", "null", "error"],
"default": "view"
},
"types": { "$ref": "#/$defs/typeList" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"projectionSet": {
"type": "object",
"propertyNames": { "$ref": "#/$defs/fieldName" },
"additionalProperties": { "$ref": "#/$defs/projection" }
},
"projection": {
"type": "object",
"required": ["expr"],
"properties": {
"expr": { "$ref": "#/$defs/expression" },
"description": { "type": "string" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"propertyMetadataSet": {
"type": "object",
"propertyNames": { "type": "string", "minLength": 1 },
"additionalProperties": { "$ref": "#/$defs/propertyMetadata" }
},
"propertyMetadata": {
"type": "object",
"properties": {
"label": { "type": "string" },
"description": { "type": "string" },
"format": { "type": "string" },
"hidden": { "type": "boolean" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"summaryFunctionSet": {
"type": "object",
"propertyNames": { "$ref": "#/$defs/fieldName" },
"additionalProperties": { "$ref": "#/$defs/summaryFunction" }
},
"summaryFunction": {
"type": "object",
"required": ["expr"],
"properties": {
"expr": { "$ref": "#/$defs/expression" },
"description": { "type": "string" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"view": {
"type": "object",
"required": ["id", "name"],
"properties": {
"id": { "$ref": "#/$defs/identifier" },
"name": { "type": "string", "minLength": 1 },
"description": { "type": "string" },
"types": { "$ref": "#/$defs/typeList" },
"where": { "$ref": "#/$defs/expression" },
"context": { "$ref": "#/$defs/viewContext" },
"projections": { "$ref": "#/$defs/projectionSet" },
"select": { "$ref": "#/$defs/select" },
"order_by": { "$ref": "#/$defs/orderBy" },
"group_by": { "$ref": "#/$defs/groupBy" },
"summaries": { "$ref": "#/$defs/summaries" },
"limit": { "type": "integer", "minimum": 0 },
"offset": { "type": "integer", "minimum": 0 },
"include_body": { "type": "boolean", "default": false },
"frontmatter_mode": {
"enum": ["effective", "persisted", "both"],
"default": "effective"
},
"presentation": { "$ref": "#/$defs/presentation" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"select": {
"type": "array",
"minItems": 1,
"items": {
"oneOf": [
{ "type": "string", "minLength": 1 },
{ "$ref": "#/$defs/selectExpression" }
]
}
},
"selectExpression": {
"type": "object",
"required": ["name", "expr"],
"properties": {
"name": { "$ref": "#/$defs/fieldName" },
"expr": { "$ref": "#/$defs/expression" },
"label": { "type": "string" },
"description": { "type": "string" }
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
},
"orderBy": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["field"],
"properties": {
"field": { "type": "string", "minLength": 1 },
"direction": { "enum": ["asc", "desc"], "default": "asc" }
},
"additionalProperties": false
}
},
"groupBy": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["field"],
"properties": {
"field": { "type": "string", "minLength": 1 },
"direction": { "enum": ["asc", "desc"], "default": "asc" }
},
"additionalProperties": false
}
},
"summaries": {
"type": "array",
"minItems": 1,
"items": { "$ref": "#/$defs/summary" }
},
"summary": {
"type": "object",
"required": ["field", "function"],
"properties": {
"field": { "type": "string", "minLength": 1 },
"function": { "$ref": "#/$defs/identifier" },
"name": { "$ref": "#/$defs/fieldName" },
"label": { "type": "string" }
},
"additionalProperties": false
},
"presentation": {
"type": "object",
"required": ["type"],
"properties": {
"type": { "$ref": "#/$defs/identifier" },
"fallback": { "$ref": "#/$defs/identifier" },
"mappings": {
"type": "object",
"propertyNames": { "$ref": "#/$defs/fieldName" },
"additionalProperties": { "type": "string", "minLength": 1 }
},
"options": {
"type": "object",
"additionalProperties": true
}
},
"patternProperties": {
"^x-[A-Za-z][A-Za-z0-9._:-]{0,127}$": { "$ref": "#/$defs/extension" }
},
"additionalProperties": false
}
}
}
Loading
Loading