@memberjunction/core-entities 2.103.0 → 2.105.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 (30) hide show
  1. package/dist/artifact-extraction/artifact-extract-rules.d.ts +163 -0
  2. package/dist/artifact-extraction/artifact-extract-rules.d.ts.map +1 -0
  3. package/dist/artifact-extraction/artifact-extract-rules.js +13 -0
  4. package/dist/artifact-extraction/artifact-extract-rules.js.map +1 -0
  5. package/dist/artifact-extraction/artifact-extractor.d.ts +157 -0
  6. package/dist/artifact-extraction/artifact-extractor.d.ts.map +1 -0
  7. package/dist/artifact-extraction/artifact-extractor.js +265 -0
  8. package/dist/artifact-extraction/artifact-extractor.js.map +1 -0
  9. package/dist/custom/EnvironmentEntityExtended.d.ts +12 -0
  10. package/dist/custom/EnvironmentEntityExtended.d.ts.map +1 -0
  11. package/dist/custom/EnvironmentEntityExtended.js +29 -0
  12. package/dist/custom/EnvironmentEntityExtended.js.map +1 -0
  13. package/dist/custom/TemplateEntityExtended.d.ts +59 -0
  14. package/dist/custom/TemplateEntityExtended.d.ts.map +1 -0
  15. package/dist/custom/TemplateEntityExtended.js +126 -0
  16. package/dist/custom/TemplateEntityExtended.js.map +1 -0
  17. package/dist/engines/artifacts.d.ts +19 -0
  18. package/dist/engines/artifacts.d.ts.map +1 -0
  19. package/dist/engines/artifacts.js +37 -0
  20. package/dist/engines/artifacts.js.map +1 -0
  21. package/dist/generated/entity_subclasses.d.ts +1901 -915
  22. package/dist/generated/entity_subclasses.d.ts.map +1 -1
  23. package/dist/generated/entity_subclasses.js +2869 -1419
  24. package/dist/generated/entity_subclasses.js.map +1 -1
  25. package/dist/index.d.ts +5 -0
  26. package/dist/index.d.ts.map +1 -1
  27. package/dist/index.js +5 -0
  28. package/dist/index.js.map +1 -1
  29. package/package.json +2 -2
  30. package/readme.md +87 -160
package/dist/index.d.ts CHANGED
@@ -14,8 +14,13 @@ export * from './custom/AIAgentRunExtended';
14
14
  export * from './custom/AIAgentRunStepExtended';
15
15
  export * from './custom/AIPromptRunEntityExtended';
16
16
  export * from './custom/ComponentEntityExtended';
17
+ export * from './custom/EnvironmentEntityExtended';
18
+ export * from './custom/TemplateEntityExtended';
17
19
  export * from './custom/ResourcePermissions/ResourcePermissionEngine';
18
20
  export * from './custom/ResourcePermissions/ResourcePermissionSubclass';
19
21
  export * from './custom/ResourcePermissions/ResourceData';
20
22
  export * from './engines/component-metadata';
23
+ export * from './engines/artifacts';
24
+ export * from './artifact-extraction/artifact-extract-rules';
25
+ export * from './artifact-extraction/artifact-extractor';
21
26
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,+BAA+B,CAAA;AAE7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,2CAA2C,CAAC;AAE1D,cAAc,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,+BAA+B,CAAA;AAE7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,mCAAmC,CAAC;AAClD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,mCAAmC,CAAC;AAClD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC;AACjD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,iCAAiC,CAAC;AAChD,cAAc,oCAAoC,CAAC;AACnD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,uDAAuD,CAAC;AACtE,cAAc,yDAAyD,CAAC;AACxE,cAAc,2CAA2C,CAAC;AAE1D,cAAc,8BAA8B,CAAC;AAC7C,cAAc,qBAAqB,CAAC;AAEpC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,0CAA0C,CAAC"}
package/dist/index.js CHANGED
@@ -30,8 +30,13 @@ __exportStar(require("./custom/AIAgentRunExtended"), exports);
30
30
  __exportStar(require("./custom/AIAgentRunStepExtended"), exports);
31
31
  __exportStar(require("./custom/AIPromptRunEntityExtended"), exports);
32
32
  __exportStar(require("./custom/ComponentEntityExtended"), exports);
33
+ __exportStar(require("./custom/EnvironmentEntityExtended"), exports);
34
+ __exportStar(require("./custom/TemplateEntityExtended"), exports);
33
35
  __exportStar(require("./custom/ResourcePermissions/ResourcePermissionEngine"), exports);
34
36
  __exportStar(require("./custom/ResourcePermissions/ResourcePermissionSubclass"), exports);
35
37
  __exportStar(require("./custom/ResourcePermissions/ResourceData"), exports);
36
38
  __exportStar(require("./engines/component-metadata"), exports);
39
+ __exportStar(require("./engines/artifacts"), exports);
40
+ __exportStar(require("./artifact-extraction/artifact-extract-rules"), exports);
41
+ __exportStar(require("./artifact-extraction/artifact-extractor"), exports);
37
42
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,gEAA6C;AAE7C,0DAAwC;AACxC,mEAAiD;AACjD,2DAAyC;AACzC,2DAAyC;AACzC,oEAAkD;AAClD,4DAA0C;AAC1C,oEAAkD;AAClD,2DAAyC;AACzC,mEAAiD;AACjD,gEAA8C;AAC9C,qEAAmD;AACnD,8DAA4C;AAC5C,kEAAgD;AAChD,qEAAmD;AACnD,mEAAiD;AAEjD,wFAAsE;AACtE,0FAAwE;AACxE,4EAA0D;AAE1D,+DAA6C"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AACA,gEAA6C;AAE7C,0DAAwC;AACxC,mEAAiD;AACjD,2DAAyC;AACzC,2DAAyC;AACzC,oEAAkD;AAClD,4DAA0C;AAC1C,oEAAkD;AAClD,2DAAyC;AACzC,mEAAiD;AACjD,gEAA8C;AAC9C,qEAAmD;AACnD,8DAA4C;AAC5C,kEAAgD;AAChD,qEAAmD;AACnD,mEAAiD;AACjD,qEAAmD;AACnD,kEAAgD;AAEhD,wFAAsE;AACtE,0FAAwE;AACxE,4EAA0D;AAE1D,+DAA6C;AAC7C,sDAAoC;AAEpC,+EAA6D;AAC7D,2EAAyD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@memberjunction/core-entities",
3
- "version": "2.103.0",
3
+ "version": "2.105.0",
4
4
  "description": "Entity subclasses for the metadata layer of MemberJunction defined in the MJ_CORE schema (usually '__mj'), distributed as part of each release of MemberJunction",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@memberjunction/core": "2.100.3",
23
23
  "@memberjunction/global": "2.100.3",
24
- "@memberjunction/interactive-component-types": "2.103.0",
24
+ "@memberjunction/interactive-component-types": "2.105.0",
25
25
  "zod": "^3.23.8"
26
26
  }
27
27
  }
package/readme.md CHANGED
@@ -7,6 +7,7 @@ A comprehensive library of strongly-typed entity classes for MemberJunction's co
7
7
  The `@memberjunction/core-entities` package contains:
8
8
  - **178+ Generated Entity Classes**: Strongly-typed TypeScript classes for all core MemberJunction entities
9
9
  - **Extended Entity Classes**: Custom subclasses with specialized business logic
10
+ - **Artifact Extraction System**: Metadata-driven attribute extraction with hierarchical inheritance
10
11
  - **Resource Permission Engine**: Comprehensive permission management system
11
12
  - **Zod Schema Validation**: Built-in runtime validation for all entity types
12
13
  - **Type Definitions**: Full TypeScript type definitions for enhanced IDE support
@@ -33,11 +34,20 @@ Several entities have custom extended classes that provide additional functional
33
34
  - **DashboardEntityExtended**: Dashboard configuration management
34
35
  - **AIModelEntityExtended**: AI model utilities and helpers
35
36
  - **AIPromptEntityExtended**: Prompt management functionality
37
+ - **ArtifactVersionExtended**: Automatic content hashing and attribute extraction
36
38
  - **ListDetailEntityExtended**: List view enhancements
37
39
  - **ScheduledActionExtended**: Scheduled task management
38
40
  - **ResourcePermissionEntity**: Resource access control
39
41
 
40
- ### 3. Resource Permission Engine
42
+ ### 3. Artifact Extraction System
43
+ A powerful metadata-driven system for extracting structured attributes from artifact content:
44
+ - Hierarchical extract rule inheritance
45
+ - Declarative JavaScript-based extractors
46
+ - Automatic SHA-256 content hashing
47
+ - Standard property mappings for UI rendering
48
+ - Type-safe attribute storage and retrieval
49
+
50
+ ### 4. Resource Permission Engine
41
51
  A sophisticated permission system for managing access to various resources:
42
52
  - Role-based permissions
43
53
  - Resource type definitions
@@ -71,159 +81,106 @@ app.Description = 'A test application';
71
81
  await app.Save();
72
82
  ```
73
83
 
74
- ### Working with User Views
84
+ (continuing in next command due to size...)
75
85
 
76
- ```typescript
77
- import { UserViewEntityExtended } from '@memberjunction/core-entities';
78
- import { Metadata, RunView } from '@memberjunction/core';
86
+ ## Artifact Extraction System
79
87
 
80
- const md = new Metadata();
88
+ The artifact extraction system enables declarative extraction of structured attributes from artifact content with hierarchical inheritance.
81
89
 
82
- // Load user views for an entity
83
- const rv = this.RunViewProviderToUse;
84
- const views = await rv.RunView<UserViewEntityExtended>({
85
- EntityName: 'User Views',
86
- ExtraFilter: `EntityID='${entityId}' AND UserID='${userId}'`,
87
- ResultType: 'entity_object'
88
- });
90
+ ### Overview
89
91
 
90
- // Access parsed view configuration
91
- const view = views.Results[0];
92
- const columns = view.Columns; // Parsed column configuration
93
- const filters = view.Filter; // Parsed filter configuration
94
- ```
92
+ Artifacts in MemberJunction can have **extract rules** defined in their `ArtifactType` that specify how to extract attributes from the artifact content. These rules:
93
+ - Are stored as JSON in the `ArtifactType.ExtractRules` column
94
+ - Support hierarchical inheritance (child types inherit and override parent rules)
95
+ - Execute JavaScript code in a controlled environment
96
+ - Map extracted values to standard properties (name, description, display formats)
97
+ - Are automatically executed when artifact versions are saved
95
98
 
96
- ### Resource Permissions
99
+ ### Defining Extract Rules
97
100
 
98
- ```typescript
99
- import { ResourcePermissionEngine } from '@memberjunction/core-entities';
100
-
101
- // Get the singleton instance
102
- const permEngine = ResourcePermissionEngine.Instance;
103
-
104
- // Initialize the engine
105
- await permEngine.Config();
106
-
107
- // Check permissions for a resource
108
- const permissions = permEngine.GetPermissionsForResource(
109
- resourceTypeId,
110
- resourceRecordId
111
- );
112
-
113
- // Get user's permission level
114
- const userPermission = await permEngine.GetUserPermissionForResource(
115
- userId,
116
- resourceTypeId,
117
- resourceRecordId
118
- );
119
- ```
120
-
121
- ### Dashboard Management
122
-
123
- ```typescript
124
- import { DashboardEntityExtended } from '@memberjunction/core-entities';
125
- import { Metadata } from '@memberjunction/core';
126
-
127
- const md = new Metadata();
101
+ Extract rules are defined in the `ArtifactType.ExtractRules` JSON field:
128
102
 
129
- // Create a new dashboard
130
- const dashboard = await md.GetEntityObject<DashboardEntityExtended>('Dashboards');
131
- dashboard.NewRecord(); // Automatically sets default configuration
103
+ ```json
104
+ [
105
+ {
106
+ "name": "subject",
107
+ "description": "Email subject line",
108
+ "type": "string",
109
+ "standardProperty": "name",
110
+ "extractor": "const parsed = JSON.parse(content); return parsed.subject || 'Untitled';"
111
+ },
112
+ {
113
+ "name": "recipientCount",
114
+ "description": "Number of recipients",
115
+ "type": "number",
116
+ "extractor": "const parsed = JSON.parse(content); return parsed.recipients?.length || 0;"
117
+ }
118
+ ]
119
+ ```
132
120
 
133
- dashboard.Name = 'Sales Dashboard';
134
- dashboard.Description = 'Monthly sales metrics';
135
- await dashboard.Save();
121
+ ### Extract Rule Properties
136
122
 
137
- // The UIConfigDetails is automatically initialized with default grid configuration
138
- ```
123
+ | Property | Type | Description |
124
+ |----------|------|-------------|
125
+ | `name` | string | Unique identifier for this rule |
126
+ | `description` | string | Human-readable description |
127
+ | `type` | string | TypeScript type (e.g., `'string'`, `'Array<{x: number}>'`) |
128
+ | `standardProperty` | string? | Maps to: `'name'`, `'description'`, `'displayMarkdown'`, `'displayHtml'` |
129
+ | `extractor` | string | JavaScript code that receives `content` and returns value |
139
130
 
140
- ### AI Model Access
131
+ ### Using the ArtifactExtractor
141
132
 
142
133
  ```typescript
143
- import { AIModelEntityExtended } from '@memberjunction/core-entities';
144
- import { RunView } from '@memberjunction/core';
134
+ import { ArtifactExtractor } from '@memberjunction/core-entities';
145
135
 
146
- const rv = this.RunViewProviderToUse;
136
+ // Resolve extract rules with inheritance
137
+ const rules = ArtifactExtractor.ResolveExtractRules(artifactTypeChain);
147
138
 
148
- // Load all active AI models
149
- const models = await rv.RunView<AIModelEntityExtended>({
150
- EntityName: 'AI Models',
151
- ExtraFilter: "IsActive=1",
152
- OrderBy: 'Name',
153
- ResultType: 'entity_object'
139
+ // Extract attributes from content
140
+ const result = await ArtifactExtractor.ExtractAttributes({
141
+ content: artifactContent,
142
+ extractRules: rules,
143
+ throwOnError: false,
144
+ timeout: 5000
154
145
  });
155
146
 
156
- // Use the extended functionality
157
- models.Results.forEach(model => {
158
- console.log(model.APINameOrName); // Uses APIName if available, otherwise Name
159
- });
147
+ // Get standard properties
148
+ const name = ArtifactExtractor.GetStandardProperty(result.attributes, 'name');
149
+ const description = ArtifactExtractor.GetStandardProperty(result.attributes, 'description');
160
150
  ```
161
151
 
162
- ## Entity Validation
163
-
164
- All entities include Zod schema validation:
152
+ ### Automatic Extraction with ArtifactVersionExtended
165
153
 
166
154
  ```typescript
167
- import { UserSchema, UserEntityType } from '@memberjunction/core-entities';
168
-
169
- // Validate data before creating entity
170
- const userData: unknown = { /* user data */ };
171
-
172
- try {
173
- const validatedData = UserSchema.parse(userData);
174
- // Data is now typed as UserEntityType
175
- } catch (error) {
176
- // Handle validation errors
177
- }
178
- ```
179
-
180
- ## Type Definitions
181
-
182
- Every entity exports both the class and its TypeScript type:
183
-
184
- ```typescript
185
- import {
186
- ApplicationEntity, // The entity class
187
- ApplicationEntityType, // The TypeScript type
188
- ApplicationSchema // The Zod schema
189
- } from '@memberjunction/core-entities';
190
-
191
- // Use types for function parameters
192
- function processApplication(app: ApplicationEntityType) {
193
- // Type-safe access to all properties
194
- }
195
- ```
196
-
197
- ## Custom Entity Extensions
198
-
199
- To create your own entity extensions:
155
+ import { ArtifactVersionExtended } from '@memberjunction/core-entities';
156
+ import { Metadata } from '@memberjunction/core';
200
157
 
201
- ```typescript
202
- import { RegisterClass } from '@memberjunction/global';
203
- import { BaseEntity } from '@memberjunction/core';
204
- import { YourEntity } from '@memberjunction/core-entities';
205
-
206
- @RegisterClass(BaseEntity, 'Your Entity Name')
207
- export class YourEntityExtended extends YourEntity {
208
- // Add custom methods and properties
209
- public customMethod(): void {
210
- // Your business logic
211
- }
212
- }
158
+ const md = new Metadata();
159
+ const version = await md.GetEntityObject<ArtifactVersionExtended>('MJ: Artifact Versions');
160
+ version.NewRecord();
161
+ version.Content = JSON.stringify({ subject: "Q4 Campaign", body: "..." });
162
+
163
+ // Save triggers automatic extraction:
164
+ // 1. Calculates SHA-256 hash → ContentHash
165
+ // 2. Resolves extract rules from ArtifactType hierarchy
166
+ // 3. Extracts attributes → Name and Description
167
+ // 4. Creates ArtifactVersionAttribute records
168
+ await version.Save();
169
+
170
+ console.log(version.Name); // "Q4 Campaign" (extracted)
171
+ console.log(version.ContentHash); // "a3f7e2..." (SHA-256)
213
172
  ```
214
173
 
215
- ## Available Entities
174
+ For complete documentation, see the [Implementation Summary](../../IMPLEMENTATION_SUMMARY_v2.105.md).
216
175
 
217
- This package includes classes for all core MemberJunction entities including:
176
+ ## Best Practices
218
177
 
219
- - **System Entities**: Users, Applications, Entities, Entity Fields, etc.
220
- - **Security**: Roles, Authorizations, User Roles, Resource Permissions
221
- - **Communication**: Conversations, Templates, Communication Providers
222
- - **Workflow**: Actions, Action Categories, Scheduled Actions
223
- - **AI/ML**: AI Models, AI Prompts, Vector Databases
224
- - **Reporting**: Reports, Dashboards, Query Fields
225
- - **Integration**: Company Integrations, API Configurations
226
- - **And 170+ more...**
178
+ 1. **Always use Metadata for entity creation**: Never instantiate entity classes directly
179
+ 2. **Use RunView for bulk operations**: More efficient than loading entities individually
180
+ 3. **Leverage TypeScript types**: Use exported types for function parameters
181
+ 4. **Handle validation errors**: Wrap entity operations in try-catch blocks
182
+ 5. **Use extended classes**: When available, use extended versions for additional functionality
183
+ 6. **Import artifacts from core-entities**: Artifact extraction utilities are in this package
227
184
 
228
185
  ## Dependencies
229
186
 
@@ -231,40 +188,10 @@ This package includes classes for all core MemberJunction entities including:
231
188
  - `@memberjunction/global`: Global utilities and decorators
232
189
  - `zod`: Runtime type validation
233
190
 
234
- ## Version Compatibility
235
-
236
- This package is released in sync with MemberJunction core releases. Always use matching versions:
237
-
238
- ```json
239
- {
240
- "dependencies": {
241
- "@memberjunction/core": "2.43.0",
242
- "@memberjunction/core-entities": "2.43.0",
243
- "@memberjunction/global": "2.43.0"
244
- }
245
- }
246
- ```
247
-
248
- ## Best Practices
249
-
250
- 1. **Always use Metadata for entity creation**: Never instantiate entity classes directly
251
- 2. **Use RunView for bulk operations**: More efficient than loading entities individually
252
- 3. **Leverage TypeScript types**: Use the exported types for function parameters and return types
253
- 4. **Handle validation errors**: Always wrap entity operations in try-catch blocks
254
- 5. **Use extended classes**: When available, use the extended versions for additional functionality
255
-
256
- ## Contributing
257
-
258
- This package is generated from MemberJunction metadata. To modify:
259
-
260
- 1. Update the source metadata in MemberJunction
261
- 2. Run the code generation process
262
- 3. Custom extensions can be added to the `/src/custom` directory
263
-
264
191
  ## License
265
192
 
266
193
  ISC - See LICENSE file for details
267
194
 
268
195
  ## Support
269
196
 
270
- For issues, questions, or contributions, please visit the [MemberJunction GitHub repository](https://github.com/MemberJunction/MJ).
197
+ For issues, questions, or contributions, visit the [MemberJunction GitHub repository](https://github.com/MemberJunction/MJ).