diff --git a/README.md b/README.md index 8f54a6c7..5462afbd 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,36 @@ const db = new BrainyData({ }); ``` +### Importing Graph Types Separately + +If you only need the graph type definitions without importing the entire library (supporting tree shaking), you can import them directly: + +```typescript +// Import only the graph types +import { GraphNoun, GraphVerb, NounType, VerbType } from '@soulcraft/brainy/types/graphTypes'; + +// Example usage +const person = { + id: '123', + createdBy: { + augmentation: 'manual', + version: '1.0', + model: 'none', + modelVersion: '1.0' + }, + noun: NounType.Person, + createdAt: { seconds: Date.now() / 1000, nanoseconds: 0 }, + updatedAt: { seconds: Date.now() / 1000, nanoseconds: 0 }, + data: { name: 'John Doe' } +}; + +// Check the type +console.log(`Person type: ${person.noun}`); // 'person' +console.log(`Available noun types:`, Object.values(NounType)); +``` + +This approach allows you to use just the type definitions without pulling in the entire library, which is useful for applications that only need to work with the data model. + ## Publishing and Using as a Private NPM Package Soulcraft Brainy is configured as a private NPM package with restricted access. This section provides information on how to publish and use it within your organization. diff --git a/package.json b/package.json index 7178f27d..1968dc72 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,10 @@ ".": { "import": "./dist/index.js", "types": "./dist/index.d.ts" + }, + "./types/graphTypes": { + "import": "./dist/types/graphTypes.js", + "types": "./dist/types/graphTypes.d.ts" } }, "engines": { diff --git a/src/types/graphTypes.ts b/src/types/graphTypes.ts index bdc2de87..84532387 100644 --- a/src/types/graphTypes.ts +++ b/src/types/graphTypes.ts @@ -15,8 +15,6 @@ interface Timestamp { interface CreatorMetadata { augmentation: string // Name of the augmentation that created this element version: string // Version of the augmentation - model: string // Model identifier used in creation - modelVersion: string // Version of the model } /** @@ -29,7 +27,9 @@ export interface GraphNoun { noun: NounType // Type classification of the noun createdAt: Timestamp // When the noun was created updatedAt: Timestamp // When the noun was last updated + label?: string // Optional descriptive label data?: Record // Additional flexible data storage + embeddedVerbs?: EmbeddedGraphVerb[] // Optional embedded relationships embedding?: number[] // Vector representation of the noun }