Skip to content

Commit 216c3fd

Browse files
Use scoped dataset datastreams
1 parent b721dd5 commit 216c3fd

4 files changed

Lines changed: 27 additions & 40 deletions

File tree

plugins/Sanity/v1/dataStreams/changeHistory.json

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"matches": {
88
"sourceType": {
99
"type": "equals",
10-
"value": "Sanity Project"
10+
"value": "Sanity Dataset"
1111
}
1212
},
1313
"config": {
14-
"baseUrl": "https://{{object.rawId}}.api.sanity.io/{{dataSource.apiVersion}}/",
14+
"baseUrl": "https://{{object.projectId}}.api.sanity.io/{{dataSource.apiVersion}}/",
1515
"httpMethod": "get",
1616
"paging": {
1717
"mode": "none"
1818
},
19-
"endpointPath": "data/history/{{dataset}}/transactions",
19+
"endpointPath": "data/history/{{object.datasetId}}/transactions",
2020
"getArgs": [
2121
{ "key": "excludeContent", "value": "true" },
2222
{ "key": "reverse", "value": "true" },
@@ -27,21 +27,12 @@
2727
"headers": [
2828
{
2929
"key": "Authorization",
30-
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.rawId) || {}).value }}"
30+
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
3131
}
3232
],
3333
"postRequestScript": "changeHistory.js"
3434
},
35-
"ui": [
36-
{
37-
"type": "text",
38-
"name": "dataset",
39-
"label": "Dataset",
40-
"defaultValue": "production",
41-
"validation": { "required": true },
42-
"help": "The dataset to read change history from (e.g. production)."
43-
}
44-
],
35+
4536
"metadata": [
4637
{
4738
"name": "timestamp",

plugins/Sanity/v1/dataStreams/customQuery.json

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
"matches": {
88
"sourceType": {
99
"type": "equals",
10-
"value": "Sanity Project"
10+
"value": "Sanity Dataset"
1111
}
1212
},
13+
"providesPluginDiagnostics": true,
1314
"config": {
14-
"baseUrl": "https://{{object.rawId}}.api.sanity.io/{{dataSource.apiVersion}}/",
15+
"baseUrl": "https://{{object.projectId}}.api.sanity.io/{{dataSource.apiVersion}}/",
1516
"httpMethod": "get",
1617
"paging": {
1718
"mode": "none"
1819
},
1920
"expandInnerObjects": true,
20-
"endpointPath": "data/query/{{dataset}}",
21+
"endpointPath": "data/query/{{object.datasetId}}",
2122
"pathToData": "result",
2223
"getArgs": [
2324
{
@@ -32,19 +33,11 @@
3233
"headers": [
3334
{
3435
"key": "Authorization",
35-
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.rawId) || {}).value }}"
36+
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
3637
}
3738
]
3839
},
3940
"ui": [
40-
{
41-
"type": "text",
42-
"name": "dataset",
43-
"label": "Dataset",
44-
"defaultValue": "production",
45-
"validation": { "required": true },
46-
"help": "The dataset to query."
47-
},
4841
{
4942
"type": "code",
5043
"name": "query",

plugins/Sanity/v1/dataStreams/documentTypeCounts.json

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
"matches": {
88
"sourceType": {
99
"type": "equals",
10-
"value": "Sanity Project"
10+
"value": "Sanity Dataset"
1111
}
1212
},
1313
"config": {
14-
"baseUrl": "https://{{object.rawId}}.api.sanity.io/{{dataSource.apiVersion}}/",
14+
"baseUrl": "https://{{object.projectId}}.api.sanity.io/{{dataSource.apiVersion}}/",
1515
"httpMethod": "get",
1616
"paging": {
1717
"mode": "none"
1818
},
19-
"endpointPath": "data/query/{{dataset}}",
19+
"endpointPath": "data/query/{{object.datasetId}}",
2020
"getArgs": [
2121
{
2222
"key": "query",
@@ -26,21 +26,12 @@
2626
"headers": [
2727
{
2828
"key": "Authorization",
29-
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.rawId) || {}).value }}"
29+
"value": "Bearer {{ ((dataSource.projects || []).find(p => p.key === object.projectId) || {}).value }}"
3030
}
3131
],
3232
"postRequestScript": "documentTypeCounts.js"
3333
},
34-
"ui": [
35-
{
36-
"type": "text",
37-
"name": "dataset",
38-
"label": "Dataset",
39-
"defaultValue": "production",
40-
"validation": { "required": true },
41-
"help": "The dataset to analyse (e.g. production)."
42-
}
43-
],
34+
"ui": [],
4435
"metadata": [
4536
{
4637
"name": "documentType",

plugins/Sanity/v1/defaultContent/scopes.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,17 @@
1010
"default": "none",
1111
"type": "object"
1212
}
13+
},
14+
{
15+
"name": "Sanity Datasets",
16+
"matches": {
17+
"sourceType": { "type": "oneOf", "values": ["Sanity Dataset"] }
18+
},
19+
"variable": {
20+
"name": "Sanity Project",
21+
"allowMultipleSelection": false,
22+
"default": "none",
23+
"type": "object"
24+
}
1325
}
1426
]

0 commit comments

Comments
 (0)