Skip to content
Draft
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
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"
}
]
75 changes: 75 additions & 0 deletions plugins/Sanity/v1/dataStreams/changeHistory.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"name": "changeHistory",
"displayName": "Change History",
"description": "Transaction history for a dataset β€” every content change with timestamp, author, and affected document count",
"tags": ["Documents"],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Dataset"
}
},
"config": {
"baseUrl": "https://{{object.projectId}}.api.sanity.io/{{dataSource.apiVersion}}/",
"httpMethod": "get",
"paging": {
"mode": "none"
},
"endpointPath": "data/history/{{object.datasetId}}/transactions",
"getArgs": [
{ "key": "excludeContent", "value": "true" },
{ "key": "reverse", "value": "true" },
{ "key": "limit", "value": "100" },
{ "key": "fromTime", "value": "{{timeframe.start}}" },
{ "key": "toTime", "value": "{{timeframe.end}}" }
],
"headers": [
{
"key": "Authorization",
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
}
],
"postRequestScript": "changeHistory.js"
},

"metadata": [
{
"name": "timestamp",
"displayName": "Time",
"shape": "date",
"role": "timestamp"
},
{
"name": "transactionId",
"displayName": "Transaction ID",
"shape": "string",
"role": "id"
},
{
"name": "author",
"displayName": "Author",
"shape": "string",
"role": "label"
},
{
"name": "documentCount",
"displayName": "Documents Changed",
"shape": "number",
"role": "value"
},
{
"pattern": ".*"
}
],
"timeframes": [
"last1hour",
"last12hours",
"last24hours",
"last7days",
"last30days",
"lastMonth",
"lastQuarter",
"lastYear"
]
}
65 changes: 65 additions & 0 deletions plugins/Sanity/v1/dataStreams/customQuery.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{
"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",
"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": "*[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
}
45 changes: 45 additions & 0 deletions plugins/Sanity/v1/dataStreams/datasetStats.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"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"
}
},
"providesPluginDiagnostics": true,
"config": {
"baseUrl": "https://{{object.projectId}}.api.sanity.io/v1/",
"httpMethod": "get",
"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
},
"ui": [
{
"type": "text",
"name": "hostname",
"label": "Hostname",
"placeholder": "api.example.com"
}
],
"metadata": [
{
"pattern": ".*"
}
],
"timeframes": false,
"manualConfigApply": true
}
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",
"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",
"computed": true,
"valueExpression": "{{ $['projectId'] + '-' + $['datasetId'] }}",
"visible": false
},
{
"name": "displayName",
"displayName": "Display Name",
"shape": "string",
"computed": true,
"valueExpression": "{{ $['projectName'] + ' - ' + $['datasetId'] }}",
"visible": false
}
],
"timeframes": false
}
51 changes: 51 additions & 0 deletions plugins/Sanity/v1/dataStreams/documentTypeCounts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "documentTypeCounts",
"displayName": "Document Type Counts",
"description": "Count of published documents per type in a dataset",
"tags": ["Documents"],
"baseDataSourceName": "httpRequestScopedSingle",
"matches": {
"sourceType": {
"type": "equals",
"value": "Dataset"
}
},
"config": {
"baseUrl": "https://{{object.projectId}}.api.sanity.io/{{dataSource.apiVersion}}/",
"httpMethod": "get",
"paging": {
"mode": "none"
},
"endpointPath": "data/query/{{object.datasetId}}",
"getArgs": [
{
"key": "query",
"value": "*[!(_id in path(\"drafts.**\"))]._type"
}
],
"headers": [
{
"key": "Authorization",
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
}
],
"postRequestScript": "documentTypeCounts.js"
},
"ui": [],
"metadata": [
{
"name": "documentType",
"displayName": "Document Type",
"shape": "string",
"role": "label"
},
{
"name": "count",
"displayName": "Count",
"shape": "number",
"role": "value"
}
],
"timeframes": false,
"manualConfigApply": true
}
Loading
Loading