@plasius/entity-manager
v1.0.15
Published
Entity definition & validation helpers for Plasius ecosystem
Readme
@plasius/entity-manager
Entity definitions and validation schemas for the Plasius ecosystem.
This package is part of the Plasius LTD selective open-source strategy. For more on our approach, see ADR-0013: Selective Open Source. This package is maintained as open source to foster community trust and enable integration, while the core Plasius platform remains proprietary.
Apache-2.0. ESM + CJS builds. TypeScript types included.
Installation
npm install @plasius/entity-managerUsage
import {
userEntitySchema,
PreferredDisplayOrder,
} from "@plasius/entity-manager";
const user = {
type: "userEntity",
version: "1.0",
email: "[email protected]",
name: {
firstName: "Alice",
lastName: "Lovelace",
displayName: "Alice L.",
preferredDisplayOrder: PreferredDisplayOrder.DISPLAY_NAME,
},
};
const result = userEntitySchema.validate(user);
if (!result.valid) {
console.error(result.errors);
}Export Overview
Base entity
baseEntitySchema,baseEntityShape,BaseEntity- Required fields include
partitionKey,id,entityType,createdAt,createdBy, andisDeleted(plus systemtypeandversion). - Persistence-only fields such as
partitionKey,createdBy,updatedBy,deletedBy, anddeletedReasonare marked internal and are omitted by default when callingschema.serialize(...).
User and permissions
userEntitySchema,userNameSchema,userAvatarSchemasettingsEntitySchema,permissionsEntitySchema,featureFlagEntitySchema,roleEntitySchema- Enums:
PreferredDisplayOrder,UserEmailPreferences,UserNotificationPreferences,Role,Scope
Assets
assetEntitySchema,imageAssetEntitySchema,audioAssetEntitySchema,modelAssetEntitySchema,objectAssetEntitySchema- Enums:
AudioChannel,ModelAssetFormat
Components
baseComponentSchema,physicsComponentSchema,animationComponentSchema,shadowComponentSchema,levelOfDetailComponentSchema- Enum:
ComponentTypes
Auth and translations
authenticatedUserSchema,AuthProvidertranslatableSchema,supportedLanguagesSchema
Validators and utilities
isValidAzureTableKey,isValidEntityType,validateAssetSchemavalidateFeatureFlagValue,validateSettingValue
Public Serialization
Entity schemas validate the full persisted entity shape, including internal audit and storage metadata.
When returning data to clients, prefer schema.serialize(entity) so only public fields are included by default.
import { baseEntitySchema } from "@plasius/entity-manager";
const payload = baseEntitySchema.serialize({
type: "baseEntity",
version: "1.0.0",
entityType: "baseEntity",
partitionKey: "tenant-a",
id: "row-1",
createdAt: new Date().toISOString(),
createdBy: "user-1",
isDeleted: false,
});
// partitionKey and createdBy are omitted from the serialized payload.
console.log(payload);Key Documentation
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
License
Licensed under the Apache-2.0 License.
