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,GAAgB,cAChBC,GAAa,eACbW,GAAc,eACd1S,GAAc,qBACd6L,GAAoB,4BACpBE,GAA2B,4BAC3BC,GAA2B,gBAC3B+G,GAAe,uBACfC,GAAsB,uBACtBwS,IACElR,G,gBCrNJ,IAAYzV,E,6BAAZ,SAAYA,GACV,gBACA,sBACA,cAIA,oBACA,oBACA,kBACA,gBACA,sBACA,oBACA,mBACD,CAdD,CAAYA,IAAAA,EAAM,I,wFCbN6mB,E,QAAZ,SAAYA,GACV,oBACA,sBACA,iBACD,CAJD,CAAYA,IAAAA,EAAe,I","sources":["webpack://core/./includes/html/utils/dom.ts","webpack://core/./includes/html/utils/find-document.ts","webpack://core/./includes/plugins/utils/create-plugins-tree.ts","webpack://core/./includes/plugins/utils/detections.ts","webpack://core/./includes/plugins/utils/extract-plugins.ts","webpack://core/./includes/plugins/utils/find.ts","webpack://core/./includes/plugins/utils/get-plugin.ts","webpack://core/./includes/plugins/utils/set-title-html.ts","webpack://core/./modules/helpers.ts","webpack://core/./modules/instances/base.ts","webpack://core/./modules/instances/plugins.ts","webpack://core/./store/middleware.ts","webpack://core/./store/modules/documents/utils.ts","webpack://core/./store/modules/documents/reducer.ts","webpack://core/./store/modules/documents/sagas/copy-documents.ts","webpack://core/./store/modules/documents/selectors.ts","webpack://core/./store/modules/documents/sagas/create-children.ts","webpack://core/./store/modules/documents/sagas/create-project.ts","webpack://core/./store/modules/documents/sagas/delete-children.ts","webpack://core/./store/modules/documents/sagas/get-children.ts","webpack://core/./store/modules/documents/sagas/get-document.ts","webpack://core/./store/modules/documents/sagas/get-project.ts","webpack://core/./store/modules/documents/sagas/handle-document-error.ts","webpack://core/./store/modules/documents/sagas/import-documents.ts","webpack://core/./store/modules/documents/sagas/move-documents.ts","webpack://core/./store/modules/documents/sagas/utils/create-revision-list.ts","webpack://core/./store/modules/documents/sagas/utils/create-rollback-list.ts","webpack://core/./store/modules/documents/sagas/update-document.ts","webpack://core/./store/modules/documents/sagas/utils/create-list-buffer.ts","webpack://core/./store/modules/documents/sagas/update-document-access.ts","webpack://core/./store/modules/documents/sagas/update-documents.ts","webpack://core/./store/modules/documents/sagas/watch-project/create-channel.ts","webpack://core/./store/modules/documents/sagas/watch-project/accumulate-changes.ts","webpack://core/./store/modules/documents/sagas/watch-project/apply-changes.ts","webpack://core/./store/modules/documents/sagas/watch-project/add-change.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/watch-document-updating.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/watch-children-creation.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/watch-children-deletion.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/watch-documents-updating.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/watch-documents-coping.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/watch-documents-moving.ts","webpack://core/./store/modules/documents/sagas/watch-project/requests-watchers/index.ts","webpack://core/./store/modules/documents/sagas/watch-project/watch-changes.ts","webpack://core/./store/modules/documents/sagas/expand-documents.ts","webpack://core/./store/modules/documents/sagas/collapse-documents.ts","webpack://core/./store/modules/documents/sagas/duplicate-project.ts","webpack://core/./store/modules/documents/sagas/export-documents.ts","webpack://core/./store/modules/documents/sagas/index.ts","webpack://core/./store/modules/documents/hooks.ts","webpack://core/./store/modules/documents/index.ts","webpack://core/./store/selectors.ts","webpack://core/./store/index.ts","webpack://core/./store/modules/common/actions/conflict.ts","webpack://core/./store/modules/common/actions/app.ts","webpack://core/./store/modules/common/actions/user.ts","webpack://core/./store/modules/common/actions/pouchdb.ts","webpack://core/./store/modules/common/actions/editor.ts","webpack://core/./store/modules/common/actions/workspace.ts","webpack://core/./store/modules/common/actions/organization.ts","webpack://core/./store/modules/common/actions/assignments.ts","webpack://core/./store/modules/common/reducers/app.ts","webpack://core/./store/modules/common/reducers/assignments.ts","webpack://core/./store/modules/common/reducers/conflict.ts","webpack://core/./store/modules/common/reducers/editor.ts","webpack://core/./store/modules/common/reducers/organization.ts","webpack://core/./store/modules/common/reducers/pouchdb.ts","webpack://core/./store/modules/common/reducers/user.ts","webpack://core/./utils/get-children.ts","webpack://core/./utils/get-parents.ts","webpack://core/./store/modules/common/reducers/workspace.ts","webpack://core/./store/modules/common/reducers/index.ts","webpack://core/./store/modules/common/sagas/assignments.ts","webpack://core/./store/modules/common/sagas/editor.ts","webpack://core/./store/modules/common/sagas/organization.ts","webpack://core/./store/modules/common/sagas/plugins.ts","webpack://core/./includes/plugins/utils/codes-get.ts","webpack://core/./repositories/utils/format-document.ts","webpack://core/./store/modules/common/sagas/utils/get-search-result.ts","webpack://core/./store/modules/common/sagas/utils/matched-tree-item.ts","webpack://core/./store/modules/common/sagas/utils/unmatched-tree-item.ts","webpack://core/./store/modules/common/sagas/pouchdb.ts","webpack://core/./store/modules/common/sagas/utils/find-assignments.ts","webpack://core/./store/modules/common/sagas/user.ts","webpack://core/./store/modules/common/sagas/workspace.ts","webpack://core/./store/modules/common/sagas/index.ts","webpack://core/./store/modules/documents/action-types.ts","webpack://core/./store/modules/documents/actions.ts","webpack://core/./store/types.ts","webpack://core/./types/issue.ts"],"sourcesContent":["export const getHTMLDocument = (html: string) => {\n const parser = new DOMParser();\n return parser.parseFromString(html, 'text/html');\n}","export const findDocument = (items: any[], id: string) => items.find(({ _id }: any) => _id === id);\n","import { PLUGINS_PATH } from 'core/store/modules/common/literals';\nimport { DocumentType } from 'core/types/document';\nimport type { EditorDocument, Plugin } from 'core/types/index';\nimport extractPluginsFromHtml from './extract-plugins';\nimport { getPluginByName, pluginToDocument } from './get-plugin';\n\nlet tree: any[] = [];\n\n// eslint-disable-next-line default-param-last\nfunction buildTreeItem(plugin: Plugin, parent: string, isPluginsRoot = false, docAttrs: any) {\n const _id = `${parent}/${isPluginsRoot ? `${PLUGINS_PATH}/` : ''}${plugin.code}`;\n\n if (plugin.load) {\n const childrenPlugins = plugin.load(docAttrs, _id);\n\n if (childrenPlugins) {\n // eslint-disable-next-line no-restricted-syntax\n for (const childPlugin of childrenPlugins) {\n tree.push(buildTreeItem(childPlugin, _id, false, docAttrs));\n }\n }\n }\n\n return pluginToDocument(plugin, {\n _id,\n parent,\n type: plugin.load ? DocumentType.PLUGINS_FOLDER : DocumentType.PLUGIN,\n order: 0,\n });\n}\n\nexport function createPluginsTree(document: EditorDocument) {\n tree = [];\n\n const { _id, html } = document;\n const pluginsMeta = extractPluginsFromHtml(html);\n\n if (pluginsMeta.length > 0) {\n pluginsMeta.forEach(pluginMeta => {\n if (pluginMeta.name) {\n // @ts-ignore\n const plugin = getPluginByName(pluginMeta.name);\n\n if (plugin) {\n tree.push(buildTreeItem(plugin, _id, true, pluginMeta.docAttrs));\n }\n }\n });\n }\n\n return tree;\n}\n","import { PLUGINS_PATH } from 'core/store/modules/common/literals';\nimport { DocumentType } from 'core/types/document';\n\nexport const isTypePluginRelated = (type: DocumentType): boolean =>\n [DocumentType.PLUGIN, DocumentType.PLUGINS_FOLDER].includes(type);\n\nexport const isPluginsDocument = (type: string): boolean => type === DocumentType.PLUGINS;\n\nexport function getPluginsFolderId(path: string) {\n const ids = path.split(`/${PLUGINS_PATH}`);\n return ids[0];\n}\n\nexport function isPluginId(path: string) {\n const ids = path.split(`/${PLUGINS_PATH}`);\n\n return ids.length === 2;\n}\n\nexport function extractPluginCode(path: string) {\n const ids = path.split('/');\n\n return ids[ids.length - 1];\n}\n","import { getHTMLDocument } from \"core/includes/html/utils/dom\";\nimport type { MetaPlugin } from \"core/types\";\n\nexport const extractAttributes = (htmlDoc: Document) => {\n return {\n dict: Object.fromEntries(\n Array.from( htmlDoc.querySelectorAll('tbody>tr') )\n .map(row => [\n row.children[0] ? row.children[0].textContent : '',\n row.children[1] ? row.children[1].innerHTML : ''\n ])\n ),\n // urls: Object.fromEntries(\n // Array.from( htmlDoc.getElementsByTagName('a') )\n // .map(link => link.href)\n // )\n }\n}\n\nconst extractPluginsFromHtml = (html: string): MetaPlugin[] => {\n const htmlDoc = getHTMLDocument(html);\n const plugins = htmlDoc.getElementsByTagName('plugin');\n const metaPlugins: MetaPlugin[] = [];\n \n Array.from(plugins).forEach(plugin => {\n const { attributes, innerHTML: name } = plugin;\n \n metaPlugins.push( {\n name,\n code: undefined,\n params: attributes,\n docAttrs: extractAttributes(htmlDoc)\n } )\n });\n \n return metaPlugins;\n};\n\nexport default extractPluginsFromHtml\n\n","import { isPluginsDocument } from \"./detections\";\n\nexport function findChildPluginsDocument(id: string, list: any[]): any {\n for (const item of list) {\n if (item.parent === id && isPluginsDocument(item.type)) {\n return item;\n }\n }\n\n return null;\n}\n\nexport function findSiblingPluginsDocument(parent: string, list: any[]): any {\n for (const item of list) {\n if (item.parent === parent && isPluginsDocument(item.type)) {\n return item;\n }\n }\n\n return null;\n}\n\nexport function findParentSiblingPluginsDocument(parent: string, list: any[]): any {\n let parentItemId;\n \n for (const item of list) {\n if (item._id === parent) {\n parentItemId = item.parent;\n break;\n }\n }\n\n return findSiblingPluginsDocument(parentItemId, list);\n}\n\nexport default function findPluginsRefDocument(id: string, parent: string, list: any[]) {\n return findChildPluginsDocument(id, list) || findSiblingPluginsDocument(parent, list) || findParentSiblingPluginsDocument(parent, list)\n}","/* eslint-disable no-restricted-syntax */\nimport { DocumentType } from 'core/types/document';\nimport { PluginsInstance } from 'core/modules/instances';\nimport type { Plugin } from '../../../types';\nimport { setTitleHtml } from './set-title-html';\n\n// Find plugin by plugin name\n\nexport function getPluginByName(\n name: string | undefined,\n childPlugin: Plugin | undefined,\n code: string | undefined,\n docAttrs: any,\n): Plugin | null {\n const pluginsList = PluginsInstance.getInstance();\n\n // eslint-disable-next-line guard-for-in\n for (const p in pluginsList) {\n const plugin: Plugin = childPlugin || pluginsList[p];\n\n if ((name && plugin.name === name) || (code && plugin.code === code)) {\n return plugin;\n }\n\n if (plugin.load) {\n const loadedPlugins = plugin.load(docAttrs);\n\n for (const lp of loadedPlugins) {\n const lpChild = getPluginByName(name, lp, code, docAttrs);\n\n if (lpChild) return lpChild;\n }\n }\n }\n\n return null;\n}\n\nexport const getPluginByCode = (code: string, docAttrs: any): Plugin | null =>\n getPluginByName(undefined, undefined, code, docAttrs);\n\nexport const pluginToDocument = (plugin: Plugin, props = {}) => ({\n _id: '',\n _rev: '',\n title: plugin.name,\n html: setTitleHtml(plugin.name) + plugin.html,\n type: DocumentType.PLUGIN,\n order: 0,\n parent: '',\n root: '',\n code: plugin.code,\n ...props,\n});\n","export const setTitleHtml = (title: string): string => `

${title}

`;\n","import type { ActionCreator, GenericFunction } from '../types';\n\nconst now = () => Math.floor(Date.now() / 1000);\n\n/**\n * Create an action\n */\nexport function createAction(\n type: string,\n payloadCreator: T,\n): ActionCreator, ReturnType> {\n if (!payloadCreator) {\n throw new TypeError('Expected a function');\n }\n\n return (...args: any[]) => ({\n type,\n payload: payloadCreator(...args),\n });\n}\n\n/**\n * Check if cache is valid\n */\nexport function hasValidCache(lastUpdated: number, max = 10): boolean {\n if (!navigator.onLine) {\n return true;\n }\n\n return lastUpdated + max * 60 > now();\n}\n","class BaseInstance {\n instance: any;\n \n setInstance(instance: any): void {\n this.instance = instance\n }\n\n getInstance(): any {\n return this.instance;\n }\n}\n\nexport default BaseInstance;","import BaseInstance from './base';\n\nconst PluginsInstance = new BaseInstance();\n\nexport { PluginsInstance };\n","import { env } from 'core/utils';\nimport type { Middleware } from 'redux';\n\nconst middleware = [] as Middleware[];\n\n/* eslint-disable */\nif (env.NODE_ENV === 'development') {\n const { createLogger } = require('redux-logger');\n const invariant = require('redux-immutable-state-invariant').default;\n\n middleware.push(invariant());\n middleware.push(createLogger({ collapsed: true }));\n}\n\nexport { middleware };\n","import { createEntityAdapter } from '@reduxjs/toolkit';\nimport type { BaseEntity } from 'core/base';\nimport type { FormError } from 'core/components/ui';\nimport { STATUS } from '../../types';\nimport type { DocumentState } from './types';\nimport type { DocumentId } from '../../../types';\n\nexport const createAdapter = () =>\n createEntityAdapter>({\n selectId: entity => entity.document?._id ?? 'null',\n });\n\nexport const updateDocumentStatus = (status: STATUS, isChildrenLoaded = false) => ({\n status,\n isChildrenLoaded,\n isSuccess: status === STATUS.SUCCESS,\n isLoading: status === STATUS.RUNNING,\n isError: status === STATUS.ERROR,\n isConflict: status === STATUS.CONFLICT,\n});\n\n// TODO: need to think over with this approach\n// Main problem is using this util outside store\nexport const toDocumentState = ({\n document,\n status = STATUS.SUCCESS,\n errors = [],\n}: {\n document: TEntity;\n parentId?: DocumentId;\n status?: STATUS;\n errors?: FormError[];\n}): DocumentState => ({\n document,\n errors,\n ...updateDocumentStatus(status),\n});\n","import { createReducer } from '@reduxjs/toolkit';\nimport { isConflictError, isValidationError } from 'core/base';\nimport type { DocumentId } from 'core/types';\nimport { STATUS } from '../../types';\nimport { ActionTypes } from './action-types';\nimport type { DocumentsActions, DocumentsState } from './types';\nimport { createAdapter, toDocumentState, updateDocumentStatus } from './utils';\n\nconst adapter = createAdapter();\n\nconst initialState = adapter.getInitialState({\n rootId: undefined,\n status: STATUS.IDLE,\n expanded: [],\n}) as DocumentsState;\n\nconst startLoading = (draft: DocumentsState) => {\n draft.status = STATUS.RUNNING;\n};\n\nconst loadingFailed = (draft: DocumentsState) => {\n draft.status = STATUS.ERROR;\n};\n\nconst addExpandedIds = (state: DocumentId[], ids: DocumentId[]) => {\n const unique = new Set([...state, ...ids]);\n return [...unique];\n};\n\nexport const reducer = createReducer(initialState, {\n [ActionTypes.CREATE_PROJECT]: startLoading,\n [ActionTypes.CREATE_PROJECT_SUCCESS](\n draft,\n { payload }: DocumentsActions['createProjectSuccess'],\n ) {\n const documents = payload.documents.map(document => toDocumentState({ document }));\n\n adapter.setAll(draft, documents);\n\n draft.rootId = payload.rootId;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.CREATE_PROJECT_FAILURE]: loadingFailed,\n\n [ActionTypes.DUPLICATE_PROJECT]: startLoading,\n [ActionTypes.DUPLICATE_PROJECT_SUCCESS](\n draft,\n { payload: { rootId, document } }: DocumentsActions['duplicateProjectSuccess'],\n ) {\n adapter.setAll(draft, [toDocumentState({ document })]);\n\n draft.rootId = rootId;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.DUPLICATE_PROJECT_FAILURE]: loadingFailed,\n\n [ActionTypes.GET_PROJECT]: startLoading,\n [ActionTypes.GET_PROJECT_SUCCESS](draft, { payload }: DocumentsActions['getProjectSuccess']) {\n const documents = payload.documents.map(document => toDocumentState({ document }));\n\n adapter.setAll(draft, documents);\n\n draft.rootId = payload.rootId;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.GET_PROJECT_FAILURE]: loadingFailed,\n\n [ActionTypes.GET_DOCUMENT_SUCCESS](\n draft,\n { payload: document }: DocumentsActions['getDocumentSuccess'],\n ) {\n adapter.setOne(draft, toDocumentState({ document }));\n },\n\n [ActionTypes.GET_CHILDREN](draft, { payload: id }: DocumentsActions['getChildren']) {\n adapter.updateOne(draft, {\n id,\n changes: updateDocumentStatus(STATUS.RUNNING),\n });\n },\n [ActionTypes.GET_CHILDREN_SUCCESS](draft, { payload }: DocumentsActions['getChildrenSuccess']) {\n adapter.updateOne(draft, {\n id: payload.parentId,\n changes: updateDocumentStatus(STATUS.SUCCESS, true),\n });\n adapter.setMany(\n draft,\n payload.documents.map(document => toDocumentState({ document })),\n );\n },\n\n [ActionTypes.COPY_DOCUMENTS_SUCCESS](\n draft,\n { payload }: DocumentsActions['copyDocumentsSuccess'],\n ) {\n adapter.setMany(\n draft,\n payload.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.MOVE_DOCUMENTS_SUCCESS](\n draft,\n { payload }: DocumentsActions['moveDocumentsSuccess'],\n ) {\n adapter.setMany(\n draft,\n payload.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.CREATE_CHILDREN_SUCCESS](\n draft,\n { payload }: DocumentsActions['createChildrenSuccess'],\n ) {\n const [parent] = payload;\n\n if (!draft.expanded.includes(parent._id)) {\n draft.expanded = addExpandedIds(draft.expanded, [parent._id]);\n }\n\n adapter.setMany(\n draft,\n payload.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.UPDATE_DOCUMENT_OPTIMISTIC](draft, e: DocumentsActions['updateDocumentOptimistic']) {\n adapter.updateOne(draft, {\n id: e.payload.document._id,\n changes: {\n document: e.payload.document,\n },\n });\n },\n [ActionTypes.UPDATE_DOCUMENT_ROLLBACK](draft, e: DocumentsActions['updateDocumentRollback']) {\n adapter.updateOne(draft, {\n id: e.payload._id,\n changes: {\n document: e.payload,\n },\n });\n },\n [ActionTypes.UPDATE_DOCUMENT_SUCCESS](draft, e: DocumentsActions['updateDocumentSuccess']) {\n const { _id, _rev } = e.payload.document;\n const docState = draft.entities[_id];\n\n if (docState) {\n docState.errors = [];\n docState.document._rev = _rev; // On success update only document revision to avoid overriding user state\n }\n },\n\n [ActionTypes.UPDATE_DOCUMENT_FAILURE](\n draft,\n { payload: { id, errors } }: DocumentsActions['updateDocumentFailure'],\n ) {\n adapter.updateOne(draft, {\n id,\n changes: {\n errors,\n },\n });\n },\n [ActionTypes.UPDATE_DOCUMENT_REVISION](\n draft,\n { payload: { id, revisionId } }: DocumentsActions['updateRevision'],\n ) {\n draft.entities[id]!.document._rev = revisionId;\n },\n [ActionTypes.DELETE_CHILDREN_SUCCESS](\n draft,\n { payload: { document, ids } }: DocumentsActions['deleteChildrenSuccess'],\n ) {\n adapter.setOne(draft, toDocumentState({ document }));\n adapter.removeMany(draft, ids);\n },\n [ActionTypes.UPDATE_DOCUMENTS_SUCCESS](draft, e: DocumentsActions['updateDocumentsSuccess']) {\n const { payload } = e;\n\n payload.forEach(({ _id, _rev }) => {\n const docState = draft.entities[_id];\n\n if (docState) {\n docState.errors = [];\n docState.document._rev = _rev; // On success update only document revision to avoid overriding user state\n }\n });\n },\n [ActionTypes.UPDATE_DOCUMENTS_OPTIMISTIC](\n draft,\n e: DocumentsActions['updateDocumentsOptimistic'],\n ) {\n adapter.updateMany(\n draft,\n e.payload.map(document => ({\n id: document._id,\n changes: {\n document,\n },\n })),\n );\n },\n [ActionTypes.UPDATE_DOCUMENTS_ROLLBACK](draft, e: DocumentsActions['updateDocumentsRollback']) {\n adapter.updateMany(\n draft,\n e.payload.map(document => ({\n id: document._id,\n changes: {\n document,\n },\n })),\n );\n },\n [ActionTypes.UPDATE_DOCUMENTS_FAILURE](draft, e: DocumentsActions['updateDocumentsFailure']) {\n const { payload } = e;\n\n const changes = payload.map(({ id, error }) => {\n if (isValidationError(error)) {\n return {\n id,\n changes: {\n errors: error.data,\n },\n };\n }\n\n if (isConflictError(error)) {\n return {\n id,\n changes: updateDocumentStatus(STATUS.CONFLICT),\n };\n }\n\n return { id, changes: {} };\n });\n\n adapter.updateMany(draft, changes);\n },\n [ActionTypes.WATCH_CREATE_DOCUMENTS](\n draft,\n { payload }: DocumentsActions['watchCreateDocuments'],\n ) {\n adapter.setMany(\n draft,\n payload.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.WATCH_DELETE_DOCUMENTS](\n draft,\n { payload }: DocumentsActions['watchDeleteDocuments'],\n ) {\n adapter.removeMany(draft, payload);\n },\n [ActionTypes.WATCH_UPDATE_DOCUMENTS](\n draft,\n { payload }: DocumentsActions['watchUpdateDocuments'],\n ) {\n adapter.setMany(\n draft,\n payload.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.HANDLE_DOCUMENT_ERROR](\n draft,\n { payload: { error, id } }: DocumentsActions['handleDocumentError'],\n ) {\n if (id && isConflictError(error)) {\n adapter.updateOne(draft, {\n id,\n changes: updateDocumentStatus(STATUS.CONFLICT),\n });\n }\n },\n [ActionTypes.IMPORT_DOCUMENTS_SUCCESS](\n draft,\n { payload }: DocumentsActions['importDocumentsSuccess'],\n ) {\n adapter.setMany(\n draft,\n payload.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.EXPAND_DOCUMENT_CHILDREN_SUCCESS](draft, e: DocumentsActions['expandAllSuccess']) {\n const { expanded, documents } = e.payload;\n\n draft.expanded = addExpandedIds(draft.expanded, expanded);\n\n adapter.setMany(\n draft,\n documents.map(document => toDocumentState({ document })),\n );\n },\n [ActionTypes.SET_EXPANDED_IDS](draft, { payload }: DocumentsActions['setExpandedIds']) {\n draft.expanded = payload;\n },\n [ActionTypes.ADD_EXPANDED_IDS](draft, { payload }: DocumentsActions['addExpandedIds']) {\n draft.expanded = addExpandedIds(draft.expanded, payload);\n },\n [ActionTypes.UPDATE_DOCUMENT_ACCESS_SUCCESS](\n draft,\n e: DocumentsActions['updateDocumentAccessSuccess'],\n ) {\n adapter.setOne(draft, toDocumentState({ document: e.payload }));\n },\n [ActionTypes.EXPORT_DOCUMENTS_SUCCESS](draft, e: DocumentsActions['exportDocumentsSuccess']) {\n adapter.setMany(\n draft,\n e.payload.map(document => toDocumentState({ document })),\n );\n },\n});\n","import type { BaseApiService } from 'core/base';\nimport type { CallEffect, GetContextEffect, PutEffect, SagaReturnType } from 'redux-saga/effects';\nimport { call, getContext, put } from 'redux-saga/effects';\nimport type { DocumentsActions } from '../types';\nimport * as actions from '../actions';\n\ntype CopyDocumentsGenerator = Generator<\n | GetContextEffect\n | CallEffect>\n | CallEffect>\n | PutEffect,\n void,\n BaseApiService &\n Awaited> &\n Awaited>\n>;\n\nexport function* copyDocuments(e: DocumentsActions['copyDocuments']): CopyDocumentsGenerator {\n try {\n const documentService = yield getContext('DocumentService');\n\n const document = yield call([documentService, 'copy'], e.payload);\n\n const children = yield call([documentService, 'getChildren'], document._id);\n\n yield put(actions.copyDocumentsSuccess([document, ...children]));\n } catch (error) {\n yield put(actions.copyDocumentsFailure({ id: e.payload.target.id, error }));\n yield put(actions.handleDocumentError({ id: e.payload.target.id, error }));\n }\n}\n","import type { BaseEntity } from 'core/base';\nimport { createDraftSafeSelector } from '@reduxjs/toolkit';\nimport type { DocumentsState } from './types';\nimport { STATUS } from '../../types';\nimport { createAdapter } from './utils';\n\nexport function createDocumentsSelectors() {\n type TState = { documents: DocumentsState };\n const adapter = createAdapter();\n\n const selectors = adapter.getSelectors(s => s.documents);\n const selectExpanded = (s: TState) => s.documents.expanded;\n\n const selectRootId = (s: TState) => s.documents.rootId;\n\n const selectProject = (s: TState) => ({\n rootId: s.documents.rootId,\n documents: s.documents.entities,\n status: s.documents.status,\n isSuccess: s.documents.status === STATUS.SUCCESS,\n isLoading: s.documents.status === STATUS.RUNNING,\n isError: s.documents.status === STATUS.ERROR,\n });\n\n const selectRootDocument = createDraftSafeSelector(\n selectRootId,\n selectors.selectEntities,\n (id, entities) => (id ? entities[id] : undefined),\n );\n\n return {\n selectDocumentById: selectors.selectById,\n selectRootDocument,\n selectRootId,\n selectProject,\n selectExpanded,\n selectAllDocuments: selectors.selectAll,\n selectDocumentsList: selectors.selectEntities,\n selectDocumentsCount: selectors.selectTotal,\n selectDocumentIds: selectors.selectIds,\n };\n}\n\nexport const documentsSelectors = createDocumentsSelectors();\n","import type {\n CallEffect,\n GetContextEffect,\n PutEffect,\n SagaReturnType,\n SelectEffect,\n} from 'redux-saga/effects';\nimport { call, delay, getContext, put, select } from 'redux-saga/effects';\nimport type { ChangesResource, DocumentResource, BaseEntity } from 'core/base';\nimport { isConflictError } from 'core/base';\nimport type { DocumentsActions, DocumentsPayloads, DocumentsState, DocumentState } from '../types';\nimport * as actions from '../actions';\nimport { documentsSelectors } from '../selectors';\n\nconst { selectDocumentById } = documentsSelectors;\n\ntype TryToCreateChildrenGenerator = Generator<\n | GetContextEffect\n | SelectEffect\n | CallEffect>\n | CallEffect>\n | PutEffect\n | CallEffect,\n BaseEntity,\n DocumentResource &\n ChangesResource &\n DocumentState &\n Awaited> &\n Awaited> &\n void\n>;\n\nfunction* tryToCreateChildren(\n payload: DocumentsPayloads['createChildren'],\n attempt = 1,\n): TryToCreateChildrenGenerator {\n const { documents, parentId, insertAt } = payload;\n\n const documentService = yield getContext('DocumentService');\n\n const { document }: DocumentState = yield select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, parentId),\n );\n\n try {\n return yield call([documentService, 'createChildren'], parentId, documents, {\n params: { index: insertAt },\n headers: {\n 'If-Match': document._rev !== undefined ? `\"${document._rev}\"` : '',\n },\n });\n } catch (error) {\n if (attempt >= 3 || !isConflictError(error)) throw error;\n\n const changesService: ChangesResource = yield getContext('ChangesService');\n\n if (!changesService) {\n throw error;\n }\n\n const [freshDocument] = yield call([changesService, 'getAndApplyChanges'], document);\n\n // Update parent node\n yield put(actions.updateDocumentSuccess({ document: freshDocument }));\n\n // Retry children creation\n return yield call(tryToCreateChildren, payload, attempt + 1);\n }\n}\n\ntype CreateChildrenGenerator = Generator<\n | CallEffect>\n | CallEffect>\n | CallEffect\n | PutEffect\n | GetContextEffect,\n void,\n BaseEntity & BaseEntity[] & DocumentResource\n>;\n\nexport function* createChildren(e: DocumentsActions['createChildren']): CreateChildrenGenerator {\n const { documents, parentId, navigate } = e.payload;\n\n try {\n const document = yield call(tryToCreateChildren, e.payload);\n\n // TODO: HOTFIX gets refresh documents data from the backend\n const documentService = yield getContext('DocumentService');\n const freshChildren = yield call([documentService, 'getChildren'], document._id);\n\n yield put(actions.createChildrenSuccess([document, ...freshChildren]));\n\n if (navigate) {\n yield delay(500); // Make small delay to wait UI update\n navigate(`/${documents[0]._id}`);\n }\n } catch (error) {\n yield put(actions.createChildrenFailure({ error, id: parentId }));\n yield put(actions.handleDocumentError({ error, id: parentId }));\n }\n}\n","import { call, getContext, put } from 'typed-redux-saga';\nimport type { DocumentResource } from 'core/base';\nimport type { DocumentsActions } from '../types';\nimport { createProjectFailure, createProjectSuccess, watchProjectChanges } from '../actions';\nimport { showAlertError, showAlertSuccess } from '../../common';\nimport type { LoggerService } from '../../../../services';\n\nexport function* createProject(e: DocumentsActions['createProject']) {\n const rootView = e.payload;\n try {\n const documentService = yield* getContext('DocumentService');\n\n const [root, ...documents] = yield* call([documentService, 'createWorkspace'], rootView);\n\n yield put(\n createProjectSuccess({\n rootId: root._id,\n documents: [root, ...documents],\n }),\n );\n yield put(showAlertSuccess('The project was successfully created.'));\n yield put(watchProjectChanges(root._id));\n } catch (error) {\n const logger = yield* getContext('LoggerService');\n logger.error(error);\n yield put(createProjectFailure());\n yield put(showAlertError('Project creation is failed!'));\n }\n}\n","import type { DocumentResource, ChangesResource, BaseEntity } from 'core/base';\nimport type {\n CallEffect,\n GetContextEffect,\n PutEffect,\n SagaReturnType,\n SelectEffect,\n} from 'redux-saga/effects';\nimport { call, getContext, put, select } from 'redux-saga/effects';\nimport type { DocumentId } from 'core/types';\nimport { isConflictError } from 'core/base';\nimport { t } from 'i18next';\nimport type { DocumentsActions, DocumentsState, DocumentState, DocumentsPayloads } from '../types';\nimport * as actions from '../actions';\nimport { documentsSelectors } from '../selectors';\nimport { showAlertSuccess } from '../../common';\n\nconst { selectDocumentById } = documentsSelectors;\n\ntype TryToDeleteChildrenGenerator = Generator<\n | GetContextEffect\n | SelectEffect\n | CallEffect\n | CallEffect>\n | CallEffect>\n | PutEffect,\n BaseEntity | void,\n BaseEntity &\n DocumentResource &\n DocumentState &\n ChangesResource &\n Awaited> &\n Awaited>\n>;\n\nfunction* tryToDeleteChildren(\n payload: DocumentsPayloads['deleteChildren'],\n attempt = 1,\n): TryToDeleteChildrenGenerator {\n const { ids, parentId } = payload;\n\n const documentService = yield getContext('DocumentService');\n\n const { document }: DocumentState = yield select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, parentId),\n );\n\n const { ok, data, error } = yield call([documentService, 'removeChildren'], parentId, ids, {\n headers: {\n 'If-Match': document._rev !== undefined ? `\"${document._rev}\"` : '',\n },\n });\n\n if (!ok) {\n if (isConflictError(error) && attempt <= 3) {\n const changesService: ChangesResource = yield getContext('ChangesService');\n\n if (!changesService) {\n throw error;\n }\n\n const [freshDocument] = yield call([changesService, 'getAndApplyChanges'], document);\n\n // Update parent node\n yield put(actions.updateDocumentSuccess({ document: freshDocument }));\n\n // Retry children creation\n return yield call(tryToDeleteChildren, payload, attempt + 1);\n }\n\n throw error;\n } else if (data) {\n return data;\n }\n}\n\ntype DeleteChildrenGenerator = Generator<\n | CallEffect>\n | SelectEffect\n | PutEffect\n | PutEffect\n | PutEffect,\n void,\n DocumentId & BaseEntity\n>;\n\nexport function* deleteChildren(e: DocumentsActions['deleteChildren']): DeleteChildrenGenerator {\n const { ids, parentId, onSuccess } = e.payload;\n try {\n const document = yield call(tryToDeleteChildren, e.payload);\n\n if (onSuccess) {\n onSuccess(parentId);\n }\n yield put(actions.deleteChildrenSuccess({ document, ids }));\n yield put(showAlertSuccess(t('AlertChildrenDeleteSuccess', { count: ids.length })));\n } catch (error) {\n yield put(actions.deleteChildrenFailure({ error, id: parentId }));\n yield put(actions.handleDocumentError({ error, id: parentId }));\n }\n}\n","import type { BaseApiService } from 'core/base';\nimport type { CallEffect, GetContextEffect, PutEffect, SagaReturnType } from 'redux-saga/effects';\nimport { call, getContext, put } from 'redux-saga/effects';\nimport type { DocumentsActions } from '../types';\nimport * as actions from '../actions';\nimport { handleDocumentError } from '../actions';\n\ntype GetChildrenGenerator = Generator<\n GetContextEffect | CallEffect> | PutEffect,\n void,\n BaseApiService & Awaited> & void\n>;\n\nexport function* getChildren(e: DocumentsActions['getChildren']): GetChildrenGenerator {\n try {\n const documentService = yield getContext('DocumentService');\n const documents = yield call([documentService, 'getChildren'], e.payload);\n\n yield put(actions.getChildrenSuccess({ parentId: e.payload, documents }));\n } catch (error) {\n yield put(handleDocumentError({ error, id: e.payload }));\n }\n}\n","import type { BaseApiService } from 'core/base';\nimport type {\n CallEffect,\n SelectEffect,\n GetContextEffect,\n PutEffect,\n SagaReturnType,\n} from 'redux-saga/effects';\nimport { call, getContext, put, select } from 'redux-saga/effects';\nimport type { DocumentsActions, DocumentsState, DocumentState } from '../types';\nimport { getDocumentSuccess, handleDocumentError } from '../actions';\nimport { documentsSelectors } from '../selectors';\n\nconst { selectDocumentById } = documentsSelectors;\n\ntype GetDocumentGenerator = Generator<\n GetContextEffect | CallEffect> | SelectEffect | PutEffect,\n void,\n BaseApiService & Awaited> & DocumentState & void\n>;\n\nexport function* getDocument(e: DocumentsActions['getDocument']): GetDocumentGenerator {\n try {\n const documentService = yield getContext('DocumentService');\n const documentState: DocumentState | void = yield select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, e.payload),\n );\n\n const freshDocument = yield call([documentService, 'get'], e.payload, {\n headers: {\n 'If-None-Match': documentState ? `\"${documentState.document._rev}\"` : '',\n },\n });\n\n yield put(getDocumentSuccess(freshDocument));\n } catch (error) {\n yield put(handleDocumentError({ error, id: e.payload }));\n }\n}\n","import type { BaseDocumentVM, DocumentResource } from 'core/base';\nimport type { CallEffect } from 'redux-saga/effects';\nimport { call, getContext, put, all } from 'typed-redux-saga';\nimport type { DocumentsActions } from '../types';\nimport {\n getProjectFailure,\n getProjectSuccess,\n watchProjectChanges,\n addExpandedIds,\n} from '../actions';\n\nexport function* getProject({ payload }: DocumentsActions['getProject']) {\n try {\n const documentService = yield* getContext('DocumentService');\n const idsPath = yield* call([documentService, 'getPathToRoot'], payload.id);\n\n const [rootId] = idsPath;\n const rootDoc = yield* call(\n [documentService, 'getWorkspace'],\n rootId,\n payload.settingsContentId,\n );\n\n // Iterate all ids path except last one to build a project tree.\n const children: Generator>[] = [];\n while (children.length < idsPath.length - 1) {\n /* eslint-disable-next-line */\n children.push(call([documentService, 'getChildren'], idsPath[children.length]));\n }\n\n const documents = yield* all(children);\n\n yield put(getProjectSuccess({ documents: [rootDoc, ...documents.flat()], rootId }));\n yield put(addExpandedIds(idsPath.slice(0, -1)));\n yield put(watchProjectChanges(rootId));\n } catch (error) {\n yield put(getProjectFailure(error));\n }\n}\n","import type { GetContextEffect, PutEffect } from 'redux-saga/effects';\nimport { getContext, put } from 'redux-saga/effects';\nimport { isCustomError, ErrorCodes, isValidationError } from 'core/base';\nimport { t } from 'i18next';\nimport type { DocumentsActions } from '../types';\nimport { showAlertError } from '../../common';\nimport { updateDocumentFailure } from '../actions';\nimport type { LoggerService } from '../../../../services';\n\ntype HandleDocumentGenerator = Generator;\n\nexport function* handleDocumentError(\n e: DocumentsActions['handleDocumentError'],\n): HandleDocumentGenerator {\n const loggerService = yield getContext('LoggerService');\n const {\n payload: { error, id },\n } = e;\n\n if (isCustomError(error)) {\n switch (error.status) {\n case ErrorCodes.notModified: {\n break;\n }\n\n case ErrorCodes.validation: {\n if (id && isValidationError(error)) {\n yield put(updateDocumentFailure({ id, errors: error.data }));\n }\n break;\n }\n\n case ErrorCodes.forbidden: {\n yield put(\n showAlertError(t('Errors.DocumentForbiddenTitle'), {\n description: t('Errors.DocumentForbiddenDescription'),\n }),\n );\n break;\n }\n\n case ErrorCodes.notFound: {\n yield put(\n showAlertError(t('Errors.DocumentDeletedTitle'), {\n description: t('Errors.DocumentDeletedDescription'),\n }),\n );\n break;\n }\n\n case ErrorCodes.conflict: {\n yield put(\n showAlertError(t('Errors.DocumentConflictTitle'), {\n description: t('Errors.DocumentConflictDescription'),\n }),\n );\n break;\n }\n\n default: {\n loggerService.error(error);\n\n yield put(\n showAlertError(t('Errors.DocumentUnhandledTitle'), {\n description: t('Errors.DocumentUnhandledDescription'),\n }),\n );\n }\n }\n } else {\n loggerService.error(error);\n\n yield put(\n showAlertError(t('Errors.DocumentUnhandledTitle'), {\n description: t('Errors.DocumentUnhandledDescription'),\n }),\n );\n }\n}\n","import type { BaseApiService } from 'core/base';\nimport type {\n CallEffect,\n GetContextEffect,\n PutEffect,\n SagaReturnType,\n SelectEffect,\n} from 'redux-saga/effects';\nimport { call, getContext, put, select } from 'redux-saga/effects';\nimport * as actions from '../actions';\nimport { handleDocumentError } from '../actions';\nimport { documentsSelectors } from '../selectors';\nimport type { DocumentState, DocumentsActions, DocumentsState } from '../types';\n\nconst { selectDocumentById } = documentsSelectors;\n\ntype ImportDocumentsGenerator = Generator<\n | GetContextEffect\n | SelectEffect\n | CallEffect>\n | CallEffect>\n | PutEffect,\n void,\n BaseApiService &\n DocumentState &\n Awaited> &\n Awaited> &\n void\n>;\n\nexport function* importDocuments(e: DocumentsActions['importDocuments']): ImportDocumentsGenerator {\n const { documents, parentId, insertAt, area } = e.payload;\n\n try {\n const documentService = yield getContext('DocumentService');\n\n const documentState: DocumentState = yield select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, parentId),\n );\n\n const parent = yield call([documentService, 'import'], parentId, area, documents, {\n params: { index: insertAt },\n headers: {\n 'If-Match': documentState ? `\"${documentState.document._rev}\"` : '',\n },\n });\n\n const children = yield call([documentService, 'getChildren'], parentId);\n\n yield put(actions.importDocumentsSuccess([parent, ...children]));\n } catch (error) {\n yield put(handleDocumentError({ error, id: parentId }));\n }\n}\n","import type { BaseApiService } from 'core/base';\nimport type { CallEffect, GetContextEffect, PutEffect, SagaReturnType } from 'redux-saga/effects';\nimport { call, getContext, put } from 'redux-saga/effects';\nimport type { DocumentsActions } from '../types';\nimport * as actions from '../actions';\n\ntype CopyDocumentsGenerator = Generator<\n GetContextEffect | CallEffect> | PutEffect,\n void,\n BaseApiService & Awaited> & void\n>;\n\nexport function* moveDocuments(e: DocumentsActions['moveDocuments']): CopyDocumentsGenerator {\n try {\n const documentService = yield getContext('DocumentService');\n const documents = yield call([documentService, 'move'], e.payload);\n\n yield put(actions.moveDocumentsSuccess(documents));\n } catch (error) {\n yield put(actions.moveDocumentsFailure({ error, id: e.payload.target.id }));\n yield put(actions.handleDocumentError({ error, id: e.payload.target.id }));\n }\n}\n","import { all, select } from 'typed-redux-saga';\nimport type { BaseEntity } from 'core/base';\nimport type { SagaGenerator } from 'typed-redux-saga';\nimport type { DocumentsState } from '../../types';\nimport { documentsSelectors } from '../../selectors';\n\nconst { selectDocumentById } = documentsSelectors;\n\nexport type RevisionList = {\n save: (entities: BaseEntity[]) => void;\n refreshRevision: (entities: BaseEntity[]) => SagaGenerator;\n};\n\nexport function createRevisionList(): RevisionList {\n const revs = new Map();\n\n return {\n save(entities: BaseEntity[]) {\n entities.forEach(e => {\n revs.set(e._id, e._rev);\n });\n },\n\n /**\n * Method looking for the highest revision comparing state, payload and local saga state\n * @returns Highest revision\n */\n *refreshRevision(entities: BaseEntity[]) {\n const result = yield* all(\n entities.map(function* (entity: BaseEntity) {\n const { _id, _rev } = entity;\n\n // Take current document state\n const documentState = yield* select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, _id),\n );\n\n const revisions = [documentState?.document._rev, _rev, revs.get(_id)].filter(\n (n): n is number => Number.isFinite(n),\n );\n\n // Take the highest revision\n const topRev = Math.max.apply(null, revisions);\n\n revs.delete(_id);\n\n return {\n ...entity,\n _rev: topRev,\n };\n }),\n );\n\n return result;\n },\n };\n}\n","/* eslint-disable no-restricted-syntax */\nimport type { DocumentId } from 'core/types';\nimport type { BaseEntity } from 'core/base';\nimport { select } from 'typed-redux-saga';\nimport { documentsSelectors } from '../../selectors';\nimport type { DocumentsState } from '../../types';\n\nconst { selectDocumentById } = documentsSelectors;\n\nexport const createRollbackList = () => {\n const list = new Map();\n return {\n *save(this: void, entities: BaseEntity[]) {\n for (const { _id } of entities) {\n const documentState = yield* select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, _id),\n );\n\n if (documentState && !list.has(_id)) {\n list.set(_id, documentState.document);\n }\n }\n },\n\n restore(ids: DocumentId[]) {\n return ids.map(id => list.get(id)).filter((n): n is BaseEntity => !!n);\n },\n\n clear(entities: BaseEntity[]) {\n entities.forEach(entity => {\n list.delete(entity._id);\n });\n },\n };\n};\n","/* eslint-disable unicorn/prefer-regexp-test */\nimport type { BaseEntity, ChangesResource, DocumentResource } from 'core/base';\nimport { isValidationError, isConflictError } from 'core/base';\nimport type { SagaGenerator } from 'typed-redux-saga';\nimport { actionChannel, take, call, getContext, put, fork } from 'typed-redux-saga';\nimport type { Channel } from 'redux-saga';\nimport type { DocumentsActions as Actions } from '../types';\nimport * as actions from '../actions';\nimport { terminateAPP } from '../../common/actions';\nimport type { RevisionList } from './utils';\nimport { createRollbackList, createListBuffer } from './utils';\n\nconst MAX_RETRY_ATTEMPTS = 3;\n\nfunction* tryToUpdate(document: BaseEntity, attempt = 1): SagaGenerator {\n try {\n const documentService = yield* getContext('DocumentService');\n\n return yield* call([documentService, 'update'], document, {\n headers: {\n 'If-Match': `\"${document._rev}\"`,\n },\n });\n } catch (error) {\n if (attempt >= MAX_RETRY_ATTEMPTS || !isConflictError(error)) throw error;\n\n const changesService = yield* getContext('ChangesService');\n\n if (!changesService) {\n throw error;\n }\n\n const [freshDocument] = yield* call([changesService, 'getAndApplyChanges'], document);\n\n // Retry updating\n return yield* call(tryToUpdate, freshDocument, attempt + 1);\n }\n}\n\nfunction* updateDocumentWorker(channel: Channel, revs: RevisionList) {\n const rollbackList = createRollbackList();\n\n while (true) {\n const { payload } = yield* take(channel);\n\n // Save previous value before update state\n yield* call([rollbackList, 'save'], [payload.document]);\n\n yield* put(actions.updateDocumentOptimistic(payload));\n\n const [entity] = yield* call(revs.refreshRevision, [payload.document]);\n\n try {\n yield put(actions.updateDocumentInProgress({ document: entity }));\n const document = yield* call(tryToUpdate, entity);\n\n revs.save([document]);\n\n yield put(actions.updateDocumentSuccess({ document, actionId: payload.actionId }));\n } catch (error) {\n const [prevDocument] = rollbackList.restore([payload.document._id]);\n\n if (!isValidationError(error) && prevDocument) {\n yield* put(actions.updateDocumentRollback(prevDocument));\n }\n\n yield put(actions.handleDocumentError({ error, id: payload.document._id }));\n } finally {\n rollbackList.clear([payload.document]);\n }\n }\n}\n\nexport function* watchUpdateDocument(revs: RevisionList) {\n const buffer = createListBuffer();\n // Buffer coming actions\n const channel = yield* actionChannel(actions.updateDocument, buffer);\n\n yield* fork(updateDocumentWorker, channel, revs);\n\n yield* take(terminateAPP);\n channel.close();\n}\n","import type { DocumentId } from 'core/types';\nimport type { DocumentsActions } from '../../types';\n\n/**\n * List buffer based on entity ids\n * @returns saga Buffer type\n */\nexport function createListBuffer() {\n let list: Map = new Map();\n\n return {\n take: () => {\n const id = list.keys().next().value;\n if (!id) return;\n\n const message = list.get(id);\n list.delete(id);\n\n return message;\n },\n isEmpty() {\n return list.size === 0;\n },\n put(message: T) {\n const { payload } = message;\n list.set(payload.document._id, message);\n },\n\n flush() {\n list = new Map();\n\n return [];\n },\n };\n}\n","import type { BaseEntity, ChangesResource, DocumentResource, DocumentAccess } from 'core/base';\nimport { isConflictError } from 'core/base';\nimport type {\n CallEffect,\n GetContextEffect,\n PutEffect,\n SagaReturnType,\n SelectEffect,\n} from 'redux-saga/effects';\nimport { call, getContext, put, select } from 'redux-saga/effects';\nimport * as actions from '../actions';\nimport { documentsSelectors } from '../selectors';\nimport type { DocumentState, DocumentsActions, DocumentsState } from '../types';\n\nconst { selectDocumentById } = documentsSelectors;\n\ntype TryToUpdateGenerator = Generator<\n | GetContextEffect\n | CallEffect>\n | PutEffect\n | CallEffect>\n | CallEffect,\n BaseEntity,\n DocumentResource &\n Awaited> &\n Awaited> &\n ChangesResource &\n void\n>;\n\nfunction* tryToUpdateAccess(\n document: BaseEntity,\n request: DocumentAccess[],\n attempt = 1,\n): TryToUpdateGenerator {\n try {\n const documentService = yield getContext('DocumentService');\n\n return yield call([documentService, 'updateAccess'], document, request);\n } catch (error) {\n if (attempt >= 3 || !isConflictError(error)) throw error;\n\n const changesService: ChangesResource = yield getContext('ChangesService');\n\n if (!changesService) {\n throw error;\n }\n\n const [freshDocument] = yield call([changesService, 'getAndApplyChanges'], document);\n\n // Retry updating\n return yield call(tryToUpdateAccess, freshDocument, request, attempt + 1);\n }\n}\n\ntype UpdateDocumentGenerator = Generator<\n SelectEffect | CallEffect> | PutEffect,\n void,\n BaseEntity & DocumentState & void\n>;\n\nexport function* updateDocumentAccess(\n e: DocumentsActions['updateDocumentAccess'],\n): UpdateDocumentGenerator {\n const { id, request } = e.payload;\n try {\n const { document } = yield select((s: { documents: DocumentsState }) =>\n selectDocumentById(s, id),\n );\n\n const updatedDocument = yield call(tryToUpdateAccess, document, request);\n\n yield put(actions.updateDocumentAccessSuccess(updatedDocument));\n } catch (error) {\n yield put(actions.updateDocumentAccessFailure());\n yield put(actions.handleDocumentError({ error, id }));\n }\n}\n","import type { BaseEntity, CustomError, ChangesResource, DocumentResource } from 'core/base';\nimport { isValidationError, isConflictError } from 'core/base';\nimport type { SagaGenerator } from 'typed-redux-saga';\nimport { call, getContext, put, all, actionChannel, fork, take } from 'typed-redux-saga';\nimport type { DocumentId } from 'core/types';\nimport type { Channel } from 'redux-saga';\nimport { buffers } from 'redux-saga';\nimport type { DocumentsActions as Actions } from '../types';\nimport { handleDocumentError, updateDocumentsFailure, updateDocumentsSuccess } from '../actions';\nimport * as actions from '../actions';\nimport { terminateAPP } from '../../common/actions';\nimport type { RevisionList } from './utils';\nimport { createRollbackList } from './utils';\n\nconst MAX_RETRY_ATTEMPTS = 3;\n\ntype UpdateManyResult = Awaited>;\n\ntype GroupDocuments = {\n succeedUpdated?: { id: DocumentId; ok: true; document: BaseEntity }[];\n conflictUpdated?: { id: DocumentId; ok: false; error: CustomError; document: BaseEntity }[];\n failedUpdated?: { id: DocumentId; ok: false; error: CustomError | unknown }[];\n};\n\nfunction groupDocuments(result: UpdateManyResult): GroupDocuments {\n return result.reduce((acc, { ok, id, document, error }) => {\n if (ok && document) {\n acc.succeedUpdated ??= [];\n acc.succeedUpdated.push({ ok: true, id, document });\n }\n\n if (error) {\n if (isConflictError(error) && document) {\n acc.conflictUpdated ??= [];\n acc.conflictUpdated.push({ id, document, error, ok: false });\n } else {\n acc.failedUpdated ??= [];\n acc.failedUpdated.push({ id, error, ok: false });\n }\n }\n\n return acc;\n }, {});\n}\n\nfunction* tryToUpdate(documents: BaseEntity[], attempt = 1): SagaGenerator {\n const documentService = yield* getContext('DocumentService');\n const response = yield* call([documentService, 'updateMany'], documents);\n\n const updatedDocuments: UpdateManyResult = [];\n\n const { succeedUpdated, conflictUpdated, failedUpdated } = groupDocuments(response);\n\n if (succeedUpdated) {\n updatedDocuments.push(...succeedUpdated);\n }\n\n if (failedUpdated) {\n updatedDocuments.push(...failedUpdated);\n }\n\n if (conflictUpdated) {\n if (attempt < MAX_RETRY_ATTEMPTS) {\n const changesService = yield* getContext('ChangesService');\n\n const changes = conflictUpdated.map(function* ({ document }) {\n const [freshDocument] = yield* call([changesService, 'getAndApplyChanges'], document);\n\n return freshDocument;\n });\n\n const freshDocuments = yield* all(changes);\n const resolved = yield* call(tryToUpdate, freshDocuments, attempt + 1);\n updatedDocuments.push(...resolved);\n } else {\n updatedDocuments.push(...conflictUpdated);\n }\n }\n\n return updatedDocuments;\n}\n\nfunction* bulkUpdateDocumentsWorker(\n channel: Channel,\n revs: RevisionList,\n) {\n const rollbackList = createRollbackList();\n\n while (true) {\n const { payload } = yield* take(channel);\n\n // Save previous value before update state\n yield* call([rollbackList, 'save'], payload);\n\n // Update state\n yield* put(actions.updateDocumentsOptimistic(payload));\n\n // Take fresh revision\n const entities = yield* call(revs.refreshRevision, payload);\n\n try {\n yield* put(actions.updateDocumentsInProgress(entities));\n\n // Make api request\n const response = yield* call(tryToUpdate, entities);\n\n const { succeedUpdated, conflictUpdated, failedUpdated } = groupDocuments(response);\n\n if (succeedUpdated) {\n const documents = succeedUpdated.map(res => res.document);\n\n revs.save(documents);\n\n yield* put(updateDocumentsSuccess(documents));\n }\n\n if (conflictUpdated || failedUpdated) {\n yield* put(updateDocumentsFailure([...(conflictUpdated ?? []), ...(failedUpdated ?? [])]));\n }\n\n // Rollback state if document update fail\n if (failedUpdated) {\n const entities = failedUpdated.filter(({ error }) => !isValidationError(error));\n\n if (entities.length > 0) {\n yield put(actions.updateDocumentsRollback(rollbackList.restore(entities.map(r => r.id))));\n }\n }\n } catch (error) {\n yield* put(handleDocumentError({ error }));\n } finally {\n rollbackList.clear(payload);\n }\n }\n}\n\nexport function* watchBulkUpdateDocuments(revs: RevisionList) {\n // Buffer coming actions\n const channel = yield* actionChannel(actions.updateDocuments, buffers.sliding());\n\n yield* fork(bulkUpdateDocumentsWorker, channel, revs);\n\n yield* take(terminateAPP);\n channel.close();\n}\n","import type { BaseSseRepository } from 'core/base';\nimport { END, eventChannel } from 'redux-saga';\nimport type { Change } from './types';\n\nexport function createChannel(sse: BaseSseRepository) {\n return eventChannel(emit => {\n sse.on('docUpdated', (data: Change) => {\n emit(data);\n });\n\n sse.on('userLogout', () => {\n emit(END);\n });\n\n sse.on('accessRevoked', () => {\n emit(END);\n });\n\n return () => sse.destroy();\n });\n}\n","import type { DocumentId } from 'core/types';\nimport type { BaseEntity } from 'core/base';\nimport { DocumentOperations } from 'core/base';\nimport mergeWith from 'lodash/mergeWith';\nimport { objectValues } from 'core/utils';\nimport type { Change } from './types';\n\ntype Operations = Change['operation'];\n\nexport const accumulateChanges = () => {\n const init = () => ({\n [DocumentOperations.create]: new Map(),\n [DocumentOperations.update]: new Map(),\n [DocumentOperations.delete]: new Map(),\n });\n\n let changes: Record> = init();\n\n const hasToIgnore = (change: Change, document?: BaseEntity) => {\n const { operation, revision } = change;\n\n if (!document) {\n return operation === DocumentOperations.delete || operation === DocumentOperations.update; // Ignore delete and update if no document\n }\n\n const currentRev = document._rev;\n const patchRev = revision;\n\n // Ignore create and update if document exist and revision match\n return (\n operation === DocumentOperations.create ||\n (operation === DocumentOperations.update && currentRev >= patchRev)\n );\n };\n\n return {\n add(change: Change, document?: BaseEntity) {\n const { operation, docId } = change;\n\n if (hasToIgnore(change, document)) return;\n\n if (this.has(operation, docId)) {\n const doc = changes[operation].get(docId);\n changes[operation].set(\n docId,\n // TODO: code duplication. Create ChangesService to handle changes merging and applying\n mergeWith({}, doc, change, (_model: unknown, _patch: unknown) => {\n if (Array.isArray(_model)) {\n return _patch; // if array was changed - override old one\n }\n }),\n );\n } else {\n changes[operation].set(docId, change);\n }\n },\n\n get(operation: Operations) {\n return changes[operation];\n },\n\n getAll() {\n return changes;\n },\n\n getIds(operation: Operations) {\n return [...changes[operation].keys()];\n },\n\n getDocs(operation: Operations) {\n return [...changes[operation].values()];\n },\n\n has(operation: Operations, id?: DocumentId) {\n if (id) {\n return changes[operation].has(id);\n }\n\n return changes[operation].size > 0;\n },\n\n hasAny() {\n const operations: Operations[] = objectValues(DocumentOperations);\n return operations.some(o => this.has(o));\n },\n\n reset() {\n changes = init();\n },\n };\n};\n","import type { BaseEntity, BaseChangesService } from 'core/base';\nimport { DocumentOperations } from 'core/base';\nimport type {\n CallEffect,\n GetContextEffect,\n PutEffect,\n SelectEffect,\n SagaReturnType,\n} from 'redux-saga/effects';\nimport { all, call, getContext, put, select } from 'redux-saga/effects';\nimport type { AllEffect } from '@redux-saga/core/effects';\nimport type { LoggerService } from 'core/services';\nimport { watchCreateDocuments, watchDeleteDocuments, watchUpdateDocuments } from '../../actions';\nimport type { Change, Changes, State } from './types';\nimport { documentsSelectors } from '../../selectors';\n\nconst { selectDocumentById } = documentsSelectors;\n\ntype ApplyChangesGenerator = Generator<\n | GetContextEffect\n | CallEffect>\n | AllEffect\n | CallEffect\n | SelectEffect\n | void\n | PutEffect,\n void,\n BaseChangesService & Change & BaseEntity & boolean & void\n>;\n\nexport function* applyChanges(changes: Changes): ApplyChangesGenerator {\n try {\n const changesService: BaseChangesService = yield getContext('ChangesService');\n\n if (changes.has(DocumentOperations.delete)) {\n const ids = changes.getIds(DocumentOperations.delete);\n yield put(watchDeleteDocuments(ids));\n }\n\n if (changes.has(DocumentOperations.create)) {\n const patches = changes.getDocs(DocumentOperations.create);\n\n const docs = yield call([changesService, 'applyChanges'], null, patches);\n yield put(watchCreateDocuments(docs));\n }\n\n if (changes.has(DocumentOperations.update)) {\n const patches = changes.getDocs(DocumentOperations.update);\n const ids = changes.getIds(DocumentOperations.update);\n const views = yield all(\n ids.map(id => select((s: State) => selectDocumentById(s, id)?.document)),\n );\n\n const docs = yield call([changesService, 'applyChanges'], views, patches);\n yield put(watchUpdateDocuments(docs));\n }\n } catch (error) {\n const loggerService: LoggerService = yield getContext('LoggerService');\n loggerService.error(error);\n }\n}\n","import type { SagaGenerator } from 'typed-redux-saga';\nimport { select } from 'typed-redux-saga';\n\nimport type { Change, Changes, State } from './types';\nimport { documentsSelectors } from '../../selectors';\n\nconst { selectDocumentById } = documentsSelectors;\n\nexport function* addChange(newChange: Change, changes: Changes): SagaGenerator {\n const document = yield* select((s: State) => selectDocumentById(s, newChange.docId)?.document);\n changes.add(newChange, document);\n}\n","import type { Channel } from 'redux-saga';\nimport { race, take } from 'typed-redux-saga';\nimport * as actions from '../../../actions';\nimport type { DocumentsActions } from '../../../types';\nimport type { DocsInProgress } from '../types';\n\nexport function* watchDocumentUpdating(\n channel: Channel,\n requests: DocsInProgress,\n) {\n try {\n while (true) {\n const { payload } = yield* take(channel);\n\n requests.add(payload.document._id);\n\n const { success, failure } = yield* race({\n success: take(actions.updateDocumentSuccess),\n failure: take(actions.updateDocumentFailure),\n });\n\n if (success) {\n requests.delete(success.payload.document._id);\n }\n\n if (failure) {\n requests.delete(failure.payload.id);\n }\n }\n } finally {\n channel.close();\n }\n}\n","import type { Channel } from 'redux-saga';\nimport { race, take } from 'typed-redux-saga';\n\nimport * as actions from '../../../actions';\nimport type { DocumentsActions } from '../../../types';\nimport type { DocsInProgress } from '../types';\n\nexport function* watchChildrenCreation(\n channel: Channel,\n requests: DocsInProgress,\n) {\n try {\n while (true) {\n const { payload } = yield* take(channel);\n\n requests.add(payload.parentId);\n\n const { success, failure } = yield* race({\n success: take(actions.createChildrenSuccess),\n failure: take(actions.createChildrenFailure),\n });\n\n if (success) {\n success.payload.forEach(entity => {\n requests.delete(entity._id);\n });\n }\n\n if (failure) {\n requests.delete(failure.payload.id);\n }\n }\n } finally {\n channel.close();\n }\n}\n","import { race, take } from 'typed-redux-saga';\nimport type { Channel } from 'redux-saga';\nimport type { DocsInProgress } from '../types';\nimport * as actions from '../../../actions';\nimport type { DocumentsActions } from '../../../types';\n\nexport function* watchChildrenDeletion(\n channel: Channel,\n requests: DocsInProgress,\n) {\n try {\n while (true) {\n const { payload } = yield* take(channel);\n\n requests.add(payload.parentId);\n\n const { success, failure } = yield* race({\n success: take(actions.deleteChildrenSuccess),\n failure: take(actions.deleteChildrenFailure),\n });\n\n if (success) {\n success.payload.ids.forEach(id => {\n requests.delete(id);\n });\n }\n\n if (failure) {\n requests.delete(failure.payload.id);\n }\n }\n } finally {\n channel.close();\n }\n}\n","import type { Channel } from 'redux-saga';\nimport { race, take } from 'typed-redux-saga';\nimport * as actions from '../../../actions';\nimport type { DocumentsActions } from '../../../types';\nimport type { DocsInProgress } from '../types';\n\nexport function* watchDocumentsUpdating(\n channel: Channel,\n requests: DocsInProgress,\n) {\n try {\n while (true) {\n const { payload } = yield* take(channel);\n\n payload.forEach(entity => {\n requests.add(entity._id);\n });\n\n const { success, failure } = yield* race({\n success: take(actions.updateDocumentsSuccess),\n failure: take(actions.updateDocumentsFailure),\n });\n\n if (success) {\n success.payload.forEach(entity => {\n requests.delete(entity._id);\n });\n }\n\n if (failure) {\n failure.payload.forEach(result => {\n requests.delete(result.id);\n });\n }\n }\n } finally {\n channel.close();\n }\n}\n","import type { Channel } from 'redux-saga';\nimport { race, take } from 'typed-redux-saga';\nimport * as actions from '../../../actions';\nimport type { DocumentsActions } from '../../../types';\nimport type { DocsInProgress } from '../types';\n\nexport function* watchDocumentsCoping(\n channel: Channel,\n requests: DocsInProgress,\n) {\n try {\n while (true) {\n const { payload } = yield* take(channel);\n\n requests.add(payload.target.id);\n\n const { success, failure } = yield* race({\n success: take(actions.copyDocumentsSuccess),\n failure: take(actions.copyDocumentsFailure),\n });\n\n if (success) {\n success.payload.forEach(entity => {\n requests.delete(entity._id);\n });\n }\n\n if (failure) {\n requests.delete(failure.payload.id);\n }\n }\n } finally {\n channel.close();\n }\n}\n","import type { Channel } from 'redux-saga';\nimport { race, take } from 'typed-redux-saga';\nimport * as actions from '../../../actions';\nimport type { DocumentsActions } from '../../../types';\nimport type { DocsInProgress } from '../types';\n\nexport function* watchDocumentsMoving(\n channel: Channel,\n requests: DocsInProgress,\n) {\n try {\n while (true) {\n const { payload } = yield* take(channel);\n\n requests.add(payload.target.id);\n\n const { success, failure } = yield* race({\n success: take(actions.moveDocumentsSuccess),\n failure: take(actions.moveDocumentsFailure),\n });\n\n if (success) {\n success.payload.forEach(entity => {\n requests.delete(entity._id);\n });\n }\n\n if (failure) {\n requests.delete(failure.payload.id);\n }\n }\n } finally {\n channel.close();\n }\n}\n","import { actionChannel, fork, take } from 'typed-redux-saga';\nimport { watchDocumentUpdating } from './watch-document-updating';\nimport { watchChildrenCreation } from './watch-children-creation';\nimport { watchChildrenDeletion } from './watch-children-deletion';\nimport { watchDocumentsUpdating } from './watch-documents-updating';\nimport { watchDocumentsCoping } from './watch-documents-coping';\nimport type { DocsInProgress } from '../types';\nimport * as actions from '../../../actions';\nimport { terminateAPP } from '../../../../common/actions';\nimport { watchDocumentsMoving } from './watch-documents-moving';\n\nexport function* watchRequests(documentsInProgress: DocsInProgress) {\n const createChildrenChannel = yield* actionChannel(actions.createChildren);\n const deleteChildrenChannel = yield* actionChannel(actions.deleteChildren);\n const updateDocumentChannel = yield* actionChannel(actions.updateDocumentInProgress);\n const updateDocumentsChannel = yield* actionChannel(actions.updateDocumentsInProgress);\n const copyDocumentsChannel = yield* actionChannel(actions.copyDocuments);\n const moveDocumentsChannel = yield* actionChannel(actions.moveDocuments);\n\n yield* fork(watchDocumentUpdating, updateDocumentChannel, documentsInProgress);\n yield* fork(watchDocumentsUpdating, updateDocumentsChannel, documentsInProgress);\n yield* fork(watchChildrenCreation, createChildrenChannel, documentsInProgress);\n yield* fork(watchChildrenDeletion, deleteChildrenChannel, documentsInProgress);\n yield* fork(watchDocumentsCoping, copyDocumentsChannel, documentsInProgress);\n yield* fork(watchDocumentsMoving, moveDocumentsChannel, documentsInProgress);\n\n yield* take(terminateAPP);\n\n [\n createChildrenChannel,\n deleteChildrenChannel,\n updateDocumentChannel,\n updateDocumentsChannel,\n copyDocumentsChannel,\n moveDocumentsChannel,\n ].forEach(ch => ch.close());\n}\n","import { call, delay, fork, getContext, put, race, take, takeEvery } from 'typed-redux-saga';\nimport type { ChangesResource } from 'core/base';\nimport type { EventChannel } from 'redux-saga';\nimport type { DocumentId } from 'core/types';\nimport type { DocumentsActions } from '../../types';\nimport { createChannel } from './create-channel';\nimport { accumulateChanges } from './accumulate-changes';\nimport { applyChanges } from './apply-changes';\nimport type { Change } from './types';\nimport { handleDocumentError } from '../../actions';\nimport { addChange } from './add-change';\nimport * as actions from '../../actions';\nimport { watchRequests } from './requests-watchers';\nimport { terminateAPP } from '../../../common/actions';\n\nexport function* listenChanges(channel: EventChannel) {\n const changes = accumulateChanges();\n\n let bufferChanges = [];\n\n const documentsInProgress = new Set();\n\n yield* fork(watchRequests, documentsInProgress);\n\n while (true) {\n const { change, timeout } = yield* race({\n // Listen sse events\n change: take(channel),\n\n // Collect sse changes during 1sec\n timeout: delay(1000),\n });\n\n const hasRequestsInProgress = documentsInProgress.size > 0;\n\n // If no requests and changes are waiting - add them to apply\n if (!hasRequestsInProgress && bufferChanges.length > 0) {\n // eslint-disable-next-line no-restricted-syntax\n for (const change of bufferChanges) {\n yield* fork(addChange, change, changes);\n }\n\n bufferChanges = [];\n }\n\n // If has change and requests in progress, save changes to add later\n if (change && hasRequestsInProgress) {\n bufferChanges.push(change);\n }\n\n // If has change and no requests, add change to apply\n if (change && !hasRequestsInProgress) {\n yield* fork(addChange, change, changes);\n }\n\n // No new events - apply changes\n if (timeout && changes.hasAny()) {\n try {\n yield* call(applyChanges, changes);\n } catch (error) {\n yield* put(handleDocumentError({ error }));\n } finally {\n changes.reset(); // Clear applied changes\n }\n }\n }\n}\n\nfunction* initWatchChanges(e: DocumentsActions['watchProjectChanges']) {\n try {\n const changesService = yield* getContext('ChangesService');\n if (!changesService) return;\n\n const sse = yield* call([changesService, 'createSSE'], e.payload);\n if (!sse) return;\n\n const channel = yield* call(createChannel, sse);\n\n yield* fork(listenChanges, channel);\n\n // Close connection when app is destroyed\n yield* take(terminateAPP);\n channel.close();\n } catch (error) {\n yield put(handleDocumentError({ error }));\n }\n}\n\nexport function* watchChanges() {\n yield* takeEvery(actions.watchProjectChanges.type, initWatchChanges);\n}\n","import type { DocumentResource } from 'core/base';\nimport { call, getContext, put, select, take } from 'typed-redux-saga';\nimport { handleDocumentError, addExpandedIds, expandAllSuccess } from '../actions';\nimport { documentsSelectors } from '../selectors';\nimport type { DocumentsActions } from '../types';\nimport * as actions from '../actions';\n\nconst { selectExpanded, selectDocumentById } = documentsSelectors;\n\nexport function* expandAll(e: DocumentsActions['expandAll']) {\n const { documentId } = e.payload;\n\n try {\n const documentService = yield* getContext('DocumentService');\n\n const [documents, ids] = yield* call([documentService, 'expandTree'], documentId);\n\n yield put(expandAllSuccess({ documents, expanded: ids }));\n } catch (error) {\n yield put(handleDocumentError({ error, id: documentId }));\n }\n}\n\nexport function* expandParents(e: DocumentsActions['expandParents']) {\n const { documentId, onSuccess } = e.payload;\n try {\n const documentService = yield* getContext('DocumentService');\n\n const expandedKeys = yield* select(selectExpanded);\n\n if (!expandedKeys.includes(documentId)) {\n const ids = yield* call([documentService, 'getPathToRoot'], documentId);\n\n let index = 0;\n while (index < ids.length - 1) {\n const id = ids[index];\n const document = yield* select(s => selectDocumentById(s, id));\n if (!document || !document.isChildrenLoaded) {\n yield put(actions.getChildren(id));\n yield take(actions.getChildrenSuccess.type);\n }\n index++;\n }\n\n const _ids = ids.slice(0, -1);\n yield put(addExpandedIds(_ids));\n }\n onSuccess?.();\n } catch (error) {\n yield put(handleDocumentError({ error, id: documentId }));\n }\n}\n\nexport function* expand(e: DocumentsActions['expand']) {\n const { documentId } = e.payload;\n yield put(addExpandedIds([documentId]));\n}\n","import type { GetContextEffect, PutEffect, SelectEffect } from 'redux-saga/effects';\nimport { put, select } from 'redux-saga/effects';\nimport type { DocumentId } from 'core/types';\nimport type { Dictionary } from '@reduxjs/toolkit';\nimport type { DocumentState, DocumentsActions } from '../types';\nimport { setExpandedIds, handleDocumentError } from '../actions';\nimport { documentsSelectors } from '../selectors';\n\nconst { selectExpanded, selectDocumentsList } = documentsSelectors;\n\ntype CollapseGenerator = Generator<\n GetContextEffect | PutEffect | SelectEffect,\n void,\n DocumentId[] & DocumentState\n>;\n\nexport function* collapse(e: DocumentsActions['collapse']): CollapseGenerator {\n const { documentId: parentId } = e.payload;\n\n const ids = new Set([parentId]);\n const traverse = (documentList: Dictionary, parentId: DocumentId) => {\n const documentsState = documentList[parentId];\n\n if (!documentsState) return;\n\n const { childrenIds } = documentsState.document.meta;\n if (!childrenIds || childrenIds.length === 0) return;\n\n const { length } = childrenIds;\n let i = 0;\n while (i < length) {\n const id = childrenIds[i++];\n ids.add(id);\n traverse(documentList, id);\n }\n };\n\n try {\n const expandedKeys: DocumentId[] = yield select(selectExpanded);\n const documentList = yield select(selectDocumentsList);\n\n traverse(documentList as unknown as Dictionary, parentId);\n\n const expanded = expandedKeys.filter(id => !ids.has(id));\n\n yield put(setExpandedIds(expanded));\n } catch (error) {\n yield put(handleDocumentError({ error, id: parentId }));\n }\n}\n","import { call, delay, getContext, put } from 'typed-redux-saga';\nimport type { DocumentResource } from 'core/base';\nimport { t } from 'i18next';\nimport type { DocumentsActions } from '../types';\nimport {\n duplicateProjectFailure,\n duplicateProjectSuccess,\n handleDocumentError,\n watchProjectChanges,\n} from '../actions';\nimport { showAlertSuccess } from '../../common';\n\nexport function* duplicateProject(e: DocumentsActions['duplicateProject']) {\n const { id, navigate } = e.payload;\n try {\n const documentService = yield* getContext('DocumentService');\n\n const newProject = yield* call([documentService, 'duplicateWorkspace'], id);\n\n yield* put(duplicateProjectSuccess({ document: newProject, rootId: newProject._id }));\n yield* put(showAlertSuccess(t('Alert.WarningDuplicate.success')));\n yield* put(watchProjectChanges(newProject._id));\n if (navigate) {\n yield* delay(500); // Make small delay to wait UI update\n navigate(`/${newProject._id}`);\n }\n } catch (error) {\n yield* put(duplicateProjectFailure());\n yield* put(handleDocumentError({ error }));\n }\n}\n","import type { DocumentResource } from 'core/base';\nimport { call, getContext, put, all } from 'typed-redux-saga';\nimport type { DocumentsActions } from '../types';\nimport * as actions from '../actions';\n\nexport function* exportDocuments({ payload }: DocumentsActions['exportDocuments']) {\n const documentService = yield* getContext('DocumentService');\n\n try {\n const result = yield* all(\n payload.map(function* (id) {\n const [documents] = yield* call([documentService, 'expandTree'], id);\n\n return documents;\n }),\n );\n\n yield* put(actions.exportDocumentsSuccess(result.flat()));\n } catch (error) {\n yield* put(actions.handleDocumentError({ error }));\n }\n}\n","import { all, takeEvery, fork, spawn } from 'typed-redux-saga';\nimport { copyDocuments } from './copy-documents';\nimport { createChildren } from './create-children';\nimport { createProject } from './create-project';\nimport { deleteChildren } from './delete-children';\nimport { getChildren } from './get-children';\nimport { getDocument } from './get-document';\nimport { getProject } from './get-project';\nimport { handleDocumentError } from './handle-document-error';\nimport { importDocuments } from './import-documents';\nimport { moveDocuments } from './move-documents';\nimport { watchUpdateDocument } from './update-document';\nimport { updateDocumentAccess } from './update-document-access';\nimport { watchBulkUpdateDocuments } from './update-documents';\nimport { watchChanges } from './watch-project';\nimport { expand, expandAll, expandParents } from './expand-documents';\nimport { collapse } from './collapse-documents';\nimport { duplicateProject } from './duplicate-project';\nimport * as actions from '../actions';\nimport { exportDocuments } from './export-documents';\nimport { createRevisionList } from './utils';\n\nexport function* sagas() {\n // Save fresh revision to use for next request\n const revs = createRevisionList();\n\n yield* all([\n takeEvery(actions.exportDocuments, exportDocuments),\n takeEvery(actions.createProject, createProject),\n takeEvery(actions.duplicateProject, duplicateProject),\n takeEvery(actions.getProject, getProject),\n takeEvery(actions.updateDocumentAccess, updateDocumentAccess),\n takeEvery(actions.getDocument, getDocument),\n takeEvery(actions.getChildren, getChildren),\n takeEvery(actions.createChildren, createChildren),\n takeEvery(actions.importDocuments, importDocuments),\n takeEvery(actions.deleteChildren, deleteChildren),\n takeEvery(actions.copyDocuments, copyDocuments),\n takeEvery(actions.moveDocuments, moveDocuments),\n takeEvery(actions.expandAll, expandAll),\n takeEvery(actions.expand, expand),\n takeEvery(actions.expandParents, expandParents),\n takeEvery(actions.collapse, collapse),\n takeEvery(actions.handleDocumentError, handleDocumentError),\n\n spawn(watchChanges),\n fork(watchUpdateDocument, revs),\n fork(watchBulkUpdateDocuments, revs),\n ]);\n}\n","import type { BaseEntity } from 'core/base';\nimport { useSelector } from 'react-redux';\nimport type { DocumentId } from 'core/types';\nimport type { DocumentsState } from './types';\nimport { createDocumentsSelectors } from './selectors';\nimport { STATUS } from '../../types';\nimport { toDocumentState } from './utils';\n\nexport const createDocumentsHooks = () => {\n type TState = { documents: DocumentsState };\n\n const selectors = createDocumentsSelectors();\n const {\n selectRootDocument,\n selectAllDocuments,\n selectDocumentById,\n selectRootId,\n selectDocumentsList,\n selectProject,\n selectExpanded,\n selectDocumentIds,\n selectDocumentsCount,\n } = selectors;\n\n const emptyState = toDocumentState({\n document: {} as TEntity,\n status: STATUS.IDLE,\n errors: [],\n });\n\n const useRootDocument = () => useSelector(selectRootDocument) ?? emptyState;\n const useRootId = () => useSelector(selectRootId);\n const useExpanded = () => useSelector(selectExpanded);\n const useDocument = (id: DocumentId) =>\n useSelector((s: TState) => selectDocumentById(s, id)) ?? emptyState;\n const useDocuments = () => useSelector(selectAllDocuments);\n const useDocumentsList = () => useSelector(selectDocumentsList);\n const useProject = () => useSelector(selectProject);\n const useDocumentIds = () => useSelector(selectDocumentIds);\n const useDocumentsCount = () => useSelector(selectDocumentsCount);\n\n return {\n useRootDocument,\n useRootId,\n useDocumentIds,\n useDocument,\n useDocuments,\n useDocumentsList,\n useProject,\n useExpanded,\n useDocumentsCount,\n };\n};\n\nexport const documentsHooks = createDocumentsHooks();\n","import { createDocumentsActions } from './actions';\n\nexport const documentsActions = createDocumentsActions(); // Export actions for core usage with BaseDocumentVM\nexport { createDocumentsActions } from './actions';\nexport * from './types';\nexport { reducer as documentsReducer } from './reducer';\nexport { sagas as documentsSagas } from './sagas';\nexport * from './selectors';\nexport * from './hooks';\n","import type { StoreState } from 'core/types';\n\nexport const selectUser = (s: StoreState) => s.user;\n","/* eslint-disable import/no-import-module-exports */\nimport type { Middleware, Reducer } from 'redux';\nimport { persistCombineReducers, persistStore } from 'redux-persist';\nimport autoMergeLevel2 from 'redux-persist/lib/stateReconciler/autoMergeLevel2';\nimport storage from 'redux-persist/lib/storage';\n\nimport { configureStore } from '@reduxjs/toolkit';\nimport createSagaMiddleware from 'redux-saga';\nimport { middleware } from './middleware';\n\nimport reducers from './modules/common/reducers';\nimport { root as rootSaga } from './modules/common/sagas';\nimport { LoggerService } from '../services';\n\nconst loggerService = new LoggerService('core');\n\n/* istanbul ignore next */\nexport const configStore = >(\n additionalMiddleware: Middleware[],\n additionalReducers: TReducers,\n) => {\n const sagaMiddleware = createSagaMiddleware({\n onError(error) {\n loggerService.error(error);\n },\n });\n\n const rootReducer = persistCombineReducers(\n {\n key: 'rrsb',\n stateReconciler: autoMergeLevel2,\n storage,\n whitelist: ['app'],\n timeout: 0,\n },\n { ...reducers, ...additionalReducers },\n );\n\n const store = configureStore({\n reducer: rootReducer,\n middleware: [...middleware, ...additionalMiddleware, sagaMiddleware],\n });\n\n sagaMiddleware.run(rootSaga);\n\n /* eslint-disable unicorn/prefer-module */\n if (module.hot) {\n module.hot.accept('./modules', () => {\n store.replaceReducer(rootReducer);\n });\n }\n\n return {\n persistor: persistStore(store),\n store,\n saga: sagaMiddleware,\n };\n};\n\nexport * from './modules';\nexport * from './selectors';\nexport * from './types';\n","/**\n * @module Actions/Conflict\n * @desc Conflict Actions\n */\nimport { ActionTypes } from '../literals';\nimport { createAction } from 'core/modules/helpers';\n\nexport const conflictSet = createAction(ActionTypes.CONFLICT_SET, (type, items) => ({\n type,\n items,\n}));\n","/**\n * @module Actions/App\n * @desc App Actions\n */\nimport type React from 'react';\nimport { uuid } from 'core/utils';\nimport { createAction } from '@reduxjs/toolkit';\nimport type { ShowAlertOptions } from 'core/types/common';\nimport { ActionTypes } from '../literals';\n\nconst makePayload = (payload = {}) => ({ payload });\n\nexport const hideAlert = createAction(ActionTypes.HIDE_ALERT, (id: string) => makePayload({ id }));\nexport const appNameSet = createAction(ActionTypes.APP_NAME_SET, (name: string) =>\n makePayload({ name }),\n);\n\nconst getAlertConfig = (message: React.ReactNode, options: ShowAlertOptions) =>\n makePayload({\n id: options.id || uuid(),\n icon: options.icon,\n message,\n description: options.description,\n position: options.position || 'bottom-right',\n variant: options.variant || 'open',\n timeout: options.timeout,\n });\n\nexport const showAlert = createAction(ActionTypes.SHOW_ALERT, getAlertConfig);\n\nexport const showAlertError = createAction(\n ActionTypes.SHOW_ALERT,\n (message: string, options = {}) =>\n getAlertConfig(message, { ...options, timeout: 0, variant: 'error' }),\n);\nexport const showAlertSuccess = createAction(\n ActionTypes.SHOW_ALERT,\n (message: string, options = {}) => getAlertConfig(message, { ...options, variant: 'success' }),\n);\nexport const assignmentWindowShow = createAction(ActionTypes.ASSIGNMENT_WINDOW_SHOW);\nexport const assignmentWindowHide = createAction(ActionTypes.ASSIGNMENT_WINDOW_HIDE);\nexport const loadingShow = createAction(ActionTypes.LOADING_SHOW, (message: string) =>\n makePayload({ message }),\n);\nexport const loadingSetMessage = createAction(ActionTypes.LOADING_SET_MESSAGE, (message: string) =>\n makePayload({ message }),\n);\nexport const loadingHide = createAction(ActionTypes.LOADING_HIDE);\n\nexport const searchPanelShow = createAction(ActionTypes.SEARCH_PANEL_SHOW);\nexport const searchPanelHide = createAction(ActionTypes.SEARCH_PANEL_HIDE);\nexport const searchPanelShowResults = createAction(ActionTypes.SEARCH_PANEL_SHOW_RESULTS);\nexport const terminateAPP = createAction(ActionTypes.TERMINATE_APP);\n","/**\n * @module Actions/User\n * @desc User Actions\n */\n\nimport { ActionTypes } from '../literals';\nimport { createAction } from 'core/modules/helpers';\n\nexport const logOut = createAction(ActionTypes.USER_LOGOUT_REQUEST, () => ({}));\nexport const userInfo = createAction(ActionTypes.USER_INFO_REQUEST, () => ({}));\nexport const userAlertWelcome = createAction(\n ActionTypes.USER_SHOW_ALERT_WELCOME,\n (message: string) => ({ message }),\n);\n","/**\n * @module Actions/PouchDB\n * @desc PouchDB Actions\n */\n\nimport type { SearchState } from 'core/types';\nimport type { UUID } from 'short-uuid';\n\nimport { ActionTypes } from '../literals';\nimport { createAction } from 'core/modules/helpers';\n\nexport const pouchDbImport = createAction(ActionTypes.POUCH_DB_IMPORT, (data: any) => ({\n data,\n}));\n\nexport const pouchDbRemove = createAction(ActionTypes.POUCH_DB_REMOVE, (id: UUID) => ({\n id,\n}));\n\nexport const pouchDbGetWorkspaces = createAction(ActionTypes.POUCH_DB_GET_WORKSPACES, () => ({}));\n\nexport const pouchDbGetList = createAction(\n ActionTypes.POUCH_DB_GET_LIST,\n (id: string | undefined) => ({ id }),\n);\n\nexport const pouchDbSearch = createAction(ActionTypes.POUCH_DB_SEARCH, (search: SearchState) => ({\n search,\n}));\n\nexport const pouchDbSearchEnabled = createAction(\n ActionTypes.POUCH_DB_SEARCH_ENABLED,\n (enabled: boolean) => ({ enabled }),\n);\n\nexport const pouchDbSaveOrder = createAction(\n ActionTypes.POUCH_DB_SAVE_ORDER,\n (order: any[], dragItem: any) => ({ order, dragItem }),\n);\n","/**\n * @module Actions/Editor\n * @desc Editor Actions\n */\n\nimport type { EditorDocument } from 'core/types';\n\nimport { ActionTypes } from '../literals';\nimport { createAction } from 'core/modules/helpers';\n\nexport const editorGetById = createAction(\n ActionTypes.EDITOR_GET_DOCUMENT_ID,\n (id: string | undefined) => ({ id }),\n);\n\nexport const editorPut = createAction(\n ActionTypes.EDITOR_PUT_DOCUMENT,\n (id: string, document: EditorDocument) => ({ id, document }),\n);\n\nexport const editorCreate = createAction(ActionTypes.EDITOR_CREATE_DOCUMENT, (document: any) => ({\n document,\n}));\n\nexport const editorUpdating = createAction(ActionTypes.EDITOR_UPDATING_DOCUMENT, (value: any) => ({\n value,\n}));\n\nexport const editorPutRev = createAction(ActionTypes.EDITOR_PUT_DOCUMENT_REV, (rev: any) => ({\n rev,\n}));\n","/**\n * @module Actions/Workspace\n * @desc Workspace Actions\n */\n\nimport { ActionTypes } from '../literals';\nimport { createAction } from 'core/modules/helpers';\n\nexport const workspaceInit = createAction(ActionTypes.WORKSPACE_INIT, (item = {}) => ({ item }));\nexport const workspaceSetId = createAction(ActionTypes.WORKSPACE_SET_ID, (id: string | undefined) => ({ id }));\n\nexport const workspaceLoadByItemId = createAction(\n ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID,\n (id: string | undefined) => ({ id }),\n);\n","/**\n * @module Actions/Organization\n * @desc Organization Actions\n */\nimport { ActionTypes } from '../literals';\nimport { createAction } from '../../../../modules/helpers';\n\nexport const organizationGetUsers = createAction(ActionTypes.ORGANIZATION_GET_USERS, () => ({}));\n","/**\n * @module Actions/Assignments\n * @desc Assignments Actions\n */\n\nimport { ActionTypes } from '../literals';\nimport { createAction } from 'core/modules/helpers';\n\nexport const assignmentsSet = createAction(ActionTypes.ASSIGNMENT_SET, (item = {}) => ({ item }));\nexport const assignmentsGet = createAction(ActionTypes.ASSIGNMENT_GET, (id: string) => ({\n id,\n}));\nexport const assignmentsResetStatus = createAction(\n ActionTypes.ASSIGNMENT_SET_RESET_STATUS,\n () => ({}),\n);\n","import { REHYDRATE } from 'redux-persist';\nimport { ActionTypes } from 'core/store/modules/common/literals';\nimport { createReducer } from '@reduxjs/toolkit';\nimport type { AppState } from 'core/types';\nimport { STATUS } from '../../../types';\n\nexport const appState: AppState = {\n name: null,\n alerts: [],\n assignmentWindow: {\n status: STATUS.IDLE,\n },\n loading: {\n status: STATUS.IDLE,\n message: '',\n },\n searchPanelStatus: STATUS.IDLE,\n};\n\nexport default {\n app: createReducer(appState, {\n [REHYDRATE]: draft => {\n draft.alerts = [];\n },\n [ActionTypes.APP_NAME_SET]: (draft, { payload: { name } }) => {\n draft.name = name;\n },\n [ActionTypes.HIDE_ALERT]: (draft, { payload: { id } }) => {\n draft.alerts = draft.alerts.filter(d => d.id !== id);\n },\n [ActionTypes.SHOW_ALERT]: (draft, { payload }) => {\n draft.alerts.push(payload);\n },\n [ActionTypes.ASSIGNMENT_WINDOW_SHOW]: draft => {\n draft.assignmentWindow.status = STATUS.SUCCESS;\n },\n [ActionTypes.ASSIGNMENT_WINDOW_HIDE]: draft => {\n draft.assignmentWindow.status = STATUS.IDLE;\n },\n [ActionTypes.LOADING_SHOW]: (draft, { payload: { message } }) => {\n draft.loading.message = message;\n draft.loading.status = STATUS.SUCCESS;\n },\n [ActionTypes.LOADING_SET_MESSAGE]: (draft, { payload: { message } }) => {\n draft.loading.message = message;\n },\n [ActionTypes.LOADING_HIDE]: draft => {\n draft.loading.status = STATUS.IDLE;\n draft.loading.message = '';\n },\n [ActionTypes.SEARCH_PANEL_SHOW]: draft => {\n draft.searchPanelStatus = STATUS.RUNNING;\n },\n [ActionTypes.SEARCH_PANEL_HIDE]: draft => {\n draft.searchPanelStatus = STATUS.IDLE;\n },\n [ActionTypes.SEARCH_PANEL_SHOW_RESULTS]: draft => {\n draft.searchPanelStatus = STATUS.SUCCESS;\n },\n }),\n};\n","import { createReducer } from '@reduxjs/toolkit';\nimport type { AssignmentsState, AssignmentsType } from 'core/types';\nimport { ActionTypes } from '../literals';\nimport { STATUS } from '../../../types';\n\nexport const assignmentsState: AssignmentsState = {\n item: {} as AssignmentsType,\n statusSet: STATUS.IDLE,\n statusGet: STATUS.IDLE,\n statusList: STATUS.IDLE,\n};\n\nexport default {\n assignment: createReducer(assignmentsState, {\n [ActionTypes.ASSIGNMENT_SET_RESET_STATUS]: draft => {\n draft.statusSet = STATUS.IDLE;\n },\n [ActionTypes.ASSIGNMENT_SET]: (draft, { payload: { item } }) => {\n draft.statusSet = STATUS.RUNNING;\n draft.item = item;\n },\n [ActionTypes.ASSIGNMENT_SET_SUCCESS]: draft => {\n draft.statusSet = STATUS.SUCCESS;\n },\n [ActionTypes.ASSIGNMENT_SET_FAILURE]: draft => {\n draft.statusSet = STATUS.ERROR;\n },\n [ActionTypes.ASSIGNMENT_GET]: draft => {\n draft.statusGet = STATUS.RUNNING;\n draft.item = {} as AssignmentsType;\n },\n [ActionTypes.ASSIGNMENT_GET_SUCCESS]: (draft, { payload: { item } }) => {\n draft.statusGet = STATUS.SUCCESS;\n draft.item = item;\n },\n [ActionTypes.ASSIGNMENT_GET_FAILURE]: draft => {\n draft.statusGet = STATUS.ERROR;\n },\n }),\n};\n","import type { ConflictState } from 'core/types';\nimport { createReducer } from '@reduxjs/toolkit';\nimport { ACTION_TYPE, ActionTypes } from '../literals';\n\nexport const conflictState: ConflictState = {\n items: null,\n type: ACTION_TYPE.NONE,\n};\n\nexport default {\n conflict: createReducer(conflictState, {\n [ActionTypes.CONFLICT_SET]: (draft, { payload: { items, type } }) => {\n draft.type = type;\n draft.items = items;\n },\n }),\n};\n","import { createReducer } from '@reduxjs/toolkit';\nimport type { EditorState } from 'core/types';\nimport { ActionTypes } from '../literals';\nimport { STATUS } from '../../../types';\n\nexport const editorState = {\n document: {},\n id: '',\n status: STATUS.IDLE,\n title: '',\n pluginCodes: [],\n pluginsDocAttrs: {},\n updated: null,\n updating: null,\n created: null,\n};\n\nexport default {\n editor: createReducer(editorState, {\n [ActionTypes.EDITOR_GET_DOCUMENT_ID]: (draft, { payload: { id } }) => {\n draft.id = id;\n draft.title = '';\n draft.updated = null;\n draft.updating = null;\n draft.created = null;\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.EDITOR_GET_DOCUMENT_SUCCESS]: (draft, { payload: { document } }) => {\n draft.document = document;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.EDITOR_GET_DOCUMENT_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.EDITOR_PUT_DOCUMENT_REV]: (draft, { payload: { rev } }) => {\n draft.rev = rev;\n // eslint-disable-next-line no-underscore-dangle\n draft.document._rev = draft.rev;\n },\n [ActionTypes.EDITOR_UPDATING_DOCUMENT]: (draft, { payload: { value } }) => {\n draft.updating = value;\n },\n [ActionTypes.EDITOR_PUT_DOCUMENT]: draft => {\n draft.updating = Date.now();\n draft.created = null;\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.EDITOR_PUT_DOCUMENT_SUCCESS]: (draft, { payload: { document } }) => {\n draft.document = document;\n // eslint-disable-next-line no-underscore-dangle\n draft.rev = document._rev;\n draft.title = document.title;\n draft.updated = Date.now();\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.EDITOR_PUT_DOCUMENT_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.EDITOR_CREATE_DOCUMENT]: draft => {\n draft.created = Date.now();\n },\n [ActionTypes.EDITOR_PLUGINS_SET_CODES]: (draft, { payload: { pluginCodes } }) => {\n draft.pluginCodes = pluginCodes;\n },\n [ActionTypes.EDITOR_PLUGINS_SET_ATTRIBUTES]: (draft, { payload: { docAttrs } }) => {\n draft.pluginsDocAttrs = docAttrs;\n },\n }),\n};\n","import { createReducer } from '@reduxjs/toolkit';\nimport type { OrganizationState } from 'core/types';\nimport { ActionTypes } from '../literals';\nimport { STATUS } from '../../../types';\n\nexport const organizationState: OrganizationState = {\n users: [],\n status: STATUS.IDLE,\n};\n\nexport default {\n organization: createReducer(organizationState, {\n [ActionTypes.ORGANIZATION_GET_USERS]: draft => {\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.ORGANIZATION_GET_USERS_SUCCESS]: (draft, { payload }) => {\n draft.users = payload;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.ORGANIZATION_GET_USERS_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n }),\n};\n","import type { PouchDbState } from 'core/types';\nimport { createReducer } from '@reduxjs/toolkit';\nimport { ActionTypes, RESOLVING_STATUS_ANY } from '../literals';\nimport { STATUS } from '../../../types';\n\nexport const pouchDbState: PouchDbState = {\n assignments: [],\n root: undefined,\n id: undefined,\n items: [],\n status: STATUS.IDLE,\n assignmentsStatus: STATUS.IDLE,\n search: {\n inHtml: true,\n inTitle: true,\n responsible: null,\n responsibleStatus: RESOLVING_STATUS_ANY.ANY,\n showUnmatched: false,\n text: '',\n count: 0,\n status: STATUS.IDLE,\n showResult: true,\n enabled: false,\n },\n order: {\n status: STATUS.IDLE,\n dragItem: {},\n items: [],\n },\n};\n\nexport default {\n pouchdb: createReducer(pouchDbState, {\n [ActionTypes.POUCH_DB_REMOVE_SUCCESS]: draft => {\n draft.status = STATUS.DELETED;\n },\n [ActionTypes.POUCH_DB_REMOVE_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.POUCH_DB_IMPORT_SUCCESS]: (draft, { payload: { id } }) => {\n draft.status = STATUS.IMPORTED;\n draft.id = id;\n },\n [ActionTypes.POUCH_DB_IMPORT_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.POUCH_DB_SET_ITEM]: (draft, { payload: { document, id } }) => {\n const index = draft.items.findIndex(item => item._id === id);\n\n if (index > -1) {\n draft.items.splice(index, 1, document);\n }\n },\n [ActionTypes.POUCH_DB_GET_WORKSPACES]: draft => {\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.POUCH_DB_GET_WORKSPACES_SUCCESS]: (draft, { payload: { items } }) => {\n draft.items = items;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.POUCH_DB_GET_WORKSPACES_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.POUCH_DB_GET_LIST]: (draft, { payload: { id } }) => {\n draft.id = id;\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.POUCH_DB_GET_LIST_SUCCESS]: (draft, { payload: { items, root } }) => {\n draft.items = items;\n draft.root = root;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.POUCH_DB_GET_LIST_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.POUCH_DB_CREATE_WORKSPACE]: draft => {\n draft.status = STATUS.CREATE;\n },\n [ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST]: draft => {\n draft.assignmentsStatus = STATUS.RUNNING;\n },\n [ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST_SUCCESS]: (draft, { payload: { items } }) => {\n draft.assignmentsStatus = STATUS.SUCCESS;\n draft.assignments = items;\n },\n [ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST_FAILURE]: draft => {\n draft.assignmentsStatus = STATUS.ERROR;\n },\n [ActionTypes.POUCH_DB_SEARCH]: (draft, { payload: { search } }) => {\n draft.search = search;\n draft.search.status = STATUS.RUNNING;\n },\n [ActionTypes.POUCH_DB_SEARCH_ENABLED]: (draft, { payload: { enabled } }) => {\n draft.search.enabled = enabled;\n },\n [ActionTypes.POUCH_DB_SEARCH_SUCCESS]: (draft, { payload: { count, items, showResult } }) => {\n draft.items = items;\n draft.search.showResult = showResult;\n draft.search.count = count;\n draft.search.status = STATUS.SUCCESS;\n },\n [ActionTypes.POUCH_DB_SEARCH_FAILURE]: draft => {\n draft.search.status = STATUS.ERROR;\n },\n [ActionTypes.POUCH_DB_SAVE_ORDER]: (draft, { payload: { dragItem, order } }) => {\n draft.order.items = order;\n draft.order.dragItem = dragItem;\n draft.order.status = STATUS.RUNNING;\n },\n [ActionTypes.POUCH_DB_SAVE_ORDER_SUCCESS]: draft => {\n draft.order.status = STATUS.SUCCESS;\n },\n [ActionTypes.POUCH_DB_SAVE_ORDER_FAILURE]: draft => {\n draft.order.status = STATUS.ERROR;\n },\n }),\n};\n","import { createReducer } from '@reduxjs/toolkit';\nimport type { UserState } from 'core/types';\nimport { ActionTypes } from '../literals';\nimport { STATUS } from '../../../types';\n\nexport const userState: UserState = {\n isAuthenticated: false,\n status: STATUS.IDLE,\n id: null,\n user: null,\n};\n\nexport default {\n user: createReducer(userState, {\n [ActionTypes.USER_LOGOUT_REQUEST]: draft => {\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.USER_LOGOUT_SUCCESS]: draft => {\n draft.isAuthenticated = false;\n draft.status = STATUS.IDLE;\n draft.token = undefined;\n draft.time = undefined;\n },\n [ActionTypes.USER_LOGOUT_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.USER_INFO_SUCCESS]: (draft, { payload: { id, time, user } }) => {\n draft.isAuthenticated = true;\n draft.status = STATUS.READY;\n draft.time = time;\n draft.id = id;\n draft.user = user;\n },\n [ActionTypes.USER_SHOW_ALERT_WELCOME]: (draft, { payload: { message } }) => {\n draft.shownAlertWelcome = message;\n },\n }),\n};\n","import { createHashDataset } from 'core/utils/create-hash-dataset';\n\nexport default (current: string, dataset: any) => {\n const hash = createHashDataset(dataset);\n\n dataset.reduce((data: any, { _id: id, parent }: any) => {\n if (!parent || !hash[parent]) {\n return [];\n }\n\n const datasetHash = hash[parent];\n\n datasetHash.children = datasetHash.children || [];\n datasetHash.children.push(hash[id]);\n\n return data;\n }, []);\n\n return hash[current] ? hash[current] : [];\n};\n","import { createHashDataset } from 'core/utils/create-hash-dataset';\n\nconst findPath = (currentId: string, hash: any, data: string[]) => {\n if (hash[currentId]) {\n const { id, parent, root } = hash[currentId];\n\n if (id === root) {\n return;\n }\n\n findPath(parent, hash, data);\n\n data.push(id);\n }\n};\n\nexport default (id: string, dataset: any) => {\n const hash = createHashDataset(dataset, ({ parent, root }: any) => ({\n parent,\n root,\n }));\n\n const result: string[] = [];\n\n findPath(id, hash, result);\n\n return result;\n};\n","import getChildren from 'core/utils/get-children';\nimport getParents from 'core/utils/get-parents';\nimport { createReducer } from '@reduxjs/toolkit';\nimport type { EditorDocument, WorkspaceState } from 'core/types';\nimport { ActionTypes } from '../literals';\nimport { STATUS } from '../../../types';\n\nexport const workspaceState: WorkspaceState = {\n item: {} as EditorDocument,\n id: '',\n status: STATUS.IDLE,\n parents: [],\n children: null,\n};\n\nexport default {\n workspace: createReducer(workspaceState, {\n [ActionTypes.WORKSPACE_INIT]: (draft, { payload: { item } }) => {\n draft.item = item;\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.WORKSPACE_INIT_SUCCESS]: (draft, { payload: { item } }) => {\n draft.item = item;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.WORKSPACE_INIT_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.WORKSPACE_SET_ID]: (draft, { payload: { id } }) => {\n draft.id = id;\n },\n [ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID]: (draft, { payload: { id } }) => {\n draft.id = id;\n draft.status = STATUS.RUNNING;\n },\n [ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID_SUCCESS]: (draft, { payload: { id, item } }) => {\n draft.item = item;\n draft.id = id;\n draft.status = STATUS.SUCCESS;\n },\n [ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID_FAILURE]: draft => {\n draft.status = STATUS.ERROR;\n },\n [ActionTypes.WORKSPACE_SET_CHILDREN]: (draft, { payload: { dataset, id } }) => {\n const children = getChildren(id, dataset);\n\n draft.children = children;\n },\n [ActionTypes.WORKSPACE_SET_PARENTS]: (draft, { payload: { dataset, id } }) => {\n const parents = getParents(id, dataset);\n\n draft.parents = parents;\n },\n }),\n};\n","import app, { appState } from './app';\nimport assignments, { assignmentsState } from './assignments';\nimport conflict, { conflictState } from './conflict';\nimport editor, { editorState } from './editor';\nimport organization, { organizationState } from './organization';\nimport pouchdb, { pouchDbState } from './pouchdb';\nimport user, { userState } from './user';\nimport workspace, { workspaceState } from './workspace';\n\nexport const commonInitialState = {\n app: appState,\n user: userState,\n pouchdb: pouchDbState,\n editor: editorState,\n workspace: workspaceState,\n organization: organizationState,\n assignments: assignmentsState,\n conflict: conflictState,\n};\n\nexport default {\n ...app,\n ...user,\n ...pouchdb,\n ...editor,\n ...workspace,\n ...organization,\n ...assignments,\n ...conflict,\n};\n","/**\n * @module Sagas/Assignments\n * @desc Assignments\n */\n\nimport { all, call, getContext, put, takeLatest } from 'redux-saga/effects';\nimport { ActionTypes } from 'core/store/modules/common/literals';\n\n/**\n * assignmentsGet\n */\nexport function* assignmentsGet({ payload }: any): any {\n const { id } = payload;\n\n try {\n const server = yield getContext('AssignmentService');\n\n if (!server) {\n return;\n }\n\n const [item] = yield call([server, 'getChildren'], id);\n\n yield put({\n type: ActionTypes.ASSIGNMENT_GET_SUCCESS,\n payload: { item },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.ASSIGNMENT_GET_FAILURE,\n });\n }\n}\n\n/**\n * assignmentsSet\n */\nexport function* assignmentsSet({ payload }: any): any {\n const { item } = payload;\n\n try {\n const server = yield getContext('AssignmentService');\n\n if (!server) {\n return;\n }\n\n yield call([server, 'update'], item);\n\n yield put({\n type: ActionTypes.ASSIGNMENT_SET_SUCCESS,\n });\n\n yield put({\n type: ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST,\n payload: { rootId: item.root },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.ASSIGNMENT_SET_FAILURE,\n });\n }\n}\n\n/**\n * Assignments Sagas\n */\nexport default function* root() {\n yield all([\n takeLatest(ActionTypes.ASSIGNMENT_GET, assignmentsGet),\n takeLatest(ActionTypes.ASSIGNMENT_SET, assignmentsSet),\n ]);\n}\n","/**\n * @module Sagas/Editor\n * @desc Editor\n */\nimport { conflictSet } from 'core/store/modules/common/actions/conflict';\nimport { getHTMLDocument } from 'core/includes/html/utils/dom';\nimport {\n extractPluginCode,\n getPluginsFolderId,\n isPluginId,\n isPluginsDocument,\n} from 'core/includes/plugins/utils/detections';\nimport { extractAttributes } from 'core/includes/plugins/utils/extract-plugins';\nimport findPluginsRefDocument from 'core/includes/plugins/utils/find';\nimport { getPluginByCode, pluginToDocument } from 'core/includes/plugins/utils/get-plugin';\nimport {\n ACTION_TYPE,\n ActionTypes,\n CONFLICT_ERROR_MESSAGE,\n} from 'core/store/modules/common/literals';\nimport { isRootDocument, isFolderDocument } from 'core/repositories';\nimport type { PutDocument } from 'core/types';\nimport { all, call, getContext, put, select, takeLatest } from 'redux-saga/effects';\n\n/**\n * editorGetDocument\n */\nfunction* editorGetDocument({ payload }: any): any {\n let document;\n let documentAttributes = {};\n const { id } = payload;\n\n try {\n const { items: dataset } = yield select(s => s.pouchdb);\n const server = yield getContext('DocumentService');\n\n const isPluginDocument = isPluginId(id);\n\n if (isPluginDocument) {\n const pluginsFolderId = getPluginsFolderId(id);\n\n // @ts-ignore\n const pluginsFolderDocument = yield call([server, 'get'], pluginsFolderId);\n const htmlDocument = getHTMLDocument(pluginsFolderDocument.html);\n\n documentAttributes = extractAttributes(htmlDocument);\n\n const pluginCode = extractPluginCode(id);\n const plugin = getPluginByCode(pluginCode, documentAttributes);\n\n if (plugin) {\n document = pluginToDocument(plugin, { _id: pluginCode });\n }\n } else {\n // @ts-ignore\n document = yield call([server, 'get'], id);\n\n if (\n !isRootDocument(document) &&\n !isFolderDocument(document.type) &&\n !isPluginsDocument(document.type)\n ) {\n // eslint-disable-next-line no-underscore-dangle\n const pluginsRefDocument = findPluginsRefDocument(document._id, document.parent, dataset);\n\n if (pluginsRefDocument) {\n const { _id } = pluginsRefDocument;\n\n // @ts-ignore\n const pluginsFolderDocument = yield call([server, 'get'], _id);\n const htmlDocument = getHTMLDocument(pluginsFolderDocument.html);\n\n documentAttributes = extractAttributes(htmlDocument);\n\n // @ts-ignore\n yield put({\n type: ActionTypes.EDITOR_PLUGINS_SET_ATTRIBUTES,\n payload: { docAttrs: documentAttributes },\n });\n }\n }\n }\n\n yield put({\n type: ActionTypes.EDITOR_GET_DOCUMENT_SUCCESS,\n payload: { document, id },\n });\n\n yield put({\n type: ActionTypes.WORKSPACE_SET_CHILDREN,\n payload: { dataset, id },\n });\n\n yield put({\n type: ActionTypes.WORKSPACE_SET_PARENTS,\n payload: { dataset, id },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.EDITOR_GET_DOCUMENT_FAILURE,\n payload: error,\n });\n }\n}\n\n/**\n * editorPutDocument\n */\nfunction* editorPutDocument({ payload: { document, id } }: PutDocument | any): any {\n const server = yield getContext('DocumentService');\n\n try {\n const { conflicts, history } = yield call([server, 'update'], document);\n // eslint-disable-next-line no-underscore-dangle\n const _rev = history[id];\n\n yield put(conflictSet(ACTION_TYPE.EDITOR, conflicts));\n\n if (conflicts) {\n throw new Error(CONFLICT_ERROR_MESSAGE);\n }\n\n yield put({\n type: ActionTypes.POUCH_DB_SET_ITEM,\n payload: { document: { ...document, _rev }, id },\n });\n\n yield put({\n type: ActionTypes.EDITOR_PUT_DOCUMENT_SUCCESS,\n payload: { document: { ...document, _rev }, id },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.EDITOR_PUT_DOCUMENT_FAILURE,\n });\n }\n}\n\n/**\n * editorCreateDocument\n */\nfunction* editorCreateDocument({ payload: { document } }: any): any {\n try {\n const server = yield getContext('DocumentService');\n\n yield call([server, 'create'], document);\n\n yield put({\n type: ActionTypes.EDITOR_CREATE_DOCUMENT_SUCCESS,\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.EDITOR_CREATE_DOCUMENT_FAILURE,\n });\n }\n}\n\n/**\n * Editor Sagas\n */\n\nexport default function* root() {\n yield all([\n takeLatest(ActionTypes.EDITOR_GET_DOCUMENT_ID, editorGetDocument),\n takeLatest(ActionTypes.EDITOR_PUT_DOCUMENT, editorPutDocument),\n takeLatest(ActionTypes.EDITOR_CREATE_DOCUMENT, editorCreateDocument),\n ]);\n}\n","/**\n * @module Sagas/Organization\n * @desc Organization\n */\n\nimport { all, call, put, takeLatest } from 'redux-saga/effects';\n\nimport { ActionTypes, URL_LIST } from 'core/store/modules/common/literals';\nimport { apiHttpClient as httpClient } from 'core/services';\nimport type { UserMember } from 'core/types';\n\n/**\n * Get Users\n */\nfunction* organizationGetUsers() {\n try {\n // @ts-ignore\n const { data }: UserMember[] | any = yield call(httpClient, {\n method: 'GET',\n url: URL_LIST.users,\n });\n\n yield put({\n type: ActionTypes.ORGANIZATION_GET_USERS_SUCCESS,\n payload: data,\n });\n } catch {\n /* istanbul ignore next */\n yield put({\n type: ActionTypes.ORGANIZATION_GET_USERS_FAILURE,\n });\n }\n}\n\n/**\n * Organization Sagas\n */\nexport default function* root() {\n yield all([takeLatest(ActionTypes.ORGANIZATION_GET_USERS, organizationGetUsers)]);\n}\n","/**\n * @module Sagas/Plugins\n * @desc Editor Plugins\n */\n\nimport { all, put, select, takeLatest } from 'redux-saga/effects';\nimport { ActionTypes } from '../literals';\nimport type { PutDocument } from 'core/types';\nimport { DocumentType } from 'core/types';\nimport { getTopLevelPluginCodes } from 'core/includes/plugins/utils/codes-get';\nimport { isPluginsDocument, isTypePluginRelated } from 'core/includes/plugins/utils/detections';\nimport findPluginsRefDocument from 'core/includes/plugins/utils/find';\nimport { createPluginsTree } from 'core/includes/plugins/utils/create-plugins-tree';\n\nexport function* editorGetDocument({ payload: { document } }: PutDocument) {\n const { _id, root, parent, type } = document;\n let pluginCodes: string[] = [];\n\n if (isPluginsDocument(type)) {\n pluginCodes = getTopLevelPluginCodes();\n\n yield put({\n type: ActionTypes.EDITOR_PLUGINS_SET_CODES,\n payload: {\n pluginCodes\n },\n });\n } else if (!isTypePluginRelated(type as DocumentType) && type !== DocumentType.FOLDER && root !== _id) {\n // @ts-ignore\n const pouchdb = yield select(s => s.pouchdb);\n\n const pluginsRefDocument = findPluginsRefDocument(_id, parent, pouchdb.items)\n\n if (pluginsRefDocument) {\n const tree = createPluginsTree(pluginsRefDocument);\n\n tree.forEach(plugin => {\n if (plugin.type === DocumentType.PLUGIN) {\n pluginCodes.push(plugin.code);\n }\n });\n }\n }\n\n yield put({\n type: ActionTypes.EDITOR_PLUGINS_SET_CODES,\n payload: {\n pluginCodes\n },\n });\n}\n\n /**\n * Plugins Sagas\n */\n\n export default function* root() {\n yield all([\n // @ts-ignore\n takeLatest(ActionTypes.EDITOR_GET_DOCUMENT_SUCCESS, editorGetDocument),\n ]);\n }\n","import { PluginsInstance } from \"core/modules/instances\"\n\nexport function getTopLevelPluginCodes(): string[] {\n const pluginsList = PluginsInstance.getInstance();\n const codes: string[] = [];\n\n for (let p in pluginsList) {\n codes.push(pluginsList[p].code);\n }\n\n return codes\n}\n","import { uuid } from 'short-uuid';\n\nconst getId = (parent: string | undefined, root: string) => (parent ? uuid() : root);\n\nexport default (\n root: string,\n { html, text, type }: any,\n parent: string | undefined = undefined,\n order = 0,\n) => {\n const id = getId(parent, root);\n\n return {\n _id: id,\n html,\n parent,\n root,\n order,\n title: text,\n type,\n };\n};\n","export default (items: any[]) => items.filter(({ isFound }: any) => isFound);\n","import { findDocument } from 'core/includes/html/utils/find-document';\nimport { createHashDataset } from 'core/utils/create-hash-dataset';\n\nconst createDataHash = (dataset: any[], findItems: any[]) => {\n return createHashDataset(dataset, (data: any) => {\n const { _id: id } = data;\n\n const isFound = !!findDocument(findItems, id);\n\n return { ...data, isFound, isExisted: isFound };\n });\n};\n\nconst getParentLine = (hash: any, id: string) => {\n if (!hash[id]) {\n return;\n }\n\n const item = hash[id];\n\n item.isExisted = true;\n\n getParentLine(hash, item.parent);\n};\n\nexport default (dataset: any[], findItems: any[]) => {\n let index = findItems.length;\n const showResult = !!index;\n\n if (!index) {\n return { items: [], count: index, showResult };\n }\n\n if (dataset.length === index) {\n return { items: dataset, count: index, showResult };\n }\n\n const hash = createDataHash(dataset, findItems);\n\n while (index--) {\n const { _id: id } = findItems[index];\n const { parent } = hash[id];\n\n getParentLine(hash, parent);\n }\n\n const items = Object.values(hash).filter(({ isExisted }: any) => isExisted);\n const count = items.length;\n\n return { items, count, showResult: !!count };\n};\n","import { findDocument } from 'core/includes/html/utils/find-document';\n\nexport default (dataset: any[], findItems: any[]) => {\n let index = dataset.length;\n const findItemsCount = findItems.length;\n const showResult = !!findItemsCount;\n\n if (!findItemsCount) {\n return { items: [], count: findItemsCount, showResult };\n }\n\n if (index === findItemsCount) {\n return { items: dataset, count: findItemsCount, showResult };\n }\n\n while (index--) {\n const item = dataset[index];\n const { _id: id } = item;\n\n if (findDocument(findItems, id)) {\n item.isFound = true;\n }\n }\n\n return { items: dataset, count: findItemsCount, showResult };\n};\n","/**\n * @module Sagas/PouchDB\n * @desc PouchDB\n */\n\nimport { conflictSet } from 'core/store/modules/common/actions';\nimport { getPluginsFolderId, isPluginId } from 'core/includes/plugins/utils/detections';\nimport { ACTION_TYPE, ActionTypes, CONFLICT_ERROR_MESSAGE } from 'core/store/modules/common/literals';\nimport formatDocument from 'core/repositories/utils/format-document';\nimport { titleDocument } from 'core/repositories/utils/title-document';\nimport { all, call, getContext, put, select, takeLatest } from 'redux-saga/effects';\nimport type { UUID} from 'short-uuid';\nimport { uuid } from 'short-uuid';\n\nimport { findAssignments } from './utils/find-assignments';\nimport getSearchResult from './utils/get-search-result';\nimport matchedTreeItem from './utils/matched-tree-item';\nimport unmatchedTreeItem from './utils/unmatched-tree-item';\n\n/**\n * pouchDbImport\n */\nfunction* pouchDbImport({ payload: { data } }: any): any {\n const server = yield getContext('DocumentService');\n\n // eslint-disable-next-line no-shadow\n const root: UUID = uuid();\n\n const documents: any[] = [];\n\n const make = (item: any, parent: any = null, order = 0) => {\n // eslint-disable-next-line no-underscore-dangle\n const document = formatDocument(root, item, parent?._id, order);\n\n documents.push(document);\n\n if (Array.isArray(item.children)) {\n item.children.forEach((child: any, index: number) => make(child, document, index));\n }\n\n return item;\n };\n\n make(data);\n\n try {\n yield call([server, 'batch'], documents);\n\n const [{ _id: id }] = documents;\n\n yield put({\n type: ActionTypes.POUCH_DB_IMPORT_SUCCESS,\n payload: { id },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.POUCH_DB_IMPORT_FAILURE,\n });\n }\n}\n\n/**\n * pouchDbRemove\n */\nfunction* pouchDbRemove({ payload: { id } }: any): any {\n const server = yield getContext('DocumentService');\n\n try {\n yield call([server, 'remove'], id);\n\n yield put({\n type: ActionTypes.POUCH_DB_REMOVE_SUCCESS,\n payload: { id },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.POUCH_DB_REMOVE_FAILURE,\n });\n }\n}\n\n/**\n * pouchDbGetWorkspaces\n */\nfunction* pouchDbGetWorkspaces(): any {\n const document = yield getContext('DocumentService');\n\n const items: any = yield call([document, 'getAll']);\n\n try {\n yield put({\n type: ActionTypes.POUCH_DB_GET_WORKSPACES_SUCCESS,\n payload: { items },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.POUCH_DB_GET_WORKSPACES_FAILURE,\n });\n }\n}\n\n/**\n * pouchDbGetList\n */\nfunction* pouchDbGetList({ payload: { id } }: any): any {\n if (!id) {\n yield put({\n type: ActionTypes.POUCH_DB_CREATE_WORKSPACE,\n });\n\n return;\n }\n\n const server = yield getContext('DocumentService');\n\n try {\n if (isPluginId(id)) {\n id = getPluginsFolderId(id);\n }\n\n // @ts-ignore\n const { root: rootId } = yield call([server, 'get'], id);\n\n // @ts-ignore\n const items = yield call([server, 'getAll'], rootId);\n\n yield put({\n type: ActionTypes.POUCH_DB_GET_LIST_SUCCESS,\n payload: { items, root: rootId },\n });\n\n yield put({\n type: ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST,\n payload: { rootId },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.POUCH_DB_GET_LIST_FAILURE,\n });\n }\n}\n\n/**\n * pouchDbAssignmentsGetList\n */\nfunction* pouchDbAssignmentsGetList({ payload: { rootId } }: any): any {\n try {\n const server = yield getContext('AssignmentService');\n\n if (!server) {\n return;\n }\n\n // @ts-ignore\n const items = yield call([server, 'getAll'], rootId);\n\n yield put({\n type: ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST_SUCCESS,\n payload: { items },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST_FAILURE,\n });\n }\n}\n\n/**\n * pouchDbSearch\n */\nfunction* pouchDbSearch(): any {\n try {\n const { root: rootId, search } = yield select(s => s.pouchdb);\n const server = yield getContext('DocumentService');\n\n const { showUnmatched } = search;\n\n // @ts-ignore\n const dataset = yield call([server, 'getAll'], rootId);\n\n // @ts-ignore\n const assignments = yield findAssignments(rootId, search);\n\n // @ts-ignore\n const findItems = yield call([server, 'find'], rootId, search, assignments);\n\n const { items, showResult } = showUnmatched\n ? unmatchedTreeItem(dataset, findItems)\n : matchedTreeItem(dataset, findItems);\n\n // Sets the workspace item[0] if we have empty result\n if (!items.length) {\n items.push(dataset[0]);\n }\n\n yield put({\n type: ActionTypes.POUCH_DB_SEARCH_SUCCESS,\n payload: { items, showResult, count: getSearchResult(items).length },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.POUCH_DB_SEARCH_FAILURE,\n });\n }\n}\n\n/**\n * pouchDbSaveOrder\n */\nfunction* pouchDbSaveOrder({ payload: { order } }: any): any {\n try {\n const server = yield getContext('DocumentService');\n\n const documents = order.reduce(\n // eslint-disable-next-line no-shadow\n (document: any, { _id, _rev, html, parent, root, title, type }: any, order: number) => {\n document.push({\n _id,\n _rev,\n parent,\n html,\n root,\n order,\n title: titleDocument({ title }),\n type,\n });\n\n return document;\n },\n [],\n );\n\n const { conflicts } = yield call([server, 'batch'], documents);\n\n yield put(conflictSet(ACTION_TYPE.TREE, conflicts));\n\n if (conflicts) {\n throw new Error(CONFLICT_ERROR_MESSAGE);\n }\n\n yield put({\n type: ActionTypes.POUCH_DB_SAVE_ORDER_SUCCESS,\n });\n } catch {\n yield put({\n type: ActionTypes.POUCH_DB_SAVE_ORDER_FAILURE,\n });\n }\n}\n\n/**\n * PouchDB Sagas\n */\nexport default function* root() {\n yield all([\n takeLatest(ActionTypes.POUCH_DB_IMPORT, pouchDbImport),\n takeLatest(ActionTypes.POUCH_DB_REMOVE, pouchDbRemove),\n takeLatest(ActionTypes.POUCH_DB_GET_WORKSPACES, pouchDbGetWorkspaces),\n takeLatest(ActionTypes.POUCH_DB_GET_LIST, pouchDbGetList),\n takeLatest(ActionTypes.POUCH_DB_ASSIGNMENT_GET_LIST, pouchDbAssignmentsGetList),\n takeLatest(ActionTypes.POUCH_DB_SEARCH, pouchDbSearch),\n takeLatest(ActionTypes.POUCH_DB_SAVE_ORDER, pouchDbSaveOrder),\n ]);\n}\n","import { call, getContext } from 'redux-saga/effects';\n\nimport { RESOLVING_STATUS_ANY } from 'core/store/modules/common/literals';\nimport type { SearchState } from 'core/types';\n\nexport function* findAssignments(rootId: string, search: SearchState): any {\n const { responsible, responsibleStatus } = search;\n\n if (responsibleStatus === RESOLVING_STATUS_ANY.ANY && !responsible) {\n return [];\n }\n\n const server = yield getContext('AssignmentService');\n\n // @ts-ignore\n return yield call([server, 'find'], rootId, search);\n}\n","/**\n * @module Sagas/User\n * @desc User\n */\n\nimport { all, call, getContext, put, takeLatest } from 'typed-redux-saga';\n\nimport { ActionTypes } from 'core/store/modules/common/literals';\nimport type { LoggerService, UsersService } from 'core/services';\n\n/**\n * Logout\n */\nfunction* logout() {\n try {\n yield put({\n type: ActionTypes.USER_LOGOUT_SUCCESS,\n });\n\n const userService = yield* getContext('UsersService');\n\n yield* call([userService, 'logout']);\n } catch (error) {\n yield* put({\n type: ActionTypes.USER_LOGOUT_FAILURE,\n payload: error,\n });\n }\n}\n\n/**\n * Get user info.\n */\nfunction* userInfo() {\n try {\n const userService = yield* getContext('UsersService');\n const loggerService = yield* getContext('LoggerService');\n\n const user = yield* call([userService, 'getUserInfo']);\n\n loggerService.setUser(user);\n\n yield* put({\n type: ActionTypes.USER_INFO_SUCCESS,\n payload: {\n id: user.id,\n user,\n time: Date.now(),\n },\n });\n } catch (error) {\n yield* put({\n type: ActionTypes.USER_INFO_FAILURE,\n payload: error,\n });\n }\n}\n\n/**\n * User Sagas\n */\nexport default function* root() {\n yield* all([\n takeLatest(ActionTypes.USER_LOGOUT_REQUEST, logout),\n takeLatest(ActionTypes.USER_INFO_REQUEST, userInfo),\n ]);\n}\n","/**\n * @module Sagas/Workspace\n * @desc Workspace\n */\n\nimport { all, call, getContext, put, takeLatest } from 'redux-saga/effects';\nimport { uuid } from 'short-uuid';\n\nimport { ActionTypes } from 'core/store/modules/common/literals';\nimport formatDocument from 'core/repositories/utils/format-document';\nimport { DocumentType } from 'core/types/document';\n\n/**\n * workspaceInit\n */\nexport function* workspaceInit(): any {\n try {\n const server = yield getContext('DocumentService');\n\n const createItem = { type: DocumentType.FOLDER, text: 'Untitled workspace' };\n const document = formatDocument(uuid(), createItem);\n // @ts-ignore\n const { documents } = yield call([server, 'create'], document);\n const [item] = documents;\n\n yield put({\n type: ActionTypes.WORKSPACE_INIT_SUCCESS,\n // eslint-disable-next-line no-underscore-dangle\n payload: { item, id: item._id },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.WORKSPACE_INIT_FAILURE,\n });\n }\n}\n\n/**\n * workspaceLoadByItemId\n */\nexport function* workspaceLoadByItemId({ payload }: any): any {\n const { id } = payload;\n\n try {\n const server = yield getContext('DocumentService');\n\n // @ts-ignore\n const item = yield call([server, 'get'], id);\n\n yield put({\n type: ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID_SUCCESS,\n payload: { item, id },\n });\n } catch (error) {\n console.error(error);\n yield put({\n type: ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID_FAILURE,\n });\n }\n}\n\n/**\n * Workspace Sagas\n */\nexport default function* root() {\n yield all([\n takeLatest(ActionTypes.WORKSPACE_INIT, workspaceInit),\n takeLatest(ActionTypes.WORKSPACE_LOAD_BY_ITEM_ID, workspaceLoadByItemId),\n ]);\n}\n","import { all, fork } from 'redux-saga/effects';\n\nimport assignments from './assignments';\nimport editor from './editor';\nimport organization from './organization';\nimport plugins from './plugins';\nimport pouchdb from './pouchdb';\nimport user from './user';\nimport workspace from './workspace';\n\n/**\n * rootSaga\n */\nexport function* root() {\n yield all([\n fork(user),\n fork(pouchdb),\n fork(workspace),\n fork(editor),\n fork(organization),\n fork(assignments),\n fork(plugins),\n ]);\n}\n","export enum ActionTypes {\n CREATE_PROJECT = 'CREATE_PROJECT',\n CREATE_PROJECT_SUCCESS = 'CREATE_PROJECT_SUCCESS',\n CREATE_PROJECT_FAILURE = 'CREATE_PROJECT_FAILURE',\n\n DUPLICATE_PROJECT = 'DUPLICATE_PROJECT',\n DUPLICATE_PROJECT_SUCCESS = 'DUPLICATE_PROJECT_SUCCESS',\n DUPLICATE_PROJECT_FAILURE = 'DUPLICATE_PROJECT_FAILURE',\n\n GET_PROJECT = 'GET_PROJECT',\n GET_PROJECT_SUCCESS = 'GET_PROJECT_SUCCESS',\n GET_PROJECT_FAILURE = 'GET_PROJECT_FAILURE',\n\n CREATE_CHILDREN = 'CREATE_CHILDREN',\n CREATE_CHILDREN_SUCCESS = 'CREATE_CHILDREN_SUCCESS',\n CREATE_CHILDREN_FAILURE = 'CREATE_CHILDREN_FAILURE',\n\n UPDATE_DOCUMENT = 'UPDATE_DOCUMENT',\n UPDATE_DOCUMENT_IN_PROGRESS = 'UPDATE_DOCUMENT_IN_PROGRESS',\n UPDATE_DOCUMENT_OPTIMISTIC = 'UPDATE_DOCUMENT_OPTIMISTIC',\n UPDATE_DOCUMENT_ROLLBACK = 'UPDATE_DOCUMENT_ROLLBACK',\n UPDATE_DOCUMENT_SUCCESS = 'UPDATE_DOCUMENT_SUCCESS',\n UPDATE_DOCUMENT_FAILURE = 'UPDATE_DOCUMENT_FAILURE',\n\n UPDATE_DOCUMENT_REVISION = 'UPDATE_DOCUMENT_REVISION',\n\n UPDATE_DOCUMENTS = 'UPDATE_DOCUMENTS',\n UPDATE_DOCUMENTS_IN_PROGRESS = 'UPDATE_DOCUMENTS_IN_PROGRESS',\n UPDATE_DOCUMENTS_OPTIMISTIC = 'UPDATE_DOCUMENTS_OPTIMISTIC',\n UPDATE_DOCUMENTS_ROLLBACK = 'UPDATE_DOCUMENTS_ROLLBACK',\n UPDATE_DOCUMENTS_SUCCESS = 'UPDATE_DOCUMENTS_SUCCESS',\n UPDATE_DOCUMENTS_FAILURE = 'UPDATE_DOCUMENTS_FAILURE',\n\n EXPORT_DOCUMENTS = 'EXPORT_DOCUMENTS',\n EXPORT_DOCUMENTS_SUCCESS = 'EXPORT_DOCUMENTS_SUCCESS',\n EXPORT_DOCUMENTS_FAILURE = 'EXPORT_DOCUMENTS_FAILURE',\n\n DELETE_CHILDREN = 'DELETE_CHILDREN',\n DELETE_CHILDREN_SUCCESS = 'DELETE_CHILDREN_SUCCESS',\n DELETE_CHILDREN_FAILURE = 'DELETE_CHILDREN_FAILURE',\n\n GET_DOCUMENT = 'GET_DOCUMENT',\n GET_DOCUMENT_SUCCESS = 'GET_DOCUMENT_SUCCESS',\n GET_DOCUMENT_FAILURE = 'GET_DOCUMENT_FAILURE',\n\n GET_CHILDREN = 'GET_CHILDREN',\n GET_CHILDREN_SUCCESS = 'GET_CHILDREN_SUCCESS',\n GET_CHILDREN_FAILURE = 'GET_CHILDREN_FAILURE',\n\n COPY_DOCUMENTS = 'COPY_DOCUMENTS',\n COPY_DOCUMENTS_SUCCESS = 'COPY_DOCUMENTS_SUCCESS',\n COPY_DOCUMENTS_FAILURE = 'COPY_DOCUMENTS_FAILURE',\n\n MOVE_DOCUMENTS = 'MOVE_DOCUMENTS',\n MOVE_DOCUMENTS_SUCCESS = 'MOVE_DOCUMENTS_SUCCESS',\n MOVE_DOCUMENTS_FAILURE = 'MOVE_DOCUMENTS_FAILURE',\n\n HANDLE_DOCUMENT_ERROR = 'HANDLE_DOCUMENT_ERROR',\n\n WATCH_PROJECT_CHANGES = 'WATCH_PROJECT_CHANGES',\n WATCH_UPDATE_DOCUMENTS = 'WATCH_UPDATE_DOCUMENTS',\n WATCH_CREATE_DOCUMENTS = 'WATCH_CREATE_DOCUMENTS',\n WATCH_DELETE_DOCUMENTS = 'WATCH_DELETE_DOCUMENTS',\n\n IMPORT_DOCUMENTS = 'IMPORT_DOCUMENTS',\n IMPORT_DOCUMENTS_SUCCESS = 'IMPORT_DOCUMENTS_SUCCESS',\n IMPORT_DOCUMENTS_FAILURE = 'IMPORT_DOCUMENTS_FAILURE',\n\n SET_EXPANDED_IDS = 'SET_EXPANDED_IDS',\n ADD_EXPANDED_IDS = 'ADD_EXPANDED_IDS',\n EXPAND_DOCUMENT_PARENTS = 'EXPAND_DOCUMENT_PARENTS',\n\n EXPAND_DOCUMENT_CHILDREN = 'EXPAND_DOCUMENT_CHILDREN',\n EXPAND_DOCUMENT_CHILDREN_SUCCESS = 'EXPAND_DOCUMENT_CHILDREN_SUCCESS',\n\n EXPAND_DOCUMENT = 'EXPAND_DOCUMENT',\n COLLAPSE_DOCUMENT = 'COLLAPSE_DOCUMENT',\n\n UPDATE_DOCUMENT_ACCESS = 'UPDATE_DOCUMENT_ACCESS',\n UPDATE_DOCUMENT_ACCESS_SUCCESS = 'UPDATE_DOCUMENT_ACCESS_SUCCESS',\n UPDATE_DOCUMENT_ACCESS_FAILURE = 'UPDATE_DOCUMENT_ACCESS_FAILURE',\n}\n","import { createAction } from '@reduxjs/toolkit';\nimport type {\n CopyRequestArg,\n MoveRequestArg,\n DocumentAccess,\n CustomError,\n BaseDocumentVM,\n} from 'core/base';\nimport type { DocumentId, DocumentRevision, DocumentWithChildren } from 'core/types';\nimport type { NavigateFunction } from 'react-router';\nimport type { FormError } from '../../../components';\nimport { ActionTypes } from './action-types';\nimport type { IdentifiedActionPayload } from './types';\n\nexport const createDocumentsActions = () => {\n return {\n createProject: createAction>(ActionTypes.CREATE_PROJECT),\n createProjectSuccess: createAction<{ documents: TModel[]; rootId: DocumentId }>(\n ActionTypes.CREATE_PROJECT_SUCCESS,\n ),\n createProjectFailure: createAction(ActionTypes.CREATE_PROJECT_FAILURE),\n\n duplicateProject: createAction<{\n id: DocumentId;\n navigate?: NavigateFunction;\n }>(ActionTypes.DUPLICATE_PROJECT),\n duplicateProjectSuccess: createAction<{\n document: TModel;\n rootId: DocumentId;\n }>(ActionTypes.DUPLICATE_PROJECT_SUCCESS),\n duplicateProjectFailure: createAction(ActionTypes.DUPLICATE_PROJECT_FAILURE),\n\n getProject: createAction<{ id: DocumentId; settingsContentId?: DocumentId }>(\n ActionTypes.GET_PROJECT,\n ),\n getProjectSuccess: createAction<{ documents: TModel[]; rootId: DocumentId }>(\n ActionTypes.GET_PROJECT_SUCCESS,\n ),\n getProjectFailure: createAction(ActionTypes.GET_PROJECT_FAILURE),\n\n getChildren: createAction(ActionTypes.GET_CHILDREN),\n getChildrenSuccess: createAction<{\n parentId: DocumentId;\n documents: TModel[];\n }>(ActionTypes.GET_CHILDREN_SUCCESS),\n\n getDocument: createAction(ActionTypes.GET_DOCUMENT),\n getDocumentSuccess: createAction(ActionTypes.GET_DOCUMENT_SUCCESS),\n getDocumentFailure: createAction(ActionTypes.GET_DOCUMENT_FAILURE),\n\n createChildren: createAction<{\n parentId: DocumentId;\n documents: DocumentWithChildren[];\n insertAt?: number;\n navigate?: NavigateFunction;\n }>(ActionTypes.CREATE_CHILDREN),\n\n createChildrenSuccess: createAction(ActionTypes.CREATE_CHILDREN_SUCCESS),\n createChildrenFailure: createAction<{ id: DocumentId; error: unknown }>(\n ActionTypes.CREATE_CHILDREN_FAILURE,\n ),\n\n copyDocuments: createAction(ActionTypes.COPY_DOCUMENTS),\n copyDocumentsSuccess: createAction(ActionTypes.COPY_DOCUMENTS_SUCCESS),\n copyDocumentsFailure: createAction<{ id: DocumentId; error: unknown }>(\n ActionTypes.COPY_DOCUMENTS_FAILURE,\n ),\n\n moveDocuments: createAction(ActionTypes.MOVE_DOCUMENTS),\n moveDocumentsSuccess: createAction(ActionTypes.MOVE_DOCUMENTS_SUCCESS),\n moveDocumentsFailure: createAction<{ id: DocumentId; error: unknown }>(\n ActionTypes.MOVE_DOCUMENTS_FAILURE,\n ),\n\n deleteChildren: createAction<{\n parentId: DocumentId;\n ids: DocumentId[];\n onSuccess?: (parentId: DocumentId) => void;\n }>(ActionTypes.DELETE_CHILDREN),\n deleteChildrenSuccess: createAction<{ document: TModel; ids: DocumentId[] }>(\n ActionTypes.DELETE_CHILDREN_SUCCESS,\n ),\n deleteChildrenFailure: createAction<{ id: DocumentId; error: unknown }>(\n ActionTypes.DELETE_CHILDREN_FAILURE,\n ),\n\n updateDocument: createAction(ActionTypes.UPDATE_DOCUMENT),\n updateDocumentInProgress: createAction(\n ActionTypes.UPDATE_DOCUMENT_IN_PROGRESS,\n ),\n updateDocumentOptimistic: createAction(\n ActionTypes.UPDATE_DOCUMENT_OPTIMISTIC,\n ),\n updateDocumentRollback: createAction(ActionTypes.UPDATE_DOCUMENT_ROLLBACK),\n updateDocumentSuccess: createAction(\n ActionTypes.UPDATE_DOCUMENT_SUCCESS,\n ),\n updateDocumentFailure: createAction<{ id: DocumentId; errors: FormError[] }>(\n ActionTypes.UPDATE_DOCUMENT_FAILURE,\n ),\n\n updateDocuments: createAction(ActionTypes.UPDATE_DOCUMENTS),\n updateDocumentsInProgress: createAction(ActionTypes.UPDATE_DOCUMENTS_IN_PROGRESS),\n updateDocumentsOptimistic: createAction(ActionTypes.UPDATE_DOCUMENTS_OPTIMISTIC),\n updateDocumentsRollback: createAction(ActionTypes.UPDATE_DOCUMENTS_ROLLBACK),\n updateDocumentsSuccess: createAction(ActionTypes.UPDATE_DOCUMENTS_SUCCESS),\n updateDocumentsFailure: createAction<{ id: DocumentId; error: CustomError | unknown }[]>(\n ActionTypes.UPDATE_DOCUMENTS_FAILURE,\n ),\n\n updateRevision: createAction<{\n id: DocumentId;\n revisionId: DocumentRevision;\n }>(ActionTypes.UPDATE_DOCUMENT_REVISION),\n\n handleDocumentError: createAction<{\n error: unknown;\n id?: DocumentId;\n }>(ActionTypes.HANDLE_DOCUMENT_ERROR),\n\n handleDocumentConflict: createAction(ActionTypes.HANDLE_DOCUMENT_ERROR),\n\n watchProjectChanges: createAction(ActionTypes.WATCH_PROJECT_CHANGES),\n watchDeleteDocuments: createAction(ActionTypes.WATCH_DELETE_DOCUMENTS),\n watchUpdateDocuments: createAction(ActionTypes.WATCH_UPDATE_DOCUMENTS),\n watchCreateDocuments: createAction(ActionTypes.WATCH_CREATE_DOCUMENTS),\n\n importDocuments: createAction<{\n parentId: DocumentId;\n area: DocumentId;\n documents: DocumentWithChildren[];\n insertAt?: number;\n }>(ActionTypes.IMPORT_DOCUMENTS),\n\n importDocumentsSuccess: createAction(ActionTypes.IMPORT_DOCUMENTS_SUCCESS),\n\n collapse: createAction<{ documentId: DocumentId }>(ActionTypes.COLLAPSE_DOCUMENT),\n collapseAll: createAction<{ documentId: DocumentId }>(ActionTypes.COLLAPSE_DOCUMENT),\n expand: createAction<{ documentId: DocumentId }>(ActionTypes.EXPAND_DOCUMENT),\n expandAll: createAction<{ documentId: DocumentId }>(ActionTypes.EXPAND_DOCUMENT_CHILDREN),\n expandAllSuccess: createAction<{ documents: TModel[]; expanded: DocumentId[] }>(\n ActionTypes.EXPAND_DOCUMENT_CHILDREN_SUCCESS,\n ),\n expandParents: createAction<{ documentId: DocumentId; onSuccess?: () => void }>(\n ActionTypes.EXPAND_DOCUMENT_PARENTS,\n ),\n setExpandedIds: createAction(ActionTypes.SET_EXPANDED_IDS),\n addExpandedIds: createAction(ActionTypes.ADD_EXPANDED_IDS),\n\n updateDocumentAccess: createAction<{\n id: DocumentId;\n request: DocumentAccess[];\n }>(ActionTypes.UPDATE_DOCUMENT_ACCESS),\n updateDocumentAccessSuccess: createAction(ActionTypes.UPDATE_DOCUMENT_ACCESS_SUCCESS),\n updateDocumentAccessFailure: createAction(ActionTypes.UPDATE_DOCUMENT_ACCESS_FAILURE),\n\n exportDocuments: createAction(ActionTypes.EXPORT_DOCUMENTS),\n exportDocumentsSuccess: createAction(ActionTypes.EXPORT_DOCUMENTS_SUCCESS),\n exportDocumentsFailure: createAction<{ error: CustomError }>(\n ActionTypes.EXPORT_DOCUMENTS_FAILURE,\n ),\n };\n};\n\nexport const {\n createProject,\n createProjectSuccess,\n createProjectFailure,\n duplicateProject,\n duplicateProjectSuccess,\n duplicateProjectFailure,\n getProject,\n getProjectSuccess,\n getProjectFailure,\n getChildren,\n getChildrenSuccess,\n getDocument,\n getDocumentSuccess,\n getDocumentFailure,\n createChildren,\n createChildrenSuccess,\n createChildrenFailure,\n copyDocuments,\n copyDocumentsSuccess,\n copyDocumentsFailure,\n moveDocuments,\n moveDocumentsSuccess,\n moveDocumentsFailure,\n deleteChildren,\n deleteChildrenSuccess,\n deleteChildrenFailure,\n updateDocument,\n updateDocumentInProgress,\n updateDocumentOptimistic,\n updateDocumentRollback,\n updateDocumentSuccess,\n updateDocumentFailure,\n updateDocuments,\n updateDocumentsInProgress,\n updateDocumentsOptimistic,\n updateDocumentsRollback,\n updateDocumentsSuccess,\n updateDocumentsFailure,\n updateRevision,\n handleDocumentError,\n handleDocumentConflict,\n watchProjectChanges,\n watchDeleteDocuments,\n watchUpdateDocuments,\n watchCreateDocuments,\n importDocuments,\n importDocumentsSuccess,\n collapse,\n collapseAll,\n expand,\n expandAll,\n expandAllSuccess,\n expandParents,\n setExpandedIds,\n addExpandedIds,\n updateDocumentAccess,\n updateDocumentAccessSuccess,\n updateDocumentAccessFailure,\n exportDocuments,\n exportDocumentsSuccess,\n exportDocumentsFailure,\n} = createDocumentsActions();\n\nexport type Actions = ReturnType;\n","import type { ActionCreatorWithPayload } from '@reduxjs/toolkit';\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype ActionCreators = { [key: string]: ActionCreatorWithPayload };\n\nexport type GetActionsTypes = {\n [key in keyof T]: ReturnType;\n};\n\nexport type GetPayloadsTypes = {\n [key in keyof T]: ReturnType['payload'];\n};\n\nexport enum STATUS {\n ERROR = 'error',\n CONFLICT = 'conflict',\n IDLE = 'idle',\n /**\n * @deprecated use loading instead\n */\n RUNNING = 'running',\n SUCCESS = 'success',\n CREATE = 'create',\n READY = 'ready',\n IMPORTED = 'imported',\n DELETED = 'deleted',\n LOADING = 'loading',\n}\n","export enum IssueStatusType {\n CREATED = 'created',\n RESOLVED = 'resolved',\n CLOSED = 'closed',\n}\n"],"names":["getHTMLDocument","html","DOMParser","parseFromString","findDocument","items","id","find","_id","tree","buildTreeItem","plugin","parent","isPluginsRoot","docAttrs","PLUGINS_PATH","code","load","childrenPlugins","childPlugin","push","pluginToDocument","type","DocumentType","PLUGINS_FOLDER","PLUGIN","order","createPluginsTree","document","pluginsMeta","length","forEach","pluginMeta","name","getPluginByName","isTypePluginRelated","includes","isPluginsDocument","PLUGINS","getPluginsFolderId","path","split","isPluginId","extractPluginCode","ids","extractAttributes","htmlDoc","dict","Object","fromEntries","Array","from","querySelectorAll","map","row","children","textContent","innerHTML","plugins","getElementsByTagName","metaPlugins","attributes","undefined","params","findChildPluginsDocument","list","item","findSiblingPluginsDocument","findParentSiblingPluginsDocument","parentItemId","findPluginsRefDocument","pluginsList","PluginsInstance","getInstance","p","loadedPlugins","lp","lpChild","getPluginByCode","props","_rev","title","setTitleHtml","root","now","Math","floor","Date","createAction","payloadCreator","TypeError","args","payload","hasValidCache","lastUpdated","max","navigator","onLine","setInstance","instance","this","middleware","env","NODE_ENV","createLogger","invariant","collapsed","createAdapter","createEntityAdapter","selectId","entity","updateDocumentStatus","status","isChildrenLoaded","isSuccess","STATUS","SUCCESS","isLoading","RUNNING","isError","ERROR","isConflict","CONFLICT","toDocumentState","errors","adapter","initialState","getInitialState","rootId","IDLE","expanded","startLoading","draft","loadingFailed","addExpandedIds","state","Set","reducer","createReducer","ActionTypes","CREATE_PROJECT","CREATE_PROJECT_SUCCESS","documents","setAll","CREATE_PROJECT_FAILURE","DUPLICATE_PROJECT","DUPLICATE_PROJECT_SUCCESS","DUPLICATE_PROJECT_FAILURE","GET_PROJECT","GET_PROJECT_SUCCESS","GET_PROJECT_FAILURE","GET_DOCUMENT_SUCCESS","setOne","GET_CHILDREN","updateOne","changes","GET_CHILDREN_SUCCESS","parentId","setMany","COPY_DOCUMENTS_SUCCESS","MOVE_DOCUMENTS_SUCCESS","CREATE_CHILDREN_SUCCESS","UPDATE_DOCUMENT_OPTIMISTIC","e","UPDATE_DOCUMENT_ROLLBACK","UPDATE_DOCUMENT_SUCCESS","docState","entities","UPDATE_DOCUMENT_FAILURE","UPDATE_DOCUMENT_REVISION","revisionId","DELETE_CHILDREN_SUCCESS","removeMany","UPDATE_DOCUMENTS_SUCCESS","UPDATE_DOCUMENTS_OPTIMISTIC","updateMany","UPDATE_DOCUMENTS_ROLLBACK","UPDATE_DOCUMENTS_FAILURE","error","isValidationError","data","isConflictError","WATCH_CREATE_DOCUMENTS","WATCH_DELETE_DOCUMENTS","WATCH_UPDATE_DOCUMENTS","HANDLE_DOCUMENT_ERROR","IMPORT_DOCUMENTS_SUCCESS","EXPAND_DOCUMENT_CHILDREN_SUCCESS","SET_EXPANDED_IDS","ADD_EXPANDED_IDS","UPDATE_DOCUMENT_ACCESS_SUCCESS","EXPORT_DOCUMENTS_SUCCESS","copyDocuments","documentService","getContext","call","put","actions","copyDocumentsSuccess","copyDocumentsFailure","target","handleDocumentError","createDocumentsSelectors","selectors","getSelectors","s","selectRootId","selectRootDocument","createDraftSafeSelector","selectEntities","selectDocumentById","selectById","selectProject","selectExpanded","selectAllDocuments","selectAll","selectDocumentsList","selectDocumentsCount","selectTotal","selectDocumentIds","selectIds","documentsSelectors","tryToCreateChildren","attempt","insertAt","select","index","headers","changesService","freshDocument","updateDocumentSuccess","createChildren","navigate","freshChildren","createChildrenSuccess","delay","createChildrenFailure","createProject","rootView","createProjectSuccess","showAlertSuccess","watchProjectChanges","createProjectFailure","showAlertError","tryToDeleteChildren","ok","deleteChildren","onSuccess","deleteChildrenSuccess","t","count","deleteChildrenFailure","getChildren","getChildrenSuccess","getDocument","documentState","getDocumentSuccess","getProject","idsPath","rootDoc","settingsContentId","all","getProjectSuccess","flat","slice","getProjectFailure","loggerService","isCustomError","ErrorCodes","notModified","validation","updateDocumentFailure","forbidden","description","notFound","conflict","importDocuments","area","importDocumentsSuccess","moveDocuments","moveDocumentsSuccess","moveDocumentsFailure","createRollbackList","Map","save","has","set","restore","get","filter","n","clear","delete","MAX_RETRY_ATTEMPTS","tryToUpdate","updateDocumentWorker","channel","revs","rollbackList","take","updateDocumentOptimistic","refreshRevision","updateDocumentInProgress","actionId","prevDocument","updateDocumentRollback","watchUpdateDocument","buffer","keys","next","value","message","isEmpty","size","flush","createListBuffer","actionChannel","updateDocument","fork","terminateAPP","close","tryToUpdateAccess","request","updateDocumentAccess","updatedDocument","updateDocumentAccessSuccess","updateDocumentAccessFailure","groupDocuments","result","reduce","acc","succeedUpdated","conflictUpdated","failedUpdated","response","updatedDocuments","freshDocuments","resolved","bulkUpdateDocumentsWorker","updateDocumentsOptimistic","updateDocumentsInProgress","res","updateDocumentsSuccess","updateDocumentsFailure","updateDocumentsRollback","r","watchBulkUpdateDocuments","updateDocuments","buffers","sliding","createChannel","sse","eventChannel","emit","on","END","destroy","accumulateChanges","init","DocumentOperations","create","update","add","change","operation","docId","revision","currentRev","patchRev","hasToIgnore","doc","_model","_patch","isArray","getAll","getIds","getDocs","values","hasAny","objectValues","some","o","reset","applyChanges","watchDeleteDocuments","patches","docs","watchCreateDocuments","views","watchUpdateDocuments","addChange","newChange","watchDocumentUpdating","requests","success","failure","race","watchChildrenCreation","watchChildrenDeletion","watchDocumentsUpdating","watchDocumentsCoping","watchDocumentsMoving","watchRequests","documentsInProgress","createChildrenChannel","deleteChildrenChannel","updateDocumentChannel","updateDocumentsChannel","copyDocumentsChannel","moveDocumentsChannel","ch","listenChanges","bufferChanges","timeout","hasRequestsInProgress","initWatchChanges","watchChanges","takeEvery","expandAll","documentId","expandAllSuccess","expandParents","_ids","expand","collapse","traverse","documentList","documentsState","childrenIds","meta","i","expandedKeys","setExpandedIds","duplicateProject","newProject","duplicateProjectSuccess","duplicateProjectFailure","exportDocuments","exportDocumentsSuccess","revisions","Number","isFinite","topRev","apply","createRevisionList","spawn","createDocumentsHooks","emptyState","useRootDocument","useSelector","useRootId","useDocumentIds","useDocument","useDocuments","useDocumentsList","useProject","useExpanded","useDocumentsCount","documentsHooks","documentsActions","createDocumentsActions","selectUser","user","LoggerService","configStore","additionalMiddleware","additionalReducers","sagaMiddleware","onError","rootReducer","persistCombineReducers","key","stateReconciler","autoMergeLevel2","storage","whitelist","reducers","store","configureStore","run","persistor","persistStore","saga","conflictSet","CONFLICT_SET","makePayload","hideAlert","HIDE_ALERT","appNameSet","APP_NAME_SET","getAlertConfig","options","uuid","icon","position","variant","showAlert","SHOW_ALERT","assignmentWindowShow","ASSIGNMENT_WINDOW_SHOW","assignmentWindowHide","ASSIGNMENT_WINDOW_HIDE","loadingShow","LOADING_SHOW","loadingSetMessage","LOADING_SET_MESSAGE","loadingHide","LOADING_HIDE","searchPanelShow","SEARCH_PANEL_SHOW","searchPanelHide","SEARCH_PANEL_HIDE","searchPanelShowResults","SEARCH_PANEL_SHOW_RESULTS","TERMINATE_APP","logOut","USER_LOGOUT_REQUEST","userInfo","USER_INFO_REQUEST","userAlertWelcome","USER_SHOW_ALERT_WELCOME","pouchDbImport","POUCH_DB_IMPORT","pouchDbRemove","POUCH_DB_REMOVE","pouchDbGetWorkspaces","POUCH_DB_GET_WORKSPACES","pouchDbGetList","POUCH_DB_GET_LIST","pouchDbSearch","POUCH_DB_SEARCH","search","pouchDbSearchEnabled","POUCH_DB_SEARCH_ENABLED","enabled","pouchDbSaveOrder","POUCH_DB_SAVE_ORDER","dragItem","editorGetById","EDITOR_GET_DOCUMENT_ID","editorPut","EDITOR_PUT_DOCUMENT","editorCreate","EDITOR_CREATE_DOCUMENT","editorUpdating","EDITOR_UPDATING_DOCUMENT","editorPutRev","EDITOR_PUT_DOCUMENT_REV","rev","workspaceInit","WORKSPACE_INIT","workspaceSetId","WORKSPACE_SET_ID","workspaceLoadByItemId","WORKSPACE_LOAD_BY_ITEM_ID","organizationGetUsers","ORGANIZATION_GET_USERS","assignmentsSet","ASSIGNMENT_SET","assignmentsGet","ASSIGNMENT_GET","assignmentsResetStatus","ASSIGNMENT_SET_RESET_STATUS","appState","alerts","assignmentWindow","loading","searchPanelStatus","app","REHYDRATE","d","assignmentsState","statusSet","statusGet","statusList","assignment","ASSIGNMENT_SET_SUCCESS","ASSIGNMENT_SET_FAILURE","ASSIGNMENT_GET_SUCCESS","ASSIGNMENT_GET_FAILURE","conflictState","ACTION_TYPE","NONE","editorState","pluginCodes","pluginsDocAttrs","updated","updating","created","editor","EDITOR_GET_DOCUMENT_SUCCESS","EDITOR_GET_DOCUMENT_FAILURE","EDITOR_PUT_DOCUMENT_SUCCESS","EDITOR_PUT_DOCUMENT_FAILURE","EDITOR_PLUGINS_SET_CODES","EDITOR_PLUGINS_SET_ATTRIBUTES","organizationState","users","organization","ORGANIZATION_GET_USERS_SUCCESS","ORGANIZATION_GET_USERS_FAILURE","pouchDbState","assignments","assignmentsStatus","inHtml","inTitle","responsible","responsibleStatus","RESOLVING_STATUS_ANY","ANY","showUnmatched","text","showResult","pouchdb","POUCH_DB_REMOVE_SUCCESS","DELETED","POUCH_DB_REMOVE_FAILURE","POUCH_DB_IMPORT_SUCCESS","IMPORTED","POUCH_DB_IMPORT_FAILURE","POUCH_DB_SET_ITEM","findIndex","splice","POUCH_DB_GET_WORKSPACES_SUCCESS","POUCH_DB_GET_WORKSPACES_FAILURE","POUCH_DB_GET_LIST_SUCCESS","POUCH_DB_GET_LIST_FAILURE","POUCH_DB_CREATE_WORKSPACE","CREATE","POUCH_DB_ASSIGNMENT_GET_LIST","POUCH_DB_ASSIGNMENT_GET_LIST_SUCCESS","POUCH_DB_ASSIGNMENT_GET_LIST_FAILURE","POUCH_DB_SEARCH_SUCCESS","POUCH_DB_SEARCH_FAILURE","POUCH_DB_SAVE_ORDER_SUCCESS","POUCH_DB_SAVE_ORDER_FAILURE","userState","isAuthenticated","USER_LOGOUT_SUCCESS","token","time","USER_LOGOUT_FAILURE","USER_INFO_SUCCESS","READY","shownAlertWelcome","findPath","currentId","hash","workspaceState","parents","workspace","WORKSPACE_INIT_SUCCESS","WORKSPACE_INIT_FAILURE","WORKSPACE_LOAD_BY_ITEM_ID_SUCCESS","WORKSPACE_LOAD_BY_ITEM_ID_FAILURE","WORKSPACE_SET_CHILDREN","dataset","current","createHashDataset","datasetHash","WORKSPACE_SET_PARENTS","commonInitialState","server","console","takeLatest","editorGetDocument","documentAttributes","pluginsFolderId","pluginsFolderDocument","htmlDocument","pluginCode","isRootDocument","isFolderDocument","pluginsRefDocument","editorPutDocument","conflicts","history","EDITOR","Error","CONFLICT_ERROR_MESSAGE","editorCreateDocument","EDITOR_CREATE_DOCUMENT_SUCCESS","EDITOR_CREATE_DOCUMENT_FAILURE","method","url","URL_LIST","codes","getTopLevelPluginCodes","FOLDER","getId","isFound","getParentLine","isExisted","findItems","createDataHash","findItemsCount","make","child","pouchDbAssignmentsGetList","findAssignments","titleDocument","TREE","logout","userService","setUser","USER_INFO_FAILURE","createItem","GET_DOCUMENT","getDocumentFailure","GET_DOCUMENT_FAILURE","CREATE_CHILDREN","CREATE_CHILDREN_FAILURE","COPY_DOCUMENTS","COPY_DOCUMENTS_FAILURE","MOVE_DOCUMENTS","MOVE_DOCUMENTS_FAILURE","DELETE_CHILDREN","DELETE_CHILDREN_FAILURE","UPDATE_DOCUMENT","UPDATE_DOCUMENT_IN_PROGRESS","UPDATE_DOCUMENTS","UPDATE_DOCUMENTS_IN_PROGRESS","updateRevision","handleDocumentConflict","WATCH_PROJECT_CHANGES","IMPORT_DOCUMENTS","COLLAPSE_DOCUMENT","collapseAll","EXPAND_DOCUMENT","EXPAND_DOCUMENT_CHILDREN","EXPAND_DOCUMENT_PARENTS","UPDATE_DOCUMENT_ACCESS","UPDATE_DOCUMENT_ACCESS_FAILURE","EXPORT_DOCUMENTS","exportDocumentsFailure","EXPORT_DOCUMENTS_FAILURE","IssueStatusType"],"sourceRoot":""}