@fleetfolio/ontology
v0.0.3
Published
FleetFolio Drizzle Schema and Relations for Infrastructure Asset Management
Readme
@fleetfolio/ontology
FleetFolio Drizzle ORM schema and relations for infrastructure asset management and surveillance.
Overview
This package provides TypeScript-first database schemas and relations for FleetFolio, an infrastructure assurance platform that compares expected assets against discovered assets to identify gaps, shadow IT, and compliance issues.
Built on top of @surveilr/ontology, this package extends the base surveillance schema with FleetFolio-specific tables for:
- Asset Management: Track infrastructure assets, their types, statuses, and assignments
- Boundary Management: Define organizational and technical boundaries (networks, regions, environments)
- Service Tracking: Monitor services running on assets with status tracking
- Risk Management: Associate risks, threats, and probabilities with assets
- Graph Relationships: Model complex infrastructure relationships
Installation
npm install @fleetfolio/ontology drizzle-ormUsage
Import Everything (Recommended)
// Import from main entry - includes schema, relations, and utilities
import {
// Schema tables
asset,
assetType,
assetStatus,
boundary,
organization,
// Relations
assetRelations,
organizationRelations,
boundaryRelations,
// Utilities
generateInsert,
sqlLiteral,
raw
} from '@fleetfolio/ontology';Import from Specific Modules
// Import only schema tables
import {
asset,
assetType,
assetStatus,
boundary,
organization
} from '@fleetfolio/ontology/schema';
// Import only relations
import {
assetRelations,
organizationRelations,
boundaryRelations
} from '@fleetfolio/ontology/models';
// Import only utilities
import {
generateInsert,
generateInsertBatch,
sqlLiteral,
raw,
RawSQL,
selectId
} from '@fleetfolio/ontology/common';Full Example with Drizzle
import { drizzle } from 'drizzle-orm/better-sqlite3';
import Database from 'better-sqlite3';
import {
asset,
organization,
boundary,
assetRelations,
generateInsert
} from '@fleetfolio/ontology';
const sqlite = new Database('fleetfolio.db');
const db = drizzle(sqlite);
// Query assets with their organization
const assetsWithOrg = await db.query.asset.findMany({
with: {
organization: true,
assetType: true,
assetStatus: true,
},
});
// Generate SQL insert statements
const insertSQL = generateInsert('asset', {
asset_id: 'server-001',
name: 'Production Server',
asset_type_id: 'server',
organization_id: 'org-001'
});Core Tables
Asset Management
asset- Infrastructure assets (servers, services, applications)assetType- Asset type taxonomyassetStatus- Asset lifecycle statusassignment- Asset ownership/assignment tracking
Boundaries
boundary- Organizational/technical boundariesboundaryNature- Boundary type definitionsgraph- Relationship graphsgraphNature- Graph type definitions
Services
assetService- Services running on assetsassetServiceType- Service type taxonomyassetServiceStatus- Service status tracking
Risk Management
assetRisk- Asset risk associationsassetRiskType- Risk type taxonomythreatEvent- Threat event definitionsprobability- Likelihood ratingsseverity- Impact ratings
Inherited Tables
This package re-exports all tables from @surveilr/ontology, including:
- Organization and party management
- Person and device tracking
- Uniform resource ingestion
- Orchestration sessions
- osQuery integration
- Code notebooks
- And more...
See @surveilr/ontology documentation for details.
Package Exports
@fleetfolio/ontology- Main entry point (all schema tables, relations, and utilities)@fleetfolio/ontology/models- Relations only@fleetfolio/ontology/schema- Schema tables only@fleetfolio/ontology/common- Common utilities only
Recommendation: Use the main entry point (@fleetfolio/ontology) for most use cases. Use specific module imports only when you need to minimize bundle size or avoid naming conflicts.
TypeScript Support
Full TypeScript support with generated type definitions for all tables and relations.
License
ISC
Repository
github.com/opsfolio/netspective-fleetfolio
Related Projects
- FleetFolio - Infrastructure assurance platform
- surveilr - Resource surveillance engine
- @surveilr/ontology - Base surveillance schema
