@servicenow/sdk - v4.14.3
    Preparing search index...

    Type Alias PluginConfig<Nodes, Shapes, Records>

    type PluginConfig<
        Nodes extends SupportedKindName[] = SupportedKindName[],
        Shapes extends ShapeClass[] = ShapeClass[],
        Records extends string[] = string[],
    > = {
        docs?: any[];
        files?: {
            entryPoint?: boolean;
            matcher?: RegExp | FileMatcher;
            toRecord?(
                file: File,
                context: Context,
            ): Result<Record> | Promise<Result<Record>>;
        }[];
        imports?: string[]
        | Record<string, string>;
        name: `${string}Plugin`;
        nodes?: {
            [I in keyof Nodes]: {
                entryPoint?: boolean;
                fileTypes?: FileType[];
                node: Nodes[I];
                toShape?(
                    node: SupportedNodeByKindName<Nodes[I]>,
                    context: Context,
                ): Result<Shape<unknown>> | Promise<Result<Shape<unknown>>>;
            }
        };
        noTelemetry?: boolean;
        records?: {
            [T in Records[number]]: {
                coalesce?: CoalesceStrategy;
                composite?: boolean;
                diff?: (
                    existing: Database,
                    incoming: Database,
                    descendants: Database,
                    context: Context,
                ) => Promise<Result<Database>>;
                relationships?: Relationships;
                getUpdateName?(
                    record: Record,
                    context: Context,
                ): Result<string> | Promise<Result<string>>;
                inspect?(record: Record, context: RecordContext): void | Promise<void>;
                toFile?(
                    record: Record,
                    context: RecordContext,
                ):
                    | Result<OutputFile | OutputFile[]>
                    | Promise<Result<OutputFile | OutputFile[]>>;
                toShape?(
                    record: Record,
                    context: RecordContext,
                ): Result<Shape<unknown>> | Promise<Result<Shape<unknown>>>;
            }
        };
        shapes?: {
            [I in keyof Shapes]: Shapes[I] extends ShapeClass<infer S>
                ? {
                    fileTypes?: FileType[];
                    shape: Shapes[I];
                    commit?(
                        shape: S,
                        target: Node,
                        context: CommitContext,
                    ): CommitResult | Promise<CommitResult>;
                    getTarget?(
                        shape: S,
                        context: Context,
                    ): Result<Node<tsc.Node>> | Promise<Result<Node<tsc.Node>>>;
                    inspect?(shape: S, context: Context): void;
                    toRecord?(
                        shape: S,
                        context: Context,
                    ): Result<Record> | Promise<Result<Record>>;
                    toSubclass?(shape: S, context: Context): Result<S> | Promise<Result<S>>;
                }
                : never
        };
    }

    Type Parameters

    Index

    Properties

    docs?: any[]

    This property is no longer read and will be removed in a future release.

    files?: {
        entryPoint?: boolean;
        matcher?: RegExp | FileMatcher;
        toRecord?(
            file: File,
            context: Context,
        ): Result<Record> | Promise<Result<Record>>;
    }[]

    The files this plugin handles. Plugins that do not introduce new file types should not need to implement anything here.

    Type Declaration

    • OptionalentryPoint?: boolean

      Indicates whether this file should be parsed as an entry point when generating output. (Default: false)

    • Optionalmatcher?: RegExp | FileMatcher

      A regex pattern or predicate to apply to a file's path to determine if it should be handled by this plugin.

    • toRecord?: function
      • Transforms a file into record(s).

        Parameters

        • file: File

          The file to transform

        • context: Context

          Context object with useful services and information

        Returns Result<Record> | Promise<Result<Record>>

        A result indicating whether the transformation was successful and, if so, the resulting record(s)

    imports?: string[] | Record<string, string>

    Declares the import specifiers for callees this plugin produces. During transform, the framework uses these declarations to add the correct import statements to files instead of relying on the TypeScript language service's fixMissingImports.

    Accepts either:

    • A string array of callee names that all import from @servicenow/sdk/core (the default)
    • A record mapping each callee name to its module specifier

    Callees in the global namespace (e.g. Now.include, Duration) should not be listed.

    // Array form — all callees default to '@servicenow/sdk/core'
    imports: ['BusinessRule', 'Table', 'Column']

    // Record form — explicit specifier per callee
    imports: {
    Action: '@servicenow/sdk/automation',
    Subflow: '@servicenow/sdk/automation',
    }
    name: `${string}Plugin`

    The name of the plugin. Must end with "Plugin" suffix. This name is used in metrics and error messages.

    nodes?: {
        [I in keyof Nodes]: {
            entryPoint?: boolean;
            fileTypes?: FileType[];
            node: Nodes[I];
            toShape?(
                node: SupportedNodeByKindName<Nodes[I]>,
                context: Context,
            ): Result<Shape<unknown>> | Promise<Result<Shape<unknown>>>;
        }
    }

    The TypeScript AST nodes this plugin handles. Plugins that do not introduce new syntax should not need to define any handlers here.

    noTelemetry?: boolean

    When true, this plugin is excluded from fluent.authored telemetry. Set this for internal/infrastructure plugins that don't represent a public Fluent entity type (e.g. CallExpressionPlugin, NowIncludePlugin).

    records?: {
        [T in Records[number]]: {
            coalesce?: CoalesceStrategy;
            composite?: boolean;
            diff?: (
                existing: Database,
                incoming: Database,
                descendants: Database,
                context: Context,
            ) => Promise<Result<Database>>;
            relationships?: Relationships;
            getUpdateName?(
                record: Record,
                context: Context,
            ): Result<string> | Promise<Result<string>>;
            inspect?(record: Record, context: RecordContext): void | Promise<void>;
            toFile?(
                record: Record,
                context: RecordContext,
            ):
                | Result<OutputFile | OutputFile[]>
                | Promise<Result<OutputFile | OutputFile[]>>;
            toShape?(
                record: Record,
                context: RecordContext,
            ): Result<Shape<unknown>> | Promise<Result<Shape<unknown>>>;
        }
    }

    The records this plugin handles. The keys of this object are the names of the tables to be handled, and the values are handlers which can implement the following:

    • Transform functions that turn records into shapes (toShape)
    • Transform functions that turn records into files (toFile)
    • Relationship mappings
    • Coalesce strategies
    • Inspect functions that can examine records for diagnostic purposes (inspect)
    shapes?: {
        [I in keyof Shapes]: Shapes[I] extends ShapeClass<infer S>
            ? {
                fileTypes?: FileType[];
                shape: Shapes[I];
                commit?(
                    shape: S,
                    target: Node,
                    context: CommitContext,
                ): CommitResult | Promise<CommitResult>;
                getTarget?(
                    shape: S,
                    context: Context,
                ): Result<Node<tsc.Node>> | Promise<Result<Node<tsc.Node>>>;
                inspect?(shape: S, context: Context): void;
                toRecord?(
                    shape: S,
                    context: Context,
                ): Result<Record> | Promise<Result<Record>>;
                toSubclass?(shape: S, context: Context): Result<S> | Promise<Result<S>>;
            }
            : never
    }

    The shapes this plugin handles. Each shape handler can implement the following:

    • Transform functions that turn shapes into records (toRecord)
    • Transform functions that turn shapes into more specialized subclasses of those shapes (toSubclass)
    • Commit functions that mutate TypeScript nodes to match shapes (commit)
    • Inspect functions that can examine shapes for diagnostic purposes (inspect)