@sanity/cross-dataset-duplicator 0.3.2 → 0.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -2
- package/lib/actions/DuplicateToAction.js.map +1 -1
- package/lib/actions/index.js.map +1 -1
- package/lib/components/CrossDatasetDuplicator.js +1 -1
- package/lib/components/CrossDatasetDuplicator.js.map +1 -1
- package/lib/components/DuplicatorQuery.js +24 -10
- package/lib/components/DuplicatorQuery.js.map +1 -1
- package/lib/components/DuplicatorTool.js +36 -18
- package/lib/components/DuplicatorTool.js.map +1 -1
- package/lib/components/Feedback.js.map +1 -1
- package/lib/components/ResetSecret.js.map +1 -1
- package/lib/components/SelectButtons.js.map +1 -1
- package/lib/components/StatusBadge.js +10 -5
- package/lib/components/StatusBadge.js.map +1 -1
- package/lib/helpers/clientConfig.js.map +1 -1
- package/lib/helpers/constants.js.map +1 -1
- package/lib/helpers/getDocumentsInArray.js +5 -4
- package/lib/helpers/getDocumentsInArray.js.map +1 -1
- package/lib/helpers/index.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/tool/index.js.map +1 -1
- package/lib/types/index.js.map +1 -1
- package/package.json +6 -6
- package/src/components/CrossDatasetDuplicator.tsx +1 -1
- package/src/components/DuplicatorQuery.tsx +25 -14
- package/src/components/DuplicatorTool.tsx +47 -14
- package/src/components/StatusBadge.tsx +8 -1
- package/src/helpers/getDocumentsInArray.ts +4 -2
package/README.md
CHANGED
|
@@ -66,11 +66,16 @@ Options:
|
|
|
66
66
|
|
|
67
67
|
### 3. Authentication Key
|
|
68
68
|
|
|
69
|
-
To Duplicate the original files of Assets, an
|
|
69
|
+
To Duplicate the original files of Assets, an API Token with Viewer permissions is required. You will be prompted for this the first time you attempt to use either the Tool or Document Action on any Dataset.
|
|
70
70
|
|
|
71
71
|
This plugin uses [Sanity Secrets](https://github.com/sanity-io/sanity-studio-secrets/) to store the token in the Dataset itself.
|
|
72
72
|
|
|
73
|
-
You can
|
|
73
|
+
You can [create API tokens in manage](https://sanity.io/manage)
|
|
74
|
+
|
|
75
|
+
### 4. CORS origins
|
|
76
|
+
|
|
77
|
+
If you want to duplicate data across different projects, you need to enable CORS for the different hosts. This allows different projects to connect to each other through the project API. CORS origins configuration can be found in your project page, under the API tab.
|
|
78
|
+
|
|
74
79
|
|
|
75
80
|
## Importing the Document Action
|
|
76
81
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"DuplicateToAction.js","names":["DuplicateToAction","draft","published","onComplete","useState","dialogOpen","setDialogOpen","disabled","title","label","dialog","type","content","onClose","onHandle","icon","LaunchIcon"],"sources":["../../src/actions/DuplicateToAction.tsx"],"sourcesContent":["import React, {useState} from 'react'\nimport {LaunchIcon} from '@sanity/icons'\n\nimport CrossDatasetDuplicator from '../components/CrossDatasetDuplicator'\n\nexport default function DuplicateToAction({draft, published, onComplete}) {\n const [dialogOpen, setDialogOpen] = useState(false)\n\n return {\n disabled: draft,\n title: draft ? `Document must be Published to begin` : null,\n label: 'Duplicate to...',\n dialog: dialogOpen && published && {\n type: 'modal',\n title: 'Cross Dataset Duplicator',\n content: <CrossDatasetDuplicator docs={[published]} mode=\"action\" />,\n onClose: () => onComplete(),\n },\n onHandle: () => setDialogOpen(true),\n icon: LaunchIcon,\n }\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;AAEe,SAASA,iBAAT,OAA2D;EAAA,IAA/BC,KAA+B,QAA/BA,KAA+B;EAAA,IAAxBC,SAAwB,QAAxBA,SAAwB;EAAA,IAAbC,UAAa,QAAbA,UAAa;;EACxE,gBAAoC,IAAAC,eAAA,EAAS,KAAT,CAApC;EAAA;EAAA,IAAOC,UAAP;EAAA,IAAmBC,aAAnB;;EAEA,OAAO;IACLC,QAAQ,EAAEN,KADL;IAELO,KAAK,EAAEP,KAAK,2CAA2C,IAFlD;IAGLQ,KAAK,EAAE,iBAHF;IAILC,MAAM,EAAEL,UAAU,IAAIH,SAAd,IAA2B;MACjCS,IAAI,EAAE,OAD2B;MAEjCH,KAAK,EAAE,0BAF0B;MAGjCI,OAAO,eAAE,6BAAC,+BAAD;QAAwB,IAAI,EAAE,CAACV,SAAD,CAA9B;QAA2C,IAAI,EAAC;MAAhD,EAHwB;MAIjCW,OAAO,EAAE,MAAMV,UAAU;IAJQ,CAJ9B;IAULW,QAAQ,EAAE,MAAMR,aAAa,CAAC,IAAD,CAVxB;IAWLS,IAAI,EAAEC;EAXD,CAAP;AAaD"}
|
package/lib/actions/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["resolveDocumentActions","props","duplicatorTypes","config","types","defaultActions","defaultResolve","includes","type","reduce","acc","cur","DuplicateAction","DuplicateToAction"],"sources":["../../src/actions/index.ts"],"sourcesContent":["import defaultResolve, {DuplicateAction} from 'part:@sanity/base/document-actions'\nimport config from 'config:@sanity/cross-dataset-duplicator'\n\nimport DuplicateToAction from './DuplicateToAction'\n\nexport default function resolveDocumentActions(props) { \n const duplicatorTypes = config?.types ?? []\n const defaultActions = defaultResolve(props)\n\n // Insert 'Duplicate to...' after 'Duplicate' only on config'd types\n if (duplicatorTypes.includes(props?.type)) {\n return defaultActions.reduce((acc, cur) => {\n if (cur === DuplicateAction) {\n return [...acc, cur, DuplicateToAction]\n }\n\n return [...acc, cur]\n }, [])\n }\n\n return defaultActions\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;;;;;AAEe,SAASA,sBAAT,CAAgCC,KAAhC,EAAuC;EAAA;;EACpD,IAAMC,eAAe,oBAAGC,+BAAH,aAAGA,+BAAH,uBAAGA,+BAAA,CAAQC,KAAX,yDAAoB,EAAzC;EACA,IAAMC,cAAc,GAAG,IAAAC,wBAAA,EAAeL,KAAf,CAAvB,CAFoD,CAIpD;;EACA,IAAIC,eAAe,CAACK,QAAhB,CAAyBN,KAAzB,aAAyBA,KAAzB,uBAAyBA,KAAK,CAAEO,IAAhC,CAAJ,EAA2C;IACzC,OAAOH,cAAc,CAACI,MAAf,CAAsB,CAACC,GAAD,EAAMC,GAAN,KAAc;MACzC,IAAIA,GAAG,KAAKC,gCAAZ,EAA6B;QAC3B,OAAO,CAAC,GAAGF,GAAJ,EAASC,GAAT,EAAcE,0BAAd,CAAP;MACD;;MAED,OAAO,CAAC,GAAGH,GAAJ,EAASC,GAAT,CAAP;IACD,CANM,EAMJ,EANI,CAAP;EAOD;;EAED,OAAON,cAAP;AACD"}
|
|
@@ -42,7 +42,7 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
42
42
|
// Check for auth secret (required for asset uploads)
|
|
43
43
|
var secretConfigKeys = [{
|
|
44
44
|
key: 'bearerToken',
|
|
45
|
-
title: 'An
|
|
45
|
+
title: 'An API token with Viewer permissions is required to duplicate the original files of assets, and will be used for all Duplications. Create one at sanity.io/manage',
|
|
46
46
|
description: ''
|
|
47
47
|
}];
|
|
48
48
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"CrossDatasetDuplicator.js","names":["secretConfigKeys","key","title","description","CrossDatasetDuplicator","props","mode","docs","secretsData","useSecrets","SECRET_NAMESPACE","loading","secrets","useState","showSecretsPrompt","setShowSecretsPrompt","useEffect","bearerToken","length"],"sources":["../../src/components/CrossDatasetDuplicator.tsx"],"sourcesContent":["import React, {useEffect, useState} from 'react'\nimport {useSecrets, SettingsView} from 'sanity-secrets'\nimport {ThemeProvider, Flex, Box, Spinner} from '@sanity/ui'\n\nimport DuplicatorQuery from './DuplicatorQuery'\nimport DuplicatorTool from './DuplicatorTool'\nimport ResetSecret from './ResetSecret'\nimport Feedback from './Feedback'\nimport {SanityDocument} from '../types'\nimport {SECRET_NAMESPACE} from '../helpers/constants'\n\n// Check for auth secret (required for asset uploads)\nconst secretConfigKeys = [\n {\n key: 'bearerToken',\n title:\n 'An API token with Viewer permissions is required to duplicate the original files of assets, and will be used for all Duplications. Create one at sanity.io/manage',\n description: '',\n },\n]\n\ntype CrossDatasetDuplicatorProps = {\n mode: 'tool' | 'action'\n docs: SanityDocument[]\n}\n\ntype Secrets = {\n bearerToken?: string\n}\n\nexport default function CrossDatasetDuplicator(props: CrossDatasetDuplicatorProps) {\n const {mode = `tool`, docs = []} = props\n\n const secretsData = useSecrets(SECRET_NAMESPACE)\n const {loading, secrets}: {loading: boolean; secrets: Secrets} = secretsData\n const [showSecretsPrompt, setShowSecretsPrompt] = useState(false)\n\n useEffect(() => {\n if (secrets) {\n setShowSecretsPrompt(!secrets?.bearerToken)\n }\n }, [secrets])\n\n if (!secretsData) {\n return (\n <Feedback>\n Could not query for Secrets. You may have insufficient permissions on your account.\n </Feedback>\n )\n }\n\n if (loading) {\n return (\n <ThemeProvider>\n <Flex justify=\"center\" align=\"center\">\n <Box padding={5}>\n <Spinner />\n </Box>\n </Flex>\n </ThemeProvider>\n )\n }\n\n if ((!loading && showSecretsPrompt) || !secrets?.bearerToken) {\n return (\n <ThemeProvider>\n <SettingsView\n title=\"Token Required\"\n namespace={SECRET_NAMESPACE}\n keys={secretConfigKeys}\n // eslint-disable-next-line react/jsx-no-bind\n onClose={() => setShowSecretsPrompt(false)}\n />\n </ThemeProvider>\n )\n }\n\n if (mode === 'tool') {\n return (\n <ThemeProvider>\n <DuplicatorQuery token={secrets?.bearerToken} />\n <ResetSecret />\n </ThemeProvider>\n )\n }\n\n if (!docs?.length) {\n return (\n <ThemeProvider>\n <Feedback>No docs passed into Duplicator Tool</Feedback>\n </ThemeProvider>\n )\n }\n\n return (\n <ThemeProvider>\n <DuplicatorTool docs={docs} token={secrets?.bearerToken} />\n </ThemeProvider>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;AAEA;AACA,IAAMA,gBAAgB,GAAG,CACvB;EACEC,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O,EAAE,MAAMe,oBAAoB,CAAC,KAAD;IALrC,EADF,CADF;EAWD;;EAED,IAAIT,IAAI,KAAK,MAAb,EAAqB;IACnB,oBACE,6BAAC,iBAAD,qBACE,6BAAC,wBAAD;MAAiB,KAAK,EAAEM,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEK;IAAjC,EADF,eAEE,6BAAC,oBAAD,OAFF,CADF;EAMD;;EAED,IAAI,EAACV,IAAD,aAACA,IAAD,eAACA,IAAI,CAAEW,MAAP,CAAJ,EAAmB;IACjB,oBACE,6BAAC,iBAAD,qBACE,6BAAC,iBAAD,8CADF,CADF;EAKD;;EAED,oBACE,6BAAC,iBAAD,qBACE,6BAAC,uBAAD;IAAgB,IAAI,EAAEX,IAAtB;IAA4B,KAAK,EAAEK,OAAF,aAAEA,OAAF,uBAAEA,OAAO,CAAEK;EAA5C,EADF,CADF;AAKD"}
|
|
@@ -37,7 +37,11 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
|
37
37
|
|
|
38
38
|
var originClient = _client.default.withConfig(_clientConfig.clientConfig);
|
|
39
39
|
|
|
40
|
+
var schemaTypes = _schema.default.getTypeNames();
|
|
41
|
+
|
|
40
42
|
function DuplicatorQuery(props) {
|
|
43
|
+
var _initialData$docs2, _initialData$docs3;
|
|
44
|
+
|
|
41
45
|
var token = props.token;
|
|
42
46
|
|
|
43
47
|
var _useState = (0, _react.useState)(""),
|
|
@@ -45,23 +49,32 @@ function DuplicatorQuery(props) {
|
|
|
45
49
|
value = _useState2[0],
|
|
46
50
|
setValue = _useState2[1];
|
|
47
51
|
|
|
48
|
-
var _useState3 = (0, _react.useState)(
|
|
52
|
+
var _useState3 = (0, _react.useState)({
|
|
53
|
+
docs: [],
|
|
54
|
+
draftIds: []
|
|
55
|
+
}),
|
|
49
56
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
50
|
-
|
|
51
|
-
|
|
57
|
+
initialData = _useState4[0],
|
|
58
|
+
setInitialData = _useState4[1];
|
|
52
59
|
|
|
53
60
|
function handleSubmit(e) {
|
|
54
61
|
if (e) e.preventDefault();
|
|
55
62
|
originClient.fetch(value).then(res => {
|
|
56
63
|
// Ensure queried docs are registered to the schema
|
|
57
|
-
var
|
|
58
|
-
|
|
64
|
+
var registeredAndPublishedDocs = res.length ? res.filter(doc => schemaTypes.includes(doc._type)).filter(doc => !doc._id.startsWith("drafts.")) : [];
|
|
65
|
+
var initialDraftIds = res.length ? res.filter(doc => doc._id.startsWith("drafts.")).map(doc => doc._id) : [];
|
|
66
|
+
setInitialData({
|
|
67
|
+
docs: registeredAndPublishedDocs,
|
|
68
|
+
draftIds: initialDraftIds
|
|
69
|
+
});
|
|
59
70
|
}).catch(err => console.error(err));
|
|
60
71
|
} // Auto-load initial textinput value
|
|
61
72
|
|
|
62
73
|
|
|
63
74
|
(0, _react.useEffect)(() => {
|
|
64
|
-
|
|
75
|
+
var _initialData$docs;
|
|
76
|
+
|
|
77
|
+
if (!((_initialData$docs = initialData.docs) !== null && _initialData$docs !== void 0 && _initialData$docs.length) && value) {
|
|
65
78
|
handleSubmit();
|
|
66
79
|
}
|
|
67
80
|
}, []);
|
|
@@ -79,7 +92,7 @@ function DuplicatorQuery(props) {
|
|
|
79
92
|
radius: 3
|
|
80
93
|
}, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
|
|
81
94
|
space: 4
|
|
82
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Box, null, /*#__PURE__*/_react.default.createElement(_ui.Label, null, "Initial Documents Query")), /*#__PURE__*/_react.default.createElement(_ui.Box, null, /*#__PURE__*/_react.default.createElement(_ui.Text, null, "Start with a valid GROQ query to load initial documents. The query will need to return an Array of Objects.")), /*#__PURE__*/_react.default.createElement("form", {
|
|
95
|
+
}, /*#__PURE__*/_react.default.createElement(_ui.Box, null, /*#__PURE__*/_react.default.createElement(_ui.Label, null, "Initial Documents Query")), /*#__PURE__*/_react.default.createElement(_ui.Box, null, /*#__PURE__*/_react.default.createElement(_ui.Text, null, "Start with a valid GROQ query to load initial documents. The query will need to return an Array of Objects. Drafts will be removed from the results.")), /*#__PURE__*/_react.default.createElement("form", {
|
|
83
96
|
onSubmit: handleSubmit
|
|
84
97
|
}, /*#__PURE__*/_react.default.createElement(_ui.Flex, null, /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
85
98
|
flex: 1,
|
|
@@ -101,12 +114,13 @@ function DuplicatorQuery(props) {
|
|
|
101
114
|
onClick: handleSubmit,
|
|
102
115
|
text: "Query",
|
|
103
116
|
disabled: !value
|
|
104
|
-
})))))), !(docs !== null &&
|
|
117
|
+
})))))), !((_initialData$docs2 = initialData.docs) !== null && _initialData$docs2 !== void 0 && _initialData$docs2.length) || initialData.docs.length < 1 && /*#__PURE__*/_react.default.createElement(_ui.Container, {
|
|
105
118
|
width: 1
|
|
106
119
|
}, /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
107
120
|
padding: 5
|
|
108
|
-
}, value ? "No Documents registered to the Schema match this query" : "Start with a valid GROQ query")), (docs === null ||
|
|
109
|
-
docs: docs,
|
|
121
|
+
}, value ? "No Documents registered to the Schema match this query" : "Start with a valid GROQ query")), ((_initialData$docs3 = initialData.docs) === null || _initialData$docs3 === void 0 ? void 0 : _initialData$docs3.length) > 0 && /*#__PURE__*/_react.default.createElement(_DuplicatorTool.default, {
|
|
122
|
+
docs: initialData.docs,
|
|
123
|
+
draftIds: initialData.draftIds,
|
|
110
124
|
token: token
|
|
111
125
|
})));
|
|
112
126
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"DuplicatorQuery.js","names":["originClient","sanityClient","withConfig","clientConfig","schemaTypes","schema","getTypeNames","DuplicatorQuery","props","token","useState","value","setValue","docs","draftIds","initialData","setInitialData","handleSubmit","e","preventDefault","fetch","then","res","registeredAndPublishedDocs","length","filter","doc","includes","_type","_id","startsWith","initialDraftIds","map","catch","err","console","error","useEffect","fontFamily","event","currentTarget"],"sources":["../../src/components/DuplicatorQuery.tsx"],"sourcesContent":["import React, {useEffect, useState} from 'react'\nimport sanityClient from 'part:@sanity/base/client'\nimport schema from 'part:@sanity/base/schema'\nimport {Button, Stack, Box, Label, Text, Card, Flex, Grid, Container, TextInput} from '@sanity/ui'\n\nimport DuplicatorTool from './DuplicatorTool'\nimport {clientConfig} from '../helpers/clientConfig'\n\nconst originClient = sanityClient.withConfig(clientConfig)\n\ntype DuplicatorQueryProps = {\n token: string\n}\n\nconst schemaTypes = schema.getTypeNames()\n\nexport default function DuplicatorQuery(props: DuplicatorQueryProps) {\n const {token} = props\n\n const [value, setValue] = useState(``)\n const [initialData, setInitialData] = useState({docs: [], draftIds: []});\n\n function handleSubmit(e?: any) {\n if (e) e.preventDefault()\n\n originClient\n .fetch(value)\n .then((res) => {\n // Ensure queried docs are registered to the schema\n const registeredAndPublishedDocs = res.length\n ? res\n .filter((doc) => schemaTypes.includes(doc._type))\n .filter((doc) => !doc._id.startsWith(`drafts.`))\n : []\n const initialDraftIds = res.length ? res.filter(doc => doc._id.startsWith(`drafts.`)).map(doc => doc._id) : []\n\n setInitialData({docs: registeredAndPublishedDocs, draftIds: initialDraftIds})\n })\n .catch((err) => console.error(err))\n }\n\n // Auto-load initial textinput value\n useEffect(() => {\n if (!initialData.docs?.length && value) {\n handleSubmit()\n }\n }, [])\n\n return (\n <Container width={[1, 1, 1, 3]} padding={[0, 0, 0, 5]}>\n <Grid columns={[1, 1, 1, 2]} gap={[1, 1, 1, 4]}>\n <Box padding={[2, 2, 2, 0]}>\n <Card padding={4} scheme=\"dark\" radius={3}>\n <Stack space={4}>\n <Box>\n <Label>Initial Documents Query</Label>\n </Box>\n <Box>\n <Text>\n Start with a valid GROQ query to load initial documents. The query will need to\n return an Array of Objects. Drafts will be removed from the results.\n </Text>\n </Box>\n <form onSubmit={handleSubmit}>\n <Flex>\n <Box flex={1} paddingRight={2}>\n <TextInput\n style={{fontFamily: 'monospace'}}\n fontSize={2}\n // eslint-disable-next-line react/jsx-no-bind\n onChange={(event) => setValue(event.currentTarget.value)}\n padding={4}\n placeholder={`*[_type == \"article\"]`}\n value={value ?? ``}\n />\n </Box>\n <Button\n padding={2}\n paddingX={4}\n tone=\"primary\"\n onClick={handleSubmit}\n text=\"Query\"\n disabled={!value}\n />\n </Flex>\n </form>\n </Stack>\n </Card>\n </Box>\n {!initialData.docs?.length ||\n (initialData.docs.length < 1 && (\n <Container width={1}>\n <Card padding={5}>\n {value\n ? `No Documents registered to the Schema match this query`\n : `Start with a valid GROQ query`}\n </Card>\n </Container>\n ))}\n {initialData.docs?.length > 0 && <DuplicatorTool docs={initialData.docs} draftIds={initialData.draftIds} token={token} />}\n </Grid>\n </Container>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AACA;;AAEA;;AACA;;;;;;;;;;;;;;;;;;;;AAEA,IAAMA,YAAY,GAAGC,eAAA,CAAaC,UAAb,CAAwBC,0BAAxB,CAArB;;AAMA,IAAMC,WAAW,GAAGC,eAAA,CAAOC,YAAP,EAApB;;AAEe,SAASC,eAAT,CAAyBC,KAAzB,EAAsD;EAAA;;EACnE,IAAOC,KAAP,GAAgBD,KAAhB,CAAOC,KAAP;;EAEA,gBAA0B,IAAAC,eAAA,KAA1B;EAAA;EAAA,IAAOC,KAAP;EAAA,IAAcC,QAAd;;EACA,iBAAsC,IAAAF,eAAA,EAAS;IAACG,IAAI,EAAE,EAAP;IAAWC,QAAQ,EAAE;EAArB,CAAT,CAAtC;EAAA;EAAA,IAAOC,WAAP;EAAA,IAAoBC,cAApB;;EAEA,SAASC,YAAT,CAAsBC,CAAtB,EAA+B;IAC7B,IAAIA,CAAJ,EAAOA,CAAC,CAACC,cAAF;IAEPnB,YAAY,CACToB,KADH,CACST,KADT,EAEGU,IAFH,CAESC,GAAD,IAAS;MACb;MACA,IAAMC,0BAA0B,GAAGD,GAAG,CAACE,MAAJ,GAC/BF,GAAG,CACAG,MADH,CACWC,GAAD,IAAStB,WAAW,CAACuB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
|
|
@@ -71,6 +71,7 @@ function DuplicatorTool(props) {
|
|
|
71
71
|
var _config$__experimenta, _destination$title, _spacesOptions$find, _message$tone;
|
|
72
72
|
|
|
73
73
|
var docs = props.docs,
|
|
74
|
+
draftIds = props.draftIds,
|
|
74
75
|
token = props.token; // Prepare origin (this Studio) client
|
|
75
76
|
// In function-scope so it is up to date on every render
|
|
76
77
|
|
|
@@ -79,6 +80,10 @@ function DuplicatorTool(props) {
|
|
|
79
80
|
|
|
80
81
|
|
|
81
82
|
var spacesOptions = _configSanity.default !== null && _configSanity.default !== void 0 && (_config$__experimenta = _configSanity.default.__experimental_spaces) !== null && _config$__experimenta !== void 0 && _config$__experimenta.length ? _configSanity.default.__experimental_spaces.map(space => _objectSpread(_objectSpread({}, space), {}, {
|
|
83
|
+
api: _objectSpread(_objectSpread({}, space.api), {}, {
|
|
84
|
+
projectId: space.api.projectId || process.env.SANITY_STUDIO_API_PROJECT_ID
|
|
85
|
+
}),
|
|
86
|
+
usingEnvForProjectId: !space.api.projectId && process.env.SANITY_STUDIO_API_PROJECT_ID,
|
|
82
87
|
disabled: space.api.dataset === originClient.config().dataset && space.api.projectId === originClient.config().projectId
|
|
83
88
|
})) : [];
|
|
84
89
|
|
|
@@ -95,7 +100,8 @@ function DuplicatorTool(props) {
|
|
|
95
100
|
var _useState5 = (0, _react.useState)(docs.length ? docs.map(item => ({
|
|
96
101
|
doc: item,
|
|
97
102
|
include: true,
|
|
98
|
-
status: null
|
|
103
|
+
status: null,
|
|
104
|
+
hasDraft: draftIds !== null && draftIds !== void 0 && draftIds.length ? draftIds.includes("drafts.".concat(item._id)) : false
|
|
99
105
|
})) : []),
|
|
100
106
|
_useState6 = _slicedToArray(_useState5, 2),
|
|
101
107
|
payload = _useState6[0],
|
|
@@ -224,14 +230,21 @@ function DuplicatorTool(props) {
|
|
|
224
230
|
_handleReferences = _asyncToGenerator(function* () {
|
|
225
231
|
setIsGathering(true);
|
|
226
232
|
var docIds = docs.map(doc => doc._id);
|
|
227
|
-
var payloadDocs = yield (0, _getDocumentsInArray.getDocumentsInArray)(docIds, originClient, null);
|
|
233
|
+
var payloadDocs = yield (0, _getDocumentsInArray.getDocumentsInArray)(docIds, originClient, null);
|
|
234
|
+
var draftDocs = yield (0, _getDocumentsInArray.getDocumentsInArray)(docIds.map(id => "drafts.".concat(id)), originClient, null, "{_id}");
|
|
235
|
+
var draftDocsIds = new Set(draftDocs.map(_ref4 => {
|
|
236
|
+
var _id = _ref4._id;
|
|
237
|
+
return _id;
|
|
238
|
+
})); // Shape it up
|
|
228
239
|
|
|
229
240
|
var payloadShaped = payloadDocs.map(doc => ({
|
|
230
241
|
doc,
|
|
231
242
|
// Include this in the transaction?
|
|
232
243
|
include: true,
|
|
233
244
|
// Does it exist at the destination?
|
|
234
|
-
status: ''
|
|
245
|
+
status: '',
|
|
246
|
+
// Does it have any drafts?
|
|
247
|
+
hasDraft: draftDocsIds.has("drafts.".concat(doc._id))
|
|
235
248
|
}));
|
|
236
249
|
setPayload(payloadShaped);
|
|
237
250
|
updatePayloadStatuses(payloadShaped);
|
|
@@ -247,9 +260,9 @@ function DuplicatorTool(props) {
|
|
|
247
260
|
function _handleDuplicate() {
|
|
248
261
|
_handleDuplicate = _asyncToGenerator(function* () {
|
|
249
262
|
setIsDuplicating(true);
|
|
250
|
-
var assetsCount = payload.filter(
|
|
251
|
-
var doc =
|
|
252
|
-
include =
|
|
263
|
+
var assetsCount = payload.filter(_ref5 => {
|
|
264
|
+
var doc = _ref5.doc,
|
|
265
|
+
include = _ref5.include;
|
|
253
266
|
return include && (0, _helpers.typeIsAsset)(doc._type);
|
|
254
267
|
}).length;
|
|
255
268
|
var currentProgress = 0;
|
|
@@ -281,11 +294,11 @@ function DuplicatorTool(props) {
|
|
|
281
294
|
var downloadUrl = uploadType === 'image' ? "".concat(doc.url, "?dlRaw=true") : doc.url;
|
|
282
295
|
var downloadConfig = uploadType === 'image' ? {
|
|
283
296
|
headers: {
|
|
284
|
-
Authorization:
|
|
297
|
+
Authorization: "Bearer ".concat(token)
|
|
285
298
|
}
|
|
286
299
|
} : {};
|
|
287
300
|
yield fetch(downloadUrl, downloadConfig).then( /*#__PURE__*/function () {
|
|
288
|
-
var
|
|
301
|
+
var _ref6 = _asyncToGenerator(function* (res) {
|
|
289
302
|
var assetData = yield res.blob();
|
|
290
303
|
var options = {
|
|
291
304
|
filename: doc.originalFilename
|
|
@@ -303,7 +316,7 @@ function DuplicatorTool(props) {
|
|
|
303
316
|
});
|
|
304
317
|
|
|
305
318
|
return function (_x2) {
|
|
306
|
-
return
|
|
319
|
+
return _ref6.apply(this, arguments);
|
|
307
320
|
};
|
|
308
321
|
}());
|
|
309
322
|
currentProgress += 1;
|
|
@@ -450,7 +463,7 @@ function DuplicatorTool(props) {
|
|
|
450
463
|
key: space.name,
|
|
451
464
|
value: space.name,
|
|
452
465
|
disabled: space.disabled
|
|
453
|
-
}, (_space$title = space.title) !== null && _space$title !== void 0 ? _space$title : space.name, hasMultipleProjectIds ? " (".concat(space.api.projectId, ")") : "");
|
|
466
|
+
}, (_space$title = space.title) !== null && _space$title !== void 0 ? _space$title : space.name, hasMultipleProjectIds || space.usingEnvForProjectId ? " (".concat(space.api.projectId, ")") : "");
|
|
454
467
|
}))), /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
455
468
|
padding: 4,
|
|
456
469
|
paddingTop: 5,
|
|
@@ -471,7 +484,7 @@ function DuplicatorTool(props) {
|
|
|
471
484
|
key: space.name,
|
|
472
485
|
value: space.name,
|
|
473
486
|
disabled: space.disabled
|
|
474
|
-
}, (_space$title2 = space.title) !== null && _space$title2 !== void 0 ? _space$title2 : space.name, hasMultipleProjectIds ? " (".concat(space.api.projectId, ")") : "", space.disabled ? " (Current)" : "");
|
|
487
|
+
}, (_space$title2 = space.title) !== null && _space$title2 !== void 0 ? _space$title2 : space.name, hasMultipleProjectIds || space.usingEnvForProjectId ? " (".concat(space.api.projectId, ")") : "", space.disabled ? " (Current)" : "");
|
|
475
488
|
})))), isDuplicating && /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
476
489
|
border: true,
|
|
477
490
|
radius: 2
|
|
@@ -504,7 +517,8 @@ function DuplicatorTool(props) {
|
|
|
504
517
|
}, payload.map((_ref2, index) => {
|
|
505
518
|
var doc = _ref2.doc,
|
|
506
519
|
include = _ref2.include,
|
|
507
|
-
status = _ref2.status
|
|
520
|
+
status = _ref2.status,
|
|
521
|
+
hasDraft = _ref2.hasDraft;
|
|
508
522
|
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
|
|
509
523
|
key: doc._id
|
|
510
524
|
}, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
@@ -513,24 +527,28 @@ function DuplicatorTool(props) {
|
|
|
513
527
|
checked: include,
|
|
514
528
|
onChange: () => handleCheckbox(doc._id)
|
|
515
529
|
}), /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
516
|
-
|
|
517
|
-
flex: 1
|
|
518
|
-
},
|
|
530
|
+
flex: 1,
|
|
519
531
|
paddingX: 3
|
|
520
532
|
}, /*#__PURE__*/_react.default.createElement(_preview.default, {
|
|
521
533
|
value: doc,
|
|
522
534
|
type: _schema.default.get(doc._type)
|
|
523
|
-
})), /*#__PURE__*/_react.default.createElement(
|
|
535
|
+
})), /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
536
|
+
items: "center",
|
|
537
|
+
gap: 2
|
|
538
|
+
}, hasDraft ? /*#__PURE__*/_react.default.createElement(_StatusBadge.default, {
|
|
539
|
+
status: "UNPUBLISHED",
|
|
540
|
+
isAsset: false
|
|
541
|
+
}) : null, /*#__PURE__*/_react.default.createElement(_StatusBadge.default, {
|
|
524
542
|
status: status,
|
|
525
543
|
isAsset: (0, _helpers.typeIsAsset)(doc._type)
|
|
526
|
-
})), (doc === null || doc === void 0 ? void 0 : doc.extension) === 'svg' && index === firstSvgIndex && /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
544
|
+
}))), (doc === null || doc === void 0 ? void 0 : doc.extension) === 'svg' && index === firstSvgIndex && /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
527
545
|
padding: 3,
|
|
528
546
|
radius: 2,
|
|
529
547
|
shadow: 1,
|
|
530
548
|
tone: "caution"
|
|
531
549
|
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
532
550
|
size: 1
|
|
533
|
-
}, "Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new",
|
|
551
|
+
}, "Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new ", /*#__PURE__*/_react.default.createElement("code", null, "_id"), "'s at the destination. The newly generated", ' ', /*#__PURE__*/_react.default.createElement("code", null, "_id"), " will be the same in each duplication, but it will never be the same ", /*#__PURE__*/_react.default.createElement("code", null, "_id"), " as the first time this Asset was uploaded. References to the asset will be updated to use the new ", /*#__PURE__*/_react.default.createElement("code", null, "_id"), ".")));
|
|
534
552
|
})), /*#__PURE__*/_react.default.createElement(_ui.Stack, {
|
|
535
553
|
space: 2,
|
|
536
554
|
padding: 4,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/components/DuplicatorTool.tsx"],"names":["DuplicatorTool","props","docs","token","originClient","sanityClient","withConfig","clientConfig","spacesOptions","config","__experimental_spaces","length","map","space","disabled","api","dataset","projectId","find","destination","setDestination","message","setMessage","item","doc","include","status","payload","setPayload","hasReferences","setHasReferences","isDuplicating","setIsDuplicating","isGathering","setIsGathering","progress","setProgress","expr","initialRefs","initialPayload","forEach","push","docCount","refsCount","tone","text","updatePayloadStatuses","newPayload","payloadActual","name","payloadIds","_id","destinationClient","destinationData","fetch","updatedPayload","existingDoc","_updatedAt","Date","handleCheckbox","handleReferences","docIds","payloadDocs","payloadShaped","handleDuplicate","assetsCount","filter","_type","currentProgress","transactionDocs","svgMaps","fetchDoc","uploadType","split","pop","replace","downloadUrl","url","downloadConfig","headers","Authorization","then","res","assetData","blob","options","filename","originalFilename","assetDoc","assets","upload","extension","old","new","result","Promise","resolve","reject","payloadIncludedDocs","err","console","error","Error","transactionDocsMapped","references","ref","newRefValue","asset","value","refPath","path","join","transaction","createOrReplace","commit","catch","details","description","handleChange","e","currentTarget","payloadCount","firstSvgIndex","findIndex","selectedDocumentsCount","selectedAssetsCount","selectedTotal","destinationTitle","title","hasMultipleProjectIds","Set","Boolean","size","headingText","buttonText","React","useMemo","stickyStyles","flex","width","transform","transformOrigin","transition","boxSizing","index","schema","get","SearchIcon","LaunchIcon"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAOe,SAASA,cAAT,CAAwBC,KAAxB,EAAoD;AAAA;;AACjE,MAAOC,IAAP,GAAsBD,KAAtB,CAAOC,IAAP;AAAA,MAAaC,KAAb,GAAsBF,KAAtB,CAAaE,KAAb,CADiE,CAGjE;AACA;;AACA,MAAMC,YAAY,GAAGC,gBAAaC,UAAb,CAAwBC,0BAAxB,CAArB,CALiE,CAOjE;AACA;;;AACA,MAAMC,aAAa,GAAGC,qHAAQC,qBAAR,wEAA+BC,MAA/B,GAClBF,sBAAOC,qBAAP,CAA6BE,GAA7B,CAAkCC,KAAD,oCAC5BA,KAD4B;AAE/BC,IAAAA,QAAQ,EAAED,KAAK,CAACE,GAAN,CAAUC,OAAV,KAAsBZ,YAAY,CAACK,MAAb,GAAsBO,OAA5C,IAAuDH,KAAK,CAACE,GAAN,CAAUE,SAAV,KAAwBb,YAAY,CAACK,MAAb,GAAsBQ;AAFhF,IAAjC,CADkB,GAKlB,EALJ;;AAOA,kBAAsC,qBACpCT,aAAa,CAACG,MAAd,GAAuBH,aAAa,CAACU,IAAd,CAAoBL,KAAD,IAAW,CAACA,KAAK,CAACC,QAArC,CAAvB,GAAwE,EADpC,CAAtC;AAAA;AAAA,MAAOK,WAAP;AAAA,MAAoBC,cAApB;;AAGA,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AC,QAAD;AAAM,MAAA,OAAO,EAAE,CAAf;AAAkB,MAAA,MAAM,EAAE,CAA1B;AAA6B,MAAA,MAAM,EAAE,CAArC;AAAwC,MAAA,IAAI,EAAC;AAA7C,oBACE,6BAAC,QAAD;AAAM,MAAA,IAAI,EAAE;AAAZ,iGACyF,GADzF,eAEE,iDAFF,8DAE6D,iDAF7D,EAE8E,GAF9E,yEAGsE,GAHtE,eAIE,iDAJF,sHAIqH,iDAJrH,MADF,CATJ,CADW;AAAA,GAAZ,CADH,CAnEJ,eA2FE,6BAAC,SAAD;AAAO,IAAA,KAAK,EAAE,CAAd;AAAiB,IAAA,OAAO,EAAE,CAA1B;AAA6B,IAAA,UAAU,EAAE;AAAzC,KACG7F,aAAa,iBACZ,6BAAC,UAAD;AACE,IAAA,QAAQ,EAAE,CADZ;AAEE,IAAA,OAAO,EAAE,CAFX;AAGE,IAAA,IAAI,EAAC,UAHP;AAIE,IAAA,IAAI,EAAC,OAJP;AAKE,IAAA,IAAI,EAAEsH,iBALR;AAME,IAAA,OAAO,EAAEvF,gBANX;AAOE,IAAA,IAAI,EAAC,mBAPP;AAQE,IAAA,QAAQ,EAAE7B,aAAa,IAAI,CAAC+F,aAAlB,IAAmC7F;AAR/C,IAFJ,eAaE,6BAAC,UAAD;AACE,IAAA,QAAQ,EAAE,CADZ;AAEE,IAAA,OAAO,EAAE,CAFX;AAGE,IAAA,IAAI,EAAC,UAHP;AAIE,IAAA,IAAI,EAAEmH,iBAJR;AAKE,IAAA,OAAO,EAAEpF,eALX;AAME,IAAA,IAAI,EAAEsE,UANR;AAOE,IAAA,QAAQ,EAAEvG,aAAa,IAAI,CAAC+F,aAAlB,IAAmC7F;AAP/C,IAbF,CA3FF,CADF,CADF,CADF,CADF;AA2HD","sourcesContent":["/* eslint-disable react/jsx-no-bind */\nimport React, {useState, useEffect} from 'react'\nimport mapLimit from 'async/mapLimit'\nimport asyncify from 'async/asyncify'\nimport {extract, extractWithPath} from '@sanity/mutator'\nimport {dset} from 'dset'\nimport {Card, Container, Text, Box, Button, Label, Stack, Select, Flex, Checkbox} from '@sanity/ui'\nimport {ArrowRightIcon, SearchIcon, LaunchIcon} from '@sanity/icons'\nimport sanityClient from 'part:@sanity/base/client'\nimport Preview from 'part:@sanity/base/preview'\nimport schema from 'part:@sanity/base/schema'\nimport config from 'config:sanity'\n\nimport {typeIsAsset, stickyStyles, createInitialMessage} from '../helpers'\nimport {getDocumentsInArray} from '../helpers/getDocumentsInArray'\nimport SelectButtons from './SelectButtons'\nimport StatusBadge from './StatusBadge'\nimport Feedback from './Feedback'\nimport {SanityDocument} from '../types'\nimport {clientConfig} from '../helpers/clientConfig'\n\ntype DuplicatorToolProps = {\n docs: SanityDocument[]\n token: string\n}\n\nexport default function DuplicatorTool(props: DuplicatorToolProps) {\n const {docs, token} = props\n\n // Prepare origin (this Studio) client\n // In function-scope so it is up to date on every render\n const originClient = sanityClient.withConfig(clientConfig)\n\n // Create list of dataset options\n // and set initial value of dropdown\n const spacesOptions = config?.__experimental_spaces?.length\n ? config.__experimental_spaces.map((space) => ({\n ...space,\n disabled: space.api.dataset === originClient.config().dataset && space.api.projectId === originClient.config().projectId,\n }))\n : []\n\n const [destination, setDestination] = useState(\n spacesOptions.length ? spacesOptions.find((space) => !space.disabled) : {}\n )\n const [message, setMessage] = useState({})\n const [payload, setPayload] = useState(\n docs.length\n ? docs.map((item) => ({\n doc: item,\n include: true,\n status: null,\n }))\n : []\n )\n const [hasReferences, setHasReferences] = useState(false)\n const [isDuplicating, setIsDuplicating] = useState(false)\n const [isGathering, setIsGathering] = useState(false)\n const [progress, setProgress] = useState([0, 0])\n\n // Check for References and update message\n useEffect(() => {\n const expr = `.._ref`\n const initialRefs = []\n const initialPayload = []\n\n docs.forEach((doc) => {\n initialRefs.push(...extract(expr, doc))\n initialPayload.push({include: true, doc})\n })\n\n setPayload(initialPayload)\n\n const docCount = docs.length\n const refsCount = initialRefs.length\n\n if (initialRefs.length) {\n setHasReferences(true)\n\n setMessage({\n tone: `caution`,\n text: createInitialMessage(docCount, refsCount),\n })\n }\n }, [docs])\n\n // Re-check payload on destination when value changes\n // (On initial render + select change)\n useEffect(() => {\n updatePayloadStatuses()\n }, [destination, docs])\n\n // Check if payload documents exist at destination\n async function updatePayloadStatuses(newPayload = []) {\n const payloadActual = newPayload.length ? newPayload : payload\n\n if (!payloadActual.length || !destination?.name) {\n return\n }\n\n const payloadIds = payloadActual.map(({doc}) => doc._id)\n const destinationClient = sanityClient.withConfig({\n ...clientConfig,\n dataset: destination.api.dataset,\n projectId: destination.api.projectId,\n })\n const destinationData = await destinationClient.fetch(\n `*[_id in $payloadIds]{ _id, _updatedAt }`,\n {payloadIds}\n )\n\n const updatedPayload = payloadActual.map((item) => {\n const existingDoc = destinationData.find((doc) => doc._id === item.doc._id)\n\n if (existingDoc?._updatedAt && item?.doc?._updatedAt) {\n if (existingDoc._updatedAt === item.doc._updatedAt) {\n // Exact same document exists at destination\n // We don't compare by _rev because that is updated in a transaction\n item.status = `EXISTS`\n } else if (existingDoc._updatedAt && item.doc._updatedAt) {\n item.status =\n new Date(existingDoc._updatedAt) > new Date(item.doc._updatedAt)\n ? // Document at destination is newer\n `OVERWRITE`\n : // Document at destination is older\n `UPDATE`\n }\n } else {\n item.status = 'CREATE'\n }\n\n return item\n })\n\n setPayload(updatedPayload)\n }\n\n function handleCheckbox(_id) {\n const updatedPayload = payload.map((item) => {\n if (item.doc._id === _id) {\n item.include = !item.include\n }\n\n return item\n })\n\n setPayload(updatedPayload)\n }\n\n // Find and recursively follow references beginning with this document\n async function handleReferences() {\n setIsGathering(true)\n const docIds = docs.map((doc) => doc._id)\n\n const payloadDocs = await getDocumentsInArray(docIds, originClient, null)\n\n // Shape it up\n const payloadShaped = payloadDocs.map((doc) => ({\n doc,\n // Include this in the transaction?\n include: true,\n // Does it exist at the destination?\n status: '',\n }))\n\n setPayload(payloadShaped)\n updatePayloadStatuses(payloadShaped)\n setIsGathering(false)\n }\n\n // Duplicate payload to destination dataset\n async function handleDuplicate() {\n setIsDuplicating(true)\n\n const assetsCount = payload.filter(({doc, include}) => include && typeIsAsset(doc._type)).length\n let currentProgress = 0\n setProgress([currentProgress, assetsCount])\n\n setMessage({text: 'Duplicating...'})\n\n const destinationClient = sanityClient.withConfig({\n ...clientConfig,\n dataset: destination.api.dataset,\n projectId: destination.api.projectId,\n })\n\n const transactionDocs = []\n const svgMaps = []\n\n // Upload assets and then add to transaction\n async function fetchDoc(doc) {\n if (typeIsAsset(doc._type)) {\n // Download and upload asset\n // Get the *original* image with this dlRaw param to create the same determenistic _id\n const uploadType = doc._type.split('.').pop().replace('Asset', '')\n const downloadUrl = uploadType === 'image' ? `${doc.url}?dlRaw=true` : doc.url\n const downloadConfig =\n uploadType === 'image' ? {headers: {Authorization: token ? `Bearer ${token}` : ``}} : {}\n\n await fetch(downloadUrl, downloadConfig).then(async (res) => {\n const assetData = await res.blob()\n\n const options = {filename: doc.originalFilename}\n const assetDoc = await destinationClient.assets.upload(uploadType, assetData, options)\n\n // SVG _id's need remapping before transaction\n if (doc?.extension === 'svg') {\n svgMaps.push({old: doc._id, new: assetDoc._id})\n }\n\n transactionDocs.push(assetDoc)\n })\n\n currentProgress += 1\n setMessage({\n text: `Duplicating ${currentProgress}/${assetsCount} ${\n assetsCount === 1 ? `Assets` : `Assets`\n }`,\n })\n\n return setProgress([currentProgress, assetsCount])\n }\n\n return transactionDocs.push(doc)\n }\n\n // Promises are limited to three at once\n const result = new Promise((resolve, reject) => {\n const payloadIncludedDocs = payload.filter((item) => item.include).map((item) => item.doc)\n\n mapLimit(payloadIncludedDocs, 3, asyncify(fetchDoc), (err) => {\n if (err) {\n setIsDuplicating(false)\n setMessage({tone: 'critical', text: `Duplication Failed`})\n console.error(err)\n reject(new Error('Duplication Failed'))\n }\n\n resolve()\n })\n })\n\n await result\n\n // Remap SVG references to new _id's\n const transactionDocsMapped = transactionDocs.map((doc) => {\n const expr = `.._ref`\n const references = extractWithPath(expr, doc)\n\n if (!references.length) {\n return doc\n }\n\n // For every found _ref, search for an SVG asset _id and update\n references.forEach((ref) => {\n const newRefValue = svgMaps.find((asset) => asset.old === ref.value)?.new\n\n if (newRefValue) {\n const refPath = ref.path.join('.')\n\n dset(doc, refPath, newRefValue)\n }\n })\n\n return doc\n })\n\n // Create transaction\n const transaction = destinationClient.transaction()\n\n transactionDocsMapped.forEach((doc) => {\n transaction.createOrReplace(doc)\n })\n\n await transaction\n .commit()\n .then((res) => {\n setMessage({tone: 'positive', text: 'Duplication complete!'})\n\n updatePayloadStatuses()\n })\n .catch((err) => {\n setMessage({tone: 'critical', text: err.details.description})\n })\n\n setIsDuplicating(false)\n setProgress(0)\n }\n\n function handleChange(e) {\n setDestination(spacesOptions.find((space) => space.name === e.currentTarget.value))\n }\n\n if (!spacesOptions.length) {\n return (\n <Feedback tone=\"critical\">\n <code>__experimental_spaces</code> not found in <code>sanity.json</code>\n </Feedback>\n )\n }\n\n const payloadCount = payload.length\n const firstSvgIndex = payload.findIndex(({doc}) => doc.extension === 'svg')\n const selectedDocumentsCount = payload.filter(\n (item) => item.include && !typeIsAsset(item.doc._type)\n ).length\n const selectedAssetsCount = payload.filter(\n (item) => item.include && typeIsAsset(item.doc._type)\n ).length\n const selectedTotal = selectedDocumentsCount + selectedAssetsCount\n const destinationTitle = destination?.title ?? destination?.name\n const hasMultipleProjectIds =\n new Set(spacesOptions.map((space) => space?.api?.projectId).filter(Boolean)).size > 1\n\n const headingText = [selectedTotal, `/`, payloadCount, `Documents and Assets selected`].join(` `)\n\n const buttonText = React.useMemo(() => {\n let text = [`Duplicate`]\n\n if (selectedDocumentsCount > 1) {\n text.push(selectedDocumentsCount, selectedDocumentsCount === 1 ? `Document` : `Documents`)\n }\n\n if (selectedAssetsCount > 1) {\n text.push(`and`, selectedAssetsCount, selectedAssetsCount === 1 ? `Asset` : `Assets`)\n }\n\n if (originClient.config().projectId !== destination.api.projectId) {\n text.push(`between Projects`)\n }\n\n text.push(`to`, destinationTitle)\n\n return text.join(` `)\n }, [selectedDocumentsCount, selectedAssetsCount, destinationTitle])\n\n return (\n <Container width={1}>\n <Card>\n <Stack>\n <>\n <Card borderBottom padding={4} style={stickyStyles}>\n <Stack space={4}>\n <Flex space={3}>\n <Stack style={{flex: 1}} space={3}>\n <Label>Duplicate from</Label>\n <Select readOnly value={spacesOptions.find((space) => space.disabled)?.name}>\n {spacesOptions\n .filter((space) => space.disabled)\n .map((space) => (\n <option key={space.name} value={space.name} disabled={space.disabled}>\n {space.title ?? space.name}\n {hasMultipleProjectIds ? ` (${space.api.projectId})` : ``}\n </option>\n ))}\n </Select>\n </Stack>\n <Box padding={4} paddingTop={5} paddingBottom={0}>\n <Text size={3}>\n <ArrowRightIcon />\n </Text>\n </Box>\n <Stack style={{flex: 1}} space={3}>\n <Label>To Destination</Label>\n <Select onChange={handleChange}>\n {spacesOptions.map((space) => (\n <option key={space.name} value={space.name} disabled={space.disabled}>\n {space.title ?? space.name}\n {hasMultipleProjectIds ? ` (${space.api.projectId})` : ``}\n {space.disabled ? ` (Current)` : ``}\n </option>\n ))}\n </Select>\n </Stack>\n </Flex>\n\n {isDuplicating && (\n <Card border radius={2}>\n <Card\n style={{\n width: '100%',\n transform: `scaleX(${progress[0] / progress[1]})`,\n transformOrigin: 'left',\n transition: 'transform .2s ease',\n boxSizing: 'border-box',\n }}\n padding={1}\n tone=\"positive\"\n />\n </Card>\n )}\n {payload.length > 0 && (\n <>\n <Label>{headingText}</Label>\n <SelectButtons payload={payload} setPayload={setPayload} />\n </>\n )}\n </Stack>\n </Card>\n {message?.text && (\n <Box paddingX={4} paddingTop={4}>\n <Card padding={3} radius={2} shadow={1} tone={message?.tone ?? 'transparent'}>\n <Text size={1}>{message.text}</Text>\n </Card>\n </Box>\n )}\n {payload.length > 0 && (\n <Stack padding={4} space={3}>\n {payload.map(({doc, include, status}, index) => (\n <React.Fragment key={doc._id}>\n <Flex align=\"center\">\n <Checkbox checked={include} onChange={() => handleCheckbox(doc._id)} />\n <Box style={{flex: 1}} paddingX={3}>\n <Preview value={doc} type={schema.get(doc._type)} />\n </Box>\n <StatusBadge status={status} isAsset={typeIsAsset(doc._type)} />\n </Flex>\n {doc?.extension === 'svg' && index === firstSvgIndex && (\n <Card padding={3} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new{' '}\n <code>_id</code>'s at the destination. The newly generated <code>_id</code>{' '}\n will be the same in each duplication, but it will never be the same{' '}\n <code>_id</code> as the first time this Asset was uploaded. References to the asset will be updated to use the new <code>_id</code>.\n </Text>\n </Card>\n )}\n </React.Fragment>\n ))}\n </Stack>\n )}\n <Stack space={2} padding={4} paddingTop={0}>\n {hasReferences && (\n <Button\n fontSize={2}\n padding={4}\n tone=\"positive\"\n mode=\"ghost\"\n icon={SearchIcon}\n onClick={handleReferences}\n text=\"Gather References\"\n disabled={isDuplicating || !selectedTotal || isGathering}\n />\n )}\n <Button\n fontSize={2}\n padding={4}\n tone=\"positive\"\n icon={LaunchIcon}\n onClick={handleDuplicate}\n text={buttonText}\n disabled={isDuplicating || !selectedTotal || isGathering}\n />\n </Stack>\n </>\n </Stack>\n </Card>\n </Container>\n )\n}\n"],"file":"DuplicatorTool.js"}
|
|
1
|
+
{"version":3,"file":"DuplicatorTool.js","names":["DuplicatorTool","props","docs","draftIds","token","originClient","sanityClient","withConfig","clientConfig","spacesOptions","config","__experimental_spaces","length","map","space","api","projectId","process","env","SANITY_STUDIO_API_PROJECT_ID","usingEnvForProjectId","disabled","dataset","useState","find","destination","setDestination","message","setMessage","item","doc","include","status","hasDraft","includes","_id","payload","setPayload","hasReferences","setHasReferences","isDuplicating","setIsDuplicating","isGathering","setIsGathering","progress","setProgress","useEffect","expr","initialRefs","initialPayload","forEach","push","extract","docCount","refsCount","tone","text","createInitialMessage","updatePayloadStatuses","newPayload","payloadActual","name","payloadIds","destinationClient","destinationData","fetch","updatedPayload","existingDoc","_updatedAt","Date","handleCheckbox","handleReferences","docIds","payloadDocs","getDocumentsInArray","draftDocs","id","draftDocsIds","Set","payloadShaped","has","handleDuplicate","assetsCount","filter","typeIsAsset","_type","currentProgress","transactionDocs","svgMaps","fetchDoc","uploadType","split","pop","replace","downloadUrl","url","downloadConfig","headers","Authorization","then","res","assetData","blob","options","filename","originalFilename","assetDoc","assets","upload","extension","old","new","result","Promise","resolve","reject","payloadIncludedDocs","mapLimit","asyncify","err","console","error","Error","transactionDocsMapped","references","extractWithPath","ref","newRefValue","asset","value","refPath","path","join","dset","transaction","createOrReplace","commit","catch","details","description","handleChange","e","currentTarget","payloadCount","firstSvgIndex","findIndex","selectedDocumentsCount","selectedAssetsCount","selectedTotal","destinationTitle","title","hasMultipleProjectIds","Boolean","size","headingText","buttonText","React","useMemo","stickyStyles","flex","width","transform","transformOrigin","transition","boxSizing","index","schema","get","SearchIcon","LaunchIcon"],"sources":["../../src/components/DuplicatorTool.tsx"],"sourcesContent":["/* eslint-disable react/jsx-no-bind */\nimport React, {useState, useEffect} from 'react'\nimport mapLimit from 'async/mapLimit'\nimport asyncify from 'async/asyncify'\nimport {extract, extractWithPath} from '@sanity/mutator'\nimport {dset} from 'dset'\nimport {\n Card,\n Container,\n Text,\n Box,\n Button,\n Label,\n Stack,\n Select,\n Flex,\n Checkbox,\n} from '@sanity/ui'\nimport {ArrowRightIcon, SearchIcon, LaunchIcon} from '@sanity/icons'\nimport sanityClient from 'part:@sanity/base/client'\nimport Preview from 'part:@sanity/base/preview'\nimport schema from 'part:@sanity/base/schema'\nimport config from 'config:sanity'\n\nimport {typeIsAsset, stickyStyles, createInitialMessage} from '../helpers'\nimport {getDocumentsInArray} from '../helpers/getDocumentsInArray'\nimport SelectButtons from './SelectButtons'\nimport StatusBadge from './StatusBadge'\nimport Feedback from './Feedback'\nimport {SanityDocument} from '../types'\nimport {clientConfig} from '../helpers/clientConfig'\n\ntype DuplicatorToolProps = {\n docs: SanityDocument[]\n draftIds: string[]\n token: string\n}\n\nexport default function DuplicatorTool(props: DuplicatorToolProps) {\n const {docs, draftIds, token} = props\n\n // Prepare origin (this Studio) client\n // In function-scope so it is up to date on every render\n const originClient = sanityClient.withConfig(clientConfig)\n\n // Create list of dataset options\n // and set initial value of dropdown\n const spacesOptions = config?.__experimental_spaces?.length\n ? config.__experimental_spaces.map((space) => ({\n ...space,\n api: {\n ...space.api,\n projectId: space.api.projectId || process.env.SANITY_STUDIO_API_PROJECT_ID,\n },\n usingEnvForProjectId: !space.api.projectId && process.env.SANITY_STUDIO_API_PROJECT_ID,\n disabled:\n space.api.dataset === originClient.config().dataset &&\n space.api.projectId === originClient.config().projectId,\n }))\n : []\n\n const [destination, setDestination] = useState(\n spacesOptions.length ? spacesOptions.find((space) => !space.disabled) : {}\n )\n const [message, setMessage] = useState({})\n const [payload, setPayload] = useState(\n docs.length\n ? docs.map((item) => ({\n doc: item,\n include: true,\n status: null,\n hasDraft: draftIds?.length ? draftIds.includes(`drafts.${item._id}`) : false,\n }))\n : []\n )\n const [hasReferences, setHasReferences] = useState(false)\n const [isDuplicating, setIsDuplicating] = useState(false)\n const [isGathering, setIsGathering] = useState(false)\n const [progress, setProgress] = useState([0, 0])\n\n // Check for References and update message\n useEffect(() => {\n const expr = `.._ref`\n const initialRefs = []\n const initialPayload = []\n\n docs.forEach((doc) => {\n initialRefs.push(...extract(expr, doc))\n initialPayload.push({include: true, doc})\n })\n\n setPayload(initialPayload)\n\n const docCount = docs.length\n const refsCount = initialRefs.length\n\n if (initialRefs.length) {\n setHasReferences(true)\n\n setMessage({\n tone: `caution`,\n text: createInitialMessage(docCount, refsCount),\n })\n }\n }, [docs])\n\n // Re-check payload on destination when value changes\n // (On initial render + select change)\n useEffect(() => {\n updatePayloadStatuses()\n }, [destination, docs])\n\n // Check if payload documents exist at destination\n async function updatePayloadStatuses(newPayload = []) {\n const payloadActual = newPayload.length ? newPayload : payload\n\n if (!payloadActual.length || !destination?.name) {\n return\n }\n\n const payloadIds = payloadActual.map(({doc}) => doc._id)\n const destinationClient = sanityClient.withConfig({\n ...clientConfig,\n dataset: destination.api.dataset,\n projectId: destination.api.projectId,\n })\n const destinationData = await destinationClient.fetch(\n `*[_id in $payloadIds]{ _id, _updatedAt }`,\n {payloadIds}\n )\n\n const updatedPayload = payloadActual.map((item) => {\n const existingDoc = destinationData.find((doc) => doc._id === item.doc._id)\n\n if (existingDoc?._updatedAt && item?.doc?._updatedAt) {\n if (existingDoc._updatedAt === item.doc._updatedAt) {\n // Exact same document exists at destination\n // We don't compare by _rev because that is updated in a transaction\n item.status = `EXISTS`\n } else if (existingDoc._updatedAt && item.doc._updatedAt) {\n item.status =\n new Date(existingDoc._updatedAt) > new Date(item.doc._updatedAt)\n ? // Document at destination is newer\n `OVERWRITE`\n : // Document at destination is older\n `UPDATE`\n }\n } else {\n item.status = 'CREATE'\n }\n\n return item\n })\n\n setPayload(updatedPayload)\n }\n\n function handleCheckbox(_id) {\n const updatedPayload = payload.map((item) => {\n if (item.doc._id === _id) {\n item.include = !item.include\n }\n\n return item\n })\n\n setPayload(updatedPayload)\n }\n\n // Find and recursively follow references beginning with this document\n async function handleReferences() {\n setIsGathering(true)\n const docIds = docs.map((doc) => doc._id)\n\n const payloadDocs = await getDocumentsInArray(docIds, originClient, null)\n const draftDocs = await getDocumentsInArray(\n docIds.map((id) => `drafts.${id}`),\n originClient,\n null,\n `{_id}`\n )\n const draftDocsIds = new Set(draftDocs.map(({_id}) => _id))\n\n // Shape it up\n const payloadShaped = payloadDocs.map((doc) => ({\n doc,\n // Include this in the transaction?\n include: true,\n // Does it exist at the destination?\n status: '',\n // Does it have any drafts?\n hasDraft: draftDocsIds.has(`drafts.${doc._id}`),\n }))\n\n setPayload(payloadShaped)\n updatePayloadStatuses(payloadShaped)\n setIsGathering(false)\n }\n\n // Duplicate payload to destination dataset\n async function handleDuplicate() {\n setIsDuplicating(true)\n\n const assetsCount = payload.filter(({doc, include}) => include && typeIsAsset(doc._type)).length\n let currentProgress = 0\n setProgress([currentProgress, assetsCount])\n\n setMessage({text: 'Duplicating...'})\n\n const destinationClient = sanityClient.withConfig({\n ...clientConfig,\n dataset: destination.api.dataset,\n projectId: destination.api.projectId,\n })\n\n const transactionDocs = []\n const svgMaps = []\n\n // Upload assets and then add to transaction\n async function fetchDoc(doc) {\n if (typeIsAsset(doc._type)) {\n // Download and upload asset\n // Get the *original* image with this dlRaw param to create the same determenistic _id\n const uploadType = doc._type.split('.').pop().replace('Asset', '')\n const downloadUrl = uploadType === 'image' ? `${doc.url}?dlRaw=true` : doc.url\n const downloadConfig =\n uploadType === 'image' ? {headers: {Authorization: `Bearer ${token}`}} : {}\n\n await fetch(downloadUrl, downloadConfig).then(async (res) => {\n const assetData = await res.blob()\n\n const options = {filename: doc.originalFilename}\n const assetDoc = await destinationClient.assets.upload(uploadType, assetData, options)\n\n // SVG _id's need remapping before transaction\n if (doc?.extension === 'svg') {\n svgMaps.push({old: doc._id, new: assetDoc._id})\n }\n\n transactionDocs.push(assetDoc)\n })\n\n currentProgress += 1\n setMessage({\n text: `Duplicating ${currentProgress}/${assetsCount} ${\n assetsCount === 1 ? `Assets` : `Assets`\n }`,\n })\n\n return setProgress([currentProgress, assetsCount])\n }\n\n return transactionDocs.push(doc)\n }\n\n // Promises are limited to three at once\n const result = new Promise((resolve, reject) => {\n const payloadIncludedDocs = payload.filter((item) => item.include).map((item) => item.doc)\n\n mapLimit(payloadIncludedDocs, 3, asyncify(fetchDoc), (err) => {\n if (err) {\n setIsDuplicating(false)\n setMessage({tone: 'critical', text: `Duplication Failed`})\n console.error(err)\n reject(new Error('Duplication Failed'))\n }\n\n resolve()\n })\n })\n\n await result\n\n // Remap SVG references to new _id's\n const transactionDocsMapped = transactionDocs.map((doc) => {\n const expr = `.._ref`\n const references = extractWithPath(expr, doc)\n\n if (!references.length) {\n return doc\n }\n\n // For every found _ref, search for an SVG asset _id and update\n references.forEach((ref) => {\n const newRefValue = svgMaps.find((asset) => asset.old === ref.value)?.new\n\n if (newRefValue) {\n const refPath = ref.path.join('.')\n\n dset(doc, refPath, newRefValue)\n }\n })\n\n return doc\n })\n\n // Create transaction\n const transaction = destinationClient.transaction()\n\n transactionDocsMapped.forEach((doc) => {\n transaction.createOrReplace(doc)\n })\n\n await transaction\n .commit()\n .then((res) => {\n setMessage({tone: 'positive', text: 'Duplication complete!'})\n\n updatePayloadStatuses()\n })\n .catch((err) => {\n setMessage({tone: 'critical', text: err.details.description})\n })\n\n setIsDuplicating(false)\n setProgress(0)\n }\n\n function handleChange(e) {\n setDestination(spacesOptions.find((space) => space.name === e.currentTarget.value))\n }\n\n if (!spacesOptions.length) {\n return (\n <Feedback tone=\"critical\">\n <code>__experimental_spaces</code> not found in <code>sanity.json</code>\n </Feedback>\n )\n }\n\n const payloadCount = payload.length\n const firstSvgIndex = payload.findIndex(({doc}) => doc.extension === 'svg')\n const selectedDocumentsCount = payload.filter(\n (item) => item.include && !typeIsAsset(item.doc._type)\n ).length\n const selectedAssetsCount = payload.filter(\n (item) => item.include && typeIsAsset(item.doc._type)\n ).length\n const selectedTotal = selectedDocumentsCount + selectedAssetsCount\n const destinationTitle = destination?.title ?? destination?.name\n const hasMultipleProjectIds =\n new Set(spacesOptions.map((space) => space?.api?.projectId).filter(Boolean)).size > 1\n\n const headingText = [selectedTotal, `/`, payloadCount, `Documents and Assets selected`].join(` `)\n\n const buttonText = React.useMemo(() => {\n const text = [`Duplicate`]\n\n if (selectedDocumentsCount > 1) {\n text.push(selectedDocumentsCount, selectedDocumentsCount === 1 ? `Document` : `Documents`)\n }\n\n if (selectedAssetsCount > 1) {\n text.push(`and`, selectedAssetsCount, selectedAssetsCount === 1 ? `Asset` : `Assets`)\n }\n\n if (originClient.config().projectId !== destination.api.projectId) {\n text.push(`between Projects`)\n }\n\n text.push(`to`, destinationTitle)\n\n return text.join(` `)\n }, [selectedDocumentsCount, selectedAssetsCount, destinationTitle])\n\n return (\n <Container width={1}>\n <Card>\n <Stack>\n <>\n <Card borderBottom padding={4} style={stickyStyles}>\n <Stack space={4}>\n <Flex space={3}>\n <Stack style={{flex: 1}} space={3}>\n <Label>Duplicate from</Label>\n <Select readOnly value={spacesOptions.find((space) => space.disabled)?.name}>\n {spacesOptions\n .filter((space) => space.disabled)\n .map((space) => (\n <option key={space.name} value={space.name} disabled={space.disabled}>\n {space.title ?? space.name}\n {hasMultipleProjectIds || space.usingEnvForProjectId ? ` (${space.api.projectId})` : ``}\n </option>\n ))}\n </Select>\n </Stack>\n <Box padding={4} paddingTop={5} paddingBottom={0}>\n <Text size={3}>\n <ArrowRightIcon />\n </Text>\n </Box>\n <Stack style={{flex: 1}} space={3}>\n <Label>To Destination</Label>\n <Select onChange={handleChange}>\n {spacesOptions.map((space) => (\n <option key={space.name} value={space.name} disabled={space.disabled}>\n {space.title ?? space.name}\n {hasMultipleProjectIds || space.usingEnvForProjectId ? ` (${space.api.projectId})` : ``}\n {space.disabled ? ` (Current)` : ``}\n </option>\n ))}\n </Select>\n </Stack>\n </Flex>\n\n {isDuplicating && (\n <Card border radius={2}>\n <Card\n style={{\n width: '100%',\n transform: `scaleX(${progress[0] / progress[1]})`,\n transformOrigin: 'left',\n transition: 'transform .2s ease',\n boxSizing: 'border-box',\n }}\n padding={1}\n tone=\"positive\"\n />\n </Card>\n )}\n {payload.length > 0 && (\n <>\n <Label>{headingText}</Label>\n <SelectButtons payload={payload} setPayload={setPayload} />\n </>\n )}\n </Stack>\n </Card>\n {message?.text && (\n <Box paddingX={4} paddingTop={4}>\n <Card padding={3} radius={2} shadow={1} tone={message?.tone ?? 'transparent'}>\n <Text size={1}>{message.text}</Text>\n </Card>\n </Box>\n )}\n {payload.length > 0 && (\n <Stack padding={4} space={3}>\n {payload.map(({doc, include, status, hasDraft}, index) => (\n <React.Fragment key={doc._id}>\n <Flex align=\"center\">\n <Checkbox checked={include} onChange={() => handleCheckbox(doc._id)} />\n <Box flex={1} paddingX={3}>\n <Preview value={doc} type={schema.get(doc._type)} />\n </Box>\n <Flex items=\"center\" gap={2}>\n {hasDraft ? <StatusBadge status=\"UNPUBLISHED\" isAsset={false} /> : null}\n <StatusBadge status={status} isAsset={typeIsAsset(doc._type)} />\n </Flex>\n </Flex>\n {doc?.extension === 'svg' && index === firstSvgIndex && (\n <Card padding={3} radius={2} shadow={1} tone=\"caution\">\n <Text size={1}>\n Due to how SVGs are sanitized after first uploaded, duplicated SVG assets\n may have new <code>_id</code>'s at the destination. The newly generated{' '}\n <code>_id</code> will be the same in each duplication, but it will never\n be the same <code>_id</code> as the first time this Asset was uploaded.\n References to the asset will be updated to use the new <code>_id</code>.\n </Text>\n </Card>\n )}\n </React.Fragment>\n ))}\n </Stack>\n )}\n <Stack space={2} padding={4} paddingTop={0}>\n {hasReferences && (\n <Button\n fontSize={2}\n padding={4}\n tone=\"positive\"\n mode=\"ghost\"\n icon={SearchIcon}\n onClick={handleReferences}\n text=\"Gather References\"\n disabled={isDuplicating || !selectedTotal || isGathering}\n />\n )}\n <Button\n fontSize={2}\n padding={4}\n tone=\"positive\"\n icon={LaunchIcon}\n onClick={handleDuplicate}\n text={buttonText}\n disabled={isDuplicating || !selectedTotal || isGathering}\n />\n </Stack>\n </>\n </Stack>\n </Card>\n </Container>\n )\n}\n"],"mappings":";;;;;;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAYA;;AACA;;AACA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;AACA;;AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQe,SAASA,cAAT,CAAwBC,KAAxB,EAAoD;EAAA;;EACjE,IAAOC,IAAP,GAAgCD,KAAhC,CAAOC,IAAP;EAAA,IAAaC,QAAb,GAAgCF,KAAhC,CAAaE,QAAb;EAAA,IAAuBC,KAAvB,GAAgCH,KAAhC,CAAuBG,KAAvB,CADiE,CAGjE;EACA;;EACA,IAAMC,YAAY,GAAGC,eAAA,CAAaC,UAAb,CAAwBC,0BAAxB,CAArB,CALiE,CAOjE;EACA;;;EACA,IAAMC,aAAa,GAAGC,qBAAA,aAAAA,qBAAA,wCAAAA,qBAAA,CA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CADH,CAnEJ,eA+FE,6BAAC,SAAD;IAAO,KAAK,EAAE,CAAd;IAAiB,OAAO,EAAE,CAA1B;IAA6B,UAAU,EAAE;EAAzC,GACG1G,aAAa,iBACZ,6BAAC,UAAD;IACE,QAAQ,EAAE,CADZ;IAEE,OAAO,EAAE,CAFX;IAGE,IAAI,EAAC,UAHP;IAIE,IAAI,EAAC,OAJP;IAKE,IAAI,EAAEkI,iBALR;IAME,OAAO,EAAEjG,gBANX;IAOE,IAAI,EAAC,mBAPP;IAQE,QAAQ,EAAE/B,aAAa,IAAI,CAAC4G,aAAlB,IAAmC1G;EAR/C,EAFJ,eAaE,6BAAC,UAAD;IACE,QAAQ,EAAE,CADZ;IAEE,OAAO,EAAE,CAFX;IAGE,IAAI,EAAC,UAHP;IAIE,IAAI,EAAE+H,iBAJR;IAKE,OAAO,EAAExF,eALX;IAME,IAAI,EAAE0E,UANR;IAOE,QAAQ,EAAEnH,aAAa,IAAI,CAAC4G,aAAlB,IAAmC1G;EAP/C,EAbF,CA/FF,CADF,CADF,CADF,CADF;AA+HD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"Feedback.js","names":["Feedback","props","children","tone"],"sources":["../../src/components/Feedback.tsx"],"sourcesContent":["import React from 'react'\nimport {Card, Text} from '@sanity/ui'\nimport type {BadgeTone} from '@sanity/ui'\n\ntype FeedbackProps = {\n children?: React.ReactNode\n tone?: BadgeTone\n}\n\nexport default function Feedback(props: FeedbackProps) {\n const {children, tone = `caution`} = props\n\n return (\n <Card padding={3} radius={2} shadow={1} tone={tone}>\n <Text size={1}>{children}</Text>\n </Card>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAQe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;EACrD,IAAOC,QAAP,GAAqCD,KAArC,CAAOC,QAAP;EAAA,kBAAqCD,KAArC,CAAiBE,IAAjB;EAAA,IAAiBA,IAAjB;EAEA,oBACE,6BAAC,QAAD;IAAM,OAAO,EAAE,CAAf;IAAkB,MAAM,EAAE,CAA1B;IAA6B,MAAM,EAAE,CAArC;IAAwC,IAAI,EAAEA;EAA9C,gBACE,6BAAC,QAAD;IAAM,IAAI,EAAE;EAAZ,GAAgBD,QAAhB,CADF,CADF;AAKD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"ResetSecret.js","names":["client","sanityClient","withConfig","clientConfig","handleClick","delete","query","SECRET_NAMESPACE","ResetSecret"],"sources":["../../src/components/ResetSecret.tsx"],"sourcesContent":["import React from 'react'\nimport {Button, Flex} from '@sanity/ui'\nimport sanityClient from 'part:@sanity/base/client'\n\nimport { clientConfig } from '../helpers/clientConfig'\nimport { SECRET_NAMESPACE } from '../helpers/constants'\n\nconst client = sanityClient.withConfig(clientConfig)\n\nfunction handleClick() {\n client.delete({query: `*[_id == \"secrets.${SECRET_NAMESPACE}\"]`})\n}\n\nexport default function ResetSecret() {\n return (\n <Flex align=\"center\" justify=\"flex-end\" paddingX={[2, 2, 2, 5]} paddingY={5}>\n <Button\n text=\"Reset Secret\"\n onClick={() => handleClick()}\n mode=\"ghost\"\n tone=\"critical\"\n fontSize={1}\n padding={2}\n />\n </Flex>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,IAAMA,MAAM,GAAGC,eAAA,CAAaC,UAAb,CAAwBC,0BAAxB,CAAf;;AAEA,SAASC,WAAT,GAAuB;EACrBJ,MAAM,CAACK,MAAP,CAAc;IAACC,KAAK,+BAAuBC,2BAAvB;EAAN,CAAd;AACD;;AAEc,SAASC,WAAT,GAAuB;EACpC,oBACE,6BAAC,QAAD;IAAM,KAAK,EAAC,QAAZ;IAAqB,OAAO,EAAC,UAA7B;IAAwC,QAAQ,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAlD;IAAgE,QAAQ,EAAE;EAA1E,gBACE,6BAAC,UAAD;IACE,IAAI,EAAC,cADP;IAEE,OAAO,EAAE,MAAMJ,WAAW,EAF5B;IAGE,IAAI,EAAC,OAHP;IAIE,IAAI,EAAC,UAJP;IAKE,QAAQ,EAAE,CALZ;IAME,OAAO,EAAE;EANX,EADF,CADF;AAYD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"SelectButtons.js","names":["buttons","SelectButtons","props","payload","setPayload","useState","disabledActions","setDisabledActions","useEffect","length","every","item","include","handleSelectButton","action","newPayload","map","Boolean","status","typeIsAsset","doc","_type","actionIndex","includes","toUpperCase"],"sources":["../../src/components/SelectButtons.tsx"],"sourcesContent":["import React, {useState, useEffect} from 'react'\nimport {Button, Card, Flex} from '@sanity/ui'\nimport {typeIsAsset} from '../helpers'\nimport {PayloadItem} from '../types'\n\nconst buttons = [`All`, `None`, null, `New`, `Existing`, `Older`, null, `Documents`, `Assets`]\n\ntype SelectButtonsProps = {\n payload: PayloadItem[]\n setPayload: Function\n}\n\nexport default function SelectButtons(props: SelectButtonsProps) {\n const {payload, setPayload} = props\n const [disabledActions, setDisabledActions] = useState([])\n\n // Set intiial disabled button\n useEffect(() => {\n if (!disabledActions?.length && payload.every((item) => item.include)) {\n setDisabledActions([`ALL`])\n }\n }, [])\n\n function handleSelectButton(action = ``) {\n if (!action || !payload.length) return\n\n const newPayload = [...payload]\n\n switch (action) {\n case 'ALL':\n newPayload.map((item) => (item.include = true))\n break\n case 'NONE':\n newPayload.map((item) => (item.include = false))\n break\n case 'NEW':\n newPayload.map((item) => (item.include = Boolean(item.status === 'CREATE')))\n break\n case 'EXISTING':\n newPayload.map((item) => (item.include = Boolean(item.status === 'EXISTS')))\n break\n case 'OLDER':\n newPayload.map((item) => (item.include = Boolean(item.status === 'OVERWRITE')))\n break\n case 'ASSETS':\n newPayload.map((item) => (item.include = typeIsAsset(item.doc._type)))\n break\n case 'DOCUMENTS':\n newPayload.map((item) => (item.include = !typeIsAsset(item.doc._type)))\n break\n default:\n break\n }\n\n setDisabledActions([action])\n setPayload(newPayload)\n }\n\n return (\n <Card padding={1} radius={3} shadow={1}>\n <Flex gap={2}>\n {buttons.map((action, actionIndex) =>\n action ? (\n <Button\n key={action}\n fontSize={1}\n mode=\"bleed\"\n padding={2}\n text={action}\n disabled={disabledActions.includes(action.toUpperCase())}\n onClick={() => handleSelectButton(action.toUpperCase())}\n />\n ) : (\n <Card key={`divider-${actionIndex}`} borderLeft />\n )\n )}\n </Flex>\n </Card>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAGA,IAAMA,OAAO,GAAG,gBAAgB,IAAhB,8BAAkD,IAAlD,wBAAhB;;AAOe,SAASC,aAAT,CAAuBC,KAAvB,EAAkD;EAC/D,IAAOC,OAAP,GAA8BD,KAA9B,CAAOC,OAAP;EAAA,IAAgBC,UAAhB,GAA8BF,KAA9B,CAAgBE,UAAhB;;EACA,gBAA8C,IAAAC,eAAA,EAAS,EAAT,CAA9C;EAAA;EAAA,IAAOC,eAAP;EAAA,IAAwBC,kBAAxB,iBAF+D,CAI/D;;;EACA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,EAACF,eAAD,aAACA,eAAD,eAACA,eAAe,CAAEG,MAAlB,KAA4BN,OAAO,CAACO,KAAR,CAAeC,IAAD,IAAUA,IAAI,CAACC,OAA7B,CAAhC,EAAuE;MACrEL,kBAAkB,CAAC,OAAD,CAAlB;IACD;EACF,CAJD,EAIG,EAJH;;EAMA,SAASM,kBAAT,GAAyC;IAAA,IAAbC,MAAa;IACvC,IAAI,CAACA,MAAD,IAAW,CAACX,OAAO,CAACM,MAAxB,EAAgC;IAEhC,IAAMM,UAAU,GAAG,CAAC,GAAGZ,OAAJ,CAAnB;;IAEA,QAAQW,MAAR;MACE,KAAK,KAAL;QACEC,UAAU,CAACC,GAAX,CAAgBL,IAAD,IAAWA,IAAI,CAACC,OAAL,GAAe,IAAzC;QACA;;MACF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,IAAI,EAAC,OAHP;IAIE,OAAO,EAAE,CAJX;IAKE,IAAI,EAAEA,MALR;IAME,QAAQ,EAAER,eAAe,CAACiB,QAAhB,CAAyBT,MAAM,CAACU,WAAP,EAAzB,CANZ;IAOE,OAAO,EAAE,MAAMX,kBAAkB,CAACC,MAAM,CAACU,WAAP,EAAD;EAPnC,EADI,gBAWJ,6BAAC,QAAD;IAAM,GAAG,oBAAaF,WAAb,CAAT;IAAqC,UAAU;EAA/C,EAZH,CADH,CADF,CADF;AAqBD"}
|
|
@@ -15,13 +15,15 @@ var documentTones = {
|
|
|
15
15
|
EXISTS: "primary",
|
|
16
16
|
OVERWRITE: "critical",
|
|
17
17
|
UPDATE: "caution",
|
|
18
|
-
CREATE: "positive"
|
|
18
|
+
CREATE: "positive",
|
|
19
|
+
UNPUBLISHED: "caution"
|
|
19
20
|
};
|
|
20
21
|
var assetTones = {
|
|
21
22
|
EXISTS: "critical",
|
|
22
23
|
OVERWRITE: "critical",
|
|
23
24
|
UPDATE: "critical",
|
|
24
|
-
CREATE: "positive"
|
|
25
|
+
CREATE: "positive",
|
|
26
|
+
UNPUBLISHED: "default"
|
|
25
27
|
};
|
|
26
28
|
var documentMessages = {
|
|
27
29
|
// Only happens once document is copied the first time, and _updatedAt is the same
|
|
@@ -33,19 +35,22 @@ var documentMessages = {
|
|
|
33
35
|
// Document at destination is older
|
|
34
36
|
UPDATE: "An older version of this document exists at the Destination, and it will be overwritten with this version.",
|
|
35
37
|
// Document at destination doesn't exist
|
|
36
|
-
CREATE: "This document will be created at the destination."
|
|
38
|
+
CREATE: "This document will be created at the destination.",
|
|
39
|
+
UNPUBLISHED: "A Draft version of this Document exists in this Dataset, but only the Published version will be duplicated to the destination."
|
|
37
40
|
};
|
|
38
41
|
var assetMessages = {
|
|
39
42
|
EXISTS: "This Asset already exists at the Destination",
|
|
40
43
|
OVERWRITE: "This Asset already exists at the Destination",
|
|
41
44
|
UPDATE: "This Asset already exists at the Destination",
|
|
42
|
-
CREATE: "This Asset does not yet exist at the Destination"
|
|
45
|
+
CREATE: "This Asset does not yet exist at the Destination",
|
|
46
|
+
UNPUBLISHED: ""
|
|
43
47
|
};
|
|
44
48
|
var assetStatus = {
|
|
45
49
|
EXISTS: "RE-UPLOAD",
|
|
46
50
|
OVERWRITE: "RE-UPLOAD",
|
|
47
51
|
UPDATE: "RE-UPLOAD",
|
|
48
|
-
CREATE: "UPLOAD"
|
|
52
|
+
CREATE: "UPLOAD",
|
|
53
|
+
UNPUBLISHED: ""
|
|
49
54
|
};
|
|
50
55
|
|
|
51
56
|
function StatusBadge(props) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"StatusBadge.js","names":["documentTones","EXISTS","OVERWRITE","UPDATE","CREATE","UNPUBLISHED","assetTones","documentMessages","assetMessages","assetStatus","StatusBadge","props","status","isAsset","badgeTone","badgeText","badgeStatus","maxWidth"],"sources":["../../src/components/StatusBadge.tsx"],"sourcesContent":["import React from 'react'\nimport {Box, Text, Badge, Tooltip} from '@sanity/ui'\nimport type {BadgeTone} from '@sanity/ui'\n\ntype StatusTones = {\n EXISTS: BadgeTone\n OVERWRITE: BadgeTone\n UPDATE: BadgeTone\n CREATE: BadgeTone\n UNPUBLISHED: BadgeTone\n}\n\nconst documentTones: StatusTones = {\n EXISTS: `primary`,\n OVERWRITE: `critical`,\n UPDATE: `caution`,\n CREATE: `positive`,\n UNPUBLISHED: `caution`,\n}\n\nconst assetTones: StatusTones = {\n EXISTS: `critical`,\n OVERWRITE: `critical`,\n UPDATE: `critical`,\n CREATE: `positive`,\n UNPUBLISHED: `default`\n}\n\ntype messageTypes = {\n EXISTS: string\n OVERWRITE: string\n UPDATE: string\n CREATE: string\n UNPUBLISHED: string\n}\n\nconst documentMessages: messageTypes = {\n // Only happens once document is copied the first time, and _updatedAt is the same\n EXISTS: `This document already exists at the Destination with the same ID with the same Updated time.`,\n // Is true immediately after transaction as _updatedAt is updated by API after mutation\n // Is also true if the document at the destination has been manually modified\n // Presently, the plugin doesn't actually compare the two documents\n OVERWRITE: `A newer version of this document exists at the Destination, and it will be overwritten with this version.`,\n // Document at destination is older\n UPDATE: `An older version of this document exists at the Destination, and it will be overwritten with this version.`,\n // Document at destination doesn't exist\n CREATE: `This document will be created at the destination.`,\n UNPUBLISHED: `A Draft version of this Document exists in this Dataset, but only the Published version will be duplicated to the destination.`\n}\n\nconst assetMessages: messageTypes = {\n EXISTS: `This Asset already exists at the Destination`,\n OVERWRITE: `This Asset already exists at the Destination`,\n UPDATE: `This Asset already exists at the Destination`,\n CREATE: `This Asset does not yet exist at the Destination`,\n UNPUBLISHED: ``,\n}\n\nconst assetStatus: messageTypes = {\n EXISTS: `RE-UPLOAD`,\n OVERWRITE: `RE-UPLOAD`,\n UPDATE: `RE-UPLOAD`,\n CREATE: `UPLOAD`,\n UNPUBLISHED: ``,\n}\n\ntype StatusBadgeProps = {\n status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE' | 'UNPUBLISHED' | undefined\n isAsset: boolean\n}\n\nexport default function StatusBadge(props: StatusBadgeProps) {\n const {status, isAsset} = props\n\n const badgeTone = isAsset ? assetTones[status] : documentTones[status]\n \n if (!badgeTone) {\n return (\n <Badge muted padding={2} fontSize={1} mode=\"outline\">\n Checking...\n </Badge>\n )\n }\n \n const badgeText = isAsset ? assetMessages[status] : documentMessages[status]\n const badgeStatus = isAsset ? assetStatus[status] : status\n\n return (\n <Tooltip\n content={\n <Box padding={3} style={{maxWidth: 200}}>\n <Text size={1}>{badgeText}</Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Badge muted padding={2} fontSize={1} tone={badgeTone} mode=\"outline\">\n {badgeStatus}\n </Badge>\n </Tooltip>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAWA,IAAMA,aAA0B,GAAG;EACjCC,MAAM,WAD2B;EAEjCC,SAAS,YAFwB;EAGjCC,MAAM,WAH2B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AEA,oBACE,6BAAC,WAAD;IACE,OAAO,eACL,6BAAC,OAAD;MAAK,OAAO,EAAE,CAAd;MAAiB,KAAK,EAAE;QAACK,QAAQ,EAAE;MAAX;IAAxB,gBACE,6BAAC,QAAD;MAAM,IAAI,EAAE;IAAZ,GAAgBF,SAAhB,CADF,CAFJ;IAME,kBAAkB,EAAE,CAAC,OAAD,EAAU,MAAV,CANtB;IAOE,SAAS,EAAC,KAPZ;IAQE,MAAM;EARR,gBAUE,6BAAC,SAAD;IAAO,KAAK,MAAZ;IAAa,OAAO,EAAE,CAAtB;IAAyB,QAAQ,EAAE,CAAnC;IAAsC,IAAI,EAAED,SAA5C;IAAuD,IAAI,EAAC;EAA5D,GACGE,WADH,CAVF,CADF;AAgBD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"clientConfig.js","names":["clientConfig","apiVersion"],"sources":["../../src/helpers/clientConfig.ts"],"sourcesContent":["export const clientConfig = {apiVersion: `2021-05-19`}"],"mappings":";;;;;;AAAO,IAAMA,YAAY,GAAG;EAACC,UAAU;AAAX,CAArB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"constants.js","names":["SECRET_NAMESPACE"],"sources":["../../src/helpers/constants.ts"],"sourcesContent":["export const SECRET_NAMESPACE = `CrossDatasetDuplicator`"],"mappings":";;;;;;AAAO,IAAMA,gBAAgB,2BAAtB"}
|
|
@@ -13,15 +13,16 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
|
|
|
13
13
|
|
|
14
14
|
// Recursively fetch Documents from an array of _id's and their references
|
|
15
15
|
// Heavy use of Set is to avoid recursively querying for id's already in the payload
|
|
16
|
-
function getDocumentsInArray(_x, _x2, _x3) {
|
|
16
|
+
function getDocumentsInArray(_x, _x2, _x3, _x4) {
|
|
17
17
|
return _getDocumentsInArray.apply(this, arguments);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
function _getDocumentsInArray() {
|
|
21
|
-
_getDocumentsInArray = _asyncToGenerator(function* (fetchIds, client, currentIds) {
|
|
21
|
+
_getDocumentsInArray = _asyncToGenerator(function* (fetchIds, client, currentIds, projection) {
|
|
22
22
|
var collection = []; // Find initial docs
|
|
23
23
|
|
|
24
|
-
var
|
|
24
|
+
var query = "*[_id in $fetchIds]".concat(projection !== null && projection !== void 0 ? projection : "");
|
|
25
|
+
var data = yield client.fetch(query, {
|
|
25
26
|
fetchIds: fetchIds !== null && fetchIds !== void 0 ? fetchIds : []
|
|
26
27
|
});
|
|
27
28
|
|
|
@@ -58,7 +59,7 @@ function _getDocumentsInArray() {
|
|
|
58
59
|
}
|
|
59
60
|
});
|
|
60
61
|
|
|
61
|
-
return function (
|
|
62
|
+
return function (_x5) {
|
|
62
63
|
return _ref.apply(this, arguments);
|
|
63
64
|
};
|
|
64
65
|
}()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"getDocumentsInArray.js","names":["getDocumentsInArray","fetchIds","client","currentIds","projection","collection","query","data","fetch","length","localCurrentIds","Set","newDataIds","map","dataDoc","_id","filter","id","size","has","Boolean","push","add","Promise","all","doc","expr","references","extract","newReferenceIds","refId","referenceDocs","Array","from","uniqueCollection","reduce","acc","cur","some"],"sources":["../../src/helpers/getDocumentsInArray.ts"],"sourcesContent":["import {extract} from '@sanity/mutator'\nimport {SanityDocument} from '../types'\n\n// Recursively fetch Documents from an array of _id's and their references\n// Heavy use of Set is to avoid recursively querying for id's already in the payload\nexport async function getDocumentsInArray(\n fetchIds: string[],\n client: any,\n currentIds?: Set<string>,\n projection?: string,\n) {\n const collection = []\n\n // Find initial docs\n const query = `*[_id in $fetchIds]${projection ?? ``}`\n const data: SanityDocument[] = await client.fetch(query, {\n fetchIds: fetchIds ?? [],\n })\n\n if (!data?.length) {\n return []\n }\n\n const localCurrentIds = currentIds ?? new Set()\n \n // Find new ids in the returned data\n // Unless we started with an empty set, get the _ids from the data\n const newDataIds: Set<string> = new Set(\n data\n .map((dataDoc) => dataDoc._id)\n .filter((id) => (currentIds?.size ? !localCurrentIds.has(id) : Boolean(id)))\n )\n\n if (newDataIds.size) {\n collection.push(...data)\n localCurrentIds.add(...newDataIds)\n\n // Check new data for more references\n await Promise.all(\n data.map(async (doc) => {\n const expr = `.._ref`\n const references = extract(expr, doc)\n\n if (references.length) {\n // Find references not already in the Collection\n const newReferenceIds = new Set(references.filter((refId) => !localCurrentIds.has(refId)))\n\n if (newReferenceIds.size) {\n // Recusive query for new documents\n const referenceDocs = await getDocumentsInArray(\n Array.from(newReferenceIds),\n client,\n localCurrentIds\n )\n\n if (referenceDocs?.length) {\n collection.push(...referenceDocs)\n }\n }\n }\n })\n )\n }\n\n // Create a unique array of objects from collection\n // Set() wasn't working for unique id's ¯\\_(ツ)_/¯\n const uniqueCollection = collection.filter(Boolean).reduce((acc, cur) => {\n if (acc.some((doc) => doc._id === cur._id)) {\n return acc\n }\n\n return [...acc, cur]\n }, []) \n\n return uniqueCollection\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAGA;AACA;SACsBA,mB;;;;;2CAAf,WACLC,QADK,EAELC,MAFK,EAGLC,UAHK,EAILC,UAJK,EAKL;IACA,IAAMC,UAAU,GAAG,EAAnB,CADA,CAGA;;IACA,IAAMC,KAAK,gCAAyBF,UAAzB,aAAyBA,UAAzB,cAAyBA,UAAzB,MAAX;IACA,IAAMG,IAAsB,SAASL,MAAM,CAACM,KAAP,CAAaF,KAAb,EAAoB;MACvDL,QAAQ,EAAEA,QAAF,aAAEA,QAAF,cAAEA,QAAF,GAAc;IADiC,CAApB,CAArC;;IAIA,IAAI,EAACM,IAAD,aAACA,IAAD,eAACA,IAAI,CAAEE,MAAP,CAAJ,EAAmB;MACjB,OAAO,EAAP;IACD;;IAED,IAAMC,eAAe,GAAGP,UAAH,aAAGA,UAAH,cAAGA,UAAH,GAAiB,IAAIQ,GAAJ,EAAtC,CAbA,CAeA;IACA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GAAG7B,UAAU,CAACW,MAAX,CAAkBI,OAAlB,EAA2Be,MAA3B,CAAkC,CAACC,GAAD,EAAMC,GAAN,KAAc;MACvE,IAAID,GAAG,CAACE,IAAJ,CAAUb,GAAD,IAASA,GAAG,CAACV,GAAJ,KAAYsB,GAAG,CAACtB,GAAlC,CAAJ,EAA4C;QAC1C,OAAOqB,GAAP;MACD;;MAED,OAAO,CAAC,GAAGA,GAAJ,EAASC,GAAT,CAAP;IACD,CANwB,EAMtB,EANsB,CAAzB;IAQA,OAAOH,gBAAP;EACD,C"}
|
package/lib/helpers/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["typeIsAsset","type","includes","createInitialMessage","docCount","refsCount","message","join","stickyStyles","position","top","zIndex","backgroundColor"],"sources":["../../src/helpers/index.ts"],"sourcesContent":["export function typeIsAsset(type = ``) {\n if (!type) return false\n\n return ['sanity.imageAsset', 'sanity.fileAsset'].includes(type)\n}\n\nexport function createInitialMessage(docCount = 0, refsCount = 0) {\n const message = [\n docCount === 1 ? `This Document contains` : `These ${docCount} Documents contain`,\n refsCount === 1 ? `1 Reference.` : `${refsCount} References.`,\n refsCount === 1 ? `That Document` : `Those Documents`,\n `may have References too. If referenced Documents do not exist at the target Destination, this transaction will fail.`\n ]\n\n return message.join(` `)\n}\n\nexport const stickyStyles = {\n position: 'sticky',\n top: 0,\n zIndex: 100,\n backgroundColor: `rgba(255,255,255,0.95)`,\n}"],"mappings":";;;;;;;;;AAAO,SAASA,WAAT,GAAgC;EAAA,IAAXC,IAAW;EACrC,IAAI,CAACA,IAAL,EAAW,OAAO,KAAP;EAEX,OAAO,CAAC,mBAAD,EAAsB,kBAAtB,EAA0CC,QAA1C,CAAmDD,IAAnD,CAAP;AACD;;AAEM,SAASE,oBAAT,GAA2D;EAAA,IAA7BC,QAA6B,uEAAlB,CAAkB;EAAA,IAAfC,SAAe,uEAAH,CAAG;EAChE,IAAMC,OAAO,GAAG,CACdF,QAAQ,KAAK,CAAb,8CAAqDA,QAArD,uBADc,EAEdC,SAAS,KAAK,CAAd,8BAAsCA,SAAtC,iBAFc,EAGdA,SAAS,KAAK,CAAd,sCAHc,yHAAhB;EAOA,OAAOC,OAAO,CAACC,IAAR,KAAP;AACD;;AAEM,IAAMC,YAAY,GAAG;EAC1BC,QAAQ,EAAE,QADgB;EAE1BC,GAAG,EAAE,CAFqB;EAG1BC,MAAM,EAAE,GAHkB;EAI1BC,eAAe;AAJW,CAArB"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["import DuplicateToAction from \"./actions/DuplicateToAction\";\nimport CrossDatasetDuplicator from \"./components/CrossDatasetDuplicator\";\n\nexport {\n DuplicateToAction,\n CrossDatasetDuplicator\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
|
package/lib/tool/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["config","tool","title","name","icon","LaunchIcon","component","CrossDatasetDuplicator"],"sources":["../../src/tool/index.ts"],"sourcesContent":["import {LaunchIcon} from '@sanity/icons'\nimport config from 'config:@sanity/cross-dataset-duplicator'\n\nimport CrossDatasetDuplicator from '../components/CrossDatasetDuplicator'\n\nexport default config?.tool\n ? {\n title: 'Duplicator',\n name: 'duplicator',\n icon: LaunchIcon,\n component: CrossDatasetDuplicator,\n }\n : null\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;eAEeA,+BAAA,aAAAA,+BAAA,eAAAA,+BAAA,CAAQC,IAAR,GACX;EACEC,KAAK,EAAE,YADT;EAEEC,IAAI,EAAE,YAFR;EAGEC,IAAI,EAAEC,iBAHR;EAIEC,SAAS,EAAEC;AAJb,CADW,GAOX,I"}
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["export type SanityDocument = {\n _id: string\n _type: string\n}\n\nexport type PayloadItem = {\n include: boolean\n status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE'\n doc: SanityDocument\n}\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cross-dataset-duplicator",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.5",
|
|
4
4
|
"description": "Empower content editors to migrate Documents and Assets between Sanity Projects and Datasets from inside Sanity Studio",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -29,26 +29,26 @@
|
|
|
29
29
|
"license": "MIT",
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@sanity/icons": "^1.2.5",
|
|
32
|
-
"@sanity/mutator": "^2.13.0",
|
|
33
32
|
"@sanity/ui": "^0.36.15",
|
|
34
33
|
"async": "^3.2.1",
|
|
35
34
|
"dset": "^3.1.0",
|
|
36
|
-
"husky": "^7.0.1",
|
|
37
|
-
"prop-types": "15.7.2",
|
|
38
35
|
"sanity-secrets": "^0.0.6",
|
|
39
36
|
"styled-components": "^5.3.3"
|
|
40
37
|
},
|
|
41
38
|
"devDependencies": {
|
|
42
|
-
"eslint": "7.31.0",
|
|
43
39
|
"eslint-config-prettier": "^8.3.0",
|
|
44
40
|
"eslint-config-sanity": "5.1.0",
|
|
45
41
|
"eslint-plugin-react": "^7.24.0",
|
|
42
|
+
"eslint": "7.31.0",
|
|
43
|
+
"husky": "^7.0.1",
|
|
46
44
|
"pinst": "^2.1.6",
|
|
47
45
|
"prettier": "^2.3.2",
|
|
46
|
+
"prop-types": "15.7.2",
|
|
48
47
|
"sanipack": "^2.1.0"
|
|
49
48
|
},
|
|
50
49
|
"peerDependencies": {
|
|
51
|
-
"react": "^17.0.0"
|
|
50
|
+
"react": "^17.0.0",
|
|
51
|
+
"@sanity/mutator": "^2.13.0"
|
|
52
52
|
},
|
|
53
53
|
"bugs": {
|
|
54
54
|
"url": "https://github.com/sanity-io/cross-dataset-duplicator/issues"
|
|
@@ -14,7 +14,7 @@ const secretConfigKeys = [
|
|
|
14
14
|
{
|
|
15
15
|
key: 'bearerToken',
|
|
16
16
|
title:
|
|
17
|
-
'An
|
|
17
|
+
'An API token with Viewer permissions is required to duplicate the original files of assets, and will be used for all Duplications. Create one at sanity.io/manage',
|
|
18
18
|
description: '',
|
|
19
19
|
},
|
|
20
20
|
]
|
|
@@ -4,7 +4,7 @@ import schema from 'part:@sanity/base/schema'
|
|
|
4
4
|
import {Button, Stack, Box, Label, Text, Card, Flex, Grid, Container, TextInput} from '@sanity/ui'
|
|
5
5
|
|
|
6
6
|
import DuplicatorTool from './DuplicatorTool'
|
|
7
|
-
import {
|
|
7
|
+
import {clientConfig} from '../helpers/clientConfig'
|
|
8
8
|
|
|
9
9
|
const originClient = sanityClient.withConfig(clientConfig)
|
|
10
10
|
|
|
@@ -12,11 +12,13 @@ type DuplicatorQueryProps = {
|
|
|
12
12
|
token: string
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
+
const schemaTypes = schema.getTypeNames()
|
|
16
|
+
|
|
15
17
|
export default function DuplicatorQuery(props: DuplicatorQueryProps) {
|
|
16
18
|
const {token} = props
|
|
17
19
|
|
|
18
20
|
const [value, setValue] = useState(``)
|
|
19
|
-
const [
|
|
21
|
+
const [initialData, setInitialData] = useState({docs: [], draftIds: []});
|
|
20
22
|
|
|
21
23
|
function handleSubmit(e?: any) {
|
|
22
24
|
if (e) e.preventDefault()
|
|
@@ -25,16 +27,21 @@ export default function DuplicatorQuery(props: DuplicatorQueryProps) {
|
|
|
25
27
|
.fetch(value)
|
|
26
28
|
.then((res) => {
|
|
27
29
|
// Ensure queried docs are registered to the schema
|
|
28
|
-
const
|
|
30
|
+
const registeredAndPublishedDocs = res.length
|
|
31
|
+
? res
|
|
32
|
+
.filter((doc) => schemaTypes.includes(doc._type))
|
|
33
|
+
.filter((doc) => !doc._id.startsWith(`drafts.`))
|
|
34
|
+
: []
|
|
35
|
+
const initialDraftIds = res.length ? res.filter(doc => doc._id.startsWith(`drafts.`)).map(doc => doc._id) : []
|
|
29
36
|
|
|
30
|
-
|
|
37
|
+
setInitialData({docs: registeredAndPublishedDocs, draftIds: initialDraftIds})
|
|
31
38
|
})
|
|
32
39
|
.catch((err) => console.error(err))
|
|
33
40
|
}
|
|
34
41
|
|
|
35
42
|
// Auto-load initial textinput value
|
|
36
43
|
useEffect(() => {
|
|
37
|
-
if (!docs?.length && value) {
|
|
44
|
+
if (!initialData.docs?.length && value) {
|
|
38
45
|
handleSubmit()
|
|
39
46
|
}
|
|
40
47
|
}, [])
|
|
@@ -50,7 +57,8 @@ export default function DuplicatorQuery(props: DuplicatorQueryProps) {
|
|
|
50
57
|
</Box>
|
|
51
58
|
<Box>
|
|
52
59
|
<Text>
|
|
53
|
-
Start with a valid GROQ query to load initial documents. The query will need to
|
|
60
|
+
Start with a valid GROQ query to load initial documents. The query will need to
|
|
61
|
+
return an Array of Objects. Drafts will be removed from the results.
|
|
54
62
|
</Text>
|
|
55
63
|
</Box>
|
|
56
64
|
<form onSubmit={handleSubmit}>
|
|
@@ -79,14 +87,17 @@ export default function DuplicatorQuery(props: DuplicatorQueryProps) {
|
|
|
79
87
|
</Stack>
|
|
80
88
|
</Card>
|
|
81
89
|
</Box>
|
|
82
|
-
{!docs?.length ||
|
|
83
|
-
<
|
|
84
|
-
<
|
|
85
|
-
{
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
{!initialData.docs?.length ||
|
|
91
|
+
(initialData.docs.length < 1 && (
|
|
92
|
+
<Container width={1}>
|
|
93
|
+
<Card padding={5}>
|
|
94
|
+
{value
|
|
95
|
+
? `No Documents registered to the Schema match this query`
|
|
96
|
+
: `Start with a valid GROQ query`}
|
|
97
|
+
</Card>
|
|
98
|
+
</Container>
|
|
99
|
+
))}
|
|
100
|
+
{initialData.docs?.length > 0 && <DuplicatorTool docs={initialData.docs} draftIds={initialData.draftIds} token={token} />}
|
|
90
101
|
</Grid>
|
|
91
102
|
</Container>
|
|
92
103
|
)
|
|
@@ -4,7 +4,18 @@ import mapLimit from 'async/mapLimit'
|
|
|
4
4
|
import asyncify from 'async/asyncify'
|
|
5
5
|
import {extract, extractWithPath} from '@sanity/mutator'
|
|
6
6
|
import {dset} from 'dset'
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Card,
|
|
9
|
+
Container,
|
|
10
|
+
Text,
|
|
11
|
+
Box,
|
|
12
|
+
Button,
|
|
13
|
+
Label,
|
|
14
|
+
Stack,
|
|
15
|
+
Select,
|
|
16
|
+
Flex,
|
|
17
|
+
Checkbox,
|
|
18
|
+
} from '@sanity/ui'
|
|
8
19
|
import {ArrowRightIcon, SearchIcon, LaunchIcon} from '@sanity/icons'
|
|
9
20
|
import sanityClient from 'part:@sanity/base/client'
|
|
10
21
|
import Preview from 'part:@sanity/base/preview'
|
|
@@ -21,11 +32,12 @@ import {clientConfig} from '../helpers/clientConfig'
|
|
|
21
32
|
|
|
22
33
|
type DuplicatorToolProps = {
|
|
23
34
|
docs: SanityDocument[]
|
|
35
|
+
draftIds: string[]
|
|
24
36
|
token: string
|
|
25
37
|
}
|
|
26
38
|
|
|
27
39
|
export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
28
|
-
const {docs, token} = props
|
|
40
|
+
const {docs, draftIds, token} = props
|
|
29
41
|
|
|
30
42
|
// Prepare origin (this Studio) client
|
|
31
43
|
// In function-scope so it is up to date on every render
|
|
@@ -36,7 +48,14 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
36
48
|
const spacesOptions = config?.__experimental_spaces?.length
|
|
37
49
|
? config.__experimental_spaces.map((space) => ({
|
|
38
50
|
...space,
|
|
39
|
-
|
|
51
|
+
api: {
|
|
52
|
+
...space.api,
|
|
53
|
+
projectId: space.api.projectId || process.env.SANITY_STUDIO_API_PROJECT_ID,
|
|
54
|
+
},
|
|
55
|
+
usingEnvForProjectId: !space.api.projectId && process.env.SANITY_STUDIO_API_PROJECT_ID,
|
|
56
|
+
disabled:
|
|
57
|
+
space.api.dataset === originClient.config().dataset &&
|
|
58
|
+
space.api.projectId === originClient.config().projectId,
|
|
40
59
|
}))
|
|
41
60
|
: []
|
|
42
61
|
|
|
@@ -50,6 +69,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
50
69
|
doc: item,
|
|
51
70
|
include: true,
|
|
52
71
|
status: null,
|
|
72
|
+
hasDraft: draftIds?.length ? draftIds.includes(`drafts.${item._id}`) : false,
|
|
53
73
|
}))
|
|
54
74
|
: []
|
|
55
75
|
)
|
|
@@ -153,6 +173,13 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
153
173
|
const docIds = docs.map((doc) => doc._id)
|
|
154
174
|
|
|
155
175
|
const payloadDocs = await getDocumentsInArray(docIds, originClient, null)
|
|
176
|
+
const draftDocs = await getDocumentsInArray(
|
|
177
|
+
docIds.map((id) => `drafts.${id}`),
|
|
178
|
+
originClient,
|
|
179
|
+
null,
|
|
180
|
+
`{_id}`
|
|
181
|
+
)
|
|
182
|
+
const draftDocsIds = new Set(draftDocs.map(({_id}) => _id))
|
|
156
183
|
|
|
157
184
|
// Shape it up
|
|
158
185
|
const payloadShaped = payloadDocs.map((doc) => ({
|
|
@@ -161,6 +188,8 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
161
188
|
include: true,
|
|
162
189
|
// Does it exist at the destination?
|
|
163
190
|
status: '',
|
|
191
|
+
// Does it have any drafts?
|
|
192
|
+
hasDraft: draftDocsIds.has(`drafts.${doc._id}`),
|
|
164
193
|
}))
|
|
165
194
|
|
|
166
195
|
setPayload(payloadShaped)
|
|
@@ -195,7 +224,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
195
224
|
const uploadType = doc._type.split('.').pop().replace('Asset', '')
|
|
196
225
|
const downloadUrl = uploadType === 'image' ? `${doc.url}?dlRaw=true` : doc.url
|
|
197
226
|
const downloadConfig =
|
|
198
|
-
uploadType === 'image' ? {headers: {Authorization:
|
|
227
|
+
uploadType === 'image' ? {headers: {Authorization: `Bearer ${token}`}} : {}
|
|
199
228
|
|
|
200
229
|
await fetch(downloadUrl, downloadConfig).then(async (res) => {
|
|
201
230
|
const assetData = await res.blob()
|
|
@@ -315,7 +344,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
315
344
|
const headingText = [selectedTotal, `/`, payloadCount, `Documents and Assets selected`].join(` `)
|
|
316
345
|
|
|
317
346
|
const buttonText = React.useMemo(() => {
|
|
318
|
-
|
|
347
|
+
const text = [`Duplicate`]
|
|
319
348
|
|
|
320
349
|
if (selectedDocumentsCount > 1) {
|
|
321
350
|
text.push(selectedDocumentsCount, selectedDocumentsCount === 1 ? `Document` : `Documents`)
|
|
@@ -350,7 +379,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
350
379
|
.map((space) => (
|
|
351
380
|
<option key={space.name} value={space.name} disabled={space.disabled}>
|
|
352
381
|
{space.title ?? space.name}
|
|
353
|
-
{hasMultipleProjectIds ? ` (${space.api.projectId})` : ``}
|
|
382
|
+
{hasMultipleProjectIds || space.usingEnvForProjectId ? ` (${space.api.projectId})` : ``}
|
|
354
383
|
</option>
|
|
355
384
|
))}
|
|
356
385
|
</Select>
|
|
@@ -366,7 +395,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
366
395
|
{spacesOptions.map((space) => (
|
|
367
396
|
<option key={space.name} value={space.name} disabled={space.disabled}>
|
|
368
397
|
{space.title ?? space.name}
|
|
369
|
-
{hasMultipleProjectIds ? ` (${space.api.projectId})` : ``}
|
|
398
|
+
{hasMultipleProjectIds || space.usingEnvForProjectId ? ` (${space.api.projectId})` : ``}
|
|
370
399
|
{space.disabled ? ` (Current)` : ``}
|
|
371
400
|
</option>
|
|
372
401
|
))}
|
|
@@ -406,22 +435,26 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
|
|
|
406
435
|
)}
|
|
407
436
|
{payload.length > 0 && (
|
|
408
437
|
<Stack padding={4} space={3}>
|
|
409
|
-
{payload.map(({doc, include, status}, index) => (
|
|
438
|
+
{payload.map(({doc, include, status, hasDraft}, index) => (
|
|
410
439
|
<React.Fragment key={doc._id}>
|
|
411
440
|
<Flex align="center">
|
|
412
441
|
<Checkbox checked={include} onChange={() => handleCheckbox(doc._id)} />
|
|
413
|
-
<Box
|
|
442
|
+
<Box flex={1} paddingX={3}>
|
|
414
443
|
<Preview value={doc} type={schema.get(doc._type)} />
|
|
415
444
|
</Box>
|
|
416
|
-
<
|
|
445
|
+
<Flex items="center" gap={2}>
|
|
446
|
+
{hasDraft ? <StatusBadge status="UNPUBLISHED" isAsset={false} /> : null}
|
|
447
|
+
<StatusBadge status={status} isAsset={typeIsAsset(doc._type)} />
|
|
448
|
+
</Flex>
|
|
417
449
|
</Flex>
|
|
418
450
|
{doc?.extension === 'svg' && index === firstSvgIndex && (
|
|
419
451
|
<Card padding={3} radius={2} shadow={1} tone="caution">
|
|
420
452
|
<Text size={1}>
|
|
421
|
-
Due to how SVGs are sanitized after first uploaded, duplicated SVG assets
|
|
422
|
-
<code>_id</code>'s at the destination. The newly generated
|
|
423
|
-
will be the same in each duplication, but it will never
|
|
424
|
-
<code>_id</code> as the first time this Asset was uploaded.
|
|
453
|
+
Due to how SVGs are sanitized after first uploaded, duplicated SVG assets
|
|
454
|
+
may have new <code>_id</code>'s at the destination. The newly generated{' '}
|
|
455
|
+
<code>_id</code> will be the same in each duplication, but it will never
|
|
456
|
+
be the same <code>_id</code> as the first time this Asset was uploaded.
|
|
457
|
+
References to the asset will be updated to use the new <code>_id</code>.
|
|
425
458
|
</Text>
|
|
426
459
|
</Card>
|
|
427
460
|
)}
|
|
@@ -7,6 +7,7 @@ type StatusTones = {
|
|
|
7
7
|
OVERWRITE: BadgeTone
|
|
8
8
|
UPDATE: BadgeTone
|
|
9
9
|
CREATE: BadgeTone
|
|
10
|
+
UNPUBLISHED: BadgeTone
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
const documentTones: StatusTones = {
|
|
@@ -14,6 +15,7 @@ const documentTones: StatusTones = {
|
|
|
14
15
|
OVERWRITE: `critical`,
|
|
15
16
|
UPDATE: `caution`,
|
|
16
17
|
CREATE: `positive`,
|
|
18
|
+
UNPUBLISHED: `caution`,
|
|
17
19
|
}
|
|
18
20
|
|
|
19
21
|
const assetTones: StatusTones = {
|
|
@@ -21,6 +23,7 @@ const assetTones: StatusTones = {
|
|
|
21
23
|
OVERWRITE: `critical`,
|
|
22
24
|
UPDATE: `critical`,
|
|
23
25
|
CREATE: `positive`,
|
|
26
|
+
UNPUBLISHED: `default`
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
type messageTypes = {
|
|
@@ -28,6 +31,7 @@ type messageTypes = {
|
|
|
28
31
|
OVERWRITE: string
|
|
29
32
|
UPDATE: string
|
|
30
33
|
CREATE: string
|
|
34
|
+
UNPUBLISHED: string
|
|
31
35
|
}
|
|
32
36
|
|
|
33
37
|
const documentMessages: messageTypes = {
|
|
@@ -41,6 +45,7 @@ const documentMessages: messageTypes = {
|
|
|
41
45
|
UPDATE: `An older version of this document exists at the Destination, and it will be overwritten with this version.`,
|
|
42
46
|
// Document at destination doesn't exist
|
|
43
47
|
CREATE: `This document will be created at the destination.`,
|
|
48
|
+
UNPUBLISHED: `A Draft version of this Document exists in this Dataset, but only the Published version will be duplicated to the destination.`
|
|
44
49
|
}
|
|
45
50
|
|
|
46
51
|
const assetMessages: messageTypes = {
|
|
@@ -48,6 +53,7 @@ const assetMessages: messageTypes = {
|
|
|
48
53
|
OVERWRITE: `This Asset already exists at the Destination`,
|
|
49
54
|
UPDATE: `This Asset already exists at the Destination`,
|
|
50
55
|
CREATE: `This Asset does not yet exist at the Destination`,
|
|
56
|
+
UNPUBLISHED: ``,
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
const assetStatus: messageTypes = {
|
|
@@ -55,10 +61,11 @@ const assetStatus: messageTypes = {
|
|
|
55
61
|
OVERWRITE: `RE-UPLOAD`,
|
|
56
62
|
UPDATE: `RE-UPLOAD`,
|
|
57
63
|
CREATE: `UPLOAD`,
|
|
64
|
+
UNPUBLISHED: ``,
|
|
58
65
|
}
|
|
59
66
|
|
|
60
67
|
type StatusBadgeProps = {
|
|
61
|
-
status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE' | undefined
|
|
68
|
+
status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE' | 'UNPUBLISHED' | undefined
|
|
62
69
|
isAsset: boolean
|
|
63
70
|
}
|
|
64
71
|
|
|
@@ -6,12 +6,14 @@ import {SanityDocument} from '../types'
|
|
|
6
6
|
export async function getDocumentsInArray(
|
|
7
7
|
fetchIds: string[],
|
|
8
8
|
client: any,
|
|
9
|
-
currentIds?: Set<string
|
|
9
|
+
currentIds?: Set<string>,
|
|
10
|
+
projection?: string,
|
|
10
11
|
) {
|
|
11
12
|
const collection = []
|
|
12
13
|
|
|
13
14
|
// Find initial docs
|
|
14
|
-
const
|
|
15
|
+
const query = `*[_id in $fetchIds]${projection ?? ``}`
|
|
16
|
+
const data: SanityDocument[] = await client.fetch(query, {
|
|
15
17
|
fetchIds: fetchIds ?? [],
|
|
16
18
|
})
|
|
17
19
|
|