@sanity/cross-dataset-duplicator 0.3.6 → 1.0.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.
Files changed (60) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +53 -53
  3. package/lib/index.esm.js +2 -0
  4. package/lib/index.esm.js.map +1 -0
  5. package/lib/index.js +2 -21
  6. package/lib/index.js.map +1 -1
  7. package/lib/src/index.d.ts +20 -0
  8. package/package.json +64 -38
  9. package/sanity.json +2 -10
  10. package/src/actions/DuplicateToAction.tsx +33 -7
  11. package/src/components/CrossDatasetDuplicator.tsx +42 -46
  12. package/src/components/{DuplicatorTool.tsx → Duplicator.tsx} +183 -126
  13. package/src/components/DuplicatorQuery.tsx +36 -13
  14. package/src/components/DuplicatorWrapper.tsx +66 -0
  15. package/src/components/ResetSecret.tsx +9 -9
  16. package/src/components/SelectButtons.tsx +13 -9
  17. package/src/components/StatusBadge.tsx +13 -9
  18. package/src/helpers/clientConfig.ts +1 -1
  19. package/src/helpers/constants.ts +1 -1
  20. package/src/helpers/getDocumentsInArray.ts +28 -21
  21. package/src/helpers/index.ts +6 -10
  22. package/src/index.ts +36 -0
  23. package/src/tool/index.ts +14 -10
  24. package/src/types/index.ts +9 -9
  25. package/v2-incompatible.js +11 -0
  26. package/.babelrc +0 -3
  27. package/.eslintignore +0 -1
  28. package/config.dist.json +0 -4
  29. package/lib/actions/DuplicateToAction.js +0 -44
  30. package/lib/actions/DuplicateToAction.js.map +0 -1
  31. package/lib/actions/index.js +0 -29
  32. package/lib/actions/index.js.map +0 -1
  33. package/lib/components/CrossDatasetDuplicator.js +0 -81
  34. package/lib/components/CrossDatasetDuplicator.js.map +0 -1
  35. package/lib/components/DuplicatorQuery.js +0 -105
  36. package/lib/components/DuplicatorQuery.js.map +0 -1
  37. package/lib/components/DuplicatorTool.js +0 -503
  38. package/lib/components/DuplicatorTool.js.map +0 -1
  39. package/lib/components/Feedback.js +0 -23
  40. package/lib/components/Feedback.js.map +0 -1
  41. package/lib/components/ResetSecret.js +0 -34
  42. package/lib/components/ResetSecret.js.map +0 -1
  43. package/lib/components/SelectButtons.js +0 -84
  44. package/lib/components/SelectButtons.js.map +0 -1
  45. package/lib/components/StatusBadge.js +0 -85
  46. package/lib/components/StatusBadge.js.map +0 -1
  47. package/lib/helpers/clientConfig.js +0 -11
  48. package/lib/helpers/clientConfig.js.map +0 -1
  49. package/lib/helpers/constants.js +0 -9
  50. package/lib/helpers/constants.js.map +0 -1
  51. package/lib/helpers/getDocumentsInArray.js +0 -74
  52. package/lib/helpers/getDocumentsInArray.js.map +0 -1
  53. package/lib/helpers/index.js +0 -27
  54. package/lib/helpers/index.js.map +0 -1
  55. package/lib/tool/index.js +0 -18
  56. package/lib/tool/index.js.map +0 -1
  57. package/lib/types/index.js +0 -2
  58. package/lib/types/index.js.map +0 -1
  59. package/src/actions/index.ts +0 -22
  60. package/src/index.js +0 -7
@@ -1,105 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = DuplicatorQuery;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _client = _interopRequireDefault(require("part:@sanity/base/client"));
9
- var _schema = _interopRequireDefault(require("part:@sanity/base/schema"));
10
- var _ui = require("@sanity/ui");
11
- var _DuplicatorTool = _interopRequireDefault(require("./DuplicatorTool"));
12
- var _clientConfig = require("../helpers/clientConfig");
13
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
- 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
- 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; }
16
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
- 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."); }
18
- 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); }
19
- 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; }
20
- 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; }
21
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
22
- var originClient = _client.default.withConfig(_clientConfig.clientConfig);
23
- var schemaTypes = _schema.default.getTypeNames();
24
- function DuplicatorQuery(props) {
25
- var _initialData$docs2, _initialData$docs3;
26
- var token = props.token;
27
- var _useState = (0, _react.useState)(""),
28
- _useState2 = _slicedToArray(_useState, 2),
29
- value = _useState2[0],
30
- setValue = _useState2[1];
31
- var _useState3 = (0, _react.useState)({
32
- docs: [],
33
- draftIds: []
34
- }),
35
- _useState4 = _slicedToArray(_useState3, 2),
36
- initialData = _useState4[0],
37
- setInitialData = _useState4[1];
38
- function handleSubmit(e) {
39
- if (e) e.preventDefault();
40
- originClient.fetch(value).then(res => {
41
- // Ensure queried docs are registered to the schema
42
- var registeredAndPublishedDocs = res.length ? res.filter(doc => schemaTypes.includes(doc._type)).filter(doc => !doc._id.startsWith("drafts.")) : [];
43
- var initialDraftIds = res.length ? res.filter(doc => doc._id.startsWith("drafts.")).map(doc => doc._id) : [];
44
- setInitialData({
45
- docs: registeredAndPublishedDocs,
46
- draftIds: initialDraftIds
47
- });
48
- }).catch(err => console.error(err));
49
- }
50
-
51
- // Auto-load initial textinput value
52
- (0, _react.useEffect)(() => {
53
- var _initialData$docs;
54
- if (!((_initialData$docs = initialData.docs) !== null && _initialData$docs !== void 0 && _initialData$docs.length) && value) {
55
- handleSubmit();
56
- }
57
- }, []);
58
- return /*#__PURE__*/_react.default.createElement(_ui.Container, {
59
- width: [1, 1, 1, 3],
60
- padding: [0, 0, 0, 5]
61
- }, /*#__PURE__*/_react.default.createElement(_ui.Grid, {
62
- columns: [1, 1, 1, 2],
63
- gap: [1, 1, 1, 4]
64
- }, /*#__PURE__*/_react.default.createElement(_ui.Box, {
65
- padding: [2, 2, 2, 0]
66
- }, /*#__PURE__*/_react.default.createElement(_ui.Card, {
67
- padding: 4,
68
- scheme: "dark",
69
- radius: 3
70
- }, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
71
- space: 4
72
- }, /*#__PURE__*/_react.default.createElement(_ui.Box, null, /*#__PURE__*/_react.default.createElement(_ui.Label, null, "Initial Documents Query")), /*#__PURE__*/_react.default.createElement(_ui.Box, null, /*#__PURE__*/_react.default.createElement(_ui.Text, null, "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__*/_react.default.createElement("form", {
73
- onSubmit: handleSubmit
74
- }, /*#__PURE__*/_react.default.createElement(_ui.Flex, null, /*#__PURE__*/_react.default.createElement(_ui.Box, {
75
- flex: 1,
76
- paddingRight: 2
77
- }, /*#__PURE__*/_react.default.createElement(_ui.TextInput, {
78
- style: {
79
- fontFamily: 'monospace'
80
- },
81
- fontSize: 2
82
- // eslint-disable-next-line react/jsx-no-bind
83
- ,
84
- onChange: event => setValue(event.currentTarget.value),
85
- padding: 4,
86
- placeholder: "*[_type == \"article\"]",
87
- value: value !== null && value !== void 0 ? value : ""
88
- })), /*#__PURE__*/_react.default.createElement(_ui.Button, {
89
- padding: 2,
90
- paddingX: 4,
91
- tone: "primary",
92
- onClick: handleSubmit,
93
- text: "Query",
94
- disabled: !value
95
- })))))), !((_initialData$docs2 = initialData.docs) !== null && _initialData$docs2 !== void 0 && _initialData$docs2.length) || initialData.docs.length < 1 && /*#__PURE__*/_react.default.createElement(_ui.Container, {
96
- width: 1
97
- }, /*#__PURE__*/_react.default.createElement(_ui.Card, {
98
- padding: 5
99
- }, value ? "No Documents registered to the Schema match this query" : "Start with a valid GROQ query")), ((_initialData$docs3 = initialData.docs) === null || _initialData$docs3 === void 0 ? void 0 : _initialData$docs3.length) > 0 && /*#__PURE__*/_react.default.createElement(_DuplicatorTool.default, {
100
- docs: initialData.docs,
101
- draftIds: initialData.draftIds,
102
- token: token
103
- })));
104
- }
105
- //# sourceMappingURL=DuplicatorQuery.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DuplicatorQuery.js","names":["originClient","sanityClient","withConfig","clientConfig","schemaTypes","schema","getTypeNames","DuplicatorQuery","props","token","useState","value","setValue","docs","draftIds","initialData","setInitialData","handleSubmit","e","preventDefault","fetch","then","res","registeredAndPublishedDocs","length","filter","doc","includes","_type","_id","startsWith","initialDraftIds","map","catch","err","console","error","useEffect","fontFamily","event","currentTarget"],"sources":["../../src/components/DuplicatorQuery.tsx"],"sourcesContent":["import React, {useEffect, useState} from 'react'\nimport sanityClient from 'part:@sanity/base/client'\nimport schema from 'part:@sanity/base/schema'\nimport {Button, Stack, Box, Label, Text, Card, Flex, Grid, Container, TextInput} from '@sanity/ui'\n\nimport DuplicatorTool from './DuplicatorTool'\nimport {clientConfig} from '../helpers/clientConfig'\n\nconst originClient = sanityClient.withConfig(clientConfig)\n\ntype DuplicatorQueryProps = {\n token: string\n}\n\nconst schemaTypes = schema.getTypeNames()\n\nexport default function DuplicatorQuery(props: DuplicatorQueryProps) {\n const {token} = props\n\n const [value, setValue] = useState(``)\n const [initialData, setInitialData] = useState({docs: [], draftIds: []});\n\n function handleSubmit(e?: any) {\n if (e) e.preventDefault()\n\n originClient\n .fetch(value)\n .then((res) => {\n // Ensure queried docs are registered to the schema\n const registeredAndPublishedDocs = res.length\n ? res\n .filter((doc) => schemaTypes.includes(doc._type))\n .filter((doc) => !doc._id.startsWith(`drafts.`))\n : []\n const initialDraftIds = res.length ? res.filter(doc => doc._id.startsWith(`drafts.`)).map(doc => doc._id) : []\n\n setInitialData({docs: registeredAndPublishedDocs, draftIds: initialDraftIds})\n })\n .catch((err) => console.error(err))\n }\n\n // Auto-load initial textinput value\n useEffect(() => {\n if (!initialData.docs?.length && value) {\n handleSubmit()\n }\n }, [])\n\n return (\n <Container width={[1, 1, 1, 3]} padding={[0, 0, 0, 5]}>\n <Grid columns={[1, 1, 1, 2]} gap={[1, 1, 1, 4]}>\n <Box padding={[2, 2, 2, 0]}>\n <Card padding={4} scheme=\"dark\" radius={3}>\n <Stack space={4}>\n <Box>\n <Label>Initial Documents Query</Label>\n </Box>\n <Box>\n <Text>\n Start with a valid GROQ query to load initial documents. The query will need to\n return an Array of Objects. Drafts will be removed from the results.\n </Text>\n </Box>\n <form onSubmit={handleSubmit}>\n <Flex>\n <Box flex={1} paddingRight={2}>\n <TextInput\n style={{fontFamily: 'monospace'}}\n fontSize={2}\n // eslint-disable-next-line react/jsx-no-bind\n onChange={(event) => setValue(event.currentTarget.value)}\n padding={4}\n placeholder={`*[_type == \"article\"]`}\n value={value ?? ``}\n />\n </Box>\n <Button\n padding={2}\n paddingX={4}\n tone=\"primary\"\n onClick={handleSubmit}\n text=\"Query\"\n disabled={!value}\n />\n </Flex>\n </form>\n </Stack>\n </Card>\n </Box>\n {!initialData.docs?.length ||\n (initialData.docs.length < 1 && (\n <Container width={1}>\n <Card padding={5}>\n {value\n ? `No Documents registered to the Schema match this query`\n : `Start with a valid GROQ query`}\n </Card>\n </Container>\n ))}\n {initialData.docs?.length > 0 && <DuplicatorTool docs={initialData.docs} draftIds={initialData.draftIds} token={token} />}\n </Grid>\n </Container>\n )\n}\n"],"mappings":"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"}
@@ -1,503 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = DuplicatorTool;
7
- var _react = _interopRequireWildcard(require("react"));
8
- var _mapLimit = _interopRequireDefault(require("async/mapLimit"));
9
- var _asyncify = _interopRequireDefault(require("async/asyncify"));
10
- var _mutator = require("@sanity/mutator");
11
- var _dset = require("dset");
12
- var _ui = require("@sanity/ui");
13
- var _icons = require("@sanity/icons");
14
- var _client = _interopRequireDefault(require("part:@sanity/base/client"));
15
- var _preview = _interopRequireDefault(require("part:@sanity/base/preview"));
16
- var _schema = _interopRequireDefault(require("part:@sanity/base/schema"));
17
- var _configSanity = _interopRequireDefault(require("config:sanity"));
18
- var _helpers = require("../helpers");
19
- var _getDocumentsInArray = require("../helpers/getDocumentsInArray");
20
- var _SelectButtons = _interopRequireDefault(require("./SelectButtons"));
21
- var _StatusBadge = _interopRequireDefault(require("./StatusBadge"));
22
- var _Feedback = _interopRequireDefault(require("./Feedback"));
23
- var _clientConfig = require("../helpers/clientConfig");
24
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
25
- 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); }
26
- 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; }
27
- 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); } }
28
- 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); }); }; }
29
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
30
- 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."); }
31
- 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); }
32
- 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; }
33
- 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; }
34
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
35
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
36
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
37
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
38
- function DuplicatorTool(props) {
39
- var _config$__experimenta, _destination$title, _spacesOptions$find, _message$tone;
40
- var docs = props.docs,
41
- draftIds = props.draftIds,
42
- token = props.token;
43
-
44
- // Prepare origin (this Studio) client
45
- // In function-scope so it is up to date on every render
46
- var originClient = _client.default.withConfig(_clientConfig.clientConfig);
47
-
48
- // Create list of dataset options
49
- // and set initial value of dropdown
50
- var spacesOptions = _configSanity.default !== null && _configSanity.default !== void 0 && (_config$__experimenta = _configSanity.default.__experimental_spaces) !== null && _config$__experimenta !== void 0 && _config$__experimenta.length ? _configSanity.default.__experimental_spaces.map(space => _objectSpread(_objectSpread({}, space), {}, {
51
- api: _objectSpread(_objectSpread({}, space.api), {}, {
52
- projectId: space.api.projectId || process.env.SANITY_STUDIO_API_PROJECT_ID
53
- }),
54
- usingEnvForProjectId: !space.api.projectId && process.env.SANITY_STUDIO_API_PROJECT_ID,
55
- disabled: space.api.dataset === originClient.config().dataset && space.api.projectId === originClient.config().projectId
56
- })) : [];
57
- var _useState = (0, _react.useState)(spacesOptions.length ? spacesOptions.find(space => !space.disabled) : {}),
58
- _useState2 = _slicedToArray(_useState, 2),
59
- destination = _useState2[0],
60
- setDestination = _useState2[1];
61
- var _useState3 = (0, _react.useState)({}),
62
- _useState4 = _slicedToArray(_useState3, 2),
63
- message = _useState4[0],
64
- setMessage = _useState4[1];
65
- var _useState5 = (0, _react.useState)(docs.length ? docs.map(item => ({
66
- doc: item,
67
- include: true,
68
- status: null,
69
- hasDraft: draftIds !== null && draftIds !== void 0 && draftIds.length ? draftIds.includes("drafts.".concat(item._id)) : false
70
- })) : []),
71
- _useState6 = _slicedToArray(_useState5, 2),
72
- payload = _useState6[0],
73
- setPayload = _useState6[1];
74
- var _useState7 = (0, _react.useState)(false),
75
- _useState8 = _slicedToArray(_useState7, 2),
76
- hasReferences = _useState8[0],
77
- setHasReferences = _useState8[1];
78
- var _useState9 = (0, _react.useState)(false),
79
- _useState10 = _slicedToArray(_useState9, 2),
80
- isDuplicating = _useState10[0],
81
- setIsDuplicating = _useState10[1];
82
- var _useState11 = (0, _react.useState)(false),
83
- _useState12 = _slicedToArray(_useState11, 2),
84
- isGathering = _useState12[0],
85
- setIsGathering = _useState12[1];
86
- var _useState13 = (0, _react.useState)([0, 0]),
87
- _useState14 = _slicedToArray(_useState13, 2),
88
- progress = _useState14[0],
89
- setProgress = _useState14[1];
90
-
91
- // Check for References and update message
92
- (0, _react.useEffect)(() => {
93
- var expr = ".._ref";
94
- var initialRefs = [];
95
- var initialPayload = [];
96
- docs.forEach(doc => {
97
- initialRefs.push(...(0, _mutator.extract)(expr, doc));
98
- initialPayload.push({
99
- include: true,
100
- doc
101
- });
102
- });
103
- setPayload(initialPayload);
104
- var docCount = docs.length;
105
- var refsCount = initialRefs.length;
106
- if (initialRefs.length) {
107
- setHasReferences(true);
108
- setMessage({
109
- tone: "caution",
110
- text: (0, _helpers.createInitialMessage)(docCount, refsCount)
111
- });
112
- }
113
- }, [docs]);
114
-
115
- // Re-check payload on destination when value changes
116
- // (On initial render + select change)
117
- (0, _react.useEffect)(() => {
118
- updatePayloadStatuses();
119
- }, [destination, docs]);
120
-
121
- // Check if payload documents exist at destination
122
- function updatePayloadStatuses() {
123
- return _updatePayloadStatuses.apply(this, arguments);
124
- }
125
- function _updatePayloadStatuses() {
126
- _updatePayloadStatuses = _asyncToGenerator(function* () {
127
- var newPayload = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
128
- var payloadActual = newPayload.length ? newPayload : payload;
129
- if (!payloadActual.length || !(destination !== null && destination !== void 0 && destination.name)) {
130
- return;
131
- }
132
- var payloadIds = payloadActual.map(_ref3 => {
133
- var doc = _ref3.doc;
134
- return doc._id;
135
- });
136
- var destinationClient = _client.default.withConfig(_objectSpread(_objectSpread({}, _clientConfig.clientConfig), {}, {
137
- dataset: destination.api.dataset,
138
- projectId: destination.api.projectId
139
- }));
140
- var destinationData = yield destinationClient.fetch("*[_id in $payloadIds]{ _id, _updatedAt }", {
141
- payloadIds
142
- });
143
- var updatedPayload = payloadActual.map(item => {
144
- var _item$doc;
145
- var existingDoc = destinationData.find(doc => doc._id === item.doc._id);
146
- if (existingDoc !== null && existingDoc !== void 0 && existingDoc._updatedAt && item !== null && item !== void 0 && (_item$doc = item.doc) !== null && _item$doc !== void 0 && _item$doc._updatedAt) {
147
- if (existingDoc._updatedAt === item.doc._updatedAt) {
148
- // Exact same document exists at destination
149
- // We don't compare by _rev because that is updated in a transaction
150
- item.status = "EXISTS";
151
- } else if (existingDoc._updatedAt && item.doc._updatedAt) {
152
- item.status = new Date(existingDoc._updatedAt) > new Date(item.doc._updatedAt) ? // Document at destination is newer
153
- "OVERWRITE" : // Document at destination is older
154
- "UPDATE";
155
- }
156
- } else {
157
- item.status = 'CREATE';
158
- }
159
- return item;
160
- });
161
- setPayload(updatedPayload);
162
- });
163
- return _updatePayloadStatuses.apply(this, arguments);
164
- }
165
- function handleCheckbox(_id) {
166
- var updatedPayload = payload.map(item => {
167
- if (item.doc._id === _id) {
168
- item.include = !item.include;
169
- }
170
- return item;
171
- });
172
- setPayload(updatedPayload);
173
- }
174
-
175
- // Find and recursively follow references beginning with this document
176
- function handleReferences() {
177
- return _handleReferences.apply(this, arguments);
178
- } // Duplicate payload to destination dataset
179
- function _handleReferences() {
180
- _handleReferences = _asyncToGenerator(function* () {
181
- setIsGathering(true);
182
- var docIds = docs.map(doc => doc._id);
183
- var payloadDocs = yield (0, _getDocumentsInArray.getDocumentsInArray)(docIds, originClient, null);
184
- var draftDocs = yield (0, _getDocumentsInArray.getDocumentsInArray)(docIds.map(id => "drafts.".concat(id)), originClient, null, "{_id}");
185
- var draftDocsIds = new Set(draftDocs.map(_ref4 => {
186
- var _id = _ref4._id;
187
- return _id;
188
- }));
189
-
190
- // Shape it up
191
- var payloadShaped = payloadDocs.map(doc => ({
192
- doc,
193
- // Include this in the transaction?
194
- include: true,
195
- // Does it exist at the destination?
196
- status: '',
197
- // Does it have any drafts?
198
- hasDraft: draftDocsIds.has("drafts.".concat(doc._id))
199
- }));
200
- setPayload(payloadShaped);
201
- updatePayloadStatuses(payloadShaped);
202
- setIsGathering(false);
203
- });
204
- return _handleReferences.apply(this, arguments);
205
- }
206
- function handleDuplicate() {
207
- return _handleDuplicate.apply(this, arguments);
208
- }
209
- function _handleDuplicate() {
210
- _handleDuplicate = _asyncToGenerator(function* () {
211
- setIsDuplicating(true);
212
- var assetsCount = payload.filter(_ref5 => {
213
- var doc = _ref5.doc,
214
- include = _ref5.include;
215
- return include && (0, _helpers.typeIsAsset)(doc._type);
216
- }).length;
217
- var currentProgress = 0;
218
- setProgress([currentProgress, assetsCount]);
219
- setMessage({
220
- text: 'Duplicating...'
221
- });
222
- var destinationClient = _client.default.withConfig(_objectSpread(_objectSpread({}, _clientConfig.clientConfig), {}, {
223
- dataset: destination.api.dataset,
224
- projectId: destination.api.projectId
225
- }));
226
- var transactionDocs = [];
227
- var svgMaps = [];
228
-
229
- // Upload assets and then add to transaction
230
- function fetchDoc(_x) {
231
- return _fetchDoc.apply(this, arguments);
232
- } // Promises are limited to three at once
233
- function _fetchDoc() {
234
- _fetchDoc = _asyncToGenerator(function* (doc) {
235
- if ((0, _helpers.typeIsAsset)(doc._type)) {
236
- // Download and upload asset
237
- // Get the *original* image with this dlRaw param to create the same determenistic _id
238
- var uploadType = doc._type.split('.').pop().replace('Asset', '');
239
- var downloadUrl = uploadType === 'image' ? "".concat(doc.url, "?dlRaw=true") : doc.url;
240
- var downloadConfig = uploadType === 'image' ? {
241
- headers: {
242
- Authorization: "Bearer ".concat(token)
243
- }
244
- } : {};
245
- yield fetch(downloadUrl, downloadConfig).then( /*#__PURE__*/function () {
246
- var _ref6 = _asyncToGenerator(function* (res) {
247
- var assetData = yield res.blob();
248
- var options = {
249
- filename: doc.originalFilename
250
- };
251
- var assetDoc = yield destinationClient.assets.upload(uploadType, assetData, options);
252
-
253
- // SVG _id's need remapping before transaction
254
- if ((doc === null || doc === void 0 ? void 0 : doc.extension) === 'svg') {
255
- svgMaps.push({
256
- old: doc._id,
257
- new: assetDoc._id
258
- });
259
- }
260
- transactionDocs.push(assetDoc);
261
- });
262
- return function (_x2) {
263
- return _ref6.apply(this, arguments);
264
- };
265
- }());
266
- currentProgress += 1;
267
- setMessage({
268
- text: "Duplicating ".concat(currentProgress, "/").concat(assetsCount, " ").concat(assetsCount === 1 ? "Assets" : "Assets")
269
- });
270
- return setProgress([currentProgress, assetsCount]);
271
- }
272
- return transactionDocs.push(doc);
273
- });
274
- return _fetchDoc.apply(this, arguments);
275
- }
276
- var result = new Promise((resolve, reject) => {
277
- var payloadIncludedDocs = payload.filter(item => item.include).map(item => item.doc);
278
- (0, _mapLimit.default)(payloadIncludedDocs, 3, (0, _asyncify.default)(fetchDoc), err => {
279
- if (err) {
280
- setIsDuplicating(false);
281
- setMessage({
282
- tone: 'critical',
283
- text: "Duplication Failed"
284
- });
285
- console.error(err);
286
- reject(new Error('Duplication Failed'));
287
- }
288
- resolve();
289
- });
290
- });
291
- yield result;
292
-
293
- // Remap SVG references to new _id's
294
- var transactionDocsMapped = transactionDocs.map(doc => {
295
- var expr = ".._ref";
296
- var references = (0, _mutator.extractWithPath)(expr, doc);
297
- if (!references.length) {
298
- return doc;
299
- }
300
-
301
- // For every found _ref, search for an SVG asset _id and update
302
- references.forEach(ref => {
303
- var _svgMaps$find;
304
- var newRefValue = (_svgMaps$find = svgMaps.find(asset => asset.old === ref.value)) === null || _svgMaps$find === void 0 ? void 0 : _svgMaps$find.new;
305
- if (newRefValue) {
306
- var refPath = ref.path.join('.');
307
- (0, _dset.dset)(doc, refPath, newRefValue);
308
- }
309
- });
310
- return doc;
311
- });
312
-
313
- // Create transaction
314
- var transaction = destinationClient.transaction();
315
- transactionDocsMapped.forEach(doc => {
316
- transaction.createOrReplace(doc);
317
- });
318
- yield transaction.commit().then(res => {
319
- setMessage({
320
- tone: 'positive',
321
- text: 'Duplication complete!'
322
- });
323
- updatePayloadStatuses();
324
- }).catch(err => {
325
- setMessage({
326
- tone: 'critical',
327
- text: err.details.description
328
- });
329
- });
330
- setIsDuplicating(false);
331
- setProgress(0);
332
- });
333
- return _handleDuplicate.apply(this, arguments);
334
- }
335
- function handleChange(e) {
336
- setDestination(spacesOptions.find(space => space.name === e.currentTarget.value));
337
- }
338
- if (!spacesOptions.length) {
339
- return /*#__PURE__*/_react.default.createElement(_Feedback.default, {
340
- tone: "critical"
341
- }, /*#__PURE__*/_react.default.createElement("code", null, "__experimental_spaces"), " not found in ", /*#__PURE__*/_react.default.createElement("code", null, "sanity.json"));
342
- }
343
- var payloadCount = payload.length;
344
- var firstSvgIndex = payload.findIndex(_ref => {
345
- var doc = _ref.doc;
346
- return doc.extension === 'svg';
347
- });
348
- var selectedDocumentsCount = payload.filter(item => item.include && !(0, _helpers.typeIsAsset)(item.doc._type)).length;
349
- var selectedAssetsCount = payload.filter(item => item.include && (0, _helpers.typeIsAsset)(item.doc._type)).length;
350
- var selectedTotal = selectedDocumentsCount + selectedAssetsCount;
351
- var destinationTitle = (_destination$title = destination === null || destination === void 0 ? void 0 : destination.title) !== null && _destination$title !== void 0 ? _destination$title : destination === null || destination === void 0 ? void 0 : destination.name;
352
- var hasMultipleProjectIds = new Set(spacesOptions.map(space => {
353
- var _space$api;
354
- return space === null || space === void 0 ? void 0 : (_space$api = space.api) === null || _space$api === void 0 ? void 0 : _space$api.projectId;
355
- }).filter(Boolean)).size > 1;
356
- var headingText = [selectedTotal, "/", payloadCount, "Documents and Assets selected"].join(" ");
357
- var buttonText = _react.default.useMemo(() => {
358
- var text = ["Duplicate"];
359
- if (selectedDocumentsCount > 1) {
360
- text.push(selectedDocumentsCount, selectedDocumentsCount === 1 ? "Document" : "Documents");
361
- }
362
- if (selectedAssetsCount > 1) {
363
- text.push("and", selectedAssetsCount, selectedAssetsCount === 1 ? "Asset" : "Assets");
364
- }
365
- if (originClient.config().projectId !== destination.api.projectId) {
366
- text.push("between Projects");
367
- }
368
- text.push("to", destinationTitle);
369
- return text.join(" ");
370
- }, [selectedDocumentsCount, selectedAssetsCount, destinationTitle]);
371
- return /*#__PURE__*/_react.default.createElement(_ui.Container, {
372
- width: 1
373
- }, /*#__PURE__*/_react.default.createElement(_ui.Card, null, /*#__PURE__*/_react.default.createElement(_ui.Stack, null, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.Card, {
374
- borderBottom: true,
375
- padding: 4,
376
- style: _helpers.stickyStyles
377
- }, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
378
- space: 4
379
- }, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
380
- space: 3
381
- }, /*#__PURE__*/_react.default.createElement(_ui.Stack, {
382
- style: {
383
- flex: 1
384
- },
385
- space: 3
386
- }, /*#__PURE__*/_react.default.createElement(_ui.Label, null, "Duplicate from"), /*#__PURE__*/_react.default.createElement(_ui.Select, {
387
- readOnly: true,
388
- value: (_spacesOptions$find = spacesOptions.find(space => space.disabled)) === null || _spacesOptions$find === void 0 ? void 0 : _spacesOptions$find.name
389
- }, spacesOptions.filter(space => space.disabled).map(space => {
390
- var _space$title;
391
- return /*#__PURE__*/_react.default.createElement("option", {
392
- key: space.name,
393
- value: space.name,
394
- disabled: space.disabled
395
- }, (_space$title = space.title) !== null && _space$title !== void 0 ? _space$title : space.name, hasMultipleProjectIds || space.usingEnvForProjectId ? " (".concat(space.api.projectId, ")") : "");
396
- }))), /*#__PURE__*/_react.default.createElement(_ui.Box, {
397
- padding: 4,
398
- paddingTop: 5,
399
- paddingBottom: 0
400
- }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
401
- size: 3
402
- }, /*#__PURE__*/_react.default.createElement(_icons.ArrowRightIcon, null))), /*#__PURE__*/_react.default.createElement(_ui.Stack, {
403
- style: {
404
- flex: 1
405
- },
406
- space: 3
407
- }, /*#__PURE__*/_react.default.createElement(_ui.Label, null, "To Destination"), /*#__PURE__*/_react.default.createElement(_ui.Select, {
408
- onChange: handleChange
409
- }, spacesOptions.map(space => {
410
- var _space$title2;
411
- return /*#__PURE__*/_react.default.createElement("option", {
412
- key: space.name,
413
- value: space.name,
414
- disabled: space.disabled
415
- }, (_space$title2 = space.title) !== null && _space$title2 !== void 0 ? _space$title2 : space.name, hasMultipleProjectIds || space.usingEnvForProjectId ? " (".concat(space.api.projectId, ")") : "", space.disabled ? " (Current)" : "");
416
- })))), isDuplicating && /*#__PURE__*/_react.default.createElement(_ui.Card, {
417
- border: true,
418
- radius: 2
419
- }, /*#__PURE__*/_react.default.createElement(_ui.Card, {
420
- style: {
421
- width: '100%',
422
- transform: "scaleX(".concat(progress[0] / progress[1], ")"),
423
- transformOrigin: 'left',
424
- transition: 'transform .2s ease',
425
- boxSizing: 'border-box'
426
- },
427
- padding: 1,
428
- tone: "positive"
429
- })), payload.length > 0 && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_ui.Label, null, headingText), /*#__PURE__*/_react.default.createElement(_SelectButtons.default, {
430
- payload: payload,
431
- setPayload: setPayload
432
- })))), (message === null || message === void 0 ? void 0 : message.text) && /*#__PURE__*/_react.default.createElement(_ui.Box, {
433
- paddingX: 4,
434
- paddingTop: 4
435
- }, /*#__PURE__*/_react.default.createElement(_ui.Card, {
436
- padding: 3,
437
- radius: 2,
438
- shadow: 1,
439
- tone: (_message$tone = message === null || message === void 0 ? void 0 : message.tone) !== null && _message$tone !== void 0 ? _message$tone : 'transparent'
440
- }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
441
- size: 1
442
- }, message.text))), payload.length > 0 && /*#__PURE__*/_react.default.createElement(_ui.Stack, {
443
- padding: 4,
444
- space: 3
445
- }, payload.map((_ref2, index) => {
446
- var doc = _ref2.doc,
447
- include = _ref2.include,
448
- status = _ref2.status,
449
- hasDraft = _ref2.hasDraft;
450
- return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, {
451
- key: doc._id
452
- }, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
453
- align: "center"
454
- }, /*#__PURE__*/_react.default.createElement(_ui.Checkbox, {
455
- checked: include,
456
- onChange: () => handleCheckbox(doc._id)
457
- }), /*#__PURE__*/_react.default.createElement(_ui.Box, {
458
- flex: 1,
459
- paddingX: 3
460
- }, /*#__PURE__*/_react.default.createElement(_preview.default, {
461
- value: doc,
462
- type: _schema.default.get(doc._type)
463
- })), /*#__PURE__*/_react.default.createElement(_ui.Flex, {
464
- items: "center",
465
- gap: 2
466
- }, hasDraft ? /*#__PURE__*/_react.default.createElement(_StatusBadge.default, {
467
- status: "UNPUBLISHED",
468
- isAsset: false
469
- }) : null, /*#__PURE__*/_react.default.createElement(_StatusBadge.default, {
470
- status: status,
471
- isAsset: (0, _helpers.typeIsAsset)(doc._type)
472
- }))), (doc === null || doc === void 0 ? void 0 : doc.extension) === 'svg' && index === firstSvgIndex && /*#__PURE__*/_react.default.createElement(_ui.Card, {
473
- padding: 3,
474
- radius: 2,
475
- shadow: 1,
476
- tone: "caution"
477
- }, /*#__PURE__*/_react.default.createElement(_ui.Text, {
478
- size: 1
479
- }, "Due to how SVGs are sanitized after first uploaded, duplicated SVG assets may have new ", /*#__PURE__*/_react.default.createElement("code", null, "_id"), "'s at the destination. The newly generated", ' ', /*#__PURE__*/_react.default.createElement("code", null, "_id"), " will be the same in each duplication, but it will never be the same ", /*#__PURE__*/_react.default.createElement("code", null, "_id"), " as the first time this Asset was uploaded. References to the asset will be updated to use the new ", /*#__PURE__*/_react.default.createElement("code", null, "_id"), ".")));
480
- })), /*#__PURE__*/_react.default.createElement(_ui.Stack, {
481
- space: 2,
482
- padding: 4,
483
- paddingTop: 0
484
- }, hasReferences && /*#__PURE__*/_react.default.createElement(_ui.Button, {
485
- fontSize: 2,
486
- padding: 4,
487
- tone: "positive",
488
- mode: "ghost",
489
- icon: _icons.SearchIcon,
490
- onClick: handleReferences,
491
- text: "Gather References",
492
- disabled: isDuplicating || !selectedTotal || isGathering
493
- }), /*#__PURE__*/_react.default.createElement(_ui.Button, {
494
- fontSize: 2,
495
- padding: 4,
496
- tone: "positive",
497
- icon: _icons.LaunchIcon,
498
- onClick: handleDuplicate,
499
- text: buttonText,
500
- disabled: isDuplicating || !selectedTotal || isGathering
501
- }))))));
502
- }
503
- //# sourceMappingURL=DuplicatorTool.js.map