Repository navigation
feat(node): locked prefill and multi-document signing for template envelopes - #91
Conversation
|
@esaugomez31 I reviewed this and pushed seven commits on top of yours that address what came up, could you look them over? Nothing you verified live should behave differently; the two deliberate changes only matter in cases the live run did not touch. What the commits do
Gates locally: esign-node 473 tests, esign-service 395 tests, both at 100% coverage; typecheck, lint, One ask on the PR body: the "does not forward a prefill yet" note in Notes can become "the service and wrapper forward it for embedding hosts; the GraphQL mutation has no prefill input by design; esign-service resolving it from TERMS_URL is a follow-up". If you can re-run your live check against the sandbox with a locked value and, if you have two templates handy, a comma-separated list, that would confirm the lock and the single-session behaviour end to end. |
parseEnvelopePrefill / assertEnvelopePrefill share the parser parseWebFormPrefill uses: the field-name rule, the 200-field cap, the per-field reason and the prototype defence now apply to envelope tabs too, and a locked tab with nothing in it is refused. The provider maps PrefillError (WebFormPrefillError kept as an alias) to VALIDATION_ERROR on both the envelope and the hosted-form path through one helper.
A property in the request overlays the template tab's, so sending an explicit unlock for every value the host had not marked as locked unlocked tabs the template designer had made read-only. The lock now travels only when the host set it, as 'true' or 'false'.
docuSignConfigFromEnv stores DOCUSIGN_TEMPLATE_ID trimmed with blank entries dropped, templateIds(config) reads the list, and missingDocuSignConfig counts a list naming no template as unset. The service boot guard, assertDocuSignConfig and the client now agree, so a lone comma fails at boot instead of on the first envelope. The provider checks the setting before any request and reports it as the caller's VALIDATION_ERROR once, no longer as PROVIDER_UNAVAILABLE after three retries.
…wrapper and the mock CreateEnvelopeInput carries prefill and createEnvelopeService forwards it; the service's tracing wrapper forwards it (never onto a span) and the mock keeps it per envelope (getEnvelopePrefill), so a host's test can read back what reached the provider. The GraphQL mutation stays without it: terms the signer cannot change are the host's to supply, not the client's.
Composite templates discard inline recipient ids; DocuSign merges the signer's copies by email, name and routing order and matches them to the server template's role by name. One signing session therefore depends on the configured role sitting at the same routing order in every listed template, which the comment now says.
…s a template list The proxy-flow fixture (now src/providers/docusign/template.ts, the script a thin runner over it) adds the Text tabs reference and notes, so make docusign-template produces a template an envelope prefill can actually write to. WRITE=1 leaves .env alone when DOCUSIGN_TEMPLATE_ID already lists several templates instead of collapsing the list to the fixture's id. Both rules are unit-tested.
…e they are read DOCUSIGN_SIGNER_ROLE joins every place DOCUSIGN_TEMPLATE_ID is listed (the development guide, the production runbook, both .env examples, the k8s secret); the proxy runbook no longer says the role must be named signer, states the Text-tab rule and the same-routing-order rule for template lists, and knows the fixture's new tabs; the ESignProvider transcription and the API contract carry the prefill parameter and why the mutation has none; docusign-lessons gains the envelope-side rules; and locked-terms-envelopes.md is the host-side recipe, listed in the index and linked from its Web Forms sibling.
01cf839 to
d90b972
Compare
|
.
Thanks @grimen I just tested it on the emulator and it works well. |
Why
Signing from a template envelope puts the signer directly on the document, with no form in front of it. The package could already create that envelope, but not with the values the host computed: the document opened empty and editable. The signer role was also fixed to
signer, so templates that name their role differently could not be used, and an agreement made of several documents needed one envelope per document.What
createEnvelopetakes an optional prefill written onto the template's text tabs, and each value can be locked. It is validated before any request, like the Web Forms prefill.DOCUSIGN_SIGNER_ROLEsets the template role the signer fills (defaultsigner).DOCUSIGN_TEMPLATE_IDaccepts several comma-separated ids, sent as one envelope of composite templates: one signer and one signing session, with the documents in the order given. A single id sends the same request as before.Notes
createEnvelopeService) does not forward a prefill yet, so for now a host calls the provider directly.