@sanity/cross-dataset-duplicator 1.2.2 → 1.2.4

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/dist/index.js CHANGED
@@ -398,7 +398,7 @@ function Duplicator(props) {
398
398
  setProgress([currentProgress, assetsCount]);
399
399
  setMessage({
400
400
  text: "Duplicating...",
401
- tone: "default"
401
+ tone: "transparent"
402
402
  });
403
403
  const destinationClient = originClient.withConfig({
404
404
  ...clientConfig,
@@ -429,6 +429,8 @@ function Duplicator(props) {
429
429
  });
430
430
  }
431
431
  transactionDocs.push(assetDoc);
432
+ doc.url = assetDoc.url;
433
+ doc.path = assetDoc.path;
432
434
  });
433
435
  currentProgress += 1;
434
436
  setMessage({
@@ -548,89 +550,89 @@ function Duplicator(props) {
548
550
  width: 1,
549
551
  children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
550
552
  border: true,
551
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
552
- children: /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
553
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Card, {
554
- borderBottom: true,
555
- padding: 4,
556
- style: stickyStyles(isDarkMode),
557
- children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
558
- space: 4,
559
- children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
560
- gap: 3,
561
- children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
562
- style: {
563
- flex: 1
564
- },
565
- space: 3,
566
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
567
- children: "Duplicate from"
568
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Select, {
569
- readOnly: true,
570
- value: (_c = workspacesOptions.find(space => space.disabled)) == null ? void 0 : _c.name,
571
- children: workspacesOptions.filter(space => space.disabled).map(space => {
572
- var _a2;
573
- return /* @__PURE__ */jsxRuntime.jsxs("option", {
574
- value: space.name,
575
- disabled: space.disabled,
576
- children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : ""]
577
- }, space.name);
578
- })
579
- })]
580
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
581
- padding: 4,
582
- paddingTop: 5,
583
- paddingBottom: 0,
584
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
585
- size: 3,
586
- children: /* @__PURE__ */jsxRuntime.jsx(icons.ArrowRightIcon, {})
553
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
554
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Card, {
555
+ padding: 4,
556
+ style: stickyStyles(isDarkMode),
557
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
558
+ space: 4,
559
+ children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
560
+ gap: 3,
561
+ children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
562
+ style: {
563
+ flex: 1
564
+ },
565
+ space: 3,
566
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
567
+ children: "Duplicate from"
568
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Select, {
569
+ readOnly: true,
570
+ value: (_c = workspacesOptions.find(space => space.disabled)) == null ? void 0 : _c.name,
571
+ children: workspacesOptions.filter(space => space.disabled).map(space => {
572
+ var _a2;
573
+ return /* @__PURE__ */jsxRuntime.jsxs("option", {
574
+ value: space.name,
575
+ disabled: space.disabled,
576
+ children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : ""]
577
+ }, space.name);
587
578
  })
588
- }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
589
- style: {
590
- flex: 1
591
- },
592
- space: 3,
593
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
594
- children: "To Destination"
595
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Select, {
596
- onChange: handleChange,
597
- children: workspacesOptions.map(space => {
598
- var _a2;
599
- return /* @__PURE__ */jsxRuntime.jsxs("option", {
600
- value: space.name,
601
- disabled: space.disabled,
602
- children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : "", space.disabled ? " (Current)" : ""]
603
- }, space.name);
604
- })
605
- })]
606
579
  })]
607
- }), isDuplicating && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
608
- border: true,
609
- radius: 2,
610
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
611
- style: {
612
- width: "100%",
613
- transform: "scaleX(".concat(progress[0] / progress[1], ")"),
614
- transformOrigin: "left",
615
- transition: "transform .2s ease",
616
- boxSizing: "border-box"
617
- },
618
- padding: 1,
619
- tone: "positive"
580
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
581
+ padding: 4,
582
+ paddingTop: 5,
583
+ paddingBottom: 0,
584
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
585
+ size: 3,
586
+ children: /* @__PURE__ */jsxRuntime.jsx(icons.ArrowRightIcon, {})
620
587
  })
621
- }), payload.length > 0 && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
588
+ }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
589
+ style: {
590
+ flex: 1
591
+ },
592
+ space: 3,
622
593
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
623
- children: headingText
624
- }), /* @__PURE__ */jsxRuntime.jsx(SelectButtons, {
625
- payload,
626
- setPayload
594
+ children: "To Destination"
595
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Select, {
596
+ onChange: handleChange,
597
+ children: workspacesOptions.map(space => {
598
+ var _a2;
599
+ return /* @__PURE__ */jsxRuntime.jsxs("option", {
600
+ value: space.name,
601
+ disabled: space.disabled,
602
+ children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : "", space.disabled ? " (Current)" : ""]
603
+ }, space.name);
604
+ })
627
605
  })]
628
606
  })]
629
- })
630
- }), message && /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
631
- paddingX: 4,
632
- paddingTop: 4,
633
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
607
+ }), isDuplicating && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
608
+ border: true,
609
+ radius: 2,
610
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
611
+ style: {
612
+ width: "100%",
613
+ transform: "scaleX(".concat(progress[0] / progress[1], ")"),
614
+ transformOrigin: "left",
615
+ transition: "transform .2s ease",
616
+ boxSizing: "border-box"
617
+ },
618
+ padding: 1,
619
+ tone: "positive"
620
+ })
621
+ }), payload.length > 0 && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
622
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
623
+ children: headingText
624
+ }), /* @__PURE__ */jsxRuntime.jsx(SelectButtons, {
625
+ payload,
626
+ setPayload
627
+ })]
628
+ })]
629
+ })
630
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
631
+ borderTop: true,
632
+ padding: 4,
633
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
634
+ space: 3,
635
+ children: [message && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
634
636
  padding: 3,
635
637
  radius: 2,
636
638
  shadow: 1,
@@ -639,89 +641,90 @@ function Duplicator(props) {
639
641
  size: 1,
640
642
  children: message.text
641
643
  })
642
- })
643
- }), payload.length > 0 && /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
644
- padding: 4,
645
- space: 3,
646
- children: payload.map((_ref5, index) => {
647
- let {
648
- doc,
649
- include,
650
- status,
651
- hasDraft
652
- } = _ref5;
653
- const schemaType = schema.get(doc._type);
654
- return /* @__PURE__ */jsxRuntime.jsxs(React__default.default.Fragment, {
655
- children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
656
- align: "center",
657
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
658
- checked: include,
659
- onChange: () => handleCheckbox(doc._id)
660
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
661
- flex: 1,
662
- paddingX: 3,
663
- children: schemaType ? /* @__PURE__ */jsxRuntime.jsx(sanity.Preview, {
664
- value: doc,
665
- schemaType
666
- }) : /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
667
- tone: "caution",
668
- children: "Invalid schema type"
669
- })
670
- }), /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
644
+ }), payload.length > 0 ? /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
645
+ children: payload.map((_ref5, index) => {
646
+ let {
647
+ doc,
648
+ include,
649
+ status,
650
+ hasDraft
651
+ } = _ref5;
652
+ const schemaType = schema.get(doc._type);
653
+ return /* @__PURE__ */jsxRuntime.jsxs(React__default.default.Fragment, {
654
+ children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
671
655
  align: "center",
672
- gap: 2,
673
- children: [hasDraft ? /* @__PURE__ */jsxRuntime.jsx(StatusBadge, {
674
- status: "UNPUBLISHED",
675
- isAsset: false
676
- }) : null, /* @__PURE__ */jsxRuntime.jsx(StatusBadge, {
677
- status,
678
- isAsset: assetUtils.isAssetId(doc._id)
656
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Checkbox, {
657
+ checked: include,
658
+ onChange: () => handleCheckbox(doc._id)
659
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
660
+ flex: 1,
661
+ paddingX: 3,
662
+ children: schemaType ? /* @__PURE__ */jsxRuntime.jsx(sanity.Preview, {
663
+ value: doc,
664
+ schemaType
665
+ }) : /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
666
+ tone: "caution",
667
+ children: "Invalid schema type"
668
+ })
669
+ }), /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
670
+ align: "center",
671
+ gap: 2,
672
+ children: [hasDraft ? /* @__PURE__ */jsxRuntime.jsx(StatusBadge, {
673
+ status: "UNPUBLISHED",
674
+ isAsset: false
675
+ }) : null, /* @__PURE__ */jsxRuntime.jsx(StatusBadge, {
676
+ status,
677
+ isAsset: assetUtils.isAssetId(doc._id)
678
+ })]
679
679
  })]
680
+ }), (doc == null ? void 0 : doc.extension) === "svg" && index === firstSvgIndex && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
681
+ padding: 3,
682
+ radius: 2,
683
+ shadow: 1,
684
+ tone: "caution",
685
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
686
+ size: 1,
687
+ children: ["Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new ", /* @__PURE__ */jsxRuntime.jsx("code", {
688
+ children: "_id"
689
+ }), "'s at the destination. The newly generated ", /* @__PURE__ */jsxRuntime.jsx("code", {
690
+ children: "_id"
691
+ }), " will be the same in each duplication, but it will never be the same ", /* @__PURE__ */jsxRuntime.jsx("code", {
692
+ children: "_id"
693
+ }), " as the first time this Asset was uploaded. References to the asset will be updated to use the new ", /* @__PURE__ */jsxRuntime.jsx("code", {
694
+ children: "_id"
695
+ }), "."]
696
+ })
680
697
  })]
681
- }), (doc == null ? void 0 : doc.extension) === "svg" && index === firstSvgIndex && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
682
- padding: 3,
683
- radius: 2,
684
- shadow: 1,
685
- tone: "caution",
686
- children: /* @__PURE__ */jsxRuntime.jsxs(ui.Text, {
687
- size: 1,
688
- children: ["Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new ", /* @__PURE__ */jsxRuntime.jsx("code", {
689
- children: "_id"
690
- }), "'s at the destination. The newly generated ", /* @__PURE__ */jsxRuntime.jsx("code", {
691
- children: "_id"
692
- }), " will be the same in each duplication, but it will never be the same ", /* @__PURE__ */jsxRuntime.jsx("code", {
693
- children: "_id"
694
- }), " as the first time this Asset was uploaded. References to the asset will be updated to use the new", " ", /* @__PURE__ */jsxRuntime.jsx("code", {
695
- children: "_id"
696
- }), "."]
697
- })
698
- })]
699
- }, doc._id);
700
- })
701
- }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
702
- space: 2,
703
- padding: 4,
704
- paddingTop: 0,
705
- children: [hasReferences && /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
706
- fontSize: 2,
707
- padding: 4,
708
- tone: "positive",
709
- mode: "ghost",
710
- icon: icons.SearchIcon,
711
- onClick: handleReferences,
712
- text: "Gather References",
713
- disabled: isDuplicating || !selectedTotal || isGathering
714
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
715
- fontSize: 2,
698
+ }, doc._id);
699
+ })
700
+ }) : /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
716
701
  padding: 4,
717
- tone: "positive",
718
- icon: icons.LaunchIcon,
719
- onClick: handleDuplicate,
720
- text: buttonText,
721
- disabled: isDuplicating || !selectedTotal || isGathering
702
+ align: "center",
703
+ justify: "center",
704
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
705
+ }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
706
+ space: 2,
707
+ children: [hasReferences && /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
708
+ fontSize: 2,
709
+ padding: 4,
710
+ tone: "positive",
711
+ mode: "ghost",
712
+ icon: icons.SearchIcon,
713
+ onClick: handleReferences,
714
+ text: "Gather References",
715
+ disabled: isDuplicating || !selectedTotal || isGathering
716
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
717
+ fontSize: 2,
718
+ padding: 4,
719
+ tone: "positive",
720
+ icon: icons.LaunchIcon,
721
+ onClick: handleDuplicate,
722
+ text: buttonText,
723
+ disabled: isDuplicating || !selectedTotal || isGathering
724
+ })]
722
725
  })]
723
- })]
724
- })
726
+ })
727
+ })]
725
728
  })
726
729
  })
727
730
  });