@aopslab/domain-dm-docman 0.1.2
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/LICENSE +202 -0
- package/NOTICE +6 -0
- package/README.md +26 -0
- package/dist/application/errors/AssetServiceError.d.ts +20 -0
- package/dist/application/errors/AssetServiceError.js +13 -0
- package/dist/application/errors/AssetVersionServiceError.d.ts +20 -0
- package/dist/application/errors/AssetVersionServiceError.js +13 -0
- package/dist/application/errors/DocumentGroupServiceError.d.ts +20 -0
- package/dist/application/errors/DocumentGroupServiceError.js +16 -0
- package/dist/application/errors/DocumentSectionLinkServiceError.d.ts +20 -0
- package/dist/application/errors/DocumentSectionLinkServiceError.js +16 -0
- package/dist/application/errors/DocumentServiceError.d.ts +20 -0
- package/dist/application/errors/DocumentServiceError.js +16 -0
- package/dist/application/errors/DocumentVersionServiceError.d.ts +20 -0
- package/dist/application/errors/DocumentVersionServiceError.js +16 -0
- package/dist/application/errors/EmbedServiceError.d.ts +20 -0
- package/dist/application/errors/EmbedServiceError.js +16 -0
- package/dist/application/errors/PageEmbedLinkServiceError.d.ts +20 -0
- package/dist/application/errors/PageEmbedLinkServiceError.js +16 -0
- package/dist/application/errors/PageServiceError.d.ts +20 -0
- package/dist/application/errors/PageServiceError.js +16 -0
- package/dist/application/errors/PageSnippetLinkServiceError.d.ts +20 -0
- package/dist/application/errors/PageSnippetLinkServiceError.js +16 -0
- package/dist/application/errors/PageVersionServiceError.d.ts +20 -0
- package/dist/application/errors/PageVersionServiceError.js +16 -0
- package/dist/application/errors/SectionPageLinkServiceError.d.ts +20 -0
- package/dist/application/errors/SectionPageLinkServiceError.js +16 -0
- package/dist/application/errors/SectionServiceError.d.ts +20 -0
- package/dist/application/errors/SectionServiceError.js +16 -0
- package/dist/application/errors/SnippetServiceError.d.ts +20 -0
- package/dist/application/errors/SnippetServiceError.js +16 -0
- package/dist/application/errors/index.d.ts +1 -0
- package/dist/application/errors/index.js +1 -0
- package/dist/application/factories/RepositoryFactoryAsset.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryAsset.js +7 -0
- package/dist/application/factories/RepositoryFactoryAssetVersion.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryAssetVersion.js +7 -0
- package/dist/application/factories/RepositoryFactoryDocument.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryDocument.js +7 -0
- package/dist/application/factories/RepositoryFactoryDocumentGroup.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryDocumentGroup.js +7 -0
- package/dist/application/factories/RepositoryFactoryDocumentIndexEntry.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryDocumentIndexEntry.js +7 -0
- package/dist/application/factories/RepositoryFactoryDocumentSectionLink.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryDocumentSectionLink.js +7 -0
- package/dist/application/factories/RepositoryFactoryDocumentVersion.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryDocumentVersion.js +7 -0
- package/dist/application/factories/RepositoryFactoryEmbed.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryEmbed.js +7 -0
- package/dist/application/factories/RepositoryFactoryPage.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryPage.js +7 -0
- package/dist/application/factories/RepositoryFactoryPageEmbedLink.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryPageEmbedLink.js +7 -0
- package/dist/application/factories/RepositoryFactoryPageSnippetLink.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryPageSnippetLink.js +7 -0
- package/dist/application/factories/RepositoryFactoryPageVersion.d.ts +4 -0
- package/dist/application/factories/RepositoryFactoryPageVersion.js +7 -0
- package/dist/application/factories/RepositoryFactorySection.d.ts +4 -0
- package/dist/application/factories/RepositoryFactorySection.js +7 -0
- package/dist/application/factories/RepositoryFactorySectionPageLink.d.ts +4 -0
- package/dist/application/factories/RepositoryFactorySectionPageLink.js +7 -0
- package/dist/application/factories/RepositoryFactorySnippet.d.ts +4 -0
- package/dist/application/factories/RepositoryFactorySnippet.js +7 -0
- package/dist/application/factories/ServiceAssetBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceAssetBuilder.js +80 -0
- package/dist/application/factories/ServiceAssetFactory.d.ts +11 -0
- package/dist/application/factories/ServiceAssetFactory.js +15 -0
- package/dist/application/factories/ServiceAssetVersionBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceAssetVersionBuilder.js +80 -0
- package/dist/application/factories/ServiceAssetVersionFactory.d.ts +11 -0
- package/dist/application/factories/ServiceAssetVersionFactory.js +15 -0
- package/dist/application/factories/ServiceDocumentBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceDocumentBuilder.js +83 -0
- package/dist/application/factories/ServiceDocumentFactory.d.ts +11 -0
- package/dist/application/factories/ServiceDocumentFactory.js +15 -0
- package/dist/application/factories/ServiceDocumentGroupBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceDocumentGroupBuilder.js +83 -0
- package/dist/application/factories/ServiceDocumentGroupFactory.d.ts +11 -0
- package/dist/application/factories/ServiceDocumentGroupFactory.js +15 -0
- package/dist/application/factories/ServiceDocumentSectionLinkBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceDocumentSectionLinkBuilder.js +83 -0
- package/dist/application/factories/ServiceDocumentSectionLinkFactory.d.ts +11 -0
- package/dist/application/factories/ServiceDocumentSectionLinkFactory.js +15 -0
- package/dist/application/factories/ServiceDocumentVersionBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceDocumentVersionBuilder.js +83 -0
- package/dist/application/factories/ServiceDocumentVersionFactory.d.ts +11 -0
- package/dist/application/factories/ServiceDocumentVersionFactory.js +15 -0
- package/dist/application/factories/ServiceEmbedBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceEmbedBuilder.js +83 -0
- package/dist/application/factories/ServiceEmbedFactory.d.ts +11 -0
- package/dist/application/factories/ServiceEmbedFactory.js +15 -0
- package/dist/application/factories/ServicePageBuilder.d.ts +30 -0
- package/dist/application/factories/ServicePageBuilder.js +83 -0
- package/dist/application/factories/ServicePageEmbedLinkBuilder.d.ts +30 -0
- package/dist/application/factories/ServicePageEmbedLinkBuilder.js +83 -0
- package/dist/application/factories/ServicePageEmbedLinkFactory.d.ts +11 -0
- package/dist/application/factories/ServicePageEmbedLinkFactory.js +15 -0
- package/dist/application/factories/ServicePageFactory.d.ts +11 -0
- package/dist/application/factories/ServicePageFactory.js +15 -0
- package/dist/application/factories/ServicePageSnippetLinkBuilder.d.ts +30 -0
- package/dist/application/factories/ServicePageSnippetLinkBuilder.js +83 -0
- package/dist/application/factories/ServicePageSnippetLinkFactory.d.ts +11 -0
- package/dist/application/factories/ServicePageSnippetLinkFactory.js +15 -0
- package/dist/application/factories/ServicePageVersionBuilder.d.ts +34 -0
- package/dist/application/factories/ServicePageVersionBuilder.js +121 -0
- package/dist/application/factories/ServicePageVersionFactory.d.ts +11 -0
- package/dist/application/factories/ServicePageVersionFactory.js +15 -0
- package/dist/application/factories/ServiceSectionBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceSectionBuilder.js +83 -0
- package/dist/application/factories/ServiceSectionFactory.d.ts +11 -0
- package/dist/application/factories/ServiceSectionFactory.js +15 -0
- package/dist/application/factories/ServiceSectionPageLinkBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceSectionPageLinkBuilder.js +83 -0
- package/dist/application/factories/ServiceSectionPageLinkFactory.d.ts +11 -0
- package/dist/application/factories/ServiceSectionPageLinkFactory.js +15 -0
- package/dist/application/factories/ServiceSnippetBuilder.d.ts +30 -0
- package/dist/application/factories/ServiceSnippetBuilder.js +83 -0
- package/dist/application/factories/ServiceSnippetFactory.d.ts +11 -0
- package/dist/application/factories/ServiceSnippetFactory.js +15 -0
- package/dist/application/factories/drizzleDialect.d.ts +16 -0
- package/dist/application/factories/drizzleDialect.js +36 -0
- package/dist/application/factories/index.d.ts +43 -0
- package/dist/application/factories/index.js +44 -0
- package/dist/application/ports/inbound/IAssetServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IAssetServicePort.js +1 -0
- package/dist/application/ports/inbound/IAssetVersionServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IAssetVersionServicePort.js +1 -0
- package/dist/application/ports/inbound/IDocumentGroupServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IDocumentGroupServicePort.js +1 -0
- package/dist/application/ports/inbound/IDocumentSectionLinkServicePort.d.ts +16 -0
- package/dist/application/ports/inbound/IDocumentSectionLinkServicePort.js +1 -0
- package/dist/application/ports/inbound/IDocumentServicePort.d.ts +300 -0
- package/dist/application/ports/inbound/IDocumentServicePort.js +1 -0
- package/dist/application/ports/inbound/IDocumentVersionServicePort.d.ts +106 -0
- package/dist/application/ports/inbound/IDocumentVersionServicePort.js +1 -0
- package/dist/application/ports/inbound/IEmbedServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IEmbedServicePort.js +1 -0
- package/dist/application/ports/inbound/IPageEmbedLinkServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IPageEmbedLinkServicePort.js +1 -0
- package/dist/application/ports/inbound/IPageServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IPageServicePort.js +1 -0
- package/dist/application/ports/inbound/IPageSnippetLinkServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IPageSnippetLinkServicePort.js +1 -0
- package/dist/application/ports/inbound/IPageVersionServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/IPageVersionServicePort.js +1 -0
- package/dist/application/ports/inbound/ISectionPageLinkServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/ISectionPageLinkServicePort.js +1 -0
- package/dist/application/ports/inbound/ISectionServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/ISectionServicePort.js +1 -0
- package/dist/application/ports/inbound/ISnippetServicePort.d.ts +14 -0
- package/dist/application/ports/inbound/ISnippetServicePort.js +1 -0
- package/dist/application/ports/inbound/index.d.ts +14 -0
- package/dist/application/ports/inbound/index.js +15 -0
- package/dist/application/ports/repository-ports/IRepositoryPortAsset.d.ts +5 -0
- package/dist/application/ports/repository-ports/IRepositoryPortAsset.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortAssetVersion.d.ts +5 -0
- package/dist/application/ports/repository-ports/IRepositoryPortAssetVersion.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocument.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocument.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentGroup.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentGroup.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentIndexEntry.d.ts +5 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentIndexEntry.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentSectionLink.d.ts +21 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentSectionLink.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentVersion.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortDocumentVersion.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortEmbed.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortEmbed.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPage.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPage.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPageEmbedLink.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPageEmbedLink.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPageSnippetLink.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPageSnippetLink.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPageVersion.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortPageVersion.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortSection.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortSection.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortSectionPageLink.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortSectionPageLink.js +1 -0
- package/dist/application/ports/repository-ports/IRepositoryPortSnippet.d.ts +10 -0
- package/dist/application/ports/repository-ports/IRepositoryPortSnippet.js +1 -0
- package/dist/application/ports/repository-ports/index.d.ts +15 -0
- package/dist/application/ports/repository-ports/index.js +16 -0
- package/dist/application/services/documentCascadeDelete.d.ts +47 -0
- package/dist/application/services/documentCascadeDelete.js +202 -0
- package/dist/application/services/documentComposeSupport.d.ts +30 -0
- package/dist/application/services/documentComposeSupport.js +285 -0
- package/dist/application/services/documentIndexSupport.d.ts +7 -0
- package/dist/application/services/documentIndexSupport.js +28 -0
- package/dist/application/services/documentPublishSupport.d.ts +14 -0
- package/dist/application/services/documentPublishSupport.js +39 -0
- package/dist/application/services/documentRetrievalAiSupport.d.ts +21 -0
- package/dist/application/services/documentRetrievalAiSupport.js +114 -0
- package/dist/application/services/index.d.ts +14 -0
- package/dist/application/services/index.js +15 -0
- package/dist/application/services/service.asset.d.ts +25 -0
- package/dist/application/services/service.asset.js +58 -0
- package/dist/application/services/service.assetVersion.d.ts +25 -0
- package/dist/application/services/service.assetVersion.js +58 -0
- package/dist/application/services/service.document.d.ts +167 -0
- package/dist/application/services/service.document.js +2860 -0
- package/dist/application/services/service.documentGroup.d.ts +25 -0
- package/dist/application/services/service.documentGroup.js +58 -0
- package/dist/application/services/service.documentSectionLink.d.ts +27 -0
- package/dist/application/services/service.documentSectionLink.js +69 -0
- package/dist/application/services/service.documentVersion.d.ts +66 -0
- package/dist/application/services/service.documentVersion.js +715 -0
- package/dist/application/services/service.embed.d.ts +25 -0
- package/dist/application/services/service.embed.js +58 -0
- package/dist/application/services/service.page.d.ts +25 -0
- package/dist/application/services/service.page.js +58 -0
- package/dist/application/services/service.pageEmbedLink.d.ts +25 -0
- package/dist/application/services/service.pageEmbedLink.js +58 -0
- package/dist/application/services/service.pageSnippetLink.d.ts +25 -0
- package/dist/application/services/service.pageSnippetLink.js +58 -0
- package/dist/application/services/service.pageVersion.d.ts +31 -0
- package/dist/application/services/service.pageVersion.js +114 -0
- package/dist/application/services/service.section.d.ts +25 -0
- package/dist/application/services/service.section.js +58 -0
- package/dist/application/services/service.sectionPageLink.d.ts +25 -0
- package/dist/application/services/service.sectionPageLink.js +58 -0
- package/dist/application/services/service.snippet.d.ts +25 -0
- package/dist/application/services/service.snippet.js +58 -0
- package/dist/application/services/service.zod-validation.d.ts +11 -0
- package/dist/application/services/service.zod-validation.js +14 -0
- package/dist/domain/domain.d.ts +8 -0
- package/dist/domain/domain.js +9 -0
- package/dist/domain/dto/index.d.ts +1 -0
- package/dist/domain/dto/index.js +1 -0
- package/dist/domain/index.d.ts +4 -0
- package/dist/domain/index.js +4 -0
- package/dist/domain/models/asset/IbmAsset.d.ts +5 -0
- package/dist/domain/models/asset/IbmAsset.js +18 -0
- package/dist/domain/models/asset/index.d.ts +2 -0
- package/dist/domain/models/asset/index.js +2 -0
- package/dist/domain/models/asset/zod.schema.d.ts +39 -0
- package/dist/domain/models/asset/zod.schema.js +22 -0
- package/dist/domain/models/assetVersion/IbmAssetVersion.d.ts +6 -0
- package/dist/domain/models/assetVersion/IbmAssetVersion.js +25 -0
- package/dist/domain/models/assetVersion/index.d.ts +2 -0
- package/dist/domain/models/assetVersion/index.js +2 -0
- package/dist/domain/models/assetVersion/zod.schema.d.ts +71 -0
- package/dist/domain/models/assetVersion/zod.schema.js +37 -0
- package/dist/domain/models/document/IbmDocument.d.ts +8 -0
- package/dist/domain/models/document/IbmDocument.js +30 -0
- package/dist/domain/models/document/index.d.ts +2 -0
- package/dist/domain/models/document/index.js +2 -0
- package/dist/domain/models/document/zod.schema.d.ts +157 -0
- package/dist/domain/models/document/zod.schema.js +31 -0
- package/dist/domain/models/documentGroup/IbmDocumentGroup.d.ts +5 -0
- package/dist/domain/models/documentGroup/IbmDocumentGroup.js +17 -0
- package/dist/domain/models/documentGroup/index.d.ts +2 -0
- package/dist/domain/models/documentGroup/index.js +2 -0
- package/dist/domain/models/documentGroup/zod.schema.d.ts +27 -0
- package/dist/domain/models/documentGroup/zod.schema.js +22 -0
- package/dist/domain/models/documentIndexEntry/IbmDocumentIndexEntry.d.ts +6 -0
- package/dist/domain/models/documentIndexEntry/IbmDocumentIndexEntry.js +50 -0
- package/dist/domain/models/documentIndexEntry/index.d.ts +2 -0
- package/dist/domain/models/documentIndexEntry/index.js +2 -0
- package/dist/domain/models/documentIndexEntry/zod.schema.d.ts +112 -0
- package/dist/domain/models/documentIndexEntry/zod.schema.js +55 -0
- package/dist/domain/models/documentSectionLink/IbmDocumentSectionLink.d.ts +5 -0
- package/dist/domain/models/documentSectionLink/IbmDocumentSectionLink.js +23 -0
- package/dist/domain/models/documentSectionLink/index.d.ts +2 -0
- package/dist/domain/models/documentSectionLink/index.js +2 -0
- package/dist/domain/models/documentSectionLink/zod.schema.d.ts +65 -0
- package/dist/domain/models/documentSectionLink/zod.schema.js +80 -0
- package/dist/domain/models/documentVersion/IbmDocumentVersion.d.ts +8 -0
- package/dist/domain/models/documentVersion/IbmDocumentVersion.js +25 -0
- package/dist/domain/models/documentVersion/index.d.ts +2 -0
- package/dist/domain/models/documentVersion/index.js +2 -0
- package/dist/domain/models/documentVersion/zod.schema.d.ts +75 -0
- package/dist/domain/models/documentVersion/zod.schema.js +26 -0
- package/dist/domain/models/embed/IbmEmbed.d.ts +5 -0
- package/dist/domain/models/embed/IbmEmbed.js +19 -0
- package/dist/domain/models/embed/index.d.ts +2 -0
- package/dist/domain/models/embed/index.js +2 -0
- package/dist/domain/models/embed/zod.schema.d.ts +39 -0
- package/dist/domain/models/embed/zod.schema.js +24 -0
- package/dist/domain/models/index.d.ts +15 -0
- package/dist/domain/models/index.js +16 -0
- package/dist/domain/models/page/IbmPage.d.ts +8 -0
- package/dist/domain/models/page/IbmPage.js +20 -0
- package/dist/domain/models/page/index.d.ts +2 -0
- package/dist/domain/models/page/index.js +2 -0
- package/dist/domain/models/page/zod.schema.d.ts +57 -0
- package/dist/domain/models/page/zod.schema.js +21 -0
- package/dist/domain/models/pageEmbedLink/IbmPageEmbedLink.d.ts +5 -0
- package/dist/domain/models/pageEmbedLink/IbmPageEmbedLink.js +14 -0
- package/dist/domain/models/pageEmbedLink/index.d.ts +2 -0
- package/dist/domain/models/pageEmbedLink/index.js +2 -0
- package/dist/domain/models/pageEmbedLink/zod.schema.d.ts +21 -0
- package/dist/domain/models/pageEmbedLink/zod.schema.js +19 -0
- package/dist/domain/models/pageSnippetLink/IbmPageSnippetLink.d.ts +5 -0
- package/dist/domain/models/pageSnippetLink/IbmPageSnippetLink.js +15 -0
- package/dist/domain/models/pageSnippetLink/index.d.ts +2 -0
- package/dist/domain/models/pageSnippetLink/index.js +2 -0
- package/dist/domain/models/pageSnippetLink/zod.schema.d.ts +23 -0
- package/dist/domain/models/pageSnippetLink/zod.schema.js +20 -0
- package/dist/domain/models/pageVersion/IbmPageVersion.d.ts +8 -0
- package/dist/domain/models/pageVersion/IbmPageVersion.js +23 -0
- package/dist/domain/models/pageVersion/index.d.ts +2 -0
- package/dist/domain/models/pageVersion/index.js +2 -0
- package/dist/domain/models/pageVersion/zod.schema.d.ts +77 -0
- package/dist/domain/models/pageVersion/zod.schema.js +24 -0
- package/dist/domain/models/section/IbmSection.d.ts +8 -0
- package/dist/domain/models/section/IbmSection.js +20 -0
- package/dist/domain/models/section/index.d.ts +2 -0
- package/dist/domain/models/section/index.js +2 -0
- package/dist/domain/models/section/zod.schema.d.ts +57 -0
- package/dist/domain/models/section/zod.schema.js +21 -0
- package/dist/domain/models/sectionPageLink/IbmSectionPageLink.d.ts +5 -0
- package/dist/domain/models/sectionPageLink/IbmSectionPageLink.js +18 -0
- package/dist/domain/models/sectionPageLink/index.d.ts +2 -0
- package/dist/domain/models/sectionPageLink/index.js +2 -0
- package/dist/domain/models/sectionPageLink/zod.schema.d.ts +29 -0
- package/dist/domain/models/sectionPageLink/zod.schema.js +23 -0
- package/dist/domain/models/snippet/IbmSnippet.d.ts +5 -0
- package/dist/domain/models/snippet/IbmSnippet.js +17 -0
- package/dist/domain/models/snippet/index.d.ts +2 -0
- package/dist/domain/models/snippet/index.js +2 -0
- package/dist/domain/models/snippet/zod.schema.d.ts +27 -0
- package/dist/domain/models/snippet/zod.schema.js +22 -0
- package/dist/domain/types.d.ts +1 -0
- package/dist/domain/types.js +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/infrastructure/db/asset/drizzle/drizzle.mapper.asset.d.ts +31 -0
- package/dist/infrastructure/db/asset/drizzle/drizzle.mapper.asset.js +6 -0
- package/dist/infrastructure/db/asset/drizzle/drizzle.schema.asset.d.ts +250 -0
- package/dist/infrastructure/db/asset/drizzle/drizzle.schema.asset.js +24 -0
- package/dist/infrastructure/db/asset/drizzle/drizzle.schema.asset.sqlite.d.ts +272 -0
- package/dist/infrastructure/db/asset/drizzle/drizzle.schema.asset.sqlite.js +25 -0
- package/dist/infrastructure/db/asset/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/asset/drizzle/index.js +2 -0
- package/dist/infrastructure/db/assetVersion/drizzle/drizzle.mapper.assetVersion.d.ts +45 -0
- package/dist/infrastructure/db/assetVersion/drizzle/drizzle.mapper.assetVersion.js +6 -0
- package/dist/infrastructure/db/assetVersion/drizzle/drizzle.schema.assetVersion.d.ts +371 -0
- package/dist/infrastructure/db/assetVersion/drizzle/drizzle.schema.assetVersion.js +30 -0
- package/dist/infrastructure/db/assetVersion/drizzle/drizzle.schema.assetVersion.sqlite.d.ts +397 -0
- package/dist/infrastructure/db/assetVersion/drizzle/drizzle.schema.assetVersion.sqlite.js +31 -0
- package/dist/infrastructure/db/assetVersion/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/assetVersion/drizzle/index.js +2 -0
- package/dist/infrastructure/db/document/drizzle/drizzle.mapper.document.d.ts +98 -0
- package/dist/infrastructure/db/document/drizzle/drizzle.mapper.document.js +6 -0
- package/dist/infrastructure/db/document/drizzle/drizzle.schema.document.d.ts +394 -0
- package/dist/infrastructure/db/document/drizzle/drizzle.schema.document.js +34 -0
- package/dist/infrastructure/db/document/drizzle/drizzle.schema.document.sqlite.d.ts +424 -0
- package/dist/infrastructure/db/document/drizzle/drizzle.schema.document.sqlite.js +35 -0
- package/dist/infrastructure/db/document/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/document/drizzle/index.js +2 -0
- package/dist/infrastructure/db/documentGroup/drizzle/drizzle.mapper.documentGroup.d.ts +29 -0
- package/dist/infrastructure/db/documentGroup/drizzle/drizzle.mapper.documentGroup.js +6 -0
- package/dist/infrastructure/db/documentGroup/drizzle/drizzle.schema.documentGroup.d.ts +233 -0
- package/dist/infrastructure/db/documentGroup/drizzle/drizzle.schema.documentGroup.js +22 -0
- package/dist/infrastructure/db/documentGroup/drizzle/drizzle.schema.documentGroup.sqlite.d.ts +253 -0
- package/dist/infrastructure/db/documentGroup/drizzle/drizzle.schema.documentGroup.sqlite.js +23 -0
- package/dist/infrastructure/db/documentGroup/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/documentGroup/drizzle/index.js +2 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/drizzle.mapper.documentIndexEntry.d.ts +95 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/drizzle.mapper.documentIndexEntry.js +12 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/drizzle.schema.documentIndexEntry.d.ts +792 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/drizzle.schema.documentIndexEntry.js +57 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/drizzle.schema.documentIndexEntry.sqlite.d.ts +854 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/drizzle.schema.documentIndexEntry.sqlite.js +58 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/documentIndexEntry/drizzle/index.js +2 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/drizzle.mapper.documentSectionLink.d.ts +41 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/drizzle.mapper.documentSectionLink.js +12 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/drizzle.schema.documentSectionLink.d.ts +335 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/drizzle.schema.documentSectionLink.js +29 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/drizzle.schema.documentSectionLink.sqlite.d.ts +357 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/drizzle.schema.documentSectionLink.sqlite.js +30 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/documentSectionLink/drizzle/index.js +2 -0
- package/dist/infrastructure/db/documentVersion/drizzle/drizzle.mapper.documentVersion.d.ts +54 -0
- package/dist/infrastructure/db/documentVersion/drizzle/drizzle.mapper.documentVersion.js +7 -0
- package/dist/infrastructure/db/documentVersion/drizzle/drizzle.schema.documentVersion.d.ts +301 -0
- package/dist/infrastructure/db/documentVersion/drizzle/drizzle.schema.documentVersion.js +30 -0
- package/dist/infrastructure/db/documentVersion/drizzle/drizzle.schema.documentVersion.sqlite.d.ts +323 -0
- package/dist/infrastructure/db/documentVersion/drizzle/drizzle.schema.documentVersion.sqlite.js +27 -0
- package/dist/infrastructure/db/documentVersion/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/documentVersion/drizzle/index.js +2 -0
- package/dist/infrastructure/db/domain-naming.d.ts +2 -0
- package/dist/infrastructure/db/domain-naming.js +57 -0
- package/dist/infrastructure/db/embed/drizzle/drizzle.mapper.embed.d.ts +33 -0
- package/dist/infrastructure/db/embed/drizzle/drizzle.mapper.embed.js +5 -0
- package/dist/infrastructure/db/embed/drizzle/drizzle.schema.embed.d.ts +267 -0
- package/dist/infrastructure/db/embed/drizzle/drizzle.schema.embed.js +24 -0
- package/dist/infrastructure/db/embed/drizzle/drizzle.schema.embed.sqlite.d.ts +291 -0
- package/dist/infrastructure/db/embed/drizzle/drizzle.schema.embed.sqlite.js +25 -0
- package/dist/infrastructure/db/embed/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/embed/drizzle/index.js +2 -0
- package/dist/infrastructure/db/page/drizzle/drizzle.mapper.page.d.ts +44 -0
- package/dist/infrastructure/db/page/drizzle/drizzle.mapper.page.js +5 -0
- package/dist/infrastructure/db/page/drizzle/drizzle.schema.page.d.ts +218 -0
- package/dist/infrastructure/db/page/drizzle/drizzle.schema.page.js +20 -0
- package/dist/infrastructure/db/page/drizzle/drizzle.schema.page.sqlite.d.ts +234 -0
- package/dist/infrastructure/db/page/drizzle/drizzle.schema.page.sqlite.js +21 -0
- package/dist/infrastructure/db/page/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/page/drizzle/index.js +2 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/drizzle.mapper.pageEmbedLink.d.ts +23 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/drizzle.mapper.pageEmbedLink.js +5 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/drizzle.schema.pageEmbedLink.d.ts +180 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/drizzle.schema.pageEmbedLink.js +18 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/drizzle.schema.pageEmbedLink.sqlite.d.ts +194 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/drizzle.schema.pageEmbedLink.sqlite.js +19 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/pageEmbedLink/drizzle/index.js +2 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/drizzle.mapper.pageSnippetLink.d.ts +25 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/drizzle.mapper.pageSnippetLink.js +7 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/drizzle.schema.pageSnippetLink.d.ts +197 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/drizzle.schema.pageSnippetLink.js +19 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/drizzle.schema.pageSnippetLink.sqlite.d.ts +211 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/drizzle.schema.pageSnippetLink.sqlite.js +20 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/pageSnippetLink/drizzle/index.js +2 -0
- package/dist/infrastructure/db/pageVersion/drizzle/drizzle.mapper.pageVersion.d.ts +50 -0
- package/dist/infrastructure/db/pageVersion/drizzle/drizzle.mapper.pageVersion.js +6 -0
- package/dist/infrastructure/db/pageVersion/drizzle/drizzle.schema.pageVersion.d.ts +271 -0
- package/dist/infrastructure/db/pageVersion/drizzle/drizzle.schema.pageVersion.js +23 -0
- package/dist/infrastructure/db/pageVersion/drizzle/drizzle.schema.pageVersion.sqlite.d.ts +289 -0
- package/dist/infrastructure/db/pageVersion/drizzle/drizzle.schema.pageVersion.sqlite.js +24 -0
- package/dist/infrastructure/db/pageVersion/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/pageVersion/drizzle/index.js +2 -0
- package/dist/infrastructure/db/section/drizzle/drizzle.mapper.section.d.ts +44 -0
- package/dist/infrastructure/db/section/drizzle/drizzle.mapper.section.js +5 -0
- package/dist/infrastructure/db/section/drizzle/drizzle.schema.section.d.ts +216 -0
- package/dist/infrastructure/db/section/drizzle/drizzle.schema.section.js +20 -0
- package/dist/infrastructure/db/section/drizzle/drizzle.schema.section.sqlite.d.ts +234 -0
- package/dist/infrastructure/db/section/drizzle/drizzle.schema.section.sqlite.js +21 -0
- package/dist/infrastructure/db/section/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/section/drizzle/index.js +2 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/drizzle.mapper.sectionPageLink.d.ts +31 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/drizzle.mapper.sectionPageLink.js +7 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/drizzle.schema.sectionPageLink.d.ts +248 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/drizzle.schema.sectionPageLink.js +22 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/drizzle.schema.sectionPageLink.sqlite.d.ts +264 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/drizzle.schema.sectionPageLink.sqlite.js +23 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/sectionPageLink/drizzle/index.js +2 -0
- package/dist/infrastructure/db/snippet/drizzle/drizzle.mapper.snippet.d.ts +29 -0
- package/dist/infrastructure/db/snippet/drizzle/drizzle.mapper.snippet.js +5 -0
- package/dist/infrastructure/db/snippet/drizzle/drizzle.schema.snippet.d.ts +233 -0
- package/dist/infrastructure/db/snippet/drizzle/drizzle.schema.snippet.js +22 -0
- package/dist/infrastructure/db/snippet/drizzle/drizzle.schema.snippet.sqlite.d.ts +253 -0
- package/dist/infrastructure/db/snippet/drizzle/drizzle.schema.snippet.sqlite.js +23 -0
- package/dist/infrastructure/db/snippet/drizzle/index.d.ts +2 -0
- package/dist/infrastructure/db/snippet/drizzle/index.js +2 -0
- package/dist/infrastructure/repositories/asset/drizzle/AssetDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/asset/drizzle/AssetDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/asset/drizzle/AssetDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/asset/drizzle/AssetDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/assetVersion/drizzle/AssetVersionDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/assetVersion/drizzle/AssetVersionDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/assetVersion/drizzle/AssetVersionDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/assetVersion/drizzle/AssetVersionDrizzleSqliteRepo.js +12 -0
- package/dist/infrastructure/repositories/document/drizzle/DocumentDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/document/drizzle/DocumentDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/document/drizzle/DocumentDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/document/drizzle/DocumentDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/documentGroup/drizzle/DocumentGroupDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/documentGroup/drizzle/DocumentGroupDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/documentGroup/drizzle/DocumentGroupDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/documentGroup/drizzle/DocumentGroupDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/documentIndexEntry/drizzle/DocumentIndexEntryDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/documentIndexEntry/drizzle/DocumentIndexEntryDrizzleRepo.js +12 -0
- package/dist/infrastructure/repositories/documentIndexEntry/drizzle/DocumentIndexEntryDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/documentIndexEntry/drizzle/DocumentIndexEntryDrizzleSqliteRepo.js +12 -0
- package/dist/infrastructure/repositories/documentSectionLink/drizzle/DocumentSectionLinkDrizzleRepo.d.ts +15 -0
- package/dist/infrastructure/repositories/documentSectionLink/drizzle/DocumentSectionLinkDrizzleRepo.js +41 -0
- package/dist/infrastructure/repositories/documentSectionLink/drizzle/DocumentSectionLinkDrizzleSqliteRepo.d.ts +15 -0
- package/dist/infrastructure/repositories/documentSectionLink/drizzle/DocumentSectionLinkDrizzleSqliteRepo.js +40 -0
- package/dist/infrastructure/repositories/documentVersion/drizzle/DocumentVersionDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/documentVersion/drizzle/DocumentVersionDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/documentVersion/drizzle/DocumentVersionDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/documentVersion/drizzle/DocumentVersionDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/embed/drizzle/EmbedDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/embed/drizzle/EmbedDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/embed/drizzle/EmbedDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/embed/drizzle/EmbedDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/index.d.ts +30 -0
- package/dist/infrastructure/repositories/index.js +31 -0
- package/dist/infrastructure/repositories/page/drizzle/PageDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/page/drizzle/PageDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/page/drizzle/PageDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/page/drizzle/PageDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/pageEmbedLink/drizzle/PageEmbedLinkDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/pageEmbedLink/drizzle/PageEmbedLinkDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/pageEmbedLink/drizzle/PageEmbedLinkDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/pageEmbedLink/drizzle/PageEmbedLinkDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/pageSnippetLink/drizzle/PageSnippetLinkDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/pageSnippetLink/drizzle/PageSnippetLinkDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/pageSnippetLink/drizzle/PageSnippetLinkDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/pageSnippetLink/drizzle/PageSnippetLinkDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/pageVersion/drizzle/PageVersionDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/pageVersion/drizzle/PageVersionDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/pageVersion/drizzle/PageVersionDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/pageVersion/drizzle/PageVersionDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/section/drizzle/SectionDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/section/drizzle/SectionDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/section/drizzle/SectionDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/section/drizzle/SectionDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/sectionPageLink/drizzle/SectionPageLinkDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/sectionPageLink/drizzle/SectionPageLinkDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/sectionPageLink/drizzle/SectionPageLinkDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/sectionPageLink/drizzle/SectionPageLinkDrizzleSqliteRepo.js +8 -0
- package/dist/infrastructure/repositories/snippet/drizzle/SnippetDrizzleRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/snippet/drizzle/SnippetDrizzleRepo.js +8 -0
- package/dist/infrastructure/repositories/snippet/drizzle/SnippetDrizzleSqliteRepo.d.ts +12 -0
- package/dist/infrastructure/repositories/snippet/drizzle/SnippetDrizzleSqliteRepo.js +8 -0
- package/dist/public/factories/index.d.ts +2 -0
- package/dist/public/factories/index.js +2 -0
- package/dist/public/index.d.ts +5 -0
- package/dist/public/index.js +5 -0
- package/dist/public/models/index.d.ts +3 -0
- package/dist/public/models/index.js +4 -0
- package/dist/public/ports/index.d.ts +1 -0
- package/dist/public/ports/index.js +2 -0
- package/dist/public/repository-ports/index.d.ts +1 -0
- package/dist/public/repository-ports/index.js +2 -0
- package/dist/public/services/index.d.ts +1 -0
- package/dist/public/services/index.js +2 -0
- package/dist/types.d.ts +1 -0
- package/dist/types.js +1 -0
- package/package.json +84 -0
|
@@ -0,0 +1,715 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { Effect } from 'effect';
|
|
3
|
+
import { pipe } from 'effect/Function';
|
|
4
|
+
import { validateInput, XfErrorFactory, effectErrorInfo } from '@aopslab/xf-core';
|
|
5
|
+
import { bmDocumentVersionMlgFields, documentVersionZodSchemaInsert } from '../../domain/models/index.js';
|
|
6
|
+
import { validateBmInputWithSchema } from './service.zod-validation.js';
|
|
7
|
+
import { mapDbError, runInTransactionEffect } from '@aopslab/xf-db';
|
|
8
|
+
import { deleteDocumentVersionCascade, } from './documentCascadeDelete.js';
|
|
9
|
+
export class DocumentVersionService {
|
|
10
|
+
documentVersionRepository;
|
|
11
|
+
documentRepository;
|
|
12
|
+
documentSectionLinkRepository;
|
|
13
|
+
sectionRepository;
|
|
14
|
+
pageRepository;
|
|
15
|
+
pageVersionRepository;
|
|
16
|
+
sectionPageLinkRepository;
|
|
17
|
+
pageSnippetLinkRepository;
|
|
18
|
+
pageEmbedLinkRepository;
|
|
19
|
+
unitOfWork;
|
|
20
|
+
logger;
|
|
21
|
+
locale;
|
|
22
|
+
constructor(options) {
|
|
23
|
+
const deps = options.serviceDependencies ?? {};
|
|
24
|
+
this.documentVersionRepository = options.documentVersionRepository;
|
|
25
|
+
this.documentRepository = deps.documentRepository;
|
|
26
|
+
this.documentSectionLinkRepository = deps.documentSectionLinkRepository;
|
|
27
|
+
this.sectionRepository = deps.sectionRepository;
|
|
28
|
+
this.pageRepository = deps.pageRepository;
|
|
29
|
+
this.pageVersionRepository = deps.pageVersionRepository;
|
|
30
|
+
this.sectionPageLinkRepository = deps.sectionPageLinkRepository;
|
|
31
|
+
this.pageSnippetLinkRepository = deps.pageSnippetLinkRepository;
|
|
32
|
+
this.pageEmbedLinkRepository = deps.pageEmbedLinkRepository;
|
|
33
|
+
this.unitOfWork = options.unitOfWork;
|
|
34
|
+
this.logger = options.logger?.child({ module: this.constructor.name });
|
|
35
|
+
this.locale = options.locale;
|
|
36
|
+
}
|
|
37
|
+
bindRepositoryContext(repository, ctx) {
|
|
38
|
+
if (!ctx || !repository || typeof repository !== 'object')
|
|
39
|
+
return false;
|
|
40
|
+
return (typeof repository.setCtx === 'function' &&
|
|
41
|
+
typeof repository.clearCtx === 'function');
|
|
42
|
+
}
|
|
43
|
+
withRepositoryContext(repositories, ctx, program) {
|
|
44
|
+
const scoped = repositories.filter((repository) => this.bindRepositoryContext(repository, ctx));
|
|
45
|
+
return Effect.acquireUseRelease(Effect.sync(() => {
|
|
46
|
+
for (const repository of scoped)
|
|
47
|
+
repository.setCtx(ctx);
|
|
48
|
+
}), () => program(), () => Effect.sync(() => {
|
|
49
|
+
for (const repository of scoped)
|
|
50
|
+
repository.clearCtx();
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
runHeadingImportWriteEffect(dependencies, program) {
|
|
54
|
+
if (!this.unitOfWork)
|
|
55
|
+
return program();
|
|
56
|
+
return runInTransactionEffect(this.unitOfWork, (ctx) => this.withRepositoryContext(Object.values(dependencies), ctx, program));
|
|
57
|
+
}
|
|
58
|
+
getById(id, options) {
|
|
59
|
+
const stage = 'DocumentVersionService::getById';
|
|
60
|
+
const optionsWithLocale = this.withLocaleOptions(options);
|
|
61
|
+
return pipe(validateInput(id, 'id', { stage }), Effect.flatMap((id) => this.documentVersionRepository.findById(id, optionsWithLocale).pipe(Effect.mapError(mapDbError({ stage, operation: 'findById', factory: XfErrorFactory.notFound })))), Effect.tapError((e) => Effect.sync(() => {
|
|
62
|
+
const info = effectErrorInfo(e);
|
|
63
|
+
this.logger?.error({ error: info.unwrapped, stage }, 'Error in getById');
|
|
64
|
+
})));
|
|
65
|
+
}
|
|
66
|
+
create(data) {
|
|
67
|
+
const stage = 'DocumentVersionService::create';
|
|
68
|
+
return pipe(validateInput(data, 'data', { stage }), Effect.flatMap((data) => validateBmInputWithSchema({
|
|
69
|
+
input: data,
|
|
70
|
+
schema: documentVersionZodSchemaInsert,
|
|
71
|
+
stage,
|
|
72
|
+
operation: 'DocumentVersionService::create.documentVersionZodSchemaInsert',
|
|
73
|
+
field: 'data',
|
|
74
|
+
})), Effect.flatMap((data) => this.ensureVersionIsUniqueForDocument(data, stage)), Effect.flatMap((data) => this.documentVersionRepository.create(data).pipe(Effect.mapError(mapDbError({ stage, operation: 'create', factory: XfErrorFactory.createFailed })))));
|
|
75
|
+
}
|
|
76
|
+
listDocumentVersions(filter = {}, options) {
|
|
77
|
+
const stage = 'DocumentVersionService::listDocumentVersions';
|
|
78
|
+
const optionsWithLocale = this.withLocaleOptions(options);
|
|
79
|
+
return pipe(validateInput(filter, 'filter', { stage }), Effect.flatMap((filter) => this.documentVersionRepository.find({ matchEq: filter, options: optionsWithLocale }).pipe(Effect.mapError(mapDbError({ stage, operation: 'find', factory: XfErrorFactory.notFound })))), Effect.tapError((e) => Effect.sync(() => {
|
|
80
|
+
const info = effectErrorInfo(e);
|
|
81
|
+
this.logger?.error({ error: info.unwrapped, stage }, 'Error in listDocumentVersions');
|
|
82
|
+
})));
|
|
83
|
+
}
|
|
84
|
+
updateDocumentVersion(id, patch) {
|
|
85
|
+
const stage = 'DocumentVersionService::updateDocumentVersion';
|
|
86
|
+
if (!patch || Object.keys(patch).length === 0) {
|
|
87
|
+
return Effect.fail(XfErrorFactory.inputRequired({ field: 'patch', stage }));
|
|
88
|
+
}
|
|
89
|
+
return pipe(validateInput(id, 'id', { stage }), Effect.flatMap((entityId) => validateBmInputWithSchema({
|
|
90
|
+
input: patch,
|
|
91
|
+
schema: documentVersionZodSchemaInsert.partial().strict(),
|
|
92
|
+
stage,
|
|
93
|
+
operation: 'DocumentVersionService::updateDocumentVersion.documentVersionZodSchemaInsert.patch',
|
|
94
|
+
field: 'patch',
|
|
95
|
+
}).pipe(Effect.map(() => entityId))), Effect.flatMap((entityId) => this.documentVersionRepository.patchById(entityId, patch).pipe(Effect.mapError(mapDbError({ stage, operation: 'patchById', factory: XfErrorFactory.upsertFailed })))), Effect.tapError((e) => Effect.sync(() => {
|
|
96
|
+
const info = effectErrorInfo(e);
|
|
97
|
+
this.logger?.error({ error: info.unwrapped, stage }, 'Error in updateDocumentVersion');
|
|
98
|
+
})));
|
|
99
|
+
}
|
|
100
|
+
setCurrent(input) {
|
|
101
|
+
const stage = 'DocumentVersionService::setCurrent';
|
|
102
|
+
const self = this;
|
|
103
|
+
return pipe(validateInput(input, 'input', { stage }), Effect.flatMap((raw) => Effect.gen(function* (_) {
|
|
104
|
+
const validInput = raw;
|
|
105
|
+
if (!validInput.documentVersionId) {
|
|
106
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'documentVersionId', stage })));
|
|
107
|
+
}
|
|
108
|
+
// 1. Resolve target version.
|
|
109
|
+
const target = yield* _(self.documentVersionRepository.findById(validInput.documentVersionId).pipe(Effect.mapError(mapDbError({ stage, operation: 'findById(target)', factory: XfErrorFactory.notFound }))));
|
|
110
|
+
const targetId = target.id;
|
|
111
|
+
const targetDocumentId = target.documentId;
|
|
112
|
+
const targetTenantId = target.tenantId;
|
|
113
|
+
// 2. documentId guard (optional).
|
|
114
|
+
if (validInput.documentId && targetDocumentId !== validInput.documentId) {
|
|
115
|
+
return yield* _(Effect.fail(XfErrorFactory.upsertFailed({
|
|
116
|
+
stage,
|
|
117
|
+
message: `documentId guard mismatch: target.documentId=${targetDocumentId} but input.documentId=${validInput.documentId}`,
|
|
118
|
+
})));
|
|
119
|
+
}
|
|
120
|
+
// 3. Find current peers (all rows where isCurrent=true for the same document).
|
|
121
|
+
const currentPeers = yield* _(self.documentVersionRepository.find({
|
|
122
|
+
matchEq: { documentId: targetDocumentId, tenantId: targetTenantId, isCurrent: true },
|
|
123
|
+
}).pipe(Effect.mapError(mapDbError({ stage, operation: 'find(currentPeers)', factory: XfErrorFactory.upsertFailed }))));
|
|
124
|
+
// 4. expectedPreviousVersionId guard (optional).
|
|
125
|
+
if (validInput.expectedPreviousVersionId) {
|
|
126
|
+
const prevId = currentPeers.find((p) => p.id !== targetId)?.id;
|
|
127
|
+
if (prevId !== validInput.expectedPreviousVersionId) {
|
|
128
|
+
return yield* _(Effect.fail(XfErrorFactory.upsertFailed({
|
|
129
|
+
stage,
|
|
130
|
+
message: `expectedPreviousVersionId mismatch: actual previous current id=${prevId ?? 'null'}, expected=${validInput.expectedPreviousVersionId}`,
|
|
131
|
+
})));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
// 5. Compute desired state.
|
|
135
|
+
const publish = validInput.publish !== false; // default true
|
|
136
|
+
const wantPublishedAt = publish
|
|
137
|
+
? (typeof validInput.publishedAt === 'string'
|
|
138
|
+
? new Date(validInput.publishedAt)
|
|
139
|
+
: (validInput.publishedAt instanceof Date ? validInput.publishedAt : new Date()))
|
|
140
|
+
: target.publishedAt ?? null;
|
|
141
|
+
const targetAlreadyCurrent = target.isCurrent === true;
|
|
142
|
+
const targetAlreadyPublished = target.status === 'published';
|
|
143
|
+
const peersToClear = currentPeers.filter((p) => p.id !== targetId);
|
|
144
|
+
const changed = !targetAlreadyCurrent || peersToClear.length > 0 || (publish && !targetAlreadyPublished);
|
|
145
|
+
// 6. Idempotent short-circuit.
|
|
146
|
+
if (!changed) {
|
|
147
|
+
return {
|
|
148
|
+
documentId: targetDocumentId,
|
|
149
|
+
currentVersionId: targetId,
|
|
150
|
+
previousCurrentVersionIds: [],
|
|
151
|
+
changed: false,
|
|
152
|
+
publishedAt: target.publishedAt ?? null,
|
|
153
|
+
status: target.status ?? null,
|
|
154
|
+
warnings: [],
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
// 7. Clear peers.
|
|
158
|
+
const previousIds = [];
|
|
159
|
+
for (const peer of peersToClear) {
|
|
160
|
+
const peerId = peer.id;
|
|
161
|
+
yield* _(self.documentVersionRepository.patchById(peerId, { isCurrent: false }).pipe(Effect.mapError(mapDbError({ stage, operation: `patchById(peer=${peerId}, isCurrent=false)`, factory: XfErrorFactory.upsertFailed }))));
|
|
162
|
+
previousIds.push(peerId);
|
|
163
|
+
}
|
|
164
|
+
// 8. Patch target.
|
|
165
|
+
const targetPatch = { isCurrent: true };
|
|
166
|
+
if (publish) {
|
|
167
|
+
if (!targetAlreadyPublished)
|
|
168
|
+
targetPatch.status = 'published';
|
|
169
|
+
targetPatch.publishedAt = wantPublishedAt instanceof Date ? wantPublishedAt : new Date();
|
|
170
|
+
}
|
|
171
|
+
const updated = yield* _(self.documentVersionRepository.patchById(targetId, targetPatch).pipe(Effect.mapError(mapDbError({ stage, operation: 'patchById(target,setCurrent)', factory: XfErrorFactory.upsertFailed }))));
|
|
172
|
+
return {
|
|
173
|
+
documentId: updated.documentId,
|
|
174
|
+
currentVersionId: updated.id,
|
|
175
|
+
previousCurrentVersionIds: previousIds,
|
|
176
|
+
changed: true,
|
|
177
|
+
publishedAt: updated.publishedAt ?? null,
|
|
178
|
+
status: updated.status ?? null,
|
|
179
|
+
warnings: [],
|
|
180
|
+
};
|
|
181
|
+
})), Effect.tapError((e) => Effect.sync(() => {
|
|
182
|
+
const info = effectErrorInfo(e);
|
|
183
|
+
this.logger?.error({ error: info.unwrapped, stage }, 'Error in setCurrent');
|
|
184
|
+
})));
|
|
185
|
+
}
|
|
186
|
+
removeDocumentVersion(id) {
|
|
187
|
+
const stage = 'DocumentVersionService::removeDocumentVersion';
|
|
188
|
+
return pipe(validateInput(id, 'id', { stage }), Effect.flatMap((entityId) => this.documentVersionRepository.deleteById(entityId).pipe(Effect.mapError(mapDbError({ stage, operation: 'deleteById', factory: XfErrorFactory.upsertFailed })))), Effect.map(() => undefined));
|
|
189
|
+
}
|
|
190
|
+
removeDocumentVersionSafe(id) {
|
|
191
|
+
const stage = 'DocumentVersionService::removeDocumentVersionSafe';
|
|
192
|
+
return Effect.gen(this, function* (_) {
|
|
193
|
+
const entityId = yield* _(validateInput(id, 'id', { stage }));
|
|
194
|
+
const dependencies = yield* _(this.resolveCascadeDependencies(stage, 'removeDocumentVersionSafe'));
|
|
195
|
+
return yield* _((deleteDocumentVersionCascade(dependencies, entityId, stage).pipe(Effect.mapError((error) => this.normalizeCascadeError(stage, 'removeDocumentVersionSafe.cascade', error)))));
|
|
196
|
+
}).pipe(Effect.tapError((e) => Effect.sync(() => {
|
|
197
|
+
const info = effectErrorInfo(e);
|
|
198
|
+
this.logger?.error({ error: info.unwrapped, stage }, 'Error in removeDocumentVersionSafe');
|
|
199
|
+
})));
|
|
200
|
+
}
|
|
201
|
+
importHeadings(input) {
|
|
202
|
+
const stage = 'DocumentVersionService::importHeadings';
|
|
203
|
+
return Effect.gen(this, function* (_) {
|
|
204
|
+
const payload = yield* _(this.validateHeadingImportInput(input, stage));
|
|
205
|
+
const dependencies = yield* _(this.resolveHeadingImportDependencies(stage, 'importHeadings'));
|
|
206
|
+
const documentVersion = yield* _(dependencies.documentVersionRepository.findById(payload.documentVersionId).pipe(Effect.mapError(mapDbError({
|
|
207
|
+
stage,
|
|
208
|
+
operation: 'documentVersionRepository.findById',
|
|
209
|
+
factory: XfErrorFactory.notFound,
|
|
210
|
+
}))));
|
|
211
|
+
if (!documentVersion?.id) {
|
|
212
|
+
return yield* _(Effect.fail(XfErrorFactory.notFound({
|
|
213
|
+
stage,
|
|
214
|
+
operation: 'documentVersionRepository.findById',
|
|
215
|
+
message: 'Document version not found.',
|
|
216
|
+
identifier: { documentVersionId: payload.documentVersionId },
|
|
217
|
+
})));
|
|
218
|
+
}
|
|
219
|
+
const existingLinks = yield* _(dependencies.documentSectionLinkRepository.find({ matchEq: { documentVersionId: payload.documentVersionId } }).pipe(Effect.mapError(mapDbError({
|
|
220
|
+
stage,
|
|
221
|
+
operation: 'documentSectionLinkRepository.find',
|
|
222
|
+
factory: XfErrorFactory.notFound,
|
|
223
|
+
}))));
|
|
224
|
+
const existingPolicy = payload.options.existingGraphPolicy;
|
|
225
|
+
if (existingLinks.length > 0 && existingPolicy === 'error' && !payload.options.dryRun) {
|
|
226
|
+
return yield* _(Effect.fail(XfErrorFactory.upsertFailed({
|
|
227
|
+
stage,
|
|
228
|
+
operation: 'existingGraphPolicy',
|
|
229
|
+
message: 'Document version already has a section/page graph. Use append explicitly or import into a clean version.',
|
|
230
|
+
data: {
|
|
231
|
+
documentVersionId: payload.documentVersionId,
|
|
232
|
+
existingLinkCount: existingLinks.length,
|
|
233
|
+
existingGraphPolicy: existingPolicy,
|
|
234
|
+
},
|
|
235
|
+
})));
|
|
236
|
+
}
|
|
237
|
+
const plan = this.buildHeadingImportPlan(payload, existingLinks);
|
|
238
|
+
if (payload.options.dryRun) {
|
|
239
|
+
return this.buildHeadingImportResult(payload.documentVersionId, true, plan);
|
|
240
|
+
}
|
|
241
|
+
return yield* _(this.runHeadingImportWriteEffect(dependencies, () => Effect.gen(this, function* (_) {
|
|
242
|
+
const sections = [];
|
|
243
|
+
const pages = [];
|
|
244
|
+
const sectionPagePositions = new Map();
|
|
245
|
+
if (existingPolicy === 'replace') {
|
|
246
|
+
yield* _(this.deleteExistingDocumentVersionLinksForHeadingImport(dependencies, existingLinks, stage));
|
|
247
|
+
}
|
|
248
|
+
const importNode = (node, parentLinkId) => Effect.gen(this, function* (_) {
|
|
249
|
+
if (node.kind === 'section') {
|
|
250
|
+
const section = yield* _(dependencies.sectionRepository.create({
|
|
251
|
+
scopeId: payload.scopeId,
|
|
252
|
+
sectionUid: node.uid,
|
|
253
|
+
title: node.title,
|
|
254
|
+
slug: node.slug,
|
|
255
|
+
kind: 'container',
|
|
256
|
+
createdBy: payload.createdBy,
|
|
257
|
+
updatedBy: payload.updatedBy,
|
|
258
|
+
}).pipe(Effect.mapError(mapDbError({
|
|
259
|
+
stage,
|
|
260
|
+
operation: 'sectionRepository.create',
|
|
261
|
+
factory: XfErrorFactory.createFailed,
|
|
262
|
+
}))));
|
|
263
|
+
const link = yield* _(dependencies.documentSectionLinkRepository.create({
|
|
264
|
+
documentVersionId: payload.documentVersionId,
|
|
265
|
+
kind: 'section',
|
|
266
|
+
sectionId: section.id,
|
|
267
|
+
parentLinkId,
|
|
268
|
+
position: node.position,
|
|
269
|
+
depth: node.depth,
|
|
270
|
+
createdBy: payload.createdBy,
|
|
271
|
+
updatedBy: payload.updatedBy,
|
|
272
|
+
}).pipe(Effect.mapError(mapDbError({
|
|
273
|
+
stage,
|
|
274
|
+
operation: 'documentSectionLinkRepository.create(section)',
|
|
275
|
+
factory: XfErrorFactory.createFailed,
|
|
276
|
+
}))));
|
|
277
|
+
sections.push({
|
|
278
|
+
title: node.title,
|
|
279
|
+
slug: node.slug,
|
|
280
|
+
depth: node.depth,
|
|
281
|
+
position: node.position,
|
|
282
|
+
parentLinkId,
|
|
283
|
+
sectionId: section.id,
|
|
284
|
+
documentSectionLinkId: link.id,
|
|
285
|
+
});
|
|
286
|
+
for (const child of node.children) {
|
|
287
|
+
yield* _(importNode(child, link.id));
|
|
288
|
+
}
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
const page = yield* _(dependencies.pageRepository.create({
|
|
292
|
+
scopeId: payload.scopeId,
|
|
293
|
+
pageUid: node.uid,
|
|
294
|
+
title: node.title,
|
|
295
|
+
kind: 'content',
|
|
296
|
+
createdBy: payload.createdBy,
|
|
297
|
+
updatedBy: payload.updatedBy,
|
|
298
|
+
}).pipe(Effect.mapError(mapDbError({
|
|
299
|
+
stage,
|
|
300
|
+
operation: 'pageRepository.create',
|
|
301
|
+
factory: XfErrorFactory.createFailed,
|
|
302
|
+
}))));
|
|
303
|
+
const pageVersion = yield* _(dependencies.pageVersionRepository.create({
|
|
304
|
+
pageId: page.id,
|
|
305
|
+
version: 1,
|
|
306
|
+
title: node.title,
|
|
307
|
+
format: 'md',
|
|
308
|
+
content: node.bodyMarkdown,
|
|
309
|
+
status: 'draft',
|
|
310
|
+
createdBy: payload.createdBy,
|
|
311
|
+
updatedBy: payload.updatedBy,
|
|
312
|
+
}).pipe(Effect.mapError(mapDbError({
|
|
313
|
+
stage,
|
|
314
|
+
operation: 'pageVersionRepository.create',
|
|
315
|
+
factory: XfErrorFactory.createFailed,
|
|
316
|
+
}))));
|
|
317
|
+
const link = yield* _(dependencies.documentSectionLinkRepository.create({
|
|
318
|
+
documentVersionId: payload.documentVersionId,
|
|
319
|
+
kind: 'page',
|
|
320
|
+
pageVersionId: pageVersion.id,
|
|
321
|
+
parentLinkId,
|
|
322
|
+
position: node.position,
|
|
323
|
+
depth: node.depth,
|
|
324
|
+
createdBy: payload.createdBy,
|
|
325
|
+
updatedBy: payload.updatedBy,
|
|
326
|
+
}).pipe(Effect.mapError(mapDbError({
|
|
327
|
+
stage,
|
|
328
|
+
operation: 'documentSectionLinkRepository.create(page)',
|
|
329
|
+
factory: XfErrorFactory.createFailed,
|
|
330
|
+
}))));
|
|
331
|
+
let sectionPageLinkId;
|
|
332
|
+
if (parentLinkId) {
|
|
333
|
+
const parentSection = sections.find((section) => section.documentSectionLinkId === parentLinkId);
|
|
334
|
+
if (parentSection?.sectionId) {
|
|
335
|
+
const nextSectionPosition = (sectionPagePositions.get(parentSection.sectionId) ?? 0) + 1;
|
|
336
|
+
sectionPagePositions.set(parentSection.sectionId, nextSectionPosition);
|
|
337
|
+
const sectionPageLink = yield* _(dependencies.sectionPageLinkRepository.create({
|
|
338
|
+
sectionId: parentSection.sectionId,
|
|
339
|
+
pageVersionId: pageVersion.id,
|
|
340
|
+
position: nextSectionPosition,
|
|
341
|
+
createdBy: payload.createdBy,
|
|
342
|
+
updatedBy: payload.updatedBy,
|
|
343
|
+
}).pipe(Effect.mapError(mapDbError({
|
|
344
|
+
stage,
|
|
345
|
+
operation: 'sectionPageLinkRepository.create',
|
|
346
|
+
factory: XfErrorFactory.createFailed,
|
|
347
|
+
}))));
|
|
348
|
+
sectionPageLinkId = sectionPageLink.id;
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
pages.push({
|
|
352
|
+
title: node.title,
|
|
353
|
+
depth: node.depth,
|
|
354
|
+
position: node.position,
|
|
355
|
+
parentLinkId,
|
|
356
|
+
pageId: page.id,
|
|
357
|
+
pageVersionId: pageVersion.id,
|
|
358
|
+
documentSectionLinkId: link.id,
|
|
359
|
+
sectionPageLinkId,
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
for (const node of plan.nodes) {
|
|
363
|
+
yield* _(importNode(node, undefined));
|
|
364
|
+
}
|
|
365
|
+
return {
|
|
366
|
+
documentVersionId: payload.documentVersionId,
|
|
367
|
+
dryRun: false,
|
|
368
|
+
summary: {
|
|
369
|
+
sectionsCreated: sections.length,
|
|
370
|
+
pagesCreated: pages.length,
|
|
371
|
+
documentLinksCreated: sections.length + pages.length,
|
|
372
|
+
sectionPageLinksCreated: pages.filter((page) => Boolean(page.sectionPageLinkId)).length,
|
|
373
|
+
warnings: plan.warnings,
|
|
374
|
+
},
|
|
375
|
+
graph: { sections, pages },
|
|
376
|
+
};
|
|
377
|
+
})));
|
|
378
|
+
}).pipe(Effect.tapError((e) => Effect.sync(() => {
|
|
379
|
+
const info = effectErrorInfo(e);
|
|
380
|
+
this.logger?.error({ error: info.unwrapped, stage }, 'Error in importHeadings');
|
|
381
|
+
})));
|
|
382
|
+
}
|
|
383
|
+
validateHeadingImportInput(input, stage) {
|
|
384
|
+
return Effect.gen(this, function* (_) {
|
|
385
|
+
const payload = yield* _(validateInput(input, 'input', { stage }));
|
|
386
|
+
const documentVersionId = this.normalizeNonEmpty(payload.documentVersionId);
|
|
387
|
+
if (!documentVersionId) {
|
|
388
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'documentVersionId', stage })));
|
|
389
|
+
}
|
|
390
|
+
const scopeId = this.normalizeNonEmpty(payload.scopeId);
|
|
391
|
+
if (!scopeId) {
|
|
392
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'scopeId', stage })));
|
|
393
|
+
}
|
|
394
|
+
const parsedGraph = payload.parsedGraph;
|
|
395
|
+
if (!parsedGraph || !Array.isArray(parsedGraph.nodes)) {
|
|
396
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({
|
|
397
|
+
field: 'parsedGraph.nodes',
|
|
398
|
+
stage,
|
|
399
|
+
message: 'parsedGraph.nodes must be an array.',
|
|
400
|
+
})));
|
|
401
|
+
}
|
|
402
|
+
const options = payload.options ?? {};
|
|
403
|
+
const existingGraphPolicy = options.existingGraphPolicy ?? 'error';
|
|
404
|
+
const slugStrategy = options.slugStrategy ?? 'hash-suffix-on-collision';
|
|
405
|
+
const bodyAssignment = options.bodyAssignment ?? 'leaf-page-content';
|
|
406
|
+
const headingToPagePolicy = options.headingToPagePolicy ?? 'h4-and-below';
|
|
407
|
+
if (!['error', 'append', 'replace'].includes(existingGraphPolicy)) {
|
|
408
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'options.existingGraphPolicy', stage })));
|
|
409
|
+
}
|
|
410
|
+
if (!['hash-suffix-on-collision', 'kebab-from-title'].includes(slugStrategy)) {
|
|
411
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'options.slugStrategy', stage })));
|
|
412
|
+
}
|
|
413
|
+
if (bodyAssignment !== 'leaf-page-content') {
|
|
414
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'options.bodyAssignment', stage })));
|
|
415
|
+
}
|
|
416
|
+
if (headingToPagePolicy !== 'h4-and-below') {
|
|
417
|
+
return yield* _(Effect.fail(XfErrorFactory.inputRequired({ field: 'options.headingToPagePolicy', stage })));
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
documentVersionId,
|
|
421
|
+
scopeId,
|
|
422
|
+
parsedGraph,
|
|
423
|
+
options: {
|
|
424
|
+
dryRun: options.dryRun === true,
|
|
425
|
+
existingGraphPolicy,
|
|
426
|
+
slugStrategy,
|
|
427
|
+
bodyAssignment,
|
|
428
|
+
headingToPagePolicy,
|
|
429
|
+
synthesizeOverviewPages: options.synthesizeOverviewPages === true,
|
|
430
|
+
},
|
|
431
|
+
createdBy: this.normalizeNonEmpty(payload.createdBy),
|
|
432
|
+
updatedBy: this.normalizeNonEmpty(payload.updatedBy) ?? this.normalizeNonEmpty(payload.createdBy),
|
|
433
|
+
};
|
|
434
|
+
});
|
|
435
|
+
}
|
|
436
|
+
resolveHeadingImportDependencies(stage, operation) {
|
|
437
|
+
return Effect.gen(this, function* (_) {
|
|
438
|
+
return {
|
|
439
|
+
documentVersionRepository: this.documentVersionRepository,
|
|
440
|
+
documentSectionLinkRepository: yield* _(this.requireDependency(this.documentSectionLinkRepository, 'documentSectionLinkRepository', stage, operation)),
|
|
441
|
+
sectionRepository: yield* _(this.requireDependency(this.sectionRepository, 'sectionRepository', stage, operation)),
|
|
442
|
+
pageRepository: yield* _(this.requireDependency(this.pageRepository, 'pageRepository', stage, operation)),
|
|
443
|
+
pageVersionRepository: yield* _(this.requireDependency(this.pageVersionRepository, 'pageVersionRepository', stage, operation)),
|
|
444
|
+
sectionPageLinkRepository: yield* _(this.requireDependency(this.sectionPageLinkRepository, 'sectionPageLinkRepository', stage, operation)),
|
|
445
|
+
};
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
buildHeadingImportPlan(input, existingLinks) {
|
|
449
|
+
const warnings = [];
|
|
450
|
+
if (existingLinks.length > 0 && input.options.existingGraphPolicy === 'error') {
|
|
451
|
+
warnings.push({
|
|
452
|
+
code: 'existing-graph-present',
|
|
453
|
+
message: `Document version already has ${existingLinks.length} outline link(s). Apply is blocked unless append or replace is explicit.`,
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
if (existingLinks.length > 0 && input.options.existingGraphPolicy === 'replace') {
|
|
457
|
+
warnings.push({
|
|
458
|
+
code: 'existing-graph-will-be-replaced',
|
|
459
|
+
message: `Replace import will remove ${existingLinks.length} existing outline link(s) from this document version before writing the new graph.`,
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
const usedSlugs = new Map();
|
|
463
|
+
const rootOffset = input.options.existingGraphPolicy === 'append'
|
|
464
|
+
? existingLinks
|
|
465
|
+
.filter((link) => !this.normalizeNonEmpty(link.parentLinkId))
|
|
466
|
+
.reduce((max, link) => Math.max(max, Number(link.position) || 0), 0)
|
|
467
|
+
: 0;
|
|
468
|
+
const planNode = (node, siblings, index, depth, path) => {
|
|
469
|
+
const kind = node.kind === 'page' ? 'page' : node.kind === 'section' ? 'section' : undefined;
|
|
470
|
+
const title = this.normalizeNonEmpty(node.title);
|
|
471
|
+
if (!kind || !title) {
|
|
472
|
+
warnings.push({
|
|
473
|
+
code: 'invalid-node-skipped',
|
|
474
|
+
message: 'Skipped heading import node without a valid kind or title.',
|
|
475
|
+
path,
|
|
476
|
+
});
|
|
477
|
+
return null;
|
|
478
|
+
}
|
|
479
|
+
const bodyMarkdown = String(node.bodyMarkdown ?? '').trim();
|
|
480
|
+
const children = Array.isArray(node.children) ? node.children : [];
|
|
481
|
+
const siblingPosition = index + 1 + (depth === 0 ? rootOffset : 0);
|
|
482
|
+
const planned = {
|
|
483
|
+
kind,
|
|
484
|
+
title,
|
|
485
|
+
uid: this.buildHeadingImportUid(kind === 'section' ? 'SEC' : 'PAG', input, title, path),
|
|
486
|
+
slug: kind === 'section' ? this.buildHeadingImportSlug(node.slug ?? title, input, usedSlugs, path) : undefined,
|
|
487
|
+
bodyMarkdown: kind === 'page' ? this.ensureTrailingNewline(bodyMarkdown) : '',
|
|
488
|
+
depth,
|
|
489
|
+
position: siblingPosition,
|
|
490
|
+
path,
|
|
491
|
+
children: [],
|
|
492
|
+
};
|
|
493
|
+
const synthesizedChildren = [];
|
|
494
|
+
if (kind === 'section' && bodyMarkdown) {
|
|
495
|
+
if (input.options.synthesizeOverviewPages) {
|
|
496
|
+
const overviewPath = `${path}.overview`;
|
|
497
|
+
synthesizedChildren.push({
|
|
498
|
+
kind: 'page',
|
|
499
|
+
title: 'Overview',
|
|
500
|
+
uid: this.buildHeadingImportUid('PAG', input, `${title}: Overview`, overviewPath),
|
|
501
|
+
bodyMarkdown: this.ensureTrailingNewline(bodyMarkdown),
|
|
502
|
+
depth: depth + 1,
|
|
503
|
+
position: 1,
|
|
504
|
+
path: overviewPath,
|
|
505
|
+
children: [],
|
|
506
|
+
});
|
|
507
|
+
warnings.push({
|
|
508
|
+
code: 'section-overview-page-synthesized',
|
|
509
|
+
message: `Direct body under section "${title}" was imported as an Overview page.`,
|
|
510
|
+
path: overviewPath,
|
|
511
|
+
});
|
|
512
|
+
}
|
|
513
|
+
else {
|
|
514
|
+
warnings.push({
|
|
515
|
+
code: 'section-direct-body-ignored',
|
|
516
|
+
message: `Direct body under section "${title}" is ignored in the MVP import policy.`,
|
|
517
|
+
path,
|
|
518
|
+
});
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
const childPositionOffset = synthesizedChildren.length;
|
|
522
|
+
planned.children = synthesizedChildren.concat(children
|
|
523
|
+
.map((child, childIndex) => planNode(child, children, childIndex + childPositionOffset, depth + 1, `${path}.${childIndex}`))
|
|
524
|
+
.filter((child) => Boolean(child)));
|
|
525
|
+
void siblings;
|
|
526
|
+
return planned;
|
|
527
|
+
};
|
|
528
|
+
const rootNodes = input.parsedGraph.nodes;
|
|
529
|
+
const nodes = rootNodes
|
|
530
|
+
.map((node, index) => planNode(node, rootNodes, index, 0, String(index)))
|
|
531
|
+
.filter((node) => Boolean(node));
|
|
532
|
+
const sections = [];
|
|
533
|
+
const pages = [];
|
|
534
|
+
const collect = (node, parentLinkId) => {
|
|
535
|
+
if (node.kind === 'section') {
|
|
536
|
+
sections.push({
|
|
537
|
+
title: node.title,
|
|
538
|
+
slug: node.slug,
|
|
539
|
+
depth: node.depth,
|
|
540
|
+
position: node.position,
|
|
541
|
+
parentLinkId,
|
|
542
|
+
});
|
|
543
|
+
for (const child of node.children)
|
|
544
|
+
collect(child, node.path);
|
|
545
|
+
return;
|
|
546
|
+
}
|
|
547
|
+
pages.push({
|
|
548
|
+
title: node.title,
|
|
549
|
+
depth: node.depth,
|
|
550
|
+
position: node.position,
|
|
551
|
+
parentLinkId,
|
|
552
|
+
});
|
|
553
|
+
};
|
|
554
|
+
nodes.forEach((node) => collect(node));
|
|
555
|
+
return { nodes, warnings, sections, pages };
|
|
556
|
+
}
|
|
557
|
+
buildHeadingImportResult(documentVersionId, dryRun, plan) {
|
|
558
|
+
return {
|
|
559
|
+
documentVersionId,
|
|
560
|
+
dryRun,
|
|
561
|
+
summary: {
|
|
562
|
+
sectionsCreated: plan.sections.length,
|
|
563
|
+
pagesCreated: plan.pages.length,
|
|
564
|
+
documentLinksCreated: plan.sections.length + plan.pages.length,
|
|
565
|
+
sectionPageLinksCreated: plan.pages.filter((page) => Boolean(page.parentLinkId)).length,
|
|
566
|
+
warnings: plan.warnings,
|
|
567
|
+
},
|
|
568
|
+
graph: {
|
|
569
|
+
sections: plan.sections,
|
|
570
|
+
pages: plan.pages,
|
|
571
|
+
},
|
|
572
|
+
};
|
|
573
|
+
}
|
|
574
|
+
deleteExistingDocumentVersionLinksForHeadingImport(dependencies, existingLinks, stage) {
|
|
575
|
+
const linkIds = existingLinks
|
|
576
|
+
.slice()
|
|
577
|
+
.sort((a, b) => (Number(b.depth) || 0) - (Number(a.depth) || 0))
|
|
578
|
+
.map((link) => this.normalizeNonEmpty(link.id))
|
|
579
|
+
.filter((id) => Boolean(id));
|
|
580
|
+
if (linkIds.length === 0)
|
|
581
|
+
return Effect.succeed(0);
|
|
582
|
+
return Effect.gen(function* (_) {
|
|
583
|
+
let deleted = 0;
|
|
584
|
+
for (const linkId of linkIds) {
|
|
585
|
+
deleted += yield* _(dependencies.documentSectionLinkRepository.deleteById(linkId).pipe(Effect.mapError(mapDbError({
|
|
586
|
+
stage,
|
|
587
|
+
operation: 'documentSectionLinkRepository.deleteById(replace-import)',
|
|
588
|
+
factory: XfErrorFactory.upsertFailed,
|
|
589
|
+
}))));
|
|
590
|
+
}
|
|
591
|
+
return deleted;
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
buildHeadingImportUid(prefix, input, title, path) {
|
|
595
|
+
const source = [
|
|
596
|
+
input.documentVersionId,
|
|
597
|
+
input.parsedGraph.sourceHash,
|
|
598
|
+
input.parsedGraph.sourcePath,
|
|
599
|
+
title,
|
|
600
|
+
path,
|
|
601
|
+
].filter(Boolean).join(':');
|
|
602
|
+
const hash = createHash('sha1').update(source).digest('hex').slice(0, 12).toUpperCase();
|
|
603
|
+
const titlePart = this.slugifyForImport(title).replace(/-/g, '_').toUpperCase().slice(0, 28) || 'NODE';
|
|
604
|
+
return `${prefix}-${hash}-${titlePart}`;
|
|
605
|
+
}
|
|
606
|
+
buildHeadingImportSlug(source, input, usedSlugs, path) {
|
|
607
|
+
const base = this.slugifyForImport(source) || 'section';
|
|
608
|
+
const count = usedSlugs.get(base) ?? 0;
|
|
609
|
+
usedSlugs.set(base, count + 1);
|
|
610
|
+
if (count === 0 || input.options.slugStrategy === 'kebab-from-title') {
|
|
611
|
+
return count === 0 ? base : `${base}-${count + 1}`;
|
|
612
|
+
}
|
|
613
|
+
const hash = createHash('sha1').update(`${input.documentVersionId}:${input.parsedGraph.sourceHash ?? ''}:${path}:${source}`).digest('hex').slice(0, 8);
|
|
614
|
+
return `${base}-${hash}`;
|
|
615
|
+
}
|
|
616
|
+
slugifyForImport(value) {
|
|
617
|
+
return String(value ?? '')
|
|
618
|
+
.trim()
|
|
619
|
+
.toLowerCase()
|
|
620
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
621
|
+
.replace(/^-+|-+$/g, '')
|
|
622
|
+
.slice(0, 64);
|
|
623
|
+
}
|
|
624
|
+
ensureTrailingNewline(value) {
|
|
625
|
+
if (!value)
|
|
626
|
+
return '';
|
|
627
|
+
return value.endsWith('\n') ? value : `${value}\n`;
|
|
628
|
+
}
|
|
629
|
+
normalizeNonEmpty(value) {
|
|
630
|
+
if (typeof value !== 'string')
|
|
631
|
+
return undefined;
|
|
632
|
+
const normalized = value.trim();
|
|
633
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
634
|
+
}
|
|
635
|
+
resolveCascadeDependencies(stage, operation) {
|
|
636
|
+
return Effect.gen(this, function* (_) {
|
|
637
|
+
return {
|
|
638
|
+
documentRepository: yield* _(this.requireDependency(this.documentRepository, 'documentRepository', stage, operation)),
|
|
639
|
+
documentVersionRepository: this.documentVersionRepository,
|
|
640
|
+
documentSectionLinkRepository: yield* _(this.requireDependency(this.documentSectionLinkRepository, 'documentSectionLinkRepository', stage, operation)),
|
|
641
|
+
sectionRepository: yield* _(this.requireDependency(this.sectionRepository, 'sectionRepository', stage, operation)),
|
|
642
|
+
pageRepository: yield* _(this.requireDependency(this.pageRepository, 'pageRepository', stage, operation)),
|
|
643
|
+
pageVersionRepository: yield* _(this.requireDependency(this.pageVersionRepository, 'pageVersionRepository', stage, operation)),
|
|
644
|
+
sectionPageLinkRepository: yield* _(this.requireDependency(this.sectionPageLinkRepository, 'sectionPageLinkRepository', stage, operation)),
|
|
645
|
+
pageSnippetLinkRepository: yield* _(this.requireDependency(this.pageSnippetLinkRepository, 'pageSnippetLinkRepository', stage, operation)),
|
|
646
|
+
pageEmbedLinkRepository: yield* _(this.requireDependency(this.pageEmbedLinkRepository, 'pageEmbedLinkRepository', stage, operation)),
|
|
647
|
+
};
|
|
648
|
+
});
|
|
649
|
+
}
|
|
650
|
+
requireDependency(dependency, name, stage, operation) {
|
|
651
|
+
if (dependency)
|
|
652
|
+
return Effect.succeed(dependency);
|
|
653
|
+
return Effect.fail(XfErrorFactory.configurationError({
|
|
654
|
+
stage,
|
|
655
|
+
operation,
|
|
656
|
+
message: `Missing dependency: ${name}`,
|
|
657
|
+
debug: { dependency: name },
|
|
658
|
+
}));
|
|
659
|
+
}
|
|
660
|
+
normalizeCascadeError(stage, operation, cause) {
|
|
661
|
+
if (cause && typeof cause === 'object' && '_tag' in cause) {
|
|
662
|
+
return cause;
|
|
663
|
+
}
|
|
664
|
+
return XfErrorFactory.upsertFailed({
|
|
665
|
+
stage,
|
|
666
|
+
operation,
|
|
667
|
+
message: 'document_version_cascade_delete_failed',
|
|
668
|
+
cause,
|
|
669
|
+
});
|
|
670
|
+
}
|
|
671
|
+
ensureVersionIsUniqueForDocument(data, stage) {
|
|
672
|
+
const documentId = String(data.documentId ?? '').trim();
|
|
673
|
+
const version = Number(data.version);
|
|
674
|
+
return this.documentVersionRepository
|
|
675
|
+
.find({
|
|
676
|
+
matchEq: {
|
|
677
|
+
documentId,
|
|
678
|
+
version,
|
|
679
|
+
},
|
|
680
|
+
})
|
|
681
|
+
.pipe(Effect.mapError(mapDbError({
|
|
682
|
+
stage,
|
|
683
|
+
operation: 'find(existingVersion)',
|
|
684
|
+
factory: XfErrorFactory.upsertFailed,
|
|
685
|
+
})), Effect.flatMap((existing) => {
|
|
686
|
+
if (!Array.isArray(existing) || existing.length === 0) {
|
|
687
|
+
return Effect.succeed(data);
|
|
688
|
+
}
|
|
689
|
+
return Effect.fail(XfErrorFactory.upsertFailed({
|
|
690
|
+
stage,
|
|
691
|
+
operation: 'checkDuplicateVersion',
|
|
692
|
+
message: `Document version ${version} already exists for document ${documentId}.`,
|
|
693
|
+
data: {
|
|
694
|
+
documentId,
|
|
695
|
+
version,
|
|
696
|
+
existingId: String(existing[0]?.id ?? ''),
|
|
697
|
+
},
|
|
698
|
+
}));
|
|
699
|
+
}));
|
|
700
|
+
}
|
|
701
|
+
withLocaleOptions(options) {
|
|
702
|
+
if (!this.locale)
|
|
703
|
+
return options;
|
|
704
|
+
const projectionOptions = { ...(options?.projectionOptions ?? {}) };
|
|
705
|
+
const languagesCurrent = projectionOptions.languages;
|
|
706
|
+
const languages = Array.isArray(languagesCurrent) && languagesCurrent.length > 0 ? languagesCurrent : [this.locale];
|
|
707
|
+
return {
|
|
708
|
+
...(options ?? {}),
|
|
709
|
+
mlgFields: options?.mlgFields && options.mlgFields.length > 0
|
|
710
|
+
? options.mlgFields
|
|
711
|
+
: [...bmDocumentVersionMlgFields],
|
|
712
|
+
projectionOptions: { ...projectionOptions, languages },
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
}
|