@sanity/cross-dataset-duplicator 0.4.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +53 -57
- package/lib/index.esm.js +1 -0
- package/lib/index.esm.js.map +1 -0
- package/lib/index.js +1 -21
- package/lib/index.js.map +1 -1
- package/lib/src/index.d.ts +548 -0
- package/package.json +64 -38
- package/sanity.json +2 -10
- package/src/actions/DuplicateToAction.tsx +20 -8
- package/src/components/CrossDatasetDuplicator.tsx +34 -49
- package/src/components/CrossDatasetDuplicatorAction.tsx +14 -0
- package/src/components/CrossDatasetDuplicatorTool.tsx +18 -0
- package/src/components/{DuplicatorTool.tsx → Duplicator.tsx} +179 -181
- package/src/components/DuplicatorQuery.tsx +36 -13
- package/src/components/DuplicatorWrapper.tsx +66 -0
- package/src/components/ResetSecret.tsx +9 -9
- package/src/components/SelectButtons.tsx +13 -9
- package/src/components/StatusBadge.tsx +13 -9
- package/src/context/ConfigProvider.tsx +30 -0
- package/src/helpers/clientConfig.ts +1 -1
- package/src/helpers/constants.ts +10 -1
- package/src/helpers/getDocumentsInArray.ts +28 -21
- package/src/helpers/index.ts +6 -10
- package/src/index.ts +5 -0
- package/src/plugin.tsx +31 -0
- package/src/tool/index.ts +11 -10
- package/src/types/index.ts +17 -7
- package/v2-incompatible.js +11 -0
- package/.babelrc +0 -3
- package/.eslintignore +0 -1
- package/config.dist.json +0 -5
- package/lib/actions/DuplicateToAction.js +0 -44
- package/lib/actions/DuplicateToAction.js.map +0 -1
- package/lib/actions/index.js +0 -29
- package/lib/actions/index.js.map +0 -1
- package/lib/components/CrossDatasetDuplicator.js +0 -81
- package/lib/components/CrossDatasetDuplicator.js.map +0 -1
- package/lib/components/DuplicatorQuery.js +0 -105
- package/lib/components/DuplicatorQuery.js.map +0 -1
- package/lib/components/DuplicatorTool.js +0 -556
- package/lib/components/DuplicatorTool.js.map +0 -1
- package/lib/components/Feedback.js +0 -23
- package/lib/components/Feedback.js.map +0 -1
- package/lib/components/ResetSecret.js +0 -34
- package/lib/components/ResetSecret.js.map +0 -1
- package/lib/components/SelectButtons.js +0 -84
- package/lib/components/SelectButtons.js.map +0 -1
- package/lib/components/StatusBadge.js +0 -85
- package/lib/components/StatusBadge.js.map +0 -1
- package/lib/helpers/clientConfig.js +0 -11
- package/lib/helpers/clientConfig.js.map +0 -1
- package/lib/helpers/constants.js +0 -9
- package/lib/helpers/constants.js.map +0 -1
- package/lib/helpers/getDocumentsInArray.js +0 -74
- package/lib/helpers/getDocumentsInArray.js.map +0 -1
- package/lib/helpers/index.js +0 -27
- package/lib/helpers/index.js.map +0 -1
- package/lib/tool/index.js +0 -18
- package/lib/tool/index.js.map +0 -1
- package/lib/types/index.js +0 -2
- package/lib/types/index.js.map +0 -1
- package/src/actions/index.ts +0 -22
- package/src/index.js +0 -7
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = Feedback;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _ui = require("@sanity/ui");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function Feedback(props) {
|
|
11
|
-
var children = props.children,
|
|
12
|
-
_props$tone = props.tone,
|
|
13
|
-
tone = _props$tone === void 0 ? "caution" : _props$tone;
|
|
14
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
15
|
-
padding: 3,
|
|
16
|
-
radius: 2,
|
|
17
|
-
shadow: 1,
|
|
18
|
-
tone: tone
|
|
19
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
20
|
-
size: 1
|
|
21
|
-
}, children));
|
|
22
|
-
}
|
|
23
|
-
//# sourceMappingURL=Feedback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = ResetSecret;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _ui = require("@sanity/ui");
|
|
9
|
-
var _client = _interopRequireDefault(require("part:@sanity/base/client"));
|
|
10
|
-
var _clientConfig = require("../helpers/clientConfig");
|
|
11
|
-
var _constants = require("../helpers/constants");
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
-
var client = _client.default.withConfig(_clientConfig.clientConfig);
|
|
14
|
-
function handleClick() {
|
|
15
|
-
client.delete({
|
|
16
|
-
query: "*[_id == \"secrets.".concat(_constants.SECRET_NAMESPACE, "\"]")
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
function ResetSecret() {
|
|
20
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
21
|
-
align: "center",
|
|
22
|
-
justify: "flex-end",
|
|
23
|
-
paddingX: [2, 2, 2, 5],
|
|
24
|
-
paddingY: 5
|
|
25
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
26
|
-
text: "Reset Secret",
|
|
27
|
-
onClick: () => handleClick(),
|
|
28
|
-
mode: "ghost",
|
|
29
|
-
tone: "critical",
|
|
30
|
-
fontSize: 1,
|
|
31
|
-
padding: 2
|
|
32
|
-
}));
|
|
33
|
-
}
|
|
34
|
-
//# sourceMappingURL=ResetSecret.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = SelectButtons;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _ui = require("@sanity/ui");
|
|
9
|
-
var _helpers = require("../helpers");
|
|
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); }
|
|
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; }
|
|
12
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
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."); }
|
|
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); }
|
|
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; }
|
|
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; }
|
|
17
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
18
|
-
var buttons = ["All", "None", null, "New", "Existing", "Older", null, "Documents", "Assets"];
|
|
19
|
-
function SelectButtons(props) {
|
|
20
|
-
var payload = props.payload,
|
|
21
|
-
setPayload = props.setPayload;
|
|
22
|
-
var _useState = (0, _react.useState)([]),
|
|
23
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
24
|
-
disabledActions = _useState2[0],
|
|
25
|
-
setDisabledActions = _useState2[1];
|
|
26
|
-
|
|
27
|
-
// Set intiial disabled button
|
|
28
|
-
(0, _react.useEffect)(() => {
|
|
29
|
-
if (!(disabledActions !== null && disabledActions !== void 0 && disabledActions.length) && payload.every(item => item.include)) {
|
|
30
|
-
setDisabledActions(["ALL"]);
|
|
31
|
-
}
|
|
32
|
-
}, []);
|
|
33
|
-
function handleSelectButton() {
|
|
34
|
-
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
35
|
-
if (!action || !payload.length) return;
|
|
36
|
-
var newPayload = [...payload];
|
|
37
|
-
switch (action) {
|
|
38
|
-
case 'ALL':
|
|
39
|
-
newPayload.map(item => item.include = true);
|
|
40
|
-
break;
|
|
41
|
-
case 'NONE':
|
|
42
|
-
newPayload.map(item => item.include = false);
|
|
43
|
-
break;
|
|
44
|
-
case 'NEW':
|
|
45
|
-
newPayload.map(item => item.include = Boolean(item.status === 'CREATE'));
|
|
46
|
-
break;
|
|
47
|
-
case 'EXISTING':
|
|
48
|
-
newPayload.map(item => item.include = Boolean(item.status === 'EXISTS'));
|
|
49
|
-
break;
|
|
50
|
-
case 'OLDER':
|
|
51
|
-
newPayload.map(item => item.include = Boolean(item.status === 'OVERWRITE'));
|
|
52
|
-
break;
|
|
53
|
-
case 'ASSETS':
|
|
54
|
-
newPayload.map(item => item.include = (0, _helpers.typeIsAsset)(item.doc._type));
|
|
55
|
-
break;
|
|
56
|
-
case 'DOCUMENTS':
|
|
57
|
-
newPayload.map(item => item.include = !(0, _helpers.typeIsAsset)(item.doc._type));
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
setDisabledActions([action]);
|
|
63
|
-
setPayload(newPayload);
|
|
64
|
-
}
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
66
|
-
padding: 1,
|
|
67
|
-
radius: 3,
|
|
68
|
-
shadow: 1
|
|
69
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Flex, {
|
|
70
|
-
gap: 2
|
|
71
|
-
}, buttons.map((action, actionIndex) => action ? /*#__PURE__*/_react.default.createElement(_ui.Button, {
|
|
72
|
-
key: action,
|
|
73
|
-
fontSize: 1,
|
|
74
|
-
mode: "bleed",
|
|
75
|
-
padding: 2,
|
|
76
|
-
text: action,
|
|
77
|
-
disabled: disabledActions.includes(action.toUpperCase()),
|
|
78
|
-
onClick: () => handleSelectButton(action.toUpperCase())
|
|
79
|
-
}) : /*#__PURE__*/_react.default.createElement(_ui.Card, {
|
|
80
|
-
key: "divider-".concat(actionIndex),
|
|
81
|
-
borderLeft: true
|
|
82
|
-
}))));
|
|
83
|
-
}
|
|
84
|
-
//# sourceMappingURL=SelectButtons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,OAAO,CAAC,EAAE;MACrEL,kBAAkB,CAAC,OAAO,CAAC;IAC7B;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,SAASM,kBAAkB,GAAc;IAAA,IAAbC,MAAM;IAChC,IAAI,CAACA,MAAM,IAAI,CAACX,OAAO,CAACM,MAAM,EAAE;IAEhC,IAAMM,UAAU,GAAG,CAAC,GAAGZ,OAAO,CAAC;IAE/B,QAAQW,MAAM;MACZ,KAAK,KAAK;QACRC,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAG,IAAK,CAAC;QAC/C;MACF,KAAK,MAAM;QACTG,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAG,KAAM,CAAC;QAChD;MACF,KAAK,KAAK;QACRG,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAGK,OAAO,CAACN,IAAI,CAACO,MAAM,KAAK,QAAQ,CAAE,CAAC;QAC5E;MACF,KAAK,UAAU;QACbH,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAGK,OAAO,CAACN,IAAI,CAACO,MAAM,KAAK,QAAQ,CAAE,CAAC;QAC5E;MACF,KAAK,OAAO;QACVH,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAGK,OAAO,CAACN,IAAI,CAACO,MAAM,KAAK,WAAW,CAAE,CAAC;QAC/E;MACF,KAAK,QAAQ;QACXH,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAG,IAAAO,oBAAW,EAACR,IAAI,CAACS,GAAG,CAACC,KAAK,CAAE,CAAC;QACtE;MACF,KAAK,WAAW;QACdN,UAAU,CAACC,GAAG,CAAEL,IAAI,IAAMA,IAAI,CAACC,OAAO,GAAG,CAAC,IAAAO,oBAAW,EAACR,IAAI,CAACS,GAAG,CAACC,KAAK,CAAE,CAAC;QACvE;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"}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = StatusBadge;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
|
-
var _ui = require("@sanity/ui");
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
var documentTones = {
|
|
11
|
-
EXISTS: "primary",
|
|
12
|
-
OVERWRITE: "critical",
|
|
13
|
-
UPDATE: "caution",
|
|
14
|
-
CREATE: "positive",
|
|
15
|
-
UNPUBLISHED: "caution"
|
|
16
|
-
};
|
|
17
|
-
var assetTones = {
|
|
18
|
-
EXISTS: "critical",
|
|
19
|
-
OVERWRITE: "critical",
|
|
20
|
-
UPDATE: "critical",
|
|
21
|
-
CREATE: "positive",
|
|
22
|
-
UNPUBLISHED: "default"
|
|
23
|
-
};
|
|
24
|
-
var documentMessages = {
|
|
25
|
-
// Only happens once document is copied the first time, and _updatedAt is the same
|
|
26
|
-
EXISTS: "This document already exists at the Destination with the same ID with the same Updated time.",
|
|
27
|
-
// Is true immediately after transaction as _updatedAt is updated by API after mutation
|
|
28
|
-
// Is also true if the document at the destination has been manually modified
|
|
29
|
-
// Presently, the plugin doesn't actually compare the two documents
|
|
30
|
-
OVERWRITE: "A newer version of this document exists at the Destination, and it will be overwritten with this version.",
|
|
31
|
-
// Document at destination is older
|
|
32
|
-
UPDATE: "An older version of this document exists at the Destination, and it will be overwritten with this version.",
|
|
33
|
-
// Document at destination doesn't exist
|
|
34
|
-
CREATE: "This document will be created at the destination.",
|
|
35
|
-
UNPUBLISHED: "A Draft version of this Document exists in this Dataset, but only the Published version will be duplicated to the destination."
|
|
36
|
-
};
|
|
37
|
-
var assetMessages = {
|
|
38
|
-
EXISTS: "This Asset already exists at the Destination",
|
|
39
|
-
OVERWRITE: "This Asset already exists at the Destination",
|
|
40
|
-
UPDATE: "This Asset already exists at the Destination",
|
|
41
|
-
CREATE: "This Asset does not yet exist at the Destination",
|
|
42
|
-
UNPUBLISHED: ""
|
|
43
|
-
};
|
|
44
|
-
var assetStatus = {
|
|
45
|
-
EXISTS: "RE-UPLOAD",
|
|
46
|
-
OVERWRITE: "RE-UPLOAD",
|
|
47
|
-
UPDATE: "RE-UPLOAD",
|
|
48
|
-
CREATE: "UPLOAD",
|
|
49
|
-
UNPUBLISHED: ""
|
|
50
|
-
};
|
|
51
|
-
function StatusBadge(props) {
|
|
52
|
-
var status = props.status,
|
|
53
|
-
isAsset = props.isAsset;
|
|
54
|
-
var badgeTone = isAsset ? assetTones[status] : documentTones[status];
|
|
55
|
-
if (!badgeTone) {
|
|
56
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Badge, {
|
|
57
|
-
muted: true,
|
|
58
|
-
padding: 2,
|
|
59
|
-
fontSize: 1,
|
|
60
|
-
mode: "outline"
|
|
61
|
-
}, "Checking...");
|
|
62
|
-
}
|
|
63
|
-
var badgeText = isAsset ? assetMessages[status] : documentMessages[status];
|
|
64
|
-
var badgeStatus = isAsset ? assetStatus[status] : status;
|
|
65
|
-
return /*#__PURE__*/_react.default.createElement(_ui.Tooltip, {
|
|
66
|
-
content: /*#__PURE__*/_react.default.createElement(_ui.Box, {
|
|
67
|
-
padding: 3,
|
|
68
|
-
style: {
|
|
69
|
-
maxWidth: 200
|
|
70
|
-
}
|
|
71
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Text, {
|
|
72
|
-
size: 1
|
|
73
|
-
}, badgeText)),
|
|
74
|
-
fallbackPlacements: ['right', 'left'],
|
|
75
|
-
placement: "top",
|
|
76
|
-
portal: true
|
|
77
|
-
}, /*#__PURE__*/_react.default.createElement(_ui.Badge, {
|
|
78
|
-
muted: true,
|
|
79
|
-
padding: 2,
|
|
80
|
-
fontSize: 1,
|
|
81
|
-
tone: badgeTone,
|
|
82
|
-
mode: "outline"
|
|
83
|
-
}, badgeStatus));
|
|
84
|
-
}
|
|
85
|
-
//# sourceMappingURL=StatusBadge.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;EAClBC,MAAM,YAAY;EAClBC,WAAW;AACb,CAAC;AAUD,IAAME,gBAA8B,GAAG;EACrC;EACAN,MAAM,gGAAgG;EACtG;EACA;EACA;EACAC,SAAS,6GAA6G;EACtH;EACAC,MAAM,8GAA8G;EACpH;EACAC,MAAM,qDAAqD;EAC3DC,WAAW;AACb,CAAC;AAED,IAAMG,aAA2B,GAAG;EAClCP,MAAM,gDAAgD;EACtDC,SAAS,gDAAgD;EACzDC,MAAM,gDAAgD;EACtDC,MAAM,oDAAoD;EAC1DC,WAAW;AACb,CAAC;AAED,IAAMI,WAAyB,GAAG;EAChCR,MAAM,aAAa;EACnBC,SAAS,aAAa;EACtBC,MAAM,aAAa;EACnBC,MAAM,UAAU;EAChBC,WAAW;AACb,CAAC;AAOc,SAASK,WAAW,CAACC,KAAuB,EAAE;EAC3D,IAAOC,MAAM,GAAaD,KAAK,CAAxBC,MAAM;IAAEC,OAAO,GAAIF,KAAK,CAAhBE,OAAO;EAEtB,IAAMC,SAAS,GAAGD,OAAO,GAAGP,UAAU,CAACM,MAAM,CAAC,GAAGZ,aAAa,CAACY,MAAM,CAAC;EAEtE,IAAI,CAACE,SAAS,EAAE;IACd,oBACE,6BAAC,SAAK;MAAC,KAAK;MAAC,OAAO,EAAE,CAAE;MAAC,QAAQ,EAAE,CAAE;MAAC,IAAI,EAAC;IAAS,iBAE5C;EAEZ;EAEA,IAAMC,SAAS,GAAGF,OAAO,GAAGL,aAAa,CAACI,MAAM,CAAC,GAAGL,gBAAgB,CAACK,MAAM,CAAC;EAC5E,IAAMI,WAAW,GAAGH,OAAO,GAAGJ,WAAW,CAACG,MAAM,CAAC,GAAGA,MAAM;EAE1D,oBACE,6BAAC,WAAO;IACN,OAAO,eACL,6BAAC,OAAG;MAAC,OAAO,EAAE,CAAE;MAAC,KAAK,EAAE;QAACK,QAAQ,EAAE;MAAG;IAAE,gBACtC,6BAAC,QAAI;MAAC,IAAI,EAAE;IAAE,GAAEF,SAAS,CAAQ,CAEpC;IACD,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 +0,0 @@
|
|
|
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"}
|
package/lib/helpers/constants.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getDocumentsInArray = getDocumentsInArray;
|
|
7
|
-
var _mutator = require("@sanity/mutator");
|
|
8
|
-
var _crossDatasetDuplicator = _interopRequireDefault(require("config:@sanity/cross-dataset-duplicator"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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
|
-
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); }); }; }
|
|
12
|
-
// Recursively fetch Documents from an array of _id's and their references
|
|
13
|
-
// Heavy use of Set is to avoid recursively querying for id's already in the payload
|
|
14
|
-
function getDocumentsInArray(_x, _x2, _x3, _x4) {
|
|
15
|
-
return _getDocumentsInArray.apply(this, arguments);
|
|
16
|
-
}
|
|
17
|
-
function _getDocumentsInArray() {
|
|
18
|
-
_getDocumentsInArray = _asyncToGenerator(function* (fetchIds, client, currentIds, projection) {
|
|
19
|
-
var collection = [];
|
|
20
|
-
|
|
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 : "");
|
|
24
|
-
var data = yield client.fetch(query, {
|
|
25
|
-
fetchIds: fetchIds !== null && fetchIds !== void 0 ? fetchIds : []
|
|
26
|
-
});
|
|
27
|
-
if (!(data !== null && data !== void 0 && data.length)) {
|
|
28
|
-
return [];
|
|
29
|
-
}
|
|
30
|
-
var localCurrentIds = currentIds !== null && currentIds !== void 0 ? currentIds : new Set();
|
|
31
|
-
|
|
32
|
-
// Find new ids in the returned data
|
|
33
|
-
// Unless we started with an empty set, get the _ids from the data
|
|
34
|
-
var newDataIds = new Set(data.map(dataDoc => dataDoc._id).filter(id => currentIds !== null && currentIds !== void 0 && currentIds.size ? !localCurrentIds.has(id) : Boolean(id)));
|
|
35
|
-
if (newDataIds.size) {
|
|
36
|
-
collection.push(...data);
|
|
37
|
-
localCurrentIds.add(...newDataIds);
|
|
38
|
-
|
|
39
|
-
// Check new data for more references
|
|
40
|
-
yield Promise.all(data.map( /*#__PURE__*/function () {
|
|
41
|
-
var _ref = _asyncToGenerator(function* (doc) {
|
|
42
|
-
var expr = ".._ref";
|
|
43
|
-
var references = (0, _mutator.extract)(expr, doc);
|
|
44
|
-
if (references.length) {
|
|
45
|
-
// Find references not already in the Collection
|
|
46
|
-
var newReferenceIds = new Set(references.filter(refId => !localCurrentIds.has(refId)));
|
|
47
|
-
if (newReferenceIds.size) {
|
|
48
|
-
// Recusive query for new documents
|
|
49
|
-
var referenceDocs = yield getDocumentsInArray(Array.from(newReferenceIds), client, localCurrentIds);
|
|
50
|
-
if (referenceDocs !== null && referenceDocs !== void 0 && referenceDocs.length) {
|
|
51
|
-
collection.push(...referenceDocs);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
return function (_x5) {
|
|
57
|
-
return _ref.apply(this, arguments);
|
|
58
|
-
};
|
|
59
|
-
}()));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
// Create a unique array of objects from collection
|
|
63
|
-
// Set() wasn't working for unique id's ¯\_(ツ)_/¯
|
|
64
|
-
var uniqueCollection = collection.filter(Boolean).reduce((acc, cur) => {
|
|
65
|
-
if (acc.some(doc => doc._id === cur._id)) {
|
|
66
|
-
return acc;
|
|
67
|
-
}
|
|
68
|
-
return [...acc, cur];
|
|
69
|
-
}, []);
|
|
70
|
-
return uniqueCollection;
|
|
71
|
-
});
|
|
72
|
-
return _getDocumentsInArray.apply(this, arguments);
|
|
73
|
-
}
|
|
74
|
-
//# sourceMappingURL=getDocumentsInArray.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,SAAST,MAAM,CAACU,KAAK,CAACF,KAAK,EAAE;MACvDT,QAAQ,EAAEA,QAAQ,aAARA,QAAQ,cAARA,QAAQ,GAAI;IACxB,CAAC,CAAC;IAEF,IAAI,EAACU,IAAI,aAAJA,IAAI,eAAJA,IAAI,CAAEE,MAAM,GAAE;MACjB,OAAO,EAAE;IACX;IAEA,IAAMC,eAAe,GAAGX,UAAU,aAAVA,UAAU,cAAVA,UAAU,GAAI,IAAIY,GAAG,EAAE;;IAE/C;IACA;IACA,IAAMC,UAAuB,GAAG,IAAID,GAAG,CACrCJ,IAAI,CACDM,GAAG,CAAEC,OAAO,IAAKA,OAAO,CAACC,GAAG,CAAC,CAC7Bb,MAAM,CAAEc,EAAE,IAAMjB,UAAU,aAAVA,UAAU,eAAVA,UAAU,CAAEkB,IAAI,GAAG,CAACP,eAAe,CAACQ,GAAG,CAACF,EAAE,CAAC,GAAGZ,OAAO,CAACY,EAAE,CAAE,CAAC,CAC/E;IAED,IAAIJ,UAAU,CAACK,IAAI,EAAE;MACnBhB,UAAU,CAACkB,IAAI,CAAC,GAAGZ,IAAI,CAAC;MACxBG,eAAe,CAACU,GAAG,CAAC,GAAGR,UAAU,CAAC;;MAElC;MACA,MAAMS,OAAO,CAACC,GAAG,CACff,IAAI,CAACM,GAAG;QAAA,6BAAC,WAAOU,GAAG,EAAK;UACtB,IAAMC,IAAI,WAAW;UACrB,IAAMC,UAAU,GAAG,IAAAC,gBAAO,EAACF,IAAI,EAAED,GAAG,CAAC;UAErC,IAAIE,UAAU,CAAChB,MAAM,EAAE;YACrB;YACA,IAAMkB,eAAe,GAAG,IAAIhB,GAAG,CAACc,UAAU,CAACvB,MAAM,CAAE0B,KAAK,IAAK,CAAClB,eAAe,CAACQ,GAAG,CAACU,KAAK,CAAC,CAAC,CAAC;YAE1F,IAAID,eAAe,CAACV,IAAI,EAAE;cACxB;cACA,IAAMY,aAAa,SAASjC,mBAAmB,CAC7CkC,KAAK,CAACC,IAAI,CAACJ,eAAe,CAAC,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"}
|
package/lib/helpers/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.createInitialMessage = createInitialMessage;
|
|
7
|
-
exports.stickyStyles = void 0;
|
|
8
|
-
exports.typeIsAsset = typeIsAsset;
|
|
9
|
-
function typeIsAsset() {
|
|
10
|
-
var type = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
11
|
-
if (!type) return false;
|
|
12
|
-
return ['sanity.imageAsset', 'sanity.fileAsset'].includes(type);
|
|
13
|
-
}
|
|
14
|
-
function createInitialMessage() {
|
|
15
|
-
var docCount = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
16
|
-
var refsCount = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
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."];
|
|
18
|
-
return message.join(" ");
|
|
19
|
-
}
|
|
20
|
-
var stickyStyles = {
|
|
21
|
-
position: 'sticky',
|
|
22
|
-
top: 0,
|
|
23
|
-
zIndex: 100,
|
|
24
|
-
backgroundColor: "rgba(255,255,255,0.95)"
|
|
25
|
-
};
|
|
26
|
-
exports.stickyStyles = stickyStyles;
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
package/lib/helpers/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/tool/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _icons = require("@sanity/icons");
|
|
8
|
-
var _crossDatasetDuplicator = _interopRequireDefault(require("config:@sanity/cross-dataset-duplicator"));
|
|
9
|
-
var _CrossDatasetDuplicator = _interopRequireDefault(require("../components/CrossDatasetDuplicator"));
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
var _default = _crossDatasetDuplicator.default !== null && _crossDatasetDuplicator.default !== void 0 && _crossDatasetDuplicator.default.tool ? {
|
|
12
|
-
title: 'Duplicator',
|
|
13
|
-
name: 'duplicator',
|
|
14
|
-
icon: _icons.LaunchIcon,
|
|
15
|
-
component: _CrossDatasetDuplicator.default
|
|
16
|
-
} : null;
|
|
17
|
-
exports.default = _default;
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/lib/tool/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/lib/types/index.js
DELETED
package/lib/types/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["export type SanityDocument = {\n _id: string\n _type: string\n}\n\nexport type PayloadItem = {\n include: boolean\n status: 'EXISTS' | 'OVERWRITE' | 'UPDATE' | 'CREATE'\n doc: SanityDocument\n}\n"],"mappings":""}
|
package/src/actions/index.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import defaultResolve, {DuplicateAction} from 'part:@sanity/base/document-actions'
|
|
2
|
-
import config from 'config:@sanity/cross-dataset-duplicator'
|
|
3
|
-
|
|
4
|
-
import DuplicateToAction from './DuplicateToAction'
|
|
5
|
-
|
|
6
|
-
export default function resolveDocumentActions(props) {
|
|
7
|
-
const duplicatorTypes = config?.types ?? []
|
|
8
|
-
const defaultActions = defaultResolve(props)
|
|
9
|
-
|
|
10
|
-
// Insert 'Duplicate to...' after 'Duplicate' only on config'd types
|
|
11
|
-
if (duplicatorTypes.includes(props?.type)) {
|
|
12
|
-
return defaultActions.reduce((acc, cur) => {
|
|
13
|
-
if (cur === DuplicateAction) {
|
|
14
|
-
return [...acc, cur, DuplicateToAction]
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return [...acc, cur]
|
|
18
|
-
}, [])
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return defaultActions
|
|
22
|
-
}
|