import { Item } from "../item"; import { PriKey } from "../key"; import { ItemQuery } from "../query/ItemQuery"; import { AffectedKeys, AllOperationResult, AllOptions, CreateOptions, FindOperationResult, FindOptions, OperationParams, Operations } from "./Operations"; /** * Primary Operations interface - specialized for primary (top-level) items only. * * This interface narrows the generic Operations interface to work exclusively * with PriKey. All operations accept only PriKey, never ComKey or locations. * * Primary items are top-level entities that don't belong to a location hierarchy. * Examples: Users, Organizations, Products, Documents * * Use this for: * - Libraries that store primary items * - Caches for primary items * - API clients for primary endpoints * - Any operations that work with non-hierarchical data * * @example * ```typescript * // Define a primary item type * interface User extends Item<'user'> { * name: string; * email: string; * } * * // Create operations for primary items * const userOps: PrimaryOperations = createUserOperations(); * * // Only PriKey allowed - no locations * await userOps.get({ kt: 'user', pk: '123' }); * await userOps.update({ kt: 'user', pk: '123' }, { name: 'Updated' }); * * // No locations parameter on collection methods * await userOps.all({}); * await userOps.find('byEmail', { email: 'test@example.com' }); * await userOps.allAction('deactivate', { reason: 'inactive' }); * ``` */ export interface PrimaryOperations, S extends string> extends Omit, 'all' | 'one' | 'create' | 'get' | 'update' | 'upsert' | 'remove' | 'find' | 'findOne' | 'action' | 'allAction' | 'facet' | 'allFacet'> { all(query?: ItemQuery, locations?: [], allOptions?: AllOptions): Promise>; one(query?: ItemQuery): Promise; find(finder: string, params?: OperationParams, locations?: [], options?: FindOptions): Promise>; findOne(finder: string, params?: OperationParams): Promise; create(item: Partial>, options?: CreateOptions): Promise; get(key: PriKey): Promise; update(key: PriKey, item: Partial>): Promise; upsert(key: PriKey, item: Partial>): Promise; remove(key: PriKey): Promise; action(key: PriKey, action: string, params?: OperationParams): Promise<[V, AffectedKeys]>; allAction(action: string, params?: OperationParams): Promise<[V[], AffectedKeys]>; facet(key: PriKey, facet: string, params?: OperationParams): Promise; allFacet(facet: string, params?: OperationParams): Promise; }