@sanity/cross-dataset-duplicator 0.3.4 → 0.3.6

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.
@@ -4,17 +4,13 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = Feedback;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _ui = require("@sanity/ui");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  function Feedback(props) {
15
11
  var children = props.children,
16
- _props$tone = props.tone,
17
- tone = _props$tone === void 0 ? "caution" : _props$tone;
12
+ _props$tone = props.tone,
13
+ tone = _props$tone === void 0 ? "caution" : _props$tone;
18
14
  return /*#__PURE__*/_react.default.createElement(_ui.Card, {
19
15
  padding: 3,
20
16
  radius: 2,
@@ -1 +1 @@
1
- {"version":3,"file":"Feedback.js","names":["Feedback","props","children","tone"],"sources":["../../src/components/Feedback.tsx"],"sourcesContent":["import React from 'react'\nimport {Card, Text} from '@sanity/ui'\nimport type {BadgeTone} from '@sanity/ui'\n\ntype FeedbackProps = {\n children?: React.ReactNode\n tone?: BadgeTone\n}\n\nexport default function Feedback(props: FeedbackProps) {\n const {children, tone = `caution`} = props\n\n return (\n <Card padding={3} radius={2} shadow={1} tone={tone}>\n <Text size={1}>{children}</Text>\n </Card>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAQe,SAASA,QAAT,CAAkBC,KAAlB,EAAwC;EACrD,IAAOC,QAAP,GAAqCD,KAArC,CAAOC,QAAP;EAAA,kBAAqCD,KAArC,CAAiBE,IAAjB;EAAA,IAAiBA,IAAjB;EAEA,oBACE,6BAAC,QAAD;IAAM,OAAO,EAAE,CAAf;IAAkB,MAAM,EAAE,CAA1B;IAA6B,MAAM,EAAE,CAArC;IAAwC,IAAI,EAAEA;EAA9C,gBACE,6BAAC,QAAD;IAAM,IAAI,EAAE;EAAZ,GAAgBD,QAAhB,CADF,CADF;AAKD"}
1
+ {"version":3,"file":"Feedback.js","names":["Feedback","props","children","tone"],"sources":["../../src/components/Feedback.tsx"],"sourcesContent":["import React from 'react'\nimport {Card, Text} from '@sanity/ui'\nimport type {BadgeTone} from '@sanity/ui'\n\ntype FeedbackProps = {\n children?: React.ReactNode\n tone?: BadgeTone\n}\n\nexport default function Feedback(props: FeedbackProps) {\n const {children, tone = `caution`} = props\n\n return (\n <Card padding={3} radius={2} shadow={1} tone={tone}>\n <Text size={1}>{children}</Text>\n </Card>\n )\n}\n"],"mappings":";;;;;;AAAA;AACA;AAAqC;AAQtB,SAASA,QAAQ,CAACC,KAAoB,EAAE;EACrD,IAAOC,QAAQ,GAAsBD,KAAK,CAAnCC,QAAQ;IAAA,cAAsBD,KAAK,CAAzBE,IAAI;IAAJA,IAAI;EAErB,oBACE,6BAAC,QAAI;IAAC,OAAO,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,IAAI,EAAEA;EAAK,gBACjD,6BAAC,QAAI;IAAC,IAAI,EAAE;EAAE,GAAED,QAAQ,CAAQ,CAC3B;AAEX"}
@@ -4,27 +4,18 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ResetSecret;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _ui = require("@sanity/ui");
11
-
12
9
  var _client = _interopRequireDefault(require("part:@sanity/base/client"));
13
-
14
10
  var _clientConfig = require("../helpers/clientConfig");
15
-
16
11
  var _constants = require("../helpers/constants");
17
-
18
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
19
-
20
13
  var client = _client.default.withConfig(_clientConfig.clientConfig);
21
-
22
14
  function handleClick() {
23
15
  client.delete({
24
16
  query: "*[_id == \"secrets.".concat(_constants.SECRET_NAMESPACE, "\"]")
25
17
  });
26
18
  }
27
-
28
19
  function ResetSecret() {
29
20
  return /*#__PURE__*/_react.default.createElement(_ui.Flex, {
30
21
  align: "center",
@@ -1 +1 @@
1
- {"version":3,"file":"ResetSecret.js","names":["client","sanityClient","withConfig","clientConfig","handleClick","delete","query","SECRET_NAMESPACE","ResetSecret"],"sources":["../../src/components/ResetSecret.tsx"],"sourcesContent":["import React from 'react'\nimport {Button, Flex} from '@sanity/ui'\nimport sanityClient from 'part:@sanity/base/client'\n\nimport { clientConfig } from '../helpers/clientConfig'\nimport { SECRET_NAMESPACE } from '../helpers/constants'\n\nconst client = sanityClient.withConfig(clientConfig)\n\nfunction handleClick() {\n client.delete({query: `*[_id == \"secrets.${SECRET_NAMESPACE}\"]`})\n}\n\nexport default function ResetSecret() {\n return (\n <Flex align=\"center\" justify=\"flex-end\" paddingX={[2, 2, 2, 5]} paddingY={5}>\n <Button\n text=\"Reset Secret\"\n onClick={() => handleClick()}\n mode=\"ghost\"\n tone=\"critical\"\n fontSize={1}\n padding={2}\n />\n </Flex>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;AAEA;;AACA;;;;AAEA,IAAMA,MAAM,GAAGC,eAAA,CAAaC,UAAb,CAAwBC,0BAAxB,CAAf;;AAEA,SAASC,WAAT,GAAuB;EACrBJ,MAAM,CAACK,MAAP,CAAc;IAACC,KAAK,+BAAuBC,2BAAvB;EAAN,CAAd;AACD;;AAEc,SAASC,WAAT,GAAuB;EACpC,oBACE,6BAAC,QAAD;IAAM,KAAK,EAAC,QAAZ;IAAqB,OAAO,EAAC,UAA7B;IAAwC,QAAQ,EAAE,CAAC,CAAD,EAAI,CAAJ,EAAO,CAAP,EAAU,CAAV,CAAlD;IAAgE,QAAQ,EAAE;EAA1E,gBACE,6BAAC,UAAD;IACE,IAAI,EAAC,cADP;IAEE,OAAO,EAAE,MAAMJ,WAAW,EAF5B;IAGE,IAAI,EAAC,OAHP;IAIE,IAAI,EAAC,UAJP;IAKE,QAAQ,EAAE,CALZ;IAME,OAAO,EAAE;EANX,EADF,CADF;AAYD"}
1
+ {"version":3,"file":"ResetSecret.js","names":["client","sanityClient","withConfig","clientConfig","handleClick","delete","query","SECRET_NAMESPACE","ResetSecret"],"sources":["../../src/components/ResetSecret.tsx"],"sourcesContent":["import React from 'react'\nimport {Button, Flex} from '@sanity/ui'\nimport sanityClient from 'part:@sanity/base/client'\n\nimport { clientConfig } from '../helpers/clientConfig'\nimport { SECRET_NAMESPACE } from '../helpers/constants'\n\nconst client = sanityClient.withConfig(clientConfig)\n\nfunction handleClick() {\n client.delete({query: `*[_id == \"secrets.${SECRET_NAMESPACE}\"]`})\n}\n\nexport default function ResetSecret() {\n return (\n <Flex align=\"center\" justify=\"flex-end\" paddingX={[2, 2, 2, 5]} paddingY={5}>\n <Button\n text=\"Reset Secret\"\n onClick={() => handleClick()}\n mode=\"ghost\"\n tone=\"critical\"\n fontSize={1}\n padding={2}\n />\n </Flex>\n )\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AAAuD;AAEvD,IAAMA,MAAM,GAAGC,eAAY,CAACC,UAAU,CAACC,0BAAY,CAAC;AAEpD,SAASC,WAAW,GAAG;EACrBJ,MAAM,CAACK,MAAM,CAAC;IAACC,KAAK,+BAAuBC,2BAAgB;EAAI,CAAC,CAAC;AACnE;AAEe,SAASC,WAAW,GAAG;EACpC,oBACE,6BAAC,QAAI;IAAC,KAAK,EAAC,QAAQ;IAAC,OAAO,EAAC,UAAU;IAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAE;IAAC,QAAQ,EAAE;EAAE,gBAC1E,6BAAC,UAAM;IACL,IAAI,EAAC,cAAc;IACnB,OAAO,EAAE,MAAMJ,WAAW,EAAG;IAC7B,IAAI,EAAC,OAAO;IACZ,IAAI,EAAC,UAAU;IACf,QAAQ,EAAE,CAAE;IACZ,OAAO,EAAE;EAAE,EACX,CACG;AAEX"}
@@ -4,89 +4,64 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = SelectButtons;
7
-
8
7
  var _react = _interopRequireWildcard(require("react"));
9
-
10
8
  var _ui = require("@sanity/ui");
11
-
12
9
  var _helpers = require("../helpers");
13
-
14
10
  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
-
16
11
  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; }
17
-
18
12
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
-
20
13
  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."); }
21
-
22
14
  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); }
23
-
24
15
  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; }
25
-
26
16
  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; }
27
-
28
17
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
29
-
30
18
  var buttons = ["All", "None", null, "New", "Existing", "Older", null, "Documents", "Assets"];
31
-
32
19
  function SelectButtons(props) {
33
20
  var payload = props.payload,
34
- setPayload = props.setPayload;
35
-
21
+ setPayload = props.setPayload;
36
22
  var _useState = (0, _react.useState)([]),
37
- _useState2 = _slicedToArray(_useState, 2),
38
- disabledActions = _useState2[0],
39
- setDisabledActions = _useState2[1]; // Set intiial disabled button
40
-
23
+ _useState2 = _slicedToArray(_useState, 2),
24
+ disabledActions = _useState2[0],
25
+ setDisabledActions = _useState2[1];
41
26
 
27
+ // Set intiial disabled button
42
28
  (0, _react.useEffect)(() => {
43
29
  if (!(disabledActions !== null && disabledActions !== void 0 && disabledActions.length) && payload.every(item => item.include)) {
44
30
  setDisabledActions(["ALL"]);
45
31
  }
46
32
  }, []);
47
-
48
33
  function handleSelectButton() {
49
34
  var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
50
35
  if (!action || !payload.length) return;
51
36
  var newPayload = [...payload];
52
-
53
37
  switch (action) {
54
38
  case 'ALL':
55
39
  newPayload.map(item => item.include = true);
56
40
  break;
57
-
58
41
  case 'NONE':
59
42
  newPayload.map(item => item.include = false);
60
43
  break;
61
-
62
44
  case 'NEW':
63
45
  newPayload.map(item => item.include = Boolean(item.status === 'CREATE'));
64
46
  break;
65
-
66
47
  case 'EXISTING':
67
48
  newPayload.map(item => item.include = Boolean(item.status === 'EXISTS'));
68
49
  break;
69
-
70
50
  case 'OLDER':
71
51
  newPayload.map(item => item.include = Boolean(item.status === 'OVERWRITE'));
72
52
  break;
73
-
74
53
  case 'ASSETS':
75
54
  newPayload.map(item => item.include = (0, _helpers.typeIsAsset)(item.doc._type));
76
55
  break;
77
-
78
56
  case 'DOCUMENTS':
79
57
  newPayload.map(item => item.include = !(0, _helpers.typeIsAsset)(item.doc._type));
80
58
  break;
81
-
82
59
  default:
83
60
  break;
84
61
  }
85
-
86
62
  setDisabledActions([action]);
87
63
  setPayload(newPayload);
88
64
  }
89
-
90
65
  return /*#__PURE__*/_react.default.createElement(_ui.Card, {
91
66
  padding: 1,
92
67
  radius: 3,
@@ -1 +1 @@
1
- {"version":3,"file":"SelectButtons.js","names":["buttons","SelectButtons","props","payload","setPayload","useState","disabledActions","setDisabledActions","useEffect","length","every","item","include","handleSelectButton","action","newPayload","map","Boolean","status","typeIsAsset","doc","_type","actionIndex","includes","toUpperCase"],"sources":["../../src/components/SelectButtons.tsx"],"sourcesContent":["import React, {useState, useEffect} from 'react'\nimport {Button, Card, Flex} from '@sanity/ui'\nimport {typeIsAsset} from '../helpers'\nimport {PayloadItem} from '../types'\n\nconst buttons = [`All`, `None`, null, `New`, `Existing`, `Older`, null, `Documents`, `Assets`]\n\ntype SelectButtonsProps = {\n payload: PayloadItem[]\n setPayload: Function\n}\n\nexport default function SelectButtons(props: SelectButtonsProps) {\n const {payload, setPayload} = props\n const [disabledActions, setDisabledActions] = useState([])\n\n // Set intiial disabled button\n useEffect(() => {\n if (!disabledActions?.length && payload.every((item) => item.include)) {\n setDisabledActions([`ALL`])\n }\n }, [])\n\n function handleSelectButton(action = ``) {\n if (!action || !payload.length) return\n\n const newPayload = [...payload]\n\n switch (action) {\n case 'ALL':\n newPayload.map((item) => (item.include = true))\n break\n case 'NONE':\n newPayload.map((item) => (item.include = false))\n break\n case 'NEW':\n newPayload.map((item) => (item.include = Boolean(item.status === 'CREATE')))\n break\n case 'EXISTING':\n newPayload.map((item) => (item.include = Boolean(item.status === 'EXISTS')))\n break\n case 'OLDER':\n newPayload.map((item) => (item.include = Boolean(item.status === 'OVERWRITE')))\n break\n case 'ASSETS':\n newPayload.map((item) => (item.include = typeIsAsset(item.doc._type)))\n break\n case 'DOCUMENTS':\n newPayload.map((item) => (item.include = !typeIsAsset(item.doc._type)))\n break\n default:\n break\n }\n\n setDisabledActions([action])\n setPayload(newPayload)\n }\n\n return (\n <Card padding={1} radius={3} shadow={1}>\n <Flex gap={2}>\n {buttons.map((action, actionIndex) =>\n action ? (\n <Button\n key={action}\n fontSize={1}\n mode=\"bleed\"\n padding={2}\n text={action}\n disabled={disabledActions.includes(action.toUpperCase())}\n onClick={() => handleSelectButton(action.toUpperCase())}\n />\n ) : (\n <Card key={`divider-${actionIndex}`} borderLeft />\n )\n )}\n </Flex>\n </Card>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;AACA;;;;;;;;;;;;;;;;;;AAGA,IAAMA,OAAO,GAAG,gBAAgB,IAAhB,8BAAkD,IAAlD,wBAAhB;;AAOe,SAASC,aAAT,CAAuBC,KAAvB,EAAkD;EAC/D,IAAOC,OAAP,GAA8BD,KAA9B,CAAOC,OAAP;EAAA,IAAgBC,UAAhB,GAA8BF,KAA9B,CAAgBE,UAAhB;;EACA,gBAA8C,IAAAC,eAAA,EAAS,EAAT,CAA9C;EAAA;EAAA,IAAOC,eAAP;EAAA,IAAwBC,kBAAxB,iBAF+D,CAI/D;;;EACA,IAAAC,gBAAA,EAAU,MAAM;IACd,IAAI,EAACF,eAAD,aAACA,eAAD,eAACA,eAAe,CAAEG,MAAlB,KAA4BN,OAAO,CAACO,KAAR,CAAeC,IAAD,IAAUA,IAAI,CAACC,OAA7B,CAAhC,EAAuE;MACrEL,kBAAkB,CAAC,OAAD,CAAlB;IACD;EACF,CAJD,EAIG,EAJH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D;;EAED,oBACE,6BAAC,QAAD;IAAM,OAAO,EAAE,CAAf;IAAkB,MAAM,EAAE,CAA1B;IAA6B,MAAM,EAAE;EAArC,gBACE,6BAAC,QAAD;IAAM,GAAG,EAAE;EAAX,GACGf,OAAO,CAACgB,GAAR,CAAY,CAACF,MAAD,EAASQ,WAAT,KACXR,MAAM,gBACJ,6BAAC,UAAD;IACE,GAAG,EAAEA,MADP;IAEE,QAAQ,EAAE,CAFZ;IAGE,IAAI,EAAC,OAHP;IAIE,OAAO,EAAE,CAJX;IAKE,IAAI,EAAEA,MALR;IAME,QAAQ,EAAER,eAAe,CAACiB,QAAhB,CAAyBT,MAAM,CAACU,WAAP,EAAzB,CANZ;IAOE,OAAO,EAAE,MAAMX,kBAAkB,CAACC,MAAM,CAACU,WAAP,EAAD;EAPnC,EADI,gBAWJ,6BAAC,QAAD;IAAM,GAAG,oBAAaF,WAAb,CAAT;IAAqC,UAAU;EAA/C,EAZH,CADH,CADF,CADF;AAqBD"}
1
+ {"version":3,"file":"SelectButtons.js","names":["buttons","SelectButtons","props","payload","setPayload","useState","disabledActions","setDisabledActions","useEffect","length","every","item","include","handleSelectButton","action","newPayload","map","Boolean","status","typeIsAsset","doc","_type","actionIndex","includes","toUpperCase"],"sources":["../../src/components/SelectButtons.tsx"],"sourcesContent":["import React, {useState, useEffect} from 'react'\nimport {Button, Card, Flex} from '@sanity/ui'\nimport {typeIsAsset} from '../helpers'\nimport {PayloadItem} from '../types'\n\nconst buttons = [`All`, `None`, null, `New`, `Existing`, `Older`, null, `Documents`, `Assets`]\n\ntype SelectButtonsProps = {\n payload: PayloadItem[]\n setPayload: Function\n}\n\nexport default function SelectButtons(props: SelectButtonsProps) {\n const {payload, setPayload} = props\n const [disabledActions, setDisabledActions] = useState([])\n\n // Set intiial disabled button\n useEffect(() => {\n if (!disabledActions?.length && payload.every((item) => item.include)) {\n setDisabledActions([`ALL`])\n }\n }, [])\n\n function handleSelectButton(action = ``) {\n if (!action || !payload.length) return\n\n const newPayload = [...payload]\n\n switch (action) {\n case 'ALL':\n newPayload.map((item) => (item.include = true))\n break\n case 'NONE':\n newPayload.map((item) => (item.include = false))\n break\n case 'NEW':\n newPayload.map((item) => (item.include = Boolean(item.status === 'CREATE')))\n break\n case 'EXISTING':\n newPayload.map((item) => (item.include = Boolean(item.status === 'EXISTS')))\n break\n case 'OLDER':\n newPayload.map((item) => (item.include = Boolean(item.status === 'OVERWRITE')))\n break\n case 'ASSETS':\n newPayload.map((item) => (item.include = typeIsAsset(item.doc._type)))\n break\n case 'DOCUMENTS':\n newPayload.map((item) => (item.include = !typeIsAsset(item.doc._type)))\n break\n default:\n break\n }\n\n setDisabledActions([action])\n setPayload(newPayload)\n }\n\n return (\n <Card padding={1} radius={3} shadow={1}>\n <Flex gap={2}>\n {buttons.map((action, actionIndex) =>\n action ? (\n <Button\n key={action}\n fontSize={1}\n mode=\"bleed\"\n padding={2}\n text={action}\n disabled={disabledActions.includes(action.toUpperCase())}\n onClick={() => handleSelectButton(action.toUpperCase())}\n />\n ) : (\n <Card key={`divider-${actionIndex}`} borderLeft />\n )\n )}\n </Flex>\n </Card>\n )\n}\n"],"mappings":";;;;;;AAAA;AACA;AACA;AAAsC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGtC,IAAMA,OAAO,GAAG,gBAAgB,IAAI,8BAA8B,IAAI,wBAAwB;AAO/E,SAASC,aAAa,CAACC,KAAyB,EAAE;EAC/D,IAAOC,OAAO,GAAgBD,KAAK,CAA5BC,OAAO;IAAEC,UAAU,GAAIF,KAAK,CAAnBE,UAAU;EAC1B,gBAA8C,IAAAC,eAAQ,EAAC,EAAE,CAAC;IAAA;IAAnDC,eAAe;IAAEC,kBAAkB;;EAE1C;EACA,IAAAC,gBAAS,EAAC,MAAM;IACd,IAAI,EAACF,eAAe,aAAfA,eAAe,eAAfA,eAAe,CAAEG,MAAM,KAAIN,OAAO,CAACO,KAAK,CAAEC,IAAI,IAAKA,IAAI,CAACC,OAA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E;MACF;QACE;IAAK;IAGTd,kBAAkB,CAAC,CAACO,MAAM,CAAC,CAAC;IAC5BV,UAAU,CAACW,UAAU,CAAC;EACxB;EAEA,oBACE,6BAAC,QAAI;IAAC,OAAO,EAAE,CAAE;IAAC,MAAM,EAAE,CAAE;IAAC,MAAM,EAAE;EAAE,gBACrC,6BAAC,QAAI;IAAC,GAAG,EAAE;EAAE,GACVf,OAAO,CAACgB,GAAG,CAAC,CAACF,MAAM,EAAEQ,WAAW,KAC/BR,MAAM,gBACJ,6BAAC,UAAM;IACL,GAAG,EAAEA,MAAO;IACZ,QAAQ,EAAE,CAAE;IACZ,IAAI,EAAC,OAAO;IACZ,OAAO,EAAE,CAAE;IACX,IAAI,EAAEA,MAAO;IACb,QAAQ,EAAER,eAAe,CAACiB,QAAQ,CAACT,MAAM,CAACU,WAAW,EAAE,CAAE;IACzD,OAAO,EAAE,MAAMX,kBAAkB,CAACC,MAAM,CAACU,WAAW,EAAE;EAAE,EACxD,gBAEF,6BAAC,QAAI;IAAC,GAAG,oBAAaF,WAAW,CAAG;IAAC,UAAU;EAAA,EAChD,CACF,CACI,CACF;AAEX"}
@@ -4,13 +4,9 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = StatusBadge;
7
-
8
7
  var _react = _interopRequireDefault(require("react"));
9
-
10
8
  var _ui = require("@sanity/ui");
11
-
12
9
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
-
14
10
  var documentTones = {
15
11
  EXISTS: "primary",
16
12
  OVERWRITE: "critical",
@@ -52,12 +48,10 @@ var assetStatus = {
52
48
  CREATE: "UPLOAD",
53
49
  UNPUBLISHED: ""
54
50
  };
55
-
56
51
  function StatusBadge(props) {
57
52
  var status = props.status,
58
- isAsset = props.isAsset;
53
+ isAsset = props.isAsset;
59
54
  var badgeTone = isAsset ? assetTones[status] : documentTones[status];
60
-
61
55
  if (!badgeTone) {
62
56
  return /*#__PURE__*/_react.default.createElement(_ui.Badge, {
63
57
  muted: true,
@@ -66,7 +60,6 @@ function StatusBadge(props) {
66
60
  mode: "outline"
67
61
  }, "Checking...");
68
62
  }
69
-
70
63
  var badgeText = isAsset ? assetMessages[status] : documentMessages[status];
71
64
  var badgeStatus = isAsset ? assetStatus[status] : status;
72
65
  return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
@@ -1 +1 @@
1
- {"version":3,"file":"StatusBadge.js","names":["documentTones","EXISTS","OVERWRITE","UPDATE","CREATE","UNPUBLISHED","assetTones","documentMessages","assetMessages","assetStatus","StatusBadge","props","status","isAsset","badgeTone","badgeText","badgeStatus","maxWidth"],"sources":["../../src/components/StatusBadge.tsx"],"sourcesContent":["import React from 'react'\nimport {Box, Text, Badge, Tooltip} from '@sanity/ui'\nimport type {BadgeTone} from '@sanity/ui'\n\ntype StatusTones = {\n EXISTS: BadgeTone\n OVERWRITE: BadgeTone\n UPDATE: BadgeTone\n CREATE: BadgeTone\n UNPUBLISHED: BadgeTone\n}\n\nconst documentTones: StatusTones = {\n EXISTS: `primary`,\n OVERWRITE: `critical`,\n UPDATE: `caution`,\n CREATE: `positive`,\n UNPUBLISHED: `caution`,\n}\n\nconst assetTones: StatusTones = {\n EXISTS: `critical`,\n OVERWRITE: `critical`,\n UPDATE: `critical`,\n CREATE: `positive`,\n UNPUBLISHED: `default`\n}\n\ntype messageTypes = {\n EXISTS: string\n OVERWRITE: string\n UPDATE: string\n CREATE: string\n UNPUBLISHED: string\n}\n\nconst documentMessages: messageTypes = {\n // Only happens once document is copied the first time, and _updatedAt is the same\n EXISTS: `This document already exists at the Destination with the same ID with the same Updated time.`,\n // Is true immediately after transaction as _updatedAt is updated by API after mutation\n // Is also true if the document at the destination has been manually modified\n // Presently, the plugin doesn't actually compare the two documents\n OVERWRITE: `A newer version of this document exists at the Destination, and it will be overwritten with this version.`,\n // Document at destination is older\n UPDATE: `An older version of this document exists at the Destination, and it will be overwritten with this version.`,\n // Document at destination doesn't exist\n CREATE: `This document will be created at the destination.`,\n UNPUBLISHED: `A Draft version of this Document exists in this Dataset, but only the Published version will be duplicated to the destination.`\n}\n\nconst assetMessages: messageTypes = {\n EXISTS: `This Asset already exists at the Destination`,\n OVERWRITE: `This Asset already exists at the Destination`,\n UPDATE: `This Asset already exists at the Destination`,\n CREATE: `This Asset does not yet exist at the Destination`,\n UNPUBLISHED: ``,\n}\n\nconst assetStatus: messageTypes = {\n EXISTS: `RE-UPLOAD`,\n OVERWRITE: `RE-UPLOAD`,\n UPDATE: `RE-UPLOAD`,\n CREATE: `UPLOAD`,\n UNPUBLISHED: ``,\n}\n\ntype StatusBadgeProps = {\n status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE' | 'UNPUBLISHED' | undefined\n isAsset: boolean\n}\n\nexport default function StatusBadge(props: StatusBadgeProps) {\n const {status, isAsset} = props\n\n const badgeTone = isAsset ? assetTones[status] : documentTones[status]\n \n if (!badgeTone) {\n return (\n <Badge muted padding={2} fontSize={1} mode=\"outline\">\n Checking...\n </Badge>\n )\n }\n \n const badgeText = isAsset ? assetMessages[status] : documentMessages[status]\n const badgeStatus = isAsset ? assetStatus[status] : status\n\n return (\n <Tooltip\n content={\n <Box padding={3} style={{maxWidth: 200}}>\n <Text size={1}>{badgeText}</Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Badge muted padding={2} fontSize={1} tone={badgeTone} mode=\"outline\">\n {badgeStatus}\n </Badge>\n </Tooltip>\n )\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;AAWA,IAAMA,aAA0B,GAAG;EACjCC,MAAM,WAD2B;EAEjCC,SAAS,YAFwB;EAGjCC,MAAM,WAH2B;EAIjCC,MAAM,YAJ2B;EAKjCC,WAAW;AALsB,CAAnC;AAQA,IAAMC,UAAuB,GAAG;EAC9BL,MAAM,YADwB;EAE9BC,SAAS,YAFqB;EAG9BC,MAAM,YAHwB;EAI9BC,MAAM,YAJwB;EAK9BC,WAA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AgBF,SAAhB,CADF,CAFJ;IAME,kBAAkB,EAAE,CAAC,OAAD,EAAU,MAAV,CANtB;IAOE,SAAS,EAAC,KAPZ;IAQE,MAAM;EARR,gBAUE,6BAAC,SAAD;IAAO,KAAK,MAAZ;IAAa,OAAO,EAAE,CAAtB;IAAyB,QAAQ,EAAE,CAAnC;IAAsC,IAAI,EAAED,SAA5C;IAAuD,IAAI,EAAC;EAA5D,GACGE,WADH,CAVF,CADF;AAgBD"}
1
+ {"version":3,"file":"StatusBadge.js","names":["documentTones","EXISTS","OVERWRITE","UPDATE","CREATE","UNPUBLISHED","assetTones","documentMessages","assetMessages","assetStatus","StatusBadge","props","status","isAsset","badgeTone","badgeText","badgeStatus","maxWidth"],"sources":["../../src/components/StatusBadge.tsx"],"sourcesContent":["import React from 'react'\nimport {Box, Text, Badge, Tooltip} from '@sanity/ui'\nimport type {BadgeTone} from '@sanity/ui'\n\ntype StatusTones = {\n EXISTS: BadgeTone\n OVERWRITE: BadgeTone\n UPDATE: BadgeTone\n CREATE: BadgeTone\n UNPUBLISHED: BadgeTone\n}\n\nconst documentTones: StatusTones = {\n EXISTS: `primary`,\n OVERWRITE: `critical`,\n UPDATE: `caution`,\n CREATE: `positive`,\n UNPUBLISHED: `caution`,\n}\n\nconst assetTones: StatusTones = {\n EXISTS: `critical`,\n OVERWRITE: `critical`,\n UPDATE: `critical`,\n CREATE: `positive`,\n UNPUBLISHED: `default`\n}\n\ntype messageTypes = {\n EXISTS: string\n OVERWRITE: string\n UPDATE: string\n CREATE: string\n UNPUBLISHED: string\n}\n\nconst documentMessages: messageTypes = {\n // Only happens once document is copied the first time, and _updatedAt is the same\n EXISTS: `This document already exists at the Destination with the same ID with the same Updated time.`,\n // Is true immediately after transaction as _updatedAt is updated by API after mutation\n // Is also true if the document at the destination has been manually modified\n // Presently, the plugin doesn't actually compare the two documents\n OVERWRITE: `A newer version of this document exists at the Destination, and it will be overwritten with this version.`,\n // Document at destination is older\n UPDATE: `An older version of this document exists at the Destination, and it will be overwritten with this version.`,\n // Document at destination doesn't exist\n CREATE: `This document will be created at the destination.`,\n UNPUBLISHED: `A Draft version of this Document exists in this Dataset, but only the Published version will be duplicated to the destination.`\n}\n\nconst assetMessages: messageTypes = {\n EXISTS: `This Asset already exists at the Destination`,\n OVERWRITE: `This Asset already exists at the Destination`,\n UPDATE: `This Asset already exists at the Destination`,\n CREATE: `This Asset does not yet exist at the Destination`,\n UNPUBLISHED: ``,\n}\n\nconst assetStatus: messageTypes = {\n EXISTS: `RE-UPLOAD`,\n OVERWRITE: `RE-UPLOAD`,\n UPDATE: `RE-UPLOAD`,\n CREATE: `UPLOAD`,\n UNPUBLISHED: ``,\n}\n\ntype StatusBadgeProps = {\n status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE' | 'UNPUBLISHED' | undefined\n isAsset: boolean\n}\n\nexport default function StatusBadge(props: StatusBadgeProps) {\n const {status, isAsset} = props\n\n const badgeTone = isAsset ? assetTones[status] : documentTones[status]\n \n if (!badgeTone) {\n return (\n <Badge muted padding={2} fontSize={1} mode=\"outline\">\n Checking...\n </Badge>\n )\n }\n \n const badgeText = isAsset ? assetMessages[status] : documentMessages[status]\n const badgeStatus = isAsset ? assetStatus[status] : status\n\n return (\n <Tooltip\n content={\n <Box padding={3} style={{maxWidth: 200}}>\n <Text size={1}>{badgeText}</Text>\n </Box>\n }\n fallbackPlacements={['right', 'left']}\n placement=\"top\"\n portal\n >\n <Badge muted padding={2} fontSize={1} tone={badgeTone} mode=\"outline\">\n {badgeStatus}\n </Badge>\n </Tooltip>\n )\n}\n"],"mappings":";;;;;;AAAA;AACA;AAAoD;AAWpD,IAAMA,aAA0B,GAAG;EACjCC,MAAM,WAAW;EACjBC,SAAS,YAAY;EACrBC,MAAM,WAAW;EACjBC,MAAM,YAAY;EAClBC,WAAW;AACb,CAAC;AAED,IAAMC,UAAuB,GAAG;EAC9BL,MAAM,YAAY;EAClBC,SAAS,YAAY;EACrBC,MAAM,YAAY;EACl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,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,CAAE;IACtC,SAAS,EAAC,KAAK;IACf,MAAM;EAAA,gBAEN,6BAAC,SAAK;IAAC,KAAK;IAAC,OAAO,EAAE,CAAE;IAAC,QAAQ,EAAE,CAAE;IAAC,IAAI,EAAED,SAAU;IAAC,IAAI,EAAC;EAAS,GAClEE,WAAW,CACN,CACA;AAEd"}
@@ -1 +1 @@
1
- {"version":3,"file":"clientConfig.js","names":["clientConfig","apiVersion"],"sources":["../../src/helpers/clientConfig.ts"],"sourcesContent":["export const clientConfig = {apiVersion: `2021-05-19`}"],"mappings":";;;;;;AAAO,IAAMA,YAAY,GAAG;EAACC,UAAU;AAAX,CAArB"}
1
+ {"version":3,"file":"clientConfig.js","names":["clientConfig","apiVersion"],"sources":["../../src/helpers/clientConfig.ts"],"sourcesContent":["export const clientConfig = {apiVersion: `2021-05-19`}"],"mappings":";;;;;;AAAO,IAAMA,YAAY,GAAG;EAACC,UAAU;AAAc,CAAC;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","names":["SECRET_NAMESPACE"],"sources":["../../src/helpers/constants.ts"],"sourcesContent":["export const SECRET_NAMESPACE = `CrossDatasetDuplicator`"],"mappings":";;;;;;AAAO,IAAMA,gBAAgB,2BAAtB"}
1
+ {"version":3,"file":"constants.js","names":["SECRET_NAMESPACE"],"sources":["../../src/helpers/constants.ts"],"sourcesContent":["export const SECRET_NAMESPACE = `CrossDatasetDuplicator`"],"mappings":";;;;;;AAAO,IAAMA,gBAAgB,2BAA2B;AAAA"}
@@ -4,74 +4,67 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getDocumentsInArray = getDocumentsInArray;
7
-
8
7
  var _mutator = require("@sanity/mutator");
9
-
8
+ var _crossDatasetDuplicator = _interopRequireDefault(require("config:@sanity/cross-dataset-duplicator"));
9
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
10
  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); } }
11
-
12
11
  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); }); }; }
13
-
14
12
  // Recursively fetch Documents from an array of _id's and their references
15
13
  // Heavy use of Set is to avoid recursively querying for id's already in the payload
16
14
  function getDocumentsInArray(_x, _x2, _x3, _x4) {
17
15
  return _getDocumentsInArray.apply(this, arguments);
18
16
  }
19
-
20
17
  function _getDocumentsInArray() {
21
18
  _getDocumentsInArray = _asyncToGenerator(function* (fetchIds, client, currentIds, projection) {
22
- var collection = []; // Find initial docs
19
+ var collection = [];
23
20
 
24
- var query = "*[_id in $fetchIds]".concat(projection !== null && projection !== void 0 ? projection : "");
21
+ // Find initial docs
22
+ var filter = ['_id in $fetchIds', _crossDatasetDuplicator.default.filter].filter(Boolean).join(' && ');
23
+ var query = "*[".concat(filter, "]").concat(projection !== null && projection !== void 0 ? projection : "");
25
24
  var data = yield client.fetch(query, {
26
25
  fetchIds: fetchIds !== null && fetchIds !== void 0 ? fetchIds : []
27
26
  });
28
-
29
27
  if (!(data !== null && data !== void 0 && data.length)) {
30
28
  return [];
31
29
  }
30
+ var localCurrentIds = currentIds !== null && currentIds !== void 0 ? currentIds : new Set();
32
31
 
33
- var localCurrentIds = currentIds !== null && currentIds !== void 0 ? currentIds : new Set(); // Find new ids in the returned data
32
+ // Find new ids in the returned data
34
33
  // Unless we started with an empty set, get the _ids from the data
35
-
36
34
  var newDataIds = new Set(data.map(dataDoc => dataDoc._id).filter(id => currentIds !== null && currentIds !== void 0 && currentIds.size ? !localCurrentIds.has(id) : Boolean(id)));
37
-
38
35
  if (newDataIds.size) {
39
36
  collection.push(...data);
40
- localCurrentIds.add(...newDataIds); // Check new data for more references
37
+ localCurrentIds.add(...newDataIds);
41
38
 
39
+ // Check new data for more references
42
40
  yield Promise.all(data.map( /*#__PURE__*/function () {
43
41
  var _ref = _asyncToGenerator(function* (doc) {
44
42
  var expr = ".._ref";
45
43
  var references = (0, _mutator.extract)(expr, doc);
46
-
47
44
  if (references.length) {
48
45
  // Find references not already in the Collection
49
46
  var newReferenceIds = new Set(references.filter(refId => !localCurrentIds.has(refId)));
50
-
51
47
  if (newReferenceIds.size) {
52
48
  // Recusive query for new documents
53
49
  var referenceDocs = yield getDocumentsInArray(Array.from(newReferenceIds), client, localCurrentIds);
54
-
55
50
  if (referenceDocs !== null && referenceDocs !== void 0 && referenceDocs.length) {
56
51
  collection.push(...referenceDocs);
57
52
  }
58
53
  }
59
54
  }
60
55
  });
61
-
62
56
  return function (_x5) {
63
57
  return _ref.apply(this, arguments);
64
58
  };
65
59
  }()));
66
- } // Create a unique array of objects from collection
67
- // Set() wasn't working for unique id's ¯\_(ツ)_/¯
68
-
60
+ }
69
61
 
62
+ // Create a unique array of objects from collection
63
+ // Set() wasn't working for unique id's ¯\_(ツ)_/¯
70
64
  var uniqueCollection = collection.filter(Boolean).reduce((acc, cur) => {
71
65
  if (acc.some(doc => doc._id === cur._id)) {
72
66
  return acc;
73
67
  }
74
-
75
68
  return [...acc, cur];
76
69
  }, []);
77
70
  return uniqueCollection;
@@ -1 +1 @@
1
- {"version":3,"file":"getDocumentsInArray.js","names":["getDocumentsInArray","fetchIds","client","currentIds","projection","collection","query","data","fetch","length","localCurrentIds","Set","newDataIds","map","dataDoc","_id","filter","id","size","has","Boolean","push","add","Promise","all","doc","expr","references","extract","newReferenceIds","refId","referenceDocs","Array","from","uniqueCollection","reduce","acc","cur","some"],"sources":["../../src/helpers/getDocumentsInArray.ts"],"sourcesContent":["import {extract} from '@sanity/mutator'\nimport {SanityDocument} from '../types'\n\n// Recursively fetch Documents from an array of _id's and their references\n// Heavy use of Set is to avoid recursively querying for id's already in the payload\nexport async function getDocumentsInArray(\n fetchIds: string[],\n client: any,\n currentIds?: Set<string>,\n projection?: string,\n) {\n const collection = []\n\n // Find initial docs\n const query = `*[_id in $fetchIds]${projection ?? ``}`\n const data: SanityDocument[] = await client.fetch(query, {\n fetchIds: fetchIds ?? [],\n })\n\n if (!data?.length) {\n return []\n }\n\n const localCurrentIds = currentIds ?? new Set()\n \n // Find new ids in the returned data\n // Unless we started with an empty set, get the _ids from the data\n const newDataIds: Set<string> = new Set(\n data\n .map((dataDoc) => dataDoc._id)\n .filter((id) => (currentIds?.size ? !localCurrentIds.has(id) : Boolean(id)))\n )\n\n if (newDataIds.size) {\n collection.push(...data)\n localCurrentIds.add(...newDataIds)\n\n // Check new data for more references\n await Promise.all(\n data.map(async (doc) => {\n const expr = `.._ref`\n const references = extract(expr, doc)\n\n if (references.length) {\n // Find references not already in the Collection\n const newReferenceIds = new Set(references.filter((refId) => !localCurrentIds.has(refId)))\n\n if (newReferenceIds.size) {\n // Recusive query for new documents\n const referenceDocs = await getDocumentsInArray(\n Array.from(newReferenceIds),\n client,\n localCurrentIds\n )\n\n if (referenceDocs?.length) {\n collection.push(...referenceDocs)\n }\n }\n }\n })\n )\n }\n\n // Create a unique array of objects from collection\n // Set() wasn't working for unique id's ¯\\_(ツ)_/¯\n const uniqueCollection = collection.filter(Boolean).reduce((acc, cur) => {\n if (acc.some((doc) => doc._id === cur._id)) {\n return acc\n }\n\n return [...acc, cur]\n }, []) \n\n return uniqueCollection\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAGA;AACA;SACsBA,mB;;;;;2CAAf,WACLC,QADK,EAELC,MAFK,EAGLC,UAHK,EAILC,UAJK,EAKL;IACA,IAAMC,UAAU,GAAG,EAAnB,CADA,CAGA;;IACA,IAAMC,KAAK,gCAAyBF,UAAzB,aAAyBA,UAAzB,cAAyBA,UAAzB,MAAX;IACA,IAAMG,IAAsB,SAASL,MAAM,CAACM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K,CAACC,IAAN,CAAWJ,eAAX,CAD6C,EAE7C3B,MAF6C,EAG7CQ,eAH6C,CAA/C;;cAMA,IAAIqB,aAAJ,aAAIA,aAAJ,eAAIA,aAAa,CAAEtB,MAAnB,EAA2B;gBACzBJ,UAAU,CAACgB,IAAX,CAAgB,GAAGU,aAAnB;cACD;YACF;UACF;QACF,CArBD;;QAAA;UAAA;QAAA;MAAA,IADI,CAAN;IAwBD,CApDD,CAsDA;IACA;;;IACA,IAAMG,gBAAgB,GAAG7B,UAAU,CAACW,MAAX,CAAkBI,OAAlB,EAA2Be,MAA3B,CAAkC,CAACC,GAAD,EAAMC,GAAN,KAAc;MACvE,IAAID,GAAG,CAACE,IAAJ,CAAUb,GAAD,IAASA,GAAG,CAACV,GAAJ,KAAYsB,GAAG,CAACtB,GAAlC,CAAJ,EAA4C;QAC1C,OAAOqB,GAAP;MACD;;MAED,OAAO,CAAC,GAAGA,GAAJ,EAASC,GAAT,CAAP;IACD,CANwB,EAMtB,EANsB,CAAzB;IAQA,OAAOH,gBAAP;EACD,C"}
1
+ {"version":3,"file":"getDocumentsInArray.js","names":["getDocumentsInArray","fetchIds","client","currentIds","projection","collection","filter","config","Boolean","join","query","data","fetch","length","localCurrentIds","Set","newDataIds","map","dataDoc","_id","id","size","has","push","add","Promise","all","doc","expr","references","extract","newReferenceIds","refId","referenceDocs","Array","from","uniqueCollection","reduce","acc","cur","some"],"sources":["../../src/helpers/getDocumentsInArray.ts"],"sourcesContent":["import { extract } from '@sanity/mutator'\nimport { SanityDocument } from '../types'\n\nimport config from 'config:@sanity/cross-dataset-duplicator'\n\n// Recursively fetch Documents from an array of _id's and their references\n// Heavy use of Set is to avoid recursively querying for id's already in the payload\nexport async function getDocumentsInArray(\n fetchIds: string[],\n client: any,\n currentIds?: Set<string>,\n projection?: string,\n) {\n const collection = []\n\n // Find initial docs\n const filter = ['_id in $fetchIds', config.filter].filter(Boolean).join(' && ')\n const query = `*[${filter}]${projection ?? ``}`\n const data: SanityDocument[] = await client.fetch(query, {\n fetchIds: fetchIds ?? [],\n })\n\n if (!data?.length) {\n return []\n }\n\n const localCurrentIds = currentIds ?? new Set()\n\n // Find new ids in the returned data\n // Unless we started with an empty set, get the _ids from the data\n const newDataIds: Set<string> = new Set(\n data\n .map((dataDoc) => dataDoc._id)\n .filter((id) => (currentIds?.size ? !localCurrentIds.has(id) : Boolean(id)))\n )\n\n if (newDataIds.size) {\n collection.push(...data)\n localCurrentIds.add(...newDataIds)\n\n // Check new data for more references\n await Promise.all(\n data.map(async (doc) => {\n const expr = `.._ref`\n const references = extract(expr, doc)\n\n if (references.length) {\n // Find references not already in the Collection\n const newReferenceIds = new Set(references.filter((refId) => !localCurrentIds.has(refId)))\n\n if (newReferenceIds.size) {\n // Recusive query for new documents\n const referenceDocs = await getDocumentsInArray(\n Array.from(newReferenceIds),\n client,\n localCurrentIds\n )\n\n if (referenceDocs?.length) {\n collection.push(...referenceDocs)\n }\n }\n }\n })\n )\n }\n\n // Create a unique array of objects from collection\n // Set() wasn't working for unique id's ¯\\_(ツ)_/¯\n const uniqueCollection = collection.filter(Boolean).reduce((acc, cur) => {\n if (acc.some((doc) => doc._id === cur._id)) {\n return acc\n }\n\n return [...acc, cur]\n }, [])\n\n return uniqueCollection\n}\n"],"mappings":";;;;;;AAAA;AAGA;AAA4D;AAAA;AAAA;AAE5D;AACA;AAAA,SACsBA,mBAAmB;EAAA;AAAA;AAAA;EAAA,yCAAlC,WACLC,QAAkB,EAClBC,MAAW,EACXC,UAAwB,EACxBC,UAAmB,EACnB;IACA,IAAMC,UAAU,GAAG,EAAE;;IAErB;IACA,IAAMC,MAAM,GAAG,CAAC,kBAAkB,EAAEC,+BAAM,CAACD,MAAM,CAAC,CAACA,MAAM,CAACE,OAAO,CAAC,CAACC,IAAI,CAAC,MAAM,CAAC;IAC/E,IAAMC,KAAK,eAAQJ,MAAM,cAAIF,UAAU,aAAVA,UAAU,cAAVA,UAAU,MAAQ;IAC/C,IAAMO,IAAsB,SA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AAC,EAC3B7B,MAAM,EACNY,eAAe,CAChB;cAED,IAAImB,aAAa,aAAbA,aAAa,eAAbA,aAAa,CAAEpB,MAAM,EAAE;gBACzBR,UAAU,CAACkB,IAAI,CAAC,GAAGU,aAAa,CAAC;cACnC;YACF;UACF;QACF,CAAC;QAAA;UAAA;QAAA;MAAA,IAAC,CACH;IACH;;IAEA;IACA;IACA,IAAMG,gBAAgB,GAAG/B,UAAU,CAACC,MAAM,CAACE,OAAO,CAAC,CAAC6B,MAAM,CAAC,CAACC,GAAG,EAAEC,GAAG,KAAK;MACvE,IAAID,GAAG,CAACE,IAAI,CAAEb,GAAG,IAAKA,GAAG,CAACR,GAAG,KAAKoB,GAAG,CAACpB,GAAG,CAAC,EAAE;QAC1C,OAAOmB,GAAG;MACZ;MAEA,OAAO,CAAC,GAAGA,GAAG,EAAEC,GAAG,CAAC;IACtB,CAAC,EAAE,EAAE,CAAC;IAEN,OAAOH,gBAAgB;EACzB,CAAC;EAAA;AAAA"}
@@ -6,20 +6,17 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.createInitialMessage = createInitialMessage;
7
7
  exports.stickyStyles = void 0;
8
8
  exports.typeIsAsset = typeIsAsset;
9
-
10
9
  function typeIsAsset() {
11
10
  var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
12
11
  if (!type) return false;
13
12
  return ['sanity.imageAsset', 'sanity.fileAsset'].includes(type);
14
13
  }
15
-
16
14
  function createInitialMessage() {
17
15
  var docCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
18
16
  var refsCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
19
17
  var message = [docCount === 1 ? "This Document contains" : "These ".concat(docCount, " Documents contain"), refsCount === 1 ? "1 Reference." : "".concat(refsCount, " References."), refsCount === 1 ? "That Document" : "Those Documents", "may have References too. If referenced Documents do not exist at the target Destination, this transaction will fail."];
20
18
  return message.join(" ");
21
19
  }
22
-
23
20
  var stickyStyles = {
24
21
  position: 'sticky',
25
22
  top: 0,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["typeIsAsset","type","includes","createInitialMessage","docCount","refsCount","message","join","stickyStyles","position","top","zIndex","backgroundColor"],"sources":["../../src/helpers/index.ts"],"sourcesContent":["export function typeIsAsset(type = ``) {\n if (!type) return false\n\n return ['sanity.imageAsset', 'sanity.fileAsset'].includes(type)\n}\n\nexport function createInitialMessage(docCount = 0, refsCount = 0) {\n const message = [\n docCount === 1 ? `This Document contains` : `These ${docCount} Documents contain`,\n refsCount === 1 ? `1 Reference.` : `${refsCount} References.`,\n refsCount === 1 ? `That Document` : `Those Documents`,\n `may have References too. If referenced Documents do not exist at the target Destination, this transaction will fail.`\n ]\n\n return message.join(` `)\n}\n\nexport const stickyStyles = {\n position: 'sticky',\n top: 0,\n zIndex: 100,\n backgroundColor: `rgba(255,255,255,0.95)`,\n}"],"mappings":";;;;;;;;;AAAO,SAASA,WAAT,GAAgC;EAAA,IAAXC,IAAW;EACrC,IAAI,CAACA,IAAL,EAAW,OAAO,KAAP;EAEX,OAAO,CAAC,mBAAD,EAAsB,kBAAtB,EAA0CC,QAA1C,CAAmDD,IAAnD,CAAP;AACD;;AAEM,SAASE,oBAAT,GAA2D;EAAA,IAA7BC,QAA6B,uEAAlB,CAAkB;EAAA,IAAfC,SAAe,uEAAH,CAAG;EAChE,IAAMC,OAAO,GAAG,CACdF,QAAQ,KAAK,CAAb,8CAAqDA,QAArD,uBADc,EAEdC,SAAS,KAAK,CAAd,8BAAsCA,SAAtC,iBAFc,EAGdA,SAAS,KAAK,CAAd,sCAHc,yHAAhB;EAOA,OAAOC,OAAO,CAACC,IAAR,KAAP;AACD;;AAEM,IAAMC,YAAY,GAAG;EAC1BC,QAAQ,EAAE,QADgB;EAE1BC,GAAG,EAAE,CAFqB;EAG1BC,MAAM,EAAE,GAHkB;EAI1BC,eAAe;AAJW,CAArB"}
1
+ {"version":3,"file":"index.js","names":["typeIsAsset","type","includes","createInitialMessage","docCount","refsCount","message","join","stickyStyles","position","top","zIndex","backgroundColor"],"sources":["../../src/helpers/index.ts"],"sourcesContent":["export function typeIsAsset(type = ``) {\n if (!type) return false\n\n return ['sanity.imageAsset', 'sanity.fileAsset'].includes(type)\n}\n\nexport function createInitialMessage(docCount = 0, refsCount = 0) {\n const message = [\n docCount === 1 ? `This Document contains` : `These ${docCount} Documents contain`,\n refsCount === 1 ? `1 Reference.` : `${refsCount} References.`,\n refsCount === 1 ? `That Document` : `Those Documents`,\n `may have References too. If referenced Documents do not exist at the target Destination, this transaction will fail.`\n ]\n\n return message.join(` `)\n}\n\nexport const stickyStyles = {\n position: 'sticky',\n top: 0,\n zIndex: 100,\n backgroundColor: `rgba(255,255,255,0.95)`,\n}"],"mappings":";;;;;;;;AAAO,SAASA,WAAW,GAAY;EAAA,IAAXC,IAAI;EAC9B,IAAI,CAACA,IAAI,EAAE,OAAO,KAAK;EAEvB,OAAO,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAACC,QAAQ,CAACD,IAAI,CAAC;AACjE;AAEO,SAASE,oBAAoB,GAA8B;EAAA,IAA7BC,QAAQ,uEAAG,CAAC;EAAA,IAAEC,SAAS,uEAAG,CAAC;EAC9D,IAAMC,OAAO,GAAG,CACdF,QAAQ,KAAK,CAAC,8CAAuCA,QAAQ,uBAAoB,EACjFC,SAAS,KAAK,CAAC,8BAAuBA,SAAS,iBAAc,EAC7DA,SAAS,KAAK,CAAC,sCAAsC,yHAEtD;EAED,OAAOC,OAAO,CAACC,IAAI,KAAK;AAC1B;AAEO,IAAMC,YAAY,GAAG;EAC1BC,QAAQ,EAAE,QAAQ;EAClBC,GAAG,EAAE,CAAC;EACNC,MAAM,EAAE,GAAG;EACXC,eAAe;AACjB,CAAC;AAAA"}
package/lib/index.js CHANGED
@@ -15,10 +15,7 @@ Object.defineProperty(exports, "DuplicateToAction", {
15
15
  return _DuplicateToAction.default;
16
16
  }
17
17
  });
18
-
19
18
  var _DuplicateToAction = _interopRequireDefault(require("./actions/DuplicateToAction"));
20
-
21
19
  var _CrossDatasetDuplicator = _interopRequireDefault(require("./components/CrossDatasetDuplicator"));
22
-
23
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
24
21
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["import DuplicateToAction from \"./actions/DuplicateToAction\";\nimport CrossDatasetDuplicator from \"./components/CrossDatasetDuplicator\";\n\nexport {\n DuplicateToAction,\n CrossDatasetDuplicator\n}"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;;AACA"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/index.js"],"sourcesContent":["import DuplicateToAction from \"./actions/DuplicateToAction\";\nimport CrossDatasetDuplicator from \"./components/CrossDatasetDuplicator\";\n\nexport {\n DuplicateToAction,\n CrossDatasetDuplicator\n}"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AACA;AAAyE"}
package/lib/tool/index.js CHANGED
@@ -4,21 +4,15 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _icons = require("@sanity/icons");
9
-
10
8
  var _crossDatasetDuplicator = _interopRequireDefault(require("config:@sanity/cross-dataset-duplicator"));
11
-
12
9
  var _CrossDatasetDuplicator = _interopRequireDefault(require("../components/CrossDatasetDuplicator"));
13
-
14
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
-
16
11
  var _default = _crossDatasetDuplicator.default !== null && _crossDatasetDuplicator.default !== void 0 && _crossDatasetDuplicator.default.tool ? {
17
12
  title: 'Duplicator',
18
13
  name: 'duplicator',
19
14
  icon: _icons.LaunchIcon,
20
15
  component: _CrossDatasetDuplicator.default
21
16
  } : null;
22
-
23
17
  exports.default = _default;
24
18
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["config","tool","title","name","icon","LaunchIcon","component","CrossDatasetDuplicator"],"sources":["../../src/tool/index.ts"],"sourcesContent":["import {LaunchIcon} from '@sanity/icons'\nimport config from 'config:@sanity/cross-dataset-duplicator'\n\nimport CrossDatasetDuplicator from '../components/CrossDatasetDuplicator'\n\nexport default config?.tool\n ? {\n title: 'Duplicator',\n name: 'duplicator',\n icon: LaunchIcon,\n component: CrossDatasetDuplicator,\n }\n : null\n"],"mappings":";;;;;;;AAAA;;AACA;;AAEA;;;;eAEeA,+BAAA,aAAAA,+BAAA,eAAAA,+BAAA,CAAQC,IAAR,GACX;EACEC,KAAK,EAAE,YADT;EAEEC,IAAI,EAAE,YAFR;EAGEC,IAAI,EAAEC,iBAHR;EAIEC,SAAS,EAAEC;AAJb,CADW,GAOX,I"}
1
+ {"version":3,"file":"index.js","names":["config","tool","title","name","icon","LaunchIcon","component","CrossDatasetDuplicator"],"sources":["../../src/tool/index.ts"],"sourcesContent":["import {LaunchIcon} from '@sanity/icons'\nimport config from 'config:@sanity/cross-dataset-duplicator'\n\nimport CrossDatasetDuplicator from '../components/CrossDatasetDuplicator'\n\nexport default config?.tool\n ? {\n title: 'Duplicator',\n name: 'duplicator',\n icon: LaunchIcon,\n component: CrossDatasetDuplicator,\n }\n : null\n"],"mappings":";;;;;;AAAA;AACA;AAEA;AAAyE;AAAA,eAE1DA,+BAAM,aAANA,+BAAM,eAANA,+BAAM,CAAEC,IAAI,GACvB;EACEC,KAAK,EAAE,YAAY;EACnBC,IAAI,EAAE,YAAY;EAClBC,IAAI,EAAEC,iBAAU;EAChBC,SAAS,EAAEC;AACb,CAAC,GACD,IAAI;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanity/cross-dataset-duplicator",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "description": "Empower content editors to migrate Documents and Assets between Sanity Projects and Datasets from inside Sanity Studio",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -33,18 +33,18 @@
33
33
  "@sanity/ui": "^0.36.15",
34
34
  "async": "^3.2.1",
35
35
  "dset": "^3.1.0",
36
- "husky": "^7.0.1",
37
- "prop-types": "15.7.2",
38
36
  "sanity-secrets": "^0.0.6",
39
37
  "styled-components": "^5.3.3"
40
38
  },
41
39
  "devDependencies": {
42
- "eslint": "7.31.0",
43
40
  "eslint-config-prettier": "^8.3.0",
44
41
  "eslint-config-sanity": "5.1.0",
45
42
  "eslint-plugin-react": "^7.24.0",
43
+ "eslint": "7.31.0",
44
+ "husky": "^7.0.1",
46
45
  "pinst": "^2.1.6",
47
46
  "prettier": "^2.3.2",
47
+ "prop-types": "15.7.2",
48
48
  "sanipack": "^2.1.0"
49
49
  },
50
50
  "peerDependencies": {
@@ -48,6 +48,11 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
48
48
  const spacesOptions = config?.__experimental_spaces?.length
49
49
  ? config.__experimental_spaces.map((space) => ({
50
50
  ...space,
51
+ api: {
52
+ ...space.api,
53
+ projectId: space.api.projectId || process.env.SANITY_STUDIO_API_PROJECT_ID,
54
+ },
55
+ usingEnvForProjectId: !space.api.projectId && process.env.SANITY_STUDIO_API_PROJECT_ID,
51
56
  disabled:
52
57
  space.api.dataset === originClient.config().dataset &&
53
58
  space.api.projectId === originClient.config().projectId,
@@ -374,7 +379,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
374
379
  .map((space) => (
375
380
  <option key={space.name} value={space.name} disabled={space.disabled}>
376
381
  {space.title ?? space.name}
377
- {hasMultipleProjectIds ? ` (${space.api.projectId})` : ``}
382
+ {hasMultipleProjectIds || space.usingEnvForProjectId ? ` (${space.api.projectId})` : ``}
378
383
  </option>
379
384
  ))}
380
385
  </Select>
@@ -390,7 +395,7 @@ export default function DuplicatorTool(props: DuplicatorToolProps) {
390
395
  {spacesOptions.map((space) => (
391
396
  <option key={space.name} value={space.name} disabled={space.disabled}>
392
397
  {space.title ?? space.name}
393
- {hasMultipleProjectIds ? ` (${space.api.projectId})` : ``}
398
+ {hasMultipleProjectIds || space.usingEnvForProjectId ? ` (${space.api.projectId})` : ``}
394
399
  {space.disabled ? ` (Current)` : ``}
395
400
  </option>
396
401
  ))}
@@ -1,5 +1,7 @@
1
- import {extract} from '@sanity/mutator'
2
- import {SanityDocument} from '../types'
1
+ import { extract } from '@sanity/mutator'
2
+ import { SanityDocument } from '../types'
3
+
4
+ import config from 'config:@sanity/cross-dataset-duplicator'
3
5
 
4
6
  // Recursively fetch Documents from an array of _id's and their references
5
7
  // Heavy use of Set is to avoid recursively querying for id's already in the payload
@@ -12,7 +14,8 @@ export async function getDocumentsInArray(
12
14
  const collection = []
13
15
 
14
16
  // Find initial docs
15
- const query = `*[_id in $fetchIds]${projection ?? ``}`
17
+ const filter = ['_id in $fetchIds', config.filter].filter(Boolean).join(' && ')
18
+ const query = `*[${filter}]${projection ?? ``}`
16
19
  const data: SanityDocument[] = await client.fetch(query, {
17
20
  fetchIds: fetchIds ?? [],
18
21
  })
@@ -22,7 +25,7 @@ export async function getDocumentsInArray(
22
25
  }
23
26
 
24
27
  const localCurrentIds = currentIds ?? new Set()
25
-
28
+
26
29
  // Find new ids in the returned data
27
30
  // Unless we started with an empty set, get the _ids from the data
28
31
  const newDataIds: Set<string> = new Set(
@@ -70,7 +73,7 @@ export async function getDocumentsInArray(
70
73
  }
71
74
 
72
75
  return [...acc, cur]
73
- }, [])
76
+ }, [])
74
77
 
75
78
  return uniqueCollection
76
79
  }