// // Copyright 2024 DXOS.org // import * as Schema from 'effect/Schema'; import * as SchemaAST from 'effect/SchemaAST'; import { type EntityId } from '@dxos/keys'; import { type ATTR_META, type EntityMeta } from './meta'; /** * Base type for all data objects (reactive, ECHO, and other raw objects). * NOTE: This describes the base type for all database objects. * It is stricter than `T extends {}` or `T extends object`. */ // TODO(burdon): Prefer Record. export type AnyProperties = Record; /** * Canonical type for all ECHO entities (objects and relations). * @depreacted Remove, use Entity.Unknown instead. */ // TODO(wittjosiah): Remove. Prefer higher level types (e.g. Entity.Unknown). export interface AnyEntity { readonly id: EntityId; } export type ExcludeId = Omit; export type PropertyKey = Extract, string>; // TODO(dmaretskyi): Remove. This should be using the symbol type. type WithMeta = { [ATTR_META]?: EntityMeta }; /** * The raw object should not include the ECHO id, but may include metadata. */ export const RawObject = ( schema: S, ): Schema.Schema> & WithMeta, Schema.Schema.Encoded> => { return Schema.make(SchemaAST.omit(schema.ast, ['id'])); };