Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/assist

Package Overview
Dependencies
Maintainers
47
Versions
62
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/assist - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

35

package.json
{
"name": "@sanity/assist",
"version": "2.0.4",
"version": "2.0.5",
"description": "You create the instructions; Sanity AI Assist does the rest.",

@@ -68,4 +68,4 @@ "keywords": [

"devDependencies": {
"@commitlint/cli": "^18.4.3",
"@commitlint/config-conventional": "^18.4.3",
"@commitlint/cli": "^19.2.1",
"@commitlint/config-conventional": "^19.1.0",
"@rollup/plugin-image": "^3.0.3",

@@ -75,22 +75,21 @@ "@sanity/pkg-utils": "^2.4.10",

"@sanity/semantic-release-preset": "^4.1.7",
"@types/react": "^18.2.37",
"@types/styled-components": "^5.1.30",
"@typescript-eslint/eslint-plugin": "^7.0.1",
"@typescript-eslint/parser": "^7.0.1",
"@types/react": "^18.2.75",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"date-fns": "^2.30.0",
"eslint": "^8.56.0",
"eslint-config-prettier": "^8.10.0",
"eslint-config-sanity": "^6.0.0",
"eslint-plugin-prettier": "^4.2.1",
"eslint-plugin-react": "^7.33.2",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"eslint-config-sanity": "^7.1.2",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-react": "^7.34.1",
"eslint-plugin-react-hooks": "^4.6.0",
"npm-run-all": "^4.1.5",
"npm-run-all2": "^5.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.5",
"sanity": "^3.28.0",
"semantic-release": "^23.0.2",
"styled-components": "^6.1.1",
"typescript": "^5.3.3",
"vitest": "^1.2.1"
"sanity": "^3.36.4",
"semantic-release": "^23.0.7",
"styled-components": "^6.1.8",
"typescript": "5.4.2",
"vitest": "^1.4.0"
},

@@ -97,0 +96,0 @@ "peerDependencies": {

@@ -615,3 +615,3 @@ # @sanity/assist

`*[_type == "language" && $market in markets]{ id, title }`,
{market}
{market},
)

@@ -693,3 +693,3 @@ return response

translateFromLanguageId,
translateToLanguageIds
translateToLanguageIds,
) {

@@ -696,0 +696,0 @@ const parentIsLanguageWrapper =

import {createContext} from 'react'
import {ConnectorsStore} from './ConnectorsStore'
export const ConnectorsStoreContext = createContext<ConnectorsStore | null>(null)
export * from './ConnectFromRegion'
export * from './ConnectToRegion'
export * from './ConnectorRegion'

@@ -7,4 +6,5 @@ export * from './ConnectorsProvider'

export * from './ConnectorsStoreContext'
export * from './ConnectToRegion'
export * from './mapConnectorToLine'
export * from './types'
export * from './useConnectorsStore'

@@ -12,3 +12,3 @@ import {

rect: Rect,
bounds: Rect
bounds: Rect,
): ConnectorLinePoint {

@@ -34,3 +34,3 @@ const centerY = rect.y + rect.h / 2

options: ConnectorOptions,
connector: {from: ConnectorRegionRects; to: ConnectorRegionRects}
connector: {from: ConnectorRegionRects; to: ConnectorRegionRects},
): ConnectorLine {

@@ -37,0 +37,0 @@ const fromBounds: Rect = {

import {useContext} from 'react'
import {ConnectorsStore} from './ConnectorsStore'
import {ConnectorsStoreContext} from './ConnectorsStoreContext'
import {ConnectorsStore} from './ConnectorsStore'

@@ -5,0 +6,0 @@ export function useConnectorsStore(): ConnectorsStore {

import {useEffect, useMemo, useRef, useState} from 'react'
import {hasOverflowScroll} from './helpers'
import {Rect, Scroll} from './types'
import {hasOverflowScroll} from './helpers'

@@ -126,3 +127,3 @@ export function useRegionRects() {

},
[relativeBoundsRect, boundsScroll]
[relativeBoundsRect, boundsScroll],
)

@@ -138,3 +139,3 @@

},
[relativeElementRect, scroll]
[relativeElementRect, scroll],
)

@@ -141,0 +142,0 @@

@@ -22,3 +22,3 @@ import {SanityClient} from '@sanity/client'

params: ListenQueryParams,
options: ListenQueryOptions
options: ListenQueryOptions,
) =>

@@ -30,3 +30,3 @@ defer(() =>

filterResponse: true,
})
}),
)

@@ -38,3 +38,3 @@

params: ListenQueryParams,
options: ListenQueryOptions
options: ListenQueryOptions,
) =>

@@ -48,7 +48,7 @@ defer(() =>

tag: options.tag,
})
}),
) as Observable<ReconnectEvent | WelcomeEvent | MutationEvent>
function isWelcomeEvent(
event: MutationEvent | ReconnectEvent | WelcomeEvent
event: MutationEvent | ReconnectEvent | WelcomeEvent,
): event is WelcomeEvent {

@@ -63,3 +63,3 @@ return event.type === 'welcome'

params: ListenQueryParams = {},
options: ListenQueryOptions = {}
options: ListenQueryOptions = {},
) => {

@@ -81,4 +81,4 @@ const fetchQuery = typeof query === 'string' ? query : query.fetch

? 'Could not establish EventSource connection'
: `Received unexpected type of first event "${ev.type}"`
)
: `Received unexpected type of first event "${ev.type}"`,
),
)

@@ -88,3 +88,3 @@ }

}),
share()
share(),
)

@@ -105,5 +105,5 @@

filter(isRelevantEvent),
switchMap((event) => merge(of(event), of(event).pipe(delay(options.throttleTime || 1000))))
)
switchMap((event) => merge(of(event), of(event).pipe(delay(options.throttleTime || 1000)))),
),
).pipe(exhaustMapToWithTrailing(fetchOnce$))
}
import {isArraySchemaType, isObjectSchemaType, ObjectItem, SchemaType} from 'sanity'
import {randomKey} from '../randomKey'

@@ -26,3 +27,3 @@

throw new Error(
`Invalid item type: "${type.type}". Default array input can only contain objects (for now)`
`Invalid item type: "${type.type}". Default array input can only contain objects (for now)`,
)

@@ -29,0 +30,0 @@ }

import {useEffect, useRef, useState} from 'react'
import isEqual from 'react-fast-compare'
import {catchError, distinctUntilChanged} from 'rxjs/operators'
import isEqual from 'react-fast-compare'
import {ListenQueryOptions, useClient} from 'sanity'
import {listenQuery} from './fixedListenQuery'

@@ -25,3 +26,3 @@

params: Params = DEFAULT_PARAMS,
options: ListenQueryOptions = DEFAULT_OPTIONS
options: ListenQueryOptions = DEFAULT_OPTIONS,
): ReturnShape<T> {

@@ -47,3 +48,3 @@ const [loading, setLoading] = useState(true)

return err
})
}),
)

@@ -50,0 +51,0 @@ .subscribe((documents) => {

@@ -7,3 +7,3 @@ import {ConnectorLine, ConnectorOptions} from '../../_lib/connector'

y: number,
dir: number
dir: number,
): string {

@@ -58,6 +58,6 @@ return [

fromX + options.arrow.marginX,
fromY - options.arrow.threshold + options.arrow.marginY
fromY - options.arrow.threshold + options.arrow.marginY,
),
lineTo(fromX + options.arrow.marginX, fromY - r0),
quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY)
quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY),
)

@@ -68,6 +68,6 @@ } else if (from.isBelow) {

fromX + options.arrow.marginX,
fromY + options.arrow.threshold - options.arrow.marginY
fromY + options.arrow.threshold - options.arrow.marginY,
),
lineTo(fromX + options.arrow.marginX, fromY + r0),
quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY)
quadCurve(fromX + options.arrow.marginX, fromY, fromX + options.arrow.marginX + r0, fromY),
)

@@ -88,3 +88,3 @@ } else {

quadCurve(dividerX, toY, dividerX, toY - cornerRadius),
lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY)
lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY),
)

@@ -95,3 +95,3 @@ } else {

quadCurve(dividerX, fromY, dividerX, fromY - cornerRadius),
lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY)
lineTo(dividerX, toY - options.arrow.threshold + options.arrow.marginY),
)

@@ -108,3 +108,3 @@ }

dividerX - options.arrow.marginX,
fromY - r1
fromY - r1,
),

@@ -116,7 +116,7 @@ lineTo(dividerX - options.arrow.marginX, toY + r1),

dividerX - options.arrow.marginX + r1,
toY
toY,
),
lineTo(dividerX - cornerRadius, toY),
quadCurve(dividerX, toY, dividerX, toY + cornerRadius),
lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY)
lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY),
)

@@ -127,3 +127,3 @@ } else {

quadCurve(dividerX, fromY, dividerX, fromY + cornerRadius),
lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY)
lineTo(dividerX, toY + options.arrow.threshold - options.arrow.marginY),
)

@@ -137,3 +137,3 @@ }

quadCurve(dividerX, toY, dividerX + r1, toY),
lineTo(toX, toY)
lineTo(toX, toY),
)

@@ -146,3 +146,3 @@ } else {

quadCurve(dividerX, toY, dividerX + r1, toY),
lineTo(toX, toY)
lineTo(toX, toY),
)

@@ -149,0 +149,0 @@ }

@@ -5,3 +5,3 @@ import {FieldError, FieldMember, FieldSetMember, ObjectMember} from 'sanity'

members: ObjectMember[],
fieldName: string
fieldName: string,
): FieldMember | FieldError | undefined {

@@ -11,3 +11,3 @@ return members.find(

(m.kind === 'field' && m.name === fieldName) ||
(m.kind === 'error' && m.fieldName === fieldName)
(m.kind === 'error' && m.fieldName === fieldName),
)

@@ -18,7 +18,7 @@ }

members: ObjectMember[],
fieldsetName: string
fieldsetName: string,
): FieldSetMember | undefined {
return members.find(
(m): m is FieldSetMember => m.kind === 'fieldSet' && m.fieldSet.name === fieldsetName
(m): m is FieldSetMember => m.kind === 'fieldSet' && m.fieldSet.name === fieldsetName,
)
}
import {useEffect, useMemo} from 'react'
import {type ObjectSchemaType, typed, useClient, useCurrentUser} from 'sanity'
import {maxHistoryVisibilityMs} from '../../constants'
import {assistDocumentId, assistTasksStatusId} from '../../helpers/ids'
import {
assistDocumentTypeName,
AssistTasksStatus,
type AssistTasksStatus,
assistTasksStatusTypeName,
InstructionTask,
StudioAssistDocument,
StudioAssistField,
StudioInstruction,
type InstructionTask,
type StudioAssistDocument,
type StudioAssistField,
type StudioInstruction,
} from '../../types'
import {ObjectSchemaType, typed, useClient, useCurrentUser} from 'sanity'
import {useDocumentState} from './useDocumentState'
import {assistDocumentId, assistTasksStatusId} from '../../helpers/ids'
import {maxHistoryVisibilityMs} from '../../constants'

@@ -32,7 +33,7 @@ interface UseAssistDocumentProps {

assistDocumentId(documentTypeName),
assistDocumentTypeName
assistDocumentTypeName,
)
const assistTasksStatus = useDocumentState<AssistTasksStatus>(
assistTasksStatusId(documentId ?? ''),
assistTasksStatusTypeName
assistTasksStatusTypeName,
)

@@ -49,3 +50,3 @@

})
.catch((e) => {
.catch(() => {
// best effort

@@ -88,3 +89,3 @@ })

instruction: StudioInstruction,
run: InstructionTask[]
run: InstructionTask[],
): StudioInstruction {

@@ -98,5 +99,5 @@ return {

task.started &&
new Date().getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs
new Date().getTime() - new Date(task.started).getTime() < maxHistoryVisibilityMs,
),
}
}

@@ -10,2 +10,4 @@ import {

} from '@sanity/icons'
import {extractWithPath} from '@sanity/mutator'
import {ComponentType, useContext, useMemo} from 'react'
import {

@@ -22,9 +24,8 @@ ArraySchemaType,

} from 'sanity'
import {ComponentType, useContext, useMemo} from 'react'
import {AssistInspectorRouteParams, documentRootKey, fieldPathParam} from '../types'
import {type PaneRouterContextValue, usePaneRouter} from 'sanity/desk'
import {SelectedFieldContext} from '../assistDocument/components/SelectedFieldContext'
import {isAssistSupported} from '../helpers/assistSupported'
import {isPortableTextArray, isType} from '../helpers/typeUtils'
import {SelectedFieldContext} from '../assistDocument/components/SelectedFieldContext'
import {extractWithPath} from '@sanity/mutator'
import {AssistInspectorRouteParams, documentRootKey, fieldPathParam} from '../types'

@@ -79,3 +80,3 @@ export interface FieldRef {

parent?: FieldRef,
depth = 0
depth = 0,
): FieldRef[] {

@@ -177,3 +178,3 @@ if (depth >= maxDepth) {

documentSchemaType?: SchemaType,
path?: string
path?: string,
): FieldRef | undefined {

@@ -185,3 +186,3 @@ const selectableFields = useMemo(

: [],
[documentSchemaType]
[documentSchemaType],
)

@@ -215,5 +216,5 @@

return useMemo(
() => ({...paneRouter, params: paneRouter.params ?? {}} as AiPaneRouter),
[paneRouter]
() => ({...paneRouter, params: paneRouter.params ?? {}}) as AiPaneRouter,
[paneRouter],
)
}
import {SparklesIcon} from '@sanity/icons'
import {DocumentInspector, typed} from 'sanity'
import {pluginTitle} from '../constants'
import {AssistInspectorRouteParams, fieldPathParam, instructionParam} from '../types'
import {AssistInspectorWrapper} from './AssistInspector'
import {aiInspectorId} from './constants'
import {AssistInspectorWrapper} from './AssistInspector'
import {AssistInspectorRouteParams, fieldPathParam, instructionParam} from '../types'
import {pluginTitle} from '../constants'

@@ -8,0 +9,0 @@ export const assistInspector: DocumentInspector = {

import {ReferenceOptions, SchemaType} from 'sanity'
import {AssistOptions} from '../schemas/typeDefExtensions'

@@ -3,0 +4,0 @@ import {isType} from './typeUtils'

@@ -1,4 +0,5 @@

import {describe, expect, test} from 'vitest'
import {Schema} from '@sanity/schema'
import {ArraySchemaType, defineField, defineType, ObjectSchemaType} from 'sanity'
import {describe, expect, test} from 'vitest'
import {getConditionalMembers} from './conditionalMembers'

@@ -5,0 +6,0 @@

/* eslint-disable max-depth */
import {
ArrayOfObjectsFormNode,
ArrayOfObjectsItemMember,
ArrayOfPrimitivesFormNode,
DocumentFormNode,
FieldsetState,
type ArrayOfObjectsFormNode,
type ArrayOfObjectsItemMember,
type ArrayOfPrimitivesFormNode,
type DocumentFormNode,
type FieldsetState,
isObjectSchemaType,
ObjectFormNode,
Path,
type ObjectFormNode,
type Path,
pathToString,
SchemaType,
type SchemaType,
} from 'sanity'

@@ -47,5 +47,8 @@

}
return [doc, ...extractConditionalPaths(docState, MAX_DEPTH)]
.filter((v) => v.conditional)
.map(({conditional, ...state}) => ({...state}))
return (
[doc, ...extractConditionalPaths(docState, MAX_DEPTH)]
.filter((v) => v.conditional)
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.map(({conditional, ...state}) => ({...state}))
)
}

@@ -72,3 +75,3 @@

node: ObjectFormNode | FieldsetState,
maxDepth: number
maxDepth: number,
): ConditionalMemberInnerState[] {

@@ -95,3 +98,3 @@ if (node.path.length >= maxDepth) {

const isObjectsArray = array.members.some(
(m) => m.kind === 'item' && isObjectSchemaType(m.item.schemaType)
(m) => m.kind === 'item' && isObjectSchemaType(m.item.schemaType),
)

@@ -118,3 +121,3 @@ if (!array.readOnly) {

const conditionalFieldset = !!(node as ObjectFormNode).schemaType?.fieldsets?.some(
(f) => !f.single && f.name === member.fieldSet.name && typeof f.hidden === 'function'
(f) => !f.single && f.name === member.fieldSet.name && typeof f.hidden === 'function',
)

@@ -121,0 +124,0 @@ const innerFields = extractConditionalPaths(member.fieldSet, maxDepth).map((f) => ({

@@ -1,5 +0,6 @@

import {documentRootKey, StudioInstruction} from '../types'
import {useMemo} from 'react'
import {Path, pathToString} from 'sanity'
import {useMemo} from 'react'
import {documentRootKey, StudioInstruction} from '../types'
export function usePathKey(path: Path | string) {

@@ -6,0 +7,0 @@ return useMemo(() => {

@@ -33,3 +33,3 @@ import {ArraySchemaType, ImageOptions, SchemaType} from 'sanity'

export function getImageInstructionFieldOption(
schemaType: SchemaType | undefined
schemaType: SchemaType | undefined,
): string | undefined {

@@ -36,0 +36,0 @@ if (!schemaType) {

@@ -0,3 +1,4 @@

import {useMemo} from 'react'
import {Path, SchemaType} from 'sanity'
import {useMemo} from 'react'
import {isAssistSupported} from './assistSupported'

@@ -4,0 +5,0 @@

@@ -25,3 +25,3 @@ import {useCallback, useState} from 'react'

const [showOnboarding, setShowOnboarding] = useState(
() => !isFeatureOnboardingDismissed(featureKey)
() => !isFeatureOnboardingDismissed(featureKey),
)

@@ -28,0 +28,0 @@ const dismissOnboarding = useCallback(() => {

import {useMemo} from 'react'
import {FormNodePresence, isKeySegment, Path, stringToPath} from 'sanity'
import {type FormNodePresence, isKeySegment, type Path, stringToPath} from 'sanity'
import {useAssistDocumentContext} from '../assistDocument/AssistDocumentContext'
import {AiPresence} from '../types'
import {maxHistoryVisibilityMs, pluginTitle} from '../constants'
import type {AiPresence} from '../types'

@@ -20,3 +21,4 @@ const NO_PRESENCE: FormNodePresence[] = []

(p) =>
p.started && new Date().getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs
p.started &&
new Date().getTime() - new Date(p.started).getTime() < maxHistoryVisibilityMs,
)

@@ -52,2 +54,3 @@ .filter((presence) => {

// eslint-disable-next-line @typescript-eslint/no-unused-vars
export function aiPresence(presence: AiPresence, path: Path, title?: string): FormNodePresence {

@@ -54,0 +57,0 @@ return {

/* eslint-disable camelcase */
import {ArrayOfType, FieldProps, SchemaTypeDefinition} from 'sanity'
import {

@@ -16,3 +18,2 @@ assistDocumentSchema,

import {contextDocumentSchema} from './contextDocumentSchema'
import {FieldProps, SchemaTypeDefinition, ArrayOfType} from 'sanity'

@@ -19,0 +20,0 @@ function excludeComments<T extends SchemaTypeDefinition | ArrayOfType>(type: T): T {

@@ -1,6 +0,7 @@

import {describe, expect, test} from 'vitest'
import {Schema} from '@sanity/schema'
import {serializeSchema} from './serializeSchema'
import {defineArrayMember, defineField, defineType} from 'sanity'
import {describe, expect, test} from 'vitest'
import {AssistOptions} from '../typeDefExtensions'
import {serializeSchema} from './serializeSchema'

@@ -7,0 +8,0 @@ const mockStudioTypes = [

@@ -12,2 +12,5 @@ import {

} from 'sanity'
import {isAssistSupported} from '../../helpers/assistSupported'
import {isType} from '../../helpers/typeUtils'
import {

@@ -21,4 +24,2 @@ assistSchemaIdPrefix,

import {hiddenTypes} from './schemaUtils'
import {isAssistSupported} from '../../helpers/assistSupported'
import {isType} from '../../helpers/typeUtils'

@@ -59,3 +60,3 @@ interface Options {

schema: Schema,
options?: Options
options?: Options,
): SerializedSchemaType {

@@ -84,3 +85,3 @@ if (!schemaType.type?.name) {

typeName: string,
options: Options | undefined
options: Options | undefined,
) {

@@ -95,3 +96,3 @@ const schemaOptions: SerializedSchemaType['options'] = removeUndef({

? type?.options?.list.map((v: string | {value: string; title: string}) =>
typeof v === 'string' ? v : v.value ?? `${v.title}`
typeof v === 'string' ? v : v.value ?? `${v.title}`,
)

@@ -122,4 +123,4 @@ : undefined,

: type.readOnly
? true
: undefined,
? true
: undefined,
})

@@ -131,3 +132,3 @@ }

schemaType: ObjectSchemaType,
options: Options | undefined
options: Options | undefined,
) {

@@ -148,3 +149,3 @@ const fields = schemaType.fieldsets

},
}))
})),
)

@@ -163,3 +164,3 @@ : schemaType.fields

name: string,
options: Options | undefined
options: Options | undefined,
): SerializedSchemaMember {

@@ -180,3 +181,3 @@ const typeNameExists = !!schema.get(type?.name)

schema: Schema,
options: Options | undefined
options: Options | undefined,
): SerializedSchemaMember[] | undefined {

@@ -194,3 +195,3 @@ const childrenField = blockSchemaType.fields.find((f) => f.name === 'children')

schema,
options
options,
)

@@ -202,3 +203,3 @@ }

schema: Schema,
options: Options | undefined
options: Options | undefined,
): SerializedSchemaMember[] | undefined {

@@ -216,3 +217,3 @@ const markDefs = blockSchemaType.fields.find((f) => f.name === 'markDefs')

schema: Schema,
options: Options | undefined
options: Options | undefined,
): SerializedSchemaMember[] {

@@ -219,0 +220,0 @@ return arrayType.of

@@ -0,4 +1,5 @@

import {CodeIcon, StarIcon} from '@sanity/icons'
import {defineField, defineType} from 'sanity'
import {assistSerializedFieldTypeName, assistSerializedTypeName} from '../types'
import {CodeIcon, StarIcon} from '@sanity/icons'

@@ -5,0 +6,0 @@ export const serializedSchemaField = defineType({

@@ -0,7 +1,7 @@

import get from 'lodash/get'
import {SanityDocumentLike} from 'sanity'
import get from 'lodash/get'
export const getLanguageParams = (
select: Record<string, string> | undefined,
document: SanityDocumentLike | undefined
document: SanityDocumentLike | undefined,
): Record<string, unknown> => {

@@ -19,3 +19,3 @@ if (!select || !document) {

value = value.filter((item) =>
typeof item === 'object' ? item?._type !== 'reference' || '_ref' in item : true
typeof item === 'object' ? item?._type !== 'reference' || '_ref' in item : true,
)

@@ -22,0 +22,0 @@ }

@@ -1,7 +0,14 @@

import {describe, expect, test} from 'vitest'
import {Schema} from '@sanity/schema'
import {defineType, ObjectSchemaType, pathToString, SanityDocumentLike, typed} from 'sanity'
import {
defineType,
type ObjectSchemaType,
pathToString,
type SanityDocumentLike,
typed,
} from 'sanity'
import {describe, expect, test} from 'vitest'
import {
defaultLanguageOutputs,
FieldLanguageMap,
type FieldLanguageMap,
getDocumentMembersFlat,

@@ -85,3 +92,3 @@ getFieldLanguageMap,

},
])
]),
)

@@ -88,0 +95,0 @@ })

@@ -0,12 +1,13 @@

import {extractWithPath} from '@sanity/mutator'
import {
isDocumentSchemaType,
isKeySegment,
ObjectSchemaType,
Path,
type ObjectSchemaType,
type Path,
pathToString,
SanityDocumentLike,
type SanityDocumentLike,
} from 'sanity'
import {extractWithPath} from '@sanity/mutator'
import {DocumentMember, TranslationOutput, TranslationOutputsFunction} from './types'
import type {DocumentMember, TranslationOutput, TranslationOutputsFunction} from './types'
export interface FieldLanguageMap {

@@ -33,3 +34,3 @@ inputLanguageId: string

path: Path,
maxDepth: number
maxDepth: number,
): DocumentMember[] {

@@ -79,3 +80,3 @@ if (path.length >= maxDepth) {

itemSchema,
}
},
)

@@ -88,3 +89,3 @@ }

itemPath,
maxDepth
maxDepth,
)

@@ -118,3 +119,3 @@ const arrayMember = {

translateFromLanguageId,
translateToLanguageIds
translateToLanguageIds,
) {

@@ -153,3 +154,3 @@ if (

outputLanguageIds: string[],
langFn: TranslationOutputsFunction
langFn: TranslationOutputsFunction,
): FieldLanguageMap[] {

@@ -167,3 +168,3 @@ const translationMaps: FieldLanguageMap[] = []

translateFromLanguageId,
outputLanguageIds
outputLanguageIds,
)?.filter((translation) => translation.id !== translateFromLanguageId)

@@ -170,0 +171,0 @@

@@ -25,3 +25,3 @@ import {Path, SanityClient, SchemaType} from 'sanity'

translateFromLanguageId: string,
translateToLanguageIds: string[]
translateToLanguageIds: string[],
) => TranslationOutput[] | undefined

@@ -31,3 +31,3 @@

client: SanityClient,
selectedLanguageParams: Record<string, unknown>
selectedLanguageParams: Record<string, unknown>,
) => Promise<Language[]>

@@ -34,0 +34,0 @@

@@ -50,3 +50,3 @@ import {Path, pathToString, useClient, useCurrentUser, useSchema} from 'sanity'

() => (customApiClient ? customApiClient(client) : client),
[client, customApiClient]
[client, customApiClient],
)

@@ -106,3 +106,3 @@ }

},
[setLoading, apiClient, toast, user, types]
[setLoading, apiClient, toast, user, types],
)

@@ -115,3 +115,3 @@

}),
[translate, loading]
[translate, loading],
)

@@ -161,3 +161,3 @@ }

},
[setLoading, apiClient, toast, user, types]
[setLoading, apiClient, toast, user, types],
)

@@ -170,3 +170,3 @@

}),
[generateCaption, loading]
[generateCaption, loading],
)

@@ -216,3 +216,3 @@ }

},
[setLoading, apiClient, toast, user, types]
[setLoading, apiClient, toast, user, types],
)

@@ -225,3 +225,3 @@

}),
[generateImage, loading]
[generateImage, loading],
)

@@ -311,3 +311,3 @@ }

},
[apiClient, types, user, toast]
[apiClient, types, user, toast],
)

@@ -320,4 +320,4 @@

}),
[runInstruction, loading]
[runInstruction, loading],
)
}

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc