@sanity/cross-dataset-duplicator
2.1.32.1.4
~
Modified (3 files)
Index: package/dist/index.js
===================================================================
--- package/dist/index.js
+++ package/dist/index.js
@@ -155,9 +155,9 @@
}
}
function SelectButtons(props) {
let $ = c(10), { payload, setPayload } = props, t0;
- $[0] === payload ? t0 = $[1] : (t0 = () => payload.length && payload.every(_temp$2) ? ["ALL"] : [], $[0] = payload, $[1] = t0);
+ $[0] === payload ? t0 = $[1] : (t0 = () => payload.length && payload.every(_temp$3) ? ["ALL"] : [], $[0] = payload, $[1] = t0);
let [disabledActions, setDisabledActions] = useState(t0), t1;
$[2] !== payload.length || $[3] !== setPayload ? (t1 = function handleSelectButton(action) {
payload.length && (setPayload((current) => current.map((item_0) => ({
...item_0,
@@ -184,9 +184,9 @@
children: t2
})
}), $[8] = t2, $[9] = t3), t3;
}
-function _temp$2(item) {
+function _temp$3(item) {
return item.include;
}
const documentTones = {
EXISTS: "primary",
@@ -512,9 +512,9 @@
return {
...workspace,
disabled: isSourceWorkspace || !isAllowedMigration
};
- }), currentWorkspace = workspacesOptions.find((workspace_0) => workspace_0.projectId === sourceProjectId && workspace_0.dataset === sourceDataset), [destination, setDestination] = useState(workspaces.length ? workspacesOptions.find(_temp$1) ?? null : null), [message, setMessage] = useState(null), t1;
+ }), currentWorkspace = workspacesOptions.find((workspace_0) => workspace_0.projectId === sourceProjectId && workspace_0.dataset === sourceDataset), [destination, setDestination] = useState(workspaces.length ? workspacesOptions.find(_temp$2) ?? null : null), [message, setMessage] = useState(null), t1;
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[2] = t1) : t1 = $[2];
let [payload, setPayload] = useState(t1), [isDuplicating, setIsDuplicating] = useState(!1), [isGathering, setIsGathering] = useState(!1), t2;
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t2 = [0, 0], $[3] = t2) : t2 = $[3];
let [progress, setProgress] = useState(t2), initialRefsCount = docs.reduce(_temp2, 0), hasReferences = initialRefsCount > 0, t3;
@@ -612,18 +612,18 @@
tone: "default"
}), setProgress([currentProgress, assetsCount]);
};
try {
- await mapWithConcurrency(payload.filter(_temp0).map(_temp1), 3, processDoc);
+ await mapWithConcurrency(payload.filter(_temp10).map(_temp11), 3, processDoc);
} catch (t11) {
let err_0 = t11;
console.error(err_0), setIsDuplicating(!1), setProgress([0, 0]), setMessage({
tone: "critical",
text: err_0 instanceof Error ? err_0.message : "Duplication Failed"
});
return;
}
- let svgIdRemap = new Map(svgMaps.map(_temp10)), transactionDocsMapped = svgIdRemap.size === 0 ? transactionDocs : transactionDocs.map((doc_7) => {
+ let svgIdRemap = new Map(svgMaps.map(_temp12)), transactionDocsMapped = svgIdRemap.size === 0 ? transactionDocs : transactionDocs.map((doc_7) => {
let references = extractWithPath(".._ref", doc_7);
if (!references.length) return doc_7;
let mappedDoc = doc_7;
return references.forEach((ref) => {
@@ -652,9 +652,9 @@
pluginConfig,
token,
setMessage,
onSuccess: onCommitSuccess,
- excludedIds: new Set(payload.filter(_temp11).map(_temp12)),
+ excludedIds: new Set(payload.filter(_temp13).map(_temp14)),
svgMaps
});
else {
let description = getErrorDescription(err_1);
@@ -678,14 +678,14 @@
if (!workspacesOptions.length) return;
let targeted = workspacesOptions.find((space_0) => space_0.name === e.currentTarget.value);
targeted && (setDestination(targeted), updatePayloadStatuses(payload, targeted).catch(console.error));
}, payloadCount = payload.length, t11;
- $[36] === payload ? t11 = $[37] : (t11 = payload.findIndex(_temp13), $[36] = payload, $[37] = t11);
+ $[36] === payload ? t11 = $[37] : (t11 = payload.findIndex(_temp15), $[36] = payload, $[37] = t11);
let firstSvgIndex = t11, t12;
- $[38] === payload ? t12 = $[39] : (t12 = payload.filter(_temp14), $[38] = payload, $[39] = t12);
+ $[38] === payload ? t12 = $[39] : (t12 = payload.filter(_temp16), $[38] = payload, $[39] = t12);
let selectedDocumentsCount = t12.length, t13;
- $[40] === payload ? t13 = $[41] : (t13 = payload.filter(_temp15), $[40] = payload, $[41] = t13);
- let selectedAssetsCount = t13.length, selectedTotal = selectedDocumentsCount + selectedAssetsCount, destinationTitle = destination?.title ?? destination?.name, hasMultipleProjectIds = new Set(workspacesOptions.map(_temp16).filter(Boolean)).size > 1, t14;
+ $[40] === payload ? t13 = $[41] : (t13 = payload.filter(_temp17), $[40] = payload, $[41] = t13);
+ let selectedAssetsCount = t13.length, selectedTotal = selectedDocumentsCount + selectedAssetsCount, destinationTitle = destination?.title ?? destination?.name, hasMultipleProjectIds = new Set(workspacesOptions.map(_temp18).filter(Boolean)).size > 1, t14;
$[42] !== payloadCount || $[43] !== selectedTotal ? (t14 = [
selectedTotal,
"/",
payloadCount,
@@ -917,35 +917,35 @@
}), t34] })
})
});
}
-function _temp16(space_1) {
+function _temp18(space_1) {
return space_1?.projectId;
}
-function _temp15(item_6) {
+function _temp17(item_6) {
return item_6.include && isAssetId(item_6.doc._id);
}
-function _temp14(item_5) {
+function _temp16(item_5) {
return item_5.include && !isAssetId(item_5.doc._id);
}
-function _temp13(t0) {
+function _temp15(t0) {
let { doc: doc_9 } = t0;
return doc_9.extension === "svg";
}
-function _temp12(item_4) {
+function _temp14(item_4) {
return item_4.doc._id;
}
-function _temp11(item_3) {
+function _temp13(item_3) {
return !item_3.include;
}
-function _temp10(t0) {
+function _temp12(t0) {
let { old, new: next } = t0;
return [old, next];
}
-function _temp1(item_2) {
+function _temp11(item_2) {
return item_2.doc;
}
-function _temp0(item_1) {
+function _temp10(item_1) {
return item_1.include;
}
function _temp9(t0) {
let { doc: doc_5, include } = t0;
@@ -976,121 +976,165 @@
}
function _temp2(acc, doc) {
return acc + extractWithPath(".._ref", doc).length;
}
-function _temp$1(space) {
+function _temp$2(space) {
return !space.disabled;
}
function DuplicatorQuery(props) {
- let { token, pluginConfig } = props, { queries: preDefinedQueries, apiVersion } = pluginConfig, originClient = useClient({ apiVersion }), schemaTypes = useSchema().getTypeNames(), [value, setValue] = useState(""), [fetched, setFetched] = useState(!1), [initialData, setInitialData] = useState({ docs: [] });
- async function runQuery() {
- try {
- let res = await originClient.fetch(value), registeredAndPublishedDocs = res.length ? res.filter((doc) => schemaTypes.includes(doc._type)).filter((doc_0) => !doc_0._id.startsWith("drafts.")) : [];
- setInitialData({ docs: registeredAndPublishedDocs }), setFetched(!0);
- } catch (err) {
- console.error(err);
- }
- }
- function handleSubmit(e) {
- e && e.preventDefault(), runQuery();
- }
- return /* @__PURE__ */ jsx(Card, {
- padding: [
- 0,
- 0,
- 0,
- 5
- ],
- children: /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsxs(Grid, {
- gridTemplateColumns: [
- 1,
- 1,
- 1,
- 2
- ],
- gap: [
- 1,
- 1,
- 1,
- 4
- ],
+ let $ = c(47), { token, pluginConfig } = props, { queries: preDefinedQueries, apiVersion } = pluginConfig, t0;
+ $[0] === apiVersion ? t0 = $[1] : (t0 = { apiVersion }, $[0] = apiVersion, $[1] = t0);
+ let originClient = useClient(t0), schema = useSchema(), t1;
+ $[2] === schema ? t1 = $[3] : (t1 = schema.getTypeNames(), $[2] = schema, $[3] = t1);
+ let schemaTypes = t1, [value, setValue] = useState(""), [fetched, setFetched] = useState(!1), t2;
+ $[4] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { docs: [] }, $[4] = t2) : t2 = $[4];
+ let [initialData, setInitialData] = useState(t2), t3;
+ if ($[5] !== originClient || $[6] !== schemaTypes || $[7] !== value) {
+ let runQuery = async function runQuery() {
+ try {
+ let res = await originClient.fetch(value), registeredAndPublishedDocs = res.length ? res.filter((doc) => schemaTypes.includes(doc._type)).filter(_temp$1) : [];
+ setInitialData({ docs: registeredAndPublishedDocs }), setFetched(!0);
+ } catch (t4) {
+ console.error(t4);
+ }
+ };
+ t3 = function handleSubmit(e) {
+ e && e.preventDefault(), runQuery();
+ }, $[5] = originClient, $[6] = schemaTypes, $[7] = value, $[8] = t3;
+ } else t3 = $[8];
+ let handleSubmit = t3, t4;
+ $[9] === Symbol.for("react.memo_cache_sentinel") ? (t4 = [
+ 0,
+ 0,
+ 0,
+ 5
+ ], $[9] = t4) : t4 = $[9];
+ let t5, t6;
+ $[10] === Symbol.for("react.memo_cache_sentinel") ? (t5 = [
+ 1,
+ 1,
+ 1,
+ 2
+ ], t6 = [
+ 1,
+ 1,
+ 1,
+ 4
+ ], $[10] = t5, $[11] = t6) : (t5 = $[10], t6 = $[11]);
+ let t7;
+ $[12] === Symbol.for("react.memo_cache_sentinel") ? (t7 = [
+ 2,
+ 2,
+ 2,
+ 0
+ ], $[12] = t7) : t7 = $[12];
+ let t8;
+ $[13] === Symbol.for("react.memo_cache_sentinel") ? (t8 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Label, { children: "Initial Documents Query" }) }), $[13] = t8) : t8 = $[13];
+ let t9;
+ $[14] === Symbol.for("react.memo_cache_sentinel") ? (t9 = /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: "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." }) }), $[14] = t9) : t9 = $[14];
+ let t10;
+ $[15] === Symbol.for("react.memo_cache_sentinel") ? (t10 = { fontFamily: "monospace" }, $[15] = t10) : t10 = $[15];
+ let t11;
+ $[16] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event) => setValue(event.currentTarget.value), $[16] = t11) : t11 = $[16];
+ let t12 = value ?? "", t13;
+ $[17] === t12 ? t13 = $[18] : (t13 = /* @__PURE__ */ jsx(Box, {
+ flex: 1,
+ paddingRight: 2,
+ children: /* @__PURE__ */ jsx(TextInput, {
+ style: t10,
+ fontSize: 2,
+ onChange: t11,
+ padding: 4,
+ placeholder: "*[_type == \"article\"]",
+ value: t12
+ })
+ }), $[17] = t12, $[18] = t13);
+ let t14;
+ $[19] === handleSubmit ? t14 = $[20] : (t14 = () => handleSubmit(), $[19] = handleSubmit, $[20] = t14);
+ let t15 = !value, t16;
+ $[21] !== t14 || $[22] !== t15 ? (t16 = /* @__PURE__ */ jsx(Button, {
+ padding: 2,
+ paddingX: 4,
+ tone: "primary",
+ onClick: t14,
+ text: "Query",
+ disabled: t15
+ }), $[21] = t14, $[22] = t15, $[23] = t16) : t16 = $[23];
+ let t17;
+ $[24] !== t13 || $[25] !== t16 ? (t17 = /* @__PURE__ */ jsxs(Flex, { children: [t13, t16] }), $[24] = t13, $[25] = t16, $[26] = t17) : t17 = $[26];
+ let t18;
+ $[27] !== handleSubmit || $[28] !== t17 ? (t18 = /* @__PURE__ */ jsx(Card, {
+ padding: 4,
+ radius: 3,
+ border: !0,
+ children: /* @__PURE__ */ jsxs(Stack, {
+ gap: 4,
children: [
- /* @__PURE__ */ jsxs(Box, {
- padding: [
- 2,
- 2,
- 2,
- 0
- ],
- children: [/* @__PURE__ */ jsx(Card, {
- padding: 4,
- radius: 3,
- border: !0,
- children: /* @__PURE__ */ jsxs(Stack, {
- gap: 4,
- children: [
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Label, { children: "Initial Documents Query" }) }),
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Text, { children: "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__ */ jsx("form", {
- onSubmit: handleSubmit,
- children: /* @__PURE__ */ jsxs(Flex, { children: [/* @__PURE__ */ jsx(Box, {
- flex: 1,
- paddingRight: 2,
- children: /* @__PURE__ */ jsx(TextInput, {
- style: { fontFamily: "monospace" },
- fontSize: 2,
- onChange: (event) => setValue(event.currentTarget.value),
- padding: 4,
- placeholder: "*[_type == \"article\"]",
- value: value ?? ""
- })
- }), /* @__PURE__ */ jsx(Button, {
- padding: 2,
- paddingX: 4,
- tone: "primary",
- onClick: () => handleSubmit(),
- text: "Query",
- disabled: !value
- })] })
- })
- ]
- })
- }), preDefinedQueries && preDefinedQueries?.length > 0 && /* @__PURE__ */ jsx(Card, {
- marginTop: 2,
- padding: 4,
- radius: 3,
- border: !0,
- children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Stack, {
- gap: 4,
- children: [/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Label, { children: "Predefined Queries" }) }), /* @__PURE__ */ jsx(Stack, {
- gap: 2,
- children: preDefinedQueries.map((query) => /* @__PURE__ */ jsx(Button, {
- padding: 2,
- paddingX: 4,
- tone: "primary",
- onClick: () => setValue(`*[${query.query}]`),
- text: query.label
- }, query.label.replace(/\s+/g, "-")))
- })]
- }) })
- })]
- }),
- fetched && initialData.docs.length < 1 && /* @__PURE__ */ jsx(Container, {
- width: 1,
- children: /* @__PURE__ */ jsx(Card, {
- padding: 5,
- children: value ? "No documents match this query" : "Start with a valid GROQ query"
- })
- }),
- initialData.docs?.length > 0 && /* @__PURE__ */ jsx(Duplicator, {
- docs: initialData.docs,
- token,
- pluginConfig
+ t8,
+ t9,
+ /* @__PURE__ */ jsx("form", {
+ onSubmit: handleSubmit,
+ children: t17
})
]
+ })
+ }), $[27] = handleSubmit, $[28] = t17, $[29] = t18) : t18 = $[29];
+ let t19;
+ $[30] === preDefinedQueries ? t19 = $[31] : (t19 = preDefinedQueries && preDefinedQueries?.length > 0 && /* @__PURE__ */ jsx(Card, {
+ marginTop: 2,
+ padding: 4,
+ radius: 3,
+ border: !0,
+ children: /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(Stack, {
+ gap: 4,
+ children: [/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Label, { children: "Predefined Queries" }) }), /* @__PURE__ */ jsx(Stack, {
+ gap: 2,
+ children: preDefinedQueries.map((query) => /* @__PURE__ */ jsx(Button, {
+ padding: 2,
+ paddingX: 4,
+ tone: "primary",
+ onClick: () => setValue(`*[${query.query}]`),
+ text: query.label
+ }, query.label.replace(/\s+/g, "-")))
+ })]
}) })
- });
+ }), $[30] = preDefinedQueries, $[31] = t19);
+ let t20;
+ $[32] !== t18 || $[33] !== t19 ? (t20 = /* @__PURE__ */ jsxs(Box, {
+ padding: t7,
+ children: [t18, t19]
+ }), $[32] = t18, $[33] = t19, $[34] = t20) : t20 = $[34];
+ let t21;
+ $[35] !== fetched || $[36] !== initialData.docs || $[37] !== value ? (t21 = fetched && initialData.docs.length < 1 && /* @__PURE__ */ jsx(Container, {
+ width: 1,
+ children: /* @__PURE__ */ jsx(Card, {
+ padding: 5,
+ children: value ? "No documents match this query" : "Start with a valid GROQ query"
+ })
+ }), $[35] = fetched, $[36] = initialData.docs, $[37] = value, $[38] = t21) : t21 = $[38];
+ let t22;
+ $[39] !== initialData.docs || $[40] !== pluginConfig || $[41] !== token ? (t22 = initialData.docs?.length > 0 && /* @__PURE__ */ jsx(Duplicator, {
+ docs: initialData.docs,
+ token,
+ pluginConfig
+ }), $[39] = initialData.docs, $[40] = pluginConfig, $[41] = token, $[42] = t22) : t22 = $[42];
+ let t23;
+ return $[43] !== t20 || $[44] !== t21 || $[45] !== t22 ? (t23 = /* @__PURE__ */ jsx(Card, {
+ padding: t4,
+ children: /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsxs(Grid, {
+ gridTemplateColumns: t5,
+ gap: t6,
+ children: [
+ t20,
+ t21,
+ t22
+ ]
+ }) })
+ }), $[43] = t20, $[44] = t21, $[45] = t22, $[46] = t23) : t23 = $[46], t23;
}
+function _temp$1(doc_0) {
+ return !doc_0._id.startsWith("drafts.");
+}
function DuplicatorWrapper(props) {
let $ = c(20), { docs, token, pluginConfig, onDuplicated } = props, t0;
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = [], $[0] = t0) : t0 = $[0];
let [inbound, setInbound] = useState(t0), { follow, apiVersion } = pluginConfig, [mode, setMode] = useState(follow.length === 1 ? follow[0] ?? "outbound" : "outbound"), t1; Index: package/package.json
===================================================================
--- package/package.json
+++ package/package.json
@@ -1,7 +1,7 @@
{
"name": "@sanity/cross-dataset-duplicator",
- "version": "2.1.3",
+ "version": "2.1.4",
"description": "Empower content editors to migrate Documents and Assets between Sanity Projects and Datasets from inside Sanity Studio",
"keywords": [
"sanity",
"sanity-plugin"
@@ -31,17 +31,17 @@
"@sanity/icons": "^5.2.1",
"@sanity/mutator": "^6.10.1",
"@sanity/ui": "^4.0.4",
"dset": "^3.1.4",
- "@sanity/studio-secrets": "^4.0.18"
+ "@sanity/studio-secrets": "^4.0.19"
},
"devDependencies": {
"@sanity/client": "^8.2.0",
"@sanity/tsconfig": "^2.2.1",
"@sanity/tsdown-config": "^0.26.0",
"@types/react": "^19.2.18",
"@types/react-dom": "^19.2.4",
- "babel-plugin-react-compiler": "^1.0.0",
+ "oxc-transform-react": "^0.145.0",
"react": "^19.2.8",
"react-dom": "^19.2.8",
"sanity": "^6.10.1",
"styled-components": "^6.5.3", File too large for inline diff