UNPKG

@prismatic-io/spectral

Version:

Utility library for building Prismatic connectors and code-native integrations

35 lines (34 loc) 3.61 kB
import { type ComponentDefinition, type ComponentHooks, type ConfigVarResultCollection, type ConnectionDefinition, type ConnectionInput, type ConnectionTemplateInputField, type InputFieldDefinition, type Inputs, type OnPremConnectionInput, type TriggerDefinition, type TriggerPayload, type TriggerResult } from "../types"; import { type PollingTriggerDefinition } from "../types/PollingTriggerDefinition"; import type { Component as ServerComponent, Connection as ServerConnection, Input as ServerInput, Trigger as ServerTrigger } from "."; import { type CleanFn } from "./perform"; /** Auto-generated cleaner for structuredObject/dynamicObject containers. * Recursively delegates to each child's clean function. Developers do not * declare a top-level clean on these containers — the conversion always * supplies one so nested clean functions are applied at runtime. */ export declare const cleanerFor: (input: InputFieldDefinition) => CleanFn | undefined; /** * Throws if `batchSize` isn't a positive integer; otherwise returns it. Shared by the * component-trigger (`TriggerDefinition.batch.batchSize`) and CNI flow (`flow.batch.batchSize`) * validation paths. */ export declare const validateBatchSize: (ownerLabel: string, fieldName: string, batchSize: unknown) => number; /** * Throws if `concurrentBatchLimit` is set but isn't a positive integer; returns it * unchanged (including `undefined`, which the platform treats as unlimited). Shared by the * component-trigger and CNI flow paths, both sourcing it from the single `batchConfig`. */ export declare const validateConcurrentBatchLimit: (ownerLabel: string, fieldName: string, concurrentBatchLimit: unknown) => number | undefined; export declare const convertInput: (key: string, definition: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput; export declare const _isValidTemplateValue: (template: string, inputs: { [key: string]: ConnectionInput | ConnectionTemplateInputField; }) => { isValid: boolean; error?: string; }; export declare const convertTemplateInput: (key: string, { templateValue, label, ...rest }: ConnectionTemplateInputField, inputs: { [key: string]: ConnectionInput | ConnectionTemplateInputField; }) => ServerInput; export declare const convertTrigger: <TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>(triggerKey: string, trigger: TriggerDefinition<any> | PollingTriggerDefinition<any, ConfigVarResultCollection, TriggerPayload, boolean, any, any>, hooks?: ComponentHooks) => ServerTrigger<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>; export declare const convertConnection: ({ inputs, ...connection }: ConnectionDefinition) => ServerConnection; export declare const convertComponent: <TPublic extends boolean, TKey extends string, TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent<TInputs, TActionInputs, TConfigVars, TPayload, TAllowsBranching, TResult>;