import { BaseApi } from "../base-api"; import type { Derivation, DerivationCollaborators, DerivationCost, DerivationCreateRequest, DerivationMapping, DerivationsResponse, DerivationUpdateRequest, DerivationWarning, ListDerivationsParams } from "./types"; /** * `DerivationsApi` wraps the derivation-rule endpoints. A derivation rule says * how one attribute's value can be produced from another's — hashing a raw * email, bucketing a birthdate into an age range — and the platform applies it * when a query asks for the target attribute and only the source is available. * * Reads cover the rules the calling company can use: the ones it owns plus the * ones shared with it through collaborators. Writes are narrower — they need an * `admin` grant on `attribute_derivations`, and only the owning company can * change or delete a rule. */ export declare class DerivationsApi extends BaseApi { /** * Lists the derivation rules the calling company can use, optionally * filtered by source or target attribute. * * @param {ListDerivationsParams} [params] - Attribute-id filters. Each accepts * several ids. * @returns {Promise} The matching rules, with empty * `warnings` — reads do not compute them. * @see https://docs.narrative.io/api-reference/derivations/get-derivation-rules */ listDerivations(params?: ListDerivationsParams): Promise; /** * Fetches a single rule. * * @param {number} derivationId - Id of the rule. * @returns {Promise} The rule. Rejects with 404 if no rule with * that id is usable by the calling company — rules belonging to someone else * are not distinguished from rules that do not exist. * @see https://docs.narrative.io/api-reference/derivations/get-a-derivation-rule */ getDerivation(derivationId: number): Promise; /** * Creates a rule, owned by the calling company. * * The transformation is validated before the rule can exist: both attributes * must be viewable, the target must grant the company `map` since the rule * produces values for it, every expression must parse and type-check against * the source attribute's shape, and the result must match the target's * declared type. * * A rule that closes a cycle in the derivation graph is still created — the * cycle comes back as a `cyclic_derivation` warning on the response rather * than as an error. * * @param {DerivationCreateRequest} request - The rule to create. * @returns {Promise} The created rule, with any warnings. Rejects * with 400 if the transformation fails validation; 403 if the caller is not * an admin, the rule's company or collaborators are not allowed, or the * target attribute does not grant `map`; 409 if another of the company's * rules already has the same name or already covers the same source and * target pair. * @see https://docs.narrative.io/api-reference/derivations/create-a-derivation-rule */ createDerivation(request: DerivationCreateRequest): Promise; /** * Updates some fields of a rule. Only the keys present in `request` change, * and a changed `mapping` runs the same validation as a creation. * * @param {number} derivationId - Id of the rule. * @param {DerivationUpdateRequest} request - The fields to change. * @returns {Promise} The updated rule, with any warnings. Rejects * with 400 if the update fails validation; 403 if the caller is not an admin * or does not own the rule; 404 if there is no rule with that id. * @see https://docs.narrative.io/api-reference/derivations/update-a-derivation-rule */ updateDerivation(derivationId: number, request: DerivationUpdateRequest): Promise; /** * Permanently removes a rule. To take a rule out of use while keeping it, * pass `{ active: false }` to {@link DerivationsApi.updateDerivation} * instead — deletions cannot be undone. * * @param {number} derivationId - Id of the rule. * @returns {Promise} Resolves when deleted. Rejects with 403 if the * caller is not an admin or does not own the rule; 404 if there is no rule * with that id. * @see https://docs.narrative.io/api-reference/derivations/delete-a-derivation-rule */ deleteDerivation(derivationId: number): Promise; } export type { Derivation, DerivationCollaborators, DerivationCost, DerivationCreateRequest, DerivationMapping, DerivationsResponse, DerivationUpdateRequest, DerivationWarning, ListDerivationsParams, };