@memberjunction/doc-utils 2.32.1 → 2.33.0

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.
Files changed (2) hide show
  1. package/README.md +137 -0
  2. package/package.json +4 -4
package/README.md ADDED
@@ -0,0 +1,137 @@
1
+ # MemberJunction Documentation Utilities
2
+
3
+ A TypeScript library for dynamically retrieving, parsing, and caching MemberJunction documentation to support AI models and other documentation-driven features.
4
+
5
+ ## Overview
6
+
7
+ The `@memberjunction/doc-utils` package provides functionality for accessing the official MemberJunction documentation. It can fetch documentation from the MemberJunction object model documentation site, parse the HTML content, and cache elements in memory for improved performance. This library is particularly useful when integrating with AI models that need context about the MemberJunction system.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @memberjunction/doc-utils
13
+ ```
14
+
15
+ ## Dependencies
16
+
17
+ This package depends on the following MemberJunction packages:
18
+ - `@memberjunction/core`
19
+ - `@memberjunction/core-entities`
20
+ - `@memberjunction/global`
21
+
22
+ External dependencies:
23
+ - `jsdom` - For HTML parsing
24
+ - `axios` - For HTTP requests
25
+
26
+ ## Main Features
27
+
28
+ - **Documentation Retrieval**: Dynamically fetch documentation from the MemberJunction documentation site
29
+ - **HTML Parsing**: Extract relevant content from HTML documentation pages
30
+ - **Caching Mechanism**: Improve performance by caching documentation content in memory
31
+ - **Extended Entity Classes**: Access documentation for entities and their properties
32
+ - **Singleton Pattern**: Easy access to documentation functionality throughout your application
33
+
34
+ ## Usage
35
+
36
+ ### Basic Example
37
+
38
+ ```typescript
39
+ import { DocumentationEngine } from '@memberjunction/doc-utils';
40
+
41
+ // Get the singleton instance
42
+ const docEngine = DocumentationEngine.getInstance();
43
+
44
+ // Get documentation for a specific entity
45
+ const entityDoc = await docEngine.getEntityDocumentation('User');
46
+ console.log(entityDoc.description);
47
+
48
+ // Get documentation for a specific entity field
49
+ const fieldDoc = await docEngine.getEntityFieldDocumentation('User', 'Email');
50
+ console.log(fieldDoc.description);
51
+ ```
52
+
53
+ ### Working with Entity Documentation
54
+
55
+ ```typescript
56
+ import { DocumentationEngine } from '@memberjunction/doc-utils';
57
+
58
+ async function displayEntityInfo(entityName: string) {
59
+ const docEngine = DocumentationEngine.getInstance();
60
+ const entityDoc = await docEngine.getEntityDocumentation(entityName);
61
+
62
+ console.log(`Entity: ${entityName}`);
63
+ console.log(`Description: ${entityDoc.description}`);
64
+ console.log(`Base Table: ${entityDoc.baseTable}`);
65
+ console.log(`Schema: ${entityDoc.schemaName}`);
66
+
67
+ // Get all fields for the entity
68
+ const fields = await docEngine.getEntityFieldsDocumentation(entityName);
69
+
70
+ console.log('Fields:');
71
+ fields.forEach(field => {
72
+ console.log(`- ${field.name}: ${field.description}`);
73
+ });
74
+ }
75
+
76
+ // Example usage
77
+ displayEntityInfo('User');
78
+ ```
79
+
80
+ ### Customizing Caching Behavior
81
+
82
+ ```typescript
83
+ import { DocumentationEngine } from '@memberjunction/doc-utils';
84
+
85
+ // Configure the documentation engine with custom settings
86
+ DocumentationEngine.configure({
87
+ cacheTimeoutMinutes: 60, // Cache documentation for 1 hour
88
+ baseDocumentationUrl: 'https://custom-docs.memberjunction.com'
89
+ });
90
+
91
+ // Get the configured instance
92
+ const docEngine = DocumentationEngine.getInstance();
93
+ ```
94
+
95
+ ## API Reference
96
+
97
+ ### DocumentationEngine
98
+
99
+ The main class that provides access to documentation functionality.
100
+
101
+ #### Methods
102
+
103
+ - `getInstance()`: Returns the singleton instance of DocumentationEngine
104
+ - `configure(options)`: Configure the documentation engine with custom settings
105
+ - `getEntityDocumentation(entityName: string)`: Get documentation for a specific entity
106
+ - `getEntityFieldDocumentation(entityName: string, fieldName: string)`: Get documentation for a specific entity field
107
+ - `getEntityFieldsDocumentation(entityName: string)`: Get documentation for all fields of an entity
108
+ - `clearCache()`: Clear the documentation cache
109
+
110
+ ### EntityDocumentation
111
+
112
+ Class representing documentation for an entity.
113
+
114
+ #### Properties
115
+
116
+ - `name`: The name of the entity
117
+ - `description`: The description of the entity
118
+ - `baseTable`: The base table name in the database
119
+ - `schemaName`: The database schema name
120
+ - `fields`: Array of field documentation objects
121
+
122
+ ### EntityFieldDocumentation
123
+
124
+ Class representing documentation for an entity field.
125
+
126
+ #### Properties
127
+
128
+ - `name`: The name of the field
129
+ - `description`: The description of the field
130
+ - `dataType`: The data type of the field
131
+ - `length`: The length of the field (for string types)
132
+ - `isPrimaryKey`: Whether the field is a primary key
133
+ - `isNullable`: Whether the field can be null
134
+
135
+ ## License
136
+
137
+ ISC
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/doc-utils",
3
- "version": "2.32.1",
3
+ "version": "2.33.0",
4
4
  "description": "This library provides functionality for dynamically retreiving documentation from the official MemberJunction object model documentation site, parsing it, and caching elements in memory for performance. Use this whenever you need dynamic access to the MJ documentation to feed to AI models and for any other similar purpose.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -19,9 +19,9 @@
19
19
  "typescript": "^5.4.5"
20
20
  },
21
21
  "dependencies": {
22
- "@memberjunction/core": "2.32.1",
23
- "@memberjunction/core-entities": "2.32.1",
24
- "@memberjunction/global": "2.32.1",
22
+ "@memberjunction/core": "2.33.0",
23
+ "@memberjunction/core-entities": "2.33.0",
24
+ "@memberjunction/global": "2.33.0",
25
25
  "jsdom": "^24.1.0",
26
26
  "axios": "^1.6.7"
27
27
  }