import { Item } from "../item"; import { ComKey, LocKeyArray } from "../key"; import { ItemQuery } from "../query/ItemQuery"; import { AffectedKeys, AllOperationResult, AllOptions, CreateOptions, FindOperationResult, FindOptions, OperationParams, Operations } from "./Operations"; /** * Contained Operations interface - specialized for contained (hierarchical) items only. * * This interface narrows the generic Operations interface to work exclusively * with ComKey and requires locations for collection operations. * * Contained items exist within a location hierarchy and belong to parent items. * Examples: Comments (in Posts), Annotations (in Documents), Tasks (in Projects) * * Use this for: * - Libraries that store contained items * - Caches for contained items * - API clients for contained endpoints * - Any operations that work with hierarchical data * * @example * ```typescript * // Define a contained item type * interface Comment extends Item<'comment', 'post'> { * text: string; * author: string; * } * * // Create operations for contained items * const commentOps: ContainedOperations = createCommentOperations(); * * // Only ComKey allowed - includes location hierarchy * await commentOps.get({ * kt: 'comment', * pk: '123', * loc: [{ kt: 'post', lk: 'post-1' }] * }); * * await commentOps.update( * { kt: 'comment', pk: '123', loc: [{ kt: 'post', lk: 'post-1' }] }, * { text: 'Updated comment' } * ); * * // Locations required on collection methods * await commentOps.all({}, [{ kt: 'post', lk: 'post-1' }]); * await commentOps.find('recent', {}, [{ kt: 'post', lk: 'post-1' }]); * await commentOps.allAction('archive', {}, [{ kt: 'post', lk: 'post-1' }]); * ``` */ export interface ContainedOperations, S extends string, L1 extends string, L2 extends string = never, L3 extends string = never, L4 extends string = never, L5 extends string = never> extends Omit, 'get' | 'update' | 'remove' | 'upsert' | 'create' | 'action' | 'facet' | 'allAction' | 'allFacet' | 'all' | 'one' | 'find' | 'findOne'> { all(query: ItemQuery | undefined, locations: LocKeyArray | [], allOptions?: AllOptions): Promise>; one(query: ItemQuery | undefined, locations: LocKeyArray | []): Promise; find(finder: string, params: OperationParams | undefined, locations: LocKeyArray | [], options?: FindOptions): Promise>; findOne(finder: string, params: OperationParams | undefined, locations: LocKeyArray | []): Promise; create(item: Partial>, options?: CreateOptions): Promise; get(key: ComKey): Promise; update(key: ComKey, item: Partial>): Promise; upsert(key: ComKey, item: Partial>): Promise; remove(key: ComKey): Promise; action(key: ComKey, action: string, params?: OperationParams): Promise<[V, AffectedKeys]>; allAction(action: string, params: OperationParams | undefined, locations: LocKeyArray | []): Promise<[V[], AffectedKeys]>; facet(key: ComKey, facet: string, params?: OperationParams): Promise; allFacet(facet: string, params: OperationParams | undefined, locations: LocKeyArray | []): Promise; }