{"version":3,"file":"useDocument.mjs","sources":["../../../admin/src/hooks/useDocument.ts"],"sourcesContent":["/**\n * This hook doesn't use a context provider because we fetch directly from the server,\n * this sounds expensive but actually, it's really not. Because we have redux-toolkit-query\n * being a cache layer so if nothing invalidates the cache, we don't fetch again.\n */\n\nimport * as React from 'react';\n\nimport {\n useNotification,\n useAPIErrorHandler,\n useQueryParams,\n FormErrors,\n getYupValidationErrors,\n useForm,\n} from '@strapi/admin/strapi-admin';\nimport { useIntl } from 'react-intl';\nimport { useParams } from 'react-router-dom';\nimport { ValidationError } from 'yup';\n\nimport { SINGLE_TYPES } from '../constants/collections';\nimport { type AnyData, transformDocument } from '../pages/EditView/utils/data';\nimport { createDefaultForm } from '../pages/EditView/utils/forms';\nimport { useGetDocumentQuery } from '../services/documents';\nimport { buildValidParams } from '../utils/api';\nimport { createYupSchema } from '../utils/validation';\n\nimport { useContentTypeSchema, ComponentsDictionary } from './useContentTypeSchema';\nimport { useDocumentLayout } from './useDocumentLayout';\n\nimport type { FindOne } from '../../../shared/contracts/collection-types';\nimport type { ContentType } from '../../../shared/contracts/content-types';\nimport type { Modules } from '@strapi/types';\n\ninterface UseDocumentArgs {\n collectionType: string;\n model: string;\n documentId?: string;\n params?: object;\n}\n\ntype UseDocumentOpts = Parameters[1];\n\ntype Document = FindOne.Response['data'];\n\ntype Schema = ContentType;\n\ntype UseDocument = (\n args: UseDocumentArgs,\n opts?: UseDocumentOpts\n) => {\n /**\n * These are the schemas of the components used in the content type, organised\n * by their uid.\n */\n components: ComponentsDictionary;\n document?: Document;\n meta?: FindOne.Response['meta'];\n isLoading: boolean;\n /**\n * This is the schema of the content type, it is not the same as the layout.\n */\n schema?: Schema;\n schemas?: Schema[];\n hasError?: boolean;\n refetch: () => void;\n validate: (document: Document) => null | FormErrors;\n /**\n * Get the document's title\n */\n getTitle: (mainField: string) => string;\n /**\n * Get the initial form values for the document\n */\n getInitialFormValues: (isCreatingDocument?: boolean) => AnyData | undefined;\n};\n\n/**\n * Mirrors the server's `isLocalizedAttribute` in\n * `packages/plugins/i18n/server/src/services/content-types.ts`: an attribute\n * counts as localized only when `pluginOptions.i18n.localized` is explicitly\n * `true`. Both `false` and `undefined` mean \"non-localized\" — important here\n * because attributes created without the i18n plugin omit the field entirely,\n * and we still want them inherited when creating a new locale draft.\n */\nconst isLocalizedAttribute = (attribute: { pluginOptions?: object }): boolean => {\n // `pluginOptions` on the base attribute is typed as `object`, so we have to\n // narrow it to the i18n-specific shape here.\n const i18nOptions = attribute.pluginOptions as { i18n?: { localized?: boolean } } | undefined;\n return i18nOptions?.i18n?.localized === true;\n};\n\n/* -------------------------------------------------------------------------------------------------\n * useDocument\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @alpha\n * @public\n * @description Returns a document based on the model, collection type & id passed as arguments.\n * Also extracts its schema from the redux cache to be used for creating a validation schema.\n * @example\n * ```tsx\n * const { id, model, collectionType } = useParams<{ id: string; model: string; collectionType: string }>();\n *\n * if(!model || !collectionType) return null;\n *\n * const { document, isLoading, validate } = useDocument({ documentId: id, model, collectionType, params: { locale: 'en-GB' } })\n * const { update } = useDocumentActions()\n *\n * const onSubmit = async (document: Document) => {\n * const errors = validate(document);\n *\n * if(errors) {\n * // handle errors\n * }\n *\n * await update({ collectionType, model, id }, document)\n * }\n * ```\n *\n */\nconst useDocument: UseDocument = (args, opts) => {\n const { toggleNotification } = useNotification();\n const { _unstableFormatAPIError: formatAPIError } = useAPIErrorHandler();\n const { formatMessage } = useIntl();\n\n const {\n currentData: data,\n isLoading: isLoadingDocument,\n isFetching: isFetchingDocument,\n error,\n refetch,\n } = useGetDocumentQuery(args, {\n ...opts,\n skip: (!args.documentId && args.collectionType !== SINGLE_TYPES) || opts?.skip,\n });\n const document = data?.data;\n const meta = data?.meta;\n\n const {\n components,\n schema,\n schemas,\n isLoading: isLoadingSchema,\n } = useContentTypeSchema(args.model);\n const isSingleType = schema?.kind === 'singleType';\n\n const getTitle = React.useCallback(\n (mainField: string) => {\n // Always use mainField if it's not an id\n if (mainField !== 'id' && document?.[mainField]) {\n return document[mainField];\n }\n\n // When it's a singleType without a mainField, use the contentType displayName\n if (schema?.kind === 'singleType' && schema.info.displayName) {\n return formatMessage({\n id: schema.info.displayName,\n defaultMessage: schema.info.displayName,\n });\n }\n\n // Otherwise, use a fallback\n return formatMessage({\n id: 'content-manager.containers.untitled',\n defaultMessage: 'Untitled',\n });\n },\n [document, formatMessage, schema]\n );\n\n React.useEffect(() => {\n if (error) {\n toggleNotification({\n type: 'danger',\n message: formatAPIError(error),\n });\n }\n }, [toggleNotification, error, formatAPIError, args.collectionType]);\n\n const validationSchema = React.useMemo(() => {\n if (!schema) {\n return null;\n }\n\n return createYupSchema(schema.attributes, components);\n }, [schema, components]);\n\n const validate = React.useCallback(\n (document: Modules.Documents.AnyDocument): FormErrors | null => {\n if (!validationSchema) {\n throw new Error(\n 'There is no validation schema generated, this is likely due to the schema not being loaded yet.'\n );\n }\n\n try {\n validationSchema.validateSync(document, { abortEarly: false, strict: true });\n return null;\n } catch (error) {\n if (error instanceof ValidationError) {\n return getYupValidationErrors(error);\n }\n\n throw error;\n }\n },\n [validationSchema]\n );\n\n /**\n * Schema attributes that should be inherited from a sibling locale when\n * creating a new locale draft.\n *\n * Scope intentionally matches what the server populates into\n * `meta.availableLocales` (see `packages/core/content-manager/server/src/services/document-metadata.ts`):\n * - non-localized — `isLocalizedAttribute` semantics, so attributes whose\n * `pluginOptions.i18n.localized` is `undefined` count as non-localized\n * (an attribute created without the i18n plugin has no i18n options at\n * all but is still inherited at save by `copyNonLocalizedFields`).\n * - scalar or media — `component` / `dynamiczone` / `relation` are excluded\n * because the server doesn't populate them in `availableLocales` either,\n * so there'd be nothing to copy from.\n */\n const nonLocalizedScalarAndMediaFields = React.useMemo(() => {\n if (!schema?.attributes) {\n return [];\n }\n\n return Object.keys(schema.attributes).filter((name) => {\n const attribute = schema.attributes[name];\n\n if (isLocalizedAttribute(attribute)) {\n return false;\n }\n\n return (\n attribute.type !== 'component' &&\n attribute.type !== 'dynamiczone' &&\n attribute.type !== 'relation'\n );\n });\n }, [schema]);\n\n /**\n * Here we prepare the form for editing, we need to:\n * - remove prohibited fields from the document (passwords | ADD YOURS WHEN THERES A NEW ONE)\n * - swap out count objects on relations for empty arrays\n * - set __temp_key__ on array objects for drag & drop\n *\n * We also prepare the form for new documents, so we need to:\n * - set default values on fields\n * - inherit non-localized scalar/media values from a sibling locale.\n * Scope is intentionally limited to scalars and media — that is exactly\n * what the server populates into `meta.availableLocales` (see\n * `packages/core/content-manager/server/src/services/document-metadata.ts`).\n * Components, dynamic zones, and relations are not in that payload; the\n * server fills them at save time via `copyNonLocalizedFields` (in\n * `packages/core/core/src/services/document-service/internationalization.ts`)\n * when the new locale row is first created.\n * Baking the inheritance into `initialValues` here is what lets it survive\n * `
` re-inits: the `SET_INITIAL_VALUES` effect in\n * `packages/core/admin/admin/src/components/Form.tsx` re-applies these\n * values whenever `initialValues` changes (e.g. after a locale switch),\n * which the previous side-effect-based prefill in `LocalePickerAction`\n * could not survive on revisits.\n */\n const getInitialFormValues = React.useCallback(\n (isCreatingDocument: boolean = false) => {\n if ((!document && !isCreatingDocument && !isSingleType) || !schema) {\n return undefined;\n }\n\n /**\n * Check that we have an ID so we know the\n * document has been created in some way.\n */\n if (document?.id) {\n return transformDocument(schema, components)(document);\n }\n\n let form: AnyData = createDefaultForm(schema, components);\n\n // Intentionally use `availableLocales[0]`:\n // - The server sorts `getAvailableLocales` with the default locale first\n // (see `document-metadata.ts`), so index 0 is the canonical inheritance\n // source. Sibling locales can drift on non-localized fields because the\n // server only syncs them at locale-creation time, not on subsequent\n // updates — preferring the default keeps the surfaced values stable.\n // - Avoids coupling this hook to `useGetLocalesQuery` just to find the\n // default locale.\n const sibling = meta?.availableLocales?.[0] as Record | undefined;\n if (sibling && nonLocalizedScalarAndMediaFields.length > 0) {\n const inherited = nonLocalizedScalarAndMediaFields.reduce((acc, name) => {\n if (name in sibling) {\n acc[name] = sibling[name];\n }\n return acc;\n }, {});\n\n form = { ...form, ...inherited };\n }\n\n return transformDocument(schema, components)(form);\n },\n [\n document,\n isSingleType,\n schema,\n components,\n meta?.availableLocales,\n nonLocalizedScalarAndMediaFields,\n ]\n );\n\n const isLoading = isLoadingDocument || isFetchingDocument || isLoadingSchema;\n const hasError = !!error;\n\n return React.useMemo(\n () =>\n ({\n components,\n document,\n meta,\n isLoading,\n hasError,\n schema,\n schemas,\n validate,\n getTitle,\n getInitialFormValues,\n refetch,\n }) satisfies ReturnType,\n [\n components,\n document,\n meta,\n isLoading,\n hasError,\n schema,\n schemas,\n validate,\n getTitle,\n getInitialFormValues,\n refetch,\n ]\n );\n};\n\n/* -------------------------------------------------------------------------------------------------\n * useDoc\n * -----------------------------------------------------------------------------------------------*/\n\n/**\n * @internal this hook uses the router to extract the model, collection type & id from the url.\n * therefore, it shouldn't be used outside of the content-manager because it won't work as intended.\n */\nconst useDoc = (opts?: UseDocumentOpts) => {\n const { id, slug, collectionType, origin } = useParams<{\n id: string;\n origin: string;\n slug: string;\n collectionType: string;\n }>();\n const [{ query }] = useQueryParams();\n const params = React.useMemo(() => buildValidParams(query), [query]);\n\n if (!collectionType) {\n throw new Error('Could not find collectionType in url params');\n }\n\n if (!slug) {\n throw new Error('Could not find model in url params');\n }\n\n const document = useDocument(\n { documentId: origin || id, model: slug, collectionType, params },\n {\n ...opts,\n skip: id === 'create' || (!origin && !id && collectionType !== SINGLE_TYPES) || opts?.skip,\n }\n );\n\n const returnId = origin || (id === 'create' ? undefined : id);\n\n return {\n collectionType,\n model: slug,\n id: returnId,\n ...document,\n };\n};\n\n/**\n * @public\n * @experimental\n * Content manager context hooks for plugin development.\n * Make sure to use this hook inside the content manager.\n */\nconst useContentManagerContext = () => {\n const {\n collectionType,\n model,\n id,\n components,\n isLoading: isLoadingDoc,\n schema,\n schemas,\n } = useDoc();\n\n const layout = useDocumentLayout(model);\n\n const form = useForm('useContentManagerContext', (state) => state);\n\n const isSingleType = collectionType === SINGLE_TYPES;\n const slug = model;\n const isCreatingEntry = id === 'create';\n\n const {} = useContentTypeSchema();\n\n const isLoading = isLoadingDoc || layout.isLoading;\n const error = layout.error;\n\n return {\n error,\n isLoading,\n\n // Base metadata\n model,\n collectionType,\n id,\n slug,\n isCreatingEntry,\n isSingleType,\n hasDraftAndPublish: schema?.options?.draftAndPublish ?? false,\n\n // All schema infos\n components,\n contentType: schema,\n contentTypes: schemas,\n\n // Form state\n form,\n\n // layout infos\n layout,\n };\n};\n\nexport { useDocument, useDoc, useContentManagerContext };\nexport type { UseDocument, UseDocumentArgs, Document, Schema, ComponentsDictionary };\n"],"names":["isLocalizedAttribute","attribute","i18nOptions","pluginOptions","i18n","localized","useDocument","args","opts","toggleNotification","useNotification","_unstableFormatAPIError","formatAPIError","useAPIErrorHandler","formatMessage","useIntl","currentData","data","isLoading","isLoadingDocument","isFetching","isFetchingDocument","error","refetch","useGetDocumentQuery","skip","documentId","collectionType","SINGLE_TYPES","document","meta","components","schema","schemas","isLoadingSchema","useContentTypeSchema","model","isSingleType","kind","getTitle","React","useCallback","mainField","info","displayName","id","defaultMessage","useEffect","type","message","validationSchema","useMemo","createYupSchema","attributes","validate","Error","validateSync","abortEarly","strict","ValidationError","getYupValidationErrors","nonLocalizedScalarAndMediaFields","Object","keys","filter","name","getInitialFormValues","isCreatingDocument","undefined","transformDocument","form","createDefaultForm","sibling","availableLocales","length","inherited","reduce","acc","hasError","useDoc","slug","origin","useParams","query","useQueryParams","params","buildValidParams","returnId","useContentManagerContext","isLoadingDoc","layout","useDocumentLayout","useForm","state","isCreatingEntry","hasDraftAndPublish","options","draftAndPublish","contentType","contentTypes"],"mappings":";;;;;;;;;;;;;;AA6EA;;;;;;;IAQA,MAAMA,uBAAuB,CAACC,SAAAA,GAAAA;;;IAG5B,MAAMC,WAAAA,GAAcD,UAAUE,aAAa;IAC3C,OAAOD,WAAAA,EAAaE,MAAMC,SAAAA,KAAc,IAAA;AAC1C,CAAA;AAEA;;;;;;;;;;;;;;;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