import { P as PackageDeclaration, n as Plugin } from "./plugin-DYhXH7JX.mjs"; import { CollectorDefinition as CollectorDefinition$1, Engine, FinalizeOptions, IngestPort, RunSource } from "@nullplatform/ingest"; /** What a collector is defined by: ingest's definition of it, its package and its schedule. */ interface CollectorDefinition extends CollectorDefinition$1 { /** The package it belongs to: its name, version and description (the slug is the name's unless given), the project's own. The source's slug defaults to the package's. */ package: PackageDeclaration; /** * How often a served collector snapshots again after the backfill (the * `intervalSeconds` port overrides it; `0` or less: the backfill only). With * a watch that is a resync, which catches what the watch missed while it was * down: once a day by default. Without a watch it is how the source stays * current. */ schedule?: { intervalSeconds: number; }; /** The catalog entity specifications its records become, each a relation's target before the specifications that point at it: described in the order given. */ entities?: EntitySpecification[]; /** Its source type, the kind of system it reads, with the mappings every source of it shares: its slug is `source.type`. With mappings, `recordTypes` is theirs unless given, and must agree with them when it is. */ sourceType?: SourceTypeDefinition; } /** Whose a definition is. */ interface Owned { /** True: nullplatform's, written by nullplatform's own publish (the platform's credentials); a client's publish looks it up and pins it, never writes it. The publisher's own otherwise. */ platform?: boolean; } /** A catalog entity specification, as catalog-entities-api's `POST /specifications` takes it, beside whose it is. */ interface EntitySpecification extends Owned { /** What it is found and pinned by; never changes. */ slug: string; name: string; description?: string; /** The JSON Schema of its entities, their relations among it: the SDK reads none of it. */ schema: Record; } /** A source type, as catalog-ingest-api's `POST /source_types` takes it, beside whose it is, with its mappings; its slug is the source's `type`. */ interface SourceTypeDefinition extends Owned { name: string; description?: string; /** What a source of the type has unless it sets its own, in the API's own case (`max_delete_ratio`, `unguarded_types`). */ runs?: Record; /** The mappings every source of the type shares, by slug, unique in the type: several may map one record type (an extension's `pod-acme` beside nullplatform's `pod`). Published under the type, never in its body. */ mappings?: Record; } /** A mapping engine, ingest's `Engine` or its value as text (`"jsonata"`). */ type EngineName = `${Engine}`; /** A source type's mapping, as catalog-ingest-api's `POST /source_types/{id}/mappings` takes it (its slug the key it is given under), beside whose it is. */ interface TypeMapping extends Owned { /** The record type it maps; its slug unless given. */ recordType?: string; engine: Engine | EngineName; expression: string; } /** The collector's own ports, beside the core's (`handle` and `serve` take both): each the one given in code, else its default (`./ports`); none is read from the environment. */ interface CollectorPorts { /** Where a run goes: catalog-ingest-api, at `ingestUrl` and authenticated by `ingestToken` or the run's platform API key, unless given; a test or a local run passes an `InMemoryIngest` (`@nullplatform/ingest/testing`). */ ingest?: IngestPort; /** catalog-ingest-api's URL, when it is not under the platform API's (a local one); the ingest library's own under the run's `apiUrl` unless given. */ ingestUrl?: string; /** catalog-ingest-api's token (a local API's), in place of the platform API key; the run's `apiKey`, exchanged for a token, unless given. */ ingestToken?: string; /** * The source it feeds, each field the one given: `slug` (else the package's * slug), `nrn` (else the organization's root) and `name` (else the * definition's `source.name`). */ source?: Partial; /** Seconds between snapshots when served; `0` or less: the backfill only. The schedule's unless given, else a day; one that is not a number of seconds is refused, whatever gives it. */ intervalSeconds?: number; } /** What a snapshot's document carries: its options. */ interface SnapshotOptions { /** How the run is finalized: ingest's options (`dryRun`, `maxDeleteRatio`, …). */ finalize?: FinalizeOptions; } /** * A collector of its package: the components of its definitions, one route * that runs a snapshot, its own serve, and its block in describe. A definition with a problem is refused when it * is defined, never when it runs: its package first, then every other problem * at once. */ declare function defineCollector(definition: CollectorDefinition): Plugin; /** A resync a day: a watch carries the changes; a snapshot catches what it missed while down. */ declare const DEFAULT_INTERVAL_SECONDS = 86400; export { type CollectorDefinition, type CollectorPorts, DEFAULT_INTERVAL_SECONDS, type EngineName, type EntitySpecification, type SnapshotOptions, type SourceTypeDefinition, type TypeMapping, defineCollector }; //# sourceMappingURL=collector.d.mts.map