import type { Accountability, PermissionsAction, Query, SchemaOverview } from '@db-studio/types'; import type Keyv from 'keyv'; import type { Knex } from 'knex'; import type { AbstractService, AbstractServiceOptions, Item as AnyItem, MutationOptions, PrimaryKey } from '../types/index.js'; export type QueryOptions = { stripNonRequested?: boolean; permissionsAction?: PermissionsAction; emitEvents?: boolean; }; export type MutationTracker = { trackMutations: (count: number) => void; getCount: () => number; }; export declare class ItemsService implements AbstractService { collection: string; knex: Knex; accountability: Accountability | null; eventScope: string; schema: SchemaOverview; cache: Keyv | null; constructor(collection: string, options: AbstractServiceOptions); createMutationTracker(initialCount?: number): MutationTracker; getKeysByQuery(query: Query): Promise; /** * Create a single new item. */ createOne(data: Partial, opts?: MutationOptions): Promise; /** * Create multiple new items at once. Inserts all provided records sequentially wrapped in a transaction. */ createMany(data: Partial[], opts?: MutationOptions): Promise; /** * Get items by query */ readByQuery(query: Query, opts?: QueryOptions): Promise; /** * Get single item by primary key */ readOne(key: PrimaryKey, query?: Query, opts?: QueryOptions): Promise; /** * Get multiple items by primary keys */ readMany(keys: PrimaryKey[], query?: Query, opts?: QueryOptions): Promise; /** * Update multiple items by query */ updateByQuery(query: Query, data: Partial, opts?: MutationOptions): Promise; /** * Update a single item by primary key */ updateOne(key: PrimaryKey, data: Partial, opts?: MutationOptions): Promise; /** * Update multiple items in a single transaction */ updateBatch(data: Partial[], opts?: MutationOptions): Promise; /** * Update many items by primary key, setting all items to the same change */ updateMany(keys: PrimaryKey[], data: Partial, opts?: MutationOptions): Promise; /** * Upsert a single item */ upsertOne(payload: Partial, opts?: MutationOptions): Promise; /** * Upsert many items */ upsertMany(payloads: Partial[], opts?: MutationOptions): Promise; /** * Delete multiple items by query */ deleteByQuery(query: Query, opts?: MutationOptions): Promise; /** * Delete a single item by primary key */ deleteOne(key: PrimaryKey, opts?: MutationOptions): Promise; /** * Delete multiple items by primary key */ deleteMany(keys: PrimaryKey[], opts?: MutationOptions): Promise; /** * Read/treat collection as singleton */ readSingleton(query: Query, opts?: QueryOptions): Promise>; /** * Upsert/treat collection as singleton */ upsertSingleton(data: Partial, opts?: MutationOptions): Promise; }