Skip to content

Conversation

@d-klotz
Copy link
Contributor

@d-klotz d-klotz commented Apr 15, 2025

Overview:

This PR introduces a new API module (@friggframework/api-module-docusign) to enable interaction with the DocuSign eSignature REST API within the Frigg framework. It follows the established patterns for Frigg API modules and provides core functionality for managing envelopes and templates.

Key Changes & Features:

  • Module Structure: Added the standard directory structure and configuration files for a Frigg API module (api.ts, definition.ts, defaultConfig.json, package.json, tsconfig.build.json, .env.example, index.ts, README.md).
  • TypeScript Implementation: The module is written entirely in TypeScript.
  • Core Integration: The Api class extends OAuth2Requester from @friggframework/core.
  • DocuSign OAuth 2.0:
    • Implements the Authorization Code Grant flow specifically for DocuSign.
    • Includes a custom getTokenFromCode method in api.ts to handle DocuSign's requirement for HTTP Basic Authentication during the token exchange step.
    • Handles dynamic determination of authorization/token endpoints based on the DOCUSIGN_ENVIRONMENT (dev vs. prod).
  • Account-Specific Base URI:
    • Correctly fetches the account-specific base_uri (API host) from the /oauth/userinfo endpoint during authentication (getEntityDetails in definition.ts).
    • Persists the base_uri (as base_url) alongside the accountId for correct rehydration of the Api instance.
    • The Api class uses this baseUriHost and accountId to construct the correct base URL for all eSignature API calls.
  • API Methods Implemented:
    • Envelopes: listEnvelopes, getEnvelope, createEnvelope, voidEnvelope.
    • Templates: listTemplates, getTemplate. (Implied by tests, ensure methods exist in api.ts)
    • Auth/User: getAuthorizationUri, getTokenFromCode, getUserInfo.
  • TypeScript Definitions: Added frigg.d.ts to provide necessary type declarations for the used parts of @friggframework/core.
  • Testing:
    • Added Jest configuration (jest.config.js, setup/teardown).
    • Includes auther.test.js with the standard Frigg live test structure (requires manual OAuth step), adapted from other modules.
    • Includes testAutherDefinition usage for structural validation with mocks.
    • Includes api.test.js for live testing of implemented API methods against a DocuSign account (requires configured .env).
  • Documentation: Includes a basic README.md.
  • Builder Instructions Update: Updated .cursor/rules/api-module-builder-instructions.mdc to reflect patterns and learnings from this implementation (TypeScript focus, definition.ts structure, defaultConfig.json, core types, etc.).

Testing:

  • Ensure .env file is created from .env.example and populated with valid DocuSign developer credentials (Client ID, Secret, Environment) and a test recipient email.
  • Run npm install and npm run build within the packages/v1-ready/docusign directory.
  • Run npm test to execute Jest tests. The auther.test.js suite requires manual interaction for the OAuth flow as prompted in the console. The api.test.js suite runs live against the configured DocuSign account.

Future Work:

  • Implement more API endpoints (e.g., document management, recipient actions, template creation/sending).
  • Refine TypeScript types for DocuSign-specific request/response bodies (currently uses any in some places).
  • Consider adding PKCE support to the OAuth flow for enhanced security.

d-klotz added 8 commits April 14, 2025 20:07
- Implemented core API functionality for DocuSign, including methods for listing, creating, and voiding envelopes.
- Added configuration and environment setup with example `.env` file.
- Included Jest setup and teardown scripts for testing.
- Created default configuration and README documentation for usage instructions.
- Updated `.gitignore` to exclude build artifacts and added necessary dependencies in `package.json`.
@d-klotz d-klotz requested a review from seanspeaks April 15, 2025 21:27
Comment on lines 17 to 21
"include": [
"./*.ts",
"./**/*.ts",
"./tests/**/*.ts"
, "tests/auth.test.js" ],
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The include array in tsconfig.json has a formatting issue - there's a comma and string literal ("tests/auth.test.js") placed outside the array brackets. This should be moved inside the array to maintain proper JSON syntax:

"include": [
  "./*.ts",
  "./**/*.ts",
  "./tests/**/*.ts",
  "tests/auth.test.js"
]

This syntax error could cause TypeScript configuration problems during build.

Suggested change
"include": [
"./*.ts",
"./**/*.ts",
"./tests/**/*.ts"
, "tests/auth.test.js" ],
"include": [
"./*.ts",
"./**/*.ts",
"./tests/**/*.ts",
"tests/auth.test.js"
],

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

Copy link
Contributor

@seanspeaks seanspeaks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Pausing but wanted to drop this comment)

@@ -0,0 +1,308 @@
import { OAuth2Requester } from '@friggframework/core';

interface DocuSignConstructorParams {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docusign (lower case the S)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants