@sanity/cross-dataset-duplicator 1.2.3 → 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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Sanity.io
3
+ Copyright (c) 2024 Sanity.io
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/dist/index.esm.js CHANGED
@@ -3,7 +3,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
3
3
  import React, { useState, useEffect, useCallback, createContext, useContext } from 'react';
4
4
  import { ArrowRightIcon, SearchIcon, LaunchIcon } from '@sanity/icons';
5
5
  import { useSecrets, SettingsView } from '@sanity/studio-secrets';
6
- import { Card, Flex, Button, Badge, Tooltip, Box, Text, useTheme, Container, Stack, Label, Select, Checkbox, Grid, TextInput, Spinner } from '@sanity/ui';
6
+ import { Card, Flex, Button, Badge, Tooltip, Box, Text, useTheme, Container, Stack, Label, Select, Checkbox, Spinner, Grid, TextInput } from '@sanity/ui';
7
7
  import mapLimit from 'async/mapLimit';
8
8
  import asyncify from 'async/asyncify';
9
9
  import { extractWithPath } from '@sanity/mutator';
@@ -385,7 +385,7 @@ function Duplicator(props) {
385
385
  setProgress([currentProgress, assetsCount]);
386
386
  setMessage({
387
387
  text: "Duplicating...",
388
- tone: "default"
388
+ tone: "transparent"
389
389
  });
390
390
  const destinationClient = originClient.withConfig({
391
391
  ...clientConfig,
@@ -416,6 +416,8 @@ function Duplicator(props) {
416
416
  });
417
417
  }
418
418
  transactionDocs.push(assetDoc);
419
+ doc.url = assetDoc.url;
420
+ doc.path = assetDoc.path;
419
421
  });
420
422
  currentProgress += 1;
421
423
  setMessage({
@@ -535,89 +537,89 @@ function Duplicator(props) {
535
537
  width: 1,
536
538
  children: /* @__PURE__ */jsx(Card, {
537
539
  border: true,
538
- children: /* @__PURE__ */jsx(Stack, {
539
- children: /* @__PURE__ */jsxs(Fragment, {
540
- children: [/* @__PURE__ */jsx(Card, {
541
- borderBottom: true,
542
- padding: 4,
543
- style: stickyStyles(isDarkMode),
544
- children: /* @__PURE__ */jsxs(Stack, {
545
- space: 4,
546
- children: [/* @__PURE__ */jsxs(Flex, {
547
- gap: 3,
548
- children: [/* @__PURE__ */jsxs(Stack, {
549
- style: {
550
- flex: 1
551
- },
552
- space: 3,
553
- children: [/* @__PURE__ */jsx(Label, {
554
- children: "Duplicate from"
555
- }), /* @__PURE__ */jsx(Select, {
556
- readOnly: true,
557
- value: (_c = workspacesOptions.find(space => space.disabled)) == null ? void 0 : _c.name,
558
- children: workspacesOptions.filter(space => space.disabled).map(space => {
559
- var _a2;
560
- return /* @__PURE__ */jsxs("option", {
561
- value: space.name,
562
- disabled: space.disabled,
563
- children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : ""]
564
- }, space.name);
565
- })
566
- })]
567
- }), /* @__PURE__ */jsx(Box, {
568
- padding: 4,
569
- paddingTop: 5,
570
- paddingBottom: 0,
571
- children: /* @__PURE__ */jsx(Text, {
572
- size: 3,
573
- children: /* @__PURE__ */jsx(ArrowRightIcon, {})
540
+ children: /* @__PURE__ */jsxs(Stack, {
541
+ children: [/* @__PURE__ */jsx(Card, {
542
+ padding: 4,
543
+ style: stickyStyles(isDarkMode),
544
+ children: /* @__PURE__ */jsxs(Stack, {
545
+ space: 4,
546
+ children: [/* @__PURE__ */jsxs(Flex, {
547
+ gap: 3,
548
+ children: [/* @__PURE__ */jsxs(Stack, {
549
+ style: {
550
+ flex: 1
551
+ },
552
+ space: 3,
553
+ children: [/* @__PURE__ */jsx(Label, {
554
+ children: "Duplicate from"
555
+ }), /* @__PURE__ */jsx(Select, {
556
+ readOnly: true,
557
+ value: (_c = workspacesOptions.find(space => space.disabled)) == null ? void 0 : _c.name,
558
+ children: workspacesOptions.filter(space => space.disabled).map(space => {
559
+ var _a2;
560
+ return /* @__PURE__ */jsxs("option", {
561
+ value: space.name,
562
+ disabled: space.disabled,
563
+ children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : ""]
564
+ }, space.name);
574
565
  })
575
- }), /* @__PURE__ */jsxs(Stack, {
576
- style: {
577
- flex: 1
578
- },
579
- space: 3,
580
- children: [/* @__PURE__ */jsx(Label, {
581
- children: "To Destination"
582
- }), /* @__PURE__ */jsx(Select, {
583
- onChange: handleChange,
584
- children: workspacesOptions.map(space => {
585
- var _a2;
586
- return /* @__PURE__ */jsxs("option", {
587
- value: space.name,
588
- disabled: space.disabled,
589
- children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : "", space.disabled ? " (Current)" : ""]
590
- }, space.name);
591
- })
592
- })]
593
566
  })]
594
- }), isDuplicating && /* @__PURE__ */jsx(Card, {
595
- border: true,
596
- radius: 2,
597
- children: /* @__PURE__ */jsx(Card, {
598
- style: {
599
- width: "100%",
600
- transform: "scaleX(".concat(progress[0] / progress[1], ")"),
601
- transformOrigin: "left",
602
- transition: "transform .2s ease",
603
- boxSizing: "border-box"
604
- },
605
- padding: 1,
606
- tone: "positive"
567
+ }), /* @__PURE__ */jsx(Box, {
568
+ padding: 4,
569
+ paddingTop: 5,
570
+ paddingBottom: 0,
571
+ children: /* @__PURE__ */jsx(Text, {
572
+ size: 3,
573
+ children: /* @__PURE__ */jsx(ArrowRightIcon, {})
607
574
  })
608
- }), payload.length > 0 && /* @__PURE__ */jsxs(Fragment, {
575
+ }), /* @__PURE__ */jsxs(Stack, {
576
+ style: {
577
+ flex: 1
578
+ },
579
+ space: 3,
609
580
  children: [/* @__PURE__ */jsx(Label, {
610
- children: headingText
611
- }), /* @__PURE__ */jsx(SelectButtons, {
612
- payload,
613
- setPayload
581
+ children: "To Destination"
582
+ }), /* @__PURE__ */jsx(Select, {
583
+ onChange: handleChange,
584
+ children: workspacesOptions.map(space => {
585
+ var _a2;
586
+ return /* @__PURE__ */jsxs("option", {
587
+ value: space.name,
588
+ disabled: space.disabled,
589
+ children: [(_a2 = space.title) != null ? _a2 : space.name, hasMultipleProjectIds ? " (".concat(space.projectId, ")") : "", space.disabled ? " (Current)" : ""]
590
+ }, space.name);
591
+ })
614
592
  })]
615
593
  })]
616
- })
617
- }), message && /* @__PURE__ */jsx(Box, {
618
- paddingX: 4,
619
- paddingTop: 4,
620
- children: /* @__PURE__ */jsx(Card, {
594
+ }), isDuplicating && /* @__PURE__ */jsx(Card, {
595
+ border: true,
596
+ radius: 2,
597
+ children: /* @__PURE__ */jsx(Card, {
598
+ style: {
599
+ width: "100%",
600
+ transform: "scaleX(".concat(progress[0] / progress[1], ")"),
601
+ transformOrigin: "left",
602
+ transition: "transform .2s ease",
603
+ boxSizing: "border-box"
604
+ },
605
+ padding: 1,
606
+ tone: "positive"
607
+ })
608
+ }), payload.length > 0 && /* @__PURE__ */jsxs(Fragment, {
609
+ children: [/* @__PURE__ */jsx(Label, {
610
+ children: headingText
611
+ }), /* @__PURE__ */jsx(SelectButtons, {
612
+ payload,
613
+ setPayload
614
+ })]
615
+ })]
616
+ })
617
+ }), /* @__PURE__ */jsx(Card, {
618
+ borderTop: true,
619
+ padding: 4,
620
+ children: /* @__PURE__ */jsxs(Stack, {
621
+ space: 3,
622
+ children: [message && /* @__PURE__ */jsx(Card, {
621
623
  padding: 3,
622
624
  radius: 2,
623
625
  shadow: 1,
@@ -626,89 +628,90 @@ function Duplicator(props) {
626
628
  size: 1,
627
629
  children: message.text
628
630
  })
629
- })
630
- }), payload.length > 0 && /* @__PURE__ */jsx(Stack, {
631
- padding: 4,
632
- space: 3,
633
- children: payload.map((_ref5, index) => {
634
- let {
635
- doc,
636
- include,
637
- status,
638
- hasDraft
639
- } = _ref5;
640
- const schemaType = schema.get(doc._type);
641
- return /* @__PURE__ */jsxs(React.Fragment, {
642
- children: [/* @__PURE__ */jsxs(Flex, {
643
- align: "center",
644
- children: [/* @__PURE__ */jsx(Checkbox, {
645
- checked: include,
646
- onChange: () => handleCheckbox(doc._id)
647
- }), /* @__PURE__ */jsx(Box, {
648
- flex: 1,
649
- paddingX: 3,
650
- children: schemaType ? /* @__PURE__ */jsx(Preview, {
651
- value: doc,
652
- schemaType
653
- }) : /* @__PURE__ */jsx(Card, {
654
- tone: "caution",
655
- children: "Invalid schema type"
656
- })
657
- }), /* @__PURE__ */jsxs(Flex, {
631
+ }), payload.length > 0 ? /* @__PURE__ */jsx(Stack, {
632
+ children: payload.map((_ref5, index) => {
633
+ let {
634
+ doc,
635
+ include,
636
+ status,
637
+ hasDraft
638
+ } = _ref5;
639
+ const schemaType = schema.get(doc._type);
640
+ return /* @__PURE__ */jsxs(React.Fragment, {
641
+ children: [/* @__PURE__ */jsxs(Flex, {
658
642
  align: "center",
659
- gap: 2,
660
- children: [hasDraft ? /* @__PURE__ */jsx(StatusBadge, {
661
- status: "UNPUBLISHED",
662
- isAsset: false
663
- }) : null, /* @__PURE__ */jsx(StatusBadge, {
664
- status,
665
- isAsset: isAssetId(doc._id)
643
+ children: [/* @__PURE__ */jsx(Checkbox, {
644
+ checked: include,
645
+ onChange: () => handleCheckbox(doc._id)
646
+ }), /* @__PURE__ */jsx(Box, {
647
+ flex: 1,
648
+ paddingX: 3,
649
+ children: schemaType ? /* @__PURE__ */jsx(Preview, {
650
+ value: doc,
651
+ schemaType
652
+ }) : /* @__PURE__ */jsx(Card, {
653
+ tone: "caution",
654
+ children: "Invalid schema type"
655
+ })
656
+ }), /* @__PURE__ */jsxs(Flex, {
657
+ align: "center",
658
+ gap: 2,
659
+ children: [hasDraft ? /* @__PURE__ */jsx(StatusBadge, {
660
+ status: "UNPUBLISHED",
661
+ isAsset: false
662
+ }) : null, /* @__PURE__ */jsx(StatusBadge, {
663
+ status,
664
+ isAsset: isAssetId(doc._id)
665
+ })]
666
666
  })]
667
+ }), (doc == null ? void 0 : doc.extension) === "svg" && index === firstSvgIndex && /* @__PURE__ */jsx(Card, {
668
+ padding: 3,
669
+ radius: 2,
670
+ shadow: 1,
671
+ tone: "caution",
672
+ children: /* @__PURE__ */jsxs(Text, {
673
+ size: 1,
674
+ children: ["Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new ", /* @__PURE__ */jsx("code", {
675
+ children: "_id"
676
+ }), "'s at the destination. The newly generated ", /* @__PURE__ */jsx("code", {
677
+ children: "_id"
678
+ }), " will be the same in each duplication, but it will never be the same ", /* @__PURE__ */jsx("code", {
679
+ children: "_id"
680
+ }), " as the first time this Asset was uploaded. References to the asset will be updated to use the new ", /* @__PURE__ */jsx("code", {
681
+ children: "_id"
682
+ }), "."]
683
+ })
667
684
  })]
668
- }), (doc == null ? void 0 : doc.extension) === "svg" && index === firstSvgIndex && /* @__PURE__ */jsx(Card, {
669
- padding: 3,
670
- radius: 2,
671
- shadow: 1,
672
- tone: "caution",
673
- children: /* @__PURE__ */jsxs(Text, {
674
- size: 1,
675
- children: ["Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new ", /* @__PURE__ */jsx("code", {
676
- children: "_id"
677
- }), "'s at the destination. The newly generated ", /* @__PURE__ */jsx("code", {
678
- children: "_id"
679
- }), " will be the same in each duplication, but it will never be the same ", /* @__PURE__ */jsx("code", {
680
- children: "_id"
681
- }), " as the first time this Asset was uploaded. References to the asset will be updated to use the new", " ", /* @__PURE__ */jsx("code", {
682
- children: "_id"
683
- }), "."]
684
- })
685
- })]
686
- }, doc._id);
687
- })
688
- }), /* @__PURE__ */jsxs(Stack, {
689
- space: 2,
690
- padding: 4,
691
- paddingTop: 0,
692
- children: [hasReferences && /* @__PURE__ */jsx(Button, {
693
- fontSize: 2,
694
- padding: 4,
695
- tone: "positive",
696
- mode: "ghost",
697
- icon: SearchIcon,
698
- onClick: handleReferences,
699
- text: "Gather References",
700
- disabled: isDuplicating || !selectedTotal || isGathering
701
- }), /* @__PURE__ */jsx(Button, {
702
- fontSize: 2,
685
+ }, doc._id);
686
+ })
687
+ }) : /* @__PURE__ */jsx(Flex, {
703
688
  padding: 4,
704
- tone: "positive",
705
- icon: LaunchIcon,
706
- onClick: handleDuplicate,
707
- text: buttonText,
708
- disabled: isDuplicating || !selectedTotal || isGathering
689
+ align: "center",
690
+ justify: "center",
691
+ children: /* @__PURE__ */jsx(Spinner, {})
692
+ }), /* @__PURE__ */jsxs(Stack, {
693
+ space: 2,
694
+ children: [hasReferences && /* @__PURE__ */jsx(Button, {
695
+ fontSize: 2,
696
+ padding: 4,
697
+ tone: "positive",
698
+ mode: "ghost",
699
+ icon: SearchIcon,
700
+ onClick: handleReferences,
701
+ text: "Gather References",
702
+ disabled: isDuplicating || !selectedTotal || isGathering
703
+ }), /* @__PURE__ */jsx(Button, {
704
+ fontSize: 2,
705
+ padding: 4,
706
+ tone: "positive",
707
+ icon: LaunchIcon,
708
+ onClick: handleDuplicate,
709
+ text: buttonText,
710
+ disabled: isDuplicating || !selectedTotal || isGathering
711
+ })]
709
712
  })]
710
- })]
711
- })
713
+ })
714
+ })]
712
715
  })
713
716
  })
714
717
  });