Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Application

Hierarchy

Index

Properties

BinaryStream

BinaryStream: BinaryStream

Blob

Blob: Blob

Buffer

References the buffer constructor.

File

File: File

Folder

Folder: Folder

Mutex

Mutex: Mutex

References the mutex constructor.

NodeWorker

NodeWorker: NodeWorker

References the node worker constructor.

SharedWorker

SharedWorker: SharedWorker

References the shared worker constructor.

SystemWorker

SystemWorker: SystemWorker

References the system worker constructor.

TextStream

TextStream: TextStream

XMLHttpRequest

XMLHttpRequest: XMLHttpRequest

console

console: WAKConsole

References the console of the application.

directory

directory: WAKDirectory

References the directory of the application.

ds

References the datastore of the application.

httpServer

httpServer: HttpServer

Reference the HTTP server of the application.

model

model: WakModel

References the model object of the application

sessionStorage

sessionStorage: LockableKeyValueStorage

References the HTTP session storage of the application.

Methods

ProgressIndicator

  • ProgressIndicator(numElements: Number, sessionName?: String, stoppable?: Boolean, unused?: String, name?: String): ProgressIndicator
  • Creates a progress indicator.

    Parameters

    • numElements: Number

      Number of elements to count

    • Optional sessionName: String

      Name of execution session for progress indicator

    • Optional stoppable: Boolean

      true if the progress indicator can be stopped, false otherwise

    • Optional unused: String

      Not used, always pass an empty string ("")

    • Optional name: String

      Unique name of object on the server

    Returns ProgressIndicator

backupDataStore

close

  • close(): void

compactDataStore

exitWait

  • exitWait(): void

generateUUID

  • generateUUID(): String
  • Creates a valid UUID string.

    generateUUID();
    // 9AE457F4B557BD7895AD4712345ABCDE

    Returns String

    Returns a string with the generated UUID

getBackupRegistry

getBackupSettings

  • getBackupSettings(): Object

getJournalInfo

  • getJournalInfo(dataFile: WAKFileInstance, options?: Object): Object
  • getJournalInfo(dataFile: String, options?: Object): Object

getLastBackups

  • getLastBackups(): Array<Object>
  • Returns an Array that lists the 20 most recent backup manifests recorded in the backup registry default folder of the application.

    Returns Array<Object>

getProgressIndicator

getStorage

  • Get or create a storage. This storage is shared between all your application.

    // First call creates the storage
    var myStorage = getStorage( 'mySuperHeroes' );
    myStorage.squadOne = ['Batman', 'Spiderman', 'Superman'];
    
    // Second call retrieves the storage even in another JS contexts.
    var myStorage = getStorage( 'mySuperHeroes' );
    // myStorage.squadOne returns ['Batman', 'Spiderman', 'Superman']
    
    // The storage object can be manipulate as a JS object.
    myStorage = { a:1,b:2,c:[1,2,3],d:{a:1} };
    myStorage.a++;
    myStorage.d.a++;

    Parameters

    • storageId: String

    Returns LockableKeyValueStorage

integrateDataStoreJournal

loadImage

  • Loads an image from its path.

    var myPict = loadImage( 'C:/images/tulips.jpg' );
    var newPict = new ds.Pict();
    newPict.name = 'Flower';
    newPict.photo = myPict;
    newPict.save();
    warning

    The Image API is partially supported on Linux platforms:

    • You can only load images of the PNG or JPG types
    • For more details, check doc center

    Parameters

    • file: String

      Image path to load (POSIX path). Supports PNG and JPG files.

    Returns Image

    Returns the image through Image object.

  • Loads an image from a File object.

    var myFile = new File( 'C:/images/tulips.jpg' );
    var myPict = loadImage(myFile);
    var newPict = new ds.Pict();
    newPict.name = 'Flower';
    newPict.photo = myPict;
    newPict.save();
    warning

    The Image API is partially supported on Linux platforms:

    • You can only load images of the PNG or JPG types
    • For more details, check doc center

    Parameters

    • file: WAKFileInstance

      File object that reference an image. Supports PNG and JPG files.

    Returns Image

    Returns the image through Image object.

loadText

  • loadText(file: String, charset?: Number): String
  • loadText(file: WAKFileInstance, charset?: Number): String
  • Loads the content of a text file from its path.

    var myText = loadText( 'PROJECT/bootstrap.js' );
    console.log(myText);

    Parameters

    • file: String

      File path to load (POSIX path).

    • Optional charset: Number

      (default: 7) Defines the charset to use to read the file. See charset values for more details.

    Returns String

    Returns a string with the full text file content.

  • Loads the content of a text file from a File object.

    var myFile = new File( 'PROJECT/bootstrap.js' );
    var myText = loadText( myFile );
    console.log( myText );

    Parameters

    • file: WAKFileInstance

      File object that reference a text file.

    • Optional charset: Number

      (default: 7) Defines the charset to use to read the file. See charset values for more details.

    Returns String

    Returns a string with the full text file content.

removeStorage

  • removeStorage(storageId: String): void

repairDataStore

require

  • require(moduleId: String): Module
  • Requires an SSJS module (CommonJS compliant). This module must be defined in PROJECT/modules/.

    // Get the module defined in PROJECT/modules/mail
    var mail = require('mail');
    // Get the module defined in PROJECT/modules/customers/platinium
    var platiniumCustomers = require('/customers/platinium');

    Parameters

    • moduleId: String

      Describes the module id and path

    Returns Module

    Returns the exported API of the given module

requireNode

  • requireNode(moduleId: String): Module
  • Requires a NodeJS module. This module must be defined in PROJECT/node_modules.

    // Get the Node module defined in PROJECT/node_modules/http
    var http = requireNode('http');
    warning

    This API is only available inside a Node worker (See NodeWorker for more details)

    Parameters

    • moduleId: String

      Describes the module id and path

    Returns Module

    Returns the exported API of the given module

resetDataStoreJournal

  • resetDataStoreJournal(dataFile: WAKFileInstance): Object
  • resetDataStoreJournal(dataFile: String): Object

restoreDataStore

  • restoreDataStore(manifest: WAKFileInstance, restoreFolder: WAKFolderInstance, options?: Object): Object
  • restoreDataStore(config: Object, options?: Object): Object

saveText

  • saveText(textToSave: String, file: String, charset?: Number): void
  • saveText(textToSave: String, file: WAKFileInstance, charset?: Number): void
  • Saves the text into a file.

    saveText( 'Hello World ! Here is my text saved.', 'C:/texts/chapter-1.txt' );

    Parameters

    • textToSave: String

      Text string to save.

    • file: String

      File path where to update (POSIX path).

    • Optional charset: Number

      (default: 7) Defines the charset of the text string. See charset values for more details.

    Returns void

  • Saves the text into a file.

    var myFile = new File( 'C:/texts/chapter-1.txt' );
    saveText( 'Hello World ! Here is my text saved.', myFile );

    Parameters

    • textToSave: String

      Text string to save.

    • file: WAKFileInstance

      File path where to update (POSIX path).

    • Optional charset: Number

      (default: 7) Defines the charset of the text string. See charset values for more details.

    Returns void

setLogListener

  • setLogListener(moduleId: String): void
  • Defines a log listener. It calls the log() function of moduleId JS module.

    warning

    This is an enterprise feature

    warning

    Do not use console logger inside setLogListener as it will trigger cyclic logs.

    // from PROJECT/bootstrap.js
    setLogListener('log-listener');
    
    // from PROJECT/modules/log-listener/index.js
    var mail = require('waf-mail/mail');
    
    exports.log = function(logArray) {
    
        logArray.forEach(function(logObject){
    
            // logObject.level returns the log type
            // logObject.source returns in which file the log occurs
            // logObject.message returns the log message
    
            switch(logObject.level)
            {
                case 3: // DEBUG log
                case 4: // INFO log
                    // Do nothing
                    break;
                case 5: // WARNING log
                case 6: // ERROR log
                case 7: // FATAL log
                    // If error or warning log, then send an alert email to admin
                    var message = new mail.Mail();
                    message.subject = 'Test';
                    message.from = 'application@myCompany.com';
                    message.to = ['admin@myCompany.com'];
                    message.setBody( logObject.source +'/n/n'+ logObject.message );
                    mail.send({
                        address: 'smtp.gmail.com',
                        port: 465,
                        isSSL: true,
                        username: 'admin@myCompany.com',
                        password: 'my-admin-password',
                        domain: 'gmail.com'
                    }, message);
    
                    break;
                default:
                    // Do nothing
                    break;
            }
        });
    };

    Parameters

    • moduleId: String

      @param moduleId Describes the module id and path from /modules/ directory

    Returns void

verifyDataStore

wait

  • wait(timeout?: Number): void
  • Allows a thread to handle events and to continue to exist after the complete code executes.

    // Wait for 100ms
    wait(100);
    // Wait for the end of time
    wait();

    Parameters

    • Optional timeout: Number

      Milliseconds to wait for. If none, it's an infinite wait. Can be squeeze with an exitWait().

    Returns void