@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,248 @@
|
|
|
1
|
+
import { LockMode } from "@mikro-orm/core";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { findOneWithDecryption } from "@open-mercato/shared/lib/encryption/find";
|
|
4
|
+
import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
|
|
5
|
+
import { assertOptimisticLock } from "@open-mercato/shared/lib/crud/optimistic-lock-command";
|
|
6
|
+
import { OPTIMISTIC_LOCK_CONFLICT_CODE } from "@open-mercato/shared/lib/crud/optimistic-lock-headers";
|
|
7
|
+
import { createLogger } from "@open-mercato/shared/lib/logger";
|
|
8
|
+
import { DocumentContent } from "../data/entities.js";
|
|
9
|
+
import { DOCUMENTS_ENTITY_IDS } from "./constants.js";
|
|
10
|
+
import { nextDocumentVersion } from "./versioning.js";
|
|
11
|
+
import { assertDocumentContentResourceLimits } from "./resourceLimits.js";
|
|
12
|
+
const logger = createLogger("documents").child({ component: "content-service" });
|
|
13
|
+
function normalizeDocumentCollaborationGeneration(value) {
|
|
14
|
+
return typeof value === "number" && Number.isSafeInteger(value) && value >= 1 ? value : null;
|
|
15
|
+
}
|
|
16
|
+
function advanceDocumentCollaborationGeneration(content) {
|
|
17
|
+
const current = normalizeDocumentCollaborationGeneration(content.collaborationGeneration);
|
|
18
|
+
if (current === null || current >= Number.MAX_SAFE_INTEGER) {
|
|
19
|
+
throw new Error("[internal] document collaboration generation is invalid");
|
|
20
|
+
}
|
|
21
|
+
content.collaborationGeneration = current + 1;
|
|
22
|
+
return content.collaborationGeneration;
|
|
23
|
+
}
|
|
24
|
+
const ENTITY_MAP = {
|
|
25
|
+
amp: "&",
|
|
26
|
+
lt: "<",
|
|
27
|
+
gt: ">",
|
|
28
|
+
quot: '"',
|
|
29
|
+
apos: "'",
|
|
30
|
+
nbsp: " "
|
|
31
|
+
};
|
|
32
|
+
function decodeHtmlEntities(value) {
|
|
33
|
+
return value.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi, (match, token) => {
|
|
34
|
+
const named = ENTITY_MAP[token.toLowerCase()];
|
|
35
|
+
if (named) return named;
|
|
36
|
+
if (token.startsWith("#x") || token.startsWith("#X")) {
|
|
37
|
+
const parsed = Number.parseInt(token.slice(2), 16);
|
|
38
|
+
return Number.isFinite(parsed) ? String.fromCodePoint(parsed) : match;
|
|
39
|
+
}
|
|
40
|
+
if (token.startsWith("#")) {
|
|
41
|
+
const parsed = Number.parseInt(token.slice(1), 10);
|
|
42
|
+
return Number.isFinite(parsed) ? String.fromCodePoint(parsed) : match;
|
|
43
|
+
}
|
|
44
|
+
return match;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function deriveContentTextFromHtml(contentHtml) {
|
|
48
|
+
return decodeHtmlEntities(
|
|
49
|
+
contentHtml.replace(/<script[\s\S]*?<\/script>/gi, " ").replace(/<style[\s\S]*?<\/style>/gi, " ").replace(/<\/(p|div|section|article|header|footer|li|tr|h[1-6])>/gi, "\n").replace(/<br\s*\/?>/gi, "\n").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim()
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
async function loadDocumentContent(em, documentId, scope) {
|
|
53
|
+
return findOneWithDecryption(
|
|
54
|
+
em,
|
|
55
|
+
DocumentContent,
|
|
56
|
+
{
|
|
57
|
+
documentId,
|
|
58
|
+
tenantId: scope.tenantId,
|
|
59
|
+
organizationId: scope.organizationId,
|
|
60
|
+
deletedAt: null
|
|
61
|
+
},
|
|
62
|
+
void 0,
|
|
63
|
+
scope
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
async function loadDocumentContentForCollaboration(em, documentId, scope) {
|
|
67
|
+
return em.fork().transactional((transactionalEm) => findOneWithDecryption(
|
|
68
|
+
transactionalEm,
|
|
69
|
+
DocumentContent,
|
|
70
|
+
{
|
|
71
|
+
documentId,
|
|
72
|
+
tenantId: scope.tenantId,
|
|
73
|
+
organizationId: scope.organizationId,
|
|
74
|
+
deletedAt: null
|
|
75
|
+
},
|
|
76
|
+
{ lockMode: LockMode.PESSIMISTIC_READ },
|
|
77
|
+
scope
|
|
78
|
+
));
|
|
79
|
+
}
|
|
80
|
+
async function loadDocumentCollaborationGeneration(em, documentId, scope) {
|
|
81
|
+
const content = await findOneWithDecryption(
|
|
82
|
+
em,
|
|
83
|
+
DocumentContent,
|
|
84
|
+
{
|
|
85
|
+
documentId,
|
|
86
|
+
tenantId: scope.tenantId,
|
|
87
|
+
organizationId: scope.organizationId,
|
|
88
|
+
deletedAt: null
|
|
89
|
+
},
|
|
90
|
+
{ fields: ["collaborationGeneration"] },
|
|
91
|
+
scope
|
|
92
|
+
);
|
|
93
|
+
if (!content) return null;
|
|
94
|
+
return normalizeDocumentCollaborationGeneration(content.collaborationGeneration);
|
|
95
|
+
}
|
|
96
|
+
async function mutateDocumentContentState(em, documentId, scope, input, options = {}) {
|
|
97
|
+
assertDocumentContentResourceLimits(input);
|
|
98
|
+
let content = options.existingContent !== void 0 ? options.existingContent : await findOneWithDecryption(
|
|
99
|
+
em,
|
|
100
|
+
DocumentContent,
|
|
101
|
+
{ documentId, tenantId: scope.tenantId, organizationId: scope.organizationId },
|
|
102
|
+
{ filters: false },
|
|
103
|
+
scope
|
|
104
|
+
);
|
|
105
|
+
const requestedNow = options.now ?? /* @__PURE__ */ new Date();
|
|
106
|
+
const now = content ? nextDocumentVersion(content.updatedAt, requestedNow) : requestedNow;
|
|
107
|
+
if (!content) {
|
|
108
|
+
content = em.create(DocumentContent, {
|
|
109
|
+
id: options.id ?? randomUUID(),
|
|
110
|
+
documentId,
|
|
111
|
+
tenantId: scope.tenantId,
|
|
112
|
+
organizationId: scope.organizationId,
|
|
113
|
+
contentHtml: "",
|
|
114
|
+
contentText: "",
|
|
115
|
+
collaborationGeneration: 1,
|
|
116
|
+
updatedAt: now
|
|
117
|
+
});
|
|
118
|
+
em.persist(content);
|
|
119
|
+
} else if (options.id && content.id !== options.id) {
|
|
120
|
+
throw new Error("[internal] document content identity does not match the prepared aggregate");
|
|
121
|
+
}
|
|
122
|
+
const hasContentHtml = Object.prototype.hasOwnProperty.call(input, "contentHtml");
|
|
123
|
+
const hasContentText = Object.prototype.hasOwnProperty.call(input, "contentText");
|
|
124
|
+
if (hasContentHtml) content.contentHtml = input.contentHtml ?? "";
|
|
125
|
+
if (hasContentText) {
|
|
126
|
+
content.contentText = input.contentText ?? deriveContentTextFromHtml(content.contentHtml ?? "");
|
|
127
|
+
} else if (hasContentHtml) {
|
|
128
|
+
content.contentText = deriveContentTextFromHtml(content.contentHtml ?? "");
|
|
129
|
+
}
|
|
130
|
+
if (Object.prototype.hasOwnProperty.call(input, "yjsState")) {
|
|
131
|
+
content.yjsState = input.yjsState ?? null;
|
|
132
|
+
}
|
|
133
|
+
assertDocumentContentResourceLimits({
|
|
134
|
+
yjsState: content.yjsState,
|
|
135
|
+
contentHtml: content.contentHtml,
|
|
136
|
+
contentText: content.contentText
|
|
137
|
+
});
|
|
138
|
+
content.deletedAt = null;
|
|
139
|
+
content.updatedAt = now;
|
|
140
|
+
return content;
|
|
141
|
+
}
|
|
142
|
+
async function persistDocumentContent(em, documentId, scope, input, deps) {
|
|
143
|
+
const persisted = await em.fork().transactional(async (transactionalEm) => {
|
|
144
|
+
const current = await findOneWithDecryption(
|
|
145
|
+
transactionalEm,
|
|
146
|
+
DocumentContent,
|
|
147
|
+
{
|
|
148
|
+
documentId,
|
|
149
|
+
tenantId: scope.tenantId,
|
|
150
|
+
organizationId: scope.organizationId
|
|
151
|
+
},
|
|
152
|
+
{ filters: false, lockMode: LockMode.PESSIMISTIC_WRITE },
|
|
153
|
+
scope
|
|
154
|
+
);
|
|
155
|
+
if (deps.requireExpectedVersion && deps.expectedUpdatedAt === void 0) {
|
|
156
|
+
throw new Error("[internal] documents content CAS requires an expected version");
|
|
157
|
+
}
|
|
158
|
+
if (deps.requireExpectedVersion && normalizeDocumentCollaborationGeneration(deps.expectedCollaborationGeneration) === null) {
|
|
159
|
+
throw new Error("[internal] documents content CAS requires an expected collaboration generation");
|
|
160
|
+
}
|
|
161
|
+
if (deps.expectedCollaborationGeneration !== void 0) {
|
|
162
|
+
const currentGeneration = normalizeDocumentCollaborationGeneration(
|
|
163
|
+
current?.collaborationGeneration
|
|
164
|
+
);
|
|
165
|
+
if (currentGeneration === null || currentGeneration !== deps.expectedCollaborationGeneration) {
|
|
166
|
+
throw new CrudHttpError(409, {
|
|
167
|
+
error: "Record changed by another user",
|
|
168
|
+
code: OPTIMISTIC_LOCK_CONFLICT_CODE,
|
|
169
|
+
currentCollaborationGeneration: currentGeneration,
|
|
170
|
+
expectedCollaborationGeneration: deps.expectedCollaborationGeneration
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
if (deps.expectedUpdatedAt !== void 0) {
|
|
175
|
+
if (!current) {
|
|
176
|
+
throw new Error("[internal] documents content changed after the collaboration room loaded");
|
|
177
|
+
}
|
|
178
|
+
assertOptimisticLock({
|
|
179
|
+
resourceKind: DOCUMENTS_ENTITY_IDS.documentContent,
|
|
180
|
+
resourceId: current.id,
|
|
181
|
+
current: current.updatedAt,
|
|
182
|
+
expected: deps.expectedUpdatedAt,
|
|
183
|
+
...deps.requireExpectedVersion ? { envValue: "all" } : {}
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
const previousUpdatedAt = current?.updatedAt.getTime() ?? null;
|
|
187
|
+
const content = await mutateDocumentContentState(
|
|
188
|
+
transactionalEm,
|
|
189
|
+
documentId,
|
|
190
|
+
scope,
|
|
191
|
+
input,
|
|
192
|
+
{ existingContent: current }
|
|
193
|
+
);
|
|
194
|
+
await transactionalEm.flush();
|
|
195
|
+
let persistedUpdatedAt = new Date(content.updatedAt.getTime());
|
|
196
|
+
if (previousUpdatedAt !== null && persistedUpdatedAt.getTime() <= previousUpdatedAt) {
|
|
197
|
+
persistedUpdatedAt = new Date(previousUpdatedAt + 1);
|
|
198
|
+
const affected = await transactionalEm.nativeUpdate(
|
|
199
|
+
DocumentContent,
|
|
200
|
+
{
|
|
201
|
+
id: content.id,
|
|
202
|
+
documentId,
|
|
203
|
+
tenantId: scope.tenantId,
|
|
204
|
+
organizationId: scope.organizationId
|
|
205
|
+
},
|
|
206
|
+
{ updatedAt: persistedUpdatedAt }
|
|
207
|
+
);
|
|
208
|
+
if (affected !== 1) {
|
|
209
|
+
throw new Error("[internal] documents content version could not be advanced");
|
|
210
|
+
}
|
|
211
|
+
content.updatedAt = persistedUpdatedAt;
|
|
212
|
+
}
|
|
213
|
+
const collaborationGeneration = normalizeDocumentCollaborationGeneration(
|
|
214
|
+
content.collaborationGeneration
|
|
215
|
+
);
|
|
216
|
+
if (collaborationGeneration === null) {
|
|
217
|
+
throw new Error("[internal] document collaboration generation is invalid");
|
|
218
|
+
}
|
|
219
|
+
return { id: content.id, updatedAt: persistedUpdatedAt, collaborationGeneration };
|
|
220
|
+
});
|
|
221
|
+
try {
|
|
222
|
+
await deps.searchIndexer?.indexRecordById({
|
|
223
|
+
entityId: DOCUMENTS_ENTITY_IDS.document,
|
|
224
|
+
recordId: documentId,
|
|
225
|
+
tenantId: scope.tenantId,
|
|
226
|
+
organizationId: scope.organizationId
|
|
227
|
+
});
|
|
228
|
+
} catch (error) {
|
|
229
|
+
logger.error("Content search indexing failed after commit", {
|
|
230
|
+
documentId,
|
|
231
|
+
tenantId: scope.tenantId,
|
|
232
|
+
organizationId: scope.organizationId,
|
|
233
|
+
err: error
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
return persisted;
|
|
237
|
+
}
|
|
238
|
+
export {
|
|
239
|
+
advanceDocumentCollaborationGeneration,
|
|
240
|
+
deriveContentTextFromHtml,
|
|
241
|
+
loadDocumentCollaborationGeneration,
|
|
242
|
+
loadDocumentContent,
|
|
243
|
+
loadDocumentContentForCollaboration,
|
|
244
|
+
mutateDocumentContentState,
|
|
245
|
+
normalizeDocumentCollaborationGeneration,
|
|
246
|
+
persistDocumentContent
|
|
247
|
+
};
|
|
248
|
+
//# sourceMappingURL=contentService.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/documents/lib/contentService.ts"],
|
|
4
|
+
"sourcesContent": ["import type { EntityManager } from '@mikro-orm/postgresql'\nimport { LockMode } from '@mikro-orm/core'\nimport { randomUUID } from 'node:crypto'\nimport { findOneWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport { assertOptimisticLock } from '@open-mercato/shared/lib/crud/optimistic-lock-command'\nimport { OPTIMISTIC_LOCK_CONFLICT_CODE } from '@open-mercato/shared/lib/crud/optimistic-lock-headers'\nimport { createLogger } from '@open-mercato/shared/lib/logger'\nimport { DocumentContent } from '../data/entities'\nimport { DOCUMENTS_ENTITY_IDS } from './constants'\nimport { nextDocumentVersion } from './versioning'\nimport { assertDocumentContentResourceLimits } from './resourceLimits'\n\nconst logger = createLogger('documents').child({ component: 'content-service' })\n\nexport type DocumentScope = {\n tenantId: string\n organizationId: string\n}\n\nexport type DocumentContentSearchIndexer = {\n indexRecordById: (params: {\n entityId: string\n recordId: string\n tenantId: string\n organizationId?: string | null\n }) => Promise<unknown>\n}\n\nexport type PersistDocumentContentDeps = {\n searchIndexer?: DocumentContentSearchIndexer | null\n /**\n * Content version observed by the writer before it prepared this mutation.\n * When present, the comparison happens while holding the content-row lock.\n */\n expectedUpdatedAt?: string | Date\n /** Server-owned collaborative lineage observed when the room loaded. */\n expectedCollaborationGeneration?: number\n /** Sidecar CAS must remain active even if user-facing optimistic locks are disabled. */\n requireExpectedVersion?: boolean\n}\n\nexport type PersistedDocumentContent = {\n id: string\n updatedAt: Date\n collaborationGeneration: number\n}\n\nexport function normalizeDocumentCollaborationGeneration(value: unknown): number | null {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 1\n ? value\n : null\n}\n\nexport function advanceDocumentCollaborationGeneration(content: DocumentContent): number {\n const current = normalizeDocumentCollaborationGeneration(content.collaborationGeneration)\n if (current === null || current >= Number.MAX_SAFE_INTEGER) {\n throw new Error('[internal] document collaboration generation is invalid')\n }\n content.collaborationGeneration = current + 1\n return content.collaborationGeneration\n}\n\nconst ENTITY_MAP: Record<string, string> = {\n amp: '&',\n lt: '<',\n gt: '>',\n quot: '\"',\n apos: \"'\",\n nbsp: ' ',\n}\n\nfunction decodeHtmlEntities(value: string): string {\n return value.replace(/&(#x?[0-9a-f]+|[a-z]+);/gi, (match, token: string) => {\n const named = ENTITY_MAP[token.toLowerCase()]\n if (named) return named\n if (token.startsWith('#x') || token.startsWith('#X')) {\n const parsed = Number.parseInt(token.slice(2), 16)\n return Number.isFinite(parsed) ? String.fromCodePoint(parsed) : match\n }\n if (token.startsWith('#')) {\n const parsed = Number.parseInt(token.slice(1), 10)\n return Number.isFinite(parsed) ? String.fromCodePoint(parsed) : match\n }\n return match\n })\n}\n\nexport function deriveContentTextFromHtml(contentHtml: string): string {\n return decodeHtmlEntities(\n contentHtml\n .replace(/<script[\\s\\S]*?<\\/script>/gi, ' ')\n .replace(/<style[\\s\\S]*?<\\/style>/gi, ' ')\n .replace(/<\\/(p|div|section|article|header|footer|li|tr|h[1-6])>/gi, '\\n')\n .replace(/<br\\s*\\/?>/gi, '\\n')\n .replace(/<[^>]+>/g, ' ')\n .replace(/\\s+/g, ' ')\n .trim(),\n )\n}\n\nexport async function loadDocumentContent(\n em: EntityManager,\n documentId: string,\n scope: DocumentScope,\n): Promise<DocumentContent | null> {\n return findOneWithDecryption(\n em,\n DocumentContent,\n {\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n deletedAt: null,\n },\n undefined,\n scope,\n )\n}\n\n/**\n * Read the exact collaboration state/version/generation tuple from an\n * isolated transaction. The short pessimistic read lock prevents observing a\n * partially completed authoritative reset while a room is being loaded or a\n * competing replica is reconciling after a CAS loss.\n */\nexport async function loadDocumentContentForCollaboration(\n em: EntityManager,\n documentId: string,\n scope: DocumentScope,\n): Promise<DocumentContent | null> {\n return em.fork().transactional((transactionalEm) => findOneWithDecryption(\n transactionalEm,\n DocumentContent,\n {\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n deletedAt: null,\n },\n { lockMode: LockMode.PESSIMISTIC_READ },\n scope,\n ))\n}\n\n/**\n * Lightweight active-room reconciliation probe. A missing row means the\n * scoped content was deleted; normal collaborative stores retain the same\n * generation while authoritative replacements advance it.\n */\nexport async function loadDocumentCollaborationGeneration(\n em: EntityManager,\n documentId: string,\n scope: DocumentScope,\n): Promise<number | null> {\n const content = await findOneWithDecryption(\n em,\n DocumentContent,\n {\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n deletedAt: null,\n },\n { fields: ['collaborationGeneration'] },\n scope,\n )\n if (!content) return null\n return normalizeDocumentCollaborationGeneration(content.collaborationGeneration)\n}\n\nexport async function mutateDocumentContentState(\n em: EntityManager,\n documentId: string,\n scope: DocumentScope,\n input: { yjsState?: Buffer | null; contentHtml?: string | null; contentText?: string | null },\n options: { id?: string; now?: Date; existingContent?: DocumentContent | null } = {},\n): Promise<DocumentContent> {\n assertDocumentContentResourceLimits(input)\n let content = options.existingContent !== undefined\n ? options.existingContent\n : await findOneWithDecryption(\n em,\n DocumentContent,\n { documentId, tenantId: scope.tenantId, organizationId: scope.organizationId },\n { filters: false },\n scope,\n )\n const requestedNow = options.now ?? new Date()\n const now = content ? nextDocumentVersion(content.updatedAt, requestedNow) : requestedNow\n if (!content) {\n content = em.create(DocumentContent, {\n id: options.id ?? randomUUID(),\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n contentHtml: '',\n contentText: '',\n collaborationGeneration: 1,\n updatedAt: now,\n })\n em.persist(content)\n } else if (options.id && content.id !== options.id) {\n throw new Error('[internal] document content identity does not match the prepared aggregate')\n }\n\n const hasContentHtml = Object.prototype.hasOwnProperty.call(input, 'contentHtml')\n const hasContentText = Object.prototype.hasOwnProperty.call(input, 'contentText')\n if (hasContentHtml) content.contentHtml = input.contentHtml ?? ''\n if (hasContentText) {\n content.contentText = input.contentText ?? deriveContentTextFromHtml(content.contentHtml ?? '')\n } else if (hasContentHtml) {\n content.contentText = deriveContentTextFromHtml(content.contentHtml ?? '')\n }\n if (Object.prototype.hasOwnProperty.call(input, 'yjsState')) {\n content.yjsState = input.yjsState ?? null\n }\n assertDocumentContentResourceLimits({\n yjsState: content.yjsState,\n contentHtml: content.contentHtml,\n contentText: content.contentText,\n })\n content.deletedAt = null\n content.updatedAt = now\n return content\n}\n\nexport async function persistDocumentContent(\n em: EntityManager,\n documentId: string,\n scope: DocumentScope,\n input: { yjsState?: Buffer | null; contentHtml?: string | null; contentText?: string | null },\n deps: PersistDocumentContentDeps,\n): Promise<PersistedDocumentContent> {\n // Collaboration stores must not reuse a request identity map: every attempt\n // gets a fresh EM, transaction, and row lock before checking both CAS axes.\n const persisted = await em.fork().transactional(async (transactionalEm) => {\n const current = await findOneWithDecryption(\n transactionalEm,\n DocumentContent,\n {\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n },\n { filters: false, lockMode: LockMode.PESSIMISTIC_WRITE },\n scope,\n )\n\n if (deps.requireExpectedVersion && deps.expectedUpdatedAt === undefined) {\n throw new Error('[internal] documents content CAS requires an expected version')\n }\n if (\n deps.requireExpectedVersion\n && normalizeDocumentCollaborationGeneration(deps.expectedCollaborationGeneration) === null\n ) {\n throw new Error('[internal] documents content CAS requires an expected collaboration generation')\n }\n if (deps.expectedCollaborationGeneration !== undefined) {\n const currentGeneration = normalizeDocumentCollaborationGeneration(\n current?.collaborationGeneration,\n )\n if (currentGeneration === null || currentGeneration !== deps.expectedCollaborationGeneration) {\n throw new CrudHttpError(409, {\n error: 'Record changed by another user',\n code: OPTIMISTIC_LOCK_CONFLICT_CODE,\n currentCollaborationGeneration: currentGeneration,\n expectedCollaborationGeneration: deps.expectedCollaborationGeneration,\n })\n }\n }\n if (deps.expectedUpdatedAt !== undefined) {\n if (!current) {\n throw new Error('[internal] documents content changed after the collaboration room loaded')\n }\n assertOptimisticLock({\n resourceKind: DOCUMENTS_ENTITY_IDS.documentContent,\n resourceId: current.id,\n current: current.updatedAt,\n expected: deps.expectedUpdatedAt,\n ...(deps.requireExpectedVersion ? { envValue: 'all' } : {}),\n })\n }\n\n const previousUpdatedAt = current?.updatedAt.getTime() ?? null\n const content = await mutateDocumentContentState(\n transactionalEm,\n documentId,\n scope,\n input,\n { existingContent: current },\n )\n await transactionalEm.flush()\n let persistedUpdatedAt = new Date(content.updatedAt.getTime())\n if (previousUpdatedAt !== null && persistedUpdatedAt.getTime() <= previousUpdatedAt) {\n persistedUpdatedAt = new Date(previousUpdatedAt + 1)\n const affected = await transactionalEm.nativeUpdate(\n DocumentContent,\n {\n id: content.id,\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n },\n { updatedAt: persistedUpdatedAt },\n )\n if (affected !== 1) {\n throw new Error('[internal] documents content version could not be advanced')\n }\n content.updatedAt = persistedUpdatedAt\n }\n const collaborationGeneration = normalizeDocumentCollaborationGeneration(\n content.collaborationGeneration,\n )\n if (collaborationGeneration === null) {\n throw new Error('[internal] document collaboration generation is invalid')\n }\n return { id: content.id, updatedAt: persistedUpdatedAt, collaborationGeneration }\n })\n\n try {\n await deps.searchIndexer?.indexRecordById({\n entityId: DOCUMENTS_ENTITY_IDS.document,\n recordId: documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n })\n } catch (error) {\n // The content transaction is already committed. Search is a retryable\n // projection and must not make Hocuspocus retain a stale CAS token or tell\n // an HTTP caller that the canonical write failed.\n logger.error('Content search indexing failed after commit', {\n documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n err: error,\n })\n }\n return persisted\n}\n"],
|
|
5
|
+
"mappings": "AACA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAC3B,SAAS,6BAA6B;AACtC,SAAS,qBAAqB;AAC9B,SAAS,4BAA4B;AACrC,SAAS,qCAAqC;AAC9C,SAAS,oBAAoB;AAC7B,SAAS,uBAAuB;AAChC,SAAS,4BAA4B;AACrC,SAAS,2BAA2B;AACpC,SAAS,2CAA2C;AAEpD,MAAM,SAAS,aAAa,WAAW,EAAE,MAAM,EAAE,WAAW,kBAAkB,CAAC;AAmCxE,SAAS,yCAAyC,OAA+B;AACtF,SAAO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ACxB;AAAA,QACA,EAAE,WAAW,mBAAmB;AAAA,MAClC;AACA,UAAI,aAAa,GAAG;AAClB,cAAM,IAAI,MAAM,4DAA4D;AAAA,MAC9E;AACA,cAAQ,YAAY;AAAA,IACtB;AACA,UAAM,0BAA0B;AAAA,MAC9B,QAAQ;AAAA,IACV;AACA,QAAI,4BAA4B,MAAM;AACpC,YAAM,IAAI,MAAM,yDAAyD;AAAA,IAC3E;AACA,WAAO,EAAE,IAAI,QAAQ,IAAI,WAAW,oBAAoB,wBAAwB;AAAA,EAClF,CAAC;AAED,MAAI;AACF,UAAM,KAAK,eAAe,gBAAgB;AAAA,MACxC,UAAU,qBAAqB;AAAA,MAC/B,UAAU;AAAA,MACV,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,IACxB,CAAC;AAAA,EACH,SAAS,OAAO;AAId,WAAO,MAAM,+CAA+C;AAAA,MAC1D;AAAA,MACA,UAAU,MAAM;AAAA,MAChB,gBAAgB,MAAM;AAAA,MACtB,KAAK;AAAA,IACP,CAAC;AAAA,EACH;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const CANONICAL_UUID_ANYWHERE_PATTERN = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i;
|
|
2
|
+
function containsCanonicalUuid(value) {
|
|
3
|
+
return typeof value === "string" && CANONICAL_UUID_ANYWHERE_PATTERN.test(value);
|
|
4
|
+
}
|
|
5
|
+
function sanitizeDocumentsDisplayLabel(value) {
|
|
6
|
+
if (typeof value !== "string") return null;
|
|
7
|
+
const normalized = value.trim();
|
|
8
|
+
if (!normalized || containsCanonicalUuid(normalized)) return null;
|
|
9
|
+
return normalized;
|
|
10
|
+
}
|
|
11
|
+
function firstSafeDocumentsDisplayLabel(...values) {
|
|
12
|
+
for (const value of values) {
|
|
13
|
+
const safe = sanitizeDocumentsDisplayLabel(value);
|
|
14
|
+
if (safe) return safe;
|
|
15
|
+
}
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
containsCanonicalUuid,
|
|
20
|
+
firstSafeDocumentsDisplayLabel,
|
|
21
|
+
sanitizeDocumentsDisplayLabel
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=displayLabels.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/modules/documents/lib/displayLabels.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * Canonical UUIDs are internal identifiers, regardless of their version nibble.\n * A system-owned display label containing one is unsafe because even otherwise\n * readable text can accidentally expose a record id (for example\n * `Customer 123e4567-e89b-12d3-a456-426614174000`).\n */\nconst CANONICAL_UUID_ANYWHERE_PATTERN =\n /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/i\n\nexport function containsCanonicalUuid(value: unknown): boolean {\n return typeof value === 'string' && CANONICAL_UUID_ANYWHERE_PATTERN.test(value)\n}\n\n/**\n * Normalize a candidate that will be rendered as a system-owned label.\n * Document prose is intentionally outside this boundary and is never censored.\n */\nexport function sanitizeDocumentsDisplayLabel(value: unknown): string | null {\n if (typeof value !== 'string') return null\n const normalized = value.trim()\n if (!normalized || containsCanonicalUuid(normalized)) return null\n return normalized\n}\n\nexport function firstSafeDocumentsDisplayLabel(...values: unknown[]): string | null {\n for (const value of values) {\n const safe = sanitizeDocumentsDisplayLabel(value)\n if (safe) return safe\n }\n return null\n}\n"],
|
|
5
|
+
"mappings": "AAMA,MAAM,kCACJ;AAEK,SAAS,sBAAsB,OAAyB;AAC7D,SAAO,OAAO,UAAU,YAAY,gCAAgC,KAAK,KAAK;AAChF;AAMO,SAAS,8BAA8B,OAA+B;AAC3E,MAAI,OAAO,UAAU,SAAU,QAAO;AACtC,QAAM,aAAa,MAAM,KAAK;AAC9B,MAAI,CAAC,cAAc,sBAAsB,UAAU,EAAG,QAAO;AAC7D,SAAO;AACT;AAEO,SAAS,kCAAkC,QAAkC;AAClF,aAAW,SAAS,QAAQ;AAC1B,UAAM,OAAO,8BAA8B,KAAK;AAChD,QAAI,KAAM,QAAO;AAAA,EACnB;AACA,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|