fix(interfaces): Fixed import path in ts_interfaces/index.ts

This commit is contained in:
Philipp Kunz 2024-12-19 18:20:51 +01:00
parent e68524bc19
commit 6f60cb216d
6 changed files with 275 additions and 114 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
## 2024-12-19 - 1.0.11 - fix(interfaces)
Fixed import path in ts_interfaces/index.ts
- Corrected import path for plugins in ts_interfaces/index.ts to prevent module resolution issues.
## 2024-12-18 - 1.0.10 - fix(test) ## 2024-12-18 - 1.0.10 - fix(test)
Add initial test for portablecontract Add initial test for portablecontract

View File

@ -5,7 +5,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "signature.digital", "gitscope": "signature.digital",
"gitrepo": "tools", "gitrepo": "tools",
"description": "A TypeScript package providing utility interfaces and classes for digital contract management and integration, leveraging modular design and business context integration.", "description": "A TypeScript package providing utilities for managing digital contracts with modular interfaces and business context integration.",
"npmPackagename": "@signature.digital/tools", "npmPackagename": "@signature.digital/tools",
"license": "MIT", "license": "MIT",
"projectDomain": "signature.digital", "projectDomain": "signature.digital",
@ -13,19 +13,27 @@
"TypeScript", "TypeScript",
"digital contracts", "digital contracts",
"contract management", "contract management",
"ESM",
"interfaces",
"business integration",
"modular design", "modular design",
"business integration",
"interfaces",
"typescript utilities",
"contract structures",
"interfaces-driven architecture",
"contract modeling", "contract modeling",
"business relationships", "business relationships",
"data handling", "data handling",
"TypeScript utilities" "asynchronous loading",
"dynamic role assignment",
"contract validation",
"unit testing"
] ]
} }
}, },
"npmci": { "npmci": {
"npmGlobalTools": [], "npmGlobalTools": [],
"npmAccessLevel": "public" "npmAccessLevel": "public"
},
"tsdoc": {
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
} }
} }

View File

@ -2,7 +2,7 @@
"name": "@signature.digital/tools", "name": "@signature.digital/tools",
"version": "1.0.10", "version": "1.0.10",
"private": false, "private": false,
"description": "A TypeScript package providing utility interfaces and classes for digital contract management and integration, leveraging modular design and business context integration.", "description": "A TypeScript package providing utilities for managing digital contracts with modular interfaces and business context integration.",
"exports": { "exports": {
".": "./ts/index.js", ".": "./ts/index.js",
"./interfaces": "./dist_ts_interfaces/index.js" "./interfaces": "./dist_ts_interfaces/index.js"
@ -53,13 +53,18 @@
"TypeScript", "TypeScript",
"digital contracts", "digital contracts",
"contract management", "contract management",
"ESM",
"interfaces",
"business integration",
"modular design", "modular design",
"business integration",
"interfaces",
"typescript utilities",
"contract structures",
"interfaces-driven architecture",
"contract modeling", "contract modeling",
"business relationships", "business relationships",
"data handling", "data handling",
"TypeScript utilities" "asynchronous loading",
"dynamic role assignment",
"contract validation",
"unit testing"
] ]
} }

326
readme.md
View File

@ -1,171 +1,315 @@
# @signature.digital/tools # @signature.digital/tools
A TypeScript package offering utility interfaces and classes for efficient digital contract management and business context integration with a modular design.
A package that defines standard tools for working with contracts.
## Install ## Install
To install the `@signature.digital/tools` package, use your preferred package manager. For npm, run the following command:
To install `@signature.digital/tools`, you'll use your preferred package manager. Assuming you're using npm, follow the steps below:
```bash ```bash
npm install @signature.digital/tools npm install @signature.digital/tools
``` ```
Or, if you prefer using Yarn: Alternatively, if you are using Yarn, you can add the package with:
```bash ```bash
yarn add @signature.digital/tools 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. Ensure your development environment supports ECMAScript Modules. In your `tsconfig.json`, you should set the `"module"` option to `"ESNext"` or a compatible module type that supports ES Modules.
## Usage ## Usage
### Overview This guide details the comprehensive features of the `@signature.digital/tools` package, designed to streamline digital contract management in TypeScript applications. By using this package, you can leverage the structured capabilities of TypeScript to define, manage, and operate on digital contracts effectively.
`@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. ### Introduction to the Module
### Core Concepts The `@signature.digital/tools` package capitalizes on TypeScript's robust typing system to mold digital contract management paradigms. It encourages an interface-driven approach to designing contracts, promotes modularity, and integrates business context inherently within its structures.
Before diving into the various tools provided by this package, let's establish a few foundational concepts: ### Key Features
1. **Interface Driven Design:** 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. Utilize TypeScript interfaces to clearly delineate data structures for contracts. This results in easily maintainable, testable, and scalable digital contract solutions.
2. **Modularity:** 2. **Modular Architecture:**
This package allows developers to segment responsibilities and logic by modularizing contract components into roles, paragraphs, parties, and related structures. Divide and conquer complex contract datasets by representing them as reusable modules.
3. **Business Context Integration:** 3. **Business Contextualization:**
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. Seamlessly integrate business metadata into your contracts to reflect real-world applications and business scenarios.
### Usage Scenarios ### Usage Scenarios
#### Defining a Contract Below are practical examples to help you understand and leverage the full capabilities of the `@signature.digital/tools` package.
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. #### 1. Designing Contract Components
Begin by defining the core components of a contract using the provided interfaces. Start with `IRole`, `IInvolvedParty`, `IParagraph`, and `IPortableContract`:
```typescript ```typescript
import { IPortableContract, IRole, IInvolvedParty, IParagraph } from '@signature.digital/tools'; import { IPortableContract, IRole, IInvolvedParty, IParagraph } from '@signature.digital/tools';
import { tsclass } from '@signature.digital/tools'; import { tsclass } from '@signature.digital/tools';
const legalRole: IRole = { const createRoles = (): IRole[] => [
{
id: 'role-001', id: 'role-001',
name: 'Legal Advisor', name: 'Legal Advisor',
description: 'Provides legal counsel and insights on contractual obligations.' description: 'Advises on legal obligations and ensures compliance.'
};
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, id: 'role-002',
contact: stakeholderContact name: 'Stakeholder',
description: 'Interest in the outcome of the contract.'
} }
]; ];
const introductoryParagraph: IParagraph = { const createContacts = (): tsclass.business.IContact[] => [
{
email: 'advisor@legalfirm.com',
address: '123 Legal Firm St, Legal City'
},
{
email: 'stakeholder@business.com',
address: '456 Business Way, Industry City'
}
];
const createParagraphs = (): IParagraph[] => [
{
uniqueId: 'para-001', uniqueId: 'para-001',
parent: null, parent: null,
title: 'Introduction', title: 'Introduction',
content: 'This section provides an introduction to the contract, detailing its purpose and significance.' content: 'Introduction to the contract, setting expectations and scope of the agreement.'
}; },
{
const commitmentParagraph: IParagraph = {
uniqueId: 'para-002', uniqueId: 'para-002',
parent: introductoryParagraph, parent: null,
title: 'Commitments', title: 'Obligations',
content: 'Describes the commitments of the involved parties.' content: 'Details the specific obligations and responsibilities of each involved party.'
}; }
];
const contract: IPortableContract = { const createPortableContract = (): IPortableContract => {
const roles = createRoles();
const contacts = createContacts();
const paragraphs = createParagraphs();
return {
title: 'Digital Service Agreement', title: 'Digital Service Agreement',
context: 'Provides a framework of service delivery between involved entities.', context: 'A digital service provision framework between organizations.',
availableRoles: [legalRole, stakeholderRole], availableRoles: roles,
involvedParties, involvedParties: [
{ role: roles[0].name, contact: contacts[0] },
{ role: roles[1].name, contact: contacts[1] }
],
priorContracts: [], priorContracts: [],
paragraphs: [introductoryParagraph, commitmentParagraph] paragraphs
};
}; };
const contract = createPortableContract();
console.log(contract); console.log(contract);
``` ```
### Validating Contracts This example highlights how you can define the roles, contacts, and paragraphs that collectively represent a comprehensive digital contract model.
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. #### 2. Expanding Contract Details
### Extending the Interfaces Extend core contracts to encapsulate more details specific to your organizational needs. You can add dates, custom attributes, or any other relevant information:
Developers are encouraged to extend the interfaces to accommodate additional requirements.
```typescript ```typescript
interface IExtendedContract extends IPortableContract { interface IExtendedPortableContract extends IPortableContract {
effectiveDate: Date; startDate: Date;
expirationDate: Date; endDate: Date;
customAttributes?: Record<string, any>;
} }
const extendedContract: IExtendedContract = { const createExtendedContract = (): IExtendedPortableContract => {
...contract, const baseContract = createPortableContract();
effectiveDate: new Date('2023-01-01'), return {
expirationDate: new Date('2025-01-01') ...baseContract,
startDate: new Date('2023-01-01'),
endDate: new Date('2024-01-01'),
customAttributes: {
department: 'Legal',
projectCode: 'DSA2023'
}
}; };
};
const extendedContract = createExtendedContract();
console.log(extendedContract);
``` ```
### Handling Prior Contracts #### 3. Maintaining Contract History
The `priorContracts` property allows you to model contract inheritance or reference, enabling historical traceability or derivations. Managing contractual history provides a strategic advantage in legal and administrative processes. Employ the `priorContracts` attribute to keep track of iterations:
```typescript ```typescript
const previousContract: IPortableContract = { const initialContractVersion: IPortableContract = {
title: 'Precedent Service Agreement', title: 'Initial Service Agreement',
context: 'Sets a precedent for the current agreement.', context: 'Foundation agreement before the current digital service contract.',
availableRoles: [legalRole, stakeholderRole], availableRoles: createRoles(),
involvedParties, involvedParties: [
{ role: 'Legal Advisor', contact: createContacts()[0] }
],
priorContracts: [], priorContracts: [],
paragraphs: [] paragraphs: []
}; };
const referencedContract: IPortableContract = { const updatedContractVersion = {
...contract, ...initialContractVersion,
priorContracts: [previousContract] title: 'Revised Digital Service Agreement',
priorContracts: [initialContractVersion]
}; };
console.log(referencedContract); console.log(updatedContractVersion);
``` ```
### Integrating Business Features This functionality is crucial for firms that require detailed records of contractual changes over time.
The built-in synergy with `@tsclass/tsclass` permits a natural extension to business contact data directly within the contracts. #### 4. Integrating Business Entities
Leverage the power of `@tsclass/tsclass` to seamlessly embed business information within contracts, enhancing clarity and context:
```typescript ```typescript
const newInvolvedParty: IInvolvedParty = { const businessParty = {
role: 'Project Manager', role: 'Business Analyst',
contact: { contact: {
email: 'manager@domain.com', email: 'analyst@corporation.com',
address: '101 Managerial Blvd, Operationscity' address: '123 Business Lane, Tech City'
} }
}; };
contract.involvedParties.push(newInvolvedParty); extendedContract.involvedParties.push(businessParty);
console.log(extendedContract.involvedParties);
``` ```
### Conclusion This level of integration is perfect for incorporating stakeholders' information.
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. #### 5. Implementing Validation Logic
undefined
While the package promotes interface-based design, users must implement validation patterns to ensure contract data integrity. Below is an example of how to perform basic validations:
```typescript
function isValidContractStructure(contract: IPortableContract): boolean {
return (
contract.context !== '' &&
contract.availableRoles.length > 0 &&
contract.involvedParties.length > 0 &&
contract.paragraphs.every(paragraph => paragraph.content !== '')
);
}
if (!isValidContractStructure(extendedContract)) {
throw new Error('Invalid contract structure detected!');
}
```
This sample function demonstrates a straightforward mechanism to verify that the contract structure adheres to defined rules and prevents incorrect data entries.
### Advanced Usage
Let's delve into more intricate capabilities and scenarios that `@signature.digital/tools` can facilitate:
#### Asynchronous Loading and Initialization
For scenarios where parts of contracts or their dependencies are fetched from databases or APIs, the `@signature.digital/tools` suite can interact seamlessly with asynchronous sources:
```typescript
async function fetchContractData(): Promise<IPortableContract> {
// Simulate API call
return new Promise((resolve) => {
setTimeout(() => resolve(createPortableContract()), 1000);
});
}
async function initializeAsyncContract() {
try {
const contractData = await fetchContractData();
console.log('Loaded contract:', contractData);
} catch (error) {
console.error('Error fetching contract data:', error);
}
}
initializeAsyncContract();
```
This approach is vital when integrating with remote contract stores or dynamically fetching contract components.
#### Dynamic Role Assignment
Business environments often require flexibility in role assignments, which can be handled dynamically within the contract configurations:
```typescript
function addDynamicRoleToContract(contract: IPortableContract, roleName: string, contactInfo: tsclass.business.IContact) {
const role: IRole = {
id: `role-${Math.random().toString(36).substr(2, 9)}`, // Random ID generator
name: roleName,
description: `Dynamic role added for ${roleName}`
};
contract.availableRoles.push(role);
contract.involvedParties.push({ role: role.name, contact: contactInfo });
console.log(`Added role: ${roleName}`);
}
addDynamicRoleToContract(contract, 'Compliance Officer', {
email: 'compliance@business.com',
address: 'Office 42, Compliance Street'
});
console.log(contract);
```
Dynamic role assignments are essential when handling expansive contracts with changing stakeholder roles.
#### Comprehensive Testing
You should construct extensive tests for contract components by leveraging TypeScript's compatibility with common testing frameworks. Although the test cases here are isolated, they serve as foundational templates:
```typescript
import { expect } from '@push.rocks/tapbundle';
tap.test('Contract Initial Structure', async () => {
const contractBase = createPortableContract();
expect(contractBase.title).toBe('Digital Service Agreement');
expect(contractBase.paragraphs.length).toBeGreaterThan(0);
});
tap.test('Role Addition', async () => {
const testContract = createPortableContract();
const initialRoleCount = testContract.availableRoles.length;
const newRole: IRole = {
id: 'role-003',
name: 'Tester',
description: 'Ensures quality and compliance of the contract.'
};
testContract.availableRoles.push(newRole);
expect(testContract.availableRoles.length).toBe(initialRoleCount + 1);
});
tap.start();
```
These examples demonstrate basic test cases to verify the functionality and resiliency of your contract management system.
By utilizing the `@signature.digital/tools` package, developers can construct robust, dynamic, and efficient digital contract management systems tailored to a wide array of business scenarios. The examples provided above only scratch the surface of the package's versatility and extendability, empowering developers to innovate and automate contract handling processes in TypeScript.
## License and Legal Information
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
### Trademarks
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
### Company Information
Task Venture Capital GmbH
Registered at District court Bremen HRB 35230 HB, Germany
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.

View File

@ -3,6 +3,6 @@
*/ */
export const commitinfo = { export const commitinfo = {
name: '@signature.digital/tools', name: '@signature.digital/tools',
version: '1.0.10', version: '1.0.11',
description: 'A TypeScript package providing utility interfaces and classes for digital contract management and integration, leveraging modular design and business context integration.' description: 'A TypeScript package providing utilities for managing digital contracts with modular interfaces and business context integration.'
} }

View File

@ -1,5 +1,4 @@
import * as plugins from '../ts/portablecontract.plugins.js'; import * as plugins from './plugins.js';
export interface IParagraph { export interface IParagraph {
uniqueId: string; uniqueId: string;
parent: IParagraph | null; parent: IParagraph | null;