@noukha-technologies/mdm-core
v1.0.8
Published
Core MDM functionality for group, schema, and record management
Readme
@noukha/mdm-core
Core MDM (Master Data Management) functionality for groups, schemas, and records management.
Installation
npm install @noukha/mdm-coreFeatures
- Group Management: Create, read, update, and delete groups
- Schema Management: Dynamic schema creation and management
- Record Management: CRUD operations for dynamic records
- Master Data Relationships: Support for master data relationships
- Bulk Operations: Bulk create, update, and delete operations
- Pagination: Built-in pagination support
- Search: Full-text search capabilities
- Validation: Comprehensive data validation
Quick Start
1. Import the Module
import { MdmCoreModule } from '@noukha/mdm-core';
@Module({
imports: [
MdmCoreModule.forRoot({
database: {
connectionString: 'mongodb://localhost:27017/mdm'
},
schema: {
collectionName: 'schemas',
cacheEnabled: true,
autoCreateCollections: true
},
logging: {
enabled: true,
level: 'info'
}
})
]
})
export class AppModule {}2. Use the Services
import { GroupService, SchemaService, RecordService } from '@noukha/mdm-core';
@Injectable()
export class MyService {
constructor(
private readonly groupService: GroupService,
private readonly schemaService: SchemaService,
private readonly recordService: RecordService
) {}
async createGroup() {
return await this.groupService.create({
groupName: 'products',
displayName: 'Products'
});
}
async createSchema() {
return await this.schemaService.createSchema({
name: 'product',
displayName: 'Product',
fields: [
{
name: 'name',
type: FieldType.STRING,
required: true,
unique: true
},
{
name: 'price',
type: FieldType.NUMBER,
required: true
}
]
});
}
async createRecord() {
return await this.recordService.createRecord('product', {
data: {
name: 'Sample Product',
price: 99.99
}
});
}
}API Reference
GroupService
create(createGroupDto: CreateGroupDto): Promise<Group>findAll(): Promise<Group[]>findOne(groupId: string): Promise<Group>update(groupId: string, updateGroupDto: UpdateGroupDto): Promise<Group>remove(groupId: string): Promise<void>
SchemaService
createSchema(createSchemaDto: CreateSchemaDto): Promise<any>getSchema(schemaName: string): Promise<CreateSchemaDto>getAllSchemas(query: FindSchemasQueryDto): Promise<PaginatedResponse<CreateSchemaDto>>deleteSchema(schemaName: string, force?: boolean): Promise<any>getSchemasByGroupId(groupId: string): Promise<CreateSchemaDto[]>
RecordService
createRecord(schemaName: string, createRecordDto: CreateRecordDto): Promise<any>findAll(schemaName: string, query: FindRecordsQueryDto): Promise<PaginatedResponse<any>>findOne(schemaName: string, id: string): Promise<any>updateRecord(schemaName: string, id: string, updateRecordDto: UpdateRecordDto): Promise<any>removeRecord(schemaName: string, id: string): Promise<any>bulkCreate(schemaName: string, records: CreateRecordDto[]): Promise<any[]>bulkUpdate(schemaName: string, updates: Array<{ id: string; data: any }>): Promise<any>bulkDelete(schemaName: string, ids: string[]): Promise<any>
Field Types
STRING: Text dataNUMBER: Numeric dataBOOLEAN: True/false valuesDATE: Date and time valuesOBJECT: Complex objectsARRAY: Arrays of dataMASTER: References to other schemas
Relationship Types
ONE_TO_ONE: Single reference to another recordONE_TO_MANY: Array of references from one recordMANY_TO_ONE: Single reference from multiple recordsMANY_TO_MANY: Array of references from multiple records
Configuration
interface MdmConfig {
database?: {
connectionString?: string;
host?: string;
port?: number;
database?: string;
username?: string;
password?: string;
};
schema?: {
collectionName?: string;
cacheEnabled?: boolean;
autoCreateCollections?: boolean;
};
logging?: {
enabled?: boolean;
level?: 'debug' | 'info' | 'warn' | 'error';
};
}License
MIT
