//#region ../internal-foundation/dist/type-utils/index.d.ts declare const brand: unique symbol; type Brand = T & { readonly [brand]: Name; }; //#endregion //#region ../internal-contracts/dist/model/types.d.ts type CommitOid = Brand; interface PersonIdentity { readonly name: string; readonly email: string; } //#endregion //#region ../internal-contracts/dist/extraction-api/facts.d.ts /** Output-format-independent representation of a single commit. */ interface CommitFact { readonly type: "commit"; readonly oid: CommitOid; readonly message: string; readonly author: { readonly name: string; readonly email: string; /** Unix timestamp in seconds. */ readonly timestamp: number; /** UTC offset in minutes using the conventional sign (JST = +540). */ readonly timezoneOffset: number; }; readonly committer: { readonly name: string; readonly email: string; /** Unix timestamp in seconds. */ readonly timestamp: number; /** UTC offset in minutes using the conventional sign (JST = +540). */ readonly timezoneOffset: number; }; readonly parents: readonly CommitOid[]; readonly repository: { readonly name: string; readonly url: string | null; }; } /** Output-format-independent representation of one file change within a commit. */ interface FileChangeFact { readonly type: "file-change"; readonly commit: CommitFact; readonly file: { readonly path: string; readonly status: "added" | "modified" | "deleted"; readonly additions: number | null; readonly deletions: number | null; }; } //#endregion //#region ../internal-contracts/dist/extraction-api/records.d.ts interface ProjectedPerson extends PersonIdentity { /** ISO 8601 timestamp retaining the commit's own timezone offset. */ readonly timestamp: string; } interface ProjectedRepository { readonly name: string; readonly url: string | null; } /** * A serialized value stored under an extension namespace. * `null` represents an extension that skipped or fatally rejected the fact. */ type ProjectedExtensionValue = string | number | boolean | Readonly> | null; interface ProjectedExtensions { [namespace: string]: ProjectedExtensionValue; } interface ProjectedCommit { readonly oid: string; readonly message: string; readonly author: ProjectedPerson; readonly committer: ProjectedPerson; readonly parents: readonly string[]; readonly repository: ProjectedRepository; readonly extensions?: ProjectedExtensions; } interface ProjectedFileChange extends ProjectedCommit { readonly file: { readonly path: string; readonly status: "added" | "modified" | "deleted"; readonly additions: number | null; readonly deletions: number | null; }; } interface FactPairMap { commit: { readonly fact: CommitFact; readonly record: ProjectedCommit; }; "file-change": { readonly fact: FileChangeFact; readonly record: ProjectedFileChange; }; } type FactType = keyof FactPairMap; type FactFor = FactPairMap[Type]["fact"]; type ProjectedRecordFor = FactPairMap[Type]["record"]; //#endregion //#region ../internal-foundation/dist/instrumentation/type.d.ts type InstrumentAttributeValue = string | number | boolean; type InstrumentAttributes = Readonly>; interface InstrumentationOptions { readonly attributes?: InstrumentAttributes; } interface InstrumentationSpan { setAttribute(name: string, value: InstrumentAttributeValue): void; addEvent(name: string, attributes?: InstrumentAttributes): void; incrementCounter(name: string, delta?: number): void; } interface ActiveInstrumentationSpan extends InstrumentationSpan { end(error?: unknown): void; } interface Instrumentation { run(name: string, fn: (span: InstrumentationSpan) => T, options?: InstrumentationOptions): T; runAsync(name: string, fn: (span: InstrumentationSpan) => Promise, options?: InstrumentationOptions): Promise; startSpan(name: string, options?: InstrumentationOptions): ActiveInstrumentationSpan; } //#endregion //#region src/plugin-api/types.d.ts interface DiagnosticReporter { warn(message: string): void; error(message: string): void; } type PluginFailurePolicy = "skip-fact" | "fatal"; type PluginInitSuccess = { type: "ready"; }; type PluginInitFatal = { type: "fatal"; }; type PluginInitResult = PluginInitSuccess | PluginInitFatal; /** * A value a plugin may return as successful projection data. * Return `{ type: "skip" }` instead of `null` when no data should be attached. */ type PluginProjectionValue = Exclude; type PluginProjectionResult = { type: "success"; data: PluginProjectionValue; } | { type: "skip"; } | { type: "fatal"; }; type ProjectionContextFor = { readonly fact: FactFor; readonly baseRecord: Readonly>; }; /** Read-only fact and base-record pair passed to plugins for enrichment. */ type ProjectionContext = { [Type in FactType]: ProjectionContextFor; }[FactType]; interface PluginRuntimeContext extends DiagnosticReporter { readonly instrumentation: Instrumentation; } /** Contract implemented by every projector plugin. */ interface ProjectorPlugin { init(runtime: PluginRuntimeContext): Promise; project(context: ProjectionContext): Promise; } /** ESM module default-export signature for plugin factories. */ type PluginFactory = (config: unknown) => ProjectorPlugin | Promise; /** Validated plugin namespace matching `/^[a-z0-9-]+$/`. */ type Namespace = Brand; //#endregion export type { Brand, CommitFact, CommitOid, DiagnosticReporter, FileChangeFact, Instrumentation, InstrumentationSpan, Namespace, PluginFactory, PluginFailurePolicy, PluginInitFatal, PluginInitResult, PluginInitSuccess, PluginProjectionResult, PluginProjectionValue, PluginRuntimeContext, ProjectedCommit, ProjectedFileChange, ProjectionContext, ProjectorPlugin }; //# sourceMappingURL=plugin-api.d.ts.map