@sanity/assist 6.1.20 → 6.2.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/README.md +4 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +363 -256
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import "@sanity/ui/styles.css";
|
|
|
2
2
|
import { FormBuilder, FormCallbacksProvider, FormFieldHeaderText, FormInput, MemberFieldError, ObjectInputMember, PatchEvent, PerspectiveProvider, PresenceOverlay, StatusButton, VirtualizerScrollInstanceProvider, createPatchChannel, defineArrayMember, defineField, definePlugin, defineType, fromMutationPatches, getDraftId, getPublishedId, getVersionFromId, getVersionId, insert, isArrayOfObjectsSchemaType, isArraySchemaType, isDocumentSchemaType, isKeySegment, isObjectSchemaType, isRecord, isVersionId, pathToString, set, setIfMissing, stringToPath, typed, unset, useClient, useColorSchemeValue, useCurrentUser, useDocumentPresence, useDocumentStore, useEditState, useFormCallbacks, usePerspective, useSchema, useSyncState, useWorkspaceSchemaId } from "sanity";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { Box, Button, Card, Checkbox, Container, Dialog, ErrorBoundary, Flex, Label, Radio, Spinner, Stack, Switch, Text, TextArea, ThemeProvider, focusFirstDescendant, rgba, useClickOutsideEvent, useGlobalKeyDown, useLayer, useTheme } from "@sanity/ui";
|
|
5
|
-
import { createContext, isValidElement, useCallback, useContext, useEffect, useEffectEvent, useId, useMemo, useReducer, useRef, useState } from "react";
|
|
6
5
|
import { DocumentInspectorHeader, DocumentPaneProvider, PaneRouterContext, useDocumentPane, usePaneRouter } from "sanity/structure";
|
|
6
|
+
import { createContext, isValidElement, useCallback, useContext, useEffect, useEffectEvent, useId, useMemo, useReducer, useRef, useState } from "react";
|
|
7
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
8
|
import { useToast } from "@sanity/ui/toast";
|
|
9
9
|
import { addSeconds } from "date-fns/addSeconds";
|
|
@@ -36,7 +36,7 @@ import { ErrorOutlineIcon } from "@sanity/icons/ErrorOutline";
|
|
|
36
36
|
import { SyncIcon } from "@sanity/icons/Sync";
|
|
37
37
|
import { Popover } from "@sanity/ui/popover";
|
|
38
38
|
import { formatDistanceToNow } from "date-fns/formatDistanceToNow";
|
|
39
|
-
import
|
|
39
|
+
import { dequal } from "dequal/lite";
|
|
40
40
|
import get from "lodash-es/get.js";
|
|
41
41
|
import { Icon, icons } from "@sanity/icons";
|
|
42
42
|
import { ControlsIcon } from "@sanity/icons/Controls";
|
|
@@ -291,7 +291,7 @@ function mapConnectorToLine(options, connector) {
|
|
|
291
291
|
to
|
|
292
292
|
};
|
|
293
293
|
}
|
|
294
|
-
const
|
|
294
|
+
const assistDocumentStatusIdPrefix = "sanity.assist.status.", assistDocumentTypeName = "sanity.assist.schemaType.annotations", assistFieldTypeName = "sanity.assist.schemaType.field", userInputTypeName = "sanity.assist.instruction.userInput", fieldReferenceTypeName = "sanity.assist.instruction.fieldRef", contextDocumentTypeName = "assist.instruction.context", assistTasksStatusTypeName = "sanity.assist.task.status", instructionTaskTypeName = "sanity.assist.instructionTask", fieldPresenceTypeName = "sanity.assist.instructionTask.presence", assistSerializedTypeName = "sanity.assist.serialized.type", assistSerializedFieldTypeName = "sanity.assist.serialized.field", fieldPathParam = "pathKey", instructionParam = "instruction", documentRootKey = "<document>";
|
|
295
295
|
function usePathKey(path) {
|
|
296
296
|
let $ = c(2), t0;
|
|
297
297
|
return $[0] === path ? t0 = $[1] : (t0 = getPathKey(path), $[0] = path, $[1] = t0), t0;
|
|
@@ -350,7 +350,7 @@ const FirstAssistedPathContext = createContext(void 0);
|
|
|
350
350
|
function FirstAssistedPathProvider(props) {
|
|
351
351
|
let $ = c(5), { members } = props, t0;
|
|
352
352
|
if ($[0] !== members) {
|
|
353
|
-
let firstAssisted = members.find(_temp$
|
|
353
|
+
let firstAssisted = members.find(_temp$16);
|
|
354
354
|
t0 = firstAssisted?.field.path ? pathToString(firstAssisted?.field.path) : void 0, $[0] = members, $[1] = t0;
|
|
355
355
|
} else t0 = $[1];
|
|
356
356
|
let firstAssistedPath = t0, t1;
|
|
@@ -359,12 +359,12 @@ function FirstAssistedPathProvider(props) {
|
|
|
359
359
|
children: props.children
|
|
360
360
|
}), $[2] = firstAssistedPath, $[3] = props.children, $[4] = t1) : t1 = $[4], t1;
|
|
361
361
|
}
|
|
362
|
-
function _temp$
|
|
362
|
+
function _temp$16(member) {
|
|
363
363
|
return member.kind === "field" && isAssistSupported(member.field.schemaType);
|
|
364
364
|
}
|
|
365
365
|
const releaseAnnouncementUrl = "https://www.sanity.io/blog/sanity-ai-assist-announcement?utm_source=sanity-assist-plugin&utm_medium=organic_social&utm_campaign=ai-assist&utm_content=", packageName = "@sanity/assist", pluginTitle = "Sanity AI Assist", pluginTitleShort = "AI Assist", maxHistoryVisibilityMs = minutesToMilliseconds(30), illegalIdChars = /[^a-zA-Z0-9._-]/g;
|
|
366
366
|
function assistDocumentId(documentType) {
|
|
367
|
-
return
|
|
367
|
+
return `sanity.assist.schemaType.${documentType}`.replace(illegalIdChars, "_");
|
|
368
368
|
}
|
|
369
369
|
function assistTasksStatusId(documentId) {
|
|
370
370
|
return isVersionId(documentId) ? `${assistDocumentStatusIdPrefix}${getVersionFromId(documentId)}.${getPublishedId(documentId)}` : `${assistDocumentStatusIdPrefix}${getPublishedId(documentId)}`;
|
|
@@ -374,7 +374,7 @@ function useDocumentState(id, docType) {
|
|
|
374
374
|
return state.draft || state.published;
|
|
375
375
|
}
|
|
376
376
|
function useStudioAssistDocument(t0) {
|
|
377
|
-
let $ = c(
|
|
377
|
+
let $ = c(17), { documentId, schemaType, initDoc } = t0, documentTypeName = schemaType.name, currentUser = useCurrentUser(), t1;
|
|
378
378
|
$[0] === documentTypeName ? t1 = $[1] : (t1 = assistDocumentId(documentTypeName), $[0] = documentTypeName, $[1] = t1);
|
|
379
379
|
let assistDocument = useDocumentState(t1, assistDocumentTypeName), t2 = documentId ?? "", t3;
|
|
380
380
|
$[2] === t2 ? t3 = $[3] : (t3 = assistTasksStatusId(t2), $[2] = t2, $[3] = t3);
|
|
@@ -385,7 +385,7 @@ function useStudioAssistDocument(t0) {
|
|
|
385
385
|
!assistDocument && initDoc && client.createIfNotExists({
|
|
386
386
|
_id: assistDocumentId(documentTypeName),
|
|
387
387
|
_type: assistDocumentTypeName
|
|
388
|
-
}).catch(_temp$
|
|
388
|
+
}).catch(_temp$15);
|
|
389
389
|
}, t6 = [
|
|
390
390
|
client,
|
|
391
391
|
assistDocument,
|
|
@@ -400,7 +400,9 @@ function useStudioAssistDocument(t0) {
|
|
|
400
400
|
}
|
|
401
401
|
let t8;
|
|
402
402
|
if ($[11] !== assistDocument || $[12] !== assistTasksStatus?.tasks || $[13] !== currentUser?.id) {
|
|
403
|
-
let tasks = assistTasksStatus?.tasks ?? [],
|
|
403
|
+
let tasks = assistTasksStatus?.tasks ?? [], t9;
|
|
404
|
+
$[15] === assistDocument?.fields ? t9 = $[16] : (t9 = assistDocument?.fields ?? [], $[15] = assistDocument?.fields, $[16] = t9);
|
|
405
|
+
let fields = t9.map((assistField) => ({
|
|
404
406
|
...assistField,
|
|
405
407
|
tasks: tasks.filter((task) => task.path === assistField.path),
|
|
406
408
|
instructions: assistField.instructions?.filter((p) => !p.userId || p.userId === currentUser?.id).map((instruction) => asStudioInstruction(instruction, tasks))
|
|
@@ -421,7 +423,7 @@ function useStudioAssistDocument(t0) {
|
|
|
421
423
|
}
|
|
422
424
|
return t7;
|
|
423
425
|
}
|
|
424
|
-
function _temp$
|
|
426
|
+
function _temp$15() {}
|
|
425
427
|
function asStudioInstruction(instruction, run) {
|
|
426
428
|
return {
|
|
427
429
|
...instruction,
|
|
@@ -439,11 +441,11 @@ function useInstructionToaster(documentId, documentSchemaType) {
|
|
|
439
441
|
$[3] !== assistDocLoaded || $[4] !== currentUser?.id || $[5] !== tasks || $[6] !== toast ? (t1 = () => {
|
|
440
442
|
if (assistDocLoaded) {
|
|
441
443
|
if (previousTasks.current !== "initial") {
|
|
442
|
-
let prevTaskByKey = Object.fromEntries((previousTasks.current ?? NO_TASKS).map(_temp$
|
|
444
|
+
let prevTaskByKey = Object.fromEntries((previousTasks.current ?? NO_TASKS).map(_temp$14));
|
|
443
445
|
(tasks?.filter((task) => task.startedByUserId === currentUser?.id).filter((task_0) => {
|
|
444
446
|
let prevTask = prevTaskByKey[task_0._key];
|
|
445
447
|
return !prevTask && task_0.ended || !prevTask?.ended && task_0.ended;
|
|
446
|
-
}).filter(_temp2$
|
|
448
|
+
}).filter(_temp2$9))?.forEach((task_2) => {
|
|
447
449
|
let title = task_2.title ?? getInstructionTitle(task_2.instruction);
|
|
448
450
|
task_2.reason === "error" ? toast.push({
|
|
449
451
|
title: `Failed: ${title}`,
|
|
@@ -481,10 +483,10 @@ function useInstructionToaster(documentId, documentSchemaType) {
|
|
|
481
483
|
assistDocLoaded
|
|
482
484
|
], $[8] = assistDocLoaded, $[9] = currentUser, $[10] = tasks, $[11] = toast, $[12] = t2) : t2 = $[12], useEffect(t1, t2);
|
|
483
485
|
}
|
|
484
|
-
function _temp2$
|
|
486
|
+
function _temp2$9(task_1) {
|
|
485
487
|
return task_1.ended && isAfter(addSeconds(new Date(task_1.ended), 30), /* @__PURE__ */ new Date());
|
|
486
488
|
}
|
|
487
|
-
function _temp$
|
|
489
|
+
function _temp$14(run) {
|
|
488
490
|
return [run._key, run];
|
|
489
491
|
}
|
|
490
492
|
function AssistDocumentInputWrapper(props) {
|
|
@@ -586,15 +588,25 @@ function getDocumentFieldRef(schemaType) {
|
|
|
586
588
|
schemaType
|
|
587
589
|
};
|
|
588
590
|
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
+
/**
|
|
592
|
+
* Collects every field (and synthetic array item) in `schemaType` that AI Assist can attach
|
|
593
|
+
* instructions to.
|
|
594
|
+
*
|
|
595
|
+
* @param maxDepth - max number of path segments a collected field can have; deeper fields are
|
|
596
|
+
* skipped. Arrays contribute one segment for the item type (`array[_key="type"]`).
|
|
597
|
+
*/
|
|
598
|
+
function getFieldRefs(schemaType, maxDepth = 6) {
|
|
599
|
+
return getObjectFieldRefs(schemaType, void 0, 0, maxDepth);
|
|
600
|
+
}
|
|
601
|
+
function getObjectFieldRefs(schemaType, parent, depth, maxDepth) {
|
|
602
|
+
return depth >= maxDepth ? [] : schemaType.fields.filter((f) => !f.name.startsWith("_")).flatMap((field) => {
|
|
591
603
|
let path = parent ? [...parent.path, field.name] : [field.name], title = field.type.title ?? field.name, fieldRef = {
|
|
592
604
|
key: patchableKey(pathToString(path)),
|
|
593
605
|
path,
|
|
594
606
|
title: parent ? [parent.title, title].join(" / ") : title,
|
|
595
607
|
schemaType: field.type,
|
|
596
608
|
icon: getTypeIcon(field.type)
|
|
597
|
-
}, fields = field.type.jsonType === "object" ?
|
|
609
|
+
}, fields = field.type.jsonType === "object" ? getObjectFieldRefs(field.type, fieldRef, depth + 1, maxDepth) : [], syntheticFields = field.type.jsonType === "array" ? getSyntheticFields(field.type, fieldRef, depth + 1, maxDepth) : [];
|
|
598
610
|
return isAssistSupported(field.type) ? [
|
|
599
611
|
fieldRef,
|
|
600
612
|
...fields,
|
|
@@ -602,8 +614,8 @@ function getFieldRefs(schemaType, parent, depth = 0) {
|
|
|
602
614
|
] : [...fields, ...syntheticFields];
|
|
603
615
|
});
|
|
604
616
|
}
|
|
605
|
-
function getSyntheticFields(schemaType, parent, depth
|
|
606
|
-
return depth >=
|
|
617
|
+
function getSyntheticFields(schemaType, parent, depth, maxDepth) {
|
|
618
|
+
return depth >= maxDepth ? [] : schemaType.of.filter((itemType) => !isType(itemType, "block")).flatMap((itemType) => {
|
|
607
619
|
let segment = { _key: itemType.name }, title = itemType.title ?? itemType.name, path = parent ? [...parent.path, segment] : [segment], fieldRef = {
|
|
608
620
|
key: patchableKey(pathToString(path)),
|
|
609
621
|
path,
|
|
@@ -611,7 +623,7 @@ function getSyntheticFields(schemaType, parent, depth = 0) {
|
|
|
611
623
|
schemaType: itemType,
|
|
612
624
|
icon: getTypeIcon(itemType),
|
|
613
625
|
synthetic: !0
|
|
614
|
-
}, fields = itemType.jsonType === "object" ?
|
|
626
|
+
}, fields = itemType.jsonType === "object" ? getObjectFieldRefs(itemType, fieldRef, depth + 1, maxDepth) : [];
|
|
615
627
|
return isAssistSupported(itemType) ? [fieldRef, ...fields] : fields;
|
|
616
628
|
});
|
|
617
629
|
}
|
|
@@ -856,7 +868,7 @@ function isUserInputBlock(block) {
|
|
|
856
868
|
function RunInstructionProvider(props) {
|
|
857
869
|
let $ = c(33), { config } = useAiAssistanceConfig(), { runInstruction: runInstructionRequest, loading } = useRunInstructionApi(useApiClient(config?.__customApiClient)), id = useId(), [inputs, setInputs] = useState(NO_INPUT), [runRequest, setRunRequest] = useState(), [resolveUserInput, setResolveUserInput] = useState(), t0;
|
|
858
870
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = async (t1) => {
|
|
859
|
-
let { title, inputs: inputs_0 } = t1, userInputBlocks = inputs_0.map(_temp$
|
|
871
|
+
let { title, inputs: inputs_0 } = t1, userInputBlocks = inputs_0.map(_temp$13);
|
|
860
872
|
if (userInputBlocks.length) return setRunRequest({
|
|
861
873
|
dialogTitle: title,
|
|
862
874
|
userInputBlocks
|
|
@@ -867,7 +879,7 @@ function RunInstructionProvider(props) {
|
|
|
867
879
|
let getUserInput = t0, t1;
|
|
868
880
|
$[1] !== loading || $[2] !== runInstructionRequest ? (t1 = (req) => {
|
|
869
881
|
if (loading) return;
|
|
870
|
-
let { instruction, ...request } = req, instructionKey = instruction._key, userInputBlocks_0 = instruction?.prompt?.flatMap(_temp2$
|
|
882
|
+
let { instruction, ...request } = req, instructionKey = instruction._key, userInputBlocks_0 = instruction?.prompt?.flatMap(_temp2$8).filter(isUserInputBlock);
|
|
871
883
|
if (!userInputBlocks_0?.length) {
|
|
872
884
|
runInstructionRequest({
|
|
873
885
|
...request,
|
|
@@ -893,7 +905,7 @@ function RunInstructionProvider(props) {
|
|
|
893
905
|
runInstructionRequest({
|
|
894
906
|
...request_0,
|
|
895
907
|
instructionKey: instruction_0._key,
|
|
896
|
-
userTexts: Object.entries(inputs).map(_temp3$
|
|
908
|
+
userTexts: Object.entries(inputs).map(_temp3$6)
|
|
897
909
|
});
|
|
898
910
|
} else {
|
|
899
911
|
let userInputs = Object.values(inputs).map((input_0, i_0) => {
|
|
@@ -915,7 +927,7 @@ function RunInstructionProvider(props) {
|
|
|
915
927
|
let runWithInput = t3, open = !!runRequest;
|
|
916
928
|
runRequest?.userInputBlocks;
|
|
917
929
|
let t4;
|
|
918
|
-
$[12] === inputs ? t4 = $[13] : (t4 = Object.entries(inputs).filter(_temp4$
|
|
930
|
+
$[12] === inputs ? t4 = $[13] : (t4 = Object.entries(inputs).filter(_temp4$4), $[12] = inputs, $[13] = t4);
|
|
919
931
|
let runDisabled = (runRequest?.userInputBlocks?.length ?? 0) > t4.length, t5;
|
|
920
932
|
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = { width: "100%" }, $[14] = t5) : t5 = $[14];
|
|
921
933
|
let t6;
|
|
@@ -973,21 +985,21 @@ function RunInstructionProvider(props) {
|
|
|
973
985
|
children: [t8, props.children]
|
|
974
986
|
}), $[29] = contextValue, $[30] = props.children, $[31] = t8, $[32] = t9) : t9 = $[32], t9;
|
|
975
987
|
}
|
|
976
|
-
function _temp4$
|
|
988
|
+
function _temp4$4(t0) {
|
|
977
989
|
let [, value_0] = t0;
|
|
978
990
|
return !!value_0;
|
|
979
991
|
}
|
|
980
|
-
function _temp3$
|
|
992
|
+
function _temp3$6(t0) {
|
|
981
993
|
let [key, value] = t0;
|
|
982
994
|
return {
|
|
983
995
|
blockKey: key,
|
|
984
996
|
userInput: value
|
|
985
997
|
};
|
|
986
998
|
}
|
|
987
|
-
function _temp2$
|
|
999
|
+
function _temp2$8(block) {
|
|
988
1000
|
return block._type === "block" ? block.children.filter(isUserInputBlock) : [block];
|
|
989
1001
|
}
|
|
990
|
-
function _temp$
|
|
1002
|
+
function _temp$13(input, i) {
|
|
991
1003
|
return {
|
|
992
1004
|
_type: userInputTypeName,
|
|
993
1005
|
_key: input.id ?? `${i}`,
|
|
@@ -1126,7 +1138,7 @@ function useAssistDocumentContextValue(documentId, documentType) {
|
|
|
1126
1138
|
return t9;
|
|
1127
1139
|
}
|
|
1128
1140
|
function useSyntheticTasks(assistableDocumentId) {
|
|
1129
|
-
let $ = c(7), [syntheticTasks, setSyntheticTasks] = useState(_temp$
|
|
1141
|
+
let $ = c(7), [syntheticTasks, setSyntheticTasks] = useState(_temp$12), t0;
|
|
1130
1142
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = (task) => {
|
|
1131
1143
|
setSyntheticTasks((current) => [...current, task]);
|
|
1132
1144
|
}, $[0] = t0) : t0 = $[0];
|
|
@@ -1147,7 +1159,7 @@ function useSyntheticTasks(assistableDocumentId) {
|
|
|
1147
1159
|
removeSyntheticTask
|
|
1148
1160
|
}, $[5] = syntheticTasks, $[6] = t4), t4;
|
|
1149
1161
|
}
|
|
1150
|
-
function _temp$
|
|
1162
|
+
function _temp$12() {
|
|
1151
1163
|
return [];
|
|
1152
1164
|
}
|
|
1153
1165
|
function AssistDocumentContextProvider(props) {
|
|
@@ -1169,7 +1181,7 @@ function AssistDocumentLayout(props) {
|
|
|
1169
1181
|
}
|
|
1170
1182
|
const fadeIn = keyframes`0%{opacity:0;transform:scale(0.75);}40%{opacity:0;transform:scale(0.75);}100%{opacity:1;transform:scale(1);}`, FadeInDiv = styled.div.withConfig({
|
|
1171
1183
|
displayName: "FadeInDiv",
|
|
1172
|
-
componentId: "sc-
|
|
1184
|
+
componentId: "sc-gocic8-0"
|
|
1173
1185
|
})`animation-name:${fadeIn};animation-timing-function:ease-in-out;`;
|
|
1174
1186
|
function FadeInContent(t0) {
|
|
1175
1187
|
let $ = c(6), { children, durationMs: t1, ref } = t0, t2 = `${t1 === void 0 ? 250 : t1}ms`, t3;
|
|
@@ -1183,43 +1195,59 @@ function FadeInContent(t0) {
|
|
|
1183
1195
|
}
|
|
1184
1196
|
const Root = styled.span.withConfig({
|
|
1185
1197
|
displayName: "Root",
|
|
1186
|
-
componentId: "sc-
|
|
1198
|
+
componentId: "sc-kyfo1k-0"
|
|
1187
1199
|
})`display:block;width:25px;height:25px;position:relative;`, dash = keyframes`0%{transform:rotate(0);}100%{transform:rotate(43deg);}`, Outline = styled.svg.withConfig({
|
|
1188
1200
|
displayName: "Outline",
|
|
1189
|
-
componentId: "sc-
|
|
1201
|
+
componentId: "sc-kyfo1k-1"
|
|
1190
1202
|
})`display:block;position:absolute;top:0;left:0;& > circle{stroke:var(--ai-avatar-stroke-color);stroke-width:1.5px;stroke-linecap:round;transform-origin:center;animation:${dash} 500ms ease-in-out infinite;transition:stroke-dasharray 200ms ease-in-out;stroke-dasharray:2.34px 0;[data-state='active'] > &{stroke-dasharray:2px 2.34px;}}`, IconDisc = styled.span.withConfig({
|
|
1191
1203
|
displayName: "IconDisc",
|
|
1192
|
-
componentId: "sc-
|
|
1204
|
+
componentId: "sc-kyfo1k-2"
|
|
1193
1205
|
})`background:var(--ai-avatar-disc-color);color:white;width:21px;height:21px;display:flex;align-items:center;justify-content:center;border-radius:10.5px;position:absolute;top:2px;left:2px;`;
|
|
1194
1206
|
function AssistAvatar(props) {
|
|
1195
|
-
let { state
|
|
1196
|
-
|
|
1197
|
-
"
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1207
|
+
let $ = c(8), { state: t0 } = props, state = t0 === void 0 ? "present" : t0, scheme = useColorSchemeValue(), t1;
|
|
1208
|
+
bb0: {
|
|
1209
|
+
if (scheme === "dark") {
|
|
1210
|
+
let t2;
|
|
1211
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
1212
|
+
"--ai-avatar-stroke-color": purple[400].hex,
|
|
1213
|
+
"--ai-avatar-disc-color": purple[600].hex
|
|
1214
|
+
}, $[0] = t2) : t2 = $[0], t1 = t2;
|
|
1215
|
+
break bb0;
|
|
1216
|
+
}
|
|
1217
|
+
let t2;
|
|
1218
|
+
$[1] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
1219
|
+
"--ai-avatar-stroke-color": purple[500].hex,
|
|
1220
|
+
"--ai-avatar-disc-color": purple[600].hex
|
|
1221
|
+
}, $[1] = t2) : t2 = $[1], t1 = t2;
|
|
1222
|
+
}
|
|
1223
|
+
let style = t1, t2;
|
|
1224
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = /* @__PURE__ */ jsx(Outline, {
|
|
1225
|
+
width: "25",
|
|
1226
|
+
height: "25",
|
|
1227
|
+
viewBox: "0 0 25 25",
|
|
1228
|
+
fill: "none",
|
|
1229
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1230
|
+
children: /* @__PURE__ */ jsx("circle", {
|
|
1231
|
+
cx: "12.5",
|
|
1232
|
+
cy: "12.5",
|
|
1233
|
+
r: "11.75"
|
|
1234
|
+
})
|
|
1235
|
+
}), $[2] = t2) : t2 = $[2];
|
|
1236
|
+
let t3;
|
|
1237
|
+
$[3] === Symbol.for("react.memo_cache_sentinel") ? (t3 = { color: "inherit" }, $[3] = t3) : t3 = $[3];
|
|
1238
|
+
let t4;
|
|
1239
|
+
$[4] === Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx(IconDisc, { children: /* @__PURE__ */ jsx(Text, {
|
|
1240
|
+
as: "span",
|
|
1241
|
+
size: 0,
|
|
1242
|
+
style: t3,
|
|
1243
|
+
children: /* @__PURE__ */ jsx(SparklesIcon, { style: { color: "inherit" } })
|
|
1244
|
+
}) }), $[4] = t4) : t4 = $[4];
|
|
1245
|
+
let t5;
|
|
1246
|
+
return $[5] !== state || $[6] !== style ? (t5 = /* @__PURE__ */ jsxs(Root, {
|
|
1203
1247
|
"data-state": state,
|
|
1204
1248
|
style,
|
|
1205
|
-
children: [
|
|
1206
|
-
|
|
1207
|
-
height: "25",
|
|
1208
|
-
viewBox: "0 0 25 25",
|
|
1209
|
-
fill: "none",
|
|
1210
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
1211
|
-
children: /* @__PURE__ */ jsx("circle", {
|
|
1212
|
-
cx: "12.5",
|
|
1213
|
-
cy: "12.5",
|
|
1214
|
-
r: "11.75"
|
|
1215
|
-
})
|
|
1216
|
-
}), /* @__PURE__ */ jsx(IconDisc, { children: /* @__PURE__ */ jsx(Text, {
|
|
1217
|
-
as: "span",
|
|
1218
|
-
size: 0,
|
|
1219
|
-
style: { color: "inherit" },
|
|
1220
|
-
children: /* @__PURE__ */ jsx(SparklesIcon, { style: { color: "inherit" } })
|
|
1221
|
-
}) })]
|
|
1222
|
-
});
|
|
1249
|
+
children: [t2, t4]
|
|
1250
|
+
}), $[5] = state, $[6] = style, $[7] = t5) : t5 = $[7], t5;
|
|
1223
1251
|
}
|
|
1224
1252
|
function AiFieldPresence(_props) {
|
|
1225
1253
|
let $ = c(3), t0;
|
|
@@ -1258,7 +1286,7 @@ function useAssistPresence(path, showFocusWithin) {
|
|
|
1258
1286
|
let $ = c(6), context = useAssistDocumentContext(), tasks = (context && "assistDocument" in context ? context.assistDocument : void 0)?.tasks, t0;
|
|
1259
1287
|
if ($[0] !== path || $[1] !== showFocusWithin || $[2] !== tasks) {
|
|
1260
1288
|
bb0: {
|
|
1261
|
-
let activePresence = tasks?.filter(_temp$
|
|
1289
|
+
let activePresence = tasks?.filter(_temp$11)?.flatMap(_temp2$7)?.filter(_temp3$5).filter((presence) => {
|
|
1262
1290
|
if (!presence.path || !path.length) return !1;
|
|
1263
1291
|
let statusPath = stringToPath(presence.path);
|
|
1264
1292
|
return !showFocusWithin && statusPath.length !== path.length ? !1 : path.every((pathSegment, i) => {
|
|
@@ -1277,13 +1305,13 @@ function useAssistPresence(path, showFocusWithin) {
|
|
|
1277
1305
|
} else t0 = $[3];
|
|
1278
1306
|
return t0;
|
|
1279
1307
|
}
|
|
1280
|
-
function _temp3$
|
|
1308
|
+
function _temp3$5(p) {
|
|
1281
1309
|
return p.started && (/* @__PURE__ */ new Date()).getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs;
|
|
1282
1310
|
}
|
|
1283
|
-
function _temp2$
|
|
1311
|
+
function _temp2$7(task_0) {
|
|
1284
1312
|
return task_0.presence ?? [];
|
|
1285
1313
|
}
|
|
1286
|
-
function _temp$
|
|
1314
|
+
function _temp$11(task) {
|
|
1287
1315
|
return !task.ended;
|
|
1288
1316
|
}
|
|
1289
1317
|
function aiPresence(presence, path, _title) {
|
|
@@ -1334,7 +1362,7 @@ function AssistField(props) {
|
|
|
1334
1362
|
}
|
|
1335
1363
|
const WrapPreCard = styled(Card).withConfig({
|
|
1336
1364
|
displayName: "WrapPreCard",
|
|
1337
|
-
componentId: "sc-
|
|
1365
|
+
componentId: "sc-flgt1j-0"
|
|
1338
1366
|
})`& pre{white-space:pre-wrap !important;}`;
|
|
1339
1367
|
function SafeValueInput(props) {
|
|
1340
1368
|
let $ = c(5), t0;
|
|
@@ -1463,7 +1491,7 @@ function AssistItem(props) {
|
|
|
1463
1491
|
children: t1
|
|
1464
1492
|
}), $[3] = t1, $[4] = t2);
|
|
1465
1493
|
let t3;
|
|
1466
|
-
$[5] === presence ? t3 = $[6] : (t3 = presence.map(_temp$
|
|
1494
|
+
$[5] === presence ? t3 = $[6] : (t3 = presence.map(_temp$10), $[5] = presence, $[6] = t3);
|
|
1467
1495
|
let t4;
|
|
1468
1496
|
return $[7] !== t2 || $[8] !== t3 ? (t4 = /* @__PURE__ */ jsxs(Flex, {
|
|
1469
1497
|
align: "center",
|
|
@@ -1471,7 +1499,7 @@ function AssistItem(props) {
|
|
|
1471
1499
|
children: [t2, t3]
|
|
1472
1500
|
}), $[7] = t2, $[8] = t3, $[9] = t4) : t4 = $[9], t4;
|
|
1473
1501
|
}
|
|
1474
|
-
function _temp$
|
|
1502
|
+
function _temp$10(pre) {
|
|
1475
1503
|
return /* @__PURE__ */ jsx(Box, {
|
|
1476
1504
|
style: {
|
|
1477
1505
|
position: "absolute",
|
|
@@ -1693,7 +1721,7 @@ function extractConditionalPaths(node, maxDepth) {
|
|
|
1693
1721
|
}
|
|
1694
1722
|
const SparklesIllustration = /* @__PURE__ */ styled(SparklesIcon).withConfig({
|
|
1695
1723
|
displayName: "SparklesIllustration",
|
|
1696
|
-
componentId: "sc-
|
|
1724
|
+
componentId: "sc-xzej1l-0"
|
|
1697
1725
|
})({
|
|
1698
1726
|
fontSize: "3.125em",
|
|
1699
1727
|
"& path": { strokeWidth: "0.6px !important" }
|
|
@@ -1787,9 +1815,9 @@ function FieldAutocomplete(props) {
|
|
|
1787
1815
|
let currentField = t1, t2;
|
|
1788
1816
|
if ($[11] !== fieldRefs || $[12] !== filter) {
|
|
1789
1817
|
let t3;
|
|
1790
|
-
$[14] === filter ? t3 = $[15] : (t3 = (field) => !filter || filter(field), $[14] = filter, $[15] = t3), t2 = fieldRefs.filter(t3).filter(_temp$
|
|
1818
|
+
$[14] === filter ? t3 = $[15] : (t3 = (field) => !filter || filter(field), $[14] = filter, $[15] = t3), t2 = fieldRefs.filter(t3).filter(_temp$9).map(_temp2$6), $[11] = fieldRefs, $[12] = filter, $[13] = t2;
|
|
1791
1819
|
} else t2 = $[13];
|
|
1792
|
-
let autocompleteOptions = t2, renderOption = _temp3$
|
|
1820
|
+
let autocompleteOptions = t2, renderOption = _temp3$4, renderValue = _temp4$3, filterOption = _temp5$2, t3 = currentField ? currentField.icon : SearchIcon, t4 = currentField?.key, t5;
|
|
1793
1821
|
return $[16] !== autocompleteOptions || $[17] !== id || $[18] !== onSelect || $[19] !== t3 || $[20] !== t4 ? (t5 = /* @__PURE__ */ jsx(Autocomplete, {
|
|
1794
1822
|
fontSize: 1,
|
|
1795
1823
|
icon: t3,
|
|
@@ -1805,14 +1833,14 @@ function FieldAutocomplete(props) {
|
|
|
1805
1833
|
filterOption
|
|
1806
1834
|
}), $[16] = autocompleteOptions, $[17] = id, $[18] = onSelect, $[19] = t3, $[20] = t4, $[21] = t5) : t5 = $[21], t5;
|
|
1807
1835
|
}
|
|
1808
|
-
function _temp5(query, option_1) {
|
|
1836
|
+
function _temp5$2(query, option_1) {
|
|
1809
1837
|
let lQuery = query.toLowerCase();
|
|
1810
1838
|
return option_1?.value?.toLowerCase().includes(lQuery) || option_1?.field?.title?.toLowerCase().includes(lQuery);
|
|
1811
1839
|
}
|
|
1812
|
-
function _temp4$
|
|
1840
|
+
function _temp4$3(value_0, option_0) {
|
|
1813
1841
|
return option_0?.field.title ?? value_0;
|
|
1814
1842
|
}
|
|
1815
|
-
function _temp3$
|
|
1843
|
+
function _temp3$4(option) {
|
|
1816
1844
|
let { value, field: field_1 } = option;
|
|
1817
1845
|
return value ? isType(field_1.schemaType, "document") ? /* @__PURE__ */ jsx(Card, {
|
|
1818
1846
|
as: "button",
|
|
@@ -1845,13 +1873,13 @@ function _temp3$2(option) {
|
|
|
1845
1873
|
})
|
|
1846
1874
|
});
|
|
1847
1875
|
}
|
|
1848
|
-
function _temp2$
|
|
1876
|
+
function _temp2$6(field_0) {
|
|
1849
1877
|
return {
|
|
1850
1878
|
value: field_0.key,
|
|
1851
1879
|
field: field_0
|
|
1852
1880
|
};
|
|
1853
1881
|
}
|
|
1854
|
-
function _temp$
|
|
1882
|
+
function _temp$9(f_0) {
|
|
1855
1883
|
return !isType(f_0.schemaType, "reference");
|
|
1856
1884
|
}
|
|
1857
1885
|
function FieldTitle(props) {
|
|
@@ -1868,7 +1896,7 @@ function FieldTitle(props) {
|
|
|
1868
1896
|
size: 1,
|
|
1869
1897
|
children: "/"
|
|
1870
1898
|
})
|
|
1871
|
-
}), $[10] = t1) : t1 = $[10], t2 = 1, t3 = splitTitle.slice(0, splitTitle.length - 1).map(_temp6), $[0] = props.field.title, $[1] = T0, $[2] = T1, $[3] = splitTitle, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4);
|
|
1899
|
+
}), $[10] = t1) : t1 = $[10], t2 = 1, t3 = splitTitle.slice(0, splitTitle.length - 1).map(_temp6$1), $[0] = props.field.title, $[1] = T0, $[2] = T1, $[3] = splitTitle, $[4] = t0, $[5] = t1, $[6] = t2, $[7] = t3, $[8] = t4);
|
|
1872
1900
|
let t5 = splitTitle[splitTitle.length - 1], t6;
|
|
1873
1901
|
$[11] === t5 ? t6 = $[12] : (t6 = /* @__PURE__ */ jsx(Box, {
|
|
1874
1902
|
marginTop: 1,
|
|
@@ -1891,7 +1919,7 @@ function FieldTitle(props) {
|
|
|
1891
1919
|
children: t7
|
|
1892
1920
|
}), $[20] = T1, $[21] = t4, $[22] = t7, $[23] = t8) : t8 = $[23], t8;
|
|
1893
1921
|
}
|
|
1894
|
-
function _temp6(pt, i) {
|
|
1922
|
+
function _temp6$1(pt, i) {
|
|
1895
1923
|
return /* @__PURE__ */ jsx(Box, {
|
|
1896
1924
|
marginTop: 1,
|
|
1897
1925
|
children: /* @__PURE__ */ jsx(Text, {
|
|
@@ -1902,13 +1930,13 @@ function _temp6(pt, i) {
|
|
|
1902
1930
|
}, i);
|
|
1903
1931
|
}
|
|
1904
1932
|
function useInterval(ms) {
|
|
1905
|
-
let $ = c(3), [tick, update] = useReducer(_temp$
|
|
1933
|
+
let $ = c(3), [tick, update] = useReducer(_temp$8, 0), t0, t1;
|
|
1906
1934
|
return $[0] === ms ? (t0 = $[1], t1 = $[2]) : (t0 = () => {
|
|
1907
1935
|
let i = setInterval(update, ms);
|
|
1908
1936
|
return () => clearInterval(i);
|
|
1909
1937
|
}, t1 = [ms], $[0] = ms, $[1] = t0, $[2] = t1), useEffect(t0, t1), tick;
|
|
1910
1938
|
}
|
|
1911
|
-
function _temp$
|
|
1939
|
+
function _temp$8(n) {
|
|
1912
1940
|
return n + 1;
|
|
1913
1941
|
}
|
|
1914
1942
|
function TimeAgo(t0) {
|
|
@@ -1924,7 +1952,7 @@ function TimeAgo(t0) {
|
|
|
1924
1952
|
}
|
|
1925
1953
|
const rotate = keyframes`0%{transform:rotate(0);}100%{transform:rotate(360deg);}`, SyncSpinningIcon = styled(SyncIcon).withConfig({
|
|
1926
1954
|
displayName: "SyncSpinningIcon",
|
|
1927
|
-
componentId: "sc-
|
|
1955
|
+
componentId: "sc-chle4-0"
|
|
1928
1956
|
})`animation:${rotate} 1s linear infinite;`, TASK_CONFIG = {
|
|
1929
1957
|
aborted: {
|
|
1930
1958
|
title: "Canceled",
|
|
@@ -1948,55 +1976,82 @@ const rotate = keyframes`0%{transform:rotate(0);}100%{transform:rotate(360deg);}
|
|
|
1948
1976
|
}
|
|
1949
1977
|
};
|
|
1950
1978
|
function InstructionTaskHistoryButton(props) {
|
|
1951
|
-
let { tasks, instructions, documentId, showTitles } = props,
|
|
1979
|
+
let $ = c(32), { tasks, instructions, documentId, showTitles } = props, t0;
|
|
1980
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = { apiVersion: "2023-01-01" }, $[0] = t0) : t0 = $[0];
|
|
1981
|
+
let client = useClient(t0), t1;
|
|
1982
|
+
$[1] !== client || $[2] !== documentId ? (t1 = (taskKey) => {
|
|
1952
1983
|
if (!documentId) return;
|
|
1953
1984
|
let statusDocId = assistTasksStatusId(documentId), basePath = `${typed("tasks")}[_key=="${taskKey}"]`;
|
|
1954
1985
|
client.patch(statusDocId).set({
|
|
1955
1986
|
[`${basePath}.${typed("ended")}`]: (/* @__PURE__ */ new Date()).toISOString(),
|
|
1956
1987
|
[`${basePath}.${typed("reason")}`]: typed("aborted")
|
|
1957
1988
|
}).commit().catch(console.error);
|
|
1958
|
-
}, [client, documentId
|
|
1959
|
-
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
}
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1989
|
+
}, $[1] = client, $[2] = documentId, $[3] = t1) : t1 = $[3];
|
|
1990
|
+
let cancelRun = t1, t;
|
|
1991
|
+
$[4] !== cancelRun || $[5] !== instructions || $[6] !== showTitles || $[7] !== tasks ? (t = tasks?.filter(_temp$7).map((task_0) => {
|
|
1992
|
+
let instruction = instructions?.find((i) => i._key === task_0.instructionKey);
|
|
1993
|
+
return {
|
|
1994
|
+
...task_0,
|
|
1995
|
+
title: showTitles ? task_0.title ?? getInstructionTitle(instruction) : void 0,
|
|
1996
|
+
cancel: () => cancelRun(task_0._key)
|
|
1997
|
+
};
|
|
1998
|
+
}) ?? [], t.sort(_temp2$5), $[4] = cancelRun, $[5] = instructions, $[6] = showTitles, $[7] = tasks, $[8] = t) : t = $[8];
|
|
1999
|
+
let titledTasks = t, t2;
|
|
2000
|
+
$[9] === titledTasks ? t2 = $[10] : (t2 = titledTasks.some(_temp3$3), $[9] = titledTasks, $[10] = t2);
|
|
2001
|
+
let isRunning = t2, t3;
|
|
2002
|
+
$[11] === titledTasks ? t3 = $[12] : (t3 = titledTasks.some(_temp4$2), $[11] = titledTasks, $[12] = t3);
|
|
2003
|
+
let hasErrors = t3, [open, setOpen] = useState(!1), t4;
|
|
2004
|
+
$[13] === Symbol.for("react.memo_cache_sentinel") ? (t4 = () => setOpen(_temp5$1), $[13] = t4) : t4 = $[13];
|
|
2005
|
+
let toggleOpen = t4, [button, setButton] = useState(null), [popover, setPopover] = useState(null), t5;
|
|
2006
|
+
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
1974
2007
|
setOpen(!1);
|
|
1975
|
-
}, []);
|
|
1976
|
-
|
|
1977
|
-
|
|
2008
|
+
}, $[14] = t5) : t5 = $[14];
|
|
2009
|
+
let handleClickOutside = t5, t6;
|
|
2010
|
+
$[15] !== button || $[16] !== popover ? (t6 = () => [button, popover], $[15] = button, $[16] = popover, $[17] = t6) : t6 = $[17], useClickOutsideEvent(handleClickOutside, t6);
|
|
2011
|
+
let t7;
|
|
2012
|
+
$[18] === button ? t7 = $[19] : (t7 = () => {
|
|
1978
2013
|
setOpen(!1), button?.focus();
|
|
1979
|
-
}, [button]);
|
|
1980
|
-
|
|
2014
|
+
}, $[18] = button, $[19] = t7);
|
|
2015
|
+
let handleEscape = t7, t8;
|
|
2016
|
+
$[20] !== handleEscape || $[21] !== titledTasks ? (t8 = /* @__PURE__ */ jsx(TaskList, {
|
|
2017
|
+
onEscape: handleEscape,
|
|
2018
|
+
tasks: titledTasks
|
|
2019
|
+
}), $[20] = handleEscape, $[21] = titledTasks, $[22] = t8) : t8 = $[22];
|
|
2020
|
+
let t9 = open && !!titledTasks?.length, t10 = !titledTasks?.length, t11;
|
|
2021
|
+
$[23] !== hasErrors || $[24] !== isRunning || $[25] !== open || $[26] !== t10 ? (t11 = /* @__PURE__ */ jsx(TaskStatusButton, {
|
|
2022
|
+
disabled: t10,
|
|
2023
|
+
hasErrors,
|
|
2024
|
+
isRunning,
|
|
2025
|
+
onClick: toggleOpen,
|
|
2026
|
+
ref: setButton,
|
|
2027
|
+
selected: open
|
|
2028
|
+
}), $[23] = hasErrors, $[24] = isRunning, $[25] = open, $[26] = t10, $[27] = t11) : t11 = $[27];
|
|
2029
|
+
let t12;
|
|
2030
|
+
return $[28] !== t11 || $[29] !== t8 || $[30] !== t9 ? (t12 = /* @__PURE__ */ jsx(Popover, {
|
|
1981
2031
|
constrainSize: !0,
|
|
1982
|
-
content:
|
|
1983
|
-
|
|
1984
|
-
tasks: titledTasks
|
|
1985
|
-
}),
|
|
1986
|
-
open: open && !!titledTasks?.length,
|
|
2032
|
+
content: t8,
|
|
2033
|
+
open: t9,
|
|
1987
2034
|
placement: "top",
|
|
1988
2035
|
portal: !0,
|
|
1989
2036
|
ref: setPopover,
|
|
1990
2037
|
width: 0,
|
|
1991
|
-
children:
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2038
|
+
children: t11
|
|
2039
|
+
}), $[28] = t11, $[29] = t8, $[30] = t9, $[31] = t12) : t12 = $[31], t12;
|
|
2040
|
+
}
|
|
2041
|
+
function _temp5$1(v) {
|
|
2042
|
+
return !v;
|
|
2043
|
+
}
|
|
2044
|
+
function _temp4$2(r_0) {
|
|
2045
|
+
return r_0.reason === "error" || r_0.reason === "timeout";
|
|
2046
|
+
}
|
|
2047
|
+
function _temp3$3(r) {
|
|
2048
|
+
return !r.ended;
|
|
2049
|
+
}
|
|
2050
|
+
function _temp2$5(a, b) {
|
|
2051
|
+
return new Date(b.started ?? "").getTime() - new Date(a.started ?? "").getTime();
|
|
2052
|
+
}
|
|
2053
|
+
function _temp$7(task) {
|
|
2054
|
+
return task.started && (/* @__PURE__ */ new Date()).getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs;
|
|
2000
2055
|
}
|
|
2001
2056
|
const TASK_STATUS_BUTTON_TOOLTIP_PROPS = { placement: "top" };
|
|
2002
2057
|
function TaskStatusButton(props) {
|
|
@@ -2020,7 +2075,7 @@ function TaskList(props) {
|
|
|
2020
2075
|
isTopLayer && event.key === "Escape" && onEscape();
|
|
2021
2076
|
}, $[0] = isTopLayer, $[1] = onEscape, $[2] = t0) : t0 = $[2], useGlobalKeyDown(t0);
|
|
2022
2077
|
let t1;
|
|
2023
|
-
$[3] === tasks ? t1 = $[4] : (t1 = tasks.map(
|
|
2078
|
+
$[3] === tasks ? t1 = $[4] : (t1 = tasks.map(_temp6), $[3] = tasks, $[4] = t1);
|
|
2024
2079
|
let t2;
|
|
2025
2080
|
return $[5] === t1 ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx(Stack, {
|
|
2026
2081
|
padding: 1,
|
|
@@ -2028,7 +2083,7 @@ function TaskList(props) {
|
|
|
2028
2083
|
children: t1
|
|
2029
2084
|
}), $[5] = t1, $[6] = t2), t2;
|
|
2030
2085
|
}
|
|
2031
|
-
function
|
|
2086
|
+
function _temp6(task) {
|
|
2032
2087
|
return /* @__PURE__ */ jsx(TaskItem, { task }, task._key);
|
|
2033
2088
|
}
|
|
2034
2089
|
function TaskItem(props) {
|
|
@@ -2118,7 +2173,7 @@ function TaskItem(props) {
|
|
|
2118
2173
|
*/
|
|
2119
2174
|
function isolatePathParams(nextParams, hostParams) {
|
|
2120
2175
|
let { path: nextLocalPath, ...restNext } = nextParams, { path: hostPath, ...restHost } = hostParams;
|
|
2121
|
-
return
|
|
2176
|
+
return dequal(restNext, restHost) ? {
|
|
2122
2177
|
nextLocalPath,
|
|
2123
2178
|
forwardParams: null
|
|
2124
2179
|
} : {
|
|
@@ -2131,10 +2186,10 @@ function isolatePathParams(nextParams, hostParams) {
|
|
|
2131
2186
|
}
|
|
2132
2187
|
const EMPTY_PANE_PARAMS = {}, CardWithShadowBelow = styled(Card).withConfig({
|
|
2133
2188
|
displayName: "CardWithShadowBelow",
|
|
2134
|
-
componentId: "sc-
|
|
2189
|
+
componentId: "sc-pz26f7-0"
|
|
2135
2190
|
})`position:relative;&:after{content:'';display:block;position:absolute;left:0;right:0;bottom:-1px;border-bottom:1px solid var(--card-border-color);opacity:0.5;z-index:100;}`, CardWithShadowAbove = styled(Card).withConfig({
|
|
2136
2191
|
displayName: "CardWithShadowAbove",
|
|
2137
|
-
componentId: "sc-
|
|
2192
|
+
componentId: "sc-pz26f7-1"
|
|
2138
2193
|
})`position:relative;&:after{content:'';display:block;position:absolute;left:0;right:0;top:-1px;border-top:1px solid var(--card-border-color);opacity:0.5;z-index:100;}`;
|
|
2139
2194
|
function AssistInspectorWrapper(props) {
|
|
2140
2195
|
let $ = c(43), context = useAiAssistanceConfig();
|
|
@@ -2310,7 +2365,7 @@ function AssistInspector(props) {
|
|
|
2310
2365
|
documentId,
|
|
2311
2366
|
schemaType,
|
|
2312
2367
|
initDoc: !0
|
|
2313
|
-
}), instruction = (assistDocument?.fields?.find((f) => f.path === typePath))?.instructions?.find((i) => i._key === instructionKey), tasks = useMemo(() => assistDocument?.tasks?.filter((
|
|
2368
|
+
}), instruction = (assistDocument?.fields?.find((f) => f.path === typePath))?.instructions?.find((i) => i._key === instructionKey), tasks = useMemo(() => assistDocument?.tasks?.filter((i) => !instructionKey || i.instructionKey === instructionKey), [assistDocument?.tasks, instructionKey]), instructions = useMemo(() => assistDocument?.fields?.flatMap((f) => f.instructions ?? []), [assistDocument?.fields]), promptValue = instruction?.prompt, isEmptyPrompt = useMemo(() => {
|
|
2314
2369
|
if (!promptValue?.length) return !0;
|
|
2315
2370
|
let children = promptValue[0]?.children;
|
|
2316
2371
|
return promptValue.length == 1 && children?.length === 1 && !children?.[0]?.text?.length;
|
|
@@ -2639,14 +2694,12 @@ const options = {
|
|
|
2639
2694
|
}
|
|
2640
2695
|
};
|
|
2641
2696
|
function AssistConnectorsOverlay(props) {
|
|
2642
|
-
let $ = c(
|
|
2643
|
-
$[0] ===
|
|
2697
|
+
let $ = c(12), { connectors } = props, [, setRedraw] = useState(!1), t0, t1;
|
|
2698
|
+
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => {
|
|
2644
2699
|
setRedraw(!0);
|
|
2645
|
-
}, $[0] =
|
|
2646
|
-
let t1;
|
|
2647
|
-
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t1 = [], $[2] = t1) : t1 = $[2], useEffect(t0, t1);
|
|
2700
|
+
}, t1 = [], $[0] = t0, $[1] = t1) : (t0 = $[0], t1 = $[1]), useEffect(t0, t1);
|
|
2648
2701
|
let t2;
|
|
2649
|
-
$[
|
|
2702
|
+
$[2] === Symbol.for("react.memo_cache_sentinel") ? (t2 = {
|
|
2650
2703
|
position: "absolute",
|
|
2651
2704
|
top: 0,
|
|
2652
2705
|
left: 0,
|
|
@@ -2654,23 +2707,23 @@ function AssistConnectorsOverlay(props) {
|
|
|
2654
2707
|
height: "100%",
|
|
2655
2708
|
pointerEvents: "none",
|
|
2656
2709
|
zIndex: 150
|
|
2657
|
-
}, $[
|
|
2710
|
+
}, $[2] = t2) : t2 = $[2];
|
|
2658
2711
|
let t3;
|
|
2659
|
-
$[
|
|
2712
|
+
$[3] === connectors ? t3 = $[4] : (t3 = connectors.map(_temp$6), $[3] = connectors, $[4] = t3);
|
|
2660
2713
|
let t4;
|
|
2661
|
-
$[
|
|
2714
|
+
$[5] === t3 ? t4 = $[6] : (t4 = /* @__PURE__ */ jsx("svg", {
|
|
2662
2715
|
fill: "none",
|
|
2663
2716
|
width: window.innerWidth,
|
|
2664
2717
|
height: window.innerHeight,
|
|
2665
2718
|
style: t2,
|
|
2666
2719
|
children: t3
|
|
2667
|
-
}), $[
|
|
2720
|
+
}), $[5] = t3, $[6] = t4);
|
|
2668
2721
|
let t5;
|
|
2669
|
-
$[
|
|
2722
|
+
$[7] === connectors ? t5 = $[8] : (t5 = !1, $[7] = connectors, $[8] = t5);
|
|
2670
2723
|
let t6;
|
|
2671
|
-
return $[
|
|
2724
|
+
return $[9] !== t4 || $[10] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Fragment, { children: [t4, t5] }), $[9] = t4, $[10] = t5, $[11] = t6) : t6 = $[11], t6;
|
|
2672
2725
|
}
|
|
2673
|
-
function _temp$
|
|
2726
|
+
function _temp$6(connector) {
|
|
2674
2727
|
return /* @__PURE__ */ jsx(ConnectorPath, {
|
|
2675
2728
|
from: connector.from,
|
|
2676
2729
|
options,
|
|
@@ -2836,7 +2889,7 @@ function FieldTranslationProvider(props) {
|
|
|
2836
2889
|
}
|
|
2837
2890
|
let preferred = getPreferredToFieldLanguages(from.id), allToLanguages = languages_0.filter((l) => l.id !== from?.id), filteredToLanguages = allToLanguages.filter((l_0) => !preferred.length || preferred.includes(l_0.id));
|
|
2838
2891
|
setToLanguages(filteredToLanguages);
|
|
2839
|
-
let fromId = from?.id, allToIds = allToLanguages?.map(_temp$
|
|
2892
|
+
let fromId = from?.id, allToIds = allToLanguages?.map(_temp$5) ?? [], docMembers = getDocumentMembersFlat(document, documentSchema, config?.maxPathDepth);
|
|
2840
2893
|
if (fromId && allToIds?.length) {
|
|
2841
2894
|
let transMap = getFieldLanguageMap(documentSchema, docMembers, fromId, allToIds.filter((toId) => fromId !== toId), config?.translationOutputs ?? defaultLanguageOutputs);
|
|
2842
2895
|
setFieldLanguageMaps(transMap);
|
|
@@ -2846,7 +2899,7 @@ function FieldTranslationProvider(props) {
|
|
|
2846
2899
|
$[6] === fromLanguage ? t4 = $[7] : (t4 = (toggledLang, toLanguages_0, languages_1) => {
|
|
2847
2900
|
if (!languages_1 || !fromLanguage) return;
|
|
2848
2901
|
let wasSelected = !!toLanguages_0?.find((l_2) => l_2.id === toggledLang.id), newToLangs = languages_1.filter((anyLang) => !!toLanguages_0?.find((selectedLang) => toggledLang.id !== selectedLang.id && selectedLang.id === anyLang.id) || toggledLang.id === anyLang.id && !wasSelected);
|
|
2849
|
-
setToLanguages(newToLangs), setPreferredToFieldLanguages(fromLanguage.id, newToLangs.map(_temp2$
|
|
2902
|
+
setToLanguages(newToLangs), setPreferredToFieldLanguages(fromLanguage.id, newToLangs.map(_temp2$4));
|
|
2850
2903
|
}, $[6] = fromLanguage, $[7] = t4);
|
|
2851
2904
|
let toggleToLanguage = t4, t5;
|
|
2852
2905
|
$[8] !== config || $[9] !== languageClient || $[10] !== selectFromLanguage ? (t5 = async (params_0) => {
|
|
@@ -2966,10 +3019,10 @@ function FieldTranslationProvider(props) {
|
|
|
2966
3019
|
children: [t11, props.children]
|
|
2967
3020
|
}), $[45] = contextValue, $[46] = props.children, $[47] = t11, $[48] = t12) : t12 = $[48], t12;
|
|
2968
3021
|
}
|
|
2969
|
-
function _temp2$
|
|
3022
|
+
function _temp2$4(l_3) {
|
|
2970
3023
|
return l_3.id;
|
|
2971
3024
|
}
|
|
2972
|
-
function _temp$
|
|
3025
|
+
function _temp$5(l_1) {
|
|
2973
3026
|
return l_1.id;
|
|
2974
3027
|
}
|
|
2975
3028
|
function ToLanguageCheckbox(props) {
|
|
@@ -3134,12 +3187,16 @@ function refToTypeNames(type) {
|
|
|
3134
3187
|
function removeUndef(obj) {
|
|
3135
3188
|
return Object.keys(obj).forEach((key) => obj[key] === void 0 ? delete obj[key] : {}), obj;
|
|
3136
3189
|
}
|
|
3137
|
-
|
|
3190
|
+
/**
|
|
3191
|
+
* @param maxFieldSelectionDepth - see `AssistConfig.maxFieldSelectionDepth`; uses the plugin
|
|
3192
|
+
* default when omitted
|
|
3193
|
+
*/
|
|
3194
|
+
function createFieldRefCache(maxFieldSelectionDepth) {
|
|
3138
3195
|
let byType = {};
|
|
3139
3196
|
function getRefsForType(schemaType) {
|
|
3140
3197
|
let documentType = schemaType.name, cached = byType[documentType];
|
|
3141
3198
|
if (cached) return cached;
|
|
3142
|
-
let fieldRefs = getFieldRefs(schemaType), refs = {
|
|
3199
|
+
let fieldRefs = getFieldRefs(schemaType, maxFieldSelectionDepth), refs = {
|
|
3143
3200
|
fieldRefs,
|
|
3144
3201
|
fieldRefsByTypePath: asFieldRefsByTypePath(fieldRefs)
|
|
3145
3202
|
};
|
|
@@ -3150,7 +3207,7 @@ function createFieldRefCache() {
|
|
|
3150
3207
|
function AiAssistanceConfigProvider(props) {
|
|
3151
3208
|
let $ = c(21), [status, setStatus] = useState(), [error, setError] = useState(), apiClient = useApiClient(props.config?.__customApiClient), { getInstructStatus, loading: statusLoading } = useGetInstructStatus(apiClient), { initInstruct, loading: initLoading } = useInitInstruct(apiClient), schema = useSchema(), t0;
|
|
3152
3209
|
$[0] === schema ? t0 = $[1] : (t0 = serializeSchema(schema, { leanFormat: !0 }), $[0] = schema, $[1] = t0);
|
|
3153
|
-
let serializedTypes = t0, { getFieldRefs, getFieldRefsByTypePath } = useFieldRefGetters(schema), t1, t2;
|
|
3210
|
+
let serializedTypes = t0, { getFieldRefs, getFieldRefsByTypePath } = useFieldRefGetters(schema, props.config.assist?.maxFieldSelectionDepth), t1, t2;
|
|
3154
3211
|
$[2] === getInstructStatus ? (t1 = $[3], t2 = $[4]) : (t1 = () => {
|
|
3155
3212
|
getInstructStatus().then((s) => setStatus(s)).catch((e) => {
|
|
3156
3213
|
console.error(e), setError(e);
|
|
@@ -3186,20 +3243,20 @@ function AiAssistanceConfigProvider(props) {
|
|
|
3186
3243
|
children
|
|
3187
3244
|
}), $[18] = children, $[19] = context, $[20] = t5) : t5 = $[20], t5;
|
|
3188
3245
|
}
|
|
3189
|
-
function useFieldRefGetters(schema) {
|
|
3190
|
-
let $ = c(
|
|
3191
|
-
$[0] ===
|
|
3246
|
+
function useFieldRefGetters(schema, maxFieldSelectionDepth) {
|
|
3247
|
+
let $ = c(7), t0;
|
|
3248
|
+
$[0] === maxFieldSelectionDepth ? t0 = $[1] : (t0 = createFieldRefCache(maxFieldSelectionDepth), $[0] = maxFieldSelectionDepth, $[1] = t0);
|
|
3192
3249
|
let getForSchemaType = t0, t1;
|
|
3193
|
-
$[
|
|
3250
|
+
$[2] !== getForSchemaType || $[3] !== schema ? (t1 = function getRefsForType(documentType) {
|
|
3194
3251
|
let schemaType = schema.get(documentType);
|
|
3195
3252
|
if (!schemaType) throw Error(`Schema type "${documentType}" not found`);
|
|
3196
3253
|
return getForSchemaType(schemaType);
|
|
3197
|
-
}, $[
|
|
3254
|
+
}, $[2] = getForSchemaType, $[3] = schema, $[4] = t1) : t1 = $[4];
|
|
3198
3255
|
let getRefsForType = t1, t2;
|
|
3199
|
-
return $[
|
|
3256
|
+
return $[5] === getRefsForType ? t2 = $[6] : (t2 = {
|
|
3200
3257
|
getFieldRefs: (documentType_0) => getRefsForType(documentType_0).fieldRefs,
|
|
3201
3258
|
getFieldRefsByTypePath: (documentType_1) => getRefsForType(documentType_1).fieldRefsByTypePath
|
|
3202
|
-
}, $[
|
|
3259
|
+
}, $[5] = getRefsForType, $[6] = t2), t2;
|
|
3203
3260
|
}
|
|
3204
3261
|
function AssistLayout(props) {
|
|
3205
3262
|
let $ = c(11), t0;
|
|
@@ -3452,7 +3509,7 @@ function useCustomFieldActions(props) {
|
|
|
3452
3509
|
pushToast,
|
|
3453
3510
|
addSyntheticTask,
|
|
3454
3511
|
removeSyntheticTask
|
|
3455
|
-
})).filter(isDefined), onlyGroups = customActions?.length && customActions?.every((
|
|
3512
|
+
})).filter(isDefined), onlyGroups = customActions?.length && customActions?.every((node) => node.type === "group");
|
|
3456
3513
|
return (customActions?.length ? onlyGroups ? customActions : [{
|
|
3457
3514
|
type: "group",
|
|
3458
3515
|
title: title || "Custom actions",
|
|
@@ -3781,26 +3838,57 @@ function createAssistDocumentPresence(documentId) {
|
|
|
3781
3838
|
};
|
|
3782
3839
|
}
|
|
3783
3840
|
function AssistDocumentPresence() {
|
|
3784
|
-
let { assistDocument, syntheticTasks } = useAssistDocumentContext()
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
|
|
3788
|
-
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3841
|
+
let $ = c(9), { assistDocument, syntheticTasks } = useAssistDocumentContext();
|
|
3842
|
+
assistDocument?.tasks;
|
|
3843
|
+
let t0;
|
|
3844
|
+
if ($[0] !== assistDocument?.tasks || $[1] !== syntheticTasks) {
|
|
3845
|
+
bb0: {
|
|
3846
|
+
let anyPresence = [...assistDocument?.tasks ?? [], ...syntheticTasks ?? []].filter(_temp$4)?.flatMap(_temp2$3).find(_temp3$2);
|
|
3847
|
+
if (anyPresence) {
|
|
3848
|
+
t0 = aiPresence(anyPresence, []);
|
|
3849
|
+
break bb0;
|
|
3850
|
+
}
|
|
3851
|
+
let t1;
|
|
3852
|
+
if ($[3] !== assistDocument?.tasks) {
|
|
3853
|
+
let anyRun = assistDocument?.tasks?.filter(_temp4$1)?.find(_temp5);
|
|
3854
|
+
t1 = anyRun ? aiPresence({
|
|
3855
|
+
started: anyRun.started,
|
|
3856
|
+
path: documentRootKey,
|
|
3857
|
+
_key: anyRun._key,
|
|
3858
|
+
_type: fieldPresenceTypeName
|
|
3859
|
+
}, []) : void 0, $[3] = assistDocument?.tasks, $[4] = t1;
|
|
3860
|
+
} else t1 = $[4];
|
|
3861
|
+
t0 = t1;
|
|
3862
|
+
}
|
|
3863
|
+
$[0] = assistDocument?.tasks, $[1] = syntheticTasks, $[2] = t0;
|
|
3864
|
+
} else t0 = $[2];
|
|
3865
|
+
let anyPresence_0 = t0, t1;
|
|
3866
|
+
$[5] === anyPresence_0 ? t1 = $[6] : (t1 = anyPresence_0 && /* @__PURE__ */ jsx(AiFieldPresence, { presence: anyPresence_0 }), $[5] = anyPresence_0, $[6] = t1);
|
|
3867
|
+
let t2;
|
|
3868
|
+
return $[7] === t1 ? t2 = $[8] : (t2 = /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Flex, {
|
|
3796
3869
|
flex: 1,
|
|
3797
3870
|
justify: "flex-end",
|
|
3798
3871
|
children: /* @__PURE__ */ jsx(Flex, {
|
|
3799
3872
|
gap: 2,
|
|
3800
3873
|
align: "center",
|
|
3801
|
-
children:
|
|
3874
|
+
children: t1
|
|
3802
3875
|
})
|
|
3803
|
-
}) });
|
|
3876
|
+
}) }), $[7] = t1, $[8] = t2), t2;
|
|
3877
|
+
}
|
|
3878
|
+
function _temp5(f_0) {
|
|
3879
|
+
return f_0.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f_0.started).getTime() < 3e4;
|
|
3880
|
+
}
|
|
3881
|
+
function _temp4$1(run_1) {
|
|
3882
|
+
return !run_1.ended && !run_1.reason;
|
|
3883
|
+
}
|
|
3884
|
+
function _temp3$2(f) {
|
|
3885
|
+
return f.started && (/* @__PURE__ */ new Date()).getTime() - new Date(f.started).getTime() < 3e4;
|
|
3886
|
+
}
|
|
3887
|
+
function _temp2$3(run_0) {
|
|
3888
|
+
return run_0.presence ?? [];
|
|
3889
|
+
}
|
|
3890
|
+
function _temp$4(run) {
|
|
3891
|
+
return !run.ended && !run.reason;
|
|
3804
3892
|
}
|
|
3805
3893
|
function BackToInstructionListLink() {
|
|
3806
3894
|
let $ = c(4), { openInspector } = useDocumentPane(), t0;
|
|
@@ -3962,37 +4050,40 @@ function _temp$3(m) {
|
|
|
3962
4050
|
return m.kind === "error" && m.fieldName === "fields";
|
|
3963
4051
|
}
|
|
3964
4052
|
function useSelectedSchema(fieldPath, documentSchema) {
|
|
3965
|
-
let $ = c(
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
break bb0;
|
|
3970
|
-
}
|
|
3971
|
-
if (fieldPath === "<document>") {
|
|
3972
|
-
t0 = documentSchema;
|
|
3973
|
-
break bb0;
|
|
3974
|
-
}
|
|
3975
|
-
let t1;
|
|
3976
|
-
$[0] === fieldPath ? t1 = $[1] : (t1 = stringToPath(fieldPath), $[0] = fieldPath, $[1] = t1);
|
|
3977
|
-
let path = t1, currentSchema = documentSchema;
|
|
3978
|
-
for (let i = 0; i < path.length; i++) {
|
|
3979
|
-
let segment = path[i], field = currentSchema?.fields.find((f) => f.name === segment);
|
|
3980
|
-
if (!field) {
|
|
4053
|
+
let $ = c(5), t0;
|
|
4054
|
+
if ($[0] !== documentSchema || $[1] !== fieldPath) {
|
|
4055
|
+
bb0: {
|
|
4056
|
+
if (!fieldPath) {
|
|
3981
4057
|
t0 = void 0;
|
|
3982
4058
|
break bb0;
|
|
3983
4059
|
}
|
|
3984
|
-
if (
|
|
3985
|
-
t0 =
|
|
4060
|
+
if (fieldPath === "<document>") {
|
|
4061
|
+
t0 = documentSchema;
|
|
3986
4062
|
break bb0;
|
|
3987
4063
|
}
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
4064
|
+
let t1;
|
|
4065
|
+
$[3] === fieldPath ? t1 = $[4] : (t1 = stringToPath(fieldPath), $[3] = fieldPath, $[4] = t1);
|
|
4066
|
+
let path = t1, currentSchema = documentSchema;
|
|
4067
|
+
for (let i = 0; i < path.length; i++) {
|
|
4068
|
+
let segment = path[i], field = currentSchema?.fields.find((f) => f.name === segment);
|
|
4069
|
+
if (!field) {
|
|
4070
|
+
t0 = void 0;
|
|
4071
|
+
break bb0;
|
|
4072
|
+
}
|
|
4073
|
+
if (i === path.length - 1) {
|
|
4074
|
+
t0 = field.type;
|
|
4075
|
+
break bb0;
|
|
4076
|
+
}
|
|
4077
|
+
if (field.type.jsonType !== "object") {
|
|
4078
|
+
t0 = void 0;
|
|
4079
|
+
break bb0;
|
|
4080
|
+
}
|
|
4081
|
+
currentSchema = field.type;
|
|
3991
4082
|
}
|
|
3992
|
-
|
|
4083
|
+
t0 = currentSchema;
|
|
3993
4084
|
}
|
|
3994
|
-
|
|
3995
|
-
}
|
|
4085
|
+
$[0] = documentSchema, $[1] = fieldPath, $[2] = t0;
|
|
4086
|
+
} else t0 = $[2];
|
|
3996
4087
|
return t0;
|
|
3997
4088
|
}
|
|
3998
4089
|
function FieldsInitializer(t0) {
|
|
@@ -4188,16 +4279,15 @@ function InstructionInput(props) {
|
|
|
4188
4279
|
}), $[1] = props, $[2] = t1), t1;
|
|
4189
4280
|
}
|
|
4190
4281
|
function ObjectMember(t0) {
|
|
4191
|
-
let $ = c(
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
} else props = $[1], t1 = $[2];
|
|
4282
|
+
let $ = c(9), fieldName, props;
|
|
4283
|
+
$[0] === t0 ? (fieldName = $[1], props = $[2]) : ({fieldName, ...props} = t0, $[0] = t0, $[1] = fieldName, $[2] = props);
|
|
4284
|
+
let t1;
|
|
4285
|
+
$[3] !== fieldName || $[4] !== props.members ? (t1 = findFieldMember(props.members, fieldName), $[3] = fieldName, $[4] = props.members, $[5] = t1) : t1 = $[5];
|
|
4196
4286
|
let member = t1, t2;
|
|
4197
|
-
return $[
|
|
4287
|
+
return $[6] !== member || $[7] !== props ? (t2 = member ? /* @__PURE__ */ jsx(ObjectInputMember, {
|
|
4198
4288
|
...props,
|
|
4199
4289
|
member
|
|
4200
|
-
}) : null, $[
|
|
4290
|
+
}) : null, $[6] = member, $[7] = props, $[8] = t2) : t2 = $[8], t2;
|
|
4201
4291
|
}
|
|
4202
4292
|
const NONE = [];
|
|
4203
4293
|
function NameField(props) {
|
|
@@ -4483,7 +4573,7 @@ function Selectable(t0) {
|
|
|
4483
4573
|
}
|
|
4484
4574
|
const PteMods = styled(Box).withConfig({
|
|
4485
4575
|
displayName: "PteMods",
|
|
4486
|
-
componentId: "sc-
|
|
4576
|
+
componentId: "sc-lca06y-0"
|
|
4487
4577
|
})`& [data-testid='pt-editor__toolbar-card'] > div > div:last-child{display:none;}& [data-testid='pt-editor']{min-height:300px;}& [data-testid='pt-editor'] .pt-inline-object *{max-width:400px;}`;
|
|
4488
4578
|
function PromptInput(props) {
|
|
4489
4579
|
let $ = c(5);
|
|
@@ -4621,46 +4711,55 @@ const contextDocumentSchema = defineType({
|
|
|
4621
4711
|
};
|
|
4622
4712
|
}
|
|
4623
4713
|
}
|
|
4624
|
-
})
|
|
4625
|
-
|
|
4626
|
-
|
|
4627
|
-
|
|
4628
|
-
|
|
4629
|
-
|
|
4630
|
-
|
|
4631
|
-
|
|
4714
|
+
});
|
|
4715
|
+
/**
|
|
4716
|
+
* The validation rule resolves the selected path against the same field-ref tree the field picker
|
|
4717
|
+
* offers, so it has to be built with the same `assist.maxFieldSelectionDepth`.
|
|
4718
|
+
*/
|
|
4719
|
+
function createFieldReferenceType(maxFieldSelectionDepth) {
|
|
4720
|
+
return defineType({
|
|
4721
|
+
type: "object",
|
|
4722
|
+
name: fieldReferenceTypeName,
|
|
4632
4723
|
title: "Field",
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4641
|
-
|
|
4642
|
-
if (!
|
|
4643
|
-
|
|
4644
|
-
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
4649
|
-
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
}
|
|
4659
|
-
|
|
4660
|
-
|
|
4661
|
-
|
|
4662
|
-
|
|
4663
|
-
|
|
4724
|
+
icon: ThListIcon,
|
|
4725
|
+
fields: [defineField({
|
|
4726
|
+
type: "string",
|
|
4727
|
+
name: "path",
|
|
4728
|
+
title: "Field",
|
|
4729
|
+
components: { input: FieldRefPathInput },
|
|
4730
|
+
validation: (rule) => {
|
|
4731
|
+
let getForSchemaType = createFieldRefCache(maxFieldSelectionDepth);
|
|
4732
|
+
return rule.custom((value, context) => {
|
|
4733
|
+
if (!value) return "Please select a field";
|
|
4734
|
+
try {
|
|
4735
|
+
let docId = context.document?._id;
|
|
4736
|
+
if (!docId) return "Field reference cannot be used outside document inspector context. Could not resolve document id.";
|
|
4737
|
+
if (!docId.startsWith("sanity.assist.schemaType.")) return `Field reference cannot be used outside document inspector context. Could not resolve document id: ${docId}`;
|
|
4738
|
+
let targetDocType = docId.slice(25), schema = context.schema.get(targetDocType);
|
|
4739
|
+
if (!schema) return `Field reference cannot be used outside document inspector context. Could not resolve schema: ${targetDocType}`;
|
|
4740
|
+
let { fieldRefs } = getForSchemaType(schema);
|
|
4741
|
+
return fieldRefs.find((r) => r.key === value) ? !0 : `Field with path "${value}" does not exist in the schema.`;
|
|
4742
|
+
} catch (e) {
|
|
4743
|
+
return console.error("Failed to resolve field reference", e), "Invalid field reference.";
|
|
4744
|
+
}
|
|
4745
|
+
});
|
|
4746
|
+
}
|
|
4747
|
+
})],
|
|
4748
|
+
preview: {
|
|
4749
|
+
select: { path: "path" },
|
|
4750
|
+
prepare({ path }) {
|
|
4751
|
+
return {
|
|
4752
|
+
title: path,
|
|
4753
|
+
path,
|
|
4754
|
+
icon: CodeIcon
|
|
4755
|
+
};
|
|
4756
|
+
}
|
|
4757
|
+
},
|
|
4758
|
+
components: { preview: FieldRefPreview },
|
|
4759
|
+
options: { modal: { type: "popover" } }
|
|
4760
|
+
});
|
|
4761
|
+
}
|
|
4762
|
+
const userInput = defineType({
|
|
4664
4763
|
type: "object",
|
|
4665
4764
|
name: userInputTypeName,
|
|
4666
4765
|
title: "User input",
|
|
@@ -4736,7 +4835,7 @@ const contextDocumentSchema = defineType({
|
|
|
4736
4835
|
annotations: []
|
|
4737
4836
|
},
|
|
4738
4837
|
of: [
|
|
4739
|
-
defineArrayMember({ type:
|
|
4838
|
+
defineArrayMember({ type: fieldReferenceTypeName }),
|
|
4740
4839
|
defineArrayMember({ type: promptContext.name }),
|
|
4741
4840
|
defineArrayMember({ type: userInput.name })
|
|
4742
4841
|
]
|
|
@@ -4986,29 +5085,37 @@ function excludeComments(type) {
|
|
|
4986
5085
|
..."of" in type ? { of: type.of?.map((arrayItemType) => excludeComments(arrayItemType)) } : {}
|
|
4987
5086
|
};
|
|
4988
5087
|
}
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5002
|
-
|
|
5003
|
-
|
|
5004
|
-
|
|
5005
|
-
|
|
5088
|
+
/**
|
|
5089
|
+
* @param maxFieldSelectionDepth - see `AssistConfig.maxFieldSelectionDepth`; the field reference
|
|
5090
|
+
* type validates picked paths against the field-ref tree, which must be built with the same depth
|
|
5091
|
+
*/
|
|
5092
|
+
function createSchemaTypes(maxFieldSelectionDepth) {
|
|
5093
|
+
return [
|
|
5094
|
+
...[
|
|
5095
|
+
fieldInstructions,
|
|
5096
|
+
instruction,
|
|
5097
|
+
createFieldReferenceType(maxFieldSelectionDepth),
|
|
5098
|
+
prompt,
|
|
5099
|
+
userInput,
|
|
5100
|
+
promptContext
|
|
5101
|
+
].map(excludeComments),
|
|
5102
|
+
outputFieldType,
|
|
5103
|
+
outputTypeType,
|
|
5104
|
+
assistDocumentSchema,
|
|
5105
|
+
documentInstructionStatus,
|
|
5106
|
+
instructionTask,
|
|
5107
|
+
contextDocumentSchema
|
|
5108
|
+
];
|
|
5109
|
+
}
|
|
5110
|
+
const assist = definePlugin((config) => {
|
|
5111
|
+
let configWithDefaults = config ?? {}, styleguide = configWithDefaults.translate?.styleguide || "", maxPathDepth = configWithDefaults.assist?.maxPathDepth, maxFieldSelectionDepth = configWithDefaults.assist?.maxFieldSelectionDepth, temperature = configWithDefaults.assist?.temperature;
|
|
5006
5112
|
if (typeof styleguide == "string" && validateStyleguide(styleguide), maxPathDepth !== void 0 && (maxPathDepth < 1 || maxPathDepth > 12)) throw Error(`[${packageName}]: \`assist.maxPathDepth\` must be be in the range [1,12] inclusive, but was ${maxPathDepth}`);
|
|
5113
|
+
if (maxFieldSelectionDepth !== void 0 && (!Number.isInteger(maxFieldSelectionDepth) || maxFieldSelectionDepth < 1 || maxFieldSelectionDepth > 12)) throw Error(`[${packageName}]: \`assist.maxFieldSelectionDepth\` must be an integer in the range [1,12] inclusive, but was ${maxFieldSelectionDepth}`);
|
|
5007
5114
|
if (temperature !== void 0 && (temperature < 0 || temperature > 1)) throw Error(`[${packageName}]: \`assist.temperature\` must be in the range [0,1] inclusive, but was ${temperature}`);
|
|
5008
5115
|
return {
|
|
5009
5116
|
name: packageName,
|
|
5010
5117
|
handlesGDR: !0,
|
|
5011
|
-
schema: { types:
|
|
5118
|
+
schema: { types: createSchemaTypes(maxFieldSelectionDepth) },
|
|
5012
5119
|
i18n: { bundles: [{}] },
|
|
5013
5120
|
document: {
|
|
5014
5121
|
inspectors: (prev, context) => {
|
|
@@ -5076,8 +5183,8 @@ function useListeningQuery(query, t0, t1) {
|
|
|
5076
5183
|
let $ = c(11), params = t0 === void 0 ? DEFAULT_PARAMS : t0, options = t1 === void 0 ? DEFAULT_OPTIONS : t1, [loading, setLoading] = useState(!0), [error, setError] = useState(!1), [data, setData] = useState(null), subscription = useRef(null), t2;
|
|
5077
5184
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t2 = { apiVersion: "v2022-05-09" }, $[0] = t2) : t2 = $[0];
|
|
5078
5185
|
let client = useClient(t2), t3, t4;
|
|
5079
|
-
$[1] !== client || $[2] !== options || $[3] !== params || $[4] !== query ? (t3 = () => (query && (subscription.current = listenQuery(client, query, params, options).pipe(distinctUntilChanged(
|
|
5080
|
-
setData((current) =>
|
|
5186
|
+
$[1] !== client || $[2] !== options || $[3] !== params || $[4] !== query ? (t3 = () => (query && (subscription.current = listenQuery(client, query, params, options).pipe(distinctUntilChanged(dequal), catchError((err) => (console.error(err), setError(!0), setLoading(!1), setData(null), of(null)))).subscribe((documents) => {
|
|
5187
|
+
setData((current) => dequal(current, documents) ? current : documents), setLoading(!1), setError(!1);
|
|
5081
5188
|
})), () => subscription.current ? subscription.current.unsubscribe() : void 0), t4 = [
|
|
5082
5189
|
query,
|
|
5083
5190
|
params,
|