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

    The Orchestrator class is responsible for managing and coordinating the lifecycle of a project, including the build, packaging, and installation processes.

    Index

    Constructors

    • Parameters

      • project: Project
      • OptionalcredentialOrConnector: LazyCredential | IConnector

      Returns Orchestrator

    Methods

    • Adds new dependency items to the project and updates now.config.json.

      This method:

      1. Updates now.config.json with the new dependency items
      2. Fetches the records from the ServiceNow instance
      3. Generates TypeScript type definitions
      4. Updates index files

      Supports adding dependencies from any ServiceNow table, with special handling for:

      • Flow items: actions, triggers, subflows (stored in dependencies..automation.*)
      • Tables: Table definitions (stored in dependencies..tables)
      • Custom records: Any other table (stored in dependencies..<table_name>)

      Parameters

      • options: { ids: string[]; scope: string; table: string }

        Configuration for the dependency to add

        • ids: string[]

          Array of sys_ids or table names. Use ['*'] to fetch all records from a scope

        • scope: string

          Scope filter (e.g., 'global', 'x_my_app'). Required when using wildcard '*'

        • table: string

          Table name or alias (e.g., 'actions', 'sys_security_acl', 'sys_user')

      Returns Promise<void>

      // Add specific flow actions
      await orchestrator.addDependency({
      table: 'actions',
      ids: ['action_id1', 'action_id2']
      })

      // Add all actions from a scope using wildcard
      await orchestrator.addDependency({
      table: 'actions',
      ids: ['*'],
      scope: 'global'
      })

      // Add specific security ACLs
      await orchestrator.addDependency({
      table: 'sys_security_acl',
      ids: ['acl_id1', 'acl_id2']
      })

      // Add all ACLs from a custom scope
      await orchestrator.addDependency({
      table: 'sys_security_acl',
      ids: ['*'],
      scope: 'x_my_app'
      })

      // Add table definitions
      await orchestrator.addDependency({
      table: 'tables',
      ids: ['incident', 'problem', 'change_request']
      })

      If wildcard '*' is used without a scope

      If fetching records from the instance fails

      If updating now.config.json fails

      types for downloading existing dependencies

    • Applies a template to the project.

      Parameters

      • id: keyof Templates

        The ID of the template to apply.

      • Optionalparams: Record<string, string>

      Returns Promise<TemplateFile[]>

      The temlate files that were applied to the project

    • Build the project, generate the output files, and save the keys registry.

      Parameters

      • Optionaloptions: { frozenKeys?: boolean; sysIds?: string[] }

      Returns Promise<BuildResult>

      The output files.

    • Cleans the build appOutDir and packOutputDir of the project.

      Returns void

    • Download the app contents from the connected ServiceNow instance.

      Parameters

      • Optionaloptions:
            | TransformOptions & DownloadCompleteOptions
            | TransformOptions & DownloadIncrementalOptions
            | TransformOptions & DownloadUpdateSetOptions

        Options for the download process, defaults to { method: 'complete' }

      • OptionaldownloadPath: string

        The path where the downloaded files will be saved. Defaults to os.tmpdir()/servicenow/download/GUID().

      Returns Promise<string>

      The path to the downloaded zip file.

    • Get documentation metadata for all APIs provided by loaded plugins. Returns a manifest mapping API names to their documentation paths and tags. Uses isomorphic module resolution that works in both Node.js and browser environments.

      Returns Promise<DocsManifest>

    • Install the project on the connected ServiceNow instance.

      Parameters

      • Optionaloptions: {
            clean?: boolean;
            demoData?: boolean;
            installAsStoreApp?: boolean;
            installAsync?: boolean;
            packageZipPath?: string;
        }

      Returns Promise<void>

    • Parameters

      • Optionaloptions: { targetUpdateSetId?: string }

      Returns Promise<string>

    • Returns the last status of the app upgrade.

      Returns Promise<{ finished: boolean; id: string }>

    • Parameters

      • _diagnostics: Diagnostic[]
      • Optional_options: { colors?: boolean }

      Returns void

      Diagnostics are logged automatically

    • Generates sys_claim records on the instance to mark desired records as moved into this global app

      Parameters

      • options: { sysIds: string[] }

      Returns Promise<TransformResult | undefined>

    • Generate a ZIP archive containing the project's output which can be installed with install method

      Parameters

      • OptionalpackagePath: string

        The path where the ZIP archive will be saved. Defaults to packOutputDir/{package name_version}.zip.

      Returns Promise<string>

      The path to the generated ZIP archive.

    • Parameters

      • options: { script: string }

      Returns Promise<void>

    • Transforms the project's metadata files.

      Parameters

      • Optionaloptions: TransformOptions | TransformPaths | DownloadOptions

        Options for the transform process

      Returns Promise<TransformResult>

      The transformed files

    • Downloads and generates TypeScript type definitions for dependencies from a ServiceNow instance.

      This method can download two types of definitions:

      • Script definitions: TypeScript definitions for ServiceNow APIs (glide.*.d.ts files)
      • Fluent types: TypeScript definitions for configured dependencies from now.config.json

      Parameters

      • Optionaloptions: { downloadFluent?: boolean; downloadScripts?: boolean }

        Configuration options for what to download

        • OptionaldownloadFluent?: boolean

          Download fluent type definitions from now.config.json (default: true)

        • OptionaldownloadScripts?: boolean

          Download script type definitions (default: true)

      Returns Promise<void>

      // Download all dependencies (default)
      await orchestrator.types()

      // Download only script definitions
      await orchestrator.types({ downloadScripts: true, downloadFluent: false })

      // Download only fluent types
      await orchestrator.types({ downloadScripts: false, downloadFluent: true })

      If fetching or generating types fails

      addDependency for adding new dependencies programmatically

    • Unpacks a ZIP archive containing ServiceNow application files

      Parameters

      • zipPath: string

        The path to the ZIP archive.

      • targetPath: string

        The path where the files will be extracted.

      Returns Promise<{ files: string[] }>

      The list of files extracted from the ZIP archive.

    • Parameters

      • filePaths: string[]
      • Optionaloptions: { targetUpdateSetId?: string }

      Returns Promise<string>