@sanity/cross-dataset-duplicator 1.2.3 → 1.3.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/dist/index.js CHANGED
@@ -133,6 +133,7 @@ function SelectButtons(props) {
133
133
  shadow: 1,
134
134
  children: /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
135
135
  gap: 2,
136
+ wrap: "wrap",
136
137
  children: buttons.map((action, actionIndex) => action ? /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
137
138
  fontSize: 1,
138
139
  mode: "bleed",
@@ -398,7 +399,7 @@ function Duplicator(props) {
398
399
  setProgress([currentProgress, assetsCount]);
399
400
  setMessage({
400
401
  text: "Duplicating...",
401
- tone: "default"
402
+ tone: "transparent"
402
403
  });
403
404
  const destinationClient = originClient.withConfig({
404
405
  ...clientConfig,
@@ -429,6 +430,8 @@ function Duplicator(props) {
429
430
  });
430
431
  }
431
432
  transactionDocs.push(assetDoc);
433
+ doc.url = assetDoc.url;
434
+ doc.path = assetDoc.path;
432
435
  });
433
436
  currentProgress += 1;
434
437
  setMessage({
@@ -548,89 +551,89 @@ function Duplicator(props) {
548
551
  width: 1,
549
552
  children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
550
553
  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, {})
554
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
555
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Card, {
556
+ padding: 4,
557
+ style: stickyStyles(isDarkMode),
558
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
559
+ space: 4,
560
+ children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
561
+ gap: 3,
562
+ children: [/* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
563
+ style: {
564
+ flex: 1
565
+ },
566
+ space: 3,
567
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
568
+ children: "Duplicate from"
569
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Select, {
570
+ readOnly: true,
571
+ value: (_c = workspacesOptions.find(space => space.disabled)) == null ? void 0 : _c.name,
572
+ children: workspacesOptions.filter(space => space.disabled).map(space => {
573
+ var _a2;
574
+ return /* @__PURE__ */jsxRuntime.jsxs("option", {
575
+ value: space.name,
576
+ disabled: space.disabled,
577
+ children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : ""]
578
+ }, space.name);
587
579
  })
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
580
  })]
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"
581
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
582
+ padding: 4,
583
+ paddingTop: 5,
584
+ paddingBottom: 0,
585
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
586
+ size: 3,
587
+ children: /* @__PURE__ */jsxRuntime.jsx(icons.ArrowRightIcon, {})
620
588
  })
621
- }), payload.length > 0 && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
589
+ }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
590
+ style: {
591
+ flex: 1
592
+ },
593
+ space: 3,
622
594
  children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
623
- children: headingText
624
- }), /* @__PURE__ */jsxRuntime.jsx(SelectButtons, {
625
- payload,
626
- setPayload
595
+ children: "To Destination"
596
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Select, {
597
+ onChange: handleChange,
598
+ children: workspacesOptions.map(space => {
599
+ var _a2;
600
+ return /* @__PURE__ */jsxRuntime.jsxs("option", {
601
+ value: space.name,
602
+ disabled: space.disabled,
603
+ children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : "", space.disabled ? " (Current)" : ""]
604
+ }, space.name);
605
+ })
627
606
  })]
628
607
  })]
629
- })
630
- }), message && /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
631
- paddingX: 4,
632
- paddingTop: 4,
633
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
608
+ }), isDuplicating && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
609
+ border: true,
610
+ radius: 2,
611
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
612
+ style: {
613
+ width: "100%",
614
+ transform: "scaleX(".concat(progress[0] / progress[1], ")"),
615
+ transformOrigin: "left",
616
+ transition: "transform .2s ease",
617
+ boxSizing: "border-box"
618
+ },
619
+ padding: 1,
620
+ tone: "positive"
621
+ })
622
+ }), payload.length > 0 && /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
623
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Label, {
624
+ children: headingText
625
+ }), /* @__PURE__ */jsxRuntime.jsx(SelectButtons, {
626
+ payload,
627
+ setPayload
628
+ })]
629
+ })]
630
+ })
631
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
632
+ borderTop: true,
633
+ padding: 4,
634
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
635
+ space: 3,
636
+ children: [message && /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
634
637
  padding: 3,
635
638
  radius: 2,
636
639
  shadow: 1,
@@ -639,89 +642,90 @@ function Duplicator(props) {
639
642
  size: 1,
640
643
  children: message.text
641
644
  })
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, {
645
+ }), payload.length > 0 ? /* @__PURE__ */jsxRuntime.jsx(ui.Stack, {
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, {
671
656
  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)
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, {
671
+ 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)
679
+ })]
679
680
  })]
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
+ })
680
698
  })]
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,
699
+ }, doc._id);
700
+ })
701
+ }) : /* @__PURE__ */jsxRuntime.jsx(ui.Flex, {
716
702
  padding: 4,
717
- tone: "positive",
718
- icon: icons.LaunchIcon,
719
- onClick: handleDuplicate,
720
- text: buttonText,
721
- disabled: isDuplicating || !selectedTotal || isGathering
703
+ align: "center",
704
+ justify: "center",
705
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Spinner, {})
706
+ }), /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
707
+ space: 2,
708
+ children: [hasReferences && /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
709
+ fontSize: 2,
710
+ padding: 4,
711
+ tone: "positive",
712
+ mode: "ghost",
713
+ icon: icons.SearchIcon,
714
+ onClick: handleReferences,
715
+ text: "Gather References",
716
+ disabled: isDuplicating || !selectedTotal || isGathering
717
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
718
+ fontSize: 2,
719
+ padding: 4,
720
+ tone: "positive",
721
+ icon: icons.LaunchIcon,
722
+ onClick: handleDuplicate,
723
+ text: buttonText,
724
+ disabled: isDuplicating || !selectedTotal || isGathering
725
+ })]
722
726
  })]
723
- })]
724
- })
727
+ })
728
+ })]
725
729
  })
726
730
  })
727
731
  });
@@ -757,67 +761,68 @@ function DuplicatorQuery(props) {
757
761
  handleSubmit();
758
762
  }
759
763
  }, []);
760
- return /* @__PURE__ */jsxRuntime.jsx(ui.Container, {
761
- width: [1, 1, 1, 3],
764
+ return /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
762
765
  padding: [0, 0, 0, 5],
763
- children: /* @__PURE__ */jsxRuntime.jsxs(ui.Grid, {
764
- columns: [1, 1, 1, 2],
765
- gap: [1, 1, 1, 4],
766
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
767
- padding: [2, 2, 2, 0],
768
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
769
- padding: 4,
770
- radius: 3,
771
- border: true,
772
- children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
773
- space: 4,
774
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
775
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
776
- children: "Initial Documents Query"
777
- })
778
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
779
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
780
- 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."
781
- })
782
- }), /* @__PURE__ */jsxRuntime.jsx("form", {
783
- onSubmit: handleSubmit,
784
- children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
785
- children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
786
- flex: 1,
787
- paddingRight: 2,
788
- children: /* @__PURE__ */jsxRuntime.jsx(ui.TextInput, {
789
- style: {
790
- fontFamily: "monospace"
791
- },
792
- fontSize: 2,
793
- onChange: event => setValue(event.currentTarget.value),
794
- padding: 4,
795
- placeholder: "*[_type == \"article\"]",
796
- value: value != null ? value : ""
797
- })
798
- }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
799
- padding: 2,
800
- paddingX: 4,
801
- tone: "primary",
802
- onClick: handleSubmit,
803
- text: "Query",
804
- disabled: !value
805
- })]
806
- })
807
- })]
766
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Container, {
767
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Grid, {
768
+ columns: [1, 1, 1, 2],
769
+ gap: [1, 1, 1, 4],
770
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
771
+ padding: [2, 2, 2, 0],
772
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
773
+ padding: 4,
774
+ radius: 3,
775
+ border: true,
776
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Stack, {
777
+ space: 4,
778
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
779
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Label, {
780
+ children: "Initial Documents Query"
781
+ })
782
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Box, {
783
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Text, {
784
+ 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."
785
+ })
786
+ }), /* @__PURE__ */jsxRuntime.jsx("form", {
787
+ onSubmit: handleSubmit,
788
+ children: /* @__PURE__ */jsxRuntime.jsxs(ui.Flex, {
789
+ children: [/* @__PURE__ */jsxRuntime.jsx(ui.Box, {
790
+ flex: 1,
791
+ paddingRight: 2,
792
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.TextInput, {
793
+ style: {
794
+ fontFamily: "monospace"
795
+ },
796
+ fontSize: 2,
797
+ onChange: event => setValue(event.currentTarget.value),
798
+ padding: 4,
799
+ placeholder: "*[_type == \"article\"]",
800
+ value: value != null ? value : ""
801
+ })
802
+ }), /* @__PURE__ */jsxRuntime.jsx(ui.Button, {
803
+ padding: 2,
804
+ paddingX: 4,
805
+ tone: "primary",
806
+ onClick: handleSubmit,
807
+ text: "Query",
808
+ disabled: !value
809
+ })]
810
+ })
811
+ })]
812
+ })
808
813
  })
809
- })
810
- }), !((_a = initialData.docs) == null ? void 0 : _a.length) || initialData.docs.length < 1 && /* @__PURE__ */jsxRuntime.jsx(ui.Container, {
811
- width: 1,
812
- children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
813
- padding: 5,
814
- children: value ? "No Documents registered to the Schema match this query" : "Start with a valid GROQ query"
815
- })
816
- }), ((_b = initialData.docs) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */jsxRuntime.jsx(Duplicator, {
817
- docs: initialData.docs,
818
- token,
819
- pluginConfig
820
- })]
814
+ }), !((_a = initialData.docs) == null ? void 0 : _a.length) || initialData.docs.length < 1 && /* @__PURE__ */jsxRuntime.jsx(ui.Container, {
815
+ width: 1,
816
+ children: /* @__PURE__ */jsxRuntime.jsx(ui.Card, {
817
+ padding: 5,
818
+ children: value ? "No Documents registered to the Schema match this query" : "Start with a valid GROQ query"
819
+ })
820
+ }), ((_b = initialData.docs) == null ? void 0 : _b.length) > 0 && /* @__PURE__ */jsxRuntime.jsx(Duplicator, {
821
+ docs: initialData.docs,
822
+ token,
823
+ pluginConfig
824
+ })]
825
+ })
821
826
  })
822
827
  });
823
828
  }