import type { CreateRankParams, CreateRankResult } from './types.js'; /** * Creates a rank entity with the given name, description, rankType, and votes. * All IDs passed to this function are validated. If any invalid ID is provided, * the function will throw an error. * * Each vote must carry a `spaceId` that scopes the ranked entity to a space * perspective (set as `to_space_id` on the vote relation). A rank may therefore * include the same entity across multiple spaces; item uniqueness is keyed on * `(entityId, spaceId)`. * * A fractional index is generated from the array order and set as each vote * relation's `position`, so clients can order votes natively. For ORDINAL ranks * the same fractional index is stored on the reified vote entity. * * When `blockId` is provided, a `Rank → Ranking Block` relation is emitted to * associate the rank with a ranking block. The link may also be added later. * * @example * ```ts * // Create an ordinal rank (ordered list) - position derived from array order * const { id, ops, voteIds } = createRank({ * id: rankId, // optional, will be generated if not provided * name: 'My Favorite Movies', * description: 'A ranked list of my favorite movies', // optional * rankType: 'ORDINAL', * blockId, // optional, links the rank to a Ranking Block * votes: [ * { entityId: movie1Id, spaceId }, // 1st place * { entityId: movie2Id, spaceId }, // 2nd place * { entityId: movie3Id, spaceId }, // 3rd place * ], * }); * * // Create a weighted rank (scored list) * const { id, ops, voteIds } = createRank({ * name: 'Restaurant Ratings', * rankType: 'WEIGHTED', * votes: [ * { entityId: restaurant1Id, spaceId, value: 4.5 }, // numeric score * { entityId: restaurant2Id, spaceId, value: 3.8 }, * ], * }); * ``` * * @param params – {@link CreateRankParams} * @returns – {@link CreateRankResult} * @throws Will throw an error if any provided ID is invalid * @throws Will throw an error if any `(entityId, spaceId)` pair is duplicated in votes */ export declare const createRank: ({ id: providedId, name, description, rankType, blockId, votes, }: CreateRankParams) => CreateRankResult; //# sourceMappingURL=create-rank.d.ts.map