@open-mercato/documents 0.6.8-develop.7016.1.4ed7b1e49d
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +88 -0
- package/build.mjs +23 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +7 -0
- package/dist/modules/documents/acl.js +15 -0
- package/dist/modules/documents/acl.js.map +7 -0
- package/dist/modules/documents/api/[id]/archive/route.js +116 -0
- package/dist/modules/documents/api/[id]/archive/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js +155 -0
- package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/attachments/route.js +153 -0
- package/dist/modules/documents/api/[id]/attachments/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/collab-token/route.js +180 -0
- package/dist/modules/documents/api/[id]/collab-token/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/comments/access-check/route.js +86 -0
- package/dist/modules/documents/api/[id]/comments/access-check/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/comments/route.js +387 -0
- package/dist/modules/documents/api/[id]/comments/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/content/route.js +143 -0
- package/dist/modules/documents/api/[id]/content/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/duplicate/route.js +200 -0
- package/dist/modules/documents/api/[id]/duplicate/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/export/route.js +421 -0
- package/dist/modules/documents/api/[id]/export/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/favorite/route.js +96 -0
- package/dist/modules/documents/api/[id]/favorite/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/links/[linkId]/route.js +85 -0
- package/dist/modules/documents/api/[id]/links/[linkId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/links/route.js +257 -0
- package/dist/modules/documents/api/[id]/links/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/principals/route.js +299 -0
- package/dist/modules/documents/api/[id]/principals/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/route.js +246 -0
- package/dist/modules/documents/api/[id]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/shares/route.js +335 -0
- package/dist/modules/documents/api/[id]/shares/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/unarchive/route.js +39 -0
- package/dist/modules/documents/api/[id]/unarchive/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js +133 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/route.js +93 -0
- package/dist/modules/documents/api/[id]/versions/[versionId]/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/versions/route.js +193 -0
- package/dist/modules/documents/api/[id]/versions/route.js.map +7 -0
- package/dist/modules/documents/api/[id]/watch/route.js +97 -0
- package/dist/modules/documents/api/[id]/watch/route.js.map +7 -0
- package/dist/modules/documents/api/_commands.js +34 -0
- package/dist/modules/documents/api/_commands.js.map +7 -0
- package/dist/modules/documents/api/_shared.js +490 -0
- package/dist/modules/documents/api/_shared.js.map +7 -0
- package/dist/modules/documents/api/folders/route.js +256 -0
- package/dist/modules/documents/api/folders/route.js.map +7 -0
- package/dist/modules/documents/api/instantiate/route.js +108 -0
- package/dist/modules/documents/api/instantiate/route.js.map +7 -0
- package/dist/modules/documents/api/route.js +322 -0
- package/dist/modules/documents/api/route.js.map +7 -0
- package/dist/modules/documents/api/templates/[templateId]/preview/route.js +94 -0
- package/dist/modules/documents/api/templates/[templateId]/preview/route.js.map +7 -0
- package/dist/modules/documents/api/templates/[templateId]/route.js +82 -0
- package/dist/modules/documents/api/templates/[templateId]/route.js.map +7 -0
- package/dist/modules/documents/api/templates/route.js +344 -0
- package/dist/modules/documents/api/templates/route.js.map +7 -0
- package/dist/modules/documents/backend/documents/DocumentsPageClient.js +160 -0
- package/dist/modules/documents/backend/documents/DocumentsPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/DocumentsTable.js +143 -0
- package/dist/modules/documents/backend/documents/DocumentsTable.js.map +7 -0
- package/dist/modules/documents/backend/documents/FolderDialog.js +55 -0
- package/dist/modules/documents/backend/documents/FolderDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/FolderTree.js +40 -0
- package/dist/modules/documents/backend/documents/FolderTree.js.map +7 -0
- package/dist/modules/documents/backend/documents/MoveDocumentDialog.js +64 -0
- package/dist/modules/documents/backend/documents/MoveDocumentDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js +77 -0
- package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentComposer.js +126 -0
- package/dist/modules/documents/backend/documents/[id]/CommentComposer.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js +88 -0
- package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/CommentsRail.js +123 -0
- package/dist/modules/documents/backend/documents/[id]/CommentsRail.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js +91 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js +27 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js +50 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js +168 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js +129 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js +429 -0
- package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js +68 -0
- package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js +69 -0
- package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js +151 -0
- package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/ExportMenu.js +121 -0
- package/dist/modules/documents/backend/documents/[id]/ExportMenu.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/MentionPicker.js +114 -0
- package/dist/modules/documents/backend/documents/[id]/MentionPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/OutlinePane.js +70 -0
- package/dist/modules/documents/backend/documents/[id]/OutlinePane.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js +157 -0
- package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js +266 -0
- package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js +227 -0
- package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js +157 -0
- package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/commentTypes.js +150 -0
- package/dist/modules/documents/backend/documents/[id]/commentTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js +13 -0
- package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/documentPagination.js +295 -0
- package/dist/modules/documents/backend/documents/[id]/documentPagination.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js +81 -0
- package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/editorTypes.js +52 -0
- package/dist/modules/documents/backend/documents/[id]/editorTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/page.js +10 -0
- package/dist/modules/documents/backend/documents/[id]/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/page.meta.js +16 -0
- package/dist/modules/documents/backend/documents/[id]/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js +38 -0
- package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/restoreVersion.js +33 -0
- package/dist/modules/documents/backend/documents/[id]/restoreVersion.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js +392 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js +253 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js +149 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js +82 -0
- package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js +144 -0
- package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js +237 -0
- package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js +216 -0
- package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js +25 -0
- package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/EntityPicker.js +156 -0
- package/dist/modules/documents/backend/documents/components/EntityPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/EntityPickerResults.js +46 -0
- package/dist/modules/documents/backend/documents/components/EntityPickerResults.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js +127 -0
- package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/PrincipalPicker.js +84 -0
- package/dist/modules/documents/backend/documents/components/PrincipalPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialog.js +77 -0
- package/dist/modules/documents/backend/documents/components/ShareDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js +93 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogList.js +82 -0
- package/dist/modules/documents/backend/documents/components/ShareDialogList.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js +96 -0
- package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js +169 -0
- package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplatePreview.js +38 -0
- package/dist/modules/documents/backend/documents/components/TemplatePreview.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js +69 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js +71 -0
- package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/principalPickerModel.js +63 -0
- package/dist/modules/documents/backend/documents/components/principalPickerModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/shareDialogModel.js +68 -0
- package/dist/modules/documents/backend/documents/components/shareDialogModel.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/templateUi.js +89 -0
- package/dist/modules/documents/backend/documents/components/templateUi.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js +30 -0
- package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useEntitySearch.js +191 -0
- package/dist/modules/documents/backend/documents/components/useEntitySearch.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js +221 -0
- package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useShareDialog.js +236 -0
- package/dist/modules/documents/backend/documents/components/useShareDialog.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useTemplateDetail.js +49 -0
- package/dist/modules/documents/backend/documents/components/useTemplateDetail.js.map +7 -0
- package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js +234 -0
- package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js.map +7 -0
- package/dist/modules/documents/backend/documents/documentUi.js +106 -0
- package/dist/modules/documents/backend/documents/documentUi.js.map +7 -0
- package/dist/modules/documents/backend/documents/documentsListTypes.js +132 -0
- package/dist/modules/documents/backend/documents/documentsListTypes.js.map +7 -0
- package/dist/modules/documents/backend/documents/page.js +9 -0
- package/dist/modules/documents/backend/documents/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/page.meta.js +26 -0
- package/dist/modules/documents/backend/documents/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js +91 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesTable.js +58 -0
- package/dist/modules/documents/backend/documents/templates/TemplatesTable.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/page.js +9 -0
- package/dist/modules/documents/backend/documents/templates/page.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/page.meta.js +34 -0
- package/dist/modules/documents/backend/documents/templates/page.meta.js.map +7 -0
- package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js +139 -0
- package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js.map +7 -0
- package/dist/modules/documents/backend/documents/useDocumentsList.js +314 -0
- package/dist/modules/documents/backend/documents/useDocumentsList.js.map +7 -0
- package/dist/modules/documents/ce.js +8 -0
- package/dist/modules/documents/ce.js.map +7 -0
- package/dist/modules/documents/commands/aggregate.js +99 -0
- package/dist/modules/documents/commands/aggregate.js.map +7 -0
- package/dist/modules/documents/commands/attachments.js +252 -0
- package/dist/modules/documents/commands/attachments.js.map +7 -0
- package/dist/modules/documents/commands/comments.js +782 -0
- package/dist/modules/documents/commands/comments.js.map +7 -0
- package/dist/modules/documents/commands/content.js +238 -0
- package/dist/modules/documents/commands/content.js.map +7 -0
- package/dist/modules/documents/commands/document-crud.js +505 -0
- package/dist/modules/documents/commands/document-crud.js.map +7 -0
- package/dist/modules/documents/commands/documents.js +473 -0
- package/dist/modules/documents/commands/documents.js.map +7 -0
- package/dist/modules/documents/commands/duplicate.js +640 -0
- package/dist/modules/documents/commands/duplicate.js.map +7 -0
- package/dist/modules/documents/commands/favorites.js +150 -0
- package/dist/modules/documents/commands/favorites.js.map +7 -0
- package/dist/modules/documents/commands/folders.js +420 -0
- package/dist/modules/documents/commands/folders.js.map +7 -0
- package/dist/modules/documents/commands/index.js +64 -0
- package/dist/modules/documents/commands/index.js.map +7 -0
- package/dist/modules/documents/commands/interceptors.js +300 -0
- package/dist/modules/documents/commands/interceptors.js.map +7 -0
- package/dist/modules/documents/commands/lifecycle.js +249 -0
- package/dist/modules/documents/commands/lifecycle.js.map +7 -0
- package/dist/modules/documents/commands/links.js +410 -0
- package/dist/modules/documents/commands/links.js.map +7 -0
- package/dist/modules/documents/commands/mutation-helpers.js +42 -0
- package/dist/modules/documents/commands/mutation-helpers.js.map +7 -0
- package/dist/modules/documents/commands/projection-types.js +1 -0
- package/dist/modules/documents/commands/projection-types.js.map +7 -0
- package/dist/modules/documents/commands/shared.js +143 -0
- package/dist/modules/documents/commands/shared.js.map +7 -0
- package/dist/modules/documents/commands/shares.js +527 -0
- package/dist/modules/documents/commands/shares.js.map +7 -0
- package/dist/modules/documents/commands/side-effects.js +103 -0
- package/dist/modules/documents/commands/side-effects.js.map +7 -0
- package/dist/modules/documents/commands/templates.js +461 -0
- package/dist/modules/documents/commands/templates.js.map +7 -0
- package/dist/modules/documents/commands/versions.js +432 -0
- package/dist/modules/documents/commands/versions.js.map +7 -0
- package/dist/modules/documents/commands/watchers.js +164 -0
- package/dist/modules/documents/commands/watchers.js.map +7 -0
- package/dist/modules/documents/data/entities.js +653 -0
- package/dist/modules/documents/data/entities.js.map +7 -0
- package/dist/modules/documents/data/extensions.js +44 -0
- package/dist/modules/documents/data/extensions.js.map +7 -0
- package/dist/modules/documents/data/validators.js +219 -0
- package/dist/modules/documents/data/validators.js.map +7 -0
- package/dist/modules/documents/di.js +35 -0
- package/dist/modules/documents/di.js.map +7 -0
- package/dist/modules/documents/encryption.js +12 -0
- package/dist/modules/documents/encryption.js.map +7 -0
- package/dist/modules/documents/events.js +27 -0
- package/dist/modules/documents/events.js.map +7 -0
- package/dist/modules/documents/index.js +19 -0
- package/dist/modules/documents/index.js.map +7 -0
- package/dist/modules/documents/lib/attachmentServicePort.js +30 -0
- package/dist/modules/documents/lib/attachmentServicePort.js.map +7 -0
- package/dist/modules/documents/lib/capabilities.js +32 -0
- package/dist/modules/documents/lib/capabilities.js.map +7 -0
- package/dist/modules/documents/lib/collabCloseEvents.js +17 -0
- package/dist/modules/documents/lib/collabCloseEvents.js.map +7 -0
- package/dist/modules/documents/lib/collabEndpoint.js +22 -0
- package/dist/modules/documents/lib/collabEndpoint.js.map +7 -0
- package/dist/modules/documents/lib/collabMaterializer.js +107 -0
- package/dist/modules/documents/lib/collabMaterializer.js.map +7 -0
- package/dist/modules/documents/lib/collabToken.js +120 -0
- package/dist/modules/documents/lib/collabToken.js.map +7 -0
- package/dist/modules/documents/lib/collaborationAwareness.js +68 -0
- package/dist/modules/documents/lib/collaborationAwareness.js.map +7 -0
- package/dist/modules/documents/lib/commentAnchors.js +15 -0
- package/dist/modules/documents/lib/commentAnchors.js.map +7 -0
- package/dist/modules/documents/lib/constants.js +25 -0
- package/dist/modules/documents/lib/constants.js.map +7 -0
- package/dist/modules/documents/lib/contentService.js +248 -0
- package/dist/modules/documents/lib/contentService.js.map +7 -0
- package/dist/modules/documents/lib/displayLabels.js +23 -0
- package/dist/modules/documents/lib/displayLabels.js.map +7 -0
- package/dist/modules/documents/lib/docxRenderer.js +601 -0
- package/dist/modules/documents/lib/docxRenderer.js.map +7 -0
- package/dist/modules/documents/lib/duplicateContent.js +22 -0
- package/dist/modules/documents/lib/duplicateContent.js.map +7 -0
- package/dist/modules/documents/lib/editorConfig.js +287 -0
- package/dist/modules/documents/lib/editorConfig.js.map +7 -0
- package/dist/modules/documents/lib/entityLinks.js +148 -0
- package/dist/modules/documents/lib/entityLinks.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistry.js +258 -0
- package/dist/modules/documents/lib/entityRegistry.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistry.server.js +189 -0
- package/dist/modules/documents/lib/entityRegistry.server.js.map +7 -0
- package/dist/modules/documents/lib/entityRegistryAvailability.server.js +9 -0
- package/dist/modules/documents/lib/entityRegistryAvailability.server.js.map +7 -0
- package/dist/modules/documents/lib/entitySuggestion.js +50 -0
- package/dist/modules/documents/lib/entitySuggestion.js.map +7 -0
- package/dist/modules/documents/lib/favorites.js +22 -0
- package/dist/modules/documents/lib/favorites.js.map +7 -0
- package/dist/modules/documents/lib/folderHierarchySerialization.js +19 -0
- package/dist/modules/documents/lib/folderHierarchySerialization.js.map +7 -0
- package/dist/modules/documents/lib/historyLimits.js +100 -0
- package/dist/modules/documents/lib/historyLimits.js.map +7 -0
- package/dist/modules/documents/lib/historyPolicy.js +14 -0
- package/dist/modules/documents/lib/historyPolicy.js.map +7 -0
- package/dist/modules/documents/lib/organizationAccess.js +17 -0
- package/dist/modules/documents/lib/organizationAccess.js.map +7 -0
- package/dist/modules/documents/lib/pdfHtml.js +62 -0
- package/dist/modules/documents/lib/pdfHtml.js.map +7 -0
- package/dist/modules/documents/lib/pdfRenderer.js +284 -0
- package/dist/modules/documents/lib/pdfRenderer.js.map +7 -0
- package/dist/modules/documents/lib/permissions.js +222 -0
- package/dist/modules/documents/lib/permissions.js.map +7 -0
- package/dist/modules/documents/lib/platformServices.js +35 -0
- package/dist/modules/documents/lib/platformServices.js.map +7 -0
- package/dist/modules/documents/lib/recordFieldInsertion.js +58 -0
- package/dist/modules/documents/lib/recordFieldInsertion.js.map +7 -0
- package/dist/modules/documents/lib/requestBody.js +80 -0
- package/dist/modules/documents/lib/requestBody.js.map +7 -0
- package/dist/modules/documents/lib/resourceLimits.js +62 -0
- package/dist/modules/documents/lib/resourceLimits.js.map +7 -0
- package/dist/modules/documents/lib/shareCounts.js +25 -0
- package/dist/modules/documents/lib/shareCounts.js.map +7 -0
- package/dist/modules/documents/lib/templateFill.js +84 -0
- package/dist/modules/documents/lib/templateFill.js.map +7 -0
- package/dist/modules/documents/lib/templateInstantiation.js +147 -0
- package/dist/modules/documents/lib/templateInstantiation.js.map +7 -0
- package/dist/modules/documents/lib/templatePreviewDigest.js +82 -0
- package/dist/modules/documents/lib/templatePreviewDigest.js.map +7 -0
- package/dist/modules/documents/lib/templateSeeds.js +201 -0
- package/dist/modules/documents/lib/templateSeeds.js.map +7 -0
- package/dist/modules/documents/lib/userLabels.js +37 -0
- package/dist/modules/documents/lib/userLabels.js.map +7 -0
- package/dist/modules/documents/lib/versionContent.js +131 -0
- package/dist/modules/documents/lib/versionContent.js.map +7 -0
- package/dist/modules/documents/lib/versionLabels.js +12 -0
- package/dist/modules/documents/lib/versionLabels.js.map +7 -0
- package/dist/modules/documents/lib/versioning.js +14 -0
- package/dist/modules/documents/lib/versioning.js.map +7 -0
- package/dist/modules/documents/lib/visibility.js +422 -0
- package/dist/modules/documents/lib/visibility.js.map +7 -0
- package/dist/modules/documents/lib/watchers.js +106 -0
- package/dist/modules/documents/lib/watchers.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260708163836_documents.js +44 -0
- package/dist/modules/documents/migrations/Migration20260708163836_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260709164720_documents.js +17 -0
- package/dist/modules/documents/migrations/Migration20260709164720_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260710002318_documents.js +32 -0
- package/dist/modules/documents/migrations/Migration20260710002318_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260710071003_documents.js +13 -0
- package/dist/modules/documents/migrations/Migration20260710071003_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260712120000_documents.js +13 -0
- package/dist/modules/documents/migrations/Migration20260712120000_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260712183000_documents.js +14 -0
- package/dist/modules/documents/migrations/Migration20260712183000_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260713092156_documents.js +29 -0
- package/dist/modules/documents/migrations/Migration20260713092156_documents.js.map +7 -0
- package/dist/modules/documents/migrations/Migration20260717000000_documents.js +37 -0
- package/dist/modules/documents/migrations/Migration20260717000000_documents.js.map +7 -0
- package/dist/modules/documents/notifications.js +47 -0
- package/dist/modules/documents/notifications.js.map +7 -0
- package/dist/modules/documents/search.js +101 -0
- package/dist/modules/documents/search.js.map +7 -0
- package/dist/modules/documents/setup.js +19 -0
- package/dist/modules/documents/setup.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js +214 -0
- package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/context.js +84 -0
- package/dist/modules/documents/widgets/injection/related-documents/context.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js +98 -0
- package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.client.js +83 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.client.js.map +7 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.js +19 -0
- package/dist/modules/documents/widgets/injection/related-documents/widget.js.map +7 -0
- package/dist/modules/documents/widgets/injection-table.js +21 -0
- package/dist/modules/documents/widgets/injection-table.js.map +7 -0
- package/dist/server/documents-collab-server.js +2260 -0
- package/dist/server/documents-collab-server.js.map +7 -0
- package/generated/entities/document/index.ts +12 -0
- package/generated/entities/document_attachment/index.ts +9 -0
- package/generated/entities/document_comment/index.ts +14 -0
- package/generated/entities/document_content/index.ts +11 -0
- package/generated/entities/document_entity_link/index.ts +19 -0
- package/generated/entities/document_favorite/index.ts +7 -0
- package/generated/entities/document_folder/index.ts +9 -0
- package/generated/entities/document_share/index.ts +11 -0
- package/generated/entities/document_template/index.ts +13 -0
- package/generated/entities/document_version/index.ts +9 -0
- package/generated/entities/document_watcher/index.ts +7 -0
- package/generated/entities.ids.generated.ts +21 -0
- package/generated/entity-fields-registry.ts +151 -0
- package/jest.config.cjs +34 -0
- package/package.json +149 -0
- package/server/documents-collab-server.ts +3416 -0
- package/src/index.ts +1 -0
- package/src/modules/documents/acl.ts +11 -0
- package/src/modules/documents/api/[id]/archive/route.ts +132 -0
- package/src/modules/documents/api/[id]/attachments/[attachmentId]/route.ts +166 -0
- package/src/modules/documents/api/[id]/attachments/route.ts +173 -0
- package/src/modules/documents/api/[id]/collab-token/route.ts +203 -0
- package/src/modules/documents/api/[id]/comments/access-check/route.ts +96 -0
- package/src/modules/documents/api/[id]/comments/route.ts +442 -0
- package/src/modules/documents/api/[id]/content/route.ts +156 -0
- package/src/modules/documents/api/[id]/duplicate/route.ts +231 -0
- package/src/modules/documents/api/[id]/export/route.ts +535 -0
- package/src/modules/documents/api/[id]/favorite/route.ts +110 -0
- package/src/modules/documents/api/[id]/links/[linkId]/route.ts +92 -0
- package/src/modules/documents/api/[id]/links/route.ts +301 -0
- package/src/modules/documents/api/[id]/principals/route.ts +375 -0
- package/src/modules/documents/api/[id]/route.ts +267 -0
- package/src/modules/documents/api/[id]/shares/route.ts +372 -0
- package/src/modules/documents/api/[id]/unarchive/route.ts +42 -0
- package/src/modules/documents/api/[id]/versions/[versionId]/restore/route.ts +152 -0
- package/src/modules/documents/api/[id]/versions/[versionId]/route.ts +100 -0
- package/src/modules/documents/api/[id]/versions/route.ts +207 -0
- package/src/modules/documents/api/[id]/watch/route.ts +111 -0
- package/src/modules/documents/api/_commands.ts +53 -0
- package/src/modules/documents/api/_shared.ts +676 -0
- package/src/modules/documents/api/folders/route.ts +287 -0
- package/src/modules/documents/api/instantiate/route.ts +114 -0
- package/src/modules/documents/api/route.ts +362 -0
- package/src/modules/documents/api/templates/[templateId]/preview/route.ts +97 -0
- package/src/modules/documents/api/templates/[templateId]/route.ts +92 -0
- package/src/modules/documents/api/templates/route.ts +370 -0
- package/src/modules/documents/backend/documents/DocumentsPageClient.tsx +150 -0
- package/src/modules/documents/backend/documents/DocumentsTable.tsx +168 -0
- package/src/modules/documents/backend/documents/FolderDialog.tsx +62 -0
- package/src/modules/documents/backend/documents/FolderTree.tsx +72 -0
- package/src/modules/documents/backend/documents/MoveDocumentDialog.tsx +70 -0
- package/src/modules/documents/backend/documents/[id]/CommentAnchorNavigation.ts +88 -0
- package/src/modules/documents/backend/documents/[id]/CommentComposer.tsx +136 -0
- package/src/modules/documents/backend/documents/[id]/CommentThreadList.tsx +131 -0
- package/src/modules/documents/backend/documents/[id]/CommentsRail.tsx +138 -0
- package/src/modules/documents/backend/documents/[id]/DocumentCanvas.tsx +111 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.tsx +39 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorIsland.tsx +50 -0
- package/src/modules/documents/backend/documents/[id]/DocumentEditorSurface.tsx +162 -0
- package/src/modules/documents/backend/documents/[id]/DocumentNavigator.tsx +129 -0
- package/src/modules/documents/backend/documents/[id]/DocumentPageClient.tsx +463 -0
- package/src/modules/documents/backend/documents/[id]/EditorColorTools.tsx +71 -0
- package/src/modules/documents/backend/documents/[id]/EditorStatusPresence.tsx +78 -0
- package/src/modules/documents/backend/documents/[id]/EditorToolbar.tsx +108 -0
- package/src/modules/documents/backend/documents/[id]/ExportMenu.tsx +144 -0
- package/src/modules/documents/backend/documents/[id]/MentionPicker.tsx +137 -0
- package/src/modules/documents/backend/documents/[id]/OutlinePane.tsx +98 -0
- package/src/modules/documents/backend/documents/[id]/RecordFieldsDialog.tsx +185 -0
- package/src/modules/documents/backend/documents/[id]/RelatedRecordsPanel.tsx +320 -0
- package/src/modules/documents/backend/documents/[id]/VersionHistoryPanel.tsx +244 -0
- package/src/modules/documents/backend/documents/[id]/VersionPreviewDialog.tsx +197 -0
- package/src/modules/documents/backend/documents/[id]/commentTypes.ts +192 -0
- package/src/modules/documents/backend/documents/[id]/componentCapabilities.ts +17 -0
- package/src/modules/documents/backend/documents/[id]/documentPagination.ts +352 -0
- package/src/modules/documents/backend/documents/[id]/editorPresenceStyles.ts +77 -0
- package/src/modules/documents/backend/documents/[id]/editorTypes.ts +84 -0
- package/src/modules/documents/backend/documents/[id]/page.meta.ts +12 -0
- package/src/modules/documents/backend/documents/[id]/page.tsx +6 -0
- package/src/modules/documents/backend/documents/[id]/relatedRecordModel.ts +49 -0
- package/src/modules/documents/backend/documents/[id]/restoreVersion.ts +49 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentCollaboration.ts +458 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentComments.ts +286 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentEditor.ts +157 -0
- package/src/modules/documents/backend/documents/[id]/useDocumentTitle.ts +77 -0
- package/src/modules/documents/backend/documents/[id]/useEditorInsertions.ts +147 -0
- package/src/modules/documents/backend/documents/[id]/useFallbackContentPersistence.ts +277 -0
- package/src/modules/documents/backend/documents/[id]/useMentionPicker.ts +259 -0
- package/src/modules/documents/backend/documents/[id]/versionHistoryModel.ts +29 -0
- package/src/modules/documents/backend/documents/components/EntityPicker.tsx +171 -0
- package/src/modules/documents/backend/documents/components/EntityPickerResults.tsx +64 -0
- package/src/modules/documents/backend/documents/components/NewFromTemplateDialog.tsx +136 -0
- package/src/modules/documents/backend/documents/components/PrincipalPicker.tsx +90 -0
- package/src/modules/documents/backend/documents/components/ShareDialog.tsx +88 -0
- package/src/modules/documents/backend/documents/components/ShareDialogAddForm.tsx +113 -0
- package/src/modules/documents/backend/documents/components/ShareDialogList.tsx +117 -0
- package/src/modules/documents/backend/documents/components/TemplateBodyEditor.tsx +96 -0
- package/src/modules/documents/backend/documents/components/TemplateEditorDialog.tsx +171 -0
- package/src/modules/documents/backend/documents/components/TemplatePreview.tsx +43 -0
- package/src/modules/documents/backend/documents/components/TemplateSlotFields.tsx +72 -0
- package/src/modules/documents/backend/documents/components/TemplateSlotsEditor.tsx +72 -0
- package/src/modules/documents/backend/documents/components/principalPickerModel.ts +86 -0
- package/src/modules/documents/backend/documents/components/shareDialogModel.ts +94 -0
- package/src/modules/documents/backend/documents/components/templateUi.ts +128 -0
- package/src/modules/documents/backend/documents/components/useAvailableEntityRegistry.ts +43 -0
- package/src/modules/documents/backend/documents/components/useEntitySearch.ts +197 -0
- package/src/modules/documents/backend/documents/components/usePrincipalPicker.ts +165 -0
- package/src/modules/documents/backend/documents/components/useShareDialog.ts +267 -0
- package/src/modules/documents/backend/documents/components/useTemplateDetail.ts +54 -0
- package/src/modules/documents/backend/documents/components/useTemplateInstantiation.ts +252 -0
- package/src/modules/documents/backend/documents/documentUi.ts +134 -0
- package/src/modules/documents/backend/documents/documentsListTypes.ts +163 -0
- package/src/modules/documents/backend/documents/page.meta.ts +24 -0
- package/src/modules/documents/backend/documents/page.tsx +5 -0
- package/src/modules/documents/backend/documents/templates/TemplatesPageClient.tsx +93 -0
- package/src/modules/documents/backend/documents/templates/TemplatesTable.tsx +71 -0
- package/src/modules/documents/backend/documents/templates/page.meta.ts +32 -0
- package/src/modules/documents/backend/documents/templates/page.tsx +5 -0
- package/src/modules/documents/backend/documents/templates/useTemplatesPage.tsx +148 -0
- package/src/modules/documents/backend/documents/useDocumentsList.tsx +305 -0
- package/src/modules/documents/ce.ts +6 -0
- package/src/modules/documents/commands/aggregate.ts +128 -0
- package/src/modules/documents/commands/attachments.ts +309 -0
- package/src/modules/documents/commands/comments.ts +966 -0
- package/src/modules/documents/commands/content.ts +294 -0
- package/src/modules/documents/commands/document-crud.ts +609 -0
- package/src/modules/documents/commands/documents.ts +581 -0
- package/src/modules/documents/commands/duplicate.ts +772 -0
- package/src/modules/documents/commands/favorites.ts +171 -0
- package/src/modules/documents/commands/folders.ts +506 -0
- package/src/modules/documents/commands/index.ts +33 -0
- package/src/modules/documents/commands/interceptors.ts +402 -0
- package/src/modules/documents/commands/lifecycle.ts +333 -0
- package/src/modules/documents/commands/links.ts +486 -0
- package/src/modules/documents/commands/mutation-helpers.ts +48 -0
- package/src/modules/documents/commands/projection-types.ts +77 -0
- package/src/modules/documents/commands/shared.ts +219 -0
- package/src/modules/documents/commands/shares.ts +612 -0
- package/src/modules/documents/commands/side-effects.ts +130 -0
- package/src/modules/documents/commands/templates.ts +522 -0
- package/src/modules/documents/commands/versions.ts +537 -0
- package/src/modules/documents/commands/watchers.ts +181 -0
- package/src/modules/documents/data/entities.ts +631 -0
- package/src/modules/documents/data/extensions.ts +42 -0
- package/src/modules/documents/data/validators.ts +248 -0
- package/src/modules/documents/di.ts +33 -0
- package/src/modules/documents/encryption.ts +14 -0
- package/src/modules/documents/events.ts +23 -0
- package/src/modules/documents/i18n/.hardcoded-allowlist.json +9 -0
- package/src/modules/documents/i18n/de.json +522 -0
- package/src/modules/documents/i18n/en.json +522 -0
- package/src/modules/documents/i18n/es.json +522 -0
- package/src/modules/documents/i18n/ko.json +522 -0
- package/src/modules/documents/i18n/pl.json +522 -0
- package/src/modules/documents/index.ts +17 -0
- package/src/modules/documents/lib/attachmentServicePort.ts +94 -0
- package/src/modules/documents/lib/capabilities.ts +57 -0
- package/src/modules/documents/lib/collabCloseEvents.ts +26 -0
- package/src/modules/documents/lib/collabEndpoint.ts +43 -0
- package/src/modules/documents/lib/collabMaterializer.ts +140 -0
- package/src/modules/documents/lib/collabToken.ts +170 -0
- package/src/modules/documents/lib/collaborationAwareness.ts +102 -0
- package/src/modules/documents/lib/commentAnchors.ts +19 -0
- package/src/modules/documents/lib/constants.ts +39 -0
- package/src/modules/documents/lib/contentService.ts +340 -0
- package/src/modules/documents/lib/displayLabels.ts +31 -0
- package/src/modules/documents/lib/docxRenderer.ts +685 -0
- package/src/modules/documents/lib/duplicateContent.ts +32 -0
- package/src/modules/documents/lib/editorConfig.ts +371 -0
- package/src/modules/documents/lib/entityLinks.ts +250 -0
- package/src/modules/documents/lib/entityRegistry.server.ts +267 -0
- package/src/modules/documents/lib/entityRegistry.ts +345 -0
- package/src/modules/documents/lib/entityRegistryAvailability.server.ts +19 -0
- package/src/modules/documents/lib/entitySuggestion.ts +61 -0
- package/src/modules/documents/lib/favorites.ts +35 -0
- package/src/modules/documents/lib/folderHierarchySerialization.ts +34 -0
- package/src/modules/documents/lib/historyLimits.ts +154 -0
- package/src/modules/documents/lib/historyPolicy.ts +7 -0
- package/src/modules/documents/lib/organizationAccess.ts +44 -0
- package/src/modules/documents/lib/pdfHtml.ts +65 -0
- package/src/modules/documents/lib/pdfRenderer.ts +367 -0
- package/src/modules/documents/lib/permissions.ts +299 -0
- package/src/modules/documents/lib/platformServices.ts +70 -0
- package/src/modules/documents/lib/recordFieldInsertion.ts +72 -0
- package/src/modules/documents/lib/requestBody.ts +97 -0
- package/src/modules/documents/lib/resourceLimits.ts +94 -0
- package/src/modules/documents/lib/shareCounts.ts +44 -0
- package/src/modules/documents/lib/templateFill.ts +138 -0
- package/src/modules/documents/lib/templateInstantiation.ts +206 -0
- package/src/modules/documents/lib/templatePreviewDigest.ts +122 -0
- package/src/modules/documents/lib/templateSeeds.ts +248 -0
- package/src/modules/documents/lib/userLabels.ts +58 -0
- package/src/modules/documents/lib/versionContent.ts +163 -0
- package/src/modules/documents/lib/versionLabels.ts +9 -0
- package/src/modules/documents/lib/versioning.ts +29 -0
- package/src/modules/documents/lib/visibility.ts +610 -0
- package/src/modules/documents/lib/watchers.ts +129 -0
- package/src/modules/documents/migrations/.snapshot-open-mercato.json +2892 -0
- package/src/modules/documents/migrations/Migration20260708163836_documents.ts +50 -0
- package/src/modules/documents/migrations/Migration20260709164720_documents.ts +19 -0
- package/src/modules/documents/migrations/Migration20260710002318_documents.ts +35 -0
- package/src/modules/documents/migrations/Migration20260710071003_documents.ts +13 -0
- package/src/modules/documents/migrations/Migration20260712120000_documents.ts +13 -0
- package/src/modules/documents/migrations/Migration20260712183000_documents.ts +12 -0
- package/src/modules/documents/migrations/Migration20260713092156_documents.ts +43 -0
- package/src/modules/documents/migrations/Migration20260717000000_documents.ts +40 -0
- package/src/modules/documents/notifications.ts +45 -0
- package/src/modules/documents/search.ts +118 -0
- package/src/modules/documents/setup.ts +19 -0
- package/src/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.tsx +224 -0
- package/src/modules/documents/widgets/injection/related-documents/context.ts +101 -0
- package/src/modules/documents/widgets/injection/related-documents/useRelatedDocuments.ts +112 -0
- package/src/modules/documents/widgets/injection/related-documents/widget.client.tsx +76 -0
- package/src/modules/documents/widgets/injection/related-documents/widget.ts +19 -0
- package/src/modules/documents/widgets/injection-table.ts +20 -0
- package/tsconfig.json +9 -0
- package/watch.mjs +6 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ApiKeyPrincipalService,
|
|
3
|
+
AuthPrincipalService,
|
|
4
|
+
OrganizationScopeService,
|
|
5
|
+
} from '@open-mercato/shared/lib/auth/principal-service'
|
|
6
|
+
|
|
7
|
+
export type DocumentsServiceContainer = {
|
|
8
|
+
resolve(name: string): unknown
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export type DocumentsRbacService = {
|
|
12
|
+
userHasAllFeatures(
|
|
13
|
+
userId: string,
|
|
14
|
+
required: string[],
|
|
15
|
+
scope: { tenantId: string | null; organizationId: string | null },
|
|
16
|
+
): Promise<boolean>
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function tryResolve(container: DocumentsServiceContainer | null | undefined, name: string): unknown {
|
|
20
|
+
if (!container) return null
|
|
21
|
+
try {
|
|
22
|
+
return container.resolve(name)
|
|
23
|
+
} catch {
|
|
24
|
+
return null
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function resolveAuthPrincipalService(
|
|
29
|
+
container: DocumentsServiceContainer | null | undefined,
|
|
30
|
+
): AuthPrincipalService | null {
|
|
31
|
+
const service = tryResolve(container, 'authPrincipalService') as Partial<AuthPrincipalService> | null
|
|
32
|
+
if (!service
|
|
33
|
+
|| typeof service.principalExists !== 'function'
|
|
34
|
+
|| typeof service.resolveActiveUserRoleIds !== 'function'
|
|
35
|
+
|| typeof service.filterActiveRoleIds !== 'function'
|
|
36
|
+
|| typeof service.resolveLabels !== 'function'
|
|
37
|
+
|| typeof service.listSuperAdminUserIds !== 'function') return null
|
|
38
|
+
return service as AuthPrincipalService
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function resolveApiKeyPrincipalService(
|
|
42
|
+
container: DocumentsServiceContainer | null | undefined,
|
|
43
|
+
): ApiKeyPrincipalService | null {
|
|
44
|
+
const service = tryResolve(container, 'apiKeyPrincipalService') as Partial<ApiKeyPrincipalService> | null
|
|
45
|
+
return service && typeof service.resolveAssignedRoleIds === 'function'
|
|
46
|
+
? service as ApiKeyPrincipalService
|
|
47
|
+
: null
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function resolveDocumentsRbacService(
|
|
51
|
+
container: DocumentsServiceContainer | null | undefined,
|
|
52
|
+
): DocumentsRbacService | null {
|
|
53
|
+
const service = tryResolve(container, 'rbacService') as Partial<DocumentsRbacService> | null
|
|
54
|
+
return service && typeof service.userHasAllFeatures === 'function'
|
|
55
|
+
? service as DocumentsRbacService
|
|
56
|
+
: null
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function resolveOrganizationScopeService(
|
|
60
|
+
container: DocumentsServiceContainer | null | undefined,
|
|
61
|
+
): OrganizationScopeService | null {
|
|
62
|
+
const service = tryResolve(container, 'organizationScopeService') as Partial<OrganizationScopeService> | null
|
|
63
|
+
if (!service
|
|
64
|
+
|| typeof service.resolve !== 'function'
|
|
65
|
+
|| typeof service.resolveFresh !== 'function'
|
|
66
|
+
|| typeof service.resolveForRequest !== 'function') {
|
|
67
|
+
return null
|
|
68
|
+
}
|
|
69
|
+
return service as OrganizationScopeService
|
|
70
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Editor, JSONContent } from '@tiptap/core'
|
|
2
|
+
import { sanitizeDocumentsDisplayLabel } from './displayLabels'
|
|
3
|
+
|
|
4
|
+
export type RecordFieldSnapshot = {
|
|
5
|
+
field: string
|
|
6
|
+
label: string
|
|
7
|
+
value: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function normalizeRecordFieldSnapshots(
|
|
11
|
+
fields: readonly RecordFieldSnapshot[],
|
|
12
|
+
): RecordFieldSnapshot[] {
|
|
13
|
+
const normalized = new Map<string, RecordFieldSnapshot>()
|
|
14
|
+
for (const field of fields) {
|
|
15
|
+
const key = field.field.trim()
|
|
16
|
+
const label = sanitizeDocumentsDisplayLabel(field.label)
|
|
17
|
+
const value = sanitizeDocumentsDisplayLabel(field.value)
|
|
18
|
+
if (!key || !label || !value || normalized.has(key)) continue
|
|
19
|
+
normalized.set(key, { field: key, label, value })
|
|
20
|
+
}
|
|
21
|
+
return Array.from(normalized.values())
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function text(value: string, bold = false): JSONContent {
|
|
25
|
+
return {
|
|
26
|
+
type: 'text',
|
|
27
|
+
text: value,
|
|
28
|
+
...(bold ? { marks: [{ type: 'bold' }] } : {}),
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function paragraph(field: RecordFieldSnapshot): JSONContent {
|
|
33
|
+
return {
|
|
34
|
+
type: 'paragraph',
|
|
35
|
+
content: [text(field.label, true), text(`: ${field.value}`)],
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function tableCell(value: string, bold = false): JSONContent {
|
|
40
|
+
return {
|
|
41
|
+
type: 'tableCell',
|
|
42
|
+
content: [{ type: 'paragraph', content: [text(value, bold)] }],
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function buildRecordFieldSnapshotContent(
|
|
47
|
+
input: readonly RecordFieldSnapshot[],
|
|
48
|
+
): JSONContent[] {
|
|
49
|
+
const fields = normalizeRecordFieldSnapshots(input)
|
|
50
|
+
if (fields.length === 0) return []
|
|
51
|
+
if (fields.length === 1) return [paragraph(fields[0]!)]
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
type: 'table',
|
|
55
|
+
content: fields.map((field) => ({
|
|
56
|
+
type: 'tableRow',
|
|
57
|
+
content: [tableCell(field.label, true), tableCell(field.value)],
|
|
58
|
+
})),
|
|
59
|
+
},
|
|
60
|
+
{ type: 'paragraph' },
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function insertRecordFieldSnapshot(
|
|
65
|
+
editor: Editor | null,
|
|
66
|
+
fields: readonly RecordFieldSnapshot[],
|
|
67
|
+
): boolean {
|
|
68
|
+
if (!editor || editor.isDestroyed || !editor.isEditable) return false
|
|
69
|
+
const content = buildRecordFieldSnapshotContent(fields)
|
|
70
|
+
if (content.length === 0) return false
|
|
71
|
+
return editor.chain().focus().insertContent(content).run()
|
|
72
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
2
|
+
import {
|
|
3
|
+
DOCUMENTS_MAX_CONTENT_HTML_BYTES,
|
|
4
|
+
DOCUMENTS_MAX_CONTENT_TEXT_BYTES,
|
|
5
|
+
} from './resourceLimits'
|
|
6
|
+
|
|
7
|
+
const KIBIBYTE = 1024
|
|
8
|
+
const MEBIBYTE = 1024 * KIBIBYTE
|
|
9
|
+
const JSON_ESCAPE_EXPANSION = 6
|
|
10
|
+
const STREAM_INITIAL_CAPACITY = 64 * KIBIBYTE
|
|
11
|
+
|
|
12
|
+
export const DOCUMENTS_REQUEST_BODY_TOO_LARGE = 'documents.errors.requestBodyTooLarge'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Request-level limits are intentionally larger than the decoded field limits.
|
|
16
|
+
* JSON may encode one input byte as a six-byte `\uXXXX` escape, so content
|
|
17
|
+
* routes retain every payload accepted by their existing schemas while still
|
|
18
|
+
* bounding buffering before JSON.parse runs.
|
|
19
|
+
*/
|
|
20
|
+
export const DOCUMENTS_JSON_BODY_LIMITS = {
|
|
21
|
+
standard: 128 * KIBIBYTE,
|
|
22
|
+
template: 4 * MEBIBYTE,
|
|
23
|
+
templateRender: 4 * MEBIBYTE,
|
|
24
|
+
content: (
|
|
25
|
+
JSON_ESCAPE_EXPANSION
|
|
26
|
+
* (DOCUMENTS_MAX_CONTENT_HTML_BYTES + DOCUMENTS_MAX_CONTENT_TEXT_BYTES)
|
|
27
|
+
) + (256 * KIBIBYTE),
|
|
28
|
+
exportSnapshot: (JSON_ESCAPE_EXPANSION * DOCUMENTS_MAX_CONTENT_HTML_BYTES) + (64 * KIBIBYTE),
|
|
29
|
+
} as const
|
|
30
|
+
|
|
31
|
+
function payloadTooLarge(): CrudHttpError {
|
|
32
|
+
return new CrudHttpError(413, { error: DOCUMENTS_REQUEST_BODY_TOO_LARGE })
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function declaredContentLength(request: Request): number | null {
|
|
36
|
+
const value = request.headers.get('content-length')?.trim()
|
|
37
|
+
if (!value || !/^\d+$/.test(value)) return null
|
|
38
|
+
const declaredBytes = Number(value)
|
|
39
|
+
return Number.isSafeInteger(declaredBytes) ? declaredBytes : Number.POSITIVE_INFINITY
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function growBuffer(current: Uint8Array, requiredBytes: number, maxBytes: number): Uint8Array {
|
|
43
|
+
let capacity = Math.max(1, current.byteLength)
|
|
44
|
+
while (capacity < requiredBytes) capacity = Math.min(maxBytes, capacity * 2)
|
|
45
|
+
const next = new Uint8Array(capacity)
|
|
46
|
+
next.set(current)
|
|
47
|
+
return next
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export async function readBoundedJsonBody<T>(
|
|
51
|
+
request: Request,
|
|
52
|
+
maxBytes: number,
|
|
53
|
+
fallback: T | null = null,
|
|
54
|
+
): Promise<T | null> {
|
|
55
|
+
if (!Number.isSafeInteger(maxBytes) || maxBytes <= 0) {
|
|
56
|
+
throw new TypeError('maxBytes must be a positive safe integer')
|
|
57
|
+
}
|
|
58
|
+
const contentLength = declaredContentLength(request)
|
|
59
|
+
if (contentLength !== null && contentLength > maxBytes) {
|
|
60
|
+
await request.body?.cancel().catch(() => undefined)
|
|
61
|
+
throw payloadTooLarge()
|
|
62
|
+
}
|
|
63
|
+
if (!request.body) return fallback
|
|
64
|
+
|
|
65
|
+
const reader = request.body.getReader()
|
|
66
|
+
let buffer: Uint8Array<ArrayBufferLike> = new Uint8Array(
|
|
67
|
+
Math.min(maxBytes, STREAM_INITIAL_CAPACITY),
|
|
68
|
+
)
|
|
69
|
+
let byteLength = 0
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
while (true) {
|
|
73
|
+
const chunk = await reader.read()
|
|
74
|
+
if (chunk.done) break
|
|
75
|
+
const nextByteLength = byteLength + chunk.value.byteLength
|
|
76
|
+
if (nextByteLength > maxBytes) {
|
|
77
|
+
await reader.cancel().catch(() => undefined)
|
|
78
|
+
throw payloadTooLarge()
|
|
79
|
+
}
|
|
80
|
+
if (nextByteLength > buffer.byteLength) {
|
|
81
|
+
buffer = growBuffer(buffer, nextByteLength, maxBytes)
|
|
82
|
+
}
|
|
83
|
+
buffer.set(chunk.value, byteLength)
|
|
84
|
+
byteLength = nextByteLength
|
|
85
|
+
}
|
|
86
|
+
} finally {
|
|
87
|
+
reader.releaseLock()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (byteLength === 0) return fallback
|
|
91
|
+
const raw = new TextDecoder().decode(buffer.subarray(0, byteLength))
|
|
92
|
+
try {
|
|
93
|
+
return JSON.parse(raw) as T
|
|
94
|
+
} catch {
|
|
95
|
+
return fallback
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
2
|
+
|
|
3
|
+
const MEBIBYTE = 1024 * 1024
|
|
4
|
+
|
|
5
|
+
/** Authoritative UTF-8 bounds for every stored representation of a document body. */
|
|
6
|
+
export const DOCUMENTS_MAX_CONTENT_HTML_BYTES = 2 * MEBIBYTE
|
|
7
|
+
export const DOCUMENTS_MAX_CONTENT_TEXT_BYTES = 2 * MEBIBYTE
|
|
8
|
+
export const DOCUMENTS_MAX_YJS_STATE_BYTES = 8 * MEBIBYTE
|
|
9
|
+
|
|
10
|
+
/** Bound cross-module verification and reverse-widget work per document. */
|
|
11
|
+
export const DOCUMENTS_MAX_ENTITY_LINKS_PER_DOCUMENT = 100
|
|
12
|
+
|
|
13
|
+
/** WebSocket messages include a small Hocuspocus/Yjs protocol envelope. */
|
|
14
|
+
export const DOCUMENTS_COLLAB_MAX_PAYLOAD_BYTES = DOCUMENTS_MAX_YJS_STATE_BYTES + 64 * 1024
|
|
15
|
+
|
|
16
|
+
export function utf8ByteLength(value: string): number {
|
|
17
|
+
return Buffer.byteLength(value, 'utf8')
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function isUtf8WithinLimit(value: string, maxBytes: number): boolean {
|
|
21
|
+
return utf8ByteLength(value) <= maxBytes
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function maxBase64EncodedLength(maxDecodedBytes: number): number {
|
|
25
|
+
return Math.ceil(maxDecodedBytes / 3) * 4
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Validate encoded size before Buffer allocates the decoded payload. */
|
|
29
|
+
export function decodeBoundedCanonicalBase64(
|
|
30
|
+
value: string,
|
|
31
|
+
maxDecodedBytes: number,
|
|
32
|
+
options: { status?: number; error?: string } = {},
|
|
33
|
+
): Buffer {
|
|
34
|
+
const fail = () => {
|
|
35
|
+
throw new CrudHttpError(options.status ?? 413, {
|
|
36
|
+
error: options.error ?? 'documents.content.tooLarge',
|
|
37
|
+
})
|
|
38
|
+
}
|
|
39
|
+
if (
|
|
40
|
+
value.length > maxBase64EncodedLength(maxDecodedBytes)
|
|
41
|
+
|| value.length % 4 !== 0
|
|
42
|
+
|| !/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(value)
|
|
43
|
+
) {
|
|
44
|
+
return fail()
|
|
45
|
+
}
|
|
46
|
+
const bytes = Buffer.from(value, 'base64')
|
|
47
|
+
if (bytes.byteLength > maxDecodedBytes || bytes.toString('base64') !== value) return fail()
|
|
48
|
+
return bytes
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type DocumentContentResourceInput = {
|
|
52
|
+
yjsState?: Buffer | Uint8Array | null
|
|
53
|
+
contentHtml?: string | null
|
|
54
|
+
contentText?: string | null
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function assertDocumentYjsStateByteLength(
|
|
58
|
+
byteLength: number,
|
|
59
|
+
options: { status?: number; error?: string } = {},
|
|
60
|
+
): void {
|
|
61
|
+
if (byteLength <= DOCUMENTS_MAX_YJS_STATE_BYTES) return
|
|
62
|
+
throw new CrudHttpError(options.status ?? 413, {
|
|
63
|
+
error: options.error ?? 'documents.content.tooLarge',
|
|
64
|
+
})
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Enforce the same bound at API, command, collaboration, and version
|
|
69
|
+
* boundaries. Keeping this check beside persistence prevents an internal or
|
|
70
|
+
* legacy call site from bypassing request validation and creating a snapshot
|
|
71
|
+
* that later exhausts the editor or export worker.
|
|
72
|
+
*/
|
|
73
|
+
export function assertDocumentContentResourceLimits(
|
|
74
|
+
input: DocumentContentResourceInput,
|
|
75
|
+
options: { status?: number; error?: string } = {},
|
|
76
|
+
): void {
|
|
77
|
+
if (input.yjsState) assertDocumentYjsStateByteLength(input.yjsState.byteLength, options)
|
|
78
|
+
if (
|
|
79
|
+
typeof input.contentHtml === 'string'
|
|
80
|
+
&& !isUtf8WithinLimit(input.contentHtml, DOCUMENTS_MAX_CONTENT_HTML_BYTES)
|
|
81
|
+
) {
|
|
82
|
+
throw new CrudHttpError(options.status ?? 413, {
|
|
83
|
+
error: options.error ?? 'documents.content.tooLarge',
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
if (
|
|
87
|
+
typeof input.contentText === 'string'
|
|
88
|
+
&& !isUtf8WithinLimit(input.contentText, DOCUMENTS_MAX_CONTENT_TEXT_BYTES)
|
|
89
|
+
) {
|
|
90
|
+
throw new CrudHttpError(options.status ?? 413, {
|
|
91
|
+
error: options.error ?? 'documents.content.tooLarge',
|
|
92
|
+
})
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { raw } from '@mikro-orm/core'
|
|
2
|
+
import type { EntityManager } from '@mikro-orm/postgresql'
|
|
3
|
+
import { DocumentShare } from '../data/entities'
|
|
4
|
+
|
|
5
|
+
export type DocumentShareCountScope = {
|
|
6
|
+
tenantId: string
|
|
7
|
+
organizationId: string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
type GroupedShareCountRow = {
|
|
11
|
+
documentId?: unknown
|
|
12
|
+
document_id?: unknown
|
|
13
|
+
shareCount?: unknown
|
|
14
|
+
share_count?: unknown
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function loadDocumentShareCounts(
|
|
18
|
+
em: EntityManager,
|
|
19
|
+
scope: DocumentShareCountScope,
|
|
20
|
+
documentIds: readonly string[],
|
|
21
|
+
): Promise<Map<string, number>> {
|
|
22
|
+
const shareCounts = new Map<string, number>()
|
|
23
|
+
if (documentIds.length === 0) return shareCounts
|
|
24
|
+
const groupedShares = await em
|
|
25
|
+
.createQueryBuilder(DocumentShare, 'document_share')
|
|
26
|
+
.select([
|
|
27
|
+
'document_share.documentId',
|
|
28
|
+
raw('count(*) as "shareCount"'),
|
|
29
|
+
])
|
|
30
|
+
.where({
|
|
31
|
+
documentId: { $in: [...documentIds] },
|
|
32
|
+
tenantId: scope.tenantId,
|
|
33
|
+
organizationId: scope.organizationId,
|
|
34
|
+
deletedAt: null,
|
|
35
|
+
})
|
|
36
|
+
.groupBy('document_share.documentId')
|
|
37
|
+
.execute<GroupedShareCountRow[]>('all', false)
|
|
38
|
+
for (const row of groupedShares) {
|
|
39
|
+
const documentId = row.documentId ?? row.document_id
|
|
40
|
+
const count = Number(row.shareCount ?? row.share_count ?? 0)
|
|
41
|
+
if (typeof documentId === 'string' && Number.isFinite(count)) shareCounts.set(documentId, count)
|
|
42
|
+
}
|
|
43
|
+
return shareCounts
|
|
44
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import {
|
|
2
|
+
getEntityRegistryEntry,
|
|
3
|
+
type DocumentEntityType,
|
|
4
|
+
type EntityPickerItem,
|
|
5
|
+
} from './entityRegistry'
|
|
6
|
+
|
|
7
|
+
export type TemplateFillSlot = {
|
|
8
|
+
slot: string
|
|
9
|
+
entityType: DocumentEntityType
|
|
10
|
+
rawItem?: Record<string, unknown> | null
|
|
11
|
+
entityId?: string
|
|
12
|
+
label?: string
|
|
13
|
+
href?: string
|
|
14
|
+
values?: Record<string, string | number | null>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type FillTemplateTokensOptions = {
|
|
18
|
+
locale?: string
|
|
19
|
+
now?: Date
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type TemplateRenderResult = {
|
|
23
|
+
html: string
|
|
24
|
+
unresolvedTokens: string[]
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function escapeHtml(value: string): string {
|
|
28
|
+
return value
|
|
29
|
+
.replace(/&/g, '&')
|
|
30
|
+
.replace(/</g, '<')
|
|
31
|
+
.replace(/>/g, '>')
|
|
32
|
+
.replace(/"/g, '"')
|
|
33
|
+
.replace(/'/g, ''')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function escapeRegExp(value: string): string {
|
|
37
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function replaceToken(source: string, token: string, replacement: string): string {
|
|
41
|
+
return source.replace(new RegExp(`{{\\s*${escapeRegExp(token)}\\s*}}`, 'g'), () => replacement)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function resolvePickerItem(slot: TemplateFillSlot): EntityPickerItem | null {
|
|
45
|
+
const entry = getEntityRegistryEntry(slot.entityType)
|
|
46
|
+
if (!entry) return null
|
|
47
|
+
if (slot.rawItem) return entry.mapItem(slot.rawItem)
|
|
48
|
+
if (!slot.entityId || !slot.label || !slot.href) return null
|
|
49
|
+
return { id: slot.entityId, label: slot.label, href: slot.href }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function buildEntityChip(slot: TemplateFillSlot): string | null {
|
|
53
|
+
const entry = getEntityRegistryEntry(slot.entityType)
|
|
54
|
+
const item = resolvePickerItem(slot)
|
|
55
|
+
if (!entry || !item) return null
|
|
56
|
+
const href = entry.resolveHref(item)
|
|
57
|
+
if (!href || !entry.isCanonicalHref(item, href)) return null
|
|
58
|
+
|
|
59
|
+
const escapedType = escapeHtml(slot.entityType)
|
|
60
|
+
const escapedId = escapeHtml(item.id)
|
|
61
|
+
const escapedLabel = escapeHtml(item.label)
|
|
62
|
+
const escapedHref = escapeHtml(href)
|
|
63
|
+
|
|
64
|
+
return `<span data-entity-ref data-entity-type="${escapedType}" data-entity-id="${escapedId}" data-label="${escapedLabel}" data-href="${escapedHref}" class="om-entity-ref">${escapedLabel}</span>`
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function resolveTokenValue(
|
|
68
|
+
slot: TemplateFillSlot,
|
|
69
|
+
field: string,
|
|
70
|
+
): { resolved: boolean; value: string } {
|
|
71
|
+
if (slot.values && Object.prototype.hasOwnProperty.call(slot.values, field)) {
|
|
72
|
+
const value = slot.values[field]
|
|
73
|
+
return { resolved: true, value: value == null ? '' : String(value) }
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const entry = getEntityRegistryEntry(slot.entityType)
|
|
77
|
+
const tokenField = entry?.tokenFields.find((candidate) => candidate.field === field)
|
|
78
|
+
if (!tokenField || !slot.rawItem) return { resolved: false, value: '' }
|
|
79
|
+
const value = tokenField.extract(slot.rawItem)
|
|
80
|
+
return value == null ? { resolved: false, value: '' } : { resolved: true, value }
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function collectUnresolvedTokens(html: string): string[] {
|
|
84
|
+
const tokens = new Set<string>()
|
|
85
|
+
for (const match of html.matchAll(/{{\s*([^{}]+?)\s*}}/g)) {
|
|
86
|
+
const token = match[1]?.trim()
|
|
87
|
+
if (token) tokens.add(token)
|
|
88
|
+
}
|
|
89
|
+
const withoutValidTokens = html.replace(/{{\s*[^{}]+?\s*}}/g, '')
|
|
90
|
+
if (withoutValidTokens.includes('{{') || withoutValidTokens.includes('}}')) {
|
|
91
|
+
tokens.add('invalid-token-syntax')
|
|
92
|
+
}
|
|
93
|
+
return Array.from(tokens).sort((left, right) => left < right ? -1 : left > right ? 1 : 0)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export function renderTemplateTokens(
|
|
97
|
+
bodyHtml: string,
|
|
98
|
+
slots: TemplateFillSlot[],
|
|
99
|
+
options: FillTemplateTokensOptions = {},
|
|
100
|
+
): TemplateRenderResult {
|
|
101
|
+
const date = (options.now ?? new Date()).toLocaleDateString(options.locale, { timeZone: 'UTC' })
|
|
102
|
+
let filled = replaceToken(bodyHtml, 'date', escapeHtml(date))
|
|
103
|
+
|
|
104
|
+
for (const slot of slots) {
|
|
105
|
+
const entry = getEntityRegistryEntry(slot.entityType)
|
|
106
|
+
if (!entry) continue
|
|
107
|
+
|
|
108
|
+
const chip = buildEntityChip(slot)
|
|
109
|
+
if (chip != null) filled = replaceToken(filled, `${slot.slot}.chip`, chip)
|
|
110
|
+
|
|
111
|
+
for (const tokenField of entry.tokenFields) {
|
|
112
|
+
const resolved = resolveTokenValue(slot, tokenField.field)
|
|
113
|
+
if (!resolved.resolved) continue
|
|
114
|
+
filled = replaceToken(
|
|
115
|
+
filled,
|
|
116
|
+
`${slot.slot}.${tokenField.field}`,
|
|
117
|
+
escapeHtml(resolved.value),
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const unresolvedTokens = collectUnresolvedTokens(filled)
|
|
123
|
+
const html = unresolvedTokens.includes('invalid-token-syntax')
|
|
124
|
+
? ''
|
|
125
|
+
: filled
|
|
126
|
+
.replace(/{{\s*[^{}]+?\s*}}/g, '')
|
|
127
|
+
.replace(/ {2,}/g, ' ')
|
|
128
|
+
|
|
129
|
+
return { html, unresolvedTokens }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function fillTemplateTokens(
|
|
133
|
+
bodyHtml: string,
|
|
134
|
+
slots: TemplateFillSlot[],
|
|
135
|
+
options: FillTemplateTokensOptions = {},
|
|
136
|
+
): string {
|
|
137
|
+
return renderTemplateTokens(bodyHtml, slots, options).html
|
|
138
|
+
}
|