import { Glue42Core } from "@glue42/core"; import { UnsubscribeFunction } from "callback-registry"; /** * Factory method used to create a new Glue4Office (G4O) instance. * It is exposed as global object (called Glue4Office) when running in the browser or * returned from module require when running in NodeJS. * This should be the entry point of your G4O usage. * * @docmenuorder 1 * * @example * ```javascript * Glue4Office({ * gateway:{ * ws: 'ws://localhost:8080/gw', * protocolVersion:3, * }, * auth: { * username: 'myUsername', * password: 'myPassword', * } * }) * .then((glue4office) => { * console.log(glue4office.version); * }) * .catch((error) => { * console.warn(error); * }) * ``` */ export default function Glue4Office(config?: Glue42Office.Config): Promise; /** * @docmenuorder 1 * @docName Glue4Office * @intro * * The Glue42 MS Office Connectors allow you to: * * * Use Excel with its familiar functionality, such as macros and pivot tables, to create sophisticated calculations, or continue using those that may have accumulated over the years, while being able to save all data edits to your web app in real time. * * * Edit and format a document in Word, including WordArt, tables and drawings, making use of the familiar and powerful capabilities of the most popular text processing tool in the world. * * * Send and receive emails and manage tasks from web applications using all the familiar capabilities of Outlook. * * ## Referencing * * The `glue4office` library is available both as an `npm` module and as a standalone transpiled JavaScript file in `%LocalAppData%\Tick42\GlueSDK\Glue4OfficeJS\js\web`. * * Because the API evolves, we have chosen the following semantic version model: * * `BreakingChangesVersion.FeatureVersion.FixVersion` * * * You can reference the library in a ` * ``` * * When deploying your application in production, we recommend that you always reference a specific minified version: * * ```html * * ``` * * The browserified JavaScript file is also a CommonJS module, which you can `require`/`import`. * * CommonJS: * * ```javascript * const Glue4Office = require("glue4office"); * ``` * * ES6: * * ```javascript * import Glue4Office from "glue4office"; * ``` * * ## Initialization * * When you reference the standalone JavaScript file, it will expose a global factory function called `Glue4Office`. * * If you have imported or required the library, the function will be available with the name you specified in the `import` or `require` statement. * * Assuming you stick to the default `Glue4Office` name, to initialize the library, you need to call the function `Glue4Office` and specify which MS Office apps you want to interoperate with. The function returns a `Promise`, which will resolve with an initialized instance of the library. * * Example: * * ```javascript * const g4oConfig = { * application: "MS Office Interop", * excel: true, // enable Excel interop * word: true, // enable Word interop * outlook: false // disable Outlook interop * } * Glue4Office(g4oConfig) * .then(g4o => { * // g4o is a reference to the Glue4Office API * window.g4o = g4o; // expose g4o as a global variable * // use g4o * }) * .catch(console.error) * ``` * * See also the [**Connectors**](../../../../../connectors/ms-office/set-up-your-application/javascript/index.html) documentation for more details. */ export declare namespace Glue42Office { /** * Configuration object used to initialize Glue4Office * @docmenuorder 2 */ export interface Config extends Glue42Core.Config { /** * Outlook configuration. If false the library is not initialized and can not be used. * Default is true. */ outlook?: boolean; /** * Excel configuration. If false the library is not initialized and can not be used. * Default is true. */ excel?: boolean; /** * Word configuration. If false the library is not initialized and can not be used. * Default is true. */ word?: boolean; /** * @hidden * Initialize with pre-created GlueCore object. * In that case it will be extended with office libs. * If not set Glue4Office will auto initialize GlueCore internally. */ glue?: Glue42Core.GlueCore; } /** * Glue4Office API as returned from Factory function. * Use this to object to interact with office products. * * @example * ```javascript * glue4office.excel.openSheet(options); * ``` * * @docmenuorder 1 */ export interface Glue4Office extends Glue42Core.GlueCore { /** * Outlook API. Use to interact with Outlook */ outlook?: Outlook.API; /** * Excel API. Use to interact with Excel */ excel?: Excel.API; /** * Word API. Use to interact with Word */ word?: Word.API; /** * Version of the API */ version: string; } /** * @docmenuorder 2 * @intro * * The Glue42 Word Connector allows applications to use MS Word as a document editor. The application sends document text and images to Word in the form of HTML, so that the user may edit it using a familiar tool. When the user saves the changes, a new HTML document is created and sent back to the application to display and/or store in the backend where it can be properly secured and audited. * * Summary of features: * * - The HTML document is sent to the application every time the user saves the document. * - Images may be embedded within the document HTML, as long as they are in one of the following formats: `PNG`, `ICO`, `BMP`, or `JPEG`. * - Embedded objects, such as images, charts and spreadsheets can be added to the Word document, but these will be converted to inline HTML images before they are returned to the application. The original objects can be preserved in Microsoft `DOCX` format, however, and can be saved to the backend so the user can edit the document later. * - Documents are created in the folder `%APPDATA%\Tick42\GlueWordPad\Files` (configurable). * * See also the [**Word Connector**](../../../../../connectors/ms-office/word-connector/javascript/index.html) documentation for more details. */ export namespace Word { export interface API { all: DocumentApi[]; /** * Word addin status */ addinStatus: boolean; /** * @example * ```javascript * var options = { * name: "MyFirstDocument", * data: "

Hello world!

", * isDocx: false * }; * glue4office.word.openDocument(options).then(console.log).catch(console.warn) * ``` */ openDocument(config: OpenDocumentConfig): Promise; /** * @hidden */ ready(): Promise; /** * @example * ```javascript * glue4office.word.onAddinStatusChanged(({connected}) => { * console.log(connected) * if (connected) { * glue4office.word.openDocument(options).then(console.log).catch(console.warn) * } else { * console.log('Word is closed'); * } * }) * ``` */ onAddinStatusChanged(callback: (args: { connected: boolean }) => void): void; } export interface OpenDocumentConfig { name: string; templateName?: string; data: string; isDocx: boolean; } export interface DocumentApi { name: string; data: string; onClose(callback: () => void): UnsubscribeFunction; getHtml(callback: (html?: string) => void): Promise; onChanged(callback: (html: string, docx?: string) => void): UnsubscribeFunction; } } /** * @docmenuorder 3 * @intro * The Glue42 Excel Connector allows applications to use Excel as a local data editor. The application uploads tabular data into Excel, so that the user may view it and edit it in a familiar environment. Any changes can then be transmitted back to the application for validation, processing, auditing and/or long-term storage. * * See also the [**Excel Connector**](../../../../../connectors/ms-office/excel-connector/javascript/index.html) documentation for more details. */ export namespace Excel { /** * @docmenuorder 1 */ export interface API { /** Excel addin status */ addinStatus: boolean; /** Returns all sheets opened by the current application */ sheets: Sheet[]; /** Opens a new sheet * @example * ```javascript * var options = { * columnConfig: [ * { header: 'Symbol', fieldName: 'symbol' }, * { header: 'Price', fieldName: 'price' } * ], * data: [ * { price: 100, symbol: 'AAPL' }, * { price: 200, symbol: 'GOOG' } * ], * options: { * workbook: 'MyWorkbook', * worksheet: 'MyWorksheet', * } * }; * * glue4office.excel.openSheet(options) * .then((sheet)=> { * // see Sheet * }) * .catch((err)=> { * * }); * ``` */ openSheet(sheetData: OpenSheetConfig): Promise; /** * @hidden */ ready(): Promise; /** * Whether the Excel add-in is working or not * * @example * ```javascript * glue4office.excel.onAddinStatusChanged((connected) => { * if (connected) { * // yahoo - we're connected to excel * } else { * console.log('Excel is closed or addin is not working'); * } * }) * ``` */ onAddinStatusChanged(callback: (connected: boolean) => void): UnsubscribeFunction; onNewWorksheet(callback: (sheet: Sheet) => void): UnsubscribeFunction; getWorksheets(): Promise; getWorkbooks(): Promise; } /** * @docmenuorder 2 */ export interface Sheet { /** Current column configuration */ columnConfig: ColumnConfig[]; /** Sheet options */ options?: OpenSheetOptions; /** The name of the sheet */ name: string; /** The name of the workbook */ workbook?: string; /** The current data in the sheet */ data: object[]; /** * Updates the data in the sheet. */ update(data: object[]): Promise; /** * Change the column configuration of the sheet. * Optionally pass new data (if not passed it will keep the existing data) */ changeColumnConfig(columnConfig: ColumnConfig[], data?: object[]): Promise; /** * Executes when the sheet is changed in Excel, after all chunks have arrived. * @example * ```javascript * glue4office.excel.openSheet(options) * .then((sheet) => { * sheet.onChanged((data, errorCb, doneCb, delta) => { * console.log(data); * // if no errors - call doneCb() * // else errorCb([{ * // row:0, * // column:1, * // description: "Error!" * //}]) * }); * }).catch(console.warn) * ``` */ onChanged(callback: (data: object[], errorCallback: (errors: ValidationError[]) => void, doneCallback: () => void, delta: DeltaItem[]) => Promise): UnsubscribeFunction; /** * Executes when data starts coming in from Excel, once for every chunk. * Useful for showing progress indication, etc. */ onChanging(callback: (info: SheetChangingInfo) => void): UnsubscribeFunction; } export interface Book { name: string; path: string; saved: boolean; worksheets: Sheet[]; } /** * Trigger conditions control when ExcelPad will to invoke the * validation method */ export const enum TriggerType { /** When the user tries to save the worksheet */ save, /** When the user clicks the ExcelPad button (see the buttonText and buttonRange arguments). */ button, /** When the user changes one or more cells in a given row and then selects a cell in a different row. */ row, } export interface OpenSheetOptions { /** Name of the sheet to receive the data; else uses the first sheet in the workbook. */ worksheet?: string; /** Name of the workbook to reuse; otherwise a new temporary workbook will be created. */ workbook?: string; /** Name of a template workbook to use when creating new workbooks. */ templateWorkbook?: string; /** Name of the worksheet to display; ignored if there is no template. */ templateWorksheet?: string; /** * Trigger conditions control tell ExcelPad when to invoke the * validation method; default is never to return data. */ updateTrigger?: TriggerType[]; // /** // * What data to be send for validation // */ // payloadType?: UpdatePayloadType; /** Set to true to prevent the user from saving the temporary workbook. */ inhibitLocalSave?: boolean; /** Remove all existing rows before applying the new data; default true. */ clearGrid?: boolean; /** The trigger button is placed over a range of cells; default is A1. */ buttonRange?: string; /** The caption to use for a trigger button. */ buttonText?: string; /** The top-left address of the data in the dataWorksheet; default is A1. */ topLeft?: string; /** ExcelPad will create an Excel Named Range that defines the extent of the data written to the worksheet. */ dataRangeName?: string; /** Excel window activation/state options */ window?: "hide" | "show" | "normal" | "restore" | "max" | "min" | "top" | "bottom"; /** How long to wait for success response from Excel when opening sheet */ timeoutMs?: number; /** The maximum number of rows of changes to send in each invocation of the Validation method; default 1000. */ chunkSize?: number; /** If true, send before and after images of each row as it's sent for validation. Defaults to true. */ sendBeforeAndAfter?: boolean; /** delta response will return only the delta change and image will return the current data after the change. Default: delta (=== row) * */ response?: "image" | "delta"; } export interface OpenSheetConfig { /** Defines the column headers to use for the grid of data (the first row). */ columnConfig: ColumnConfig[]; /** Defines the data itself. */ data?: object[]; options?: OpenSheetOptions; } export interface ColumnConfig { /** The name of the property that is used to transmit this value to/from Excel */ fieldName: string; /** A string that forms the Column header text in Excel. If not specified fieldName is used. */ header?: string; /** A color value for the text colour of the cells in this column */ foregroundColor?: string; /** A color value for the background colour of the cells in this column */ backgroundColor?: string; /** Width of the column in Excel units of 0 (zero) to 255. This value represents the number of characters that can be displayed in a cell that is formatted with the standard font. * The default column width is 8.43 characters. If a column has a width of 0 (zero), the column is hidden. */ width?: number; /** The type and possible values for cells in the column. */ validation?: Validation; /** If true, will cause numeric data in this column to be stored as text in Excel. */ forceText?: boolean; /** If true, will cause empty strings in this column to be stored quoted in Excel, enabling round trip. */ preserveEmptyString?: boolean; } export interface Validation { /** * The type of data that can be used in the cells. */ type?: ValidationType; /** * Affects the type of warning when the validation fails. */ alert?: ValidationAlert; /** * An array of strings giving the possible values for the cells, when the * type is set to List. ExcelPad uses this to build a drop-down * combo box allowing the user to select one from the possible values. */ list?: string[]; } export interface ValidationError { /** The location of the error (row 0 is the row containing the column headers) */ row: number; /** The location of the error (column 0 is the left-most column in the grid) */ column: number; /** An error code that defines the problem. This will be displayed in the cell’s comment. */ error?: number; /** A human-readable description of the problem. This will be displayed in the cell’s comment */ description?: string; /** The cell text will be replaced by this value; default is not to change the value in the cell. */ text?: string; /** The new colour for the cell. default is to use the column colour. */ foregroundColor?: string; /** The new background colour for the cell. default is to use the column colour. */ backgroundColor?: string; } export interface SheetChangingInfo { /** In case of large updates, GlueXL sends the update data in chunks. * This field indicates which chunk has been received. * Between 0 to (totalChunks - 1) */ chunkIndex: number; /** In case of large updates, GlueXL sends the update data in chunks. * This field indicates the total number of chunks. */ totalChunks: number; } export const enum ValidationAlert { /** Prevent users from entering invalid data in a cell. A Stop alert message has two options: Retry or Cancel. */ Stop, /** Warn users that the data they entered is invalid, without preventing them from entering it. When a Warning alert message appears, users can click Yes to accept the invalid entry, No to edit the invalid entry, or Cancel to remove the invalid entry. */ Warning, /** Inform users that the data they entered is invalid, without preventing them from entering it. This type of error alert is the most flexible. When an Information alert message appears, users can click OK to accept the invalid value or Cancel to reject it. */ Information, } export const enum ValidationType { /** only whole numbers are allowed. Once the whole number option is selected, other options become available to further limit input. */ WholeNumber, /** only decimal numbers are allowed. Once the decimal number option is selected, other options become available to further limit input. */ Decimal, /** only dates are allowed. */ Date, /** only times are allowed. */ Time, /** validates input based on number of characters or digits */ TextLength, /** only values from a predefined list are allowed. The values are presented to the user as a dropdown menu control */ List, } /** Represents a change to a row */ export interface DeltaItem { action: "modified" | "inserted" | "unchanged" | "deleted"; row: any[]; rowAfter: any[]; rowAfterIndex: number; rowBefore: any[]; rowBeforeIndex: number; /** Count of deleted rows in case 'action' is "deleted" */ count?: number; } } /** * @docmenuorder 4 * @intro * * The Glue42 Outlook Connector allows applications to use Outlook for creating emails, tasks, meetings and appointments, so that the user may view and edit these in a familiar environment. Once the items are sent or saved by the user, they can then be transmitted back to the application for processing, auditing and/or long-term storage. * * The Glue42 Outlook Connector API lets your application interact with Outlook, and enables it to: * * - Initiate new emails with rich `HTML` body and attachments and get notified when the email has been sent. * - Monitor certain folders in Outlook and get notified when an email has been received. * - Save complete email messages with attachments in your web application. * - Show a saved email in Outlook. * - Initiate the creation of new tasks and get notified when a task is created. * - Save complete tasks with attachments in your web application. * - Show a saved task in Outlook. * * See also the [**Outlook Connector**](../../../../../connectors/ms-office/outlook-connector/javascript/index.html) documentation for more details. */ export namespace Outlook { /** * The entry points of outlook API - accessible from g4o.outlook or g4oe.outlook * * @doc-menu-order 2 */ export interface API { /** * Outlook addin status */ addinStatus: boolean; /** * @hidden * The entry point for your outlook code. * @function ready * @returns A promise for outlook API */ ready(): Promise; /** * Creates new email window * * @example * ```javascript * outlook.newEmail( * { * to: "emailAddress@mail.com", * subject: "Sample subject", * body: "Sample body", * attachments: [{ * fileName: "attachmentFileName.txt", * data: "Sample text" * }] * }, * { * onSent: (email) => console.log(email), * onCanceled: () => console.log("canceled"), * } * ) * .then(console.log) * .catch(console.error) * ``` * * @function newEmail * @returns A promise for the created Outlook new email window */ newEmail(emailParams?: EmailParams, options?: NewEmailOptions): Promise; /** * Tracks appointment or meeting * @function trackCalendarEvent * @returns A promise for the tracked appointment or meeting */ trackCalendarEvent(event: T42Appointment | T42Meeting, conversationId?: T42Id): Promise<{ event: T42Appointment | T42Meeting, conversationIds: T42Id[], }>; /** * Untracks appointment or meeting * @function untrackCalendarEvent * @returns A promise for the untracked appointment or meeting */ untrackCalendarEvent(event: T42Appointment | T42Meeting): Promise<{ event: T42Appointment | T42Meeting }>; /** * Creates new local email * * @example * ```javascript * outlook.createLocalEmail( * { * sender: "emailAddress@mail.com", * to: "emailAddress@mail.com", * subject: "Sample body", * location: "$Inbox" * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function createLocalEmail * @returns A promise for the created local email */ createLocalEmail(localEmailParams: LocalEmailParams): Promise; /** * Creates new task window * * @example * ```javascript * outlook.newTask( * { * subject: "Sample subject", * body: "Sample body", * priority: "high", * dueDate: new Date('2017-07-01') * }, * { * onSaved: (task) => console.log(task), * onCanceled: () => console.log("canceled") * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function newTask * @returns A promise for the created Outlook new task window */ newTask(taskParams?: TaskParams, options?: NewTaskOptions): Promise; emailFromJSON(email: T42Email): Email; /** * Converts email object to Email with methods: getAsMsg(), saveToFile(), show(), track() and untrack() * * @function emailFromJSON * @returns Email */ /** * Converts task object to Task with methods saveToFile() and show() * * @function taskFromJSON * @returns Task */ taskFromJSON(task: T42Task): Task; /** * Converts attachment object to Attachment with method getData() but without the parent property * * @function attachmentFromJSON * @returns Attachment */ attachmentFromJSON(attachment: T42Attachment): Attachment; /** * Shows email in Outlook * * @example * ```javascript * outlook.newEmail( * { * to: "emailAddress@mail.com", * subject: "Sample subject", * body: "Sample body" * }, * { * onSent: (email) => { * g4o.outlook.showEmail(email.ids) * .then(console.log) * .catch(console.error); * } * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function showEmail * @returns A promise for the shown email in Outlook */ showEmail(ids: T42Id[]): Promise; /** * Shows task in Outlook * * @function showTask * @returns A promise for the shown task in Outlook */ showTask(ids: T42Id[]): Promise; /** * Notifies when the connection status has changed * * @example * ```javascript * outlook.onAddinStatusChanged(({connected}) => { * console.log(`Outlook is ${connected ? "available" : "unavailable"}.`); * }); * ``` * * @function onAddinStatusChanged */ onAddinStatusChanged(callback: (args: { connected: boolean }) => any): () => void; /** * Notifies when an email is received in GlueHandleEmail folder * * @example * ```javascript * outlook.onEmailReceived((email) => console.log("An email was received.", email)); * ``` * * @function onEmailReceived */ onEmailReceived(callback: (email: Email) => any): void; /** * Notifies when an email is received in GlueHandleEmail folder * * @example * ```javascript * outlook.onTaskCreated((task) => console.log("A task was created.", task)); * ``` * * @function onEmailReceived */ onTaskCreated(callback: (task: Task) => any): void; /** * Notifies when an email gets tracked * * @function onTrackEmail */ onTrackEmail(callback: (args: { conversationIds: T42Id[], email: Email }) => any): void; /** * Notifies when an email gets untracked * * @function onUntrackEmail */ onUntrackEmail(callback: (args: { conversationIds: T42Id[], emailIds: T42Id[] }) => any): void; /** * Notifies when an appointment or meeting gets tracked * * @function onTrackCalendarEvent */ onTrackCalendarEvent(callback: (args: { conversationIds: T42Id[], event: T42Appointment | T42Meeting }) => any): void; /** * Notifies when an appointment or meeting gets untracked * * @function onUntrackCalendarEvent */ onUntrackCalendarEvent(callback: (args: { conversationIds: T42Id[], eventIds: T42Id[] }) => any): void; /** * Notifies on secure reply to local email * * @function onSecureReply */ onSecureReply(callback: (email: Email) => any): void; /** * Notifies on request for local email to be displayed * * @function onDisplaySecureEmail */ onDisplaySecureEmail(callback: (email: Email) => any): void; } /** * @hidden * This composite type describes the common parameters to be populated on creating a new email or local email */ export interface CommonEmailParams { /** * An array of the full paths to existing files to be attached OR an array of objects with the name and data of * each attachment to be dynamically created and attached */ attachments?: string[] | AttachmentParams[]; /** * The blind co-recipient(s) of the email */ bcc?: string | string[]; /** * The body text of the email, formatted as a plain string */ body?: string; /** * The body of the email, formatted as an HTML string */ bodyHtml?: string; /** * The co-recipient(s) of the email */ cc?: string | string[]; /** * @hidden * The cookie of the email */ cookie?: string; [key: string]: any; } /** * @hidden * This composite type describes the common parameters to be populated on creating a new email or task, such as the display settings. */ export interface CommonItemOptions { displaySettings?: { left?: number; top?: number; width?: number; height?: number; action?: string; actionDelayMSecs?: number; }; } export interface NewEmailOptions extends CommonItemOptions { /** * Callback which will be executed on send */ onSent?: (email: Email) => any; /** * Callback which will be executed on cancel */ onCanceled?: () => any; } /** * This composite type describes the parameters to be populated on creating a new email */ export interface EmailParams extends CommonEmailParams { /** * The subject field of the email */ subject?: string; /** * The primary recipient(s) of the email */ to?: string | string[]; [key: string]: any; } /** * This composite type describes the parameters to be populated on creating a new local email */ export interface LocalEmailParams extends CommonEmailParams { /** * Additional properties */ additionalProps?: object; /** * The subject field of the email */ subject: string; /** * The primary recipient(s) of the email */ to: string | string[]; /** * The sender of the email */ sender: string; /** * The location where the local email will be created */ location: Email | CommonOutlookFolder | string; [key: string]: any; } export interface CommonOutlookFolder { $Inbox: number; $SentMail: number; } /** * This composite type describes the parameters to be populated on creating a new task */ export interface TaskParams { /** * An array of the full paths to existing files to be attached OR an array of objects with the name and data of * each attachment to be dynamically created and attached */ attachments?: string[] | AttachmentParams[]; /** * The body text of the task, formatted as a plain string */ body?: string; /** * @hidden * The cookie of the task */ cookie?: string; /** * The start date of the task which is Date object, string Date or Unix timpestamp number */ startDate?: Date | string | number; /** * The due time of the task which is Date object, string Date or Unix timpestamp number */ dueDate?: Date | string | number; /** * The priority of the task - "low", "normal" or "high" */ priority?: "low" | "normal" | "high"; /** * The reminder time of the task which is Date object, string Date or Unix timpestamp number */ reminderTime?: Date | string | number; /** * The subject field of the task */ subject?: string; [key: string]: any; } export interface NewTaskOptions extends CommonItemOptions { /** * Callback which will be executed on save & close */ onSaved?: (task: Task) => any; /** * Callback which will be executed on cancel */ onCanceled?: () => any; } /** * This composite type describes the attachment file, created dynamically */ export interface AttachmentParams { /** * Attachment file data */ data: string; /** * Attachment file name */ fileName: string; /** * @hidden * Truncate the file. Defaulted to true */ truncate?: boolean; /** * @hidden * Encoding (base64 for example) */ encoding?: string; } /** * @hidden * This composite type describes a single email. The data stored in the object includes the sender, subject, * recipients, body and optional extra values */ export interface T42Email { /** * An array of identifiers for the attachments to the email */ attachments: Attachment[]; /** * The blind co-recipient(s) of the email. If this parameter is missing then there are no blind co-recipients */ bcc: T42Contact | T42Contact[]; /** * The body text of the email, formatted as a plain string */ body: string; /** * The body of the email, formatted as an HTML string. If the email was not sent in HTML format, then the Helper * must convert the plain-text body into a valid HTML string by wrapping it in the standard tags */ bodyHtml: string; /** * The co-recipient(s) of the email. If this parameter is missing then there are no co-recipients */ cc: T42Contact | T42Contact[]; /** * The time at which the email was sent, using local time for the sender */ date: Date; /** * Identifiers for the email; globally unique to the system */ ids: T42Id[]; /** * The originator of the email. This might be only the email address, if the T42Contact has not yet been resolved */ sender: T42Contact; /** * The subject field of the email */ subject: string; /** * The primary recipient(s) of the email */ to: T42Contact | T42Contact[]; /** * @hidden */ entityType: number; [key: string]: any; } export interface Email extends T42Email { /** * Shows email in Outlook * * @example * ```javascript * outlook.newEmail( * { * to: "emailAddress@mail.com", * subject: "Sample subject", * body: "Sample body" * }, * { * onSent: (email) => { * email.show() * .then((ids) => console.log(ids)) * .catch(console.error); * } * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function show * @returns A promise for the shown email in Outlook */ show(): Promise; /** * Saves email as .msg file * * @example * ```javascript * outlook.newEmail( * { * to: "emailAddress@mail.com", * subject: "Sample subject", * body: "Sample body" * }, * { * onSent: (email) => { * email.saveToFile() * .then((uri) => console.log(uri)) * .catch(console.error); * } * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function saveToFile * @returns A promise for the saved email as .msg file */ saveToFile(): Promise; /** * Returns email, saved as .msg as base64 * * @example * ```javascript * outlook.newEmail( * { * to: "emailAddress@mail.com", * subject: "Sample subject", * body: "Sample body" * }, * { * onSent: (email) => { * email.getAsMsg() * .then((data) => console.log(data)) * .catch(console.error); * } * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function getAsMsg * @returns A promise for the returned email data as base64 */ getAsMsg(): Promise; /** * Tracks email * * @example * ```javascript * outlook.onTrackEmail(({conversationIds, email}) => { * email.track() * .then(({conversationIds, emailIds}) => console.log(conversationIds, emailIds)) * .catch(console.error); * }) * .then(console.log) * .catch(console.error); * ``` * * @function track * @returns A promise for the tracked email */ track(conversationId?: T42Id): Promise<{ conversationIds: T42Id[], emailIds: T42Id[] }>; /** * Untracks email * * @returns A promise for the untracked email * @example * ```javascript * outlook.onTrackEmail(({conversationIds, email}) => { * email.track() * .then(() => { * email.untrack() * .then(({conversationIds, emailIds}) => console.log(conversationIds, emailIds)) * .catch(console.error); * }) * .catch(console.error); * }) * .then(console.log) * .catch(console.error); *``` */ untrack(): Promise<{ conversationIds: T42Id[], emailIds: T42Id[] }>; } /** * @hidden * This composite type describes a single task. The data stored in the object includes the subject, body and * optional extra values */ export interface T42Task { actualWork: number; /** * An array of identifiers for the attachments to the task */ attachments: Attachment[]; /** * The body text of the task, formatted as a plain string */ body: string; /** * @hidden * The cookie of the task */ cookie?: string; /** * The time at which the task was created, using local time for the sender. */ creationTime: Date; /** * The time at which the task is due to be completed */ dateCompleted: Date; /** * The due time of the task */ dueDate: Date; /** * The originator of the task */ ids: T42Id[]; /** * @hidden * The importance of the task - 0 for low, 1 for normal and 2 for high */ importance?: number; /** * The priority of the task */ priority: string; /** * The reminder time of the task */ reminderTime: Date; /** * The start date time of the task */ startDate: Date; /** * The subject field of the task */ subject: string; /** * @hidden */ entityType: number; [key: string]: any; } export interface Task extends T42Task { /** * Shows task in Outlook * * @example * ```javascript * outlook.newTask( * { * subject: "Sample subject", * body: "Sample body", * priority: "high", * dueDate: new Date('2017-07-01') * }, * { * onSaved: (task) => { * task.show() * .then((ids) => console.log(ids)) * .catch(console.error); * } * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function show * @returns A promise for the shown task in Outlook */ show(): Promise; /** * Saves task as .msg file * * @example * ```javascript * outlook.newTask( * { * subject: "Sample subject", * body: "Sample body", * priority: "high", * dueDate: new Date('2017-07-01') * }, * { * onSaved: (task) => { * task.saveToFile() * .then((uri) => console.log(uri)) * .catch(console.error); * } * } * ) * .then(console.log) * .catch(console.error); * ``` * * @function saveToFile * @returns A promise for the saved task as .msg file */ saveToFile(): Promise; } export interface Attachment extends T42Attachment { /** * Returns the parent of the attachment */ parent: Email | Task; /** * Returns attachment data as base64 * * @function getData * @param callback - A callback which will be called multiple times with the percent of progress * @returns A promise for the returned attachment data as base64 */ getData(callback?: (percent: number) => number): Promise; } /** * This is a Glue composite value that describes a single contact within the system */ export interface T42Contact { /** * Identifier for the contact; globally unique to the system */ ids: T42Id[]; /** * Advisory only. A user-friendly name for this object to use in debug logs etc. */ displayName?: string; /** * The name of the contact. Optional in case the name has not yet been resolved from the email, or id etc. */ name?: object; /** * The status of the contact, e.g. “client”, “prospect”, “lead” */ status?: string; /** * Is the contact a single person? */ isPerson?: boolean; /** * The account allocated to this contact */ account?: object[]; /** * Each T42Address includes a description saying the type of address, e.g. “home”, “office” */ addresses?: string[]; /** * An array of phone numbers for this contact */ phones?: object[]; /** * An array of email addresses for this contact */ emails?: string[]; /** * A dictionary of CRM specific fields */ context?: object; } /** * This composite type describes a file attachment to an email or a task */ export interface T42Attachment { /** * @hidden */ cookie?: string; /** * Optional id of the email owning the attachment. This field is only required when a T42Attachment value is used * outside the context of the email that owns it */ emailIds?: T42Id[]; /** * @hidden */ errorMessage?: string; data?: string; /** * Identifiers for the attachment, which is unique within a single email */ ids?: T42Id[]; /** * @hidden * Set to true if the data has been chunked and there are more chunks to be received */ more?: boolean; /** * Display name for the attachment; typically a filename without a path. Therefore, neither the Helper nor the CRM * should rely on identifying the attachment using this field */ name?: string; /** * An estimate of the size of the attachment. This is an estimate of the size that the attachment would have if it * were saved to disk. It is not the size of the encoded string (e.g. MIME) and it is an advisory-value only, to * help with storage optimisations. * Neither the Helper nor the CRM should rely on this field being present and 100% accurate in all cases * (especially when the attachment may be encoded or encrypted In some way) */ sizeHint?: number; /** * @hidden */ success?: boolean; /** * @hidden */ length?: number; /** * @hidden */ totalLength?: number; } /** * @hidden * The parameters with which the callback of getEmailAsMsg is called */ export interface GetEmailAsMsgCallbackParams { /** * The cookie of the email */ cookie: string; /** * The email data in base64 format */ data: string; /** * Error message */ errorMessage: string; /** * Set to true if the data has been chunked and there are more chunks to be received */ more: boolean; length: number; offset: number; /** * True if the data is returned successfully */ success: boolean; totalLength: number; } /** * This is the universal identifier class for an object in the CRM-Helper system. It consists of two elements: * An optional user-friendly display name, that has no meaning to the CRM or the Helper but may be useful for * displaying to the user; * an array of application-specific name-value pairs that identify the object to each window in the system. */ export interface T42Id { /** * Identifies the creator of the id */ systemName: string; /** * The opaque value that identifies the object to the named system */ nativeId: string; } /** * This is a Glue composite value that describes an appointment */ export interface T42Appointment { /** * The originator of the appointment */ ids: T42Id[]; /** * An array of identifiers for the attachments to the appointment */ attachments: T42Attachment[]; /** * The subject field of the appointment */ subject: string; /** * The body text of the appointment, formatted as a plain string */ body: string; /** * The body of the appointment, formatted as an HTML string */ bodyHtml: string; /** * The location of the appointment */ location: string; /** * The start date time of the appointment */ startTime: Date; /** * The end date time of the appointment */ endTime: Date; /** * Is the appointment all day long */ allDayEvent: boolean; /** * The primary recipient(s) of the appointment */ to: T42Contact | T42Contact[]; /** * The co-recipient(s) of the appointment */ cc: T42Contact | T42Contact[]; /** * The blind co-recipient(s) of the appointment */ bcc: T42Contact | T42Contact[]; busyStatus: boolean; /** * @hidden */ entityType: number; [key: string]: any; } /** * This is a Glue composite value that describes an meeting */ export interface T42Meeting { /** * The originator of the meeting */ ids: T42Id[]; /** * An array of identifiers for the attachments to the meeting */ attachments: T42Attachment[]; /** * The subject field of the meeting */ subject: string; /** * The body text of the meeting, formatted as a plain string */ body: string; /** * The primary recipient(s) of the meeting */ to: T42Contact | T42Contact[]; /** * The co-recipient(s) of the meeting */ cc: T42Contact | T42Contact[]; /** * The blind co-recipient(s) of the meeting */ bcc: T42Contact | T42Contact[]; /** * The sender of the meeting */ sender: T42Contact; /** * The reminder time of the meeting */ reminderTime: Date; /** * @hidden */ entityType: number; [key: string]: any; } } } declare module 'glue42Office' { export = Glue42Office; } interface NodeRequireFunction { (moduleName: 'glue4office'): typeof Glue42Office; }