docs: add separate graph type import section to README and update type definitions
Introduced a new README section explaining how to import graph types individually to enable tree shaking. Updated `package.json` exports to support direct graph type imports. Enhanced `GraphNoun` structure by adding optional `label` and `embeddedVerbs` properties while simplifying the `CreatorMetadata` interface.
This commit is contained in:
parent
d86962100c
commit
ce9c5e2522
3 changed files with 36 additions and 2 deletions
30
README.md
30
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.
|
||||
|
|
|
|||
|
|
@ -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": {
|
||||
|
|
|
|||
|
|
@ -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<string, unknown> // Additional flexible data storage
|
||||
embeddedVerbs?: EmbeddedGraphVerb[] // Optional embedded relationships
|
||||
embedding?: number[] // Vector representation of the noun
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue