Documentation
¶
Index ¶
- func NewDefaultTemplateResolver() port.TemplateResolver
- func NewInternalDocumentService(generator *DocumentGenerator, documentRepo port.DocumentRepository, ...) documentuc.InternalDocumentUseCase
- func NewPreSigningService(accessTokenRepo port.DocumentAccessTokenRepository, ...) documentuc.PreSigningUseCase
- func NewTemplateVersionSearchAdapter(tenantRepo port.TenantRepository, workspaceRepo port.WorkspaceRepository, ...) port.TemplateVersionSearchAdapter
- type DefaultTemplateResolver
- type DocumentAccessService
- func (s *DocumentAccessService) GetPublicDocumentInfo(ctx context.Context, documentID string) (*documentuc.PublicDocumentInfoResponse, error)
- func (s *DocumentAccessService) RequestAccess(ctx context.Context, documentID, email string) error
- func (s *DocumentAccessService) RequestAccessByToken(ctx context.Context, token, email string) error
- func (s *DocumentAccessService) RequestDirectAccess(ctx context.Context, documentID, email string) (string, error)
- type DocumentGenerationResult
- type DocumentGenerator
- type DocumentService
- func (s *DocumentService) CancelDocument(ctx context.Context, documentID string) error
- func (s *DocumentService) CreateAndSendDocument(ctx context.Context, cmd documentuc.CreateDocumentCommand) (*entity.DocumentWithRecipients, error)
- func (s *DocumentService) CreateDocumentsBatch(ctx context.Context, cmds []documentuc.CreateDocumentCommand) ([]documentuc.BatchDocumentResult, error)
- func (s *DocumentService) ExpireDocuments(ctx context.Context, limit int) error
- func (s *DocumentService) GetDocument(ctx context.Context, id string) (*entity.Document, error)
- func (s *DocumentService) GetDocumentPDF(ctx context.Context, documentID string) ([]byte, string, error)
- func (s *DocumentService) GetDocumentRecipients(ctx context.Context, documentID string) ([]*entity.DocumentRecipientWithRole, error)
- func (s *DocumentService) GetDocumentStatistics(ctx context.Context, workspaceID string) (*documentuc.DocumentStatistics, error)
- func (s *DocumentService) GetDocumentWithRecipients(ctx context.Context, id string) (*entity.DocumentWithRecipients, error)
- func (s *DocumentService) GetDocumentsByExternalRef(ctx context.Context, workspaceID, externalRef string) ([]*entity.Document, error)
- func (s *DocumentService) GetSigningURL(ctx context.Context, documentID, recipientID string) (string, error)
- func (s *DocumentService) HandleWebhookEvent(ctx context.Context, event *port.WebhookEvent) error
- func (s *DocumentService) ListDocuments(ctx context.Context, workspaceID string, filters port.DocumentFilters) ([]*entity.DocumentListItem, error)
- func (s *DocumentService) RefreshDocumentStatus(ctx context.Context, documentID string) (*entity.DocumentWithRecipients, error)
- func (s *DocumentService) SendReminder(ctx context.Context, documentID string) error
- type EventEmitter
- type InternalDocumentService
- type NotificationService
- func (s *NotificationService) NotifyDocumentCompleted(ctx context.Context, documentID string)
- func (s *NotificationService) NotifyDocumentCreated(ctx context.Context, documentID string)
- func (s *NotificationService) NotifyDocumentDeclined(ctx context.Context, documentID string)
- func (s *NotificationService) NotifyDocumentExpired(ctx context.Context, documentID string)
- func (s *NotificationService) SendAccessLink(ctx context.Context, recipient *entity.DocumentRecipient, doc *entity.Document, ...)
- func (s *NotificationService) SendReminder(ctx context.Context, documentID string) error
- type PreSigningService
- func (s *PreSigningService) CompleteEmbeddedSigning(ctx context.Context, token string) error
- func (s *PreSigningService) DownloadCompletedPDF(ctx context.Context, token string) ([]byte, string, error)
- func (s *PreSigningService) GetPublicSigningPage(ctx context.Context, token string) (*documentuc.PublicSigningResponse, error)
- func (s *PreSigningService) InvalidateTokens(ctx context.Context, documentID string) error
- func (s *PreSigningService) ProceedToSigning(ctx context.Context, token string) (*documentuc.PublicSigningResponse, error)
- func (s *PreSigningService) RefreshEmbeddedURL(ctx context.Context, token string) (*documentuc.PublicSigningResponse, error)
- func (s *PreSigningService) RenderPreviewPDF(ctx context.Context, token string) ([]byte, error)
- func (s *PreSigningService) SubmitPreSigningForm(ctx context.Context, token string, responses []documentuc.FieldResponseInput) (*documentuc.PublicSigningResponse, error)
- type PreparedDocumentData
- type SigningSessionService
- type TemplateVersionSearchAdapter
- func (a *TemplateVersionSearchAdapter) ResolveInternalTemplateContext(ctx context.Context, params port.InternalTemplateContextSearchParams) (*port.InternalTemplateContext, error)
- func (a *TemplateVersionSearchAdapter) SearchTemplateVersions(ctx context.Context, params port.TemplateVersionSearchParams) ([]port.TemplateVersionSearchItem, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDefaultTemplateResolver ¶
func NewDefaultTemplateResolver() port.TemplateResolver
NewDefaultTemplateResolver creates a new default resolver instance.
func NewInternalDocumentService ¶
func NewInternalDocumentService( generator *DocumentGenerator, documentRepo port.DocumentRepository, tenantRepo port.TenantRepository, workspaceRepo port.WorkspaceRepository, docTypeRepo port.DocumentTypeRepository, templateRepo port.TemplateRepository, versionRepo port.TemplateVersionRepository, customResolver port.TemplateResolver, ) documentuc.InternalDocumentUseCase
NewInternalDocumentService creates a new InternalDocumentService.
func NewPreSigningService ¶
func NewPreSigningService( accessTokenRepo port.DocumentAccessTokenRepository, fieldResponseRepo port.DocumentFieldResponseRepository, documentRepo port.DocumentRepository, recipientRepo port.DocumentRecipientRepository, attemptRepo port.SigningAttemptRepository, signingUOW port.SigningExecutionUnitOfWork, versionRepo port.TemplateVersionRepository, signerRoleRepo port.TemplateVersionSignerRoleRepository, pdfRenderer port.PDFRenderer, signingProvider port.SigningProvider, storageAdapter port.StorageAdapter, storageEnabled bool, eventEmitter *EventEmitter, publicURL string, ) documentuc.PreSigningUseCase
NewPreSigningService creates a new PreSigningService.
func NewTemplateVersionSearchAdapter ¶
func NewTemplateVersionSearchAdapter( tenantRepo port.TenantRepository, workspaceRepo port.WorkspaceRepository, docTypeRepo port.DocumentTypeRepository, templateRepo port.TemplateRepository, versionRepo port.TemplateVersionRepository, ) port.TemplateVersionSearchAdapter
NewTemplateVersionSearchAdapter builds a new read-only search adapter.
Types ¶
type DefaultTemplateResolver ¶
type DefaultTemplateResolver struct{}
DefaultTemplateResolver resolves template versions by deterministic fallback.
func (*DefaultTemplateResolver) Resolve ¶
func (r *DefaultTemplateResolver) Resolve( ctx context.Context, req *port.TemplateResolverRequest, adapter port.TemplateVersionSearchAdapter, ) (*string, error)
Resolve applies tenant/workspace/documentType fallback and requires a published version. When Environment==dev and SandboxWorkspaceCode is set, sandbox workspace is tried first.
type DocumentAccessService ¶
type DocumentAccessService struct {
// contains filtered or unexported fields
}
DocumentAccessService handles email-verified access to public documents.
func NewDocumentAccessService ¶
func NewDocumentAccessService( documentRepo port.DocumentRepository, recipientRepo port.DocumentRecipientRepository, versionRepo port.TemplateVersionRepository, accessTokenRepo port.DocumentAccessTokenRepository, notificationSvc *NotificationService, publicURL string, rateLimitMax int, rateLimitWindowMin int, tokenTTLHours int, ) *DocumentAccessService
NewDocumentAccessService creates a new document access service.
func (*DocumentAccessService) GetPublicDocumentInfo ¶
func (s *DocumentAccessService) GetPublicDocumentInfo(ctx context.Context, documentID string) (*documentuc.PublicDocumentInfoResponse, error)
GetPublicDocumentInfo returns minimal public info about a document.
func (*DocumentAccessService) RequestAccess ¶
func (s *DocumentAccessService) RequestAccess(ctx context.Context, documentID, email string) error
RequestAccess validates the email against document recipients and sends an access link. Always returns nil to prevent email enumeration.
func (*DocumentAccessService) RequestAccessByToken ¶
func (s *DocumentAccessService) RequestAccessByToken(ctx context.Context, token, email string) error
RequestAccessByToken requests a new access link using an existing token as the entrypoint (expired-link recovery). Always returns nil to prevent enumeration.
func (*DocumentAccessService) RequestDirectAccess ¶
func (s *DocumentAccessService) RequestDirectAccess(ctx context.Context, documentID, email string) (string, error)
RequestDirectAccess generates a tokenized signing URL for an authenticated recipient (custom middleware path). It does not send email.
type DocumentGenerationResult ¶
type DocumentGenerationResult struct {
Document *entity.Document
Recipients []*entity.DocumentRecipient
Version *entity.TemplateVersionWithDetails
PortableDoc *portable_doc.Document
ResolvedValues map[string]any
}
DocumentGenerationResult contains the result of document generation.
type DocumentGenerator ¶
type DocumentGenerator struct {
// contains filtered or unexported fields
}
DocumentGenerator is the centralized service for document generation. It orchestrates the entire flow: validation, mapping, injection, and creation. This service is reusable by CREATE, RENEW, AMEND operations.
func NewDocumentGenerator ¶
func NewDocumentGenerator( templateRepo port.TemplateRepository, versionRepo port.TemplateVersionRepository, documentRepo port.DocumentRepository, recipientRepo port.DocumentRecipientRepository, injectableUC injectable_uc.InjectableUseCase, mapperRegistry port.MapperRegistry, resolver *injectable_svc.InjectableResolverService, ) *DocumentGenerator
NewDocumentGenerator creates a new DocumentGenerator instance.
func (*DocumentGenerator) GenerateDocument ¶
func (g *DocumentGenerator) GenerateDocument( ctx context.Context, mapCtx *port.MapperContext, ) (*DocumentGenerationResult, error)
GenerateDocument is the centralized method for document generation. It handles the complete flow from template lookup through document creation. Note: PDF rendering and signing provider upload are NOT handled here. The caller (InternalDocumentService) handles those steps after generation.
func (*DocumentGenerator) PrepareDocument ¶
func (g *DocumentGenerator) PrepareDocument( ctx context.Context, mapCtx *port.MapperContext, ) (*PreparedDocumentData, error)
PrepareDocument resolves template data, injectables and recipients without persistence.
type DocumentService ¶
type DocumentService struct {
// contains filtered or unexported fields
}
DocumentService implements document business logic.
func NewDocumentService ¶
func NewDocumentService( documentRepo port.DocumentRepository, recipientRepo port.DocumentRecipientRepository, attemptRepo port.SigningAttemptRepository, signingUOW port.SigningExecutionUnitOfWork, templateRepo port.TemplateRepository, versionRepo port.TemplateVersionRepository, signerRoleRepo port.TemplateVersionSignerRoleRepository, pdfRenderer port.PDFRenderer, signingProvider port.SigningProvider, storageAdapter port.StorageAdapter, eventEmitter *EventEmitter, notificationSvc *NotificationService, expirationDays int, accessTokenRepo port.DocumentAccessTokenRepository, fieldResponseRepo port.DocumentFieldResponseRepository, storageEnabled bool, ) *DocumentService
NewDocumentService creates a new document service.
func (*DocumentService) CancelDocument ¶
func (s *DocumentService) CancelDocument(ctx context.Context, documentID string) error
CancelDocument cancels/voids a document that is pending signatures.
func (*DocumentService) CreateAndSendDocument ¶
func (s *DocumentService) CreateAndSendDocument(ctx context.Context, cmd documentuc.CreateDocumentCommand) (*entity.DocumentWithRecipients, error)
CreateAndSendDocument creates a document, generates the PDF, and sends it for signing. If the template has interactive fields and exactly one unsigned signer, the document is placed in AWAITING_INPUT status with an access token instead of rendering/uploading.
func (*DocumentService) CreateDocumentsBatch ¶
func (s *DocumentService) CreateDocumentsBatch(ctx context.Context, cmds []documentuc.CreateDocumentCommand) ([]documentuc.BatchDocumentResult, error)
CreateDocumentsBatch creates multiple documents in a single batch.
func (*DocumentService) ExpireDocuments ¶
func (s *DocumentService) ExpireDocuments(ctx context.Context, limit int) error
ExpireDocuments finds and expires documents that have passed their expiration time.
func (*DocumentService) GetDocument ¶
GetDocument retrieves a document by ID.
func (*DocumentService) GetDocumentPDF ¶
func (s *DocumentService) GetDocumentPDF(ctx context.Context, documentID string) ([]byte, string, error)
GetDocumentPDF returns the signed PDF for a completed document.
func (*DocumentService) GetDocumentRecipients ¶
func (s *DocumentService) GetDocumentRecipients(ctx context.Context, documentID string) ([]*entity.DocumentRecipientWithRole, error)
GetDocumentRecipients retrieves all recipients for a document with their role information.
func (*DocumentService) GetDocumentStatistics ¶
func (s *DocumentService) GetDocumentStatistics(ctx context.Context, workspaceID string) (*documentuc.DocumentStatistics, error)
GetDocumentStatistics returns document statistics for a workspace.
func (*DocumentService) GetDocumentWithRecipients ¶
func (s *DocumentService) GetDocumentWithRecipients(ctx context.Context, id string) (*entity.DocumentWithRecipients, error)
GetDocumentWithRecipients retrieves a document with all its recipients.
func (*DocumentService) GetDocumentsByExternalRef ¶
func (s *DocumentService) GetDocumentsByExternalRef(ctx context.Context, workspaceID, externalRef string) ([]*entity.Document, error)
GetDocumentsByExternalRef finds documents by the client's external reference ID.
func (*DocumentService) GetSigningURL ¶
func (s *DocumentService) GetSigningURL(ctx context.Context, documentID, recipientID string) (string, error)
GetSigningURL retrieves the signing URL for a specific recipient.
func (*DocumentService) HandleWebhookEvent ¶
func (s *DocumentService) HandleWebhookEvent(ctx context.Context, event *port.WebhookEvent) error
HandleWebhookEvent processes an incoming webhook event from the signing provider.
func (*DocumentService) ListDocuments ¶
func (s *DocumentService) ListDocuments(ctx context.Context, workspaceID string, filters port.DocumentFilters) ([]*entity.DocumentListItem, error)
ListDocuments lists documents in a workspace with optional filters.
func (*DocumentService) RefreshDocumentStatus ¶
func (s *DocumentService) RefreshDocumentStatus(ctx context.Context, documentID string) (*entity.DocumentWithRecipients, error)
RefreshDocumentStatus requests an attempt-scoped River refresh and returns the current projection.
func (*DocumentService) SendReminder ¶
func (s *DocumentService) SendReminder(ctx context.Context, documentID string) error
SendReminder sends reminder notifications to pending recipients of a document.
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
EventEmitter handles creating document audit events.
func NewEventEmitter ¶
func NewEventEmitter(repo port.DocumentEventRepository) *EventEmitter
NewEventEmitter creates a new event emitter.
func (*EventEmitter) EmitDocumentEvent ¶
func (e *EventEmitter) EmitDocumentEvent( ctx context.Context, documentID, eventType, actorType, actorID, oldStatus, newStatus string, metadata json.RawMessage, )
EmitDocumentEvent creates a document-level event.
func (*EventEmitter) EmitRecipientEvent ¶
func (e *EventEmitter) EmitRecipientEvent( ctx context.Context, documentID, recipientID, eventType, actorType, actorID, oldStatus, newStatus string, )
EmitRecipientEvent creates a recipient-level event.
func (*EventEmitter) GetDocumentEvents ¶
func (e *EventEmitter) GetDocumentEvents(ctx context.Context, documentID string, limit, offset int) ([]*entity.DocumentEvent, error)
GetDocumentEvents retrieves events for a document.
type InternalDocumentService ¶
type InternalDocumentService struct {
// contains filtered or unexported fields
}
InternalDocumentService implements usecase.InternalDocumentUseCase.
func (*InternalDocumentService) CreateDocument ¶
func (s *InternalDocumentService) CreateDocument( ctx context.Context, cmd documentuc.InternalCreateCommand, ) (*documentuc.InternalCreateResult, error)
CreateDocument creates or replays a document using the extension system.
type NotificationService ¶
type NotificationService struct {
// contains filtered or unexported fields
}
NotificationService handles sending document-related notifications.
func NewNotificationService ¶
func NewNotificationService( provider port.NotificationProvider, recipientRepo port.DocumentRecipientRepository, documentRepo port.DocumentRepository, accessTokenRepo port.DocumentAccessTokenRepository, publicURL string, ) *NotificationService
NewNotificationService creates a new notification service.
func (*NotificationService) NotifyDocumentCompleted ¶
func (s *NotificationService) NotifyDocumentCompleted(ctx context.Context, documentID string)
NotifyDocumentCompleted sends a notification that the document is fully signed.
func (*NotificationService) NotifyDocumentCreated ¶
func (s *NotificationService) NotifyDocumentCreated(ctx context.Context, documentID string)
NotifyDocumentCreated sends notifications to all recipients of a newly created document.
func (*NotificationService) NotifyDocumentDeclined ¶
func (s *NotificationService) NotifyDocumentDeclined(ctx context.Context, documentID string)
NotifyDocumentDeclined sends a notification that a signer has declined.
func (*NotificationService) NotifyDocumentExpired ¶
func (s *NotificationService) NotifyDocumentExpired(ctx context.Context, documentID string)
NotifyDocumentExpired sends a notification that the signing period has expired.
func (*NotificationService) SendAccessLink ¶
func (s *NotificationService) SendAccessLink(ctx context.Context, recipient *entity.DocumentRecipient, doc *entity.Document, tokenStr string)
SendAccessLink sends an email with a signing access link to a recipient.
func (*NotificationService) SendReminder ¶
func (s *NotificationService) SendReminder(ctx context.Context, documentID string) error
SendReminder sends a reminder notification to pending recipients of a document.
type PreSigningService ¶
type PreSigningService struct {
// contains filtered or unexported fields
}
PreSigningService implements the public signing use case.
func (*PreSigningService) CompleteEmbeddedSigning ¶
func (s *PreSigningService) CompleteEmbeddedSigning(ctx context.Context, token string) error
CompleteEmbeddedSigning marks the token as used after embedded signing is completed.
func (*PreSigningService) DownloadCompletedPDF ¶
func (s *PreSigningService) DownloadCompletedPDF(ctx context.Context, token string) ([]byte, string, error)
DownloadCompletedPDF returns the signed PDF for completed documents when the token recipient is authorized.
func (*PreSigningService) GetPublicSigningPage ¶
func (s *PreSigningService) GetPublicSigningPage(ctx context.Context, token string) (*documentuc.PublicSigningResponse, error)
GetPublicSigningPage returns the current signing page state based on document status and token type. GetPublicSigningPage returns the current signing page state based on document status and active attempt.
func (*PreSigningService) InvalidateTokens ¶
func (s *PreSigningService) InvalidateTokens(ctx context.Context, documentID string) error
InvalidateTokens invalidates all active tokens for a document in AWAITING_INPUT status.
func (*PreSigningService) ProceedToSigning ¶
func (s *PreSigningService) ProceedToSigning(ctx context.Context, token string) (*documentuc.PublicSigningResponse, error)
ProceedToSigning renders the PDF, uploads to the signing provider, and returns the embedded signing URL. Accepts both SIGNING (Path A) and PRE_SIGNING (Path B) tokens.
func (*PreSigningService) RefreshEmbeddedURL ¶
func (s *PreSigningService) RefreshEmbeddedURL(ctx context.Context, token string) (*documentuc.PublicSigningResponse, error)
RefreshEmbeddedURL refreshes an expired embedded signing URL.
func (*PreSigningService) RenderPreviewPDF ¶
RenderPreviewPDF renders the document PDF on-demand for preview without storing it.
func (*PreSigningService) SubmitPreSigningForm ¶
func (s *PreSigningService) SubmitPreSigningForm( ctx context.Context, token string, responses []documentuc.FieldResponseInput, ) (*documentuc.PublicSigningResponse, error)
SubmitPreSigningForm validates responses, saves them, renders PDF, sends to provider, and returns the signing page state with embedded URL.
type PreparedDocumentData ¶
type PreparedDocumentData struct {
WorkspaceID string
Version *entity.TemplateVersionWithDetails
PortableDoc *portable_doc.Document
ResolvedValues map[string]any
Recipients []*entity.DocumentRecipient
}
PreparedDocumentData contains generation output before persistence.
type SigningSessionService ¶
type SigningSessionService struct {
// contains filtered or unexported fields
}
SigningSessionService handles authenticated signing session creation for embedded CRM flows.
func NewSigningSessionService ¶
func NewSigningSessionService( documentRepo port.DocumentRepository, recipientRepo port.DocumentRecipientRepository, versionRepo port.TemplateVersionRepository, accessTokenRepo port.DocumentAccessTokenRepository, preSigningUC documentuc.PreSigningUseCase, storageAdapter port.StorageAdapter, tokenTTLHours int, storageEnabled bool, ) *SigningSessionService
NewSigningSessionService creates a new signing session service.
func (*SigningSessionService) CreateOrGetSession ¶
func (s *SigningSessionService) CreateOrGetSession( ctx context.Context, documentID string, principal *documentuc.SigningSessionPrincipal, ) (*documentuc.SigningSessionResponse, error)
CreateOrGetSession returns a reusable tokenized signing session URL and summarized flow state for an authenticated principal.
type TemplateVersionSearchAdapter ¶
type TemplateVersionSearchAdapter struct {
// contains filtered or unexported fields
}
TemplateVersionSearchAdapter provides read-only template version search for custom resolvers.
func (*TemplateVersionSearchAdapter) ResolveInternalTemplateContext ¶
func (a *TemplateVersionSearchAdapter) ResolveInternalTemplateContext( ctx context.Context, params port.InternalTemplateContextSearchParams, ) (*port.InternalTemplateContext, error)
ResolveInternalTemplateContext returns the full internal-create template context in one read model query.
func (*TemplateVersionSearchAdapter) SearchTemplateVersions ¶
func (a *TemplateVersionSearchAdapter) SearchTemplateVersions(ctx context.Context, params port.TemplateVersionSearchParams) ([]port.TemplateVersionSearchItem, error)
SearchTemplateVersions returns deterministic candidates by tenant/workspace/document type.