Go to file
Philipp Kunz c01c1904cf
Some checks failed
Default (tags) / security (push) Failing after 16s
Default (tags) / test (push) Failing after 14s
Default (tags) / release (push) Has been skipped
Default (tags) / metadata (push) Has been skipped
1.0.9
2024-12-18 21:54:35 +01:00
.gitea/workflows fix(core): update 2023-11-22 20:02:38 +01:00
.vscode fix(core): update 2023-11-22 20:02:38 +01:00
test fix(core): update 2023-11-22 20:02:38 +01:00
ts fix(ts_interfaces): Resolved missing exports in plugins.ts 2024-12-18 21:54:35 +01:00
ts_interfaces fix(ts_interfaces): Resolved missing exports in plugins.ts 2024-12-18 21:54:35 +01:00
.gitignore fix(core): update 2023-11-22 20:02:38 +01:00
changelog.md fix(ts_interfaces): Resolved missing exports in plugins.ts 2024-12-18 21:54:35 +01:00
npmextra.json fix(project): Corrected misalignment in file structure and package metadata. 2024-12-18 20:31:19 +01:00
package.json 1.0.9 2024-12-18 21:54:35 +01:00
pnpm-lock.yaml fix(core): Fixed export paths in package configuration 2024-12-18 20:39:44 +01:00
readme.hints.md fix(core): Corrected package and npm extra configuration to ensure consistent naming. 2024-12-18 20:28:10 +01:00
readme.md fix(project): Corrected misalignment in file structure and package metadata. 2024-12-18 20:31:19 +01:00
tsconfig.json fix(core): update 2023-11-22 20:02:38 +01:00

@signature.digital/tools

A package that defines standard tools for working with contracts.

Install

To install @signature.digital/tools, you'll use your preferred package manager. Assuming you're using npm, follow the steps below:

npm install @signature.digital/tools

Or, if you prefer using Yarn:

yarn add @signature.digital/tools

Make sure that you have Node.js installed on your system to use this package. The module is distributed as an ECMAScript Module (ESM), so you'll need a strategy for dealing with ESM in your project if you're using commonjs modules. As usual, ensure that your TypeScript configuration (tsconfig.json) has "module": "ESNext" or similar settings that support ESM.

Usage

Overview

@signature.digital/tools provides a set of interfaces and classes that serve as general utilities for working with contracts digitalization, management, and integration. With a focus on adaptability and ease of use in TypeScript projects, its toolset leverages types, interfaces, and utilities from the @tsclass/tsclass package to enhance contract structures. This package aims to facilitate the definition and handling of contractual data, enabling the modeling of business relationships and agreements as TypeScript objects.

Core Concepts

Before diving into the various tools provided by this package, let's establish a few foundational concepts:

  1. Interface Driven Design: The module uses TypeScript interfaces as blueprints for structuring custom contract models. Interfaces such as IPortableContract, IParagraph, IRole, and IInvolvedParty are integral to the way data is defined and manipulated.

  2. Modularity: This package allows developers to segment responsibilities and logic by modularizing contract components into roles, paragraphs, parties, and related structures.

  3. Business Context Integration: Through integration with @tsclass/tsclass, the module facilitates the inclusion of business-related metadata into contracts, aligning with typical business use cases such as defining involved parties and their roles.

Usage Scenarios

Defining a Contract

A IPortableContract is at the heart of this package. It encapsulates crucial details about a contract such as title, context, roles, parties involved, prior related contracts, and structured paragraphs or sections.

import { IPortableContract, IRole, IInvolvedParty, IParagraph } from '@signature.digital/tools';
import { tsclass } from '@signature.digital/tools';

const legalRole: IRole = {
  id: 'role-001',
  name: 'Legal Advisor',
  description: 'Provides legal counsel and insights on contractual obligations.'
};

const stakeholderRole: IRole = {
  id: 'role-002',
  name: 'Stakeholder',
  description: 'Has a stake in the contract outcomes and implications.'
};

const legalAdvisorContact: tsclass.business.IContact = {
  email: 'legal@firm.domain',
  address: '456 Legal Ave, Lawyersville'
};

const stakeholderContact: tsclass.business.IContact = {
  email: 'stakeholder@domain.org',
  address: '789 Stakeholder Loop, Business City'
};

const involvedParties: IInvolvedParty[] = [
  {
    role: legalRole.name,
    contact: legalAdvisorContact
  },
  {
    role: stakeholderRole.name,
    contact: stakeholderContact
  }
];

const introductoryParagraph: IParagraph = {
  uniqueId: 'para-001',
  parent: null,
  title: 'Introduction',
  content: 'This section provides an introduction to the contract, detailing its purpose and significance.'
};

const commitmentParagraph: IParagraph = {
  uniqueId: 'para-002',
  parent: introductoryParagraph,
  title: 'Commitments',
  content: 'Describes the commitments of the involved parties.'
};

const contract: IPortableContract = {
  title: 'Digital Service Agreement',
  context: 'Provides a framework of service delivery between involved entities.',
  availableRoles: [legalRole, stakeholderRole],
  involvedParties,
  priorContracts: [],
  paragraphs: [introductoryParagraph, commitmentParagraph]
};

console.log(contract);

Validating Contracts

Regarding validation, this package utilizes @tsclass/tsclass to enhance the consistency and robustness of contact data handling. While not embedding specific validation methods, this encourages the integration of validation strategies that developers can extend or implement themselves.

Extending the Interfaces

Developers are encouraged to extend the interfaces to accommodate additional requirements.

interface IExtendedContract extends IPortableContract {
  effectiveDate: Date;
  expirationDate: Date;
}

const extendedContract: IExtendedContract = {
  ...contract,
  effectiveDate: new Date('2023-01-01'),
  expirationDate: new Date('2025-01-01')
};

Handling Prior Contracts

The priorContracts property allows you to model contract inheritance or reference, enabling historical traceability or derivations.

const previousContract: IPortableContract = {
  title: 'Precedent Service Agreement',
  context: 'Sets a precedent for the current agreement.',
  availableRoles: [legalRole, stakeholderRole],
  involvedParties,
  priorContracts: [],
  paragraphs: []
};

const referencedContract: IPortableContract = {
  ...contract,
  priorContracts: [previousContract]
};

console.log(referencedContract);

Integrating Business Features

The built-in synergy with @tsclass/tsclass permits a natural extension to business contact data directly within the contracts.

const newInvolvedParty: IInvolvedParty = {
  role: 'Project Manager',
  contact: {
    email: 'manager@domain.com',
    address: '101 Managerial Blvd, Operationscity'
  }
};

contract.involvedParties.push(newInvolvedParty);

Conclusion

The @signature.digital/tools package is designed to provide the essential scaffolding necessary to build intricate, business-oriented contract models while ensuring TypeScript's static type safety. Its major strength lies in its extensibility and the clarity it brings to contract structures, making modeling, data management, and integration straightforward for any digital contract-centric application. Adopt these tools to facilitate the standardized crafting of contract-based solutions across your enterprise applications. undefined