Static DeserializeDeserializes stored attributes from ArtifactVersionAttribute records.
Converts JSON strings back to their original types for use in application.
Array of attribute records from database
Array of extracted attributes with deserialized values
const stored = await artifactVersionAttributes.load();
const attributes = ArtifactExtractor.DeserializeFromStorage(stored);
// attributes have parsed JSON values, not strings
Private Static ExecutePrivate Executes an extractor function with timeout protection.
Creates a sandboxed environment where the extractor code can run safely with access to the content but isolated from the global scope.
The artifact content to extract from
JavaScript code that performs the extraction
Maximum execution time in milliseconds
The extracted value
Error if execution times out or fails
Static ExtractExtracts attributes from artifact content using the provided extract rules.
Executes each extractor function in a controlled environment with timeout and error handling. Failed extractors can either throw or return null values based on configuration.
Extraction configuration including content and rules
Extraction result with attributes, errors, and timing information
const result = await ArtifactExtractor.ExtractAttributes({
content: '{"subject": "Hello", "body": "World"}',
extractRules: [
{
name: 'subject',
type: 'string',
standardProperty: 'name',
extractor: 'const parsed = JSON.parse(content); return parsed.subject;'
}
]
});
// result.attributes = [{ name: 'subject', type: 'string', value: 'Hello', standardProperty: 'name' }]
Static GetFinds a specific standard property value from extracted attributes.
Convenience method for retrieving attributes mapped to standard properties like 'name', 'description', etc.
Array of extracted attributes
The standard property to find
The value of the attribute, or null if not found
const name = ArtifactExtractor.GetStandardProperty(attributes, 'name');
const description = ArtifactExtractor.GetStandardProperty(attributes, 'description');
Static ResolveResolves extract rules with hierarchical inheritance.
Child artifact types inherit all rules from their parent/grandparent types, but can override rules with the same name. This method resolves the final set of rules by walking up the hierarchy and merging rules.
Array of artifact types from most specific (child) to least specific (root parent) Each element should have an ExtractRules JSON string
Resolved array of extract rules with overrides applied
// Parent type has rules: [{ name: 'title', ... }, { name: 'author', ... }]
// Child type has rules: [{ name: 'title', ... (override) }, { name: 'date', ... (new) }]
const resolved = ArtifactExtractor.ResolveExtractRules([
childType.ExtractRules,
parentType.ExtractRules
]);
// Result: [{ name: 'title' (from child), ... }, { name: 'author' (from parent), ... }, { name: 'date' (from child), ... }]
Static SerializeSerializes extracted attributes for storage in ArtifactVersionAttribute table.
Converts extracted attribute values to JSON strings suitable for database storage.
Array of extracted attributes
Array of objects ready for database insertion
const serialized = ArtifactExtractor.SerializeForStorage(result.attributes);
// Can now insert these into ArtifactVersionAttribute table
for (const attr of serialized) {
await artifactVersionAttribute.save({
ArtifactVersionID: versionId,
Name: attr.name,
Type: attr.type,
Value: attr.value,
StandardProperty: attr.standardProperty
});
}
Utility class for managing artifact extract rules and performing extraction.
Handles: