@sanity/cross-dataset-duplicator 0.3.5 → 0.4.0
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 +5 -2
- package/config.dist.json +2 -1
- package/lib/actions/DuplicateToAction.js +5 -20
- package/lib/actions/DuplicateToAction.js.map +1 -1
- package/lib/actions/index.js +2 -11
- package/lib/actions/index.js.map +1 -1
- package/lib/components/CrossDatasetDuplicator.js +11 -37
- package/lib/components/CrossDatasetDuplicator.js.map +1 -1
- package/lib/components/DuplicatorQuery.js +13 -35
- package/lib/components/DuplicatorQuery.js.map +1 -1
- package/lib/components/DuplicatorTool.js +131 -150
- package/lib/components/DuplicatorTool.js.map +1 -1
- package/lib/components/Feedback.js +2 -6
- package/lib/components/Feedback.js.map +1 -1
- package/lib/components/ResetSecret.js +0 -9
- package/lib/components/ResetSecret.js.map +1 -1
- package/lib/components/SelectButtons.js +5 -30
- package/lib/components/SelectButtons.js.map +1 -1
- package/lib/components/StatusBadge.js +1 -8
- 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 +13 -20
- package/lib/helpers/getDocumentsInArray.js.map +1 -1
- package/lib/helpers/index.js +0 -3
- package/lib/helpers/index.js.map +1 -1
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/tool/index.js +0 -6
- package/lib/tool/index.js.map +1 -1
- package/package.json +3 -3
- package/src/components/CrossDatasetDuplicator.tsx +2 -2
- package/src/components/DuplicatorTool.tsx +61 -2
- package/src/helpers/getDocumentsInArray.ts +8 -5
|
@@ -1 +1 @@
|
|
|
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,K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,KAAK,KAAKrB,aAAtC,iBACC,6BAAC,QAAD;MAAM,OAAO,EAAE,CAAf;MAAkB,MAAM,EAAE,CAA1B;MAA6B,MAAM,EAAE,CAArC;MAAwC,IAAI,EAAC;IAA7C,gBACE,6BAAC,QAAD;MAAM,IAAI,EAAE;IAAZ,2GAEe,iDAFf,gDAE0E,GAF1E,eAGE,iDAHF,wFAIc,iDAJd,sHAKyD,iDALzD,MADF,CAZJ,CADW;EAAA,CAAZ,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
|
+
{"version":3,"file":"DuplicatorTool.js","names":["DuplicatorToolWrapper","props","docs","token","useState","mode","setMode","inbound","setInbound","duplicatorConfig","follow","useEffect","inboundReferences","sanityClient","fetch","id","_id","console","log","includes","length","DuplicatorTool","draftIds","originClient","withConfig","clientConfig","spacesOptions","config","__experimental_spaces","map","space","api","projectId","process","env","SANITY_STUDIO_API_PROJECT_ID","usingEnvForProjectId","disabled","dataset","find","destination","setDestination","message","setMessage","item","doc","include","status","hasDraft","payload","setPayload","hasReferences","setHasReferences","isDuplicating","setIsDuplicating","isGathering","setIsGathering","progress","setProgress","expr","initialRefs","initialPayload","forEach","push","extract","docCount","refsCount","tone","text","createInitialMessage","updatePayloadStatuses","newPayload","payloadActual","name","payloadIds","destinationClient","destinationData","updatedPayload","existingDoc","_updatedAt","Date","handleCheckbox","handleReferences","docIds","payloadDocs","getDocumentsInArray","draftDocs","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","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 Grid,\n Card,\n Container,\n Text,\n Box,\n Button,\n Label,\n Stack,\n Select,\n Flex,\n Checkbox,\n Tab,\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'\nimport duplicatorConfig from 'config:@sanity/cross-dataset-duplicator'\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 function DuplicatorToolWrapper(props: DuplicatorToolProps) {\n const {docs, token} = props\n const [mode, setMode] = useState('outbound')\n const [inbound, setInbound] = useState([])\n const {follow = []} = duplicatorConfig\n\n useEffect(() => {\n ;(async () => {\n const inboundReferences = await sanityClient.fetch('*[references($id)]', {id: docs[0]._id})\n setInbound([...props.docs, ...inboundReferences])\n })()\n }, [])\n\n console.log(docs, inbound)\n\n return (\n <Container>\n {follow.includes(`inbound`) || follow.includes(`outbound`) ? (\n <Card paddingX={4} paddingBottom={4} marginBottom={4} borderBottom>\n <Grid columns={2} gap={4}>\n {follow.includes(`outbound`) ? (\n <Button\n mode=\"ghost\"\n tone=\"primary\"\n selected={mode === 'outbound'}\n onClick={() => setMode('outbound')}\n text={`Outbound`}\n />\n ) : null}\n {follow.includes(`inbound`) ? (\n <Button\n mode=\"ghost\"\n tone=\"primary\"\n selected={mode === 'inbound'}\n onClick={() => setMode('inbound')}\n disabled={inbound.length === 0}\n text={inbound.length > 0 ? `Inbound (${inbound.length})` : 'No inbound references'}\n />\n ) : null}\n </Grid>\n </Card>\n ) : null}\n <DuplicatorTool\n key={mode}\n docs={mode === 'outbound' ? docs : inbound}\n token={token}\n draftIds={[]}\n />\n </Container>\n )\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\n ? ` (${space.api.projectId})`\n : ``}\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\n ? ` (${space.api.projectId})`\n : ``}\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;AAcA;AACA;AACA;AACA;AACA;AACA;AAEA;AACA;AACA;AACA;AACA;AAEA;AAAoD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQ7C,SAASA,qBAAqB,CAACC,KAA0B,EAAE;EAChE,IAAOC,IAAI,GAAWD,KAAK,CAApBC,IAAI;IAAEC,KAAK,GAAIF,KAAK,CAAdE,KAAK;EAClB,gBAAwB,IAAAC,eAAQ,EAAC,UAAU,CAAC;IAAA;IAArCC,IAAI;IAAEC,OAAO;EACpB,iBAA8B,IAAAF,eAAQ,EAAC,EAAE,CAAC;IAAA;IAAnCG,OAAO;IAAEC,UAAU;EAC1B,4BAAsBC,+BAAgB,CAA/BC,MAAM;IAANA,MAAM,sCAAG,EAAE;EAElB,IAAAC,gBAAS,EAAC,MAAM;IACd;IAAC,kBAAC,aAAY;MACZ,IAAMC,iBAAiB,SAASC,eAAY,CAACC,KAAK,CAAC,oBAAoB,EAAE;QAACC,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BACZ,6BAAC,UAAM;IACL,QAAQ,EAAE,CAAE;IACZ,OAAO,EAAE,CAAE;IACX,IAAI,EAAC,UAAU;IACf,IAAI,EAAC,OAAO;IACZ,IAAI,EAAE8H,iBAAW;IACjB,OAAO,EAAE/F,gBAAiB;IAC1B,IAAI,EAAC,mBAAmB;IACxB,QAAQ,EAAE7B,aAAa,IAAI,CAACwG,aAAa,IAAItG;EAAY,EAE5D,eACD,6BAAC,UAAM;IACL,QAAQ,EAAE,CAAE;IACZ,OAAO,EAAE,CAAE;IACX,IAAI,EAAC,UAAU;IACf,IAAI,EAAE2H,iBAAW;IACjB,OAAO,EAAEvF,eAAgB;IACzB,IAAI,EAAEyE,UAAW;IACjB,QAAQ,EAAE/G,aAAa,IAAI,CAACwG,aAAa,IAAItG;EAAY,EACzD,CACI,CACP,CACG,CACH,CACG;AAEhB"}
|
|
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = Feedback;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _ui = require("@sanity/ui");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
function Feedback(props) {
|
|
15
11
|
var children = props.children,
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
_props$tone = props.tone,
|
|
13
|
+
tone = _props$tone === void 0 ? "caution" : _props$tone;
|
|
18
14
|
return /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
19
15
|
padding: 3,
|
|
20
16
|
radius: 2,
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;AAAqC;AAQtB,SAASA,QAAQ,CAACC,KAAoB,EAAE;EACrD,IAAOC,QAAQ,GAAsBD,KAAK,CAAnCC,QAAQ;IAAA,cAAsBD,KAAK,CAAzBE,IAAI;IAAJA,IAAI;EAErB,oBACE,6BAAC,QAAI;IAAC,OAAO,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,IAAI,EAAEA;EAAK,gBACjD,6BAAC,QAAI;IAAC,IAAI,EAAE;EAAE,GAAED,QAAQ,CAAQ,CAC3B;AAEX"}
|
|
@@ -4,27 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = ResetSecret;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _ui = require("@sanity/ui");
|
|
11
|
-
|
|
12
9
|
var _client = _interopRequireDefault(require("part:@sanity/base/client"));
|
|
13
|
-
|
|
14
10
|
var _clientConfig = require("../helpers/clientConfig");
|
|
15
|
-
|
|
16
11
|
var _constants = require("../helpers/constants");
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
var client = _client.default.withConfig(_clientConfig.clientConfig);
|
|
21
|
-
|
|
22
14
|
function handleClick() {
|
|
23
15
|
client.delete({
|
|
24
16
|
query: "*[_id == \"secrets.".concat(_constants.SECRET_NAMESPACE, "\"]")
|
|
25
17
|
});
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
function ResetSecret() {
|
|
29
20
|
return /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
30
21
|
align: "center",
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;AAAuD;AAEvD,IAAMA,MAAM,GAAGC,eAAY,CAACC,UAAU,CAACC,0BAAY,CAAC;AAEpD,SAASC,WAAW,GAAG;EACrBJ,MAAM,CAACK,MAAM,CAAC;IAACC,KAAK,+BAAuBC,2BAAgB;EAAI,CAAC,CAAC;AACnE;AAEe,SAASC,WAAW,GAAG;EACpC,oBACE,6BAAC,QAAI;IAAC,KAAK,EAAC,QAAQ;IAAC,OAAO,EAAC,UAAU;IAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE;IAAC,QAAQ,EAAE;EAAE,gBAC1E,6BAAC,UAAM;IACL,IAAI,EAAC,cAAc;IACnB,OAAO,EAAE,MAAMJ,WAAW,EAAG;IAC7B,IAAI,EAAC,OAAO;IACZ,IAAI,EAAC,UAAU;IACf,QAAQ,EAAE,CAAE;IACZ,OAAO,EAAE;EAAE,EACX,CACG;AAEX"}
|
|
@@ -4,89 +4,64 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = SelectButtons;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
|
|
10
8
|
var _ui = require("@sanity/ui");
|
|
11
|
-
|
|
12
9
|
var _helpers = require("../helpers");
|
|
13
|
-
|
|
14
10
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
15
|
-
|
|
16
11
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
-
|
|
18
12
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
19
|
-
|
|
20
13
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
|
|
22
14
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
23
|
-
|
|
24
15
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
25
|
-
|
|
26
16
|
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
27
|
-
|
|
28
17
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
29
|
-
|
|
30
18
|
var buttons = ["All", "None", null, "New", "Existing", "Older", null, "Documents", "Assets"];
|
|
31
|
-
|
|
32
19
|
function SelectButtons(props) {
|
|
33
20
|
var payload = props.payload,
|
|
34
|
-
|
|
35
|
-
|
|
21
|
+
setPayload = props.setPayload;
|
|
36
22
|
var _useState = (0, _react.useState)([]),
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
23
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
+
disabledActions = _useState2[0],
|
|
25
|
+
setDisabledActions = _useState2[1];
|
|
41
26
|
|
|
27
|
+
// Set intiial disabled button
|
|
42
28
|
(0, _react.useEffect)(() => {
|
|
43
29
|
if (!(disabledActions !== null && disabledActions !== void 0 && disabledActions.length) && payload.every(item => item.include)) {
|
|
44
30
|
setDisabledActions(["ALL"]);
|
|
45
31
|
}
|
|
46
32
|
}, []);
|
|
47
|
-
|
|
48
33
|
function handleSelectButton() {
|
|
49
34
|
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
50
35
|
if (!action || !payload.length) return;
|
|
51
36
|
var newPayload = [...payload];
|
|
52
|
-
|
|
53
37
|
switch (action) {
|
|
54
38
|
case 'ALL':
|
|
55
39
|
newPayload.map(item => item.include = true);
|
|
56
40
|
break;
|
|
57
|
-
|
|
58
41
|
case 'NONE':
|
|
59
42
|
newPayload.map(item => item.include = false);
|
|
60
43
|
break;
|
|
61
|
-
|
|
62
44
|
case 'NEW':
|
|
63
45
|
newPayload.map(item => item.include = Boolean(item.status === 'CREATE'));
|
|
64
46
|
break;
|
|
65
|
-
|
|
66
47
|
case 'EXISTING':
|
|
67
48
|
newPayload.map(item => item.include = Boolean(item.status === 'EXISTS'));
|
|
68
49
|
break;
|
|
69
|
-
|
|
70
50
|
case 'OLDER':
|
|
71
51
|
newPayload.map(item => item.include = Boolean(item.status === 'OVERWRITE'));
|
|
72
52
|
break;
|
|
73
|
-
|
|
74
53
|
case 'ASSETS':
|
|
75
54
|
newPayload.map(item => item.include = (0, _helpers.typeIsAsset)(item.doc._type));
|
|
76
55
|
break;
|
|
77
|
-
|
|
78
56
|
case 'DOCUMENTS':
|
|
79
57
|
newPayload.map(item => item.include = !(0, _helpers.typeIsAsset)(item.doc._type));
|
|
80
58
|
break;
|
|
81
|
-
|
|
82
59
|
default:
|
|
83
60
|
break;
|
|
84
61
|
}
|
|
85
|
-
|
|
86
62
|
setDisabledActions([action]);
|
|
87
63
|
setPayload(newPayload);
|
|
88
64
|
}
|
|
89
|
-
|
|
90
65
|
return /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
91
66
|
padding: 1,
|
|
92
67
|
radius: 3,
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;AAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGtC,IAAMA,OAAO,GAAG,gBAAgB,IAAI,8BAA8B,IAAI,wBAAwB;AAO/E,SAASC,aAAa,CAACC,KAAyB,EAAE;EAC/D,IAAOC,OAAO,GAAgBD,KAAK,CAA5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Q;QACXH,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAG,IAAAO,oBAAW,EAACR,IAAI,CAACS,GAAG,CAACC,KAAK,CAAE,CAAC;QACtE;MACF,KAAK,WAAW;QACdN,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAG,CAAC,IAAAO,oBAAW,EAACR,IAAI,CAACS,GAAG,CAACC,KAAK,CAAE,CAAC;QACvE;MACF;QACE;IAAK;IAGTd,kBAAkB,CAAC,CAACO,MAAM,CAAC,CAAC;IAC5BV,UAAU,CAACW,UAAU,CAAC;EACxB;EAEA,oBACE,6BAAC,QAAI;IAAC,OAAO,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,MAAM,EAAE;EAAE,gBACrC,6BAAC,QAAI;IAAC,GAAG,EAAE;EAAE,GACVf,OAAO,CAACgB,GAAG,CAAC,CAACF,MAAM,EAAEQ,WAAW,KAC/BR,MAAM,gBACJ,6BAAC,UAAM;IACL,GAAG,EAAEA,MAAO;IACZ,QAAQ,EAAE,CAAE;IACZ,IAAI,EAAC,OAAO;IACZ,OAAO,EAAE,CAAE;IACX,IAAI,EAAEA,MAAO;IACb,QAAQ,EAAER,eAAe,CAACiB,QAAQ,CAACT,MAAM,CAACU,WAAW,EAAE,CAAE;IACzD,OAAO,EAAE,MAAMX,kBAAkB,CAACC,MAAM,CAACU,WAAW,EAAE;EAAE,EACxD,gBAEF,6BAAC,QAAI;IAAC,GAAG,oBAAaF,WAAW,CAAG;IAAC,UAAU;EAAA,EAChD,CACF,CACI,CACF;AAEX"}
|
|
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = StatusBadge;
|
|
7
|
-
|
|
8
7
|
var _react = _interopRequireDefault(require("react"));
|
|
9
|
-
|
|
10
8
|
var _ui = require("@sanity/ui");
|
|
11
|
-
|
|
12
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
|
|
14
10
|
var documentTones = {
|
|
15
11
|
EXISTS: "primary",
|
|
16
12
|
OVERWRITE: "critical",
|
|
@@ -52,12 +48,10 @@ var assetStatus = {
|
|
|
52
48
|
CREATE: "UPLOAD",
|
|
53
49
|
UNPUBLISHED: ""
|
|
54
50
|
};
|
|
55
|
-
|
|
56
51
|
function StatusBadge(props) {
|
|
57
52
|
var status = props.status,
|
|
58
|
-
|
|
53
|
+
isAsset = props.isAsset;
|
|
59
54
|
var badgeTone = isAsset ? assetTones[status] : documentTones[status];
|
|
60
|
-
|
|
61
55
|
if (!badgeTone) {
|
|
62
56
|
return /*#__PURE__*/_react.default.createElement(_ui.Badge, {
|
|
63
57
|
muted: true,
|
|
@@ -66,7 +60,6 @@ function StatusBadge(props) {
|
|
|
66
60
|
mode: "outline"
|
|
67
61
|
}, "Checking...");
|
|
68
62
|
}
|
|
69
|
-
|
|
70
63
|
var badgeText = isAsset ? assetMessages[status] : documentMessages[status];
|
|
71
64
|
var badgeStatus = isAsset ? assetStatus[status] : status;
|
|
72
65
|
return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
@@ -1 +1 @@
|
|
|
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":"
|
|
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;AAAoD;AAWpD,IAAMA,aAA0B,GAAG;EACjCC,MAAM,WAAW;EACjBC,SAAS,YAAY;EACrBC,MAAM,WAAW;EACjBC,MAAM,YAAY;EAClBC,WAAW;AACb,CAAC;AAED,IAAMC,UAAuB,GAAG;EAC9BL,MAAM,YAAY;EAClBC,SAAS,YAAY;EACrBC,MAAM,YAAY;EAClBC,MAAM,YAAY;EAClBC,WAAW;AACb,CAAC;AA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AE;IACtC,SAAS,EAAC,KAAK;IACf,MAAM;EAAA,gBAEN,6BAAC,SAAK;IAAC,KAAK;IAAC,OAAO,EAAE,CAAE;IAAC,QAAQ,EAAE,CAAE;IAAC,IAAI,EAAED,SAAU;IAAC,IAAI,EAAC;EAAS,GAClEE,WAAW,CACN,CACA;AAEd"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAAc,CAAC;AAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","names":["SECRET_NAMESPACE"],"sources":["../../src/helpers/constants.ts"],"sourcesContent":["export const SECRET_NAMESPACE = `CrossDatasetDuplicator`"],"mappings":";;;;;;AAAO,IAAMA,gBAAgB,
|
|
1
|
+
{"version":3,"file":"constants.js","names":["SECRET_NAMESPACE"],"sources":["../../src/helpers/constants.ts"],"sourcesContent":["export const SECRET_NAMESPACE = `CrossDatasetDuplicator`"],"mappings":";;;;;;AAAO,IAAMA,gBAAgB,2BAA2B;AAAA"}
|
|
@@ -4,74 +4,67 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getDocumentsInArray = getDocumentsInArray;
|
|
7
|
-
|
|
8
7
|
var _mutator = require("@sanity/mutator");
|
|
9
|
-
|
|
8
|
+
var _crossDatasetDuplicator = _interopRequireDefault(require("config:@sanity/cross-dataset-duplicator"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
10
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
11
|
-
|
|
12
11
|
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
13
|
-
|
|
14
12
|
// Recursively fetch Documents from an array of _id's and their references
|
|
15
13
|
// Heavy use of Set is to avoid recursively querying for id's already in the payload
|
|
16
14
|
function getDocumentsInArray(_x, _x2, _x3, _x4) {
|
|
17
15
|
return _getDocumentsInArray.apply(this, arguments);
|
|
18
16
|
}
|
|
19
|
-
|
|
20
17
|
function _getDocumentsInArray() {
|
|
21
18
|
_getDocumentsInArray = _asyncToGenerator(function* (fetchIds, client, currentIds, projection) {
|
|
22
|
-
var collection = [];
|
|
19
|
+
var collection = [];
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
// Find initial docs
|
|
22
|
+
var filter = ['_id in $fetchIds', _crossDatasetDuplicator.default.filter].filter(Boolean).join(' && ');
|
|
23
|
+
var query = "*[".concat(filter, "]").concat(projection !== null && projection !== void 0 ? projection : "");
|
|
25
24
|
var data = yield client.fetch(query, {
|
|
26
25
|
fetchIds: fetchIds !== null && fetchIds !== void 0 ? fetchIds : []
|
|
27
26
|
});
|
|
28
|
-
|
|
29
27
|
if (!(data !== null && data !== void 0 && data.length)) {
|
|
30
28
|
return [];
|
|
31
29
|
}
|
|
30
|
+
var localCurrentIds = currentIds !== null && currentIds !== void 0 ? currentIds : new Set();
|
|
32
31
|
|
|
33
|
-
|
|
32
|
+
// Find new ids in the returned data
|
|
34
33
|
// Unless we started with an empty set, get the _ids from the data
|
|
35
|
-
|
|
36
34
|
var newDataIds = new Set(data.map(dataDoc => dataDoc._id).filter(id => currentIds !== null && currentIds !== void 0 && currentIds.size ? !localCurrentIds.has(id) : Boolean(id)));
|
|
37
|
-
|
|
38
35
|
if (newDataIds.size) {
|
|
39
36
|
collection.push(...data);
|
|
40
|
-
localCurrentIds.add(...newDataIds);
|
|
37
|
+
localCurrentIds.add(...newDataIds);
|
|
41
38
|
|
|
39
|
+
// Check new data for more references
|
|
42
40
|
yield Promise.all(data.map( /*#__PURE__*/function () {
|
|
43
41
|
var _ref = _asyncToGenerator(function* (doc) {
|
|
44
42
|
var expr = ".._ref";
|
|
45
43
|
var references = (0, _mutator.extract)(expr, doc);
|
|
46
|
-
|
|
47
44
|
if (references.length) {
|
|
48
45
|
// Find references not already in the Collection
|
|
49
46
|
var newReferenceIds = new Set(references.filter(refId => !localCurrentIds.has(refId)));
|
|
50
|
-
|
|
51
47
|
if (newReferenceIds.size) {
|
|
52
48
|
// Recusive query for new documents
|
|
53
49
|
var referenceDocs = yield getDocumentsInArray(Array.from(newReferenceIds), client, localCurrentIds);
|
|
54
|
-
|
|
55
50
|
if (referenceDocs !== null && referenceDocs !== void 0 && referenceDocs.length) {
|
|
56
51
|
collection.push(...referenceDocs);
|
|
57
52
|
}
|
|
58
53
|
}
|
|
59
54
|
}
|
|
60
55
|
});
|
|
61
|
-
|
|
62
56
|
return function (_x5) {
|
|
63
57
|
return _ref.apply(this, arguments);
|
|
64
58
|
};
|
|
65
59
|
}()));
|
|
66
|
-
}
|
|
67
|
-
// Set() wasn't working for unique id's ¯\_(ツ)_/¯
|
|
68
|
-
|
|
60
|
+
}
|
|
69
61
|
|
|
62
|
+
// Create a unique array of objects from collection
|
|
63
|
+
// Set() wasn't working for unique id's ¯\_(ツ)_/¯
|
|
70
64
|
var uniqueCollection = collection.filter(Boolean).reduce((acc, cur) => {
|
|
71
65
|
if (acc.some(doc => doc._id === cur._id)) {
|
|
72
66
|
return acc;
|
|
73
67
|
}
|
|
74
|
-
|
|
75
68
|
return [...acc, cur];
|
|
76
69
|
}, []);
|
|
77
70
|
return uniqueCollection;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getDocumentsInArray.js","names":["getDocumentsInArray","fetchIds","client","currentIds","projection","collection","query","data","fetch","length","localCurrentIds","Set","newDataIds","map","dataDoc","_id","
|
|
1
|
+
{"version":3,"file":"getDocumentsInArray.js","names":["getDocumentsInArray","fetchIds","client","currentIds","projection","collection","filter","config","Boolean","join","query","data","fetch","length","localCurrentIds","Set","newDataIds","map","dataDoc","_id","id","size","has","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\nimport config from 'config:@sanity/cross-dataset-duplicator'\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 filter = ['_id in $fetchIds', config.filter].filter(Boolean).join(' && ')\n const query = `*[${filter}]${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;AAA4D;AAAA;AAAA;AAE5D;AACA;AAAA,SACsBA,mBAAmB;EAAA;AAAA;AAAA;EAAA,yCAAlC,WACLC,QAAkB,EAClBC,MAAW,EACXC,UAAwB,EACxBC,UAAmB,EACnB;IACA,IAAMC,UAAU,GAAG,EAAE;;IAErB;IACA,IAAMC,MAAM,GAAG,CAAC,kBAAkB,EAAEC,+BAAM,CAACD,MAAM,CAAC,CAACA,MAAM,CAACE,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;IAC/E,IAAMC,KAAK,eAAQJ,MAAM,cAAIF,UAAU,aAAVA,UAAU,cAAVA,UAAU,MAAQ;IAC/C,IAAMO,IAAsB,SAAST,MAAM,CAACU,KAAK,CAACF,KAAK,EAAE;MACvDT,QAAQ,EAAEA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI;IACxB,CAAC,CAAC;IAEF,IAAI,EAACU,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEE,MAAM,GAAE;MACjB,OAAO,EAAE;IACX;IAEA,IAAMC,eAAe,GAAGX,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,IAAIY,GAAG,EAAE;;IAE/C;IACA;IACA,IAAMC,UAAuB,GAAG,IAAID,GAAG,CACrCJ,IAAI,CACDM,GAAG,CAAEC,OAAO,IAAKA,OAAO,CAACC,GAAG,CAAC,CAC7Bb,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