@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,267 @@
|
|
|
1
|
+
import { CrudHttpError, isCrudHttpError } from '@open-mercato/shared/lib/crud/errors'
|
|
2
|
+
import {
|
|
3
|
+
fetchWithTimeout,
|
|
4
|
+
type FetchWithTimeoutInit,
|
|
5
|
+
resolveTimeoutMs,
|
|
6
|
+
withTimeout,
|
|
7
|
+
} from '@open-mercato/shared/lib/http/fetchWithTimeout'
|
|
8
|
+
import { getSecurityEmailBaseUrl } from '@open-mercato/shared/lib/url'
|
|
9
|
+
import type { DocumentEntityType } from '../data/validators'
|
|
10
|
+
import {
|
|
11
|
+
getEntityRegistryEntry,
|
|
12
|
+
readItemsArray,
|
|
13
|
+
type EntityPickerItem,
|
|
14
|
+
} from './entityRegistry'
|
|
15
|
+
import { isDocumentEntityRegistryModuleEnabled } from './entityRegistryAvailability.server'
|
|
16
|
+
|
|
17
|
+
export type VerifyEntityRegistrySelectionInput = {
|
|
18
|
+
entityType: DocumentEntityType
|
|
19
|
+
entityId: string
|
|
20
|
+
label: string
|
|
21
|
+
href: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export type VerifyEntityRegistryTargetAccessInput = Pick<
|
|
25
|
+
VerifyEntityRegistrySelectionInput,
|
|
26
|
+
'entityType' | 'entityId'
|
|
27
|
+
>
|
|
28
|
+
|
|
29
|
+
export type VerifiedEntityRegistrySelection = EntityPickerItem & {
|
|
30
|
+
href: string
|
|
31
|
+
values: Record<string, string | null>
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type RegistryFetch = (
|
|
35
|
+
input: RequestInfo | URL,
|
|
36
|
+
init?: FetchWithTimeoutInit,
|
|
37
|
+
) => Promise<Response>
|
|
38
|
+
|
|
39
|
+
const DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS = 3_000
|
|
40
|
+
const MAX_REGISTRY_RESPONSE_BYTES = 1_000_000
|
|
41
|
+
|
|
42
|
+
async function readRegistryJsonBody(
|
|
43
|
+
response: Response,
|
|
44
|
+
callerSignal: AbortSignal,
|
|
45
|
+
timeoutMs: number,
|
|
46
|
+
): Promise<unknown> {
|
|
47
|
+
return withTimeout(async (timeoutSignal) => {
|
|
48
|
+
const signals = [callerSignal, timeoutSignal]
|
|
49
|
+
for (const signal of signals) {
|
|
50
|
+
if (signal.aborted) {
|
|
51
|
+
throw signal.reason instanceof Error
|
|
52
|
+
? signal.reason
|
|
53
|
+
: new DOMException('Aborted', 'AbortError')
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const reader = response.body?.getReader()
|
|
58
|
+
if (!reader) return null
|
|
59
|
+
let aborted: unknown = null
|
|
60
|
+
const listeners = signals.map((signal) => {
|
|
61
|
+
let handled = false
|
|
62
|
+
const listener = () => {
|
|
63
|
+
if (handled) return
|
|
64
|
+
handled = true
|
|
65
|
+
aborted = signal.reason instanceof Error
|
|
66
|
+
? signal.reason
|
|
67
|
+
: new DOMException('Aborted', 'AbortError')
|
|
68
|
+
void reader.cancel(aborted).catch(() => undefined)
|
|
69
|
+
}
|
|
70
|
+
signal.addEventListener('abort', listener, { once: true })
|
|
71
|
+
if (signal.aborted) listener()
|
|
72
|
+
return { signal, listener }
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const decoder = new TextDecoder()
|
|
76
|
+
let decoded = ''
|
|
77
|
+
let totalBytes = 0
|
|
78
|
+
try {
|
|
79
|
+
while (true) {
|
|
80
|
+
const { done, value } = await reader.read()
|
|
81
|
+
if (done) break
|
|
82
|
+
totalBytes += value.byteLength
|
|
83
|
+
if (totalBytes > MAX_REGISTRY_RESPONSE_BYTES) {
|
|
84
|
+
await reader.cancel().catch(() => undefined)
|
|
85
|
+
throw new Error('[internal] Entity registry response exceeded the size limit')
|
|
86
|
+
}
|
|
87
|
+
decoded += decoder.decode(value, { stream: true })
|
|
88
|
+
}
|
|
89
|
+
if (aborted) throw aborted
|
|
90
|
+
decoded += decoder.decode()
|
|
91
|
+
} finally {
|
|
92
|
+
for (const { signal, listener } of listeners) {
|
|
93
|
+
signal.removeEventListener('abort', listener)
|
|
94
|
+
}
|
|
95
|
+
reader.releaseLock()
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
return JSON.parse(decoded) as unknown
|
|
100
|
+
} catch {
|
|
101
|
+
return null
|
|
102
|
+
}
|
|
103
|
+
}, timeoutMs, 'documents entity-registry response')
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function buildForwardedHeaders(request: Request): Headers {
|
|
107
|
+
const headers = new Headers()
|
|
108
|
+
const cookie = request.headers.get('cookie')
|
|
109
|
+
const authorization = request.headers.get('authorization')
|
|
110
|
+
const apiKey = request.headers.get('x-api-key')
|
|
111
|
+
if (cookie) headers.set('cookie', cookie)
|
|
112
|
+
if (authorization) headers.set('authorization', authorization)
|
|
113
|
+
if (apiKey) headers.set('x-api-key', apiKey)
|
|
114
|
+
return headers
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
type RegistryVerificationOptions = {
|
|
118
|
+
fetchImpl?: RegistryFetch
|
|
119
|
+
timeoutMs?: number
|
|
120
|
+
maskTargetAbsence?: boolean
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async function verifyEntityRegistryTarget(
|
|
124
|
+
request: Request,
|
|
125
|
+
input: VerifyEntityRegistryTargetAccessInput,
|
|
126
|
+
options: RegistryVerificationOptions = {},
|
|
127
|
+
): Promise<VerifiedEntityRegistrySelection> {
|
|
128
|
+
const entry = getEntityRegistryEntry(input.entityType)
|
|
129
|
+
if (!entry) {
|
|
130
|
+
throw new CrudHttpError(400, { error: 'documents.links.invalidEntityType' })
|
|
131
|
+
}
|
|
132
|
+
if (!isDocumentEntityRegistryModuleEnabled(entry)) {
|
|
133
|
+
throw new CrudHttpError(503, { error: 'documents.links.targetUnavailable' })
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const timeoutMs = Math.min(
|
|
137
|
+
resolveTimeoutMs(options.timeoutMs, DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS),
|
|
138
|
+
DEFAULT_REGISTRY_LOOKUP_TIMEOUT_MS,
|
|
139
|
+
)
|
|
140
|
+
const deadline = Date.now() + timeoutMs
|
|
141
|
+
let response: Response
|
|
142
|
+
try {
|
|
143
|
+
// This request carries the caller's credentials, so its destination must
|
|
144
|
+
// come from the configured application URL rather than request.url/Host.
|
|
145
|
+
// getSecurityEmailBaseUrl intentionally has a fixed loopback development
|
|
146
|
+
// fallback and requires APP_URL in production.
|
|
147
|
+
const lookupUrl = new URL(entry.searchPath, getSecurityEmailBaseUrl())
|
|
148
|
+
lookupUrl.searchParams.set('id', input.entityId)
|
|
149
|
+
lookupUrl.searchParams.set('pageSize', '1')
|
|
150
|
+
const fetchImpl = options.fetchImpl ?? fetchWithTimeout
|
|
151
|
+
response = await fetchImpl(lookupUrl, {
|
|
152
|
+
method: 'GET',
|
|
153
|
+
headers: buildForwardedHeaders(request),
|
|
154
|
+
cache: 'no-store',
|
|
155
|
+
redirect: 'manual',
|
|
156
|
+
signal: request.signal,
|
|
157
|
+
timeoutMs,
|
|
158
|
+
})
|
|
159
|
+
} catch {
|
|
160
|
+
throw new CrudHttpError(503, { error: 'documents.links.targetUnavailable' })
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (response.status === 404) {
|
|
164
|
+
throw new CrudHttpError(options.maskTargetAbsence ? 403 : 503, {
|
|
165
|
+
error: options.maskTargetAbsence
|
|
166
|
+
? 'documents.links.targetRestricted'
|
|
167
|
+
: 'documents.links.targetUnavailable',
|
|
168
|
+
})
|
|
169
|
+
}
|
|
170
|
+
if (response.status >= 500) {
|
|
171
|
+
throw new CrudHttpError(503, { error: 'documents.links.targetUnavailable' })
|
|
172
|
+
}
|
|
173
|
+
if (!response.ok) {
|
|
174
|
+
throw new CrudHttpError(response.status === 401 ? 401 : 403, {
|
|
175
|
+
error: 'documents.links.targetRestricted',
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let payload: unknown
|
|
180
|
+
try {
|
|
181
|
+
payload = await readRegistryJsonBody(
|
|
182
|
+
response,
|
|
183
|
+
request.signal,
|
|
184
|
+
Math.max(1, deadline - Date.now()),
|
|
185
|
+
)
|
|
186
|
+
} catch {
|
|
187
|
+
throw new CrudHttpError(503, { error: 'documents.links.targetUnavailable' })
|
|
188
|
+
}
|
|
189
|
+
const rawItem = readItemsArray(payload).find((candidate) => (
|
|
190
|
+
entry.mapItem(candidate)?.id === input.entityId
|
|
191
|
+
)) ?? null
|
|
192
|
+
const mapped = rawItem ? entry.mapItem(rawItem) : null
|
|
193
|
+
const resolvedHref = mapped ? entry.resolveHref(mapped) : null
|
|
194
|
+
if (!mapped || !rawItem || !resolvedHref || !entry.isCanonicalHref(mapped, resolvedHref)) {
|
|
195
|
+
throw new CrudHttpError(options.maskTargetAbsence ? 403 : 400, {
|
|
196
|
+
error: options.maskTargetAbsence
|
|
197
|
+
? 'documents.links.targetRestricted'
|
|
198
|
+
: 'documents.links.targetMismatch',
|
|
199
|
+
})
|
|
200
|
+
}
|
|
201
|
+
return {
|
|
202
|
+
...mapped,
|
|
203
|
+
href: resolvedHref,
|
|
204
|
+
values: Object.fromEntries(entry.tokenFields.map((field) => [field.field, field.extract(rawItem)])),
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export async function verifyEntityRegistrySelection(
|
|
209
|
+
request: Request,
|
|
210
|
+
input: VerifyEntityRegistrySelectionInput,
|
|
211
|
+
options: { fetchImpl?: RegistryFetch; timeoutMs?: number } = {},
|
|
212
|
+
): Promise<VerifiedEntityRegistrySelection> {
|
|
213
|
+
return verifyEntityRegistryTarget(request, input, options)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Verify access to one exact peer record before using its UUID as a reverse
|
|
218
|
+
* relation filter. Missing and restricted targets intentionally share the same
|
|
219
|
+
* denial so the Documents collection cannot become a peer-record oracle.
|
|
220
|
+
*/
|
|
221
|
+
export async function verifyEntityRegistryTargetAccess(
|
|
222
|
+
request: Request,
|
|
223
|
+
input: VerifyEntityRegistryTargetAccessInput,
|
|
224
|
+
options: { fetchImpl?: RegistryFetch; timeoutMs?: number } = {},
|
|
225
|
+
): Promise<VerifiedEntityRegistrySelection> {
|
|
226
|
+
try {
|
|
227
|
+
return await verifyEntityRegistryTarget(request, input, {
|
|
228
|
+
...options,
|
|
229
|
+
maskTargetAbsence: true,
|
|
230
|
+
})
|
|
231
|
+
} catch (error) {
|
|
232
|
+
if (isCrudHttpError(error) && error.status >= 400 && error.status < 500) {
|
|
233
|
+
throw new CrudHttpError(403, { error: 'documents.links.targetRestricted' })
|
|
234
|
+
}
|
|
235
|
+
throw error
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export async function verifyEntityRegistrySelections(
|
|
240
|
+
request: Request,
|
|
241
|
+
inputs: VerifyEntityRegistrySelectionInput[],
|
|
242
|
+
options: { fetchImpl?: RegistryFetch; concurrency?: number; timeoutMs?: number } = {},
|
|
243
|
+
): Promise<Map<string, VerifiedEntityRegistrySelection>> {
|
|
244
|
+
const deduped = Array.from(
|
|
245
|
+
new Map(inputs.map((input) => [`${input.entityType}:${input.entityId}`, input])).values(),
|
|
246
|
+
)
|
|
247
|
+
if (deduped.length > 20) {
|
|
248
|
+
throw new CrudHttpError(400, { error: 'documents.templates.tooManySlots' })
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const concurrency = Math.max(1, Math.min(4, options.concurrency ?? 4))
|
|
252
|
+
const verified = new Map<string, VerifiedEntityRegistrySelection>()
|
|
253
|
+
let nextIndex = 0
|
|
254
|
+
const workers = Array.from({ length: Math.min(concurrency, deduped.length) }, async () => {
|
|
255
|
+
while (nextIndex < deduped.length) {
|
|
256
|
+
const index = nextIndex
|
|
257
|
+
nextIndex += 1
|
|
258
|
+
const input = deduped[index]!
|
|
259
|
+
verified.set(
|
|
260
|
+
`${input.entityType}:${input.entityId}`,
|
|
261
|
+
await verifyEntityRegistrySelection(request, input, options),
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
})
|
|
265
|
+
await Promise.all(workers)
|
|
266
|
+
return verified
|
|
267
|
+
}
|
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import type { DocumentEntityType } from '../data/validators'
|
|
2
|
+
import {
|
|
3
|
+
firstSafeDocumentsDisplayLabel,
|
|
4
|
+
sanitizeDocumentsDisplayLabel,
|
|
5
|
+
} from './displayLabels'
|
|
6
|
+
|
|
7
|
+
export type { DocumentEntityType } from '../data/validators'
|
|
8
|
+
|
|
9
|
+
export type EntityPickerItem = {
|
|
10
|
+
id: string
|
|
11
|
+
label: string
|
|
12
|
+
subtitle?: string
|
|
13
|
+
href?: string
|
|
14
|
+
archivedAt?: string | null
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export type EntityTokenField = {
|
|
18
|
+
field: string
|
|
19
|
+
labelKey: string
|
|
20
|
+
extract: (item: Record<string, unknown>) => string | null
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type EntityRegistryEntry = {
|
|
24
|
+
type: DocumentEntityType
|
|
25
|
+
labelKey: string
|
|
26
|
+
searchPath: string
|
|
27
|
+
mapItem: (item: Record<string, unknown>) => EntityPickerItem | null
|
|
28
|
+
href: (id: string) => string
|
|
29
|
+
tokenFields: EntityTokenField[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Internal registry contract used by Documents integrations. Keep the
|
|
34
|
+
* long-standing EntityRegistryEntry shape above assignable for deep-import
|
|
35
|
+
* consumers while requiring every built-in entry to declare its capability
|
|
36
|
+
* and canonical-link policy.
|
|
37
|
+
*/
|
|
38
|
+
export type DocumentEntityRegistryEntry = EntityRegistryEntry & {
|
|
39
|
+
resolveHref: (item: EntityPickerItem) => string | null
|
|
40
|
+
isCanonicalHref: (item: Pick<EntityPickerItem, 'id' | 'href'>, href: string) => boolean
|
|
41
|
+
requiredModule: string
|
|
42
|
+
/**
|
|
43
|
+
* Module that owns `requiredFeature`. This is usually the same as
|
|
44
|
+
* `requiredModule`, but catalog offers are rendered by Catalog while their
|
|
45
|
+
* channel-access feature is owned by Sales. Keeping it explicit lets the
|
|
46
|
+
* server and ClientBootstrap-backed picker make the same fail-closed choice.
|
|
47
|
+
*/
|
|
48
|
+
requiredFeatureModule: string
|
|
49
|
+
requiredFeature: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function readRecord(value: unknown): Record<string, unknown> | null {
|
|
53
|
+
return value && typeof value === 'object' && !Array.isArray(value)
|
|
54
|
+
? value as Record<string, unknown>
|
|
55
|
+
: null
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function readString(item: Record<string, unknown>, ...keys: string[]): string | null {
|
|
59
|
+
for (const key of keys) {
|
|
60
|
+
const value = item[key]
|
|
61
|
+
if (typeof value === 'string' && value.trim().length > 0) return value.trim()
|
|
62
|
+
}
|
|
63
|
+
return null
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Cross-module records are an untrusted display boundary. Their identifiers
|
|
68
|
+
* remain available to the registry for canonical routing, but a name, status,
|
|
69
|
+
* SKU, or other rendered value must never fall back to an identifier-shaped
|
|
70
|
+
* string. Continue through aliases so a malformed preferred field does not
|
|
71
|
+
* hide a later readable value.
|
|
72
|
+
*/
|
|
73
|
+
function readDisplayString(item: Record<string, unknown>, ...keys: string[]): string | null {
|
|
74
|
+
return firstSafeDocumentsDisplayLabel(...keys.map((key) => item[key]))
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function readNestedString(
|
|
78
|
+
item: Record<string, unknown>,
|
|
79
|
+
parentKey: string,
|
|
80
|
+
...keys: string[]
|
|
81
|
+
): string | null {
|
|
82
|
+
const parent = readRecord(item[parentKey])
|
|
83
|
+
return parent ? readString(parent, ...keys) : null
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function readNestedDisplayString(
|
|
87
|
+
item: Record<string, unknown>,
|
|
88
|
+
parentKey: string,
|
|
89
|
+
...keys: string[]
|
|
90
|
+
): string | null {
|
|
91
|
+
const parent = readRecord(item[parentKey])
|
|
92
|
+
return parent ? readDisplayString(parent, ...keys) : null
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function readDisplayTextValue(item: Record<string, unknown>, ...keys: string[]): string | null {
|
|
96
|
+
for (const key of keys) {
|
|
97
|
+
const value = item[key]
|
|
98
|
+
const safe = typeof value === 'number' && Number.isFinite(value)
|
|
99
|
+
? sanitizeDocumentsDisplayLabel(String(value))
|
|
100
|
+
: sanitizeDocumentsDisplayLabel(value)
|
|
101
|
+
if (safe) return safe
|
|
102
|
+
}
|
|
103
|
+
return null
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function optionalSubtitle(value: string | null): string | undefined {
|
|
107
|
+
return value ?? undefined
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function mapCustomerItem(item: Record<string, unknown>): EntityPickerItem | null {
|
|
111
|
+
const id = readString(item, 'id')
|
|
112
|
+
const email = readDisplayString(item, 'email', 'primaryEmail', 'primary_email')
|
|
113
|
+
const label = readDisplayString(item, 'name', 'displayName', 'display_name') ?? email
|
|
114
|
+
if (!id || !label) return null
|
|
115
|
+
return { id, label, subtitle: optionalSubtitle(email) }
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
function mapDealItem(item: Record<string, unknown>): EntityPickerItem | null {
|
|
119
|
+
const id = readString(item, 'id')
|
|
120
|
+
const label = readDisplayString(item, 'title')
|
|
121
|
+
if (!id || !label) return null
|
|
122
|
+
return { id, label, subtitle: optionalSubtitle(readDisplayString(item, 'status')) }
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function mapProductItem(item: Record<string, unknown>): EntityPickerItem | null {
|
|
126
|
+
const id = readString(item, 'id')
|
|
127
|
+
const label = readDisplayString(item, 'title')
|
|
128
|
+
if (!id || !label) return null
|
|
129
|
+
return { id, label, subtitle: optionalSubtitle(readDisplayString(item, 'sku')) }
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function mapCatalogOfferItem(item: Record<string, unknown>): EntityPickerItem | null {
|
|
133
|
+
const id = readString(item, 'id')
|
|
134
|
+
const productId = readString(item, 'productId', 'product_id')
|
|
135
|
+
?? readNestedString(item, 'product', 'id')
|
|
136
|
+
const productTitle = readNestedDisplayString(item, 'product', 'title', 'name')
|
|
137
|
+
const label = readDisplayString(item, 'title', 'name') ?? productTitle
|
|
138
|
+
if (!id || !productId || !label) return null
|
|
139
|
+
const productSku = readNestedDisplayString(item, 'product', 'sku')
|
|
140
|
+
return {
|
|
141
|
+
id,
|
|
142
|
+
label,
|
|
143
|
+
subtitle: optionalSubtitle(productTitle ?? productSku),
|
|
144
|
+
href: `/backend/catalog/products/${productId}`,
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function mapSalesDocumentItem(
|
|
149
|
+
item: Record<string, unknown>,
|
|
150
|
+
numberKeys: string[],
|
|
151
|
+
): EntityPickerItem | null {
|
|
152
|
+
const id = readString(item, 'id')
|
|
153
|
+
const label = readDisplayString(item, ...numberKeys, 'number', 'title')
|
|
154
|
+
if (!id || !label) return null
|
|
155
|
+
return { id, label, subtitle: optionalSubtitle(readDisplayString(item, 'status')) }
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function mapDocumentItem(item: Record<string, unknown>): EntityPickerItem | null {
|
|
159
|
+
const id = readString(item, 'id')
|
|
160
|
+
const label = readDisplayString(item, 'title')
|
|
161
|
+
if (!id || !label) return null
|
|
162
|
+
const archivedAt = item.archivedAt ?? item.archived_at
|
|
163
|
+
return {
|
|
164
|
+
id,
|
|
165
|
+
label,
|
|
166
|
+
archivedAt: typeof archivedAt === 'string' && archivedAt.length > 0 ? archivedAt : null,
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function field(fieldName: string, labelKey: string, keys: string[]): EntityTokenField {
|
|
171
|
+
return {
|
|
172
|
+
field: fieldName,
|
|
173
|
+
labelKey,
|
|
174
|
+
extract: (item) => readDisplayTextValue(item, ...keys),
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function exactIdPath(pathPrefix: string, id: string): string {
|
|
179
|
+
return `${pathPrefix}/${id}`
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
const CATALOG_PRODUCT_HREF_PATTERN =
|
|
183
|
+
/^\/backend\/catalog\/products\/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
|
184
|
+
|
|
185
|
+
function buildIdAddressableEntry(
|
|
186
|
+
input: Omit<DocumentEntityRegistryEntry, 'resolveHref' | 'isCanonicalHref'>,
|
|
187
|
+
): DocumentEntityRegistryEntry {
|
|
188
|
+
return {
|
|
189
|
+
...input,
|
|
190
|
+
resolveHref: (item) => input.href(item.id),
|
|
191
|
+
isCanonicalHref: (item, href) => href === input.href(item.id),
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function readItemsArray(response: unknown): Record<string, unknown>[] {
|
|
196
|
+
if (Array.isArray(response)) {
|
|
197
|
+
return response.map(readRecord).filter((item): item is Record<string, unknown> => item !== null)
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const record = readRecord(response)
|
|
201
|
+
const candidates = [record?.items, record?.data]
|
|
202
|
+
for (const candidate of candidates) {
|
|
203
|
+
if (Array.isArray(candidate)) {
|
|
204
|
+
return candidate.map(readRecord).filter((item): item is Record<string, unknown> => item !== null)
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return []
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export const DOCUMENT_ENTITY_REGISTRY: DocumentEntityRegistryEntry[] = [
|
|
211
|
+
buildIdAddressableEntry({
|
|
212
|
+
type: 'customer-person',
|
|
213
|
+
labelKey: 'documents.entities.customerPerson',
|
|
214
|
+
searchPath: '/api/customers/people',
|
|
215
|
+
mapItem: mapCustomerItem,
|
|
216
|
+
href: (id) => exactIdPath('/backend/customers/people', id),
|
|
217
|
+
requiredModule: 'customers',
|
|
218
|
+
requiredFeatureModule: 'customers',
|
|
219
|
+
requiredFeature: 'customers.people.view',
|
|
220
|
+
tokenFields: [
|
|
221
|
+
field('name', 'documents.entityFields.name', ['name', 'displayName', 'display_name']),
|
|
222
|
+
field('email', 'documents.entityFields.email', ['email', 'primaryEmail', 'primary_email']),
|
|
223
|
+
field('phone', 'documents.entityFields.phone', ['phone', 'primaryPhone', 'primary_phone']),
|
|
224
|
+
],
|
|
225
|
+
}),
|
|
226
|
+
buildIdAddressableEntry({
|
|
227
|
+
type: 'customer-company',
|
|
228
|
+
labelKey: 'documents.entities.customerCompany',
|
|
229
|
+
searchPath: '/api/customers/companies',
|
|
230
|
+
mapItem: mapCustomerItem,
|
|
231
|
+
href: (id) => exactIdPath('/backend/customers/companies', id),
|
|
232
|
+
requiredModule: 'customers',
|
|
233
|
+
requiredFeatureModule: 'customers',
|
|
234
|
+
requiredFeature: 'customers.companies.view',
|
|
235
|
+
tokenFields: [
|
|
236
|
+
field('name', 'documents.entityFields.name', ['name', 'displayName', 'display_name']),
|
|
237
|
+
field('email', 'documents.entityFields.email', ['email', 'primaryEmail', 'primary_email']),
|
|
238
|
+
field('phone', 'documents.entityFields.phone', ['phone', 'primaryPhone', 'primary_phone']),
|
|
239
|
+
],
|
|
240
|
+
}),
|
|
241
|
+
buildIdAddressableEntry({
|
|
242
|
+
type: 'deal',
|
|
243
|
+
labelKey: 'documents.entities.deal',
|
|
244
|
+
searchPath: '/api/customers/deals',
|
|
245
|
+
mapItem: mapDealItem,
|
|
246
|
+
href: (id) => exactIdPath('/backend/customers/deals', id),
|
|
247
|
+
requiredModule: 'customers',
|
|
248
|
+
requiredFeatureModule: 'customers',
|
|
249
|
+
requiredFeature: 'customers.deals.view',
|
|
250
|
+
tokenFields: [
|
|
251
|
+
field('title', 'documents.entityFields.title', ['title']),
|
|
252
|
+
field('status', 'documents.entityFields.status', ['status']),
|
|
253
|
+
field('value', 'documents.entityFields.value', ['value', 'valueAmount', 'value_amount']),
|
|
254
|
+
field('valueCurrency', 'documents.entityFields.valueCurrency', ['valueCurrency', 'value_currency']),
|
|
255
|
+
],
|
|
256
|
+
}),
|
|
257
|
+
buildIdAddressableEntry({
|
|
258
|
+
type: 'product',
|
|
259
|
+
labelKey: 'documents.entities.product',
|
|
260
|
+
searchPath: '/api/catalog/products',
|
|
261
|
+
mapItem: mapProductItem,
|
|
262
|
+
href: (id) => exactIdPath('/backend/catalog/products', id),
|
|
263
|
+
requiredModule: 'catalog',
|
|
264
|
+
requiredFeatureModule: 'catalog',
|
|
265
|
+
requiredFeature: 'catalog.products.view',
|
|
266
|
+
tokenFields: [
|
|
267
|
+
field('title', 'documents.entityFields.title', ['title']),
|
|
268
|
+
field('subtitle', 'documents.entityFields.subtitle', ['subtitle']),
|
|
269
|
+
field('sku', 'documents.entityFields.sku', ['sku']),
|
|
270
|
+
],
|
|
271
|
+
}),
|
|
272
|
+
{
|
|
273
|
+
type: 'catalog-offer',
|
|
274
|
+
labelKey: 'documents.entities.catalogOffer',
|
|
275
|
+
searchPath: '/api/catalog/offers',
|
|
276
|
+
mapItem: mapCatalogOfferItem,
|
|
277
|
+
href: () => '',
|
|
278
|
+
resolveHref: (item) => {
|
|
279
|
+
const href = item.href ?? null
|
|
280
|
+
return href && CATALOG_PRODUCT_HREF_PATTERN.test(href) ? href : null
|
|
281
|
+
},
|
|
282
|
+
isCanonicalHref: (item, href) => Boolean(item.href && href === item.href && CATALOG_PRODUCT_HREF_PATTERN.test(href)),
|
|
283
|
+
requiredModule: 'catalog',
|
|
284
|
+
requiredFeatureModule: 'sales',
|
|
285
|
+
requiredFeature: 'sales.channels.manage',
|
|
286
|
+
tokenFields: [
|
|
287
|
+
field('title', 'documents.entityFields.title', ['title', 'name']),
|
|
288
|
+
field('description', 'documents.entityFields.description', ['description']),
|
|
289
|
+
],
|
|
290
|
+
},
|
|
291
|
+
buildIdAddressableEntry({
|
|
292
|
+
type: 'quote',
|
|
293
|
+
labelKey: 'documents.entities.quote',
|
|
294
|
+
searchPath: '/api/sales/quotes',
|
|
295
|
+
mapItem: (item) => mapSalesDocumentItem(item, ['quoteNumber', 'quote_number']),
|
|
296
|
+
href: (id) => exactIdPath('/backend/sales/quotes', id),
|
|
297
|
+
requiredModule: 'sales',
|
|
298
|
+
requiredFeatureModule: 'sales',
|
|
299
|
+
requiredFeature: 'sales.quotes.view',
|
|
300
|
+
tokenFields: [
|
|
301
|
+
field('number', 'documents.entityFields.number', ['quoteNumber', 'quote_number', 'number']),
|
|
302
|
+
field('status', 'documents.entityFields.status', ['status']),
|
|
303
|
+
field('total', 'documents.entityFields.total', ['grandTotalGross', 'grand_total_gross', 'total']),
|
|
304
|
+
field('currency', 'documents.entityFields.currency', ['currencyCode', 'currency_code']),
|
|
305
|
+
],
|
|
306
|
+
}),
|
|
307
|
+
buildIdAddressableEntry({
|
|
308
|
+
type: 'sales-order',
|
|
309
|
+
labelKey: 'documents.entities.salesOrder',
|
|
310
|
+
searchPath: '/api/sales/orders',
|
|
311
|
+
mapItem: (item) => mapSalesDocumentItem(item, ['orderNumber', 'order_number']),
|
|
312
|
+
href: (id) => exactIdPath('/backend/sales/orders', id),
|
|
313
|
+
requiredModule: 'sales',
|
|
314
|
+
requiredFeatureModule: 'sales',
|
|
315
|
+
requiredFeature: 'sales.orders.view',
|
|
316
|
+
tokenFields: [
|
|
317
|
+
field('number', 'documents.entityFields.number', ['orderNumber', 'order_number', 'number']),
|
|
318
|
+
field('status', 'documents.entityFields.status', ['status']),
|
|
319
|
+
field('total', 'documents.entityFields.total', ['grandTotalGross', 'grand_total_gross', 'total']),
|
|
320
|
+
field('currency', 'documents.entityFields.currency', ['currencyCode', 'currency_code']),
|
|
321
|
+
],
|
|
322
|
+
}),
|
|
323
|
+
buildIdAddressableEntry({
|
|
324
|
+
type: 'document',
|
|
325
|
+
labelKey: 'documents.entities.document',
|
|
326
|
+
searchPath: '/api/documents',
|
|
327
|
+
mapItem: mapDocumentItem,
|
|
328
|
+
href: (id) => exactIdPath('/backend/documents', id),
|
|
329
|
+
requiredModule: 'documents',
|
|
330
|
+
requiredFeatureModule: 'documents',
|
|
331
|
+
requiredFeature: 'documents.view',
|
|
332
|
+
tokenFields: [
|
|
333
|
+
field('title', 'documents.entityFields.title', ['title']),
|
|
334
|
+
],
|
|
335
|
+
}),
|
|
336
|
+
]
|
|
337
|
+
|
|
338
|
+
export function getEntityRegistryEntry(type: string): DocumentEntityRegistryEntry | null {
|
|
339
|
+
return DOCUMENT_ENTITY_REGISTRY.find((entry) => entry.type === type) ?? null
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export function getEntityTokenFieldNames(type: DocumentEntityType): Set<string> {
|
|
343
|
+
const entry = getEntityRegistryEntry(type)
|
|
344
|
+
return new Set(entry?.tokenFields.map((tokenField) => tokenField.field) ?? [])
|
|
345
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { getEnabledModuleIds } from '@open-mercato/shared/security/enabledModulesRegistry'
|
|
2
|
+
import type { DocumentEntityRegistryEntry } from './entityRegistry'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Returns whether the peer module backing a Documents entity-registry entry
|
|
6
|
+
* is enabled in the running application.
|
|
7
|
+
*
|
|
8
|
+
* The bootstrapped module registry is the canonical server-side source. An
|
|
9
|
+
* empty/unavailable registry therefore fails closed for peer-backed entries;
|
|
10
|
+
* stale ACL grants (including superadmin wildcards) must never make a disabled
|
|
11
|
+
* module addressable through Documents.
|
|
12
|
+
*/
|
|
13
|
+
export function isDocumentEntityRegistryModuleEnabled(
|
|
14
|
+
entry: Pick<DocumentEntityRegistryEntry, 'requiredModule' | 'requiredFeatureModule'>,
|
|
15
|
+
): boolean {
|
|
16
|
+
const enabledModuleIds = new Set(getEnabledModuleIds())
|
|
17
|
+
return enabledModuleIds.has(entry.requiredModule)
|
|
18
|
+
&& enabledModuleIds.has(entry.requiredFeatureModule)
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { Extension, type Editor } from '@tiptap/core'
|
|
2
|
+
import { Suggestion, type SuggestionProps } from '@tiptap/suggestion'
|
|
3
|
+
import type { EntityRefAttributes } from './editorConfig'
|
|
4
|
+
|
|
5
|
+
type EntitySuggestionHandlers = {
|
|
6
|
+
onTrigger: (ctx: { query: string; range: { from: number; to: number } }) => void
|
|
7
|
+
onClose: () => void
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function notifyTrigger(
|
|
11
|
+
handlers: EntitySuggestionHandlers,
|
|
12
|
+
props: Pick<SuggestionProps<unknown, unknown>, 'query' | 'range'>,
|
|
13
|
+
): void {
|
|
14
|
+
handlers.onTrigger({
|
|
15
|
+
query: props.query,
|
|
16
|
+
range: {
|
|
17
|
+
from: props.range.from,
|
|
18
|
+
to: props.range.to,
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function createEntitySuggestionExtension(handlers: EntitySuggestionHandlers): Extension {
|
|
24
|
+
return Extension.create({
|
|
25
|
+
name: 'entitySuggestion',
|
|
26
|
+
addProseMirrorPlugins() {
|
|
27
|
+
return [
|
|
28
|
+
Suggestion<unknown, unknown>({
|
|
29
|
+
editor: this.editor,
|
|
30
|
+
char: '@',
|
|
31
|
+
allowSpaces: false,
|
|
32
|
+
startOfLine: false,
|
|
33
|
+
items: () => [],
|
|
34
|
+
command: () => undefined,
|
|
35
|
+
render: () => ({
|
|
36
|
+
onStart: (props) => notifyTrigger(handlers, props),
|
|
37
|
+
onUpdate: (props) => notifyTrigger(handlers, props),
|
|
38
|
+
onExit: () => handlers.onClose(),
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function insertEntityRef(editor: Editor, attrs: EntityRefAttributes): boolean {
|
|
47
|
+
return editor
|
|
48
|
+
.chain()
|
|
49
|
+
.focus()
|
|
50
|
+
.insertContent([
|
|
51
|
+
{
|
|
52
|
+
type: 'entityRef',
|
|
53
|
+
attrs,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
type: 'text',
|
|
57
|
+
text: ' ',
|
|
58
|
+
},
|
|
59
|
+
])
|
|
60
|
+
.run()
|
|
61
|
+
}
|