@josephomills/esign 0.5.1 → 0.6.1
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/dist/{ports-DM0-2hQd.d.cts → ports-CkBaAepo.d.cts} +40 -1
- package/dist/{ports-DM0-2hQd.d.ts → ports-CkBaAepo.d.ts} +40 -1
- package/dist/prisma/index.cjs +61 -0
- package/dist/prisma/index.cjs.map +1 -1
- package/dist/prisma/index.d.cts +17 -1
- package/dist/prisma/index.d.ts +17 -1
- package/dist/prisma/index.js +61 -0
- package/dist/prisma/index.js.map +1 -1
- package/dist/server/index.cjs +37 -0
- package/dist/server/index.cjs.map +1 -1
- package/dist/server/index.d.cts +38 -3
- package/dist/server/index.d.ts +38 -3
- package/dist/server/index.js +37 -1
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { S as SubjectSelection, E as EsignChannel, R as ResendPolicy, P as PersistencePort, a as SubjectsPort, N as NotifierPort, C as Clock, b as SkippedSubject, c as
|
|
2
|
-
export { A as ACTIVE_STATUSES, p as
|
|
1
|
+
import { S as SubjectSelection, E as EsignChannel, R as ResendPolicy, P as PersistencePort, a as SubjectsPort, N as NotifierPort, C as Clock, b as SkippedSubject, c as StoragePort, H as HooksPort, d as SignatureField, e as SigningDocumentVersionDTO, f as SigningDocumentDTO, g as SigningRequestDTO, h as EsignConfig, V as VersionPolicy, i as SubjectSigningStatus, j as CoverageReport, k as CampaignStatsRow, D as DocumentStatsRow, l as StatsRange, m as ScopeStatsRow, O as OutstandingRequest, n as SubjectTypeDescriptor, o as Placement } from '../ports-CkBaAepo.js';
|
|
2
|
+
export { A as ACTIVE_STATUSES, p as AffectedSubject, q as AuthPort, r as DeclineInput, s as DocumentDeletionContext, t as ESIGN_CHANNELS, u as ESIGN_STATUSES, v as EsignStatus, G as GroupBreakdown, w as NewAuditEventRow, x as NewRequestRow, y as NotifierAttachment, z as Recipient, B as RequestSummary, F as SigningAuditEventDTO, I as SigningCampaignDTO, J as StatusCountMap, K as SubjectFilter, L as SubjectFilterField, M as SubjectSigningState, Q as SubjectSummary, T as SubmitSignatureInput, U as TERMINAL_STATUSES, W as assertTransition, X as canTransition, Y as declineSchema, Z as esignChannelSchema, _ as isActive, $ as isTerminal, a0 as placementSchema, a1 as placementsSchema, a2 as signatureFieldSchema, a3 as subjectSelectionSchema, a4 as submitSignatureSchema } from '../ports-CkBaAepo.js';
|
|
3
3
|
import { PDFDocument } from 'pdf-lib';
|
|
4
4
|
import { ZodType } from 'zod';
|
|
5
5
|
|
|
@@ -85,6 +85,40 @@ interface CreateCampaignResult {
|
|
|
85
85
|
*/
|
|
86
86
|
declare function createCampaign(deps: CreateCampaignDeps, args: CreateCampaignArgs): Promise<CreateCampaignResult>;
|
|
87
87
|
|
|
88
|
+
type DeleteMode = "soft" | "purge";
|
|
89
|
+
interface DeleteDocumentInput {
|
|
90
|
+
documentId: string;
|
|
91
|
+
/**
|
|
92
|
+
* "soft" (default) archives reversibly — hides the document + campaigns, revokes
|
|
93
|
+
* live links, keeps the sealed PDFs + audit trail. "purge" permanently removes
|
|
94
|
+
* all rows and the source/sealed objects, and is refused once anything is signed.
|
|
95
|
+
*/
|
|
96
|
+
mode?: DeleteMode;
|
|
97
|
+
}
|
|
98
|
+
type DeleteDocumentResult = {
|
|
99
|
+
ok: true;
|
|
100
|
+
mode: DeleteMode;
|
|
101
|
+
documentId: string;
|
|
102
|
+
objectsPurged: number;
|
|
103
|
+
} | {
|
|
104
|
+
ok: false;
|
|
105
|
+
reason: "not_found" | "has_signatures";
|
|
106
|
+
};
|
|
107
|
+
interface DeleteDocumentDeps {
|
|
108
|
+
persistence: PersistencePort;
|
|
109
|
+
storage: StoragePort;
|
|
110
|
+
clock: Clock;
|
|
111
|
+
hooks?: HooksPort;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Delete a logical document and everything under it. Soft by default (reversible,
|
|
115
|
+
* preserves signed evidence); purge permanently removes rows + storage objects but
|
|
116
|
+
* is refused when any request is SIGNED. Either way the affected subjects are
|
|
117
|
+
* reported through {@link HooksPort.onDocumentDeleted} so the host can react
|
|
118
|
+
* (milestone-grid retraction lives in the host, never in this package).
|
|
119
|
+
*/
|
|
120
|
+
declare function deleteDocument(deps: DeleteDocumentDeps, input: DeleteDocumentInput): Promise<DeleteDocumentResult>;
|
|
121
|
+
|
|
88
122
|
interface CreateDocumentInput {
|
|
89
123
|
scopeId?: string | null;
|
|
90
124
|
documentType?: string | null;
|
|
@@ -235,6 +269,7 @@ interface EsignRuntime<S> {
|
|
|
235
269
|
createDocument(input: CreateDocumentInput): Promise<SigningDocumentDTO>;
|
|
236
270
|
addVersion(input: AddVersionInput): Promise<SigningDocumentVersionDTO>;
|
|
237
271
|
createCampaign(args: CreateCampaignArgs): Promise<CreateCampaignResult>;
|
|
272
|
+
deleteDocument(input: DeleteDocumentInput): Promise<DeleteDocumentResult>;
|
|
238
273
|
getSigningView(token: string): Promise<SigningView | null>;
|
|
239
274
|
recordView(token: string): Promise<void>;
|
|
240
275
|
submitSignature(input: SubmitInput): Promise<SubmitResult>;
|
|
@@ -355,4 +390,4 @@ declare class EsignError extends Error {
|
|
|
355
390
|
}
|
|
356
391
|
declare function toErrorResponse(err: unknown): Response;
|
|
357
392
|
|
|
358
|
-
export { type AddVersionInput, type AuditEventInput, type AuditLink, type CampaignContentBuilder, CampaignStatsRow, type CertInfo, type ChannelContent, Clock, type CoverageDeps, CoverageReport, type CreateCampaignArgs, type CreateCampaignDeps, type CreateCampaignResult, type CreateDocumentInput, type DeclineRequestInput, DocumentStatsRow, EsignChannel, EsignConfig, EsignError, type EsignErrorCode, type EsignRuntime, HooksPort, NotifierPort, OutstandingRequest, PersistencePort, Placement, ResendPolicy, type ResolvedEsignConfig, ScopeStatsRow, type SealInput, type SealResult, type SignDeps, type SignServeDeps, SignatureField, SigningDocumentDTO, SigningDocumentVersionDTO, SigningRequestDTO, type SigningToken, type SigningView, SkippedSubject, StatsRange, StoragePort, SubjectSelection, SubjectSigningStatus, type SubjectSigningStatusArgs, SubjectTypeDescriptor, SubjectsPort, type SubmitInput, type SubmitResult, VersionPolicy, type VersionSource, addVersion, appendEvent, buildChain, canonicalize, clientIp, configureEsign, createCampaign, createDocument, createSignActionsRoute, createSignServeRoute, declineRequest, documentCoverage, getSigningView, linkHash, newSigningToken, ok, parseBody, recordEvent, recordView, registerSubjectTypes, renderAuditCertificatePage, sealPdf, sha256Hex, submitSignature, toErrorResponse, uid, verifyChain };
|
|
393
|
+
export { type AddVersionInput, type AuditEventInput, type AuditLink, type CampaignContentBuilder, CampaignStatsRow, type CertInfo, type ChannelContent, Clock, type CoverageDeps, CoverageReport, type CreateCampaignArgs, type CreateCampaignDeps, type CreateCampaignResult, type CreateDocumentInput, type DeclineRequestInput, type DeleteDocumentDeps, type DeleteDocumentInput, type DeleteDocumentResult, type DeleteMode, DocumentStatsRow, EsignChannel, EsignConfig, EsignError, type EsignErrorCode, type EsignRuntime, HooksPort, NotifierPort, OutstandingRequest, PersistencePort, Placement, ResendPolicy, type ResolvedEsignConfig, ScopeStatsRow, type SealInput, type SealResult, type SignDeps, type SignServeDeps, SignatureField, SigningDocumentDTO, SigningDocumentVersionDTO, SigningRequestDTO, type SigningToken, type SigningView, SkippedSubject, StatsRange, StoragePort, SubjectSelection, SubjectSigningStatus, type SubjectSigningStatusArgs, SubjectTypeDescriptor, SubjectsPort, type SubmitInput, type SubmitResult, VersionPolicy, type VersionSource, addVersion, appendEvent, buildChain, canonicalize, clientIp, configureEsign, createCampaign, createDocument, createSignActionsRoute, createSignServeRoute, declineRequest, deleteDocument, documentCoverage, getSigningView, linkHash, newSigningToken, ok, parseBody, recordEvent, recordView, registerSubjectTypes, renderAuditCertificatePage, sealPdf, sha256Hex, submitSignature, toErrorResponse, uid, verifyChain };
|
package/dist/server/index.js
CHANGED
|
@@ -390,6 +390,41 @@ async function documentCoverage(deps, documentId) {
|
|
|
390
390
|
departed
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
|
+
|
|
394
|
+
// src/server/delete.ts
|
|
395
|
+
async function deleteDocument(deps, input) {
|
|
396
|
+
const mode = input.mode ?? "soft";
|
|
397
|
+
const ctx = await deps.persistence.getDocumentDeletionContext(input.documentId);
|
|
398
|
+
if (!ctx) return { ok: false, reason: "not_found" };
|
|
399
|
+
if (mode === "purge" && ctx.signedCount > 0) {
|
|
400
|
+
return { ok: false, reason: "has_signatures" };
|
|
401
|
+
}
|
|
402
|
+
if (mode === "purge") {
|
|
403
|
+
await deps.persistence.hardDeleteDocument(input.documentId);
|
|
404
|
+
const keys = [...ctx.sourceKeys, ...ctx.sealedKeys];
|
|
405
|
+
for (const key of keys) {
|
|
406
|
+
await deps.storage.delete(key).catch(() => void 0);
|
|
407
|
+
}
|
|
408
|
+
await emitDeleted(deps.hooks, ctx, "purge");
|
|
409
|
+
return { ok: true, mode: "purge", documentId: input.documentId, objectsPurged: keys.length };
|
|
410
|
+
}
|
|
411
|
+
await deps.persistence.softDeleteDocument(input.documentId, deps.clock.now());
|
|
412
|
+
await emitDeleted(deps.hooks, ctx, "soft");
|
|
413
|
+
return { ok: true, mode: "soft", documentId: input.documentId, objectsPurged: 0 };
|
|
414
|
+
}
|
|
415
|
+
async function emitDeleted(hooks, ctx, mode) {
|
|
416
|
+
if (!hooks?.onDocumentDeleted) return;
|
|
417
|
+
try {
|
|
418
|
+
await hooks.onDocumentDeleted({
|
|
419
|
+
documentId: ctx.documentId,
|
|
420
|
+
documentType: ctx.documentType,
|
|
421
|
+
scopeId: ctx.scopeId,
|
|
422
|
+
mode,
|
|
423
|
+
affectedSubjects: ctx.affectedSubjects
|
|
424
|
+
});
|
|
425
|
+
} catch {
|
|
426
|
+
}
|
|
427
|
+
}
|
|
393
428
|
async function createDocument(persistence, input) {
|
|
394
429
|
if (!input.title.trim()) {
|
|
395
430
|
throw new EsignError("INVALID_INPUT", "A document title is required.");
|
|
@@ -949,6 +984,7 @@ function configureEsign(opts) {
|
|
|
949
984
|
},
|
|
950
985
|
args
|
|
951
986
|
),
|
|
987
|
+
deleteDocument: (input) => deleteDocument({ persistence, storage, clock, hooks }, input),
|
|
952
988
|
getSigningView: (token) => getSigningView({ persistence, clock }, token),
|
|
953
989
|
recordView: (token) => recordView({ persistence, clock, hooks }, token),
|
|
954
990
|
submitSignature: (input) => submitSignature(signDeps, input),
|
|
@@ -975,6 +1011,6 @@ function registerSubjectTypes(types) {
|
|
|
975
1011
|
};
|
|
976
1012
|
}
|
|
977
1013
|
|
|
978
|
-
export { ACTIVE_STATUSES, ESIGN_CHANNELS, ESIGN_STATUSES, EsignError, TERMINAL_STATUSES, addVersion, appendEvent, assertTransition, buildChain, canTransition, canonicalize, clientIp, configureEsign, createCampaign, createDocument, createSignActionsRoute, createSignServeRoute, declineRequest, declineSchema, documentCoverage, esignChannelSchema, getSigningView, isActive, isTerminal, linkHash, newSigningToken, ok, parseBody, placementSchema, placementsSchema, recordEvent, recordView, registerSubjectTypes, renderAuditCertificatePage, sealPdf, sha256Hex, signatureFieldSchema, subjectSelectionSchema, submitSignature, submitSignatureSchema, toErrorResponse, uid, verifyChain };
|
|
1014
|
+
export { ACTIVE_STATUSES, ESIGN_CHANNELS, ESIGN_STATUSES, EsignError, TERMINAL_STATUSES, addVersion, appendEvent, assertTransition, buildChain, canTransition, canonicalize, clientIp, configureEsign, createCampaign, createDocument, createSignActionsRoute, createSignServeRoute, declineRequest, declineSchema, deleteDocument, documentCoverage, esignChannelSchema, getSigningView, isActive, isTerminal, linkHash, newSigningToken, ok, parseBody, placementSchema, placementsSchema, recordEvent, recordView, registerSubjectTypes, renderAuditCertificatePage, sealPdf, sha256Hex, signatureFieldSchema, subjectSelectionSchema, submitSignature, submitSignatureSchema, toErrorResponse, uid, verifyChain };
|
|
979
1015
|
//# sourceMappingURL=index.js.map
|
|
980
1016
|
//# sourceMappingURL=index.js.map
|