Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FolderJob

Hierarchy

  • Job
    • FolderJob

Index

Constructors

constructor

Properties

Protected _basename

_basename: string

Protected _dirname

_dirname: string

Protected _files

_files: File[]

Protected _id

_id: string

Protected _lifeCycle

_lifeCycle: LifeEvent[]

Protected _locallyAvailable

_locallyAvailable: boolean

Protected _name

_name: string

Protected _nest

_nest: Nest

Protected _path

_path: string

Protected _properties

_properties: any

Protected _tunnel

_tunnel: Tunnel

Protected _type

_type: string

Protected e

Accessors

basename

  • get basename(): string

dirname

  • get dirname(): string

extension

  • get extension(): any

files

  • get files(): Array<File>

id

  • get id(): string

isLocallyAvailable

  • get isLocallyAvailable(): boolean

lifeCycle

locallyAvailable

  • set locallyAvailable(available: boolean): void

name

  • get name(): string

nameProper

  • get nameProper(): string

nest

  • get nest(): Nest
  • set nest(nest: Nest): void

path

  • get path(): string
  • set path(path: string): void

properties

  • get properties(): any

propertyValues

  • set propertyValues(properties: Object): void

size

  • get size(): any

sizeBytes

  • get sizeBytes(): any

tunnel

type

  • get type(): string

Methods

addFile

  • addFile(file: File): void

count

  • count(): number

createFiles

  • createFiles(callback: function): void
  • Creates file objects for folder contents. Async operation returns a callback on completion.

    Parameters

    • callback: function
        • (): void
        • Returns void

    Returns void

Protected createLifeEvent

  • createLifeEvent(verb: string, start: string, finish: string): void

email

  • Sends an email.

    Parameters

    • emailOptions: EmailOptions

      Email options

      Sending pug template email example

      // my_tunnel.js
      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email from pug template",
               to: "john.smith@example.com",
               template: __dirname + "./template_files/my_email.pug"
           });
      });
      
      // template_files/my_email.pug
      h1="Example email!"
      p="Got job ID " + job.getId()
      

      Sending plain-text email

      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email with hard-coded plain-text",
               to: "john.smith@example.com",
               text: "My email body!"
           });
      });
      

      Sending html email

      tunnel.run(function (job, nest) {
           job.email({
               subject: "Test email with hard-coded html",
               to: "john.smith@example.com",
               html: "<h1>My email body!</h1>"
           });
      });
      

    Returns void

fail

  • fail(reason: string): void
  • Function to call to fail a job while in a tunnel.

    Parameters

    • reason: string

    Returns void

getFile

  • getFile(index: number): File

getJSON

  • getJSON(): any

getProperty

getPropertyType

  • getPropertyType(key: string): any
  • Get the type of a property.

    Example

    job.setPropertyValue("My Job Number", 123456);
    
    console.log(job.getPropertyType("My Job Number"));
    // "number"
    

    Parameters

    • key: string

    Returns any

getPropertyValue

  • getPropertyValue(key: string): any

Protected getStatistics

  • getStatistics(): void

isFile

  • isFile(): boolean

isFolder

  • isFolder(): boolean

log

  • log(level: number, message: string): void
  • Add a message to the log with this job as the actor.

    Parameters

    • level: number

      0 = debug, 1 = info, 2, = warning, 3 = error

    • message: string

      Log message

    Returns void

move

  • move(destinationNest: Nest, callback: function): void
  • Moves a folder to a nest. This is an asynchronous method which provides a callback on completion.

    Parameters

    • destinationNest: Nest
    • callback: function
        • (job?: Job): void
        • Parameters

          • Optional job: Job

          Returns void

    Returns void

pack

  • pack(callback: function): void
  • Packs the job instance and file together in a zip. Returns a PackJob in the parameter of the callback.

    Parameters

    • callback: function

      Example

      job.pack(function(packJob){
           packJob.move(packed_folder_nest);
      });
      

    Returns void

remove

  • remove(): void

rename

  • rename(newName: string): void

setPropertyValue

  • setPropertyValue(key: string, value: any): void
  • Attach job specific data to the job instance.

    Example

    job.setPropertyValue("My Job Number", 123456);
    
    console.log(job.getPropertyValue("My Job Number"));
    // 123456
    

    Parameters

    • key: string
    • value: any

    Returns void

toString

  • toString(): string

transfer

  • transfer(tunnel: Tunnel): void

unpack

  • unpack(callback: function): void
  • Unpacks a packed job. Returns a the original unpacked job in the parameter of the callback.

    Parameters

    • callback: function

      Example

      packedJob.unpack(function(unpackedJob){
          console.log("Unpacked", unpackedJob.name);
          unpackedJob.move(unpacked_folder);
          packedJob.remove();
      });
      
        • (job: Job): void
        • Parameters

          Returns void

    Returns void

Generated using TypeDoc