Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a114afb
Add a Sanity.io plugin
andrewmumblebee Jun 17, 2026
604a72c
index sanity datasets using dependent imports
andrewmumblebee Jun 18, 2026
3dd494a
Use scoped dataset datastreams
andrewmumblebee Jun 18, 2026
1a2cbea
Add dataset stats dataStream
andrewmumblebee Jun 18, 2026
6b65bc8
Update Sanity data stream tags
andrewmumblebee Jun 24, 2026
b255f92
Sanity plugin cleanup
andrewmumblebee Jul 1, 2026
b91fd2f
Reduce dataStreams down to useful ones
andrewmumblebee Jul 15, 2026
b1535bd
Show recently updated documents in the GROQ tile
andrewmumblebee Jul 15, 2026
328dcfd
Show dataset limit usage on the Dataset dashboard
andrewmumblebee Jul 15, 2026
bb5984e
Add an Overview dashboard summarising the org
andrewmumblebee Jul 15, 2026
edcbddc
Explain the missing token when content tiles fail
andrewmumblebee Jul 15, 2026
76ca3db
Index only projects with a configured token
andrewmumblebee Jul 15, 2026
90c2cb9
Show every project's token status on the Overview
andrewmumblebee Jul 15, 2026
860eb18
Keep description to one sentence
andrewmumblebee Jul 15, 2026
8cabb6e
update readme
andrewmumblebee Jul 15, 2026
86a8c84
Escape project names in token error messages
andrewmumblebee Jul 15, 2026
951cd19
Derive dataset uid and displayName in the script
andrewmumblebee Jul 15, 2026
6fccd09
Parse project createdAt as a date
andrewmumblebee Jul 15, 2026
ce72435
Describe the document type counts query
andrewmumblebee Jul 15, 2026
54125d7
Match dashboard timeframes to their tiles
andrewmumblebee Jul 15, 2026
e7ab531
Give overview project tiles distinct titles
andrewmumblebee Jul 15, 2026
9610e46
Give each dashboard tile a unique GUID
andrewmumblebee Jul 15, 2026
d3b5ed5
Document correct admin token creation steps
andrewmumblebee Jul 15, 2026
705796a
Index members per project membership
andrewmumblebee Jul 15, 2026
d4e1471
Scope member roles to the imported project
andrewmumblebee Jul 15, 2026
02103b7
Load error handling scripts from script files
andrewmumblebee Jul 15, 2026
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
13 changes: 13 additions & 0 deletions plugins/Sanity/v1/configValidation.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"steps": [
{
"displayName": "Authenticate",
"dataStream": {
"name": "listProjects"
},
"required": true,
"success": "Connected to the Sanity management API.",
"error": "Could not list projects. Check your Admin API token is valid and has access to your projects."
}
]
}
16 changes: 16 additions & 0 deletions plugins/Sanity/v1/custom_types.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"name": "Project",
"sourceType": "Project",
"icon": "layer-group",
"singular": "Project",
"plural": "Projects"
},
{
"name": "Dataset",
"sourceType": "Dataset",
"icon": "layer-group",
"singular": "Dataset",
"plural": "Datasets"
}
]
45 changes: 45 additions & 0 deletions plugins/Sanity/v1/dataStreams/allProjects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "allProjects",
"displayName": "All Projects",
"description": "Every project the admin token can see, flagging which have a content API token configured",
"tags": ["Project"],
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "get",
"paging": {
"mode": "none"
},
"expandInnerObjects": false,
"endpointPath": "projects",
"getArgs": [],
"headers": [],
"postRequestScript": "allProjects.js"
},
"metadata": [
{
"name": "displayName",
"shape": "string",
"displayName": "Name",
"role": "label"
},
{
"name": "tokenStatus",
"displayName": "Token Status",
"shape": [
"state",
{
"map": {
"success": ["configured"],
"error": ["missing"]
}
}
]
},
{
"name": "id",
"shape": "string",
"displayName": "Project ID"
}
],
"timeframes": false
}
69 changes: 69 additions & 0 deletions plugins/Sanity/v1/dataStreams/customQuery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
{
"name": "customQuery",
"displayName": "Custom GROQ Query",
"description": "Run an arbitrary GROQ query against a dataset",
"tags": ["Documents"],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Dataset"
}
},
"providesPluginDiagnostics": true,
"config": {
"baseUrl": "https://{{object.projectId}}.api.sanity.io/{{dataSource.apiVersion}}/",
"httpMethod": "get",
"errorHandling": {
"type": "script",
"script": "const hasToken = {{ !!((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}; const apiMsg = data && (data.message || (typeof data.error === 'string' ? data.error : (data.error || {}).description)); result = hasToken ? (apiMsg || ('Request failed with HTTP ' + response.status)) : 'No API token is configured for project {{object.projectId}} (which this dataset belongs to). Add its Project ID and API token under Project API tokens in the Sanity data source settings to query it.';"
},
"paging": {
"mode": "none"
},
"expandInnerObjects": true,
"endpointPath": "data/query/{{object.datasetId}}",
"pathToData": "result",
"getArgs": [
{
"key": "query",
"value": "{{query}}"
},
{
"key": "perspective",
"value": "{{perspective}}"
}
],
"headers": [
{
"key": "Authorization",
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
}
]
},
"ui": [
{
"type": "code",
"name": "query",
"language": "groq",
"label": "GROQ query",
"defaultValue": "*[ !(_id in path(\"_.**\")) ] | order(_updatedAt desc) [0...20] {_id, _type, _updatedAt}",
"validation": { "required": true },
"help": "See [GROQ query cheat sheet](https://www.sanity.io/docs/content-lake/query-cheat-sheet) for patterns"
},
{
"type": "switch",
"name": "perspective",
"label": "Perspective",
"defaultValue": "published",
"options": [
{ "value": "published", "label": "Published" },
{ "value": "drafts", "label": "Drafts" },
{ "value": "raw", "label": "Raw" }
]
}
],
"metadata": [{ "pattern": ".*" }],
"timeframes": false,
"manualConfigApply": true
}
97 changes: 97 additions & 0 deletions plugins/Sanity/v1/dataStreams/datasetStats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"name": "datasetStats",
"displayName": "Dataset Stats",
"description": "Get stats on how close to usage limits this dataset is",
"tags": ["Analytics"],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Dataset"
}
},
"config": {
"baseUrl": "https://{{object.projectId}}.api.sanity.io/v1/",
"httpMethod": "get",
"errorHandling": {
"type": "script",
"script": "const hasToken = {{ !!((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}; const apiMsg = data && (data.message || (typeof data.error === 'string' ? data.error : (data.error || {}).description)); result = hasToken ? (apiMsg || ('Request failed with HTTP ' + response.status)) : 'No API token is configured for project {{object.projectId}} (which this dataset belongs to). Add its Project ID and API token under Project API tokens in the Sanity data source settings to see its usage stats.';"
},
"paging": {
"mode": "none"
},
"endpointPath": "data/stats/{{object.datasetId}}",
"getArgs": [],
"headers": [
{
"key": "Authorization",
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
}
],
"expandInnerObjects": true,
"postRequestScript": "datasetStats.js"
},
"metadata": [
{
"name": "dataset",
"displayName": "Dataset",
"shape": "string",
"role": "label"
},
{
"name": "documentsPctOfLimit",
"displayName": "Documents (% of limit)",
"shape": "percent",
"role": "value"
},
{
"name": "fieldsPctOfLimit",
"displayName": "Fields (% of limit)",
"shape": "percent"
},
{
"name": "jsonSizePctOfLimit",
"displayName": "JSON Size (% of limit)",
"shape": "percent"
},
{
"name": "releasesPctOfLimit",
"displayName": "Releases (% of limit)",
"shape": "percent"
},
{
"name": "documents.count.value",
"displayName": "Documents",
"shape": "number"
},
{
"name": "documents.count.limit",
"displayName": "Document Limit",
"shape": "number"
},
{
"name": "fields.count.value",
"displayName": "Fields",
"shape": "number"
},
{
"name": "fields.count.limit",
"displayName": "Field Limit",
"shape": "number"
},
{
"name": "documents.jsonSizeSum.value",
"displayName": "JSON Size",
"shape": "bytes"
},
{
"name": "documents.jsonSizeSum.limit",
"displayName": "JSON Size Limit",
"shape": "bytes"
},
{
"pattern": ".*"
}
],
"timeframes": false
}
80 changes: 80 additions & 0 deletions plugins/Sanity/v1/dataStreams/datasets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"name": "datasets",
"displayName": "Datasets",
"description": "Lists the datasets in a project, with their access-control mode",
"tags": ["Datasets"],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Project"
}
},
"config": {
"httpMethod": "get",
"errorHandling": {
"type": "script",
"script": "errorHandling/datasets.js"
},
Comment thread
andrewmumblebee marked this conversation as resolved.
"paging": {
"mode": "none"
},
"expandInnerObjects": true,
"endpointPath": "projects/{{object.rawId}}/datasets",
"getArgs": [],
"postRequestScript": "datasets.js",
"headers": [
{
"key": "Authorization",
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.rawId) || {}).value }}"
}
]
},
"metadata": [
{
"name": "projectId",
"displayName": "Project ID",
"shape": "string",
"visible": false
},
{
"name": "datasetId",
"shape": "string",
"displayName": "Dataset",
"role": "label"
},
{
"name": "aclMode",
"shape": "string",
"displayName": "Access mode"
},
{
"name": "createdAt",
"shape": "date",
"displayName": "Created At"
},
{
"name": "createdByUserId",
"shape": "string",
"displayName": "Created By User Id"
},
{
"name": "projectName",
"displayName": "Project Name",
"shape": "string"
},
{
"name": "uid",
"displayName": "uid",
"shape": "string",
"visible": false
},
{
"name": "displayName",
"displayName": "Display Name",
"shape": "string",
"visible": false
Comment thread
andrewmumblebee marked this conversation as resolved.
}
],
"timeframes": false
}
52 changes: 52 additions & 0 deletions plugins/Sanity/v1/dataStreams/listProjects.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "listProjects",
"displayName": "Projects",
"description": "Lists the projects that have a content API token configured",
"tags": ["Project"],
"baseDataSourceName": "httpRequestUnscoped",
"config": {
"httpMethod": "get",
"paging": {
"mode": "none"
},
"expandInnerObjects": false,
"endpointPath": "projects",
"getArgs": [],
"headers": [],
"postRequestScript": "listProjects.js"
},
"metadata": [
{
"name": "id",
"shape": "string",
"displayName": "Project ID"
},
{
"name": "displayName",
"shape": "string",
"displayName": "Name"
},
{
"name": "organizationId",
"shape": "string",
"displayName": "Organization ID"
},
{
"name": "studioHost",
"shape": "string",
"displayName": "Studio host"
},
{
"name": "createdAt",
"shape": "date",
"displayName": "Created"
Comment thread
andrewmumblebee marked this conversation as resolved.
},
{
"pattern": ".*"
}
],
"timeframes": false,
"visibility": {
"type": "hidden"
}
}
Loading
Loading