@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.
Files changed (602) hide show
  1. package/README.md +88 -0
  2. package/build.mjs +23 -0
  3. package/dist/index.js +5 -0
  4. package/dist/index.js.map +7 -0
  5. package/dist/modules/documents/acl.js +15 -0
  6. package/dist/modules/documents/acl.js.map +7 -0
  7. package/dist/modules/documents/api/[id]/archive/route.js +116 -0
  8. package/dist/modules/documents/api/[id]/archive/route.js.map +7 -0
  9. package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js +155 -0
  10. package/dist/modules/documents/api/[id]/attachments/[attachmentId]/route.js.map +7 -0
  11. package/dist/modules/documents/api/[id]/attachments/route.js +153 -0
  12. package/dist/modules/documents/api/[id]/attachments/route.js.map +7 -0
  13. package/dist/modules/documents/api/[id]/collab-token/route.js +180 -0
  14. package/dist/modules/documents/api/[id]/collab-token/route.js.map +7 -0
  15. package/dist/modules/documents/api/[id]/comments/access-check/route.js +86 -0
  16. package/dist/modules/documents/api/[id]/comments/access-check/route.js.map +7 -0
  17. package/dist/modules/documents/api/[id]/comments/route.js +387 -0
  18. package/dist/modules/documents/api/[id]/comments/route.js.map +7 -0
  19. package/dist/modules/documents/api/[id]/content/route.js +143 -0
  20. package/dist/modules/documents/api/[id]/content/route.js.map +7 -0
  21. package/dist/modules/documents/api/[id]/duplicate/route.js +200 -0
  22. package/dist/modules/documents/api/[id]/duplicate/route.js.map +7 -0
  23. package/dist/modules/documents/api/[id]/export/route.js +421 -0
  24. package/dist/modules/documents/api/[id]/export/route.js.map +7 -0
  25. package/dist/modules/documents/api/[id]/favorite/route.js +96 -0
  26. package/dist/modules/documents/api/[id]/favorite/route.js.map +7 -0
  27. package/dist/modules/documents/api/[id]/links/[linkId]/route.js +85 -0
  28. package/dist/modules/documents/api/[id]/links/[linkId]/route.js.map +7 -0
  29. package/dist/modules/documents/api/[id]/links/route.js +257 -0
  30. package/dist/modules/documents/api/[id]/links/route.js.map +7 -0
  31. package/dist/modules/documents/api/[id]/principals/route.js +299 -0
  32. package/dist/modules/documents/api/[id]/principals/route.js.map +7 -0
  33. package/dist/modules/documents/api/[id]/route.js +246 -0
  34. package/dist/modules/documents/api/[id]/route.js.map +7 -0
  35. package/dist/modules/documents/api/[id]/shares/route.js +335 -0
  36. package/dist/modules/documents/api/[id]/shares/route.js.map +7 -0
  37. package/dist/modules/documents/api/[id]/unarchive/route.js +39 -0
  38. package/dist/modules/documents/api/[id]/unarchive/route.js.map +7 -0
  39. package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js +133 -0
  40. package/dist/modules/documents/api/[id]/versions/[versionId]/restore/route.js.map +7 -0
  41. package/dist/modules/documents/api/[id]/versions/[versionId]/route.js +93 -0
  42. package/dist/modules/documents/api/[id]/versions/[versionId]/route.js.map +7 -0
  43. package/dist/modules/documents/api/[id]/versions/route.js +193 -0
  44. package/dist/modules/documents/api/[id]/versions/route.js.map +7 -0
  45. package/dist/modules/documents/api/[id]/watch/route.js +97 -0
  46. package/dist/modules/documents/api/[id]/watch/route.js.map +7 -0
  47. package/dist/modules/documents/api/_commands.js +34 -0
  48. package/dist/modules/documents/api/_commands.js.map +7 -0
  49. package/dist/modules/documents/api/_shared.js +490 -0
  50. package/dist/modules/documents/api/_shared.js.map +7 -0
  51. package/dist/modules/documents/api/folders/route.js +256 -0
  52. package/dist/modules/documents/api/folders/route.js.map +7 -0
  53. package/dist/modules/documents/api/instantiate/route.js +108 -0
  54. package/dist/modules/documents/api/instantiate/route.js.map +7 -0
  55. package/dist/modules/documents/api/route.js +322 -0
  56. package/dist/modules/documents/api/route.js.map +7 -0
  57. package/dist/modules/documents/api/templates/[templateId]/preview/route.js +94 -0
  58. package/dist/modules/documents/api/templates/[templateId]/preview/route.js.map +7 -0
  59. package/dist/modules/documents/api/templates/[templateId]/route.js +82 -0
  60. package/dist/modules/documents/api/templates/[templateId]/route.js.map +7 -0
  61. package/dist/modules/documents/api/templates/route.js +344 -0
  62. package/dist/modules/documents/api/templates/route.js.map +7 -0
  63. package/dist/modules/documents/backend/documents/DocumentsPageClient.js +160 -0
  64. package/dist/modules/documents/backend/documents/DocumentsPageClient.js.map +7 -0
  65. package/dist/modules/documents/backend/documents/DocumentsTable.js +143 -0
  66. package/dist/modules/documents/backend/documents/DocumentsTable.js.map +7 -0
  67. package/dist/modules/documents/backend/documents/FolderDialog.js +55 -0
  68. package/dist/modules/documents/backend/documents/FolderDialog.js.map +7 -0
  69. package/dist/modules/documents/backend/documents/FolderTree.js +40 -0
  70. package/dist/modules/documents/backend/documents/FolderTree.js.map +7 -0
  71. package/dist/modules/documents/backend/documents/MoveDocumentDialog.js +64 -0
  72. package/dist/modules/documents/backend/documents/MoveDocumentDialog.js.map +7 -0
  73. package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js +77 -0
  74. package/dist/modules/documents/backend/documents/[id]/CommentAnchorNavigation.js.map +7 -0
  75. package/dist/modules/documents/backend/documents/[id]/CommentComposer.js +126 -0
  76. package/dist/modules/documents/backend/documents/[id]/CommentComposer.js.map +7 -0
  77. package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js +88 -0
  78. package/dist/modules/documents/backend/documents/[id]/CommentThreadList.js.map +7 -0
  79. package/dist/modules/documents/backend/documents/[id]/CommentsRail.js +123 -0
  80. package/dist/modules/documents/backend/documents/[id]/CommentsRail.js.map +7 -0
  81. package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js +91 -0
  82. package/dist/modules/documents/backend/documents/[id]/DocumentCanvas.js.map +7 -0
  83. package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js +27 -0
  84. package/dist/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.js.map +7 -0
  85. package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js +50 -0
  86. package/dist/modules/documents/backend/documents/[id]/DocumentEditorIsland.js.map +7 -0
  87. package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js +168 -0
  88. package/dist/modules/documents/backend/documents/[id]/DocumentEditorSurface.js.map +7 -0
  89. package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js +129 -0
  90. package/dist/modules/documents/backend/documents/[id]/DocumentNavigator.js.map +7 -0
  91. package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js +429 -0
  92. package/dist/modules/documents/backend/documents/[id]/DocumentPageClient.js.map +7 -0
  93. package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js +68 -0
  94. package/dist/modules/documents/backend/documents/[id]/EditorColorTools.js.map +7 -0
  95. package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js +69 -0
  96. package/dist/modules/documents/backend/documents/[id]/EditorStatusPresence.js.map +7 -0
  97. package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js +151 -0
  98. package/dist/modules/documents/backend/documents/[id]/EditorToolbar.js.map +7 -0
  99. package/dist/modules/documents/backend/documents/[id]/ExportMenu.js +121 -0
  100. package/dist/modules/documents/backend/documents/[id]/ExportMenu.js.map +7 -0
  101. package/dist/modules/documents/backend/documents/[id]/MentionPicker.js +114 -0
  102. package/dist/modules/documents/backend/documents/[id]/MentionPicker.js.map +7 -0
  103. package/dist/modules/documents/backend/documents/[id]/OutlinePane.js +70 -0
  104. package/dist/modules/documents/backend/documents/[id]/OutlinePane.js.map +7 -0
  105. package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js +157 -0
  106. package/dist/modules/documents/backend/documents/[id]/RecordFieldsDialog.js.map +7 -0
  107. package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js +266 -0
  108. package/dist/modules/documents/backend/documents/[id]/RelatedRecordsPanel.js.map +7 -0
  109. package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js +227 -0
  110. package/dist/modules/documents/backend/documents/[id]/VersionHistoryPanel.js.map +7 -0
  111. package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js +157 -0
  112. package/dist/modules/documents/backend/documents/[id]/VersionPreviewDialog.js.map +7 -0
  113. package/dist/modules/documents/backend/documents/[id]/commentTypes.js +150 -0
  114. package/dist/modules/documents/backend/documents/[id]/commentTypes.js.map +7 -0
  115. package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js +13 -0
  116. package/dist/modules/documents/backend/documents/[id]/componentCapabilities.js.map +7 -0
  117. package/dist/modules/documents/backend/documents/[id]/documentPagination.js +295 -0
  118. package/dist/modules/documents/backend/documents/[id]/documentPagination.js.map +7 -0
  119. package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js +81 -0
  120. package/dist/modules/documents/backend/documents/[id]/editorPresenceStyles.js.map +7 -0
  121. package/dist/modules/documents/backend/documents/[id]/editorTypes.js +52 -0
  122. package/dist/modules/documents/backend/documents/[id]/editorTypes.js.map +7 -0
  123. package/dist/modules/documents/backend/documents/[id]/page.js +10 -0
  124. package/dist/modules/documents/backend/documents/[id]/page.js.map +7 -0
  125. package/dist/modules/documents/backend/documents/[id]/page.meta.js +16 -0
  126. package/dist/modules/documents/backend/documents/[id]/page.meta.js.map +7 -0
  127. package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js +38 -0
  128. package/dist/modules/documents/backend/documents/[id]/relatedRecordModel.js.map +7 -0
  129. package/dist/modules/documents/backend/documents/[id]/restoreVersion.js +33 -0
  130. package/dist/modules/documents/backend/documents/[id]/restoreVersion.js.map +7 -0
  131. package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js +392 -0
  132. package/dist/modules/documents/backend/documents/[id]/useDocumentCollaboration.js.map +7 -0
  133. package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js +253 -0
  134. package/dist/modules/documents/backend/documents/[id]/useDocumentComments.js.map +7 -0
  135. package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js +149 -0
  136. package/dist/modules/documents/backend/documents/[id]/useDocumentEditor.js.map +7 -0
  137. package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js +82 -0
  138. package/dist/modules/documents/backend/documents/[id]/useDocumentTitle.js.map +7 -0
  139. package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js +144 -0
  140. package/dist/modules/documents/backend/documents/[id]/useEditorInsertions.js.map +7 -0
  141. package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js +237 -0
  142. package/dist/modules/documents/backend/documents/[id]/useFallbackContentPersistence.js.map +7 -0
  143. package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js +216 -0
  144. package/dist/modules/documents/backend/documents/[id]/useMentionPicker.js.map +7 -0
  145. package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js +25 -0
  146. package/dist/modules/documents/backend/documents/[id]/versionHistoryModel.js.map +7 -0
  147. package/dist/modules/documents/backend/documents/components/EntityPicker.js +156 -0
  148. package/dist/modules/documents/backend/documents/components/EntityPicker.js.map +7 -0
  149. package/dist/modules/documents/backend/documents/components/EntityPickerResults.js +46 -0
  150. package/dist/modules/documents/backend/documents/components/EntityPickerResults.js.map +7 -0
  151. package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js +127 -0
  152. package/dist/modules/documents/backend/documents/components/NewFromTemplateDialog.js.map +7 -0
  153. package/dist/modules/documents/backend/documents/components/PrincipalPicker.js +84 -0
  154. package/dist/modules/documents/backend/documents/components/PrincipalPicker.js.map +7 -0
  155. package/dist/modules/documents/backend/documents/components/ShareDialog.js +77 -0
  156. package/dist/modules/documents/backend/documents/components/ShareDialog.js.map +7 -0
  157. package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js +93 -0
  158. package/dist/modules/documents/backend/documents/components/ShareDialogAddForm.js.map +7 -0
  159. package/dist/modules/documents/backend/documents/components/ShareDialogList.js +82 -0
  160. package/dist/modules/documents/backend/documents/components/ShareDialogList.js.map +7 -0
  161. package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js +96 -0
  162. package/dist/modules/documents/backend/documents/components/TemplateBodyEditor.js.map +7 -0
  163. package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js +169 -0
  164. package/dist/modules/documents/backend/documents/components/TemplateEditorDialog.js.map +7 -0
  165. package/dist/modules/documents/backend/documents/components/TemplatePreview.js +38 -0
  166. package/dist/modules/documents/backend/documents/components/TemplatePreview.js.map +7 -0
  167. package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js +69 -0
  168. package/dist/modules/documents/backend/documents/components/TemplateSlotFields.js.map +7 -0
  169. package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js +71 -0
  170. package/dist/modules/documents/backend/documents/components/TemplateSlotsEditor.js.map +7 -0
  171. package/dist/modules/documents/backend/documents/components/principalPickerModel.js +63 -0
  172. package/dist/modules/documents/backend/documents/components/principalPickerModel.js.map +7 -0
  173. package/dist/modules/documents/backend/documents/components/shareDialogModel.js +68 -0
  174. package/dist/modules/documents/backend/documents/components/shareDialogModel.js.map +7 -0
  175. package/dist/modules/documents/backend/documents/components/templateUi.js +89 -0
  176. package/dist/modules/documents/backend/documents/components/templateUi.js.map +7 -0
  177. package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js +30 -0
  178. package/dist/modules/documents/backend/documents/components/useAvailableEntityRegistry.js.map +7 -0
  179. package/dist/modules/documents/backend/documents/components/useEntitySearch.js +191 -0
  180. package/dist/modules/documents/backend/documents/components/useEntitySearch.js.map +7 -0
  181. package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js +221 -0
  182. package/dist/modules/documents/backend/documents/components/usePrincipalPicker.js.map +7 -0
  183. package/dist/modules/documents/backend/documents/components/useShareDialog.js +236 -0
  184. package/dist/modules/documents/backend/documents/components/useShareDialog.js.map +7 -0
  185. package/dist/modules/documents/backend/documents/components/useTemplateDetail.js +49 -0
  186. package/dist/modules/documents/backend/documents/components/useTemplateDetail.js.map +7 -0
  187. package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js +234 -0
  188. package/dist/modules/documents/backend/documents/components/useTemplateInstantiation.js.map +7 -0
  189. package/dist/modules/documents/backend/documents/documentUi.js +106 -0
  190. package/dist/modules/documents/backend/documents/documentUi.js.map +7 -0
  191. package/dist/modules/documents/backend/documents/documentsListTypes.js +132 -0
  192. package/dist/modules/documents/backend/documents/documentsListTypes.js.map +7 -0
  193. package/dist/modules/documents/backend/documents/page.js +9 -0
  194. package/dist/modules/documents/backend/documents/page.js.map +7 -0
  195. package/dist/modules/documents/backend/documents/page.meta.js +26 -0
  196. package/dist/modules/documents/backend/documents/page.meta.js.map +7 -0
  197. package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js +91 -0
  198. package/dist/modules/documents/backend/documents/templates/TemplatesPageClient.js.map +7 -0
  199. package/dist/modules/documents/backend/documents/templates/TemplatesTable.js +58 -0
  200. package/dist/modules/documents/backend/documents/templates/TemplatesTable.js.map +7 -0
  201. package/dist/modules/documents/backend/documents/templates/page.js +9 -0
  202. package/dist/modules/documents/backend/documents/templates/page.js.map +7 -0
  203. package/dist/modules/documents/backend/documents/templates/page.meta.js +34 -0
  204. package/dist/modules/documents/backend/documents/templates/page.meta.js.map +7 -0
  205. package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js +139 -0
  206. package/dist/modules/documents/backend/documents/templates/useTemplatesPage.js.map +7 -0
  207. package/dist/modules/documents/backend/documents/useDocumentsList.js +314 -0
  208. package/dist/modules/documents/backend/documents/useDocumentsList.js.map +7 -0
  209. package/dist/modules/documents/ce.js +8 -0
  210. package/dist/modules/documents/ce.js.map +7 -0
  211. package/dist/modules/documents/commands/aggregate.js +99 -0
  212. package/dist/modules/documents/commands/aggregate.js.map +7 -0
  213. package/dist/modules/documents/commands/attachments.js +252 -0
  214. package/dist/modules/documents/commands/attachments.js.map +7 -0
  215. package/dist/modules/documents/commands/comments.js +782 -0
  216. package/dist/modules/documents/commands/comments.js.map +7 -0
  217. package/dist/modules/documents/commands/content.js +238 -0
  218. package/dist/modules/documents/commands/content.js.map +7 -0
  219. package/dist/modules/documents/commands/document-crud.js +505 -0
  220. package/dist/modules/documents/commands/document-crud.js.map +7 -0
  221. package/dist/modules/documents/commands/documents.js +473 -0
  222. package/dist/modules/documents/commands/documents.js.map +7 -0
  223. package/dist/modules/documents/commands/duplicate.js +640 -0
  224. package/dist/modules/documents/commands/duplicate.js.map +7 -0
  225. package/dist/modules/documents/commands/favorites.js +150 -0
  226. package/dist/modules/documents/commands/favorites.js.map +7 -0
  227. package/dist/modules/documents/commands/folders.js +420 -0
  228. package/dist/modules/documents/commands/folders.js.map +7 -0
  229. package/dist/modules/documents/commands/index.js +64 -0
  230. package/dist/modules/documents/commands/index.js.map +7 -0
  231. package/dist/modules/documents/commands/interceptors.js +300 -0
  232. package/dist/modules/documents/commands/interceptors.js.map +7 -0
  233. package/dist/modules/documents/commands/lifecycle.js +249 -0
  234. package/dist/modules/documents/commands/lifecycle.js.map +7 -0
  235. package/dist/modules/documents/commands/links.js +410 -0
  236. package/dist/modules/documents/commands/links.js.map +7 -0
  237. package/dist/modules/documents/commands/mutation-helpers.js +42 -0
  238. package/dist/modules/documents/commands/mutation-helpers.js.map +7 -0
  239. package/dist/modules/documents/commands/projection-types.js +1 -0
  240. package/dist/modules/documents/commands/projection-types.js.map +7 -0
  241. package/dist/modules/documents/commands/shared.js +143 -0
  242. package/dist/modules/documents/commands/shared.js.map +7 -0
  243. package/dist/modules/documents/commands/shares.js +527 -0
  244. package/dist/modules/documents/commands/shares.js.map +7 -0
  245. package/dist/modules/documents/commands/side-effects.js +103 -0
  246. package/dist/modules/documents/commands/side-effects.js.map +7 -0
  247. package/dist/modules/documents/commands/templates.js +461 -0
  248. package/dist/modules/documents/commands/templates.js.map +7 -0
  249. package/dist/modules/documents/commands/versions.js +432 -0
  250. package/dist/modules/documents/commands/versions.js.map +7 -0
  251. package/dist/modules/documents/commands/watchers.js +164 -0
  252. package/dist/modules/documents/commands/watchers.js.map +7 -0
  253. package/dist/modules/documents/data/entities.js +653 -0
  254. package/dist/modules/documents/data/entities.js.map +7 -0
  255. package/dist/modules/documents/data/extensions.js +44 -0
  256. package/dist/modules/documents/data/extensions.js.map +7 -0
  257. package/dist/modules/documents/data/validators.js +219 -0
  258. package/dist/modules/documents/data/validators.js.map +7 -0
  259. package/dist/modules/documents/di.js +35 -0
  260. package/dist/modules/documents/di.js.map +7 -0
  261. package/dist/modules/documents/encryption.js +12 -0
  262. package/dist/modules/documents/encryption.js.map +7 -0
  263. package/dist/modules/documents/events.js +27 -0
  264. package/dist/modules/documents/events.js.map +7 -0
  265. package/dist/modules/documents/index.js +19 -0
  266. package/dist/modules/documents/index.js.map +7 -0
  267. package/dist/modules/documents/lib/attachmentServicePort.js +30 -0
  268. package/dist/modules/documents/lib/attachmentServicePort.js.map +7 -0
  269. package/dist/modules/documents/lib/capabilities.js +32 -0
  270. package/dist/modules/documents/lib/capabilities.js.map +7 -0
  271. package/dist/modules/documents/lib/collabCloseEvents.js +17 -0
  272. package/dist/modules/documents/lib/collabCloseEvents.js.map +7 -0
  273. package/dist/modules/documents/lib/collabEndpoint.js +22 -0
  274. package/dist/modules/documents/lib/collabEndpoint.js.map +7 -0
  275. package/dist/modules/documents/lib/collabMaterializer.js +107 -0
  276. package/dist/modules/documents/lib/collabMaterializer.js.map +7 -0
  277. package/dist/modules/documents/lib/collabToken.js +120 -0
  278. package/dist/modules/documents/lib/collabToken.js.map +7 -0
  279. package/dist/modules/documents/lib/collaborationAwareness.js +68 -0
  280. package/dist/modules/documents/lib/collaborationAwareness.js.map +7 -0
  281. package/dist/modules/documents/lib/commentAnchors.js +15 -0
  282. package/dist/modules/documents/lib/commentAnchors.js.map +7 -0
  283. package/dist/modules/documents/lib/constants.js +25 -0
  284. package/dist/modules/documents/lib/constants.js.map +7 -0
  285. package/dist/modules/documents/lib/contentService.js +248 -0
  286. package/dist/modules/documents/lib/contentService.js.map +7 -0
  287. package/dist/modules/documents/lib/displayLabels.js +23 -0
  288. package/dist/modules/documents/lib/displayLabels.js.map +7 -0
  289. package/dist/modules/documents/lib/docxRenderer.js +601 -0
  290. package/dist/modules/documents/lib/docxRenderer.js.map +7 -0
  291. package/dist/modules/documents/lib/duplicateContent.js +22 -0
  292. package/dist/modules/documents/lib/duplicateContent.js.map +7 -0
  293. package/dist/modules/documents/lib/editorConfig.js +287 -0
  294. package/dist/modules/documents/lib/editorConfig.js.map +7 -0
  295. package/dist/modules/documents/lib/entityLinks.js +148 -0
  296. package/dist/modules/documents/lib/entityLinks.js.map +7 -0
  297. package/dist/modules/documents/lib/entityRegistry.js +258 -0
  298. package/dist/modules/documents/lib/entityRegistry.js.map +7 -0
  299. package/dist/modules/documents/lib/entityRegistry.server.js +189 -0
  300. package/dist/modules/documents/lib/entityRegistry.server.js.map +7 -0
  301. package/dist/modules/documents/lib/entityRegistryAvailability.server.js +9 -0
  302. package/dist/modules/documents/lib/entityRegistryAvailability.server.js.map +7 -0
  303. package/dist/modules/documents/lib/entitySuggestion.js +50 -0
  304. package/dist/modules/documents/lib/entitySuggestion.js.map +7 -0
  305. package/dist/modules/documents/lib/favorites.js +22 -0
  306. package/dist/modules/documents/lib/favorites.js.map +7 -0
  307. package/dist/modules/documents/lib/folderHierarchySerialization.js +19 -0
  308. package/dist/modules/documents/lib/folderHierarchySerialization.js.map +7 -0
  309. package/dist/modules/documents/lib/historyLimits.js +100 -0
  310. package/dist/modules/documents/lib/historyLimits.js.map +7 -0
  311. package/dist/modules/documents/lib/historyPolicy.js +14 -0
  312. package/dist/modules/documents/lib/historyPolicy.js.map +7 -0
  313. package/dist/modules/documents/lib/organizationAccess.js +17 -0
  314. package/dist/modules/documents/lib/organizationAccess.js.map +7 -0
  315. package/dist/modules/documents/lib/pdfHtml.js +62 -0
  316. package/dist/modules/documents/lib/pdfHtml.js.map +7 -0
  317. package/dist/modules/documents/lib/pdfRenderer.js +284 -0
  318. package/dist/modules/documents/lib/pdfRenderer.js.map +7 -0
  319. package/dist/modules/documents/lib/permissions.js +222 -0
  320. package/dist/modules/documents/lib/permissions.js.map +7 -0
  321. package/dist/modules/documents/lib/platformServices.js +35 -0
  322. package/dist/modules/documents/lib/platformServices.js.map +7 -0
  323. package/dist/modules/documents/lib/recordFieldInsertion.js +58 -0
  324. package/dist/modules/documents/lib/recordFieldInsertion.js.map +7 -0
  325. package/dist/modules/documents/lib/requestBody.js +80 -0
  326. package/dist/modules/documents/lib/requestBody.js.map +7 -0
  327. package/dist/modules/documents/lib/resourceLimits.js +62 -0
  328. package/dist/modules/documents/lib/resourceLimits.js.map +7 -0
  329. package/dist/modules/documents/lib/shareCounts.js +25 -0
  330. package/dist/modules/documents/lib/shareCounts.js.map +7 -0
  331. package/dist/modules/documents/lib/templateFill.js +84 -0
  332. package/dist/modules/documents/lib/templateFill.js.map +7 -0
  333. package/dist/modules/documents/lib/templateInstantiation.js +147 -0
  334. package/dist/modules/documents/lib/templateInstantiation.js.map +7 -0
  335. package/dist/modules/documents/lib/templatePreviewDigest.js +82 -0
  336. package/dist/modules/documents/lib/templatePreviewDigest.js.map +7 -0
  337. package/dist/modules/documents/lib/templateSeeds.js +201 -0
  338. package/dist/modules/documents/lib/templateSeeds.js.map +7 -0
  339. package/dist/modules/documents/lib/userLabels.js +37 -0
  340. package/dist/modules/documents/lib/userLabels.js.map +7 -0
  341. package/dist/modules/documents/lib/versionContent.js +131 -0
  342. package/dist/modules/documents/lib/versionContent.js.map +7 -0
  343. package/dist/modules/documents/lib/versionLabels.js +12 -0
  344. package/dist/modules/documents/lib/versionLabels.js.map +7 -0
  345. package/dist/modules/documents/lib/versioning.js +14 -0
  346. package/dist/modules/documents/lib/versioning.js.map +7 -0
  347. package/dist/modules/documents/lib/visibility.js +422 -0
  348. package/dist/modules/documents/lib/visibility.js.map +7 -0
  349. package/dist/modules/documents/lib/watchers.js +106 -0
  350. package/dist/modules/documents/lib/watchers.js.map +7 -0
  351. package/dist/modules/documents/migrations/Migration20260708163836_documents.js +44 -0
  352. package/dist/modules/documents/migrations/Migration20260708163836_documents.js.map +7 -0
  353. package/dist/modules/documents/migrations/Migration20260709164720_documents.js +17 -0
  354. package/dist/modules/documents/migrations/Migration20260709164720_documents.js.map +7 -0
  355. package/dist/modules/documents/migrations/Migration20260710002318_documents.js +32 -0
  356. package/dist/modules/documents/migrations/Migration20260710002318_documents.js.map +7 -0
  357. package/dist/modules/documents/migrations/Migration20260710071003_documents.js +13 -0
  358. package/dist/modules/documents/migrations/Migration20260710071003_documents.js.map +7 -0
  359. package/dist/modules/documents/migrations/Migration20260712120000_documents.js +13 -0
  360. package/dist/modules/documents/migrations/Migration20260712120000_documents.js.map +7 -0
  361. package/dist/modules/documents/migrations/Migration20260712183000_documents.js +14 -0
  362. package/dist/modules/documents/migrations/Migration20260712183000_documents.js.map +7 -0
  363. package/dist/modules/documents/migrations/Migration20260713092156_documents.js +29 -0
  364. package/dist/modules/documents/migrations/Migration20260713092156_documents.js.map +7 -0
  365. package/dist/modules/documents/migrations/Migration20260717000000_documents.js +37 -0
  366. package/dist/modules/documents/migrations/Migration20260717000000_documents.js.map +7 -0
  367. package/dist/modules/documents/notifications.js +47 -0
  368. package/dist/modules/documents/notifications.js.map +7 -0
  369. package/dist/modules/documents/search.js +101 -0
  370. package/dist/modules/documents/search.js.map +7 -0
  371. package/dist/modules/documents/setup.js +19 -0
  372. package/dist/modules/documents/setup.js.map +7 -0
  373. package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js +214 -0
  374. package/dist/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.js.map +7 -0
  375. package/dist/modules/documents/widgets/injection/related-documents/context.js +84 -0
  376. package/dist/modules/documents/widgets/injection/related-documents/context.js.map +7 -0
  377. package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js +98 -0
  378. package/dist/modules/documents/widgets/injection/related-documents/useRelatedDocuments.js.map +7 -0
  379. package/dist/modules/documents/widgets/injection/related-documents/widget.client.js +83 -0
  380. package/dist/modules/documents/widgets/injection/related-documents/widget.client.js.map +7 -0
  381. package/dist/modules/documents/widgets/injection/related-documents/widget.js +19 -0
  382. package/dist/modules/documents/widgets/injection/related-documents/widget.js.map +7 -0
  383. package/dist/modules/documents/widgets/injection-table.js +21 -0
  384. package/dist/modules/documents/widgets/injection-table.js.map +7 -0
  385. package/dist/server/documents-collab-server.js +2260 -0
  386. package/dist/server/documents-collab-server.js.map +7 -0
  387. package/generated/entities/document/index.ts +12 -0
  388. package/generated/entities/document_attachment/index.ts +9 -0
  389. package/generated/entities/document_comment/index.ts +14 -0
  390. package/generated/entities/document_content/index.ts +11 -0
  391. package/generated/entities/document_entity_link/index.ts +19 -0
  392. package/generated/entities/document_favorite/index.ts +7 -0
  393. package/generated/entities/document_folder/index.ts +9 -0
  394. package/generated/entities/document_share/index.ts +11 -0
  395. package/generated/entities/document_template/index.ts +13 -0
  396. package/generated/entities/document_version/index.ts +9 -0
  397. package/generated/entities/document_watcher/index.ts +7 -0
  398. package/generated/entities.ids.generated.ts +21 -0
  399. package/generated/entity-fields-registry.ts +151 -0
  400. package/jest.config.cjs +34 -0
  401. package/package.json +149 -0
  402. package/server/documents-collab-server.ts +3416 -0
  403. package/src/index.ts +1 -0
  404. package/src/modules/documents/acl.ts +11 -0
  405. package/src/modules/documents/api/[id]/archive/route.ts +132 -0
  406. package/src/modules/documents/api/[id]/attachments/[attachmentId]/route.ts +166 -0
  407. package/src/modules/documents/api/[id]/attachments/route.ts +173 -0
  408. package/src/modules/documents/api/[id]/collab-token/route.ts +203 -0
  409. package/src/modules/documents/api/[id]/comments/access-check/route.ts +96 -0
  410. package/src/modules/documents/api/[id]/comments/route.ts +442 -0
  411. package/src/modules/documents/api/[id]/content/route.ts +156 -0
  412. package/src/modules/documents/api/[id]/duplicate/route.ts +231 -0
  413. package/src/modules/documents/api/[id]/export/route.ts +535 -0
  414. package/src/modules/documents/api/[id]/favorite/route.ts +110 -0
  415. package/src/modules/documents/api/[id]/links/[linkId]/route.ts +92 -0
  416. package/src/modules/documents/api/[id]/links/route.ts +301 -0
  417. package/src/modules/documents/api/[id]/principals/route.ts +375 -0
  418. package/src/modules/documents/api/[id]/route.ts +267 -0
  419. package/src/modules/documents/api/[id]/shares/route.ts +372 -0
  420. package/src/modules/documents/api/[id]/unarchive/route.ts +42 -0
  421. package/src/modules/documents/api/[id]/versions/[versionId]/restore/route.ts +152 -0
  422. package/src/modules/documents/api/[id]/versions/[versionId]/route.ts +100 -0
  423. package/src/modules/documents/api/[id]/versions/route.ts +207 -0
  424. package/src/modules/documents/api/[id]/watch/route.ts +111 -0
  425. package/src/modules/documents/api/_commands.ts +53 -0
  426. package/src/modules/documents/api/_shared.ts +676 -0
  427. package/src/modules/documents/api/folders/route.ts +287 -0
  428. package/src/modules/documents/api/instantiate/route.ts +114 -0
  429. package/src/modules/documents/api/route.ts +362 -0
  430. package/src/modules/documents/api/templates/[templateId]/preview/route.ts +97 -0
  431. package/src/modules/documents/api/templates/[templateId]/route.ts +92 -0
  432. package/src/modules/documents/api/templates/route.ts +370 -0
  433. package/src/modules/documents/backend/documents/DocumentsPageClient.tsx +150 -0
  434. package/src/modules/documents/backend/documents/DocumentsTable.tsx +168 -0
  435. package/src/modules/documents/backend/documents/FolderDialog.tsx +62 -0
  436. package/src/modules/documents/backend/documents/FolderTree.tsx +72 -0
  437. package/src/modules/documents/backend/documents/MoveDocumentDialog.tsx +70 -0
  438. package/src/modules/documents/backend/documents/[id]/CommentAnchorNavigation.ts +88 -0
  439. package/src/modules/documents/backend/documents/[id]/CommentComposer.tsx +136 -0
  440. package/src/modules/documents/backend/documents/[id]/CommentThreadList.tsx +131 -0
  441. package/src/modules/documents/backend/documents/[id]/CommentsRail.tsx +138 -0
  442. package/src/modules/documents/backend/documents/[id]/DocumentCanvas.tsx +111 -0
  443. package/src/modules/documents/backend/documents/[id]/DocumentEditorErrorBoundary.tsx +39 -0
  444. package/src/modules/documents/backend/documents/[id]/DocumentEditorIsland.tsx +50 -0
  445. package/src/modules/documents/backend/documents/[id]/DocumentEditorSurface.tsx +162 -0
  446. package/src/modules/documents/backend/documents/[id]/DocumentNavigator.tsx +129 -0
  447. package/src/modules/documents/backend/documents/[id]/DocumentPageClient.tsx +463 -0
  448. package/src/modules/documents/backend/documents/[id]/EditorColorTools.tsx +71 -0
  449. package/src/modules/documents/backend/documents/[id]/EditorStatusPresence.tsx +78 -0
  450. package/src/modules/documents/backend/documents/[id]/EditorToolbar.tsx +108 -0
  451. package/src/modules/documents/backend/documents/[id]/ExportMenu.tsx +144 -0
  452. package/src/modules/documents/backend/documents/[id]/MentionPicker.tsx +137 -0
  453. package/src/modules/documents/backend/documents/[id]/OutlinePane.tsx +98 -0
  454. package/src/modules/documents/backend/documents/[id]/RecordFieldsDialog.tsx +185 -0
  455. package/src/modules/documents/backend/documents/[id]/RelatedRecordsPanel.tsx +320 -0
  456. package/src/modules/documents/backend/documents/[id]/VersionHistoryPanel.tsx +244 -0
  457. package/src/modules/documents/backend/documents/[id]/VersionPreviewDialog.tsx +197 -0
  458. package/src/modules/documents/backend/documents/[id]/commentTypes.ts +192 -0
  459. package/src/modules/documents/backend/documents/[id]/componentCapabilities.ts +17 -0
  460. package/src/modules/documents/backend/documents/[id]/documentPagination.ts +352 -0
  461. package/src/modules/documents/backend/documents/[id]/editorPresenceStyles.ts +77 -0
  462. package/src/modules/documents/backend/documents/[id]/editorTypes.ts +84 -0
  463. package/src/modules/documents/backend/documents/[id]/page.meta.ts +12 -0
  464. package/src/modules/documents/backend/documents/[id]/page.tsx +6 -0
  465. package/src/modules/documents/backend/documents/[id]/relatedRecordModel.ts +49 -0
  466. package/src/modules/documents/backend/documents/[id]/restoreVersion.ts +49 -0
  467. package/src/modules/documents/backend/documents/[id]/useDocumentCollaboration.ts +458 -0
  468. package/src/modules/documents/backend/documents/[id]/useDocumentComments.ts +286 -0
  469. package/src/modules/documents/backend/documents/[id]/useDocumentEditor.ts +157 -0
  470. package/src/modules/documents/backend/documents/[id]/useDocumentTitle.ts +77 -0
  471. package/src/modules/documents/backend/documents/[id]/useEditorInsertions.ts +147 -0
  472. package/src/modules/documents/backend/documents/[id]/useFallbackContentPersistence.ts +277 -0
  473. package/src/modules/documents/backend/documents/[id]/useMentionPicker.ts +259 -0
  474. package/src/modules/documents/backend/documents/[id]/versionHistoryModel.ts +29 -0
  475. package/src/modules/documents/backend/documents/components/EntityPicker.tsx +171 -0
  476. package/src/modules/documents/backend/documents/components/EntityPickerResults.tsx +64 -0
  477. package/src/modules/documents/backend/documents/components/NewFromTemplateDialog.tsx +136 -0
  478. package/src/modules/documents/backend/documents/components/PrincipalPicker.tsx +90 -0
  479. package/src/modules/documents/backend/documents/components/ShareDialog.tsx +88 -0
  480. package/src/modules/documents/backend/documents/components/ShareDialogAddForm.tsx +113 -0
  481. package/src/modules/documents/backend/documents/components/ShareDialogList.tsx +117 -0
  482. package/src/modules/documents/backend/documents/components/TemplateBodyEditor.tsx +96 -0
  483. package/src/modules/documents/backend/documents/components/TemplateEditorDialog.tsx +171 -0
  484. package/src/modules/documents/backend/documents/components/TemplatePreview.tsx +43 -0
  485. package/src/modules/documents/backend/documents/components/TemplateSlotFields.tsx +72 -0
  486. package/src/modules/documents/backend/documents/components/TemplateSlotsEditor.tsx +72 -0
  487. package/src/modules/documents/backend/documents/components/principalPickerModel.ts +86 -0
  488. package/src/modules/documents/backend/documents/components/shareDialogModel.ts +94 -0
  489. package/src/modules/documents/backend/documents/components/templateUi.ts +128 -0
  490. package/src/modules/documents/backend/documents/components/useAvailableEntityRegistry.ts +43 -0
  491. package/src/modules/documents/backend/documents/components/useEntitySearch.ts +197 -0
  492. package/src/modules/documents/backend/documents/components/usePrincipalPicker.ts +165 -0
  493. package/src/modules/documents/backend/documents/components/useShareDialog.ts +267 -0
  494. package/src/modules/documents/backend/documents/components/useTemplateDetail.ts +54 -0
  495. package/src/modules/documents/backend/documents/components/useTemplateInstantiation.ts +252 -0
  496. package/src/modules/documents/backend/documents/documentUi.ts +134 -0
  497. package/src/modules/documents/backend/documents/documentsListTypes.ts +163 -0
  498. package/src/modules/documents/backend/documents/page.meta.ts +24 -0
  499. package/src/modules/documents/backend/documents/page.tsx +5 -0
  500. package/src/modules/documents/backend/documents/templates/TemplatesPageClient.tsx +93 -0
  501. package/src/modules/documents/backend/documents/templates/TemplatesTable.tsx +71 -0
  502. package/src/modules/documents/backend/documents/templates/page.meta.ts +32 -0
  503. package/src/modules/documents/backend/documents/templates/page.tsx +5 -0
  504. package/src/modules/documents/backend/documents/templates/useTemplatesPage.tsx +148 -0
  505. package/src/modules/documents/backend/documents/useDocumentsList.tsx +305 -0
  506. package/src/modules/documents/ce.ts +6 -0
  507. package/src/modules/documents/commands/aggregate.ts +128 -0
  508. package/src/modules/documents/commands/attachments.ts +309 -0
  509. package/src/modules/documents/commands/comments.ts +966 -0
  510. package/src/modules/documents/commands/content.ts +294 -0
  511. package/src/modules/documents/commands/document-crud.ts +609 -0
  512. package/src/modules/documents/commands/documents.ts +581 -0
  513. package/src/modules/documents/commands/duplicate.ts +772 -0
  514. package/src/modules/documents/commands/favorites.ts +171 -0
  515. package/src/modules/documents/commands/folders.ts +506 -0
  516. package/src/modules/documents/commands/index.ts +33 -0
  517. package/src/modules/documents/commands/interceptors.ts +402 -0
  518. package/src/modules/documents/commands/lifecycle.ts +333 -0
  519. package/src/modules/documents/commands/links.ts +486 -0
  520. package/src/modules/documents/commands/mutation-helpers.ts +48 -0
  521. package/src/modules/documents/commands/projection-types.ts +77 -0
  522. package/src/modules/documents/commands/shared.ts +219 -0
  523. package/src/modules/documents/commands/shares.ts +612 -0
  524. package/src/modules/documents/commands/side-effects.ts +130 -0
  525. package/src/modules/documents/commands/templates.ts +522 -0
  526. package/src/modules/documents/commands/versions.ts +537 -0
  527. package/src/modules/documents/commands/watchers.ts +181 -0
  528. package/src/modules/documents/data/entities.ts +631 -0
  529. package/src/modules/documents/data/extensions.ts +42 -0
  530. package/src/modules/documents/data/validators.ts +248 -0
  531. package/src/modules/documents/di.ts +33 -0
  532. package/src/modules/documents/encryption.ts +14 -0
  533. package/src/modules/documents/events.ts +23 -0
  534. package/src/modules/documents/i18n/.hardcoded-allowlist.json +9 -0
  535. package/src/modules/documents/i18n/de.json +522 -0
  536. package/src/modules/documents/i18n/en.json +522 -0
  537. package/src/modules/documents/i18n/es.json +522 -0
  538. package/src/modules/documents/i18n/ko.json +522 -0
  539. package/src/modules/documents/i18n/pl.json +522 -0
  540. package/src/modules/documents/index.ts +17 -0
  541. package/src/modules/documents/lib/attachmentServicePort.ts +94 -0
  542. package/src/modules/documents/lib/capabilities.ts +57 -0
  543. package/src/modules/documents/lib/collabCloseEvents.ts +26 -0
  544. package/src/modules/documents/lib/collabEndpoint.ts +43 -0
  545. package/src/modules/documents/lib/collabMaterializer.ts +140 -0
  546. package/src/modules/documents/lib/collabToken.ts +170 -0
  547. package/src/modules/documents/lib/collaborationAwareness.ts +102 -0
  548. package/src/modules/documents/lib/commentAnchors.ts +19 -0
  549. package/src/modules/documents/lib/constants.ts +39 -0
  550. package/src/modules/documents/lib/contentService.ts +340 -0
  551. package/src/modules/documents/lib/displayLabels.ts +31 -0
  552. package/src/modules/documents/lib/docxRenderer.ts +685 -0
  553. package/src/modules/documents/lib/duplicateContent.ts +32 -0
  554. package/src/modules/documents/lib/editorConfig.ts +371 -0
  555. package/src/modules/documents/lib/entityLinks.ts +250 -0
  556. package/src/modules/documents/lib/entityRegistry.server.ts +267 -0
  557. package/src/modules/documents/lib/entityRegistry.ts +345 -0
  558. package/src/modules/documents/lib/entityRegistryAvailability.server.ts +19 -0
  559. package/src/modules/documents/lib/entitySuggestion.ts +61 -0
  560. package/src/modules/documents/lib/favorites.ts +35 -0
  561. package/src/modules/documents/lib/folderHierarchySerialization.ts +34 -0
  562. package/src/modules/documents/lib/historyLimits.ts +154 -0
  563. package/src/modules/documents/lib/historyPolicy.ts +7 -0
  564. package/src/modules/documents/lib/organizationAccess.ts +44 -0
  565. package/src/modules/documents/lib/pdfHtml.ts +65 -0
  566. package/src/modules/documents/lib/pdfRenderer.ts +367 -0
  567. package/src/modules/documents/lib/permissions.ts +299 -0
  568. package/src/modules/documents/lib/platformServices.ts +70 -0
  569. package/src/modules/documents/lib/recordFieldInsertion.ts +72 -0
  570. package/src/modules/documents/lib/requestBody.ts +97 -0
  571. package/src/modules/documents/lib/resourceLimits.ts +94 -0
  572. package/src/modules/documents/lib/shareCounts.ts +44 -0
  573. package/src/modules/documents/lib/templateFill.ts +138 -0
  574. package/src/modules/documents/lib/templateInstantiation.ts +206 -0
  575. package/src/modules/documents/lib/templatePreviewDigest.ts +122 -0
  576. package/src/modules/documents/lib/templateSeeds.ts +248 -0
  577. package/src/modules/documents/lib/userLabels.ts +58 -0
  578. package/src/modules/documents/lib/versionContent.ts +163 -0
  579. package/src/modules/documents/lib/versionLabels.ts +9 -0
  580. package/src/modules/documents/lib/versioning.ts +29 -0
  581. package/src/modules/documents/lib/visibility.ts +610 -0
  582. package/src/modules/documents/lib/watchers.ts +129 -0
  583. package/src/modules/documents/migrations/.snapshot-open-mercato.json +2892 -0
  584. package/src/modules/documents/migrations/Migration20260708163836_documents.ts +50 -0
  585. package/src/modules/documents/migrations/Migration20260709164720_documents.ts +19 -0
  586. package/src/modules/documents/migrations/Migration20260710002318_documents.ts +35 -0
  587. package/src/modules/documents/migrations/Migration20260710071003_documents.ts +13 -0
  588. package/src/modules/documents/migrations/Migration20260712120000_documents.ts +13 -0
  589. package/src/modules/documents/migrations/Migration20260712183000_documents.ts +12 -0
  590. package/src/modules/documents/migrations/Migration20260713092156_documents.ts +43 -0
  591. package/src/modules/documents/migrations/Migration20260717000000_documents.ts +40 -0
  592. package/src/modules/documents/notifications.ts +45 -0
  593. package/src/modules/documents/search.ts +118 -0
  594. package/src/modules/documents/setup.ts +19 -0
  595. package/src/modules/documents/widgets/injection/related-documents/LinkDocumentDialog.tsx +224 -0
  596. package/src/modules/documents/widgets/injection/related-documents/context.ts +101 -0
  597. package/src/modules/documents/widgets/injection/related-documents/useRelatedDocuments.ts +112 -0
  598. package/src/modules/documents/widgets/injection/related-documents/widget.client.tsx +76 -0
  599. package/src/modules/documents/widgets/injection/related-documents/widget.ts +19 -0
  600. package/src/modules/documents/widgets/injection-table.ts +20 -0
  601. package/tsconfig.json +9 -0
  602. package/watch.mjs +6 -0
@@ -0,0 +1,473 @@
1
+ import { LockMode } from "@mikro-orm/core";
2
+ import { z } from "zod";
3
+ import { registerCommand } from "@open-mercato/shared/lib/commands";
4
+ import { withAtomicFlush } from "@open-mercato/shared/lib/commands/flush";
5
+ import { extractUndoPayload } from "@open-mercato/shared/lib/commands/undo";
6
+ import { findOneWithDecryption, findWithDecryption } from "@open-mercato/shared/lib/encryption/find";
7
+ import { CrudHttpError } from "@open-mercato/shared/lib/crud/errors";
8
+ import {
9
+ assertOptimisticLock,
10
+ buildOptimisticLockConflictBody
11
+ } from "@open-mercato/shared/lib/crud/optimistic-lock-command";
12
+ import { resolveTranslations } from "@open-mercato/shared/lib/i18n/server";
13
+ import {
14
+ Document,
15
+ DocumentContent,
16
+ DocumentEntityLink,
17
+ DocumentFolder,
18
+ DocumentTemplate
19
+ } from "../data/entities.js";
20
+ import { documentTemplateInstantiateSchema } from "../data/validators.js";
21
+ import { DOCUMENTS_ENTITY_IDS } from "../lib/constants.js";
22
+ import {
23
+ advanceDocumentCollaborationGeneration,
24
+ mutateDocumentContentState
25
+ } from "../lib/contentService.js";
26
+ import {
27
+ buildDocumentEntityLinkTarget,
28
+ createDocumentEntityLinkData
29
+ } from "../lib/entityLinks.js";
30
+ import { getEntityRegistryEntry } from "../lib/entityRegistry.js";
31
+ import { isDocumentEntityRegistryModuleEnabled } from "../lib/entityRegistryAvailability.server.js";
32
+ import { dedupeTemplateLinkSlots, prepareTemplateRender } from "../lib/templateInstantiation.js";
33
+ import { assertNoPostCreateDocumentDependents } from "./aggregate.js";
34
+ import {
35
+ bufferDocumentMutationSideEffects,
36
+ bufferLinkMutationSideEffects
37
+ } from "./side-effects.js";
38
+ import {
39
+ assertCommandFeature,
40
+ assertDocumentCommandCanEdit,
41
+ resolveDocumentsCommandActor,
42
+ resolveDocumentsCommandEntityManager,
43
+ resolveDocumentsCommandFeatures,
44
+ resolveDocumentsCommandScope
45
+ } from "./shared.js";
46
+ import { nextDocumentVersion } from "./mutation-helpers.js";
47
+ const instantiateDocumentCommandSchema = documentTemplateInstantiateSchema.extend({
48
+ tenantId: z.string().uuid(),
49
+ organizationId: z.string().uuid(),
50
+ documentId: z.string().uuid(),
51
+ contentId: z.string().uuid(),
52
+ linkIds: z.array(z.string().uuid()).max(20),
53
+ createdByUserId: z.string().uuid()
54
+ }).superRefine((input, context) => {
55
+ if (input.linkIds.length !== dedupeTemplateLinkSlots(input.slots).length) {
56
+ context.addIssue({ code: "custom", message: "documents.templates.linkIdentityMismatch" });
57
+ }
58
+ });
59
+ async function loadTemplate(em, input) {
60
+ const template = await findOneWithDecryption(
61
+ em,
62
+ DocumentTemplate,
63
+ {
64
+ id: input.templateId,
65
+ tenantId: input.tenantId,
66
+ organizationId: input.organizationId,
67
+ deletedAt: null,
68
+ isActive: true
69
+ },
70
+ void 0,
71
+ { tenantId: input.tenantId, organizationId: input.organizationId }
72
+ );
73
+ if (!template) throw new CrudHttpError(404, { error: "documents.templates.notFound" });
74
+ return template;
75
+ }
76
+ async function lockAndValidateTemplateRevision(em, input) {
77
+ const template = await findOneWithDecryption(
78
+ em,
79
+ DocumentTemplate,
80
+ {
81
+ id: input.templateId,
82
+ tenantId: input.tenantId,
83
+ organizationId: input.organizationId,
84
+ deletedAt: null,
85
+ isActive: true
86
+ },
87
+ { lockMode: LockMode.PESSIMISTIC_READ },
88
+ { tenantId: input.tenantId, organizationId: input.organizationId }
89
+ );
90
+ const submittedRevision = new Date(input.templateUpdatedAt);
91
+ if (!template || Number.isNaN(submittedRevision.getTime()) || submittedRevision.toISOString() !== template.updatedAt.toISOString()) {
92
+ throw new CrudHttpError(409, { error: "documents.templates.staleTemplate" });
93
+ }
94
+ return template;
95
+ }
96
+ async function assertWritableFolder(em, input, features, actorUserId, lock = false) {
97
+ if (!input.folderId) return;
98
+ const folder = await findOneWithDecryption(
99
+ em,
100
+ DocumentFolder,
101
+ {
102
+ id: input.folderId,
103
+ tenantId: input.tenantId,
104
+ organizationId: input.organizationId,
105
+ deletedAt: null
106
+ },
107
+ lock ? { lockMode: LockMode.PESSIMISTIC_READ } : void 0,
108
+ { tenantId: input.tenantId, organizationId: input.organizationId }
109
+ );
110
+ if (!folder) throw new CrudHttpError(404, { error: "documents.folders.notFound" });
111
+ if (folder.ownerUserId !== actorUserId) assertCommandFeature(features, "documents.manage");
112
+ }
113
+ async function loadAggregate(em, input, lock = false, afterDocumentLock) {
114
+ const scope = { tenantId: input.tenantId, organizationId: input.organizationId };
115
+ const options = lock ? { filters: false, lockMode: LockMode.PESSIMISTIC_WRITE } : { filters: false };
116
+ if (lock) {
117
+ const document2 = await findOneWithDecryption(
118
+ em,
119
+ Document,
120
+ { id: input.documentId, ...scope },
121
+ options,
122
+ scope
123
+ );
124
+ if (afterDocumentLock) await afterDocumentLock();
125
+ const content2 = await findOneWithDecryption(
126
+ em,
127
+ DocumentContent,
128
+ { documentId: input.documentId, ...scope },
129
+ options,
130
+ scope
131
+ );
132
+ const links2 = await findWithDecryption(
133
+ em,
134
+ DocumentEntityLink,
135
+ { documentId: input.documentId, ...scope },
136
+ options,
137
+ scope
138
+ );
139
+ return { document: document2, content: content2, linksById: new Map(links2.map((link) => [link.id, link])) };
140
+ }
141
+ const [document, content, links] = await Promise.all([
142
+ findOneWithDecryption(
143
+ em,
144
+ Document,
145
+ { id: input.documentId, ...scope },
146
+ options,
147
+ scope
148
+ ),
149
+ findOneWithDecryption(
150
+ em,
151
+ DocumentContent,
152
+ { documentId: input.documentId, ...scope },
153
+ options,
154
+ scope
155
+ ),
156
+ findWithDecryption(
157
+ em,
158
+ DocumentEntityLink,
159
+ { documentId: input.documentId, ...scope },
160
+ options,
161
+ scope
162
+ )
163
+ ]);
164
+ return { document, content, linksById: new Map(links.map((link) => [link.id, link])) };
165
+ }
166
+ function snapshotAggregate(input, aggregate) {
167
+ return {
168
+ documentId: input.documentId,
169
+ contentId: aggregate.content?.id ?? input.contentId,
170
+ linkIds: [...input.linkIds],
171
+ documentDeletedAt: aggregate.document?.deletedAt?.toISOString() ?? null,
172
+ contentDeletedAt: aggregate.content?.deletedAt?.toISOString() ?? null,
173
+ documentUpdatedAt: aggregate.document?.updatedAt?.toISOString() ?? null,
174
+ contentUpdatedAt: aggregate.content?.updatedAt?.toISOString() ?? null,
175
+ links: input.linkIds.map((id) => {
176
+ const link = aggregate.linksById.get(id);
177
+ return {
178
+ id,
179
+ deletedAt: link?.deletedAt?.toISOString() ?? null,
180
+ updatedAt: link?.updatedAt?.toISOString() ?? null
181
+ };
182
+ })
183
+ };
184
+ }
185
+ function assertInstantiateEntityUnchanged(entity, expected, resourceKind, resourceId) {
186
+ if (!entity || !expected.updatedAt) {
187
+ throw new CrudHttpError(409, { error: "Record changed by another user" });
188
+ }
189
+ assertOptimisticLock({
190
+ resourceKind,
191
+ resourceId,
192
+ current: entity.updatedAt,
193
+ expected: expected.updatedAt,
194
+ envValue: "all"
195
+ });
196
+ const deletedAt = entity.deletedAt?.toISOString() ?? null;
197
+ if (deletedAt !== expected.deletedAt) {
198
+ throw new CrudHttpError(409, buildOptimisticLockConflictBody(
199
+ entity.updatedAt.toISOString(),
200
+ expected.updatedAt
201
+ ));
202
+ }
203
+ }
204
+ function assertInstantiateSlotFeatures(slots, features) {
205
+ for (const slot of slots) {
206
+ const registryEntry = getEntityRegistryEntry(slot.entityType);
207
+ if (!registryEntry) {
208
+ throw new CrudHttpError(400, { error: "documents.links.invalidEntityType" });
209
+ }
210
+ if (!isDocumentEntityRegistryModuleEnabled(registryEntry)) {
211
+ throw new CrudHttpError(403, { error: "Forbidden" });
212
+ }
213
+ assertCommandFeature(features, registryEntry.requiredFeature);
214
+ }
215
+ }
216
+ const instantiateDocumentCommand = {
217
+ id: "documents.document.instantiate",
218
+ async execute(rawInput, ctx) {
219
+ const input = instantiateDocumentCommandSchema.parse(rawInput);
220
+ const scope = resolveDocumentsCommandScope(ctx, input);
221
+ const requestEm = ctx.container.resolve("em");
222
+ const actorUserId = resolveDocumentsCommandActor(ctx);
223
+ if (actorUserId !== input.createdByUserId) {
224
+ throw new CrudHttpError(403, { error: "Forbidden" });
225
+ }
226
+ const previewFeatures = await resolveDocumentsCommandFeatures(ctx, scope);
227
+ assertCommandFeature(previewFeatures, "documents.create");
228
+ assertCommandFeature(previewFeatures, "documents.edit");
229
+ await assertWritableFolder(requestEm, input, previewFeatures, actorUserId);
230
+ const template = await loadTemplate(requestEm, input);
231
+ const sourceRequest = ctx.request;
232
+ if (!sourceRequest) throw new Error("[internal] template instantiation requires the source request");
233
+ const prepared = await prepareTemplateRender({
234
+ request: sourceRequest,
235
+ template,
236
+ title: input.title,
237
+ locale: input.locale,
238
+ effectiveDate: input.effectiveDate,
239
+ templateUpdatedAt: input.templateUpdatedAt,
240
+ slots: input.slots,
241
+ userFeatures: previewFeatures,
242
+ expectedDigest: input.previewDigest,
243
+ rejectUnresolved: true
244
+ });
245
+ const uniqueLinkSlots = dedupeTemplateLinkSlots(prepared.verifiedSlots);
246
+ const em = resolveDocumentsCommandEntityManager(ctx);
247
+ let aggregate;
248
+ let document = null;
249
+ let content = null;
250
+ const links = [];
251
+ let before;
252
+ let after;
253
+ await withAtomicFlush(em, [
254
+ async () => {
255
+ await lockAndValidateTemplateRevision(em, input);
256
+ aggregate = await loadAggregate(em, input, true);
257
+ const features = await resolveDocumentsCommandFeatures(ctx, scope);
258
+ assertCommandFeature(features, "documents.create");
259
+ assertCommandFeature(features, "documents.edit");
260
+ assertInstantiateSlotFeatures(uniqueLinkSlots, features);
261
+ before = snapshotAggregate(input, aggregate);
262
+ if (aggregate.document && !aggregate.document.deletedAt || aggregate.content && !aggregate.content.deletedAt || Array.from(aggregate.linksById.values()).some((link) => !input.linkIds.includes(link.id) || !link.deletedAt)) {
263
+ throw new CrudHttpError(409, { error: "Record changed by another user" });
264
+ }
265
+ await assertWritableFolder(em, input, features, actorUserId, true);
266
+ document = aggregate.document;
267
+ if (!document) {
268
+ document = em.create(Document, {
269
+ id: input.documentId,
270
+ tenantId: scope.tenantId,
271
+ organizationId: scope.organizationId,
272
+ title: input.title,
273
+ folderId: input.folderId ?? null,
274
+ ownerUserId: input.createdByUserId,
275
+ createdByUserId: input.createdByUserId,
276
+ isActive: true
277
+ });
278
+ em.persist(document);
279
+ } else {
280
+ document.title = input.title;
281
+ document.folderId = input.folderId ?? null;
282
+ document.ownerUserId = input.createdByUserId;
283
+ document.createdByUserId = input.createdByUserId;
284
+ document.isActive = true;
285
+ document.deletedAt = null;
286
+ document.updatedAt = nextDocumentVersion(document.updatedAt);
287
+ }
288
+ },
289
+ async () => {
290
+ if (aggregate.content) {
291
+ advanceDocumentCollaborationGeneration(aggregate.content);
292
+ }
293
+ content = await mutateDocumentContentState(
294
+ em,
295
+ input.documentId,
296
+ scope,
297
+ {
298
+ yjsState: prepared.content.yjsState,
299
+ contentHtml: prepared.content.html,
300
+ contentText: prepared.content.text
301
+ },
302
+ { id: input.contentId, existingContent: aggregate.content }
303
+ );
304
+ aggregate.content = content;
305
+ },
306
+ () => {
307
+ for (const [index, slot] of uniqueLinkSlots.entries()) {
308
+ const linkId = input.linkIds[index];
309
+ let link = aggregate.linksById.get(linkId) ?? null;
310
+ if (!link) {
311
+ link = em.create(DocumentEntityLink, createDocumentEntityLinkData({
312
+ id: linkId,
313
+ documentId: input.documentId,
314
+ scope,
315
+ actorUserId: input.createdByUserId,
316
+ link: {
317
+ entityType: slot.entityType,
318
+ entityId: slot.entityId,
319
+ label: slot.label,
320
+ href: slot.href,
321
+ source: "template"
322
+ }
323
+ }));
324
+ em.persist(link);
325
+ aggregate.linksById.set(linkId, link);
326
+ }
327
+ Object.assign(link, buildDocumentEntityLinkTarget(slot.entityType, slot.entityId));
328
+ link.labelSnapshot = slot.label;
329
+ link.hrefSnapshot = slot.href;
330
+ link.source = "template";
331
+ link.createdByUserId = input.createdByUserId;
332
+ link.deletedAt = null;
333
+ link.updatedAt = nextDocumentVersion(link.updatedAt);
334
+ links.push(link);
335
+ }
336
+ },
337
+ () => {
338
+ if (!document || !content) {
339
+ throw new Error("[internal] document instantiation did not produce an aggregate");
340
+ }
341
+ aggregate.document = document;
342
+ aggregate.content = content;
343
+ after = snapshotAggregate(input, aggregate);
344
+ }
345
+ ], { transaction: true, label: "documents.document.instantiate" });
346
+ const finalDocument = document;
347
+ if (!finalDocument) throw new Error("[internal] document instantiation did not produce a document");
348
+ await bufferDocumentMutationSideEffects(ctx, "created", finalDocument);
349
+ await Promise.all(links.map((link, index) => bufferLinkMutationSideEffects(
350
+ ctx,
351
+ "created",
352
+ link,
353
+ {
354
+ entityType: uniqueLinkSlots[index].entityType,
355
+ entityId: uniqueLinkSlots[index].entityId
356
+ }
357
+ )));
358
+ return {
359
+ id: input.documentId,
360
+ updatedAt: finalDocument.updatedAt.toISOString(),
361
+ links: links.map((link, index) => ({
362
+ id: link.id,
363
+ entityType: uniqueLinkSlots[index].entityType,
364
+ label: link.labelSnapshot,
365
+ href: link.hrefSnapshot
366
+ })),
367
+ before,
368
+ after
369
+ };
370
+ },
371
+ async buildLog({ input, result }) {
372
+ const { translate } = await resolveTranslations();
373
+ return {
374
+ actionLabel: translate("documents.audit.documentInstantiated", "Create document from template"),
375
+ resourceKind: DOCUMENTS_ENTITY_IDS.document,
376
+ resourceId: result.id,
377
+ tenantId: input.tenantId,
378
+ organizationId: input.organizationId,
379
+ snapshotBefore: result.before,
380
+ snapshotAfter: result.after,
381
+ payload: {
382
+ undo: {
383
+ before: result.before,
384
+ after: result.after
385
+ }
386
+ }
387
+ };
388
+ },
389
+ async undo({ logEntry, ctx }) {
390
+ const after = extractUndoPayload(logEntry)?.after;
391
+ if (!after) return;
392
+ const redoInput = logEntry.commandPayload && typeof logEntry.commandPayload === "object" ? logEntry.commandPayload.__redoInput : null;
393
+ const input = instantiateDocumentCommandSchema.parse(redoInput);
394
+ const em = resolveDocumentsCommandEntityManager(ctx);
395
+ const scope = resolveDocumentsCommandScope(ctx, input);
396
+ let deletedLinks = [];
397
+ let deletedDocument = null;
398
+ await withAtomicFlush(em, [async () => {
399
+ const aggregate = await loadAggregate(
400
+ em,
401
+ input,
402
+ true,
403
+ async () => {
404
+ const features = await assertDocumentCommandCanEdit(ctx, em, input.documentId, scope);
405
+ assertCommandFeature(features, "documents.create");
406
+ assertCommandFeature(features, "documents.delete");
407
+ assertInstantiateSlotFeatures(dedupeTemplateLinkSlots(input.slots), features);
408
+ }
409
+ );
410
+ assertInstantiateEntityUnchanged(
411
+ aggregate.document,
412
+ { updatedAt: after.documentUpdatedAt, deletedAt: after.documentDeletedAt },
413
+ DOCUMENTS_ENTITY_IDS.document,
414
+ input.documentId
415
+ );
416
+ assertInstantiateEntityUnchanged(
417
+ aggregate.content,
418
+ { updatedAt: after.contentUpdatedAt, deletedAt: after.contentDeletedAt },
419
+ DOCUMENTS_ENTITY_IDS.documentContent,
420
+ after.contentId
421
+ );
422
+ if (aggregate.linksById.size !== after.links.length) {
423
+ throw new CrudHttpError(409, { error: "Record changed by another user" });
424
+ }
425
+ for (const expectedLink of after.links) {
426
+ assertInstantiateEntityUnchanged(
427
+ aggregate.linksById.get(expectedLink.id) ?? null,
428
+ expectedLink,
429
+ DOCUMENTS_ENTITY_IDS.documentEntityLink,
430
+ expectedLink.id
431
+ );
432
+ }
433
+ await assertNoPostCreateDocumentDependents(em, input.documentId, scope, {
434
+ allowedLinkIds: after.links.map((link) => link.id)
435
+ });
436
+ deletedLinks = Array.from(aggregate.linksById.values());
437
+ deletedDocument = aggregate.document;
438
+ if (aggregate.document) {
439
+ const documentVersion = nextDocumentVersion(aggregate.document.updatedAt);
440
+ aggregate.document.deletedAt = documentVersion;
441
+ aggregate.document.updatedAt = documentVersion;
442
+ }
443
+ if (aggregate.content) {
444
+ const contentVersion = nextDocumentVersion(aggregate.content.updatedAt);
445
+ advanceDocumentCollaborationGeneration(aggregate.content);
446
+ aggregate.content.deletedAt = contentVersion;
447
+ aggregate.content.updatedAt = contentVersion;
448
+ }
449
+ for (const link of deletedLinks) {
450
+ const linkVersion = nextDocumentVersion(link.updatedAt);
451
+ link.deletedAt = linkVersion;
452
+ link.updatedAt = linkVersion;
453
+ }
454
+ }], { transaction: true, label: "documents.document.instantiate.undo" });
455
+ if (deletedLinks.length > 0) {
456
+ await Promise.all(deletedLinks.map((link) => bufferLinkMutationSideEffects(
457
+ ctx,
458
+ "deleted",
459
+ link,
460
+ { undo: true }
461
+ )));
462
+ }
463
+ if (deletedDocument) {
464
+ await bufferDocumentMutationSideEffects(ctx, "deleted", deletedDocument, { undo: true });
465
+ }
466
+ }
467
+ };
468
+ registerCommand(instantiateDocumentCommand);
469
+ export {
470
+ instantiateDocumentCommand,
471
+ instantiateDocumentCommandSchema
472
+ };
473
+ //# sourceMappingURL=documents.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/modules/documents/commands/documents.ts"],
4
+ "sourcesContent": ["import { LockMode } from '@mikro-orm/core'\nimport type { EntityManager } from '@mikro-orm/postgresql'\nimport { z } from 'zod'\nimport { registerCommand, type CommandHandler } from '@open-mercato/shared/lib/commands'\nimport { withAtomicFlush } from '@open-mercato/shared/lib/commands/flush'\nimport { extractUndoPayload } from '@open-mercato/shared/lib/commands/undo'\nimport { findOneWithDecryption, findWithDecryption } from '@open-mercato/shared/lib/encryption/find'\nimport { CrudHttpError } from '@open-mercato/shared/lib/crud/errors'\nimport {\n assertOptimisticLock,\n buildOptimisticLockConflictBody,\n} from '@open-mercato/shared/lib/crud/optimistic-lock-command'\nimport { resolveTranslations } from '@open-mercato/shared/lib/i18n/server'\nimport {\n Document,\n DocumentContent,\n DocumentEntityLink,\n DocumentFolder,\n DocumentTemplate,\n} from '../data/entities'\nimport { documentTemplateInstantiateSchema } from '../data/validators'\nimport { DOCUMENTS_ENTITY_IDS } from '../lib/constants'\nimport {\n advanceDocumentCollaborationGeneration,\n mutateDocumentContentState,\n} from '../lib/contentService'\nimport {\n buildDocumentEntityLinkTarget,\n createDocumentEntityLinkData,\n} from '../lib/entityLinks'\nimport { getEntityRegistryEntry } from '../lib/entityRegistry'\nimport { isDocumentEntityRegistryModuleEnabled } from '../lib/entityRegistryAvailability.server'\nimport { dedupeTemplateLinkSlots, prepareTemplateRender } from '../lib/templateInstantiation'\nimport { assertNoPostCreateDocumentDependents } from './aggregate'\nimport {\n bufferDocumentMutationSideEffects,\n bufferLinkMutationSideEffects,\n} from './side-effects'\nimport {\n assertCommandFeature,\n assertDocumentCommandCanEdit,\n resolveDocumentsCommandActor,\n resolveDocumentsCommandEntityManager,\n resolveDocumentsCommandFeatures,\n resolveDocumentsCommandScope,\n} from './shared'\nimport { nextDocumentVersion } from './mutation-helpers'\n\nexport const instantiateDocumentCommandSchema = documentTemplateInstantiateSchema.extend({\n tenantId: z.string().uuid(),\n organizationId: z.string().uuid(),\n documentId: z.string().uuid(),\n contentId: z.string().uuid(),\n linkIds: z.array(z.string().uuid()).max(20),\n createdByUserId: z.string().uuid(),\n}).superRefine((input, context) => {\n if (input.linkIds.length !== dedupeTemplateLinkSlots(input.slots).length) {\n context.addIssue({ code: 'custom', message: 'documents.templates.linkIdentityMismatch' })\n }\n})\n\nexport type InstantiateDocumentCommandInput = z.infer<typeof instantiateDocumentCommandSchema>\n\ntype InstantiateSnapshot = {\n documentId: string\n contentId: string\n linkIds: string[]\n documentDeletedAt: string | null\n contentDeletedAt: string | null\n documentUpdatedAt: string | null\n contentUpdatedAt: string | null\n links: Array<{ id: string; deletedAt: string | null; updatedAt: string | null }>\n}\n\ntype InstantiateUndoPayload = {\n before?: InstantiateSnapshot | null\n after?: InstantiateSnapshot | null\n}\n\nasync function loadTemplate(\n em: EntityManager,\n input: InstantiateDocumentCommandInput,\n): Promise<DocumentTemplate> {\n const template = await findOneWithDecryption(\n em,\n DocumentTemplate,\n {\n id: input.templateId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n deletedAt: null,\n isActive: true,\n },\n undefined,\n { tenantId: input.tenantId, organizationId: input.organizationId },\n )\n if (!template) throw new CrudHttpError(404, { error: 'documents.templates.notFound' })\n return template\n}\n\nasync function lockAndValidateTemplateRevision(\n em: EntityManager,\n input: InstantiateDocumentCommandInput,\n): Promise<DocumentTemplate> {\n const template = await findOneWithDecryption(\n em,\n DocumentTemplate,\n {\n id: input.templateId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n deletedAt: null,\n isActive: true,\n },\n { lockMode: LockMode.PESSIMISTIC_READ },\n { tenantId: input.tenantId, organizationId: input.organizationId },\n )\n const submittedRevision = new Date(input.templateUpdatedAt)\n if (\n !template\n || Number.isNaN(submittedRevision.getTime())\n || submittedRevision.toISOString() !== template.updatedAt.toISOString()\n ) {\n throw new CrudHttpError(409, { error: 'documents.templates.staleTemplate' })\n }\n return template\n}\n\nasync function assertWritableFolder(\n em: EntityManager,\n input: InstantiateDocumentCommandInput,\n features: readonly string[],\n actorUserId: string,\n lock = false,\n): Promise<void> {\n if (!input.folderId) return\n const folder = await findOneWithDecryption(\n em,\n DocumentFolder,\n {\n id: input.folderId,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n deletedAt: null,\n },\n lock ? { lockMode: LockMode.PESSIMISTIC_READ } : undefined,\n { tenantId: input.tenantId, organizationId: input.organizationId },\n )\n if (!folder) throw new CrudHttpError(404, { error: 'documents.folders.notFound' })\n if (folder.ownerUserId !== actorUserId) assertCommandFeature(features, 'documents.manage')\n}\n\nasync function loadAggregate(\n em: EntityManager,\n input: InstantiateDocumentCommandInput,\n lock = false,\n afterDocumentLock?: () => Promise<void>,\n): Promise<{\n document: Document | null\n content: DocumentContent | null\n linksById: Map<string, DocumentEntityLink>\n}> {\n const scope = { tenantId: input.tenantId, organizationId: input.organizationId }\n const options = lock\n ? { filters: false, lockMode: LockMode.PESSIMISTIC_WRITE } as const\n : { filters: false } as const\n if (lock) {\n // Keep lock acquisition deterministic on the transaction's single\n // connection. This also aligns every undo with collab writes, which lock\n // DocumentContent after resolving the parent document.\n const document = await findOneWithDecryption(\n em,\n Document,\n { id: input.documentId, ...scope },\n options,\n scope,\n )\n if (afterDocumentLock) await afterDocumentLock()\n const content = await findOneWithDecryption(\n em,\n DocumentContent,\n { documentId: input.documentId, ...scope },\n options,\n scope,\n )\n // The instantiated document did not exist before this command, so every\n // link currently attached to it belongs to the aggregate. Loading only the\n // original linkIds would miss a link added after creation and let undo\n // delete the document while leaving that concurrent relation behind.\n const links = await findWithDecryption(\n em,\n DocumentEntityLink,\n { documentId: input.documentId, ...scope },\n options,\n scope,\n )\n return { document, content, linksById: new Map(links.map((link) => [link.id, link])) }\n }\n const [document, content, links] = await Promise.all([\n findOneWithDecryption(\n em,\n Document,\n { id: input.documentId, ...scope },\n options,\n scope,\n ),\n findOneWithDecryption(\n em,\n DocumentContent,\n { documentId: input.documentId, ...scope },\n options,\n scope,\n ),\n findWithDecryption(\n em,\n DocumentEntityLink,\n { documentId: input.documentId, ...scope },\n options,\n scope,\n ),\n ])\n return { document, content, linksById: new Map(links.map((link) => [link.id, link])) }\n}\n\nfunction snapshotAggregate(\n input: InstantiateDocumentCommandInput,\n aggregate: {\n document: Document | null\n content: DocumentContent | null\n linksById: Map<string, DocumentEntityLink>\n },\n): InstantiateSnapshot {\n return {\n documentId: input.documentId,\n contentId: aggregate.content?.id ?? input.contentId,\n linkIds: [...input.linkIds],\n documentDeletedAt: aggregate.document?.deletedAt?.toISOString() ?? null,\n contentDeletedAt: aggregate.content?.deletedAt?.toISOString() ?? null,\n documentUpdatedAt: aggregate.document?.updatedAt?.toISOString() ?? null,\n contentUpdatedAt: aggregate.content?.updatedAt?.toISOString() ?? null,\n links: input.linkIds.map((id) => {\n const link = aggregate.linksById.get(id)\n return {\n id,\n deletedAt: link?.deletedAt?.toISOString() ?? null,\n updatedAt: link?.updatedAt?.toISOString() ?? null,\n }\n }),\n }\n}\n\nfunction assertInstantiateEntityUnchanged(\n entity: { updatedAt: Date; deletedAt?: Date | null } | null,\n expected: { updatedAt: string | null; deletedAt: string | null },\n resourceKind: string,\n resourceId: string,\n): void {\n if (!entity || !expected.updatedAt) {\n throw new CrudHttpError(409, { error: 'Record changed by another user' })\n }\n assertOptimisticLock({\n resourceKind,\n resourceId,\n current: entity.updatedAt,\n expected: expected.updatedAt,\n envValue: 'all',\n })\n const deletedAt = entity.deletedAt?.toISOString() ?? null\n if (deletedAt !== expected.deletedAt) {\n throw new CrudHttpError(409, buildOptimisticLockConflictBody(\n entity.updatedAt.toISOString(),\n expected.updatedAt,\n ))\n }\n}\n\nfunction assertInstantiateSlotFeatures(\n slots: readonly Pick<InstantiateDocumentCommandInput['slots'][number], 'entityType'>[],\n features: readonly string[],\n): void {\n for (const slot of slots) {\n const registryEntry = getEntityRegistryEntry(slot.entityType)\n if (!registryEntry) {\n throw new CrudHttpError(400, { error: 'documents.links.invalidEntityType' })\n }\n if (!isDocumentEntityRegistryModuleEnabled(registryEntry)) {\n throw new CrudHttpError(403, { error: 'Forbidden' })\n }\n assertCommandFeature(features, registryEntry.requiredFeature)\n }\n}\n\ntype InstantiateDocumentCommandResult = {\n id: string\n updatedAt: string\n links: Array<{ id: string; entityType: string; label: string; href: string }>\n before: InstantiateSnapshot\n after: InstantiateSnapshot\n}\n\nconst instantiateDocumentCommand: CommandHandler<\n InstantiateDocumentCommandInput,\n InstantiateDocumentCommandResult\n> = {\n id: 'documents.document.instantiate',\n async execute(rawInput, ctx) {\n const input = instantiateDocumentCommandSchema.parse(rawInput)\n const scope = resolveDocumentsCommandScope(ctx, input)\n const requestEm = ctx.container.resolve('em') as EntityManager\n const actorUserId = resolveDocumentsCommandActor(ctx)\n if (actorUserId !== input.createdByUserId) {\n throw new CrudHttpError(403, { error: 'Forbidden' })\n }\n const previewFeatures = await resolveDocumentsCommandFeatures(ctx, scope)\n assertCommandFeature(previewFeatures, 'documents.create')\n assertCommandFeature(previewFeatures, 'documents.edit')\n await assertWritableFolder(requestEm, input, previewFeatures, actorUserId)\n const template = await loadTemplate(requestEm, input)\n const sourceRequest = ctx.request\n if (!sourceRequest) throw new Error('[internal] template instantiation requires the source request')\n // The authoritative render performs up to 20 loopback HTTP verifications,\n // so it must complete before the transaction acquires aggregate locks. It\n // enforces the preview-digest CAS against caller-controlled values, and\n // the in-transaction revalidation below pins its inputs at commit: the\n // locked template revision check rejects any template edited after this\n // render (monotonic versions), and slot features plus module availability\n // are re-asserted against a fresh post-lock ACL.\n const prepared = await prepareTemplateRender({\n request: sourceRequest,\n template,\n title: input.title,\n locale: input.locale,\n effectiveDate: input.effectiveDate,\n templateUpdatedAt: input.templateUpdatedAt,\n slots: input.slots,\n userFeatures: previewFeatures,\n expectedDigest: input.previewDigest,\n rejectUnresolved: true,\n })\n const uniqueLinkSlots = dedupeTemplateLinkSlots(prepared.verifiedSlots)\n const em = resolveDocumentsCommandEntityManager(ctx)\n let aggregate!: Awaited<ReturnType<typeof loadAggregate>>\n let document: Document | null = null\n let content: DocumentContent | null = null\n const links: DocumentEntityLink[] = []\n let before!: InstantiateSnapshot\n let after!: InstantiateSnapshot\n\n await withAtomicFlush(em, [\n async () => {\n await lockAndValidateTemplateRevision(em, input)\n aggregate = await loadAggregate(em, input, true)\n const features = await resolveDocumentsCommandFeatures(ctx, scope)\n assertCommandFeature(features, 'documents.create')\n assertCommandFeature(features, 'documents.edit')\n assertInstantiateSlotFeatures(uniqueLinkSlots, features)\n before = snapshotAggregate(input, aggregate)\n if (\n (aggregate.document && !aggregate.document.deletedAt)\n || (aggregate.content && !aggregate.content.deletedAt)\n || Array.from(aggregate.linksById.values()).some((link) => (\n !input.linkIds.includes(link.id) || !link.deletedAt\n ))\n ) {\n throw new CrudHttpError(409, { error: 'Record changed by another user' })\n }\n await assertWritableFolder(em, input, features, actorUserId, true)\n document = aggregate.document\n if (!document) {\n document = em.create(Document, {\n id: input.documentId,\n tenantId: scope.tenantId,\n organizationId: scope.organizationId,\n title: input.title,\n folderId: input.folderId ?? null,\n ownerUserId: input.createdByUserId,\n createdByUserId: input.createdByUserId,\n isActive: true,\n })\n em.persist(document)\n } else {\n document.title = input.title\n document.folderId = input.folderId ?? null\n document.ownerUserId = input.createdByUserId\n document.createdByUserId = input.createdByUserId\n document.isActive = true\n document.deletedAt = null\n document.updatedAt = nextDocumentVersion(document.updatedAt)\n }\n },\n async () => {\n if (aggregate.content) {\n advanceDocumentCollaborationGeneration(aggregate.content)\n }\n content = await mutateDocumentContentState(\n em,\n input.documentId,\n scope,\n {\n yjsState: prepared.content.yjsState,\n contentHtml: prepared.content.html,\n contentText: prepared.content.text,\n },\n { id: input.contentId, existingContent: aggregate.content },\n )\n aggregate.content = content\n },\n () => {\n for (const [index, slot] of uniqueLinkSlots.entries()) {\n const linkId = input.linkIds[index]!\n let link = aggregate.linksById.get(linkId) ?? null\n if (!link) {\n link = em.create(DocumentEntityLink, createDocumentEntityLinkData({\n id: linkId,\n documentId: input.documentId,\n scope,\n actorUserId: input.createdByUserId,\n link: {\n entityType: slot.entityType,\n entityId: slot.entityId,\n label: slot.label,\n href: slot.href,\n source: 'template',\n },\n }))\n em.persist(link)\n aggregate.linksById.set(linkId, link)\n }\n Object.assign(link, buildDocumentEntityLinkTarget(slot.entityType, slot.entityId))\n link.labelSnapshot = slot.label\n link.hrefSnapshot = slot.href\n link.source = 'template'\n link.createdByUserId = input.createdByUserId\n link.deletedAt = null\n link.updatedAt = nextDocumentVersion(link.updatedAt)\n links.push(link)\n }\n },\n () => {\n if (!document || !content) {\n throw new Error('[internal] document instantiation did not produce an aggregate')\n }\n aggregate.document = document\n aggregate.content = content\n after = snapshotAggregate(input, aggregate)\n },\n ], { transaction: true, label: 'documents.document.instantiate' })\n\n const finalDocument = document as Document | null\n if (!finalDocument) throw new Error('[internal] document instantiation did not produce a document')\n await bufferDocumentMutationSideEffects(ctx, 'created', finalDocument)\n await Promise.all(links.map((link, index) => bufferLinkMutationSideEffects(\n ctx,\n 'created',\n link,\n {\n entityType: uniqueLinkSlots[index]!.entityType,\n entityId: uniqueLinkSlots[index]!.entityId,\n },\n )))\n\n return {\n id: input.documentId,\n updatedAt: finalDocument.updatedAt.toISOString(),\n links: links.map((link, index) => ({\n id: link.id,\n entityType: uniqueLinkSlots[index]!.entityType,\n label: link.labelSnapshot,\n href: link.hrefSnapshot,\n })),\n before,\n after,\n }\n },\n async buildLog({ input, result }) {\n const { translate } = await resolveTranslations()\n return {\n actionLabel: translate('documents.audit.documentInstantiated', 'Create document from template'),\n resourceKind: DOCUMENTS_ENTITY_IDS.document,\n resourceId: result.id,\n tenantId: input.tenantId,\n organizationId: input.organizationId,\n snapshotBefore: result.before,\n snapshotAfter: result.after,\n payload: {\n undo: {\n before: result.before,\n after: result.after,\n } satisfies InstantiateUndoPayload,\n },\n }\n },\n async undo({ logEntry, ctx }) {\n const after = extractUndoPayload<InstantiateUndoPayload>(logEntry)?.after\n if (!after) return\n const redoInput = logEntry.commandPayload && typeof logEntry.commandPayload === 'object'\n ? (logEntry.commandPayload as { __redoInput?: unknown }).__redoInput\n : null\n const input = instantiateDocumentCommandSchema.parse(redoInput)\n const em = resolveDocumentsCommandEntityManager(ctx)\n const scope = resolveDocumentsCommandScope(ctx, input)\n let deletedLinks: DocumentEntityLink[] = []\n let deletedDocument: Document | null = null\n await withAtomicFlush(em, [async () => {\n // Authorization, optimistic validation, and deletion all run while the\n // same aggregate rows are locked. In particular, a collab materializer\n // cannot update DocumentContent between validation and soft deletion.\n const aggregate = await loadAggregate(\n em,\n input,\n true,\n async () => {\n const features = await assertDocumentCommandCanEdit(ctx, em, input.documentId, scope)\n assertCommandFeature(features, 'documents.create')\n assertCommandFeature(features, 'documents.delete')\n assertInstantiateSlotFeatures(dedupeTemplateLinkSlots(input.slots), features)\n },\n )\n assertInstantiateEntityUnchanged(\n aggregate.document,\n { updatedAt: after.documentUpdatedAt, deletedAt: after.documentDeletedAt },\n DOCUMENTS_ENTITY_IDS.document,\n input.documentId,\n )\n assertInstantiateEntityUnchanged(\n aggregate.content,\n { updatedAt: after.contentUpdatedAt, deletedAt: after.contentDeletedAt },\n DOCUMENTS_ENTITY_IDS.documentContent,\n after.contentId,\n )\n if (aggregate.linksById.size !== after.links.length) {\n throw new CrudHttpError(409, { error: 'Record changed by another user' })\n }\n for (const expectedLink of after.links) {\n assertInstantiateEntityUnchanged(\n aggregate.linksById.get(expectedLink.id) ?? null,\n expectedLink,\n DOCUMENTS_ENTITY_IDS.documentEntityLink,\n expectedLink.id,\n )\n }\n await assertNoPostCreateDocumentDependents(em, input.documentId, scope, {\n allowedLinkIds: after.links.map((link) => link.id),\n })\n\n deletedLinks = Array.from(aggregate.linksById.values())\n deletedDocument = aggregate.document\n if (aggregate.document) {\n const documentVersion = nextDocumentVersion(aggregate.document.updatedAt)\n aggregate.document.deletedAt = documentVersion\n aggregate.document.updatedAt = documentVersion\n }\n if (aggregate.content) {\n const contentVersion = nextDocumentVersion(aggregate.content.updatedAt)\n advanceDocumentCollaborationGeneration(aggregate.content)\n aggregate.content.deletedAt = contentVersion\n aggregate.content.updatedAt = contentVersion\n }\n for (const link of deletedLinks) {\n const linkVersion = nextDocumentVersion(link.updatedAt)\n link.deletedAt = linkVersion\n link.updatedAt = linkVersion\n }\n }], { transaction: true, label: 'documents.document.instantiate.undo' })\n if (deletedLinks.length > 0) {\n await Promise.all(deletedLinks.map((link) => bufferLinkMutationSideEffects(\n ctx,\n 'deleted',\n link,\n { undo: true },\n )))\n }\n if (deletedDocument) {\n await bufferDocumentMutationSideEffects(ctx, 'deleted', deletedDocument, { undo: true })\n }\n },\n}\n\nregisterCommand(instantiateDocumentCommand)\n\nexport { instantiateDocumentCommand }\n"],
5
+ "mappings": "AAAA,SAAS,gBAAgB;AAEzB,SAAS,SAAS;AAClB,SAAS,uBAA4C;AACrD,SAAS,uBAAuB;AAChC,SAAS,0BAA0B;AACnC,SAAS,uBAAuB,0BAA0B;AAC1D,SAAS,qBAAqB;AAC9B;AAAA,EACE;AAAA,EACA;AAAA,OACK;AACP,SAAS,2BAA2B;AACpC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,yCAAyC;AAClD,SAAS,4BAA4B;AACrC;AAAA,EACE;AAA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