300 lines
11 KiB
JavaScript
300 lines
11 KiB
JavaScript
/**
|
|
* @file index.js
|
|
* @description Central barrel exporting all domain, configuration, and list
|
|
* automats, along with their action creators and reactive selectors.
|
|
*/
|
|
|
|
export * from './deliveryEditorAutomat';
|
|
export * from './manifestDraftAutomat';
|
|
|
|
export { default as authAutomat } from './authAutomat';
|
|
export * from './authAutomat';
|
|
|
|
export { default as navigationAutomat } from './navigationAutomat';
|
|
export {
|
|
setLastDeliveryPath,
|
|
setLastArticleSku,
|
|
setLastSearchTerm,
|
|
setLastArticleSearchPath,
|
|
setLastCategoryId,
|
|
setLastCategorySlug,
|
|
setLastCategoryPath,
|
|
clearNavigation,
|
|
} from './navigationAutomat';
|
|
|
|
export { default as userSettingsAutomat } from './userSettingsAutomat';
|
|
export { setViewerPosition } from './userSettingsAutomat';
|
|
|
|
export { default as helpAutomat } from './helpAutomat';
|
|
export {
|
|
toggleHelp,
|
|
setHelpEnabled,
|
|
isHelpEnabled,
|
|
openHelpPopper,
|
|
closeHelpPopper,
|
|
toggleHelpPopper,
|
|
selectActiveHelpId,
|
|
} from './helpAutomat';
|
|
|
|
export {
|
|
default as pwaAutomat,
|
|
initPwa,
|
|
openPwaDialog,
|
|
closePwaDialog,
|
|
applyPwaUpdate,
|
|
} from './pwaAutomat';
|
|
|
|
export { default as supplierAutomat } from './supplierAutomat';
|
|
export { default as warehouseAutomat } from './warehouseAutomat';
|
|
export { default as carrierAutomat } from './carrierAutomat';
|
|
|
|
/** Article search over the derived index (replaces StorageManager.doSearch). */
|
|
export {
|
|
default as articleSearchAutomat,
|
|
selectSearchResult,
|
|
searchArticlesIndex,
|
|
} from './articleSearchAutomat';
|
|
|
|
/**
|
|
* Derived article search index: the union of every loaded category view.
|
|
* Replaces the former `GET /api/articleIndex` list store.
|
|
*/
|
|
export {
|
|
default as articleIndexAutomat,
|
|
setArticleIndexName,
|
|
buildArticleIndex,
|
|
selectArticleIndexItems,
|
|
} from './articleIndexAutomat';
|
|
export {
|
|
default as deliveryAutomat,
|
|
CHUNK_SIZE as DELIVERY_CHUNK_SIZE,
|
|
MAX_LRU_CHUNKS as DELIVERY_MAX_LRU_CHUNKS,
|
|
selectDeliveries,
|
|
selectDeliveryTotal,
|
|
selectDeliveryUnfilteredTotal,
|
|
selectDeliveryPagination,
|
|
selectOnlyUnbooked,
|
|
isDeliveryBooked,
|
|
getDeliveryUnbookedCount,
|
|
getChunkStats as getDeliveryChunkStats,
|
|
subscribeChunkStats as subscribeDeliveryChunkStats,
|
|
} from './deliveryAutomat';
|
|
export { default as quoteAutomat } from './quoteAutomat';
|
|
export {
|
|
default as orderAutomat,
|
|
selectOrders,
|
|
selectOrderTotal,
|
|
selectOrderUnfilteredTotal,
|
|
selectOrderPagination,
|
|
selectOnlyUnpaid,
|
|
selectOnlyUndelivered,
|
|
selectNegativeSeekMonths,
|
|
isOrderPaid,
|
|
isOrderDelivered,
|
|
getNegativeSeekCutoff,
|
|
formatNegativeSeek,
|
|
getChunkStats,
|
|
subscribeChunkStats,
|
|
} from './orderAutomat';
|
|
export { default as entityAutomat } from './entityAutomat';
|
|
export { default as customergroupAutomat } from './customergroupAutomat';
|
|
export { default as numberAutomat } from './numberAutomat';
|
|
export { default as accountAutomat } from './accountAutomat';
|
|
export { default as backupAutomat } from './backupAutomat';
|
|
export {
|
|
default as shipmentAutomat,
|
|
CHUNK_SIZE as SHIPMENT_CHUNK_SIZE,
|
|
selectShipments,
|
|
selectShipmentTotal,
|
|
selectShipmentUnfilteredTotal,
|
|
selectShipmentPagination,
|
|
selectStateFilter,
|
|
getChunkStats as getShipmentChunkStats,
|
|
subscribeChunkStats as subscribeShipmentChunkStats,
|
|
} from './shipmentAutomat';
|
|
export { createListAutomat, selectListItems, selectListStatus } from './createListAutomat';
|
|
|
|
|
|
/** Per-SKU article detail views keyed by SKU. */
|
|
export { articleHistoryAutomat, articleSupplierAutomat } from './articleDetailAutomat';
|
|
|
|
/** Single shared GET /api/events connection. */
|
|
export { default as sseAutomat, invalidateArticle } from './sseAutomat';
|
|
|
|
export { default as artikelAutomat } from './artikelAutomat';
|
|
export {
|
|
getArticle,
|
|
hasArticle,
|
|
selectArticle,
|
|
createArticleSelector,
|
|
} from './artikelAutomat';
|
|
|
|
export { default as companyAutomat } from './companyAutomat';
|
|
export {
|
|
selectCurrentCompany,
|
|
selectCompanyId,
|
|
selectCompanyStatus,
|
|
selectCompanyName,
|
|
selectCompanyIso639,
|
|
selectCompanyLanguageId,
|
|
selectCompanyTaxrate,
|
|
selectCompanyReducedTaxrate,
|
|
selectCompanyTaxfreerate,
|
|
selectCompanyRootCategoryId,
|
|
} from './companyAutomat';
|
|
|
|
export { default as brandAutomat } from './brandAutomat';
|
|
export { default as unitAutomat } from './unitAutomat';
|
|
export { default as attributeAutomat, selectAttributes, selectAttributeStatus } from './attributeAutomat';
|
|
export { default as propertyAutomat, selectProperties, selectPropertyStatus } from './propertyAutomat';
|
|
|
|
export { default as posterminalAutomat } from './posterminalAutomat';
|
|
export {
|
|
selectPosterminals,
|
|
selectPosterminalStatus,
|
|
selectHasPosterminals,
|
|
} from './posterminalAutomat';
|
|
|
|
export { default as categoryAutomat } from './categoryAutomat';
|
|
export {
|
|
ROOT_CATEGORY_NAME,
|
|
parseCategoryTreeResponse,
|
|
normalizeCategoryNode,
|
|
getCategoryBreadcrumbs,
|
|
getCategoryChildren,
|
|
categoryDisplayName,
|
|
categorySlug,
|
|
normalizeCategoryMap,
|
|
getCategoryState,
|
|
whenCategoryTreeReady,
|
|
selectCategoryTreeArticleCount,
|
|
} from './categoryAutomat';
|
|
|
|
/**
|
|
* Per-category article views keyed by slug path, warmed in bulk by
|
|
* `categoryAutomat.loadTree()` once the tree succeeded.
|
|
*/
|
|
export {
|
|
default as categoryViews,
|
|
attachCategoryTree,
|
|
categoryViewSlugPath,
|
|
collectLoadedCategoryViewData,
|
|
loadAllCategoryViews,
|
|
reloadLoadedCategoryViews,
|
|
getOrCreateCategoryAutomat,
|
|
disposeAllCategoryViewAutomats,
|
|
invalidateAllCategoryViews,
|
|
refreshCategoryViewChildren,
|
|
appendArticlesToCategoryViews,
|
|
} from './categoryViewAutomat';
|
|
|
|
export { default as articleHistoryGridAutomat } from './articleHistoryAutomat';
|
|
export { default as globalHistoryAutomat, globalHistoryGridAutomat } from './globalHistoryAutomat';
|
|
|
|
export { default as chatAutomat } from './chatAutomat';
|
|
export {
|
|
selectChatIsOpen,
|
|
selectChatState,
|
|
selectChatMessages,
|
|
selectChatConversations,
|
|
selectSelectedConversationId,
|
|
selectSseStatus,
|
|
selectPendingAskUser,
|
|
selectHasPendingAsk,
|
|
} from './chatAutomat';
|
|
|
|
export { default as vfsAutomat } from './vfsAutomat';
|
|
|
|
export { default as pinnedAppletAutomat } from './pinnedAppletAutomat';
|
|
export {
|
|
isPinned,
|
|
getPinnedForRoute,
|
|
pinApplet,
|
|
unpinApplet,
|
|
togglePin,
|
|
executeApplet,
|
|
closeExecution,
|
|
normalizeRoute,
|
|
} from './pinnedAppletAutomat';
|
|
|
|
|
|
/**
|
|
* ============================================================================
|
|
* Overview of Automats in Dashfront
|
|
* ============================================================================
|
|
*
|
|
* Automats are lightweight, reactive, out-of-tree state containers powered by
|
|
* `react-automat`. They manage all client-side state without React context,
|
|
* hooks, or HOCs, enabling pure, zero-flash rendering in `React.PureComponent`
|
|
* via constructor reads and fine-grained subscriptions.
|
|
*
|
|
* 1. Multi-Tenant Session & Security
|
|
* ----------------------------------------------------------------------------
|
|
* - `authAutomat`: Tracks authenticated session (`user`, `googleClientId`,
|
|
* `selectedCompanyId`, and auth status `'loading' | 'anon' | 'authed'`).
|
|
* Coordinates session bootstrap, company switching, and acts as the root
|
|
* lifecycle trigger that loads or resets all company-scoped automats.
|
|
*
|
|
* 2. Real-Time SSE Hub
|
|
* ----------------------------------------------------------------------------
|
|
* - `sseAutomat`: Manages the single persistent Server-Sent Events connection
|
|
* (`GET /api/events`). Automatically reconnects when the active company changes
|
|
* and terminates on logout. Dispatches incoming server mutation signals into
|
|
* targeted automats (`artikelAutomat`, `articleDetailAutomat`, `categoryAutomat`,
|
|
* `articleIndexAutomat`, `warehouseAutomat`, `supplierAutomat`, `attributeAutomat`,
|
|
* `propertyAutomat`).
|
|
*
|
|
* 3. Domain & Entity Caches
|
|
* ----------------------------------------------------------------------------
|
|
* - `artikelAutomat`: In-memory cache for full article records (`GET /api/article/:sku`)
|
|
* with inflight request deduplication, optimistic renames, and reactive selectors.
|
|
* - `articleDetailAutomat`: Keyed automats (`articleHistoryAutomat`, `articleSupplierAutomat`)
|
|
* providing per-SKU supplier catalog bindings and change history.
|
|
* - `deliveryEditorAutomat`: Interactive draft state machine for incoming goods receipts
|
|
* and invoice reconciliation (line items, supplier article auto-matching, PDF/receipt OCR).
|
|
*
|
|
* 4. Company Configuration & Catalogs
|
|
* ----------------------------------------------------------------------------
|
|
* - `companyAutomat`: Active company settings (tax rates, ISO language, root category ID).
|
|
* - `categoryAutomat`: Hierarchical category tree (ID -> node map), mutations (create,
|
|
* rename, move, reorder, delete), and breadcrumb resolution.
|
|
* - `categoryViewAutomat`: Keyed view container (`categoryViews`) holding articles and child
|
|
* categories per slug path, auto-preloaded when category tree finishes loading.
|
|
* - `brandAutomat`: Catalog manufacturer and brand records.
|
|
* - `unitAutomat`: Allowed units of measure (Stück, kg, Liter, etc.).
|
|
* - `posterminalAutomat`: Point-of-sale hardware terminals and enabled category filters.
|
|
* - `attributeAutomat`: Product attribute definitions and discrete values (e.g. Size, Color).
|
|
* - `propertyAutomat`: Custom product property and metadata names.
|
|
* - `supplierAutomat`: Directory of vendor entities and supplier article mappings.
|
|
* - `warehouseAutomat`: Warehouse locations and stock storage areas.
|
|
*
|
|
* 5. Company-Scoped List Automats (`createListAutomat`)
|
|
* ----------------------------------------------------------------------------
|
|
* Built with the shared list factory with deduplicated `load()`, silent `reload()`,
|
|
* and automatic synchronization with `authAutomat`:
|
|
* - `deliveryAutomat`: Delivery receipt list (`GET /api/delivery`).
|
|
* - `quoteAutomat`: Sales quotes / Angebote (`GET /api/quote`).
|
|
* - `orderAutomat`: Sales orders / Bestellungen (`GET /api/order`).
|
|
* - `entityAutomat`: Customers and business partners (`GET /api/entity`).
|
|
* - `customergroupAutomat`: Customer discount groups (`GET /api/customergroup`).
|
|
* - `numberAutomat`: Document numbering sequences (`GET /api/number`).
|
|
*
|
|
* 6. Search & Infinite-Scroll Grid Automats
|
|
* ----------------------------------------------------------------------------
|
|
* - `articleIndexAutomat`: Fast client-side search index, **derived** from the loaded
|
|
* category views (`GET /api/category/:id/articles`) — no dedicated index endpoint.
|
|
* - `articleSearchAutomat`: Client-side search engine querying `articleIndexAutomat`.
|
|
* - `articleHistoryGridAutomat`: Virtualized infinite-scroll grid for article history.
|
|
* - `globalHistoryGridAutomat`: Virtualized infinite-scroll grid for global audit logs.
|
|
*
|
|
* 7. UI State & Utilities
|
|
* ----------------------------------------------------------------------------
|
|
* - `chatAutomat`: AI assistant chat drawer state, conversations, and live SSE streaming tokens.
|
|
* - `navigationAutomat`: Persists last visited delivery document path and article SKU.
|
|
* - `userSettingsAutomat`: User layout preferences (viewer position, drawer widths in IndexedDB).
|
|
* - `helpAutomat`: Interactive help badge states and popper positioning (in IndexedDB).
|
|
* ============================================================================
|
|
*/
|
|
|
|
|