{"version":3,"file":"DataManagerContext.mjs","sources":["../../../../admin/src/components/DataManager/DataManagerContext.ts"],"sourcesContent":["/* eslint-disable check-file/filename-naming-convention */\nimport { createContext } from 'react';\n\nimport type { AttributeRenameMigrationMode } from './RenameMigrationModal';\nimport type { ContentStructure, FolderSelection, SectionKey } from './utils/contentStructure';\nimport type { Component, ContentType } from '../../types';\nimport type { ComponentWithChildren } from './utils/retrieveComponentsThatHaveComponents';\nimport type { NestedComponent } from './utils/retrieveNestedComponents';\nimport type { Internal, Struct } from '@strapi/types';\n\nexport interface DataManagerContextValue {\n  isLoading: boolean;\n  addAttribute: (opts: {\n    attributeToSet: Record<string, unknown>;\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n  }) => void;\n  editAttribute: (opts: {\n    attributeToSet: Record<string, unknown>;\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    name: string;\n    recordRename?: boolean;\n    declineRename?: boolean;\n    recordTargetRename?: boolean;\n    declineTargetRename?: boolean;\n  }) => void;\n  moveAttribute: (opts: {\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    from: number;\n    to: number;\n  }) => void;\n  addCustomFieldAttribute: (params: {\n    attributeToSet: Record<string, unknown>;\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n  }) => void;\n  editCustomFieldAttribute: (params: {\n    attributeToSet: Record<string, unknown>;\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    name: string;\n    recordRename?: boolean;\n    declineRename?: boolean;\n  }) => void;\n  /**\n   * Resolves the user's consent to preserve data for one rename hop performed\n   * in the attribute form: `true` records the hop, `false` declines it (and the\n   * rest of its chain), `null` means the user cancelled the edit.\n   */\n  confirmAttributeRenameMigration: (rename: {\n    forTarget: Struct.ModelType;\n    uid: Internal.UID.Schema;\n    oldName: string;\n    newName: string;\n  }) => Promise<boolean | null>;\n  /** Effective `renameMigrations.attributes` plugin setting. */\n  attributeRenameMigrationMode: AttributeRenameMigrationMode;\n  addCreatedComponentToDynamicZone: (opts: {\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    dynamicZoneTarget: string;\n    componentsToAdd: Internal.UID.Component[];\n  }) => void;\n  createComponentSchema: (opts: {\n    data: {\n      icon?: string;\n      displayName: string;\n    };\n    componentCategory: string;\n    uid: Internal.UID.Component;\n  }) => void;\n  createSchema: (opts: {\n    data: {\n      displayName: string;\n      singularName: string;\n      pluralName: string;\n      kind: Struct.ContentTypeKind;\n      draftAndPublish: boolean;\n      pluginOptions: Record<string, unknown>;\n    };\n    uid: Internal.UID.Schema;\n    folder?: FolderSelection;\n  }) => void;\n  changeDynamicZoneComponents: (opts: {\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    dynamicZoneTarget: string;\n    newComponents: Internal.UID.Component[];\n  }) => void;\n  removeAttribute: (opts: {\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    attributeToRemoveName: string;\n  }) => void;\n  deleteComponent(uid: Internal.UID.Component): void;\n  deleteContentType(uid: Internal.UID.ContentType): void;\n  contentStructure: ContentStructure;\n  createFolder: (opts: { section: SectionKey; name: string; parentId: string | null }) => void;\n  renameFolder: (opts: { section: SectionKey; id: string; name: string }) => void;\n  moveFolder: (opts: {\n    section: SectionKey;\n    id: string;\n    newParentId: string | null;\n    index?: number;\n  }) => void;\n  deleteFolderOnly: (opts: { section: SectionKey; id: string }) => void;\n  deleteFolderAndContent: (opts: {\n    section: SectionKey;\n    id: string;\n    contentTypeUids: Internal.UID.ContentType[];\n  }) => void;\n  assignContentTypeToFolder: (opts: {\n    section: SectionKey;\n    uid: Internal.UID.ContentType;\n    targetGroupId: string | null;\n    index?: number;\n  }) => void;\n  reorderFolderChildren: (opts: {\n    section: SectionKey;\n    groupId: string;\n    from: number;\n    to: number;\n  }) => void;\n  removeComponentFromDynamicZone: (opts: {\n    forTarget: Struct.ModelType;\n    targetUid: Internal.UID.Schema;\n    dzName: string;\n    componentToRemoveIndex: number;\n  }) => void;\n  sortedContentTypesList: {\n    visible: ContentType['visible'];\n    name: ContentType['uid'];\n    title: ContentType['info']['displayName'];\n    plugin: ContentType['plugin'];\n    uid: ContentType['uid'];\n    to: string;\n    kind: ContentType['kind'];\n    restrictRelationsTo: ContentType['restrictRelationsTo'];\n    status: ContentType['status'];\n  }[];\n  updateComponentSchema: (opts: {\n    data: {\n      icon?: string;\n      displayName: string;\n    };\n    componentUID: Internal.UID.Component;\n  }) => void;\n  updateComponentUid: (opts: {\n    newComponentUID: Internal.UID.Component;\n    componentUID: Internal.UID.Component;\n  }) => void;\n  updateSchema: (opts: {\n    data: {\n      displayName: string;\n      kind: Struct.ContentTypeKind;\n      draftAndPublish: boolean;\n      pluginOptions: Record<string, unknown>;\n    };\n    uid: Internal.UID.ContentType;\n    folder?: FolderSelection;\n  }) => void;\n  initialComponents: Record<Internal.UID.Component, Component>;\n  components: Record<Internal.UID.Component, Component>;\n  componentsGroupedByCategory: Record<string, Component[]>;\n  componentsThatHaveOtherComponentInTheirAttributes: ComponentWithChildren[];\n  initialContentTypes: Record<Internal.UID.ContentType, ContentType>;\n  contentTypes: Record<Internal.UID.ContentType, ContentType>;\n  isInDevelopmentMode?: boolean;\n  nestedComponents: NestedComponent[];\n  reservedNames: {\n    models: string[];\n    attributes: string[];\n  };\n  allComponentsCategories: string[];\n  saveSchema(): Promise<void>;\n  isModified: boolean;\n  isSaving: boolean;\n  /**\n   * Applies a whole-type change (AI chat). Rename hops declared by the change\n   * go through the same preservation consent as manual renames, so this may\n   * prompt the user. Resolves `false` when the user cancelled and nothing was\n   * applied.\n   */\n  applyChange: (opts: {\n    action: 'add' | 'update' | 'delete';\n    schema: ContentType | Component;\n  }) => Promise<boolean>;\n  history: {\n    undo(): void;\n    redo(): void;\n    discardAllChanges(): void;\n    canUndo: boolean;\n    canRedo: boolean;\n    canDiscardAll: boolean;\n  };\n}\n\n// @ts-expect-error need to pass initial value to params\nexport const DataManagerContext = createContext<DataManagerContextValue>();\n"],"names":["DataManagerContext","createContext"],"mappings":";;AAuMA;AACO,MAAMA,qBAAqBC,aAAAA;;;;"}