From 853deb1f46ba82f9feff2c0184e1cdd533c0ff8b Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Tue, 17 Jan 2017 00:41:59 +0000 Subject: [PATCH 001/258] Initial commit of typings for OpenFin API --- openfin/index.d.ts | 1493 ++++++++++++++++++++++++++++++++++++++ openfin/openfin-tests.ts | 718 ++++++++++++++++++ openfin/tsconfig.json | 20 + openfin/tslint.json | 1 + 4 files changed, 2232 insertions(+) create mode 100644 openfin/index.d.ts create mode 100644 openfin/openfin-tests.ts create mode 100644 openfin/tsconfig.json create mode 100644 openfin/tslint.json diff --git a/openfin/index.d.ts b/openfin/index.d.ts new file mode 100644 index 0000000000..2c37e6f9b2 --- /dev/null +++ b/openfin/index.d.ts @@ -0,0 +1,1493 @@ +// Type definitions for OpenFin API 15.0 +// Project: https://openfin.co/ +// Definitions by: Chris Barker +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// based on v6.49.15.18 +// see https://openfin.co/support/technical-faq/#what-do-the-numbers-in-the-runtime-version-mean + + +/** + * JavaScript API + * The JavaScript API allows you to create an HTML/JavaScript application that has access to the native windowing environment, can communicate with other applications and has access to sandboxed system-level features. + * + * API Ready + * When using the OpenFin API, it is important to ensure that it has been fully loaded before making any API calls. To verify that the API is in fact ready, be sure to make any API calls either from within the fin.desktop.main() method or explicitly after it has returned. This avoids the situation of trying to access methods that are not yet fully injected. + * + * Overview + * When running within the OpenFin Runtime your web applications have access to the "fin" namespace and all the modules within the API without the need to include additional source files. You can treat the "fin" namespace as you would the "window", "navigator" or "document" objects. + **/ +declare namespace fin { + const desktop: OpenFinDesktop; + + interface OpenFinDesktop { + main(f: () => any): void; + Application: OpenFinApplication; + ExternalApp: OpenFinExternalApplication; + InterApplicationBus: OpenFinInterApplicationBus; + Notification: OpenFinNotification; + System: OpenFinSystem; + Window: OpenFinWindow; + } + + /** + * Application + * An object representing an application.Allows the developer to create, execute, show / close an application as well as listen to application events. + */ + interface OpenFinApplication { + /** + * Creates a new Application. + * An object representing an application. Allows the developer to create, execute, show/close an application as well as listen to application events. + */ + new (options: ApplicationOptions, callback?: (successObj: { httpResponseCode: number }) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): OpenFinApplication; + /** + * Returns an Application object that represents an existing application. + */ + getCurrent(): OpenFinApplication; + /** + * Returns an Application object that represents an existing application. + */ + wrap(uuid: string): OpenFinApplication; + /** + * Returns an instance of the main Window of the application + */ + getWindow(): OpenFinWindow; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinApplicationEventType, listener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Closes the application and any child windows created by the application. + */ + close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of wrapped fin.desktop.Windows for each of the application’s child windows. + */ + getChildWindows(callback?: (children: OpenFinWindow[]) => any, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of active window groups for all of the application's windows. Each group is represented as an array of wrapped fin.desktop.Windows. + */ + getGroups(callback?: (groups: OpenFinWindow[][]) => any, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the JSON manifest that was used to create the application. Invokes the error callback if the application was not created from a manifest. + */ + getManifest(callback?: (manifest: any) => any, errorCallback?: (reason: string) => void): void; + /** + * Retrieves UUID of the application that launches this application. Invokes the error callback if the application was created from a manifest. + */ + getParentUuid(callback?: (uuid: string) => any, errorCallback?: (reason: string) => void): void; + /** + * Retrieves current configuration of application's shortcuts. + */ + getShortcuts(callback?: (config: ShortCutConfig) => void, errorCallback?: (reason: string) => void): void; + /** + * Determines if the application is currently running. + */ + isRunning(callback?: (running: boolean) => void, errorCallback?: (reason: string) => void): void; + /** + * Passes in custom data that will be relayed to the RVM + */ + registerCustomData(data: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinApplicationEventType, previouslyRegisteredListener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes the application’s icon from the tray. + */ + removeTrayIcon(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Restarts the application. + */ + restart(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Runs the application. When the application is created, run must be called. + */ + run(callback?: (successObj: SuccessObj) => any, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => any): void; + /** + * Tells the rvm to relaunch the main application once upon a complete shutdown + */ + scheduleRestart(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sets new shortcut configuration for current application. Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest to be able to change shortcut states. + */ + setShortcuts(config: ShortCutConfig, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Adds a customizable icon in the system tray and notifies the application when clicked. + */ + setTrayIcon(iconUrl: string, listener: (clickInfo: TrayIconClickedEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Closes the application by terminating its process. + */ + terminate(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Waits for a hanging application. This method can be called in response to an application "not-responding" to allow the application to continue and to generate another "not-responding" message after a certain period of time. + */ + wait(callback?: () => void, errorCallback?: (reason: string) => void): void; + } + + interface ShortCutConfig { + /** + * application has a shortcut on the desktop + */ + desktop: boolean; + /** + * application has no shortcut in the start menu + */ + startMenu: boolean; + /** + * application will be launched on system startup + */ + systemStartup: boolean; + } + + interface SuccessObj { + httpResponseCode: number; + } + + interface NetworkErrorInfo extends ErrorInfo { + networkErrorCode: number; + } + + interface ErrorInfo { + stack: string; + message: string; + } + + interface ApplicationOptions { + url: string; + uuid: string; + name: string; + mainWindowOptions: WindowOptions; + } + + interface WindowOptions { + /** + * Enable keyboard shortcuts for devtools and zoom. Default: false for both. + */ + accelerator?: { + devtools?: boolean, + zoom?: boolean + }; + /** + * A flag to always position the window at the top of the window stack. Default: false. + */ + alwaysOnTop?: boolean; + /** + * A flag to automatically show the Window when it is created. Default: false. + */ + autoShow?: boolean; + /** + * A flag to show the context menu when right-clicking on a window. Gives access to the Developer Console for the Window. Default: true + */ + contextMenu?: boolean; + /** + * This defines and applies rounded corners for a frameless window. Default for both width and height: 0. + */ + cornerRounding?: { + width: number; + height: number; + }; + /** + * A field that the user can attach serializable data to to be ferried around with the window options. Default: ''. + */ + customData?: any; + /** + * Specifies that the window will be positioned in the center of the primary monitor when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the position from before the window was closed is used. This option overrides defaultLeft and defaultTop. Default: false. + */ + defaultCentered?: boolean; + /** + * The default height of the window. Specifies the height of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the height is taken to be the last height of the window before it was closed. Default: 500. + */ + defaultHeight?: number; + /** + * The default left position of the window. Specifies the position of the left of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the value of left is taken to be the last value before the window was closed. Default: 100. + */ + defaultWidth?: number; + /** + * The default top position of the window. Specifies the position of the top of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the value of top is taken to be the last value before the window was closed. Default: 100. + */ + defaultTop?: number; + /** + * The default width of the window. Specifies the width of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the width is taken to be the last width of the window before it was closed. Default: 800. + */ + defaultLeft?: number; + /** + * A flag to show the frame. Default: true. + */ + frame?: boolean; + /** + * A flag to allow a window to be hidden when the close button is clicked.Default: false. + */ + hideOnClose?: boolean; + /** + * A URL for the icon to be shown in the window title bar and the taskbar.Default: The parent application's applicationIcon. + */ + icon?: string; + /** + * The maximum height of a window.Will default to the OS defined value if set to - 1. Default: -1. + */ + maxHeight?: number; + /** + * A flag that lets the window be maximized.Default: true. + */ + maximizable?: boolean; + /** + * The maximum width of a window.Will default to the OS defined value if set to - 1. Default: -1. + */ + maxWidth?: number; + /** + * The minimum height of a window.Default: 0. + */ + minHeight?: number; + /** + * A flag that lets the window be minimized.Default: true. + */ + minimizable?: boolean; + /** + * The minimum width of a window.Default: 0. + */ + minWidth?: number; + /** + * The name for the window which must be unique within the context of the invoking Application. + */ + name?: string; + /** + * A flag that specifies how transparent the window will be.This value is clamped between 0.0 and 1.0.Default: 1.0. + */ + opacity?: number; + /** + * A flag to drop to allow the user to resize the window.Default: true. + */ + resizable?: boolean; + /** + * Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window. + */ + resizeRegion?: { + /** + * The size in pixels (Default: 2), + */ + size: number; + /** + * The size in pixels of an additional + * square resizable region located at the + * bottom right corner of a + * frameless window. (Default: 4) + */ + bottomRightCorner: number; + }; + /** + * A flag to show the Window's icon in the taskbar. Default: true. + */ + showTaskbarIcon?: boolean; + /** + * A flag to cache the location of the window or not. Default: true. + */ + saveWindowState?: boolean; + /** + * Specify a taskbar group for the window. Default: app's uuid. + */ + taskbarIconGroup?: string; + /** + * A string that sets the window to be "minimized", "maximized", or "normal" on creation. Default: "normal". + */ + state?: string; + /** + * The URL of the window. Default: "about:blank". + */ + url?: string; + /** + * When set to false, the window will render before the "load" event is fired on the content's window. Caution, when false you will see an initial empty white window. Default: true. + */ + waitForPageLoad?: boolean; + } + + /** + * Clipboard + * Clipboard API allows reading and writting to the clipboard in multiple formats. + */ + interface OpenFinClipboard { + /** + * Reads available formats for the clipboard type + */ + availableFormats(type: string | null, callback?: (formats: string[]) => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Reads available formats for the clipboard type + */ + readHtml(type: string | null, callback?: (html: string) => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Read the content of the clipboard as Rtf + */ + readRtf(type: string | null, callback?: (rtf: string) => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Read the content of the clipboard as plain text + */ + readText(type: string | null, callback?: (text: string) => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Writes data into the clipboard + */ + write(data: any, type: string | null, callback?: () => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Writes data into the clipboard as Html + */ + writeHtml(data: string, type: string | null, callback?: () => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Writes data into the clipboard as Rtf + */ + writeRtf(data: string, type: string | null, callback?: () => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Writes data into the clipboard as plain text + */ + writeText(data: string, type: string | null, callback?: () => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + } + + /** + * ExternalApplication + * An object representing an application. Allows the developer to create, execute, show and close an application, as well as listen to application events. + */ + interface OpenFinExternalApplication { + /** + * Returns an External Application object that represents an existing external application. + */ + wrap(uuid: string): OpenFinExternalApplication; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinExternalApplicationEventType, listener: () => any, callback?: () => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinExternalApplicationEventType, listener: () => any, callback?: () => any, errorCallback?: (reason: string, error: ErrorInfo) => any): void; + } + + /** + * InterApplicationBus + * A messaging bus that allows for pub/sub messaging between different applications. + */ + interface OpenFinInterApplicationBus { + /** + * Adds a listener that gets called when applications subscribe to the current application's messages. + */ + addSubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Adds a listener that gets called when applications unsubscribe to the current application's messages. + */ + addUnsubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Removes a previously registered subscribe listener. + */ + removeSubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Removes a previously registered unsubscribe listener. + */ + removeUnsubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Publishes a message to all applications running on OpenFin Runtime that are subscribed to the specified topic. + */ + publish(topic: string, message: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sends a message to a specific application on a specific topic. + */ + send(destinationUuid: string, name: string, topic: string, message: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + send(destinationUuid: string, topic: string, message: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Subscribes to messages from the specified application on the specified topic. If the subscription is for a uuid, [name], topic combination that has already been published to upon subscription you will receive the last 20 missed messages in the order they were published. + */ + subscribe(senderUuid: string, name: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + subscribe(senderUuid: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Unsubscribes to messages from the specified application on the specified topic. + */ + unsubscribe(senderUuid: string, name: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + unsubscribe(senderUuid: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + } + + /** + * Notification + * Notification represents a window on OpenFin Runtime which is shown briefly to the user on the bottom-right corner of the primary monitor. A notification is typically used to alert the user of some important event which requires his or her attention. Notifications are a child or your application that are controlled by the runtime. + */ + interface OpenFinNotification { + /** + * + */ + new (options: NotificationOptions, callback?: () => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): OpenFinNotification; + /** + * Gets an instance of the current notification. For use within a notification window to close the window or send a message back to its parent application. + */ + getCurrent(): OpenFinNotification; + /** + * Closes the notification. + */ + close(callback?: () => void): void; + /** + * Sends a message to the notification. + */ + sendMessage(message: any, callback?: () => void): void; + /** + * Sends a message from the notification to the application that created the notification. The message is handled by the notification's onMessage callback. + */ + sendMessageToApplication(message: any, callback?: () => void): void; + } + + interface NotificationOptions { + /** + * A boolean that will force dismissal even if the mouse is hovering over the notification + */ + ignoreMouseOver?: boolean; + /** + * A message of any primitive or composite-primitive type to be passed to the notification upon creation. + */ + message: any; + /** + * The timeout for displaying a notification.Can be in milliseconds or "never". + */ + duration?: number | "never"; + /** + * The url of the notification + */ + url: string; + /** + * A function that is called when a notification is clicked. + */ + onClick?(callback: () => void): void; + /** + * Invoked when the notification is closed via .close() method on the created notification instance or the by the notification itself via fin.desktop.Notification.getCurrent().close(). NOTE: this is not invoked when the notification is dismissed via a swipe. For the swipe dismissal callback see onDismiss + */ + onClose?(callback: () => void): void; + /** + * Invoked when a the notification is dismissed by swiping it off the screen to the right. NOTE: this is no fired on a programmatic close. + */ + onDismiss?(callback: () => void): void; + /** + * A function that is called when an error occurs.The reason for the error is passed as an argument. + */ + onError?(errorCallback: (reason: string, errorObj: NetworkErrorInfo) => void): void; + /** + * The onMessage function will respond to messages sent from notification.sendMessageToApplication.The function is passed the message, which can be of any primitive or composite-primitive type. + */ + onMessage?(callback: (message: any) => void): void; + /** + * A function that is called when a notification is shown. + */ + onShow?(callback: (successObj: SuccessObj) => void): void; + } + + /** + * System + * An object representing the core of OpenFin Runtime. Allows the developer to perform system-level actions, such as accessing logs, viewing processes, clearing the cache and exiting the runtime. + */ + interface OpenFinSystem { + /** + * + */ + Clipboard: OpenFinClipboard; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinSystemEventType, listener: (event: SystemBaseEvent | DesktopIconClickedEvent | IdleStateChangedEvent | MonitorInfoChangedEvent | SessionChangedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Clears cached data containing window state/positions, application resource files (images, HTML, JavaScript files), cookies, and items stored in the Local Storage. + */ + clearCache(options: CacheOptions, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Clears all cached data when OpenFin Runtime exits. + */ + deleteCacheOnExit(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Downloads the given application asset + */ + downloadAsset(assetObj: AppAssetInfo, progressListener?: (progress: { downloadedBytes: number, totalBytes: number }) => void, callback?: (successObj: { path: string }) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): void; + /** + * Exits the Runtime. + */ + exit(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of data for all applications. + */ + getAllApplications(callback?: (applicationInfoList: ApplicationInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of data for all external applications. + */ + getAllExternalApplications(callback?: (applicationInfoList: ApplicationInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of data (name, ids, bounds) for all application windows. + */ + getAllWindows(callback?: (windowInfoList: WindowDetails[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the command line argument string that started OpenFin Runtime. + */ + getCommandLineArguments(callback?: (args: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the configuration object that started the OpenFin Runtime. + */ + getDeviceId(callback?: (uuid: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the value of a given environment variable on the computer on which the runtime is installed. + */ + getEnvironmentVariable(envVar: string, callback?: (variable: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the contents of the log with the specified filename. + */ + getLog(logFileName: string, callback?: (variable: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array containing information for each log file. + */ + getLogList(callback?: (logInfoList: LogInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an object that contains data about the about the monitor setup of the computer that the runtime is running on. + */ + getMonitorInfo(callback?: (monitorInfo: MonitorInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Returns the mouse in virtual screen coordinates (left, top). + */ + getMousePosition(callback?: (mousePosition: VirtualScreenCoordinates) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of all of the runtime processes that are currently running. Each element in the array is an object containing the uuid and the name of the application to which the process belongs. + */ + getProcessList(callback?: (processInfoList: ProcessInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the Proxy settings. + */ + getProxySettings(callback?: (proxy: ProxyInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Returns information about the running RVM in an object. + */ + getRvmInfo(callback?: (rvmInfo: RvmInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Returns the version of the runtime. The version contains the major, minor, build and revision numbers. + */ + getVersion(callback?: (version: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Runs an executable or batch file. + */ + launchExternalProcess(options: ExternalProcessLaunchInfo, callback?: (payload: { uuid: string }) => void, errorCallback?: (reason: string) => void): void; + /** + * Writes the passed message into both the log file and the console. + */ + log(level: "debug" | "info" | "warn" | "error", message: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Monitors a running process. + */ + monitorExternalProcess(options: ExternalProcessInfo, callback?: (payload: { uuid: string }) => void, errorCallback?: (reason: string) => void): void; + /** + * Opens the passed URL in the default web browser. + */ + openUrlWithBrowser(url: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * This function call will register a unique id and produce a token. The token can be used to broker an external connection. + */ + registerExternalConnection(uuid: string, callback?: (detail: { + /** + * this will be unique each time + */ + token: string; + /** + * "remote-connection-uuid" + */ + uuid: string; + }) => void, errorCallback?: (reason: string) => void): void; + /** + * Removes the process entry for the passed UUID obtained from a prior call of fin.desktop.System.launchExternalProcess(). + */ + releaseExternalProcess(processUuid: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinSystemEventType, listener: (event: SystemBaseEvent | DesktopIconClickedEvent | IdleStateChangedEvent | MonitorInfoChangedEvent | SessionChangedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Shows the Chrome Developer Tools for the specified window. + */ + showDeveloperTools(uuid: string, name: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Attempt to close an external process. The process will be terminated if it has not closed after the elapsed timeout in milliseconds. + */ + terminateExternalProcess(processUuid: string, timeout: number, killTree: boolean, callback?: (info: { result: "clean" | "terminated" | "failed" }) => void, errorCallback?: (reason: string) => void): void; + terminateExternalProcess(processUuid: string, timeout: number, callback?: (info: { result: "clean" | "terminated" | "failed" }) => void, errorCallback?: (reason: string) => void): void; + /** + * Update the OpenFin Runtime Proxy settings. + */ + updateProxySettings(type: string, address: string, port: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + + } + + interface CacheOptions { + cache?: boolean; + cookies?: boolean; + localStorage?: boolean; + appcache?: boolean; + userData?: boolean; + } + + interface AppAssetInfo { + 'src': string; + 'alias': string; + 'version': string; + 'target': string; + 'args': string; + } + + interface ApplicationInfo { + /** + * true when the application is running. + */ + isRunning: boolean; + /** + * uuid of the application. + */ + uuid: string; + /** + * uuid of the application that launches this application. + */ + parentUuid: string; + } + + interface WindowDetails { + uuid: string; + mainWindow: WindowInfo; + childWindows: WindowInfo[]; + } + + interface WindowInfo { + /** + * name of the child window + */ + name: string; + /** + * top-most coordinate of the child window + */ + top: number; + /** + * right-most coordinate of the child window + */ + right: number; + /** + * bottom-most coordinate of the child window + */ + bottom: number; + /** + * left-most coordinate of the child window + */ + left: number; + } + + interface LogInfo { + /** + * the filename of the log + */ + name: string; + /** + * the size of the log in bytes + */ + size: number; + /** + * the unix time at which the log was created "Thu Jan 08 2015 14:40:30 GMT-0500 (Eastern Standard Time)" + */ + date: string; + } + + interface ProcessInfo { + /** + * the percentage of total CPU usage + */ + cpuUsage?: number; + /** + * the application name + */ + name?: string; + /** + * the current nonpaged pool usage in bytes + */ + nonPagedPoolUsage?: number; + /** + * the number of page faults + */ + pageFaultCount?: number; + /** + * the current paged pool usage in bytes + */ + pagedPoolUsage?: number; + /** + * the total amount of memory in bytes that the memory manager has committed + */ + pagefileUsage?: number; + /** + * the peak nonpaged pool usage in bytes + */ + peakNonPagedPoolUsage?: number; + /** + * the peak paged pool usage in bytes + */ + peakPagedPoolUsage?: number; + /** + * the peak value in bytes of pagefileUsage during the lifetime of this process + */ + peakPagefileUsage?: number; + /** + * the peak working set size in bytes + */ + peakWorkingSetSize?: number; + /** + * the native process identifier + */ + processId?: number; + /** + * the application UUID + */ + uuid?: string; + /** + * the current working set size (both shared and private data) in bytes + */ + workingSetSize?: number; + } + + interface ProxyInfo { + /** + * the configured Proxy Address + */ + proxyAddress: string; + /** + * the configured Proxy port + */ + proxyPort: number; + /** + * Proxy Type + */ + type: string; + } + + interface RvmInfo { + version: string; + "start-time": string; + } + + interface ExternalProcessLaunchInfo { + path?: string; + /** + * Additionally note that the executable found in the zip file specified in appAssets + * will default to the one mentioned by appAssets.target + * If the the path below refers to a specific path it will override this default + */ + alias?: string; + /** + * When using alias; if no arguments are passed then the arguments (if any) + * are taken from the 'app.json' file, from the 'args' parameter + * of the 'appAssets' Object with the relevant 'alias'. + * If 'arguments' is passed as a parameter it takes precedence + * over any 'args' set in the 'app.json'. + */ + arguments?: string; + listener?: (result: { + /** + * "Exited" Or "released" on a call to releaseExternalProcess + */ + topic: string; + /** + * The mapped UUID which identifies the launched process + */ + uuid: string; + /* + * Process exit code + */ + exitCode: number; + }) => void; + certificate?: CertificationInfo; + } + + interface CertificationInfo { + /** + * A hex string with or without spaces + */ + serial?: string; + /** + * An internally tokenized and comma delimited string allowing partial or full checks of the subject fields + */ + subject: string; + /** + * A hex string with or without spaces + */ + publickey?: string; + /** + * A hex string with or without spaces + */ + thumbprint: string; + /** + * A boolean indicating that the certificate is trusted and not revoked + */ + trusted: boolean; + } + + interface ExternalProcessInfo { + pid: number; + listener?: (result: { + /** + * "Exited" Or "released" on a call to releaseExternalProcess + */ + topic: string; + /** + * The mapped UUID which identifies the launched process + */ + uuid: string; + /* + * Process exit code + */ + exitCode: number; + }) => void; + } + + /** + * Window + * A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window. + */ + interface OpenFinWindow { + /** + * Class: Window + * + * new Window(options, callbackopt, errorCallbackopt) + * + * Creates a new OpenFin Window + * + * A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window. + * @param {any} options - The options of the window + * @param {Function} [callback] - Called if the window creation was successful + * @param {number} [callback.successObj] - httpResponseCode + */ + new (options: WindowOptions, callback?: (successObj: { httpResponseCode: number }) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): OpenFinWindow; + /** + * Name of window + */ + name: string; + /** + * Returns an instance of the current window. + * @returns {OpenFinWindow} Current window + */ + getCurrent(): OpenFinWindow; + /** + * Returns the native JavaScript "window" object for the window. This method can only be used by the parent application or the window itself, otherwise it will return undefined. The same Single-Origin-Policy (SOP) rules apply for child windows created by window.open(url) in that the contents of the window object are only accessible if the URL has the same origin as the invoking window. See example below. Also, will not work with fin.desktop.Window objects created with fin.desktop.Window.wrap(). + * @returns {Window} Native window + */ + getNativeWindow(): Window; + /** + * Gets the parent application. + * @returns {OpenFinApplication} Parent application + */ + getParentApplication(): OpenFinApplication; + /** + * Gets the parent window. + */ + getParentWindow(): OpenFinWindow; + /** + * Returns a Window object that wraps an existing window. + */ + wrap(appUuid: string, windowName: string): OpenFinWindow; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinWindowEventType, listener: (event: WindowBaseEvent | WindowAuthRequestedEvent | WindowBoundsEvent | WindowExternalProcessStartedEvent | WindowExternalProcessExited | WindowGroupChangedEvent | WindowHiddenEvent | Window_NavigationRejectedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Performs the specified window transitions + */ + animate(transitions: AnimationTransition, options: AnimationOptions, callback?: (event: any) => void, errorCallback?: (reason: string) => void): void; + /** + * Provides credentials to authentication requests + */ + authenticate(userName: string, password: string, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Removes focus from the window. + */ + blur(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Brings the window to the front of the OpenFin window stack. + */ + bringToFront(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Closes the window. + * @param {force} Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window. + */ + close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Prevents a user from changing a window's size/position when using the window's frame. + * 'disabled-frame-bounds-changing' is generated at the start of and during a user move/size operation. + * 'disabled-frame-bounds-changed' is generated after a user move/size operation. + * The events provide the bounds that would have been applied if the frame was enabled. + * 'frame-disabled' is generated when an enabled frame becomes disabled. + */ + disableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Re-enables user changes to a window's size/position when using the window's frame. + * 'disabled-frame-bounds-changing' is generated at the start of and during a user move/size operation. + * 'disabled-frame-bounds-changed' is generated after a user move/size operation. + * The events provide the bounds that would have been applied if the frame was enabled. + * 'frame-enabled' is generated when a disabled frame has becomes enabled. + */ + enableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Flashes the window’s frame and taskbar icon until the window is activated. + */ + flash(options?: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Gives focus to the window. + */ + focus(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the current bounds (top, left, width, height) of the window. + */ + getBounds(callback?: (bounds: WindowBounds) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array containing wrapped fin.desktop.Windows that are grouped with this window. If a window is not in a group an empty array is returned. Please note that calling window is included in the result array. + */ + getGroup(callback?: (group: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the current settings of the window. + */ + getOptions(callback?: (options: WindowOptions) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets a base64 encoded PNG snapshot of the window. + */ + getSnapshot(callback?: (base64Snapshot: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the current state ("minimized", "maximized", or "restored") of the window. + */ + getState(callback?: (state: "minimized" | "maximized" | "restored") => void, errorCallback?: (reason: string) => void): void; + /** + * Returns the zoom level of the window. + */ + getZoomLevel(callback?: (level: number) => void, errorCallback?: (reason: string) => void): void; + /** + * Hides the window. + */ + hide(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Determines if the window is currently showing. + */ + isShowing(callback?: (showing: boolean) => void, errorCallback?: (reason: string) => void): void; + /** + * Joins the same window group as the specified window. + */ + joinGroup(target: OpenFinWindow, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Leaves the current window group so that the window can be move independently of those in the group. + */ + leaveGroup(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Maximizes the window. + */ + maximize(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Merges the instance's window group with the same window group as the specified window + */ + mergeGroups(target: OpenFinWindow, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Minimizes the window. + */ + minimize(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Moves the window by a specified amount. + */ + moveBy(deltaLeft: number, deltaTop: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Moves the window to a specified location. + */ + moveTo(left: number, top: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinWindowEventType, listener: (event: WindowBaseEvent | WindowAuthRequestedEvent | WindowBoundsEvent | WindowExternalProcessStartedEvent | WindowExternalProcessExited | WindowGroupChangedEvent | WindowHiddenEvent | Window_NavigationRejectedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Resizes the window by a specified amount. + */ + resizeBy(deltaWidth: number, deltaHeight: number, anchor: OpenFinAnchor, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Resizes the window by a specified amount. + */ + resizeTo(width: number, height: number, anchor: OpenFinAnchor, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Restores the window to its normal state (i.e., unminimized, unmaximized). + */ + restore(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Will bring the window to the front of the entire stack and give it focus. + */ + setAsForeground(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sets the window's size and position + */ + setBounds(left: number, top: number, width: number, height: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sets the zoom level of the window. + */ + setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Shows the window if it is hidden. + * @param {force} Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window. + */ + show(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Shows the window if it is hidden at the specified location. If the toggle parameter is set to true, the window will alternate between showing and hiding. + */ + showAt(left: number, top: number, force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Stops the taskbar icon from flashing. + */ + stopFlashing(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Updates the window using the passed options + */ + updateOptions(options: WindowOptions, callback?: () => void, errorCallback?: (reason: string) => void): void; + } + + interface ApplicationBaseEvent { + topic: string; + type: OpenFinApplicationEventType; + uuid: string; + } + + interface TrayIconClickedEvent extends ApplicationBaseEvent { + button: number; // 0 for left, 1 for middle, 2 for right + monitorInfo: MonitorInfo; + x: number; // the cursor x coordinate + y: number; // the cursor y coordinate + } + + interface WindowEvent extends ApplicationBaseEvent { + name: string; + } + + interface WindowAlertRequestedEvent extends WindowEvent { + message: string; + url: string; + } + + interface WindowAuthRequested extends WindowEvent { + authInfo: { + host: string; + isProxy: boolean; + port: number; + realm: string; + scheme: string; + }; + } + + interface WindowNavigationRejectedEvent extends WindowEvent { + sourceName: string; + url: string; + } + + interface WindowEndLoadEvent extends WindowEvent { + documentName: string; + isMain: boolean; + } + + interface MonitorInfoChangedEvent extends MonitorInfo { + topic: "system"; + type: "monitor-info-changed"; + } + + interface MonitorInfo { + nonPrimaryMonitors: MonitorInfoDetail[]; + primaryMonitor: MonitorInfoDetail; + reason: string; + taskbar: { + edge: "left" | "right" | "top" | "bottom", + rect: MontiorCoordinates + }; + topic: "system"; + type: "monitor-info-changed"; + virtualScreen: MontiorCoordinates; + } + + interface MonitorInfoDetail { + availableRect: MontiorCoordinates; + deviceId: string; + displayDeviceActive: boolean; + monitorRect: MontiorCoordinates; + name: string; + } + + interface MontiorCoordinates { + bottom: number; + left: number; + right: number; + top: number; + } + + interface VirtualScreenCoordinates { + left: number; + top: number; + } + + interface SystemBaseEvent { + topic: string; + type: OpenFinSystemEventType; + uuid: string; + } + + interface DesktopIconClickedEvent { + mouse: { + /** + * the left virtual screen coordinate of the mouse + */ + left: number, + /** + * the top virtual screen coordinate of the mouse + */ + top: number + }; + /** + * the number of milliseconds that have elapsed since the system was started, + */ + tickCount: number; + topic: "system"; + type: "desktop-icon-clicked"; + } + + interface IdleStateChangedEvent { + /** + * How long in milliseconds since the user has been idle. + */ + elapsedTime: number; + /** + * true when the user is idle,false when the user has returned; + */ + isIdle: boolean; + topic: "system"; + type: "idle-state-changed"; + } + + interface WindowBaseEvent { + /** + * the name of the window + */ + name: string; + /** + * always window + */ + topic: "window"; + /** + * window event type + */ + type: OpenFinWindowEventType; + /** + * the UUID of the application the window belongs to + */ + uuid: string; + } + + interface WindowAuthRequestedEvent extends WindowBaseEvent { + authInfo: { + host: string; + isProxy: boolean; + port: number; + realm: string; + scheme: string; + }; + } + + interface WindowBoundsEvent extends WindowBaseEvent { + /** + * describes what kind of change occurred. + * 0 means a change in position. + * 1 means a change in size. + * 2 means a change in position and size. + */ + changeType: number; + /** + * true when pending changes have been applied to the window. + */ + deferred: boolean; + /** + * the new height of the window. + */ + height: number; + /** + * the left-most coordinate of the window. + */ + left: number; + /** + * the top-most coordinate of the window. + */ + top: number; + /** + * + */ + type: "bounds-changed" | "bounds-changing" | "disabled-frame-bounds-changed" | "disabled-frame-bounds-changing"; + /** + * the new width of the window. + */ + width: number; + } + + interface WindowExternalProcessStartedEvent extends WindowBaseEvent { + /** + * the process handle uuid + */ + processUuid: string; + type: "external-process-started"; + } + + interface WindowExternalProcessExited extends WindowBaseEvent { + /** + * the process exit code + */ + exitCode: number; + /** + * the process handle uuid + */ + processUuid: string; + type: "external-process-exited"; + } + + interface WindowGroupChangedEvent extends WindowBaseEvent { + /** + * Which group array the window that the event listener was registered on is included in: + * 'source' The window is included in sourceGroup. + * 'target' The window is included in targetGroup. + * 'nothing' The window is not included in sourceGroup nor targetGroup. + */ + memberOf: "source" | "target" | "nothing"; + /** + * The reason this event was triggered. + * 'leave' A window has left the group due to a leave or merge with group. + * 'join' A window has joined the group. + * 'merge' Two groups have been merged together. + * 'disband' There are no other windows in the group. + */ + reason: "leave" | "join" | "merge" | "disband"; + /** + * All the windows in the group the sourceWindow originated from. + */ + sourceGroup: WindowOfGroupInfo[]; + /** + * The UUID of the application the sourceWindow belongs to The source window is the window in which (merge/join/leave)group(s) was called. + */ + sourceWindowAppUuid: string; + /** + * the name of the sourcewindow.The source window is the window in which(merge / join / leave) group(s) was called. + */ + sourceWindowName: string; + /** + * All the windows in the group the targetWindow orginated from + */ + targetGroup: WindowOfGroupInfo[]; + /** + * The UUID of the application the targetWindow belongs to. The target window is the window that was passed into (merge/join) group(s). + */ + targetWindowAppUuid: string; + /** + * The name of the targetWindow. The target window is the window that was passed into (merge/join) group(s). + */ + targetWindowName: string; + type: "group-changed"; + } + + interface WindowOfGroupInfo { + /** + * The UUID of the application this window entry belongs to. + */ + appUuid: string; + /** + * The name of this window entry. + */ + windowName: string; + } + + interface WindowHiddenEvent extends WindowBaseEvent { + /** + * What action prompted the close. + * The reasons are: "hide", "hide-on-close" + */ + reason: "hide" | "hide-on-close"; + type: "hidden"; + } + + interface Window_NavigationRejectedEvent { + name: string; + /** + * source of navigation window name + */ + sourceName: string; + topic: "navigation-rejected"; + /** + * Url that was not reached "http://blocked-content.url" + */ + url: string; + /** + * the UUID of the application the window belongs to. + */ + uuid: string; + } + + interface AnimationTransition { + opacity?: { + /** + * This value is clamped from 0.0 to 1.0 + */ + opacity: number; + /** + * The total time in milliseconds this transition should take. + */ + duration: number; + /** + * Treat 'opacity' as absolute or as a delta. Defaults to false. + */ + relative?: boolean; + }; + position?: { + /** + * Defaults to the window's current left position in virtual screen coordinates. + */ + left?: number; + /** + * Defaults to the window's current top position in virtual screen coordinates. + */ + top?: number; + /** + * The total time in milliseconds this transition should take. + */ + duration: number; + /** + * Treat 'left' and 'top' as absolute or as deltas. Defaults to false. + */ + relative?: boolean; + }; + size?: { + /** + * Optional if height is present. Defaults to the window's current width. + */ + width?: number; + /** + * Optional if width is present. Defaults to the window's current height. + */ + height?: number; + /** + * The total time in milliseconds this transition should take. + */ + duration: number; + /** + * Treat 'width' and 'height' as absolute or as deltas. Defaults to false. + */ + relative?: boolean; + }; + } + + interface AnimationOptions { + /** + * This option interrupts the current animation. When false it pushes this animation onto the end of the animation queue. + */ + interrupt?: boolean; + /** + * Transition effect. Defaults to 'ease-in-out'. + */ + tween?: OpenFinTweenType; + } + + interface WindowBounds { + /** + * the height of the window. + */ + height: number; + /** + * left-most coordinate of the window. + */ + left: number; + /** + * top-most coordinate of the window. + */ + top: number; + /** + * the width of the window. + */ + width: number; + } + + interface SessionChangedEvent { + /** + * the action that triggered this event: + */ + reason: "lock" + | "unlock" + | "remote-connect" + | "remote-disconnect" + | "unknown"; + topic: "system"; + type: "session-changed"; + } + + type OpenFinTweenType = "linear" + | "ease-in" + | "ease-out" + | "ease-in-out" + | "ease-in-quad" + | "ease-out-quad" + | "ease-in-out-quad" + | "ease-in-cubic" + | "ease-out-cubic" + | "ease-in-out-cubic" + | "ease-out-bounce" + | "ease-in-back" + | "ease-out-back" + | "ease-in-out-back" + | "ease-in-elastic" + | "ease-out-elastic" + | "ease-in-out-elastic"; + + type OpenFinApplicationEventType = "closed" + | "connected" + | "crashed" + | "initialized" + | "manifest-changed" + | "not-responding" + | "out-of-memory" + | "responding" + | "run-requested" + | "started" + | "tray-icon-clicked" + | "window-alert-requested" + | "window-auth-requested" + | "window-closed" + | "window-created" + | "window-end-load" + | "window-navigation-rejected" + | "window-show-requested" + | "window-start-load"; + + type OpenFinExternalApplicationEventType = "connected" + | "disconnected"; + + type OpenFinSystemEventType = "application-closed" + | "application-crashed" + | "application-created" + | "application-started" + | "desktop-icon-clicked" + | "idle-state-changed" + | "monitor-info-changed" + | "session-changed"; + + type OpenFinWindowEventType = "auth-requested" + | "blurred" + | "bounds-changed" + | "bounds-changing" + | "close-requested" + | "closed" + | "disabled-frame-bounds-changed" + | "disabled-frame-bounds-changing" + | "embedded" + | "external-process-exited" + | "external-process-started" + | "focused" + | "frame-disabled" + | "frame-enabled" + | "group-changed" + | "hidden" + | "initialized" + | "maximized" + | "minimized" + | "navigation-rejected" + | "restored" + | "show-requested" + | "shown"; + + type OpenFinAnchor = "top-left" + | "top-right" + | "bottom-left" + | "bottom-right"; +} \ No newline at end of file diff --git a/openfin/openfin-tests.ts b/openfin/openfin-tests.ts new file mode 100644 index 0000000000..7aa2930089 --- /dev/null +++ b/openfin/openfin-tests.ts @@ -0,0 +1,718 @@ + +function test_application() { + let application: fin.OpenFinApplication; + // constructor + application = new fin.desktop.Application({ + url: "application.html", + uuid: "74BED629-2D8E-4141-8582-73E364BDFA74", + name: "Application Name", + mainWindowOptions: { + defaultHeight: 600, + defaultWidth: 800, + defaultTop: 300, + defaultLeft: 300, + autoShow: true + } + }, function (successObj) { + console.log("Application successfully created, HTTP response code:", successObj); + application.run(); + }, function (error) { + console.log("Error creating application:", error); + }); + // getCurrent + application = fin.desktop.Application.getCurrent(); + // wrap + application = fin.desktop.Application.wrap("454C7F31-A915-4EA2-83F2-CFA655453C52"); + // getWindow + application.getWindow(); + // addEventListener + application.addEventListener("closed", function (event) { + console.log("The application has closed"); + }, function () { + console.log("The registration was successful"); + }, function (reason) { + console.log("failure: " + reason); + }); + // close + application.close(); + // getChildWindows + application.getChildWindows(function (children) { + children.forEach(function (childWindow) { + console.log("Showing child: " + childWindow.name); + childWindow.show(); + }); + }); + // getGroups + application.getGroups(function (allGroups) { + console.log("There are a total of " + allGroups.length + " groups."); + + var groupCounter = 1; + allGroups.forEach(function (windowGroup) { + console.log("Group " + groupCounter + " contains " + + windowGroup.length + " windows."); + ++groupCounter; + }); + }); + // getManifest + application.getManifest(function (manifest) { + console.log("Application manifest:"); + console.log(manifest); + }); + // getParentUuid + application.getParentUuid(function (parentUuid) { + console.log("UUID of parent application:"); + console.log(parentUuid); + }); + // getShortcuts + application.getShortcuts(function (config) { + console.log("Desktop shortcut is enabled: ", config.desktop); + console.log("Start Menu shortcut is enabled: ", config.startMenu); + console.log("System Startup shortcut is enabled: ", config.systemStartup); + }); + // isRunning + application.isRunning(function (running) { + console.log("the application is", running ? "running" : "not running"); + }); + // registerCustomData + application.registerCustomData({ + someData: "this is custom" + }, function () { + console.log("You will not read this."); + }, function (err) { + console.log("failure:", err); + }); + // removeEventListener + let previousCallback = function (event: fin.WindowEvent) { }; + application.removeEventListener("closed", previousCallback, function () { + console.log("The unregistration was successful"); + }, function (err) { + console.log("failure:", err); + }); + // removeTrayIcon + application.removeTrayIcon(function () { + console.log("Removed the tray icon."); + }, function (err) { + console.log("failure:", err); + }); + // restart + application.restart(function () { + console.log("You will not read this."); + }, function (err) { + console.log("failure:", err); + }); + // schedule restart + application.scheduleRestart(function () { + console.log("You will not read this."); + }, function (err) { + console.log("failure:", err); + }); + // setShortcuts + application.setShortcuts({ + desktop: true, + startMenu: false, + systemStartup: true + }, function () { + console.log("Successfully set new shortcut states"); + }, function (error) { + console.log("Failed to set new shortcut states. Error: ", error); + }); + // setTrayIcon + application.setTrayIcon("https://developer.openf.in/download/openfin.png", function (clickInfo) { + console.log("The mouse has clicked at (" + clickInfo.x + "," + clickInfo.y + ")"); + }); + // terminate + application.terminate(); + // wait + application.addEventListener("not-responding", function () { + console.log("waiting for hung application"); + application.wait(); + }); +} + +function test_external_application() { + let externalApp: fin.OpenFinExternalApplication; + // wrap + externalApp = fin.desktop.ExternalApp.wrap('my-uuid'); + // addEventListener + externalApp.addEventListener('connected', () => { + console.log('external app connected'); + }, () => { + console.log('The registration was successful'); + }, (reason, err) => { + console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`); + }); + // removeEventListener + let previousCallback = function () { }; + externalApp.removeEventListener('connected', previousCallback, () => { + console.log('The unregistration was successful'); + }, (reason, err) => { + console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`); + }); +} + +function test_inter_application_bus() { + // addSubscribeListener + fin.desktop.InterApplicationBus.addSubscribeListener(function (uuid, topic, name) { + console.log("The application " + uuid + " has subscribed to " + topic); + }); + // addUnsubscribeListener + fin.desktop.InterApplicationBus.addUnsubscribeListener(function (uuid, topic, name) { + console.log("The application " + uuid + " has unsubscribed to " + topic); + }); + // removeSubscribeListener + let aRegisteredListener = function (uuid: string, topic: string, name: string) { }; + fin.desktop.InterApplicationBus.removeSubscribeListener(aRegisteredListener); + // removeUnsubscribeListener + fin.desktop.InterApplicationBus.removeUnsubscribeListener(aRegisteredListener); + // publish + fin.desktop.InterApplicationBus.publish("a topic", { + field1: "value1", + field2: "value2" + }); + // send + fin.desktop.InterApplicationBus.send("an application's uuid", "a topic", { + field1: "value1", + field2: "value2" + }); + // subscribe + fin.desktop.InterApplicationBus.subscribe("*", "a topic", function (message, uuid, name) { + console.log("The application " + uuid + " sent this message: " + message); + }); + // unsubscribe + let aRegisteredMessageListener = function (message: any, senderUuid: string) { + console.log(message, senderUuid); + }; + fin.desktop.InterApplicationBus.unsubscribe("*", "a topic", aRegisteredMessageListener); +} + +function test_notification() { + let notification: fin.OpenFinNotification; + // getCurrent + notification = fin.desktop.Notification.getCurrent(); + // close + notification.close(); + // sendMessage + notification = new fin.desktop.Notification({ + duration: 10, + url: "http://localhost:5000/Account/Register", + message: "Hello", + onShow: () => { }, + //onClose: () => { }, + onDismiss: () => { }, + //onClick: () => { }, + onMessage: () => { }, + onError: () => { } + }); + // sendMessageToApplication + notification.sendMessageToApplication("some message"); +} + +function test_system() { + // addEventListener + fin.desktop.System.addEventListener('monitor-info-changed', function (event) { + console.log("The monitor information has changed to: ", event); + }, function () { + console.log("The registration was successful"); + }, function (err) { + console.log("failure: " + err); + }); + // clearCache + fin.desktop.System.clearCache({ + cache: true, + cookies: true, + localStorage: true, + appcache: true, + userData: true + }); + // deleteCacheOnExit + fin.desktop.System.deleteCacheOnExit(function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // downloadAsset + let dirAppAsset = { + 'src': 'http://local:8000/dir.zip', + 'alias': 'dirApp', + 'version': '1.23.24', + 'target': 'dir.bat', + 'args': '' + }; + fin.desktop.System.downloadAsset(dirAppAsset, progress => { + let downloadedPercent = Math.floor((progress.downloadedBytes / progress.totalBytes) * 100); + console.log(`Downloaded ${downloadedPercent}%`); + }, p => { + console.log(`Downlod complete, can be found on ${p.path}`); + //lets launch our application asset. + //launchDirApp(); + }, (reason, err) => { + console.log(reason, err); + }); + // exit + fin.desktop.System.exit(function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // getAllApplications + fin.desktop.System.getAllApplications(function (applicationInfoList) { + applicationInfoList.forEach(function (applicationInfo) { + console.log("Showing information for application with uuid: " + + applicationInfo.uuid); + console.log("isRunning: ", applicationInfo.isRunning); + }); + }); + // getAllExternalApplications + fin.desktop.System.getAllExternalApplications(externalAppsInfoList => { + externalAppsInfoList.forEach(appInfo => { + console.log(`External app connected to the runtime with UUID ${appInfo.uuid}`); + }); + }); + // getAllWindows + fin.desktop.System.getAllWindows(function (windowInfoList) { + windowInfoList.forEach(function (windowInfo) { + console.log("Showing information for application with uuid: ", windowInfo.uuid); + console.log("Main window: ", windowInfo.mainWindow); + console.log("Child windows: ", windowInfo.childWindows); + }); + }); + // getCommandLineArguments + fin.desktop.System.getCommandLineArguments(function (args) { + console.log("The command line arguments are " + args); + }); + // getDeviceId + fin.desktop.System.getDeviceId(function (id) { + console.log("The id of the device is: " + id); + }); + // getEnvironmentVariable + fin.desktop.System.getEnvironmentVariable("APPDATA", function (variable) { + console.log("this is the APPDATA value", variable); + }); + // getLog + fin.desktop.System.getLog('debug-2015-01-08-22-27-53.log', function (log) { + console.log(log); + }); + // getLogList + fin.desktop.System.getLogList(function (logList) { + logList.forEach(function (logInfo) { + console.log("The filename of the log is " + + logInfo.name + ", the size is " + + logInfo.size + ", and the date of creation is " + + logInfo.date); + }); + }); + // getMonitorInfo + fin.desktop.System.getMonitorInfo(function (monitorInfo) { + console.log("This object contains information about all monitors: ", monitorInfo); + }); + // getMousePosition + fin.desktop.System.getMousePosition(function (mousePosition) { + console.log("The mouse is located at left: " + mousePosition.left + ", top: " + mousePosition.top); + }); + // getProcessList + fin.desktop.System.getProcessList(function (list) { + list.forEach(function (process) { + console.log("UUID: " + process.uuid + ", Application Name: " + process.name); + }); + }); + // getProxySettings + fin.desktop.System.getProxySettings(function (proxy) { + console.log(proxy); + }); + // getRvmInfo + fin.desktop.System.getRvmInfo(function (rvmInfoObject) { + console.log("RVM version:", rvmInfoObject.version); + console.log("RVM has been running since:", rvmInfoObject["start-time"]); + }, function (err) { + console.log("Failed to get rvm info, error message:", err); + }); + // getVersion + fin.desktop.System.getVersion(function (version) { + console.log("The version is " + version); + }); + // launchExternalProcess + fin.desktop.System.launchExternalProcess({ + path: "notepad", + arguments: "", + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // + fin.desktop.System.launchExternalProcess({ + //Additionally note that the executable found in the zip file specified in appAssets + //will default to the one mentioned by appAssets.target + //If the the path below refers to a specific path it will override this default + alias: "myApp", + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // + fin.desktop.System.launchExternalProcess({ + alias: "myApp", + arguments: "e f g", + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // + fin.desktop.System.launchExternalProcess({ + path: "C:\Users\ExampleUser\AppData\Local\OpenFin\OpenFinRVM.exe", + arguments: "--version", + certificate: { + trusted: true, + subject: 'O=OpenFin INC., L=New York, S=NY, C=US', + thumbprint: '‎3c a5 28 19 83 05 fe 69 88 e6 8f 4b 3a af c5 c5 1b 07 80 5b' + }, + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // log + fin.desktop.System.log("info", "An example log message", function () { + console.log("message successfully logged"); + }, function (err) { + console.log(err); + }); + // monitorExternalProcess + fin.desktop.System.monitorExternalProcess({ + pid: 2508, + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log("The process is now being monitored: ", payload.uuid); + }, function (error) { + console.log("Error:", error); + }); + // openUrlWithBrowser + fin.desktop.System.openUrlWithBrowser("https://developer.openf.in/", function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // registerExternalConnection + fin.desktop.System.registerExternalConnection("remote-connection-uuid", function () { + console.log(arguments); + }); + // releaseExternalProcess + fin.desktop.System.launchExternalProcess({ + path: "notepad", + arguments: "", + listener: function (result) { + console.log("The exit code", result.exitCode); + } + }, function (result) { + console.log("Result UUID is " + result.uuid); + + //release it. + fin.desktop.System.releaseExternalProcess(result.uuid, function () { + console.log("Process has been unmapped!"); + }, function (reason) { + console.log("failure: " + reason); + }); + }); + // removeEventListener + let aRegisteredListener = (event: fin.SystemBaseEvent) => { }; + fin.desktop.System.removeEventListener("monitor-info-changed", aRegisteredListener, function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // showDeveloperTools + fin.desktop.System.showDeveloperTools("uuid", "name", function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // terminateExternalProcess + fin.desktop.System.launchExternalProcess({ + // notepad is in the system’s PATH + path: "notepad", + arguments: "", + listener: function (result) { + console.log("The exit code", result.exitCode); + } + }, function (result) { + console.log("Result UUID is " + result.uuid); + + // Attempt to close the process. Terminate after 4 seconds if it + // has not done so. + fin.desktop.System.terminateExternalProcess(result.uuid, 4000, function (info) { + console.log("Termination result " + info.result); + }, function (reason) { + console.log("failure: " + reason); + }); + }); + // updateProxySettings + fin.desktop.System.updateProxySettings("type", "proxyAddress", 8080, function () { + console.log('success'); + }, function (err) { + console.log(err); + }); +} + +function test_system_clipboard() { + // availableFormats + fin.desktop.System.Clipboard.availableFormats(null, formats => { + formats.forEach(format => console.log(`The format ${format} is available to read`)); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // readHtml + fin.desktop.System.Clipboard.readHtml(null, html => { + console.log(`This is the html from the clipboard: ${html}`); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // readRtf + fin.desktop.System.Clipboard.readRtf(null, rtf => { + console.log(`This is the rtf from the clipboard: ${rtf}`); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // readText + fin.desktop.System.Clipboard.readText(null, text => { + console.log(`This is the text from the clipboard: ${text}`); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // write + fin.desktop.System.Clipboard.write({ + text: 'Hello Text!', + html: '

Hello Html

', + rtf: 'Hello Rtf' + }, null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // writeHtml + fin.desktop.System.Clipboard.writeHtml('

Hello World

', null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // writeRtf + fin.desktop.System.Clipboard.writeRtf('Hello World!', null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // writeText + fin.desktop.System.Clipboard.writeText('Hello World', null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); +} + +function test_window() { + let finWindow: fin.OpenFinWindow; + // constructor + finWindow = new fin.desktop.Window({ + name: "childWindow", + url: "child.html", + defaultWidth: 320, + defaultHeight: 320, + defaultTop: 10, + defaultLeft: 300, + frame: false, + resizable: false, + state: "normal" + }, function () { + var _win = finWindow.getNativeWindow(); + _win.addEventListener("DOMContentLoaded", function () { finWindow.show(); }); + }, function (error) { + console.log("Error creating window:", error); + }); + // getCurrent + finWindow = fin.desktop.Window.getCurrent(); + // getNativeWindow + let nativeWindow: Window; + nativeWindow = finWindow.getNativeWindow(); + // getParentApplication + let parentApp: fin.OpenFinApplication; + parentApp = finWindow.getParentApplication(); + // getParentWindow + let parentFinWindow: fin.OpenFinWindow; + parentFinWindow = finWindow.getParentWindow(); + // wrap + finWindow = fin.desktop.Window.wrap("uuid", "name"); + // addEventListener + finWindow.addEventListener("bounds-changed", function (event) { + console.log("The window has been moved or resized"); + }, function () { + console.log("The registration was successful"); + }, function (reason) { + console.log("failure:" + reason); + }); + // animate + finWindow.animate({ + opacity: { + opacity: 0.15, + duration: 1000 + }, + position: { + left: 10, + top: 10, + duration: 3000 + } + }, { + interrupt: false + }, function (evt) { + // Callback will only fire after both "opacity" and "position" have finished animating. + }); + // authenticate + finWindow.addEventListener('auth-requested', evt => { + finWindow.authenticate('userName', 'P@assw0rd', () => { }, (reason, err) => { + console.log("failure:", err); + }); + }); + // blur + finWindow.blur(); + // bringToFront + finWindow.bringToFront(); + // close + finWindow.close(); + // disableFrame + finWindow.disableFrame(); + // enableFrame + finWindow.enableFrame(); + // flash + finWindow.flash(); + // focus + finWindow.focus(); + // getBounds + finWindow.getBounds(function (bounds) { + console.log("top: " + bounds.top + + "left: " + bounds.left + + "height: " + bounds.height + + "width: " + bounds.width); + }); + // getOptions + finWindow.getOptions(function (options) { + console.log(options); + }); + // getSnapshot + finWindow.getSnapshot(function (base64Snapshot) { + console.log("data:image/png;base64," + base64Snapshot); + }); + // getState + finWindow.getState(function (state) { + console.log("state: " + state); + }); + // getZoomLevel + finWindow.getZoomLevel(function (level) { + console.log("zoom level: " + level); + }, function (error) { + console.log('error:', error); + }); + // hide + finWindow.hide(); + // isShowing + finWindow.isShowing(function (showing) { + console.log("the window is " + (showing ? "showing" : "hidden")); + }); + // joinGroup + let secondWindow = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "secondWindow", + autoShow: true + }, function () { + // When mainWindow moves or is moved, secondWindow moves by the same amount + secondWindow.joinGroup(finWindow); + }); + // leaveGroup + secondWindow = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "secondWindow", + autoShow: true + }, function () { + // When finWindow moves or is moved, secondWindow moves by the same amount + secondWindow.joinGroup(finWindow, function () { + //once we are in the group, lets leave it. + secondWindow.leaveGroup(); + }); + }); + // maximize + finWindow.maximize(); + // mergeGroups + { + let finWindowOne = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowOne", + autoShow: true + }); + let finWindowTwo = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowTwo", + autoShow: true + }); + let finWindowThree = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowThree", + autoShow: true + }); + let finWindowFour = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowFour", + autoShow: true + }); + // When finWindowOne moves or is moved, finWindowTwo moves by the same amount + finWindowOne.joinGroup(finWindowTwo); + // When finWindowThree moves or is moved, finWindowFour moves by the same amount + finWindowThree.joinGroup(finWindowFour); + // finWindowOne, finWindowTwo, finWindowThree, and finWindowFour now move together in the same group + finWindowOne.mergeGroups(finWindowThree); + } + // minimize + finWindow.minimize(); + // moveBy + finWindow.moveBy(10, 10); + // moveTo + finWindow.moveTo(100, 200); + // removeEventListener + let aRegisteredListener = (event: fin.WindowBaseEvent) => { }; + finWindow.removeEventListener("bounds-changed", aRegisteredListener); + // resizeBy + finWindow.resizeBy(10, 10, "top-right"); + // resizeTo + finWindow.resizeTo(10, 10, "top-right"); + // restore + finWindow.restore(); + // setAsForeground + finWindow.setAsForeground(); + // setBounds + finWindow.setBounds(100, 200, 400, 400); + // setZoomLevel + finWindow.setZoomLevel(10); + // show + finWindow.show(); + // showAt + finWindow.showAt(10, 10, false); + // stopFlashing + finWindow.stopFlashing(); + // updateOptions + finWindow.updateOptions({ + frame: false, + maxWidth: 500 + }); +} \ No newline at end of file diff --git a/openfin/tsconfig.json b/openfin/tsconfig.json new file mode 100644 index 0000000000..8785bdb90f --- /dev/null +++ b/openfin/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "openfin-tests.ts" + ] +} diff --git a/openfin/tslint.json b/openfin/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/openfin/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From b24d2ab7d9003eff940302e77edec81a2375c117 Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Thu, 2 Feb 2017 21:14:23 +0100 Subject: [PATCH 002/258] rename language to culture in numbro --- numbro/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/numbro/index.d.ts b/numbro/index.d.ts index ccb0892a0d..55234aad81 100644 --- a/numbro/index.d.ts +++ b/numbro/index.d.ts @@ -24,7 +24,7 @@ interface Numbro { (value?: any): Numbro; version: string; isNumbro: boolean; - language(key: string, values?: NumbroLanguage): Numbro; + culture(key: string, values?: NumbroLanguage): Numbro; zeroFormat(format: string): string; clone(): Numbro; format(inputString?: string): string; From d09124c0dadba0706409036d1b2948ee5d08496f Mon Sep 17 00:00:00 2001 From: Olmo del Corral Date: Sun, 5 Feb 2017 20:34:10 +0100 Subject: [PATCH 003/258] remove numbro and add it to notNeededPackages.json --- notNeededPackages.json | 6 ++++++ numbro/index.d.ts | 49 ------------------------------------------ numbro/numbro-tests.ts | 43 ------------------------------------ numbro/tsconfig.json | 22 ------------------- 4 files changed, 6 insertions(+), 114 deletions(-) delete mode 100644 numbro/index.d.ts delete mode 100644 numbro/numbro-tests.ts delete mode 100644 numbro/tsconfig.json diff --git a/notNeededPackages.json b/notNeededPackages.json index e671ef4523..ef4e4f7f85 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -5,6 +5,12 @@ "typingsPackageName": "moment", "sourceRepoURL": "https://github.com/moment/moment", "asOfVersion": "2.13.0" + }, + { + "libraryName": "Numbro", + "typingsPackageName": "numbro", + "sourceRepoURL": "https://github.com/foretagsplatsen/numbro/", + "asOfVersion": "1.9.3" }, { "libraryName": "ng-table", diff --git a/numbro/index.d.ts b/numbro/index.d.ts deleted file mode 100644 index 55234aad81..0000000000 --- a/numbro/index.d.ts +++ /dev/null @@ -1,49 +0,0 @@ -// Type definitions for Numbro.js -// Project: https://github.com/foretagsplatsen/numbro -// Definitions by: Vincent Bortone -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface NumbroLanguage { - delimiters: { - thousands: string; - decimal: string; - }; - abbreviations: { - thousand: string; - million: string; - billion: string; - trillion: string; - }; - ordinal(num: number): string; - currency: { - symbol: string; - }; -} - -interface Numbro { - (value?: any): Numbro; - version: string; - isNumbro: boolean; - culture(key: string, values?: NumbroLanguage): Numbro; - zeroFormat(format: string): string; - clone(): Numbro; - format(inputString?: string): string; - formatCurrency(inputString?: string): string; - unformat(inputString: string): number; - value(): number; - valueOf(): number; - set (value: any): Numbro; - add(value: any): Numbro; - subtract(value: any): Numbro; - multiply(value: any): Numbro; - divide(value: any): Numbro; - difference(value: any): number; -} - -declare var numbro: Numbro; - -declare module "numbro" { - - export = numbro; - -} diff --git a/numbro/numbro-tests.ts b/numbro/numbro-tests.ts deleted file mode 100644 index 5b5b762353..0000000000 --- a/numbro/numbro-tests.ts +++ /dev/null @@ -1,43 +0,0 @@ - - -var valueFormat: string = numbro(1000).format('0,0'); -// '1,000' - -var valueUnformat: number = numbro().unformat('($10,000.00)'); -// '-10000' - -var value3: Numbro = numbro(1000); -var added: Numbro = value3.add(10); -// 1010 - -var value4: Numbro = numbro(1000); -var formatValue4a: string = value4.format('0,0'); -// '1,000' -var formatValue4b: number = value4.value(); -// 1000 - -var value5: Numbro = numbro(); -value5.set(1000); -var value5Num: number = value5.value(); -// 1000 - -var value6: Numbro = numbro(1000); -var value: number = 100; -var difference = value6.difference(value); -// 900 - -var value7: Numbro = numbro(0); -numbro.zeroFormat('N/A'); -var zeroString: string = value7.format('0.0'); -// 'N/A' - -var a: Numbro = numbro(1000); -var b: Numbro = numbro(a); -var c: Numbro = a.clone(); - -var aVal: number = a.set(2000).value(); -// 2000 -var bVal: number = b.value(); -// 1000 -var cVal: number = c.add(10).value(); -// 1010 diff --git a/numbro/tsconfig.json b/numbro/tsconfig.json deleted file mode 100644 index 4a55ffe0ab..0000000000 --- a/numbro/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "numbro-tests.ts" - ] -} \ No newline at end of file From ec4b986bc8641599b223a79efaebafe196aeb2e8 Mon Sep 17 00:00:00 2001 From: Alexey Svetliakov Date: Tue, 14 Feb 2017 01:49:54 +0100 Subject: [PATCH 004/258] enzyme: return any as state for shallow() and mount() --- enzyme/enzyme-tests.tsx | 14 ++++++++++++++ enzyme/index.d.ts | 4 ++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/enzyme/enzyme-tests.tsx b/enzyme/enzyme-tests.tsx index 82a8dc9822..c7323766f7 100644 --- a/enzyme/enzyme-tests.tsx +++ b/enzyme/enzyme-tests.tsx @@ -37,6 +37,13 @@ namespace ShallowWrapperTest { elementWrapper: ShallowWrapper, {}>, statelessWrapper: ShallowWrapper; + function test_props_state_inferring() { + let wrapper: ShallowWrapper; + wrapper = shallow(); + wrapper.state().stateProperty; + wrapper.props().stringProp.toUpperCase(); + } + function test_shallow_options() { shallow(, { context: { @@ -337,6 +344,13 @@ namespace ReactWrapperTest { elementWrapper: ReactWrapper, {}>, statelessWrapper: ReactWrapper; + function test_prop_state_inferring() { + let wrapper: ReactWrapper; + wrapper = mount(); + wrapper.state().stateProperty; + wrapper.props().stringProp.toUpperCase(); + } + function test_unmount() { reactWrapper = reactWrapper.unmount(); } diff --git a/enzyme/index.d.ts b/enzyme/index.d.ts index 66c86d1166..184b20ec57 100644 --- a/enzyme/index.d.ts +++ b/enzyme/index.d.ts @@ -541,14 +541,14 @@ export interface MountRendererProps { * @param node * @param [options] */ -export function shallow(node: ReactElement

, options?: ShallowRendererProps): ShallowWrapper; +export function shallow(node: ReactElement

, options?: ShallowRendererProps): ShallowWrapper; /** * Mounts and renders a react component into the document and provides a testing wrapper around it. * @param node * @param [options] */ -export function mount(node: ReactElement

, options?: MountRendererProps): ReactWrapper; +export function mount(node: ReactElement

, options?: MountRendererProps): ReactWrapper; /** * Render react components to static HTML and analyze the resulting HTML structure. From b983469a15b61bf259d37d04de304273dcbdc3ef Mon Sep 17 00:00:00 2001 From: sqwk Date: Thu, 16 Feb 2017 10:12:42 +0100 Subject: [PATCH 005/258] Initial Commit --- lowdb/index.d.ts | 536 +++++++++++++++++++++++++++++++++++++++++++ lowdb/lowdb-tests.ts | 12 + lowdb/tsconfig.json | 23 ++ 3 files changed, 571 insertions(+) create mode 100644 lowdb/index.d.ts create mode 100644 lowdb/lowdb-tests.ts create mode 100644 lowdb/tsconfig.json diff --git a/lowdb/index.d.ts b/lowdb/index.d.ts new file mode 100644 index 0000000000..ddd20e89ed --- /dev/null +++ b/lowdb/index.d.ts @@ -0,0 +1,536 @@ +declare module 'lowdb' { + interface PromiseLike { + + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; + } + + interface StringRepresentable { + toString(): string; + } + + interface List { + [index: number]: T; + length: number; + } + + interface Dictionary { + [index: string]: T; + } + + interface DictionaryIterator { + (value: T, key?: string, collection?: Dictionary): TResult; + } + + interface ListIterator { + (value: T, index: number, collection: List): TResult; + } + + interface StringIterator { + (char: string, index?: number, string?: string): TResult; + } + + interface MixinOptions { + chain?: boolean; + } + + interface LoDashWrapper { + + /** + * @see _.has + */ + has(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; + + /** + * @see _.hasIn + */ + hasIn(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source: TSource + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source1: TSource1, + source2: TSource2 + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source1: TSource1, + source2: TSource2, + source3: TSource3 + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4 + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign(): LoDashWrapper; + + /** + * @see _.assign + */ + assign(...otherArgs: any[]): LoDashWrapper; + + /** + * @see _.cloneDeep + */ + cloneDeep(): LoDashWrapper; + + /** + * @see _.cloneDeep + */ + cloneDeep(): LoDashWrapper; + + /** + * @see _.cloneDeep + */ + cloneDeepWith(customizer: (value: any) => any): LoDashWrapper[]; + + /** + * @see _.cloneDeep + */ + cloneDeepWith(customizer: (value: any) => any): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + source2: S2, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + source2: S2, + source3: S3, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + source2: S2, + source3: S3, + source4: S4, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults(): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults(...sources: {}[]): LoDashWrapper; + + /** + * @see _.get + */ + get(object: Object, + path: string | number | boolean | Array, + defaultValue?: TResult + ): LoDashWrapper; + + /** + * @see _.get + */ + get(path: string | number | boolean | Array, + defaultValue?: TResult + ): LoDashWrapper; + + + /** + * @see _.mixin + */ + mixin( + source: Dictionary, + options?: MixinOptions + ): LoDashWrapper; + + /** + * @see _.mixin + */ + mixin( + options?: MixinOptions + ): LoDashWrapper; + + /** + * @see _.set + */ + set( + path: StringRepresentable | StringRepresentable[], + value: any + ): LoDashWrapper; + + /** + * @see _.set + */ + set( + path: StringRepresentable | StringRepresentable[], + value: V + ): LoDashWrapper; + + /** + * @see _.find + */ + find( + predicate?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.find + */ + find( + predicate?: string, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.find + */ + find( + predicate?: TObject + ): LoDashWrapper; + + /** + * @see _.find + */ + filter( + predicate?: TObject + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate: string, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate: ListIterator | DictionaryIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate?: StringIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter(predicate: W): LoDashWrapper; + /** + * @see _.map + */ + map( + iteratee?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.map + */ + map( + iteratee?: string + ): LoDashWrapper; + + /** + * @see _.map + */ + map( + iteratee?: TObject + ): LoDashWrapper; + /** + * @see _.map + */ + map( + iteratee?: ListIterator | DictionaryIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.range + */ + range( + end?: number, + step?: number + ): LoDashWrapper; + + /** + * @see _.rangeRight + */ + rangeRight( + end?: number, + step?: number + ): LoDashWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: string, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: W + ): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy( + iteratee?: ListIterator + ): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(iteratee: string): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(whereValue: W): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(...iteratees: (ListIterator | Object | string)[]): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(iteratees: (ListIterator | string | Object)[]): LoDashWrapper; + + /** + * @see _.slice + */ + slice( + start?: number, + end?: number + ): LoDashWrapper; + + /** + * @see _.size + */ + size(): LoDashWrapper; + + /** + * @see _.take + */ + take(n?: number): LoDashWrapper; + + /** + * @see _.times + */ + times( + iteratee: (num: number) => TResult + ): LoDashWrapper; + + /** + * @see _.times + */ + times(): LoDashWrapper; + + /** + * @see _.uniqueId + */ + uniqueId(): LoDashWrapper; + + value(): T; + + pop(): T; + push(...items: T[]): LoDashWrapper; + shift(): T; + sort(compareFn?: (a: T, b: T) => number): LoDashWrapper; + splice(start: number): LoDashWrapper; + splice(start: number, deleteCount: number, ...items: any[]): LoDashWrapper; + unshift(...items: T[]): LoDashWrapper; + } + + interface Storage { + /** + * Reads the database. + * + * @param source The source location. + * @param deserialize The deserialize function to apply. + * @return Returns a promise with the deserialized db object. + */ + read?(source: string, deserialize: any): PromiseLike + /** + * Reads the database. + * + * @param source The source location. + * @param deserialize The deserialize function to apply. + * @return Returns the deserialized db object. + */ + read?(source: string, deserialize: any): Object + /** + * Writes to the database. + * + * @param destination The destination location. + * @param obj The object to write. + * @param serialize The serialize function to apply. + */ + write?(destination: string, obj: any, serialize: any): void + /** + * Writes to the database. + * + * @param destination The destination location. + * @param obj The object to write. + * @param serialize The serialize function to apply. + */ + write?(destination: string, obj: any, serialize: any): PromiseLike + } + + interface Format { + /** + * Writes to the database. + * + * @param obj The object to serialize. + * @return Returns the serialized object string. + */ + serialize(obj: Object): string + /** + * Writes to the database. + * + * @param data The object to deserialize. + * @return Returns the deserialized object. + */ + deserialize(data: string): Object + } + + interface Options { + /** + * The custom "storage" object. + */ + storage?: Storage + /** + * The custom "format" object. + */ + format?: Format + /** + * The flag to automatically persist changes. + */ + writeOnChange?: boolean + } + + export interface Low extends LoDashWrapper, Format { + /** + * Access current database state. + * Returns Returns the database state. + */ + getState(): Object + /** + * Drop or reset database state. + * @param newState New state of the database + */ + setState(newState: Object): void + /** + * Persist database. + * @param source The source location. + */ + write(source: string): void + /** + * Persist database. + * @param source The source location. + */ + write(source: string): PromiseLike + /** + * Read database. + * @param source The source location. + */ + read(source?: string): Object + /** + * Read database. + * @param source The source location. + */ + read(source?: string): PromiseLike + } + +// declare class lowdb { +// new (source?: string, opts?: Options): Low; +// (source?: string, opts?: Options) : Low; +// } + +// declare module "lowdb" { +// export = lowdb; +// } + +} + diff --git a/lowdb/lowdb-tests.ts b/lowdb/lowdb-tests.ts new file mode 100644 index 0000000000..d656c63b62 --- /dev/null +++ b/lowdb/lowdb-tests.ts @@ -0,0 +1,12 @@ +import Lowdb = require('lowdb'); + +Lowdb +let db = new Lowdb(); + +db.defaults({ 'someObject': {}, 'anotherObject': {} }).value(); + +db.get('someObject').set('foo' , 'bar').value(); +db.get('anotherObject').set('foo' , 'bar').value(); +db.set('singleValue', 'foo').value(); + +console.log(db.getState()); diff --git a/lowdb/tsconfig.json b/lowdb/tsconfig.json new file mode 100644 index 0000000000..4a6104842c --- /dev/null +++ b/lowdb/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lowdb-tests.ts" + ] +} \ No newline at end of file From 3479affcfe6394800fc3562be7461552c3ed1326 Mon Sep 17 00:00:00 2001 From: Yuya Tanaka Date: Wed, 15 Feb 2017 03:06:14 +0900 Subject: [PATCH 006/258] react: Fix SVGAttributes contains all HTMLAttributes --- react/index.d.ts | 21 +++++++++++++++++++-- react/test/index.ts | 3 +++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index b2be91bf62..61b282dfc7 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -2203,7 +2203,25 @@ declare namespace React { // - "number | string" // - "string" // - union of string literals - interface SVGAttributes extends HTMLAttributes { + interface SVGAttributes extends DOMAttributes { + // Attributes which also defined in HTMLAttributes + // See comment in SVGDOMPropertyConfig.js + className?: string; + color?: string; + height?: number | string; + id?: string; + lang?: string; + max?: number | string; + media?: string; + method?: string; + min?: number | string; + name?: string; + style?: CSSProperties; + target?: string; + type?: string; + width?: number | string; + + // SVG Specific attributes accentHeight?: number | string; accumulate?: "none" | "sum"; additive?: "replace" | "sum"; @@ -2396,7 +2414,6 @@ declare namespace React { textRendering?: number | string; to?: number | string; transform?: string; - type?: string; u1?: number | string; u2?: number | string; underlinePosition?: number | string; diff --git a/react/test/index.ts b/react/test/index.ts index 4b00e988bf..702f1632c9 100644 --- a/react/test/index.ts +++ b/react/test/index.ts @@ -341,6 +341,9 @@ React.DOM.svg({ xmlns: "http://www.w3.org/2000/svg" }, React.DOM.rect({ + className: 'foobar', + id: 'foo', + color: 'black', x: 22, y: 10, width: 4, From a302f69580ad40511c18a61d5e8bcbdabcf4f16a Mon Sep 17 00:00:00 2001 From: Yuya Tanaka Date: Wed, 15 Feb 2017 04:30:20 +0900 Subject: [PATCH 007/258] react: Add type parameter to SVGProps --- react/index.d.ts | 108 +++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/react/index.d.ts b/react/index.d.ts index 61b282dfc7..867e066c7e 100644 --- a/react/index.d.ts +++ b/react/index.d.ts @@ -437,7 +437,7 @@ declare namespace React { interface ChangeTargetHTMLProps extends ChangeTargetHTMLAttributes, ClassAttributes { } - interface SVGProps extends SVGAttributes, ClassAttributes { + interface SVGProps extends SVGAttributes, ClassAttributes { } interface DOMAttributes { @@ -2810,60 +2810,60 @@ declare global { wbr: React.HTMLProps; // SVG - svg: React.SVGProps; + svg: React.SVGProps; - circle: React.SVGProps; - clipPath: React.SVGProps; - defs: React.SVGProps; - desc: React.SVGProps; - ellipse: React.SVGProps; - feBlend: React.SVGProps; - feColorMatrix: React.SVGProps; - feComponentTransfer: React.SVGProps; - feComposite: React.SVGProps; - feConvolveMatrix: React.SVGProps; - feDiffuseLighting: React.SVGProps; - feDisplacementMap: React.SVGProps; - feDistantLight: React.SVGProps; - feFlood: React.SVGProps; - feFuncA: React.SVGProps; - feFuncB: React.SVGProps; - feFuncG: React.SVGProps; - feFuncR: React.SVGProps; - feGaussianBlur: React.SVGProps; - feImage: React.SVGProps; - feMerge: React.SVGProps; - feMergeNode: React.SVGProps; - feMorphology: React.SVGProps; - feOffset: React.SVGProps; - fePointLight: React.SVGProps; - feSpecularLighting: React.SVGProps; - feSpotLight: React.SVGProps; - feTile: React.SVGProps; - feTurbulence: React.SVGProps; - filter: React.SVGProps; - foreignObject: React.SVGProps; - g: React.SVGProps; - image: React.SVGProps; - line: React.SVGProps; - linearGradient: React.SVGProps; - marker: React.SVGProps; - mask: React.SVGProps; - metadata: React.SVGProps; - path: React.SVGProps; - pattern: React.SVGProps; - polygon: React.SVGProps; - polyline: React.SVGProps; - radialGradient: React.SVGProps; - rect: React.SVGProps; - stop: React.SVGProps; - switch: React.SVGProps; - symbol: React.SVGProps; - text: React.SVGProps; - textPath: React.SVGProps; - tspan: React.SVGProps; - use: React.SVGProps; - view: React.SVGProps; + circle: React.SVGProps; + clipPath: React.SVGProps; + defs: React.SVGProps; + desc: React.SVGProps; + ellipse: React.SVGProps; + feBlend: React.SVGProps; + feColorMatrix: React.SVGProps; + feComponentTransfer: React.SVGProps; + feComposite: React.SVGProps; + feConvolveMatrix: React.SVGProps; + feDiffuseLighting: React.SVGProps; + feDisplacementMap: React.SVGProps; + feDistantLight: React.SVGProps; + feFlood: React.SVGProps; + feFuncA: React.SVGProps; + feFuncB: React.SVGProps; + feFuncG: React.SVGProps; + feFuncR: React.SVGProps; + feGaussianBlur: React.SVGProps; + feImage: React.SVGProps; + feMerge: React.SVGProps; + feMergeNode: React.SVGProps; + feMorphology: React.SVGProps; + feOffset: React.SVGProps; + fePointLight: React.SVGProps; + feSpecularLighting: React.SVGProps; + feSpotLight: React.SVGProps; + feTile: React.SVGProps; + feTurbulence: React.SVGProps; + filter: React.SVGProps; + foreignObject: React.SVGProps; + g: React.SVGProps; + image: React.SVGProps; + line: React.SVGProps; + linearGradient: React.SVGProps; + marker: React.SVGProps; + mask: React.SVGProps; + metadata: React.SVGProps; + path: React.SVGProps; + pattern: React.SVGProps; + polygon: React.SVGProps; + polyline: React.SVGProps; + radialGradient: React.SVGProps; + rect: React.SVGProps; + stop: React.SVGProps; + switch: React.SVGProps; + symbol: React.SVGProps; + text: React.SVGProps; + textPath: React.SVGProps; + tspan: React.SVGProps; + use: React.SVGProps; + view: React.SVGProps; } } } From a7ffc449a43f2ac89a4ee2a57f625663abbb9ba3 Mon Sep 17 00:00:00 2001 From: morrisjdev Date: Sun, 19 Feb 2017 21:26:34 +0100 Subject: [PATCH 008/258] Added declarations for 'linq4js' --- linq4js/index.d.ts | 286 +++++++++++++++++++++++++++++++++++++++ linq4js/linq4js-tests.ts | 5 + linq4js/tsconfig.json | 22 +++ 3 files changed, 313 insertions(+) create mode 100644 linq4js/index.d.ts create mode 100644 linq4js/linq4js-tests.ts create mode 100644 linq4js/tsconfig.json diff --git a/linq4js/index.d.ts b/linq4js/index.d.ts new file mode 100644 index 0000000000..6b98907453 --- /dev/null +++ b/linq4js/index.d.ts @@ -0,0 +1,286 @@ +// Type definitions for Linq4JS 2.0.3 +// Project: https://github.com/morrisjdev/Linq4JS +// Definitions by: Morris Janatzek +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace Linq4JS { + class GeneratedEntity { + _GeneratedId_: number; + Id: number; + } +} +declare namespace Linq4JS { + class Helper { + static ConvertStringFunction: (functionString: string) => any; + static ConvertFunction: (testFunction: any) => T; + static OrderCompareFunction: (valueSelector: (item: T) => any, a: T, b: T, invert: boolean) => number; + } +} +interface Array { + Order: Array; + GroupValue: any; + /** + * Creates a copy of the array + */ + Clone(): Array; + /** + * Gets the index of the first item found by a filter + * @param filter A function (or function-string) that returns a boolean when matching element was found + */ + FindIndex(filter: ((item: T) => boolean) | string): number; + /** + * Gets the index of the last item found by a filter + * @param filter A function (or function-string) that returns a boolean when matching element was found + */ + FindLastIndex(filter: ((item: T) => boolean) | string): number; + /** + * Gets the item with the index + * @param index Item index + */ + Get(index: number): T; + /** + * Executes a method for each item in the array + * @param action A function (or function-string) that gets executed for each element. If it returns false the loop stops. + */ + ForEach(action: ((item: T, index?: number) => boolean | any) | string): Array; + /** + * Updates an object in the array + * @param object The object to update + * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array + */ + Update(object: T, primaryKeySelector?: ((item: T) => any) | string): Array; + /** + * Updates objects in the array + * @param objects The array of objects to update + * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array + */ + UpdateRange(objects: Array, primaryKeySelector?: ((item: T) => any) | string): Array; + /** + * Removes an object from the array + * @param object The object to remove + * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array + */ + Remove(object: T, primaryKeySelector?: ((item: T) => any) | string): Array; + /** + * Removes objects from the array + * @param objects The array of objects to remove + * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array + */ + RemoveRange(objects: Array, primaryKeySelector?: ((item: T) => any) | string): Array; + /** + * Adds an object to the array + * @param object The object to add + * @param generateId Auto-generate a property to identify object in later processes + */ + Add(object: T, generateId?: boolean): Array; + /** + * Adds objects to the array + * @param objects The array of objects to add + */ + AddRange(objects: Array, generateId?: boolean): Array; + /** + * Inserts an entry at a specific position + * @param object The object to insert + * @param index The position to insert + */ + Insert(object: T, index: number): Array; + /** + * Searches for all items in array that match the given filter + * @param filter A function (or function-string) that returns a boolean when matching element was found + */ + Where(filter: ((item: T, index?: number) => boolean) | string): Array; + /** + * Takes items in a specific range + * @param start The start position + * @param length The number of elements to take + */ + Range(start: number, length: number): Array; + /** + * Repeats an object in the array + * @param object The object to repeat + * @param count The count of repeats + */ + Repeat(object: T, count: number): Array; + /** + * Returns the length of the array + * @param filter If set the function returns count of elements matched by the condition + */ + Count(filter?: ((item: T) => boolean) | string): number; + /** + * Tests if all items in the array match the condition + * @param filter A function (or function-string) that returns a boolean when matching element was found + */ + All(filter: ((item: T) => boolean) | string): boolean; + /** + * Tests if any item is in the array + * @param filter If set the function tests if any item in the array matches the condition + */ + Any(filter?: ((item: T) => boolean) | string): boolean; + /** + * Returns the first item of the array - Throws an exception if no item was found + * @param filter If set the function returns the first item that matches the filter + */ + First(filter?: ((item: T) => boolean) | string): T; + /** + * Returns the first item of the array - returns `null` if no suitable item was found + * @param filter If set the function returns the first item that matches the filter + */ + FirstOrDefault(filter?: ((item: T) => boolean) | string): (T | null); + /** + * Returns the last item of the array - Throws an exception if no item was found + * @param filter If set the function returns the last item that matches the filter + */ + Last(filter?: ((item: T) => boolean) | string): T; + /** + * Returns the last item of the array - returns `null` if no suitable item was found + * @param filter If set the function returns the last item that matches the filter + */ + LastOrDefault(filter?: ((item: T) => boolean) | string): (T | null); + /** + * Select the properties for a new array + * @param selector A function (or a function-string) that returns a new object + */ + Select(selector: ((item: T) => any) | string): any[]; + /** + * Limits the number of entries taken + * @param count The count of elements taken + */ + Take(count: number): Array; + /** + * Takes entries as long as a condition is true + * @param condition The condition-function (or function-string) that returns a boolean. All elements until a false gets created are taken + * @param initial A initial-function (or function-string) that gets executed once at the start of the loop + * @param after A function that gets executed after every element-iteration after the condition-function was evaluated + */ + TakeWhile(condition: ((item: T, storage?: any) => boolean) | string, initial?: ((storage: any) => void) | string, after?: ((item: T, storage: any) => void) | string): Array; + /** + * Skips entries + * @param count The count of elements skipped + */ + Skip(count: number): Array; + /** + * Orders array by property or value in ascending direction + * @param valueSelector The selector-function (or function-string) that selects the property for sorting + */ + OrderBy(valueSelector: ((item: T) => any) | string): Array; + /** + * Orders array by additional properties in ascending direction in combination with OrderBy/OrderByDescending + * @param valueSelector The selector-function (or function-string) that selects the property for sorting + */ + ThenBy(valueSelector: ((item: T) => any) | string): Array; + /** + * Orders array by property or value in descending direction + * @param valueSelector The selector-function (or function-string) that selects the property for sorting + */ + OrderByDescending(valueSelector: ((item: T) => any) | string): Array; + /** + * Orders array by additional properties in descending direction in combination with OrderBy/OrderByDescending + * @param valueSelector The selector-function (or function-string) that selects the property for sorting + */ + ThenByDescending(valueSelector: ((item: T) => any) | string): Array; + /** + * Returns the smallest element in array + * @param valueSelector The selector-function (or function-string) that selects the property for comparison + */ + Min(valueSelector?: ((item: T) => any) | string): (T | null); + /** + * Returns the greates element in array + * @param valueSelector The selector-function (or function-string) that selects the property for comparison + */ + Max(valueSelector?: ((item: T) => any) | string): (T | null); + /** + * Groups array by property + * @param selector The selector-function (or function-string) that selects the property for grouping + */ + GroupBy(selector: ((item: T) => any) | string): Array>; + /** + * Moves an item from one index to another + * @param oldIndex The current position of the item + * @param newIndex The new position of the item + */ + Move(oldIndex: number, newIndex: number): Array; + /** + * Makes all values unique + * @param valueSelector A selector-function (or function-string) to select property for comparison and distinction + */ + Distinct(valueSelector?: ((item: T) => any) | string): Array; + /** + * Tests if array contains specific object + * @param object The object to test for + */ + Contains(object: T): boolean; + /** + * Combines two arrays + * @param array The array to combine + */ + Concat(array: Array): Array; + /** + * Combines two arrays but only applies values that are in both arrays + * @param array The array to combine + */ + Intersect(array: Array): Array; + /** + * Joins the entries by a given char + * @param character The character for joining + * @param selector A selector-function (or function-string) to select property for joining + */ + Join(character: string, selector?: ((item: T) => any) | string): string; + /** + * Combines the entries using a custom function + * @param method A function (or function-string) for aggregation + * @param startVal The value to start aggregation + */ + Aggregate(method: ((result: any, item: T) => any) | string, startVal?: any): string; + /** + * Reverses the array + */ + Reverse(): Array; + /** + * Computes the average of the elements + * @param selector A selector-function (or function-string) to select property for average computing + * @param filter If set the function computes the average of elements that match the filter + */ + Average(selector?: ((item: T) => any) | string, filter?: ((item: T) => boolean) | string): number; + /** + * Computes the sum of the elements + * @param selector A selector-function (or function-string) to select property for adding + * @param filter If set the function computes the sum of elements that match the filter + */ + Sum(selector?: ((item: T) => any) | string, filter?: ((item: T) => boolean) | string): number; + /** + * Compares to sequences of objects + * @param array The array to compare + */ + SequenceEqual(array: Array): boolean; + /** + * Combines the entries of two arrays using a custom function + * @param array The array to combine + * @param result The function (or function-string) to combine elements + */ + Zip(array: Array, result: ((first: T, second: X) => any) | string): Array; + /** + * Combines two arrays without duplicates + * @param array The array to combine + */ + Union(array: Array): Array; + /** + * Converts the array to a dictionary + * @param keySelector The selector-function (or function-string) to select property for key + * @param valueSelector A selector-function (or function-string) to select property for value + */ + ToDictionary(keySelector: ((item: T) => any) | string, valueSelector?: ((item: T) => any) | string): any; +} +declare module "linq4js" { + export = Linq4JS; +} +declare namespace Linq4JS { + class OrderEntry { + Direction: OrderDirection; + ValueSelector: (item: any) => any; + constructor(_direction: OrderDirection, _valueSelector: (item: any) => any); + } + enum OrderDirection { + Ascending = 0, + Descending = 1, + } +} diff --git a/linq4js/linq4js-tests.ts b/linq4js/linq4js-tests.ts new file mode 100644 index 0000000000..6d15649c2c --- /dev/null +++ b/linq4js/linq4js-tests.ts @@ -0,0 +1,5 @@ +import * as linq from "linq4js"; + +let array: Array = ["test", "test2", "test3", "test4", "test5"]; + +array.Add("test6").Remove("test3").Insert("test3", 2).Distinct().OrderBy(x => x).OrderByDescending(x => x).Select(x => x.length).Average(); \ No newline at end of file diff --git a/linq4js/tsconfig.json b/linq4js/tsconfig.json new file mode 100644 index 0000000000..fa4dac9326 --- /dev/null +++ b/linq4js/tsconfig.json @@ -0,0 +1,22 @@ +{ + "files": [ + "index.d.ts", + "linq4js-tests.ts" + ], + "compilerOptions": { + "module": "commonjs", + "noImplicitAny": true, + "noImplicitReturns": true, + "noImplicitThis": true, + "strictNullChecks": true, + "alwaysStrict": true, + "target": "es6", + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + } +} \ No newline at end of file From a8a54caf2fa90399a14615348e90d4807e2604ad Mon Sep 17 00:00:00 2001 From: morrisjdev Date: Sun, 19 Feb 2017 22:02:31 +0100 Subject: [PATCH 009/258] fixed lint --- linq4js/index.d.ts | 65 +++++++++++++++++++++------------------------ linq4js/tslint.json | 1 + 2 files changed, 32 insertions(+), 34 deletions(-) create mode 100644 linq4js/tslint.json diff --git a/linq4js/index.d.ts b/linq4js/index.d.ts index 6b98907453..4fe054d5fc 100644 --- a/linq4js/index.d.ts +++ b/linq4js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Linq4JS 2.0.3 +// Type definitions for Linq4JS 2.0 // Project: https://github.com/morrisjdev/Linq4JS // Definitions by: Morris Janatzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -17,12 +17,12 @@ declare namespace Linq4JS { } } interface Array { - Order: Array; + Order: Linq4JS.OrderEntry[]; GroupValue: any; /** * Creates a copy of the array */ - Clone(): Array; + Clone(): T[]; /** * Gets the index of the first item found by a filter * @param filter A function (or function-string) that returns a boolean when matching element was found @@ -42,65 +42,65 @@ interface Array { * Executes a method for each item in the array * @param action A function (or function-string) that gets executed for each element. If it returns false the loop stops. */ - ForEach(action: ((item: T, index?: number) => boolean | any) | string): Array; + ForEach(action: ((item: T, index?: number) => boolean | any) | string): T[]; /** * Updates an object in the array * @param object The object to update * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array */ - Update(object: T, primaryKeySelector?: ((item: T) => any) | string): Array; + Update(object: T, primaryKeySelector?: ((item: T) => any) | string): T[]; /** * Updates objects in the array * @param objects The array of objects to update * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array */ - UpdateRange(objects: Array, primaryKeySelector?: ((item: T) => any) | string): Array; + UpdateRange(objects: T[], primaryKeySelector?: ((item: T) => any) | string): T[]; /** * Removes an object from the array * @param object The object to remove * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array */ - Remove(object: T, primaryKeySelector?: ((item: T) => any) | string): Array; + Remove(object: T, primaryKeySelector?: ((item: T) => any) | string): T[]; /** * Removes objects from the array * @param objects The array of objects to remove * @param primaryKeySelector A selector-function (or function-string) to define a property to indentify object in array */ - RemoveRange(objects: Array, primaryKeySelector?: ((item: T) => any) | string): Array; + RemoveRange(objects: T[], primaryKeySelector?: ((item: T) => any) | string): T[]; /** * Adds an object to the array * @param object The object to add * @param generateId Auto-generate a property to identify object in later processes */ - Add(object: T, generateId?: boolean): Array; + Add(object: T, generateId?: boolean): T[]; /** * Adds objects to the array * @param objects The array of objects to add */ - AddRange(objects: Array, generateId?: boolean): Array; + AddRange(objects: T[], generateId?: boolean): T[]; /** * Inserts an entry at a specific position * @param object The object to insert * @param index The position to insert */ - Insert(object: T, index: number): Array; + Insert(object: T, index: number): T[]; /** * Searches for all items in array that match the given filter * @param filter A function (or function-string) that returns a boolean when matching element was found */ - Where(filter: ((item: T, index?: number) => boolean) | string): Array; + Where(filter: ((item: T, index?: number) => boolean) | string): T[]; /** * Takes items in a specific range * @param start The start position * @param length The number of elements to take */ - Range(start: number, length: number): Array; + Range(start: number, length: number): T[]; /** * Repeats an object in the array * @param object The object to repeat * @param count The count of repeats */ - Repeat(object: T, count: number): Array; + Repeat(object: T, count: number): T[]; /** * Returns the length of the array * @param filter If set the function returns count of elements matched by the condition @@ -145,39 +145,39 @@ interface Array { * Limits the number of entries taken * @param count The count of elements taken */ - Take(count: number): Array; + Take(count: number): T[]; /** * Takes entries as long as a condition is true * @param condition The condition-function (or function-string) that returns a boolean. All elements until a false gets created are taken * @param initial A initial-function (or function-string) that gets executed once at the start of the loop * @param after A function that gets executed after every element-iteration after the condition-function was evaluated */ - TakeWhile(condition: ((item: T, storage?: any) => boolean) | string, initial?: ((storage: any) => void) | string, after?: ((item: T, storage: any) => void) | string): Array; + TakeWhile(condition: ((item: T, storage?: any) => boolean) | string, initial?: ((storage: any) => void) | string, after?: ((item: T, storage: any) => void) | string): T[]; /** * Skips entries * @param count The count of elements skipped */ - Skip(count: number): Array; + Skip(count: number): T[]; /** * Orders array by property or value in ascending direction * @param valueSelector The selector-function (or function-string) that selects the property for sorting */ - OrderBy(valueSelector: ((item: T) => any) | string): Array; + OrderBy(valueSelector: ((item: T) => any) | string): T[]; /** * Orders array by additional properties in ascending direction in combination with OrderBy/OrderByDescending * @param valueSelector The selector-function (or function-string) that selects the property for sorting */ - ThenBy(valueSelector: ((item: T) => any) | string): Array; + ThenBy(valueSelector: ((item: T) => any) | string): T[]; /** * Orders array by property or value in descending direction * @param valueSelector The selector-function (or function-string) that selects the property for sorting */ - OrderByDescending(valueSelector: ((item: T) => any) | string): Array; + OrderByDescending(valueSelector: ((item: T) => any) | string): T[]; /** * Orders array by additional properties in descending direction in combination with OrderBy/OrderByDescending * @param valueSelector The selector-function (or function-string) that selects the property for sorting */ - ThenByDescending(valueSelector: ((item: T) => any) | string): Array; + ThenByDescending(valueSelector: ((item: T) => any) | string): T[]; /** * Returns the smallest element in array * @param valueSelector The selector-function (or function-string) that selects the property for comparison @@ -192,18 +192,18 @@ interface Array { * Groups array by property * @param selector The selector-function (or function-string) that selects the property for grouping */ - GroupBy(selector: ((item: T) => any) | string): Array>; + GroupBy(selector: ((item: T) => any) | string): T[][]; /** * Moves an item from one index to another * @param oldIndex The current position of the item * @param newIndex The new position of the item */ - Move(oldIndex: number, newIndex: number): Array; + Move(oldIndex: number, newIndex: number): T[]; /** * Makes all values unique * @param valueSelector A selector-function (or function-string) to select property for comparison and distinction */ - Distinct(valueSelector?: ((item: T) => any) | string): Array; + Distinct(valueSelector?: ((item: T) => any) | string): T[]; /** * Tests if array contains specific object * @param object The object to test for @@ -213,12 +213,12 @@ interface Array { * Combines two arrays * @param array The array to combine */ - Concat(array: Array): Array; + Concat(array: T[]): T[]; /** * Combines two arrays but only applies values that are in both arrays * @param array The array to combine */ - Intersect(array: Array): Array; + Intersect(array: T[]): T[]; /** * Joins the entries by a given char * @param character The character for joining @@ -234,7 +234,7 @@ interface Array { /** * Reverses the array */ - Reverse(): Array; + Reverse(): T[]; /** * Computes the average of the elements * @param selector A selector-function (or function-string) to select property for average computing @@ -251,18 +251,18 @@ interface Array { * Compares to sequences of objects * @param array The array to compare */ - SequenceEqual(array: Array): boolean; + SequenceEqual(array: T[]): boolean; /** * Combines the entries of two arrays using a custom function * @param array The array to combine * @param result The function (or function-string) to combine elements */ - Zip(array: Array, result: ((first: T, second: X) => any) | string): Array; + Zip(array: X[], result: ((first: T, second: X) => any) | string): any[]; /** * Combines two arrays without duplicates * @param array The array to combine */ - Union(array: Array): Array; + Union(array: T[]): T[]; /** * Converts the array to a dictionary * @param keySelector The selector-function (or function-string) to select property for key @@ -270,9 +270,6 @@ interface Array { */ ToDictionary(keySelector: ((item: T) => any) | string, valueSelector?: ((item: T) => any) | string): any; } -declare module "linq4js" { - export = Linq4JS; -} declare namespace Linq4JS { class OrderEntry { Direction: OrderDirection; @@ -283,4 +280,4 @@ declare namespace Linq4JS { Ascending = 0, Descending = 1, } -} +} \ No newline at end of file diff --git a/linq4js/tslint.json b/linq4js/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/linq4js/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 0b19c9cf595d7db45f437e035c762addf99f975e Mon Sep 17 00:00:00 2001 From: morrisjdev Date: Sun, 19 Feb 2017 22:03:08 +0100 Subject: [PATCH 010/258] fixed version --- linq4js/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linq4js/index.d.ts b/linq4js/index.d.ts index 4fe054d5fc..e108f31a4c 100644 --- a/linq4js/index.d.ts +++ b/linq4js/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Linq4JS 2.0 +// Type definitions for Linq4JS 2.1 // Project: https://github.com/morrisjdev/Linq4JS // Definitions by: Morris Janatzek // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 36a25dcc742b344e98372f9cff9efadc02f2648c Mon Sep 17 00:00:00 2001 From: morrisjdev Date: Sun, 19 Feb 2017 22:19:41 +0100 Subject: [PATCH 011/258] fixed tsconfig.json --- linq4js/linq4js-tests.ts | 2 +- linq4js/tsconfig.json | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/linq4js/linq4js-tests.ts b/linq4js/linq4js-tests.ts index 6d15649c2c..9e0bbe7be5 100644 --- a/linq4js/linq4js-tests.ts +++ b/linq4js/linq4js-tests.ts @@ -1,4 +1,4 @@ -import * as linq from "linq4js"; +import "linq4js"; let array: Array = ["test", "test2", "test3", "test4", "test5"]; diff --git a/linq4js/tsconfig.json b/linq4js/tsconfig.json index fa4dac9326..2c6f199057 100644 --- a/linq4js/tsconfig.json +++ b/linq4js/tsconfig.json @@ -16,6 +16,9 @@ "../" ], "types": [], + "lib":[ + "es6" + ], "noEmit": true, "forceConsistentCasingInFileNames": true } From 32b84dfb0bb755753ed03a3cafb809cffac2426b Mon Sep 17 00:00:00 2001 From: morrisjdev Date: Sun, 19 Feb 2017 22:25:18 +0100 Subject: [PATCH 012/258] tsconfig.json fix 2 --- linq4js/tsconfig.json | 1 - 1 file changed, 1 deletion(-) diff --git a/linq4js/tsconfig.json b/linq4js/tsconfig.json index 2c6f199057..f053fa2e23 100644 --- a/linq4js/tsconfig.json +++ b/linq4js/tsconfig.json @@ -9,7 +9,6 @@ "noImplicitReturns": true, "noImplicitThis": true, "strictNullChecks": true, - "alwaysStrict": true, "target": "es6", "baseUrl": "../", "typeRoots": [ From d8edccd12a27b614e78d88342edde56379963ee8 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Mon, 20 Feb 2017 03:11:11 +0000 Subject: [PATCH 013/258] Initial commit for v17 of openfin api --- openfin/index.d.ts | 45 +- openfin/openfin-tests.ts | 6 +- openfin/v16/index.d.ts | 1581 ++++++++++++++++++++++++++++++++++ openfin/v16/openfin-tests.ts | 724 ++++++++++++++++ openfin/v16/tsconfig.json | 25 + openfin/v16/tslint.json | 1 + 6 files changed, 2373 insertions(+), 9 deletions(-) create mode 100644 openfin/v16/index.d.ts create mode 100644 openfin/v16/openfin-tests.ts create mode 100644 openfin/v16/tsconfig.json create mode 100644 openfin/v16/tslint.json diff --git a/openfin/index.d.ts b/openfin/index.d.ts index 2c1cfd648e..893a253606 100644 --- a/openfin/index.d.ts +++ b/openfin/index.d.ts @@ -1,9 +1,9 @@ -// Type definitions for OpenFin API 16.0 +// Type definitions for OpenFin API 17.0 // Project: https://openfin.co/ // Definitions by: Chris Barker // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// based on v6.49.16.16 +// based on v6.49.17.14 // see https://openfin.co/support/technical-faq/#what-do-the-numbers-in-the-runtime-version-mean /** @@ -63,7 +63,7 @@ declare namespace fin { */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Retrieves an array of wrapped fin.desktop.Windows for each of the application’s child windows. + * Retrieves an array of wrapped fin.desktop.Windows for each of the application�s child windows. */ getChildWindows(callback?: (children: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; /** @@ -82,6 +82,10 @@ declare namespace fin { * Retrieves current configuration of application's shortcuts. */ getShortcuts(callback?: (config: ShortCutConfig) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves information about the application. + */ + getInfo(callback?: (info: LaunchInfo) => void, errorCallback?: (reason: string) => void): void; /** * Determines if the application is currently running. */ @@ -95,7 +99,7 @@ declare namespace fin { */ removeEventListener(type: OpenFinApplicationEventType, previouslyRegisteredListener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Removes the application’s icon from the tray. + * Removes the application�s icon from the tray. */ removeTrayIcon(callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -185,10 +189,13 @@ declare namespace fin { */ accelerator?: { devtools?: boolean, - zoom?: boolean + zoom?: boolean, + reload?: boolean, + reloadIgnoreCache?: boolean, }; /** * A flag to always position the window at the top of the window stack. Default: false. + * Updatable */ alwaysOnTop?: boolean; /** @@ -197,10 +204,12 @@ declare namespace fin { autoShow?: boolean; /** * A flag to show the context menu when right-clicking on a window. Gives access to the Developer Console for the Window. Default: true + * Updatable */ contextMenu?: boolean; /** * This defines and applies rounded corners for a frameless window. Default for both width and height: 0. + * Updatable */ cornerRounding?: { width?: number; @@ -232,30 +241,37 @@ declare namespace fin { defaultLeft?: number; /** * A flag to show the frame. Default: true. + * Updatable */ frame?: boolean; /** * A flag to allow a window to be hidden when the close button is clicked.Default: false. + * Updatable */ hideOnClose?: boolean; /** * A URL for the icon to be shown in the window title bar and the taskbar.Default: The parent application's applicationIcon. + * Updatable */ icon?: string; /** * The maximum height of a window.Will default to the OS defined value if set to - 1. Default: -1. + * Updatable */ maxHeight?: number; /** * A flag that lets the window be maximized.Default: true. + * Updatable */ maximizable?: boolean; /** * The maximum width of a window.Will default to the OS defined value if set to - 1. Default: -1. + * Updatable */ maxWidth?: number; /** * The minimum height of a window.Default: 0. + * Updatable */ minHeight?: number; /** @@ -272,14 +288,17 @@ declare namespace fin { name?: string; /** * A flag that specifies how transparent the window will be.This value is clamped between 0.0 and 1.0.Default: 1.0. + * Updatable */ opacity?: number; /** * A flag to drop to allow the user to resize the window.Default: true. + * Updatable */ resizable?: boolean; /** * Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window. + * Updatable */ resizeRegion?: { /** @@ -989,7 +1008,7 @@ declare namespace fin { bringToFront(callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Closes the window. - * @param {force} Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window. + * @param {force} Close will be prevented from closing when force is false and �close-requested� has been subscribed to for application�s main window. */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1009,7 +1028,7 @@ declare namespace fin { */ enableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Flashes the window’s frame and taskbar icon until the window is activated. + * Flashes the window�s frame and taskbar icon until the window is activated. */ flash(options?: any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1106,7 +1125,7 @@ declare namespace fin { setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Shows the window if it is hidden. - * @param {force} Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window. + * @param {force} Show will be prevented from closing when force is false and �show-requested� has been subscribed to for application�s main window. */ show(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1500,6 +1519,16 @@ declare namespace fin { type: "session-changed"; } + interface LaunchInfo { + launchMode: "fin-protocol" + | "fins-protocol" + | "shortcut" + | "command-line" + | "adapter" + | "other" + | string; + } + type OpenFinTweenType = "linear" | "ease-in" | "ease-out" diff --git a/openfin/openfin-tests.ts b/openfin/openfin-tests.ts index 81ac24f937..ae5fe587d3 100644 --- a/openfin/openfin-tests.ts +++ b/openfin/openfin-tests.ts @@ -1,6 +1,6 @@ function test_application() { let application: fin.OpenFinApplication; - // constructor + // constructor application = new fin.desktop.Application({ url: "application.html", uuid: "74BED629-2D8E-4141-8582-73E364BDFA74", @@ -69,6 +69,10 @@ console.log("Start Menu shortcut is enabled: ", config.startMenu); console.log("System Startup shortcut is enabled: ", config.systemStartup); }); + // getInfo + application.getInfo(info => { + console.log(`Launch mode: ${info.launchMode}`); + }); // isRunning application.isRunning(function (running) { console.log("the application is", running ? "running" : "not running"); diff --git a/openfin/v16/index.d.ts b/openfin/v16/index.d.ts new file mode 100644 index 0000000000..2c1cfd648e --- /dev/null +++ b/openfin/v16/index.d.ts @@ -0,0 +1,1581 @@ +// Type definitions for OpenFin API 16.0 +// Project: https://openfin.co/ +// Definitions by: Chris Barker +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +// based on v6.49.16.16 +// see https://openfin.co/support/technical-faq/#what-do-the-numbers-in-the-runtime-version-mean + +/** + * JavaScript API + * The JavaScript API allows you to create an HTML/JavaScript application that has access to the native windowing environment, can communicate with other applications and has access to sandboxed system-level features. + * + * API Ready + * When using the OpenFin API, it is important to ensure that it has been fully loaded before making any API calls. To verify that the API is in fact ready, be sure to make any API calls either from within the fin.desktop.main() method or explicitly after it has returned. This avoids the situation of trying to access methods that are not yet fully injected. + * + * Overview + * When running within the OpenFin Runtime your web applications have access to the "fin" namespace and all the modules within the API without the need to include additional source files. You can treat the "fin" namespace as you would the "window", "navigator" or "document" objects. + **/ +declare namespace fin { + const desktop: OpenFinDesktop; + + interface OpenFinDesktop { + main(f: () => any): void; + Application: OpenFinApplicationStatic; + ExternalApp: OpenFinExternalApplicationStatic; + InterApplicationBus: OpenFinInterApplicationBus; + Notification: OpenFinNotificationStatic; + System: OpenFinSystem; + Window: OpenFinWindowStatic; + } + + interface OpenFinApplicationStatic { + /** + * Creates a new Application. + * An object representing an application. Allows the developer to create, execute, show/close an application as well as listen to application events. + */ + new (options: ApplicationOptions, callback?: (successObj: { httpResponseCode: number }) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): OpenFinApplication; + /** + * Returns an Application object that represents an existing application. + */ + getCurrent(): OpenFinApplication; + /** + * Returns an Application object that represents an existing application. + */ + wrap(uuid: string): OpenFinApplication; + } + + /** + * Application + * An object representing an application.Allows the developer to create, execute, show / close an application as well as listen to application events. + */ + interface OpenFinApplication { + /** + * Returns an instance of the main Window of the application + */ + getWindow(): OpenFinWindow; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinApplicationEventType, listener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Closes the application and any child windows created by the application. + */ + close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of wrapped fin.desktop.Windows for each of the application’s child windows. + */ + getChildWindows(callback?: (children: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of active window groups for all of the application's windows. Each group is represented as an array of wrapped fin.desktop.Windows. + */ + getGroups(callback?: (groups: OpenFinWindow[][]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the JSON manifest that was used to create the application. Invokes the error callback if the application was not created from a manifest. + */ + getManifest(callback?: (manifest: any) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves UUID of the application that launches this application. Invokes the error callback if the application was created from a manifest. + */ + getParentUuid(callback?: (uuid: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves current configuration of application's shortcuts. + */ + getShortcuts(callback?: (config: ShortCutConfig) => void, errorCallback?: (reason: string) => void): void; + /** + * Determines if the application is currently running. + */ + isRunning(callback?: (running: boolean) => void, errorCallback?: (reason: string) => void): void; + /** + * Passes in custom data that will be relayed to the RVM + */ + registerCustomData(data: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinApplicationEventType, previouslyRegisteredListener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes the application’s icon from the tray. + */ + removeTrayIcon(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Restarts the application. + */ + restart(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Runs the application. When the application is created, run must be called. + */ + run(callback?: (successObj: SuccessObj) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): void; + /** + * Tells the rvm to relaunch the main application once upon a complete shutdown + */ + scheduleRestart(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sets new shortcut configuration for current application. Application has to be launched with a manifest and has to have shortcut configuration (icon url, name, etc.) in its manifest to be able to change shortcut states. + */ + setShortcuts(config: ShortCutConfig, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Adds a customizable icon in the system tray and notifies the application when clicked. + */ + setTrayIcon(iconUrl: string, listener: (clickInfo: TrayIconClickedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Closes the application by terminating its process. + */ + terminate(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Waits for a hanging application. This method can be called in response to an application "not-responding" to allow the application to continue and to generate another "not-responding" message after a certain period of time. + */ + wait(callback?: () => void, errorCallback?: (reason: string) => void): void; + } + + interface ShortCutConfig { + /** + * application has a shortcut on the desktop + */ + desktop?: boolean; + /** + * application has no shortcut in the start menu + */ + startMenu?: boolean; + /** + * application will be launched on system startup + */ + systemStartup?: boolean; + } + + interface SuccessObj { + httpResponseCode: number; + } + + interface NetworkErrorInfo extends ErrorInfo { + networkErrorCode: number; + } + + interface ErrorInfo { + stack: string; + message: string; + } + + interface ApplicationOptions { + /** + * The name of the application. + */ + name?: string; + /** + * The url to the application. + */ + url?: string; + /** + * The UUID of the application, unique within the set of all other applications running in the OpenFin Runtime. name and uuid must match. + */ + uuid?: string; + /** + * Enable Flash at the application level. Default: false. + */ + plugins?: boolean; + /** + * The options of the main window of the application. + */ + mainWindowOptions?: WindowOptions; + } + + interface WindowOptions { + /** + * Enable keyboard shortcuts for devtools and zoom. Default: false for both. + */ + accelerator?: { + devtools?: boolean, + zoom?: boolean + }; + /** + * A flag to always position the window at the top of the window stack. Default: false. + */ + alwaysOnTop?: boolean; + /** + * A flag to automatically show the Window when it is created. Default: false. + */ + autoShow?: boolean; + /** + * A flag to show the context menu when right-clicking on a window. Gives access to the Developer Console for the Window. Default: true + */ + contextMenu?: boolean; + /** + * This defines and applies rounded corners for a frameless window. Default for both width and height: 0. + */ + cornerRounding?: { + width?: number; + height?: number; + }; + /** + * A field that the user can attach serializable data to to be ferried around with the window options. Default: ''. + */ + customData?: any; + /** + * Specifies that the window will be positioned in the center of the primary monitor when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the position from before the window was closed is used. This option overrides defaultLeft and defaultTop. Default: false. + */ + defaultCentered?: boolean; + /** + * The default height of the window. Specifies the height of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the height is taken to be the last height of the window before it was closed. Default: 500. + */ + defaultHeight?: number; + /** + * The default left position of the window. Specifies the position of the left of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the value of left is taken to be the last value before the window was closed. Default: 100. + */ + defaultWidth?: number; + /** + * The default top position of the window. Specifies the position of the top of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the value of top is taken to be the last value before the window was closed. Default: 100. + */ + defaultTop?: number; + /** + * The default width of the window. Specifies the width of the window when loaded for the first time on a machine. When the window corresponding to that id is loaded again, the width is taken to be the last width of the window before it was closed. Default: 800. + */ + defaultLeft?: number; + /** + * A flag to show the frame. Default: true. + */ + frame?: boolean; + /** + * A flag to allow a window to be hidden when the close button is clicked.Default: false. + */ + hideOnClose?: boolean; + /** + * A URL for the icon to be shown in the window title bar and the taskbar.Default: The parent application's applicationIcon. + */ + icon?: string; + /** + * The maximum height of a window.Will default to the OS defined value if set to - 1. Default: -1. + */ + maxHeight?: number; + /** + * A flag that lets the window be maximized.Default: true. + */ + maximizable?: boolean; + /** + * The maximum width of a window.Will default to the OS defined value if set to - 1. Default: -1. + */ + maxWidth?: number; + /** + * The minimum height of a window.Default: 0. + */ + minHeight?: number; + /** + * A flag that lets the window be minimized.Default: true. + */ + minimizable?: boolean; + /** + * The minimum width of a window.Default: 0. + */ + minWidth?: number; + /** + * The name for the window which must be unique within the context of the invoking Application. + */ + name?: string; + /** + * A flag that specifies how transparent the window will be.This value is clamped between 0.0 and 1.0.Default: 1.0. + */ + opacity?: number; + /** + * A flag to drop to allow the user to resize the window.Default: true. + */ + resizable?: boolean; + /** + * Defines a region in pixels that will respond to user mouse interaction for resizing a frameless window. + */ + resizeRegion?: { + /** + * The size in pixels (Default: 2), + */ + size?: number; + /** + * The size in pixels of an additional + * square resizable region located at the + * bottom right corner of a + * frameless window. (Default: 4) + */ + bottomRightCorner?: number; + }; + /** + * A flag to show the Window's icon in the taskbar. Default: true. + */ + showTaskbarIcon?: boolean; + /** + * A flag to cache the location of the window or not. Default: true. + */ + saveWindowState?: boolean; + /** + * Specify a taskbar group for the window. Default: app's uuid. + */ + taskbarIconGroup?: string; + /** + * A string that sets the window to be "minimized", "maximized", or "normal" on creation. Default: "normal". + */ + state?: string; + /** + * The URL of the window. Default: "about:blank". + */ + url?: string; + /** + * When set to false, the window will render before the "load" event is fired on the content's window. Caution, when false you will see an initial empty white window. Default: true. + */ + waitForPageLoad?: boolean; + } + + /** + * Clipboard + * Clipboard API allows reading and writting to the clipboard in multiple formats. + */ + interface OpenFinClipboard { + /** + * Reads available formats for the clipboard type + */ + availableFormats(type: string | null, callback?: (formats: string[]) => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Reads available formats for the clipboard type + */ + readHtml(type: string | null, callback?: (html: string) => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Read the content of the clipboard as Rtf + */ + readRtf(type: string | null, callback?: (rtf: string) => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Read the content of the clipboard as plain text + */ + readText(type: string | null, callback?: (text: string) => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Writes data into the clipboard + */ + write(data: any, type: string | null, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Writes data into the clipboard as Html + */ + writeHtml(data: string, type: string | null, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Writes data into the clipboard as Rtf + */ + writeRtf(data: string, type: string | null, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Writes data into the clipboard as plain text + */ + writeText(data: string, type: string | null, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + } + + interface OpenFinExternalApplicationStatic { + /** + * Returns an External Application object that represents an existing external application. + */ + wrap(uuid: string): OpenFinExternalApplication; + } + /** + * ExternalApplication + * An object representing an application. Allows the developer to create, execute, show and close an application, as well as listen to application events. + */ + interface OpenFinExternalApplication { + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinExternalApplicationEventType, listener: () => void, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinExternalApplicationEventType, listener: () => void, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + } + + /** + * InterApplicationBus + * A messaging bus that allows for pub/sub messaging between different applications. + */ + interface OpenFinInterApplicationBus { + /** + * Adds a listener that gets called when applications subscribe to the current application's messages. + */ + addSubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Adds a listener that gets called when applications unsubscribe to the current application's messages. + */ + addUnsubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Removes a previously registered subscribe listener. + */ + removeSubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Removes a previously registered unsubscribe listener. + */ + removeUnsubscribeListener(listener: (uuid: string, topic: string, name: string) => void): void; + /** + * Publishes a message to all applications running on OpenFin Runtime that are subscribed to the specified topic. + */ + publish(topic: string, message: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sends a message to a specific application on a specific topic. + */ + send(destinationUuid: string, name: string, topic: string, message: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + send(destinationUuid: string, topic: string, message: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Subscribes to messages from the specified application on the specified topic. If the subscription is for a uuid, [name], topic combination that has already been published to upon subscription you will receive the last 20 missed messages in the order they were published. + */ + subscribe(senderUuid: string, name: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + subscribe(senderUuid: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Unsubscribes to messages from the specified application on the specified topic. + */ + unsubscribe(senderUuid: string, name: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + unsubscribe(senderUuid: string, topic: string, listener: (message: any, uuid: string, name: string) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + } + + interface OpenFinNotificationStatic { + /** + * ctor + */ + new (options: NotificationOptions, callback?: () => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): OpenFinNotification; + /** + * Gets an instance of the current notification. For use within a notification window to close the window or send a message back to its parent application. + */ + getCurrent(): OpenFinNotification; + } + + /** + * Notification + * Notification represents a window on OpenFin Runtime which is shown briefly to the user on the bottom-right corner of the primary monitor. A notification is typically used to alert the user of some important event which requires his or her attention. Notifications are a child or your application that are controlled by the runtime. + */ + interface OpenFinNotification { + /** + * Closes the notification. + */ + close(callback?: () => void): void; + /** + * Sends a message to the notification. + */ + sendMessage(message: any, callback?: () => void): void; + /** + * Sends a message from the notification to the application that created the notification. The message is handled by the notification's onMessage callback. + */ + sendMessageToApplication(message: any, callback?: () => void): void; + } + + interface NotificationOptions { + /** + * A boolean that will force dismissal even if the mouse is hovering over the notification + */ + ignoreMouseOver?: boolean; + /** + * A message of any primitive or composite-primitive type to be passed to the notification upon creation. + */ + message?: any; + /** + * The timeout for displaying a notification.Can be in milliseconds or "never". + */ + duration?: number | "never"; + /** + * The url of the notification + */ + url?: string; + /** + * A function that is called when a notification is clicked. + */ + onClick?(callback: () => void): void; + /** + * Invoked when the notification is closed via .close() method on the created notification instance or the by the notification itself via fin.desktop.Notification.getCurrent().close(). NOTE: this is not invoked when the notification is dismissed via a swipe. For the swipe dismissal callback see onDismiss + */ + onClose?(callback: () => void): void; + /** + * Invoked when a the notification is dismissed by swiping it off the screen to the right. NOTE: this is no fired on a programmatic close. + */ + onDismiss?(callback: () => void): void; + /** + * A function that is called when an error occurs.The reason for the error is passed as an argument. + */ + onError?(errorCallback: (reason: string, errorObj: NetworkErrorInfo) => void): void; + /** + * The onMessage function will respond to messages sent from notification.sendMessageToApplication.The function is passed the message, which can be of any primitive or composite-primitive type. + */ + onMessage?(callback: (message: any) => void): void; + /** + * A function that is called when a notification is shown. + */ + onShow?(callback: (successObj: SuccessObj) => void): void; + } + + /** + * System + * An object representing the core of OpenFin Runtime. Allows the developer to perform system-level actions, such as accessing logs, viewing processes, clearing the cache and exiting the runtime. + */ + interface OpenFinSystem { + /** + * + */ + Clipboard: OpenFinClipboard; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinSystemEventType, listener: (event: SystemBaseEvent | DesktopIconClickedEvent | IdleStateChangedEvent | MonitorInfoChangedEvent | SessionChangedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Clears cached data containing window state/positions, application resource files (images, HTML, JavaScript files), cookies, and items stored in the Local Storage. + */ + clearCache(options: CacheOptions, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Clears all cached data when OpenFin Runtime exits. + */ + deleteCacheOnExit(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Downloads the given application asset + */ + downloadAsset(assetObj: AppAssetInfo, progressListener?: (progress: { downloadedBytes: number, totalBytes: number }) => void, callback?: (successObj: { path: string }) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): void; + /** + * Exits the Runtime. + */ + exit(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of data for all applications. + */ + getAllApplications(callback?: (applicationInfoList: ApplicationInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of data for all external applications. + */ + getAllExternalApplications(callback?: (applicationInfoList: ApplicationInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of data (name, ids, bounds) for all application windows. + */ + getAllWindows(callback?: (windowInfoList: WindowDetails[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the command line argument string that started OpenFin Runtime. + */ + getCommandLineArguments(callback?: (args: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the configuration object that started the OpenFin Runtime. + */ + getDeviceId(callback?: (uuid: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the value of a given environment variable on the computer on which the runtime is installed. + */ + getEnvironmentVariable(envVar: string, callback?: (variable: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves system information. + */ + getHostSpecs(callback?: (info: HostSpecInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the contents of the log with the specified filename. + */ + getLog(logFileName: string, callback?: (variable: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array containing information for each log file. + */ + getLogList(callback?: (logInfoList: LogInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an object that contains data about the about the monitor setup of the computer that the runtime is running on. + */ + getMonitorInfo(callback?: (monitorInfo: MonitorInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Returns the mouse in virtual screen coordinates (left, top). + */ + getMousePosition(callback?: (mousePosition: VirtualScreenCoordinates) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array of all of the runtime processes that are currently running. Each element in the array is an object containing the uuid and the name of the application to which the process belongs. + */ + getProcessList(callback?: (processInfoList: ProcessInfo[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves the Proxy settings. + */ + getProxySettings(callback?: (proxy: ProxyInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Returns information about the running RVM in an object. + */ + getRvmInfo(callback?: (rvmInfo: RvmInfo) => void, errorCallback?: (reason: string) => void): void; + /** + * Returns the version of the runtime. The version contains the major, minor, build and revision numbers. + */ + getVersion(callback?: (version: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Runs an executable or batch file. + */ + launchExternalProcess(options: ExternalProcessLaunchInfo, callback?: (payload: { uuid: string }) => void, errorCallback?: (reason: string) => void): void; + /** + * Writes the passed message into both the log file and the console. + */ + log(level: "debug" | "info" | "warn" | "error", message: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Monitors a running process. + */ + monitorExternalProcess(options: ExternalProcessInfo, callback?: (payload: { uuid: string }) => void, errorCallback?: (reason: string) => void): void; + /** + * Opens the passed URL in the default web browser. + */ + openUrlWithBrowser(url: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * This function call will register a unique id and produce a token. The token can be used to broker an external connection. + */ + registerExternalConnection(uuid: string, callback?: (detail: { + /** + * this will be unique each time + */ + token: string; + /** + * "remote-connection-uuid" + */ + uuid: string; + }) => void, errorCallback?: (reason: string) => void): void; + /** + * Removes the process entry for the passed UUID obtained from a prior call of fin.desktop.System.launchExternalProcess(). + */ + releaseExternalProcess(processUuid: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinSystemEventType, listener: (event: SystemBaseEvent | DesktopIconClickedEvent | IdleStateChangedEvent | MonitorInfoChangedEvent | SessionChangedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Shows the Chrome Developer Tools for the specified window. + */ + showDeveloperTools(uuid: string, name: string, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Attempt to close an external process. The process will be terminated if it has not closed after the elapsed timeout in milliseconds. + */ + terminateExternalProcess(processUuid: string, timeout: number, killTree: boolean, callback?: (info: { result: "clean" | "terminated" | "failed" }) => void, errorCallback?: (reason: string) => void): void; + terminateExternalProcess(processUuid: string, timeout: number, callback?: (info: { result: "clean" | "terminated" | "failed" }) => void, errorCallback?: (reason: string) => void): void; + /** + * Update the OpenFin Runtime Proxy settings. + */ + updateProxySettings(type: string, address: string, port: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + + } + + interface CacheOptions { + cache?: boolean; + cookies?: boolean; + localStorage?: boolean; + appcache?: boolean; + userData?: boolean; + } + + interface AppAssetInfo { + src?: string; + alias?: string; + version?: string; + target?: string; + args?: string; + } + + interface ApplicationInfo { + /** + * true when the application is running. + */ + isRunning?: boolean; + /** + * uuid of the application. + */ + uuid?: string; + /** + * uuid of the application that launches this application. + */ + parentUuid?: string; + } + + interface WindowDetails { + uuid?: string; + mainWindow?: WindowInfo; + childWindows?: WindowInfo[]; + } + + interface WindowInfo { + /** + * name of the child window + */ + name?: string; + /** + * top-most coordinate of the child window + */ + top?: number; + /** + * right-most coordinate of the child window + */ + right?: number; + /** + * bottom-most coordinate of the child window + */ + bottom?: number; + /** + * left-most coordinate of the child window + */ + left?: number; + } + + interface HostSpecInfo { + /** + * "x86" for 32-bit or "x86_64" for 64-bit + */ + arch: string; + /** + * Same payload as Node's os.cpus() + */ + cpus: NodeCpuInfo[]; + /** + * + */ + gpu: { + /** + * Graphics card name + */ + name: string; + }; + /** + * Same payload as Node's os.totalmem() + */ + memory: number; + /** + * OS name and version/edition + */ + name: string; + } + + interface NodeCpuInfo { + model: string; + /** + * in MHz + */ + speed: number; + times: { + /** + * The number of milliseconds the CPU has spent in user mode. + */ + user: number; + /** + * The number of milliseconds the CPU has spent in nice mode. + */ + nice: number; + /** + * The number of milliseconds the CPU has spent in sys mode. + */ + sys: number; + /** + * The number of milliseconds the CPU has spent in idle mode. + */ + idle: number; + /** + * The number of milliseconds the CPU has spent in irq mode. + */ + irq: number; + }; + } + + interface LogInfo { + /** + * the filename of the log + */ + name?: string; + /** + * the size of the log in bytes + */ + size?: number; + /** + * the unix time at which the log was created "Thu Jan 08 2015 14:40:30 GMT-0500 (Eastern Standard Time)" + */ + date?: string; + } + + interface ProcessInfo { + /** + * the percentage of total CPU usage + */ + cpuUsage?: number; + /** + * the application name + */ + name?: string; + /** + * the current nonpaged pool usage in bytes + */ + nonPagedPoolUsage?: number; + /** + * the number of page faults + */ + pageFaultCount?: number; + /** + * the current paged pool usage in bytes + */ + pagedPoolUsage?: number; + /** + * the total amount of memory in bytes that the memory manager has committed + */ + pagefileUsage?: number; + /** + * the peak nonpaged pool usage in bytes + */ + peakNonPagedPoolUsage?: number; + /** + * the peak paged pool usage in bytes + */ + peakPagedPoolUsage?: number; + /** + * the peak value in bytes of pagefileUsage during the lifetime of this process + */ + peakPagefileUsage?: number; + /** + * the peak working set size in bytes + */ + peakWorkingSetSize?: number; + /** + * the native process identifier + */ + processId?: number; + /** + * the application UUID + */ + uuid?: string; + /** + * the current working set size (both shared and private data) in bytes + */ + workingSetSize?: number; + } + + interface ProxyInfo { + /** + * the configured Proxy Address + */ + proxyAddress?: string; + /** + * the configured Proxy port + */ + proxyPort?: number; + /** + * Proxy Type + */ + type?: string; + } + + interface RvmInfo { + version?: string; + "start-time"?: string; + } + + interface ExternalProcessLaunchInfo { + path?: string; + /** + * Additionally note that the executable found in the zip file specified in appAssets + * will default to the one mentioned by appAssets.target + * If the the path below refers to a specific path it will override this default + */ + alias?: string; + /** + * When using alias; if no arguments are passed then the arguments (if any) + * are taken from the 'app.json' file, from the 'args' parameter + * of the 'appAssets' Object with the relevant 'alias'. + * If 'arguments' is passed as a parameter it takes precedence + * over any 'args' set in the 'app.json'. + */ + arguments?: string; + listener?: (result: { + /** + * "Exited" Or "released" on a call to releaseExternalProcess + */ + topic?: string; + /** + * The mapped UUID which identifies the launched process + */ + uuid?: string; + /* + * Process exit code + */ + exitCode?: number; + }) => void; + certificate?: CertificationInfo; + } + + interface CertificationInfo { + /** + * A hex string with or without spaces + */ + serial?: string; + /** + * An internally tokenized and comma delimited string allowing partial or full checks of the subject fields + */ + subject?: string; + /** + * A hex string with or without spaces + */ + publickey?: string; + /** + * A hex string with or without spaces + */ + thumbprint?: string; + /** + * A boolean indicating that the certificate is trusted and not revoked + */ + trusted?: boolean; + } + + interface ExternalProcessInfo { + pid?: number; + listener?: (result: { + /** + * "Exited" Or "released" on a call to releaseExternalProcess + */ + topic?: string; + /** + * The mapped UUID which identifies the launched process + */ + uuid?: string; + /* + * Process exit code + */ + exitCode?: number; + }) => void; + } + + interface OpenFinWindowStatic { + /** + * Class: Window + * + * new Window(options, callbackopt, errorCallbackopt) + * + * Creates a new OpenFin Window + * + * A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window. + * @param {any} options - The options of the window + * @param {Function} [callback] - Called if the window creation was successful + * @param {number} [callback.successObj] - httpResponseCode + */ + new (options: WindowOptions, callback?: (successObj: { httpResponseCode: number }) => void, errorCallback?: (reason: string, errorObj: NetworkErrorInfo) => void): OpenFinWindow; + /** + * Returns an instance of the current window. + * @returns {OpenFinWindow} Current window + */ + getCurrent(): OpenFinWindow; + /** + * Returns a Window object that wraps an existing window. + */ + wrap(appUuid: string, windowName: string): OpenFinWindow; + } + + /** + * Window + * A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window. + */ + interface OpenFinWindow { + /** + * Name of window + */ + name: string; + /** + * Returns the native JavaScript "window" object for the window. This method can only be used by the parent application or the window itself, otherwise it will return undefined. The same Single-Origin-Policy (SOP) rules apply for child windows created by window.open(url) in that the contents of the window object are only accessible if the URL has the same origin as the invoking window. See example below. Also, will not work with fin.desktop.Window objects created with fin.desktop.Window.wrap(). + * @returns {Window} Native window + */ + getNativeWindow(): Window; + /** + * Gets the parent application. + * @returns {OpenFinApplication} Parent application + */ + getParentApplication(): OpenFinApplication; + /** + * Gets the parent window. + */ + getParentWindow(): OpenFinWindow; + /** + * Registers an event listener on the specified event. + */ + addEventListener(type: OpenFinWindowEventType, listener: (event: WindowBaseEvent | WindowAuthRequestedEvent | WindowBoundsEvent | WindowExternalProcessStartedEvent | WindowExternalProcessExited | WindowGroupChangedEvent | WindowHiddenEvent | Window_NavigationRejectedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Performs the specified window transitions + */ + animate(transitions: AnimationTransition, options: AnimationOptions, callback?: (event: any) => void, errorCallback?: (reason: string) => void): void; + /** + * Provides credentials to authentication requests + */ + authenticate(userName: string, password: string, callback?: () => void, errorCallback?: (reason: string, error: ErrorInfo) => void): void; + /** + * Removes focus from the window. + */ + blur(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Brings the window to the front of the OpenFin window stack. + */ + bringToFront(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Closes the window. + * @param {force} Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window. + */ + close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Prevents a user from changing a window's size/position when using the window's frame. + * 'disabled-frame-bounds-changing' is generated at the start of and during a user move/size operation. + * 'disabled-frame-bounds-changed' is generated after a user move/size operation. + * The events provide the bounds that would have been applied if the frame was enabled. + * 'frame-disabled' is generated when an enabled frame becomes disabled. + */ + disableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Re-enables user changes to a window's size/position when using the window's frame. + * 'disabled-frame-bounds-changing' is generated at the start of and during a user move/size operation. + * 'disabled-frame-bounds-changed' is generated after a user move/size operation. + * The events provide the bounds that would have been applied if the frame was enabled. + * 'frame-enabled' is generated when a disabled frame has becomes enabled. + */ + enableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Flashes the window’s frame and taskbar icon until the window is activated. + */ + flash(options?: any, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Gives focus to the window. + */ + focus(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the current bounds (top, left, width, height) of the window. + */ + getBounds(callback?: (bounds: WindowBounds) => void, errorCallback?: (reason: string) => void): void; + /** + * Retrieves an array containing wrapped fin.desktop.Windows that are grouped with this window. If a window is not in a group an empty array is returned. Please note that calling window is included in the result array. + */ + getGroup(callback?: (group: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the current settings of the window. + */ + getOptions(callback?: (options: WindowOptions) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets a base64 encoded PNG snapshot of the window. + */ + getSnapshot(callback?: (base64Snapshot: string) => void, errorCallback?: (reason: string) => void): void; + /** + * Gets the current state ("minimized", "maximized", or "restored") of the window. + */ + getState(callback?: (state: "minimized" | "maximized" | "restored") => void, errorCallback?: (reason: string) => void): void; + /** + * Returns the zoom level of the window. + */ + getZoomLevel(callback?: (level: number) => void, errorCallback?: (reason: string) => void): void; + /** + * Hides the window. + */ + hide(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Determines if the window is currently showing. + */ + isShowing(callback?: (showing: boolean) => void, errorCallback?: (reason: string) => void): void; + /** + * Joins the same window group as the specified window. + */ + joinGroup(target: OpenFinWindow, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Leaves the current window group so that the window can be move independently of those in the group. + */ + leaveGroup(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Maximizes the window. + */ + maximize(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Merges the instance's window group with the same window group as the specified window + */ + mergeGroups(target: OpenFinWindow, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Minimizes the window. + */ + minimize(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Moves the window by a specified amount. + */ + moveBy(deltaLeft: number, deltaTop: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Moves the window to a specified location. + */ + moveTo(left: number, top: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Removes a previously registered event listener from the specified event. + */ + removeEventListener(type: OpenFinWindowEventType, listener: (event: WindowBaseEvent | WindowAuthRequestedEvent | WindowBoundsEvent | WindowExternalProcessStartedEvent | WindowExternalProcessExited | WindowGroupChangedEvent | WindowHiddenEvent | Window_NavigationRejectedEvent) => void, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Resizes the window by a specified amount. + */ + resizeBy(deltaWidth: number, deltaHeight: number, anchor: OpenFinAnchor, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Resizes the window by a specified amount. + */ + resizeTo(width: number, height: number, anchor: OpenFinAnchor, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Restores the window to its normal state (i.e., unminimized, unmaximized). + */ + restore(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Will bring the window to the front of the entire stack and give it focus. + */ + setAsForeground(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sets the window's size and position + */ + setBounds(left: number, top: number, width: number, height: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Sets the zoom level of the window. + */ + setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Shows the window if it is hidden. + * @param {force} Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window. + */ + show(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Shows the window if it is hidden at the specified location. If the toggle parameter is set to true, the window will alternate between showing and hiding. + */ + showAt(left: number, top: number, force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Stops the taskbar icon from flashing. + */ + stopFlashing(callback?: () => void, errorCallback?: (reason: string) => void): void; + /** + * Updates the window using the passed options + */ + updateOptions(options: WindowOptions, callback?: () => void, errorCallback?: (reason: string) => void): void; + } + + interface ApplicationBaseEvent { + topic: string; + type: OpenFinApplicationEventType; + uuid: string; + } + + interface TrayIconClickedEvent extends ApplicationBaseEvent { + button: number; // 0 for left, 1 for middle, 2 for right + monitorInfo: MonitorInfo; + x: number; // the cursor x coordinate + y: number; // the cursor y coordinate + } + + interface WindowEvent extends ApplicationBaseEvent { + name: string; + } + + interface WindowAlertRequestedEvent extends WindowEvent { + message: string; + url: string; + } + + interface WindowAuthRequested extends WindowEvent { + authInfo: { + host: string; + isProxy: boolean; + port: number; + realm: string; + scheme: string; + }; + } + + interface WindowNavigationRejectedEvent extends WindowEvent { + sourceName: string; + url: string; + } + + interface WindowEndLoadEvent extends WindowEvent { + documentName: string; + isMain: boolean; + } + + interface MonitorInfoChangedEvent extends MonitorInfo { + topic: "system"; + type: "monitor-info-changed"; + } + + interface MonitorInfo { + nonPrimaryMonitors: MonitorInfoDetail[]; + primaryMonitor: MonitorInfoDetail; + reason: string; + taskbar: { + edge: "left" | "right" | "top" | "bottom", + rect: MontiorCoordinates + }; + topic: "system"; + type: "monitor-info-changed"; + virtualScreen: MontiorCoordinates; + } + + interface MonitorInfoDetail { + availableRect: MontiorCoordinates; + deviceId: string; + displayDeviceActive: boolean; + monitorRect: MontiorCoordinates; + name: string; + } + + interface MontiorCoordinates { + bottom: number; + left: number; + right: number; + top: number; + } + + interface VirtualScreenCoordinates { + left: number; + top: number; + } + + interface SystemBaseEvent { + topic: string; + type: OpenFinSystemEventType; + uuid: string; + } + + interface DesktopIconClickedEvent { + mouse: { + /** + * the left virtual screen coordinate of the mouse + */ + left: number, + /** + * the top virtual screen coordinate of the mouse + */ + top: number + }; + /** + * the number of milliseconds that have elapsed since the system was started, + */ + tickCount: number; + topic: "system"; + type: "desktop-icon-clicked"; + } + + interface IdleStateChangedEvent { + /** + * How long in milliseconds since the user has been idle. + */ + elapsedTime: number; + /** + * true when the user is idle,false when the user has returned; + */ + isIdle: boolean; + topic: "system"; + type: "idle-state-changed"; + } + + interface WindowBaseEvent { + /** + * the name of the window + */ + name: string; + /** + * always window + */ + topic: "window"; + /** + * window event type + */ + type: OpenFinWindowEventType; + /** + * the UUID of the application the window belongs to + */ + uuid: string; + } + + interface WindowAuthRequestedEvent extends WindowBaseEvent { + authInfo: { + host: string; + isProxy: boolean; + port: number; + realm: string; + scheme: string; + }; + } + + interface WindowBoundsEvent extends WindowBaseEvent { + /** + * describes what kind of change occurred. + * 0 means a change in position. + * 1 means a change in size. + * 2 means a change in position and size. + */ + changeType: number; + /** + * true when pending changes have been applied to the window. + */ + deferred: boolean; + /** + * the new height of the window. + */ + height: number; + /** + * the left-most coordinate of the window. + */ + left: number; + /** + * the top-most coordinate of the window. + */ + top: number; + /** + * + */ + type: "bounds-changed" | "bounds-changing" | "disabled-frame-bounds-changed" | "disabled-frame-bounds-changing"; + /** + * the new width of the window. + */ + width: number; + } + + interface WindowExternalProcessStartedEvent extends WindowBaseEvent { + /** + * the process handle uuid + */ + processUuid: string; + type: "external-process-started"; + } + + interface WindowExternalProcessExited extends WindowBaseEvent { + /** + * the process exit code + */ + exitCode: number; + /** + * the process handle uuid + */ + processUuid: string; + type: "external-process-exited"; + } + + interface WindowGroupChangedEvent extends WindowBaseEvent { + /** + * Which group array the window that the event listener was registered on is included in: + * 'source' The window is included in sourceGroup. + * 'target' The window is included in targetGroup. + * 'nothing' The window is not included in sourceGroup nor targetGroup. + */ + memberOf: "source" | "target" | "nothing"; + /** + * The reason this event was triggered. + * 'leave' A window has left the group due to a leave or merge with group. + * 'join' A window has joined the group. + * 'merge' Two groups have been merged together. + * 'disband' There are no other windows in the group. + */ + reason: "leave" | "join" | "merge" | "disband"; + /** + * All the windows in the group the sourceWindow originated from. + */ + sourceGroup: WindowOfGroupInfo[]; + /** + * The UUID of the application the sourceWindow belongs to The source window is the window in which (merge/join/leave)group(s) was called. + */ + sourceWindowAppUuid: string; + /** + * the name of the sourcewindow.The source window is the window in which(merge / join / leave) group(s) was called. + */ + sourceWindowName: string; + /** + * All the windows in the group the targetWindow orginated from + */ + targetGroup: WindowOfGroupInfo[]; + /** + * The UUID of the application the targetWindow belongs to. The target window is the window that was passed into (merge/join) group(s). + */ + targetWindowAppUuid: string; + /** + * The name of the targetWindow. The target window is the window that was passed into (merge/join) group(s). + */ + targetWindowName: string; + type: "group-changed"; + } + + interface WindowOfGroupInfo { + /** + * The UUID of the application this window entry belongs to. + */ + appUuid: string; + /** + * The name of this window entry. + */ + windowName: string; + } + + interface WindowHiddenEvent extends WindowBaseEvent { + /** + * What action prompted the close. + * The reasons are: "hide", "hide-on-close" + */ + reason: "hide" | "hide-on-close"; + type: "hidden"; + } + + interface Window_NavigationRejectedEvent { + name: string; + /** + * source of navigation window name + */ + sourceName: string; + topic: "navigation-rejected"; + /** + * Url that was not reached "http://blocked-content.url" + */ + url: string; + /** + * the UUID of the application the window belongs to. + */ + uuid: string; + } + + interface AnimationTransition { + opacity?: { + /** + * This value is clamped from 0.0 to 1.0 + */ + opacity?: number; + /** + * The total time in milliseconds this transition should take. + */ + duration?: number; + /** + * Treat 'opacity' as absolute or as a delta. Defaults to false. + */ + relative?: boolean; + }; + position?: { + /** + * Defaults to the window's current left position in virtual screen coordinates. + */ + left?: number; + /** + * Defaults to the window's current top position in virtual screen coordinates. + */ + top?: number; + /** + * The total time in milliseconds this transition should take. + */ + duration?: number; + /** + * Treat 'left' and 'top' as absolute or as deltas. Defaults to false. + */ + relative?: boolean; + }; + size?: { + /** + * Optional if height is present. Defaults to the window's current width. + */ + width?: number; + /** + * Optional if width is present. Defaults to the window's current height. + */ + height?: number; + /** + * The total time in milliseconds this transition should take. + */ + duration?: number; + /** + * Treat 'width' and 'height' as absolute or as deltas. Defaults to false. + */ + relative?: boolean; + }; + } + + interface AnimationOptions { + /** + * This option interrupts the current animation. When false it pushes this animation onto the end of the animation queue. + */ + interrupt?: boolean; + /** + * Transition effect. Defaults to 'ease-in-out'. + */ + tween?: OpenFinTweenType; + } + + interface WindowBounds { + /** + * the height of the window. + */ + height?: number; + /** + * left-most coordinate of the window. + */ + left?: number; + /** + * top-most coordinate of the window. + */ + top?: number; + /** + * the width of the window. + */ + width?: number; + } + + interface SessionChangedEvent { + /** + * the action that triggered this event: + */ + reason: "lock" + | "unlock" + | "remote-connect" + | "remote-disconnect" + | "unknown"; + topic: "system"; + type: "session-changed"; + } + + type OpenFinTweenType = "linear" + | "ease-in" + | "ease-out" + | "ease-in-out" + | "ease-in-quad" + | "ease-out-quad" + | "ease-in-out-quad" + | "ease-in-cubic" + | "ease-out-cubic" + | "ease-in-out-cubic" + | "ease-out-bounce" + | "ease-in-back" + | "ease-out-back" + | "ease-in-out-back" + | "ease-in-elastic" + | "ease-out-elastic" + | "ease-in-out-elastic"; + + type OpenFinApplicationEventType = "closed" + | "connected" + | "crashed" + | "initialized" + | "manifest-changed" + | "not-responding" + | "out-of-memory" + | "responding" + | "run-requested" + | "started" + | "tray-icon-clicked" + | "window-alert-requested" + | "window-auth-requested" + | "window-closed" + | "window-created" + | "window-end-load" + | "window-navigation-rejected" + | "window-show-requested" + | "window-start-load"; + + type OpenFinExternalApplicationEventType = "connected" + | "disconnected"; + + type OpenFinSystemEventType = "application-closed" + | "application-crashed" + | "application-created" + | "application-started" + | "desktop-icon-clicked" + | "idle-state-changed" + | "monitor-info-changed" + | "session-changed"; + + type OpenFinWindowEventType = "auth-requested" + | "blurred" + | "bounds-changed" + | "bounds-changing" + | "close-requested" + | "closed" + | "disabled-frame-bounds-changed" + | "disabled-frame-bounds-changing" + | "embedded" + | "external-process-exited" + | "external-process-started" + | "focused" + | "frame-disabled" + | "frame-enabled" + | "group-changed" + | "hidden" + | "initialized" + | "maximized" + | "minimized" + | "navigation-rejected" + | "restored" + | "show-requested" + | "shown"; + + type OpenFinAnchor = "top-left" + | "top-right" + | "bottom-left" + | "bottom-right"; +} \ No newline at end of file diff --git a/openfin/v16/openfin-tests.ts b/openfin/v16/openfin-tests.ts new file mode 100644 index 0000000000..81ac24f937 --- /dev/null +++ b/openfin/v16/openfin-tests.ts @@ -0,0 +1,724 @@ +function test_application() { + let application: fin.OpenFinApplication; + // constructor + application = new fin.desktop.Application({ + url: "application.html", + uuid: "74BED629-2D8E-4141-8582-73E364BDFA74", + name: "Application Name", + plugins: false, + mainWindowOptions: { + defaultHeight: 600, + defaultWidth: 800, + defaultTop: 300, + defaultLeft: 300, + autoShow: true + } + }, function (successObj) { + console.log("Application successfully created, HTTP response code:", successObj); + application.run(); + }, function (error) { + console.log("Error creating application:", error); + }); + // getCurrent + application = fin.desktop.Application.getCurrent(); + // wrap + application = fin.desktop.Application.wrap("454C7F31-A915-4EA2-83F2-CFA655453C52"); + // getWindow + application.getWindow(); + // addEventListener + application.addEventListener("closed", function (event) { + console.log("The application has closed"); + }, function () { + console.log("The registration was successful"); + }, function (reason) { + console.log("failure: " + reason); + }); + // close + application.close(); + // getChildWindows + application.getChildWindows(function (children) { + children.forEach(function (childWindow) { + console.log("Showing child: " + childWindow.name); + childWindow.show(); + }); + }); + // getGroups + application.getGroups(function (allGroups) { + console.log("There are a total of " + allGroups.length + " groups."); + + var groupCounter = 1; + allGroups.forEach(function (windowGroup) { + console.log("Group " + groupCounter + " contains " + + windowGroup.length + " windows."); + ++groupCounter; + }); + }); + // getManifest + application.getManifest(function (manifest) { + console.log("Application manifest:"); + console.log(manifest); + }); + // getParentUuid + application.getParentUuid(function (parentUuid) { + console.log("UUID of parent application:"); + console.log(parentUuid); + }); + // getShortcuts + application.getShortcuts(function (config) { + console.log("Desktop shortcut is enabled: ", config.desktop); + console.log("Start Menu shortcut is enabled: ", config.startMenu); + console.log("System Startup shortcut is enabled: ", config.systemStartup); + }); + // isRunning + application.isRunning(function (running) { + console.log("the application is", running ? "running" : "not running"); + }); + // registerCustomData + application.registerCustomData({ + someData: "this is custom" + }, function () { + console.log("You will not read this."); + }, function (err) { + console.log("failure:", err); + }); + // removeEventListener + let previousCallback = function (event: fin.WindowEvent) { }; + application.removeEventListener("closed", previousCallback, function () { + console.log("The unregistration was successful"); + }, function (err) { + console.log("failure:", err); + }); + // removeTrayIcon + application.removeTrayIcon(function () { + console.log("Removed the tray icon."); + }, function (err) { + console.log("failure:", err); + }); + // restart + application.restart(function () { + console.log("You will not read this."); + }, function (err) { + console.log("failure:", err); + }); + // schedule restart + application.scheduleRestart(function () { + console.log("You will not read this."); + }, function (err) { + console.log("failure:", err); + }); + // setShortcuts + application.setShortcuts({ + desktop: true, + startMenu: false, + systemStartup: true + }, function () { + console.log("Successfully set new shortcut states"); + }, function (error) { + console.log("Failed to set new shortcut states. Error: ", error); + }); + // setTrayIcon + application.setTrayIcon("https://developer.openf.in/download/openfin.png", function (clickInfo) { + console.log("The mouse has clicked at (" + clickInfo.x + "," + clickInfo.y + ")"); + }); + // terminate + application.terminate(); + // wait + application.addEventListener("not-responding", function () { + console.log("waiting for hung application"); + application.wait(); + }); +} + +function test_external_application() { + let externalApp: fin.OpenFinExternalApplication; + // wrap + externalApp = fin.desktop.ExternalApp.wrap('my-uuid'); + // addEventListener + externalApp.addEventListener('connected', () => { + console.log('external app connected'); + }, () => { + console.log('The registration was successful'); + }, (reason, err) => { + console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`); + }); + // removeEventListener + let previousCallback = function () { }; + externalApp.removeEventListener('connected', previousCallback, () => { + console.log('The unregistration was successful'); + }, (reason, err) => { + console.log(`Error Message: ${err.message} Error Stack: ${err.stack}`); + }); +} + +function test_inter_application_bus() { + // addSubscribeListener + fin.desktop.InterApplicationBus.addSubscribeListener(function (uuid, topic, name) { + console.log("The application " + uuid + " has subscribed to " + topic); + }); + // addUnsubscribeListener + fin.desktop.InterApplicationBus.addUnsubscribeListener(function (uuid, topic, name) { + console.log("The application " + uuid + " has unsubscribed to " + topic); + }); + // removeSubscribeListener + let aRegisteredListener = function (uuid: string, topic: string, name: string) { }; + fin.desktop.InterApplicationBus.removeSubscribeListener(aRegisteredListener); + // removeUnsubscribeListener + fin.desktop.InterApplicationBus.removeUnsubscribeListener(aRegisteredListener); + // publish + fin.desktop.InterApplicationBus.publish("a topic", { + field1: "value1", + field2: "value2" + }); + // send + fin.desktop.InterApplicationBus.send("an application's uuid", "a topic", { + field1: "value1", + field2: "value2" + }); + // subscribe + fin.desktop.InterApplicationBus.subscribe("*", "a topic", function (message, uuid, name) { + console.log("The application " + uuid + " sent this message: " + message); + }); + // unsubscribe + let aRegisteredMessageListener = function (message: any, senderUuid: string) { + console.log(message, senderUuid); + }; + fin.desktop.InterApplicationBus.unsubscribe("*", "a topic", aRegisteredMessageListener); +} + +function test_notification() { + let notification: fin.OpenFinNotification; + // getCurrent + notification = fin.desktop.Notification.getCurrent(); + // close + notification.close(); + // sendMessage + notification = new fin.desktop.Notification({ + duration: 10, + url: "http://localhost:5000/Account/Register", + message: "Hello", + onShow: () => { }, + //onClose: () => { }, + onDismiss: () => { }, + //onClick: () => { }, + onMessage: () => { }, + onError: () => { } + }); + // sendMessageToApplication + notification.sendMessageToApplication("some message"); +} + +function test_system() { + // addEventListener + fin.desktop.System.addEventListener('monitor-info-changed', function (event) { + console.log("The monitor information has changed to: ", event); + }, function () { + console.log("The registration was successful"); + }, function (err) { + console.log("failure: " + err); + }); + // clearCache + fin.desktop.System.clearCache({ + cache: true, + cookies: true, + localStorage: true, + appcache: true, + userData: true + }); + // deleteCacheOnExit + fin.desktop.System.deleteCacheOnExit(function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // downloadAsset + let dirAppAsset = { + 'src': 'http://local:8000/dir.zip', + 'alias': 'dirApp', + 'version': '1.23.24', + 'target': 'dir.bat', + 'args': '' + }; + fin.desktop.System.downloadAsset(dirAppAsset, progress => { + let downloadedPercent = Math.floor((progress.downloadedBytes / progress.totalBytes) * 100); + console.log(`Downloaded ${downloadedPercent}%`); + }, p => { + console.log(`Downlod complete, can be found on ${p.path}`); + //lets launch our application asset. + //launchDirApp(); + }, (reason, err) => { + console.log(reason, err); + }); + // exit + fin.desktop.System.exit(function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // getAllApplications + fin.desktop.System.getAllApplications(function (applicationInfoList) { + applicationInfoList.forEach(function (applicationInfo) { + console.log("Showing information for application with uuid: " + + applicationInfo.uuid); + console.log("isRunning: ", applicationInfo.isRunning); + }); + }); + // getAllExternalApplications + fin.desktop.System.getAllExternalApplications(externalAppsInfoList => { + externalAppsInfoList.forEach(appInfo => { + console.log(`External app connected to the runtime with UUID ${appInfo.uuid}`); + }); + }); + // getAllWindows + fin.desktop.System.getAllWindows(function (windowInfoList) { + windowInfoList.forEach(function (windowInfo) { + console.log("Showing information for application with uuid: ", windowInfo.uuid); + console.log("Main window: ", windowInfo.mainWindow); + console.log("Child windows: ", windowInfo.childWindows); + }); + }); + // getCommandLineArguments + fin.desktop.System.getCommandLineArguments(function (args) { + console.log("The command line arguments are " + args); + }); + // getDeviceId + fin.desktop.System.getDeviceId(function (id) { + console.log("The id of the device is: " + id); + }); + // getEnvironmentVariable + fin.desktop.System.getEnvironmentVariable("APPDATA", function (variable) { + console.log("this is the APPDATA value", variable); + }); + // getHostSpecs + fin.desktop.System.getHostSpecs(function (info) { + console.log(info); + }, function (error) { + console.log('There was an error:', error); + }); + // getLog + fin.desktop.System.getLog('debug-2015-01-08-22-27-53.log', function (log) { + console.log(log); + }); + // getLogList + fin.desktop.System.getLogList(function (logList) { + logList.forEach(function (logInfo) { + console.log("The filename of the log is " + + logInfo.name + ", the size is " + + logInfo.size + ", and the date of creation is " + + logInfo.date); + }); + }); + // getMonitorInfo + fin.desktop.System.getMonitorInfo(function (monitorInfo) { + console.log("This object contains information about all monitors: ", monitorInfo); + }); + // getMousePosition + fin.desktop.System.getMousePosition(function (mousePosition) { + console.log("The mouse is located at left: " + mousePosition.left + ", top: " + mousePosition.top); + }); + // getProcessList + fin.desktop.System.getProcessList(function (list) { + list.forEach(function (process) { + console.log("UUID: " + process.uuid + ", Application Name: " + process.name); + }); + }); + // getProxySettings + fin.desktop.System.getProxySettings(function (proxy) { + console.log(proxy); + }); + // getRvmInfo + fin.desktop.System.getRvmInfo(function (rvmInfoObject) { + console.log("RVM version:", rvmInfoObject.version); + console.log("RVM has been running since:", rvmInfoObject["start-time"]); + }, function (err) { + console.log("Failed to get rvm info, error message:", err); + }); + // getVersion + fin.desktop.System.getVersion(function (version) { + console.log("The version is " + version); + }); + // launchExternalProcess + fin.desktop.System.launchExternalProcess({ + path: "notepad", + arguments: "", + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // + fin.desktop.System.launchExternalProcess({ + //Additionally note that the executable found in the zip file specified in appAssets + //will default to the one mentioned by appAssets.target + //If the the path below refers to a specific path it will override this default + alias: "myApp", + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // + fin.desktop.System.launchExternalProcess({ + alias: "myApp", + arguments: "e f g", + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // + fin.desktop.System.launchExternalProcess({ + path: "C:\Users\ExampleUser\AppData\Local\OpenFin\OpenFinRVM.exe", + arguments: "--version", + certificate: { + trusted: true, + subject: 'O=OpenFin INC., L=New York, S=NY, C=US', + thumbprint: '‎3c a5 28 19 83 05 fe 69 88 e6 8f 4b 3a af c5 c5 1b 07 80 5b' + }, + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log('Success:', payload.uuid); + }, function (error) { + console.log('Error:', error); + }); + // log + fin.desktop.System.log("info", "An example log message", function () { + console.log("message successfully logged"); + }, function (err) { + console.log(err); + }); + // monitorExternalProcess + fin.desktop.System.monitorExternalProcess({ + pid: 2508, + listener: function (result) { + console.log('the exit code', result.exitCode); + } + }, function (payload) { + console.log("The process is now being monitored: ", payload.uuid); + }, function (error) { + console.log("Error:", error); + }); + // openUrlWithBrowser + fin.desktop.System.openUrlWithBrowser("https://developer.openf.in/", function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // registerExternalConnection + fin.desktop.System.registerExternalConnection("remote-connection-uuid", function () { + console.log(arguments); + }); + // releaseExternalProcess + fin.desktop.System.launchExternalProcess({ + path: "notepad", + arguments: "", + listener: function (result) { + console.log("The exit code", result.exitCode); + } + }, function (result) { + console.log("Result UUID is " + result.uuid); + + //release it. + fin.desktop.System.releaseExternalProcess(result.uuid, function () { + console.log("Process has been unmapped!"); + }, function (reason) { + console.log("failure: " + reason); + }); + }); + // removeEventListener + let aRegisteredListener = (event: fin.SystemBaseEvent) => { }; + fin.desktop.System.removeEventListener("monitor-info-changed", aRegisteredListener, function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // showDeveloperTools + fin.desktop.System.showDeveloperTools("uuid", "name", function () { + console.log("successful"); + }, function (err) { + console.log("failure: " + err); + }); + // terminateExternalProcess + fin.desktop.System.launchExternalProcess({ + // notepad is in the system’s PATH + path: "notepad", + arguments: "", + listener: function (result) { + console.log("The exit code", result.exitCode); + } + }, function (result) { + console.log("Result UUID is " + result.uuid); + + // Attempt to close the process. Terminate after 4 seconds if it + // has not done so. + fin.desktop.System.terminateExternalProcess(result.uuid, 4000, function (info) { + console.log("Termination result " + info.result); + }, function (reason) { + console.log("failure: " + reason); + }); + }); + // updateProxySettings + fin.desktop.System.updateProxySettings("type", "proxyAddress", 8080, function () { + console.log('success'); + }, function (err) { + console.log(err); + }); +} + +function test_system_clipboard() { + // availableFormats + fin.desktop.System.Clipboard.availableFormats(null, formats => { + formats.forEach(format => console.log(`The format ${format} is available to read`)); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // readHtml + fin.desktop.System.Clipboard.readHtml(null, html => { + console.log(`This is the html from the clipboard: ${html}`); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // readRtf + fin.desktop.System.Clipboard.readRtf(null, rtf => { + console.log(`This is the rtf from the clipboard: ${rtf}`); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // readText + fin.desktop.System.Clipboard.readText(null, text => { + console.log(`This is the text from the clipboard: ${text}`); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // write + fin.desktop.System.Clipboard.write({ + text: 'Hello Text!', + html: '

Hello Html

', + rtf: 'Hello Rtf' + }, null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // writeHtml + fin.desktop.System.Clipboard.writeHtml('

Hello World

', null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // writeRtf + fin.desktop.System.Clipboard.writeRtf('Hello World!', null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); + // writeText + fin.desktop.System.Clipboard.writeText('Hello World', null, () => { + console.log('Success!!'); + }, (reason, err) => { + console.log(`Error while reading the clipboard Message: ${err.message}, Stack: ${err.stack}`); + }); +} + +function test_window() { + let finWindow: fin.OpenFinWindow; + // constructor + finWindow = new fin.desktop.Window({ + name: "childWindow", + url: "child.html", + defaultWidth: 320, + defaultHeight: 320, + defaultTop: 10, + defaultLeft: 300, + frame: false, + resizable: false, + state: "normal" + }, function () { + var _win = finWindow.getNativeWindow(); + _win.addEventListener("DOMContentLoaded", function () { finWindow.show(); }); + }, function (error) { + console.log("Error creating window:", error); + }); + // getCurrent + finWindow = fin.desktop.Window.getCurrent(); + // getNativeWindow + let nativeWindow: Window; + nativeWindow = finWindow.getNativeWindow(); + // getParentApplication + let parentApp: fin.OpenFinApplication; + parentApp = finWindow.getParentApplication(); + // getParentWindow + let parentFinWindow: fin.OpenFinWindow; + parentFinWindow = finWindow.getParentWindow(); + // wrap + finWindow = fin.desktop.Window.wrap("uuid", "name"); + // addEventListener + finWindow.addEventListener("bounds-changed", function (event) { + console.log("The window has been moved or resized"); + }, function () { + console.log("The registration was successful"); + }, function (reason) { + console.log("failure:" + reason); + }); + // animate + finWindow.animate({ + opacity: { + opacity: 0.15, + duration: 1000 + }, + position: { + left: 10, + top: 10, + duration: 3000 + } + }, { + interrupt: false + }, function (evt) { + // Callback will only fire after both "opacity" and "position" have finished animating. + }); + // authenticate + finWindow.addEventListener('auth-requested', evt => { + finWindow.authenticate('userName', 'P@assw0rd', () => { }, (reason, err) => { + console.log("failure:", err); + }); + }); + // blur + finWindow.blur(); + // bringToFront + finWindow.bringToFront(); + // close + finWindow.close(); + // disableFrame + finWindow.disableFrame(); + // enableFrame + finWindow.enableFrame(); + // flash + finWindow.flash(); + // focus + finWindow.focus(); + // getBounds + finWindow.getBounds(function (bounds) { + console.log("top: " + bounds.top + + "left: " + bounds.left + + "height: " + bounds.height + + "width: " + bounds.width); + }); + // getOptions + finWindow.getOptions(function (options) { + console.log(options); + }); + // getSnapshot + finWindow.getSnapshot(function (base64Snapshot) { + console.log("data:image/png;base64," + base64Snapshot); + }); + // getState + finWindow.getState(function (state) { + console.log("state: " + state); + }); + // getZoomLevel + finWindow.getZoomLevel(function (level) { + console.log("zoom level: " + level); + }, function (error) { + console.log('error:', error); + }); + // hide + finWindow.hide(); + // isShowing + finWindow.isShowing(function (showing) { + console.log("the window is " + (showing ? "showing" : "hidden")); + }); + // joinGroup + let secondWindow = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "secondWindow", + autoShow: true + }, function () { + // When mainWindow moves or is moved, secondWindow moves by the same amount + secondWindow.joinGroup(finWindow); + }); + // leaveGroup + secondWindow = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "secondWindow", + autoShow: true + }, function () { + // When finWindow moves or is moved, secondWindow moves by the same amount + secondWindow.joinGroup(finWindow, function () { + //once we are in the group, lets leave it. + secondWindow.leaveGroup(); + }); + }); + // maximize + finWindow.maximize(); + // mergeGroups + { + let finWindowOne = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowOne", + autoShow: true + }); + let finWindowTwo = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowTwo", + autoShow: true + }); + let finWindowThree = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowThree", + autoShow: true + }); + let finWindowFour = new fin.desktop.Window({ + url: "http://www.openfin.co", + name: "finWindowFour", + autoShow: true + }); + // When finWindowOne moves or is moved, finWindowTwo moves by the same amount + finWindowOne.joinGroup(finWindowTwo); + // When finWindowThree moves or is moved, finWindowFour moves by the same amount + finWindowThree.joinGroup(finWindowFour); + // finWindowOne, finWindowTwo, finWindowThree, and finWindowFour now move together in the same group + finWindowOne.mergeGroups(finWindowThree); + } + // minimize + finWindow.minimize(); + // moveBy + finWindow.moveBy(10, 10); + // moveTo + finWindow.moveTo(100, 200); + // removeEventListener + let aRegisteredListener = (event: fin.WindowBaseEvent) => { }; + finWindow.removeEventListener("bounds-changed", aRegisteredListener); + // resizeBy + finWindow.resizeBy(10, 10, "top-right"); + // resizeTo + finWindow.resizeTo(10, 10, "top-right"); + // restore + finWindow.restore(); + // setAsForeground + finWindow.setAsForeground(); + // setBounds + finWindow.setBounds(100, 200, 400, 400); + // setZoomLevel + finWindow.setZoomLevel(10); + // show + finWindow.show(); + // showAt + finWindow.showAt(10, 10, false); + // stopFlashing + finWindow.stopFlashing(); + // updateOptions + finWindow.updateOptions({ + frame: false, + maxWidth: 500 + }); +} \ No newline at end of file diff --git a/openfin/v16/tsconfig.json b/openfin/v16/tsconfig.json new file mode 100644 index 0000000000..24629d90e4 --- /dev/null +++ b/openfin/v16/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "types": [], + "paths": { + "openfin": [ + "openfin/v16" + ] + }, + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "openfin-tests.ts" + ] +} diff --git a/openfin/v16/tslint.json b/openfin/v16/tslint.json new file mode 100644 index 0000000000..af53769b6b --- /dev/null +++ b/openfin/v16/tslint.json @@ -0,0 +1 @@ +{ "extends": "../../tslint.json" } From f36d20dcd0aa4f92c02cbdea3638083cfd2a58e2 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Tue, 21 Feb 2017 00:14:41 +0000 Subject: [PATCH 014/258] Fixed tslint and test issue that showed up on travis --- openfin/index.d.ts | 12 ++++++------ openfin/v16/tsconfig.json | 5 ++++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/openfin/index.d.ts b/openfin/index.d.ts index 893a253606..f0803864ae 100644 --- a/openfin/index.d.ts +++ b/openfin/index.d.ts @@ -307,8 +307,8 @@ declare namespace fin { size?: number; /** * The size in pixels of an additional - * square resizable region located at the - * bottom right corner of a + * square resizable region located at the + * bottom right corner of a * frameless window. (Default: 4) */ bottomRightCorner?: number; @@ -941,11 +941,11 @@ declare namespace fin { interface OpenFinWindowStatic { /** * Class: Window - * + * * new Window(options, callbackopt, errorCallbackopt) - * + * * Creates a new OpenFin Window - * + * * A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window. * @param {any} options - The options of the window * @param {Function} [callback] - Called if the window creation was successful @@ -982,7 +982,7 @@ declare namespace fin { * @returns {OpenFinApplication} Parent application */ getParentApplication(): OpenFinApplication; - /** + /** * Gets the parent window. */ getParentWindow(): OpenFinWindow; diff --git a/openfin/v16/tsconfig.json b/openfin/v16/tsconfig.json index 24629d90e4..88e1dbe7fa 100644 --- a/openfin/v16/tsconfig.json +++ b/openfin/v16/tsconfig.json @@ -1,7 +1,10 @@ { "compilerOptions": { "module": "commonjs", - "target": "es6", + "lib": [ + "es6", + "dom" + ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From a4ba9a452279b77f8c28d2506093f8956db94740 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Tue, 21 Feb 2017 00:24:31 +0000 Subject: [PATCH 015/258] And fixed one more --- openfin/v16/index.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/openfin/v16/index.d.ts b/openfin/v16/index.d.ts index 2c1cfd648e..0b9f3e16ac 100644 --- a/openfin/v16/index.d.ts +++ b/openfin/v16/index.d.ts @@ -63,7 +63,7 @@ declare namespace fin { */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Retrieves an array of wrapped fin.desktop.Windows for each of the application’s child windows. + * Retrieves an array of wrapped fin.desktop.Windows for each of the application�s child windows. */ getChildWindows(callback?: (children: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; /** @@ -95,7 +95,7 @@ declare namespace fin { */ removeEventListener(type: OpenFinApplicationEventType, previouslyRegisteredListener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Removes the application’s icon from the tray. + * Removes the application�s icon from the tray. */ removeTrayIcon(callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -288,8 +288,8 @@ declare namespace fin { size?: number; /** * The size in pixels of an additional - * square resizable region located at the - * bottom right corner of a + * square resizable region located at the + * bottom right corner of a * frameless window. (Default: 4) */ bottomRightCorner?: number; @@ -922,11 +922,11 @@ declare namespace fin { interface OpenFinWindowStatic { /** * Class: Window - * + * * new Window(options, callbackopt, errorCallbackopt) - * + * * Creates a new OpenFin Window - * + * * A basic window that wraps a native HTML window. Provides more fine-grained control over the window state such as the ability to minimize, maximize, restore, etc. By default a window does not show upon instantiation; instead the window's show() method must be invoked manually. The new window appears in the same process as the parent window. * @param {any} options - The options of the window * @param {Function} [callback] - Called if the window creation was successful @@ -963,7 +963,7 @@ declare namespace fin { * @returns {OpenFinApplication} Parent application */ getParentApplication(): OpenFinApplication; - /** + /** * Gets the parent window. */ getParentWindow(): OpenFinWindow; @@ -989,7 +989,7 @@ declare namespace fin { bringToFront(callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Closes the window. - * @param {force} Close will be prevented from closing when force is false and ‘close-requested’ has been subscribed to for application’s main window. + * @param {force} Close will be prevented from closing when force is false and �close-requested� has been subscribed to for application�s main window. */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1009,7 +1009,7 @@ declare namespace fin { */ enableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Flashes the window’s frame and taskbar icon until the window is activated. + * Flashes the window�s frame and taskbar icon until the window is activated. */ flash(options?: any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1106,7 +1106,7 @@ declare namespace fin { setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Shows the window if it is hidden. - * @param {force} Show will be prevented from closing when force is false and ‘show-requested’ has been subscribed to for application’s main window. + * @param {force} Show will be prevented from closing when force is false and �show-requested� has been subscribed to for application�s main window. */ show(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** From 700d3a139d81fb5e7f694aeca54569df37ff0fc6 Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Wed, 22 Feb 2017 13:11:41 +1300 Subject: [PATCH 016/258] Updated bacbone.marionette to support marionette 3.1.0 Updated tinymce --- backbone.marionette/index.d.ts | 334 ++++++++++----------------------- tinymce/index.d.ts | 172 +++++++++++++++-- 2 files changed, 256 insertions(+), 250 deletions(-) diff --git a/backbone.marionette/index.d.ts b/backbone.marionette/index.d.ts index edaab2c2d6..c9705c53c1 100644 --- a/backbone.marionette/index.d.ts +++ b/backbone.marionette/index.d.ts @@ -4,6 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Backbone from 'backbone'; +import * as Radio from '../backbone.radio'; export as namespace Marionette; export = Marionette; @@ -22,8 +23,6 @@ declare module 'backbone' { findByIndex(index: number): TView; findByCid(cid: string): TView; remove(view: TView): void; - call(method: any): void; - apply(method: any, args?: any[]): void; //mixins from Collection (copied from Backbone's Collection declaration) @@ -180,6 +179,27 @@ declare namespace Marionette { * backbone conventions and utilities like initialize and Backbone.Events. */ class Object extends Backbone.Events { + + /** + * Defines the Radio channel that will be used for the requests and/or events + */ + channelName: string; + + /** + * Returns a Radio.Channel instance using 'channelName' + */ + getChannel(): Backbone.Radio.Channel; + + /** + * Defines an events hash with the events to be listened and its respective handlers + */ + radioEvents: any; + + /** + * Defines an events hash with the requests to be replied and its respective handlers + */ + radioRequests: any; + /** * Initialize is called immediately after the Object has been instantiated, * and is invoked with the same arguments that the constructor received. @@ -772,12 +792,37 @@ declare namespace Marionette { triggerMethod(name: string, ...args: any[]): any; /** - * Called on the view instance when the view has been rendered and - * displayed. This event can be used to react to when a view has been - * shown via a region. A common use case for the onShow method is to - * use it to add children views. + * Item views will serialize a model or collection, by default, by calling + * .toJSON on either the model or collection. If both a model and + * collection are attached to an item view, the model will be used as the + * data source. The results of the data serialization will be passed to + * the template that is rendered. + * + * If you need custom serialization for your data, you can provide a serializeData + * method on your view. It must return a valid JSON object, as if you had + * called .toJSON on a model or collection. */ - onShow(): void; + serializeData(): any; + + /** + * Renders the view. It is unwise to override the render method of any + * Marionette view. Instead, you should use the onBeforeRender and + * onRender callbacks to layer in additional functionality to the + * rendering of your view. + */ + render(): any; + + /** + * Triggered before an ItemView is rendered. + */ + onBeforeRender(): void; + + /** + * Triggered after the view has been rendered. You can implement this in + * your view to provide custom code for dealing with the view's el after + * it has been rendered. + */ + onRender(): void; /** * Triggered just after the view has been destroyed. @@ -814,49 +859,65 @@ declare namespace Marionette { isDestroyed: boolean; supportsRenderLifecycle: boolean; supportsDestroyLifecycle: boolean; - } - - /** - * An ItemView is a view that represents a single item. That item may be - * a Backbone.Model or may be a Backbone.Collection. Whichever it is though, - * it will be treated as a single item. - */ - class ItemView extends View { - - constructor(options?: Backbone.ViewOptions); /** - * Item views will serialize a model or collection, by default, by calling - * .toJSON on either the model or collection. If both a model and - * collection are attached to an item view, the model will be used as the - * data source. The results of the data serialization will be passed to - * the template that is rendered. - * - * If you need custom serialization for your data, you can provide a serializeData - * method on your view. It must return a valid JSON object, as if you had - * called .toJSON on a model or collection. + * If you have the need to replace the Region with a region class of your + * own implementation, you can specify an alternate class to use with this + * property. */ - serializeData(): any; + regionClass: any; /** - * Renders the view. It is unwise to override the render method of any - * Marionette view. Instead, you should use the onBeforeRender and - * onRender callbacks to layer in additional functionality to the - * rendering of your view. - */ - render(): ItemView; + * Regions hash or a method returning the regions hash that maps + * regions/selectors to methods on your View. + **/ + regions(): any; + + /** Adds a region to the layout view. */ + addRegion(name: string, definition: any): Region; /** - * Triggered before an ItemView is rendered. + * Add multiple regions as a {name: definition, name2: def2} object literal. */ - onBeforeRender(): void; + addRegions(regions: any): any; + + /** Returns a region from the layout view */ + getRegion(name: string): Region; /** - * Triggered after the view has been rendered. You can implement this in - * your view to provide custom code for dealing with the view's el after - * it has been rendered. + * Removes the region with the specified name. + * @param name the name of the region to remove. */ - onRender(): void; + removeRegion(name: string): Region; + + /** Enable easy overriding of the default `RegionManager` + * for customized region interactions and business specific + * view logic for better control over single regions. + */ + getRegionManager(): RegionManager; + + /** + * Show a view into the region specified by `regionName`. + */ + showChildView(regionName: string, view: any, options?: RegionShowOptions): void; + + /** + * Get the current view that is shown in the region specified by + * `regionName`. + */ + getChildView(regionName: string): Backbone.View; + + /** + * Returns all regions from the layout view. The results contains an + * Object hash that has `string`s as keys and `Region`s as values. + */ + getRegions(): {[key: string]: Region}; + + /** + * You can customize the event prefix for events that are forwarded through + * the layout view with this property. + */ + childViewEventPrefix: string; } @@ -928,12 +989,12 @@ declare namespace Marionette { childViewEventPrefix: string; /** - * You can specify a childEvents hash or method which allows you to - * capture all bubbling childEvents without having to manually set bindings. + * You can specify a childViewEvents hash or method which allows you to + * capture all bubbling childViewEvents without having to manually set bindings. * The keys of the hash can either be a function or a string that is the * name of a method on the collection view. */ - childEvents: any; + childViewEvents: any; /** * When a collection has no children, and you need to render a view other than @@ -1034,37 +1095,9 @@ declare namespace Marionette { */ attachHtml(collectionView: CollectionView, childView: TView, index: number): void; - /** - * The value returned by this method is the ChildView class that will be - * instantiated when a Model needs to be initially rendered. This method - * also gives you the ability to customize per Model ChildViews. - */ - getChildView(item: M): new (...args:any[]) => TView; - - /** - * If you need the emptyView's class chosen dynamically, specify - * getEmptyView. - */ - getEmptyView(): any; - /** Serialize a collection by serializing each of its models. */ serializeCollection(): any; - /** - * Attaches the content of a given view. - * This method can be overridden to optimize rendering, - * or to render in a non standard way. - * - * For example, using `innerHTML` instead of `$el.html` - * - * @example - * attachElContent: function(html) { - * this.el.innerHTML = html; - * return this; - * } - */ - attachElContent(html: string): ItemView; - /** * Reorder DOM after sorting. When your element's rendering * do not use their index, you can pass reorderOnSort: true @@ -1132,165 +1165,6 @@ declare namespace Marionette { onRemoveChild(childView: TView): void; } - /** - * A CompositeView extends from CollectionView to be used as a composite view - * for scenarios where it should represent both a branch and leaf in a tree - * structure, or for scenarios where a collection needs to be rendered within - * a wrapper template. - */ - class CompositeView> extends CollectionView { - - constructor(options?: CollectionViewOptions); - - /** - * Each childView will be rendered using the childView's template. The - * CompositeView's template is rendered and the childView's templates are - * added to this. - */ - childView: new (...args:any[]) => TView; - - /** - * By default the composite view uses the same attachHtml method that the - * collection view provides. This means the view will call jQuery's - * .append to move the HTML contents from the child view instance in to - * the collection view's el. - * This is typically not very useful as a composite view will usually render - * a container DOM element in which the child views should be placed. - * This can be either a string or a function returning a string. - */ - childViewContainer: any; - - /** - * Renders the view. - */ - render(): CompositeView; - - /** - * Invoked before the model has been rendered - */ - onBeforeRenderTemplate(): void; - - /** - * Invoked after the model has been rendered. - */ - onRenderTemplate(): void; - - /** - * Invoked before the collection of models is rendered - */ - onBeforeRenderCollection(): void; - - /** - * Invoked after the collection of models has been rendered - */ - onRenderCollection(): void; - } - - interface LayoutViewOptions extends Backbone.ViewOptions { - /** - * The LayoutView takes an additional parameter where you can pass the regions as option on creation. - */ - regions?:any; - - /** - * This option removes the layoutView from the DOM before destroying the - * children preventing repaints as each option is removed. However, it - * makes it difficult to do close animations for a child view (false by - * default) - */ - destroyImmediate?: boolean; - } - - /** - * A LayoutView is a hybrid of an ItemView and a collection of Region objects. - * They are ideal for rendering application layouts with multiple sub-regions - * managed by specified region managers. - * A layoutView can also act as a composite-view to aggregate multiple views - * and sub-application areas of the screen allowing applications to attach - * multiple region managers to dynamically rendered HTML. - * You can create complex views by nesting layoutView managers within Regions. - */ - class LayoutView extends ItemView { - /** - * If you have the need to replace the Region with a region class of your - * own implementation, you can specify an alternate class to use with this - * property. - */ - regionClass: any; - - /** - * Constructor. - * A hash that can contain a regions hash that allows you to specify regions per - * LayoutView instance. - */ - constructor(options?: LayoutViewOptions); - - /** - * Handle destroying regions, and then destroy the view itself. - */ - destroy(): LayoutView; - - /** - * Regions hash or a method returning the regions hash that maps - * regions/selectors to methods on your View. - **/ - regions(): any; - - /** Adds a region to the layout view. */ - addRegion(name: string, definition: any): Region; - - /** - * Add multiple regions as a {name: definition, name2: def2} object literal. - */ - addRegions(regions: any): any; - - /** Returns a region from the layout view */ - getRegion(name: string): Region; - - /** - * Renders the view. It will use the existing region objects the first - * time it is called. Subsequent calls will destroy the views that the - * regions are showing and then reset the `el` for the regions to the - * newly rendered DOM elements. - */ - render(): LayoutView; - - /** - * Removes the region with the specified name. - * @param name the name of the region to remove. - */ - removeRegion(name: string): Region; - - /** Enable easy overriding of the default `RegionManager` - * for customized region interactions and business specific - * view logic for better control over single regions. - */ - getRegionManager(): RegionManager; - - /** - * Show a view into the region specified by `regionName`. - */ - showChildView(regionName: string, view: any, options?: RegionShowOptions): void; - - /** - * Get the current view that is shown in the region specified by - * `regionName`. - */ - getChildView(regionName: string): Backbone.View; - - /** - * Returns all regions from the layout view. The results contains an - * Object hash that has `string`s as keys and `Region`s as values. - */ - getRegions(): {[key: string]: Region}; - - /** - * You can customize the event prefix for events that are forwarded through - * the layout view with this property. - */ - childViewEventPrefix: string; - } - interface AppRouterOptions extends Backbone.RouterOptions { /** * The appRoutes. @@ -1437,7 +1311,7 @@ declare namespace Marionette { options: any; - /** + /** * Behaviors can have their own ui hash, which will be mixed into the ui * hash of its associated View instance. ui elements defined on either the * Behavior or the View will be made available within events and triggers. diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index f760671a8e..e382910026 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -7,37 +7,169 @@ declare namespace TinyMCE { export interface Observable { - off: (name?: string, callback?: () => void) => any; - on: (name: string, callback: () => void) => any; - fire: (name: string, args?: any, bubble?: boolean) => Event; + off(name?: string, callback?: void): any; + on(name: string, callback: () => void): any; + fire(name: string, args?: any, bubble?: boolean): Event; } export interface Editor extends Observable { - destroy: (automatic: boolean) => void; - remove: () => void; - hide: () => void; - show: () => void; - getContent: (args?: any) => string; - setContent: (content: string, args?: any) => string; - focus: (skip_focus?: boolean) => void; + $: any; + iframeElement: string; + selection: Selection; undoManager: UndoManager; - settings: any; - getDoc: () => Document; - editorUpload: any; + formatter: Formatter; + shortcuts: Shortcuts; + dom: DOMUtils; + notificationManager: NotificationManager; + focus(): void; + getContent(args?: Object): string; + isDirty(): boolean; + insertContent(content: string, args?: any): any; + setContent(content: string, args?: any): any; + reset(): any; + execCommand(command: string, ui?: boolean, value?: any, args?: any): boolean; + remove(): any; + destroy(state?: boolean): void; + getElement(): Element; + getDoc(): Document; + queryCommandSupported(cmd: string): boolean; + getBody(): Element; + setDirty(dirty: boolean): void; + on(eventName: String, handler: Function): void; + addShortcut(pattern: string, desc: string, cmdFunc: string, scope?: any ): boolean; + addButton(name: string, settings: any): void; + addMenuItem(name: string, settings: any): void; + menuItems: any; + initialized: boolean; + } + + export interface Formatter { + remove(name: string): any; + apply(name: string): any; + toggle(name: string): any; + match(name: string, vars?: Object, node?: Node): boolean; + matchAll(names: [string], vars?: Object): [string]; } export interface UndoManager { - undo: () => any; - clear: () => void; - hasUndo: () => boolean; + transact(callback: Function): any; + undo(): any; + redo(): any; + hasRedo(): boolean; + hasUndo(): boolean; + } + + export interface DOMUtils { + DOM: any; + getParent(n: Node, s: string): Node; + setStyle(n: any, na: string, v: string): void; + select(pattern: string, scope ?: Element): Array; + getAttrib(elm: string, name: string, defaultVal ?: string): string; + isEmpty(elements: Object): boolean; + } + + export interface NotificationManager { + getNotifications(): any[]; + open(args: any): any; + close(): any; + } + + export interface Shortcuts { + addShortcut(pattern: string, desc: string, cmdFunc: string, scope?: any): boolean; + remove(pattern: string): boolean; + } + + export interface Collection { + + } + + export interface Container { + add(items: any): Collection; + items(): Collection; + } + + export interface Tooltip { + + } + + export interface Control { + renderTo(node?: Node): void; + innerHtml(html: string): Control; + $el: any; + show(): void; + hide(): void; + visible(state ?: boolean): boolean; + disabled(state: boolean): boolean; + active(state: boolean): boolean; + on(name: string, callback: Function): Control; + parent(parent ?: any): Control; + settings: any; + text(text: string): void; + tooltip(): Tooltip; + } + + export interface Moveable { + moveRel(elm: Node, rel: string): Control; + } + + export interface FloatPanel extends Control, Moveable { + + } + + export interface Menu extends FloatPanel, Control, Container { + + } + + export interface Factory { + create(settings: any): Control; + } + + export interface Tools { + grep(array: any, f: Function): any; + each(o: Object, cb: Function, s?: Object): void; + } + + export interface UI { + Factory: Factory; + Control: Control; + FloatPanel: FloatPanel; + } + + export interface util { + Tools: Tools; + } + + export interface Selection { + getContent(args?: Object): string; + getNode(): any; + getRng(): Range; + collapse(toStart?: boolean): any; + select(node: any, body: boolean): any; + getStart(): any; + getEnd(real ?: boolean): void; + selectorChanged(selector: string, handler: any): void; + getSel(): any; + } + + export interface FocusManager { + isEditorUIElement(elm: Node): boolean; + } + + export interface UI { + Factory: Factory; + Control: Control; + FloatPanel: FloatPanel; } export interface Static extends Observable { - init: (settings: any) => void; - execCommand: (c: string, u: boolean, v: string) => boolean; + init(settings: any): void; + execCommand(c: string, u: boolean, v: string): boolean; activeEditor: Editor; - get: (id: string) => Editor; - triggerSave: () => void; + FocusManager: FocusManager; + get(id: string): Editor; + triggerSave(): void; + ui: UI; + util: util; } } From 44b4d01af14305b1a18f274bb50ef2816ee73754 Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Wed, 22 Feb 2017 13:16:51 +1300 Subject: [PATCH 017/258] Remove parent relationship --- backbone.marionette/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backbone.marionette/index.d.ts b/backbone.marionette/index.d.ts index c9705c53c1..9fdfd70594 100644 --- a/backbone.marionette/index.d.ts +++ b/backbone.marionette/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as Backbone from 'backbone'; -import * as Radio from '../backbone.radio'; +import * as Radio from 'backbone.radio'; export as namespace Marionette; export = Marionette; From d701bd4a5b05fdb23eb2c23800464bee4885df30 Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Wed, 22 Feb 2017 14:25:02 +1300 Subject: [PATCH 018/258] Fixed build errors --- .../backbone.marionette-tests.ts | 8 ++--- backbone.marionette/index.d.ts | 2 +- tinymce/index.d.ts | 30 +++++++++---------- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/backbone.marionette/backbone.marionette-tests.ts b/backbone.marionette/backbone.marionette-tests.ts index b5eb9d07c6..2c1f5b68bd 100644 --- a/backbone.marionette/backbone.marionette-tests.ts +++ b/backbone.marionette/backbone.marionette-tests.ts @@ -66,11 +66,11 @@ namespace MarionetteTests { let regions: {[key: string]: Marionette.Region} = this.layoutView.getRegions(); let prefix: string = this.layoutView.childViewEventPrefix; let region: Marionette.Region = this.layoutView.removeRegion('main'); - let layout: Marionette.LayoutView = this.layoutView.destroy(); + let layout: Marionette.View = this.layoutView.destroy(); } } - class AppLayoutView extends Marionette.LayoutView { + class AppLayoutView extends Marionette.View { constructor() { super({ el: 'body' }); } @@ -111,7 +111,7 @@ namespace MarionetteTests { } - class MyView extends Marionette.ItemView { + class MyView extends Marionette.View { behaviors: any; constructor(model: MyModel) { @@ -189,7 +189,7 @@ namespace MarionetteTests { constructor() { super(); this.childView = MyView; - this.childEvents = { + this.childViewEvents = { render: function () { console.log("a childView has been rendered"); } diff --git a/backbone.marionette/index.d.ts b/backbone.marionette/index.d.ts index 9fdfd70594..d24f9d64f9 100644 --- a/backbone.marionette/index.d.ts +++ b/backbone.marionette/index.d.ts @@ -770,7 +770,7 @@ declare namespace Marionette { /** * View implements a destroy method, which is called by the region managers automatically. As part of the implementation. */ - destroy(...args: any[]): void; + destroy(...args: any[]): View; /** * In several cases you need to access ui elements inside the view to diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index e382910026..b393c1c20e 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -7,8 +7,8 @@ declare namespace TinyMCE { export interface Observable { - off(name?: string, callback?: void): any; - on(name: string, callback: () => void): any; + off(name?: string, callback?: void): void; + on(name: string, callback: () => void): void; fire(name: string, args?: any, bubble?: boolean): Event; } @@ -22,7 +22,7 @@ declare namespace TinyMCE { dom: DOMUtils; notificationManager: NotificationManager; focus(): void; - getContent(args?: Object): string; + getContent(args?: any): string; isDirty(): boolean; insertContent(content: string, args?: any): any; setContent(content: string, args?: any): any; @@ -35,7 +35,7 @@ declare namespace TinyMCE { queryCommandSupported(cmd: string): boolean; getBody(): Element; setDirty(dirty: boolean): void; - on(eventName: String, handler: Function): void; + on(eventName: string, handler: () => void): void; addShortcut(pattern: string, desc: string, cmdFunc: string, scope?: any ): boolean; addButton(name: string, settings: any): void; addMenuItem(name: string, settings: any): void; @@ -47,12 +47,12 @@ declare namespace TinyMCE { remove(name: string): any; apply(name: string): any; toggle(name: string): any; - match(name: string, vars?: Object, node?: Node): boolean; - matchAll(names: [string], vars?: Object): [string]; + match(name: string, vars?: any, node?: Node): boolean; + matchAll(names: [string], vars?: any): [string]; } export interface UndoManager { - transact(callback: Function): any; + transact(callback: () => void): any; undo(): any; redo(): any; hasRedo(): boolean; @@ -63,9 +63,9 @@ declare namespace TinyMCE { DOM: any; getParent(n: Node, s: string): Node; setStyle(n: any, na: string, v: string): void; - select(pattern: string, scope ?: Element): Array; + select(pattern: string, scope ?: Element): Element[]; getAttrib(elm: string, name: string, defaultVal ?: string): string; - isEmpty(elements: Object): boolean; + isEmpty(elements: any): boolean; } export interface NotificationManager { @@ -80,7 +80,7 @@ declare namespace TinyMCE { } export interface Collection { - + active():Collection; } export interface Container { @@ -89,7 +89,7 @@ declare namespace TinyMCE { } export interface Tooltip { - + repaint(): void; } export interface Control { @@ -101,7 +101,7 @@ declare namespace TinyMCE { visible(state ?: boolean): boolean; disabled(state: boolean): boolean; active(state: boolean): boolean; - on(name: string, callback: Function): Control; + on(name: string, callback: () => void): Control; parent(parent ?: any): Control; settings: any; text(text: string): void; @@ -125,8 +125,8 @@ declare namespace TinyMCE { } export interface Tools { - grep(array: any, f: Function): any; - each(o: Object, cb: Function, s?: Object): void; + grep(array: any, f: () => void): any; + each(o: Object, cb: () => void, s?: any): void; } export interface UI { @@ -140,7 +140,7 @@ declare namespace TinyMCE { } export interface Selection { - getContent(args?: Object): string; + getContent(args?: any): string; getNode(): any; getRng(): Range; collapse(toStart?: boolean): any; From 648d85936ee669957e5d214e00a5cde7c2a3bf88 Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Wed, 22 Feb 2017 14:30:33 +1300 Subject: [PATCH 019/258] Fixed build errors --- tinymce/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index b393c1c20e..e6a9374ab4 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -7,7 +7,7 @@ declare namespace TinyMCE { export interface Observable { - off(name?: string, callback?: void): void; + off(name?: string, callback ?: () => void): void; on(name: string, callback: () => void): void; fire(name: string, args?: any, bubble?: boolean): Event; } @@ -80,7 +80,7 @@ declare namespace TinyMCE { } export interface Collection { - active():Collection; + active(): Collection; } export interface Container { @@ -126,7 +126,7 @@ declare namespace TinyMCE { export interface Tools { grep(array: any, f: () => void): any; - each(o: Object, cb: () => void, s?: any): void; + each(o: any, cb: () => void, s?: any): void; } export interface UI { From 9d913b0229ffc45ac544433d89a4373bcf934e46 Mon Sep 17 00:00:00 2001 From: morrisjdev Date: Wed, 22 Feb 2017 19:05:16 +0100 Subject: [PATCH 020/258] small changes in function definition --- linq4js/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/linq4js/index.d.ts b/linq4js/index.d.ts index e108f31a4c..e6b9084ea3 100644 --- a/linq4js/index.d.ts +++ b/linq4js/index.d.ts @@ -11,9 +11,9 @@ declare namespace Linq4JS { } declare namespace Linq4JS { class Helper { - static ConvertStringFunction: (functionString: string) => any; - static ConvertFunction: (testFunction: any) => T; - static OrderCompareFunction: (valueSelector: (item: T) => any, a: T, b: T, invert: boolean) => number; + private static ConvertStringFunction(functionString); + static ConvertFunction(testFunction: string | T): T; + static OrderCompareFunction(valueSelector: (item: T) => any, a: T, b: T, invert: boolean): number; } } interface Array { @@ -148,7 +148,7 @@ interface Array { Take(count: number): T[]; /** * Takes entries as long as a condition is true - * @param condition The condition-function (or function-string) that returns a boolean. All elements until a false gets created are taken + * @param condition The condition-function (or function-string) that returns a boolean. All elements until a false gets thrown are taken * @param initial A initial-function (or function-string) that gets executed once at the start of the loop * @param after A function that gets executed after every element-iteration after the condition-function was evaluated */ @@ -280,4 +280,4 @@ declare namespace Linq4JS { Ascending = 0, Descending = 1, } -} \ No newline at end of file +} From e650a40fac972b3412a7e402f40146b13b691fd1 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 23 Feb 2017 12:14:22 +0100 Subject: [PATCH 021/258] Add definitions for fetch-jsonp (https://github.com/camsong/fetch-jsonp) --- fetch-jsonp/fetch-jsonp-tests.ts | 48 ++++++++++++++++++++++++++++++++ fetch-jsonp/index.d.ts | 15 ++++++++++ fetch-jsonp/tsconfig.json | 19 +++++++++++++ fetch-jsonp/tslint.json | 1 + 4 files changed, 83 insertions(+) create mode 100644 fetch-jsonp/fetch-jsonp-tests.ts create mode 100644 fetch-jsonp/index.d.ts create mode 100644 fetch-jsonp/tsconfig.json create mode 100644 fetch-jsonp/tslint.json diff --git a/fetch-jsonp/fetch-jsonp-tests.ts b/fetch-jsonp/fetch-jsonp-tests.ts new file mode 100644 index 0000000000..058f47e70c --- /dev/null +++ b/fetch-jsonp/fetch-jsonp-tests.ts @@ -0,0 +1,48 @@ +import * as fetchJsonp from 'fetch-jsonp'; + +/* Taken from https://github.com/camsong/fetch-jsonp/blob/v1.0.2/README.md */ + +fetchJsonp('/users.jsonp') + .then(function(response) { + return response.json() + }).then(function(json) { + console.log('parsed json', json) + }).catch(function(ex) { + console.log('parsing failed', ex) + }) + +fetchJsonp('/users.jsonp', { + jsonpCallback: 'custom_callback' + }) + .then(function(response) { + return response.json() + }).then(function(json) { + console.log('parsed json', json) + }).catch(function(ex) { + console.log('parsing failed', ex) + }) + +fetchJsonp('/users.jsonp', { + timeout: 3000, + jsonpCallback: 'custom_callback' + }) + .then(function(response) { + return response.json() + }).then(function(json) { + console.log('parsed json', json) + }).catch(function(ex) { + console.log('parsing failed', ex) + }) + +// Taken from https://github.com/camsong/fetch-jsonp/blob/v1.0.2/examples/index.html +var result = fetchJsonp('http://www.flickr.com/services/feeds/photos_public.gne?format=json', { + jsonpCallback: 'jsoncallback', + timeout: 3000 +}) +result.then(function(response) { + return response.json() +}).then(function(json) { + document.body.innerHTML = JSON.stringify(json); +})['catch'](function(ex) { + document.body.innerHTML = 'failed:' + ex; +}) diff --git a/fetch-jsonp/index.d.ts b/fetch-jsonp/index.d.ts new file mode 100644 index 0000000000..99867cdda2 --- /dev/null +++ b/fetch-jsonp/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for fetch-jsonp 1.0 +// Project: https://github.com/camsong/fetch-jsonp +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace fetchJsonp { + interface Options { + timeout?: number; + jsonpCallback?: string; + } +} + +declare function fetchJsonp(url: RequestInfo, options?: fetchJsonp.Options): Promise; + +export = fetchJsonp; diff --git a/fetch-jsonp/tsconfig.json b/fetch-jsonp/tsconfig.json new file mode 100644 index 0000000000..0aaee7fbf4 --- /dev/null +++ b/fetch-jsonp/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "lib": ["es6", "dom"], + "noUnusedLocals": true, + "noUnusedParameters": true, + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "fetch-jsonp-tests.ts" + ] +} diff --git a/fetch-jsonp/tslint.json b/fetch-jsonp/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fetch-jsonp/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From b33b361bba6c18b4ce91b1f825bab4198c5be528 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 23 Feb 2017 12:41:41 +0100 Subject: [PATCH 022/258] Add "module": "commonjs" --- fetch-jsonp/tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/fetch-jsonp/tsconfig.json b/fetch-jsonp/tsconfig.json index 0aaee7fbf4..05c3f994ed 100644 --- a/fetch-jsonp/tsconfig.json +++ b/fetch-jsonp/tsconfig.json @@ -3,6 +3,7 @@ "baseUrl": "../", "typeRoots": ["../"], "types": [], + "module": "commonjs", "lib": ["es6", "dom"], "noUnusedLocals": true, "noUnusedParameters": true, From df8b672c7a12c28d0cc05401529de547ec607be9 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Thu, 23 Feb 2017 12:16:04 +0100 Subject: [PATCH 023/258] Use Partial keyword for objectContaining --- jasmine/index.d.ts | 6 +++--- jasmine/jasmine-tests.ts | 13 +++++++++---- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index e18361dec4..146ab55ad4 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -49,7 +49,7 @@ declare namespace jasmine { function any(aclass: any): Any; function anything(): Any; function arrayContaining(sample: any[]): ArrayContaining; - function objectContaining(sample: any): ObjectContaining; + function objectContaining(sample: Partial): ObjectContaining; function createSpy(name: string, originalFn?: Function): Spy; function createSpyObj(baseName: string, methodNames: any[]): any; function createSpyObj(baseName: string, methodNames: any[]): T; @@ -82,8 +82,8 @@ declare namespace jasmine { jasmineToString(): string; } - interface ObjectContaining { - new (sample: any): any; + interface ObjectContaining { + new (sample: Partial): T; jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; jasmineToString(): string; diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index 4632eb8b4c..13d80af9db 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -663,7 +663,12 @@ describe("jasmine.any", function () { }); describe("jasmine.objectContaining", function () { - var foo: any; + interface fooType { + a:number; + b:number; + bar:string; + } + var foo: fooType; beforeEach(function () { foo = { @@ -674,11 +679,11 @@ describe("jasmine.objectContaining", function () { }); it("matches objects with the expect key/value pairs", function () { - expect(foo).toEqual(jasmine.objectContaining({ + expect(foo).toEqual(jasmine.objectContaining({ bar: "baz" })); - expect(foo).not.toEqual(jasmine.objectContaining({ - c: 37 + expect(foo).not.toEqual(jasmine.objectContaining({ + a: 37 })); }); From d1a477c46afe174d349d007c1021332d8cfce73c Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 23 Feb 2017 13:29:09 +0100 Subject: [PATCH 024/258] =?UTF-8?q?Add=20=E2=80=9CTypeScript=20Version:=20?= =?UTF-8?q?2.2=E2=80=9D=20header?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fetch-jsonp/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/fetch-jsonp/index.d.ts b/fetch-jsonp/index.d.ts index 99867cdda2..e37094254e 100644 --- a/fetch-jsonp/index.d.ts +++ b/fetch-jsonp/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/camsong/fetch-jsonp // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 declare namespace fetchJsonp { interface Options { From ea45419314f1dd5be0b5b7c30c495b4203cc098c Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Thu, 23 Feb 2017 16:01:54 +0100 Subject: [PATCH 025/258] add qlik-visualizationextensions as typescript definition Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 2417 +++++++++++++++++ .../qlik-visualizationextensions-tests.ts | 3 + qlik-visualizationextensions/tsconfig.json | 23 + qlik-visualizationextensions/tslint.json | 7 + 4 files changed, 2450 insertions(+) create mode 100644 qlik-visualizationextensions/index.d.ts create mode 100644 qlik-visualizationextensions/qlik-visualizationextensions-tests.ts create mode 100644 qlik-visualizationextensions/tsconfig.json create mode 100644 qlik-visualizationextensions/tslint.json diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts new file mode 100644 index 0000000000..8a9c145969 --- /dev/null +++ b/qlik-visualizationextensions/index.d.ts @@ -0,0 +1,2417 @@ +// Type definitions for qlik-visualizationextensions +// Project: http://help.qlik.com/en-US/sense-developer/3.2/Subsystems/Extensions/Content/extensions-introduction.htm +// Definitions by: Konrad Mattheis +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +declare namespace BackendAPI { + type StateType = "L" | "S" | "O" | "D" | "A" | "X" | "XS" | "XL"; + type SortIndicatorType = "N" | "A" | "D"; + type DimensionType = "D" | "N" | "T"; + type GroupingType = "N" | "H" | "C"; + type FieldAttributesType = "U" | "A" | "I" | "R" | "F" | "M" | "D" | "T" | "TS" | "IV"; + type PatchType = "Add" | "Remove" | "Replace"; + + interface ICharRange { + /** + * Position of the first search occurrence + * Integer + */ + qCharPos: number; + + /** + * Number of occurrences found + * Integer + */ + qCharCount: number; + } + + interface INxHighlightRanges { + /** + * Ranges of highlighted values + * Array of CharRange + */ + qRanges: ICharRange[]; + } + + interface INxSimpleValue { + /** + * Text related to the attribute expression value. + * This property is optional. No text is returned if the attribute expression value is a numeric. + * String + */ + qText: string; + + /** + * Numeric value of the attribute expression. + * This property is set to NaN (Not a Number) if the attribute expression value is not a numeric. + * Numerical values are not returned as text. + * Double precision floating point + */ + qNum: number; + } + + interface INxAttributeExpressionValues { + /** + * List of attribute expressions values. + * Array of NxSimpleValue + */ + qValues: INxSimpleValue[]; + } + + interface INxSimpleDimValue { + /** + * Text related to the attribute expression value. + * This property is optional. No text is returned if the attribute expression value is a numeric. + * String + */ + qText: string; + + /** + * Element number. + * Integer + */ + qElemNo: number; + } + + interface INxAttributeDimValues { + /** + * List of values. + * Array of NxSimpleDimValue + */ + qValues: INxSimpleDimValue[]; + } + + interface INxCell { + /** + * Some text. + * This parameter is optional. + */ + qText?: string; + + /** + * A value. + * This parameter is optional. + */ + qNum?: number; + + /** + * Rank number of the value, starting from 0. + * If the element number is a negative number, it means that the returned value is not an element number. + * You can get the following negative values: + * # -1: the cell is a Total cell. It shows a total. + * # -2: the cell is collapsed. Applies to pivot tables. + * # -3: the cell belongs to the group Others. + * # -4: the cell is empty. Applies to pivot tables. + */ + qElemNumber: number; + + /** + * State of the value. + * The default state for a measure is L. + * L for Locked + * S for Selected + * O for Optional + * D for Deselected + * A for Alternative + * X for eXcluded + * XS for eXcluded Selected + * XL for eXcluded Locked + */ + qState: StateType; + + /** + * Is set to true, if qText and qNum are empty. + * This parameter is optional. The default value is false. + */ + qIsEmpty: boolean; + + /** + * Is set to true if a total is displayed in the cell. + * This parameter is optional. The default value is false. + * Not applicable to list objects. + */ + qIsTotalCell: boolean; + + /** + * Is set to true if the cell belongs to the group Others. + * Dimension values can be set as Others depending on what has been defined in OtherTotalSpecProp. + * This parameter is optional. The default value is false. + * Not applicable to list objects. + */ + qIsOtherCell: boolean; + + /** + * Frequency of the value. + * This parameter is optional. + */ + qFrequency: string; + + /** + * Search hits. + * The search hits are highlighted. + * This parameter is optional. + */ + qHighlightRanges: INxHighlightRanges; + + /** + * Attribute expression values. + */ + qAttrExps: INxAttributeExpressionValues; + + /** + * Is set to true if the value is Null. + */ + qIsNull: boolean; + + /** + * Attribute dimensions values. + */ + qAttrDims: INxAttributeDimValues; + } + + interface INxPage { + /** + * Position from the left. + * Corresponds to the first column. + */ + qLeft: number; + + /** + * Position from the top. + * Corresponds to the first row. + */ + qTop: number; + + /** + * Number of columns in the page. The indexing of the columns may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + */ + qWidth: number; + + /** + * Number of rows or elements in the page. The indexing of the rows may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + */ + qHeight: number; + } + + interface INxAttrDimInfo { + /** + * Cardinality of the attribute expression. + * Integer + */ + qCardinal: number; + + /** + * Number of rows. + * Size + */ + qSize: number; + + /** + * The title for the attribute dimension. + * String + */ + qFallbackTitle: string; + + /** + * The Locked value of the dimension. + * Boolean + */ + qLocked: boolean; + + /** + * Validation error. + * REF(NxValidationError) + */ + //?Type = REF(NxValidationError)? + qError: INxValidationError; + } + + interface INxDimensionInfo { + /** + * Corresponds to the label of the dimension that is selected. + * If the label is not defined then the field name is used. + * String + */ + qFallbackTitle: string; + + /** + * Length of the longest value in the field. + * Integer + */ + qApprMaxGlyphCount: number; + + /** + * Number of distinct field values. + * Integer + */ + qCardinal: number; + + /** + * Is set to true if the field is locked. + * Boolean + */ + qLocked: boolean; + + /** + * Sort indicator. + * This parameter is optional. + * The default value is no sorting. + * One of: + * # N for no sorting + * # A for sorting ascending + * # D for sorting descending + */ + qSortIndicator: SortIndicatorType; + + /** + * Array of dimension labels. + * Contains the labels of all dimensions in a hierarchy group (for example the labels of all dimensions in a drill down group). + * Array of String + */ + qGroupFallbackTitles: string[]; + + /** + * Index of the dimension that is currently in use. + * qGroupPos is set to 0 if there are no hierarchical groups (drill-down groups) or cycle groups. + * Integer + */ + qGroupPos: number; + + /** + * Number of values in a particular state. + * NxStateCounts + */ + qStateCounts: INxStateCounts; + + /** + * Gives information on a field. For example, it can return the type of the field. + * Examples: key, text, ASCII + * Array of String + */ + qTags: string[]; + + /** + * This parameter is optional. + * Gives information on the error. + * Null or NxValidationError + */ + qError: INxValidationError; + + /** + * Binary format of the field. + * One of: + * # D for discrete (String) + * # N for numeric (Double) + * # T for Time (Timestamp) + */ + qDimensionType: DimensionType; + + /** + * If set to true, it inverts the sort criteria in the field. + * Boolean + */ + qReverseSort: boolean; + + /** + * Defines the grouping. + * One of: + * # N for no grouping + * # H for drill-down + * # C for cyclic + */ + qGrouping: GroupingType; + + /** + * If set to true, it means that the field is a semantic. + * Boolean + */ + qIsSemantic: boolean; + + /** + * Format of the field. + * This parameter is optional. + * FieldAttributes + */ + qNumFormat: FieldAttributesType; + + /** + * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's definition. + * Boolean + */ + qIsAutoFormat: boolean; + + /** + * Array of field names. + * Array of String + */ + qGroupFieldDefs: string[]; + + /** + * Array of attribute expressions. + * Array of NxAttrExprInfo + */ + qAttrExprInfo: INxAttrExprInfo; + + /** + * Minimum value. + * Double + */ + qMin: number; + + /** + * Maximum value. + * Double + */ + qMax: number; + + /** + * Is continuous axis used. + * Boolean + */ + qContinuousAxes: boolean; + + /** + * Is a cyclic dimension used. + * Boolean + */ + qIsCyclic: boolean; + + /** + * Is derived field is used as a dimension. + * Boolean + */ + qDerivedField: boolean; + + /** + * Array of attribute dimensions. + * Array of NxAttrDimInfo + */ + qAttrDimInfo: INxAttrDimInfo; + } + + interface INxAttrExprInfo { + /** + * Minimum value. + */ + qMin: number; + + /** + * Maximum value. + */ + qMax: number; + + /** + * Is continuous axis used. + */ + qContinuousAxes: boolean; + + /** + * Is a cyclic dimension used. + */ + qIsCyclic: boolean; + + /** + * Corresponds to the label of the dimension that is selected. + */ + qFallbackTitle: string; + } + + interface INxStateCounts { + /** + * Number of values in locked state. + * Integer + */ + qLocked: number; + + /** + * Number of values in selected state. + * Integer + */ + qSelected: number; + + /** + * Number of values in optional state. + * Integer + */ + qOption: number; + + /** + * Number of values in deselected state. + * Integer + */ + qDeselected: number; + + /** + * Number of values in alternative state. + * Integer + */ + qAlternative: number; + + /** + * Number of values in excluded state + * Integer + */ + qExcluded: number; + + /** + * Number of values in selected excluded state. + * Integer + */ + qSelectedExcluded: number; + + /** + * Number of values in locked excluded state. + * Integer + */ + qLockedExcluded: number; + } + + interface INxValidationError { + /** + * Error code. + * This parameter is always displayed in case of error. + * Integer + */ + qErrorCode: number; + + /** + * Context related to the error, from the user app domain. + * It can be the identifier of an object, a field name, a table name. + * This parameter is optional. + * String + */ + qContext: string; + + /** + * Internal information from the server. + * This parameter is optional. + * String + */ + qExtendedMessage: string; + } + + interface IFieldAttributes { + /** + * Type of the field. + * Default is U. + * One of: + * # U for UNKNOWN type. + * # A for ASCII; Numeric fields values contain only standard ASCII characters. + * # I for INTEGER; Numeric fields values are shown as integer numbers. + * # R for REAL; Numeric fields values are shown as real numbers. + * # F for FIX; Numeric fields values are shown as numbers with a fix number of decimals. + * # M for MONEY; Numeric fields values are shown as in the money format. + * # D for DATE; Numeric fields values are shown as dates. + * # T for TIME; Numeric fields values are shown as times. + * # TS TIMESTAMP; Numeric fields values are shown as time stamps. + * # IV for INTERVAL; Numeric fields values are shown as intervals. + */ + qType: FieldAttributesType; + + /** + * Number of decimals. + * Default is 10. + * Integer between 0 and 15. + */ + qnDec: number; + + /** + * Defines whether or not a thousands separator must be used. + * Default is 0. + * One of: 0 for false | 1 for true + */ + qUseThou: boolean; + + /** + * Defines the format pattern that applies to qText. + * Is used in connection to the type of the field (parameter qType). + * For more information, see Struct FieldAttributes. + * Example: YYYY-MM-DD for a date + */ + qFmt: string; + + /** + * Defines the decimal separator. + * Example: . + */ + qDec: string; + + /** + * Defines the thousand separator (if any). + * Is used if qUseThou is set to 1. + * Example: , + */ + qThou: string; + + /** + * Array + */ + qSAFEARRAY: any[]; + } + + interface INxMeasureInfo { + /** + * Corresponds to the label of the measure. If the label is not defined then the measure name is used. + * String + */ + qFallbackTitle: string; + + /** + * Length of the longest value in the field. + * Integer + */ + qApprMaxGlyphCount: number; + + /** + * Number of distinct field values. + * Integer + */ + qCardinal: number; + + /** + * Sort indicator. This parameter is optional. The default value is no sorting. + */ + qSortIndicator: SortIndicatorType; + + /** + * Format of the field. This parameter is optional. + * One of: N for no sorting, A for sorting ascending, D for sorting descending + */ + qNumFormat: IFieldAttributes; + + /** + * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's expression. + */ + qIsAutoFormat: boolean; + + /** + * Lowest value in the range. + */ + qMin: number; + + /** + * Highest value in the range. + */ + qMax: number; + + /** + * This parameter is optional. Gives information on the error. + */ + qError: INxValidationError; + + /** + * If set to true, it inverts the sort criteria in the field. + */ + qReverseSort: boolean; + + /** + * List of attribute expressions. + */ + qAttrExprInfo: INxAttrExprInfo[]; + + /** + * List of attribute dimensions. + */ + qAttrDimInfo: INxMeasureInfo[]; + } + + interface IRange { + /** + * Lowest value in the range + * Double + */ + qMin: number; + + /** + * Highest value in the range + * Double + */ + qMax: number; + + /** + * If set to true, the range includes the lowest value in the range of selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means that 1 is included in the range of selections. + */ + qMinInclEq: boolean; + + /** + * If set to true, the range includes the highest value in the range of selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means that 10 is included in the range of selections. + */ + qMaxInclEq: boolean; + } + + interface INxPatch { + /** + * Operation to perform. + * One of: + * # Add + * # Remove + * # Replace + */ + qOp: PatchType; + + /** + * Path to the property to add, remove or replace. + * String + */ + qPath: string; + + /** + * This parameter is not used in a remove operation. + * Corresponds to the value of the property to add or to the new value of the property to update. + * Examples: "false", "2", "\"New title\"" + * String + */ + qValue: string; + } + + interface IBackend { + /** + * Aborts the result of a search in a list object. Clears the existing search and returns the object to the state it was in prior to the search started. + */ + abortSearch(): void; + + /** + * Accepts the result of a search in a list object and the search result is selected in the field. + * @param {boolean} toggleMode - If true, toggle state for selected values + */ + acceptSearch(toggleMode: boolean): void; + + /** + * Updates the properties for this object. + * @param {array} qPatches - Array of patches. Each path contains: + * #qOp: Add/Remove/Replace + * #qPath: Path to property + * #qValue: The new value in string format. Strings need to be surrounded by \". + * @param {boolean} qSoftPatch - Set to True if properties should be soft, that is not persisted. + * @return {Promise} - A promise of a Qlik engine reply. + */ + applyPatches(qPatches: any[], qSoftPatch: boolean): ng.IPromise; + + /** + * Clears unconfirmed selections for this object. + */ + clearSelections(): void; + + /** + * Clears all soft patches that has previously been applied for this object using the applyPatches method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + clearSoftPatches(): ng.IPromise; + + /** + * Collapse the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + collapseLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Collapse the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + collapseTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Loops through data rows for this object. Only rows that are available client side will be used. + * @param {function} callback - Function to call for each row. + * Parameters are row number and row data as an array of NxCell objects. + * The loop is terminated if the function returns false. + * @return {NxCell[]} - An array of NxCell. + */ + eachDataRow(callback: any): INxCell[]; + + /** + * Expands the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + expandLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Expands the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ + expandTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; + + /** + * Geta data from Qlik engine for this object. + * @param {array} qPages - An array of NxPage objects. + * @return {Promise} - A promise of qDataPages. + */ + getData(qPages: INxPage[]): ng.IPromise; + + /** + * Gets a data row for this object. + * @param {number} rownum - The row number. + * @return {NxCell} - A row of NxCell or null if the row is not available client side and need to be fetched with getData method. + */ + getDataRow(rownum: number): INxCell; + + /** + * Gets qDimensionInfo for this object. + * @return {NxDimensionInfo[]} - An array of qDimensionInfo objects. + */ + getDimensionInfos(): INxDimensionInfo[]; + + /** + * Gets qMeasureInfo for this object. + * @return {NxMeasureInfo} - An array of qMeasureInfo objects. + */ + getMeasureInfos(): INxMeasureInfo; + + /** + * Gets pivot data from the Qlik engine for this object. Only works for hypercubes with qMode = P. + * @param {array} qPages - An array of request page objects. + * @return {Promise} - A promise of pivot data pages. + */ + getPivotData(qPages: INxPage[]): ng.IPromise; + + /** + * Get properties for this object. + * @return {Promise} - A promise of object properties. + */ + getProperties(): ng.IPromise; + + /** + * Get reduced data from the Qlik engine for this object. This method is intended for preserving the shape of the data, not for viewing the actual data points. + * @param {array} qPages - An array of request page objects. + * @param {number} qZoomFactor - Zoom factor. + * If set to -1, the Qlik engine decides of the zoom factor. + * If qReductionMode is D1 or S, the zoom factor is 2ⁿ. If the zoom factor is 5, the data are reduced by a factor 32. + * If qReductionMode is C, the zoom factor defines the number of centroids. + * @param {string} qReductionMode - Reduction mode.Can be: + * # N for no data reduction. + * # D1 to reduce a bar chart or line chart. The profile of the chart is reduced whatever the number of dimensions in the chart. + * # S to reduce the resolution of a scatter plot. + * # C to reduce the data of a scatter plot chart. + * # ST to reduce the data of a stacked pivot table. + * @return {Promise} - A promise of reduced data pages. + */ + getReducedData(qPages: INxPage[], qZoomFactor: number, qReductionMode: string): ng.IPromise; + + /** + * Get total number of data rows for this object. + * @return {Number} - A number. + */ + getRowCount(): number; + + /** + * Get stacked data from the Qlik engine for this object. Only works for hypercubes with qMode = S. + * @param {array} qPages - An array of request page objects. + * @param {number} qMaxNbrCells - Maximum number of cells at outer level. + * @return {Promise} - A promise of stack data pages. + */ + getStackedData(qPages: INxPage[], qMaxNbrCells: number): ng.IPromise; + + /** + * Find out if there are unconfirmed selections for this object. + * @return {boolean} - True if there are unconfirmed selections. + */ + hasSelections(): boolean; + + /** + * Save this object. + * @return {Promise} - A promise. In case of success, it returns "undefined". In case of failure it returns the error. + */ + save(): ng.IPromise; + + /** + * Search for a term in a list object. Results in an updated layout, containing only matching records. + * @param {string} term - Term to search for. + */ + search(term: string): void; + + /** + * Select values in this object using ranges. + * @param {array} qRanges - Array of ranges to select. + * @param {boolean} qOrMode - If true only one of the measures needs to be in range. + */ + selectRange(qRanges: IRange[], qOrMode: boolean): void; + + /** + * Select values in this object with a Qlik engine call which triggers a repaint of the object. + * @param {number} qDimNo - Dimension number. 0 = first dimension. + * @param {array} qValues - Array of values (qElemNumber in the matrix from the Qlik engine) to select or deselect. + * @param {boolean} qToggleMode - If true, values in the field are selected in addition to any previously selected items. + * If false, values in the field are selected while previously selected items are deselected. + */ + selectValues(qDimNo: number, qValues: any[], qToggleMode: boolean): void; + + /** + * Set properties for this object. + * @param {object} props - The properties to set. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setProperties(props: any): ng.IPromise; + } +} + +declare namespace RootAPI { + interface IAppConfig { + /** + * Optional Qlik host. + */ + host?: string; + + /** + * Port number. + */ + port: string | number; + + /** + * Optional. Qlik virtual proxy. "/" if no proxy. + */ + prefix?: string; + + /** + * Optional. Use SSL. + */ + isSecure?: boolean; + + /** + * Optional. Open app without loading data. Introduced in version 1.1. + */ + openWithoutData?: boolean; + + /** + * Optional. Unique identity for the session. If omitted, the session will be shared. + */ + identity?: string; + } + + interface IGlobalConfig { + /** + * Qlik Sense host + */ + host: string; + + /** + * Port number + */ + port: string; + + /** + * Qlik Sense virtual proxy. / if no virtual proxy + */ + prefix: string; + + /** + * Use SSL + */ + isSecure: boolean; + + /** + * Unique identity for the session. If omitted, the session will be shared. + */ + identity: string; + } + + interface IRoot { + /** + * Calls the Qlik Sense repository. + * @param {string} path - Path to the Qlik Sense repository. + * Refer to Qlik Sense repository documentation for the available paths. + * @param {string} [method] - Optional. HTTP method. Default is GET. + * @param {string} [body] - Optional. Body of the post. + * @return {Promise} - A promise of a Qlik engine reply. + */ + callRepository(path: string, method?: string, body?: string): ng.IPromise; + + /** currApp + * Gets a reference to the current app. Use the currApp method in an extension to get a reference to the app currently displayed. + * @param {object} [reference] - Optional. Reference to extension object. Introduced in version 1.1. + * @return {IApp} - An App JavaScript object with app methods. + */ + currApp(object?: any): AppAPI.IApp; + + /** + * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. + * The getAppList method opens a WebSocket, gets the app list, and then closes the WebSocket. + * @param {function} callback - Callback method. + * @param {object} [config] - Optional. Additional configuration parameters: + * Name | Type | Descr | Name + * host | String | Optional. Qlik host. | host + * port | String or integer | Port number. | port + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. | prefix + * isSecure | Boolean | Optional. Use SSL. | isSecure + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. | openWithoutData + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. | identity + */ + getAppList(callback: any, config?: any): void; + + /** + * Gets a list of extensions installed for Qlik Sense. The reply contains all extensions, that is widget libraries, visualization extensions and mashups. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getExtensionList(callback?: any): ng.IPromise; + + /** + * Opens a WebSocekt connection to the Qlik engine for global methods. + * @param {object} [config] - Optional. Parameters: + * Name | Type | Description + * host | String | Qlik Sense host + * port | String | Port number + * prefix | String | Qlik Sense virtual proxy. / if no virtual proxy + * isSecure | Boolean | Use SSL + * identity | String | Unique identity for the session. If omitted, the session will be shared. + * @return {ANY} - A global JavaScript object with global methods. + */ + getGlobal(config: any): any; + + /** Opens a Qlik Sense app. You can open multiple apps. + * Most other methods are defined on the app. Returns: App JavaScript object with app methods. + * @param {string} appId The app id. + * @param {object} [config] Optional. Additional configuration parameters: + * Name | Type | Descr + * host | String | Optional. Qlik host. + * port | String or Integer | Port number. + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. + * isSecure | Boolean | Optional. Use SSL. + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. + * Parameter updated in version 2.2. + * @return {any} - App JavaScript object with app methods. + */ + openApp(appId: string, config?: any): any; + + /** + * Registers an extension for use in this mashup. The extension is not installed on the Qlik Sense server and only available in the session where it is created. + * As long as a JavaScript module is created in the correct format, it can be sent to the registerExtension function. + * @param {string} id - Set the ID of the visualization extension. + * @param {object} impl - Set the extension implementation. + * @param {object} [metadata] - Optional. Extension meta-data, same format as the QEXT file. Default: {"type":"visualization"} + */ + registerExtension(id: string, impl: any, metadata?: any): void; + + /** + * Sends a resize event to all Qlik Sense objects. + * @param {string} [ID] - Object id. Optional: if no ID resize event will be sent to all objects. + */ + resize(ID?: string): void; + + /** + * Sets a specific language for the Qlik Sense session. + * Language should be defined before the app is opened meaning the setLanguage method should be called before the openApp method is called. + * @param {string} lang - Language code. Can be: + * # German: short: de long: de-DE + * # English: short: en long: en-US + * # Spanish: short: es long: es-ES + * # French: short: fr long: fr-FR + * # Italian: short: it long: it-IT + * # Japanese: short: ja long: ja-JP + * # Korean: (introduced in version 3.0) short: ko long: ko-KR + * # Dutch: short: nl long: nl-NL + * # Polish: (introduced in version 3.0) short: pl long: pl-PL + * # Brazilian Portuguese: short: pt long: pt-BR + * # Russian: short: ru long: ru-RU + * # Swedish: short: sv long: sv-SE + * # Turkish: (introduced in version 3.0) short: tr long: tr-TR + * # Simplified Chinese: short: Do not use! long: zh-CN + * # Traditional Chinese: (introduced in version 3.0) short: Do not use! long: zh-TW + */ + setLanguage(lang: string): void; + + /** + * Registers a callback for error handling. Standard Qlik Sense error handling is used if this method is not called. + * @param {function} onError - Error handling function + * @param {function} [onWarning] - Optional. Warning handling function. Introduced in version 2.1. + */ + setOnError(onError: any, onWarning?: any): void; + + /** + * Create a QTable object that wraps data in your extension and provides an object oriented interface. + * @param {object} ext - Extension or angular scope for the extension. + * @param {string} [path] - Optional. Path to the hypercube. Default: qHyperCube + * @return {QTable} - A QTable object that holds data and options for the table. + */ + table(ext: any, path?: string): TableAPI.IQTable; + + navigation: NavigationAPI.INavigation; + } +} + +declare namespace AppAPI { + interface IApp { + /** + * Adds an alternate state in the app. Multiple states within a Qlik Sense app can be created and applied to specific objects within the app. Objects in a given state are not affected by user selection in the other states. + * @param {string} qStateName - Mandatory. Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. + */ + addAlternateState(qStateName: string): ng.IPromise; + + /** + * Steps back in the list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ + back(): ng.IPromise; + + /** + * Clears all selections in all fields of the current Qlik Sense app. + * @param {boolean} [lockedAlso] - Optional. Alternate state name. Default: false Introduced in version 2.1. + * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ + clearAll(lockedAlso?: boolean, state?: string): ng.IPromise; + + /** + * Closes a Qlik Sense app. Also closes the WebSocket and clears out client side data. + */ + close(): void; + + /** + * Defines a hypercube and registers a callback to receive the data. + * @param {object} qHyperCubeDef - Cube definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qHyperCube. + * @return {Promise} - A promise of an object model. + */ + createCube(qHyperCubeDef: any, callback?: any): ng.IPromise; + + /** + * Creates a generic object and registers a callback to receive the data. The generic object can contain the following: + * # qHyperCubeDef + * # qListObjectDef + * # qStringExpression + * # qValueExpression + * The callback method will be called whenever the selection state changes in a way that affects the generic object. The parameter will be the evaluated version of the definition. + * @param {object} [def] - Optional. Generic object definition + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of an object model. + */ + createGenericObject(def?: any, callback?: any): ng.IPromise; + + /** + * Defines a list of field values and registers a callback to receive the data. + * @param {object} qListObjectDef - List definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qListObject. + * @return {Promise} - A promise of an object model. + */ + createList(qListObjectDef: any, callback?: any): ng.IPromise; + + /** + * Defines a hypercube for a table and is the entry point to the Table API. It creates a table object that wraps the hypercube. + * @param {Array.} dimensions - Dimensions to use. + * Should, for each entry, be a field name or a NxDimension structure. + * @param {Array.} measures - Measures to use. + * Should, for each entry, be an expression or a NxMeasure structure. + * @param {object} [options] - Optional. Options to set. + * @return {QTable} - A table object of type QTable, which is initially empty but that eventually will contain data. The table object will be updated when selection state changes. + */ + createTable(dimensions: string[] | any[], measures: string[] | any[], options?: any): TableAPI.IQTable; + + /** + * Destroys a Qlik Sense session object created with the createGenericObject method or any of createCube, createList or getList methods. + * Calling this method removes the object from the Qlik engine, no more updates are sent to the client and all methods on the object are invalid. + * @param {string} id - Session object id. + * @return {Promise} - A promise of a Qlik engine reply. + */ + destroySessionObject(id: string): ng.IPromise; + + /** + * Reloads the data in a Qlik Sense app. + * @param {string} [qMode] - Optional. Error handling mode: + * # 0 = default mode. + * # 1 = attempt recovery on all errors. + * # 2 = fail on all errors. + * @param {boolean} [qPartial] - Optional. Set to true for partial reload. + * @param {boolean} [qDebug] - Optional. Set to true if debug breakpoints are honored. Execution of the script will be in debug mode. + * @return {Promise} - A promise of a Qlik engine reply. + */ + doReload(qMode?: string, qPartial?: boolean, qDebug?: boolean): ng.IPromise; + + /** + * Saves a Qlik Sense app, including all objects and data in the data model. + * @param {string} [qFileName] - Optional. File name of the file to save. + * @return {Promise} - A promise of a Qlik engine reply. + */ + doSave(qFileName?: string): ng.IPromise; + + /** + * Gets a field reference with methods that can be used to manipulate the field. + * @param {string} [field] - Optional. Name of the field. + * @param {string} [state] - Optional. Alternate state name. Default is $. + * @return {QField} - A QField object with methods and properties that can be used to manipulate the field. + */ + field(field?: string, state?: string): FieldAPI.IQField; + + /** + * Step forward in list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ + forward(): ng.IPromise; + + /** + * Gets a layout for this Qlik Sense app and registers a callback to receive the data. Returns the dynamic properties (if any) in addition to the fixed properties. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getAppLayout(callback?: any): ng.IPromise; + + /** + * Gets a list of sheets and visualizations and registers a callback to receive the data. + * @param {string} [field] - Optional. Type of object. One of: + * # sheet + * # masterobject + * Default is sheet. + * @param {function} [callback] - Optional. Callback method. + */ + getAppObjectList(type?: string, callback?: any): void; + + /** + * Gets properties for a generic object, the children of the generic object and the bookmarks and/or embedded snapshots of the generic object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ + getFullPropertyTree(id: string): ng.IPromise; + + /** + * Gets a list of internal Qlik Sense objects and registers a callback to receive the data. + * @param {string} type - Type of object: + * # FieldList + * # MeasureList + * # DimensionList + * # BookmarkList + * # SelectionObject + * # SnapshotList (Introduced in version 1.1) + * # MediaList (Introduced in version 1.1) + * # Sheet (Introduced in version 1.1) + * # MasterObject (Introduced in version 1.1) + * # VariableList (Introduced in version 2.0) + * # story (Introduced in version 2.1) + * @param {function} [callback] - Optional. Registers a callback that is executed every time data is returned. + * @return {Promise} - A promise of an object model. + */ + getList(type: string, callback?: any): ng.IPromise; + + /** + * Retrieves a Qlik Sense object from the Qlik Sense application and inserts it into a HTML element. The object fills the HTML object, so you can size and position the element to determine how large the Qlik Sense object will be. + * If you supply only one parameter, you get the model without displaying the object. + * @param {string} id - Object id or 'CurrentSelections' if used for Selections bar. + * @param {Element | string} [elem] - Optional. HTML element. + * Since version 1.1 it is also possible to define a string of the HTML element id. + * @param {object} [options] - Optional. + * Name | Type | Description + * noInteraction | Boolean | Set to true if you want to disable interaction, including selections, in the visualization. Introduced in version 1.1 and updated in version 3.0. + * noSelections | Boolean | Set to true if you want to disable selections in the visualization. Introduced in version 3.0. + * @return {Promise} - A promise of an object model. + */ + getObject(id: string, elem?: any | string, options?: any): ng.IPromise; + + /** + * Gets properties for a Qlik Sense object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ + getObjectProperties(id: string): ng.IPromise; + + /** + * Inserts a Qlik Sense snapshot into a HTML element. The snapshot fills the HTML object so you can size and position the element to determine how large the Qlik Sense object will be. + * If you only supply one parameter, you will just get the model without displaying the object. + * @param {string} id - Snapshot ID. + * @param {element | string} [elem] - Optional. HTML element or string with HTML element id. + * @return {Promise} - A promise of an object model. + */ + getSnapshot(id: string, elem?: any | string): ng.IPromise; + + /** + * Locks all selections. + * @param {string} [state=$] - Optional. Alternate state name. + * Default: $ + * Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ + lockAll(state?: string): ng.IPromise; + + /** + * Removes an alternate state in the app. + * @param {string} qStateName - Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. + */ + removeAlternateState(qStateName: string): ng.IPromise; + + /** + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qMaxNbrFieldMatches | Number | Maximum number of matching values to return per search result. + * @param {object} qOptions - Properties + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + searchAssociations(qTerms: any[], qPage: any, qOptions: any, callback?: any): ng.IPromise; + + /** + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qGroupOptions | Array | This parameter is optional. Options of the search groups. If this property is not set, all values are returned. + * qGroupItemOptions | Array | This parameter is optional. Options of the search group items. If this property is not set, all values are returned. + * qOptions | Object | Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + searchResults(qTerms: any[], qPage: any, qOptions?: any, callback?: any): ng.IPromise; + + /** + * Returns suggestions of words from the values entered in the search. Acts as a helper for the searchAssociations method. + * @param {array} qTerms - Terms to search for. + * @param {object} [qOptions] - Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + searchSuggest(qTerms: any[], qOptions?: any, callback?: any): ng.IPromise; + + /** + * Makes a selection based on searchAssociation results. + * @param {number} qMatchIx - Index to search result. + * @param {array} qTerms - Values to select. + * @param {object} qOptions - Values to select. + * @param {array} [qTerms] - Optional. Parameter sent to the Qlik engine containing information about the search fields and the search context. + * @param {object} [qSoftLock] - Optional. This parameter was deprecated in version 2.0 and is ignored in newer versions. Use the qOtions.qContext parameter instead. + * @return {Promise} - A promise of a Qlik engine reply. + */ + selectAssociations(qMatchIx: number, qTerms: any[], qOptions?: any, qSoftLock?: any): ng.IPromise; + + /** + * Creates a QSelectionState object that encapsulates the selection state. Entry point to the Selection API. + * @param {string} [state] - Optional. Sets the state. Default is $. + */ + selectionState(state?: string): SelectionStateAPI.IQSelectionState; + + /** + * Unlocks all selections that has previously been locked. + * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. + */ + unlockAll(state?: string): ng.IPromise; + } +} + +declare namespace BookmarkAPI { + interface IBookmark { + /** + * Applies a bookmark. + * @param {string} id - Bookmark id. + * @return {Promise} - A promise of a Qlik engine reply. + */ + apply(id: string): ng.IPromise; + + /** + * Creates a bookmark based on the current selection. + * @param {string} title - Bookmark title. + * @param {string} description - Bookmark description. + * @param {string} [sheetId] - Optional. Bookmark sheet id. Introduced in version 2.2. + * @return {Promise} - A promise of a Qlik engine reply. + */ + create(title: string, description: string, sheetId?: string): ng.IPromise; + + /** + * Removes a bookmark. + * @param {string} id - Bookmark id. + * @return {Promise} - A promise of a Qlik engine reply. + */ + remove(id: string): ng.IPromise; + } +} + +declare namespace FieldAPI { + interface IQField { + /** + * Clears a field selection. + * @return {Promise} - A promise. + */ + clear(): ng.IPromise; + + /** + * Clears all fields except the selected one. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + clearOther(softlock?: boolean): ng.IPromise; + + /** + * Gets field data. The values are available as QFieldValue in array field.rows and will updated when the selection state changes. Notification OnData will be triggered after each update. + * @param {boolean} [options] - Optional. Properties: + * Name | Type | Description + * rows | Number | Number of rows to fetch. Default: 200. + * frequencyMode | String | Can be one of: + * # V=Absolute + * # P=Percent + * # R=Relative + * # N=No frequency + * | | Default: V. + * @return {IQField} - The field object. + */ + getData(options?: boolean): IQField; + + /** + * Gets more data for your field. Notification OnData is triggered when complete. + * @return {IQField} - The field object. + */ + getMoreData(): IQField; + + /** + * Locks a field selection. + * @return {Promise} - A promise. + */ + lock(): ng.IPromise; + + /** + * Selects field values using indexes. + * @param {number[]} Array - Array of index values to select + * @param {boolean} [toggle] - Optional. If true, toggle selected state. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + select(Array: number[], toggle?: boolean, softlock?: boolean): ng.IPromise; + + /** + * Selects all values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectAll(softlock?: boolean): ng.IPromise; + + /** + * Selects alternative values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectAlternative(softlock?: boolean): ng.IPromise; + + /** + * Selects excluded values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectExcluded(softlock?: boolean): ng.IPromise; + + /** + * Selects matching field values. + * @param {string} match - Match string. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectMatch(match: string, softlock?: boolean): ng.IPromise; + + /** + * Selects possible values in a field. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectPossible(softlock?: boolean): ng.IPromise; + + /** + * Selects specific values in a field. + * @param {array} array - Array of qFieldValues to select. A simplified syntax with strings or numbers also works since version 1.1. + * For a numeric field you need to provide the numeric value. + * @param {boolean} [toggle] - Optional. If true, toggle selected state. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + selectValues(array: IQFieldValue[], toggle?: boolean, softlock?: boolean): ng.IPromise; + + /** + * Toggles a field selection. + * @param {string} match - Match string. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + toggleSelect(match: string, softlock?: boolean): ng.IPromise; + + /** + * Unlocks field selections. + * @return {Promise} - A promise. + */ + unlock(): ng.IPromise; + + /** + * Field values. You need to call getData() method to make this available. Introduced in 2.1. + */ + rows: IQFieldValue[]; + + /** + * Optional. Number of different values. Only after getData() call. Introduced in 2.1. + */ + rowCount: number; + + /** + * Optional. Object with number of values in different states. Only after getData() call. Introduced in 2.1. + */ + qStateCounts: any; + } + + interface IQFieldValue { + /** + * Cell value formatted as set up in properties. + */ + qText: string; + + /** + * Cell value index. + */ + qElemNumber: number; + + /** + * Cell state. + */ + qState: any; + + /** + * Optional. Cell numeric value, if cell is numeric. + */ + qNum?: number; + + /** + * Optional. Frequency, if calculated by the Qlik engine. + */ + qFrequency?: string; + + /** + * Selects a field value. + * @param {boolean} [toggle] - Optional. If true, toggle selected state. + * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. + * @return {Promise} - A promise. + */ + select(toggle?: boolean, softlock?: boolean): ng.IPromise; + } +} + +declare namespace GlobalAPI { + interface IGlobal { + /** + * Cancels an ongoing reload. The reload of the app is stopped. + * @return {Promise} - A promise of a Qlik engine reply. + */ + cancelReload(): ng.IPromise; + + /** + * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. + * Calling the getAppList method opens a WebSocket, gets the app list, and then keeps the WebSocket open for you to make other calls as well. + * @param {Function} callback - Callback method. + */ + getAppList(callback: any): void; + + /** + * Gets information (user directory and user id) about the authenticated user. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getAuthenticatedUser(callback?: any): ng.IPromise; + + /** + * Gets information about progress of doReload and doSave calls. + * @param {Number} qRequestId - Request id from doReload call or 0. + * Complete information is returned if the identifier of the request is specified. + * If qRequestId = 0, less information is returned. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getProgress(qRequestId: number, callback?: any): ng.IPromise; + + /** + * Gets the product version. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getProductVersion(callback?: any): ng.IPromise; + + /** + * Gets the Qlik product name. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getQTProduct(callback?: any): ng.IPromise; + + /** + * Gets the Qlik Sense version number. + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise. + */ + getQvVersion(callback?: any): ng.IPromise; + + /** + * Gets information if the user is working in personal mode (returns true if Qlik Sense Desktop is used) or not (returns false if Qlik Sense Desktop is not used). + * @param {Function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ + isPersonalMode(callback?: any): ng.IPromise; + } +} + +declare namespace NavigationAPI { + type NavigationModeType = "ANALYSIS" | "EDIT"; + type NavigationErrorType = "NOSUCHSHEET" | "NOCURRENTSHEET" | "NOSUCHSTORY"; + + /** + * The navigation result object. + */ + interface NavigationResult { + /** + * Returns true if successful. + */ + success: boolean; + + /** + * The new sheet ID. + */ + sheetId: string; + + /** + * The new story ID. + */ + storyId: string; + + /** + * The new mode. + */ + mode: string; + + /** + * Error code. Can be: NOSUCHSHEET | NOCURRENTSHEET | NOSUCHSTORY + */ + error: NavigationErrorType; + + /** + * Error message, for example 'No current sheet'. + */ + errorMsg: string; + } + + /** Navigation API for Qlik Sense. The Navigation API allows you to navigate + * within a Qlik Sense app, and is meant to be used in visualization extensions + * and will not work in Mashup scenarios. + */ + interface INavigation { + /** + * Used for analysis mode. + */ + edit: "edit"; + + /** + * Used for edit mode. + */ + analysis: "analysis"; + + /** + * Gets the current sheet ID. + * @return {NavigationResult} - A navigation result object. + */ + getCurrentSheetId(): NavigationResult; + + /** + * Gets the current mode. + * @return {string} - The current mode as a string. + */ + getMode(): string; + + /** + * Navigate to a given sheet in the current app. The method will return before the actual navigation takes place. + * @param {string} sheetId - Set the sheet ID to navigate to. + * @return {NavigationResult} - A navigation result object. + */ + gotoSheet(sheetId: string): NavigationResult; + + /** + * Navigate to a given story in the current app. The method will return before the actual navigation takes place. + * @param {string} storyId - Set the story ID to navigate to. + * @return {NavigationResult} - A navigation result object. + */ + gotoStory(storyId: string): NavigationResult; + + /** + * Checks if a given mode is allowed. + * @param {NavigationModeType} mode - Can be one of the strings: edit | analysis + * or one of the constants: qlik.navigation.EDIT | qlik.navigation.ANALYSIS + * @return {boolean} - A Boolean value (true or false). + */ + isModeAllowed(mode: NavigationModeType): boolean; + + /** + * Go to the next sheet in the current app. It will do nothing if you do not have sheets in the current context. + * The method will return before the actual navigation takes place. + * @return {NavigationResult} - A navigation result object. + */ + nextSheet(): NavigationResult; + + /** + * Jumps to the previous sheet in the current app. It will do nothing if you do not have sheets in the current context. + * The method will return before the actual navigation takes place + * @return {NavigationResult} - A navigation result object. + */ + prevSheet(): NavigationResult; + + /** + * Sets the current working mode of Qlik Sense. + * @param {string | constant} mode - Can be one of the strings: edit | analysis + * or one of the constants: qlik.navigation.EDIT | qlik.navigation.ANALYSIS + * @return {NavigationResult} - A navigation result object. + */ + setMode(mode: string): NavigationResult; + + /** + * Switches the working mode of Qlik Sense. + * @param {NavigationModeType} mode - Can be one of the strings: edit | analysis + * or one of the constants: qlik.navigation.EDIT | qlik.navigation.ANALYSIS + * @return {NavigationResult} - A navigation result object. + */ + switchMode(mode: NavigationModeType): NavigationResult; + } +} + +declare namespace SelectionStateAPI { + interface IQFieldSelections { + /** + * Selection state for a field. + */ + fieldName: string; + + /** + * Sort index. Starting from 0. + */ + qSortIndex: number; + + /** + * Reference to the field. + */ + field: FieldAPI.IQField; + + /** + * Defines if the field is locked. + */ + locked: boolean; + + /** + * Defines if the field is numeric. + */ + isNumeric: boolean; + + /** + * Total number of values in the field. + */ + totalCount: number; + + /** + * Number of selected values. + */ + selectedCount: number; + + /** + * Number of values that will be listed. + */ + qSelectionThreshold: number; + + /** + * Object with number of values in different states. + */ + qStateCounts: any; + + /** + * Concatenated string of selected values if number of values are less than the threshold, or if the string is of format "7 of 123". + */ + qSelected: string; + + /** + * Array with maximum of qSelectionThreshold values that are selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + */ + selectedValues: number[]; + + /** + * Array with maximum of qSelectionThreshold values that are not selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + */ + notSelectedValues: number[]; + } + + interface IQSelectionState { + /** + * State name. $ for default state. + */ + stateName: string; + + /** + * Selections + */ + selections: IQFieldSelections; + + /** + * Number of back steps available. + */ + backCount: number; + + /** + * Number of forward steps available. OnData notification will be triggered after each update. + */ + forwardCount: number; + + /** + * Cleara all selections in this state. + * @param {boolean} lockedAlso - Use to also clear locked fields. + * @return {Promise} - A promise of a Qlik engine reply. + */ + clearAll(lockedAlso: boolean): ng.IPromise; + + /** + * Locks all selections in this state. + * @return {Promise} - A promise of a Qlik engine reply. + */ + lockAll(): ng.IPromise; + + /** + * Unlocks all selections in this state. + * @return {Promise} - A promise of a Qlik engine reply. + */ + unlockAll(): ng.IPromise; + } +} + +declare namespace TableAPI { + interface IQTable { + /** + * Data rows. + */ + rows: IQRow[]; + + /** + * Header information. + */ + headers: IQHeader[]; + + /** + * Total information for measures. + */ + totals: IQMeasureCell[]; + + /** + * Total number of rows for the qHyperCube, including rows not fetched from the server. + */ + rowCount: number; + + /** + * Total number of columns for the qHyperCube. + */ + colCount: number; + + /** + * Exports data of the underlying hypercube in OOXML or CSV format. + * @param {object} [options] - Optional. Properties: + * Name | Type | Description + * format | String | Data format. Can be one of: + * # OOXML: open XML, default + * # CSV_C: comma separated CSV + * # CSV_T: tab separated CSV + * filename | String | Name of the exported file after download from browser. This parameter is optional and only used in desktop. + * state | String | Can be: + * # A: all values + * # P: possible values (default) + * download | Boolean | Automatically start download of file (with window.open). + * @param {Function} [callback] - Optional. Callback function returning the link to the exported file. + */ + exportData(options?: any, callback?: any): void; + + /** + * Gets the column number for a given field name. + * @param {string} fld - Field name. + * @return {number} - Column number, starting with zero. Undefined if no column with that name exists. + */ + getColByName(fld: string): number; + + /** + * Gets more data for your qHyperCube. + */ + getMoreData(): any; + } + + interface IQHeader { + /** + * Column title. + */ + qFallbackTitle: string; + + /** + * Can be: + * # A: ascending + * # D: descending + */ + qSortIndicator: string; + + /** + * True indicates if this is the first column for sorting. + */ + isOrderedBy: boolean; + + /** + * True indicates if the sort order is reversed for this column. + */ + qReverseSort: boolean; + + /** + * Column number. + */ + col: number; + + /** + * Optional. Number of different values. Only used for dimensions. + */ + qCardinal?: number; + + /** + * Optional. Object with number of values in different states. Only used for dimensions. + */ + qStateCounts?: any; + + /** + * Optional. Field object with methods to manipulate the underlying field. Only used for dimensions. + */ + field?: any; + + /** + * Optional. Minimum value. Only used for measures. + */ + qMin?: number; + + /** + * Optional. Maximum value. Only used for measures. + */ + qMax?: number; + + /** + * Optional. Error code for this column. Only if column has an error. Introduced in version 2.2. + */ + errorCode?: number; + + /** + * Error message for this column. Only if column has an error. Introduced in version 2.2. + */ + errorMessage: number; + + /** + * Sets this column to be the first in the sort order. + */ + orderBy(): void; + + /** + * Reverses the sort order for this column. + */ + reverseOrder(): void; + + /** + * Select a range in this measure. + * @param {number} min - Sets the minimum value of the range. + * @param {number} max - Sets the maximum value of the range. + * @param {boolean} [inclMin] - Optional. Set to true to include minimum value. + * @param {boolean} [inclMax] - Optional. Set to true to include maximum value. + * @return {Promise} - A promise. + */ + selectRange(min: number, max: number, inclMin?: boolean, inclMax?: boolean): ng.IPromise; + } + + interface IQRow { + /** + * Dimension cells. + */ + dimensions: IQDimensionCell[]; + + /** + * Measure cells. + */ + measures: IQMeasureCell[]; + + /** + * All cells, in the order they are defined in the properties. + */ + cells: any[]; + } + + interface IQDimensionCell extends IQMeasureCell { + /** + * Cell value index. + */ + qElemNumber: number; + + /** + * Cell state. + */ + qState: string; + + /** + * Selects the value in this cell. + */ + select(): void; + } + + interface IQMeasureCell { + /** + * Cell value formatted as set up in properties. + */ + qText: string; + + /** + * Optional. Cell numeric value, if cell is numeric. + */ + qNum?: number; + + /** + * Gets the value of this cell as a percentage of the total. Might be more than 100% if this is an average. + */ + getPercent(): number; + + /** + * Gets the value of this cell as a percentage of the maximum. + */ + getPercentOfMax(): number; + } +} + +declare namespace VariableAPI { + interface IVariable { + /** + * Creates a variable. + * @param {string | object} qProp - Variable name or properties. Properties: + * Name | Type | Description + * qInfo.qId | String | Optional. Variable id. If the selected ID is already in use, a new ID is automatically set by the engine. + * qName | String | Variable name. The name must be unique. + * qComment | String | Optional. Comment related to the variable. + * qDefinition | String | Optional. Variable definition. + * qNumberPresentation | Object | Optional. Defines the format of the value. + * qIncludeInBookmark | Boolean | Optional. Set to true to update the variable when applying a bookmark. The variable value will be persisted in the bookmark. + * @return {Promise} - Returns a promise of a variable model. + */ + create(qProp: string | any): ng.IPromise; + + /** + * Creates a session variable, that is a temporary variable which is not persisted and needs to be recreated for each new session. + * @param {object} qProp - Variable properties: + * Name | Type | Description + * qInfo.qId | String | Optional. Variable id. + * qName | String | Variable name. + * qComment | String | Optional. Comment. + * qDefinition | String | Optional. Variable definition. + * qNumberPresentation | Object | Optional. + * qIncludeInBookmark | Boolean | Optional. Include in bookmark flag. + * @return {Promise} - A promise of a variable model. + */ + createSessionVariable(qProp: any): ng.IPromise; + + /** + * Gets a variable by id. + * @param {string} qId - Variable id. + * @return {Promise} - A promise of a variable model. + */ + get(qId: string): ng.IPromise; + + /** + * Gets a variable by name. + * @param {string} qName - Variable name. + * @return {Promise} - A promise of a variable model. + */ + getByName(qName: string): ng.IPromise; + + /** + * Gets variable content. + * @param {string} name - Variable name. + * @param {Function} callback - Callback to receive the content. + * @return {Promise} - A promise of a Qlik engine reply. + */ + getContent(name: string, callback: any): ng.IPromise; + + /** + * Sets the content of a variable. + * @param {string} name - Variable name. + * @param {string} content - Variable content. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setContent(name: string, content: string): ng.IPromise; + + /** + * Sets a numeric value as a variable. + * @param {string} qName - Variable name. + * @param {Number} qVal - Variable value. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setNumValue(qName: string, qVal: number): ng.IPromise; + + /** + * Sets variable string value. + * @param {string} qName - Variable name. + * @param {string} qVal - Variable value. + * @return {Promise} - A promise of a Qlik engine reply. + */ + setStringValue(qName: string, qVal: string): ng.IPromise; + } +} + +declare namespace VisualizationAPI { + type VisualizationType = "barchart" | "combochart" | "gauge" | "kpi" | "linechart" | "piechart" | "pivot-table" | + "scatterplot" | "table" | "treemap" | "extension"; + + interface IVisualization { + /** + * Create a new visualization on the fly based on a session object and will not be persisted in the app. + * @param {VisualizationType} type - Visualization type. Can be: + * # barchart + * # combochart + * # gauge + * # kpi + * # linechart + * # piechart + * # pivot-table + * # scatterplot + * # table + * # treemap + * # extension + * @param {array} [cols] - Optional. Column definitions, dimensions and measures. Each entry can be of the following structures: + * # String + * # NxDimension + * # NxMeasure + * If the NxDimension or the NxMeasure refer to a library dimension or a library measure, you also need to add qType : "measure" or "dimension". + * @param {object} [options] - Optional. Options to set. + * @return {Promise} - A promise of a QVisualization. + */ + create(type: VisualizationType, cols?: any[], options?: any): ng.IPromise; + + /** + * Gets an existing visualization. + * @param {string} id - Id for an existing visualization. + * @return {Promise} - A promise of a QVisualization. + */ + get(id: string): ng.IPromise; + } + + interface IQVisualization { + /** + * Table object for this visualization. Only for visualizations built on a hypercube. + */ + table: TableAPI.IQTable; + + /** + * Closes a visualization and releases the session object. + * @return {Promise} - A promise. + */ + close(): ng.IPromise; + + /** + * Tells the visualization it has been resized and should re-paint. + */ + resize(): void; + + /** + * Sets options for a visualization. + * @param {object} options - Options to set (using applyPatches). + */ + setOptions(options?: any): void; + + /** + * Shows the visualization in an HTML element. + * @param {Element | string} [element] - Optional. HTML element or HTML element ID. + * @param {object} [options] - Optional. + * Name | Type | Description + * noInteraction | Boolean | Set to true if you want to disable all interaction, including selections, in the visualization. + * noSelections | Boolean | Set to true if you want to disable selections in the visualization. + * | | Parameter introduced in version 3.0. + */ + show(element?: any | string, options?: any): void; + } +} + +declare namespace ExtensionAPI { + + + interface IExtensionModel { + + } + + interface IExtensionComponent { + model: IExtensionModel; + } + + interface IExtensionScope extends ng.IScope { + component: IExtensionComponent; + } + + + //ExtensionAPI + type SelectionModeType = "CONFIRM" | "QUICK"; + + interface IInitialProperties { + qHyperCubeDef?: any; //IHyperCubeDef; + qListObjectDef?: any; //IListObjectDef; + fixed?: boolean; + width?: number; + percent?: boolean; + selectionMode?: SelectionModeType; + } + + interface ISupport { + snapshot?: boolean; + export?: boolean; + exportData?: boolean; + } + + interface IExtension { + definition?: IDefinition; + paint?: ($element: HTMLElement, layout?: any) => void; + initialProperties?: IInitialProperties; + template?: string; + controller?: any; + support?: ISupport; + } + + interface ISupport { + snapshot?: boolean; // | () => boolean; + export?: boolean; // | () => boolean; + canTakeSnapshot?: boolean; + } + + interface IInitialProperties { + // qHyperCubeDef: IVisualizationHyperCubeDef; + // qListObjectDef: IVis + + //[""]: + } + + //#region IDefinition + type ExpressionType = "always" | "optional" | ""; + + type func = () => T; + type valueOrfunc = T | func; + + //#region Controls + interface ICustomControlOption { + value: string; + label: string; + } + + interface ICustomControl { + type: string; + label: string; + ref: string; + } + + interface ICustomString extends ICustomControl { + defaultValue: string; + expression: ExpressionType; + show: valueOrfunc; + maxlength: number; + } + + interface ICustomNumber extends ICustomControl { + defaultValue: number; + min: number; + max: number; + } + + interface ICustomInteger extends ICustomNumber { + } + + interface ICustomArray extends ICustomControl { + itemTitleRef: string; + addTranslation: string; + allowAdd: boolean; + allowMove: boolean; + allowRemove: boolean; + } + + interface ICustomButton extends ICustomControl { + label: string; + component: "button"; + action: valueOrfunc; + } + + interface ICustomButtonGroup extends ICustomControl { + component: "buttongroup"; + defaultValue: string; + options: valueOrfunc; + } + + interface ICustomCheckBox extends ICustomControl { + component: "checkbox"; + defaultValue: boolean; + } + + interface ICustomColorPicker extends ICustomControl { + component: "color-picker"; + defaultValue: number; + } + + interface ICustomDropDownList extends ICustomControl { + component: "dropdown"; + defaultValue: string; + options: valueOrfunc; + } + + interface ICustomLink { + type: string; + component: "link"; + label: string; + url: string; + } + + interface ICustomMedia extends ICustomControl { + component: "media"; + layoutRef: string; + } + + interface ICustomRadioButton extends ICustomControl { + component: "radiobuttons"; + defaultValue: string; + options: valueOrfunc; + } + + interface ICustomSlider extends ICustomControl { + component: "slider"; + defaultValue: number; + min: number; + max: number; + step: number; + } + + interface ICustomRangeSlider extends ICustomControl { + component: "slider"; + defaultValue: number[]; + min: number; + max: number; + step: number; + } + + interface ICustomSwitch { + component: "switch"; + defaultValue: boolean; + options: valueOrfunc; + } + + interface ICustomText { + type: "text"; + component: "text"; + label: string; + } + + interface ICustomTextArea extends ICustomControl { + component: "textarea"; + rows: number; + maxlength: number; + defaultValue: string; + show: valueOrfunc; + } + //#endregion + + interface IDefinition { + type: "items"; + component: "accordion"; + items: IItems; + } + + interface IItems { + dimentions?: IDimensions; + measures?: IMeasures; + appearance?: IAppearance; + sorting?: ISorting; + AddOns?: IAddOns; + [other: string]: any; + } + + interface IAddOns { + uses: "addons"; + } + + interface ISorting { + uses: "sorting"; + } + + interface IDimensions { + uses: "dimensions"; + min?: number; + max?: number; + } + + interface IAppearance { + uses: "settings"; + min?: number; + max?: number; + items: any; + } + + //?Das selbe wie Appearance? + interface ISettings { + uses: "settings"; + min?: number; + max?: number; + } + + interface IMeasures { + uses: "measures"; + min?: number; + max?: number; + } + + //#endregion +} + +declare module "qlik" { + var e: RootAPI.IRoot; export = e; +} + +interface IQVAngular { + /** + * Register a new directive with the compiler. + * + * @param name Name of the directive in camel-case (i.e. ngBind which will match as ng-bind) + * @param directiveFactory An injectable directive factory function. + */ + directive(name: string, directiveFactory: ng.Injectable): void; + directive(object: { [directiveName: string]: ng.Injectable }): void; + + filter(name: string, filterFactoryFunction: ng.Injectable): void; + filter(object: { [name: string]: ng.Injectable }): void; + + /** + * Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function. + * + * @param name The name of the instance. + * @param serviceConstructor An injectable class (constructor function) that will be instantiated. + * @return Returns the constructed singleton of the service class/function. + */ + service(name: string, serviceConstructor: ng.Injectable): T; + service(object: { [name: string]: ng.Injectable }): T; + + //provider(name: string, serviceProviderFactory: ng.IServiceProviderFactory): void; + //provider(name: string, serviceProviderConstructor: ng.IServiceProviderClass): void; +} + +declare module "qvangular" { + var e: IQVAngular; export = e; +} \ No newline at end of file diff --git a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts new file mode 100644 index 0000000000..032b755b34 --- /dev/null +++ b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts @@ -0,0 +1,3 @@ +import * as qlik from "qlik"; + +const t = qlik.currApp(); \ No newline at end of file diff --git a/qlik-visualizationextensions/tsconfig.json b/qlik-visualizationextensions/tsconfig.json new file mode 100644 index 0000000000..47e4903e2e --- /dev/null +++ b/qlik-visualizationextensions/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "amd", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "qlik-visualizationextensions-tests.ts" + ] +} \ No newline at end of file diff --git a/qlik-visualizationextensions/tslint.json b/qlik-visualizationextensions/tslint.json new file mode 100644 index 0000000000..965a36a968 --- /dev/null +++ b/qlik-visualizationextensions/tslint.json @@ -0,0 +1,7 @@ +{ "extends": "../tslint.json", + "rules": { + "forbidden-types": false, + "no-empty-interface": false, + "interface-name": false + } +} \ No newline at end of file From 47134067acfda2acc7230e44d1c2b7ba9c6ef85b Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Thu, 23 Feb 2017 16:08:25 +0100 Subject: [PATCH 026/258] fixes BOM & module to run npm test Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 4 ++-- .../qlik-visualizationextensions-tests.ts | 2 +- qlik-visualizationextensions/tsconfig.json | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index 8a9c145969..c7eb32273c 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for qlik-visualizationextensions +// Type definitions for qlik-visualizationextensions 3.2 // Project: http://help.qlik.com/en-US/sense-developer/3.2/Subsystems/Extensions/Content/extensions-introduction.htm // Definitions by: Konrad Mattheis // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -791,7 +791,7 @@ declare namespace BackendAPI { * @param {array} qPages - An array of request page objects. * @param {number} qZoomFactor - Zoom factor. * If set to -1, the Qlik engine decides of the zoom factor. - * If qReductionMode is D1 or S, the zoom factor is 2ⁿ. If the zoom factor is 5, the data are reduced by a factor 32. + * If qReductionMode is D1 or S, the zoom factor is 2n. If the zoom factor is 5, the data are reduced by a factor 32. * If qReductionMode is C, the zoom factor defines the number of centroids. * @param {string} qReductionMode - Reduction mode.Can be: * # N for no data reduction. diff --git a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts index 032b755b34..2e1d738198 100644 --- a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts +++ b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts @@ -1,3 +1,3 @@ -import * as qlik from "qlik"; +import qlik=require("qlik"); const t = qlik.currApp(); \ No newline at end of file diff --git a/qlik-visualizationextensions/tsconfig.json b/qlik-visualizationextensions/tsconfig.json index 47e4903e2e..f4a5bc132a 100644 --- a/qlik-visualizationextensions/tsconfig.json +++ b/qlik-visualizationextensions/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "amd", + "module": "commonjs", "lib": [ "es6", "dom" From 1dfe4c5dada036e164d2114a1cf3ebbb71224bf0 Mon Sep 17 00:00:00 2001 From: Jan Alonzo Date: Sat, 25 Feb 2017 15:55:05 +1100 Subject: [PATCH 027/258] Remove localforage and point to upstream typings instead --- localforage/index.d.ts | 115 ------------------------------ localforage/localforage-tests.ts | 117 ------------------------------- localforage/package.json | 5 ++ localforage/tsconfig.json | 23 ------ notNeededPackages.json | 8 ++- 5 files changed, 12 insertions(+), 256 deletions(-) delete mode 100644 localforage/index.d.ts delete mode 100644 localforage/localforage-tests.ts create mode 100644 localforage/package.json delete mode 100644 localforage/tsconfig.json diff --git a/localforage/index.d.ts b/localforage/index.d.ts deleted file mode 100644 index d0194ec60f..0000000000 --- a/localforage/index.d.ts +++ /dev/null @@ -1,115 +0,0 @@ -// Type definitions for Mozilla's localForage -// Project: https://github.com/mozilla/localforage -// Definitions by: yuichi david pichsenmeister -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface LocalForageOptions { - driver?: string | LocalForageDriver | LocalForageDriver[]; - - name?: string; - - size?: number; - - storeName?: string; - - version?: number; - - description?: string; -} - -interface LocalForageDbMethods { - getItem(key: string): Promise; - getItem(key: string, callback: (err: any, value: T) => void): void; - - setItem(key: string, value: T): Promise; - setItem(key: string, value: T, callback: (err: any, value: T) => void): void; - - removeItem(key: string): Promise; - removeItem(key: string, callback: (err: any) => void): void; - - clear(): Promise; - clear(callback: (err: any) => void): void; - - length(): Promise; - length(callback: (err: any, numberOfKeys: number) => void): void; - - key(keyIndex: number): Promise; - key(keyIndex: number, callback: (err: any, key: string) => void): void; - - keys(): Promise; - keys(callback: (err: any, keys: string[]) => void): void; - - iterate(iteratee: (value: any, key: string, iterationNumber: number) => any): Promise; - iterate(iteratee: (value: any, key: string, iterationNumber: number) => any, - callback: (err: any, result: any) => void): void; -} - -interface LocalForageDriverSupportFunc { - (): Promise; -} - -interface LocalForageDriver extends LocalForageDbMethods { - _driver: string; - - _initStorage(options: LocalForageOptions): void; - - _support?: boolean | LocalForageDriverSupportFunc; -} - -interface LocalForageSerializer { - serialize(value: T | ArrayBuffer | Blob, callback: (value: string, error: any) => void): void; - - deserialize(value: string): T | ArrayBuffer | Blob; - - stringToBuffer(serializedString: string): ArrayBuffer; - - bufferToString(buffer: ArrayBuffer): string; -} - -interface LocalForage extends LocalForageDbMethods { - LOCALSTORAGE: string; - WEBSQL: string; - INDEXEDDB: string; - - /** - * Set and persist localForage options. This must be called before any other calls to localForage are made, but can be called after localForage is loaded. - * If you set any config values with this method they will persist after driver changes, so you can call config() then setDriver() - * @param {LocalForageOptions} options? - */ - config(options: LocalForageOptions): boolean; - - /** - * Create a new instance of localForage to point to a different store. - * All the configuration options used by config are supported. - * @param {LocalForageOptions} options - */ - createInstance(options: LocalForageOptions): LocalForage; - - driver(): string; - /** - * Force usage of a particular driver or drivers, if available. - * @param {string} driver - */ - setDriver(driver: string | string[]): Promise; - setDriver(driver: string | string[], callback: () => void, errorCallback: (error: any) => void): void; - defineDriver(driver: LocalForageDriver): Promise; - defineDriver(driver: LocalForageDriver, callback: () => void, errorCallback: (error: any) => void): void; - /** - * Return a particular driver - * @param {string} driver - */ - getDriver(driver: string): Promise; - - getSerializer(): Promise; - getSerializer(callback: (serializer: LocalForageSerializer) => void): void; - - supports(driverName: string): boolean; - - ready(callback: () => void): void; - ready(): Promise; -} - -declare module "localforage" { - let localforage: LocalForage; - export = localforage; -} diff --git a/localforage/localforage-tests.ts b/localforage/localforage-tests.ts deleted file mode 100644 index e3edeba2d0..0000000000 --- a/localforage/localforage-tests.ts +++ /dev/null @@ -1,117 +0,0 @@ - - -declare let localForage: LocalForage; - -namespace LocalForageTest { - localForage.clear((err: any) => { - let newError: any = err; - }); - - localForage.iterate((str: string, key: string, num: number) => { - let newStr: string = str; - let newKey: string = key; - let newNum: number = num; - }); - - localForage.length((err: any, num: number) => { - let newError: any = err; - let newNumber: number = num; - }); - - localForage.length().then((num: number) => { - var newNumber: number = num; - }); - - localForage.key(0, (err: any, value: string) => { - let newError: any = err; - let newValue: string = value; - }); - - localForage.keys((err: any, keys: Array) => { - let newError: any = err; - let newArray: Array = keys; - }); - - localForage.keys().then((keys: Array) => { - var newArray: Array = keys; - }); - - localForage.getItem("key",(err: any, str: string) => { - let newError: any = err; - let newStr: string = str - }); - - localForage.getItem("key").then((str: string) => { - let newStr: string = str; - }); - - localForage.setItem("key", "value",(err: any, str: string) => { - let newError: any = err; - let newStr: string = str - }); - - localForage.setItem("key", "value").then((str: string) => { - let newStr: string = str; - }); - - localForage.removeItem("key",(err: any) => { - let newError: any = err; - }); - - localForage.removeItem("key").then(() => { - }); - - localForage.getDriver("CustomDriver").then((result: LocalForageDriver) => { - var driver: LocalForageDriver = result; - // we need to use a variable for proper type guards before TS 2.0 - var _support = driver._support; - if (typeof _support === "function") { - // _support = _support.bind(driver); - _support().then((result: boolean) => { - let doesSupport: boolean = result; - }); - } else if (typeof _support === "boolean") { - let doesSupport: boolean = _support; - } - }); - - { - let config: boolean; - - config = localForage.config({ - name: "testyo", - driver: localForage.LOCALSTORAGE - }); - } - - { - let store: LocalForage; - - store = localForage.createInstance({ - name: "da instance", - driver: localForage.LOCALSTORAGE - }); - } - - { - let testSerializer: LocalForageSerializer; - - localForage.getSerializer() - .then((serializer: LocalForageSerializer) => { - testSerializer = serializer; - }); - - localForage.getSerializer((serializer: LocalForageSerializer) => { - testSerializer = serializer; - }); - } - - { - let store: LocalForage; - - store.ready() - .then(() => {}); - - store.ready(() => {}); - } -} \ No newline at end of file diff --git a/localforage/package.json b/localforage/package.json new file mode 100644 index 0000000000..29f45814b2 --- /dev/null +++ b/localforage/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "localforage": ">=1.5.0" + } +} diff --git a/localforage/tsconfig.json b/localforage/tsconfig.json deleted file mode 100644 index 1e3cbf9e63..0000000000 --- a/localforage/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "localforage-tests.ts" - ] -} \ No newline at end of file diff --git a/notNeededPackages.json b/notNeededPackages.json index 0cd56b96d1..bcdf36987a 100644 --- a/notNeededPackages.json +++ b/notNeededPackages.json @@ -305,6 +305,12 @@ "typingsPackageName": "gaea-model", "sourceRepoURL": "https://github.com/ascoders/gaea-model", "asOfVersion": "0.0.0" + }, + { + "libraryName": "localforage", + "typingsPackageName": "localforage", + "sourceRepoURL": "https://github.com/localForage/localForage", + "asOfVersion": "0.0.34" } ] -} +} \ No newline at end of file From a8059edc7aab2c3ac955fb6049209c102fd3db86 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Sat, 25 Feb 2017 12:55:26 -0500 Subject: [PATCH 028/258] placeId => placeid As per https://developers.google.com/places/web-service/details --- googlemaps/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/googlemaps/index.d.ts b/googlemaps/index.d.ts index 06eba68a94..d4d0935717 100644 --- a/googlemaps/index.d.ts +++ b/googlemaps/index.d.ts @@ -2258,7 +2258,7 @@ declare namespace google.maps { } export interface PlaceDetailsRequest { - placeId: string; + placeid: string; } export interface PlaceGeometry { From e45de33a3f658465e6c96a6b686eea9afc49757e Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Thu, 23 Feb 2017 15:32:05 +0100 Subject: [PATCH 029/258] Add generic parameter to Matchers --- jasmine/index.d.ts | 55 ++++-- jasmine/jasmine-tests.ts | 391 ++++++++++++++++++++------------------- 2 files changed, 233 insertions(+), 213 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index 146ab55ad4..78fea75ec2 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -24,8 +24,9 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void; declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; -declare function expect(spy: Function): jasmine.Matchers; -declare function expect(actual: any): jasmine.Matchers; +declare function expect>(actual: ArrayLike): jasmine.ArrayLikeMatchers; +declare function expect(actual: T): jasmine.Matchers; +declare function expect(spy: Function): jasmine.Matchers; declare function fail(e?: any): void; /** Action method that should be called when the async work is complete */ @@ -43,23 +44,33 @@ declare function waitsFor(latchMethod: () => boolean, failureMessage?: string, t declare function waits(timeout?: number): void; declare namespace jasmine { + type Expected = T | ObjectContaining | Any | Spy; var clock: () => Clock; function any(aclass: any): Any; + function anything(): Any; + function arrayContaining(sample: any[]): ArrayContaining; function objectContaining(sample: Partial): ObjectContaining; function createSpy(name: string, originalFn?: Function): Spy; + function createSpyObj(baseName: string, methodNames: any[]): any; function createSpyObj(baseName: string, methodNames: any[]): T; + function pp(value: any): string; + function getEnv(): Env; + function addCustomEqualityTester(equalityTester: CustomEqualityTester): void; + function addMatchers(matchers: CustomMatcherFactories): void; + function stringMatching(str: string): Any; function stringMatching(str: RegExp): Any; - function formatErrorMsg(domain: string, usage: string) : (msg: string) => string + + function formatErrorMsg(domain: string, usage: string): (msg: string) => string interface Any { @@ -83,7 +94,7 @@ declare namespace jasmine { } interface ObjectContaining { - new (sample: Partial): T; + new (sample: Partial): Partial; jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean; jasmineToString(): string; @@ -150,7 +161,7 @@ declare namespace jasmine { currentSpec: Spec; - matchersClass: Matchers; + matchersClass: Matchers; version(): any; versionString(): string; @@ -224,12 +235,12 @@ declare namespace jasmine { passed(): boolean; } - interface MessageResult extends Result { + interface MessageResult extends Result { values: any; trace: Trace; } - interface ExpectationResult extends Result { + interface ExpectationResult extends Result { matcherName: string; passed(): boolean; expected: any; @@ -242,12 +253,13 @@ declare namespace jasmine { new (options: {random: boolean, seed: string}): any; random: boolean; seed: string; - sort(items: T[]) : T[]; + sort(items: T[]): T[]; } namespace errors { class ExpectationFailed extends Error { constructor(); + stack: any; } } @@ -255,7 +267,7 @@ declare namespace jasmine { interface TreeProcessor { new (attrs: any): any; execute: (done: Function) => void; - processTree() : any; + processTree(): any; } interface Trace { @@ -301,18 +313,18 @@ declare namespace jasmine { results(): NestedResults; } - interface Matchers { + interface Matchers { - new (env: Env, actual: any, spec: Env, isNot?: boolean): any; + new (env: Env, actual: T, spec: Env, isNot?: boolean): any; env: Env; - actual: any; + actual: T; spec: Env; isNot?: boolean; message(): any; - toBe(expected: any, expectationFailOutput?: any): boolean; - toEqual(expected: any, expectationFailOutput?: any): boolean; + toBe(expected: Expected, expectationFailOutput?: any): boolean; + toEqual(expected: Expected, expectationFailOutput?: any): boolean; toMatch(expected: string | RegExp, expectationFailOutput?: any): boolean; toBeDefined(expectationFailOutput?: any): boolean; toBeUndefined(expectationFailOutput?: any): boolean; @@ -332,11 +344,18 @@ declare namespace jasmine { toThrow(expected?: any): boolean; toThrowError(message?: string | RegExp): boolean; toThrowError(expected?: new (...args: any[]) => Error, message?: string | RegExp): boolean; - not: Matchers; + not: Matchers; Any: Any; } + interface ArrayLikeMatchers> extends Matchers { + toBe(expected: Expected>, expectationFailOutput?: any): boolean; + toEqual(expected: Expected>, expectationFailOutput?: any): boolean; + toContain(expected: T, expectationFailOutput?: any): boolean; + not: ArrayLikeMatchers; + } + interface Reporter { reportRunnerStarting(runner: Runner): void; reportRunnerResults(runner: Runner): void; @@ -433,7 +452,7 @@ declare namespace jasmine { spies_: Spy[]; results_: NestedResults; - matchersClass: Matchers; + matchersClass: Matchers; getFullName(): string; results(): NestedResults; @@ -446,7 +465,7 @@ declare namespace jasmine { waits(timeout: number): Spec; waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; fail(e?: any): void; - getMatchersClass_(): Matchers; + getMatchersClass_(): Matchers; addMatchers(matchersPrototype: CustomMatcherFactories): void; finishCallback(): void; finish(onComplete?: () => void): void; @@ -494,7 +513,7 @@ declare namespace jasmine { identity: string; and: SpyAnd; calls: Calls; - mostRecentCall: { args: any[]; }; + mostRecentCall: {args: any[];}; argsForCall: any[]; } diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index 13d80af9db..f841a613c5 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -1,34 +1,34 @@ // tests based on http://jasmine.github.io/2.2/introduction.html -describe("A suite", function () { - it("contains spec with an expectation", function () { +describe("A suite", function() { + it("contains spec with an expectation", function() { expect(true).toBe(true); }); }); -describe("A suite is just a function", function () { +describe("A suite is just a function", function() { var a: boolean; - it("and so is a spec", function () { + it("and so is a spec", function() { a = true; expect(a).toBe(true); }); }); -describe("The 'toBe' matcher compares with ===", function () { +describe("The 'toBe' matcher compares with ===", function() { - it("and has a positive case", function () { + it("and has a positive case", function() { expect(true).toBe(true); }); - it("and can have a negative case", function () { + it("and can have a negative case", function() { expect(false).not.toBe(true); }); }); -describe("Included matchers:", function () { +describe("Included matchers:", function() { - it("The 'toBe' matcher compares with ===", function () { + it("The 'toBe' matcher compares with ===", function() { var a = 12; var b = a; @@ -36,14 +36,14 @@ describe("Included matchers:", function () { expect(a).not.toBe(null); }); - describe("The 'toEqual' matcher", function () { + describe("The 'toEqual' matcher", function() { - it("works for simple literals and variables", function () { + it("works for simple literals and variables", function() { var a = 12; expect(a).toEqual(12); }); - it("should work for objects", function () { + it("should work for objects", function() { var foo = { a: 12, b: 34 @@ -56,7 +56,7 @@ describe("Included matchers:", function () { }); }); - it("The 'toMatch' matcher is for regular expressions", function () { + it("The 'toMatch' matcher is for regular expressions", function() { var message = "foo bar baz"; expect(message).toMatch(/bar/); @@ -64,7 +64,7 @@ describe("Included matchers:", function () { expect(message).not.toMatch(/quux/); }); - it("The 'toBeDefined' matcher compares against `undefined`", function () { + it("The 'toBeDefined' matcher compares against `undefined`", function() { var a = { foo: "foo" }; @@ -73,16 +73,16 @@ describe("Included matchers:", function () { expect((a).bar).not.toBeDefined(); }); - it("The `toBeUndefined` matcher compares against `undefined`", function () { + it("The `toBeUndefined` matcher compares against `undefined`", function() { var a = { foo: "foo" }; expect(a.foo).not.toBeUndefined(); - expect((a).bar).toBeUndefined(); + expect((a as any).bar).toBeUndefined(); }); - it("The 'toBeNull' matcher compares against null", function () { + it("The 'toBeNull' matcher compares against null", function() { var a: string = null; var foo = "foo"; @@ -91,28 +91,28 @@ describe("Included matchers:", function () { expect(foo).not.toBeNull(); }); - it("The 'toBeTruthy' matcher is for boolean casting testing", function () { + it("The 'toBeTruthy' matcher is for boolean casting testing", function() { var a: string, foo = "foo"; expect(foo).toBeTruthy(); expect(a).not.toBeTruthy(); }); - it("The 'toBeFalsy' matcher is for boolean casting testing", function () { + it("The 'toBeFalsy' matcher is for boolean casting testing", function() { var a: string, foo = "foo"; expect(a).toBeFalsy(); expect(foo).not.toBeFalsy(); }); - it("The 'toContain' matcher is for finding an item in an Array", function () { + it("The 'toContain' matcher is for finding an item in an Array", function() { var a = ["foo", "bar", "baz"]; - expect(a).toContain("bar"); + expect(a).toContain('foo'); expect(a).not.toContain("quux"); }); - it("The 'toBeLessThan' matcher is for mathematical comparisons", function () { + it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; @@ -120,7 +120,7 @@ describe("Included matchers:", function () { expect(pi).not.toBeLessThan(e); }); - it("The 'toBeGreaterThan' is for mathematical comparisons", function () { + it("The 'toBeGreaterThan' is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; @@ -128,7 +128,7 @@ describe("Included matchers:", function () { expect(e).not.toBeGreaterThan(pi); }); - it("The 'toBeCloseTo' matcher is for precision math comparison", function () { + it("The 'toBeCloseTo' matcher is for precision math comparison", function() { var pi = 3.1415926, e = 2.78; @@ -136,11 +136,11 @@ describe("Included matchers:", function () { expect(pi).toBeCloseTo(e, 0); }); - it("The 'toThrow' matcher is for testing if a function throws an exception", function () { - var foo = function () { + it("The 'toThrow' matcher is for testing if a function throws an exception", function() { + var foo = function() { return 1 + 2; }; - var bar = function () { + var bar = function() { var a: any = undefined; return a + 1; }; @@ -161,15 +161,15 @@ describe("Included matchers:", function () { }); }); -describe("A spec", function () { - it("is just a function, so it can contain any code", function () { +describe("A spec", function() { + it("is just a function, so it can contain any code", function() { var foo = 0; foo += 1; expect(foo).toEqual(1); }); - it("can have more than one expectation", function () { + it("can have more than one expectation", function() { var foo = 0; foo += 1; @@ -178,94 +178,94 @@ describe("A spec", function () { }); }); -describe("A spec (with setup and tear-down)", function () { +describe("A spec (with setup and tear-down)", function() { var foo: number; - beforeEach(function () { + beforeEach(function() { foo = 0; foo += 1; }); - afterEach(function () { + afterEach(function() { foo = 0; }); - it("is just a function, so it can contain any code", function () { + it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); - it("can have more than one expectation", function () { + it("can have more than one expectation", function() { expect(foo).toEqual(1); expect(true).toEqual(true); }); }); -describe("A spec", function () { +describe("A spec", function() { var foo: number; - beforeEach(function () { + beforeEach(function() { foo = 0; foo += 1; }); - afterEach(function () { + afterEach(function() { foo = 0; }); - it("is just a function, so it can contain any code", function () { + it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); - it("can have more than one expectation", function () { + it("can have more than one expectation", function() { expect(foo).toEqual(1); expect(true).toEqual(true); }); - describe("nested inside a second describe", function () { + describe("nested inside a second describe", function() { var bar: number; - beforeEach(function () { + beforeEach(function() { bar = 1; }); - it("can reference both scopes as needed", function () { + it("can reference both scopes as needed", function() { expect(foo).toEqual(bar); }); }); }); -xdescribe("A spec", function () { +xdescribe("A spec", function() { var foo: number; - beforeEach(function () { + beforeEach(function() { foo = 0; foo += 1; }); - it("is just a function, so it can contain any code", function () { + it("is just a function, so it can contain any code", function() { expect(foo).toEqual(1); }); }); -describe("Pending specs", function () { +describe("Pending specs", function() { - xit("can be declared 'xit'", function () { + xit("can be declared 'xit'", function() { expect(true).toBe(false); }); it("can be declared with 'it' but without a function"); - it("can be declared by calling 'pending' in the spec body", function () { + it("can be declared by calling 'pending' in the spec body", function() { expect(true).toBe(false); pending(); // without reason pending('this is why it is pending'); }); }); -describe("A spy", function () { +describe("A spy", function() { var foo: any, bar: any = null; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -278,29 +278,29 @@ describe("A spy", function () { foo.setBar(456, 'another param'); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.setBar).toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function () { + it("tracks all the arguments of its calls", function() { expect(foo.setBar).toHaveBeenCalledWith(123); expect(foo.setBar).toHaveBeenCalledWith(456, 'another param'); }); - it("stops all execution on a function", function () { + it("stops all execution on a function", function() { expect(bar).toBeNull(); }); }); -describe("A spy, when configured to call through", function () { +describe("A spy, when configured to call through", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; @@ -311,28 +311,28 @@ describe("A spy, when configured to call through", function () { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(123); }); }); -describe("A spy, when configured to fake a return value", function () { +describe("A spy, when configured to fake a return value", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; @@ -343,15 +343,15 @@ describe("A spy, when configured to fake a return value", function () { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(745); }); }); @@ -361,7 +361,7 @@ describe("A spy, when configured to fake a series of return values", function() beforeEach(function() { foo = { - setBar: function(value: any) { + setBar: function (value: any) { bar = value; }, getBar: function() { @@ -390,20 +390,20 @@ describe("A spy, when configured to fake a series of return values", function() }); }); -describe("A spy, when configured with an alternate implementation", function () { +describe("A spy, when configured with an alternate implementation", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; - spyOn(foo, "getBar").and.callFake(function () { + spyOn(foo, "getBar").and.callFake(function() { return 1001; }); @@ -411,23 +411,23 @@ describe("A spy, when configured with an alternate implementation", function () fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(1001); }); }); -describe("A spy, when configured to throw a value", function () { +describe("A spy, when configured to throw a value", function() { var foo: any, bar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -437,55 +437,55 @@ describe("A spy, when configured to throw a value", function () { spyOn(foo, "setBar").and.throwError("quux"); }); - it("throws the value", function () { - expect(function () { + it("throws the value", function() { + expect(function() { foo.setBar(123) - }).toThrowError("quux"); + }).toThrowError("quux"); }); }); -describe("A spy, when configured with multiple actions", function () { +describe("A spy, when configured with multiple actions", function() { var foo: any, bar: any, fetchedBar: any; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; }, - getBar: function () { + getBar: function() { return bar; } }; spyOn(foo, 'getBar').and.callThrough().and.callFake(() => { - this.fakeCalled = true; + this.fakeCalled = true; }); foo.setBar(123); fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function () { + it("should not effect other functions", function() { expect(bar).toEqual(123); }); - it("when called returns the requested value", function () { + it("when called returns the requested value", function() { expect(fetchedBar).toEqual(123); }); - it("should have called the fake implementation", function () { + it("should have called the fake implementation", function() { expect(this.fakeCalled).toEqual(true); }); }); -describe("A spy", function () { +describe("A spy", function() { var foo: any, bar: any = null; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -495,7 +495,7 @@ describe("A spy", function () { spyOn(foo, 'setBar').and.callThrough(); }); - it("can call through and then stub in the same spec", function () { + it("can call through and then stub in the same spec", function() { foo.setBar(123); expect(bar).toEqual(123); @@ -507,10 +507,10 @@ describe("A spy", function () { }); }); -describe("A spy", function () { +describe("A spy", function() { var foo: any, bar: any = null; - beforeEach(function () { + beforeEach(function() { foo = { setBar: function (value: any) { bar = value; @@ -520,7 +520,7 @@ describe("A spy", function () { spyOn(foo, 'setBar'); }); - it("tracks if it was called at all", function () { + it("tracks if it was called at all", function() { expect(foo.setBar.calls.any()).toEqual(false); foo.setBar(); @@ -528,7 +528,7 @@ describe("A spy", function () { expect(foo.setBar.calls.any()).toEqual(true); }); - it("tracks the number of times it was called", function () { + it("tracks the number of times it was called", function() { expect(foo.setBar.calls.count()).toEqual(0); foo.setBar(); @@ -537,7 +537,7 @@ describe("A spy", function () { expect(foo.setBar.calls.count()).toEqual(2); }); - it("tracks the arguments of each call", function () { + it("tracks the arguments of each call", function() { foo.setBar(123); foo.setBar(456, "baz"); @@ -545,34 +545,34 @@ describe("A spy", function () { expect(foo.setBar.calls.argsFor(1)).toEqual([456, "baz"]); }); - it("tracks the arguments of all calls", function () { + it("tracks the arguments of all calls", function() { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.allArgs()).toEqual([[123], [456, "baz"]]); }); - it("can provide the context and arguments to all calls", function () { + it("can provide the context and arguments to all calls", function() { foo.setBar(123); expect(foo.setBar.calls.all()).toEqual([{ object: foo, args: [123], returnValue: undefined }]); }); - it("has a shortcut to the most recent call", function () { + it("has a shortcut to the most recent call", function() { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.mostRecent()).toEqual({ object: foo, args: [456, "baz"], returnValue: undefined }); }); - it("has a shortcut to the first call", function () { + it("has a shortcut to the first call", function() { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.first()).toEqual({ object: foo, args: [123], returnValue: undefined }); }); - it("can be reset", function () { + it("can be reset", function() { foo.setBar(123); foo.setBar(456, "baz"); @@ -584,40 +584,40 @@ describe("A spy", function () { }); }); -describe("A spy, when created manually", function () { +describe("A spy, when created manually", function() { var whatAmI: any; - beforeEach(function () { + beforeEach(function() { whatAmI = jasmine.createSpy('whatAmI'); whatAmI("I", "am", "a", "spy"); }); - it("is named, which helps in error reporting", function () { + it("is named, which helps in error reporting", function() { expect(whatAmI.and.identity()).toEqual('whatAmI'); }); - it("tracks that the spy was called", function () { + it("tracks that the spy was called", function() { expect(whatAmI).toHaveBeenCalled(); }); - it("tracks its number of calls", function () { + it("tracks its number of calls", function() { expect(whatAmI.calls.count()).toEqual(1); }); - it("tracks all the arguments of its calls", function () { + it("tracks all the arguments of its calls", function() { expect(whatAmI).toHaveBeenCalledWith("I", "am", "a", "spy"); }); - it("allows access to the most recent call", function () { + it("allows access to the most recent call", function() { expect(whatAmI.calls.mostRecent().args[0]).toEqual("I"); }); }); -describe("Multiple spies, when created manually", function () { +describe("Multiple spies, when created manually", function() { var tape: any; - beforeEach(function () { + beforeEach(function() { tape = jasmine.createSpyObj('tape', ['play', 'pause', 'stop', 'rewind']); tape.play(); @@ -625,35 +625,35 @@ describe("Multiple spies, when created manually", function () { tape.rewind(0); }); - it("creates spies for each requested function", function () { + it("creates spies for each requested function", function() { expect(tape.play).toBeDefined(); expect(tape.pause).toBeDefined(); expect(tape.stop).toBeDefined(); expect(tape.rewind).toBeDefined(); }); - it("tracks that the spies were called", function () { + it("tracks that the spies were called", function() { expect(tape.play).toHaveBeenCalled(); expect(tape.pause).toHaveBeenCalled(); expect(tape.rewind).toHaveBeenCalled(); expect(tape.stop).not.toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function () { + it("tracks all the arguments of its calls", function() { expect(tape.rewind).toHaveBeenCalledWith(0); }); }); -describe("jasmine.any", function () { - it("matches any value", function () { +describe("jasmine.any", function() { + it("matches any value", function() { expect({}).toEqual(jasmine.any(Object)); expect(12).toEqual(jasmine.any(Number)); }); - describe("when used with a spy", function () { - it("is useful for comparing arguments", function () { + describe("when used with a spy", function() { + it("is useful for comparing arguments", function() { var foo = jasmine.createSpy('foo'); - foo(12, function () { + foo(12, function() { return true; }); @@ -662,15 +662,15 @@ describe("jasmine.any", function () { }); }); -describe("jasmine.objectContaining", function () { +describe("jasmine.objectContaining", function() { interface fooType { - a:number; - b:number; - bar:string; + a: number; + b: number; + bar: string; } var foo: fooType; - beforeEach(function () { + beforeEach(function() { foo = { a: 1, b: 2, @@ -678,17 +678,18 @@ describe("jasmine.objectContaining", function () { }; }); - it("matches objects with the expect key/value pairs", function () { + it("matches objects with the expect key/value pairs", function() { expect(foo).toEqual(jasmine.objectContaining({ - bar: "baz" + bar: '' })); - expect(foo).not.toEqual(jasmine.objectContaining({ + + expect(foo).not.toEqual(jasmine.objectContaining({ a: 37 })); }); - describe("when used with a spy", function () { - it("is useful for comparing arguments", function () { + describe("when used with a spy", function() { + it("is useful for comparing arguments", function() { var callback = jasmine.createSpy('callback'); callback({ @@ -706,43 +707,43 @@ describe("jasmine.objectContaining", function () { }); describe("jasmine.arrayContaining", function() { - var foo: any; + var foo: any; - beforeEach(function() { - foo = [1, 2, 3, 4]; - }); + beforeEach(function() { + foo = [1, 2, 3, 4]; + }); - it("matches arrays with some of the values", function() { - expect(foo).toEqual(jasmine.arrayContaining([3, 1])); - expect(foo).not.toEqual(jasmine.arrayContaining([6])); - }); + it("matches arrays with some of the values", function() { + expect(foo).toEqual(jasmine.arrayContaining([3, 1])); + expect(foo).not.toEqual(jasmine.arrayContaining([6])); + }); - describe("when used with a spy", function() { - it("is useful when comparing arguments", function() { - var callback = jasmine.createSpy('callback'); + describe("when used with a spy", function() { + it("is useful when comparing arguments", function() { + var callback = jasmine.createSpy('callback'); - callback([1, 2, 3, 4]); + callback([1, 2, 3, 4]); - expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); - expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); + expect(callback).toHaveBeenCalledWith(jasmine.arrayContaining([4, 2, 3])); + expect(callback).not.toHaveBeenCalledWith(jasmine.arrayContaining([5, 2])); + }); }); - }); }); -describe("Manually ticking the Jasmine Clock", function () { +describe("Manually ticking the Jasmine Clock", function() { var timerCallback: any; - beforeEach(function () { + beforeEach(function() { timerCallback = jasmine.createSpy("timerCallback"); jasmine.clock().install(); }); - afterEach(function () { + afterEach(function() { jasmine.clock().uninstall(); }); - it("causes a timeout to be called synchronously", function () { - setTimeout(function () { + it("causes a timeout to be called synchronously", function() { + setTimeout(function() { timerCallback(); }, 100); @@ -753,8 +754,8 @@ describe("Manually ticking the Jasmine Clock", function () { expect(timerCallback).toHaveBeenCalled(); }); - it("causes an interval to be called synchronously", function () { - setInterval(function () { + it("causes an interval to be called synchronously", function() { + setInterval(function() { timerCallback(); }, 100); @@ -770,7 +771,7 @@ describe("Manually ticking the Jasmine Clock", function () { expect(timerCallback.calls.count()).toEqual(2); }); - describe("Mocking the Date object", function(){ + describe("Mocking the Date object", function() { it("mocks the Date object and sets it to a given time", function() { var baseTime = new Date(2013, 9, 23); @@ -782,10 +783,10 @@ describe("Manually ticking the Jasmine Clock", function () { }); }); -describe("Asynchronous specs", function () { +describe("Asynchronous specs", function() { var value: number; beforeEach(function (done: DoneFn) { - setTimeout(function () { + setTimeout(function() { value = 0; done(); }, 1); @@ -798,42 +799,42 @@ describe("Asynchronous specs", function () { }); describe("long asynchronous specs", function() { - beforeEach(function(done: DoneFn) { - done(); + beforeEach(function (done: DoneFn) { + done(); }, 1000); - it("takes a long time", function(done: DoneFn) { - setTimeout(function() { - done(); - }, 9000); + it("takes a long time", function (done: DoneFn) { + setTimeout(function() { + done(); + }, 9000); }, 10000); - afterEach(function(done: DoneFn) { - done(); + afterEach(function (done: DoneFn) { + done(); }, 1000); }); }); -describe("Fail", function () { +describe("Fail", function() { - it("should fail test when called without arguments", function () { - fail(); - }); + it("should fail test when called without arguments", function() { + fail(); + }); - it("should fail test when called with a fail message", function () { - fail("The test failed"); - }); + it("should fail test when called with a fail message", function() { + fail("The test failed"); + }); - it("should fail test when called an error", function () { - fail(new Error("The test failed with this error")); - }); + it("should fail test when called an error", function() { + fail(new Error("The test failed with this error")); + }); }); // test based on http://jasmine.github.io/2.2/custom_equality.html describe("custom equality", function() { - var myCustomEquality: jasmine.CustomEqualityTester = function(first: any, second: any): boolean { + var myCustomEquality: jasmine.CustomEqualityTester = function (first: any, second: any): boolean { if (typeof first == "string" && typeof second == "string") { return first[0] == second[1]; } @@ -886,29 +887,29 @@ var customMatchers: jasmine.CustomMatcherFactories = { // } // } declare namespace jasmine { - interface Matchers { - toBeGoofy(expected?: any): boolean; + interface Matchers { + toBeGoofy(expected?: jasmine.Expected): boolean; } } -describe("Custom matcher: 'toBeGoofy'", function () { - beforeEach(function () { +describe("Custom matcher: 'toBeGoofy'", function() { + beforeEach(function() { jasmine.addMatchers(customMatchers); }); - it("is available on an expectation", function () { + it("is available on an expectation", function() { expect({ hyuk: 'gawrsh' }).toBeGoofy(); }); - it("can take an 'expected' parameter", function () { + it("can take an 'expected' parameter", function() { expect({ hyuk: 'gawrsh is fun' - }).toBeGoofy(' is fun'); + }).toBeGoofy({ hyuk: ' is fun' }); }); - it("can be negated", function () { + it("can be negated", function() { expect({ hyuk: 'this is fun' }).not.toBeGoofy(); @@ -917,7 +918,7 @@ describe("Custom matcher: 'toBeGoofy'", function () { // test based on http://jasmine.github.io/2.5/custom_reporter.html var myReporter: jasmine.CustomReporter = { - jasmineStarted: function (suiteInfo: jasmine.SuiteInfo ) { + jasmineStarted: function (suiteInfo: jasmine.SuiteInfo) { console.log("Running suite with " + suiteInfo.totalSpecsDefined); }, @@ -948,7 +949,7 @@ var myReporter: jasmine.CustomReporter = { } }, - jasmineDone: function(runDetails: jasmine.RunDetails) { + jasmineDone: function (runDetails: jasmine.RunDetails) { console.log('Finished suite'); console.log('Random:', runDetails.order.random); } @@ -957,20 +958,20 @@ var myReporter: jasmine.CustomReporter = { jasmine.getEnv().addReporter(myReporter); describe("Randomize Tests", function() { - it("should allow randomization of the order of tests", function() { - expect(function() { - var env = jasmine.getEnv(); - return env.randomizeTests(true); - }).not.toThrow(); - }); + it("should allow randomization of the order of tests", function() { + expect(function() { + var env = jasmine.getEnv(); + return env.randomizeTests(true); + }).not.toThrow(); + }); - it("should allow a seed to be passed in for randomization", function() { - expect(function() { - var env = jasmine.getEnv(); - env.randomizeTests(true); - return env.seed(1234); - }).not.toThrow(); - }); + it("should allow a seed to be passed in for randomization", function() { + expect(function() { + var env = jasmine.getEnv(); + env.randomizeTests(true); + return env.seed(1234); + }).not.toThrow(); + }); }); (() => { @@ -986,7 +987,7 @@ describe("Randomize Tests", function() { }; var currentWindowOnload = window.onload; - window.onload = function () { + window.onload = function() { if (currentWindowOnload) { (currentWindowOnload)(null); } From 5d864d9772c27269b06f0ecccc2cd88e98af9428 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Sun, 26 Feb 2017 12:29:39 +0100 Subject: [PATCH 030/258] Fix linter errors --- jasmine/index.d.ts | 34 ++-- jasmine/jasmine-tests.ts | 386 ++++++++++++++++++------------------ jasmine/v1/jasmine-tests.ts | 22 +- 3 files changed, 219 insertions(+), 223 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index 78fea75ec2..03c1e30c78 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -70,7 +70,7 @@ declare namespace jasmine { function stringMatching(str: string): Any; function stringMatching(str: RegExp): Any; - function formatErrorMsg(domain: string, usage: string): (msg: string) => string + function formatErrorMsg(domain: string, usage: string): (msg: string) => string; interface Any { @@ -124,18 +124,14 @@ declare namespace jasmine { withMock(func: () => void): void; } - interface CustomEqualityTester { - (first: any, second: any): boolean; - } + type CustomEqualityTester = (first: any, second: any) => boolean; interface CustomMatcher { compare(actual: T, expected: T): CustomMatcherResult; compare(actual: any, expected: any): CustomMatcherResult; } - interface CustomMatcherFactory { - (util: MatchersUtil, customEqualityTesters: Array): CustomMatcher; - } + type CustomMatcherFactory = (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]) => CustomMatcher; interface CustomMatcherFactories { [index: string]: CustomMatcherFactory; @@ -147,9 +143,9 @@ declare namespace jasmine { } interface MatchersUtil { - equals(a: any, b: any, customTesters?: Array): boolean; - contains(haystack: ArrayLike | string, needle: any, customTesters?: Array): boolean; - buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: Array): string; + equals(a: any, b: any, customTesters?: CustomEqualityTester[]): boolean; + contains(haystack: ArrayLike | string, needle: any, customTesters?: CustomEqualityTester[]): boolean; + buildFailureMessage(matcherName: string, isNot: boolean, actual: any, ...expected: any[]): string; } interface Env { @@ -390,18 +386,18 @@ declare namespace jasmine { } interface CustomReporterResult { - description: string, - failedExpectations?: FailedExpectation[], - fullName: string, + description: string; + failedExpectations?: FailedExpectation[]; + fullName: string; id: string; - passedExpectations?: PassedExpectation[], + passedExpectations?: PassedExpectation[]; pendingReason?: string; status?: string; } interface RunDetails { failedExpectations: ExpectationResult[]; - order: jasmine.Order + order: jasmine.Order; } interface CustomReporter { @@ -431,9 +427,7 @@ declare namespace jasmine { results(): NestedResults; } - interface SpecFunction { - (spec?: Spec): void; - } + type SpecFunction = (spec?: Spec) => void; interface SuiteOrSpec { id: number; @@ -513,7 +507,7 @@ declare namespace jasmine { identity: string; and: SpyAnd; calls: Calls; - mostRecentCall: {args: any[];}; + mostRecentCall: {args: any[]; }; argsForCall: any[]; } @@ -574,7 +568,7 @@ declare namespace jasmine { finished: boolean; result: any; messages: any; - runDetails: RunDetails + runDetails: RunDetails; new (): any; diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index f841a613c5..e80060510b 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -1,34 +1,34 @@ // tests based on http://jasmine.github.io/2.2/introduction.html -describe("A suite", function() { - it("contains spec with an expectation", function() { +describe("A suite", () => { + it("contains spec with an expectation", () => { expect(true).toBe(true); }); }); -describe("A suite is just a function", function() { +describe("A suite is just a function", () => { var a: boolean; - it("and so is a spec", function() { + it("and so is a spec", () => { a = true; expect(a).toBe(true); }); }); -describe("The 'toBe' matcher compares with ===", function() { +describe("The 'toBe' matcher compares with ===", () => { - it("and has a positive case", function() { + it("and has a positive case", () => { expect(true).toBe(true); }); - it("and can have a negative case", function() { + it("and can have a negative case", () => { expect(false).not.toBe(true); }); }); -describe("Included matchers:", function() { +describe("Included matchers:", () => { - it("The 'toBe' matcher compares with ===", function() { + it("The 'toBe' matcher compares with ===", () => { var a = 12; var b = a; @@ -36,14 +36,14 @@ describe("Included matchers:", function() { expect(a).not.toBe(null); }); - describe("The 'toEqual' matcher", function() { + describe("The 'toEqual' matcher", () => { - it("works for simple literals and variables", function() { + it("works for simple literals and variables", () => { var a = 12; expect(a).toEqual(12); }); - it("should work for objects", function() { + it("should work for objects", () => { var foo = { a: 12, b: 34 @@ -56,7 +56,7 @@ describe("Included matchers:", function() { }); }); - it("The 'toMatch' matcher is for regular expressions", function() { + it("The 'toMatch' matcher is for regular expressions", () => { var message = "foo bar baz"; expect(message).toMatch(/bar/); @@ -64,16 +64,16 @@ describe("Included matchers:", function() { expect(message).not.toMatch(/quux/); }); - it("The 'toBeDefined' matcher compares against `undefined`", function() { + it("The 'toBeDefined' matcher compares against `undefined`", () => { var a = { foo: "foo" }; expect(a.foo).toBeDefined(); - expect((a).bar).not.toBeDefined(); + expect((a as any).bar).not.toBeDefined(); }); - it("The `toBeUndefined` matcher compares against `undefined`", function() { + it("The `toBeUndefined` matcher compares against `undefined`", () => { var a = { foo: "foo" }; @@ -82,7 +82,7 @@ describe("Included matchers:", function() { expect((a as any).bar).toBeUndefined(); }); - it("The 'toBeNull' matcher compares against null", function() { + it("The 'toBeNull' matcher compares against null", () => { var a: string = null; var foo = "foo"; @@ -91,28 +91,28 @@ describe("Included matchers:", function() { expect(foo).not.toBeNull(); }); - it("The 'toBeTruthy' matcher is for boolean casting testing", function() { + it("The 'toBeTruthy' matcher is for boolean casting testing", () => { var a: string, foo = "foo"; expect(foo).toBeTruthy(); expect(a).not.toBeTruthy(); }); - it("The 'toBeFalsy' matcher is for boolean casting testing", function() { + it("The 'toBeFalsy' matcher is for boolean casting testing", () => { var a: string, foo = "foo"; expect(a).toBeFalsy(); expect(foo).not.toBeFalsy(); }); - it("The 'toContain' matcher is for finding an item in an Array", function() { + it("The 'toContain' matcher is for finding an item in an Array", () => { var a = ["foo", "bar", "baz"]; expect(a).toContain('foo'); expect(a).not.toContain("quux"); }); - it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { + it("The 'toBeLessThan' matcher is for mathematical comparisons", () => { var pi = 3.1415926, e = 2.78; @@ -120,7 +120,7 @@ describe("Included matchers:", function() { expect(pi).not.toBeLessThan(e); }); - it("The 'toBeGreaterThan' is for mathematical comparisons", function() { + it("The 'toBeGreaterThan' is for mathematical comparisons", () => { var pi = 3.1415926, e = 2.78; @@ -128,7 +128,7 @@ describe("Included matchers:", function() { expect(e).not.toBeGreaterThan(pi); }); - it("The 'toBeCloseTo' matcher is for precision math comparison", function() { + it("The 'toBeCloseTo' matcher is for precision math comparison", () => { var pi = 3.1415926, e = 2.78; @@ -136,12 +136,12 @@ describe("Included matchers:", function() { expect(pi).toBeCloseTo(e, 0); }); - it("The 'toThrow' matcher is for testing if a function throws an exception", function() { - var foo = function() { + it("The 'toThrow' matcher is for testing if a function throws an exception", () => { + var foo = () => { return 1 + 2; }; - var bar = function() { - var a: any = undefined; + var bar = () => { + var a: any; return a + 1; }; @@ -149,8 +149,8 @@ describe("Included matchers:", function() { expect(bar).toThrow(); }); - it("The 'toThrowError' matcher is for testing a specific thrown exception", function() { - var foo = function() { + it("The 'toThrowError' matcher is for testing a specific thrown exception", () => { + var foo = () => { throw new TypeError("foo bar baz"); }; @@ -161,15 +161,15 @@ describe("Included matchers:", function() { }); }); -describe("A spec", function() { - it("is just a function, so it can contain any code", function() { +describe("A spec", () => { + it("is just a function, so it can contain any code", () => { var foo = 0; foo += 1; expect(foo).toEqual(1); }); - it("can have more than one expectation", function() { + it("can have more than one expectation", () => { var foo = 0; foo += 1; @@ -178,96 +178,96 @@ describe("A spec", function() { }); }); -describe("A spec (with setup and tear-down)", function() { +describe("A spec (with setup and tear-down)", () => { var foo: number; - beforeEach(function() { + beforeEach(() => { foo = 0; foo += 1; }); - afterEach(function() { + afterEach(() => { foo = 0; }); - it("is just a function, so it can contain any code", function() { + it("is just a function, so it can contain any code", () => { expect(foo).toEqual(1); }); - it("can have more than one expectation", function() { + it("can have more than one expectation", () => { expect(foo).toEqual(1); expect(true).toEqual(true); }); }); -describe("A spec", function() { +describe("A spec", () => { var foo: number; - beforeEach(function() { + beforeEach(() => { foo = 0; foo += 1; }); - afterEach(function() { + afterEach(() => { foo = 0; }); - it("is just a function, so it can contain any code", function() { + it("is just a function, so it can contain any code", () => { expect(foo).toEqual(1); }); - it("can have more than one expectation", function() { + it("can have more than one expectation", () => { expect(foo).toEqual(1); expect(true).toEqual(true); }); - describe("nested inside a second describe", function() { + describe("nested inside a second describe", () => { var bar: number; - beforeEach(function() { + beforeEach(() => { bar = 1; }); - it("can reference both scopes as needed", function() { + it("can reference both scopes as needed", () => { expect(foo).toEqual(bar); }); }); }); -xdescribe("A spec", function() { +xdescribe("A spec", () => { var foo: number; - beforeEach(function() { + beforeEach(() => { foo = 0; foo += 1; }); - it("is just a function, so it can contain any code", function() { + it("is just a function, so it can contain any code", () => { expect(foo).toEqual(1); }); }); -describe("Pending specs", function() { +describe("Pending specs", () => { - xit("can be declared 'xit'", function() { + xit("can be declared 'xit'", () => { expect(true).toBe(false); }); it("can be declared with 'it' but without a function"); - it("can be declared by calling 'pending' in the spec body", function() { + it("can be declared by calling 'pending' in the spec body", () => { expect(true).toBe(false); pending(); // without reason pending('this is why it is pending'); }); }); -describe("A spy", function() { +describe("A spy", () => { var foo: any, bar: any = null; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -278,29 +278,29 @@ describe("A spy", function() { foo.setBar(456, 'another param'); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.setBar).toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function() { + it("tracks all the arguments of its calls", () => { expect(foo.setBar).toHaveBeenCalledWith(123); expect(foo.setBar).toHaveBeenCalledWith(456, 'another param'); }); - it("stops all execution on a function", function() { + it("stops all execution on a function", () => { expect(bar).toBeNull(); }); }); -describe("A spy, when configured to call through", function() { +describe("A spy, when configured to call through", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -311,28 +311,28 @@ describe("A spy, when configured to call through", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(123); }); }); -describe("A spy, when configured to fake a return value", function() { +describe("A spy, when configured to fake a return value", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -343,28 +343,28 @@ describe("A spy, when configured to fake a return value", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(745); }); }); -describe("A spy, when configured to fake a series of return values", function() { +describe("A spy, when configured to fake a series of return values", () => { var foo: any, bar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -374,36 +374,36 @@ describe("A spy, when configured to fake a series of return values", function() foo.setBar(123); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { foo.getBar(123); expect(foo.getBar).toHaveBeenCalled(); }); - it("should not affect other functions", function() { + it("should not affect other functions", () => { expect(bar).toEqual(123); }); - it("when called multiple times returns the requested values in order", function() { + it("when called multiple times returns the requested values in order", () => { expect(foo.getBar()).toEqual("fetched first"); expect(foo.getBar()).toEqual("fetched second"); expect(foo.getBar()).toBeUndefined(); }); }); -describe("A spy, when configured with an alternate implementation", function() { +describe("A spy, when configured with an alternate implementation", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; - spyOn(foo, "getBar").and.callFake(function() { + spyOn(foo, "getBar").and.callFake(() => { return 1001; }); @@ -411,25 +411,25 @@ describe("A spy, when configured with an alternate implementation", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(1001); }); }); -describe("A spy, when configured to throw a value", function() { +describe("A spy, when configured to throw a value", () => { var foo: any, bar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -437,22 +437,22 @@ describe("A spy, when configured to throw a value", function() { spyOn(foo, "setBar").and.throwError("quux"); }); - it("throws the value", function() { - expect(function() { - foo.setBar(123) + it("throws the value", () => { + expect(() => { + foo.setBar(123); }).toThrowError("quux"); }); }); -describe("A spy, when configured with multiple actions", function() { +describe("A spy, when configured with multiple actions", () => { var foo: any, bar: any, fetchedBar: any; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, - getBar: function() { + getBar: () => { return bar; } }; @@ -465,29 +465,29 @@ describe("A spy, when configured with multiple actions", function() { fetchedBar = foo.getBar(); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(foo.getBar).toHaveBeenCalled(); }); - it("should not effect other functions", function() { + it("should not effect other functions", () => { expect(bar).toEqual(123); }); - it("when called returns the requested value", function() { + it("when called returns the requested value", () => { expect(fetchedBar).toEqual(123); }); - it("should have called the fake implementation", function() { + it("should have called the fake implementation", () => { expect(this.fakeCalled).toEqual(true); }); }); -describe("A spy", function() { +describe("A spy", () => { var foo: any, bar: any = null; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -495,7 +495,7 @@ describe("A spy", function() { spyOn(foo, 'setBar').and.callThrough(); }); - it("can call through and then stub in the same spec", function() { + it("can call through and then stub in the same spec", () => { foo.setBar(123); expect(bar).toEqual(123); @@ -507,12 +507,12 @@ describe("A spy", function() { }); }); -describe("A spy", function() { +describe("A spy", () => { var foo: any, bar: any = null; - beforeEach(function() { + beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -520,7 +520,7 @@ describe("A spy", function() { spyOn(foo, 'setBar'); }); - it("tracks if it was called at all", function() { + it("tracks if it was called at all", () => { expect(foo.setBar.calls.any()).toEqual(false); foo.setBar(); @@ -528,7 +528,7 @@ describe("A spy", function() { expect(foo.setBar.calls.any()).toEqual(true); }); - it("tracks the number of times it was called", function() { + it("tracks the number of times it was called", () => { expect(foo.setBar.calls.count()).toEqual(0); foo.setBar(); @@ -537,7 +537,7 @@ describe("A spy", function() { expect(foo.setBar.calls.count()).toEqual(2); }); - it("tracks the arguments of each call", function() { + it("tracks the arguments of each call", () => { foo.setBar(123); foo.setBar(456, "baz"); @@ -545,34 +545,34 @@ describe("A spy", function() { expect(foo.setBar.calls.argsFor(1)).toEqual([456, "baz"]); }); - it("tracks the arguments of all calls", function() { + it("tracks the arguments of all calls", () => { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.allArgs()).toEqual([[123], [456, "baz"]]); }); - it("can provide the context and arguments to all calls", function() { + it("can provide the context and arguments to all calls", () => { foo.setBar(123); expect(foo.setBar.calls.all()).toEqual([{ object: foo, args: [123], returnValue: undefined }]); }); - it("has a shortcut to the most recent call", function() { + it("has a shortcut to the most recent call", () => { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.mostRecent()).toEqual({ object: foo, args: [456, "baz"], returnValue: undefined }); }); - it("has a shortcut to the first call", function() { + it("has a shortcut to the first call", () => { foo.setBar(123); foo.setBar(456, "baz"); expect(foo.setBar.calls.first()).toEqual({ object: foo, args: [123], returnValue: undefined }); }); - it("can be reset", function() { + it("can be reset", () => { foo.setBar(123); foo.setBar(456, "baz"); @@ -584,40 +584,40 @@ describe("A spy", function() { }); }); -describe("A spy, when created manually", function() { +describe("A spy, when created manually", () => { var whatAmI: any; - beforeEach(function() { + beforeEach(() => { whatAmI = jasmine.createSpy('whatAmI'); whatAmI("I", "am", "a", "spy"); }); - it("is named, which helps in error reporting", function() { + it("is named, which helps in error reporting", () => { expect(whatAmI.and.identity()).toEqual('whatAmI'); }); - it("tracks that the spy was called", function() { + it("tracks that the spy was called", () => { expect(whatAmI).toHaveBeenCalled(); }); - it("tracks its number of calls", function() { + it("tracks its number of calls", () => { expect(whatAmI.calls.count()).toEqual(1); }); - it("tracks all the arguments of its calls", function() { + it("tracks all the arguments of its calls", () => { expect(whatAmI).toHaveBeenCalledWith("I", "am", "a", "spy"); }); - it("allows access to the most recent call", function() { + it("allows access to the most recent call", () => { expect(whatAmI.calls.mostRecent().args[0]).toEqual("I"); }); }); -describe("Multiple spies, when created manually", function() { +describe("Multiple spies, when created manually", () => { var tape: any; - beforeEach(function() { + beforeEach(() => { tape = jasmine.createSpyObj('tape', ['play', 'pause', 'stop', 'rewind']); tape.play(); @@ -625,35 +625,35 @@ describe("Multiple spies, when created manually", function() { tape.rewind(0); }); - it("creates spies for each requested function", function() { + it("creates spies for each requested function", () => { expect(tape.play).toBeDefined(); expect(tape.pause).toBeDefined(); expect(tape.stop).toBeDefined(); expect(tape.rewind).toBeDefined(); }); - it("tracks that the spies were called", function() { + it("tracks that the spies were called", () => { expect(tape.play).toHaveBeenCalled(); expect(tape.pause).toHaveBeenCalled(); expect(tape.rewind).toHaveBeenCalled(); expect(tape.stop).not.toHaveBeenCalled(); }); - it("tracks all the arguments of its calls", function() { + it("tracks all the arguments of its calls", () => { expect(tape.rewind).toHaveBeenCalledWith(0); }); }); -describe("jasmine.any", function() { - it("matches any value", function() { +describe("jasmine.any", () => { + it("matches any value", () => { expect({}).toEqual(jasmine.any(Object)); expect(12).toEqual(jasmine.any(Number)); }); - describe("when used with a spy", function() { - it("is useful for comparing arguments", function() { + describe("when used with a spy", () => { + it("is useful for comparing arguments", () => { var foo = jasmine.createSpy('foo'); - foo(12, function() { + foo(12, () => { return true; }); @@ -662,7 +662,7 @@ describe("jasmine.any", function() { }); }); -describe("jasmine.objectContaining", function() { +describe("jasmine.objectContaining", () => { interface fooType { a: number; b: number; @@ -670,7 +670,7 @@ describe("jasmine.objectContaining", function() { } var foo: fooType; - beforeEach(function() { + beforeEach(() => { foo = { a: 1, b: 2, @@ -678,7 +678,7 @@ describe("jasmine.objectContaining", function() { }; }); - it("matches objects with the expect key/value pairs", function() { + it("matches objects with the expect key/value pairs", () => { expect(foo).toEqual(jasmine.objectContaining({ bar: '' })); @@ -688,8 +688,8 @@ describe("jasmine.objectContaining", function() { })); }); - describe("when used with a spy", function() { - it("is useful for comparing arguments", function() { + describe("when used with a spy", () => { + it("is useful for comparing arguments", () => { var callback = jasmine.createSpy('callback'); callback({ @@ -706,20 +706,20 @@ describe("jasmine.objectContaining", function() { }); }); -describe("jasmine.arrayContaining", function() { +describe("jasmine.arrayContaining", () => { var foo: any; - beforeEach(function() { + beforeEach(() => { foo = [1, 2, 3, 4]; }); - it("matches arrays with some of the values", function() { + it("matches arrays with some of the values", () => { expect(foo).toEqual(jasmine.arrayContaining([3, 1])); expect(foo).not.toEqual(jasmine.arrayContaining([6])); }); - describe("when used with a spy", function() { - it("is useful when comparing arguments", function() { + describe("when used with a spy", () => { + it("is useful when comparing arguments", () => { var callback = jasmine.createSpy('callback'); callback([1, 2, 3, 4]); @@ -730,20 +730,20 @@ describe("jasmine.arrayContaining", function() { }); }); -describe("Manually ticking the Jasmine Clock", function() { +describe("Manually ticking the Jasmine Clock", () => { var timerCallback: any; - beforeEach(function() { + beforeEach(() => { timerCallback = jasmine.createSpy("timerCallback"); jasmine.clock().install(); }); - afterEach(function() { + afterEach(() => { jasmine.clock().uninstall(); }); - it("causes a timeout to be called synchronously", function() { - setTimeout(function() { + it("causes a timeout to be called synchronously", () => { + setTimeout(() => { timerCallback(); }, 100); @@ -754,8 +754,8 @@ describe("Manually ticking the Jasmine Clock", function() { expect(timerCallback).toHaveBeenCalled(); }); - it("causes an interval to be called synchronously", function() { - setInterval(function() { + it("causes an interval to be called synchronously", () => { + setInterval(() => { timerCallback(); }, 100); @@ -771,8 +771,8 @@ describe("Manually ticking the Jasmine Clock", function() { expect(timerCallback.calls.count()).toEqual(2); }); - describe("Mocking the Date object", function() { - it("mocks the Date object and sets it to a given time", function() { + describe("Mocking the Date object", () => { + it("mocks the Date object and sets it to a given time", () => { var baseTime = new Date(2013, 9, 23); jasmine.clock().mockDate(baseTime); @@ -783,82 +783,82 @@ describe("Manually ticking the Jasmine Clock", function() { }); }); -describe("Asynchronous specs", function() { +describe("Asynchronous specs", () => { var value: number; - beforeEach(function (done: DoneFn) { - setTimeout(function() { + beforeEach((done: DoneFn) => { + setTimeout(() => { value = 0; done(); }, 1); }); - it("should support async execution of test preparation and expectations", function (done: DoneFn) { + it("should support async execution of test preparation and expectations", (done: DoneFn) => { value++; expect(value).toBeGreaterThan(0); done(); }); - describe("long asynchronous specs", function() { - beforeEach(function (done: DoneFn) { + describe("long asynchronous specs", () => { + beforeEach((done: DoneFn) => { done(); }, 1000); - it("takes a long time", function (done: DoneFn) { - setTimeout(function() { + it("takes a long time", (done: DoneFn) => { + setTimeout(() => { done(); }, 9000); }, 10000); - afterEach(function (done: DoneFn) { + afterEach((done: DoneFn) => { done(); }, 1000); }); }); -describe("Fail", function() { +describe("Fail", () => { - it("should fail test when called without arguments", function() { + it("should fail test when called without arguments", () => { fail(); }); - it("should fail test when called with a fail message", function() { + it("should fail test when called with a fail message", () => { fail("The test failed"); }); - it("should fail test when called an error", function() { + it("should fail test when called an error", () => { fail(new Error("The test failed with this error")); }); }); // test based on http://jasmine.github.io/2.2/custom_equality.html -describe("custom equality", function() { - var myCustomEquality: jasmine.CustomEqualityTester = function (first: any, second: any): boolean { - if (typeof first == "string" && typeof second == "string") { - return first[0] == second[1]; +describe("custom equality", () => { + var myCustomEquality: jasmine.CustomEqualityTester = function(first: any, second: any): boolean { + if (typeof first === "string" && typeof second === "string") { + return first[0] === second[1]; } }; - beforeEach(function() { + beforeEach(() => { jasmine.addCustomEqualityTester(myCustomEquality); }); - it("should be custom equal", function() { + it("should be custom equal", () => { expect("abc").toEqual("aaa"); }); - it("should be custom not equal", function() { + it("should be custom not equal", () => { expect("abc").not.toEqual("abc"); }); }); // test based on http://jasmine.github.io/2.2/custom_matcher.html var customMatchers: jasmine.CustomMatcherFactories = { - toBeGoofy: function (util: jasmine.MatchersUtil, customEqualityTesters: Array) { + toBeGoofy: (util: jasmine.MatchersUtil, customEqualityTesters: jasmine.CustomEqualityTester[]) => { return { - compare: function (actual: any, expected: any): jasmine.CustomMatcherResult { + compare: (actual: any, expected: any): jasmine.CustomMatcherResult => { if (expected === undefined) { expected = ''; } @@ -892,24 +892,24 @@ declare namespace jasmine { } } -describe("Custom matcher: 'toBeGoofy'", function() { - beforeEach(function() { +describe("Custom matcher: 'toBeGoofy'", () => { + beforeEach(() => { jasmine.addMatchers(customMatchers); }); - it("is available on an expectation", function() { + it("is available on an expectation", () => { expect({ hyuk: 'gawrsh' }).toBeGoofy(); }); - it("can take an 'expected' parameter", function() { + it("can take an 'expected' parameter", () => { expect({ hyuk: 'gawrsh is fun' }).toBeGoofy({ hyuk: ' is fun' }); }); - it("can be negated", function() { + it("can be negated", () => { expect({ hyuk: 'this is fun' }).not.toBeGoofy(); @@ -918,20 +918,21 @@ describe("Custom matcher: 'toBeGoofy'", function() { // test based on http://jasmine.github.io/2.5/custom_reporter.html var myReporter: jasmine.CustomReporter = { - jasmineStarted: function (suiteInfo: jasmine.SuiteInfo) { + jasmineStarted: (suiteInfo: jasmine.SuiteInfo) => { console.log("Running suite with " + suiteInfo.totalSpecsDefined); }, - suiteStarted: function (result: jasmine.CustomReporterResult) { + suiteStarted: (result: jasmine.CustomReporterResult) => { console.log("Suite started: " + result.description + " whose full description is: " + result.fullName); }, - specStarted: function (result: jasmine.CustomReporterResult) { + specStarted: (result: jasmine.CustomReporterResult) => { console.log("Spec started: " + result.description + " whose full description is: " + result.fullName); }, - specDone: function (result: jasmine.CustomReporterResult) { + specDone: (result: jasmine.CustomReporterResult) => { console.log("Spec: " + result.description + " was " + result.status); + //tslint:disable-next-line:prefer-for-of for (var i = 0; i < result.failedExpectations.length; i++) { console.log("Failure: " + result.failedExpectations[i].message); console.log("Actual: " + result.failedExpectations[i].actual); @@ -941,15 +942,16 @@ var myReporter: jasmine.CustomReporter = { console.log(result.passedExpectations.length); }, - suiteDone: function (result: jasmine.CustomReporterResult) { + suiteDone: (result: jasmine.CustomReporterResult) => { console.log('Suite: ' + result.description + ' was ' + result.status); + //tslint:disable-next-line:prefer-for-of for (var i = 0; i < result.failedExpectations.length; i++) { console.log('AfterAll ' + result.failedExpectations[i].message); console.log(result.failedExpectations[i].stack); } }, - jasmineDone: function (runDetails: jasmine.RunDetails) { + jasmineDone: (runDetails: jasmine.RunDetails) => { console.log('Finished suite'); console.log('Random:', runDetails.order.random); } @@ -957,16 +959,16 @@ var myReporter: jasmine.CustomReporter = { jasmine.getEnv().addReporter(myReporter); -describe("Randomize Tests", function() { - it("should allow randomization of the order of tests", function() { - expect(function() { +describe("Randomize Tests", () => { + it("should allow randomization of the order of tests", () => { + expect(() => { var env = jasmine.getEnv(); return env.randomizeTests(true); }).not.toThrow(); }); - it("should allow a seed to be passed in for randomization", function() { - expect(function() { + it("should allow a seed to be passed in for randomization", () => { + expect(() => { var env = jasmine.getEnv(); env.randomizeTests(true); return env.seed(1234); @@ -982,14 +984,14 @@ describe("Randomize Tests", function() { env.addReporter(htmlReporter); var specFilter = new jasmine.HtmlSpecFilter(); - env.specFilter = function (spec) { + env.specFilter = (spec) => { return specFilter.matches(spec.getFullName()); }; var currentWindowOnload = window.onload; - window.onload = function() { + window.onload = () => { if (currentWindowOnload) { - (currentWindowOnload)(null); + (currentWindowOnload as any)(null); } htmlReporter.initialize(); env.execute(); diff --git a/jasmine/v1/jasmine-tests.ts b/jasmine/v1/jasmine-tests.ts index 9177679f8a..c47fc84007 100644 --- a/jasmine/v1/jasmine-tests.ts +++ b/jasmine/v1/jasmine-tests.ts @@ -60,7 +60,7 @@ describe("Included matchers:", () => { foo: 'foo' }; expect(a.foo).toBeDefined(); - expect((a).bar).not.toBeDefined(); + expect((a as any).bar).not.toBeDefined(); }); it("The `toBeUndefined` matcher compares against `undefined`", () => { @@ -68,7 +68,7 @@ describe("Included matchers:", () => { foo: 'foo' }; expect(a.foo).not.toBeUndefined(); - expect((a).bar).toBeUndefined(); + expect((a as any).bar).toBeUndefined(); }); it("The 'toBeNull' matcher compares against null", () => { @@ -202,7 +202,7 @@ describe("A spy", () => { var foo: any, bar: any = null; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; } }; @@ -235,7 +235,7 @@ describe("A spy, when configured to call through", () => { var foo: any, bar: any, fetchedBar: any; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, getBar: () => { @@ -261,7 +261,7 @@ describe("A spy, when faking a return value", () => { var foo: any, bar: any, fetchedBar: any; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, getBar: () => { @@ -287,7 +287,7 @@ describe("A spy, when faking a return value", () => { var foo: any, bar: any, fetchedBar: any; beforeEach(() => { foo = { - setBar: function (value: any) { + setBar: (value: any) => { bar = value; }, getBar: () => { @@ -319,7 +319,7 @@ describe("A spy, when created manually", () => { whatAmI("I", "am", "a", "spy"); }); it("is named, which helps in error reporting", () => { - expect(whatAmI.identity).toEqual('whatAmI') + expect(whatAmI.identity).toEqual('whatAmI'); }); it("tracks that the spy was called", () => { expect(whatAmI).toHaveBeenCalled(); @@ -369,7 +369,7 @@ describe("jasmine.any", () => { it("is useful for comparing arguments", () => { var foo = jasmine.createSpy('foo'); foo(12, () => { - return true + return true; }); expect(foo).toHaveBeenCalledWith(jasmine.any(Number), jasmine.any(Function)); }); @@ -430,7 +430,7 @@ describe("Asynchronous specs", () => { jasmineEnv.updateInterval = 250; var htmlReporter = new jasmine.HtmlReporter(); jasmineEnv.addReporter(htmlReporter); - jasmineEnv.specFilter = function (spec) { + jasmineEnv.specFilter = (spec) => { return htmlReporter.specFilter(spec); }; var currentWindowOnload = (arg: any) => window.onload(arg); @@ -439,11 +439,11 @@ describe("Asynchronous specs", () => { currentWindowOnload(null); } - (document.querySelector('.version')).innerHTML = jasmineEnv.versionString(); + (document.querySelector('.version') as HTMLElement).innerHTML = jasmineEnv.versionString(); execJasmine(); }; function execJasmine() { jasmineEnv.execute(); } -})(); \ No newline at end of file +})(); From ba29010d1438767c5db5e73d716447178d85f0f3 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Sun, 26 Feb 2017 13:17:07 +0100 Subject: [PATCH 031/258] Fix other jasmine packages --- jasmine-es6-promise-matchers/index.d.ts | 2 +- jasmine-expect/index.d.ts | 2 +- jasmine-jquery/index.d.ts | 6 +++--- jasmine-jquery/jasmine-jquery-tests.ts | 4 ++-- jasmine-matchers/index.d.ts | 2 +- jasmine-promise-matchers/index.d.ts | 2 +- jasmine/v1/index.d.ts | 16 ++++++++-------- jasminewd2/index.d.ts | 17 ++++++++++++----- 8 files changed, 29 insertions(+), 22 deletions(-) diff --git a/jasmine-es6-promise-matchers/index.d.ts b/jasmine-es6-promise-matchers/index.d.ts index 89e3146c2c..7d61d4d660 100644 --- a/jasmine-es6-promise-matchers/index.d.ts +++ b/jasmine-es6-promise-matchers/index.d.ts @@ -13,7 +13,7 @@ declare namespace JasminePromiseMatchers { declare namespace jasmine { - interface Matchers { + interface Matchers { /** * Verifies that a Promise is (or has been) rejected. */ diff --git a/jasmine-expect/index.d.ts b/jasmine-expect/index.d.ts index c2ee7e0ee5..25a21d49d5 100644 --- a/jasmine-expect/index.d.ts +++ b/jasmine-expect/index.d.ts @@ -7,7 +7,7 @@ /// declare namespace jasmine { - interface Matchers { + interface Matchers { // These functions are written in the order defined in the src directory of jasmine-matchers // The type system is used smartly whenever it can provide value (by looking at the code of every matcher) toBeAfter(otherDate: Date): boolean; // diff --git a/jasmine-jquery/index.d.ts b/jasmine-jquery/index.d.ts index fb91e0c37b..ebc14cee75 100644 --- a/jasmine-jquery/index.d.ts +++ b/jasmine-jquery/index.d.ts @@ -81,7 +81,7 @@ declare namespace jasmine { proxyCallTo_(methodName: string, passedArguments: any): any; } - interface Matchers { + interface Matchers { /** * Check if DOM element has class. * @@ -232,7 +232,7 @@ declare namespace jasmine { * */ toHaveData(key : string, expectedValue : string): boolean; - toBe(selector: JQuery): boolean; + toBe(selector: T): boolean; /** * Check if DOM element is matched by the given selector. @@ -241,7 +241,7 @@ declare namespace jasmine { * // returns true * expect($('
')).toContain('some-class') */ - toContain(selector: JQuery): boolean; + toContain(selector: T): boolean; /** * Check if DOM element exists inside the given parent element. diff --git a/jasmine-jquery/jasmine-jquery-tests.ts b/jasmine-jquery/jasmine-jquery-tests.ts index 67b349d45e..9d51a3775b 100644 --- a/jasmine-jquery/jasmine-jquery-tests.ts +++ b/jasmine-jquery/jasmine-jquery-tests.ts @@ -4,8 +4,8 @@ describe("Jasmine jQuery extension", () => { it("Adds jQuery matchers", () => { - expect($('
')).toBe('div'); - expect($('
')).toBe('div#some-id'); + expect($('
')).toBe($('div')); + expect($('
')).toBe($('div#some-id')); expect($('')).toBeChecked(); expect($('
')).toBeHidden(); expect($('
')).toHaveCss({ display: "none", margin: "10px" }); diff --git a/jasmine-matchers/index.d.ts b/jasmine-matchers/index.d.ts index ac44d25c1c..d4cad3b77c 100644 --- a/jasmine-matchers/index.d.ts +++ b/jasmine-matchers/index.d.ts @@ -23,7 +23,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI /// declare namespace jasmine { - interface Matchers { + interface Matchers { //toBe toBeArray(): boolean; diff --git a/jasmine-promise-matchers/index.d.ts b/jasmine-promise-matchers/index.d.ts index c511019b62..ffe4f65142 100644 --- a/jasmine-promise-matchers/index.d.ts +++ b/jasmine-promise-matchers/index.d.ts @@ -10,7 +10,7 @@ declare function installPromiseMatchers(): void; declare namespace jasmine { - interface Matchers { + interface Matchers { /** * Verifies that a Promise is (or has been) rejected. */ diff --git a/jasmine/v1/index.d.ts b/jasmine/v1/index.d.ts index 5cbb2a9f83..3f51240f63 100644 --- a/jasmine/v1/index.d.ts +++ b/jasmine/v1/index.d.ts @@ -16,9 +16,9 @@ declare function xit(expectation: string, assertion: () => void): void; declare function beforeEach(action: () => void): void; declare function afterEach(action: () => void): void; -declare function expect(spy: Function): jasmine.Matchers; -//declare function expect(spy: jasmine.Spy): jasmine.Matchers; -declare function expect(actual: any): jasmine.Matchers; +declare function expect(spy: Function): jasmine.Matchers; +//declare function expect(spy: jasmine.Spy): jasmine.Matchers; +declare function expect(actual: any): jasmine.Matchers; declare function spyOn(object: any, method: string): jasmine.Spy; @@ -91,7 +91,7 @@ declare namespace jasmine { currentSpec: Spec; - matchersClass: Matchers; + matchersClass: Matchers; version(): any; versionString(): string; @@ -204,7 +204,7 @@ declare namespace jasmine { results(): NestedResults; } - interface Matchers { + interface Matchers { new (env: Env, actual: any, spec: Env, isNot?: boolean): any; @@ -232,7 +232,7 @@ declare namespace jasmine { toContainHtml(expected: string): boolean; toContainText(expected: string): boolean; toThrow(expected?: any): boolean; - not: Matchers; + not: Matchers; Any: Any; } @@ -287,7 +287,7 @@ declare namespace jasmine { spies_: Spy[]; results_: NestedResults; - matchersClass: Matchers; + matchersClass: Matchers; getFullName(): string; results(): NestedResults; @@ -299,7 +299,7 @@ declare namespace jasmine { waits(timeout: number): Spec; waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec; fail(e?: any): void; - getMatchersClass_(): Matchers; + getMatchersClass_(): Matchers; addMatchers(matchersPrototype: any): void; finishCallback(): void; finish(onComplete?: () => void): void; diff --git a/jasminewd2/index.d.ts b/jasminewd2/index.d.ts index 9d8ecde76e..a4122c6639 100644 --- a/jasminewd2/index.d.ts +++ b/jasminewd2/index.d.ts @@ -17,10 +17,10 @@ declare function afterAll(action: () => Promise, timeout?: number): void; declare namespace jasmine { // The global `Promise` type is too strict and kinda wrong interface Promise { - then(onFulfill?: (value: T) => U | Promise, onReject?: (error: any) => U | Promise): Promise; + then(onFulfill?: (value: T) => U | Promise, onReject?: (error: any) => U | Promise): Promise; } - interface Matchers { + interface Matchers { toBe(expected: any, expectationFailOutput?: any): Promise; toEqual(expected: any, expectationFailOutput?: any): Promise; toMatch(expected: string | RegExp | Promise, expectationFailOutput?: any): Promise; @@ -44,6 +44,13 @@ declare namespace jasmine { toThrowError(expected?: new (...args: any[]) => Error | Promise Error>, message?: string | RegExp | Promise): Promise; } + interface ArrayLikeMatchers> extends Matchers { + toBe(expected: Expected>, expectationFailOutput?: any): Promise; + toEqual(expected: Expected>, expectationFailOutput?: any): Promise; + toContain(expected: T, expectationFailOutput?: any): Promise; + not: ArrayLikeMatchers; + } + function addMatchers(matchers: AsyncCustomMatcherFactories): void; interface Env { @@ -59,12 +66,12 @@ declare namespace jasmine { } interface AsyncCustomMatcherFactory { - (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]): AsyncCustomMatcher; + (util: MatchersUtil, customEqualityTesters: CustomEqualityTester[]): AsyncCustomMatcher; } interface AsyncCustomMatcher { - compare(actual: T, expected: T): AsyncCustomMatcherResult; - compare(actual: any, expected: any): AsyncCustomMatcherResult; + compare(actual: T, expected: T): AsyncCustomMatcherResult; + compare(actual: any, expected: any): AsyncCustomMatcherResult; } interface AsyncCustomMatcherResult { From d2267ead2004bf3e87d769808ab51532fc5db132 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Mon, 27 Feb 2017 18:00:08 +0100 Subject: [PATCH 032/258] Fix fetch-mock with TypeScript version 2.2 --- fetch-mock/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch-mock/index.d.ts b/fetch-mock/index.d.ts index 4d69096845..bda708ee55 100644 --- a/fetch-mock/index.d.ts +++ b/fetch-mock/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/wheresrhys/fetch-mock // Definitions by: Alexey Svetliakov , Tamir Duberstein , Risto Keravuori // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +// TypeScript Version: 2.2 type MockRequest = Request | RequestInit; From f7ab322332c2a6e3d923402cec1db0811ea753f2 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Thu, 2 Mar 2017 11:36:31 +0100 Subject: [PATCH 033/258] Modernizr: various fixes. Updated version to 3.3, since all everything new since 3.2 was already added. --- modernizr/index.d.ts | 95 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 77 insertions(+), 18 deletions(-) diff --git a/modernizr/index.d.ts b/modernizr/index.d.ts index 7fd0ffa316..44d3c40775 100644 --- a/modernizr/index.d.ts +++ b/modernizr/index.d.ts @@ -1,19 +1,19 @@ -// Type definitions for Modernizr 3.2 +// Type definitions for Modernizr 3.3 // Project: http://modernizr.com/ // Definitions by: Boris Yankov , Theodore Brown , Leon Yu , Luca Trazzi // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface AudioBoolean { - ogg: boolean; - mp3: boolean; - wav: boolean; - m4a: boolean; + ogg: string; + mp3: string; + wav: string; + m4a: string; } interface VideoBoolean { - ogg: boolean; - h264: boolean; - webm: boolean; + ogg: string; + h264: string; + webm: string; } interface InputBoolean { @@ -45,6 +45,66 @@ interface InputTypesBoolean { week: boolean; } +interface CssColumnsBoolean extends Boolean { + breakafter: boolean; + breakbefore: boolean; + breakinside: boolean; + fill: boolean; + gap: boolean; + rule: boolean; + rulecolor: boolean; + rulestyle: boolean; + rulewidth: boolean; + span: boolean; + width: boolean; +} + +interface FlashBoolean extends Boolean { + blocked: boolean; +} + +interface IndexeddbBoolean extends Boolean { + deletedatabase: boolean; +} + +interface WebglextensionsBoolean extends Boolean { + ANGLE_instanced_arrays: boolean; + EXT_blend_minmax: boolean; + EXT_disjoint_timer_query: boolean; + EXT_frag_depth: boolean; + EXT_sRGB: boolean; + EXT_shader_texture_lod: boolean; + EXT_texture_filter_anisotropic: boolean; + OES_element_index_uint: boolean; + OES_standard_derivatives: boolean; + OES_texture_float: boolean; + OES_texture_float_linear: boolean; + OES_texture_half_float: boolean; + OES_texture_half_float_linear: boolean; + OES_vertex_array_object: boolean; + WEBGL_compressed_texture_etc1: boolean; + WEBGL_compressed_texture_s3tc: boolean; + WEBGL_debug_renderer_info: boolean; + WEBGL_debug_shaders: boolean; + WEBGL_depth_texture: boolean; + WEBGL_draw_buffers: boolean; + WEBGL_lose_context: boolean; + WEBKIT_EXT_texture_filter_anisotropic: boolean; + WEBKIT_WEBGL_compressed_texture_s3tc: boolean; + WEBKIT_WEBGL_depth_texture: boolean; + WEBKIT_WEBGL_lose_context: boolean; +} + +interface WebpBoolean extends Boolean { + alpha: boolean; + animation: boolean; + lossless: boolean; +} + +interface DatauriBoolean extends Boolean { + over32kb: boolean; +} + interface FeatureDetects { // Documented @@ -67,7 +127,7 @@ interface FeatureDetects { emoji: boolean; eventlistener: boolean; exiforientation: boolean; - flash: boolean; + flash: false | FlashBoolean; forcetouch: boolean; fullscreen: boolean; gamepads: boolean; @@ -77,7 +137,7 @@ interface FeatureDetects { history: boolean; htmlimports: boolean; ie8compat: boolean; - indexeddb: boolean; + indexeddb: false | IndexeddbBoolean; indexeddbblob: boolean; input: InputBoolean; search: boolean; @@ -143,7 +203,7 @@ interface FeatureDetects { csscalc: boolean; checked: boolean; csschunit: boolean; - csscolumns: boolean; + csscolumns: false | CssColumnsBoolean; cubicbezierrange: boolean; "display-runin": boolean; displaytable: boolean; @@ -266,8 +326,7 @@ interface FeatureDetects { webpalpha: boolean; webpanimation: boolean; webplossless: boolean; - "webp-lossless": boolean; - webp: boolean; + webp: false | WebpBoolean; inputformaction: boolean; inputformenctype: boolean; inputformmethod: boolean; @@ -299,12 +358,12 @@ interface FeatureDetects { smil: boolean; textareamaxlength: boolean; bloburls: boolean; - datauri: boolean; + datauri: false | DatauriBoolean; urlparser: boolean; videoautoplay: boolean; videoloop: boolean; videopreload: boolean; - webglextensions: boolean; + webglextensions: false | WebglextensionsBoolean; datachannel: boolean; getusermedia: boolean; peerconnection: boolean; @@ -344,8 +403,8 @@ interface Dictionary { interface ModernizrAPI { on(feature: string, cb: (result: boolean) => any): void; - addTest(feature: string, test: (() => boolean) | boolean): void; - addTest(feature: Dictionary): void; + addTest(feature: string, test: (() => boolean) | boolean): ModernizrStatic; + addTest(feature: Dictionary): ModernizrStatic; atRule(prop: string): boolean; @@ -360,7 +419,7 @@ interface ModernizrAPI { prefixedCSS(prop: string): string; - prefixedCSSValue(prop: string, value: string): string; + prefixedCSSValue(prop: string, value: string): boolean; _prefixes: string[]; From 52031f3484ee170fcd343fa90a7684855fb6844c Mon Sep 17 00:00:00 2001 From: Lauri Koskela Date: Thu, 2 Mar 2017 18:02:52 +0200 Subject: [PATCH 034/258] Update time scale options - add `minUnit` option - change `round` option to only accept TimeUnits - remove deprecated `format` option --- chart.js/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chart.js/index.d.ts b/chart.js/index.d.ts index 08781f4463..206be68c92 100644 --- a/chart.js/index.d.ts +++ b/chart.js/index.d.ts @@ -410,16 +410,16 @@ declare namespace Chart { } export interface TimeScale extends ChartScales { - format?: string; displayFormats?: TimeDisplayFormat; isoWeekday?: boolean; max?: string; min?: string; parser?: string | ((arg: any) => any); - round?: string; + round?: TimeUnit; tooltipFormat?: string; unit?: TimeUnit; unitStepSize?: number; + minUnit?: TimeUnit; } export interface RadialLinearScale { From 5f56a7e5e1eabe1d55740f3961ca1fa4c7988d6b Mon Sep 17 00:00:00 2001 From: Jed Mao Date: Sun, 5 Mar 2017 08:48:17 -0600 Subject: [PATCH 035/258] Update vinyl-fs options --- vinyl-fs/index.d.ts | 56 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 9 deletions(-) diff --git a/vinyl-fs/index.d.ts b/vinyl-fs/index.d.ts index 4fa6101b69..52aa5cd506 100644 --- a/vinyl-fs/index.d.ts +++ b/vinyl-fs/index.d.ts @@ -27,32 +27,70 @@ interface SrcOptions extends globStream.Options { /** * Specifies the folder relative to the cwd * This is used to determine the file names when saving in .dest() - * Default is where the glob begins + * Default: where the glob begins */ base?: string; /** * Setting this to false will make file.contents a paused stream * If true it will buffer the file contents - * Defaults to true + * Default: true */ buffer?: boolean; /** - * Setting this to false will ignore the contents of the file and disable writing to disk to speed up operations - * Defaults to true + * The mode the directory should be created with. + * Default: the process mode + */ + dirMode?: number; + + /** + * Whether or not you want globs to match on dot files or not + * (e.g., `.gitignore`). + */ + dot?: boolean; + + /** + * Whether or not to recursively resolve symlinks to their targets. + * Setting to `false` to preserve them as symlinks and make `file.symlink` + * equal the original symlink's target path. + * Default: true + */ + followSymlinks?: boolean; + + /** + * Setting this to false will ignore the contents of the file and disable + * writing to disk to speed up operations + * Default: true */ read?: boolean; - /** Only find files that have been modified since the time specified */ + /** + * Whether or not the symlink should be relative or absolute. + * Default: false + */ + relative?: boolean; + + /** Only find files that have been modified since the time specified */ since?: Date|number; - /** Setting this to true will create a duplex stream, one that passes through items and emits globbed files. - * Defaults to false */ + /** + * Causes the BOM to be stripped on UTF-8 encoded files. Set to `false` + * if you need the BOM for some reason. + */ + stripBOM?: boolean; + + /** + * Setting this to true will create a duplex stream, one that passes + * through items and emits globbed files. + * Default: false + */ passthrough?: boolean; - /** Setting this to true will enable sourcemaps. - * Defaults to false */ + /** + * Setting this to true will enable sourcemaps. + * Default: false + */ sourcemaps?: boolean; } From 638891042fc8b67f9c60022dfe6f7911723eda25 Mon Sep 17 00:00:00 2001 From: Leonidas Arvanitis Date: Sun, 5 Mar 2017 21:26:44 +0200 Subject: [PATCH 036/258] Fix and update according to version 2.1.3 - Added missing methods and options - Removed non-existing options - Expanded comments with default values For this update I used both the site and the code of Toastr to find missing and undocumented (only public ofc.) members. --- toastr/index.d.ts | 381 ++++++++++++++++++++++++++++++++-------------- 1 file changed, 269 insertions(+), 112 deletions(-) diff --git a/toastr/index.d.ts b/toastr/index.d.ts index 5cd8b30c82..767627c95d 100644 --- a/toastr/index.d.ts +++ b/toastr/index.d.ts @@ -8,214 +8,371 @@ interface ToastrOptions { /** - * Optionally override the animation easing to show or hide the toasts. Default is swing. swing and linear are built into jQuery. - */ + * Optionally override the animation easing to show or hide the toasts. + * swing and linear are built into jQuery. + * @default swing + */ showEasing?: string; /** - * Optionally override the animation easing to show or hide the toasts. Default is swing. swing and linear are built into jQuery. - */ + * Optionally override the animation easing to show or hide the toasts. + * swing and linear are built into jQuery. + * @default swing + */ hideEasing?: string; /** - * Use the jQuery show/hide method of your choice. These default to fadeIn/fadeOut. The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. - */ + * Use the jQuery show method of your choice. + * The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. + * @default fadeIn + */ showMethod?: string; /** - * Use the jQuery show/hide method of your choice. These default to fadeIn/fadeOut. The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. - */ + * Use the jQuery hide method of your choice. + * The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. + * @default fadeOut + */ hideMethod?: string; /** - * Should a close button be shown - */ + * Should a close button be shown? + * @default undefined + */ closeButton?: boolean; /** - * Html for the close button - */ + * CSS class the close button will be given. + * @default toast-close-button + */ + closeClass?: string; + /** + * Time in milliseconds the toast should take to hide, when the close button is clicked. + * Falls back to hide configuration. + * @default false + */ + closeDuration?: number; + /** + * The animation easing while hiding the toast, when the close button is clicked. + * Falls back to hide configuration. + * swing and linear are built into jQuery. + * @default false + */ + closeEasing?: string; + /** + * Use the jQuery show/hide method of your choice, when the close button is clicked. + * Falls back to hide configuration. + * The methods fadeIn/fadeOut, slideDown/slideUp, and show/hide are built into jQuery. + * @default false + */ + closeMethod?: string; + /** + * Set to false so that the toast hides event if hovered. + * @default true + */ + closeOnHover?: boolean; + /** + * Html for the close button. + */ closeHtml?: string; /** - * Should clicking on toast dismiss it? - */ + * onCloseClick function callback, fired when the close button is clicked. + * Closing cannot be prevented by ev.stopPropagation() etc. + * @default undefined + */ + onCloseClick?: (ev: JQueryMouseEventObject) => void; + /** + * Should clicking on toast dismiss it? + * @default true + */ tapToDismiss?: boolean; /** - * CSS class the toast element will be given - */ + * CSS class the toast element will be given. + * @default toast + */ toastClass?: string; /** - * Id toast container will be given - */ + * Id toast container will be given. + * @default toast-container + */ containerId?: string; /** - * Should debug details be outputted to the console - */ + * Should debug details be outputted to the console? + * @default false + */ debug?: boolean; /** - * Time in milliseconds the toast should take to show - */ + * Time in milliseconds the toast should take to show. + * @default 300 + */ showDuration?: number; /** - * onShown function callback - **/ + * onShown function callback. + * @default undefined + */ onShown?: () => void; /** - * Time in milliseconds the toast should take to hide - */ + * Time in milliseconds the toast should take to hide. + * @default 1000 + */ hideDuration?: number; /** - * onHidden function callback - **/ + * onHidden function callback. + * @default undefined + */ onHidden?: () => void; /** - * Time in milliseconds the toast should be displayed after mouse over - */ + * Time in milliseconds the toast should be displayed after leaving mouse over. + * Set timeOut and extendedTimeOut to 0 to make it sticky. + * @default 1000 + */ extendedTimeOut?: number; + /** + * If specified, you must provide all classes. + */ iconClasses?: { /** - * Icon to use on error toasts - */ + * Icon to use on error toasts. + * @default toast-error + */ error: string; /** - * Icon to use on info toasts - */ + * Icon to use on info toasts. + * @default toast-info + */ info: string; /** - * Icon to use on success toasts - */ + * Icon to use on success toasts. + * @default toast-success + */ success: string; /** - * Icon to use on warning toasts - */ + * Icon to use on warning toasts. + * @default toast-warning + */ warning: string; }; /** - * Icon to use for toast - */ + * Icon to use for toast. + * @default toast-info + */ iconClass?: string; /** - * Where toast should be displayed - */ + * Where toast should be displayed. + * The default stylesheet covers: + * toast-top-left, toast-top-center, toast-top-right, toast-top-full-width, + * toast-bottom-left, toast-bottom-center, toast-bottom-right, toast-bottom-full-width + * @default toast-top-right + */ positionClass?: string; /** - * Where toast should be displayed - background - */ - backgroundpositionClass?: string; - /** - * Time in milliseconds that the toast should be displayed - */ + * Time in milliseconds that the toast should be displayed. + * Set timeOut and extendedTimeOut to 0 to make it sticky. + * @default 5000 + */ timeOut?: number; /** - * CSS class the title element will be given - */ + * CSS class the title element will be given. + * @default toast-title + */ titleClass?: string; /** - * CSS class the message element will be given - */ + * CSS class the message element will be given. + * @default toast-message + */ messageClass?: string; /** - * Set newest toast to appear on top - **/ + * Set newest toast to appear on top. + * @default true + */ newestOnTop?: boolean; /** - * The element to put the toastr container - **/ + * The element to put the toastr container + * @default body + */ target?: string; /** - * Rather than having identical toasts stack, set the preventDuplicates property to true. Duplicates are matched to the previous toast based on their message content. - */ + * Rather than having identical toasts stack, set the preventDuplicates property to true. + * Duplicates are matched to the previous toast based on their message content. + * @default false + */ preventDuplicates?: boolean; /** - * Visually indicates how long before a toast expires. - */ + * Visually indicates how long before a toast expires. + * @default false + */ progressBar?: boolean; /** - * Function to execute on toast click - */ - onclick?: () => void; + * CSS class the progressbar element will be given. + * @default toast-progress + */ + progressClass?: string; /** - * Set if toastr should parse containing html - **/ - allowHtml?: boolean; + * Function to execute on toast click. Closing cannot be prevented by ev.stopPropagation() etc. + * @default undefined + */ + onclick?: (ev: JQueryMouseEventObject) => void; /** - * Set if toastr should escape html - **/ + * Should the title and message text be escaped? + * @default false + */ escapeHtml?: boolean; + /** + * Flip the toastr to be displayed properly for right-to-left languages. + * @default false + */ + rtl?: boolean; } interface ToastrDisplayMethod { /** - * Create a toast - * - * @param message Message to display in toast - */ + * Create a toast + * + * @param message Message to display in toast + */ (message: string): JQuery; /** - * Create a toast - * - * @param message Message to display in toast - * @param title Title to display on toast - */ + * Create a toast + * + * @param message Message to display in toast + * @param title Title to display on toast + */ (message: string, title: string): JQuery; /** - * Create a toast - * - * @param message Message to display in toast - * @param title Title to display on toast - * @param overrides Option values for toast - */ + * Create a toast + * + * @param message Message to display in toast + * @param title Title to display on toast + * @param overrides Option values for toast + */ (message: string, title: string, overrides: ToastrOptions): JQuery; } +type ToastrType = 'error'|'info'|'success'|'warning'; + +interface ToastMap { + /** + * The toast type. + */ + type: ToastrType; + /** + * The toast message. + */ + message: string; + /** + * The toast icon class. + */ + iconClass: string; + /** + * The toast title. + */ + title?: string; + /** + * Any override options specified when the toast was created. + */ + optionsOverride?: ToastrOptions; +} + +interface ToastrResponse { + /** + * The internal toast id. + */ + toastId: number; + /** + * The current state of the toast. + */ + state: 'visible'|'hidden'; + /** + * The datetime the toast was opened. + */ + startTime: Date; + /** + * The datetime the toast was closed, if the state is hidden. + */ + endTime?: Date; + /** + * The toastr options. + */ + options: ToastrOptions; + /** + * The event's toast details. + */ + map: ToastMap; +} + interface Toastr { /** - * Clear toasts - */ + * Clear toasts + */ clear: { /** - * Clear all toasts - */ + * Clear all toasts + */ (): void; /** - * Clear specific toast - * - * @param toast Toast to clear - */ + * Clear specific toast + * + * @param toast Toast to clear + */ (toast: JQuery): void; - /** - * Clear specific toast - * - * @param toast Toast to clear - * @param clearOptions force clearing a toast, ignoring focus - */ - (toast: JQuery, clearOptions: { force: boolean }): void; + /** + * Clear specific toast + * + * @param toast Toast to clear + * @param clearOptions force clearing a toast, ignoring focus + */ + (toast: JQuery, clearOptions: {force: boolean}): void; }; /** - * Removes all toasts (without animation) - */ + * Removes all toasts (without animation) + */ remove: { (): void; }; /** - * Create an error toast - */ + * Create an error toast + */ error: ToastrDisplayMethod; /** - * Create an info toast - */ + * Create an info toast + */ info: ToastrDisplayMethod; /** - * Create an options object - */ + * The toatsr options object + */ options: ToastrOptions; /** - * Create a success toast - */ + * Create a success toast + */ success: ToastrDisplayMethod; /** - * Create a warning toast - */ + * Create a warning toast + */ warning: ToastrDisplayMethod; /** - * Get toastr version - */ + * Get toastr version + */ version: string; + /** + * Get or create a container. + */ + getContainer: { + /** + * Get the container by options.containerId. + * + * @param options Option values for the container + */ + (options?: ToastrOptions): JQuery, + /** + * Get the container by options.containerId. + * If it doesn't exist, it will be created according to options. + * + * @param options Option values for the container + * @param create Use true to create a container, if it doesn't exist + */ + (options: ToastrOptions, create: boolean): JQuery, + }; + /** + * Register a callback to be called when a toast gets created or hidden. + * + * @param callback The function which will be passed the event details. + */ + subscribe: (callback: (response: ToastrResponse) => any) => void; [key: string]: any; } From 5e762d799d6779106c33b899ed71839501b1443a Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Mon, 6 Mar 2017 01:18:30 +0200 Subject: [PATCH 037/258] Add compression-webpack-plugin --- .../compression-webpack-plugin-tests.ts | 14 +++++++ compression-webpack-plugin/index.d.ts | 40 +++++++++++++++++++ compression-webpack-plugin/tsconfig.json | 20 ++++++++++ compression-webpack-plugin/tslint.json | 7 ++++ 4 files changed, 81 insertions(+) create mode 100644 compression-webpack-plugin/compression-webpack-plugin-tests.ts create mode 100644 compression-webpack-plugin/index.d.ts create mode 100644 compression-webpack-plugin/tsconfig.json create mode 100644 compression-webpack-plugin/tslint.json diff --git a/compression-webpack-plugin/compression-webpack-plugin-tests.ts b/compression-webpack-plugin/compression-webpack-plugin-tests.ts new file mode 100644 index 0000000000..4ee93c78b7 --- /dev/null +++ b/compression-webpack-plugin/compression-webpack-plugin-tests.ts @@ -0,0 +1,14 @@ +import { Configuration } from 'webpack' +import * as CompressionPlugin from 'compression-webpack-plugin' + +const c: Configuration = { + plugins: [ + new CompressionPlugin({ + asset: "[path].gz[query]", + algorithm: "gzip", + test: /\.js$|\.html$/, + threshold: 10240, + minRatio: 0.8 + }) + ] +}; diff --git a/compression-webpack-plugin/index.d.ts b/compression-webpack-plugin/index.d.ts new file mode 100644 index 0000000000..cf65f55300 --- /dev/null +++ b/compression-webpack-plugin/index.d.ts @@ -0,0 +1,40 @@ +// Type definitions for compression-webpack-plugin 0.3.2 +// Project: https://github.com/webpack-contrib/compression-webpack-plugin +// Definitions by: Anton Kandybo +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Plugin } from 'webpack'; + +export = CompressionPlugin; + +declare class CompressionPlugin extends Plugin { + constructor(options?: CompressionPlugin.Options); +} + +declare namespace CompressionPlugin { + export interface Options { + asset?: string; + algorithm?: string; + test?: RegExp | RegExp[]; + regExp?: RegExp | RegExp[]; + threshold?: number; + minRatio?: number; + + // zopfli options + verbose?: boolean; + verbose_more?: boolean; + numiterations?: number; + blocksplitting?: boolean; + blocksplittinglast?: boolean; + blocksplittingmax?: number; + + // zlib options + level?: number; + flush?: number; + chunkSize?: number; + windowBits?: number; + memLevel?: number; + strategy?: number; + dictionary?: any; + } +} diff --git a/compression-webpack-plugin/tsconfig.json b/compression-webpack-plugin/tsconfig.json new file mode 100644 index 0000000000..f9c84d64f8 --- /dev/null +++ b/compression-webpack-plugin/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "compression-webpack-plugin-tests.ts" + ] +} diff --git a/compression-webpack-plugin/tslint.json b/compression-webpack-plugin/tslint.json new file mode 100644 index 0000000000..02312e1c7d --- /dev/null +++ b/compression-webpack-plugin/tslint.json @@ -0,0 +1,7 @@ +{ + "extends": "../tslint.json", + "rules": { + "dt-header": false + } + } + \ No newline at end of file From 972fc4d5606f96fc50b01bf2578f2cff786dd3a7 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Mon, 6 Mar 2017 01:26:47 +0200 Subject: [PATCH 038/258] Added es6 lib --- compression-webpack-plugin/tsconfig.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/compression-webpack-plugin/tsconfig.json b/compression-webpack-plugin/tsconfig.json index f9c84d64f8..70383d3658 100644 --- a/compression-webpack-plugin/tsconfig.json +++ b/compression-webpack-plugin/tsconfig.json @@ -2,6 +2,9 @@ "compilerOptions": { "module": "commonjs", "target": "es6", + "lib": [ + "es6" + ], "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From 92be25fe09e45373607ca5c247622becc08a2751 Mon Sep 17 00:00:00 2001 From: Marcel Good Date: Sun, 5 Mar 2017 17:08:47 -0800 Subject: [PATCH 039/258] Update breeze-client type definitions --- breeze/index.d.ts | 104 ++++++++++++++++++++++++++-------------------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/breeze/index.d.ts b/breeze/index.d.ts index 8cc109d746..323e9a8f87 100644 --- a/breeze/index.d.ts +++ b/breeze/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Breeze 1.5.x +// Type definitions for Breeze 1.6.3 // Project: http://www.breezejs.com/ // Definitions by: Boris Yankov , IdeaBlade // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -12,7 +12,10 @@ // Updated Jan 20 2015 for Breeze 1.5.2 and merging changes from DefinitelyTyped // Updated Feb 28 2015 add any/all clause on Predicate // Updated Jun 27 2016 - Marcel Good (www.ideablade.com) -// Updated Jul 28 2016 - Serkan "coni2k" Holat +// Updated Jun 29 2016 - Marcel Good (www.ideablade.com) +// Updated Jul 15 2016 - Added methods to JsonResultsAdapter - Steve Schmitt +// Updated Sep 23 2016 - Added core methods +// Updated March 5 2017 - Eliminate promises.IPromise and replace with Promise declare namespace breeze.core { @@ -89,6 +92,19 @@ declare namespace breeze.core { export function stringStartsWith(str: string, prefix: string): boolean; export function stringEndsWith(str: string, suffix: string): boolean; export function formatString(format: string, ...args: any[]): string; + + /** Change text to title case with spaces, e.g. 'myPropertyName12' to 'My Property Name 12' */ + export function titleCase(str: string): string; + + /** Return the ES5 property descriptor for the property, which may be on a prototype of the object */ + export function getPropertyDescriptor(obj: any, propertyName: string): PropertyDescriptor + + /** safely perform toJSON logic on objects with cycles. Replacer function can map or exclude properties. */ + export function toJSONSafe(obj: any, replacer: (prop: string, val: any) => any): any + + /** Default value replacer for toJSONSafe. Replaces entityAspect and other internal properties with undefined. */ + export function toJSONSafeReplacer(prop: string, val: any): any + } declare namespace breeze { @@ -214,19 +230,23 @@ declare namespace breeze { export class DataServiceAdapter { checkForRecomposition(interfaceInitializedArgs: { interfaceName: string; isDefault: boolean }): void; initialize(): void; - fetchMetadata(metadataStore: MetadataStore, dataService: DataService): breeze.promises.IPromise; - executeQuery(mappingContext: { getUrl: () => string; query: EntityQuery; dataService: DataService }): breeze.promises.IPromise; - saveChanges(saveContext: { resourceName: string; dataService: DataService }, saveBundle: Object): breeze.promises.IPromise; + fetchMetadata(metadataStore: MetadataStore, dataService: DataService): Promise; + executeQuery(mappingContext: { getUrl: () => string; query: EntityQuery; dataService: DataService }): Promise; + saveChanges(saveContext: { resourceName: string; dataService: DataService }, saveBundle: Object): Promise; JsonResultsAdapter: JsonResultsAdapter; } export class JsonResultsAdapter { name: string; extractResults: (data: {}) => {}; + extractSaveResults: (data: {}) => any[]; + extractKeyMappings: (data: {}) => KeyMapping[]; visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: boolean; }; constructor(config: { name: string; extractResults?: (data: {}) => {}; + extractSaveResults?: (data: {}) => any[]; + extractKeyMappings?: (data: {}) => KeyMapping[]; visitNode: (node: {}, queryContext: QueryContext, nodeContext: NodeContext) => { entityType?: EntityType; nodeId?: any; nodeRefId?: any; ignore?: boolean; }; }); } @@ -241,6 +261,7 @@ declare namespace breeze { export interface NodeContext { nodeType: string; + propertyName: string; } export class DataTypeSymbol extends breeze.core.EnumSymbol { @@ -333,8 +354,8 @@ declare namespace breeze { isNavigationPropertyLoaded(navigationProperty: string): boolean; isNavigationPropertyLoaded(navigationProperty: NavigationProperty): boolean; - loadNavigationProperty(navigationProperty: string, callback?: Function, errorCallback?: Function): breeze.promises.IPromise; - loadNavigationProperty(navigationProperty: NavigationProperty, callback?: Function, errorCallback?: Function): breeze.promises.IPromise; + loadNavigationProperty(navigationProperty: string, callback?: Function, errorCallback?: Function): Promise; + loadNavigationProperty(navigationProperty: NavigationProperty, callback?: Function, errorCallback?: Function): Promise; rejectChanges(): void; @@ -423,16 +444,16 @@ declare namespace breeze { createEntity(typeName: string, config?: {}, entityState?: EntityStateSymbol, mergeStrategy?: MergeStrategySymbol): Entity; createEntity(entityType: EntityType, config?: {}, entityState?: EntityStateSymbol, mergeStrategy?: MergeStrategySymbol): Entity; detachEntity(entity: Entity): boolean; - executeQuery(query: string, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): breeze.promises.IPromise; - executeQuery(query: EntityQuery, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): breeze.promises.IPromise; + executeQuery(query: string, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Promise; + executeQuery(query: EntityQuery, callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Promise; executeQueryLocally(query: EntityQuery): Entity[]; exportEntities(entities?: Entity[], includeMetadata?: boolean): string; exportEntities(entities?: Entity[], options?: ExportEntitiesOptions): any; // string | Object - fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: boolean): breeze.promises.IPromise; - fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: boolean): breeze.promises.IPromise; - fetchEntityByKey(entityKey: EntityKey): breeze.promises.IPromise; - fetchMetadata(callback?: (schema: any) => void, errorCallback?: breeze.core.ErrorCallback): breeze.promises.IPromise; + fetchEntityByKey(typeName: string, keyValue: any, checkLocalCacheFirst?: boolean): Promise; + fetchEntityByKey(typeName: string, keyValues: any[], checkLocalCacheFirst?: boolean): Promise; + fetchEntityByKey(entityKey: EntityKey): Promise; + fetchMetadata(callback?: (schema: any) => void, errorCallback?: breeze.core.ErrorCallback): Promise; generateTempKeyValue(entity: Entity): any; getChanges(): Entity[]; getChanges(entityTypeName: string): Entity[]; @@ -466,7 +487,7 @@ declare namespace breeze { importEntities(exportedData: Object, config?: { mergeStrategy?: MergeStrategySymbol; metadataVersionFn?: (any: any) => void }): { entities: Entity[]; tempKeyMapping: { [key: string]: EntityKey } }; rejectChanges(): Entity[]; - saveChanges(entities?: Entity[], saveOptions?: SaveOptions, callback?: SaveChangesSuccessCallback, errorCallback?: SaveChangesErrorCallback): breeze.promises.IPromise; + saveChanges(entities?: Entity[], saveOptions?: SaveOptions, callback?: SaveChangesSuccessCallback, errorCallback?: SaveChangesErrorCallback): Promise; setProperties(config: EntityManagerProperties): void; } @@ -554,7 +575,7 @@ declare namespace breeze { /** Create query from an expression tree */ constructor(tree: Object); - execute(callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): breeze.promises.IPromise; + execute(callback?: ExecuteQuerySuccessCallback, errorCallback?: ExecuteQueryErrorCallback): Promise; executeLocally(): Entity[]; expand(propertyPaths: string[]): EntityQuery; expand(propertyPaths: string): EntityQuery; @@ -591,6 +612,8 @@ declare namespace breeze { where(property: string, filterop: FilterQueryOpSymbol, property2: string, filterop2: FilterQueryOpSymbol, value: any): EntityQuery; // for any/all clauses where(property: string, filterop: string, property2: string, filterop2: string, value: any): EntityQuery; // for any/all clauses where(predicate: FilterQueryOpSymbol): EntityQuery; + where(anArray: IRecursiveArray): EntityQuery; + withParameters(params: Object): EntityQuery; toJSON(): string; @@ -721,13 +744,14 @@ declare namespace breeze { addDataService(dataService: DataService, shouldOverwrite?: boolean): void; addEntityType(structuralType: IStructuralType): void; exportMetadata(): string; - fetchMetadata(dataService: string, callback?: (data: any) => void, errorCallback?: breeze.core.ErrorCallback): breeze.promises.IPromise; - fetchMetadata(dataService: DataService, callback?: (data: any) => void, errorCallback?: breeze.core.ErrorCallback): breeze.promises.IPromise; + fetchMetadata(dataService: string, callback?: (data: any) => void, errorCallback?: breeze.core.ErrorCallback): Promise; + fetchMetadata(dataService: DataService, callback?: (data: any) => void, errorCallback?: breeze.core.ErrorCallback): Promise; getDataService(serviceName: string): DataService; getEntityType(entityTypeName: string, okIfNotFound?: boolean): IStructuralType; getEntityTypes(): IStructuralType[]; hasMetadataFor(serviceName: string): boolean; static importMetadata(exportedString: string): MetadataStore; + static normalizeTypeName(typeName: string): string; importMetadata(exportedString: string, allowMerge?: boolean): MetadataStore; isEmpty(): boolean; registerEntityTypeCtor(entityTypeName: string, entityCtor: Function, initializationFn?: (entity: Entity) => void, noTrackingFn?: (node: Object, entityType: EntityType) => Object): void; @@ -796,7 +820,7 @@ declare namespace breeze { export interface IRecursiveArray { [i: number]: T | IRecursiveArray; } - + export class Predicate { constructor(); constructor(property: string, operator: string, value: any); @@ -904,10 +928,16 @@ declare namespace breeze { export interface SaveResult { entities: Entity[]; - keyMappings: any; + keyMappings: KeyMapping[]; XHR: XMLHttpRequest; } + export interface KeyMapping { + entityTypeName: string; + tempValue: any; + realValue: any; + } + export class ValidationError { key: string; context: any; @@ -993,7 +1023,7 @@ declare namespace breeze { /** Creates a regular expression validator with a fixed expression. */ static makeRegExpValidator(validatorName: string, expression: RegExp, defaultMessage: string, context?: any): Validator; - /** Run this validator against the specified value. + /** Run this validator against the specified value. @param value {Object} Value to validate @param additionalContext {Object} Any additional contextual information that the Validator can make use of. @return {ValidationError|null} A ValidationError if validation fails, null otherwise */ @@ -1044,20 +1074,16 @@ declare namespace breeze.config { @return {an instance of the specified adapter} **/ export function getAdapterInstance(interfaceName: string, adapterName?: string): Object; - - export interface Adapter { - getRoutePrefix: Function - } /** - Initializes a single adapter implementation. Initialization means either newing a instance of the + Initializes a single adapter implementation. Initialization means either newing a instance of the specified interface and then calling "initialize" on it or simply calling "initialize" on the instance if it already exists. @param interfaceName {String} The name of the interface to which the adapter to initialize belongs. @param adapterName {String} - The name of a previously registered adapter to initialize. - @param isDefault=true {Boolean} - Whether to make this the default "adapter" for this interface. + @param isDefault=true {Boolean} - Whether to make this the default "adapter" for this interface. @return {an instance of the specified adapter} **/ - export function initializeAdapterInstance(interfaceName: string, adapterName: string, isDefault?: boolean): Adapter; + export function initializeAdapterInstance(interfaceName: string, adapterName: string, isDefault?: boolean): Object; export interface AdapterInstancesConfig { /** the name of a previously registered "ajax" adapter */ @@ -1080,15 +1106,15 @@ declare namespace breeze.config { export var objectRegistry: Object; /** Method use to register implementations of standard breeze interfaces. Calls to this method are usually - made as the last step within an adapter implementation. + made as the last step within an adapter implementation. @param interfaceName {String} - one of the following interface names "ajax", "dataService" or "modelLibrary" - @param adapterCtor {Function} - an ctor function that returns an instance of the specified interface. + @param adapterCtor {Function} - an ctor function that returns an instance of the specified interface. **/ export function registerAdapter(interfaceName: string, adapterCtor: Function): void; export function registerFunction(fn: Function, fnName: string): void; export function registerType(ctor: Function, typeName: string): void; //static setProperties(config: Object): void; //deprecated - /** + /** Set the promise implementation, if Q.js is not found. @param q - implementation of promise. @see http://wiki.commonjs.org/wiki/Promises/A */ @@ -1101,27 +1127,17 @@ declare namespace breeze.config { /** Promises interface used by Breeze. Usually implemented by Q (https://github.com/kriskowal/q) or angular.$q using breeze.config.setQ(impl) */ declare namespace breeze.promises { - export interface IPromise { - then(onFulfill: (value: T) => U, onReject?: (reason: any) => U): IPromise; - then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => U): IPromise; - then(onFulfill: (value: T) => U, onReject?: (reason: any) => IPromise): IPromise; - then(onFulfill: (value: T) => IPromise, onReject?: (reason: any) => IPromise): IPromise; - catch(onRejected: (reason: any) => U): IPromise; - catch(onRejected: (reason: any) => IPromise): IPromise; - finally(finallyCallback: () => any): IPromise; - } - export interface IDeferred { - promise: IPromise; + promise: Promise; resolve(value: T): void; reject(reason: any): void; } export interface IPromiseService { defer(): IDeferred; - reject(reason?: any): IPromise; - resolve(object: T): IPromise; - resolve(object: IPromise): IPromise; + reject(reason?: any): Promise; + resolve(object: T): Promise; + resolve(object: Promise): Promise; } } From eadbc0cd3badb6f402d66311b171e57d860f0b84 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 6 Mar 2017 15:32:29 +0100 Subject: [PATCH 040/258] async: Various fixes, mostly related to strict-nulls. Also some places where the error type was wrong. --- async/index.d.ts | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/async/index.d.ts b/async/index.d.ts index e3fbe7e512..7f71f3b9bc 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -6,17 +6,16 @@ interface Dictionary { [key: string]: T; } interface ErrorCallback { (err?: T): void; } -interface AsyncWaterfallCallback { (err: E, ...args: any[]): void; } -interface AsyncBooleanResultCallback { (err: E, truthValue: boolean): void; } -interface AsyncResultCallback { (err: E, result: T): void; } -interface AsyncResultArrayCallback { (err: E, results: T[]): void; } -interface AsyncResultObjectCallback { (err: E, results: Dictionary): void; } +interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } +interface AsyncResultCallback { (err?: E, result?: T): void; } +interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } +interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } -interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } +interface AsyncFunction { (callback: (err?: E, result?: T) => void): any; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } -interface AsyncMemoIterator { (memo: R, item: T, callback: AsyncResultCallback): void; } +interface AsyncMemoIterator { (memo: R | undefined, item: T, callback: AsyncResultCallback): void; } interface AsyncBooleanIterator { (item: T, callback: AsyncBooleanResultCallback): void; } interface AsyncWorker { (task: T, callback: ErrorCallback): void; } @@ -76,7 +75,7 @@ interface AsyncPriorityQueue { interface AsyncCargo { length(): number; - payload: number; + payload?: number; push(task: any, callback? : Function): void; push(task: any[], callback? : Function): void; saturated(): void; @@ -186,25 +185,25 @@ interface Async { cargo(worker : (tasks: any[], callback : ErrorCallback) => void, payload? : number) : AsyncCargo; auto(tasks: any, concurrency?: number, callback?: AsyncResultCallback): void; autoInject(tasks: any, callback?: AsyncResultCallback): void; - retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; - retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; - retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; - apply(fn: Function, ...arguments: any[]): AsyncFunction; + retry(opts: number, task: (callback : AsyncResultCallback, results: any) => void, callback: AsyncResultCallback): void; + retry(opts: { times: number, interval: number|((retryCount: number) => number) }, task: (callback: AsyncResultCallback, results : any) => void, callback: AsyncResultCallback): void; + retryable(opts: number | {times: number, interval: number}, task: AsyncFunction): AsyncFunction; + apply(fn: Function, ...arguments: any[]): AsyncFunction; nextTick(callback: Function, ...args: any[]): void; setImmediate: typeof async.nextTick; - reflect(fn: AsyncFunction) : (callback: (err: void, result: {error?: Error, value?: T}) => void) => void; - reflectAll(tasks: AsyncFunction[]): ((callback: (err: void, result: {error?: Error, value?: T}) => void) => void)[]; + reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; + reflectAll(tasks: AsyncFunction[]): ((callback: (err: undefined, result: {error?: E, value?: T}) => void) => void)[]; - timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; - timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; + timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; + timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; times (n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; transform(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; - transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: T[], acc: R[], iteratee: (acc: R[] | null, item: T | undefined[], key?: string, callback?: (error?: E) => void) => void): void; transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; @@ -226,4 +225,3 @@ declare var async: Async; declare module "async" { export = async; } - From 66bd4290746e62eea9af862b46c22756c61e853a Mon Sep 17 00:00:00 2001 From: Steve Purol Date: Mon, 6 Mar 2017 14:11:17 -0500 Subject: [PATCH 041/258] recompose: withHandlers may take a factory function --- recompose/index.d.ts | 5 +++-- recompose/recompose-tests.tsx | 6 ++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/recompose/index.d.ts b/recompose/index.d.ts index 3ff504fab3..6cef47160e 100644 --- a/recompose/index.d.ts +++ b/recompose/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Recompose v0.20.3 +// Type definitions for Recompose v0.22.0 // Project: https://github.com/acdlite/recompose // Definitions by: Iskander Sierra // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -50,8 +50,9 @@ declare module 'recompose' { type HandleCreators = { [handlerName: string]: mapper; }; + type HandleCreatorsFactory = (initialProps: TOutter) => HandleCreators; export function withHandlers( - handlerCreators: HandleCreators + handlerCreators: HandleCreators | HandleCreatorsFactory ): ComponentEnhancer; // defaultProps: https://github.com/acdlite/recompose/blob/master/docs/API.md#defaultprops diff --git a/recompose/recompose-tests.tsx b/recompose/recompose-tests.tsx index c4c66b3e2c..01bd1d28f5 100644 --- a/recompose/recompose-tests.tsx +++ b/recompose/recompose-tests.tsx @@ -73,6 +73,12 @@ function testWithHandlers() { onSubmit: (props: OutterProps) => (e: any) => {}, }); const enhanced: React.ComponentClass = enhancer(innerComponent); + + const enhancer2 = withHandlers((props: OutterProps) => ({ + onChange: (props: OutterProps) => (e: any) => {}, + onSubmit: (props: OutterProps) => (e: any) => {}, + })); + const enhanced2: React.ComponentClass = enhancer2(innerComponent); } function testDefaultProps() { From 53fd6a1051a5b6a74f9c5e1335e7286e30adb960 Mon Sep 17 00:00:00 2001 From: sqwk Date: Mon, 6 Mar 2017 23:19:10 +0100 Subject: [PATCH 042/258] Update Lowdb Test --- lowdb/index.d.ts | 1073 +++++++++++++++++++++--------------------- lowdb/lowdb-tests.ts | 5 +- 2 files changed, 547 insertions(+), 531 deletions(-) diff --git a/lowdb/index.d.ts b/lowdb/index.d.ts index ddd20e89ed..2beda1e2ba 100644 --- a/lowdb/index.d.ts +++ b/lowdb/index.d.ts @@ -1,536 +1,553 @@ -declare module 'lowdb' { - interface PromiseLike { - - /** - * Attaches callbacks for the resolution and/or rejection of the Promise. - * @param onfulfilled The callback to execute when the Promise is resolved. - * @param onrejected The callback to execute when the Promise is rejected. - * @returns A Promise for the completion of which ever callback is executed. - */ - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; - then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; - } - - interface StringRepresentable { - toString(): string; - } - - interface List { - [index: number]: T; - length: number; - } - - interface Dictionary { - [index: string]: T; - } - - interface DictionaryIterator { - (value: T, key?: string, collection?: Dictionary): TResult; - } - - interface ListIterator { - (value: T, index: number, collection: List): TResult; - } - - interface StringIterator { - (char: string, index?: number, string?: string): TResult; - } - - interface MixinOptions { - chain?: boolean; - } - - interface LoDashWrapper { - - /** - * @see _.has - */ - has(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; - - /** - * @see _.hasIn - */ - hasIn(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; - - /** - * @see _.assign - */ - assign( - source: TSource - ): LoDashWrapper; - - /** - * @see _.assign - */ - assign( - source1: TSource1, - source2: TSource2 - ): LoDashWrapper; - - /** - * @see _.assign - */ - assign( - source1: TSource1, - source2: TSource2, - source3: TSource3 - ): LoDashWrapper; - - /** - * @see _.assign - */ - assign( - source1: TSource1, - source2: TSource2, - source3: TSource3, - source4: TSource4 - ): LoDashWrapper; - - /** - * @see _.assign - */ - assign(): LoDashWrapper; - - /** - * @see _.assign - */ - assign(...otherArgs: any[]): LoDashWrapper; - - /** - * @see _.cloneDeep - */ - cloneDeep(): LoDashWrapper; - - /** - * @see _.cloneDeep - */ - cloneDeep(): LoDashWrapper; - - /** - * @see _.cloneDeep - */ - cloneDeepWith(customizer: (value: any) => any): LoDashWrapper[]; - - /** - * @see _.cloneDeep - */ - cloneDeepWith(customizer: (value: any) => any): LoDashWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - ...sources: {}[] - ): LoDashWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - ...sources: {}[] - ): LoDashWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - source3: S3, - ...sources: {}[] - ): LoDashWrapper; - - /** - * @see _.defaults - */ - defaults( - source1: S1, - source2: S2, - source3: S3, - source4: S4, - ...sources: {}[] - ): LoDashWrapper; - - /** - * @see _.defaults - */ - defaults(): LoDashWrapper; - - /** - * @see _.defaults - */ - defaults(...sources: {}[]): LoDashWrapper; - - /** - * @see _.get - */ - get(object: Object, - path: string | number | boolean | Array, - defaultValue?: TResult - ): LoDashWrapper; - - /** - * @see _.get - */ - get(path: string | number | boolean | Array, - defaultValue?: TResult - ): LoDashWrapper; - - - /** - * @see _.mixin - */ - mixin( - source: Dictionary, - options?: MixinOptions - ): LoDashWrapper; - - /** - * @see _.mixin - */ - mixin( - options?: MixinOptions - ): LoDashWrapper; - - /** - * @see _.set - */ - set( - path: StringRepresentable | StringRepresentable[], - value: any - ): LoDashWrapper; - - /** - * @see _.set - */ - set( - path: StringRepresentable | StringRepresentable[], - value: V - ): LoDashWrapper; - - /** - * @see _.find - */ - find( - predicate?: ListIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.find - */ - find( - predicate?: string, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.find - */ - find( - predicate?: TObject - ): LoDashWrapper; - - /** - * @see _.find - */ - filter( - predicate?: TObject - ): LoDashWrapper; - - /** - * @see _.filter - */ - filter( - predicate?: ListIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.filter - */ - filter( - predicate: string, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.filter - */ - filter( - predicate: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.filter - */ - filter( - predicate?: StringIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.filter - */ - filter(predicate: W): LoDashWrapper; - /** - * @see _.map - */ - map( - iteratee?: ListIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.map - */ - map( - iteratee?: string - ): LoDashWrapper; - - /** - * @see _.map - */ - map( - iteratee?: TObject - ): LoDashWrapper; - /** - * @see _.map - */ - map( - iteratee?: ListIterator | DictionaryIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.range - */ - range( - end?: number, - step?: number - ): LoDashWrapper; - - /** - * @see _.rangeRight - */ - rangeRight( - end?: number, - step?: number - ): LoDashWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: ListIterator, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: string, - thisArg?: any - ): LoDashWrapper; - - /** - * @see _.remove - */ - remove( - predicate?: W - ): LoDashWrapper; - - /** - * @see _.sortBy - */ - sortBy( - iteratee?: ListIterator - ): LoDashWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratee: string): LoDashWrapper; - - /** - * @see _.sortBy - */ - sortBy(whereValue: W): LoDashWrapper; - - /** - * @see _.sortBy - */ - sortBy(): LoDashWrapper; - - /** - * @see _.sortBy - */ - sortBy(...iteratees: (ListIterator | Object | string)[]): LoDashWrapper; - - /** - * @see _.sortBy - */ - sortBy(iteratees: (ListIterator | string | Object)[]): LoDashWrapper; - - /** - * @see _.slice - */ - slice( - start?: number, - end?: number - ): LoDashWrapper; - - /** - * @see _.size - */ - size(): LoDashWrapper; - - /** - * @see _.take - */ - take(n?: number): LoDashWrapper; - - /** - * @see _.times - */ - times( - iteratee: (num: number) => TResult - ): LoDashWrapper; - - /** - * @see _.times - */ - times(): LoDashWrapper; - - /** - * @see _.uniqueId - */ - uniqueId(): LoDashWrapper; - - value(): T; - - pop(): T; - push(...items: T[]): LoDashWrapper; - shift(): T; - sort(compareFn?: (a: T, b: T) => number): LoDashWrapper; - splice(start: number): LoDashWrapper; - splice(start: number, deleteCount: number, ...items: any[]): LoDashWrapper; - unshift(...items: T[]): LoDashWrapper; - } - - interface Storage { - /** - * Reads the database. - * - * @param source The source location. - * @param deserialize The deserialize function to apply. - * @return Returns a promise with the deserialized db object. - */ - read?(source: string, deserialize: any): PromiseLike - /** - * Reads the database. - * - * @param source The source location. - * @param deserialize The deserialize function to apply. - * @return Returns the deserialized db object. - */ - read?(source: string, deserialize: any): Object - /** - * Writes to the database. - * - * @param destination The destination location. - * @param obj The object to write. - * @param serialize The serialize function to apply. - */ - write?(destination: string, obj: any, serialize: any): void - /** - * Writes to the database. - * - * @param destination The destination location. - * @param obj The object to write. - * @param serialize The serialize function to apply. - */ - write?(destination: string, obj: any, serialize: any): PromiseLike - } - - interface Format { - /** - * Writes to the database. - * - * @param obj The object to serialize. - * @return Returns the serialized object string. - */ - serialize(obj: Object): string - /** - * Writes to the database. - * - * @param data The object to deserialize. - * @return Returns the deserialized object. - */ - deserialize(data: string): Object - } - - interface Options { - /** - * The custom "storage" object. - */ - storage?: Storage - /** - * The custom "format" object. - */ - format?: Format - /** - * The flag to automatically persist changes. - */ - writeOnChange?: boolean - } - - export interface Low extends LoDashWrapper, Format { - /** - * Access current database state. - * Returns Returns the database state. - */ - getState(): Object - /** - * Drop or reset database state. - * @param newState New state of the database - */ - setState(newState: Object): void - /** - * Persist database. - * @param source The source location. - */ - write(source: string): void - /** - * Persist database. - * @param source The source location. - */ - write(source: string): PromiseLike - /** - * Read database. - * @param source The source location. - */ - read(source?: string): Object - /** - * Read database. - * @param source The source location. - */ - read(source?: string): PromiseLike +declare namespace lowdb { + + interface PromiseLike { + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => TResult | PromiseLike): PromiseLike; + then(onfulfilled?: (value: T) => TResult | PromiseLike, onrejected?: (reason: any) => void): PromiseLike; + } + + interface StringRepresentable { + toString(): string; + } + + interface List { + [index: number]: T; + length: number; + } + + interface Dictionary { + [index: string]: T; + } + + interface DictionaryIterator { + (value: T, key?: string, collection?: Dictionary): TResult; + } + + interface ListIterator { + (value: T, index: number, collection: List): TResult; + } + + interface StringIterator { + (char: string, index?: number, string?: string): TResult; + } + + interface MixinOptions { + chain?: boolean; + } + + class LoDashWrapper { + + /** + * @see _.has + */ + has(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; + + /** + * @see _.hasIn + */ + hasIn(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source: TSource + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source1: TSource1, + source2: TSource2 + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source1: TSource1, + source2: TSource2, + source3: TSource3 + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign( + source1: TSource1, + source2: TSource2, + source3: TSource3, + source4: TSource4 + ): LoDashWrapper; + + /** + * @see _.assign + */ + assign(): LoDashWrapper; + + /** + * @see _.assign + */ + assign(...otherArgs: any[]): LoDashWrapper; + + /** + * @see _.cloneDeep + */ + cloneDeep(): LoDashWrapper; + + /** + * @see _.cloneDeep + */ + cloneDeep(): LoDashWrapper; + + /** + * @see _.cloneDeep + */ + cloneDeepWith(customizer: (value: any) => any): LoDashWrapper[]; + + /** + * @see _.cloneDeep + */ + cloneDeepWith(customizer: (value: any) => any): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + source2: S2, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + source2: S2, + source3: S3, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults( + source1: S1, + source2: S2, + source3: S3, + source4: S4, + ...sources: {}[] + ): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults(): LoDashWrapper; + + /** + * @see _.defaults + */ + defaults(...sources: {}[]): LoDashWrapper; + + /** + * @see _.get + */ + get(object: Object, + path: string | number | boolean | Array, + defaultValue?: TResult + ): LoDashWrapper; + + /** + * @see _.get + */ + get(path: string | number | boolean | Array, + defaultValue?: TResult + ): LoDashWrapper; + + + /** + * @see _.mixin + */ + mixin( + source: Dictionary, + options?: MixinOptions + ): LoDashWrapper; + + /** + * @see _.mixin + */ + mixin( + options?: MixinOptions + ): LoDashWrapper; + + /** + * @see _.set + */ + set( + path: StringRepresentable | StringRepresentable[], + value: any + ): LoDashWrapper; + + /** + * @see _.set + */ + set( + path: StringRepresentable | StringRepresentable[], + value: V + ): LoDashWrapper; + + /** + * @see _.find + */ + find( + predicate?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.find + */ + find( + predicate?: string, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.find + */ + find( + predicate?: TObject + ): LoDashWrapper; + + /** + * @see _.find + */ + filter( + predicate?: TObject + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate: string, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate: ListIterator | DictionaryIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter( + predicate?: StringIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.filter + */ + filter(predicate: W): LoDashWrapper; + /** + * @see _.map + */ + map( + iteratee?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.map + */ + map( + iteratee?: string + ): LoDashWrapper; + + /** + * @see _.map + */ + map( + iteratee?: TObject + ): LoDashWrapper; + /** + * @see _.map + */ + map( + iteratee?: ListIterator | DictionaryIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.range + */ + range( + end?: number, + step?: number + ): LoDashWrapper; + + /** + * @see _.rangeRight + */ + rangeRight( + end?: number, + step?: number + ): LoDashWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: ListIterator, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: string, + thisArg?: any + ): LoDashWrapper; + + /** + * @see _.remove + */ + remove( + predicate?: W + ): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy( + iteratee?: ListIterator + ): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(iteratee: string): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(whereValue: W): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(...iteratees: (ListIterator | Object | string)[]): LoDashWrapper; + + /** + * @see _.sortBy + */ + sortBy(iteratees: (ListIterator | string | Object)[]): LoDashWrapper; + + /** + * @see _.slice + */ + slice( + start?: number, + end?: number + ): LoDashWrapper; + + /** + * @see _.size + */ + size(): LoDashWrapper; + + /** + * @see _.take + */ + take(n?: number): LoDashWrapper; + + /** + * @see _.times + */ + times( + iteratee: (num: number) => TResult + ): LoDashWrapper; + + /** + * @see _.times + */ + times(): LoDashWrapper; + + /** + * @see _.uniqueId + */ + uniqueId(): LoDashWrapper; + + value(): T; + + pop(): T; + push(...items: T[]): LoDashWrapper; + shift(): T; + sort(compareFn?: (a: T, b: T) => number): LoDashWrapper; + splice(start: number): LoDashWrapper; + splice(start: number, deleteCount: number, ...items: any[]): LoDashWrapper; + unshift(...items: T[]): LoDashWrapper; + } + + export interface Storage { + + /** + * Reads the database. + * + * @param source The source location. + * @param deserialize The deserialize function to apply. + * @return Returns a promise with the deserialized db object. + */ + read?(source: string, deserialize: any): PromiseLike + + /** + * Reads the database. + * + * @param source The source location. + * @param deserialize The deserialize function to apply. + * @return Returns the deserialized db object. + */ + read?(source: string, deserialize: any): Object + + /** + * Writes to the database. + * + * @param destination The destination location. + * @param obj The object to write. + * @param serialize The serialize function to apply. + */ + write?(destination: string, obj: any, serialize: any): void + + /** + * Writes to the database. + * + * @param destination The destination location. + * @param obj The object to write. + * @param serialize The serialize function to apply. + */ + write?(destination: string, obj: any, serialize: any): PromiseLike + } + + export interface Format { + + /** + * Writes to the database. + * + * @param obj The object to serialize. + * @return Returns the serialized object string. + */ + serialize(obj: Object): string + + /** + * Writes to the database. + * + * @param data The object to deserialize. + * @return Returns the deserialized object. + */ + deserialize(data: string): Object + } + + export interface Options { + + /** + * The custom "storage" object. + */ + storage?: Storage + + /** + * The custom "format" object. + */ + format?: Format + + /** + * The flag to automatically persist changes. + */ + writeOnChange?: boolean + + } + + export class Low extends LoDashWrapper { + + constructor(filePath: string, options?: Options); + + /** + * Access current database state. + * Returns Returns the database state. + */ + getState(): Object + + /** + * Drop or reset database state. + * @param newState New state of the database + */ + setState(newState: Object): void + + /** + * Persist database. + * @param source The source location. + */ + write(source: string): void + + /** + * Persist database. + * @param source The source location. + */ + write(source: string): PromiseLike + + /** + * Read database. + * @param source The source location. + */ + read(source?: string): Object + + /** + * Read database. + * @param source The source location. + */ + read(source?: string): PromiseLike + } // declare class lowdb { // new (source?: string, opts?: Options): Low; // (source?: string, opts?: Options) : Low; // } - -// declare module "lowdb" { -// export = lowdb; -// } - } +declare module "lowdb" { + export = lowdb.Low; +} \ No newline at end of file diff --git a/lowdb/lowdb-tests.ts b/lowdb/lowdb-tests.ts index d656c63b62..612288e8dd 100644 --- a/lowdb/lowdb-tests.ts +++ b/lowdb/lowdb-tests.ts @@ -1,9 +1,8 @@ import Lowdb = require('lowdb'); -Lowdb -let db = new Lowdb(); +const db = new Lowdb('db.json'); -db.defaults({ 'someObject': {}, 'anotherObject': {} }).value(); +db.defaults({ someObject: {}, anotherObject: {} }).value(); db.get('someObject').set('foo' , 'bar').value(); db.get('anotherObject').set('foo' , 'bar').value(); From 8bfb64811e76ee7217a78ae355ae6e6d8c6802fb Mon Sep 17 00:00:00 2001 From: sqwk Date: Mon, 6 Mar 2017 23:40:18 +0100 Subject: [PATCH 043/258] Update Lowdb Test --- lowdb/index.d.ts | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/lowdb/index.d.ts b/lowdb/index.d.ts index 2beda1e2ba..4118372647 100644 --- a/lowdb/index.d.ts +++ b/lowdb/index.d.ts @@ -1,3 +1,8 @@ +// Type definitions for Lowdb 0.15 +// Project: https://github.com/typicode/lowdb +// Definitions by: typicode, +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + declare namespace lowdb { interface PromiseLike { @@ -167,7 +172,7 @@ declare namespace lowdb { /** * @see _.get */ - get(object: Object, + get(object: any, path: string | number | boolean | Array, defaultValue?: TResult ): LoDashWrapper; @@ -184,7 +189,7 @@ declare namespace lowdb { * @see _.mixin */ mixin( - source: Dictionary, + source: Dictionary<() => void>, options?: MixinOptions ): LoDashWrapper; @@ -370,12 +375,12 @@ declare namespace lowdb { /** * @see _.sortBy */ - sortBy(...iteratees: (ListIterator | Object | string)[]): LoDashWrapper; + sortBy(...iteratees: (ListIterator | any | string)[]): LoDashWrapper; /** * @see _.sortBy */ - sortBy(iteratees: (ListIterator | string | Object)[]): LoDashWrapper; + sortBy(iteratees: (ListIterator | string | any)[]): LoDashWrapper; /** * @see _.slice @@ -441,7 +446,7 @@ declare namespace lowdb { * @param deserialize The deserialize function to apply. * @return Returns the deserialized db object. */ - read?(source: string, deserialize: any): Object + read?(source: string, deserialize: any): {} /** * Writes to the database. @@ -470,7 +475,7 @@ declare namespace lowdb { * @param obj The object to serialize. * @return Returns the serialized object string. */ - serialize(obj: Object): string + serialize(obj: any): string /** * Writes to the database. @@ -478,7 +483,7 @@ declare namespace lowdb { * @param data The object to deserialize. * @return Returns the deserialized object. */ - deserialize(data: string): Object + deserialize(data: string): any } export interface Options { @@ -508,13 +513,13 @@ declare namespace lowdb { * Access current database state. * Returns Returns the database state. */ - getState(): Object + getState(): any /** * Drop or reset database state. * @param newState New state of the database */ - setState(newState: Object): void + setState(newState: any): void /** * Persist database. @@ -532,13 +537,13 @@ declare namespace lowdb { * Read database. * @param source The source location. */ - read(source?: string): Object + read(source?: string): any /** * Read database. * @param source The source location. */ - read(source?: string): PromiseLike + read(source?: string): PromiseLike } From d581cd13ab2425f27373d4e220932ce9b26bd315 Mon Sep 17 00:00:00 2001 From: Belinda Teh Date: Mon, 6 Mar 2017 16:43:00 -0800 Subject: [PATCH 044/258] Update qs definitions to include 'sort' in its stringify options --- qs/index.d.ts | 4 +++- qs/qs-tests.ts | 5 +++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/qs/index.d.ts b/qs/index.d.ts index c23c02f871..400cc7a1e4 100644 --- a/qs/index.d.ts +++ b/qs/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for qs 6.2.0 // Project: https://github.com/hapijs/qs -// Definitions by: Roman Korneev , Leon Yu +// Definitions by: Roman Korneev , Leon Yu , +// Belinda Teh // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = QueryString; @@ -16,6 +17,7 @@ declare namespace QueryString { filter?: Array | ((prefix: string, value: any) => any); arrayFormat?: 'indices' | 'brackets' | 'repeat'; indices?: boolean; + sort?: (a: any, b: any) => number; } interface IParseOptions { diff --git a/qs/qs-tests.ts b/qs/qs-tests.ts index bcff0a0762..f3d361476e 100644 --- a/qs/qs-tests.ts +++ b/qs/qs-tests.ts @@ -249,3 +249,8 @@ qs.parse('a=b&c=d', { delimiter: '&' }); var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder }); assert.deepEqual(obj, { a: 'こんにちは!' }); } + +() => { + var sorted = qs.stringify({ a: 1, c: 3, b: 2 }, { sort: (a, b) => a.localeCompare(b) }) + assert.equal(sorted, 'a=1&b=2&c=3') +} From 01e6251cd20e73a71f73207272be11d4bf2e9eff Mon Sep 17 00:00:00 2001 From: Belinda Teh Date: Mon, 6 Mar 2017 16:51:48 -0800 Subject: [PATCH 045/258] Update qs tests to 4 space indent --- qs/qs-tests.ts | 256 ++++++++++++++++++++++++------------------------- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/qs/qs-tests.ts b/qs/qs-tests.ts index f3d361476e..10a911c2dc 100644 --- a/qs/qs-tests.ts +++ b/qs/qs-tests.ts @@ -8,82 +8,82 @@ qs.parse('a=b'); qs.parse('a=b&c=d', { delimiter: '&' }); () => { - var obj = qs.parse('a=c'); - assert.deepEqual(obj, { a: 'c' }); + var obj = qs.parse('a=c'); + assert.deepEqual(obj, { a: 'c' }); - var str = qs.stringify(obj); - assert.equal(str, 'a=c'); + var str = qs.stringify(obj); + assert.equal(str, 'a=c'); } () => { - var plainObject = qs.parse('a[hasOwnProperty]=b', { plainObjects: true }); - assert.deepEqual(plainObject, { a: { hasOwnProperty: 'b' } }); + var plainObject = qs.parse('a[hasOwnProperty]=b', { plainObjects: true }); + assert.deepEqual(plainObject, { a: { hasOwnProperty: 'b' } }); } () => { - var protoObject = qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }); - assert.deepEqual(protoObject, { a: { hasOwnProperty: 'b' } }); + var protoObject = qs.parse('a[hasOwnProperty]=b', { allowPrototypes: true }); + assert.deepEqual(protoObject, { a: { hasOwnProperty: 'b' } }); } () => { - assert.deepEqual(qs.parse('a%5Bb%5D=c'), { - a: { b: 'c' } - }); + assert.deepEqual(qs.parse('a%5Bb%5D=c'), { + a: { b: 'c' } + }); } () => { - assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), { - foo: { - bar: { - baz: 'foobarbaz' - } - } - }); -} - -() => { - var expected = { - a: { - b: { - c: { - d: { - e: { - f: { - '[g][h][i]': 'j' - } + assert.deepEqual(qs.parse('foo[bar][baz]=foobarbaz'), { + foo: { + bar: { + baz: 'foobarbaz' } - } } - } - } - }; - var string = 'a[b][c][d][e][f][g][h][i]=j'; - assert.deepEqual(qs.parse(string), expected); + }); } () => { - var deep = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 }); - assert.deepEqual(deep, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }); + var expected = { + a: { + b: { + c: { + d: { + e: { + f: { + '[g][h][i]': 'j' + } + } + } + } + } + } + }; + var string = 'a[b][c][d][e][f][g][h][i]=j'; + assert.deepEqual(qs.parse(string), expected); } () => { - var limited = qs.parse('a=b&c=d', { parameterLimit: 1 }); - assert.deepEqual(limited, { a: 'b' }); + var deep = qs.parse('a[b][c][d][e][f][g][h][i]=j', { depth: 1 }); + assert.deepEqual(deep, { a: { b: { '[c][d][e][f][g][h][i]': 'j' } } }); } () => { - var delimited = qs.parse('a=b;c=d', { delimiter: ';' }); - assert.deepEqual(delimited, { a: 'b', c: 'd' }); + var limited = qs.parse('a=b&c=d', { parameterLimit: 1 }); + assert.deepEqual(limited, { a: 'b' }); } () => { - var regexed = qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ }); - assert.deepEqual(regexed, { a: 'b', c: 'd', e: 'f' }); + var delimited = qs.parse('a=b;c=d', { delimiter: ';' }); + assert.deepEqual(delimited, { a: 'b', c: 'd' }); } () => { - var withDots = qs.parse('a.b=c', { allowDots: true }); - assert.deepEqual(withDots, { a: { b: 'c' } }); + var regexed = qs.parse('a=b;c=d,e=f', { delimiter: /[;,]/ }); + assert.deepEqual(regexed, { a: 'b', c: 'd', e: 'f' }); +} + +() => { + var withDots = qs.parse('a.b=c', { allowDots: true }); + assert.deepEqual(withDots, { a: { b: 'c' } }); } () => { @@ -92,165 +92,165 @@ qs.parse('a=b&c=d', { delimiter: '&' }); } () => { - var withIndexes = qs.parse('a[1]=c&a[0]=b'); - assert.deepEqual(withIndexes, { a: ['b', 'c'] }); + var withIndexes = qs.parse('a[1]=c&a[0]=b'); + assert.deepEqual(withIndexes, { a: ['b', 'c'] }); } () => { - var noSparse = qs.parse('a[1]=b&a[15]=c'); - assert.deepEqual(noSparse, { a: ['b', 'c'] }); + var noSparse = qs.parse('a[1]=b&a[15]=c'); + assert.deepEqual(noSparse, { a: ['b', 'c'] }); } () => { - var withEmptyString = qs.parse('a[]=&a[]=b'); - assert.deepEqual(withEmptyString, { a: ['', 'b'] }); + var withEmptyString = qs.parse('a[]=&a[]=b'); + assert.deepEqual(withEmptyString, { a: ['', 'b'] }); - var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c'); - assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] }); + var withIndexedEmptyString = qs.parse('a[0]=b&a[1]=&a[2]=c'); + assert.deepEqual(withIndexedEmptyString, { a: ['b', '', 'c'] }); } () => { - var withMaxIndex = qs.parse('a[100]=b'); - assert.deepEqual(withMaxIndex, { a: { '100': 'b' } }); + var withMaxIndex = qs.parse('a[100]=b'); + assert.deepEqual(withMaxIndex, { a: { '100': 'b' } }); } () => { - var withArrayLimit = qs.parse('a[1]=b', { arrayLimit: 0 }); - assert.deepEqual(withArrayLimit, { a: { '1': 'b' } }); + var withArrayLimit = qs.parse('a[1]=b', { arrayLimit: 0 }); + assert.deepEqual(withArrayLimit, { a: { '1': 'b' } }); } () => { - var noParsingArrays = qs.parse('a[]=b', { parseArrays: false }); - assert.deepEqual(noParsingArrays, { a: { '0': 'b' } }); + var noParsingArrays = qs.parse('a[]=b', { parseArrays: false }); + assert.deepEqual(noParsingArrays, { a: { '0': 'b' } }); } () => { - var mixedNotation = qs.parse('a[0]=b&a[b]=c'); - assert.deepEqual(mixedNotation, { a: { '0': 'b', b: 'c' } }); + var mixedNotation = qs.parse('a[0]=b&a[b]=c'); + assert.deepEqual(mixedNotation, { a: { '0': 'b', b: 'c' } }); } () => { - var arraysOfObjects = qs.parse('a[][b]=c'); - assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] }); + var arraysOfObjects = qs.parse('a[][b]=c'); + assert.deepEqual(arraysOfObjects, { a: [{ b: 'c' }] }); } () => { - assert.equal(qs.stringify({ a: 'b' }), 'a=b'); - assert.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); + assert.equal(qs.stringify({ a: 'b' }), 'a=b'); + assert.equal(qs.stringify({ a: { b: 'c' } }), 'a%5Bb%5D=c'); } () => { - var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false }); - assert.equal(unencoded, 'a[b]=c'); + var unencoded = qs.stringify({ a: { b: 'c' } }, { encode: false }); + assert.equal(unencoded, 'a[b]=c'); } () => { - var encoded = qs.stringify({ a: { b: 'c' } }, { - encoder: function (str) { - // Passed in values `a`, `b`, `c` - return // Return encoded string - } - }) + var encoded = qs.stringify({ a: { b: 'c' } }, { + encoder: function (str) { + // Passed in values `a`, `b`, `c` + return // Return encoded string + } + }) } () => { - var decoded = qs.parse('x=z', { - decoder: function (str) { - // Passed in values `x`, `z` - return // Return decoded string - } - }) + var decoded = qs.parse('x=z', { + decoder: function (str) { + // Passed in values `x`, `z` + return // Return decoded string + } + }) } () => { - qs.stringify({ a: ['b', 'c', 'd'] }); - // 'a[0]=b&a[1]=c&a[2]=d' + qs.stringify({ a: ['b', 'c', 'd'] }); + // 'a[0]=b&a[1]=c&a[2]=d' } () => { - qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }); - // 'a=b&a=c&a=d' + qs.stringify({ a: ['b', 'c', 'd'] }, { indices: false }); + // 'a=b&a=c&a=d' } () => { - qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) - // 'a[0]=b&a[1]=c' - qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }) - // 'a[]=b&a[]=c' - qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) - // 'a=b&a=c' + qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'indices' }) + // 'a[0]=b&a[1]=c' + qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'brackets' }) + // 'a[]=b&a[]=c' + qs.stringify({ a: ['b', 'c'] }, { arrayFormat: 'repeat' }) + // 'a=b&a=c' } () => { - assert.equal(qs.stringify({ a: '' }), 'a='); + assert.equal(qs.stringify({ a: '' }), 'a='); } () => { - assert.equal(qs.stringify({ a: null, b: undefined }), 'a='); + assert.equal(qs.stringify({ a: null, b: undefined }), 'a='); } () => { - assert.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d'); + assert.equal(qs.stringify({ a: 'b', c: 'd' }, { delimiter: ';' }), 'a=b;c=d'); } () => { - qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: function (prefix, value) { - if (prefix == 'b') { - // Return an `undefined` value to omit a property. - return; - } - if (prefix == 'e[f]') { - return value.getTime(); - } - if (prefix == 'e[g][0]') { - return value * 2; - } - return value; - } }); - // 'a=b&c=d&e[f]=123&e[g][0]=4' - qs.stringify({ a: 'b', c: 'd', e: 'f' }, { filter: ['a', 'e'] }); - // 'a=b&e=f' - qs.stringify({ a: ['b', 'c', 'd'], e: 'f' }, { filter: ['a', 0, 2] }); + qs.stringify({ a: 'b', c: 'd', e: { f: new Date(123), g: [2] } }, { filter: function (prefix, value) { + if (prefix == 'b') { + // Return an `undefined` value to omit a property. + return; + } + if (prefix == 'e[f]') { + return value.getTime(); + } + if (prefix == 'e[g][0]') { + return value * 2; + } + return value; + } }); + // 'a=b&c=d&e[f]=123&e[g][0]=4' + qs.stringify({ a: 'b', c: 'd', e: 'f' }, { filter: ['a', 'e'] }); + // 'a=b&e=f' + qs.stringify({ a: ['b', 'c', 'd'], e: 'f' }, { filter: ['a', 0, 2] }); } () => { - var withNull = qs.stringify({ a: null, b: '' }); - assert.equal(withNull, 'a=&b='); + var withNull = qs.stringify({ a: null, b: '' }); + assert.equal(withNull, 'a=&b='); } () => { - var equalsInsensitive = qs.parse('a&b='); - assert.deepEqual(equalsInsensitive, { a: '', b: '' }); + var equalsInsensitive = qs.parse('a&b='); + assert.deepEqual(equalsInsensitive, { a: '', b: '' }); } () => { - var strictNull = qs.stringify({ a: null, b: '' }, { strictNullHandling: true }); - assert.equal(strictNull, 'a&b='); + var strictNull = qs.stringify({ a: null, b: '' }, { strictNullHandling: true }); + assert.equal(strictNull, 'a&b='); } () => { - var parsedStrictNull = qs.parse('a&b=', { strictNullHandling: true }); - assert.deepEqual(parsedStrictNull, { a: null, b: '' }); + var parsedStrictNull = qs.parse('a&b=', { strictNullHandling: true }); + assert.deepEqual(parsedStrictNull, { a: null, b: '' }); } () => { - var nullsSkipped = qs.stringify({ a: 'b', c: null }, { skipNulls: true }); - assert.equal(nullsSkipped, 'a=b'); + var nullsSkipped = qs.stringify({ a: 'b', c: null }, { skipNulls: true }); + assert.equal(nullsSkipped, 'a=b'); } () => { - var encoder = () => {}; - var shiftJISEncoded = qs.stringify({ a: 'こんにちは!' }, { encoder: encoder }); - assert.equal(shiftJISEncoded, 'a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I'); + var encoder = () => {}; + var shiftJISEncoded = qs.stringify({ a: 'こんにちは!' }, { encoder: encoder }); + assert.equal(shiftJISEncoded, 'a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I'); } () => { - var decoder = () => {}; - var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder }); - assert.deepEqual(obj, { a: 'こんにちは!' }); + var decoder = () => {}; + var obj = qs.parse('a=%82%B1%82%F1%82%C9%82%BF%82%CD%81I', { decoder: decoder }); + assert.deepEqual(obj, { a: 'こんにちは!' }); } () => { - var sorted = qs.stringify({ a: 1, c: 3, b: 2 }, { sort: (a, b) => a.localeCompare(b) }) - assert.equal(sorted, 'a=1&b=2&c=3') + var sorted = qs.stringify({ a: 1, c: 3, b: 2 }, { sort: (a, b) => a.localeCompare(b) }) + assert.equal(sorted, 'a=1&b=2&c=3') } From c87f276f9a6ec3e1c8061ddec297e2d6da21cc61 Mon Sep 17 00:00:00 2001 From: Belinda Teh Date: Mon, 6 Mar 2017 16:52:57 -0800 Subject: [PATCH 046/258] Update qs tests to 4 space indent --- qs/qs-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qs/qs-tests.ts b/qs/qs-tests.ts index 10a911c2dc..f3e5ca3230 100644 --- a/qs/qs-tests.ts +++ b/qs/qs-tests.ts @@ -147,8 +147,8 @@ qs.parse('a=b&c=d', { delimiter: '&' }); () => { var encoded = qs.stringify({ a: { b: 'c' } }, { encoder: function (str) { - // Passed in values `a`, `b`, `c` - return // Return encoded string + // Passed in values `a`, `b`, `c` + return // Return encoded string } }) } @@ -156,8 +156,8 @@ qs.parse('a=b&c=d', { delimiter: '&' }); () => { var decoded = qs.parse('x=z', { decoder: function (str) { - // Passed in values `x`, `z` - return // Return decoded string + // Passed in values `x`, `z` + return // Return decoded string } }) } From e19736d7fe980db3ddf649d7fb5a78a028c81d0f Mon Sep 17 00:00:00 2001 From: bappleyard Date: Tue, 7 Mar 2017 09:09:09 +0000 Subject: [PATCH 047/258] #15029 include declaration for DOMImplementation --- xmldom/index.d.ts | 5 +++++ 1 file changed, 5 insertions(+) mode change 100644 => 100755 xmldom/index.d.ts diff --git a/xmldom/index.d.ts b/xmldom/index.d.ts old mode 100644 new mode 100755 index dfbe34599c..8c252389cc --- a/xmldom/index.d.ts +++ b/xmldom/index.d.ts @@ -7,6 +7,11 @@ declare namespace xmldom { var DOMParser: DOMParserStatic; var XMLSerializer: XMLSerializerStatic; + var DOMImplementation: DOMImplementationStatic; + + interface DOMImplementationStatic { + new(): DOMImplementation; + } interface DOMParserStatic { new (): DOMParser; From cebf787454d64884e1ff2306d62148018eb401ac Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Tue, 7 Mar 2017 23:14:25 -0500 Subject: [PATCH 048/258] react-day-picker add tslint.json --- react-day-picker/tslint.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 react-day-picker/tslint.json diff --git a/react-day-picker/tslint.json b/react-day-picker/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/react-day-picker/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From a45eb5ec85c5c5ba5183ccf82e75aa75c04e5969 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Tue, 7 Mar 2017 23:22:30 -0500 Subject: [PATCH 049/258] react-day-picker add types react and reformat tsconfig.json --- react-day-picker/tsconfig.json | 46 ++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/react-day-picker/tsconfig.json b/react-day-picker/tsconfig.json index 943c51e1e6..4cf47535ad 100644 --- a/react-day-picker/tsconfig.json +++ b/react-day-picker/tsconfig.json @@ -1,24 +1,26 @@ { - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": true, - "baseUrl": "../", - "jsx": "react", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "react-day-picker-tests.tsx" - ] + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "jsx": "react", + "typeRoots": [ + "../" + ], + "types": [ + "react" + ], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-day-picker-tests.tsx" + ] } From 60a8ba65e05048e097fdfa74b7fce9d9f19b92f7 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Tue, 7 Mar 2017 23:23:02 -0500 Subject: [PATCH 050/258] react-day-picker redo types to external module syntax, fix missing fields --- react-day-picker/index.d.ts | 252 +++++++++++++++++++++--------------- 1 file changed, 148 insertions(+), 104 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index 01c5492922..e50ff542b0 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -1,113 +1,157 @@ -// Type definitions for react-day-picker v1.2.0 +// Type definitions for react-day-picker 1.2 // Project: https://github.com/gpbl/react-day-picker // Definitions by: Giampaolo Bellavite , Jason Killian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -/// +import * as React from 'react'; -declare module "react-day-picker" { - import DayPicker = ReactDayPicker.DayPicker; - export = DayPicker; +interface LocaleUtils { + formatDay(day: Date, locale: string): string; + formatMonthTitle(month: Date, locale: string): string; + formatWeekdayLong(weekday: number, locale: string): string; + formatWeekdayShort(weekday: number, locale: string): string; + getFirstDayOfWeek(locale: string): number; + getMonths(locale: string): [string, string, string, string, string, string, string, string, string, string, string, string]; } -declare var DayPicker: typeof ReactDayPicker.DayPicker; - -declare namespace ReactDayPicker { - interface LocaleUtils { - formatMonthTitle: (month: Date, locale: string) => string; - formatWeekdayShort: (weekday: number, locale: string) => string; - formatWeekdayLong: (weekday: number, locale: string) => string; - getFirstDayOfWeek: (locale: string) => number; - getMonths: (locale: string) => string[]; - } - - interface DayModifiers { - selected?: boolean; - disabled?: boolean; - [name: string]: boolean | undefined; - } - - interface Modifiers { - [name: string]: (date: Date) => boolean; - } - - interface CaptionElementProps extends React.Props { - date?: Date; - localeUtils?: LocaleUtils; - locale?: string; - onClick?: React.MouseEventHandler<{}>; - } - - interface NavbarElementProps extends React.Props { - className?: string; - previousMonth?: Date; - nextMonth?: Date; - showPreviousButton?: boolean; - showNextButton?: boolean; - onPreviousClick(): void; - onNextClick(): void; - dir?: string; - localeUtils?: LocaleUtils; - locale?: string; - - } - - interface WeekdayElementProps extends React.Props { - weekday?: number; - className?: string; - localeUtils?: LocaleUtils; - locale?: string; - } - - interface Props extends React.Props{ - modifiers?: Modifiers; - initialMonth?: Date; - numberOfMonths?: number; - renderDay?: (date: Date) => number | string | JSX.Element; - enableOutsideDays?: boolean; - firstDayOfWeek?:number; - canChangeMonth?: boolean; - disabledDays?: (date: Date) => boolean; - fixedWeeks?: boolean; - fromMonth?: Date; - reverseMonths?: boolean; - toMonth?: Date; - localeUtils?: LocaleUtils; - locale?: string; - captionElement?: React.ReactElement; - onDayClick?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; - onDayTouchTap?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; - onDayMouseEnter?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; - onDayMouseLeave?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; - onDayTouchEnd?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; - onDayTouchStart?: (e: React.SyntheticEvent<{}>, day: Date, modifiers: DayModifiers) => any; - navbarElement?: React.ReactElement; - weekdayElement?: React.ReactElement; - onMonthChange?: (month: Date) => any; - onCaptionClick?: (e: React.SyntheticEvent<{}>, month: Date) => any; - className?: string; - selectedDays?: (date: Date) => boolean; - style?: React.CSSProperties; - tabIndex?: number; - } - - class DayPicker extends React.Component { - showMonth(month: Date): void; - showPreviousMonth(): void; - showNextMonth(): void; - } - - namespace DayPicker { - var LocaleUtils: LocaleUtils; - namespace DateUtils { - function addMonths(d: Date, n: number): Date; - function clone(d: Date): Date; - function isSameDay(d1?: Date, d2?: Date): boolean; - function isPastDay(d: Date): boolean; - function isDayBetween(day: Date, startDate: Date, endDate: Date): boolean; - function addDayToRange(day: Date, range: { from?: Date, to?: Date }): { from?: Date, to?: Date }; - function isDayInRange(day: Date, range: { from?: Date, to?: Date }): boolean; - } - } +interface DateUtils { + addMonths(d: Date, n: number): Date; + clone(d: Date): Date; + isSameDay(d1: Date, d2: Date): Date; + isPastDay(d: Date): boolean; + isFutureDay(d: Date): boolean; + isDayBetween(day: Date, begin: Date, end: Date): boolean; + addDayToRange(day: Date, range: RangeModifier): RangeModifier; + isDayInRange(day: Date, range: RangeModifier): boolean; } + +interface CaptionElementProps { + date: Date; + localeUtils: LocaleUtils; + locale: string; + onClick: typeof Props.onCaptionClick; +} + +interface NavbarElementProps { + className: string; + previousMonth: Date; + nextMonth: Date; + showPreviousButton: boolean; + showNextButton: boolean; + onPreviousClick(): void; + onNextClick(): void; + dir: string; + localeUtils: LocaleUtils; + locale: string; +} + +interface WeekdayElementProps { + weekday: number; + className: string; + localeUtils: LocaleUtils; + locale: string; +} + +interface ClassNames { + container: string; + interactionDisabled: string; + navBar: string; + navButtonPrev: string; + navButtonNext: string; + + month: string; + caption: string; + weekdays: string; + weekdaysRow: string; + weekday: string; + body: string; + week: string; + day: string; + + today: string; + selected: string; + disabled: string; + outside: string; +} + +interface RangeModifier { + from: Date; + to: Date; +} +interface BeforeModifier { + before: Date; +} +interface AfterModifier { + after: Date; +} +interface FunctionModifier { + (date: Date): boolean; +} +type Modifier = RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; + +interface Modifiers { + today: Modifier | Modifier[]; + outside: Modifier | Modifier[]; + [other: string]: Modifier | Modifier[] | undefined; +} + +interface Props { + canChangeMonth?: boolean; + captionElement?: React.SFC; + className?: string; + classNames?: ClassNames; + containerProps?: React.HTMLAttributes; + disabledDays?: Modifier | Modifier[]; + enableOutsideDays?: boolean; + firstDayOfWeek?: number; + fixedWeeks?: boolean; + fromMonth?: Date; + initialMonth?: Date; + labels?: { previousMonth: string; nextMonth: string; }; + locale?: string; + localeUtils?: LocaleUtils; + modifiers?: Modifiers; + month?: Date; + months?: [string, string, string, string, string, string, string, string, string, string, string, string]; + navbarElement?: React.SFC | React.ComponentClass; + numberOfMonths?: number; + onBlur?(e: React.FocusEvent): void; + onCaptionClick?(month: Date, e: React.MouseEvent): void; + onDayClick?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayKeyDown?(day: Date, modifiers: Modifiers, e: React.KeyboardEvent): void; + onDayMouseEnter?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayMouseLeave?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayTouchEnd?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; + onDayTouchStart?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; + onFocus?(e: React.FocusEvent): void; + onKeyDown?(e: React.KeyboardEvent): void; + onMonthChange?(month: Date): void; + pagedNavigation?: boolean; + renderDay?(date: Date, modifiers: Modifiers): React.ReactNode; + reverseMonths?: boolean; + selectedDays?: Modifier | Modifier[]; + toMonth?: Date; + weekdayElement?: React.SFC | React.ComponentClass; + weekdaysLong?: [string, string, string, string, string, string, string]; + weekdaysShort?: [string, string, string, string, string, string, string]; +} + + +class DayPicker extends React.Component { + showMonth(month: Date): void; + + showPreviousMonth(): void; + + showNextMonth(): void; + + showPreviousYear(): void; + + showNextYear(): void; + + static readonly VERSION: string; + static readonly LocaleUtils: LocaleUtils; + static readonly DateUtils: DateUtils; +} + +export = DayPicker; From 7d55759e192e42ff871ee148a95b8707fd79c3a6 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Wed, 8 Mar 2017 00:35:03 -0500 Subject: [PATCH 051/258] react-day-picker merge types into namespace for export = syntax --- react-day-picker/index.d.ts | 270 ++++++++++++++++++------------------ 1 file changed, 135 insertions(+), 135 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index e50ff542b0..3f166a0c84 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -6,139 +6,143 @@ import * as React from 'react'; -interface LocaleUtils { - formatDay(day: Date, locale: string): string; - formatMonthTitle(month: Date, locale: string): string; - formatWeekdayLong(weekday: number, locale: string): string; - formatWeekdayShort(weekday: number, locale: string): string; - getFirstDayOfWeek(locale: string): number; - getMonths(locale: string): [string, string, string, string, string, string, string, string, string, string, string, string]; +declare namespace DayPicker { + export interface LocaleUtils { + formatDay(day: Date, locale: string): string; + formatMonthTitle(month: Date, locale: string): string; + formatWeekdayLong(weekday: number, locale: string): string; + formatWeekdayShort(weekday: number, locale: string): string; + getFirstDayOfWeek(locale: string): number; + getMonths(locale: string): [string, string, string, string, string, string, string, string, string, string, string, string]; + } + + export interface DateUtils { + addMonths(d: Date, n: number): Date; + clone(d: Date): Date; + isSameDay(d1: Date, d2: Date): Date; + isPastDay(d: Date): boolean; + isFutureDay(d: Date): boolean; + isDayBetween(day: Date, begin: Date, end: Date): boolean; + addDayToRange(day: Date, range: RangeModifier): RangeModifier; + isDayInRange(day: Date, range: RangeModifier): boolean; + } + + export interface CaptionElementProps { + date?: Date; + localeUtils?: LocaleUtils; + locale?: string; + onClick?(month: Date, e: React.MouseEvent): void; + } + + export interface NavbarElementProps { + className?: string; + previousMonth?: Date; + nextMonth?: Date; + showPreviousButton?: boolean; + showNextButton?: boolean; + onPreviousClick?(): void; + onNextClick?(): void; + dir?: string; + localeUtils?: LocaleUtils; + locale?: string; + } + + export interface WeekdayElementProps { + weekday?: number; + className?: string; + localeUtils?: LocaleUtils; + locale?: string; + } + + export interface ClassNames { + container: string; + interactionDisabled: string; + navBar: string; + navButtonPrev: string; + navButtonNext: string; + + month: string; + caption: string; + weekdays: string; + weekdaysRow: string; + weekday: string; + body: string; + week: string; + day: string; + + today: string; + selected: string; + disabled: string; + outside: string; + } + + export interface RangeModifier { + from: Date; + to: Date; + } + export interface BeforeModifier { + before: Date; + } + export interface AfterModifier { + after: Date; + } + export interface FunctionModifier { + (date: Date): boolean; + } + export type Modifier = RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; + + export interface Modifiers { + today: Modifier | Modifier[]; + outside: Modifier | Modifier[]; + [other: string]: Modifier | Modifier[] | undefined; + } + + export interface Props { + canChangeMonth?: boolean; + captionElement?: React.ReactElement; + className?: string; + classNames?: ClassNames; + containerProps?: React.HTMLAttributes; + disabledDays?: Modifier | Modifier[]; + enableOutsideDays?: boolean; + firstDayOfWeek?: number; + fixedWeeks?: boolean; + fromMonth?: Date; + initialMonth?: Date; + labels?: { previousMonth: string; nextMonth: string; }; + locale?: string; + localeUtils?: LocaleUtils; + modifiers?: Partial; + month?: Date; + months?: [string, string, string, string, string, string, string, string, string, string, string, string]; + navbarElement?: React.ReactElement; + numberOfMonths?: number; + onBlur?(e: React.FocusEvent): void; + onCaptionClick?(month: Date, e: React.MouseEvent): void; + onDayClick?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayKeyDown?(day: Date, modifiers: Modifiers, e: React.KeyboardEvent): void; + onDayMouseEnter?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayMouseLeave?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; + onDayTouchEnd?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; + onDayTouchStart?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; + onFocus?(e: React.FocusEvent): void; + onKeyDown?(e: React.KeyboardEvent): void; + onMonthChange?(month: Date): void; + pagedNavigation?: boolean; + renderDay?(date: Date, modifiers: Modifiers): React.ReactNode; + reverseMonths?: boolean; + selectedDays?: Modifier | Modifier[]; + toMonth?: Date; + weekdayElement?: React.ReactElement; + weekdaysLong?: [string, string, string, string, string, string, string]; + weekdaysShort?: [string, string, string, string, string, string, string]; + } + const VERSION: string; + const LocaleUtils: DayPicker.LocaleUtils; + const DateUtils: DayPicker.DateUtils; } -interface DateUtils { - addMonths(d: Date, n: number): Date; - clone(d: Date): Date; - isSameDay(d1: Date, d2: Date): Date; - isPastDay(d: Date): boolean; - isFutureDay(d: Date): boolean; - isDayBetween(day: Date, begin: Date, end: Date): boolean; - addDayToRange(day: Date, range: RangeModifier): RangeModifier; - isDayInRange(day: Date, range: RangeModifier): boolean; -} - -interface CaptionElementProps { - date: Date; - localeUtils: LocaleUtils; - locale: string; - onClick: typeof Props.onCaptionClick; -} - -interface NavbarElementProps { - className: string; - previousMonth: Date; - nextMonth: Date; - showPreviousButton: boolean; - showNextButton: boolean; - onPreviousClick(): void; - onNextClick(): void; - dir: string; - localeUtils: LocaleUtils; - locale: string; -} - -interface WeekdayElementProps { - weekday: number; - className: string; - localeUtils: LocaleUtils; - locale: string; -} - -interface ClassNames { - container: string; - interactionDisabled: string; - navBar: string; - navButtonPrev: string; - navButtonNext: string; - - month: string; - caption: string; - weekdays: string; - weekdaysRow: string; - weekday: string; - body: string; - week: string; - day: string; - - today: string; - selected: string; - disabled: string; - outside: string; -} - -interface RangeModifier { - from: Date; - to: Date; -} -interface BeforeModifier { - before: Date; -} -interface AfterModifier { - after: Date; -} -interface FunctionModifier { - (date: Date): boolean; -} -type Modifier = RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; - -interface Modifiers { - today: Modifier | Modifier[]; - outside: Modifier | Modifier[]; - [other: string]: Modifier | Modifier[] | undefined; -} - -interface Props { - canChangeMonth?: boolean; - captionElement?: React.SFC; - className?: string; - classNames?: ClassNames; - containerProps?: React.HTMLAttributes; - disabledDays?: Modifier | Modifier[]; - enableOutsideDays?: boolean; - firstDayOfWeek?: number; - fixedWeeks?: boolean; - fromMonth?: Date; - initialMonth?: Date; - labels?: { previousMonth: string; nextMonth: string; }; - locale?: string; - localeUtils?: LocaleUtils; - modifiers?: Modifiers; - month?: Date; - months?: [string, string, string, string, string, string, string, string, string, string, string, string]; - navbarElement?: React.SFC | React.ComponentClass; - numberOfMonths?: number; - onBlur?(e: React.FocusEvent): void; - onCaptionClick?(month: Date, e: React.MouseEvent): void; - onDayClick?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; - onDayKeyDown?(day: Date, modifiers: Modifiers, e: React.KeyboardEvent): void; - onDayMouseEnter?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; - onDayMouseLeave?(day: Date, modifiers: Modifiers, e: React.MouseEvent): void; - onDayTouchEnd?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; - onDayTouchStart?(day: Date, modifiers: Modifiers, e: React.TouchEvent): void; - onFocus?(e: React.FocusEvent): void; - onKeyDown?(e: React.KeyboardEvent): void; - onMonthChange?(month: Date): void; - pagedNavigation?: boolean; - renderDay?(date: Date, modifiers: Modifiers): React.ReactNode; - reverseMonths?: boolean; - selectedDays?: Modifier | Modifier[]; - toMonth?: Date; - weekdayElement?: React.SFC | React.ComponentClass; - weekdaysLong?: [string, string, string, string, string, string, string]; - weekdaysShort?: [string, string, string, string, string, string, string]; -} - - -class DayPicker extends React.Component { +declare class DayPicker extends React.Component { showMonth(month: Date): void; showPreviousMonth(): void; @@ -148,10 +152,6 @@ class DayPicker extends React.Component { showPreviousYear(): void; showNextYear(): void; - - static readonly VERSION: string; - static readonly LocaleUtils: LocaleUtils; - static readonly DateUtils: DateUtils; } export = DayPicker; From 99e2521b64f732b59ab658a54673ffa083adbe1e Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Wed, 8 Mar 2017 00:35:31 -0500 Subject: [PATCH 052/258] react-day-picker typing tests passing --- react-day-picker/react-day-picker-tests.tsx | 30 +++++++++------------ 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/react-day-picker/react-day-picker-tests.tsx b/react-day-picker/react-day-picker-tests.tsx index e8a17b5087..deecb3e21a 100644 --- a/react-day-picker/react-day-picker-tests.tsx +++ b/react-day-picker/react-day-picker-tests.tsx @@ -1,37 +1,33 @@ import * as React from 'react'; -import * as DayPicker2 from "react-day-picker"; +import DayPicker = require('react-day-picker'); function isSunday(day: Date) { return day.getDay() === 0; } -// make sure global variable version works -function MyComponent2() { - return +function MyComponent() { + return ( + + ); } DayPicker.DateUtils.clone(new Date()); -DayPicker.DateUtils.isDayInRange(new Date(), {from: new Date()}); +DayPicker.DateUtils.isDayInRange(new Date(), { from: new Date(), to: new Date(2050) }); -// make sure imported version works -function MyComponent() { - return +interface MyCaptionProps extends DayPicker.CaptionElementProps { } -DayPicker2.DateUtils.clone(new Date()); -DayPicker2.DateUtils.isDayInRange(new Date(), { from: new Date() }); - -// test interface for captionElement prop -interface MyCaptionProps extends ReactDayPicker.CaptionElementProps { } class Caption extends React.Component { render() { const { date, locale, localeUtils, onClick } = this.props; - if (!date || !localeUtils || typeof locale === 'undefined') { - return null + if (!date || !localeUtils || !onClick || typeof locale === 'undefined') { + return null; } return ( -
- { localeUtils.formatMonthTitle(date, locale) } +
onClick(date, e) }> + { localeUtils.formatMonthTitle(date, locale) }
); } From 395d4c556b1937ba6820a6c7859b641356a09eb5 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Wed, 8 Mar 2017 00:41:42 -0500 Subject: [PATCH 053/258] react-day-picker update version string --- react-day-picker/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index 3f166a0c84..1e99e1f48b 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-day-picker 1.2 +// Type definitions for react-day-picker 5.1 // Project: https://github.com/gpbl/react-day-picker // Definitions by: Giampaolo Bellavite , Jason Killian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From acb5edf962060577cd4ff68bf2f42b1f8477a304 Mon Sep 17 00:00:00 2001 From: sqwk Date: Wed, 8 Mar 2017 11:48:25 +0100 Subject: [PATCH 054/258] fix: Make Chainable Work --- lowdb/index.d.ts | 130 +++++++++++++++++++++++------------------------ 1 file changed, 65 insertions(+), 65 deletions(-) diff --git a/lowdb/index.d.ts b/lowdb/index.d.ts index 4118372647..3ca15155e1 100644 --- a/lowdb/index.d.ts +++ b/lowdb/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: typicode, // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace lowdb { +declare namespace Lowdb { interface PromiseLike { /** @@ -45,24 +45,24 @@ declare namespace lowdb { chain?: boolean; } - class LoDashWrapper { + class LoDashWrapper> { /** * @see _.has */ - has(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; + has(path: StringRepresentable | StringRepresentable[]): LowEntryClass; /** * @see _.hasIn */ - hasIn(path: StringRepresentable | StringRepresentable[]): LoDashWrapper; + hasIn(path: StringRepresentable | StringRepresentable[]): LowEntryClass; /** * @see _.assign */ assign( source: TSource - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.assign @@ -70,7 +70,7 @@ declare namespace lowdb { assign( source1: TSource1, source2: TSource2 - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.assign @@ -79,7 +79,7 @@ declare namespace lowdb { source1: TSource1, source2: TSource2, source3: TSource3 - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.assign @@ -89,37 +89,37 @@ declare namespace lowdb { source2: TSource2, source3: TSource3, source4: TSource4 - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.assign */ - assign(): LoDashWrapper; + assign(): LowEntryClass; /** * @see _.assign */ - assign(...otherArgs: any[]): LoDashWrapper; + assign(...otherArgs: any[]): LowEntryClass; /** * @see _.cloneDeep */ - cloneDeep(): LoDashWrapper; + cloneDeep(): LowEntryClass; /** * @see _.cloneDeep */ - cloneDeep(): LoDashWrapper; + cloneDeep(): LowEntryClass; /** * @see _.cloneDeep */ - cloneDeepWith(customizer: (value: any) => any): LoDashWrapper[]; + cloneDeepWith(customizer: (value: any) => any): LowEntryClass[]; /** * @see _.cloneDeep */ - cloneDeepWith(customizer: (value: any) => any): LoDashWrapper; + cloneDeepWith(customizer: (value: any) => any): LowEntryClass; /** * @see _.defaults @@ -127,7 +127,7 @@ declare namespace lowdb { defaults( source1: S1, ...sources: {}[] - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.defaults @@ -136,7 +136,7 @@ declare namespace lowdb { source1: S1, source2: S2, ...sources: {}[] - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.defaults @@ -146,7 +146,7 @@ declare namespace lowdb { source2: S2, source3: S3, ...sources: {}[] - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.defaults @@ -157,17 +157,17 @@ declare namespace lowdb { source3: S3, source4: S4, ...sources: {}[] - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.defaults */ - defaults(): LoDashWrapper; + defaults(): LowEntryClass; /** * @see _.defaults */ - defaults(...sources: {}[]): LoDashWrapper; + defaults(...sources: {}[]): LowEntryClass; /** * @see _.get @@ -175,14 +175,14 @@ declare namespace lowdb { get(object: any, path: string | number | boolean | Array, defaultValue?: TResult - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.get */ get(path: string | number | boolean | Array, defaultValue?: TResult - ): LoDashWrapper; + ): LowEntryClass; /** @@ -191,14 +191,14 @@ declare namespace lowdb { mixin( source: Dictionary<() => void>, options?: MixinOptions - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.mixin */ mixin( options?: MixinOptions - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.set @@ -206,7 +206,7 @@ declare namespace lowdb { set( path: StringRepresentable | StringRepresentable[], value: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.set @@ -214,7 +214,7 @@ declare namespace lowdb { set( path: StringRepresentable | StringRepresentable[], value: V - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.find @@ -222,7 +222,7 @@ declare namespace lowdb { find( predicate?: ListIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.find @@ -230,21 +230,21 @@ declare namespace lowdb { find( predicate?: string, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.find */ find( predicate?: TObject - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.find */ filter( predicate?: TObject - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.filter @@ -252,7 +252,7 @@ declare namespace lowdb { filter( predicate?: ListIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.filter @@ -260,7 +260,7 @@ declare namespace lowdb { filter( predicate: string, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.filter @@ -268,7 +268,7 @@ declare namespace lowdb { filter( predicate: ListIterator | DictionaryIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.filter @@ -276,40 +276,40 @@ declare namespace lowdb { filter( predicate?: StringIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.filter */ - filter(predicate: W): LoDashWrapper; + filter(predicate: W): LowEntryClass; /** * @see _.map */ map( iteratee?: ListIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.map */ map( iteratee?: string - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.map */ map( iteratee?: TObject - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.map */ map( iteratee?: ListIterator | DictionaryIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.range @@ -317,7 +317,7 @@ declare namespace lowdb { range( end?: number, step?: number - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.rangeRight @@ -325,7 +325,7 @@ declare namespace lowdb { rangeRight( end?: number, step?: number - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.remove @@ -333,7 +333,7 @@ declare namespace lowdb { remove( predicate?: ListIterator, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.remove @@ -341,46 +341,46 @@ declare namespace lowdb { remove( predicate?: string, thisArg?: any - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.remove */ remove( predicate?: W - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.sortBy */ sortBy( iteratee?: ListIterator - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.sortBy */ - sortBy(iteratee: string): LoDashWrapper; + sortBy(iteratee: string): LowEntryClass; /** * @see _.sortBy */ - sortBy(whereValue: W): LoDashWrapper; + sortBy(whereValue: W): LowEntryClass; /** * @see _.sortBy */ - sortBy(): LoDashWrapper; + sortBy(): LowEntryClass; /** * @see _.sortBy */ - sortBy(...iteratees: (ListIterator | any | string)[]): LoDashWrapper; + sortBy(...iteratees: (ListIterator | any | string)[]): LowEntryClass; /** * @see _.sortBy */ - sortBy(iteratees: (ListIterator | string | any)[]): LoDashWrapper; + sortBy(iteratees: (ListIterator | string | any)[]): LowEntryClass; /** * @see _.slice @@ -388,44 +388,44 @@ declare namespace lowdb { slice( start?: number, end?: number - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.size */ - size(): LoDashWrapper; + size(): LowEntryClass; /** * @see _.take */ - take(n?: number): LoDashWrapper; + take(n?: number): LowEntryClass; /** * @see _.times */ times( iteratee: (num: number) => TResult - ): LoDashWrapper; + ): LowEntryClass; /** * @see _.times */ - times(): LoDashWrapper; + times(): LowEntryClass; /** * @see _.uniqueId */ - uniqueId(): LoDashWrapper; + uniqueId(): LowEntryClass; value(): T; pop(): T; - push(...items: T[]): LoDashWrapper; + push(...items: T[]): LowEntryClass; shift(): T; - sort(compareFn?: (a: T, b: T) => number): LoDashWrapper; - splice(start: number): LoDashWrapper; - splice(start: number, deleteCount: number, ...items: any[]): LoDashWrapper; - unshift(...items: T[]): LoDashWrapper; + sort(compareFn?: (a: T, b: T) => number): LowEntryClass; + splice(start: number): LowEntryClass; + splice(start: number, deleteCount: number, ...items: any[]): LowEntryClass; + unshift(...items: T[]): LowEntryClass; } export interface Storage { @@ -505,7 +505,7 @@ declare namespace lowdb { } - export class Low extends LoDashWrapper { + export class Lowdb extends LoDashWrapper { constructor(filePath: string, options?: Options); @@ -525,13 +525,13 @@ declare namespace lowdb { * Persist database. * @param source The source location. */ - write(source: string): void + write(source?: string): void /** * Persist database. * @param source The source location. */ - write(source: string): PromiseLike + write(source?: string): PromiseLike /** * Read database. @@ -554,5 +554,5 @@ declare namespace lowdb { } declare module "lowdb" { - export = lowdb.Low; + export = Lowdb.Lowdb; } \ No newline at end of file From 162688615a8f5e9980b12633e4c19ff54aaefe84 Mon Sep 17 00:00:00 2001 From: sqwk Date: Wed, 8 Mar 2017 11:48:54 +0100 Subject: [PATCH 055/258] fix: Update Tests for v15.5 --- lowdb/lowdb-tests.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lowdb/lowdb-tests.ts b/lowdb/lowdb-tests.ts index 612288e8dd..b7e0f4f5f6 100644 --- a/lowdb/lowdb-tests.ts +++ b/lowdb/lowdb-tests.ts @@ -2,10 +2,15 @@ import Lowdb = require('lowdb'); const db = new Lowdb('db.json'); -db.defaults({ someObject: {}, anotherObject: {} }).value(); +db.defaults({ someObject: {}, anotherObject: {} }).write(); -db.get('someObject').set('foo' , 'bar').value(); -db.get('anotherObject').set('foo' , 'bar').value(); -db.set('singleValue', 'foo').value(); +db.get('someObject').set('foo' , 'bar').write(); +db.get('someObject.foo').value(); + +db.get('anotherObject').set('foo' , 'bar').write(); +db.get('anotherObject.foo').value(); + +db.set('singleValue', 'foo').write(); +db.get('singleValue').value(); console.log(db.getState()); From 673f3c9b72d71b51476be7b072f5d621733c31f3 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Wed, 8 Mar 2017 10:59:34 -0500 Subject: [PATCH 056/258] react-day-picker remove tsconfig.json types react and add reference comment in index.d.ts --- react-day-picker/index.d.ts | 2 ++ react-day-picker/tsconfig.json | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index 1e99e1f48b..d1f71a911e 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -4,6 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 +/// + import * as React from 'react'; declare namespace DayPicker { diff --git a/react-day-picker/tsconfig.json b/react-day-picker/tsconfig.json index 4cf47535ad..823be84e03 100644 --- a/react-day-picker/tsconfig.json +++ b/react-day-picker/tsconfig.json @@ -13,9 +13,7 @@ "typeRoots": [ "../" ], - "types": [ - "react" - ], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From d6472a73263a821cf19241bd4df444ec01c64668 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Wed, 8 Mar 2017 11:12:26 -0500 Subject: [PATCH 057/258] react-day-picker remove reference type react because it is already imported --- react-day-picker/index.d.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index d1f71a911e..1e99e1f48b 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -4,8 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 -/// - import * as React from 'react'; declare namespace DayPicker { From eed88053b0ec98c27e50e77b4216053aa455d432 Mon Sep 17 00:00:00 2001 From: abeall Date: Wed, 8 Mar 2017 14:24:11 -0500 Subject: [PATCH 058/258] Added browser name values --- detect-browser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detect-browser/index.d.ts b/detect-browser/index.d.ts index 0f845cd781..5ca68eabdf 100644 --- a/detect-browser/index.d.ts +++ b/detect-browser/index.d.ts @@ -6,7 +6,7 @@ /** * Browser name */ -export const name: string; +export const name: "edge" | "yandexbrowser" | "chrome" | "crios" | "firefox" | "opera" | "ie" | "bb10" | "android" | "ios" | "safari"; /** * Browser version From 023d4ef9370dc1a7ca348d75cb4b0e42c890dee5 Mon Sep 17 00:00:00 2001 From: abeall Date: Wed, 8 Mar 2017 14:26:53 -0500 Subject: [PATCH 059/258] Updated version --- detect-browser/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/detect-browser/index.d.ts b/detect-browser/index.d.ts index 5ca68eabdf..57ed80c411 100644 --- a/detect-browser/index.d.ts +++ b/detect-browser/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for detect-browser v1.3.3 +// Type definitions for detect-browser v1.6.2 // Project: https://github.com/DamonOehlman/detect-browser // Definitions by: Rogier Schouten // Definitions: https://github.com/borisyankov/DefinitelyTyped From 1b95ed269fbbcb34ec770a212147aed1e5c72f03 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Thu, 9 Mar 2017 01:21:15 +0000 Subject: [PATCH 060/258] Fixed magic quotes. --- openfin/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openfin/index.d.ts b/openfin/index.d.ts index f0803864ae..24f91ab9ca 100644 --- a/openfin/index.d.ts +++ b/openfin/index.d.ts @@ -63,7 +63,7 @@ declare namespace fin { */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Retrieves an array of wrapped fin.desktop.Windows for each of the application�s child windows. + * Retrieves an array of wrapped fin.desktop.Windows for each of the application's child windows. */ getChildWindows(callback?: (children: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; /** @@ -99,7 +99,7 @@ declare namespace fin { */ removeEventListener(type: OpenFinApplicationEventType, previouslyRegisteredListener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Removes the application�s icon from the tray. + * Removes the application's icon from the tray. */ removeTrayIcon(callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1008,7 +1008,7 @@ declare namespace fin { bringToFront(callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Closes the window. - * @param {force} Close will be prevented from closing when force is false and �close-requested� has been subscribed to for application�s main window. + * @param {force} Close will be prevented from closing when force is false and 'close-requested' has been subscribed to for application's main window. */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1028,7 +1028,7 @@ declare namespace fin { */ enableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Flashes the window�s frame and taskbar icon until the window is activated. + * Flashes the window's frame and taskbar icon until the window is activated. */ flash(options?: any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1125,7 +1125,7 @@ declare namespace fin { setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Shows the window if it is hidden. - * @param {force} Show will be prevented from closing when force is false and �show-requested� has been subscribed to for application�s main window. + * @param {force} Show will be prevented from closing when force is false and 'show-requested' has been subscribed to for application's main window. */ show(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** From 9fc167714de333821347c5ebcb090f9f78457bf2 Mon Sep 17 00:00:00 2001 From: Chris Barker Date: Thu, 9 Mar 2017 01:45:36 +0000 Subject: [PATCH 061/258] Fixed magic quotes in v16 too. --- openfin/v16/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openfin/v16/index.d.ts b/openfin/v16/index.d.ts index 0b9f3e16ac..32e980120f 100644 --- a/openfin/v16/index.d.ts +++ b/openfin/v16/index.d.ts @@ -63,7 +63,7 @@ declare namespace fin { */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Retrieves an array of wrapped fin.desktop.Windows for each of the application�s child windows. + * Retrieves an array of wrapped fin.desktop.Windows for each of the application's child windows. */ getChildWindows(callback?: (children: OpenFinWindow[]) => void, errorCallback?: (reason: string) => void): void; /** @@ -95,7 +95,7 @@ declare namespace fin { */ removeEventListener(type: OpenFinApplicationEventType, previouslyRegisteredListener: (event: ApplicationBaseEvent | TrayIconClickedEvent | WindowEvent | WindowAlertRequestedEvent | WindowAuthRequested | WindowNavigationRejectedEvent | WindowEndLoadEvent) => any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Removes the application�s icon from the tray. + * Removes the application's icon from the tray. */ removeTrayIcon(callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -989,7 +989,7 @@ declare namespace fin { bringToFront(callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Closes the window. - * @param {force} Close will be prevented from closing when force is false and �close-requested� has been subscribed to for application�s main window. + * @param {force} Close will be prevented from closing when force is false and 'close-requested' has been subscribed to for application's main window. */ close(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1009,7 +1009,7 @@ declare namespace fin { */ enableFrame(callback?: () => void, errorCallback?: (reason: string) => void): void; /** - * Flashes the window�s frame and taskbar icon until the window is activated. + * Flashes the window's frame and taskbar icon until the window is activated. */ flash(options?: any, callback?: () => void, errorCallback?: (reason: string) => void): void; /** @@ -1106,7 +1106,7 @@ declare namespace fin { setZoomLevel(level: number, callback?: () => void, errorCallback?: (reason: string) => void): void; /** * Shows the window if it is hidden. - * @param {force} Show will be prevented from closing when force is false and �show-requested� has been subscribed to for application�s main window. + * @param {force} Show will be prevented from closing when force is false and 'show-requested' has been subscribed to for application's main window. */ show(force?: boolean, callback?: () => void, errorCallback?: (reason: string) => void): void; /** From d4864b74edfcd79afc9f120e8b7df33c4665bd50 Mon Sep 17 00:00:00 2001 From: Ricky Blankenaufulland Date: Thu, 9 Mar 2017 14:58:30 +0100 Subject: [PATCH 062/258] fixed how the GridStack object is obtained jQuery plugins return the jQuery object, to get the plugin, also in the case of GridStack 0.2.6 (latest) you use the data() method with the correct name --- gridstack/gridstack-tests.ts | 6 +++++- gridstack/index.d.ts | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gridstack/gridstack-tests.ts b/gridstack/gridstack-tests.ts index 96aa14b19f..02e6c1597f 100644 --- a/gridstack/gridstack-tests.ts +++ b/gridstack/gridstack-tests.ts @@ -10,7 +10,11 @@ var options = { float: true }; -var gridstack:GridStack = $(document).gridstack(options); +var element: JQuery = $(document).gridstack(options); +var gridstack: GridStack = $(document).data("gridstack"); +var gsFromElement: GridStack = element.data("gridstack"); + +if (gridstack !== gsFromElement) throw Error('These should match!'); gridstack.addWidget("test", 1, 2, 3, 4, true); gridstack.batchUpdate(); diff --git a/gridstack/index.d.ts b/gridstack/index.d.ts index 75056999e2..19e4bda280 100644 --- a/gridstack/index.d.ts +++ b/gridstack/index.d.ts @@ -4,7 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface JQuery { - gridstack (options: IGridstackOptions):GridStack + gridstack (options: IGridstackOptions): JQuery; + data(key: "gridstack"): GridStack; } interface GridStack { From bd35ad182875e11c8c70c97d1bc40726a62e08e1 Mon Sep 17 00:00:00 2001 From: Ricky Blankenaufulland Date: Thu, 9 Mar 2017 14:59:27 +0100 Subject: [PATCH 063/258] added ZoolWay to the authors --- gridstack/gridstack-tests.ts | 1 + gridstack/index.d.ts | 1 + 2 files changed, 2 insertions(+) diff --git a/gridstack/gridstack-tests.ts b/gridstack/gridstack-tests.ts index 02e6c1597f..0546bab506 100644 --- a/gridstack/gridstack-tests.ts +++ b/gridstack/gridstack-tests.ts @@ -5,6 +5,7 @@ // Type definitions for Gridstack // Project: http://troolee.github.io/gridstack.js/ // Definitions by: Pascal Senn +// Definitions by: Ricky Blankenaufulland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped var options = { diff --git a/gridstack/index.d.ts b/gridstack/index.d.ts index 19e4bda280..7f557f4af6 100644 --- a/gridstack/index.d.ts +++ b/gridstack/index.d.ts @@ -1,6 +1,7 @@ // Type definitions for Gridstack // Project: http://troolee.github.io/gridstack.js/ // Definitions by: Pascal Senn +// Definitions by: Ricky Blankenaufulland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface JQuery { From d57893528cfc43ee257764d0d4986a996fa91ac7 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Thu, 9 Mar 2017 13:07:57 -0500 Subject: [PATCH 064/258] add types for react-day-picker 5.2 --- react-day-picker/index.d.ts | 54 ++++++++++++++++++++++--------------- 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/react-day-picker/index.d.ts b/react-day-picker/index.d.ts index 1e99e1f48b..be90f72d07 100644 --- a/react-day-picker/index.d.ts +++ b/react-day-picker/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-day-picker 5.1 +// Type definitions for react-day-picker 5.2 // Project: https://github.com/gpbl/react-day-picker // Definitions by: Giampaolo Bellavite , Jason Killian // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -28,30 +28,34 @@ declare namespace DayPicker { } export interface CaptionElementProps { - date?: Date; - localeUtils?: LocaleUtils; - locale?: string; - onClick?(month: Date, e: React.MouseEvent): void; + date: Date; + classNames: ClassNames, + localeUtils: LocaleUtils; + locale: string; + months: undefined; + onClick?: React.MouseEventHandler; } export interface NavbarElementProps { - className?: string; - previousMonth?: Date; - nextMonth?: Date; - showPreviousButton?: boolean; - showNextButton?: boolean; - onPreviousClick?(): void; - onNextClick?(): void; + className: string; + classNames: ClassNames; + previousMonth: Date; + nextMonth: Date; + showPreviousButton: boolean; + showNextButton: boolean; + onPreviousClick(callback?: () => void): void; + onNextClick(callback?: () => void): void; dir?: string; - localeUtils?: LocaleUtils; - locale?: string; + labels: { previousMonth: string; nextMonth: string; }; + localeUtils: LocaleUtils; + locale: string; } export interface WeekdayElementProps { - weekday?: number; - className?: string; - localeUtils?: LocaleUtils; - locale?: string; + weekday: number; + className: string; + localeUtils: LocaleUtils; + locale: string; } export interface ClassNames { @@ -89,7 +93,7 @@ declare namespace DayPicker { export interface FunctionModifier { (date: Date): boolean; } - export type Modifier = RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; + export type Modifier = Date | RangeModifier | BeforeModifier | AfterModifier | FunctionModifier; export interface Modifiers { today: Modifier | Modifier[]; @@ -99,7 +103,9 @@ declare namespace DayPicker { export interface Props { canChangeMonth?: boolean; - captionElement?: React.ReactElement; + captionElement?: React.ReactElement> | + React.ComponentClass | + React.SFC; className?: string; classNames?: ClassNames; containerProps?: React.HTMLAttributes; @@ -115,7 +121,9 @@ declare namespace DayPicker { modifiers?: Partial; month?: Date; months?: [string, string, string, string, string, string, string, string, string, string, string, string]; - navbarElement?: React.ReactElement; + navbarElement?: React.ReactElement> | + React.ComponentClass | + React.SFC; numberOfMonths?: number; onBlur?(e: React.FocusEvent): void; onCaptionClick?(month: Date, e: React.MouseEvent): void; @@ -133,7 +141,9 @@ declare namespace DayPicker { reverseMonths?: boolean; selectedDays?: Modifier | Modifier[]; toMonth?: Date; - weekdayElement?: React.ReactElement; + weekdayElement?: React.ReactElement> | + React.ComponentClass | + React.SFC; weekdaysLong?: [string, string, string, string, string, string, string]; weekdaysShort?: [string, string, string, string, string, string, string]; } From c0b6319ccf49e2ac3107bfb906456489ab30f9d4 Mon Sep 17 00:00:00 2001 From: cwmoo740 Date: Thu, 9 Mar 2017 15:22:54 -0500 Subject: [PATCH 065/258] react-day-picker update tests to include new use of Element or React.SFC for captionElement --- react-day-picker/react-day-picker-tests.tsx | 23 ++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/react-day-picker/react-day-picker-tests.tsx b/react-day-picker/react-day-picker-tests.tsx index deecb3e21a..8c2755f9b5 100644 --- a/react-day-picker/react-day-picker-tests.tsx +++ b/react-day-picker/react-day-picker-tests.tsx @@ -8,7 +8,7 @@ function isSunday(day: Date) { function MyComponent() { return ( ); } @@ -26,10 +26,27 @@ class Caption extends React.Component { } return ( -
onClick(date, e) }> +
{ localeUtils.formatMonthTitle(date, locale) }
); } } -}/> + + + +type CaptionElementProps = Partial; +class CaptionElement extends React.Component { + render() { + const { date, locale, localeUtils, onClick } = this.props; + if (!date || !locale || !localeUtils || !onClick) { + return
; + } + return ( +
+ { localeUtils.formatMonthTitle(date, locale) } +
+ ) + } +} + }/> From b00b86d7197ed3217557fc6e88657c19a8b67f55 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 09:57:24 +0200 Subject: [PATCH 066/258] Enable dt-header tslint rule --- compression-webpack-plugin/tslint.json | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/compression-webpack-plugin/tslint.json b/compression-webpack-plugin/tslint.json index 02312e1c7d..70cee1ba88 100644 --- a/compression-webpack-plugin/tslint.json +++ b/compression-webpack-plugin/tslint.json @@ -1,7 +1,4 @@ { - "extends": "../tslint.json", - "rules": { - "dt-header": false - } - } + "extends": "../tslint.json" +} \ No newline at end of file From 9e069e784e7a5bc12f1abacd71b319a9f02f1c8b Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 10:13:16 +0200 Subject: [PATCH 067/258] Using require syntax in tests --- .../compression-webpack-plugin-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/compression-webpack-plugin/compression-webpack-plugin-tests.ts b/compression-webpack-plugin/compression-webpack-plugin-tests.ts index 4ee93c78b7..3939bf5847 100644 --- a/compression-webpack-plugin/compression-webpack-plugin-tests.ts +++ b/compression-webpack-plugin/compression-webpack-plugin-tests.ts @@ -1,5 +1,5 @@ -import { Configuration } from 'webpack' -import * as CompressionPlugin from 'compression-webpack-plugin' +import { Configuration } from 'webpack'; +import CompressionPlugin = require('compression-webpack-plugin'); const c: Configuration = { plugins: [ From 911335f7fe972e349f402ce229627095b38ab020 Mon Sep 17 00:00:00 2001 From: Anton Kandybo Date: Fri, 10 Mar 2017 10:14:53 +0200 Subject: [PATCH 068/258] Remove patch version --- compression-webpack-plugin/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compression-webpack-plugin/index.d.ts b/compression-webpack-plugin/index.d.ts index cf65f55300..536a77b8e9 100644 --- a/compression-webpack-plugin/index.d.ts +++ b/compression-webpack-plugin/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for compression-webpack-plugin 0.3.2 +// Type definitions for compression-webpack-plugin 0.3 // Project: https://github.com/webpack-contrib/compression-webpack-plugin // Definitions by: Anton Kandybo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From a2a2083f840bc8b5c0d05a3ed779802c4f1e5e90 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Mon, 20 Feb 2017 05:13:22 -0800 Subject: [PATCH 069/258] Improve PrismJS types Convert PrismJS types to [module.d.ts][1] pattern and fix linting errors. Also fix bugs in a couple types. [1]: http://www.typescriptlang.org/docs/handbook/declaration-files/templates/module-d-ts.html --- prismjs/index.d.ts | 346 ++++++++++++++++++-------------- prismjs/prismjs-module-tests.ts | 26 +++ prismjs/prismjs-tests.ts | 18 +- prismjs/tsconfig.json | 7 +- prismjs/tslint.json | 1 + 5 files changed, 243 insertions(+), 155 deletions(-) create mode 100644 prismjs/prismjs-module-tests.ts create mode 100644 prismjs/tslint.json diff --git a/prismjs/index.d.ts b/prismjs/index.d.ts index c3bbffae02..f95cabe990 100644 --- a/prismjs/index.d.ts +++ b/prismjs/index.d.ts @@ -1,164 +1,210 @@ -// Type definitions for prism v1.4.4 +// Type definitions for prism 1.6 // Project: http://prismjs.com/ -// Definitions by: Erik Lieben +// Definitions by: Erik Lieben , Andre Wiggins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace PrismJS { +export as namespace Prism; - /** - * The Prism object - */ - interface Prism { +/** + * @deprecated + * Use the Prism namespace directly directly + */ +export as namespace PrismJS; - util: Util; - languages: Languages; - plugins: any; +export const util: Util; +export const languages: Languages; +export const plugins: any; +export const hooks: Hooks; - /** - * This is the most high-level function in Prism’s API. It fetches all the elements that have a .language-xxxx class and then calls Prism.highlightElement() on each one of them. - * - * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting very large chunks of code. False by default. - * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. Mostly useful when async is true, since in that case, the highlighting is done asynchronously. - * @returns void - */ - highlightAll(async: boolean, callback?: (element: Element) => void): void; +/** + * This is the most high-level function in Prism’s API. It fetches all the elements that have a .language-xxxx class and then calls Prism.highlightElement() on each one of them. + * + * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting very large chunks of code. False by default. + * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. Mostly useful when async is true, since in that case, the highlighting is done asynchronously. + * @returns void + */ +export function highlightAll(async: boolean, callback?: (element: Element) => void): void; - /** - * Highlights the code inside a single element. - * - * @param {Element} element - The element containing the code. It must have a class of language-xxxx to be processed, where xxxx is a valid language identifier. - * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting very large chunks of code. False by default. - * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. Mostly useful when async is true, since in that case, the highlighting is done asynchronously. - * @returns void - */ - highlightElement(element: Element, async: boolean, callback?: (element: Element) => void): void; +/** + * Highlights the code inside a single element. + * + * @param {Element} element - The element containing the code. It must have a class of language-xxxx to be processed, where xxxx is a valid language identifier. + * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting very large chunks of code. False by default. + * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. Mostly useful when async is true, since in that case, the highlighting is done asynchronously. + * @returns void + */ +export function highlightElement(element: Element, async: boolean, callback?: (element: Element) => void): void; - /** - * Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language definitions to use, and returns a string with the HTML produced. - * - * @param {string} text - A string with the code to be highlighted. - * @param {LanguageDefinition} grammer - An object containing the tokens to use. Usually a language definition like Prism.languages.markup - * @param {LanguageDefinition} language - * @returns string - The highlighted HTML - */ - highlight(text: string, grammer: LanguageDefinition, language?: LanguageDefinition): string; +/** + * Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language definitions to use, and returns a string with the HTML produced. + * + * @param {string} text - A string with the code to be highlighted. + * @param {LanguageDefinition} grammer - An object containing the tokens to use. Usually a language definition like Prism.languages.markup + * @param {LanguageDefinition} language + * @returns string - The highlighted HTML + */ +export function highlight(text: string, grammer: LanguageDefinition, language?: LanguageDefinition): string; - /** - * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input and the language definitions to use, - * and returns an array with the tokenized code. When the language definition includes nested tokens, the function is called recursively on each of - * these tokens. This method could be useful in other contexts as well, as a very crude parser. - * - * @param {string} text - A string with the code to be highlighted. - * @param {LanguageDefinition} grammar - An object containing the tokens to use. Usually a language definition like Prism.languages.markup - * @param {LanguageDefinition} language - * @returns Array - An array of strings, tokens (class Prism.Token) and other arrays. - */ - tokenize(text: string, grammar: LanguageDefinition, language?: LanguageDefinition): Array; +/** + * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input and the language definitions to use, + * and returns an array with the tokenized code. When the language definition includes nested tokens, the function is called recursively on each of + * these tokens. This method could be useful in other contexts as well, as a very crude parser. + * + * @param {string} text - A string with the code to be highlighted. + * @param {LanguageDefinition} grammar - An object containing the tokens to use. Usually a language definition like Prism.languages.markup + * @returns Array - An array of strings, tokens (class Prism.Token) and other arrays. + */ +export function tokenize(text: string, grammar: LanguageDefinition): Array; - fileHighlight(): void; +export function fileHighlight(): void; - hooks: Hooks; - } - - interface Environment { - element?: Element; - language?: LanguageDefinition; - grammer?: any; - code?: any; - highlightedCode?: any; - type?: string; - content?:string; - tag?: string; - classes?: Array; - attributes?: Array | Object; - parent?: Element; - } - - interface Identifier { - value: number; - } - - interface Util { - encode(tokens:Token | Array | string): Token | Array | string; - type(o: Object): string; - objId(obj: Object): Identifier; - clone(o: LanguageDefinition): LanguageDefinition; - } - - interface LanguageDefinition { - keyword?: RegExp | LanguageDefinition; - number?: RegExp | LanguageDefinition; - function?: RegExp | LanguageDefinition; - string?: RegExp | LanguageDefinition; - boolean?: RegExp | LanguageDefinition; - operator?: RegExp | LanguageDefinition; - punctuation?: RegExp | LanguageDefinition; - atrule?: RegExp | LanguageDefinition; - url?: RegExp | LanguageDefinition; - selector?: RegExp | LanguageDefinition; - property?: RegExp | LanguageDefinition; - important?: RegExp | LanguageDefinition; - style?: RegExp | LanguageDefinition; - - /** - * This option can be used to define one or more aliases for the matched token. The result will be, that the styles - * of the token and its aliases are combined. This can be useful, to combine the styling of a well known token, - * which is already supported by most of the themes, with a semantically correct token name. The option can be - * set to a string literal or an array of string literals. In the following example the token name latex-equation - * is not supported by any theme, but it will be highlighted the same as a string. - */ - alias?: string; - - pattern?: RegExp; - - /** - * This option mitigates JavaScript’s lack of lookbehind. When set to true, the first capturing group in the regex - * pattern is discarded when matching this token, so it effectively behaves as if it was lookbehind - */ - lookbehind?: boolean; - - /** - * This property accepts another object literal, with tokens that are allowed to be nested in this token. - * This makes it easier to define certain languages. However, keep in mind that they’re slower and if coded poorly, - * can even result in infinite recursion. For an example of nested tokens, check out the Markup language definition - */ - inside?: LanguageDefinition; - - /** - * Accepts an object literal with tokens and appends them to the end of the current object literal. - */ - rest?: Array; - } - - interface Languages extends Array { - - extend(id: string, redef: LanguageDefinition): LanguageDefinition; - - /** - * Insert a token before another token in a language literal - * As this needs to recreate the object (we cannot actually insert before keys in object literals), - * we cannot just provide an object, we need anobject and a key. - * @param inside The key (or language id) of the parent - * @param before The key to insert before. If not provided, the function appends instead. - * @param insert Object with the key/value pairs to insert - * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted. - */ - insertBefore(inside: string, before: string, insert: LanguageDefinition, root: Object): any; - } - - interface Hooks { - all: Array void>>; - add(name: string, callback: (env: Environment) => void):void; - run(name: string, env: Environment): void; - } - - interface Token { - type: string; - content: Token | Array | string; - alias: string; - stringify(o:string| Array, language: LanguageDefinition, parent: HTMLPreElement): string; - } +interface Environment { + element?: Element; + language?: LanguageDefinition; + grammar?: any; + code?: any; + highlightedCode?: any; + type?: string; + content?: string; + tag?: string; + classes?: string[]; + attributes?: any; + parent?: Element; } -declare var Prism : PrismJS.Prism; \ No newline at end of file +interface Identifier { + value: number; +} + +interface Util { + /** Encode raw strings in tokens in preparation to display as HTML */ + encode(tokens: TokenNode): TokenNode; + + /** Determine the type of the object */ + type(o: any): string; + + /** Get the unique id of this object or give it one if it does not have one */ + objId(obj: any): Identifier; + + /** Deep clone a language definition (e.g. to extend it) */ + clone(o: LanguageDefinition): LanguageDefinition; +} + +interface LanguageDefinition { + keyword?: RegExp | LanguageDefinition; + number?: RegExp | LanguageDefinition; + function?: RegExp | LanguageDefinition; + string?: RegExp | LanguageDefinition; + boolean?: RegExp | LanguageDefinition; + operator?: RegExp | LanguageDefinition; + punctuation?: RegExp | LanguageDefinition; + atrule?: RegExp | LanguageDefinition; + url?: RegExp | LanguageDefinition; + selector?: RegExp | LanguageDefinition; + property?: RegExp | LanguageDefinition; + important?: RegExp | LanguageDefinition; + style?: RegExp | LanguageDefinition; + + /** + * This option can be used to define one or more aliases for the matched token. The result will be, that the styles + * of the token and its aliases are combined. This can be useful, to combine the styling of a well known token, + * which is already supported by most of the themes, with a semantically correct token name. The option can be + * set to a string literal or an array of string literals. In the following example the token name latex-equation + * is not supported by any theme, but it will be highlighted the same as a string. + */ + alias?: string; + + pattern?: RegExp; + + /** + * This option mitigates JavaScript’s lack of lookbehind. When set to true, the first capturing group in the regex + * pattern is discarded when matching this token, so it effectively behaves as if it was lookbehind + */ + lookbehind?: boolean; + + /** + * This property accepts another object literal, with tokens that are allowed to be nested in this token. + * This makes it easier to define certain languages. However, keep in mind that they’re slower and if coded poorly, + * can even result in infinite recursion. For an example of nested tokens, check out the Markup language definition + */ + inside?: LanguageDefinition; + + /** + * Accepts an object literal with tokens and appends them to the end of the current object literal. + */ + rest?: Token[]; +} + +interface Languages { + + /** Get a defined language's definition */ + [key: string]: LanguageDefinition; + + /** + * Extend a language definition + * @param id The language definition to extend + * @param redef The new language definition to extend the original + */ + extend(id: string, redef: LanguageDefinition): LanguageDefinition; + + /** + * Insert a token before another token in a language literal + * As this needs to recreate the object (we cannot actually insert before keys in object literals), + * we cannot just provide an object, we need anobject and a key. + * @param inside The key (or language id) of the parent + * @param before The key to insert before. If not provided, the function appends instead. + * @param insert Object with the key/value pairs to insert + * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted. + */ + insertBefore(inside: string, before: string, insert: LanguageDefinition, root: LanguageDefinition): any; +} + +type HookCallback = (env: Environment) => void; +type AvailableHooks = "before-highlightall" + | "before-sanity-check" + | "before-highlight" + | "before-insert" + | "after-highlight" + | "complete" + | "wrap"; + +interface Hooks { + all: Array void>>; + + add(name: AvailableHooks | string, callback: HookCallback): void; + + run(name: AvailableHooks | string, env: Environment): void; +} + +type TokenNode = Token | string | Array; + +export class Token { + /** + * Given a token or string input, convert it to highlighted HTML + * @param type The token(s) to stringify + * @param language The language definition that understands the given token(s) + * @param parent The parent element element to pass into hook callbacks + * @returns The HTML that represents the given token(s) + */ + static stringify(token: TokenNode, language: LanguageDefinition, parent: HTMLPreElement): string; + + /** + * The constructor for the Prism Token class + * @param type The type of the token + * @param content The contents of the token + * @param alias Aliases for the current token (added as classes to this token's HTML) + * @param matchedStr The matched string that generated this token + * @param greedy Value that determines whether or not this token was generated using a greedy parsing algorithm + */ + constructor(type: string, content: TokenNode, alias: any, matchedStr: string, greedy: boolean); + + /** The type of the token */ + type: string; + + /** The content of the token */ + content: TokenNode; + + /** Other names for this token (added as classes to this token's HTML) */ + alias: string; +} diff --git a/prismjs/prismjs-module-tests.ts b/prismjs/prismjs-module-tests.ts new file mode 100644 index 0000000000..3c48e476c5 --- /dev/null +++ b/prismjs/prismjs-module-tests.ts @@ -0,0 +1,26 @@ +import * as Prism from "prismjs"; + +var element = document.createElement("code"); +var callback = (element: Element) => console.log(element); + +Prism.highlightElement(element, false, callback); +Prism.highlightElement(element, false); +Prism.highlightAll(true, callback); +Prism.highlightAll(true); + +const hookCallback: Prism.HookCallback = env => null; +Prism.hooks.add("before-highlightall", hookCallback); +Prism.hooks.add("future-hook", hookCallback); + +var language = "js"; +var tokens = Prism.tokenize("var n = 1;", Prism.languages[language]); +(function visit(token: Prism.TokenNode): Prism.TokenNode { + if (typeof token === "string") { + return token; + } else if (Array.isArray(token)) { + return token.map(visit) as Prism.TokenNode; + } else { + token.alias += "visited"; + return token; + } +})(tokens); diff --git a/prismjs/prismjs-tests.ts b/prismjs/prismjs-tests.ts index 6d87b9b217..feadde4c51 100644 --- a/prismjs/prismjs-tests.ts +++ b/prismjs/prismjs-tests.ts @@ -1,5 +1,3 @@ - - var element = document.createElement("code"); var callback = (element: Element) => console.log(element); @@ -8,3 +6,19 @@ Prism.highlightElement(element, false); Prism.highlightAll(true, callback); Prism.highlightAll(true); +const hookCallback: PrismJS.HookCallback = env => null; +Prism.hooks.add("before-highlightall", hookCallback); +Prism.hooks.add("future-hook", hookCallback); + +var language = "js"; +var tokens = Prism.tokenize("var n = 1;", Prism.languages[language]); +(function visit(token: PrismJS.TokenNode): PrismJS.TokenNode { + if (typeof token === "string") { + return token; + } else if (Array.isArray(token)) { + return token.map(visit) as PrismJS.TokenNode; + } else { + token.alias += "visited"; + return token; + } +})(tokens); diff --git a/prismjs/tsconfig.json b/prismjs/tsconfig.json index b01a635b30..5a528ed4a4 100644 --- a/prismjs/tsconfig.json +++ b/prismjs/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -18,6 +18,7 @@ }, "files": [ "index.d.ts", - "prismjs-tests.ts" + "prismjs-tests.ts", + "prismjs-module-tests.ts" ] -} \ No newline at end of file +} diff --git a/prismjs/tslint.json b/prismjs/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/prismjs/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 9a6a2e54636f2dbd365892945409323bfc76e203 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Mon, 20 Feb 2017 05:57:33 -0800 Subject: [PATCH 070/258] Remove extra module import test --- prismjs/prismjs-module-tests.ts | 26 -------------------------- prismjs/prismjs-tests.ts | 6 +++--- prismjs/tsconfig.json | 3 +-- 3 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 prismjs/prismjs-module-tests.ts diff --git a/prismjs/prismjs-module-tests.ts b/prismjs/prismjs-module-tests.ts deleted file mode 100644 index 3c48e476c5..0000000000 --- a/prismjs/prismjs-module-tests.ts +++ /dev/null @@ -1,26 +0,0 @@ -import * as Prism from "prismjs"; - -var element = document.createElement("code"); -var callback = (element: Element) => console.log(element); - -Prism.highlightElement(element, false, callback); -Prism.highlightElement(element, false); -Prism.highlightAll(true, callback); -Prism.highlightAll(true); - -const hookCallback: Prism.HookCallback = env => null; -Prism.hooks.add("before-highlightall", hookCallback); -Prism.hooks.add("future-hook", hookCallback); - -var language = "js"; -var tokens = Prism.tokenize("var n = 1;", Prism.languages[language]); -(function visit(token: Prism.TokenNode): Prism.TokenNode { - if (typeof token === "string") { - return token; - } else if (Array.isArray(token)) { - return token.map(visit) as Prism.TokenNode; - } else { - token.alias += "visited"; - return token; - } -})(tokens); diff --git a/prismjs/prismjs-tests.ts b/prismjs/prismjs-tests.ts index feadde4c51..137dad7ece 100644 --- a/prismjs/prismjs-tests.ts +++ b/prismjs/prismjs-tests.ts @@ -6,17 +6,17 @@ Prism.highlightElement(element, false); Prism.highlightAll(true, callback); Prism.highlightAll(true); -const hookCallback: PrismJS.HookCallback = env => null; +const hookCallback: Prism.HookCallback = env => null; Prism.hooks.add("before-highlightall", hookCallback); Prism.hooks.add("future-hook", hookCallback); var language = "js"; var tokens = Prism.tokenize("var n = 1;", Prism.languages[language]); -(function visit(token: PrismJS.TokenNode): PrismJS.TokenNode { +(function visit(token: Prism.TokenNode): Prism.TokenNode { if (typeof token === "string") { return token; } else if (Array.isArray(token)) { - return token.map(visit) as PrismJS.TokenNode; + return token.map(visit) as Prism.TokenNode; } else { token.alias += "visited"; return token; diff --git a/prismjs/tsconfig.json b/prismjs/tsconfig.json index 5a528ed4a4..0bd8440986 100644 --- a/prismjs/tsconfig.json +++ b/prismjs/tsconfig.json @@ -18,7 +18,6 @@ }, "files": [ "index.d.ts", - "prismjs-tests.ts", - "prismjs-module-tests.ts" + "prismjs-tests.ts" ] } From 6b90165d6011d9f5149c294a0b5d6178c9b6a3b2 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Fri, 10 Mar 2017 17:40:45 -0800 Subject: [PATCH 071/258] Rewrap long comments --- prismjs/index.d.ts | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/prismjs/index.d.ts b/prismjs/index.d.ts index f95cabe990..14197acf73 100644 --- a/prismjs/index.d.ts +++ b/prismjs/index.d.ts @@ -6,8 +6,7 @@ export as namespace Prism; /** - * @deprecated - * Use the Prism namespace directly directly + * @deprecated Use the Prism namespace directly directly */ export as namespace PrismJS; @@ -17,10 +16,13 @@ export const plugins: any; export const hooks: Hooks; /** - * This is the most high-level function in Prism’s API. It fetches all the elements that have a .language-xxxx class and then calls Prism.highlightElement() on each one of them. + * This is the most high-level function in Prism’s API. It fetches all the elements that have a .language-xxxx class and + * then calls Prism.highlightElement() on each one of them. * - * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting very large chunks of code. False by default. - * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. Mostly useful when async is true, since in that case, the highlighting is done asynchronously. + * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when + * highlighting very large chunks of code. False by default. + * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. + * Mostly useful when async is true, since in that case, the highlighting is done asynchronously. * @returns void */ export function highlightAll(async: boolean, callback?: (element: Element) => void): void; @@ -28,31 +30,38 @@ export function highlightAll(async: boolean, callback?: (element: Element) => vo /** * Highlights the code inside a single element. * - * @param {Element} element - The element containing the code. It must have a class of language-xxxx to be processed, where xxxx is a valid language identifier. - * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting very large chunks of code. False by default. - * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. Mostly useful when async is true, since in that case, the highlighting is done asynchronously. + * @param {Element} element - The element containing the code. It must have a class of language-xxxx to be processed, + * where xxxx is a valid language identifier. + * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when + * highlighting very large chunks of code. False by default. + * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. + * Mostly useful when async is true, since in that case, the highlighting is done asynchronously. * @returns void */ export function highlightElement(element: Element, async: boolean, callback?: (element: Element) => void): void; /** - * Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language definitions to use, and returns a string with the HTML produced. + * Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language + * definitions to use, and returns a string with the HTML produced. * * @param {string} text - A string with the code to be highlighted. - * @param {LanguageDefinition} grammer - An object containing the tokens to use. Usually a language definition like Prism.languages.markup + * @param {LanguageDefinition} grammer - An object containing the tokens to use. Usually a language definition like + * Prism.languages.markup * @param {LanguageDefinition} language * @returns string - The highlighted HTML */ export function highlight(text: string, grammer: LanguageDefinition, language?: LanguageDefinition): string; /** - * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input and the language definitions to use, - * and returns an array with the tokenized code. When the language definition includes nested tokens, the function is called recursively on each of - * these tokens. This method could be useful in other contexts as well, as a very crude parser. + * This is the heart of Prism, and the most low-level function you can use. It accepts a string of text as input and the + * language definitions to use, and returns an array with the tokenized code. When the language definition includes + * nested tokens, the function is called recursively on each of these tokens. This method could be useful in other + * contexts as well, as a very crude parser. * * @param {string} text - A string with the code to be highlighted. - * @param {LanguageDefinition} grammar - An object containing the tokens to use. Usually a language definition like Prism.languages.markup + * @param {LanguageDefinition} grammar - An object containing the tokens to use. Usually a language definition like + * Prism.languages.markup * @returns Array - An array of strings, tokens (class Prism.Token) and other arrays. */ export function tokenize(text: string, grammar: LanguageDefinition): Array; From f403fb6bdda69f1e720c914e56da1cf37540c9d2 Mon Sep 17 00:00:00 2001 From: Andre Wiggins Date: Fri, 10 Mar 2017 17:58:22 -0800 Subject: [PATCH 072/258] Clean up comments --- prismjs/index.d.ts | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/prismjs/index.d.ts b/prismjs/index.d.ts index 14197acf73..531dfe9b8f 100644 --- a/prismjs/index.d.ts +++ b/prismjs/index.d.ts @@ -19,24 +19,22 @@ export const hooks: Hooks; * This is the most high-level function in Prism’s API. It fetches all the elements that have a .language-xxxx class and * then calls Prism.highlightElement() on each one of them. * - * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when - * highlighting very large chunks of code. False by default. - * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. - * Mostly useful when async is true, since in that case, the highlighting is done asynchronously. - * @returns void + * @param {boolean} async Whether to use Web Workers to improve performance and avoid blocking the UI when highlighting + * very large chunks of code. False by default. + * @param {Function} callback An optional callback to be invoked after the highlighting is done. Mostly useful when async + * is true, since in that case, the highlighting is done asynchronously. */ export function highlightAll(async: boolean, callback?: (element: Element) => void): void; /** * Highlights the code inside a single element. * - * @param {Element} element - The element containing the code. It must have a class of language-xxxx to be processed, + * @param {Elment} element The element containing the code. It must have a class of language-xxxx to be processed, * where xxxx is a valid language identifier. - * @param {boolean} async - Whether to use Web Workers to improve performance and avoid blocking the UI when + * @param {boolean} async Whether to use Web Workers to improve performance and avoid blocking the UI when * highlighting very large chunks of code. False by default. - * @param {(element:Element)=>void} callback? - An optional callback to be invoked after the highlighting is done. + * @param {Function} callback An optional callback to be invoked after the highlighting is done. * Mostly useful when async is true, since in that case, the highlighting is done asynchronously. - * @returns void */ export function highlightElement(element: Element, async: boolean, callback?: (element: Element) => void): void; @@ -45,11 +43,11 @@ export function highlightElement(element: Element, async: boolean, callback?: (e * Low-level function, only use if you know what you’re doing. It accepts a string of text as input and the language * definitions to use, and returns a string with the HTML produced. * - * @param {string} text - A string with the code to be highlighted. - * @param {LanguageDefinition} grammer - An object containing the tokens to use. Usually a language definition like + * @param {string} text A string with the code to be highlighted. + * @param {LanguageDefinition} grammer - An object containing the tokens to use. Usually a language definition like * Prism.languages.markup - * @param {LanguageDefinition} language - * @returns string - The highlighted HTML + * @param {LanguageDefinition} language + * @returns {string} The highlighted HTML */ export function highlight(text: string, grammer: LanguageDefinition, language?: LanguageDefinition): string; @@ -59,10 +57,10 @@ export function highlight(text: string, grammer: LanguageDefinition, language?: * nested tokens, the function is called recursively on each of these tokens. This method could be useful in other * contexts as well, as a very crude parser. * - * @param {string} text - A string with the code to be highlighted. - * @param {LanguageDefinition} grammar - An object containing the tokens to use. Usually a language definition like + * @param {string} text A string with the code to be highlighted. + * @param {LanguageDefinition} grammar An object containing the tokens to use. Usually a language definition like * Prism.languages.markup - * @returns Array - An array of strings, tokens (class Prism.Token) and other arrays. + * @returns {Array} An array of strings, tokens (class Prism.Token) and other arrays. */ export function tokenize(text: string, grammar: LanguageDefinition): Array; From 5dc3a5eb9caab465735a863f8d53feaa9e09dc68 Mon Sep 17 00:00:00 2001 From: Jan Alonzo Date: Sat, 11 Mar 2017 16:04:46 +1100 Subject: [PATCH 073/258] Remove localforage folder --- localforage/package.json | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 localforage/package.json diff --git a/localforage/package.json b/localforage/package.json deleted file mode 100644 index 29f45814b2..0000000000 --- a/localforage/package.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "dependencies": { - "localforage": ">=1.5.0" - } -} From 6969dc0304f5e55d8408db7b8bc108d84da4f4c0 Mon Sep 17 00:00:00 2001 From: rzymek Date: Wed, 1 Mar 2017 22:57:24 +0100 Subject: [PATCH 074/258] lodash - Add _.nth --- lodash/index.d.ts | 51 ++++++++++++++++++++++++++++++++++++++++++ lodash/lodash-tests.ts | 31 +++++++++++++++++++++++++ lodash/nth/index.d.ts | 2 ++ lodash/tsconfig.json | 3 ++- 4 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 lodash/nth/index.d.ts diff --git a/lodash/index.d.ts b/lodash/index.d.ts index da5710a7de..0acf1d8726 100644 --- a/lodash/index.d.ts +++ b/lodash/index.d.ts @@ -2679,6 +2679,57 @@ declare namespace _ { ): LoDashExplicitWrapper; } + //_.nth + interface LoDashStatic { + /** + * Gets the element at index `n` of `array`. If `n` is negative, the nth element from the end is returned. + * + * @param array array The array to query. + * @param value The index of the element to return. + * @return Returns the nth element of `array`. + */ + nth( + array: List, + n?: number + ): T; + } + + interface LoDashImplicitArrayWrapper { + /** + * @see _.nth + */ + nth( + n?: number + ): T; + } + + interface LoDashImplicitObjectWrapper { + /** + * @see _.nth + */ + nth( + n?:number + ): TResult; + } + + interface LoDashExplicitArrayWrapper { + /** + * @see _.nth + */ + nth( + n?:number + ): LoDashExplicitWrapper; + } + + interface LoDashExplicitObjectWrapper { + /** + * @see _.nth + */ + nth( + n?:number + ): LoDashExplicitWrapper; + } + //_.pull interface LoDashStatic { /** diff --git a/lodash/lodash-tests.ts b/lodash/lodash-tests.ts index 8accba65c0..2f5cf2ac57 100644 --- a/lodash/lodash-tests.ts +++ b/lodash/lodash-tests.ts @@ -1289,6 +1289,37 @@ namespace TestLastIndexOf { } } +// _.nth +namespace TestNth { + let array: TResult[]; + let list: _.List; + let value: number; + + { + let result: TResult; + + result = _.nth(array); + + result = _.nth(array, 42); + + result = _(array).nth(); + result = _(array).nth(42); + + result = _(list).nth(); + result = _(list).nth(42); + } + + { + let result: _.LoDashExplicitWrapper; + + result = _(array).chain().nth(); + result = _(array).chain().nth(42); + + result = _(list).chain().nth(); + result = _(list).chain().nth(42); + } +} + // _.pull namespace TestPull { let array: TResult[]; diff --git a/lodash/nth/index.d.ts b/lodash/nth/index.d.ts new file mode 100644 index 0000000000..afbe952398 --- /dev/null +++ b/lodash/nth/index.d.ts @@ -0,0 +1,2 @@ +import { nth } from "../index"; +export = nth; \ No newline at end of file diff --git a/lodash/tsconfig.json b/lodash/tsconfig.json index 3a760cfd1a..419b6142b1 100644 --- a/lodash/tsconfig.json +++ b/lodash/tsconfig.json @@ -171,6 +171,7 @@ "noConflict/index.d.ts", "noop/index.d.ts", "now/index.d.ts", + "nth/index.d.ts", "nthArg/index.d.ts", "omit/index.d.ts", "omitBy/index.d.ts", @@ -306,4 +307,4 @@ "noEmit": true, "forceConsistentCasingInFileNames": true } -} \ No newline at end of file +} From 8fcc61d878839c2166a9ededf4cda7aced43a030 Mon Sep 17 00:00:00 2001 From: Federico Caselli Date: Thu, 23 Feb 2017 19:41:04 +0100 Subject: [PATCH 075/258] Added export for nodejs Closes #14815 --- jointjs/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jointjs/index.d.ts b/jointjs/index.d.ts index 95e2b2b7e3..cd9d722ec5 100644 --- a/jointjs/index.d.ts +++ b/jointjs/index.d.ts @@ -6,6 +6,9 @@ /// +declare module "jointjs" { + export = joint; +} declare namespace joint { export var g: any; From 8dd3e03bedbb3e94a25761ab5cfea65b4b728abb Mon Sep 17 00:00:00 2001 From: CaselIT Date: Thu, 23 Feb 2017 20:45:45 +0100 Subject: [PATCH 076/258] Changed to export as namespace --- jointjs/index.d.ts | 1684 ++++++++++++++++++++++---------------------- rappid/index.d.ts | 49 +- 2 files changed, 867 insertions(+), 866 deletions(-) diff --git a/jointjs/index.d.ts b/jointjs/index.d.ts index cd9d722ec5..5ce0f187f0 100644 --- a/jointjs/index.d.ts +++ b/jointjs/index.d.ts @@ -6,894 +6,892 @@ /// -declare module "jointjs" { - export = joint; +import * as Backbone from "backbone"; + +export as namespace joint; + +export var g: any; +export var V: any; + +export namespace dia { + interface Size { + width: number; + height: number; + } + + interface Point { + x: number; + y: number; + } + + interface BBox extends Point, Size { } + + interface TranslateOptions { + restrictedArea?: BBox; + transition?: TransitionOptions; + } + + interface TransitionOptions { + delay?: number; + duration?: number; + timingFunction?: (t: number) => number; + valueFunction?: (a: any, b: any) => (t: number) => any; + } + + interface DfsBfsOptions { + inbound?: boolean; + outbound?: boolean; + deep?: boolean; + } + + interface ExploreOptions { + breadthFirst?: boolean; + deep?: boolean; + } + + class Graph extends Backbone.Model { + constructor(attributes?: any, options?: { cellNamespace: any }); + addCell(cell: Cell | Cell[]): this; + addCells(cells: Cell[]): this; + resetCells(cells: Cell[], options?: any): this; + getCell(id: string): Cell; + getElements(): Element[]; + getLinks(): Link[]; + getCells(): Cell[]; + getFirstCell(): Cell; + getLastCell(): Cell; + getConnectedLinks(element: Cell, options?: { inbound?: boolean, outbound?: boolean, deep?: boolean }): Link[]; + disconnectLinks(cell: Cell, options?: any): void; + removeLinks(cell: Cell, options?: any): void; + translate(tx: number, ty?: number, options?: TranslateOptions): void; + cloneCells(cells: Cell[]): { [id: string]: Cell }; + getSubgraph(cells: Cell[], options?: { deep?: boolean }): Cell[]; + cloneSubgraph(cells: Cell[], options?: { deep?: boolean }): { [id: string]: Cell }; + dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions, visited?: Object, distance?: number): void; + bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions): void; + search(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: { breadthFirst?: boolean }): void; + getSuccessors(element: Element, options?: ExploreOptions): Element[]; + getPredecessors(element: Element, options?: ExploreOptions): Element[]; + isSuccessor(elementA: Element, elementB: Element): boolean; + isPredecessor(elementA: Element, elementB: Element): boolean; + isSource(element: Element): boolean; + isSink(element: Element): boolean; + getSources(): Element[]; + getSinks(): Element[]; + getNeighbors(element: Element, options?: DfsBfsOptions): Element[]; + isNeighbor(elementA: Element, elementB: Element, options?: { inbound?: boolean, outbound?: boolean; }): boolean; + getCommonAncestor(...cells: Cell[]): Element; + toJSON(): any; + fromJSON(json: any, options?: any): this; + clear(options?: any): this; + findModelsFromPoint(rect: BBox): Element[]; + findModelsUnderElement(element: Element, options?: { searchBy?: 'bbox' | 'center' | 'origin' | 'corner' | 'topRight' | 'bottomLeft' }): Element[]; + getBBox(elements: Element[], options?: any): BBox; + toGraphLib(): any; // graphlib graph object + findModelsInArea(rect: BBox, options?: any): BBox | boolean; + getCellsBBox(cells: Cell[], options?: any): BBox; + getInboundEdges(node: string): Object; + getOutboundEdges(node: string): Object; + hasActiveBatch(name?: string): number | boolean; + maxZIndex(): number; + removeCells(cells: Cell[], options?: any): this; + resize(width: number, height: number, options?: number): this; + resizeCells(width: number, height: number, cells: Cell[], options?: number): this; + set(key: Object | string, value: any, options?: any): this; + startBatch(name: string, data?: Object): any; + stopBatch(name: string, data?: Object): any; + } + + class Cell extends Backbone.Model { + id: string; + toJSON(): any; + remove(options?: { disconnectLinks?: boolean }): this; + toFront(options?: { deep?: boolean }): this; + toBack(options?: { deep?: boolean }): this; + getAncestors(): Cell[]; + isEmbeddedIn(element: Element, options?: { deep: boolean }): boolean; + prop(key: string): any; + prop(object: any): this; + prop(key: string, value: any, options?: any): this; + removeProp(path: string, options?: any): this; + attr(key: string): any; + attr(object: SVGAttributes): this; + attr(key: string, value: any): this; + clone(): Cell; + clone(opt: { deep?: boolean }): Cell | Cell[]; + removeAttr(path: string | string[], options?: any): this; + transition(path: string, value?: any, options?: TransitionOptions, delim?: string): number; + getTransitions(): string[]; + stopTransitions(path?: string, delim?: string): this; + addTo(graph: Graph, options?: any): this; + isLink(): boolean; + embed(cell: Cell, options?: any): this; + findView(paper: Paper): CellView; + getEmbeddedCells(options?: any): Cell[]; + initialize(options?: any): void; + isElement(): boolean; + isEmbedded(): boolean; + processPorts(): void; + startBatch(name: string, options?: any): this; + stopBatch(name: string, options?: any): this; + unembed(cell: Cell, options?: any): this; + } + + type Padding = number | { + top?: number; + right?: number; + bottom?: number; + left?: number + }; + + class Element extends Cell { + translate(tx: number, ty?: number, options?: TranslateOptions): this; + position(options?: { parentRelative: boolean }): Point; + position(x: number, y: number, options?: { parentRelative?: boolean }): this; + resize(width: number, height: number, options?: { direction?: 'left' | 'right' | 'top' | 'bottom' | 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right' }): this; + rotate(deg: number, absolute?: boolean, origin?: Point): this; + embed(cell: Cell): this; + unembed(cell: Cell): this; + getEmbeddedCells(options?: ExploreOptions): Cell[]; + fitEmbeds(options?: { deep?: boolean, padding?: Padding }): this; + getBBox(options?: any): BBox; + findView(paper: Paper): ElementView; + isElement(): boolean; + scale(scaleX: number, scaleY: number, origin?: Point, options?: any): this; + addPort(port: any, opt?: any): this; + addPorts(ports: any[], opt?: any): this; + removePort(port: any, opt?: any): this; + hasPorts(): boolean; + hasPort(id: string): boolean; + getPorts(): any[]; + getPort(id: string): any; + getPortIndex(port: any): number; + portProp(portId: string, path: any, value?: any, opt?: any): joint.dia.Element; + } + + interface CSSSelector { + [key: string]: string | number | Object; // Object added to support special attributes like filter http://jointjs.com/api#SpecialAttributes:filter + } + + interface SVGAttributes { + [selector: string]: CSSSelector; + } + + interface CellAttributes { + [key: string]: any; + } + + interface TextAttrs extends SVGAttributes { + text?: { + [key: string]: string | number; + text?: string; + }; + } + + interface Label { + position: number; + attrs?: TextAttrs; + } + interface LinkAttributes extends CellAttributes { + source?: Point | { id: string, selector?: string, port?: string }; + target?: Point | { id: string, selector?: string, port?: string }; + labels?: Label[]; + vertices?: Point[]; + smooth?: boolean; + attrs?: TextAttrs; + z?: number; + } + + class Link extends Cell { + markup: string; + labelMarkup: string; + toolMakup: string; + vertexMarkup: string; + arrowHeadMarkup: string; + + constructor(attributes?: LinkAttributes, options?: Object); + disconnect(): this; + label(index?: number): any; + label(index: number, value: Label): this; + reparent(options?: any): Element; + findView(paper: Paper): LinkView; + getSourceElement(): Element; + getTargetElement(): Element; + hasLoop(options?: { deep?: boolean }): boolean; + applyToPoints(fn: Function, options?: any): this; + getRelationshipAncestor(): Element; + isLink(): boolean; + isRelationshipEmbeddedIn(element: Element): boolean; + scale(sx: number, sy: number, origin: Point, optionts?: any): this; + translate(tx: number, ty: number, options?: any): this; + } + + interface ManhattanRouterArgs { + excludeTypes?: string[]; + excludeEnds?: 'source' | 'target'; + startDirections?: ['left' | 'right' | 'top' | 'bottom']; + endDirections?: ['left' | 'right' | 'top' | 'bottom']; + } + + interface PaperOptions extends Backbone.ViewOptions { + el?: string | JQuery | HTMLElement; + width?: number; + height?: number; + origin?: Point; + gridSize?: number; + perpendicularLinks?: boolean; + elementView?: (element: Element) => ElementView | ElementView; + linkView?: (link: Link) => LinkView | LinkView; + defaultLink?: ((cellView: CellView, magnet: SVGElement) => Link) | Link; + defaultRouter?: ((vertices: Point[], args: Object, linkView: LinkView) => Point[]) | { name: string, args?: ManhattanRouterArgs }; + defaultConnector?: ((sourcePoint: Point, targetPoint: Point, vertices: Point[], args: Object, linkView: LinkView) => string) | { name: string, args?: { radius?: number } }; + interactive?: ((cellView: CellView, event: string) => boolean) | boolean | { vertexAdd?: boolean, vertexMove?: boolean, vertexRemove?: boolean, arrowheadMove?: boolean }; + validateMagnet?: (cellView: CellView, magnet: SVGElement) => boolean; + validateConnection?: (cellViewS: CellView, magnetS: SVGElement, cellViewT: CellView, magnetT: SVGElement, end: 'source' | 'target', linkView: LinkView) => boolean; + linkConnectionPoint?: (linkView: LinkView, view: ElementView, magnet: SVGElement, reference: Point) => Point; + snapLinks?: boolean | { radius: number }; + linkPinning?: boolean; + markAvailable?: boolean; + async?: boolean | { batchZise: number }; + embeddingMode?: boolean; + validateEmbedding?: (childView: ElementView, parentView: ElementView) => boolean; + restrictTranslate?: ((elementView: ElementView) => BBox) | boolean; + guard?: (evt: Event, view: CellView) => boolean; + multiLinks?: boolean; + cellViewNamespace?: Object; + /** useful undocumented option */ + clickThreshold?: number; + highlighting?: any; + } + + interface ScaleContentOptions { + padding?: number; + preserveAspectRatio?: boolean; + minScale?: number; + minScaleX?: number; + minScaleY?: number; + maxScale?: number; + maxScaleX?: number; + maxScaleY?: number; + scaleGrid?: number; + fittingBBox?: BBox; + } + + interface FitToContentOptions { + gridWidth?: number; + gridHeight?: number; + padding?: Padding; + allowNewOrigin?: 'negative' | 'positive' | 'any'; + minWidth?: number; + minHeight?: number; + maxWidth?: number; + maxHeight?: number; + } + + class Paper extends Backbone.View { + constructor(options?: PaperOptions); + options: PaperOptions; + svg: SVGElement; + viewport: SVGGElement; + defs: SVGDefsElement; + setDimensions(width: number, height: number): void; + setOrigin(x: number, y: number): void; + scale(sx: number, sy?: number, ox?: number, oy?: number): this; + findView(element: any): CellView; + findViewByModel(model: Cell | string): CellView; + findViewsFromPoint(point: Point): ElementView[]; + findViewsInArea(rect: BBox, options?: { strict?: boolean }): CellView[]; + fitToContent(options?: FitToContentOptions): void; + scaleContentToFit(options?: ScaleContentOptions): void; + getContentBBox(): BBox; + clientToLocalPoint(p: Point): Point; + + rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already + + afterRenderViews(): void; + asyncRenderViews(cells: Cell[], options?: any): void; + beforeRenderViews(cells: Cell[]): Cell[]; + cellMouseout(evt: Event): void; + cellMouseover(evt: Event): void; + clearGrid(): this; + contextmenu(evt: Event): void; + createViewForModel(cell: Cell): CellView; + drawGrid(options?: any): this; + fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, options?: any): void; + getArea(): BBox; + getDefaultLink(cellView: CellView, magnet: HTMLElement): Link; + getModelById(id: string): Cell; + getRestrictedArea(): BBox; + guard(evt: Event, view: CellView): boolean; + linkAllowed(linkViewOrModel: LinkView | Link): boolean; + mouseclick(evt: Event): void; + mousedblclick(evt: Event): void; + mousewheel(evt: Event): void; + onCellAdded(cell: Cell, graph: Graph, options: Object): void; + onCellHighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; + onCellUnhighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; + onRemove(): void; + pointerdown(evt: Event): void; + pointermove(evt: Event): void; + pointerup(evt: Event): void; + remove(): this; + removeView(cell: Cell): CellView; + removeViews(): void; + renderView(cell: Cell): CellView; + resetViews(cellsCollection: Cell[], options: any): void; + resolveHighlighter(options?: any): boolean | Object; + setGridSize(gridSize: number): this; + setInteractivity(value: any): void; + snapToGrid(p: Point): Point; + sortViews(): void; + } + + + interface GradientOptions { + type: 'linearGradient' | 'radialGradient'; + stops: Array<{ + offset: string; + color: string; + opacity?: number; + }>; + } + class CellViewGeneric extends Backbone.View { + getBBox(options?: { useModelGeometry?: boolean }): BBox; + highlight(el?: any, options?: any): this; + unhighlight(el?: any, options?: any): this; + applyFilter(selector: string | HTMLElement, filter: Object): void; + applyGradient(selector: string | HTMLElement, attr: 'fill' | 'stroke', gradient: GradientOptions): void; + can(feature: string): boolean; + findBySelector(selector: string): JQuery; + findMagnet(el: any): HTMLElement; + getSelector(el: HTMLElement, prevSelector: string): string; + getStrokeBBox(el: any): BBox; // string|HTMLElement|Vectorizer + mouseout(evt: Event): void; + mouseover(evt: Event): void; + mousewheel(evt: Event, x: number, y: number, delta: number): void + notify(eventName: string): void; + onChangeAttrs(cell: Cell, attrs: Backbone.ViewOptions, options?: any): this; + onSetTheme(oldTheme: string, newTheme: string): void; + pointerclick(evt: Event, x: number, y: number): void; + pointerdblclick(evt: Event, x: number, y: number): void; + pointerdown(evt: Event, x: number, y: number): void; + pointermove(evt: Event, x: number, y: number): void; + pointerup(evt: Event, x: number, y: number): void; + remove(): this; + setInteractivity(value: any): void; + setTheme(theme: string, options?: any): this; + } + + class CellView extends CellViewGeneric { } + + interface ElementViewAttributes { + style?: string; + text?: string; + html?: string; + "ref-x"?: string | number; + "ref-y"?: string | number; + "ref-dx"?: number; + "ref-dy"?: number; + "ref-width"?: string | number; + "ref-height"?: string | number; + ref?: string; + "x-alignment"?: 'middle' | 'right' | number; + "y-alignment"?: 'middle' | 'bottom' | number; + port?: string; + } + class ElementView extends CellViewGeneric { + scale(sx: number, sy: number): void; // @todo Documented in source but not released + finalizeEmbedding(options?: any): void; + getBBox(options?: any): BBox; + pointerdown(evt: Event, x: number, y: number): void; + pointermove(evt: Event, x: number, y: number): void; + pointerup(evt: Event, x: number, y: number): void; + positionRelative(vel: any, bbox: BBox, attributes: ElementViewAttributes, nodesBySelector?: Object): void; // Vectorizer + prepareEmbedding(options?: any): void; + processEmbedding(options?: any): void; + render(): this; + renderMarkup(): void; + resize(): void; + rotate(): void; + translate(model: Backbone.Model, changes?: any, options?: any): void; + update(cell: Cell, renderingOnlyAttrs?: Object): void; + } + + class LinkView extends CellViewGeneric { + options: { + shortLinkLength?: number, + doubleLinkTools?: boolean, + longLinkLength?: number, + linkToolsOffset?: number, + doubleLinkToolsOffset?: number, + sampleInterval: number + }; + getConnectionLength(): number; + sendToken(token: SVGElement, duration?: number, callback?: () => void): void; + addVertex(vertex: Point): number; + getPointAtLength(length: number): Point; // Marked as public api in source but not in the documents + createWatcher(endType: { id: string }): Function; + findRoute(oldVertices: Point[]): Point[]; + getConnectionPoint(end: 'source' | 'target', selectorOrPoint: Element | Point, referenceSelectorOrPoint: Element | Point): Point; + getPathData(vertices: Point[]): any; + onEndModelChange(endType: 'source' | 'target', endModel?: Element, opt?: any): void; + onLabelsChange(): void; + onSourceChange(cell: Cell, sourceEnd: { id: string }, options: any): void; + onTargetChange(cell: Cell, targetEnd: { id: string }, options: any): void; + onToolsChange(): void; + onVerticesChange(cell: Cell, changed: any, options: any): void; + pointerdown(evt: Event, x: number, y: number): void; + pointermove(evt: Event, x: number, y: number): void; + pointerup(evt: Event, x: number, y: number): void; + removeVertex(idx: number): this; + render(): this; + renderArrowheadMarkers(): this; + renderLabels(): this; + renderTools(): this; + renderVertexMarkers(): this; + startArrowheadMove(end: 'source' | 'target', options?: any): void; + startListening(): void; + update(model: any, attributes: any, options?: any): this; + updateArrowheadMarkers(): this; + updateAttributes(): void; + updateConnection(options?: any): void; + updateLabelPositions(): this; + updateToolsPosition(): this; + } } -declare namespace joint { - export var g: any; - export var V: any; +export namespace ui { } - namespace dia { - interface Size { - width: number; - height: number; +export namespace shapes { + interface GenericAttributes extends dia.CellAttributes { + position?: dia.Point; + size?: dia.Size; + angle?: number; + attrs?: T; + } + interface ShapeAttrs extends dia.CSSSelector { + fill?: string; + stroke?: string; + r?: string | number; + rx?: string | number; + ry?: string | number; + cx?: string | number; + cy?: string | number; + height?: string | number; + width?: string | number; + transform?: string; + points?: string; + 'stroke-width'?: string | number; + 'ref-x'?: string | number; + 'ref-y'?: string | number; + ref?: string + } + + namespace basic { + class Generic extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface Point { - x: number; - y: number; + interface RectAttrs extends dia.TextAttrs { + rect?: ShapeAttrs; } - - interface BBox extends Point, Size { } - - interface TranslateOptions { - restrictedArea?: BBox; - transition?: TransitionOptions; + class Rect extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface TransitionOptions { - delay?: number; - duration?: number; - timingFunction?: (t: number) => number; - valueFunction?: (a: any, b: any) => (t: number) => any; + class Text extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface DfsBfsOptions { - inbound?: boolean; - outbound?: boolean; - deep?: boolean; + interface CircleAttrs extends dia.TextAttrs { + circle?: ShapeAttrs; } - - interface ExploreOptions { - breadthFirst?: boolean; - deep?: boolean; + class Circle extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - class Graph extends Backbone.Model { - constructor(attributes?: any, options?: { cellNamespace: any }); - addCell(cell: Cell | Cell[]): this; - addCells(cells: Cell[]): this; - resetCells(cells: Cell[], options?: any): this; - getCell(id: string): Cell; - getElements(): Element[]; - getLinks(): Link[]; - getCells(): Cell[]; - getFirstCell(): Cell; - getLastCell(): Cell; - getConnectedLinks(element: Cell, options?: { inbound?: boolean, outbound?: boolean, deep?: boolean }): Link[]; - disconnectLinks(cell: Cell, options?: any): void; - removeLinks(cell: Cell, options?: any): void; - translate(tx: number, ty?: number, options?: TranslateOptions): void; - cloneCells(cells: Cell[]): { [id: string]: Cell }; - getSubgraph(cells: Cell[], options?: { deep?: boolean }): Cell[]; - cloneSubgraph(cells: Cell[], options?: { deep?: boolean }): { [id: string]: Cell }; - dfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions, visited?: Object, distance?: number): void; - bfs(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: DfsBfsOptions): void; - search(element: Element, iteratee: (element: Element, distance: number) => boolean, options?: { breadthFirst?: boolean }): void; - getSuccessors(element: Element, options?: ExploreOptions): Element[]; - getPredecessors(element: Element, options?: ExploreOptions): Element[]; - isSuccessor(elementA: Element, elementB: Element): boolean; - isPredecessor(elementA: Element, elementB: Element): boolean; - isSource(element: Element): boolean; - isSink(element: Element): boolean; - getSources(): Element[]; - getSinks(): Element[]; - getNeighbors(element: Element, options?: DfsBfsOptions): Element[]; - isNeighbor(elementA: Element, elementB: Element, options?: { inbound?: boolean, outbound?: boolean; }): boolean; - getCommonAncestor(...cells: Cell[]): Element; - toJSON(): any; - fromJSON(json: any, options?: any): this; - clear(options?: any): this; - findModelsFromPoint(rect: BBox): Element[]; - findModelsUnderElement(element: Element, options?: { searchBy?: 'bbox' | 'center' | 'origin' | 'corner' | 'topRight' | 'bottomLeft' }): Element[]; - getBBox(elements: Element[], options?: any): BBox; - toGraphLib(): any; // graphlib graph object - findModelsInArea(rect: BBox, options?: any): BBox | boolean; - getCellsBBox(cells: Cell[], options?: any): BBox; - getInboundEdges(node: string): Object; - getOutboundEdges(node: string): Object; - hasActiveBatch(name?: string): number | boolean; - maxZIndex(): number; - removeCells(cells: Cell[], options?: any): this; - resize(width: number, height: number, options?: number): this; - resizeCells(width: number, height: number, cells: Cell[], options?: number): this; - set(key: Object | string, value: any, options?: any): this; - startBatch(name: string, data?: Object): any; - stopBatch(name: string, data?: Object): any; + interface EllipseAttrs extends dia.TextAttrs { + ellipse?: ShapeAttrs; } - - class Cell extends Backbone.Model { - id: string; - toJSON(): any; - remove(options?: { disconnectLinks?: boolean }): this; - toFront(options?: { deep?: boolean }): this; - toBack(options?: { deep?: boolean }): this; - getAncestors(): Cell[]; - isEmbeddedIn(element: Element, options?: { deep: boolean }): boolean; - prop(key: string): any; - prop(object: any): this; - prop(key: string, value: any, options?: any): this; - removeProp(path: string, options?: any): this; - attr(key: string): any; - attr(object: SVGAttributes): this; - attr(key: string, value: any): this; - clone(): Cell; - clone(opt: { deep?: boolean }): Cell | Cell[]; - removeAttr(path: string | string[], options?: any): this; - transition(path: string, value?: any, options?: TransitionOptions, delim?: string): number; - getTransitions(): string[]; - stopTransitions(path?: string, delim?: string): this; - addTo(graph: Graph, options?: any): this; - isLink(): boolean; - embed(cell: Cell, options?: any): this; - findView(paper: Paper): CellView; - getEmbeddedCells(options?: any): Cell[]; - initialize(options?: any): void; - isElement(): boolean; - isEmbedded(): boolean; - processPorts(): void; - startBatch(name: string, options?: any): this; - stopBatch(name: string, options?: any): this; - unembed(cell: Cell, options?: any): this; + class Ellipse extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - type Padding = number | { - top?: number; - right?: number; - bottom?: number; - left?: number - }; - - class Element extends Cell { - translate(tx: number, ty?: number, options?: TranslateOptions): this; - position(options?: { parentRelative: boolean }): Point; - position(x: number, y: number, options?: { parentRelative?: boolean }): this; - resize(width: number, height: number, options?: { direction?: 'left' | 'right' | 'top' | 'bottom' | 'top-right' | 'top-left' | 'bottom-left' | 'bottom-right' }): this; - rotate(deg: number, absolute?: boolean, origin?: Point): this; - embed(cell: Cell): this; - unembed(cell: Cell): this; - getEmbeddedCells(options?: ExploreOptions): Cell[]; - fitEmbeds(options?: { deep?: boolean, padding?: Padding }): this; - getBBox(options?: any): BBox; - findView(paper: Paper): ElementView; - isElement(): boolean; - scale(scaleX: number, scaleY: number, origin?: Point, options?: any): this; - addPort(port: any, opt?: any): this; - addPorts(ports: any[], opt?: any): this; - removePort(port: any, opt?: any): this; - hasPorts(): boolean; - hasPort(id: string): boolean; - getPorts(): any[]; - getPort(id: string): any; - getPortIndex(port: any): number; - portProp(portId: string, path: any, value?: any, opt?: any): joint.dia.Element; + interface PolygonAttrs extends dia.TextAttrs { + polygon?: ShapeAttrs; } - - interface CSSSelector { - [key: string]: string | number | Object; // Object added to support special attributes like filter http://jointjs.com/api#SpecialAttributes:filter + class Polygon extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface SVGAttributes { - [selector: string]: CSSSelector; + interface PolylineAttrs extends dia.TextAttrs { + polyline?: ShapeAttrs; } - - interface CellAttributes { - [key: string]: any; + class Polyline extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface TextAttrs extends SVGAttributes { - text?: { - [key: string]: string | number; - text?: string; - }; + class Image extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface Label { - position: number; - attrs?: TextAttrs; + interface PathAttrs extends dia.TextAttrs { + path?: ShapeAttrs; } - interface LinkAttributes extends CellAttributes { - source?: Point | { id: string, selector?: string, port?: string }; - target?: Point | { id: string, selector?: string, port?: string }; - labels?: Label[]; - vertices?: Point[]; - smooth?: boolean; - attrs?: TextAttrs; - z?: number; + class Path extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - class Link extends Cell { - markup: string; - labelMarkup: string; - toolMakup: string; - vertexMarkup: string; - arrowHeadMarkup: string; - - constructor(attributes?: LinkAttributes, options?: Object); - disconnect(): this; - label(index?: number): any; - label(index: number, value: Label): this; - reparent(options?: any): Element; - findView(paper: Paper): LinkView; - getSourceElement(): Element; - getTargetElement(): Element; - hasLoop(options?: { deep?: boolean }): boolean; - applyToPoints(fn: Function, options?: any): this; - getRelationshipAncestor(): Element; - isLink(): boolean; - isRelationshipEmbeddedIn(element: Element): boolean; - scale(sx: number, sy: number, origin: Point, optionts?: any): this; - translate(tx: number, ty: number, options?: any): this; + interface RhombusAttrs extends dia.TextAttrs { + path?: ShapeAttrs; } - - interface ManhattanRouterArgs { - excludeTypes?: string[]; - excludeEnds?: 'source' | 'target'; - startDirections?: ['left' | 'right' | 'top' | 'bottom']; - endDirections?: ['left' | 'right' | 'top' | 'bottom']; + class Rhombus extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - interface PaperOptions extends Backbone.ViewOptions { - el?: string | JQuery | HTMLElement; - width?: number; - height?: number; - origin?: Point; - gridSize?: number; - perpendicularLinks?: boolean; - elementView?: (element: Element) => ElementView | ElementView; - linkView?: (link: Link) => LinkView | LinkView; - defaultLink?: ((cellView: CellView, magnet: SVGElement) => Link) | Link; - defaultRouter?: ((vertices: Point[], args: Object, linkView: LinkView) => Point[]) | { name: string, args?: ManhattanRouterArgs }; - defaultConnector?: ((sourcePoint: Point, targetPoint: Point, vertices: Point[], args: Object, linkView: LinkView) => string) | { name: string, args?: { radius?: number } }; - interactive?: ((cellView: CellView, event: string) => boolean) | boolean | { vertexAdd?: boolean, vertexMove?: boolean, vertexRemove?: boolean, arrowheadMove?: boolean }; - validateMagnet?: (cellView: CellView, magnet: SVGElement) => boolean; - validateConnection?: (cellViewS: CellView, magnetS: SVGElement, cellViewT: CellView, magnetT: SVGElement, end: 'source' | 'target', linkView: LinkView) => boolean; - linkConnectionPoint?: (linkView: LinkView, view: ElementView, magnet: SVGElement, reference: Point) => Point; - snapLinks?: boolean | { radius: number }; - linkPinning?: boolean; - markAvailable?: boolean; - async?: boolean | { batchZise: number }; - embeddingMode?: boolean; - validateEmbedding?: (childView: ElementView, parentView: ElementView) => boolean; - restrictTranslate?: ((elementView: ElementView) => BBox) | boolean; - guard?: (evt: Event, view: CellView) => boolean; - multiLinks?: boolean; - cellViewNamespace?: Object; - /** useful undocumented option */ - clickThreshold?: number; - highlighting?: any; + interface TextBlockAttrs extends dia.TextAttrs { + rect?: ShapeAttrs; } - - interface ScaleContentOptions { - padding?: number; - preserveAspectRatio?: boolean; - minScale?: number; - minScaleX?: number; - minScaleY?: number; - maxScale?: number; - maxScaleX?: number; - maxScaleY?: number; - scaleGrid?: number; - fittingBBox?: BBox; + class TextBlock extends Generic { + constructor(attributes?: GenericAttributes, options?: Object); + updateSize(cell: dia.Cell, size: dia.Size): void; + updateContent(cell: dia.Cell, content: string): void; } + } - interface FitToContentOptions { - gridWidth?: number; - gridHeight?: number; - padding?: Padding; - allowNewOrigin?: 'negative' | 'positive' | 'any'; - minWidth?: number; - minHeight?: number; - maxWidth?: number; - maxHeight?: number; + namespace chess { + class KingWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - class Paper extends Backbone.View { - constructor(options?: PaperOptions); - options: PaperOptions; - svg: SVGElement; - viewport: SVGGElement; - defs: SVGDefsElement; - setDimensions(width: number, height: number): void; - setOrigin(x: number, y: number): void; - scale(sx: number, sy?: number, ox?: number, oy?: number): this; - findView(element: any): CellView; - findViewByModel(model: Cell | string): CellView; - findViewsFromPoint(point: Point): ElementView[]; - findViewsInArea(rect: BBox, options?: { strict?: boolean }): CellView[]; - fitToContent(options?: FitToContentOptions): void; - scaleContentToFit(options?: ScaleContentOptions): void; - getContentBBox(): BBox; - clientToLocalPoint(p: Point): Point; - - rotate(deg: number, ox?: number, oy?: number): Paper; // @todo not released yet though it's in the source code already - - afterRenderViews(): void; - asyncRenderViews(cells: Cell[], options?: any): void; - beforeRenderViews(cells: Cell[]): Cell[]; - cellMouseout(evt: Event): void; - cellMouseover(evt: Event): void; - clearGrid(): this; - contextmenu(evt: Event): void; - createViewForModel(cell: Cell): CellView; - drawGrid(options?: any): this; - fitToContent(gridWidth?: number, gridHeight?: number, padding?: number, options?: any): void; - getArea(): BBox; - getDefaultLink(cellView: CellView, magnet: HTMLElement): Link; - getModelById(id: string): Cell; - getRestrictedArea(): BBox; - guard(evt: Event, view: CellView): boolean; - linkAllowed(linkViewOrModel: LinkView | Link): boolean; - mouseclick(evt: Event): void; - mousedblclick(evt: Event): void; - mousewheel(evt: Event): void; - onCellAdded(cell: Cell, graph: Graph, options: Object): void; - onCellHighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; - onCellUnhighlight(cellView: CellView, magnetEl: HTMLElement, options?: any): void; - onRemove(): void; - pointerdown(evt: Event): void; - pointermove(evt: Event): void; - pointerup(evt: Event): void; - remove(): this; - removeView(cell: Cell): CellView; - removeViews(): void; - renderView(cell: Cell): CellView; - resetViews(cellsCollection: Cell[], options: any): void; - resolveHighlighter(options?: any): boolean | Object; - setGridSize(gridSize: number): this; - setInteractivity(value: any): void; - snapToGrid(p: Point): Point; - sortViews(): void; + class KingBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - - - interface GradientOptions { - type: 'linearGradient' | 'radialGradient'; - stops: Array<{ - offset: string; - color: string; - opacity?: number; - }>; + class QueenWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } - class CellViewGeneric extends Backbone.View { - getBBox(options?: { useModelGeometry?: boolean }): BBox; - highlight(el?: any, options?: any): this; - unhighlight(el?: any, options?: any): this; - applyFilter(selector: string | HTMLElement, filter: Object): void; - applyGradient(selector: string | HTMLElement, attr: 'fill' | 'stroke', gradient: GradientOptions): void; - can(feature: string): boolean; - findBySelector(selector: string): JQuery; - findMagnet(el: any): HTMLElement; - getSelector(el: HTMLElement, prevSelector: string): string; - getStrokeBBox(el: any): BBox; // string|HTMLElement|Vectorizer - mouseout(evt: Event): void; - mouseover(evt: Event): void; - mousewheel(evt: Event, x: number, y: number, delta: number): void - notify(eventName: string): void; - onChangeAttrs(cell: Cell, attrs: Backbone.ViewOptions, options?: any): this; - onSetTheme(oldTheme: string, newTheme: string): void; - pointerclick(evt: Event, x: number, y: number): void; - pointerdblclick(evt: Event, x: number, y: number): void; - pointerdown(evt: Event, x: number, y: number): void; - pointermove(evt: Event, x: number, y: number): void; - pointerup(evt: Event, x: number, y: number): void; - remove(): this; - setInteractivity(value: any): void; - setTheme(theme: string, options?: any): this; + class QueenBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); } + class RookWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class RookBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class BishopWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class BishopBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class KnightWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class KnightBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class PawnWhite extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class PawnBlack extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + } - class CellView extends CellViewGeneric { } + namespace devs { + interface ModelAttributes extends GenericAttributes { + inPorts?: string[]; + outPorts?: string[]; + ports?: Object; + } + class Model extends basic.Generic { + constructor(attributes?: ModelAttributes, options?: Object); + changeInGroup(properties: any, opt?: any): boolean; + changeOutGroup(properties: any, opt?: any): boolean; + createPortItem(group: string, port: string): any; + createPortItems(group: string, ports: string[]): any[]; + addOutPort(port: string, opt?: any): this; + addInPort(port: string, opt?: any): this; + removeOutPort(port: string, opt?: any): this; + removeInPort(port: string, opt?: any): this; + } + class Coupled extends Model { + constructor(attributes?: ModelAttributes, options?: Object); + } + class Atomic extends Model { + constructor(attributes?: ModelAttributes, options?: Object); + } + class Link extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + } - interface ElementViewAttributes { - style?: string; - text?: string; - html?: string; - "ref-x"?: string | number; - "ref-y"?: string | number; - "ref-dx"?: number; - "ref-dy"?: number; - "ref-width"?: string | number; - "ref-height"?: string | number; + namespace erd { + class Entity extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class WeakEntity extends Entity { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Relationship extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class IdentifyingRelationship extends Relationship { + constructor(attributes?: GenericAttributes, options?: Object); + } + interface AttributeAttrs extends dia.TextAttrs { + ellipse?: ShapeAttrs; + } + class Attribute extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Multivalued extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Derived extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Key extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Normal extends Attribute { + constructor(attributes?: GenericAttributes, options?: Object); + } + interface ISAAttrs extends dia.Element { + polygon?: ShapeAttrs; + } + class ISA extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Line extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + cardinality(value: string | number): void; + } + } + + namespace fsa { + class State extends basic.Circle { + constructor(attributes?: GenericAttributes, options?: Object); + } + class StartState extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class EndState extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Arrow extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + } + + namespace logic { + interface LogicAttrs extends ShapeAttrs { ref?: string; - "x-alignment"?: 'middle' | 'right' | number; - "y-alignment"?: 'middle' | 'bottom' | number; + 'ref-x'?: number | string; + 'ref-dx'?: number | string; + 'ref-y'?: number | string; + 'ref-dy'?: number | string; + magnet?: boolean; + 'class'?: string; port?: string; } - class ElementView extends CellViewGeneric { - scale(sx: number, sy: number): void; // @todo Documented in source but not released - finalizeEmbedding(options?: any): void; - getBBox(options?: any): BBox; - pointerdown(evt: Event, x: number, y: number): void; - pointermove(evt: Event, x: number, y: number): void; - pointerup(evt: Event, x: number, y: number): void; - positionRelative(vel: any, bbox: BBox, attributes: ElementViewAttributes, nodesBySelector?: Object): void; // Vectorizer - prepareEmbedding(options?: any): void; - processEmbedding(options?: any): void; - render(): this; - renderMarkup(): void; - resize(): void; - rotate(): void; - translate(model: Backbone.Model, changes?: any, options?: any): void; - update(cell: Cell, renderingOnlyAttrs?: Object): void; + interface IOAttrs extends dia.TextAttrs { + circle?: LogicAttrs; } - - class LinkView extends CellViewGeneric { - options: { - shortLinkLength?: number, - doubleLinkTools?: boolean, - longLinkLength?: number, - linkToolsOffset?: number, - doubleLinkToolsOffset?: number, - sampleInterval: number - }; - getConnectionLength(): number; - sendToken(token: SVGElement, duration?: number, callback?: () => void): void; - addVertex(vertex: Point): number; - getPointAtLength(length: number): Point; // Marked as public api in source but not in the documents - createWatcher(endType: { id: string }): Function; - findRoute(oldVertices: Point[]): Point[]; - getConnectionPoint(end: 'source' | 'target', selectorOrPoint: Element | Point, referenceSelectorOrPoint: Element | Point): Point; - getPathData(vertices: Point[]): any; - onEndModelChange(endType: 'source' | 'target', endModel?: Element, opt?: any): void; - onLabelsChange(): void; - onSourceChange(cell: Cell, sourceEnd: { id: string }, options: any): void; - onTargetChange(cell: Cell, targetEnd: { id: string }, options: any): void; - onToolsChange(): void; - onVerticesChange(cell: Cell, changed: any, options: any): void; - pointerdown(evt: Event, x: number, y: number): void; - pointermove(evt: Event, x: number, y: number): void; - pointerup(evt: Event, x: number, y: number): void; - removeVertex(idx: number): this; - render(): this; - renderArrowheadMarkers(): this; - renderLabels(): this; - renderTools(): this; - renderVertexMarkers(): this; - startArrowheadMove(end: 'source' | 'target', options?: any): void; - startListening(): void; - update(model: any, attributes: any, options?: any): this; - updateArrowheadMarkers(): this; - updateAttributes(): void; - updateConnection(options?: any): void; - updateLabelPositions(): this; - updateToolsPosition(): this; + class Gate extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class IO extends Gate { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Input extends IO { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Output extends IO { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Gate11 extends Gate { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Gate21 extends Gate { + constructor(attributes?: GenericAttributes, options?: Object); + } + interface Image { + 'xlink:href'?: string; + } + interface ImageAttrs extends LogicAttrs { + image?: Image; + } + class Repeater extends Gate11 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input: any): any; + } + class Note extends Gate11 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input: any): boolean; + } + class Or extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class And extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Nor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Nand extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Xor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + class Xnor extends Gate21 { + constructor(attributes?: GenericAttributes, options?: Object); + operation(input1: any, input2: any): boolean; + } + interface WireArgs extends dia.LinkAttributes { + router?: Object; + connector?: Object; + } + class Wire extends dia.Link { + constructor(attributes?: WireArgs, options?: Object); } } - namespace ui { } - - namespace shapes { - interface GenericAttributes extends dia.CellAttributes { - position?: dia.Point; - size?: dia.Size; - angle?: number; - attrs?: T; + namespace org { + interface MemberAttrs { + rect?: ShapeAttrs; + image?: ShapeAttrs; } - interface ShapeAttrs extends dia.CSSSelector { - fill?: string; - stroke?: string; - r?: string | number; - rx?: string | number; - ry?: string | number; - cx?: string | number; - cy?: string | number; - height?: string | number; - width?: string | number; - transform?: string; - points?: string; - 'stroke-width'?: string | number; - 'ref-x'?: string | number; - 'ref-y'?: string | number; - ref?: string + class Member extends dia.Element { + constructor(attributes?: GenericAttributes, options?: Object); } - - namespace basic { - class Generic extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface RectAttrs extends dia.TextAttrs { - rect?: ShapeAttrs; - } - class Rect extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Text extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface CircleAttrs extends dia.TextAttrs { - circle?: ShapeAttrs; - } - class Circle extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface EllipseAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs; - } - class Ellipse extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface PolygonAttrs extends dia.TextAttrs { - polygon?: ShapeAttrs; - } - class Polygon extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface PolylineAttrs extends dia.TextAttrs { - polyline?: ShapeAttrs; - } - class Polyline extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Image extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface PathAttrs extends dia.TextAttrs { - path?: ShapeAttrs; - } - class Path extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface RhombusAttrs extends dia.TextAttrs { - path?: ShapeAttrs; - } - class Rhombus extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface TextBlockAttrs extends dia.TextAttrs { - rect?: ShapeAttrs; - } - class TextBlock extends Generic { - constructor(attributes?: GenericAttributes, options?: Object); - updateSize(cell: dia.Cell, size: dia.Size): void; - updateContent(cell: dia.Cell, content: string): void; - } - } - - namespace chess { - class KingWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class KingBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class QueenWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class QueenBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class RookWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class RookBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class BishopWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class BishopBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class KnightWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class KnightBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class PawnWhite extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class PawnBlack extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - } - - namespace devs { - interface ModelAttributes extends GenericAttributes { - inPorts?: string[]; - outPorts?: string[]; - ports?: Object; - } - class Model extends basic.Generic { - constructor(attributes?: ModelAttributes, options?: Object); - changeInGroup(properties: any, opt?: any): boolean; - changeOutGroup(properties: any, opt?: any): boolean; - createPortItem(group: string, port: string): any; - createPortItems(group: string, ports: string[]): any[]; - addOutPort(port: string, opt?: any): this; - addInPort(port: string, opt?: any): this; - removeOutPort(port: string, opt?: any): this; - removeInPort(port: string, opt?: any): this; - } - class Coupled extends Model { - constructor(attributes?: ModelAttributes, options?: Object); - } - class Atomic extends Model { - constructor(attributes?: ModelAttributes, options?: Object); - } - class Link extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace erd { - class Entity extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class WeakEntity extends Entity { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Relationship extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class IdentifyingRelationship extends Relationship { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface AttributeAttrs extends dia.TextAttrs { - ellipse?: ShapeAttrs; - } - class Attribute extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Multivalued extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Derived extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Key extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Normal extends Attribute { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface ISAAttrs extends dia.Element { - polygon?: ShapeAttrs; - } - class ISA extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Line extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - cardinality(value: string | number): void; - } - } - - namespace fsa { - class State extends basic.Circle { - constructor(attributes?: GenericAttributes, options?: Object); - } - class StartState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class EndState extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Arrow extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace logic { - interface LogicAttrs extends ShapeAttrs { - ref?: string; - 'ref-x'?: number | string; - 'ref-dx'?: number | string; - 'ref-y'?: number | string; - 'ref-dy'?: number | string; - magnet?: boolean; - 'class'?: string; - port?: string; - } - interface IOAttrs extends dia.TextAttrs { - circle?: LogicAttrs; - } - class Gate extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class IO extends Gate { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Input extends IO { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Output extends IO { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Gate11 extends Gate { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Gate21 extends Gate { - constructor(attributes?: GenericAttributes, options?: Object); - } - interface Image { - 'xlink:href'?: string; - } - interface ImageAttrs extends LogicAttrs { - image?: Image; - } - class Repeater extends Gate11 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input: any): any; - } - class Note extends Gate11 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input: any): boolean; - } - class Or extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class And extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Nor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Nand extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Xor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - class Xnor extends Gate21 { - constructor(attributes?: GenericAttributes, options?: Object); - operation(input1: any, input2: any): boolean; - } - interface WireArgs extends dia.LinkAttributes { - router?: Object; - connector?: Object; - } - class Wire extends dia.Link { - constructor(attributes?: WireArgs, options?: Object); - } - } - - namespace org { - interface MemberAttrs { - rect?: ShapeAttrs; - image?: ShapeAttrs; - } - class Member extends dia.Element { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Arrow extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace pn { - class Place extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class PlaceView extends dia.ElementView { - renderTokens(): void; - } - class Transition extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Link extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - } - - namespace uml { - interface ClassAttributes extends GenericAttributes { - name: string[]; - attributes: string[]; - methods: string[]; - } - class Class extends basic.Generic { - constructor(attributes?: ClassAttributes, options?: Object); - getClassName(): string[]; - updateRectangles(): void; - } - class ClassView extends dia.ElementView { - } - class Abstract extends Class { - constructor(attributes?: ClassAttributes, options?: Object); - } - class AbstractView extends ClassView { - constructor(attributes?: ClassAttributes, options?: Object); - } - class Interface extends Class { - constructor(attributes?: ClassAttributes, options?: Object); - } - class InterfaceView extends ClassView { - constructor(attributes?: ClassAttributes, options?: Object); - } - class Generalization extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Implementation extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Aggregation extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Composition extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - class Association extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } - interface StateAttributes extends GenericAttributes { - events?: string[]; - } - class State extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - updateName(): void; - updateEvents(): void; - updatePath(): void; - } - class StartState extends basic.Circle { - constructor(attributes?: GenericAttributes, options?: Object); - } - class EndState extends basic.Generic { - constructor(attributes?: GenericAttributes, options?: Object); - } - class Transition extends dia.Link { - constructor(attributes?: dia.LinkAttributes, options?: Object); - } + class Arrow extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); } } - namespace util { - - namespace format { - export function number(specifier: string, value: number): string; + namespace pn { + class Place extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class PlaceView extends dia.ElementView { + renderTokens(): void; + } + class Transition extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Link extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); } - - export function uuid(): string; - export function guid(obj?: Object): string; - export function nextFrame(callback: () => void, context?: Object): number; - export function cancelFrame(requestId: number): void; - export function flattenObject(object: Object, delim: string, stop: (node: any) => boolean): any; - export function getByPath(object: Object, path: string, delim: string): any; - export function setByPath(object: Object, path: string, value: Object, delim: string): any; - export function unsetByPath(object: Object, path: string, delim: string): any; - export function breakText(text: string, size: dia.Size, attrs?: dia.SVGAttributes, options?: { svgDocument?: SVGElement }): string; - export function normalizeSides(box: number | { x?: number, y?: number, height?: number, width?: number }): dia.BBox; - export function getElementBBox(el: Element): dia.BBox; - export function setAttributesBySelector(el: Element, attrs: dia.SVGAttributes): void; - export function sortElements(elements: Element[] | string | JQuery, comparator: (a: Element, b: Element) => number): Element[]; - export function shapePerimeterConnectionPoint(linkView: dia.LinkView, view: dia.ElementView, magnet: SVGElement, ref: dia.Point): dia.Point; - export function imageToDataUri(url: string, callback: (err: Error, dataUri: string) => void): void; - - // Not documented but used in examples - /** @deprecated use lodash _.defaultsDeep */ - export function deepSupplement(objects: any, defaultIndicator?: any): any; - - // Private functions - /** @deprecated use lodash _.assign */ - export function mixin(objects: any[]): any; - /** @deprecated use lodash _.defaults */ - export function supplement(objects: any[]): any; - /** @deprecated use lodash _.mixin */ - export function deepMixin(objects: any[]): any; } - namespace layout { - - interface LayoutOptions { - nodeSep?: number; - edgeSep?: number; - rankSep?: number; - rankDir?: 'TB' | 'BT' | 'LR' | 'RL'; - marginX?: number; - marginY?: number; - resizeCluster?: boolean; - setPosition?: (element: dia.Element, position: dia.BBox) => void; - setLinkVertices?: (link: dia.Link, vertices: Position[]) => void; + namespace uml { + interface ClassAttributes extends GenericAttributes { + name: string[]; + attributes: string[]; + methods: string[]; } - - export class DirectedGraph { - static layout(graph: dia.Graph | dia.Cell[], options?: LayoutOptions): dia.BBox; + class Class extends basic.Generic { + constructor(attributes?: ClassAttributes, options?: Object); + getClassName(): string[]; + updateRectangles(): void; + } + class ClassView extends dia.ElementView { + } + class Abstract extends Class { + constructor(attributes?: ClassAttributes, options?: Object); + } + class AbstractView extends ClassView { + constructor(attributes?: ClassAttributes, options?: Object); + } + class Interface extends Class { + constructor(attributes?: ClassAttributes, options?: Object); + } + class InterfaceView extends ClassView { + constructor(attributes?: ClassAttributes, options?: Object); + } + class Generalization extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Implementation extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Aggregation extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Composition extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + class Association extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); + } + interface StateAttributes extends GenericAttributes { + events?: string[]; + } + class State extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + updateName(): void; + updateEvents(): void; + updatePath(): void; + } + class StartState extends basic.Circle { + constructor(attributes?: GenericAttributes, options?: Object); + } + class EndState extends basic.Generic { + constructor(attributes?: GenericAttributes, options?: Object); + } + class Transition extends dia.Link { + constructor(attributes?: dia.LinkAttributes, options?: Object); } } } + +export namespace util { + + namespace format { + export function number(specifier: string, value: number): string; + } + + export function uuid(): string; + export function guid(obj?: Object): string; + export function nextFrame(callback: () => void, context?: Object): number; + export function cancelFrame(requestId: number): void; + export function flattenObject(object: Object, delim: string, stop: (node: any) => boolean): any; + export function getByPath(object: Object, path: string, delim: string): any; + export function setByPath(object: Object, path: string, value: Object, delim: string): any; + export function unsetByPath(object: Object, path: string, delim: string): any; + export function breakText(text: string, size: dia.Size, attrs?: dia.SVGAttributes, options?: { svgDocument?: SVGElement }): string; + export function normalizeSides(box: number | { x?: number, y?: number, height?: number, width?: number }): dia.BBox; + export function getElementBBox(el: Element): dia.BBox; + export function setAttributesBySelector(el: Element, attrs: dia.SVGAttributes): void; + export function sortElements(elements: Element[] | string | JQuery, comparator: (a: Element, b: Element) => number): Element[]; + export function shapePerimeterConnectionPoint(linkView: dia.LinkView, view: dia.ElementView, magnet: SVGElement, ref: dia.Point): dia.Point; + export function imageToDataUri(url: string, callback: (err: Error, dataUri: string) => void): void; + + // Not documented but used in examples + /** @deprecated use lodash _.defaultsDeep */ + export function deepSupplement(objects: any, defaultIndicator?: any): any; + + // Private functions + /** @deprecated use lodash _.assign */ + export function mixin(objects: any[]): any; + /** @deprecated use lodash _.defaults */ + export function supplement(objects: any[]): any; + /** @deprecated use lodash _.mixin */ + export function deepMixin(objects: any[]): any; +} + +export namespace layout { + + interface LayoutOptions { + nodeSep?: number; + edgeSep?: number; + rankSep?: number; + rankDir?: 'TB' | 'BT' | 'LR' | 'RL'; + marginX?: number; + marginY?: number; + resizeCluster?: boolean; + setPosition?: (element: dia.Element, position: dia.BBox) => void; + setLinkVertices?: (link: dia.Link, vertices: Position[]) => void; + } + + class DirectedGraph { + static layout(graph: dia.Graph | dia.Cell[], options?: LayoutOptions): dia.BBox; + } +} diff --git a/rappid/index.d.ts b/rappid/index.d.ts index 5cbf07b995..d70023e055 100644 --- a/rappid/index.d.ts +++ b/rappid/index.d.ts @@ -5,33 +5,36 @@ /// -declare namespace joint { - namespace ui { - interface Handle { - name: string; - position: string; - icon: string; - } +import * as joint from 'jointjs'; +import * as Backbone from "backbone"; - class SelectionView extends Backbone.Model { +export as namespace joint; + +export namespace ui { + interface Handle { + name: string; + position: string; + icon: string; + } + + class SelectionView extends Backbone.Model { + paper: joint.dia.Paper; + graph: joint.dia.Graph; + model: Backbone.Collection; + + constructor(opt: { paper: joint.dia.Paper; graph: joint.dia.Graph; - model: Backbone.Collection; + model: Backbone.Collection + }); - constructor(opt: { - paper: joint.dia.Paper; - graph: joint.dia.Graph; - model: Backbone.Collection - }); + createSelectionBox(cellView: joint.dia.CellView): void; + destroySelectionBox(cellView: joint.dia.CellView): void; + startSelecting(evt: any): void; + cancelSelection(): void; - createSelectionBox(cellView: joint.dia.CellView): void; - destroySelectionBox(cellView: joint.dia.CellView): void; - startSelecting(evt: any): void; - cancelSelection(): void; - - addHandle(handle: Handle): void; - removeHandle(name: string): void; - changeHandle(name: string, handle: Handle): void; - } + addHandle(handle: Handle): void; + removeHandle(name: string): void; + changeHandle(name: string, handle: Handle): void; } } From fcc78898d3baf2e1ed7c45f693fdc4e2aaf94530 Mon Sep 17 00:00:00 2001 From: Victor Palomo de Castro Date: Sat, 11 Mar 2017 23:56:50 -0300 Subject: [PATCH 077/258] Added positions prop for DrawerLayoutAndroidStatic --- react-native/index.d.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index 35a7eae5ce..c0d1884a97 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -2563,8 +2563,18 @@ declare module "react" { ref?: Ref } + interface DrawerPosition { + Left: number + Right: number + } + export interface DrawerLayoutAndroidStatic extends NativeMethodsMixin, React.ClassicComponentClass { + /** + * drawer's positions. + */ + positions: DrawerPosition + /** * Opens the drawer. */ From 7f0410d887d7893c6232020356bbd890437af80d Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 12 Mar 2017 15:58:56 +0100 Subject: [PATCH 078/258] fix requested changes from @minestarks for PR #14816 --- qlik-visualizationextensions/index.d.ts | 816 ++++++++++-------- .../qlik-visualizationextensions-tests.ts | 2 +- qlik-visualizationextensions/tsconfig.json | 2 +- qlik-visualizationextensions/tslint.json | 3 +- 4 files changed, 447 insertions(+), 376 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index c7eb32273c..4f384ca925 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -14,10 +14,10 @@ declare namespace BackendAPI { type PatchType = "Add" | "Remove" | "Replace"; interface ICharRange { - /** - * Position of the first search occurrence - * Integer - */ + /** + * Position of the first search occurrence + * Integer + */ qCharPos: number; /** @@ -84,8 +84,8 @@ declare namespace BackendAPI { } interface INxCell { - /** - * Some text. + /** + * Some text. * This parameter is optional. */ qText?: string; @@ -97,13 +97,13 @@ declare namespace BackendAPI { qNum?: number; /** - * Rank number of the value, starting from 0. + * Rank number of the value, starting from 0. * If the element number is a negative number, it means that the returned value is not an element number. * You can get the following negative values: - * # -1: the cell is a Total cell. It shows a total. - * # -2: the cell is collapsed. Applies to pivot tables. - * # -3: the cell belongs to the group Others. - * # -4: the cell is empty. Applies to pivot tables. + * # -1: the cell is a Total cell. It shows a total. + * # -2: the cell is collapsed. Applies to pivot tables. + * # -3: the cell belongs to the group Others. + * # -4: the cell is empty. Applies to pivot tables. */ qElemNumber: number; @@ -130,15 +130,15 @@ declare namespace BackendAPI { /** * Is set to true if a total is displayed in the cell. * This parameter is optional. The default value is false. - * Not applicable to list objects. + * Not applicable to list objects. */ qIsTotalCell: boolean; /** * Is set to true if the cell belongs to the group Others. * Dimension values can be set as Others depending on what has been defined in OtherTotalSpecProp. - * This parameter is optional. The default value is false. - * Not applicable to list objects. + * This parameter is optional. The default value is false. + * Not applicable to list objects. */ qIsOtherCell: boolean; @@ -150,7 +150,7 @@ declare namespace BackendAPI { /** * Search hits. - * The search hits are highlighted. + * The search hits are highlighted. * This parameter is optional. */ qHighlightRanges: INxHighlightRanges; @@ -185,12 +185,14 @@ declare namespace BackendAPI { qTop: number; /** - * Number of columns in the page. The indexing of the columns may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + * Number of columns in the page. The indexing of the columns may vary depending on whether + * the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). */ qWidth: number; /** - * Number of rows or elements in the page. The indexing of the rows may vary depending on whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). + * Number of rows or elements in the page. The indexing of the rows may vary depending on + * whether the cells are expanded or not (parameter qAlwaysFullyExpanded in HyperCubeDef). */ qHeight: number; } @@ -198,13 +200,13 @@ declare namespace BackendAPI { interface INxAttrDimInfo { /** * Cardinality of the attribute expression. - * Integer + * Integer */ qCardinal: number; /** * Number of rows. - * Size + * Size */ qSize: number; @@ -267,7 +269,8 @@ declare namespace BackendAPI { /** * Array of dimension labels. - * Contains the labels of all dimensions in a hierarchy group (for example the labels of all dimensions in a drill down group). + * Contains the labels of all dimensions in a hierarchy group + * (for example the labels of all dimensions in a drill down group). * Array of String */ qGroupFallbackTitles: string[]; @@ -337,7 +340,8 @@ declare namespace BackendAPI { qNumFormat: FieldAttributesType; /** - * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's definition. + * This parameter is set to true if qNumFormat is set to U (unknown). + * The engine guesses the type of the field based on the field's definition. * Boolean */ qIsAutoFormat: boolean; @@ -582,7 +586,8 @@ declare namespace BackendAPI { qNumFormat: IFieldAttributes; /** - * This parameter is set to true if qNumFormat is set to U (unknown). The engine guesses the type of the field based on the field's expression. + * This parameter is set to true if qNumFormat is set to U (unknown). + * The engine guesses the type of the field based on the field's expression. */ qIsAutoFormat: boolean; @@ -631,14 +636,18 @@ declare namespace BackendAPI { qMax: number; /** - * If set to true, the range includes the lowest value in the range of selections (Equals to ). [bn(50500)] - * Example: The range is [1,10]. If qMinInclEq is set to true it means that 1 is included in the range of selections. + * If set to true, the range includes the lowest value in the range of + * selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means + * that 1 is included in the range of selections. */ qMinInclEq: boolean; /** - * If set to true, the range includes the highest value in the range of selections (Equals to ). [bn(50500)] - * Example: The range is [1,10]. If qMinInclEq is set to true it means that 10 is included in the range of selections. + * If set to true, the range includes the highest value in the range of + * selections (Equals to ). [bn(50500)] + * Example: The range is [1,10]. If qMinInclEq is set to true it means + * that 10 is included in the range of selections. */ qMaxInclEq: boolean; } @@ -660,8 +669,8 @@ declare namespace BackendAPI { qPath: string; /** - * This parameter is not used in a remove operation. - * Corresponds to the value of the property to add or to the new value of the property to update. + * This parameter is not used in a remove operation. Corresponds to the value of the + * property to add or to the new value of the property to update. * Examples: "false", "2", "\"New title\"" * String */ @@ -669,25 +678,26 @@ declare namespace BackendAPI { } interface IBackend { - /** - * Aborts the result of a search in a list object. Clears the existing search and returns the object to the state it was in prior to the search started. + /** + * Aborts the result of a search in a list object. Clears the existing search and returns the + * object to the state it was in prior to the search started. */ abortSearch(): void; /** * Accepts the result of a search in a list object and the search result is selected in the field. - * @param {boolean} toggleMode - If true, toggle state for selected values + * @param {boolean} toggleMode - If true, toggle state for selected values */ acceptSearch(toggleMode: boolean): void; /** - * Updates the properties for this object. + * Updates the properties for this object. * @param {array} qPatches - Array of patches. Each path contains: - * #qOp: Add/Remove/Replace - * #qPath: Path to property - * #qValue: The new value in string format. Strings need to be surrounded by \". - * @param {boolean} qSoftPatch - Set to True if properties should be soft, that is not persisted. - * @return {Promise} - A promise of a Qlik engine reply. + * #qOp: Add/Remove/Replace + * #qPath: Path to property + * #qValue: The new value in string format. Strings need to be surrounded by \". + * @param {boolean} qSoftPatch - Set to True if properties should be soft, that is not persisted. + * @return {Promise} - A promise of a Qlik engine reply. */ applyPatches(qPatches: any[], qSoftPatch: boolean): ng.IPromise; @@ -697,164 +707,173 @@ declare namespace BackendAPI { clearSelections(): void; /** - * Clears all soft patches that has previously been applied for this object using the applyPatches method. - * @return {Promise} - A promise of a Qlik engine reply. + * Clears all soft patches that has previously been applied for this object using the + * applyPatches method. + * @return {Promise} - A promise of a Qlik engine reply. */ clearSoftPatches(): ng.IPromise; /** - * Collapse the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. + * Collapse the left dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. */ collapseLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** - * Collapse the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. + * Collapse the top dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. */ collapseTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** * Loops through data rows for this object. Only rows that are available client side will be used. - * @param {function} callback - Function to call for each row. - * Parameters are row number and row data as an array of NxCell objects. - * The loop is terminated if the function returns false. - * @return {NxCell[]} - An array of NxCell. - */ + * @param {function} callback - Function to call for each row. + * Parameters are row number and row data as an array of NxCell objects. + * The loop is terminated if the function returns false. + * @return {NxCell[]} - An array of NxCell. + */ eachDataRow(callback: any): INxCell[]; /** - * Expands the left dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Expands the left dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. + */ expandLeft(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** - * Expands the top dimensions of a pivot table. Only works for hypercubes with qMode = P which are not always fully expanded. - * @param {number} qRow - Row index. - * @param {number} qCol - Column index. - * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. - * @return {Promise} - A promise of a Qlik engine reply. + * Expands the top dimensions of a pivot table. Only works for hypercubes with + * qMode = P which are not always fully expanded. + * @param {number} qRow - Row index. + * @param {number} qCol - Column index. + * @param {boolean} [qAll] - Optional. If set to true, qRow and qCol are ignored and all cells are collapsed. + * @return {Promise} - A promise of a Qlik engine reply. */ expandTop(qRow: number, qCol: number, qAll?: boolean): ng.IPromise; /** * Geta data from Qlik engine for this object. - * @param {array} qPages - An array of NxPage objects. - * @return {Promise} - A promise of qDataPages. + * @param {array} qPages - An array of NxPage objects. + * @return {Promise} - A promise of qDataPages. */ getData(qPages: INxPage[]): ng.IPromise; /** * Gets a data row for this object. - * @param {number} rownum - The row number. - * @return {NxCell} - A row of NxCell or null if the row is not available client side and need to be fetched with getData method. + * @param {number} rownum - The row number. + * @return {NxCell} - A row of NxCell or null if the row is not available client side + * and need to be fetched with getData method. */ getDataRow(rownum: number): INxCell; /** * Gets qDimensionInfo for this object. - * @return {NxDimensionInfo[]} - An array of qDimensionInfo objects. + * @return {NxDimensionInfo[]} - An array of qDimensionInfo objects. */ getDimensionInfos(): INxDimensionInfo[]; /** * Gets qMeasureInfo for this object. - * @return {NxMeasureInfo} - An array of qMeasureInfo objects. + * @return {NxMeasureInfo} - An array of qMeasureInfo objects. */ getMeasureInfos(): INxMeasureInfo; /** * Gets pivot data from the Qlik engine for this object. Only works for hypercubes with qMode = P. - * @param {array} qPages - An array of request page objects. - * @return {Promise} - A promise of pivot data pages. + * @param {array} qPages - An array of request page objects. + * @return {Promise} - A promise of pivot data pages. */ getPivotData(qPages: INxPage[]): ng.IPromise; /** - * Get properties for this object. - * @return {Promise} - A promise of object properties. - */ + * Get properties for this object. + * @return {Promise} - A promise of object properties. + */ getProperties(): ng.IPromise; /** - * Get reduced data from the Qlik engine for this object. This method is intended for preserving the shape of the data, not for viewing the actual data points. - * @param {array} qPages - An array of request page objects. - * @param {number} qZoomFactor - Zoom factor. - * If set to -1, the Qlik engine decides of the zoom factor. - * If qReductionMode is D1 or S, the zoom factor is 2n. If the zoom factor is 5, the data are reduced by a factor 32. - * If qReductionMode is C, the zoom factor defines the number of centroids. - * @param {string} qReductionMode - Reduction mode.Can be: - * # N for no data reduction. - * # D1 to reduce a bar chart or line chart. The profile of the chart is reduced whatever the number of dimensions in the chart. - * # S to reduce the resolution of a scatter plot. - * # C to reduce the data of a scatter plot chart. - * # ST to reduce the data of a stacked pivot table. - * @return {Promise} - A promise of reduced data pages. + * Get reduced data from the Qlik engine for this object. This method is intended for preserving the + * shape of the data, not for viewing the actual data points. + * @param {array} qPages - An array of request page objects. + * @param {number} qZoomFactor - Zoom factor. + * If set to -1, the Qlik engine decides of the zoom factor. + * If qReductionMode is D1 or S, the zoom factor is 2n. + * If the zoom factor is 5, the data are reduced by a factor 32. + * If qReductionMode is C, the zoom factor defines the number of centroids. + * @param {string} qReductionMode - Reduction mode.Can be: + * # N for no data reduction. + * # D1 to reduce a bar chart or line chart. + * The profile of the chart is reduced whatever the number of dimensions in the chart. + * # S to reduce the resolution of a scatter plot. + * # C to reduce the data of a scatter plot chart. + * # ST to reduce the data of a stacked pivot table. + * @return {Promise} - A promise of reduced data pages. */ getReducedData(qPages: INxPage[], qZoomFactor: number, qReductionMode: string): ng.IPromise; /** * Get total number of data rows for this object. - * @return {Number} - A number. + * @return {Number} - A number. */ getRowCount(): number; /** * Get stacked data from the Qlik engine for this object. Only works for hypercubes with qMode = S. - * @param {array} qPages - An array of request page objects. - * @param {number} qMaxNbrCells - Maximum number of cells at outer level. - * @return {Promise} - A promise of stack data pages. + * @param {array} qPages - An array of request page objects. + * @param {number} qMaxNbrCells - Maximum number of cells at outer level. + * @return {Promise} - A promise of stack data pages. */ getStackedData(qPages: INxPage[], qMaxNbrCells: number): ng.IPromise; /** * Find out if there are unconfirmed selections for this object. - * @return {boolean} - True if there are unconfirmed selections. + * @return {boolean} - True if there are unconfirmed selections. */ hasSelections(): boolean; /** * Save this object. - * @return {Promise} - A promise. In case of success, it returns "undefined". In case of failure it returns the error. + * @return {Promise} - A promise. In case of success, it returns "undefined". In case of failure it returns the error. */ save(): ng.IPromise; /** * Search for a term in a list object. Results in an updated layout, containing only matching records. - * @param {string} term - Term to search for. + * @param {string} term - Term to search for. */ search(term: string): void; /** * Select values in this object using ranges. - * @param {array} qRanges - Array of ranges to select. - * @param {boolean} qOrMode - If true only one of the measures needs to be in range. + * @param {array} qRanges - Array of ranges to select. + * @param {boolean} qOrMode - If true only one of the measures needs to be in range. */ selectRange(qRanges: IRange[], qOrMode: boolean): void; /** * Select values in this object with a Qlik engine call which triggers a repaint of the object. - * @param {number} qDimNo - Dimension number. 0 = first dimension. - * @param {array} qValues - Array of values (qElemNumber in the matrix from the Qlik engine) to select or deselect. - * @param {boolean} qToggleMode - If true, values in the field are selected in addition to any previously selected items. - * If false, values in the field are selected while previously selected items are deselected. + * @param {number} qDimNo - Dimension number. 0 = first dimension. + * @param {array} qValues - Array of values (qElemNumber in the matrix from the Qlik engine) to select or deselect. + * @param {boolean} qToggleMode - If true, values in the field are selected in addition to any previously selected items. + * If false, values in the field are selected while previously selected items are deselected. */ selectValues(qDimNo: number, qValues: any[], qToggleMode: boolean): void; /** * Set properties for this object. - * @param {object} props - The properties to set. - * @return {Promise} - A promise of a Qlik engine reply. + * @param {object} props - The properties to set. + * @return {Promise} - A promise of a Qlik engine reply. */ setProperties(props: any): ng.IPromise; } @@ -923,114 +942,119 @@ declare namespace RootAPI { interface IRoot { /** * Calls the Qlik Sense repository. - * @param {string} path - Path to the Qlik Sense repository. - * Refer to Qlik Sense repository documentation for the available paths. - * @param {string} [method] - Optional. HTTP method. Default is GET. - * @param {string} [body] - Optional. Body of the post. + * @param {string} path - Path to the Qlik Sense repository. + * Refer to Qlik Sense repository documentation for the available paths. + * @param {string} [method] - Optional. HTTP method. Default is GET. + * @param {string} [body] - Optional. Body of the post. * @return {Promise} - A promise of a Qlik engine reply. */ callRepository(path: string, method?: string, body?: string): ng.IPromise; /** currApp * Gets a reference to the current app. Use the currApp method in an extension to get a reference to the app currently displayed. - * @param {object} [reference] - Optional. Reference to extension object. Introduced in version 1.1. + * @param {object} [reference] - Optional. Reference to extension object. Introduced in version 1.1. * @return {IApp} - An App JavaScript object with app methods. */ currApp(object?: any): AppAPI.IApp; /** * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. - * The getAppList method opens a WebSocket, gets the app list, and then closes the WebSocket. - * @param {function} callback - Callback method. - * @param {object} [config] - Optional. Additional configuration parameters: - * Name | Type | Descr | Name - * host | String | Optional. Qlik host. | host - * port | String or integer | Port number. | port - * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. | prefix - * isSecure | Boolean | Optional. Use SSL. | isSecure - * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. | openWithoutData - * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. | identity + * The getAppList method opens a WebSocket, gets the app list, and then closes the WebSocket. + * @param {function} callback - Callback method. + * @param {object} [config] - Optional. Additional configuration parameters: + * Name | Type | Descr | Name + * host | String | Optional. Qlik host. | host + * port | String or integer | Port number. | port + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. | prefix + * isSecure | Boolean | Optional. Use SSL. | isSecure + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. | openWithoutData + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. | identity */ getAppList(callback: any, config?: any): void; /** - * Gets a list of extensions installed for Qlik Sense. The reply contains all extensions, that is widget libraries, visualization extensions and mashups. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. + * Gets a list of extensions installed for Qlik Sense. The reply contains all extensions, + * that is widget libraries, visualization extensions and mashups. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. */ getExtensionList(callback?: any): ng.IPromise; /** - * Opens a WebSocekt connection to the Qlik engine for global methods. - * @param {object} [config] - Optional. Parameters: - * Name | Type | Description - * host | String | Qlik Sense host - * port | String | Port number - * prefix | String | Qlik Sense virtual proxy. / if no virtual proxy - * isSecure | Boolean | Use SSL - * identity | String | Unique identity for the session. If omitted, the session will be shared. - * @return {ANY} - A global JavaScript object with global methods. - */ + * Opens a WebSocekt connection to the Qlik engine for global methods. + * @param {object} [config] - Optional. Parameters: + * Name | Type | Description + * host | String | Qlik Sense host + * port | String | Port number + * prefix | String | Qlik Sense virtual proxy. / if no virtual proxy + * isSecure | Boolean | Use SSL + * identity | String | Unique identity for the session. If omitted, the session will be shared. + * @return {ANY} - A global JavaScript object with global methods. + */ getGlobal(config: any): any; /** Opens a Qlik Sense app. You can open multiple apps. * Most other methods are defined on the app. Returns: App JavaScript object with app methods. - * @param {string} appId The app id. - * @param {object} [config] Optional. Additional configuration parameters: - * Name | Type | Descr - * host | String | Optional. Qlik host. - * port | String or Integer | Port number. - * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. - * isSecure | Boolean | Optional. Use SSL. - * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. - * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. - * Parameter updated in version 2.2. - * @return {any} - App JavaScript object with app methods. + * @param {string} appId The app id. + * @param {object} [config] Optional. Additional configuration parameters: + * Name | Type | Descr + * host | String | Optional. Qlik host. + * port | String or Integer | Port number. + * prefix | String | Optional. Qlik virtual proxy. "/" if no proxy. + * isSecure | Boolean | Optional. Use SSL. + * openWithoutData | Boolean | Optional. Open app without loading data. Introduced in version 1.1. + * identity | String | Optional. Unique identity for the session. If omitted, the session will be shared. + * Parameter updated in version 2.2. + * @return {any} - App JavaScript object with app methods. */ openApp(appId: string, config?: any): any; /** - * Registers an extension for use in this mashup. The extension is not installed on the Qlik Sense server and only available in the session where it is created. - * As long as a JavaScript module is created in the correct format, it can be sent to the registerExtension function. - * @param {string} id - Set the ID of the visualization extension. - * @param {object} impl - Set the extension implementation. - * @param {object} [metadata] - Optional. Extension meta-data, same format as the QEXT file. Default: {"type":"visualization"} - */ + * Registers an extension for use in this mashup. The extension is not installed on the + * Qlik Sense server and only available in the session where it is created. + * As long as a JavaScript module is created in the correct format, it can be sent to + * the registerExtension function. + * @param {string} id - Set the ID of the visualization extension. + * @param {object} impl - Set the extension implementation. + * @param {object} [metadata] - Optional. Extension meta-data, same format as the QEXT file. Default: {"type":"visualization"} + */ registerExtension(id: string, impl: any, metadata?: any): void; /** - * Sends a resize event to all Qlik Sense objects. - * @param {string} [ID] - Object id. Optional: if no ID resize event will be sent to all objects. - */ + * Sends a resize event to all Qlik Sense objects. + * @param {string} [ID] - Object id. Optional: if no ID resize event will be sent to all objects. + */ resize(ID?: string): void; /** - * Sets a specific language for the Qlik Sense session. - * Language should be defined before the app is opened meaning the setLanguage method should be called before the openApp method is called. - * @param {string} lang - Language code. Can be: - * # German: short: de long: de-DE - * # English: short: en long: en-US - * # Spanish: short: es long: es-ES - * # French: short: fr long: fr-FR - * # Italian: short: it long: it-IT - * # Japanese: short: ja long: ja-JP - * # Korean: (introduced in version 3.0) short: ko long: ko-KR - * # Dutch: short: nl long: nl-NL - * # Polish: (introduced in version 3.0) short: pl long: pl-PL - * # Brazilian Portuguese: short: pt long: pt-BR - * # Russian: short: ru long: ru-RU - * # Swedish: short: sv long: sv-SE - * # Turkish: (introduced in version 3.0) short: tr long: tr-TR - * # Simplified Chinese: short: Do not use! long: zh-CN - * # Traditional Chinese: (introduced in version 3.0) short: Do not use! long: zh-TW - */ + * Sets a specific language for the Qlik Sense session. + * Language should be defined before the app is opened meaning the setLanguage + * method should be called before the openApp method is called. + * @param {string} lang - Language code. Can be: + * # German: short: de long: de-DE + * # English: short: en long: en-US + * # Spanish: short: es long: es-ES + * # French: short: fr long: fr-FR + * # Italian: short: it long: it-IT + * # Japanese: short: ja long: ja-JP + * # Korean: (introduced in version 3.0) short: ko long: ko-KR + * # Dutch: short: nl long: nl-NL + * # Polish: (introduced in version 3.0) short: pl long: pl-PL + * # Brazilian Portuguese: short: pt long: pt-BR + * # Russian: short: ru long: ru-RU + * # Swedish: short: sv long: sv-SE + * # Turkish: (introduced in version 3.0) short: tr long: tr-TR + * # Simplified Chinese: short: Do not use! long: zh-CN + * # Traditional Chinese: (introduced in version 3.0) short: Do not use! long: zh-TW + */ setLanguage(lang: string): void; /** - * Registers a callback for error handling. Standard Qlik Sense error handling is used if this method is not called. - * @param {function} onError - Error handling function - * @param {function} [onWarning] - Optional. Warning handling function. Introduced in version 2.1. - */ + * Registers a callback for error handling. Standard Qlik Sense error + * handling is used if this method is not called. + * @param {function} onError - Error handling function + * @param {function} [onWarning] - Optional. Warning handling function. Introduced in version 2.1. + */ setOnError(onError: any, onWarning?: any): void; /** @@ -1047,260 +1071,278 @@ declare namespace RootAPI { declare namespace AppAPI { interface IApp { - /** - * Adds an alternate state in the app. Multiple states within a Qlik Sense app can be created and applied to specific objects within the app. Objects in a given state are not affected by user selection in the other states. - * @param {string} qStateName - Mandatory. Alternate state name. - * @return {Promise} - A promise of a Qlik engine reply. + /** + * Adds an alternate state in the app. Multiple states within a Qlik Sense + * app can be created and applied to specific objects within the app. + * Objects in a given state are not affected by user selection in the other states. + * @param {string} qStateName - Mandatory. Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. */ addAlternateState(qStateName: string): ng.IPromise; /** - * Steps back in the list of selections. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Steps back in the list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ back(): ng.IPromise; /** - * Clears all selections in all fields of the current Qlik Sense app. - * @param {boolean} [lockedAlso] - Optional. Alternate state name. Default: false Introduced in version 2.1. - * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Clears all selections in all fields of the current Qlik Sense app. + * @param {boolean} [lockedAlso] - Optional. Alternate state name. Default: false Introduced in version 2.1. + * @param {string} [state] - Optional. Alternate state name. Default: $ Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ clearAll(lockedAlso?: boolean, state?: string): ng.IPromise; /** - * Closes a Qlik Sense app. Also closes the WebSocket and clears out client side data. - */ + * Closes a Qlik Sense app. Also closes the WebSocket and clears out client side data. + */ close(): void; /** - * Defines a hypercube and registers a callback to receive the data. - * @param {object} qHyperCubeDef - Cube definition. - * @param {function} [callback] - Optional. Callback method. Parameter will contain a qHyperCube. - * @return {Promise} - A promise of an object model. - */ + * Defines a hypercube and registers a callback to receive the data. + * @param {object} qHyperCubeDef - Cube definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qHyperCube. + * @return {Promise} - A promise of an object model. + */ createCube(qHyperCubeDef: any, callback?: any): ng.IPromise; /** - * Creates a generic object and registers a callback to receive the data. The generic object can contain the following: - * # qHyperCubeDef - * # qListObjectDef - * # qStringExpression - * # qValueExpression - * The callback method will be called whenever the selection state changes in a way that affects the generic object. The parameter will be the evaluated version of the definition. - * @param {object} [def] - Optional. Generic object definition - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of an object model. - */ + * Creates a generic object and registers a callback to receive the data. The generic object can contain the following: + * # qHyperCubeDef + * # qListObjectDef + * # qStringExpression + * # qValueExpression + * The callback method will be called whenever the selection state changes + * in a way that affects the generic object. + * The parameter will be the evaluated version of the definition. + * @param {object} [def] - Optional. Generic object definition + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of an object model. + */ createGenericObject(def?: any, callback?: any): ng.IPromise; /** - * Defines a list of field values and registers a callback to receive the data. - * @param {object} qListObjectDef - List definition. - * @param {function} [callback] - Optional. Callback method. Parameter will contain a qListObject. - * @return {Promise} - A promise of an object model. - */ + * Defines a list of field values and registers a callback to receive the data. + * @param {object} qListObjectDef - List definition. + * @param {function} [callback] - Optional. Callback method. Parameter will contain a qListObject. + * @return {Promise} - A promise of an object model. + */ createList(qListObjectDef: any, callback?: any): ng.IPromise; /** - * Defines a hypercube for a table and is the entry point to the Table API. It creates a table object that wraps the hypercube. - * @param {Array.} dimensions - Dimensions to use. + * Defines a hypercube for a table and is the entry point to the Table API. + * It creates a table object that wraps the hypercube. + * @param {Array.} dimensions - Dimensions to use. * Should, for each entry, be a field name or a NxDimension structure. - * @param {Array.} measures - Measures to use. + * @param {Array.} measures - Measures to use. * Should, for each entry, be an expression or a NxMeasure structure. - * @param {object} [options] - Optional. Options to set. - * @return {QTable} - A table object of type QTable, which is initially empty but that eventually will contain data. The table object will be updated when selection state changes. - */ + * @param {object} [options] - Optional. Options to set. + * @return {QTable} - A table object of type QTable, which is initially + * empty but that eventually will contain data. + * The table object will be updated when selection state changes. + */ createTable(dimensions: string[] | any[], measures: string[] | any[], options?: any): TableAPI.IQTable; /** - * Destroys a Qlik Sense session object created with the createGenericObject method or any of createCube, createList or getList methods. - * Calling this method removes the object from the Qlik engine, no more updates are sent to the client and all methods on the object are invalid. - * @param {string} id - Session object id. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Destroys a Qlik Sense session object created with the createGenericObject + * method or any of createCube, createList or getList methods. + * Calling this method removes the object from the Qlik engine, + * no more updates are sent to the client and all methods on the object are invalid. + * @param {string} id - Session object id. + * @return {Promise} - A promise of a Qlik engine reply. + */ destroySessionObject(id: string): ng.IPromise; /** - * Reloads the data in a Qlik Sense app. - * @param {string} [qMode] - Optional. Error handling mode: - * # 0 = default mode. - * # 1 = attempt recovery on all errors. - * # 2 = fail on all errors. - * @param {boolean} [qPartial] - Optional. Set to true for partial reload. - * @param {boolean} [qDebug] - Optional. Set to true if debug breakpoints are honored. Execution of the script will be in debug mode. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Reloads the data in a Qlik Sense app. + * @param {string} [qMode] - Optional. Error handling mode: + * # 0 = default mode. + * # 1 = attempt recovery on all errors. + * # 2 = fail on all errors. + * @param {boolean} [qPartial] - Optional. Set to true for partial reload. + * @param {boolean} [qDebug] - Optional. Set to true if debug breakpoints are honored. Execution of the script will be in debug mode. + * @return {Promise} - A promise of a Qlik engine reply. + */ doReload(qMode?: string, qPartial?: boolean, qDebug?: boolean): ng.IPromise; /** - * Saves a Qlik Sense app, including all objects and data in the data model. - * @param {string} [qFileName] - Optional. File name of the file to save. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Saves a Qlik Sense app, including all objects and data in the data model. + * @param {string} [qFileName] - Optional. File name of the file to save. + * @return {Promise} - A promise of a Qlik engine reply. + */ doSave(qFileName?: string): ng.IPromise; /** - * Gets a field reference with methods that can be used to manipulate the field. - * @param {string} [field] - Optional. Name of the field. - * @param {string} [state] - Optional. Alternate state name. Default is $. - * @return {QField} - A QField object with methods and properties that can be used to manipulate the field. - */ + * Gets a field reference with methods that can be used to manipulate the field. + * @param {string} [field] - Optional. Name of the field. + * @param {string} [state] - Optional. Alternate state name. Default is $. + * @return {QField} - A QField object with methods and properties that can be used to manipulate the field. + */ field(field?: string, state?: string): FieldAPI.IQField; /** - * Step forward in list of selections. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Step forward in list of selections. + * @return {Promise} - A promise of a Qlik engine reply. + */ forward(): ng.IPromise; /** - * Gets a layout for this Qlik Sense app and registers a callback to receive the data. Returns the dynamic properties (if any) in addition to the fixed properties. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Gets a layout for this Qlik Sense app and registers a callback to receive the data. + * Returns the dynamic properties (if any) in addition to the fixed properties. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ getAppLayout(callback?: any): ng.IPromise; /** - * Gets a list of sheets and visualizations and registers a callback to receive the data. - * @param {string} [field] - Optional. Type of object. One of: - * # sheet - * # masterobject - * Default is sheet. - * @param {function} [callback] - Optional. Callback method. - */ + * Gets a list of sheets and visualizations and registers a callback to receive the data. + * @param {string} [field] - Optional. Type of object. One of: + * # sheet + * # masterobject + * Default is sheet. + * @param {function} [callback] - Optional. Callback method. + */ getAppObjectList(type?: string, callback?: any): void; /** - * Gets properties for a generic object, the children of the generic object and the bookmarks and/or embedded snapshots of the generic object. - * @param {string} id - Object id. - * @return {Promise} - A promise of an object model. - */ + * Gets properties for a generic object, the children of the generic object + * and the bookmarks and/or embedded snapshots of the generic object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ getFullPropertyTree(id: string): ng.IPromise; /** - * Gets a list of internal Qlik Sense objects and registers a callback to receive the data. - * @param {string} type - Type of object: - * # FieldList - * # MeasureList - * # DimensionList - * # BookmarkList - * # SelectionObject - * # SnapshotList (Introduced in version 1.1) - * # MediaList (Introduced in version 1.1) - * # Sheet (Introduced in version 1.1) - * # MasterObject (Introduced in version 1.1) - * # VariableList (Introduced in version 2.0) - * # story (Introduced in version 2.1) - * @param {function} [callback] - Optional. Registers a callback that is executed every time data is returned. - * @return {Promise} - A promise of an object model. - */ + * Gets a list of internal Qlik Sense objects and registers a callback to receive the data. + * @param {string} type - Type of object: + * # FieldList + * # MeasureList + * # DimensionList + * # BookmarkList + * # SelectionObject + * # SnapshotList (Introduced in version 1.1) + * # MediaList (Introduced in version 1.1) + * # Sheet (Introduced in version 1.1) + * # MasterObject (Introduced in version 1.1) + * # VariableList (Introduced in version 2.0) + * # story (Introduced in version 2.1) + * @param {function} [callback] - Optional. Registers a callback that is executed every time data is returned. + * @return {Promise} - A promise of an object model. + */ getList(type: string, callback?: any): ng.IPromise; /** - * Retrieves a Qlik Sense object from the Qlik Sense application and inserts it into a HTML element. The object fills the HTML object, so you can size and position the element to determine how large the Qlik Sense object will be. - * If you supply only one parameter, you get the model without displaying the object. - * @param {string} id - Object id or 'CurrentSelections' if used for Selections bar. + * Retrieves a Qlik Sense object from the Qlik Sense application and inserts + * it into a HTML element. The object fills the HTML object, so you can size + * and position the element to determine how large the Qlik Sense object will be. + * If you supply only one parameter, you get the model without displaying the object. + * @param {string} id - Object id or 'CurrentSelections' if used for Selections bar. * @param {Element | string} [elem] - Optional. HTML element. * Since version 1.1 it is also possible to define a string of the HTML element id. - * @param {object} [options] - Optional. - * Name | Type | Description - * noInteraction | Boolean | Set to true if you want to disable interaction, including selections, in the visualization. Introduced in version 1.1 and updated in version 3.0. - * noSelections | Boolean | Set to true if you want to disable selections in the visualization. Introduced in version 3.0. - * @return {Promise} - A promise of an object model. - */ + * @param {object} [options] - Optional. + * Name | Type | Description + * noInteraction | Boolean | Set to true if you want to disable interaction, + * including selections, in the visualization. + * Introduced in version 1.1 and updated in version 3.0. + * noSelections | Boolean | Set to true if you want to disable selections in the visualization. + * Introduced in version 3.0. + * @return {Promise} - A promise of an object model. + */ getObject(id: string, elem?: any | string, options?: any): ng.IPromise; /** - * Gets properties for a Qlik Sense object. - * @param {string} id - Object id. - * @return {Promise} - A promise of an object model. - */ + * Gets properties for a Qlik Sense object. + * @param {string} id - Object id. + * @return {Promise} - A promise of an object model. + */ getObjectProperties(id: string): ng.IPromise; /** - * Inserts a Qlik Sense snapshot into a HTML element. The snapshot fills the HTML object so you can size and position the element to determine how large the Qlik Sense object will be. - * If you only supply one parameter, you will just get the model without displaying the object. + * Inserts a Qlik Sense snapshot into a HTML element. The snapshot fills + * the HTML object so you can size and position the element to determine + * how large the Qlik Sense object will be. If you only supply one parameter, + * you will just get the model without displaying the object. * @param {string} id - Snapshot ID. * @param {element | string} [elem] - Optional. HTML element or string with HTML element id. - * @return {Promise} - A promise of an object model. - */ + * @return {Promise} - A promise of an object model. + */ getSnapshot(id: string, elem?: any | string): ng.IPromise; /** - * Locks all selections. - * @param {string} [state=$] - Optional. Alternate state name. - * Default: $ - * Introduced in version 2.1. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Locks all selections. + * @param {string} [state=$] - Optional. Alternate state name. + * Default: $ + * Introduced in version 2.1. + * @return {Promise} - A promise of a Qlik engine reply. + */ lockAll(state?: string): ng.IPromise; /** - * Removes an alternate state in the app. - * @param {string} qStateName - Alternate state name. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Removes an alternate state in the app. + * @param {string} qStateName - Alternate state name. + * @return {Promise} - A promise of a Qlik engine reply. + */ removeAlternateState(qStateName: string): ng.IPromise; /** - * Searches for one or more terms in the values of a Qlik Sense app. - * @param {array} qTerms - Terms to search for. - * @param {object} qPage - Properties: - * Name | Type | Description - * qOffset | Number | Position from the top, starting from 0. - * qCount | Number | Number of search results to return. - * qMaxNbrFieldMatches | Number | Maximum number of matching values to return per search result. - * @param {object} qOptions - Properties - * Name | Type | Description - * qSearchFields | Array | List of search fields. - * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. - * | | Default value is LockedFieldsOnly. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qMaxNbrFieldMatches | Number | Maximum number of matching values to return per search result. + * @param {object} qOptions - Properties + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ searchAssociations(qTerms: any[], qPage: any, qOptions: any, callback?: any): ng.IPromise; /** - * Searches for one or more terms in the values of a Qlik Sense app. - * @param {array} qTerms - Terms to search for. - * @param {object} qPage - Properties: - * Name | Type | Description - * qOffset | Number | Position from the top, starting from 0. - * qCount | Number | Number of search results to return. - * qGroupOptions | Array | This parameter is optional. Options of the search groups. If this property is not set, all values are returned. - * qGroupItemOptions | Array | This parameter is optional. Options of the search group items. If this property is not set, all values are returned. - * qOptions | Object | Optional. Search options. Properties: - * Name | Type | Description - * qSearchFields | Array | List of search fields. - * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. - * | | Default value is LockedFieldsOnly. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Searches for one or more terms in the values of a Qlik Sense app. + * @param {array} qTerms - Terms to search for. + * @param {object} qPage - Properties: + * Name | Type | Description + * qOffset | Number | Position from the top, starting from 0. + * qCount | Number | Number of search results to return. + * qGroupOptions | Array | This parameter is optional. Options of the search groups. If this property is not set, all values are returned. + * qGroupItemOptions | Array | This parameter is optional. Options of the search group items. If this property is not set, all values are returned. + * qOptions | Object | Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * qContext | | Search context. Can be one of: + * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * | | Default value is LockedFieldsOnly. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ searchResults(qTerms: any[], qPage: any, qOptions?: any, callback?: any): ng.IPromise; /** - * Returns suggestions of words from the values entered in the search. Acts as a helper for the searchAssociations method. - * @param {array} qTerms - Terms to search for. - * @param {object} [qOptions] - Optional. Search options. Properties: - * Name | Type | Description - * qSearchFields | Array | List of search fields. - * @param {function} [callback] - Optional. Callback method. - * @return {Promise} - A promise of a Qlik engine reply. - */ + * Returns suggestions of words from the values entered in the search. Acts as a helper for the searchAssociations method. + * @param {array} qTerms - Terms to search for. + * @param {object} [qOptions] - Optional. Search options. Properties: + * Name | Type | Description + * qSearchFields | Array | List of search fields. + * @param {function} [callback] - Optional. Callback method. + * @return {Promise} - A promise of a Qlik engine reply. + */ searchSuggest(qTerms: any[], qOptions?: any, callback?: any): ng.IPromise; /** - * Makes a selection based on searchAssociation results. - * @param {number} qMatchIx - Index to search result. - * @param {array} qTerms - Values to select. + * Makes a selection based on searchAssociation results. + * @param {number} qMatchIx - Index to search result. + * @param {array} qTerms - Values to select. * @param {object} qOptions - Values to select. * @param {array} [qTerms] - Optional. Parameter sent to the Qlik engine containing information about the search fields and the search context. * @param {object} [qSoftLock] - Optional. This parameter was deprecated in version 2.0 and is ignored in newer versions. Use the qOtions.qContext parameter instead. @@ -1365,7 +1407,9 @@ declare namespace FieldAPI { clearOther(softlock?: boolean): ng.IPromise; /** - * Gets field data. The values are available as QFieldValue in array field.rows and will updated when the selection state changes. Notification OnData will be triggered after each update. + * Gets field data. The values are available as QFieldValue in array + * field.rows and will updated when the selection state changes. + * Notification OnData will be triggered after each update. * @param {boolean} [options] - Optional. Properties: * Name | Type | Description * rows | Number | Number of rows to fetch. Default: 200. @@ -1438,7 +1482,8 @@ declare namespace FieldAPI { /** * Selects specific values in a field. - * @param {array} array - Array of qFieldValues to select. A simplified syntax with strings or numbers also works since version 1.1. + * @param {array} array - Array of qFieldValues to select. A simplified syntax with + * strings or numbers also works since version 1.1. * For a numeric field you need to provide the numeric value. * @param {boolean} [toggle] - Optional. If true, toggle selected state. * @param {boolean} [softlock] - Optional. If true, locked selections can be overridden. @@ -1471,7 +1516,8 @@ declare namespace FieldAPI { rowCount: number; /** - * Optional. Object with number of values in different states. Only after getData() call. Introduced in 2.1. + * Optional. Object with number of values in different states. + * Only after getData() call. Introduced in 2.1. */ qStateCounts: any; } @@ -1521,8 +1567,10 @@ declare namespace GlobalAPI { cancelReload(): ng.IPromise; /** - * Gets a list of Qlik Sense apps that you potentially can connect to and registers a callback to receive the data. - * Calling the getAppList method opens a WebSocket, gets the app list, and then keeps the WebSocket open for you to make other calls as well. + * Gets a list of Qlik Sense apps that you potentially can connect to and + * registers a callback to receive the data. Calling the getAppList method + * opens a WebSocket, gets the app list, and then keeps the WebSocket open + * for you to make other calls as well. * @param {Function} callback - Callback method. */ getAppList(callback: any): void; @@ -1566,7 +1614,9 @@ declare namespace GlobalAPI { getQvVersion(callback?: any): ng.IPromise; /** - * Gets information if the user is working in personal mode (returns true if Qlik Sense Desktop is used) or not (returns false if Qlik Sense Desktop is not used). + * Gets information if the user is working in personal mode + * (returns true if Qlik Sense Desktop is used) or not + * (returns false if Qlik Sense Desktop is not used). * @param {Function} [callback] - Optional. Callback method. * @return {Promise} - A promise of a Qlik engine reply. */ @@ -1641,14 +1691,16 @@ declare namespace NavigationAPI { getMode(): string; /** - * Navigate to a given sheet in the current app. The method will return before the actual navigation takes place. + * Navigate to a given sheet in the current app. + * The method will return before the actual navigation takes place. * @param {string} sheetId - Set the sheet ID to navigate to. * @return {NavigationResult} - A navigation result object. */ gotoSheet(sheetId: string): NavigationResult; /** - * Navigate to a given story in the current app. The method will return before the actual navigation takes place. + * Navigate to a given story in the current app. + * The method will return before the actual navigation takes place. * @param {string} storyId - Set the story ID to navigate to. * @return {NavigationResult} - A navigation result object. */ @@ -1663,14 +1715,16 @@ declare namespace NavigationAPI { isModeAllowed(mode: NavigationModeType): boolean; /** - * Go to the next sheet in the current app. It will do nothing if you do not have sheets in the current context. + * Go to the next sheet in the current app. + * It will do nothing if you do not have sheets in the current context. * The method will return before the actual navigation takes place. * @return {NavigationResult} - A navigation result object. */ nextSheet(): NavigationResult; /** - * Jumps to the previous sheet in the current app. It will do nothing if you do not have sheets in the current context. + * Jumps to the previous sheet in the current app. + * It will do nothing if you do not have sheets in the current context. * The method will return before the actual navigation takes place * @return {NavigationResult} - A navigation result object. */ @@ -1742,17 +1796,20 @@ declare namespace SelectionStateAPI { qStateCounts: any; /** - * Concatenated string of selected values if number of values are less than the threshold, or if the string is of format "7 of 123". + * Concatenated string of selected values if number of values are less + * than the threshold, or if the string is of format "7 of 123". */ qSelected: string; /** - * Array with maximum of qSelectionThreshold values that are selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + * Array with maximum of qSelectionThreshold values that are selected. + * For each value, the text plus the selection mode (NORMAL/AND/NOT) */ selectedValues: number[]; /** - * Array with maximum of qSelectionThreshold values that are not selected. For each value, the text plus the selection mode (NORMAL/AND/NOT) + * Array with maximum of qSelectionThreshold values that are not selected. + * For each value, the text plus the selection mode (NORMAL/AND/NOT) */ notSelectedValues: number[]; } @@ -1834,7 +1891,8 @@ declare namespace TableAPI { * # OOXML: open XML, default * # CSV_C: comma separated CSV * # CSV_T: tab separated CSV - * filename | String | Name of the exported file after download from browser. This parameter is optional and only used in desktop. + * filename | String | Name of the exported file after download from browser. + * This parameter is optional and only used in desktop. * state | String | Can be: * # A: all values * # P: possible values (default) @@ -1890,12 +1948,14 @@ declare namespace TableAPI { qCardinal?: number; /** - * Optional. Object with number of values in different states. Only used for dimensions. + * Optional. Object with number of values in different states. + * Only used for dimensions. */ qStateCounts?: any; /** - * Optional. Field object with methods to manipulate the underlying field. Only used for dimensions. + * Optional. Field object with methods to manipulate the underlying field. + * Only used for dimensions. */ field?: any; @@ -1910,12 +1970,14 @@ declare namespace TableAPI { qMax?: number; /** - * Optional. Error code for this column. Only if column has an error. Introduced in version 2.2. + * Optional. Error code for this column. + * Only if column has an error. Introduced in version 2.2. */ errorCode?: number; /** - * Error message for this column. Only if column has an error. Introduced in version 2.2. + * Error message for this column. + * Only if column has an error. Introduced in version 2.2. */ errorMessage: number; @@ -1986,7 +2048,8 @@ declare namespace TableAPI { qNum?: number; /** - * Gets the value of this cell as a percentage of the total. Might be more than 100% if this is an average. + * Gets the value of this cell as a percentage of the total. + * Might be more than 100% if this is an average. */ getPercent(): number; @@ -2014,7 +2077,8 @@ declare namespace VariableAPI { create(qProp: string | any): ng.IPromise; /** - * Creates a session variable, that is a temporary variable which is not persisted and needs to be recreated for each new session. + * Creates a session variable, that is a temporary variable which is not + * persisted and needs to be recreated for each new session. * @param {object} qProp - Variable properties: * Name | Type | Description * qInfo.qId | String | Optional. Variable id. @@ -2081,7 +2145,8 @@ declare namespace VisualizationAPI { interface IVisualization { /** - * Create a new visualization on the fly based on a session object and will not be persisted in the app. + * Create a new visualization on the fly based on a session object + * and will not be persisted in the app. * @param {VisualizationType} type - Visualization type. Can be: * # barchart * # combochart @@ -2094,11 +2159,13 @@ declare namespace VisualizationAPI { * # table * # treemap * # extension - * @param {array} [cols] - Optional. Column definitions, dimensions and measures. Each entry can be of the following structures: + * @param {array} [cols] - Optional. Column definitions, dimensions and measures. + Each entry can be of the following structures: * # String * # NxDimension * # NxMeasure - * If the NxDimension or the NxMeasure refer to a library dimension or a library measure, you also need to add qType : "measure" or "dimension". + * If the NxDimension or the NxMeasure refer to a library dimension + * or a library measure, you also need to add qType : "measure" or "dimension". * @param {object} [options] - Optional. Options to set. * @return {Promise} - A promise of a QVisualization. */ @@ -2114,7 +2181,8 @@ declare namespace VisualizationAPI { interface IQVisualization { /** - * Table object for this visualization. Only for visualizations built on a hypercube. + * Table object for this visualization. + * Only for visualizations built on a hypercube. */ table: TableAPI.IQTable; @@ -2399,8 +2467,10 @@ interface IQVAngular { filter(object: { [name: string]: ng.Injectable }): void; /** - * Register a service constructor, which will be invoked with new to create the service instance. This is short for registering a service where its provider's $get property is a factory function that returns an instance instantiated by the injector from the service constructor function. - * + * Register a service constructor, which will be invoked with new to create + * the service instance. This is short for registering a service where its + * provider's $get property is a factory function that returns an instance + * instantiated by the injector from the service constructor function. * @param name The name of the instance. * @param serviceConstructor An injectable class (constructor function) that will be instantiated. * @return Returns the constructed singleton of the service class/function. diff --git a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts index 2e1d738198..76a71d22dc 100644 --- a/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts +++ b/qlik-visualizationextensions/qlik-visualizationextensions-tests.ts @@ -1,3 +1,3 @@ -import qlik=require("qlik"); +import qlik = require("qlik"); const t = qlik.currApp(); \ No newline at end of file diff --git a/qlik-visualizationextensions/tsconfig.json b/qlik-visualizationextensions/tsconfig.json index f4a5bc132a..c71a5c597d 100644 --- a/qlik-visualizationextensions/tsconfig.json +++ b/qlik-visualizationextensions/tsconfig.json @@ -7,7 +7,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" diff --git a/qlik-visualizationextensions/tslint.json b/qlik-visualizationextensions/tslint.json index 965a36a968..cae1bdf2ad 100644 --- a/qlik-visualizationextensions/tslint.json +++ b/qlik-visualizationextensions/tslint.json @@ -1,4 +1,5 @@ -{ "extends": "../tslint.json", +{ + "extends": "../tslint.json", "rules": { "forbidden-types": false, "no-empty-interface": false, From 63fd21838b726dc7dacd07c2704819fd8a8cb0c5 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Sun, 12 Mar 2017 16:01:20 +0100 Subject: [PATCH 079/258] fix trailing whitespaces Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index 4f384ca925..bb1d6dd6f5 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -772,7 +772,7 @@ declare namespace BackendAPI { /** * Gets a data row for this object. * @param {number} rownum - The row number. - * @return {NxCell} - A row of NxCell or null if the row is not available client side + * @return {NxCell} - A row of NxCell or null if the row is not available client side * and need to be fetched with getData method. */ getDataRow(rownum: number): INxCell; @@ -1242,7 +1242,7 @@ declare namespace AppAPI { * Since version 1.1 it is also possible to define a string of the HTML element id. * @param {object} [options] - Optional. * Name | Type | Description - * noInteraction | Boolean | Set to true if you want to disable interaction, + * noInteraction | Boolean | Set to true if you want to disable interaction, * including selections, in the visualization. * Introduced in version 1.1 and updated in version 3.0. * noSelections | Boolean | Set to true if you want to disable selections in the visualization. From 26f66082018071739cdc822b1bfdd4d68ba8e750 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Mon, 13 Mar 2017 07:43:51 +0100 Subject: [PATCH 080/258] fix "max-line-length Exceeds maximum line length of 200" Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 30 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index bb1d6dd6f5..d12cbac656 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -1297,9 +1297,18 @@ declare namespace AppAPI { * Name | Type | Description * qSearchFields | Array | List of search fields. * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * # Cleared: In this mode, the first step is to clear any current selections in the app. + * The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * with the selections made in locked fields, ignoring selections + * in any unlocked field. If no locked fields, the behavior is + * identical to the Cleared context. You cannot make any new selections + * in a locked field. You can get search hits for the associated values + * of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections:In this mode, the current selections are kept (if any). Search + * for one or more terms in the values of the app. New selections + * are made on top of the current selections. If no selections were + * made before the search, this mode is identical to the Cleared context. * | | Default value is LockedFieldsOnly. * @param {function} [callback] - Optional. Callback method. * @return {Promise} - A promise of a Qlik engine reply. @@ -1319,9 +1328,18 @@ declare namespace AppAPI { * Name | Type | Description * qSearchFields | Array | List of search fields. * qContext | | Search context. Can be one of: - * # Cleared: In this mode, the first step is to clear any current selections in the app. The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated with the selections made in locked fields, ignoring selections in any unlocked field. If no locked fields, the behavior is identical to the Cleared context. You cannot make any new selections in a locked field. You can get search hits for the associated values of a locked field but you cannot get the search hits for the non associative values. - * # CurrentSelections: In this mode, the current selections are kept (if any). Search for one or more terms in the values of the app. New selections are made on top of the current selections. If no selections were made before the search, this mode is identical to the Cleared context. + * # Cleared: In this mode, the first step is to clear any current selections in the app. + * The second step is to search for one or more terms in the values of the app. + * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * with the selections made in locked fields, ignoring selections + * in any unlocked field. If no locked fields, the behavior is + * identical to the Cleared context. You cannot make any new selections + * in a locked field. You can get search hits for the associated values + * of a locked field but you cannot get the search hits for the non associative values. + * # CurrentSelections:In this mode, the current selections are kept (if any). Search + * for one or more terms in the values of the app. New selections + * are made on top of the current selections. If no selections were + * made before the search, this mode is identical to the Cleared context. * | | Default value is LockedFieldsOnly. * @param {function} [callback] - Optional. Callback method. * @return {Promise} - A promise of a Qlik engine reply. From 31a8844a49a39605d37f4ef4d3062a55881a6481 Mon Sep 17 00:00:00 2001 From: Konrad Mattheis Date: Mon, 13 Mar 2017 07:49:25 +0100 Subject: [PATCH 081/258] fix some trailing white spaces Signed-off-by: Konrad Mattheis --- qlik-visualizationextensions/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/qlik-visualizationextensions/index.d.ts b/qlik-visualizationextensions/index.d.ts index d12cbac656..e5d5850423 100644 --- a/qlik-visualizationextensions/index.d.ts +++ b/qlik-visualizationextensions/index.d.ts @@ -1299,7 +1299,7 @@ declare namespace AppAPI { * qContext | | Search context. Can be one of: * # Cleared: In this mode, the first step is to clear any current selections in the app. * The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * # LockedFieldsOnly: In this mode, the search applies only to the values associated * with the selections made in locked fields, ignoring selections * in any unlocked field. If no locked fields, the behavior is * identical to the Cleared context. You cannot make any new selections @@ -1330,8 +1330,8 @@ declare namespace AppAPI { * qContext | | Search context. Can be one of: * # Cleared: In this mode, the first step is to clear any current selections in the app. * The second step is to search for one or more terms in the values of the app. - * # LockedFieldsOnly: In this mode, the search applies only to the values associated - * with the selections made in locked fields, ignoring selections + * # LockedFieldsOnly: In this mode, the search applies only to the values associated + * with the selections made in locked fields, ignoring selections * in any unlocked field. If no locked fields, the behavior is * identical to the Cleared context. You cannot make any new selections * in a locked field. You can get search hits for the associated values From 10b1dd1ba5964dbbc380a96782d110edbe099f3c Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 10:20:33 +0100 Subject: [PATCH 082/258] Async: made AsyncFunction return void again. --- async/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/async/index.d.ts b/async/index.d.ts index 7f71f3b9bc..b46002d971 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -11,7 +11,7 @@ interface AsyncResultCallback { (err?: E, result?: T): void; } interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } -interface AsyncFunction { (callback: (err?: E, result?: T) => void): any; } +interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } interface AsyncForEachOfIterator { (item: T, key: number|string, callback: ErrorCallback): void; } interface AsyncResultIterator { (item: T, callback: AsyncResultCallback): void; } From aebfd7772bc582ed8d6f646f0ecfcb183e5a02c5 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 12:53:33 +0100 Subject: [PATCH 083/258] async: reflectAll err is always null --- async/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/async/index.d.ts b/async/index.d.ts index b46002d971..88d4cf900b 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -193,7 +193,7 @@ interface Async { setImmediate: typeof async.nextTick; reflect(fn: AsyncFunction) : (callback: (err: null, result: {error?: E, value?: T}) => void) => void; - reflectAll(tasks: AsyncFunction[]): ((callback: (err: undefined, result: {error?: E, value?: T}) => void) => void)[]; + reflectAll(tasks: AsyncFunction[]): ((callback: (err: null, result: {error?: E, value?: T}) => void) => void)[]; timeout(fn: AsyncFunction, milliseconds: number, info?: any): AsyncFunction; timeout(fn: AsyncResultIterator, milliseconds: number, info?: any): AsyncResultIterator; From 8875c23774e1fea4f4e6293c6a29d57172c3b5a8 Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 14:20:12 +0100 Subject: [PATCH 084/258] async: 3 more small errors i found --- async/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/async/index.d.ts b/async/index.d.ts index 88d4cf900b..a17735eb6e 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -9,7 +9,7 @@ interface ErrorCallback { (err?: T): void; } interface AsyncBooleanResultCallback { (err?: E, truthValue?: boolean): void; } interface AsyncResultCallback { (err?: E, result?: T): void; } interface AsyncResultArrayCallback { (err?: E, results?: (T | undefined)[]): void; } -interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } +interface AsyncResultObjectCallback { (err: E | undefined, results: Dictionary): void; } interface AsyncFunction { (callback: (err?: E, result?: T) => void): void; } interface AsyncIterator { (item: T, callback: ErrorCallback): void; } @@ -174,7 +174,7 @@ interface Async { during(test: (testCallback : AsyncBooleanResultCallback) => void, fn: AsyncVoidFunction, callback: ErrorCallback): void; doDuring(fn: AsyncVoidFunction, test: (testCallback: AsyncBooleanResultCallback) => void, callback: ErrorCallback): void; forever(next: (next : ErrorCallback) => void, errBack: ErrorCallback) : void; - waterfall(tasks: Function[], callback?: AsyncResultCallback): void; + waterfall(tasks: Function[], callback?: AsyncResultCallback): void; compose(...fns: Function[]): Function; seq(...fns: Function[]): Function; applyEach(fns: Function[], argsAndCallback: any[]): void; // applyEach(fns, args..., callback). TS does not support ... for a middle argument. Callback is optional. @@ -207,7 +207,7 @@ interface Async { transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; - race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; + race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; // Utils memoize(fn: Function, hasher?: Function): Function; From 04573ae491126ace626edc4866c73502d1881dbb Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Mon, 13 Mar 2017 14:27:09 +0100 Subject: [PATCH 085/258] async: Changed strictNullChecks to true, and fixed the tests --- async/test/explicit.ts | 54 ++++++++++++++++++++++++++++++++---------- async/test/index.ts | 16 ++++++------- async/tsconfig.json | 4 ++-- 3 files changed, 52 insertions(+), 22 deletions(-) diff --git a/async/test/explicit.ts b/async/test/explicit.ts index 80343cf6b1..b9ea9c84ed 100644 --- a/async/test/explicit.ts +++ b/async/test/explicit.ts @@ -1,44 +1,74 @@ -interface StringCallback { (err: Error, result: string): void; } +interface StringCallback { (err?: Error, result?: string): void; } interface AsyncStringGetter { (callback: StringCallback): void; } var taskArray: AsyncStringGetter[] = [ function (callback) { setTimeout(function () { - callback(null, 'one'); + callback(undefined, 'one'); }, 200); }, function (callback) { setTimeout(function () { - callback(null, 'two'); + callback(undefined, 'two'); }, 100); }, ]; -async.series(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); -async.parallel(taskArray, function (err, results) { console.log(results[0].match(/o/)) }); -async.parallelLimit(taskArray, 3, function (err, results) { console.log(results[0].match(/o/)) }); +async.series(taskArray, function (err, results) { + if (results) { + let first = results[0]; + if (first) { + console.log(first.match(/o/)) + } + } +}); +async.parallel(taskArray, function (err, results) { + if (results) { + let first = results[0]; + if (first) { + console.log(first.match(/o/)) + } + } +}); +async.parallelLimit(taskArray, 3, function (err, results) { + if (results) { + let first = results[0]; + if (first) { + console.log(first.match(/o/)) + } + } +}); interface Lookup { [key: string]: T; } -interface NumberCallback { (err: Error, result: number): void; } +interface NumberCallback { (err?: Error, result?: number): void; } interface AsyncNumberGetter { (callback: NumberCallback): void; } var taskDict: Lookup = { one: function(callback){ setTimeout(function(){ - callback(null, 1); + callback(undefined, 1); }, 200); }, two: function(callback){ setTimeout(function(){ - callback(null, 2); + callback(undefined, 2); }, 100); } } -async.series(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); -async.parallel(taskDict, function(err, results) { console.log(results['one'].toFixed(1)) }); -async.parallelLimit(taskDict, 3, function(err, results) { console.log(results['one'].toFixed(1)) }); +async.series(taskDict, function(err, results) { + let one = results['one']; + console.log(one && one.toFixed(1)) +}); +async.parallel(taskDict, function(err, results) { + let one = results['one']; + console.log(one && one.toFixed(1)) +}); +async.parallelLimit(taskDict, 3, function(err, results) { + let one = results['one']; + console.log(one && one.toFixed(1)) +}); diff --git a/async/test/index.ts b/async/test/index.ts index 8c6be303e4..b30ca4c7ba 100644 --- a/async/test/index.ts +++ b/async/test/index.ts @@ -350,9 +350,9 @@ q2.unshift(['task3', 'task4', 'task5'], function (error) { }); -var aq = async.queue(function (level: number, callback: (error : Error, newLevel: number) => void) { +var aq = async.queue(function (level: number, callback: (error?: Error, newLevel?: number) => void) { console.log('hello ' + level); - callback(null, level+1); + callback(undefined, level+1); }); aq.push(1, function (err : Error, newLevel : number) { @@ -807,9 +807,9 @@ async.some({ // timeout -function myFunction1(foo : any, callback: (err : Error, result : any) => void ) : void { +function myFunction1(foo : any, callback: (err?: Error, result?: any) => void ) : void { console.log(`async.timeout 1 ${foo}`); - return callback(null, foo); + return callback(undefined, foo); } var wrapped1 = async.timeout(myFunction1, 1000); wrapped1({ bar: 'bar' }, function(err : Error, data : any) { @@ -817,9 +817,9 @@ wrapped1({ bar: 'bar' }, function(err : Error, data : any) { }); -function myFunction2(callback: (err : Error, result : any) => void ) : void { +function myFunction2(callback: (err?: Error, result?: any) => void ) : void { console.log(`async.timeout 2`); - return callback(null, { bar: 'bar' }); + return callback(undefined, { bar: 'bar' }); } var wrapped2 = async.timeout(myFunction2, 1000); @@ -827,9 +827,9 @@ wrapped2( function(err : Error, data : any) { console.log(`async.timeout 2 end ${data}`); }); -function myFunction3(callback: (err : Error, result : any) => void ) : void { +function myFunction3(callback: (err?: Error, result?: any) => void ) : void { console.log(`async.timeout 3`); - return callback(null, { bar: 'bar' }); + return callback(undefined, { bar: 'bar' }); } var wrapped3 = async.timeout(myFunction3, 1000, { bar: 'bar' }); diff --git a/async/tsconfig.json b/async/tsconfig.json index 851293fccf..5b8f42c6d2 100644 --- a/async/tsconfig.json +++ b/async/tsconfig.json @@ -6,7 +6,7 @@ ], "noImplicitAny": true, "noImplicitThis": true, - "strictNullChecks": false, + "strictNullChecks": true, "baseUrl": "../", "typeRoots": [ "../" @@ -20,4 +20,4 @@ "test/index.ts", "test/explicit.ts" ] -} \ No newline at end of file +} From 38f2dcaf65a50c7cfa5768f3f3455aa439e3d982 Mon Sep 17 00:00:00 2001 From: Simon Ramsay Date: Wed, 8 Mar 2017 16:12:52 -0500 Subject: [PATCH 086/258] added S3 lambda event definition - doc: https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html --- aws-lambda/aws-lambda-tests.ts | 47 +++++++++++++++++++++++++++++++--- aws-lambda/index.d.ts | 45 +++++++++++++++++++++++++++++++- 2 files changed, 87 insertions(+), 5 deletions(-) diff --git a/aws-lambda/aws-lambda-tests.ts b/aws-lambda/aws-lambda-tests.ts index 1ffdb2980b..3aede36d4c 100644 --- a/aws-lambda/aws-lambda-tests.ts +++ b/aws-lambda/aws-lambda-tests.ts @@ -12,11 +12,50 @@ var context: AWSLambda.Context; var identity: AWSLambda.CognitoIdentity; var proxyResult: AWSLambda.ProxyResult; var snsEvt: AWSLambda.SNSEvent; -var snsEvtRecs: Array; +var snsEvtRecs: AWSLambda.SNSEventRecord[]; var snsEvtRec: AWSLambda.SNSEventRecord; var snsMsg: AWSLambda.SNSMessage; var snsMsgAttr: AWSLambda.SNSMessageAttribute; var snsMsgAttrs: AWSLambda.SNSMessageAttributes; +var S3CreateEvent: AWSLambda.S3CreateEvent = { + Records: [{ + eventVersion: 'string', + eventSource: 'string', + awsRegion: 'string', + eventTime: 'string', + eventName: 'string', + userIdentity: { + principalId: 'string' + }, + requestParameters: { + sourceIPAddress: 'string' + }, + responseElements: { + 'x-amz-request-id': 'string', + 'x-amz-id-2': 'string' + }, + s3: { + s3SchemaVersion: 'string', + configurationId: 'string', + bucket: { + name: 'string', + ownerIdentity: { + principalId: 'string' + }, + arn: 'string' + }, + object: { + key: 'string', + size: 1, + eTag: 'string', + versionId: 'string', + sequencer: 'string' + } + } + } + ] +}; + /* API Gateway Event */ str = apiGwEvt.body; @@ -78,7 +117,7 @@ num = proxyResult.statusCode; proxyResult.headers["example"] = str; proxyResult.headers["example"] = b; proxyResult.headers["example"] = num; -str = proxyResult.body +str = proxyResult.body; /* Context */ b = context.callbackWaitsForEmptyEventLoop; @@ -142,5 +181,5 @@ context.fail(error); context.fail(str); /* Handler */ -let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => {}; -let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => {}; +let handler: AWSLambda.Handler = (event: any, context: AWSLambda.Context, cb: AWSLambda.Callback) => { }; +let proxyHandler: AWSLambda.ProxyHandler = (event: AWSLambda.APIGatewayEvent, context: AWSLambda.Context, cb: AWSLambda.ProxyCallback) => { }; diff --git a/aws-lambda/index.d.ts b/aws-lambda/index.d.ts index 83579b4d0d..c5e49d54c6 100644 --- a/aws-lambda/index.d.ts +++ b/aws-lambda/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for AWS Lambda // Project: http://docs.aws.amazon.com/lambda -// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath , Toby Hede , Rich Buggy +// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath , Toby Hede , Rich Buggy , Simon Ramsay // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // API Gateway "event" @@ -74,6 +74,49 @@ interface SNSEvent { Records: Array; } +/** + * S3Create event + * https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html + */ +interface S3CreateEvent { + Records: [{ + eventVersion: string; + eventSource: string; + awsRegion: string + eventTime: string; + eventName: string; + userIdentity: { + principalId: string; + }, + requestParameters: { + sourceIPAddress: string; + }, + responseElements: { + 'x-amz-request-id': string; + 'x-amz-id-2': string; + }, + s3: { + s3SchemaVersion: string; + configurationId: string; + bucket: { + name: string; + ownerIdentity: { + principalId: string; + }, + arn: string; + }, + object: { + key: string; + size: number; + eTag: string; + versionId: string; + sequencer: string; + } + } + } + ]; +} + // Context // http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html interface Context { From a217b4a320fa74afa68b6a59bd8ec496f5626ae9 Mon Sep 17 00:00:00 2001 From: Damiano Date: Mon, 13 Mar 2017 20:48:46 +0100 Subject: [PATCH 087/258] angular-ui-bootstrap rename IModalServiceInstance angular-ui-bootstrap IModalServiceInstance should be IModaInstanceService see #15142 --- angular-ui-bootstrap/index.d.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/angular-ui-bootstrap/index.d.ts b/angular-ui-bootstrap/index.d.ts index bc80d96b5a..1e4d15d282 100644 --- a/angular-ui-bootstrap/index.d.ts +++ b/angular-ui-bootstrap/index.d.ts @@ -15,6 +15,7 @@ export type IDropdownConfig = angular.ui.bootstrap.IDropdownConfig; export type IModalProvider = angular.ui.bootstrap.IModalProvider; export type IModalService = angular.ui.bootstrap.IModalService; export type IModalServiceInstance = angular.ui.bootstrap.IModalServiceInstance; +export type IModalInstanceService = angular.ui.bootstrap.IModalInstanceService; export type IModalScope = angular.ui.bootstrap.IModalScope; export type IModalSettings = angular.ui.bootstrap.IModalSettings; export type IModalStackService = angular.ui.bootstrap.IModalStackService; @@ -320,12 +321,12 @@ declare module 'angular' { interface IModalService { /** * @param {IModalSettings} options - * @returns {IModalServiceInstance} + * @returns {IModalInstanceService} */ - open(options: IModalSettings): IModalServiceInstance; + open(options: IModalSettings): IModalInstanceService; } - interface IModalServiceInstance { + interface IModalInstanceService { /** * A method that can be used to close a modal, passing a result. If `preventDefault` is called on the `modal.closing` event then the modal will remain open. */ @@ -357,6 +358,11 @@ declare module 'angular' { closed: angular.IPromise; } + /** + * @deprecated use IModalInstanceService instead. + */ + interface IModalServiceInstance extends IModalInstanceService { } + interface IModalScope extends angular.IScope { /** * Dismiss the dialog without assigning a value to the promise output. If `preventDefault` is called on the `modal.closing` event then the modal will remain open. @@ -512,17 +518,17 @@ declare module 'angular' { /** * Opens a new modal instance. */ - open(modalInstance: IModalServiceInstance, modal: any): void; + open(modalInstance: IModalInstanceService, modal: any): void; /** * Closes a modal instance with an optional result. */ - close(modalInstance: IModalServiceInstance, result?: any): void; + close(modalInstance: IModalInstanceService, result?: any): void; /** * Dismisses a modal instance with an optional reason. */ - dismiss(modalInstance: IModalServiceInstance, reason?: any): void; + dismiss(modalInstance: IModalInstanceService, reason?: any): void; /** * Dismiss all open modal instances with an optional reason that will be passed to each instance. @@ -536,7 +542,7 @@ declare module 'angular' { } interface IModalStackedMapKeyValuePair { - key: IModalServiceInstance; + key: IModalInstanceService; value: any; } From 6f84b49a480b533c3709497979e3b39977ba766a Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Tue, 14 Mar 2017 10:01:02 +1300 Subject: [PATCH 088/258] Updated to match master --- tinymce/index.d.ts | 1515 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 1384 insertions(+), 131 deletions(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index e6a9374ab4..da9cdcf9f2 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -5,172 +5,1425 @@ // Work In Progress -declare namespace TinyMCE { - export interface Observable { - off(name?: string, callback ?: () => void): void; - on(name: string, callback: () => void): void; - fire(name: string, args?: any, bubble?: boolean): Event; +declare namespace TinyMce { + + export interface Static extends TinyMce.EditorManager { + + DOM: TinyMce.dom.DOMUtils; + + PluginManager: TinyMce.AddOnManager; + + ScriptLoader: TinyMce.dom.ScriptLoader; + + ThemeManager: TinyMce.AddOnManager; + + create(s: string, p: {}, root?: {}): void; + + createNS(n: string, o: {}): {}; + + each(o: {}, cb: () => void, s?: {}): void; + + explode(s: string, d: string): void; + + grep(a: any[], f: () => void): any[]; + + inArray(item: any, arr: any[]): number; + + is(obj: {}, type?: string): boolean; + + isArray(obj: {}): boolean; + + makeMap(items: any[], delim?: string, map?: {}): {}; + + map(array: any[], callback: () => void): any[]; + + resolve(n: string, o?: {}): {}; + + toArray(obj: {}): any[]; + + trim(s: string): string; + + walk(o: {}, f: () => void, n?: string, s?: string): void; } - export interface Editor extends Observable { - $: any; - iframeElement: string; - selection: Selection; - undoManager: UndoManager; + export interface Settings { + + auto_focus?: string; + + cache_suffix?: string; + + content_security_policy?: string; + + external_plugins?: {}; + + hidden_input?: boolean; + + init_instance_callback?: (editor: TinyMce.Editor) => void; + + plugins?: string | string[]; + + selector?: string; + + setup?: (edtor: TinyMce.Editor) => void; + + target?: Element; + + color_picker_callback?: (callback: (hexColor: string) => void, value: string) => void; + + elementpath?: boolean; + + event_root?: boolean; + + fixed_toolbar_container?: string; + + height?: number; + + inline?: boolean; + + insert_button_items?: string; + + insert_toolbar?: string; + + max_height?: number; + + max_width?: number; + + menu?: settings.Menu; + + menubar?: string | boolean; + + min_height?: number; + + min_width?: number; + + preview_styles?: boolean | string; + + removed_menuitems?: string; + + resize?: boolean | string; + + selection_toolbar?: string; + + skin_url?: string; + + skin?: string; + + statusbar?: boolean; + + theme_url?: string; + + theme?: string; + + toolbar?: boolean | string | string[]; + + width?: number; + + body_class?: string; + + body_id?: string; + + content_css?: string; + + content_style?: string; + + visual_anchor_class?: string; + + visual_table_class?: string; + + visual?: boolean; + + allow_conditional_comments?: boolean; + + allow_html_in_named_anchor?: boolean; + + allow_unsafe_link_target?: boolean; + + convert_fonts_to_spans?: boolean; + + custom_elements?: string; + + doctype?: string; + + element_format?: string; + + encoding?: string; + + entities?: string; + + entity_encoding?: string; + + extended_valid_elements?: string; + + fix_list_elements?: boolean; + + force_hex_style_colors?: boolean; + + forced_root_block?: string; + + forced_root_block_attrs?: {}; + + invalid_elements?: string; + + invalid_styles?: string | {}; + + keep_styles?: boolean; + + protect?: RegExp[]; + + remove_trailing_brs?: boolean; + + schema?: string; + + valid_children?: string; + + valid_classes?: string | {}; + + valid_elements?: string; + + valid_styles?: {}; + + block_formats?: string; + + font_formats?: string; + + fontsize_formats?: string; + + formats?: {}; + + removeFormat?: Array<{}>; + + indentation?: string; + + style_formats?: Array<{}>; + + style_formats_autohide?: boolean; + + style_formats_merge?: boolean; + + browser_spellcheck?: boolean; + + gecko_spellcheck?: boolean; + + automatic_uploads?: boolean; + + file_browser_callback?: (field_name: string, url: string, type: string, win: Window) => void; + + file_browser_callback_types?: string; + + file_picker_callback?: (callback: (filename: string, metadata: {}) => void, valud: string, meta: {}) => void; + + file_picker_types?: string; + + images_dataimg_filter?: (img: any) => void; + + images_reuse_filename?: boolean; + + images_upload_base_path?: string; + + images_upload_credentials?: boolean; + + images_upload_handler?: (blobInfo: any, success: (msg: string) => void, failure: (msg: string) => void) => void; + + images_upload_url?: string; + + directionality?: string; + + language?: string; + + language_url?: string; + + allow_script_urls?: boolean; + + convert_urls?: boolean; + + document_base_url?: string; + + relative_urls?: boolean; + + remove_script_host?: boolean; + + urlconverter_callback?: (url: string, node: HTMLElement, on_save: boolean, name: string) => void; + + anchor_bottom?: string; + + anchor_top?: string; + + br_in_pre?: boolean; + + custom_undo_redo_levels?: number; + + end_container_on_empty_block?: boolean; + + nowrap?: boolean; + + object_resizing?: boolean | string; + + type_ahead_urls?: boolean; + + } + + export namespace settings { + + export interface Menu { + file: MenuItem; + edit: MenuItem; + insert: MenuItem; + view: MenuItem; + format: MenuItem; + table: MenuItem; + tools: MenuItem; + } + + export interface MenuItem { + title: string; + items: string; + } + } + + export interface AddOnManager { + + add(id: string, addOn: (editor: TinyMce.Editor, url: string) => void): Theme | Plugin; + + addComponents(pluginName: string, scripts: string[]): void; + + get(name: string): Theme | Plugin; + + load(name: string, addOnUrl: string, success?: () => void, scope?: {}, failure?: () => void): void; + + requireLangPack(name: string, languages?: string): void; + } + + export interface Editor extends util.Observable { + + $: dom.DomQuery; + + baseURI: util.URI; + + contentCSS: string[]; + + contentStyles: string[]; + + documentBaseURI: util.URI; + + dom: dom.DOMUtils; + formatter: Formatter; - shortcuts: Shortcuts; - dom: DOMUtils; - notificationManager: NotificationManager; - focus(): void; - getContent(args?: any): string; - isDirty(): boolean; - insertContent(content: string, args?: any): any; - setContent(content: string, args?: any): any; - reset(): any; - execCommand(command: string, ui?: boolean, value?: any, args?: any): boolean; - remove(): any; - destroy(state?: boolean): void; - getElement(): Element; - getDoc(): Document; - queryCommandSupported(cmd: string): boolean; - getBody(): Element; - setDirty(dirty: boolean): void; - on(eventName: string, handler: () => void): void; - addShortcut(pattern: string, desc: string, cmdFunc: string, scope?: any ): boolean; - addButton(name: string, settings: any): void; - addMenuItem(name: string, settings: any): void; - menuItems: any; + + id: string; + initialized: boolean; - } - export interface Formatter { - remove(name: string): any; - apply(name: string): any; - toggle(name: string): any; - match(name: string, vars?: any, node?: Node): boolean; - matchAll(names: [string], vars?: any): [string]; - } + notificationManager: notificationManager; - export interface UndoManager { - transact(callback: () => void): any; - undo(): any; - redo(): any; - hasRedo(): boolean; - hasUndo(): boolean; - } + parser: html.DomParser; - export interface DOMUtils { - DOM: any; - getParent(n: Node, s: string): Node; - setStyle(n: any, na: string, v: string): void; - select(pattern: string, scope ?: Element): Element[]; - getAttrib(elm: string, name: string, defaultVal ?: string): string; - isEmpty(elements: any): boolean; - } + schema: html.Schema; - export interface NotificationManager { - getNotifications(): any[]; - open(args: any): any; - close(): any; - } + selection: dom.Selection; - export interface Shortcuts { - addShortcut(pattern: string, desc: string, cmdFunc: string, scope?: any): boolean; - remove(pattern: string): boolean; - } + serializer: dom.Serializer; - export interface Collection { - active(): Collection; - } + settings: Settings; - export interface Container { - add(items: any): Collection; - items(): Collection; - } + theme: Theme; - export interface Tooltip { - repaint(): void; - } + undoManager: UndoManager; + + WindowManager: WindowManager; + + addButton(name: string, settings: {}): void; + + addCommand(name: string, callback: (ui: boolean, value: {}) => boolean, scope?: {}): void; + + addContextToolbar(predicate: () => void, items: string): void; + + addMenuItem(name: string, settings: {}): void; + + addQueryStateHandler(name: string, callback: () => boolean, scope?: {}): void; + + addQueryValueHandler(name: string, callback: () => {}, scope?: {}): void; + + addShortcut(pattern: string, desc: string, cmdFunc: string, sc?: {}): boolean; + + addSidebar(name: string, settings: {}): void; + + addVisual(elm?: Element): void; + + convertURL(url: string, name: string, elm: string): string; + + destroy(automatic?: boolean): void; + + execCallback(name: string): {}; + + execCommand(cmd: string, ui: boolean, value?: any, args?: {}): void; + + focus(skipFocus: boolean): void; + + getBody(): HTMLBodyElement; + + getContainer(): Element; + + getContent(args?: {}): string; + + getContentAreaContainer(): Element; + + getDoc(): Document; + + getElement(): Element; + + getLang(name: string, defaultVal?: string): void; + + getParam(name: string, defaultVal?: string, type?: string): string; + + getWin(): Window; + + hasEventListeners(name: string): boolean; - export interface Control { - renderTo(node?: Node): void; - innerHtml(html: string): Control; - $el: any; - show(): void; hide(): void; - visible(state ?: boolean): boolean; - disabled(state: boolean): boolean; - active(state: boolean): boolean; - on(name: string, callback: () => void): Control; - parent(parent ?: any): Control; - settings: any; - text(text: string): void; - tooltip(): Tooltip; + + init(): void; + + insertContent(content: string, args?: {}): void; + + isDirty(): boolean; + + isHidden(): boolean; + + load(args?: {}): string; + + nodeChanged(args?: {}): void; + + queryCommandState(cmd: string): boolean; + + queryCommandSupported(cmd: string): boolean; + + queryCommandValue(cmd: string): {}; + + remove(): void; + + render(): void; + + save(args: {}): string; + + setContent(content: string, args?: {}): string; + + setDirty(state: boolean): void; + + setMode(mode: string): void; + + setProgressState(state: boolean, time: number): boolean; + + show(): void; + + translate(text: string): string; + + uploadImages(callback: () => void): Promise; } - export interface Moveable { - moveRel(elm: Node, rel: string): Control; + export interface EditorCommands { + + addCommands(command_list: {}, type?: string): void; + + execCommand(command: string, ui?: boolean, value?: {}, args?: {}): boolean; + + queryCommandState(command: string): boolean | number; + + queryCommandSupported(command: string): boolean; + + queryCommandValue(command: string): {}; } - export interface FloatPanel extends Control, Moveable { + export interface EditorManager extends util.Observable { + $: dom.DomQuery; + + activeEditor: TinyMce.Editor; + + baseURI: TinyMce.util.URI; + + baseURL: string; + + documentBaseURL: string; + + editors: TinyMce.Editor[]; + + i18n: {}; + + majorVersion: string; + + minorVersion: string; + + releaseDate: string; + + suffix: string; + + add(editor: TinyMce.Editor): TinyMce.Editor; + + addI18n(code: string, items: {}): void; + + createEditor(id: string, settings: {}): TinyMce.Editor; + + execCommand(cmd: string, ui?: boolean, value?: string): boolean; + + get(id: string): TinyMce.Editor; + + init(settings: Settings): Promise; + + overrideDefaults(defaultSettings: {}): void; + + remove(selector: TinyMce.Editor): TinyMce.Editor; + + setActive(editor: TinyMce.Editor): void; + + translate(text: string): string; + + triggerSave(): void; } - export interface Menu extends FloatPanel, Control, Container { + export interface Env { + android: boolean; + + ceFalse: boolean; + + contentEditable: boolean; + + documentMode: boolean; + + fileApi: boolean; + + gecko: boolean; + + iOS: boolean; + + ie: boolean; + + mac: boolean; + + noCaretAfter: boolean; + + opera: boolean; + + range: boolean; + + transparentSrc: boolean; + + webKit: boolean; } - export interface Factory { - create(settings: any): Control; - } + export namespace Events { - export interface Tools { - grep(array: any, f: () => void): any; - each(o: any, cb: () => void, s?: any): void; - } + export interface Event { - export interface UI { - Factory: Factory; - Control: Control; - FloatPanel: FloatPanel; - } + type: string; - export interface util { - Tools: Tools; - } + target: string; - export interface Selection { - getContent(args?: any): string; - getNode(): any; - getRng(): Range; - collapse(toStart?: boolean): any; - select(node: any, body: boolean): any; - getStart(): any; - getEnd(real ?: boolean): void; - selectorChanged(selector: string, handler: any): void; - getSel(): any; + isDefaultPrevented(): boolean; + + isImmediatePropagationStopped(): boolean; + + isPropagationStopped(): boolean; + + preventDefault(): void; + + stopImmediatePropagation(): void; + + stopPropagation(): void; + } + + export interface FocusBlurEvent extends Event { + + blurredEditor: Editor; + } + + export interface ContentEvent extends Event { + + format: string; + + set: boolean; + + content: string; + } + + export interface ProcessEvent extends Event { + + content: string; + + forced_root_block: string; + + format: string; + + get: boolean; + + get_inner: boolean; + + node: Node; + + selection: true; + } + + export interface NodeChangeEvent extends Event { + + element: Node; + + parents: Node[]; + + selectionChange: boolean; + } + + export interface UndoRedoEvent extends Event { + + level: {}; + } + + export interface ChangeEvent extends Event { + + lastLevel: {}; + + level: {}; + } + + export interface CommandEvent extends Event { + + command: string; + + ui: boolean; + + value: string; + } } export interface FocusManager { - isEditorUIElement(elm: Node): boolean; + + isEditorUIElement(elm: Element): boolean; } - export interface UI { - Factory: Factory; - Control: Control; - FloatPanel: FloatPanel; + export class FocusManager implements FocusManager { + + constructor(editorManager: TinyMce.EditorManager); } - export interface Static extends Observable { - init(settings: any): void; - execCommand(c: string, u: boolean, v: string): boolean; - activeEditor: Editor; - FocusManager: FocusManager; - get(id: string): Editor; - triggerSave(): void; - ui: UI; - util: util; + export interface Formatter { + + apply(name: string, vars?: {}, node?: html.Node): void; + + canApply(name: string): boolean; + + formatChanged(formats: string, callback: () => void, similar: boolean): void; + + get(name?: string): any[] | {}; + + getCssText(format: string): string; + + match(name: string, vars?: {}, node?: html.Node): boolean; + + matchAll(names: any[], vars?: {}): any[]; + + matchNode(node: html.Node, name: string, vars: {}, similar: boolean): {}; + + register(name: {}, format?: {}): void; + + remove(name: string, vars?: {}, node?: html.Node): void; + + toggle(name: string, vars?: {}, node?: html.Node): void; + + unregister(name: string): void; + } + + export class Formatter implements Formatter { + + constructor(ed: Editor); + } + + export interface Shortcuts { + + add(pattern: string, desc: string, cmdFunc: () => void | string, scope?: {}): boolean; + + remove(pattern: string): boolean; + } + + export interface Theme { + + renderUI(obj: {}): {}; + } + + export interface UndoManager { + + add(level?: {}, event?: DocumentEvent): {}; + + beforeChange(): void; + + clear(): void; + + extra(callback1: () => void, callback2: () => void): void; + + hasRedo(): boolean; + + hasUndo(): boolean; + + redo(): {}; + + transact(callback: () => void): {}; + + undo(): {}; + } + + export interface WindowManager { + + alert(message: string, callback: () => void, scope?: {}): void; + + close(): void; + + confirm(message: string, callback: () => void, scope?: {}): void; + + getParams(): {}; + + getWindows(): Window[]; + + open(args: {}, params: {}): void; + + setParams(params: {}): void; + } + + export interface notificationManager { + + close(): void; + + getNotifications(): Array<{}>; + + open(args?: {}): void; + } + + export namespace dom { + + export interface BookmarkManager { + + getBookmark(type?: number, normalized?: boolean): {}; + + isBookmarkNode(node: HTMLElement): boolean; + + moveToBookmark(bookmark: {}): boolean; + } + + export interface DOMUtils { + + add(parentElm: string, name: string, attrs?: {}, html?: string, create?: boolean): Element | T[]; + + addClass(elm: string, cls: string): string | T[]; + + addStyle(cssText: string): void; + + bind(target: Element, name: string, func: () => void, scope?: {}): () => void; + + create(name: string, attrs?: {}, html?: string): Element; + + createFragment(html: string): DocumentFragment; + + createHTML(name: string, attrs?: {}, html?: string): string; + + createRng(): Range; + + decode(s: string): string; + + destroy(): void; + + encode(text: string): string; + + findCommonAncestor(a: Element, b: Element): Element; + + fire(target: Node, name: string, evt: {}): Event; + + get(n: string): Element; + + getAttrib(elm: string, name: string, defaultVal: string): string; + + getAttribs(elm?: HTMLElement): NodeList; + + getNext(node: Node, selector: string): Node; + + getOuterHTML(elm: string): string; + + getParent(node: Node, selector: () => void, root?: Node): Node; + + getParents(node: Node, selector: () => void, root?: Node): T[]; + + getPos(elm: Element, rootElm?: Element): {}; + + getPrev(node: Node, selector: string): Node; + + getRect(elm: Element): {}; + + getRoot(): Element; + + getSize(elm: Element): {}; + + getStyle(elm: string, name: string, computed: boolean): string; + + getViewPort(win?: Window): {}; + + hasClass(elm: string, cls: string): boolean; + + hide(elm: string): void; + + insertAfter(node: Element, referenceNode: Element): Element | T[]; + + is(elm: Node, selector: string): void; + + isBlock(node: Node): boolean; + + isEmpty(elements?: {}): boolean; + + isHidden(elm: string): boolean; + + loadCSS(url: string): void; + + nodeIndex(node: Node, normalized?: boolean): number; + + parseStyle(cssText: string): {}; + + remove(node: string, keepChildren?: boolean): Element | T[]; + + removeAllAttribs(e: Element): void; + + removeClass(elm: string, cls: string): string | T[]; + + rename(elm: Element, name: string): Element; + + replace(newElm: Element, oldElm: Element, keepChildren?: boolean): void; + + run(elm: string, func: () => void, scope?: {}): {} | T[]; + + select(selector: string, scope?: {}): T[]; + + serializeStyle(styles: {}, name?: string): string; + + setAttrib(elm: Element, name: string, value: string): void; + + setAttribs(elm: Element, attrs: {}): void; + + setHTML(elm: Element, html: string): void; + + setOuterHTML(elm: Element, html: {}): void; + + setStyle(elm: string, name: string, value: string): void; + + setStyles(elm: Element, styles: {}): void; + + show(elm: string): void; + + split(parentElm: Element, splitElm: Element, replacementElm?: Element): Element; + + toHex(rgbVal: string): string; + + toggleClass(elm: Element, cls: string, state?: string): void; + + unbind(target: Element, name: string, func: () => void): boolean | T[]; + + uniqueId(prefix?: string): string; + } + + export class DOMUtils implements DOMUtils { + + constructor(doc: Document, settings?: {}); + } + + export interface DomQuery { + + add(items: T[], sort?: boolean): DomQuery; + + addClass(className: string): DomQuery; + + after(content: string): DomQuery; + + append(content: string): DomQuery; + + appendTo(val: string): DomQuery; + + attr(name: string, value?: string): DomQuery | string; + + before(content: string): DomQuery; + + children(node: Element | string): DomQuery; + + clone(): DomQuery; + + closest(selector: string): DomQuery; + + contents(node: Element | string): DomQuery; + + css(name: string, value?: string): DomQuery | string; + + each(callback: () => void): DomQuery; + + each(obj: {}, callback: () => void): void; + + empty(): DomQuery; + + eq(index: number): DomQuery; + + extend(target: {}, object: {}): {}; + + filter(selector: string): DomQuery; + + find(selector: string): DomQuery; + + first(): DomQuery; + + grep(array: T[], callback: () => void): T[]; + + hasClass(className: string): boolean; + + hide(): DomQuery; + + html(value?: string): DomQuery | string; + + inArray(item: {}, array: T[]): number; + + is(selector: string): boolean; + + isArray(array: {}): boolean; + + last(): DomQuery; + + makeArray(object: {}): T[]; + + next(node: Element | string): DomQuery; + + nextUntil(node: Element | string, until: string): DomQuery; + + off(name?: string, callback?: () => void): DomQuery; + + offset(offset?: {}): {} | DomQuery; + + on(name: string, callback: () => void): DomQuery; + + parent(node: Element | string): DomQuery; + + parents(node: Element | string): DomQuery; + + parentsUntil(node: Element | string, until: string): DomQuery; + + prepend(content: string): DomQuery; + + prependTo(val: string): DomQuery; + + prev(node: Element | string): DomQuery; + + prevUntil(node: Element | string, until: string): DomQuery; + + remove(): DomQuery; + + removeAttr(name: string): DomQuery | string; + + removeClass(className: string): DomQuery; + + replaceWith(content: string): DomQuery; + + show(): DomQuery; + + slice(start: number, end?: number): DomQuery; + + text(value?: string): DomQuery | string; + + toArray(): T[]; + + toggleClass(className: string, state?: boolean): DomQuery; + + trigger(name: string): DomQuery; + + trim(str: string): string; + + unwrap(): DomQuery; + + wrap(content: string): DomQuery; + + wrapAll(content: string): DomQuery; + + wrapInner(content: string): DomQuery; + } + + export class DomQuery implements DomQuery { + + constructor(selector?: string, context?: Document); + } + + export interface EventUtils { + + bind(target: {}, names: string, callback: () => void, scope: {}): () => void; + + clean(target: {}): EventUtils; + + fire(target: {}, name: string, args?: {}): EventUtils; + + unbind(target: {}, names?: string, callback?: () => void): EventUtils; + } + + export interface RangeUtils { + + compareRanges(rng1: Range, rng2: Range): boolean; + + getCaretRangeFromPoint(clientX: number, clientY: number, doc: Document): Range; + } + + export interface ScriptLoader { + + add(url: string, success?: () => void, scope?: {}, failure?: () => void): void; + + isDone(url: string): boolean; + + load(url: string, callback1?: () => void, callback2?: () => void): void; + + loadQueue(success?: () => void, failure?: () => void, scope?: {}): void; + + loadScripts(scripts: string[], callback1?: () => void, scope?: {}, callback2?: () => void): void; + + markDone(url: string): void; + } + + export interface Selection { + + collapse(toStart?: boolean): void; + + getBookmark(type?: number, normalized?: boolean): {}; + + getContent(args?: {}): string; + + getEnd(real?: boolean): Element; + + getNode(): Element; + + getRng(w3c: boolean): Range; + + getSel(): Selection; + + getStart(real?: boolean): Element; + + isCollapsed(): boolean; + + moveToBookmark(bookmark: {}): boolean; + + select(node: Element, content?: boolean): Element; + + selectorChanged(selector: string, callback: () => void): void; + + setContent(content: string, args?: {}): void; + + setCursorLocation(node?: html.Node, offset?: number): void; + + setNode(elm: Element): Element; + + setRng(rng: Range, forward?: boolean): void; + } + + export class Selection implements Selection { + + constructor(dom: DOMUtils, win: Window, editor: Editor, serializer: Serializer); + } + + export interface Serializer { + + addAttributeFilter(callback: () => void): void; + + addNodeFilter(callback: () => void): void; + + addRules(rules: string): void; + + addTempAttr(name: string): void; + + serialize(node: HTMLElement, args: {}): void; + + setRules(rules: string): void; + + } + + export class Serializer implements Serializer { + + constructor(settings: {}, editor?: Editor); + } + + export interface TreeWalker { + + current(): html.Node; + + next(): html.Node; + + prev(): html.Node; + } + } + + export class TreeWalker implements TreeWalker { + + constructor(startNode: html.Node, rootNode: html.Node); + } + + export namespace geom { + + export interface Rect { + + clamp(rect: Rect, clampRect: Rect, fixedSize: boolean): Rect; + + create(x: number, y: number, w: number, h: number): Rect; + + findBestRelativePosition(rect: Rect, targetRect: Rect, constrainRect: Rect, rels: any[]): void; + + fromClientRect(clientRect: ClientRect): Rect; + + inflate(rect: Rect, w: number, h: number): Rect; + + intersect(rect: Rect, cropRect: Rect): Rect; + + relativePosition(rect: Rect, targetRect: Rect, rel: string): void; + } + } + + export namespace html { + + export interface DomParser { + + addAttributeFilter(attributes: string, callback: () => void): void; + + addNodeFilter(attributes: string, callback: () => void): void; + + filterNode(node: TinyMce.html.Node): TinyMce.html.Node; + + parse(html: string, args?: {}): TinyMce.html.Node; + } + + export class DomParser implements DomParser { + + constructor(settings: {}, schema: TinyMce.html.Schema); + } + + export interface Entities { + + decode(text: string): string; + + encodeAllRaw(text: string): string; + + encodeNamed(text: string, attr?: boolean, entities?: {}): string; + + encodeNumeric(text: string, attr?: boolean): string; + + encodeRaw(text: string, attr?: boolean): string; + + getEncodeFunc(name: string, entities?: string): () => void; + } + + export interface Node { + + append(node: TinyMce.html.Node): TinyMce.html.Node; + + attr(name: string, value?: string): string | TinyMce.html.Node; + + clone(): TinyMce.html.Node; + + create(name: string, attrs: {}): void; + + empty(): TinyMce.html.Node; + + getAll(name: string): TinyMce.html.Node[]; + + insert(node: TinyMce.html.Node, ref_node: TinyMce.html.Node, before?: boolean): TinyMce.html.Node; + + isEmpty(elements: {}): boolean; + + remove(): TinyMce.html.Node; + + replace(node: TinyMce.html.Node): TinyMce.html.Node; + + unwrap(): void; + + walk(prev?: boolean): TinyMce.html.Node; + + wrap(wrapperNode: TinyMce.html.Node): TinyMce.html.Node; + } + + export class Node implements Node { + + constructor(name: string, type: number); + } + + export interface SaxParser { + + parse(html: string): void; + } + + export class SaxParser implements SaxParser { + + constructor(settings: {}, schema: TinyMce.html.Schema); + } + + export interface Schema { + + addCustomElements(custom_elements: string): void; + + addValidChildren(valid_children: string): void; + + addValidElements(valid_elements: string): void; + + getBlockElements(): {}; + + getBoolAttrs(): {}; + + getCustomElements(): {}; + + getElementRule(name: string): {}; + + getInvalidStyles(): void; + + getMoveCaretBeforeOnEnterElements(): {}; + + getNonEmptyElements(): {}; + + getSelfClosingElements(): {}; + + getShortEndedElements(): {}; + + getSpecialElements(): {}; + + getTextBlockElements(): {}; + + getTextInlineElements(): {}; + + getValidClasses(): void; + + getValidStyles(): void; + + getWhiteSpaceElements(): {}; + + isValid(name: string, attr?: string): boolean; + + isValidChild(name: string, child: string): boolean; + + setValidElements(valid_elements: string): void; + } + + export class Schema implements Schema { + + constructor(settings: {}); + } + + export interface Serializer { + + serialize(node: TinyMce.html.Node): string; + } + + export class Serializer implements Serializer { + + constructor(settings: {}, schema: TinyMce.html.Schema); + } + + export interface Styles { + + parse(css: string): {}; + + serialize(styles: {}, elementName: string): string; + + toHex(color: string): string; + } + + export interface Writer { + + cdata(text: string): void; + + doctype(text: string): void; + + end(name: string): void; + + getContent(): string; + + pi(name: string, text: string): void; + + reset(): void; + + start(name: string, attrs?: any[], empty?: boolean): void; + + text(text: string, raw: boolean): void; + } + } + + export class Writer implements Writer { + + constructor(settings: {}); + } + + export namespace util { + + export interface Color { + + parse(value: {}): TinyMce.util.Color; + + toHex(): string; + + toHsv(): {}; + + toRgb(): {}; + } + + export class Color implements Color { + + constructor(value: string | {}); + } + + export interface Delay { + + clearInterval(interval: number): void; + + clearTimeout(timeout: number): void; + + debounce(callback: () => void, time: number): () => void; + + requestAnimationFrame(callback: () => void, element?: HTMLElement): void; + + setEditorInterval(callback: () => void, time: number): number; + + setEditorTimeout(editor: TinyMce.Editor, callback: () => void, time: number): number; + + setInterval(callback: () => void, time: number): number; + + setTimeout(callback: () => void, time: number): number; + } + + export interface EventDispatcher { + + fire(name: string, args?: {}): {}; + + has(name: string): boolean; + + isNative(name: string): boolean; + + off(name: string, callback?: () => void): {}; + + on(name: string, callback: () => void, first?: boolean): {}; + + once(name: string, callback: () => void, first: boolean): {}; + } + + export interface i18n { + + rtl: boolean; + + add(code: string, items: Array<{}>): void; + + getCode(): string; + + setCode(newCode: string): void; + + translate(text: string): string; + } + + export interface JSON { + + parse(s: string): {}; + + serialize(obj: {}, quote?: string): string; + } + + export interface JSONRequest { + + send(args: {}): void; + + sendRPC(o: {}): void; + } + + export interface LocalStorage { + + length: number; + + clear(): void; + + getItem(key: string): string; + + key(index: number): string; + + removeItem(key: string): void; + + setItem(key: string, value: string): void; + } + + export interface Observable { + + fire(name: string, args?: {}, bubble?: boolean): {}; + + hasEventListeners(name: string): boolean; + + off(name?: string, callback?: () => void): {}; + + on(name: string, callback: (event: any) => void, first?: boolean): {}; + + once(name: string, callback: (event: any) => void): {}; + } + + export interface Tools { + + create(s: string, p: {}, root?: {}): void; + + createNS(n: string, o?: {}): {}; + + each(o: {}, cb: () => void, s?: {}): void; + + explode(s: string, d: string): void; + + grep(a: T[], f: () => void): T[]; + + inArray(item: T, arr: T[]): number; + + is(obj: {}, type: string): boolean; + + isArray(obj: {}): boolean; + + makeMap(items: T[], delim?: string, map?: {}): {}; + + map(array: T[], callback: (c: T) => S): S[]; + + resolve(n: string, o?: {}): {}; + + toArray(obj: {}): T[]; + + trim(s: string): string; + + walk(o: {}, f: () => void, n?: string, s?: string): void; + } + + export interface URI { + + getURI(noProtoHost: boolean): URI; + + isSameOrigin(uri: TinyMce.util.URI): boolean; + + setPath(path: string): void; + + toAbsPath(base: string, path: string): void; + + toAbsolute(uri: string, noHost: boolean): string; + + toRelPath(base: string, path: string): void; + + toRelative(uri: string): string; + } + + export class URI implements URI { + + constructor(url: string, settings?: {}); + } + + export interface XHR { + + fire(name: string, args?: {}, bubble?: boolean): {}; + + hasEventListeners(name: string): boolean; + + off(name?: string, callback?: () => void): {}; + + on(name: string, callback: () => void, first?: boolean): {}; + + once(name: string, callback: () => void): {}; + + send(settings: {}): void; + } + } } -declare var tinymce: TinyMCE.Static; +declare var tinymce: TinyMce.Static; From 16f4e7e2e03cc599500cdfa5eb67c120c5b66ea0 Mon Sep 17 00:00:00 2001 From: codemannz Date: Tue, 14 Mar 2017 13:31:33 +1300 Subject: [PATCH 089/258] Update index.d.ts Added table_toolbar --- tinymce/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index da9cdcf9f2..a142e244ef 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -47,6 +47,7 @@ declare namespace TinyMce { } export interface Settings { + table_toolbar?: boolean; auto_focus?: string; From 4bdfa8fd6d27ed5a38d9aeb8714acc733fc2625c Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Tue, 14 Mar 2017 08:33:15 +0100 Subject: [PATCH 090/258] Add comments to tests for generic version of jasmine.objectContaining --- jasmine/index.d.ts | 2 +- jasmine/jasmine-tests.ts | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index cb19aa7cd8..f75a9f2127 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -24,9 +24,9 @@ declare function afterEach(action: (done: DoneFn) => void, timeout?: number): vo declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): void; declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; +declare function expect(spy: Function): jasmine.Matchers; declare function expect>(actual: ArrayLike): jasmine.ArrayLikeMatchers; declare function expect(actual: T): jasmine.Matchers; -declare function expect(spy: Function): jasmine.Matchers; declare function fail(e?: any): void; /** Action method that should be called when the async work is complete */ diff --git a/jasmine/jasmine-tests.ts b/jasmine/jasmine-tests.ts index e80060510b..1c9d5366e1 100644 --- a/jasmine/jasmine-tests.ts +++ b/jasmine/jasmine-tests.ts @@ -679,12 +679,19 @@ describe("jasmine.objectContaining", () => { }); it("matches objects with the expect key/value pairs", () => { - expect(foo).toEqual(jasmine.objectContaining({ - bar: '' + // not explictly providing the type on objectContaining only guards against + // missmatching types on know properties + expect(foo).not.toEqual(jasmine.objectContaining({ + a: 37, + foo: 2, // <-- this does not cause an error as the compiler cannot infer the type completely + // b: '123', <-- this would cause an error as `b` defined as number in fooType })); - expect(foo).not.toEqual(jasmine.objectContaining({ - a: 37 + // explictly providing the type on objectContaining makes the guard more precise + // as misspelled properties are detected as well + expect(foo).not.toEqual(jasmine.objectContaining({ + bar: '', + // foo: 1, <-- this would cause an error as `foo` is not defined in fooType })); }); From 9ad681855ff9b53e76e5057db01b8197ad458b73 Mon Sep 17 00:00:00 2001 From: Geert Jansen Date: Tue, 14 Mar 2017 11:59:33 +0100 Subject: [PATCH 091/258] Update to IBottomSheetOptions Adds missing bindToController property on interface IBottomSheetOptions. --- angular-material/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/angular-material/index.d.ts b/angular-material/index.d.ts index 0e27fe3b60..64441a96be 100644 --- a/angular-material/index.d.ts +++ b/angular-material/index.d.ts @@ -18,6 +18,7 @@ declare module 'angular' { controller?: string | Function; locals?: { [index: string]: any }; clickOutsideToClose?: boolean; + bindToController?: boolean; // default: false disableBackdrop?: boolean; escapeToClose?: boolean; resolve?: { [index: string]: () => angular.IPromise }; From d0ed29f8a20a386bc82b075efda68e549efb316c Mon Sep 17 00:00:00 2001 From: use-strict Date: Tue, 14 Mar 2017 15:03:47 +0200 Subject: [PATCH 092/258] http-errors: Add missing constructor Allows the following to work: ```typescript import { HttpError } from "http-errors"; let error: HttpError; console.log(error instanceof HttpError); ``` --- http-errors/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/http-errors/index.d.ts b/http-errors/index.d.ts index 176703f23f..aff5b312dd 100644 --- a/http-errors/index.d.ts +++ b/http-errors/index.d.ts @@ -23,6 +23,8 @@ declare module 'http-errors' { [code: string]: new (msg?: string) => HttpError; (...args: Array): HttpError; + + HttpError: HttpErrorConstructor; Continue: HttpErrorConstructor; SwitchingProtocols: HttpErrorConstructor; From 12f7d2809dfa8e5da27c281a521a91f2acdc1c39 Mon Sep 17 00:00:00 2001 From: Alexander Abashkin Date: Tue, 14 Mar 2017 17:00:06 +0300 Subject: [PATCH 093/258] Added module declaration --- platform/index.d.ts | 23 ++++++++++++----------- platform/platform-tests.ts | 8 +++----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/platform/index.d.ts b/platform/index.d.ts index c02615b932..ad6100c707 100644 --- a/platform/index.d.ts +++ b/platform/index.d.ts @@ -4,7 +4,7 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -interface PlatformStatic { +interface Platform { description?: string; layout?: string; manufacturer?: string; @@ -13,18 +13,19 @@ interface PlatformStatic { product?: string; ua?: string; version?: string; - os?: PlatformOS; - parse?(ua: string): PlatformStatic; + os?: { + architecture?: number; + family?: string; + version?: string; + toString(): string; + }; + parse?(ua: string): Platform; toString?(): string; } -interface PlatformOS { - architecture?: number; //platform's docs say this is a string, but their code doesn't agree - family?: string; - version?: string; - toString(): string; +declare var platform: Platform; + +declare module "platform" { + export = platform; } -declare var platform: PlatformStatic; - - diff --git a/platform/platform-tests.ts b/platform/platform-tests.ts index ce24ada335..572e85830c 100644 --- a/platform/platform-tests.ts +++ b/platform/platform-tests.ts @@ -1,7 +1,5 @@ - - interface ITestContainer { - [name: string]: PlatformStatic; + [name: string]: Platform; } @@ -40,8 +38,8 @@ var tests: ITestContainer = { function runTests() { - var t: PlatformStatic; - var p: PlatformStatic; + var t: Platform; + var p: Platform; var x: string; var px: any; var res: boolean; From adcadc8b7cb1a3d69a00925b68ed88a2c77a7ae2 Mon Sep 17 00:00:00 2001 From: NomiBernard Date: Tue, 14 Mar 2017 15:35:33 +0100 Subject: [PATCH 094/258] fix transaction callback return type return bluebird instead of T --- bookshelf/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bookshelf/index.d.ts b/bookshelf/index.d.ts index 4aa6fd38b5..c7947579c8 100644 --- a/bookshelf/index.d.ts +++ b/bookshelf/index.d.ts @@ -17,7 +17,7 @@ interface Bookshelf extends Bookshelf.Events { Collection: typeof Bookshelf.Collection; plugin(name: string | string[] | Function, options?: any): Bookshelf; - transaction(callback: (transaction: knex.Transaction) => T): BlueBird; + transaction(callback: (transaction: knex.Transaction) => BlueBird): BlueBird; } declare function Bookshelf(knex: knex): Bookshelf; From dda288d3f6f1995d667cd05cc39fbe0af1f9596c Mon Sep 17 00:00:00 2001 From: Erik Krogh Kristensen Date: Tue, 14 Mar 2017 15:37:32 +0100 Subject: [PATCH 095/258] async: fixed the types of async.transform --- async/index.d.ts | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/async/index.d.ts b/async/index.d.ts index a17735eb6e..62e047b209 100644 --- a/async/index.d.ts +++ b/async/index.d.ts @@ -202,10 +202,11 @@ interface Async { timesSeries(n: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; timesLimit(n: number, limit: number, iterator: AsyncResultIterator, callback: AsyncResultArrayCallback): void; - transform(arr: T[], iteratee: (acc: R[], item: T, key: string, callback: (error?: E) => void) => void): void; - transform(arr: T[], acc: R[], iteratee: (acc: R[] | null, item: T | undefined[], key?: string, callback?: (error?: E) => void) => void): void; - transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; - transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void): void; + transform(arr: T[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; + transform(arr: T[], acc: R[], iteratee: (acc: R[], item: T, key: number, callback: (error?: E) => void) => void, callback?: AsyncResultArrayCallback): void; + + transform(arr: {[key: string] : T}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; + transform(arr: {[key: string] : T}, acc: {[key: string] : R}, iteratee: (acc: {[key: string] : R}, item: T, key: string, callback: (error?: E) => void) => void, callback?: AsyncResultObjectCallback): void; race(tasks: (AsyncFunction)[], callback: AsyncResultCallback) : void; From 264c29142589d25f87f2d3e4144c0426f1ba4c63 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 07:43:39 -0700 Subject: [PATCH 096/258] Remove more unnecessary references in test files (#15167) --- gapi.calendar/gapi.calendar-tests.ts | Bin 4385 -> 9070 bytes gapi/gapi-tests.ts | Bin 2877 -> 5944 bytes .../jquery-toastmessage-plugin-tests.ts | 3 --- .../knuddels-userapps-api-tests.ts | 2 -- nanoscroller/nanoscroller-tests.ts | 2 -- .../protractor-helpers-tests.ts | 2 -- 6 files changed, 9 deletions(-) diff --git a/gapi.calendar/gapi.calendar-tests.ts b/gapi.calendar/gapi.calendar-tests.ts index de335c6a1552bb34fce8383919b79bdd06aa64bb..909e503846a038e58a583b4e930fcdeb0868b805 100644 GIT binary patch literal 9070 zcmc(kYi}Dx6o%(B68~WV2|JY9X}Jel5z;_|3V~ieK&h%Uw;B>V*iKuh^4Ed)nX|_; zv%5}OT7fLzc4yA@J-6Av{~Ct(LKQZ{v#=A6!$~*_`}#lEzu)w0tltM=8Ya3|g>Upd z35WHX4Xt7IIPB@yRQK1z4`EB+-|GJpz3+rwT_1_+TvvY#r~17sy0b`s8m~Uq=Ugjh zVJ!^x+7rbmdLN0?iN2@0GZ4?jc_13dGc2xN7Qd57XQ=z7WW(@#2k&9{RkSPVKMZe% zH{$zw{H$~pS*q}pIGsk_HYCv~YKtyg;f6lpgM}XHdZktS(gb}?gFRhKw)BS=^YA!Q$!&~ONtPQm-DH_6Y>3iWT1=uR-q-4;J+W0Ae}g4|l`E+5*>fy%)Zaowmcha9h{gtFCLs=L-v?k5jy()!V|%rjSwvXx$HQw={Sf zc$FBy*Q1CG$HI>Mgbmx?A4JdWNOLT46#fv82Mvjcg7+4_2NURvN5CsSI?(5C!~%XE zN6(!~0uYMTcOsTtiixg{!k@Ye3XltFE3E>fAPMZu^^Ht}g0rC!I~|DMIHJVXA%V-Z zUhCTrD_WUw%f7?NXC%5VPx_T4>t|fq)udwA@b7Mh{fClyPuJG8zU}MxTQs54lkWJ5 zc($Fn=Ld>~iKvc4Uw2u(5|+^!DejM>RY%c&PLH@d)pf_L%YG(G<{h#W*~;y9Tfb-8 zb0jaU)M#MWS)}1~x^Qt*oSm9Q{Y;u!l#vHg%)9m7=E>ugc!L}=-L&C<=WQtbQnZOb zvNImqR<`lnai%NIBiDyaY|+rg8T`8DFOEDA?pizboM*pN5>S$7v~_7Sk`7Mcs&dJs zt~9x3ZA^R4aD82~eP!a2>}dIe7$-`>2r)|5AS-W1-}}|ClmoVe2k_RWcUgC!2oB%M zkO4X@4|MBVg?II;w8v@Y_8CM^lli9|5esdrI5)+E8kjs=DYI@x99xZ`;!p#~Xk>)E zF7f+OM9Wk<=H9i4aLJn18we3|?I1#^5o9a!)Q+y1WqYzG7$@Q^n;S*@ba|RRf%%&p zRqg?~)OezxEAN;s?kL+$l>57EL4}9wQ^`7(mo3XeEoJ4o?pu8wNjuLNiJDs>kIP5W zI7OgoXVRFZsRz!nZB2RsA`i}GUVnA_!xjH_`M|OkJTA^(TcXfy4|12;)VmVP6?t|u znM>4Kd_PtG!=kcJ?T+T5a8zMSt?7cX`;TU01uZ+eWlDH2dP} zoXKe4$-8EOBwssY{rf7M$F$YkW!08C;+2&(d0nOQwd*CT4iwiGd(_8dBg1HyE%Hp( zjAbw~mp!KPOinvR{Kc5OC5u`<%c}()M%l@`ryT{&d{?PQC3n$RpDKe{cj)n&yg19W zrq?4{cVjNfZBL%f^C|YEi}P$pcbDhb^D*YTnmVN%+029qLAg|e1%K)nePlj`^k)JR2)(`SEHpR+5x6o10o6)OKGpt(xpUjdr>oF(JBU-@a zzABzy!2@*IPK_M*O#irouc;Oufp`G!3AcFAceZmfRnqenohTS8Z8p%gt;nAm*W`ut z*4GjB^gyOv$=^DA>O1pYsx|02(`zSoB90(ig9Tp}Ll^t9Ya;OO2~C)VkqPTEb1g$z z+e*0)K%vRfZ%iL#kv1;rx2*T?)fRHBfYM}3%RxO!XBhb|`r3B(W&Qow58SAcgsv-! zL8{W0vfsAeHiOd>aJP&0tnMqAsEHl(g7HYXv3sZG5_aYBV|#rH>Dr05&om*Y-g{Qt z<4RcVl#=d*PH-CNSKW3gp6=Eb>J`>ITf}m1)6(w)QGKR2oie)jTNSY%F;5TJu4{P6 z@suON&;%#;4I~}3kM%EA0`o5M!yHUx?`i&L54o(Fp~^^H(+aOWxo*((zC4!)gu>xa zay-_W>w2#)(FYm_!Vt53zs3YqO{Z09VE?|*_i`S#>QcCL4wr808K0c;eR20w3b$JR z?H+g;V(e4-G`Q^_u=utRN=dE02vxpI!b zFW<4ttqQjBSij-#O8JlI`$ZH}#&$HDcAQ713cyM0NGRk)rdux0`w8o*OMRIq7|qjh z$z zZ`7L++x_&V>j{X>J)Do)DT_r35;4!6NCM9SXz)bx(%+63xniv$(|=>#E=}xNj%N$A z5U64b;RG;glICT%TTkoCXHc*D#DU7=^A8B~9@DO-^Cgp$tU%{s`N$%TU7&B%hLX%a9Q^MRM~Y^7FpBhYW>OGPwL-I{zf0WP;GvWzVT-wJz1Bl z*bd(fbv81Q77umZq5@nph2%DGo(T1{hA#beX?JCzi|P1(Ye(GW&-LgFOxOE`UCh$A zHNoAJ9XI8Vul0LVPqnY<3B&T0-KIr$c18FZIsr$3R-~l)R_TsKhLqbW@wfX9rZJ^Qh%$X={W%k0qmN z#MArb$gxwI8`{CtZO`It_4!lyB-ZR{M7Cv!Wgc@~i34gG(QIo=Ym$w6wcIunyWCfm zo$N{6$BM%)Tb{>*lXH5p6H#BzgY4IyIvy1GOZU&}dD{Kp9UYc`U1vLaXVN_1d6l!B zo_q$%$;4A3)MG8pa;{aHZ~RKB-;11KB&zLhJMTZ!3B+bS!%!vio_A02ZWATFZK6Af Vy~DBMkaOp;o)wgxs{b?Z{R2avS2_Ry literal 4385 zcmbtX+j84R5`EWKw6j$KBufCLB)bV6r6N;G%#>m|x;!|J%QXUq097D^{GI!_(3E`0VBNJD5MF=@E(Z#E? zE6BY0Bt+o;{=Rcv)T(jri`LG1zY`-xuB&44$y=u;-P?mQ+N04-W_P3}l(ojN?`~=Nrj^~{C1NkCypW9Q zQZ{X2cc0~TsJsPY zW9+Lx3bio1C0q}Y#ca~67o8HtEw(>B$O0B8|}|7<29MLgmt#q?_?R*L_8W7CHI+ zQK4>)Fbn4?wD&fFEotnckV&qZx)2Ml>`GS>)yy!+X$h?kmt&VBWQk;fbof$o2(D)O zeuY33g}ztS)U}|iS*y{J%5ov}_I(y^7o9D%Iq+t8e6EK`x2?5ZO#@H=d@FQS6{-in zgxbw&8m|MO2_P~{^u+~;4(j6|y3Pzmb~Z;U5f1)C&mC6pg@5#DagEs9*c~0xj~d3E zwvgG!TGS^Njk(^J8O`zLudaAJ%u5RnTc`K=Um7$6h?=f_ljQ9!Fnb zbgmkZR1JdXEIQX3PVXM+Dw7ZDk-%GArZV3WCVsI|dF#aG%_b}pM`3zI`xMPT!)E~y zHys8S(Pj&^yfO+I;}OxcWr^+}a1Hs%m7_|nDrL%FNKc$tB|ktOo#nkk>3GLjMPHV= zE1{^tg!1z-q49(&9S#Wt64Na#iS9Uv+vwW3#wcaeh^geb;7Mh-2j&mn^`y?kW8|-` zL=uiY#dneF;dt-~hbRv1+edKBJRiX{$0G{W5^*SgR2AOEmAt1@1SQ_xO{^YYU0h)T zSJSv>{HOsDoXSE1JPx>8>J>E*EqswT-8ksqmEwbESblRj=$~toOY?kzhmlLpHNZrU zF_y@x`_j3b$PY4Wfh~-^m|Ht^lb_*T?v7p8C(6pQ2~>wfV550uWE_R!>9RJAf+f$) zA%?P=+8KRAgOv@;Tx}?Z`=pS9!882%x>J*&B5(kYo<3bav4#vsyz(~+n*bBA|KY^m zGpl#+!P?lc5-v}U$GRwwjwdX;X@dUj{Q6m@%Cld5((m(^SuUGYLSL<+G({2x$PHgN6mT1J?WU}85Pc*$j} zQBeKA_W8)olH9Q%zVd4<>s*{klvoLzByLfB-Ms$=1Fg?IYF6iMW}77Fb7TZf9y`znUSjQx`C#zH z!O@r3gRh2z0e%k#|H9|yeEFHTP6ks-gL_PRuA6r!$Uq^Rj_o_};OM_#>X0q`T~h|* zgs)v0BYWdw2j?y?Z_dw#-(8;lbbNX;K7ajebaC_Y`uNDheA~ek79E;PpkE#R7|Bwo zg54}?%=vG-KHv*s)GudiQq3*+VpGbY2u6&=nuYPmM*84mjXaeTftwAUZq8qgo07p* zVI36idr>KIEpoHp1H>W)#Tcb5c=S0q^Phtr-{yf@*KN(4*XqFGAdG>x4lVz;?61dv zZ9nlu(QPP??k5q3JnsE2M~-FKnxEHyx)(UPK*KAZj?UZ`@2M1XeMy5@@f>E1Y{YKdn@*hVoLmOu+F}3cO8Z zAKX@0Rmz(3v4a&SxDN52GEDI%gA4_Jd&+qRDY-YF%e9Q>L&!(@D_Pd@bL<=9nqk!o zj81TsSU1JG30CEJs&qv>UdC$jx`Y*!h1aS6Cz#!Zyu`Qyl>(!rMrB0?@(pIfYVI&C ztwMrCHn8JB_YRfE*Wj4C+SmKtIhR{CE|W;Iq#;?h;EN{(E!WY=aH5?$XmG|oDbA#2 z+ye(QJgw>66Zutsmq+qUewK&e`WfD@%M-l65}jxicCeqw7OFKOejDR$%o)9>xHol7 zy}BL7x;1{Nao6$J(mo-F9%ef+^*EyJgLIL>>An6Ev#hN{XC1)x%sSjFq-(~5P+Hk*$ zy?xg18aRSkh2x%yL8@(`dR(osqwxafS zAEyu1yFW%m4bhYslkNasQjaL~nK=GC-)E}(^Jk9L&oXm-iP4@Xcu!&d^lrwN&m~5C z2DM1v7mrh5GSpn;xO_-8aUv_oQe9Cz&VbYjqjo)~e~IE_L|V&KmRUZ%D89PLJ|T+J z26A)+|NowbeIR{>)e*glmTr9(Ygf+1olVGc^~`2EW^Efhv+aeXZT(-4%D?GVmK|*u zJFz32ZT@?TyU}K^;68m9v2P!BM+&d|P(QQG@(WI7wa-e)tGZAjQKx5`!7ow=bx{s= zjM4NefKPq+)@uq!(Geq-DXj1!^>^PnPCM@WGqnZwJ=?&Xakon&)I`ihvqnwub>TX& zJ;lYfR-=Ux5n$gv#d}6vcJiz(?_gZ%*_Z!FZ?Eu$kRoSM~aNhriaJieugL3 zd$ez^rOsz^1EX7*9pRLh7&kM<9@cZ$u{;OP-f2F-EWZ#G%I7Xtjcb!l0`oRJZ>MxbQ zfL;ANL9l}nqR|>wa2*l&7@ZMmIZp0@R=Zd~KOHc543=$J(~$9@@?q z9*g?2MZD9kuRmu5D>O+Nt48?dNT25yn-Q#|?R9Q>rh_50^$06VSX69-mN(h|)6;zo zqZjjNuscU7j(X?!%~)z`(lg?}ffvu~`@-W$y&o>I&vv8K)DE)*qwl*>cRhrNA9HE> NVGCBk2ygbm|F^fEt8oAT literal 2877 zcmd^B+m6#P5Pk1gj1W><=*Dyr5-Kc+OA+NREhQtoGQz)x`84r9Czrc7B zr(L#OBm^(Kv{CGtIdeNFUq62lLcmpvbF`>41iz}#9h_OnN~IN=s=zZKuJwL)tEe5{ z>4|eN`6x@Wap2`U)G)WEgxveejfI%u5(`tIb?L&GMS*E%NU^KyE7pX%S2n(v$_LImp`Qpd4u9 z!Q%T`S)4T~5SD1)p?x{Id3fu=bn@u=;q-PYt14E#c4#xBJykrQ+N8r#gMDSqTou@! ztOqGoQTJobyJB;>FPEmf=-Zt4$Y?M!Vmd?ZT@ zxOg5#iAmdm_23FWoq|Y)mC+94TmVqU&d|seX3>wQDLvGMk4}c&SkVpXjNWaXOsqAQ z;J|qT81A)xQVa)aiO$IdMz8$84mhdHqZA$(Is5fka)k=I+HX6X4BJ^Jf9qXKu;2CN zpDw}wJi1{CX}CMWpf#+d&%+A+oCua9v6!mTsT z<|^|?FOb>^qzw%OZ~@YClIQA~I9-PU_WlxRqn}t`q!)@_Bv4()Unh);Kfw;yHa_ zG-@oAbF@EVbm8*FOTphfL>q5dxN|%N%?jYWReBL=c{|~*n_&TI|4#R^Y32Bs`#5HY zr<=GHG1ewV1J1LhdMa-1@;?v~ZgoFoMJ@dx8&T){aW5vTGwa3J|YqR1}zw-@Bjb+ diff --git a/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts b/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts index d1feba15ce..f11813cfbb 100644 --- a/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts +++ b/jquery-toastmessage-plugin/jquery-toastmessage-plugin-tests.ts @@ -1,6 +1,3 @@ -/// - - /* code examples from documentation */ $().toastmessage('showNoticeToast', 'some message here'); diff --git a/knuddels-userapps-api/knuddels-userapps-api-tests.ts b/knuddels-userapps-api/knuddels-userapps-api-tests.ts index 1faaa193e5..a940b7f19b 100644 --- a/knuddels-userapps-api/knuddels-userapps-api-tests.ts +++ b/knuddels-userapps-api/knuddels-userapps-api-tests.ts @@ -1,5 +1,3 @@ -/// - class Server implements App { private usersPlaying: { [nick: string]: number } = {}; diff --git a/nanoscroller/nanoscroller-tests.ts b/nanoscroller/nanoscroller-tests.ts index 3b9eeea820..46e61c1aaf 100644 --- a/nanoscroller/nanoscroller-tests.ts +++ b/nanoscroller/nanoscroller-tests.ts @@ -1,5 +1,3 @@ -/// - $('.nano').nanoScroller(); $('.nano').nanoScroller({ diff --git a/protractor-helpers/protractor-helpers-tests.ts b/protractor-helpers/protractor-helpers-tests.ts index 9b03e43005..543991392b 100644 --- a/protractor-helpers/protractor-helpers-tests.ts +++ b/protractor-helpers/protractor-helpers-tests.ts @@ -1,5 +1,3 @@ -/// - import helpers = require('protractor-helpers'); declare var $$: any, $: any, by: any, element: any; // ?? From 04fed0d7022ff5e02089e8f8fdcded8963281cad Mon Sep 17 00:00:00 2001 From: Balazs Erdos Date: Tue, 14 Mar 2017 15:48:45 +0100 Subject: [PATCH 097/258] Add missing parameter. --- riot/index.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/riot/index.d.ts b/riot/index.d.ts index 3abb3fa147..3c76a0b1d0 100644 --- a/riot/index.d.ts +++ b/riot/index.d.ts @@ -205,8 +205,9 @@ declare namespace riot { * Register a shared mixin, globally available to be used in any tag using `TagInstance.mixin(mixinName)` * @param mixinName Name of the mixin * @param mixinObject Mixin object + * @param isGlobal Is global mixin? */ - function mixin(mixinName: string, mixinObject: TagMixin): void; + function mixin(mixinName: string, mixinObject: TagMixin, isGlobal?: boolean): void; /** * Create a new custom tag “manually” without the compiler. Returns name of the tag. From 023bcf3e7ae33cac5fc278cfd415683d4297f5a6 Mon Sep 17 00:00:00 2001 From: Alexander Abashkin Date: Tue, 14 Mar 2017 17:55:00 +0300 Subject: [PATCH 098/258] =?UTF-8?q?Platform=20=E2=80=94=20Fixed=20declarat?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/index.d.ts | 9 ++++----- platform/platform-tests.ts | 34 ++++++++++++++-------------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/platform/index.d.ts b/platform/index.d.ts index ad6100c707..eed60394f4 100644 --- a/platform/index.d.ts +++ b/platform/index.d.ts @@ -1,10 +1,9 @@ -// Type definitions for Platform 1.0.0 +// Type definitions for Platform 1.3 // Project: https://github.com/bestiejs/platform.js // Definitions by: Jake Hickman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -interface Platform { +declare interface Platform { description?: string; layout?: string; manufacturer?: string; @@ -23,9 +22,9 @@ interface Platform { toString?(): string; } -declare var platform: Platform; - declare module "platform" { + declare var platform: Platform; + export = platform; } diff --git a/platform/platform-tests.ts b/platform/platform-tests.ts index 572e85830c..65433ffb13 100644 --- a/platform/platform-tests.ts +++ b/platform/platform-tests.ts @@ -1,9 +1,8 @@ -interface ITestContainer { +interface TestContainer { [name: string]: Platform; } - -var tests: ITestContainer = { +var tests: TestContainer = { 'Chrome Mobile 16.0.912.77 on Android 4.0.3': { description: "Chrome Mobile 16.0.912.77 on Android 4.0.3", layout: "WebKit", @@ -45,34 +44,29 @@ function runTests() { var res: boolean; var onFalse: (name: string) => () => any; - for (var n in tests) { - + for (const [n, value] of Object.entries(tests)) { t = tests[n]; p = platform.parse(t.ua); - onFalse = (name: string) => { return () => { console.log('\tfailed on prop "' + name + '" for "' + n + '"'); - } - } + }; + }; console.log('Starting tests for: ' + n); - falsy(() => { return t.description === p.description }, onFalse('description')); - falsy(() => { return t.layout === p.layout }, onFalse('layout')); - falsy(() => { return t.name === p.name }, onFalse('name')); - falsy(() => { return t.prerelease === p.prerelease }, onFalse('prerelease')); - falsy(() => { return t.ua === p.ua }, onFalse('ua')); - falsy(() => { return t.version === p.version }, onFalse('version')); - - falsy(() => { return t.os.architecture === p.os.architecture }, onFalse('os.architecture')); - falsy(() => { return t.os.family === p.os.family }, onFalse('os.family')); - falsy(() => { return t.os.version === p.os.version }, onFalse('os.version')); + falsy(() => t.description === p.description, onFalse('description')); + falsy(() => t.layout === p.layout, onFalse('layout')); + falsy(() => t.name === p.name, onFalse('name')); + falsy(() => t.prerelease === p.prerelease, onFalse('prerelease')); + falsy(() => t.ua === p.ua, onFalse('ua')); + falsy(() => t.version === p.version, onFalse('version')); + falsy(() => t.os.architecture === p.os.architecture, onFalse('os.architecture')); + falsy(() => t.os.family === p.os.family, onFalse('os.family')); + falsy(() => t.os.version === p.os.version, onFalse('os.version')); console.log('Finished tests for: ' + n); - - } } From bb8dfc6c4744926ef38245fb85cb6186f1100b49 Mon Sep 17 00:00:00 2001 From: Alexander Abashkin Date: Tue, 14 Mar 2017 18:01:18 +0300 Subject: [PATCH 099/258] =?UTF-8?q?Platform=20=E2=80=94=20Fixed=20declarat?= =?UTF-8?q?ions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- platform/index.d.ts | 4 ++-- platform/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/platform/index.d.ts b/platform/index.d.ts index eed60394f4..fd995a085e 100644 --- a/platform/index.d.ts +++ b/platform/index.d.ts @@ -22,9 +22,9 @@ declare interface Platform { toString?(): string; } -declare module "platform" { - declare var platform: Platform; +declare var platform: Platform; +declare module "platform" { export = platform; } diff --git a/platform/tsconfig.json b/platform/tsconfig.json index c7a29f12be..2efb10866a 100644 --- a/platform/tsconfig.json +++ b/platform/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "module": "commonjs", "lib": [ - "es6", + "es2017", "dom" ], "noImplicitAny": true, From 5141daceb0a11f126a035ccc6e7044530bb2c3c1 Mon Sep 17 00:00:00 2001 From: use-strict Date: Tue, 14 Mar 2017 17:15:43 +0200 Subject: [PATCH 100/258] Update http-errors-tests.ts --- http-errors/http-errors-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/http-errors/http-errors-tests.ts b/http-errors/http-errors-tests.ts index e8c12126b4..51017828a1 100644 --- a/http-errors/http-errors-tests.ts +++ b/http-errors/http-errors-tests.ts @@ -83,3 +83,4 @@ var err = new createError.MisdirectedRequest(); var err = new createError.MisdirectedRequest('Where should this go?'); let error: createError.HttpError; +console.log(error instanceof createError.HttpError); From 1fb801b4155cb95695504d36354ca2c801667bb6 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Tue, 14 Mar 2017 17:17:12 +0100 Subject: [PATCH 101/258] Update React Router to version 4.0 --- react-router-dom/index.d.ts | 80 ++++++++ react-router-dom/tsconfig.json | 18 ++ react-router-dom/tslint.json | 6 + react-router/examples/Ambiguous.tsx | 50 +++++ react-router/examples/Animation.tsx | 123 ++++++++++++ react-router/examples/Auth.tsx | 101 ++++++++++ react-router/examples/Basic.tsx | 73 ++++++++ react-router/examples/CustomLink.tsx | 45 +++++ react-router/examples/ModalGallery.tsx | 177 ++++++++++++++++++ react-router/examples/NoMatch.tsx | 48 +++++ react-router/examples/Params.tsx | 31 +++ .../examples/PreventingTransitions.tsx | 74 ++++++++ react-router/examples/README.md | 1 + react-router/examples/Recursive.tsx | 50 +++++ react-router/examples/RouteConfig.tsx | 88 +++++++++ react-router/examples/Sidebar.tsx | 80 ++++++++ react-router/index.d.ts | 154 +++++++++------ react-router/tsconfig.json | 70 +++---- react-router/tslint.json | 9 +- react-router/v3/index.d.ts | 62 ++++++ react-router/{ => v3}/lib/IndexLink.d.ts | 0 react-router/{ => v3}/lib/IndexRedirect.d.ts | 0 react-router/{ => v3}/lib/IndexRoute.d.ts | 0 react-router/{ => v3}/lib/Link.d.ts | 0 react-router/{ => v3}/lib/PatternUtils.d.ts | 0 react-router/{ => v3}/lib/PropTypes.d.ts | 0 react-router/{ => v3}/lib/Redirect.d.ts | 0 react-router/{ => v3}/lib/Route.d.ts | 0 react-router/{ => v3}/lib/RouteUtils.d.ts | 0 react-router/{ => v3}/lib/Router.d.ts | 0 react-router/{ => v3}/lib/RouterContext.d.ts | 0 .../{ => v3}/lib/applyRouterMiddleware.d.ts | 0 react-router/{ => v3}/lib/browserHistory.d.ts | 0 .../{ => v3}/lib/createMemoryHistory.d.ts | 0 react-router/{ => v3}/lib/hashHistory.d.ts | 0 react-router/{ => v3}/lib/match.d.ts | 0 .../{ => v3}/lib/useRouterHistory.d.ts | 0 react-router/{ => v3}/lib/withRouter.d.ts | 0 react-router/{ => v3}/react-router-tests.tsx | 0 react-router/v3/tsconfig.json | 46 +++++ react-router/v3/tslint.json | 1 + 41 files changed, 1288 insertions(+), 99 deletions(-) create mode 100644 react-router-dom/index.d.ts create mode 100644 react-router-dom/tsconfig.json create mode 100644 react-router-dom/tslint.json create mode 100644 react-router/examples/Ambiguous.tsx create mode 100644 react-router/examples/Animation.tsx create mode 100644 react-router/examples/Auth.tsx create mode 100644 react-router/examples/Basic.tsx create mode 100644 react-router/examples/CustomLink.tsx create mode 100644 react-router/examples/ModalGallery.tsx create mode 100644 react-router/examples/NoMatch.tsx create mode 100644 react-router/examples/Params.tsx create mode 100644 react-router/examples/PreventingTransitions.tsx create mode 100644 react-router/examples/README.md create mode 100644 react-router/examples/Recursive.tsx create mode 100644 react-router/examples/RouteConfig.tsx create mode 100644 react-router/examples/Sidebar.tsx create mode 100644 react-router/v3/index.d.ts rename react-router/{ => v3}/lib/IndexLink.d.ts (100%) rename react-router/{ => v3}/lib/IndexRedirect.d.ts (100%) rename react-router/{ => v3}/lib/IndexRoute.d.ts (100%) rename react-router/{ => v3}/lib/Link.d.ts (100%) rename react-router/{ => v3}/lib/PatternUtils.d.ts (100%) rename react-router/{ => v3}/lib/PropTypes.d.ts (100%) rename react-router/{ => v3}/lib/Redirect.d.ts (100%) rename react-router/{ => v3}/lib/Route.d.ts (100%) rename react-router/{ => v3}/lib/RouteUtils.d.ts (100%) rename react-router/{ => v3}/lib/Router.d.ts (100%) rename react-router/{ => v3}/lib/RouterContext.d.ts (100%) rename react-router/{ => v3}/lib/applyRouterMiddleware.d.ts (100%) rename react-router/{ => v3}/lib/browserHistory.d.ts (100%) rename react-router/{ => v3}/lib/createMemoryHistory.d.ts (100%) rename react-router/{ => v3}/lib/hashHistory.d.ts (100%) rename react-router/{ => v3}/lib/match.d.ts (100%) rename react-router/{ => v3}/lib/useRouterHistory.d.ts (100%) rename react-router/{ => v3}/lib/withRouter.d.ts (100%) rename react-router/{ => v3}/react-router-tests.tsx (100%) create mode 100644 react-router/v3/tsconfig.json create mode 100644 react-router/v3/tslint.json diff --git a/react-router-dom/index.d.ts b/react-router-dom/index.d.ts new file mode 100644 index 0000000000..7b827ba3d5 --- /dev/null +++ b/react-router-dom/index.d.ts @@ -0,0 +1,80 @@ +// Type definitions for React Router 4.0 +// Project: https://github.com/ReactTraining/react-router +// Definitions by: Tanguy Krotoff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare module 'react-router-dom' { + import { + Prompt, + MemoryRouter, + Redirect, + RouteComponentProps, + PartialRouteComponentProps, + RouteProps, + Route, + Router, + StaticRouter, + Switch, + match, + matchPath, + withRouter + } from 'react-router'; + import * as React from 'react'; + import * as H from 'history'; + + + interface BrowserRouterProps { + basename?: string; + getUserConfirmation?: () => void; + forceRefresh?: boolean; + keyLength?: number; + } + class BrowserRouter extends React.Component {} + + + interface HashRouterProps { + basename?: string; + getUserConfirmation?: () => void; + hashType?: 'slash' | 'noslash' | 'hashbang'; + } + class HashRouter extends React.Component {} + + + interface LinkProps extends React.HTMLAttributes { + to: H.LocationDescriptor; + replace?: boolean; + } + class Link extends React.Component {} + + + interface NavLinkProps extends LinkProps { + activeClassName?: string; + activeStyle?: React.CSSProperties; + exact?: boolean; + strict?: boolean; + isActive?: (location: H.Location, props: any) => boolean; + } + class NavLink extends React.Component {} + + + export { + BrowserRouter, + HashRouter, + LinkProps, // TypeScript specific, not from React Router itself + Link, + NavLink, + Prompt, + MemoryRouter, + Redirect, + RouteComponentProps, // TypeScript specific, not from React Router itself + PartialRouteComponentProps, // TypeScript specific, not from React Router itself + RouteProps, // TypeScript specific, not from React Router itself + Route, + Router, + StaticRouter, + Switch, + match, // TypeScript specific, not from React Router itself + matchPath, + withRouter + } +} diff --git a/react-router-dom/tsconfig.json b/react-router-dom/tsconfig.json new file mode 100644 index 0000000000..41c143c1c6 --- /dev/null +++ b/react-router-dom/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/react-router-dom/tslint.json b/react-router-dom/tslint.json new file mode 100644 index 0000000000..cfdf2986e5 --- /dev/null +++ b/react-router-dom/tslint.json @@ -0,0 +1,6 @@ +{ + "extends": "../tslint.json", + "rules": { + "no-single-declare-module": false + } +} diff --git a/react-router/examples/Ambiguous.tsx b/react-router/examples/Ambiguous.tsx new file mode 100644 index 0000000000..971636a1e0 --- /dev/null +++ b/react-router/examples/Ambiguous.tsx @@ -0,0 +1,50 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + Switch +} from 'react-router-dom' + +const AmbiguousExample = () => ( + +
+
    +
  • About Us (static)
  • +
  • Company (static)
  • +
  • Kim (dynamic)
  • +
  • Chris (dynamic)
  • +
+ + {/* + Sometimes you want to have a whitelist of static paths + like "/about" and "/company" but also allow for dynamic + patterns like "/:user". The problem is that "/about" + is ambiguous and will match both "/about" and "/:user". + Most routers have an algorithm to decide for you what + it will match since they only allow you to match one + "route". React Router lets you match in multiple places + on purpose (sidebars, breadcrumbs, etc). So, when you + want to clear up any ambiguous matching, and not match + "/about" to "/:user", just wrap your s in a + . It will render the first one that matches. + */} + + + + + +
+
+) + +const About = () =>

About

+const Company = () =>

Company

+const User: React.SFC> = ({ match }) => ( +
+

User: {match.params.user}

+
+) + +export default AmbiguousExample \ No newline at end of file diff --git a/react-router/examples/Animation.tsx b/react-router/examples/Animation.tsx new file mode 100644 index 0000000000..1696dfd6fd --- /dev/null +++ b/react-router/examples/Animation.tsx @@ -0,0 +1,123 @@ +import * as React from 'react' +import * as ReactCSSTransitionGroup from 'react-addons-css-transition-group' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + LinkProps, + Link, + Redirect +} from 'react-router-dom' + +/* you'll need this CSS somewhere +.fade-enter { + opacity: 0; + z-index: 1; +} +.fade-enter.fade-enter-active { + opacity: 1; + transition: opacity 250ms ease-in; +} +*/ + +const AnimationExample = () => ( + + ( +
+ ( + + )}/> + +
    + Red + Green + Blue + Pink +
+ +
+ + {/* no different than other usage of + ReactCSSTransitionGroup, just make + sure to pass `location` to `Route` + so it can match the old location + as it animates out + */} + + +
+
+ )}/> +
+) + +const NavLink: React.SFC = (props) => ( +
  • + +
  • +) + +interface HSLParams { + h: number; + s: number; + l: number; +} + +const HSL: React.SFC> = ({ match: { params } }) => ( +
    hsl({params.h}, {params.s}%, {params.l}%)
    +) + +const styles: any = {} + +styles.fill = { + position: 'absolute', + left: 0, + right: 0, + top: 0, + bottom: 0 +} + +styles.content = { + ...styles.fill, + top: '40px', + textAlign: 'center' +} + +styles.nav = { + padding: 0, + margin: 0, + position: 'absolute', + top: 0, + height: '40px', + width: '100%', + display: 'flex' +} + +styles.navItem = { + textAlign: 'center', + flex: 1, + listStyleType: 'none', + padding: '10px' +} + +styles.hsl = { + ...styles.fill, + color: 'white', + paddingTop: '20px', + fontSize: '30px' +} + +export default AnimationExample \ No newline at end of file diff --git a/react-router/examples/Auth.tsx b/react-router/examples/Auth.tsx new file mode 100644 index 0000000000..86dffe2b63 --- /dev/null +++ b/react-router/examples/Auth.tsx @@ -0,0 +1,101 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + RouteProps, + Route, + Link, + Redirect, + withRouter +} from 'react-router-dom' + +//////////////////////////////////////////////////////////// +// 1. Click the public page +// 2. Click the protected page +// 3. Log in +// 4. Click the back button, note the URL each time + +const AuthExample = () => ( + +
    + +
      +
    • Public Page
    • +
    • Protected Page
    • +
    + + + +
    +
    +) + +const fakeAuth = { + isAuthenticated: false, + authenticate(this: any, cb: () => void) { + this.isAuthenticated = true + setTimeout(cb, 100) // fake async + }, + signout(this: any, cb: () => void) { + this.isAuthenticated = false + setTimeout(cb, 100) + } +} + +const AuthButton = withRouter(({ history }) => ( + fakeAuth.isAuthenticated ? ( +

    + Welcome! +

    + ) : ( +

    You are not logged in.

    + ) +)) + +const PrivateRoute: React.SFC = ({ component, ...rest }) => ( + ( + fakeAuth.isAuthenticated ? React.createElement(component! as React.SFC, props) : ( + + ) + )}/> +) + +const Public: React.SFC> = () =>

    Public

    +const Protected: React.SFC> = () =>

    Protected

    + +class Login extends React.Component, {redirectToReferrer: boolean}> { + state = { + redirectToReferrer: false + } + + login = () => { + fakeAuth.authenticate(() => { + this.setState({ redirectToReferrer: true }) + }) + } + + render() { + const { from } = this.props.location.state || { from: { pathname: '/' } } + const { redirectToReferrer } = this.state + + if (redirectToReferrer) { + return ( + + ) + } + + return ( +
    +

    You must log in to view the page at {from.pathname}

    + +
    + ) + } +} + +export default AuthExample \ No newline at end of file diff --git a/react-router/examples/Basic.tsx b/react-router/examples/Basic.tsx new file mode 100644 index 0000000000..16ff86947a --- /dev/null +++ b/react-router/examples/Basic.tsx @@ -0,0 +1,73 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link +} from 'react-router-dom' + +const BasicExample = () => ( + +
    +
      +
    • Home
    • +
    • About
    • +
    • Topics
    • +
    + +
    + + + + +
    +
    +) + +const Home = () => ( +
    +

    Home

    +
    +) + +const About = () => ( +
    +

    About

    +
    +) + +const Topics: React.SFC> = ({ match }) => ( +
    +

    Topics

    +
      +
    • + + Rendering with React + +
    • +
    • + + Components + +
    • +
    • + + Props v. State + +
    • +
    + + + ( +

    Please select a topic.

    + )}/> +
    +) + +const Topic: React.SFC> = ({ match }) => ( +
    +

    {match.params.topicId}

    +
    +) + +export default BasicExample \ No newline at end of file diff --git a/react-router/examples/CustomLink.tsx b/react-router/examples/CustomLink.tsx new file mode 100644 index 0000000000..2159cf039a --- /dev/null +++ b/react-router/examples/CustomLink.tsx @@ -0,0 +1,45 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + Route, + LinkProps, + Link +} from 'react-router-dom' + +const CustomLinkExample = () => ( + +
    + + +
    + + +
    +
    +) + +interface OldSchoolMenuLinkProps extends LinkProps { + activeOnlyWhenExact?: boolean; +} + +const OldSchoolMenuLink: React.SFC = ({ label, to, activeOnlyWhenExact }) => ( + ( +
    + {match ? '> ' : ''}{label} +
    + )}/> +) + +const Home = () => ( +
    +

    Home

    +
    +) + +const About = () => ( +
    +

    About

    +
    +) + +export default CustomLinkExample \ No newline at end of file diff --git a/react-router/examples/ModalGallery.tsx b/react-router/examples/ModalGallery.tsx new file mode 100644 index 0000000000..ccaefe3adc --- /dev/null +++ b/react-router/examples/ModalGallery.tsx @@ -0,0 +1,177 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + Switch, + RouteComponentProps, + Route, + Link +} from 'react-router-dom' + +// This example shows how to render two different screens +// (or the same screen in a different context) at the same url, +// depending on you got there. +// +// Click the colors and see them full screen, then "visit the +// gallery" and click on the colors. Note the URL and the component +// are the same as before but now we see them inside a modal +// on top of the old screen. + +class ModalSwitch extends React.Component, void> { + + // We can pass a location to that will tell it to + // ignore the router's current location and use the location + // prop instead. + // + // We can also use "location state" to tell the app the user + // wants to go to `/images/2` in a modal, rather than as the + // main page, keeping the gallery visible behind it. + // + // Normally, `/images/2` wouldn't match the gallery at `/`. + // So, to get both screens to render, we can save the old + // location and pass it to Switch, so it will think the location + // is still `/` even though its `/images/2`. + previousLocation = this.props.location + + componentWillUpdate(nextProps: RouteComponentProps) { + const { location } = this.props + // set previousLocation if props.location is not modal + if ( + nextProps.history.action !== 'POP' && + (!location.state || !location.state.modal) + ) { + this.previousLocation = this.props.location + } + } + + render() { + const { location } = this.props + const isModal = !!( + location.state && + location.state.modal && + this.previousLocation !== location // not initial render + ) + return ( +
    + + + + + + {isModal ? : null} +
    + ) + } +} + +const IMAGES = [ + { id: 0, title: 'Dark Orchid', color: 'DarkOrchid' }, + { id: 1, title: 'Lime Green', color: 'LimeGreen' }, + { id: 2, title: 'Tomato', color: 'Tomato' }, + { id: 3, title: 'Seven Ate Nine', color: '#789' }, + { id: 4, title: 'Crimson', color: 'Crimson' } +] + +const Thumbnail: React.SFC<{color: string}> = ({ color }) => +
    + +const Image: React.SFC<{color: string}> = ({ color }) => +
    + +const Home = () => ( +
    + Visit the Gallery +

    Featured Images

    +
      +
    • Tomato
    • +
    • Crimson
    • +
    +
    +) + +const Gallery = () => ( +
    + {IMAGES.map(i => ( + + +

    {i.title}

    + + ))} +
    +) + +const ImageView: React.SFC> = ({ match }) => { + const image = IMAGES[parseInt(match.params.id, 10)] + if (!image) { + return
    Image not found
    + } + + return ( +
    +

    {image.title}

    + +
    + ) +} + +const Modal: React.SFC> = ({ match, history }) => { + const image = IMAGES[parseInt(match.params.id, 10)] + if (!image) { + return null! + } + const back = (e: React.MouseEvent) => { + e.stopPropagation() + history.goBack() + } + return ( +
    +
    +

    {image.title}

    + + +
    +
    + ) +} + +const ModalGallery = () => ( + + + +) + +export default ModalGallery \ No newline at end of file diff --git a/react-router/examples/NoMatch.tsx b/react-router/examples/NoMatch.tsx new file mode 100644 index 0000000000..10b7a64fa9 --- /dev/null +++ b/react-router/examples/NoMatch.tsx @@ -0,0 +1,48 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + Switch, + Redirect +} from 'react-router-dom' + +const NoMatchExample = () => ( + +
    +
      +
    • Home
    • +
    • Old Match, to be redirected
    • +
    • Will Match
    • +
    • Will Not Match
    • +
    • Also Will Not Match
    • +
    + + + + + + +
    +
    +) + +const Home = () => ( +

    + A <Switch> renders the + first child <Route> that + matches. A <Route> with + no path always matches. +

    +) + +const WillMatch = () =>

    Matched!

    + +const NoMatch: React.SFC> = ({ location }) => ( +
    +

    No match for {location.pathname}

    +
    +) + +export default NoMatchExample \ No newline at end of file diff --git a/react-router/examples/Params.tsx b/react-router/examples/Params.tsx new file mode 100644 index 0000000000..148161c317 --- /dev/null +++ b/react-router/examples/Params.tsx @@ -0,0 +1,31 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link +} from 'react-router-dom' + +const ParamsExample = () => ( + +
    +

    Accounts

    +
      +
    • Netflix
    • +
    • Zillow Group
    • +
    • Yahoo
    • +
    • Modus Create
    • +
    + + +
    +
    +) + +const Child: React.SFC> = ({ match }) => ( +
    +

    ID: {match.params.id}

    +
    +) + +export default ParamsExample \ No newline at end of file diff --git a/react-router/examples/PreventingTransitions.tsx b/react-router/examples/PreventingTransitions.tsx new file mode 100644 index 0000000000..b23ba65608 --- /dev/null +++ b/react-router/examples/PreventingTransitions.tsx @@ -0,0 +1,74 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + Prompt +} from 'react-router-dom' + +const PreventingTransitionsExample = () => ( + +
    +
      +
    • Form
    • +
    • One
    • +
    • Two
    • +
    + +

    One

    }/> +

    Two

    }/> +
    +
    +) + +class Form extends React.Component { + state = { + isBlocking: false + } + + render() { + const { isBlocking } = this.state + + return ( +
    { + event.preventDefault(); + (event.target as HTMLFormElement).reset(); + this.setState({ + isBlocking: false + }) + }} + > + ( + `Are you sure you want to go to ${location.pathname}` + )} + /> + +

    + Blocking? {isBlocking ? 'Yes, click a link or the back button' : 'Nope'} +

    + +

    + { + this.setState({ + isBlocking: event.target.value.length > 0 + }) + }} + /> +

    + +

    + +

    + + ) + } +} + +export default PreventingTransitionsExample \ No newline at end of file diff --git a/react-router/examples/README.md b/react-router/examples/README.md new file mode 100644 index 0000000000..341bd29130 --- /dev/null +++ b/react-router/examples/README.md @@ -0,0 +1 @@ +Examples taken from https://github.com/ReactTraining/react-router/tree/22bd52c901ef0312348c2b02549c7102bd5653ae/packages/react-router-website/modules/examples diff --git a/react-router/examples/Recursive.tsx b/react-router/examples/Recursive.tsx new file mode 100644 index 0000000000..ec6e77207b --- /dev/null +++ b/react-router/examples/Recursive.tsx @@ -0,0 +1,50 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + Route, + Link, + match +} from 'react-router-dom' +import * as H from 'history'; + +const PEEPS = [ + { id: 0, name: 'Michelle', friends: [ 1, 2, 3 ] }, + { id: 1, name: 'Sean', friends: [ 0, 3 ] }, + { id: 2, name: 'Kim', friends: [ 0, 1, 3 ], }, + { id: 3, name: 'David', friends: [ 1, 2 ] } +] + +const find = (id: number) => PEEPS.find(p => p.id == id) + +const RecursiveExample = () => ( + + + +) + +interface PersonProps extends Partial> { + match: match<{id: number}>; +} + +const Person: React.SFC = ({ match }) => { + const person = find(match.params.id) + + return ( +
    +

    {person!.name}’s Friends

    +
      + {person!.friends.map(id => ( +
    • + + {find(id)!.name} + +
    • + ))} +
    + +
    + ) +} + +export default RecursiveExample \ No newline at end of file diff --git a/react-router/examples/RouteConfig.tsx b/react-router/examples/RouteConfig.tsx new file mode 100644 index 0000000000..1dffdc1527 --- /dev/null +++ b/react-router/examples/RouteConfig.tsx @@ -0,0 +1,88 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteComponentProps, + RouteProps, + Route, + Link +} from 'react-router-dom' + +// Some folks find value in a centralized route config. +// A route config is just data. React is great at mapping +// data into components, and is a component. + +//////////////////////////////////////////////////////////// +// first our route components +const Main = () =>

    Main

    + +const Sandwiches = () =>

    Sandwiches

    + +interface PropsWithRoutes extends RouteComponentProps { + routes: Array; +} + +const Tacos: React.SFC = ({ routes }) => ( +
    +

    Tacos

    +
      +
    • Bus
    • +
    • Cart
    • +
    + + {routes.map((route, i) => ( + + ))} +
    +) + +const Bus = () =>

    Bus

    +const Cart = () =>

    Cart

    + +//////////////////////////////////////////////////////////// +// then our route config +interface MyRouteProps extends RouteProps { + component: React.SFC; + routes?: MyRouteProps[]; +} +const routes: Array = [ + { path: '/sandwiches', + component: Sandwiches + }, + { path: '/tacos', + component: Tacos, + routes: [ + { path: '/tacos/bus', + component: Bus + }, + { path: '/tacos/cart', + component: Cart + } + ] + } +] + +// wrap and use this everywhere instead, then when +// sub routes are added to any route it'll work +const RouteWithSubRoutes = (route: MyRouteProps) => ( + ( + // pass the sub-routes down to keep nesting + + )}/> +) + +const RouteConfigExample = () => ( + +
    +
      +
    • Tacos
    • +
    • Sandwiches
    • +
    + + {routes.map((route, i) => ( + + ))} +
    +
    +) + +export default RouteConfigExample \ No newline at end of file diff --git a/react-router/examples/Sidebar.tsx b/react-router/examples/Sidebar.tsx new file mode 100644 index 0000000000..fb81829dfb --- /dev/null +++ b/react-router/examples/Sidebar.tsx @@ -0,0 +1,80 @@ +import * as React from 'react' +import { + BrowserRouter as Router, + RouteProps, + Route, + Link +} from 'react-router-dom' + +// Each logical "route" has two components, one for +// the sidebar and one for the main area. We want to +// render both of them in different places when the +// path matches the current URL. +interface MyRoute extends RouteProps { + sidebar: () => JSX.Element; + main: () => JSX.Element; +} +const routes: Array = [ + { path: '/', + exact: true, + sidebar: () =>
    home!
    , + main: () =>

    Home

    + }, + { path: '/bubblegum', + sidebar: () =>
    bubblegum!
    , + main: () =>

    Bubblegum

    + }, + { path: '/shoelaces', + sidebar: () =>
    shoelaces!
    , + main: () =>

    Shoelaces

    + } +] + +const SidebarExample = () => ( + +
    +
    +
      +
    • Home
    • +
    • Bubblegum
    • +
    • Shoelaces
    • +
    + + {routes.map((route, index) => ( + // You can render a in as many places + // as you want in your app. It will render along + // with any other s that also match the URL. + // So, a sidebar or breadcrumbs or anything else + // that requires you to render multiple things + // in multiple places at the same URL is nothing + // more than multiple s. + + ))} +
    + +
    + {routes.map((route, index) => ( + // Render more s with the same paths as + // above, but different components this time. + + ))} +
    +
    +
    +) + +export default SidebarExample \ No newline at end of file diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 05fe9b3371..1e0f01510c 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -1,62 +1,104 @@ -// Type definitions for react-router 3.0 -// Project: https://github.com/rackt/react-router -// Definitions by: Sergey Buturlakin -// Yuichi Murata -// Václav Ostrožlík -// Nathan Brown -// Alex Wendland -// Kostya Esmukov -// John Reilly -// Karol Janyst -// Dovydas Navickas +// Type definitions for React Router 4.0 +// Project: https://github.com/ReactTraining/react-router +// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 -export { - ChangeHook, - EnterHook, - InjectedRouter, - LeaveHook, - ParseQueryString, - RouteComponent, - RouteComponents, - RouteComponentProps, - RouteConfig, - RoutePattern, - RouterProps, - RouterState, - RedirectFunction, - StringifyQuery -} from "react-router/lib/Router"; -export { LinkProps } from "react-router/lib/Link"; -export { IndexLinkProps } from "react-router/lib/IndexLink"; -export { RouteProps, PlainRoute } from "react-router/lib/Route"; -export { IndexRouteProps } from "react-router/lib/IndexRoute"; -export { RedirectProps } from "react-router/lib/Redirect"; -export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; +declare module 'react-router' { + import * as React from 'react'; + import * as H from 'history'; -/* components */ -export { default as Router } from "react-router/lib/Router"; -export { default as Link } from "react-router/lib/Link"; -export { default as IndexLink } from "react-router/lib/IndexLink"; -export { default as withRouter } from "react-router/lib/withRouter"; -/* components (configuration) */ -export { default as IndexRedirect } from "react-router/lib/IndexRedirect"; -export { default as IndexRoute } from "react-router/lib/IndexRoute"; -export { default as Redirect } from "react-router/lib/Redirect"; -export { default as Route } from "react-router/lib/Route"; + interface MemoryRouterProps { + initialEntries?: H.Location[]; + initialIndex?: number; + getUserConfirmation?: () => void; + keyLength?: number; + } + class MemoryRouter extends React.Component {} -/* utils */ -export { createRoutes } from "react-router/lib/RouteUtils"; -export { default as RouterContext } from "react-router/lib/RouterContext"; -export { routerShape, locationShape } from "react-router/lib/PropTypes"; -export { default as match } from "react-router/lib/match"; -export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; -export { formatPattern } from "react-router/lib/PatternUtils"; -export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; -/* histories */ -export { default as browserHistory } from "react-router/lib/browserHistory"; -export { default as hashHistory } from "react-router/lib/hashHistory"; -export { default as createMemoryHistory } from "react-router/lib/createMemoryHistory"; + interface PromptProps { + message: string | ((location: H.Location) => void); + when?: boolean; + } + class Prompt extends React.Component {} + + + interface RedirectProps { + to: H.LocationDescriptor; + push?: boolean; + from?: string; + } + class Redirect extends React.Component {} + + + interface RouteComponentProps

    { + match: match

    ; + location: H.Location; + history: H.History; + } + + interface PartialRouteComponentProps

    extends Partial> { + } + + interface RouteProps { + location?: H.Location; + component?: React.SFC | void> | React.ComponentClass | void>; + render?: (props: RouteComponentProps) => React.ReactNode; + children?: (props: RouteComponentProps) => React.ReactNode | React.ReactNode; + path?: string; + exact?: boolean; + strict?: boolean; + } + class Route extends React.Component {} + + + interface RouterProps { + history: any; + } + class Router extends React.Component {} + + + interface StaticRouterProps extends RouterProps { + basename?: string; + location?: string | object; + context?: object; + } + class StaticRouter extends React.Component {} + + + interface SwitchProps extends RouteProps { + } + class Switch extends React.Component {} + + + interface match

    { + params: P; + isExact?: boolean; + path?: string; + url?: string; + } + + + function matchPath

    (pathname: string, props: RouteProps): match

    ; + + + function withRouter(component: React.SFC> | React.ComponentClass>): React.ComponentClass; + + + export { + MemoryRouter, + Prompt, + Redirect, + RouteComponentProps, // TypeScript specific, not from React Router itself + PartialRouteComponentProps, // TypeScript specific, not from React Router itself + RouteProps, // TypeScript specific, not from React Router itself + Route, + Router, + StaticRouter, + Switch, + match, // TypeScript specific, not from React Router itself + matchPath, + withRouter + } +} diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index 301ed3f651..c7af9e3fcf 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -1,44 +1,30 @@ { - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "jsx": "react", - "baseUrl": "../", - "typeRoots": ["../"], - "paths": { - "history": ["history/v3"], - "history/*": ["history/v3/*"] - }, - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "lib/applyRouterMiddleware.d.ts", - "lib/browserHistory.d.ts", - "lib/createMemoryHistory.d.ts", - "lib/hashHistory.d.ts", - "lib/IndexLink.d.ts", - "lib/IndexRedirect.d.ts", - "lib/IndexRoute.d.ts", - "lib/Link.d.ts", - "lib/match.d.ts", - "lib/PatternUtils.d.ts", - "lib/PropTypes.d.ts", - "lib/Redirect.d.ts", - "lib/Route.d.ts", - "lib/Router.d.ts", - "lib/RouterContext.d.ts", - "lib/RouteUtils.d.ts", - "lib/useRouterHistory.d.ts", - "lib/withRouter.d.ts", - "react-router-tests.tsx" - ] + "compilerOptions": { + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "module": "commonjs", + "lib": ["es6", "dom"], + "jsx": "react", + "strictNullChecks": true, + "noImplicitAny": true, + "noImplicitThis": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true + }, + "files": [ + "index.d.ts", + "examples/Ambiguous.tsx", + "examples/Animation.tsx", + "examples/Auth.tsx", + "examples/Basic.tsx", + "examples/CustomLink.tsx", + "examples/ModalGallery.tsx", + "examples/NoMatch.tsx", + "examples/Params.tsx", + "examples/PreventingTransitions.tsx", + "examples/Recursive.tsx", + "examples/RouteConfig.tsx", + "examples/Sidebar.tsx" + ] } diff --git a/react-router/tslint.json b/react-router/tslint.json index 377cc837d4..0209984d72 100644 --- a/react-router/tslint.json +++ b/react-router/tslint.json @@ -1 +1,8 @@ -{ "extends": "../tslint.json" } +{ + "extends": "../tslint.json", + "rules": { + "no-empty-interface": false, + "void-return": false, + "no-single-declare-module": false + } +} diff --git a/react-router/v3/index.d.ts b/react-router/v3/index.d.ts new file mode 100644 index 0000000000..05fe9b3371 --- /dev/null +++ b/react-router/v3/index.d.ts @@ -0,0 +1,62 @@ +// Type definitions for react-router 3.0 +// Project: https://github.com/rackt/react-router +// Definitions by: Sergey Buturlakin +// Yuichi Murata +// Václav Ostrožlík +// Nathan Brown +// Alex Wendland +// Kostya Esmukov +// John Reilly +// Karol Janyst +// Dovydas Navickas +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +export { + ChangeHook, + EnterHook, + InjectedRouter, + LeaveHook, + ParseQueryString, + RouteComponent, + RouteComponents, + RouteComponentProps, + RouteConfig, + RoutePattern, + RouterProps, + RouterState, + RedirectFunction, + StringifyQuery +} from "react-router/lib/Router"; +export { LinkProps } from "react-router/lib/Link"; +export { IndexLinkProps } from "react-router/lib/IndexLink"; +export { RouteProps, PlainRoute } from "react-router/lib/Route"; +export { IndexRouteProps } from "react-router/lib/IndexRoute"; +export { RedirectProps } from "react-router/lib/Redirect"; +export { IndexRedirectProps } from "react-router/lib/IndexRedirect"; + +/* components */ +export { default as Router } from "react-router/lib/Router"; +export { default as Link } from "react-router/lib/Link"; +export { default as IndexLink } from "react-router/lib/IndexLink"; +export { default as withRouter } from "react-router/lib/withRouter"; + +/* components (configuration) */ +export { default as IndexRedirect } from "react-router/lib/IndexRedirect"; +export { default as IndexRoute } from "react-router/lib/IndexRoute"; +export { default as Redirect } from "react-router/lib/Redirect"; +export { default as Route } from "react-router/lib/Route"; + +/* utils */ +export { createRoutes } from "react-router/lib/RouteUtils"; +export { default as RouterContext } from "react-router/lib/RouterContext"; +export { routerShape, locationShape } from "react-router/lib/PropTypes"; +export { default as match } from "react-router/lib/match"; +export { default as useRouterHistory } from "react-router/lib/useRouterHistory"; +export { formatPattern } from "react-router/lib/PatternUtils"; +export { default as applyRouterMiddleware } from "react-router/lib/applyRouterMiddleware"; + +/* histories */ +export { default as browserHistory } from "react-router/lib/browserHistory"; +export { default as hashHistory } from "react-router/lib/hashHistory"; +export { default as createMemoryHistory } from "react-router/lib/createMemoryHistory"; diff --git a/react-router/lib/IndexLink.d.ts b/react-router/v3/lib/IndexLink.d.ts similarity index 100% rename from react-router/lib/IndexLink.d.ts rename to react-router/v3/lib/IndexLink.d.ts diff --git a/react-router/lib/IndexRedirect.d.ts b/react-router/v3/lib/IndexRedirect.d.ts similarity index 100% rename from react-router/lib/IndexRedirect.d.ts rename to react-router/v3/lib/IndexRedirect.d.ts diff --git a/react-router/lib/IndexRoute.d.ts b/react-router/v3/lib/IndexRoute.d.ts similarity index 100% rename from react-router/lib/IndexRoute.d.ts rename to react-router/v3/lib/IndexRoute.d.ts diff --git a/react-router/lib/Link.d.ts b/react-router/v3/lib/Link.d.ts similarity index 100% rename from react-router/lib/Link.d.ts rename to react-router/v3/lib/Link.d.ts diff --git a/react-router/lib/PatternUtils.d.ts b/react-router/v3/lib/PatternUtils.d.ts similarity index 100% rename from react-router/lib/PatternUtils.d.ts rename to react-router/v3/lib/PatternUtils.d.ts diff --git a/react-router/lib/PropTypes.d.ts b/react-router/v3/lib/PropTypes.d.ts similarity index 100% rename from react-router/lib/PropTypes.d.ts rename to react-router/v3/lib/PropTypes.d.ts diff --git a/react-router/lib/Redirect.d.ts b/react-router/v3/lib/Redirect.d.ts similarity index 100% rename from react-router/lib/Redirect.d.ts rename to react-router/v3/lib/Redirect.d.ts diff --git a/react-router/lib/Route.d.ts b/react-router/v3/lib/Route.d.ts similarity index 100% rename from react-router/lib/Route.d.ts rename to react-router/v3/lib/Route.d.ts diff --git a/react-router/lib/RouteUtils.d.ts b/react-router/v3/lib/RouteUtils.d.ts similarity index 100% rename from react-router/lib/RouteUtils.d.ts rename to react-router/v3/lib/RouteUtils.d.ts diff --git a/react-router/lib/Router.d.ts b/react-router/v3/lib/Router.d.ts similarity index 100% rename from react-router/lib/Router.d.ts rename to react-router/v3/lib/Router.d.ts diff --git a/react-router/lib/RouterContext.d.ts b/react-router/v3/lib/RouterContext.d.ts similarity index 100% rename from react-router/lib/RouterContext.d.ts rename to react-router/v3/lib/RouterContext.d.ts diff --git a/react-router/lib/applyRouterMiddleware.d.ts b/react-router/v3/lib/applyRouterMiddleware.d.ts similarity index 100% rename from react-router/lib/applyRouterMiddleware.d.ts rename to react-router/v3/lib/applyRouterMiddleware.d.ts diff --git a/react-router/lib/browserHistory.d.ts b/react-router/v3/lib/browserHistory.d.ts similarity index 100% rename from react-router/lib/browserHistory.d.ts rename to react-router/v3/lib/browserHistory.d.ts diff --git a/react-router/lib/createMemoryHistory.d.ts b/react-router/v3/lib/createMemoryHistory.d.ts similarity index 100% rename from react-router/lib/createMemoryHistory.d.ts rename to react-router/v3/lib/createMemoryHistory.d.ts diff --git a/react-router/lib/hashHistory.d.ts b/react-router/v3/lib/hashHistory.d.ts similarity index 100% rename from react-router/lib/hashHistory.d.ts rename to react-router/v3/lib/hashHistory.d.ts diff --git a/react-router/lib/match.d.ts b/react-router/v3/lib/match.d.ts similarity index 100% rename from react-router/lib/match.d.ts rename to react-router/v3/lib/match.d.ts diff --git a/react-router/lib/useRouterHistory.d.ts b/react-router/v3/lib/useRouterHistory.d.ts similarity index 100% rename from react-router/lib/useRouterHistory.d.ts rename to react-router/v3/lib/useRouterHistory.d.ts diff --git a/react-router/lib/withRouter.d.ts b/react-router/v3/lib/withRouter.d.ts similarity index 100% rename from react-router/lib/withRouter.d.ts rename to react-router/v3/lib/withRouter.d.ts diff --git a/react-router/react-router-tests.tsx b/react-router/v3/react-router-tests.tsx similarity index 100% rename from react-router/react-router-tests.tsx rename to react-router/v3/react-router-tests.tsx diff --git a/react-router/v3/tsconfig.json b/react-router/v3/tsconfig.json new file mode 100644 index 0000000000..0f60e7a6ea --- /dev/null +++ b/react-router/v3/tsconfig.json @@ -0,0 +1,46 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "jsx": "react", + "baseUrl": "../../", + "typeRoots": ["../../"], + "paths": { + "history": ["history/v3"], + "history/*": ["history/v3/*"], + "react-router": ["react-router/v3"], + "react-router/*": ["react-router/v3/*"] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "lib/applyRouterMiddleware.d.ts", + "lib/browserHistory.d.ts", + "lib/createMemoryHistory.d.ts", + "lib/hashHistory.d.ts", + "lib/IndexLink.d.ts", + "lib/IndexRedirect.d.ts", + "lib/IndexRoute.d.ts", + "lib/Link.d.ts", + "lib/match.d.ts", + "lib/PatternUtils.d.ts", + "lib/PropTypes.d.ts", + "lib/Redirect.d.ts", + "lib/Route.d.ts", + "lib/Router.d.ts", + "lib/RouterContext.d.ts", + "lib/RouteUtils.d.ts", + "lib/useRouterHistory.d.ts", + "lib/withRouter.d.ts", + "react-router-tests.tsx" + ] +} diff --git a/react-router/v3/tslint.json b/react-router/v3/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-router/v3/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 3c2d2dd01970440b2b6e268183214c7a75b2c76b Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 14 Mar 2017 11:43:53 -0700 Subject: [PATCH 102/258] Fix transform argument type, and add deprecated method documentation. (#15158) --- typeahead/index.d.ts | 15 +++++++++++++-- typeahead/typeahead-tests.ts | 8 ++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/typeahead/index.d.ts b/typeahead/index.d.ts index 95100bbbba..d6ed81a921 100644 --- a/typeahead/index.d.ts +++ b/typeahead/index.d.ts @@ -1015,7 +1015,7 @@ declare namespace Bloodhound { * @param response Prefetch response. * @returns Transform response. */ - transform?: (response: T[]) => T[]; + transform?: (response: T) => T; } /** @@ -1069,7 +1069,13 @@ declare namespace Bloodhound { * @param response Prefetch response. * @returns Transform response. */ - transform?: (response: T[]) => T[]; + transform?: (response: T) => T; + + /** + * DEPRECATED: transform the remote response before the Bloodhound instance operates on it. + * */ + filter?: (response: T) => T; + } /** @@ -1200,6 +1206,11 @@ declare class Bloodhound { * clearRemoteCache offers a way to programmatically clear said cache. */ public clearRemoteCache(): Bloodhound; + + /* + * DEPRECATED: wraps the suggestion engine in an adapter that is compatible with the typeahead jQuery plugin + */ + public ttAdapter(): any; } declare module "bloodhound" { diff --git a/typeahead/typeahead-tests.ts b/typeahead/typeahead-tests.ts index 61d48b6aa9..d298508e11 100644 --- a/typeahead/typeahead-tests.ts +++ b/typeahead/typeahead-tests.ts @@ -374,7 +374,7 @@ function test_bloodhout() { } function test_bloodhout_prefetch_options_transform() { - var options: Bloodhound.PrefetchOptions = { + var options: Bloodhound.PrefetchOptions = { url: 'url', transform: (response: string[]) => { return new Array(); } }; @@ -383,7 +383,7 @@ function test_bloodhout() { function test_bloodhout_prefetch_options_all() { var ajaxSettings: JQueryAjaxSettings = { url: 'url' }; - var options: Bloodhound.PrefetchOptions = { + var options: Bloodhound.PrefetchOptions = { url: 'url', cache: true, ttl: 86400000, @@ -433,7 +433,7 @@ function test_bloodhout() { } function test_bloodhout_remote_options_transform() { - var options: Bloodhound.RemoteOptions = { + var options: Bloodhound.RemoteOptions = { url: 'url', transform: (response: string[]) => { return new Array(); } }; @@ -442,7 +442,7 @@ function test_bloodhout() { function test_bloodhout_remote_options_all() { var ajaxSettings: JQueryAjaxSettings = { url: 'url' }; - var options: Bloodhound.RemoteOptions = { + var options: Bloodhound.RemoteOptions = { url: 'url', prepare: (query: string, settings: JQueryAjaxSettings) => { return ajaxSettings; }, wildcard: '%QUERY', From 28924690db8c6e9845ca8eb9855abc2ec3a4933b Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 12:12:20 -0700 Subject: [PATCH 103/258] Remove unnecessary references to "q" (#15172) --- cordova-plugin-app-version/index.d.ts | 11 ++++------- pathwatcher/index.d.ts | 9 +++------ q/index.d.ts | 5 +---- text-buffer/index.d.ts | 5 ++--- webdriverio/index.d.ts | 11 +++++++---- 5 files changed, 17 insertions(+), 24 deletions(-) diff --git a/cordova-plugin-app-version/index.d.ts b/cordova-plugin-app-version/index.d.ts index e295724474..b30beef9c6 100644 --- a/cordova-plugin-app-version/index.d.ts +++ b/cordova-plugin-app-version/index.d.ts @@ -3,14 +3,11 @@ // Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -/// - interface Cordova { getAppVersion: { - getAppName: () => Q.IPromise & JQueryPromise; - getPackageName: () => Q.IPromise & JQueryPromise; - getVersionCode: () => Q.IPromise & JQueryPromise; - getVersionNumber: () => Q.IPromise & JQueryPromise; + getAppName: () => Promise; + getPackageName: () => Promise; + getVersionCode: () => Promise; + getVersionNumber: () => Promise; }; } diff --git a/pathwatcher/index.d.ts b/pathwatcher/index.d.ts index 0a44ee596b..61f084b6ca 100644 --- a/pathwatcher/index.d.ts +++ b/pathwatcher/index.d.ts @@ -4,8 +4,8 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// +import { EventEmitter } from "events"; import * as Q from "q"; export as namespace PathWatcher; @@ -28,7 +28,7 @@ export interface IFile { getBaseName():string; write(text:string):void; readSync(flushCache:boolean):string; - read(flushCache?:boolean):Q.Promise; + read(flushCache?:boolean): Promise; // exists():boolean; existsSync():boolean; setDigest(contents:string):void; @@ -62,10 +62,7 @@ export interface IDirectory { isPathPrefixOf(prefix:string, fullPath:string):boolean; } - -import events = require("events"); - -export interface IHandleWatcher extends events.EventEmitter { +export interface IHandleWatcher extends EventEmitter { onEvent(event:any, filePath:any, oldFilePath:any):any; start():void; closeIfNoListener():void; diff --git a/q/index.d.ts b/q/index.d.ts index c6f2a068a7..6b2deb3161 100644 --- a/q/index.d.ts +++ b/q/index.d.ts @@ -168,10 +168,7 @@ declare namespace Q { } interface PromiseState { - /** - * "fulfilled", "rejected", "pending" - */ - state: string; + state: "fulfilled" | "rejected" | "pending"; value?: T; reason?: any; } diff --git a/text-buffer/index.d.ts b/text-buffer/index.d.ts index 60207c7e80..a3d652bd28 100644 --- a/text-buffer/index.d.ts +++ b/text-buffer/index.d.ts @@ -5,7 +5,6 @@ /// /// -/// declare namespace TextBuffer { @@ -240,7 +239,7 @@ declare namespace TextBuffer { positionForCharacterIndex(offset:number):IPoint; getMaxCharacterIndex():number; loadSync():ITextBuffer; - load():Q.IPromise; + load():Promise; finishLoading():ITextBuffer; handleTextChange(event:any):any; destroy():any; @@ -253,7 +252,7 @@ declare namespace TextBuffer { hasMultipleEditors():boolean; reload():any; updateCachedDiskContentsSync():string; - updateCachedDiskContents():Q.IPromise; + updateCachedDiskContents():Promise; getBaseName():string; getPath():string; getUri():string; diff --git a/webdriverio/index.d.ts b/webdriverio/index.d.ts index f091159263..e74b4712a5 100644 --- a/webdriverio/index.d.ts +++ b/webdriverio/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// declare namespace WebdriverIO { export type Method = 'POST' | 'GET' | 'DELETE'; @@ -506,7 +505,11 @@ declare namespace WebdriverIO { onRejected?: (error: any) => P | Client

    ): Client

    ; - inspect(): Q.PromiseState; + inspect(): { + state: "fulfilled" | "rejected" | "pending"; + value?: T; + reason?: any; + }; } export interface Client { @@ -1815,14 +1818,14 @@ declare namespace WebdriverIO { ): Client

    ; waitUntil( - condition: () => boolean | Q.IPromise | Client> & RawResult, + condition: () => boolean | Promise | Client> & RawResult, timeout?: number, timeoutMsg?: string, interval?: number ): Client & any; waitUntil

    ( - condition: () => boolean | Q.IPromise | Client> & RawResult, + condition: () => boolean | Promise | Client> & RawResult, timeout?: number, timeoutMsg?: string, interval?: number From 21a11ab7d96f315cbbcf8e3e7bdfbdd3c91cfe36 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 12:12:30 -0700 Subject: [PATCH 104/258] nedb: Lint (#15173) --- nedb/index.d.ts | 156 ++++++++++--------- nedb/nedb-tests.ts | 371 ++++++++++++++++++++------------------------- nedb/tslint.json | 3 + 3 files changed, 250 insertions(+), 280 deletions(-) create mode 100644 nedb/tslint.json diff --git a/nedb/index.d.ts b/nedb/index.d.ts index 23519d3579..790f3f6d06 100644 --- a/nedb/index.d.ts +++ b/nedb/index.d.ts @@ -1,34 +1,31 @@ -// Type definitions for NeDB +// Type definitions for NeDB 1.8 // Project: https://github.com/louischatriot/nedb // Definitions by: Stefan Steinhart // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -export = NeDBDataStore; +export = Nedb; export as namespace Nedb; -declare namespace NeDBDataStore { } -declare class NeDBDataStore { - constructor(); - constructor(path:string); - constructor(options:NeDB.DataStoreOptions); +declare class Nedb { + constructor(pathOrOptions?: string | Nedb.DataStoreOptions); - persistence:NeDB.Persistence; + persistence: Nedb.Persistence; /** * Load the database from the datafile, and trigger the execution of buffered commands if any */ - loadDatabase(cb?:(err:Error)=>void):void; + loadDatabase(cb?: (err: Error) => void): void; /** * Get an array of all the data in the database */ - getAllData():Array; + getAllData(): Array; /** * Reset all currently defined indexes */ - resetIndexes(newData:any):void; + resetIndexes(newData: any): void; /** * Ensure an index is kept for this field. Same parameters as lib/indexes @@ -39,34 +36,32 @@ declare class NeDBDataStore { * @param {Boolean} options.sparse * @param {Function} cb Optional callback, signature: err */ - ensureIndex(options:NeDB.EnsureIndexOptions, cb?:(err:Error)=>void):void; + ensureIndex(options: Nedb.EnsureIndexOptions, cb?: (err: Error) => void): void; /** * Remove an index * @param {String} fieldName * @param {Function} cb Optional callback, signature: err */ - removeIndex(fieldName:string, cb?:(err:Error)=>void):void; + removeIndex(fieldName: string, cb?: (err: Error) => void): void; /** * Add one or several document(s) to all indexes */ - addToIndexes(doc:T):void; - addToIndexes(doc:Array):void; + addToIndexes(doc: T | T[]): void; /** * Remove one or several document(s) from all indexes */ - removeFromIndexes(doc:T):void; - removeFromIndexes(doc:Array):void; + removeFromIndexes(doc: T | T[]): void; /** * Update one or several documents in all indexes * To update multiple documents, oldDoc must be an array of { oldDoc, newDoc } pairs * If one update violates a constraint, all changes are rolled back */ - updateIndexes(oldDoc:T, newDoc:T):void; - updateIndexes(updates:Array<{oldDoc:T; newDoc:T;}>):void; + updateIndexes(oldDoc: T, newDoc: T): void; + updateIndexes(updates: Array<{oldDoc: T; newDoc: T}>): void; /** * Return the list of candidates for a given query @@ -77,20 +72,20 @@ declare class NeDBDataStore { * * TODO: needs to be moved to the Cursor module */ - getCandidates(query:any):void; + getCandidates(query: any): void; /** * Insert a new document * @param {Function} cb Optional callback, signature: err, insertedDoc */ - insert(newDoc:T, cb?:(err:Error, document:T)=>void):void; + insert(newDoc: T, cb?: (err: Error, document: T) => void): void; /** * Count all documents matching the query * @param {any} query MongoDB-style query */ - count(query:any, callback:(err:Error, n:number)=>void):void; - count(query:any):NeDB.CursorCount; + count(query: any, callback: (err: Error, n: number) => void): void; + count(query: any): Nedb.CursorCount; /** * Find all documents matching the query @@ -98,61 +93,61 @@ declare class NeDBDataStore { * @param {any} query MongoDB-style query * @param {any} projection MongoDB-style projection */ - find(query:any, projection:T, callback:(err:Error, documents:Array)=>void):void; - find(query:any, projection:T):NeDB.Cursor; + find(query: any, projection: T, callback: (err: Error, documents: Array) => void): void; + find(query: any, projection?: T): Nedb.Cursor; /** * Find all documents matching the query * If no callback is passed, we return the cursor so that user can limit, skip and finally exec * * @param {any} query MongoDB-style query */ - find(query:any, callback:(err:Error, documents:Array)=>void):void; - find(query:any):NeDB.Cursor; + find(query: any, callback: (err: Error, documents: Array) => void): void; /** * Find one document matching the query * @param {any} query MongoDB-style query * @param {any} projection MongoDB-style projection */ - findOne(query:any, projection:T, callback:(err:Error, document:T)=>void):void; + findOne(query: any, projection: T, callback: (err: Error, document: T) => void): void; /** * Find one document matching the query * @param {any} query MongoDB-style query */ - findOne(query:any, callback:(err:Error, document:T)=>void):void; + findOne(query: any, callback: (err: Error, document: T) => void): void; /** - * Update all docs matching query v1.7.4 and prior signature. + * Update all docs matching query v1.7.4 and prior signature. * For now, very naive implementation (recalculating the whole database) * @param {any} query * @param {any} updateQuery * @param {Object} options Optional options * options.multi If true, can update multiple documents (defaults to false) * options.upsert If true, document is inserted if the query doesn't match anything - * @param {Function} cb Optional callback, signature: err, - * numReplaced, - * upsert (set to true if the update was in fact an upsert) + * @param {Function} cb Optional callback, signature: err, + * numReplaced, + * upsert (set to true if the update was in fact an upsert) * * @api private Use Datastore.update which has the same signature */ - update(query:any, updateQuery:any, options?:NeDB.UpdateOptions, cb?:(err:Error, numberOfUpdated:number, upsert:boolean)=>void):void; - /** - * Update all docs matching query v1.8 signature. - * For now, very naive implementation (recalculating the whole database) - * @param {any} query - * @param {any} updateQuery - * @param {Object} options Optional options - * options.multi If true, can update multiple documents (defaults to false) - * options.upsert If true, document is inserted if the query doesn't match anything - * @param {Function} cb Optional callback, signature: err, - * numAffected, - * affectedDocuments (when returnUpdatedDocs is set to true), obj or array - * upsert (set to true if the update was in fact an upsert) - * - * @api private Use Datastore.update which has the same signature - */ - update(query:any, updateQuery:any, options?:NeDB.UpdateOptions, cb?:(err:Error, numberOfUpdated:number, affectedDocuments:any, upsert:boolean)=>void):void; + update(query: any, updateQuery: any, options?: Nedb.UpdateOptions, cb?: (err: Error, numberOfUpdated: number, upsert: boolean) => void): void; + + /** + * Update all docs matching query v1.8 signature. + * For now, very naive implementation (recalculating the whole database) + * @param {any} query + * @param {any} updateQuery + * @param {Object} options Optional options + * options.multi If true, can update multiple documents (defaults to false) + * options.upsert If true, document is inserted if the query doesn't match anything + * @param {Function} cb Optional callback, signature: err, + * numAffected, + * affectedDocuments (when returnUpdatedDocs is set to true), obj or array + * upsert (set to true if the update was in fact an upsert) + * + * @api private Use Datastore.update which has the same signature + */ + update(query: any, updateQuery: any, options?: Nedb.UpdateOptions, cb?: (err: Error, numberOfUpdated: number, affectedDocuments: any, upsert: boolean) => void): void; /** * Remove all docs matching the query @@ -164,32 +159,45 @@ declare class NeDBDataStore { * * @api private Use Datastore.remove which has the same signature */ - remove(query:any, options:NeDB.RemoveOptions, cb?:(err:Error, n:number)=>void):void; - remove(query:any, cb?:(err:Error, n:number)=>void):void; + remove(query: any, options: Nedb.RemoveOptions, cb?: (err: Error, n: number) => void): void; + remove(query: any, cb?: (err: Error, n: number) => void): void; } -declare namespace NeDB { +declare namespace Nedb { interface Cursor { - sort(query:any):Cursor; - skip(n:number):Cursor; - limit(n:number):Cursor; - projection(query:any):Cursor; - exec(callback:(err:Error, documents:Array)=>void):void; + sort(query: any): Cursor; + skip(n: number): Cursor; + limit(n: number): Cursor; + projection(query: any): Cursor; + exec(callback: (err: Error, documents: Array) => void): void; } interface CursorCount { - exec(callback:(err:Error, count:number)=>void):void; + exec(callback: (err: Error, count: number) => void): void; } interface DataStoreOptions { - filename?:string // Optional, datastore will be in-memory only if not provided - inMemoryOnly?:boolean // Optional, default to false - nodeWebkitAppName?:boolean // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where - autoload?:boolean // Optional, defaults to false - onload?:(error:Error)=>any // Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown - afterSerialization?:(line:string)=>string; // (optional): hook you can use to transform data after it was serialized and before it is written to disk. Can be used for example to encrypt data before writing database to disk. This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost) - beforeDeserialization?:(line:string)=>string; // (optional): reverse of afterSerialization. Make sure to include both and not just one or you risk data loss. For the same reason, make sure both functions are inverses of one another. Some failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths. In addition, if too much data is detected as corrupt, NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below) - corruptAlertThreshold?:number; // (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt. 0 means you don't tolerate any corruption, 1 means you don't care + filename?: string // Optional, datastore will be in-memory only if not provided + inMemoryOnly?: boolean // Optional, default to false + nodeWebkitAppName?: boolean // Optional, specify the name of your NW app if you want options.filename to be relative to the directory where + autoload?: boolean // Optional, defaults to false + // Optional, if autoload is used this will be called after the load database with the error object as parameter. If you don't pass it the error will be thrown + onload?: (error: Error) => any + // (optional): hook you can use to transform data after it was serialized and before it is written to disk. + // Can be used for example to encrypt data before writing database to disk. + // This function takes a string as parameter (one line of an NeDB data file) and outputs the transformed string, which must absolutely not contain a \n character (or data will be lost) + afterSerialization?: (line: string) => string; + // (optional): reverse of afterSerialization. + // Make sure to include both and not just one or you risk data loss. + // For the same reason, make sure both functions are inverses of one another. + // Some failsafe mechanisms are in place to prevent data loss if you misuse the serialization hooks: + // NeDB checks that never one is declared without the other, and checks that they are reverse of one another by testing on random strings of various lengths. + // In addition, if too much data is detected as corrupt, + // NeDB will refuse to start as it could mean you're not using the deserialization hook corresponding to the serialization hook used before (see below) + beforeDeserialization?: (line: string) => string; + // (optional): between 0 and 1, defaults to 10%. NeDB will refuse to start if more than this percentage of the datafile is corrupt. + // 0 means you don't tolerate any corruption, 1 means you don't care + corruptAlertThreshold?: number; } /** @@ -206,18 +214,18 @@ declare namespace NeDB { * options only one option for now: multi which allows the removal of multiple documents if set to true. Default is false */ interface RemoveOptions { - multi?:boolean + multi?: boolean } interface EnsureIndexOptions { - fieldName:string; - unique?:boolean; - sparse?:boolean; + fieldName: string; + unique?: boolean; + sparse?: boolean; } interface Persistence { - compactDatafile():void; - setAutocompactionInterval(interval:number):void; - stopAutocompaction():void; + compactDatafile(): void; + setAutocompactionInterval(interval: number): void; + stopAutocompaction(): void; } } diff --git a/nedb/nedb-tests.ts b/nedb/nedb-tests.ts index 5faa3d0ffb..e90b682c68 100644 --- a/nedb/nedb-tests.ts +++ b/nedb/nedb-tests.ts @@ -2,193 +2,152 @@ * Created by stefansteinhart on 31.01.15. */ -/// /// - import * as es6styleimport from 'nedb'; -import Q = require('q'); import nedb = require('nedb'); class BaseCollection { + private dataStore: nedb; - private dataStore:nedb; - - constructor(dataStore:nedb) { - + constructor(dataStore: nedb) { this.dataStore = dataStore; } - public insert(document:T):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.insert(document, function (err:Error, newDoc:T) { // Callback is optional - // newDoc is the newly inserted document, including its _id - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(newDoc); - } + insert(document: T): Promise { + return new Promise((resolve, reject) => { + this.dataStore.insert(document, (err: Error, newDoc: T) => { // Callback is optional + // newDoc is the newly inserted document, including its _id + if (err) { + reject(err); + } else { + resolve(newDoc); + } + }); }); - - return deferred.promise; } - public count():Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.count({}, function (err:Error, count:number) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(count); - } + count(): Promise { + return new Promise((resolve, reject) => { + this.dataStore.count({}, (err: Error, count: number) => { + if (err) { + reject(err); + } else { + resolve(count); + } + }); }); - - return deferred.promise; } - public countBy(criteria:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.count(criteria, function (err:Error, count:number) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(count); - } + countBy(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.count(criteria, (err: Error, count: number) => { + if (err) { + reject(err); + } else { + resolve(count); + } + }); }); - - return deferred.promise; } - public findByID(id:string):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.findOne({_id: id}, function (err:Error, doc:T) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(doc); - } + findByID(id: string): Promise { + return new Promise((resolve, reject) => { + this.dataStore.findOne({_id: id}, (err: Error, doc: T) => { + if (err) { + reject(err); + } else { + resolve(doc); + } + }); }); - - return deferred.promise; } - public findOne(criteria:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.findOne(criteria, function (err:Error, doc:T) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(doc); - } + findOne(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.findOne(criteria, (err: Error, doc: T) => { + if (err) { + reject(err); + } else { + resolve(doc); + } + }); }); - - return deferred.promise; } - public find(criteria:any):Q.Promise> { - - var deferred = Q.defer>(); - - this.dataStore.find(criteria, function (err:Error, docs:Array) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(docs); - } + find(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.find(criteria, (err: Error, docs: T[]) => { + if (err) { + reject(err); + } + else { + resolve(docs); + } + }); }); - - return deferred.promise; } - public all():Q.Promise> { - - var deferred = Q.defer>(); - - this.dataStore.find({}, function (err:Error, docs:Array) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(docs); - } + all(): Promise { + return new Promise((resolve, reject) => { + this.dataStore.find({}, (err: Error, docs: T[]) => { + if (err) { + reject(err); + } else { + resolve(docs); + } + }); }); - - return deferred.promise; } - public upsert(query:any, updateQuery:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.update(query, updateQuery, {upsert: true}, function (err:Error, numberOfUpdated:number, upsert: boolean) { - if (err) { - deferred.reject(err); - } - else { - //deferred.resolve(newDoc); - } + upsert(query: any, updateQuery: any): Promise { + const a: Promise = new Promise((resolve, reject) => { + this.dataStore.update(query, updateQuery, {upsert: true}, (err: Error, numberOfUpdated: number, upsert: boolean) => { + if (err) { + reject(err); + } else { + //resolve(newDoc); + } + }); }); - this.dataStore.update(query, updateQuery, {upsert: true}, function (err:Error, numberOfUpdated:number, affectedDocs:any, upsert: boolean) { - if (err) { - deferred.reject(err); - } - else { - //deferred.resolve(newDoc); - } + const b: Promise = new Promise((resolve, reject) => { + this.dataStore.update(query, updateQuery, {upsert: true}, (err: Error, numberOfUpdated: number, affectedDocs: any, upsert: boolean) => { + if (err) { + reject(err); + } else { + //resolve(newDoc); + } + }); }); - return deferred.promise; + return a || b; } - public update(query:Object, updateQuery:Object, options?:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.update(query, updateQuery, options, function (err:Error, numberOfUpdated:number) { - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(numberOfUpdated); - } + update(query: {}, updateQuery: {}, options?: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.update(query, updateQuery, options, (err: Error, numberOfUpdated: number) => { + if (err) { + reject(err); + } else { + resolve(numberOfUpdated); + } + }); }); - - return deferred.promise; } - public remove(criteria:any):Q.Promise { - - var deferred = Q.defer(); - - this.dataStore.remove(criteria, function (err:Error, numberOfDeletedEntrys:number) { - - if (err) { - deferred.reject(err); - } - else { - deferred.resolve(numberOfDeletedEntrys); - } + remove(criteria: any): Promise { + return new Promise((resolve, reject) => { + this.dataStore.remove(criteria, (err: Error, numberOfDeletedEntrys: number) => { + if (err) { + reject(err); + } + else { + resolve(numberOfDeletedEntrys); + } + }); }); - - return deferred.promise; } } @@ -199,7 +158,7 @@ var db = new Datastore(); // Type 2: Persistent datastore with manual loading db = new Datastore({filename: 'path/to/datafile'}); -db.loadDatabase(function (err) { // Callback is optional +db.loadDatabase((err) => { // Callback is optional // Now commands will be executed }); @@ -217,7 +176,7 @@ db = new Datastore({filename: path.join(require('nw.gui').App.dataPath, 'somethi // Of course you can create multiple datastores if you need several // collections. In this case it's usually a good idea to use autoload for all collections. -var dbContainer:any = {}; +var dbContainer: any = {}; dbContainer.users = new Datastore('path/to/users.db'); dbContainer.robots = new Datastore('path/to/robots.db'); @@ -225,7 +184,7 @@ dbContainer.robots = new Datastore('path/to/robots.db'); dbContainer.users.loadDatabase(); dbContainer.robots.loadDatabase(); -var doc:any = { +var doc: any = { hello: 'world' , n: 5 , today: new Date() @@ -236,151 +195,151 @@ var doc:any = { , infos: {name: 'nedb'} }; -db.insert(doc, function (err:Error, newDoc:any) { // Callback is optional +db.insert(doc, (err: Error, newDoc: any) => { // Callback is optional // newDoc is the newly inserted document, including its _id // newDoc has no key called notToBeSaved since its value was undefined }); -db.insert([{a: 5}, {a: 42}], function (err:Error, newdocs:Array) { +db.insert([{a: 5}, {a: 42}], (err: Error, newdocs: any[]) => { // Two documents were inserted in the database // newDocs is an array with these documents, augmented with their _id }); // If there is a unique constraint on field 'a', this will fail -db.insert([{a: 5}, {a: 42}, {a: 5}], function (err:Error) { +db.insert([{a: 5}, {a: 42}, {a: 5}], (err: Error) => { // err is a 'uniqueViolated' error // The database was not modified }); // Finding all planets in the solar system -db.find({system: 'solar'}, function (err:Error, docs:Array) { +db.find({system: 'solar'}, (err: Error, docs: any[]) => { // docs is an array containing documents Mars, Earth, Jupiter // If no document is found, docs is equal to [] }); // Finding all planets whose name contain the substring 'ar' using a regular expression -db.find({planet: /ar/}, function (err:Error, docs:Array) { +db.find({planet: /ar/}, (err: Error, docs: any[]) => { // docs contains Mars and Earth }); // Finding all inhabited planets in the solar system -db.find({system: 'solar', inhabited: true}, function (err:Error, docs:Array) { +db.find({system: 'solar', inhabited: true}, (err: Error, docs: any[]) => { // docs is an array containing document Earth only }); // Use the dot-notation to match fields in subdocuments -db.find({"humans.genders": 2}, function (err:Error, docs:Array) { +db.find({"humans.genders": 2}, (err: Error, docs: any[]) => { // docs contains Earth }); // Use the dot-notation to navigate arrays of subdocuments -db.find({"completeData.planets.name": "Mars"}, function (err:Error, docs:Array) { +db.find({"completeData.planets.name": "Mars"}, (err: Error, docs: any[]) => { // docs contains document 5 }); -db.find({"completeData.planets.name": "Jupiter"}, function (err:Error, docs:Array) { +db.find({"completeData.planets.name": "Jupiter"}, (err: Error, docs: any[]) => { // docs is empty }); -db.find({"completeData.planets.0.name": "Earth"}, function (err:Error, docs:Array) { +db.find({"completeData.planets.0.name": "Earth"}, (err: Error, docs: any[]) => { // docs contains document 5 // If we had tested against "Mars" docs would be empty because we are matching against a specific array element }); // You can also deep-compare objects. Don't confuse this with dot-notation! -db.find({humans: {genders: 2}}, function (err:Error, docs:Array) { +db.find({humans: {genders: 2}}, (err: Error, docs: any[]) => { // docs is empty, because { genders: 2 } is not equal to { genders: 2, eyes: true } }); // Find all documents in the collection -db.find({}, function (err:Error, docs:Array) { +db.find({}, (err: Error, docs: any[]) => { }); // The same rules apply when you want to only find one document -db.findOne({_id: 'id1'}, function (err:Error, doc:any) { +db.findOne({_id: 'id1'}, (err: Error, doc: any) => { // doc is the document Mars // If no document is found, doc is null }); // $lt, $lte, $gt and $gte work on numbers and strings -db.find({"humans.genders": {$gt: 5}}, function (err:Error, docs:Array) { +db.find({"humans.genders": {$gt: 5}}, (err: Error, docs: any[]) => { // docs contains Omicron Persei 8, whose humans have more than 5 genders (7). }); // When used with strings, lexicographical order is used -db.find({planet: {$gt: 'Mercury'}}, function (err:Error, docs:Array) { +db.find({planet: {$gt: 'Mercury'}}, (err: Error, docs: any[]) => { // docs contains Omicron Persei 8 }) // Using $in. $nin is used in the same way -db.find({planet: {$in: ['Earth', 'Jupiter']}}, function (err:Error, docs:Array) { +db.find({planet: {$in: ['Earth', 'Jupiter']}}, (err: Error, docs: any[]) => { // docs contains Earth and Jupiter }); // Using $exists -db.find({satellites: {$exists: true}}, function (err:Error, docs:Array) { +db.find({satellites: {$exists: true}}, (err: Error, docs: any[]) => { // docs contains only Mars }); // Using $regex with another operator -db.find({planet: {$regex: /ar/, $nin: ['Jupiter', 'Earth']}}, function (err:Error, docs:Array) { +db.find({planet: {$regex: /ar/, $nin: ['Jupiter', 'Earth']}}, (err: Error, docs: any[]) => { // docs only contains Mars because Earth was excluded from the match by $nin }); // Using an array-specific comparison function // Note: you can't use nested comparison functions, e.g. { $size: { $lt: 5 } } will throw an error -db.find({satellites: {$size: 2}}, function (err:Error, docs:Array) { +db.find({satellites: {$size: 2}}, (err: Error, docs: any[]) => { // docs contains Mars }); -db.find({satellites: {$size: 1}}, function (err:Error, docs:Array) { +db.find({satellites: {$size: 1}}, (err: Error, docs: any[]) => { // docs is empty }); // If a document's field is an array, matching it means matching any element of the array -db.find({satellites: 'Phobos'}, function (err:Error, docs:Array) { +db.find({satellites: 'Phobos'}, (err: Error, docs: any[]) => { // docs contains Mars. Result would have been the same if query had been { satellites: 'Deimos' } }); // This also works for queries that use comparison operators -db.find({satellites: {$lt: 'Amos'}}, function (err:Error, docs:Array) { +db.find({satellites: {$lt: 'Amos'}}, (err: Error, docs: any[]) => { // docs is empty since Phobos and Deimos are after Amos in lexicographical order }); // This also works with the $in and $nin operator -db.find({satellites: {$in: ['Moon', 'Deimos']}}, function (err:Error, docs:Array) { +db.find({satellites: {$in: ['Moon', 'Deimos']}}, (err: Error, docs: any[]) => { // docs contains Mars (the Earth document is not complete!) }); -db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}]}, function (err:Error, docs:Array) { +db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}]}, (err: Error, docs: any[]) => { // docs contains Earth and Mars }); -db.find({$not: {planet: 'Earth'}}, function (err:Error, docs:Array) { +db.find({$not: {planet: 'Earth'}}, (err: Error, docs: any[]) => { // docs contains Mars, Jupiter, Omicron Persei 8 }); db.find({ - $where: function () { + $where() { return parseInt(Object.keys(this)[0]) > 6; } -}, function (err:Error, docs:Array) { +}, (err: Error, docs: any[]) => { // docs with more than 6 properties }); // You can mix normal queries, comparison queries and logical operators -db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}], inhabited: true}, function (err:Error, docs:Array) { +db.find({$or: [{planet: 'Earth'}, {planet: 'Mars'}], inhabited: true}, (err: Error, docs: any[]) => { // docs contains Earth }); // No query used means all results are returned (before the Cursor modifiers) -db.find({}).sort({planet: 1}).skip(1).limit(2).exec(function (err:Error, docs:Array) { +db.find({}).sort({planet: 1}).skip(1).limit(2).exec((err: Error, docs: any[]) => { // docs is [doc3, doc1] }); // You can sort in reverse order like this -db.find({system: 'solar'}).sort({planet: -1}).exec(function (err:Error, docs:Array) { +db.find({system: 'solar'}).sort({planet: -1}).exec((err: Error, docs: any[]) => { // docs is [doc1, doc3, doc2] }); @@ -390,38 +349,38 @@ db.find({}).sort({firstField: 1, secondField: -1}); // Same database as above // Keeping only the given fields -db.find({planet: 'Mars'}, {planet: 1, system: 1}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 1, system: 1}, (err: Error, docs: any[]) => { // docs is [{ planet: 'Mars', system: 'solar', _id: 'id1' }] }); // Keeping only the given fields but removing _id -db.find({planet: 'Mars'}, {planet: 1, system: 1, _id: 0}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 1, system: 1, _id: 0}, (err: Error, docs: any[]) => { // docs is [{ planet: 'Mars', system: 'solar' }] }); // Omitting only the given fields and removing _id -db.find({planet: 'Mars'}, {planet: 0, system: 0, _id: 0}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 0, system: 0, _id: 0}, (err: Error, docs: any[]) => { // docs is [{ inhabited: false, satellites: ['Phobos', 'Deimos'] }] }); // Failure: using both modes at the same time -db.find({planet: 'Mars'}, {planet: 0, system: 1}, function (err:Error, docs:Array) { +db.find({planet: 'Mars'}, {planet: 0, system: 1}, (err: Error, docs: any[]) => { // err is the error message, docs is undefined }); // You can also use it in a Cursor way but this syntax is not compatible with MongoDB // If upstream compatibility is important don't use this method -db.find({planet: 'Mars'}).projection({planet: 1, system: 1}).exec(function (err:Error, docs:Array) { +db.find({planet: 'Mars'}).projection({planet: 1, system: 1}).exec((err: Error, docs: any[]) => { // docs is [{ planet: 'Mars', system: 'solar', _id: 'id1' }] }); // Count all planets in the solar system -db.count({system: 'solar'}, function (err:Error, count:number) { +db.count({system: 'solar'}, (err: Error, count: number) => { // count equals to 3 }); // Count all documents in the datastore -db.count({}, function (err:Error, count:number) { +db.count({}, (err: Error, count: number) => { // count equals to 4 }); @@ -432,7 +391,7 @@ db.count({}, function (err:Error, count:number) { // { _id: 'id4', planet: 'Omicron Persia 8', system: 'futurama', inhabited: true } // Replace a document by another -db.update({planet: 'Jupiter'}, {planet: 'Pluton'}, {}, function (err:Error, numReplaced:number) { +db.update({planet: 'Jupiter'}, {planet: 'Pluton'}, {}, (err: Error, numReplaced: number) => { // numReplaced = 1 // The doc #3 has been replaced by { _id: 'id3', planet: 'Pluton' } // Note that the _id is kept unchanged, and the document has been replaced @@ -440,19 +399,19 @@ db.update({planet: 'Jupiter'}, {planet: 'Pluton'}, {}, function (err:Error, numR }); // Set an existing field's value -db.update({system: 'solar'}, {$set: {system: 'solar system'}}, {multi: true}, function (err:Error, numReplaced:number) { +db.update({system: 'solar'}, {$set: {system: 'solar system'}}, {multi: true}, (err: Error, numReplaced: number) => { // numReplaced = 3 // Field 'system' on Mars, Earth, Jupiter now has value 'solar system' }); // Setting the value of a non-existing field in a subdocument by using the dot-notation -db.update({planet: 'Mars'}, {$set: {"data.satellites": 2, "data.red": true}}, {}, function () { +db.update({planet: 'Mars'}, {$set: {"data.satellites": 2, "data.red": true}}, {}, () => { // Mars document now is { _id: 'id1', system: 'solar', inhabited: false // , data: { satellites: 2, red: true } // } // Not that to set fields in subdocuments, you HAVE to use dot-notation // Using object-notation will just replace the top-level field - db.update({planet: 'Mars'}, {$set: {data: {satellites: 3}}}, {}, function () { + db.update({planet: 'Mars'}, {$set: {data: {satellites: 3}}}, {}, () => { // Mars document now is { _id: 'id1', system: 'solar', inhabited: false // , data: { satellites: 3 } // } @@ -461,7 +420,7 @@ db.update({planet: 'Mars'}, {$set: {"data.satellites": 2, "data.red": true}}, {} }); // Deleting a field -db.update({planet: 'Mars'}, {$unset: {planet: true}}, {}, function () { +db.update({planet: 'Mars'}, {$unset: {planet: true}}, {}, () => { // Now the document for Mars doesn't contain the planet field // You can unset nested fields with the dot notation of course }); @@ -470,14 +429,14 @@ db.update({planet: 'Mars'}, {$unset: {planet: true}}, {}, function () { db.update({planet: 'Pluton'}, { planet: 'Pluton', inhabited: false -}, {upsert: true}, function (err:Error, numReplaced:number, upsert:boolean) { +}, {upsert: true}, (err: Error, numReplaced: number, upsert: boolean) => { // numReplaced = 1, upsert = { _id: 'id5', planet: 'Pluton', inhabited: false } // A new document { _id: 'id5', planet: 'Pluton', inhabited: false } has been added to the collection }); // If you upsert with a modifier, the upserted doc is the query modified by the modifier // This is simpler than it sounds :) -db.update({planet: 'Pluton'}, {$inc: {distance: 38}}, {upsert: true}, function () { +db.update({planet: 'Pluton'}, {$inc: {distance: 38}}, {upsert: true}, () => { // A new document { _id: 'id5', planet: 'Pluton', distance: 38 } has been added to the collection }); @@ -485,12 +444,12 @@ db.update({planet: 'Pluton'}, {$inc: {distance: 38}}, {upsert: true}, function ( // let's see how we can modify the array field atomically // $push inserts new elements at the end of the array -db.update({_id: 'id6'}, {$push: {fruits: 'banana'}}, {}, function () { +db.update({_id: 'id6'}, {$push: {fruits: 'banana'}}, {}, () => { // Now the fruits array is ['apple', 'orange', 'pear', 'banana'] }); // $pop removes an element from the end (if used with 1) or the front (if used with -1) of the array -db.update({_id: 'id6'}, {$pop: {fruits: 1}}, {}, function () { +db.update({_id: 'id6'}, {$pop: {fruits: 1}}, {}, () => { // Now the fruits array is ['apple', 'orange'] // With { $pop: { fruits: -1 } }, it would have been ['orange', 'pear'] }); @@ -498,23 +457,23 @@ db.update({_id: 'id6'}, {$pop: {fruits: 1}}, {}, function () { // $addToSet adds an element to an array only if it isn't already in it // Equality is deep-checked (i.e. $addToSet will not insert an object in an array already containing the same object) // Note that it doesn't check whether the array contained duplicates before or not -db.update({_id: 'id6'}, {$addToSet: {fruits: 'apple'}}, {}, function () { +db.update({_id: 'id6'}, {$addToSet: {fruits: 'apple'}}, {}, () => { // The fruits array didn't change // If we had used a fruit not in the array, e.g. 'banana', it would have been added to the array }); // $pull removes all values matching a value or even any NeDB query from the array -db.update({_id: 'id6'}, {$pull: {fruits: 'apple'}}, {}, function () { +db.update({_id: 'id6'}, {$pull: {fruits: 'apple'}}, {}, () => { // Now the fruits array is ['orange', 'pear'] }); -db.update({_id: 'id6'}, {$pull: {fruits: {$in: ['apple', 'pear']}}}, {}, function () { +db.update({_id: 'id6'}, {$pull: {fruits: {$in: ['apple', 'pear']}}}, {}, () => { // Now the fruits array is ['orange'] }); // $each can be used to $push or $addToSet multiple values at once // This example works the same way with $addToSet -db.update({_id: 'id6'}, {$push: {fruits: {$each: ['banana', 'orange']}}}, {}, function () { +db.update({_id: 'id6'}, {$push: {fruits: {$each: ['banana', 'orange']}}}, {}, () => { // Now the fruits array is ['apple', 'orange', 'pear', 'banana', 'orange'] }); @@ -526,33 +485,33 @@ db.update({_id: 'id6'}, {$push: {fruits: {$each: ['banana', 'orange']}}}, {}, fu // Remove one document from the collection // options set to {} since the default for multi is false -db.remove({_id: 'id2'}, {}, function (err:Error, numRemoved:number) { +db.remove({_id: 'id2'}, {}, (err: Error, numRemoved: number) => { // numRemoved = 1 }); // Remove multiple documents -db.remove({system: 'solar'}, {multi: true}, function (err:Error, numRemoved:number) { +db.remove({system: 'solar'}, {multi: true}, (err: Error, numRemoved: number) => { // numRemoved = 3 // All planets from the solar system were removed }); -db.ensureIndex({fieldName: 'somefield'}, function (err:Error) { +db.ensureIndex({fieldName: 'somefield'}, (err: Error) => { // If there was an error, err is not null }); // Using a unique constraint with the index -db.ensureIndex({fieldName: 'somefield', unique: true}, function (err:Error) { +db.ensureIndex({fieldName: 'somefield', unique: true}, (err: Error) => { }); // Using a sparse unique index -db.ensureIndex({fieldName: 'somefield', unique: true, sparse: true}, function (err:Error) { +db.ensureIndex({fieldName: 'somefield', unique: true, sparse: true}, (err: Error) => { }); // Format of the error message when the unique constraint is not met -db.insert({somefield: 'nedb'}, function (err:Error) { +db.insert({somefield: 'nedb'}, (err: Error) => { // err is null - db.insert({somefield: 'nedb'}, function (err:Error) { + db.insert({somefield: 'nedb'}, (err: Error) => { // err is { errorType: 'uniqueViolated' // , key: 'name' // , message: 'Unique constraint violated for key name' } @@ -560,5 +519,5 @@ db.insert({somefield: 'nedb'}, function (err:Error) { }); // Remove index on field somefield -db.removeIndex('somefield', function (err:Error) { +db.removeIndex('somefield', (err: Error) => { }); \ No newline at end of file diff --git a/nedb/tslint.json b/nedb/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/nedb/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file From a3dc5d2e661c26006481ad0f0eb75c5925adf018 Mon Sep 17 00:00:00 2001 From: Wil Lee Date: Tue, 14 Mar 2017 11:12:46 -0700 Subject: [PATCH 105/258] Add rheostat typings --- rheostat/index.d.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 rheostat/index.d.ts diff --git a/rheostat/index.d.ts b/rheostat/index.d.ts new file mode 100644 index 0000000000..372e5c6f1b --- /dev/null +++ b/rheostat/index.d.ts @@ -0,0 +1,49 @@ +// Type definitions for rheostat 2.1 +// Project: https://github.com/airbnb/rheostat +// Definitions by: Sasha Bayan , Wil Lee +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 + +import * as React from 'react'; + +export type Orientation = 'horizontal' | 'vertical'; + +export interface Algorithm { + getPosition(value: number, min: number, max: number): number; + getValue(pos: number, min: number, max: number): number; +} + +export interface PublicState { + max: number; + min: number; + values: number[]; +} + +export interface Events { + onClick?: () => any; + onChange?: (publicState: PublicState) => any; + onKeyPress?: () => any; + onSliderDragEnd?: () => any; + onSliderDragMove?: () => any; + onSliderDragStart?: () => any; + onValuesUpdated?: (publicState: PublicState) => any; +} + +export interface Props extends Events { + algorithm?: Algorithm; + className?: string; + disabled?: boolean; + handle?: React.ReactType; + max?: number; + min?: number; + orientation?: Orientation; + pitComponent?: React.ReactType; + pitPoints?: number[]; + progressBar?: React.ReactType; + snap?: boolean; + snapPoints?: number[]; + values?: number[]; +} + +export default class Rheostat extends React.Component {} + From d0b032eb4a61bac2702dfd0fa59da1221b5f4835 Mon Sep 17 00:00:00 2001 From: Wil Lee Date: Tue, 14 Mar 2017 11:13:03 -0700 Subject: [PATCH 106/258] Add rheostat tests --- rheostat/rheostat-tests.tsx | 74 +++++++++++++++++++++++++++++++++++++ rheostat/tsconfig.json | 21 +++++++++++ 2 files changed, 95 insertions(+) create mode 100644 rheostat/rheostat-tests.tsx create mode 100644 rheostat/tsconfig.json diff --git a/rheostat/rheostat-tests.tsx b/rheostat/rheostat-tests.tsx new file mode 100644 index 0000000000..1116861943 --- /dev/null +++ b/rheostat/rheostat-tests.tsx @@ -0,0 +1,74 @@ +import * as React from 'react'; +import Rheostat, {Orientation, Algorithm, PublicState} from 'rheostat'; + +type Element = React.ReactElement; + +function Basic(props: {}): Element { + return ; +} + +function MultiHandles(props: {}): Element { + return ( + + ); +} + +function CustomAlgorithm(props: {}): Element { + const geometric: Algorithm = { + getPosition(x: number, min: number, max: number) { + return ((max / (max - min)) ** 0.5) * (((x - min) / max) ** 0.5) * 100; + }, + + getValue(x: number, min: number, max: number) { + return (Math.floor(((x / 100) ** 2) * (max - min)) + min); + } + }; + + return ; +} + +function ComponentOverrides(props: {}): Element { + function Bar(props: {}): Element { return


    ; } + return ( + + ); +} + +function Vertical(props: {}): Element { + return ; +} + +function Pits(props: {}): Element { + function Pit(props: {}): Element { return ; } + return ( + + ); +} + +function CustomValues(props: {}): Element { + return ( + + ); +} + +function Handlers(props: {}): Element { + function handler(data: PublicState): void {} + return ( + + ); +} diff --git a/rheostat/tsconfig.json b/rheostat/tsconfig.json new file mode 100644 index 0000000000..384dce128d --- /dev/null +++ b/rheostat/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es6", "dom"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "jsx": "react", + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "rheostat-tests.tsx" + ] +} From 9593fd1968f13b2d144492f458221bb6a4fe4c89 Mon Sep 17 00:00:00 2001 From: Wil Lee Date: Tue, 14 Mar 2017 12:06:59 -0700 Subject: [PATCH 107/258] Turn on linting --- rheostat/tslint.json | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 rheostat/tslint.json diff --git a/rheostat/tslint.json b/rheostat/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/rheostat/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 9a57ca6254125457328aa2cd0e4ebf59bd7389e4 Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 14 Mar 2017 15:04:44 -0700 Subject: [PATCH 108/258] Remove 'promises-a-plus' and lint stamplay (#15176) --- promises-a-plus/index.d.ts | 18 ------ promises-a-plus/promises-a-plus-tests.ts | 79 ------------------------ promises-a-plus/tsconfig.json | 22 ------- stamplay-js-sdk/index.d.ts | 42 +++++-------- stamplay-js-sdk/stamplay-js-sdk-tests.ts | 26 ++++---- stamplay-js-sdk/tslint.json | 1 + 6 files changed, 30 insertions(+), 158 deletions(-) delete mode 100644 promises-a-plus/index.d.ts delete mode 100644 promises-a-plus/promises-a-plus-tests.ts delete mode 100644 promises-a-plus/tsconfig.json create mode 100644 stamplay-js-sdk/tslint.json diff --git a/promises-a-plus/index.d.ts b/promises-a-plus/index.d.ts deleted file mode 100644 index 806020d051..0000000000 --- a/promises-a-plus/index.d.ts +++ /dev/null @@ -1,18 +0,0 @@ -// Type definitions for promises-a-plus -// Project: http://promisesaplus.com/ -// Definitions by: Igor Oleinikov -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped - -declare namespace PromisesAPlus { - interface PromiseCtor { - (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; - } - - interface PromiseImpl { - new (resolver: (resolvePromise: (value: T) => void, rejectPromise: (reason: any) => void) => void): Thenable; - } - - interface Thenable { - then(onFulfill?: (value: T) => Thenable|R, onReject?: (error: any) => Thenable|R): Thenable; - } -} diff --git a/promises-a-plus/promises-a-plus-tests.ts b/promises-a-plus/promises-a-plus-tests.ts deleted file mode 100644 index 222cca14d8..0000000000 --- a/promises-a-plus/promises-a-plus-tests.ts +++ /dev/null @@ -1,79 +0,0 @@ -/// -/// -/// - -var thenNum: PromisesAPlus.Thenable; -var thenStr: PromisesAPlus.Thenable; -var thenBool: PromisesAPlus.Thenable; - -var impl: PromisesAPlus.PromiseImpl; - -declare class PromiseImpl { - constructor(resolver: (resolvePromise: (value: R) => void, rejectPromise: (reason: any) => void) => void); - - then(onFulfill: (value: R) => PromiseImpl, onReject: (error: any) => PromiseImpl): PromiseImpl; - then(onFulfill: (value: R) => PromiseImpl, onReject?: (error: any) => U): PromiseImpl; - then(onFulfill: (value: R) => U, onReject: (error: any) => PromiseImpl): PromiseImpl; - then(onFulfill?: (value: R) => U, onReject?: (error: any) => U): PromiseImpl; -} - -function testCompatibleWithPromiseImpl() { - var pNum: PromiseImpl = thenNum; - - thenNum = pNum; - - impl = PromiseImpl; -} - -function testCompatibleWithRxJS() { - // from spec to Rx - var rxThenNum: Rx.IPromise = thenNum; - var rxThenStr: Rx.IPromise = thenStr; - - // from Rx to spec - thenNum = rxThenNum; - thenStr = rxThenStr; - - var obsNum: Rx.Observable; - - // implementation usage - thenNum = obsNum.toPromise>(impl); - thenNum = obsNum.toPromise(impl); - obsNum.toPromise(PromiseImpl); -} - -function testCompatibleWithES6Promises() { - // define ES6 thenables - var es6ThenNum: PromiseLike; - var es6ThenStr: PromiseLike; - - // from ES6 to spec - thenNum = es6ThenNum; - thenStr = es6ThenStr; - - // implementation - impl = Promise; -} - -function testCompatibleWithQ() { - // from spec to ES6 - var qThenNum: Q.IPromise = thenNum; - var qThenStr: Q.IPromise = thenStr; - - // from ES6 to spec - thenNum = qThenNum; - thenStr = qThenStr; - - // there's no standart implementation with constructor behaviour -} - -function testCompatibleWithWhen() { - var whenPromiseNum: When.Promise; - var whenPromiseStr: When.Promise; - - // from ES6 to spec - thenNum = whenPromiseNum; - thenStr = whenPromiseStr; - - // there's no standart implementation with constructor behaviour -} diff --git a/promises-a-plus/tsconfig.json b/promises-a-plus/tsconfig.json deleted file mode 100644 index d5ccf86f75..0000000000 --- a/promises-a-plus/tsconfig.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "baseUrl": "../", - "typeRoots": [ - "../" - ], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true - }, - "files": [ - "index.d.ts", - "promises-a-plus-tests.ts" - ] -} \ No newline at end of file diff --git a/stamplay-js-sdk/index.d.ts b/stamplay-js-sdk/index.d.ts index 53f57ad86c..81f20d8c95 100644 --- a/stamplay-js-sdk/index.d.ts +++ b/stamplay-js-sdk/index.d.ts @@ -1,35 +1,27 @@ -// Type definitions for stamplay-js-sdk 1.2.9 +// Type definitions for stamplay-js-sdk 1.2 // Project: https://github.com/Stamplay/stamplay-js-sdk // Definitions by: Riderman de Sousa Barbosa // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace Stamplay { + export function init(appId: string): void; + export function User(): StamplayObject; + export function Cobject(object: string): StamplayObject; - export interface IStamplayModel { - signup({}) : PromisesAPlus.Thenable - new() : IStamplayModel - get(property : string) : any - set(property : string, value: any) : void - unset(property : string) : void - fetch(id : any) : PromisesAPlus.Thenable - destroy() : PromisesAPlus.Thenable - save({}?) : PromisesAPlus.Thenable - upVote() : PromisesAPlus.Thenable + export interface Model { + signup({}): Promise; + new(): Model; // This is suspicious, but tests show model instances being constructable... + get(property: string): any; + set(property: string, value: any): void; + unset(property: string) : void; + fetch(id: any) : Promise; + destroy(): Promise; + save({}?): Promise; + upVote(): Promise; } - export interface IStamplayObject { - Model : IStamplayModel - Collection : any - - } - - export interface StamplayStatic { - init(appId : string) : void; - User() : IStamplayObject - Cobject(object : string) : IStamplayObject + export interface StamplayObject { + Model: Model; + Collection : any; } } - -declare var Stamplay: Stamplay.StamplayStatic; diff --git a/stamplay-js-sdk/stamplay-js-sdk-tests.ts b/stamplay-js-sdk/stamplay-js-sdk-tests.ts index d9a4247e03..9dddc1b242 100644 --- a/stamplay-js-sdk/stamplay-js-sdk-tests.ts +++ b/stamplay-js-sdk/stamplay-js-sdk-tests.ts @@ -11,26 +11,24 @@ var registrationData = { password: 'mySecret' }; -user.signup(registrationData).then(function(){ - user.set('phoneNumber', '020 123 4567' ); - return user.save(); - }).then(function(){ - var number = user.get('phoneNumber'); - console.log(number); // number value is 020 123 4567 - }); +user.signup(registrationData).then(() => { + user.set('phoneNumber', '020 123 4567' ); + return user.save(); +}).then(() => { + var number = user.get('phoneNumber'); + console.log(number); // number value is 020 123 4567 +}); // Action var colFoo = Stamplay.Cobject('foo'); var fooMod = new colFoo.Model(); -fooMod.fetch(5).then( - function(){ - return fooMod.upVote() - } -).then( - function(){ +fooMod.fetch(5) + .then(() => fooMod.upVote()) + .then( + () => { //success callback - }, function( err : any ){ + }, (err: any) => { //error callback } ) diff --git a/stamplay-js-sdk/tslint.json b/stamplay-js-sdk/tslint.json new file mode 100644 index 0000000000..2221e40e4a --- /dev/null +++ b/stamplay-js-sdk/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } \ No newline at end of file From 643304a0f407b25c50560665b45635ff7076df34 Mon Sep 17 00:00:00 2001 From: Wink Saville Date: Tue, 14 Mar 2017 18:15:52 -0700 Subject: [PATCH 109/258] Add csprng (#15178) --- csprng/csprng-tests.ts | 5 +++++ csprng/index.d.ts | 7 +++++++ csprng/tsconfig.json | 22 ++++++++++++++++++++++ csprng/tslint.json | 3 +++ 4 files changed, 37 insertions(+) create mode 100644 csprng/csprng-tests.ts create mode 100644 csprng/index.d.ts create mode 100644 csprng/tsconfig.json create mode 100644 csprng/tslint.json diff --git a/csprng/csprng-tests.ts b/csprng/csprng-tests.ts new file mode 100644 index 0000000000..aafddc4021 --- /dev/null +++ b/csprng/csprng-tests.ts @@ -0,0 +1,5 @@ +import csprng = require("csprng"); + +let rngStr: string; + +rngStr = csprng(32, 16); diff --git a/csprng/index.d.ts b/csprng/index.d.ts new file mode 100644 index 0000000000..90aa83b017 --- /dev/null +++ b/csprng/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for csprng 0.1 +// Project: https://github.com/jcoglan/node-csprng +// Definitions by: Wink Saville +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +export = csprng; + +declare function csprng(bits: number, radix: number): string; diff --git a/csprng/tsconfig.json b/csprng/tsconfig.json new file mode 100644 index 0000000000..0877c1ab25 --- /dev/null +++ b/csprng/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "csprng-tests.ts" + ] +} diff --git a/csprng/tslint.json b/csprng/tslint.json new file mode 100644 index 0000000000..ec365f164b --- /dev/null +++ b/csprng/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} From 295246936681b56d5a9555b25dfbe275bf0da851 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Tue, 14 Mar 2017 18:21:24 -0700 Subject: [PATCH 110/258] Add Q.try definition (#15161) * Add Q.try defintion * Persever q@0.0 * Depend on q@0.0 * Remove uneeded `/// ` * Use built-in Promise instead of Q.Promise * Remove usused path mappings * Use Q again * Use global reference instead of path mapping for q * Add dependncy on q@0.0 * Switch hystrixjs to a module * Remove import when there is a triple-slash-reference-types in the index * Use triple-slash-reference-types instead of path mapping * Update version of Q to 1.0 * Switch the file to a module and use declare global * Switch to a module * use import instead of triple-slash-reference-types * Do not use triple-slash-reference types * Switch firebase-client to a module * import q as a module * use import for q --- atom/index.d.ts | 2 +- atom/tsconfig.json | 3 + business-rules-engine/Validation.d.ts | 2 - business-rules-engine/index.d.ts | 1 - business-rules-engine/node-validators.d.ts | 1 - business-rules-engine/tsconfig.json | 3 + cordova-plugin-ibeacon/index.d.ts | 168 +- cordova-plugin-ibeacon/tsconfig.json | 3 + easy-api-request/index.d.ts | 1 - easy-api-request/tsconfig.json | 3 + firebase-client/firebase-client-tests.ts | 14 +- firebase-client/index.d.ts | 22 +- firebase-client/tsconfig.json | 3 + gulp-help-doc/tsconfig.json | 3 + gulp-help/tsconfig.json | 3 + gulp-protractor/tsconfig.json | 3 + gulp-tsd/tsconfig.json | 3 + gulp/tsconfig.json | 3 + hystrixjs/index.d.ts | 271 +- hystrixjs/tsconfig.json | 3 + microsoft-sdk-soap/index.d.ts | 5655 ++++++++--------- .../microsoft-sdk-soap-tests.ts | 3 +- microsoft-sdk-soap/tsconfig.json | 3 + mongoose-seeder/tsconfig.json | 3 + msportalfx-test/index.d.ts | 2 - msportalfx-test/tsconfig.json | 3 + node-form/index.d.ts | 2 - node-form/tsconfig.json | 3 + node-persist/index.d.ts | 1 - node-persist/tsconfig.json | 3 + o.js/index.d.ts | 4 +- o.js/tsconfig.json | 3 + orchestrator/index.d.ts | 2 - orchestrator/tsconfig.json | 3 + pathwatcher/tsconfig.json | 3 + promise-pg/index.d.ts | 1 - promise-pg/tsconfig.json | 3 + promise-pool/index.d.ts | 1 - promise-pool/tsconfig.json | 3 + q-io/index.d.ts | 282 +- q-io/q-io-tests.ts | 2 - q-io/tsconfig.json | 3 + q-retry/index.d.ts | 2 - q-retry/tsconfig.json | 3 + q/index.d.ts | 20 +- q/q-tests.ts | 11 + q/v0/index.d.ts | 357 ++ q/v0/q-tests.ts | 226 + q/v0/tsconfig.json | 26 + qajax/index.d.ts | 2 - qajax/tsconfig.json | 3 + run-sequence/tsconfig.json | 3 + status-bar/tsconfig.json | 3 + text-buffer/tsconfig.json | 3 + twilio/index.d.ts | 3 +- twilio/tsconfig.json | 3 + vso-node-api/index.d.ts | 2 +- vso-node-api/tsconfig.json | 3 + 58 files changed, 3877 insertions(+), 3296 deletions(-) create mode 100644 q/v0/index.d.ts create mode 100644 q/v0/q-tests.ts create mode 100644 q/v0/tsconfig.json diff --git a/atom/index.d.ts b/atom/index.d.ts index 7c984bd812..05c9794eec 100644 --- a/atom/index.d.ts +++ b/atom/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: vvakame // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// /// /// @@ -1519,6 +1518,7 @@ declare var atom:AtomCore.IAtom; declare module "atom" { import spacePen = require("space-pen"); + import Q = require("q"); var $:typeof spacePen.$; var $$:typeof spacePen.$$; diff --git a/atom/tsconfig.json b/atom/tsconfig.json index 3bb8fe9761..6c1bb13aef 100644 --- a/atom/tsconfig.json +++ b/atom/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/business-rules-engine/Validation.d.ts b/business-rules-engine/Validation.d.ts index 0dd8283dc2..7f61f517be 100644 --- a/business-rules-engine/Validation.d.ts +++ b/business-rules-engine/Validation.d.ts @@ -3,8 +3,6 @@ // Definitions by: Roman Samec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare namespace Validation { interface IErrorCustomMessage { (config: any, args: any): string; diff --git a/business-rules-engine/index.d.ts b/business-rules-engine/index.d.ts index 4f71b43dfb..a74bcf180d 100644 --- a/business-rules-engine/index.d.ts +++ b/business-rules-engine/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // Source: typings/business-rules-engine/Validation.d.ts -/// import * as Q from "q"; diff --git a/business-rules-engine/node-validators.d.ts b/business-rules-engine/node-validators.d.ts index 73746eef92..fa2b9cb39e 100644 --- a/business-rules-engine/node-validators.d.ts +++ b/business-rules-engine/node-validators.d.ts @@ -3,7 +3,6 @@ // Definitions by: Roman Samec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// import Validation = require("business-rules-engine"); diff --git a/business-rules-engine/tsconfig.json b/business-rules-engine/tsconfig.json index 008e622d1f..a80b05099b 100644 --- a/business-rules-engine/tsconfig.json +++ b/business-rules-engine/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/cordova-plugin-ibeacon/index.d.ts b/cordova-plugin-ibeacon/index.d.ts index bfbfe607d4..3530ccb70d 100644 --- a/cordova-plugin-ibeacon/index.d.ts +++ b/cordova-plugin-ibeacon/index.d.ts @@ -3,95 +3,97 @@ // Definitions by: Markus Wagner // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as Q from "q"; -interface CordovaPlugins { - locationManager: BeaconPlugin.LocationManager; -} - -declare namespace BeaconPlugin { - /** - * Beacon Plugin. - */ - export interface LocationManager { - delegate: Delegate; - BeaconRegion: BeaconRegion; - Region: Region; - onDomDelegateReady(): Q.Promise; - startMonitoringForRegion(region: Region): Q.Promise; - stopMonitoringForRegion(region: Region): Q.Promise; - requestStateForRegion(region: Region): Q.Promise; - startRangingBeaconsInRegion(region: Region): Q.Promise; - stopRangingBeaconsInRegion(region: Region): Q.Promise; - getAuthorizationStatus(): Q.Promise; - requestWhenInUseAuthorization(): Q.Promise; - requestAlwaysAuthorization(): Q.Promise; - getMonitoredRegions(): Q.Promise; - getRangedRegions(): Q.Promise; - isRangingAvailable(): Q.Promise; - isMonitoringAvailableForClass(region: Region): Q.Promise; - startAdvertising(region: Region, measuredPower: boolean): Q.Promise; - stopAdvertising(): Q.Promise; - isAdvertisingAvailable(): Q.Promise; - isAdvertising(): Q.Promise; - disableDebugLogs(): Q.Promise; - enableDebugNotifications(): Q.Promise; - disableDebugNotifications(): Q.Promise; - enableDebugLogs(): Q.Promise; - isBluetoothEnabled(): Q.Promise; - enableBluetooth(): Q.Promise; - disableBluetooth(): Q.Promise; - appendToDeviceLog(message: string): Q.Promise; +declare global { + interface CordovaPlugins { + locationManager: BeaconPlugin.LocationManager; } - export interface PluginResult { - eventType: string; - region: Region; - beacons: Beacon[]; - authorizationStatus: string; - state: string; - error: string; - } + namespace BeaconPlugin { + /** + * Beacon Plugin. + */ + export interface LocationManager { + delegate: Delegate; + BeaconRegion: BeaconRegion; + Region: Region; + onDomDelegateReady(): Q.Promise; + startMonitoringForRegion(region: Region): Q.Promise; + stopMonitoringForRegion(region: Region): Q.Promise; + requestStateForRegion(region: Region): Q.Promise; + startRangingBeaconsInRegion(region: Region): Q.Promise; + stopRangingBeaconsInRegion(region: Region): Q.Promise; + getAuthorizationStatus(): Q.Promise; + requestWhenInUseAuthorization(): Q.Promise; + requestAlwaysAuthorization(): Q.Promise; + getMonitoredRegions(): Q.Promise; + getRangedRegions(): Q.Promise; + isRangingAvailable(): Q.Promise; + isMonitoringAvailableForClass(region: Region): Q.Promise; + startAdvertising(region: Region, measuredPower: boolean): Q.Promise; + stopAdvertising(): Q.Promise; + isAdvertisingAvailable(): Q.Promise; + isAdvertising(): Q.Promise; + disableDebugLogs(): Q.Promise; + enableDebugNotifications(): Q.Promise; + disableDebugNotifications(): Q.Promise; + enableDebugLogs(): Q.Promise; + isBluetoothEnabled(): Q.Promise; + enableBluetooth(): Q.Promise; + disableBluetooth(): Q.Promise; + appendToDeviceLog(message: string): Q.Promise; + } - export interface Delegate { - didDetermineStateForRegion(pluginResult: PluginResult): void; - didStartMonitoringForRegion(pluginResult: PluginResult): void; - didExitRegion(pluginResult: PluginResult): void; - didEnterRegion(pluginResult: PluginResult): void; - didRangeBeaconsInRegion(pluginResult: PluginResult): void; - peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void; - peripheralManagerDidUpdateState(pluginResult: PluginResult): void; - didChangeAuthorizationStatus(authorizationStatus: string): void; - monitoringDidFailForRegionWithError(pluginResult: PluginResult): void; - } + export interface PluginResult { + eventType: string; + region: Region; + beacons: Beacon[]; + authorizationStatus: string; + state: string; + error: string; + } - export interface Region { - identifier: string; - new (identifier: string): Region; - } + export interface Delegate { + didDetermineStateForRegion(pluginResult: PluginResult): void; + didStartMonitoringForRegion(pluginResult: PluginResult): void; + didExitRegion(pluginResult: PluginResult): void; + didEnterRegion(pluginResult: PluginResult): void; + didRangeBeaconsInRegion(pluginResult: PluginResult): void; + peripheralManagerDidStartAdvertising(pluginResult: PluginResult): void; + peripheralManagerDidUpdateState(pluginResult: PluginResult): void; + didChangeAuthorizationStatus(authorizationStatus: string): void; + monitoringDidFailForRegionWithError(pluginResult: PluginResult): void; + } - export interface BeaconRegion extends Region { - uuid: string; - major: string; - minor: string; - notifyEntryStateOnDisplay: boolean; - new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion; - } + export interface Region { + identifier: string; + new (identifier: string): Region; + } - export interface CircularRegion extends Region { - latitude: number; - longitude: number; - radius: number; - new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion; - } + export interface BeaconRegion extends Region { + uuid: string; + major: string; + minor: string; + notifyEntryStateOnDisplay: boolean; + new (identifier: string, uuid: string, major?: number, minor?: number, notifyEntryStateOnDisplay?: boolean): BeaconRegion; + } - export interface Beacon { - uuid: string; - major: string; - minor: string; - proximity: string; - tx: number; - rssi: number; - accuracy: number; + export interface CircularRegion extends Region { + latitude: number; + longitude: number; + radius: number; + new (identifier: string, latitude: number, longitude: number, radius: number): CircularRegion; + } + + export interface Beacon { + uuid: string; + major: string; + minor: string; + proximity: string; + tx: number; + rssi: number; + accuracy: number; + } } -} +} \ No newline at end of file diff --git a/cordova-plugin-ibeacon/tsconfig.json b/cordova-plugin-ibeacon/tsconfig.json index 603b991c64..af70edc7f5 100644 --- a/cordova-plugin-ibeacon/tsconfig.json +++ b/cordova-plugin-ibeacon/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/easy-api-request/index.d.ts b/easy-api-request/index.d.ts index 8f4ca0d553..f04b68be3a 100644 --- a/easy-api-request/index.d.ts +++ b/easy-api-request/index.d.ts @@ -3,7 +3,6 @@ // Definitions by: Karl Düüna // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// import stream = require('stream'); diff --git a/easy-api-request/tsconfig.json b/easy-api-request/tsconfig.json index 663d9a15d0..0f8b3873e0 100644 --- a/easy-api-request/tsconfig.json +++ b/easy-api-request/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/firebase-client/firebase-client-tests.ts b/firebase-client/firebase-client-tests.ts index 0b79ec75d6..987b4b638b 100644 --- a/firebase-client/firebase-client-tests.ts +++ b/firebase-client/firebase-client-tests.ts @@ -19,16 +19,16 @@ var client = new FirebaseClient({ var newUser:User = new User(); newUser.name = { first: "Fred", - last: "Flinstone" + last: "Flinstone" }; client.push("users", newUser) .then(function (result){ console.log(result.name); var newUser2:User = new User(); - newUser2.name = { - first: "Fred", - last: "Rockington" + newUser2.name = { + first: "Fred", + last: "Rockington" } return client.update("users/" + result.name, newUser2); }).then(function (result){ @@ -36,15 +36,15 @@ client.push("users", newUser) var newUser3:User = new User(); newUser3.name = { first: "Axe", - last: "Steel" + last: "Steel" }; return client.set("users/AXESTEEL", newUser3); }).then(function (result){ console.log(result.name.first); return client.get(); - }).then(function (result){ + }).then(function (result){ console.log(result); return client.get("users/AXESTEEL") }).then(function (result){ - console.log(result.name.first); + console.log(result.name.first); }); \ No newline at end of file diff --git a/firebase-client/index.d.ts b/firebase-client/index.d.ts index d2c58bb5ba..b766fc2478 100644 --- a/firebase-client/index.d.ts +++ b/firebase-client/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Andrew Breen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// +import * as Q from "q"; interface PushResponse { /** @@ -17,7 +17,7 @@ interface FirebaseConfig { * path for the Firebase instance */ url : string; - + /** * Token for authorisation */ @@ -29,38 +29,38 @@ interface FirebaseClient { * Creates a new FirebaseClient given the provided configuration */ new (config : FirebaseConfig) : FirebaseClient; - + /** * Retrieves all objects at the base path */ get() : Q.Promise; - + /** * Retrieves an object * @param path Relative path from the base for the resource */ get(path : string) : Q.Promise; - + /** * Returns a promise of the HTTP response from setting the value at the given path * @param path Relative path from the base for the resource * @param data Data to be set as the value for the given path */ set(path : string, data : T) : Q.Promise; - + /** * Update a node at a given path * @param path Relative path from the base for the resource * @param value Value of the response */ update(path : string, value : T) : Q.Promise; - + /** * Deletes the resource at a given path * @param path Relative path from the base for the resource */ delete(path : string) : Q.Promise; - + /** * @param path Relative path from the base for the resource * @param value Object to push to the path @@ -70,7 +70,5 @@ interface FirebaseClient { declare var FirebaseClient: FirebaseClient; -declare module 'firebase-client' { - export = FirebaseClient; -} - +export = FirebaseClient; +export as namespace FirebaseClient; diff --git a/firebase-client/tsconfig.json b/firebase-client/tsconfig.json index fdb35ab929..b439fb8310 100644 --- a/firebase-client/tsconfig.json +++ b/firebase-client/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-help-doc/tsconfig.json b/gulp-help-doc/tsconfig.json index 646e8ad141..283808fe7b 100644 --- a/gulp-help-doc/tsconfig.json +++ b/gulp-help-doc/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-help/tsconfig.json b/gulp-help/tsconfig.json index d0647ad22a..f8e499e793 100644 --- a/gulp-help/tsconfig.json +++ b/gulp-help/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-protractor/tsconfig.json b/gulp-protractor/tsconfig.json index 1141cf2042..667da98b75 100644 --- a/gulp-protractor/tsconfig.json +++ b/gulp-protractor/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-tsd/tsconfig.json b/gulp-tsd/tsconfig.json index a5738eb561..4252bbc080 100644 --- a/gulp-tsd/tsconfig.json +++ b/gulp-tsd/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp/tsconfig.json b/gulp/tsconfig.json index f6670453d1..01afedbf29 100644 --- a/gulp/tsconfig.json +++ b/gulp/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/hystrixjs/index.d.ts b/hystrixjs/index.d.ts index d4a738b999..39fef977e1 100644 --- a/hystrixjs/index.d.ts +++ b/hystrixjs/index.d.ts @@ -3,146 +3,141 @@ // Definitions by: Igor Sechyn // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// -/// +import * as Q from "q"; +import * as RX from "rx"; -declare namespace HystrixJS { +export as namespace hystrixjs; +export as namespace HystrixJS; - interface HystrixProperties { - "hystrix.force.circuit.open"?: boolean, - "hystrix.force.circuit.closed"?: boolean, - "hystrix.circuit.sleepWindowInMilliseconds"?:number, - "hystrix.circuit.errorThresholdPercentage"?: number, - "hystrix.circuit.volumeThreshold"?:number, - "hystrix.circuit.volumeThreshold.forceOverride"?: boolean, - "hystrix.circuit.volumeThreshold.override"?: number, - "hystrix.execution.timeoutInMilliseconds"?: number, - "hystrix.metrics.statistical.window.timeInMilliseconds"?: number, - "hystrix.metrics.statistical.window.bucketsNumber"?: number, - "hystrix.metrics.percentile.window.timeInMilliseconds"?: number, - "hystrix.metrics.percentile.window.bucketsNumber"?: number, - "hystrix.request.volume.rejectionThreshold"?: number - } - - interface HystrixConfig { - metricsPercentileWindowBuckets(): number; - circuitBreakerForceClosed(): boolean; - circuitBreakerForceOpened(): boolean; - circuitBreakerSleepWindowInMilliseconds(): number; - circuitBreakerErrorThresholdPercentage(): number; - circuitBreakerRequestVolumeThreshold(): number; - circuitBreakerRequestVolumeThresholdForceOverride(): boolean; - circuitBreakerRequestVolumeThresholdOverride(): number; - executionTimeoutInMilliseconds(): number; - metricsStatisticalWindowBuckets(): number; - metricsStatisticalWindowInMilliseconds(): number; - metricsPercentileWindowInMilliseconds(): number; - metricsPercentileWindowBuckets(): number; - requestVolumeRejectionThreshold(): number; - resetProperties(): void; - init(properties: HystrixProperties): void; - } - - interface Command { - execute(...args: any[]): Q.Promise; - } - - interface CommandBuilder { - circuitBreakerSleepWindowInMilliseconds(value: number): CommandBuilder; - errorHandler(value: (error: any) => boolean): CommandBuilder; - timeout(value: number): CommandBuilder; - circuitBreakerRequestVolumeThreshold(value: number): CommandBuilder; - requestVolumeRejectionThreshold(value: number): CommandBuilder; - circuitBreakerForceOpened(value: boolean): CommandBuilder; - circuitBreakerForceClosed(value: boolean): CommandBuilder; - statisticalWindowNumberOfBuckets(value: number): CommandBuilder; - statisticalWindowLength(value: number): CommandBuilder; - percentileWindowNumberOfBuckets(value: number): CommandBuilder; - percentileWindowLength(value: number): CommandBuilder; - circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder; - run(value: (args: any) => Q.Promise): CommandBuilder; - fallbackTo(value: (...args: any[]) => Q.Promise): CommandBuilder; - context(value: any): CommandBuilder; - build(): Command; - } - - interface CommandFactory { - getOrCreate(commandKey: string, commandGroup?: string): CommandBuilder; - resetCache(): void; - } - - interface HealthCounts { - totalCount: number; - errorCount: number; - errorPercentage: number; - } - - interface CommandMetrics { - markSuccess(): void; - markRejected(): void; - markFailure(): void; - markTimeout(): void; - markShortCircuited(): void; - incrementExecutionCount(): void; - decrementExecutionCount(): void; - getCurrentExecutionCount(): number; - addExecutionTime(value: number): void; - getRollingCount(type: any): number; - getExecutionTime(percentile: any): number; - getHealthCounts(): HealthCounts; - reset(): void; - } - - interface MetricsProperties { - commandKey: string, - commandGroup: string, - statisticalWindowTimeInMilliSeconds?: number, - statisticalWindowNumberOfBuckets?: number, - percentileWindowTimeInMilliSeconds?: number, - percentileWindowNumberOfBuckets?: number - } - - interface MetricsFactory { - getOrCreate(config: MetricsProperties): CommandMetrics; - resetCache(): void; - getAllMetrics(): Array; - } - - interface CirctuiBreakerConfig { - circuitBreakerSleepWindowInMilliseconds: number, - commandKey: string, - circuitBreakerErrorThresholdPercentage: number, - circuitBreakerRequestVolumeThreshold: number, - commandGroup: string, - circuitBreakerForceClosed: boolean, - circuitBreakerForceOpened: boolean - } - - interface CircuitBreaker { - allowRequest(): boolean; - allowSingleTest(): boolean; - isOpen(): boolean; - markSuccess(): void; - } - - interface CircuitFactory { - getOrCreate(config: CirctuiBreakerConfig): CircuitBreaker; - getCache(): Array; - resetCache(): void; - } - - interface HystrixSSEStream { - toObservable(): Rx.Observable - } +export interface HystrixProperties { + "hystrix.force.circuit.open"?: boolean, + "hystrix.force.circuit.closed"?: boolean, + "hystrix.circuit.sleepWindowInMilliseconds"?: number, + "hystrix.circuit.errorThresholdPercentage"?: number, + "hystrix.circuit.volumeThreshold"?: number, + "hystrix.circuit.volumeThreshold.forceOverride"?: boolean, + "hystrix.circuit.volumeThreshold.override"?: number, + "hystrix.execution.timeoutInMilliseconds"?: number, + "hystrix.metrics.statistical.window.timeInMilliseconds"?: number, + "hystrix.metrics.statistical.window.bucketsNumber"?: number, + "hystrix.metrics.percentile.window.timeInMilliseconds"?: number, + "hystrix.metrics.percentile.window.bucketsNumber"?: number, + "hystrix.request.volume.rejectionThreshold"?: number } -declare var hystrixjs: { - commandFactory: HystrixJS.CommandFactory, - metricsFactory: HystrixJS.MetricsFactory, - circuitFactory: HystrixJS.CircuitFactory, - hystrixSSEStream: HystrixJS.HystrixSSEStream, - hystrixConfig: HystrixJS.HystrixConfig -}; -declare module "hystrixjs" { - export = hystrixjs; +export interface HystrixConfig { + metricsPercentileWindowBuckets(): number; + circuitBreakerForceClosed(): boolean; + circuitBreakerForceOpened(): boolean; + circuitBreakerSleepWindowInMilliseconds(): number; + circuitBreakerErrorThresholdPercentage(): number; + circuitBreakerRequestVolumeThreshold(): number; + circuitBreakerRequestVolumeThresholdForceOverride(): boolean; + circuitBreakerRequestVolumeThresholdOverride(): number; + executionTimeoutInMilliseconds(): number; + metricsStatisticalWindowBuckets(): number; + metricsStatisticalWindowInMilliseconds(): number; + metricsPercentileWindowInMilliseconds(): number; + metricsPercentileWindowBuckets(): number; + requestVolumeRejectionThreshold(): number; + resetProperties(): void; + init(properties: HystrixProperties): void; } + +export interface Command { + execute(...args: any[]): Q.Promise; +} + +export interface CommandBuilder { + circuitBreakerSleepWindowInMilliseconds(value: number): CommandBuilder; + errorHandler(value: (error: any) => boolean): CommandBuilder; + timeout(value: number): CommandBuilder; + circuitBreakerRequestVolumeThreshold(value: number): CommandBuilder; + requestVolumeRejectionThreshold(value: number): CommandBuilder; + circuitBreakerForceOpened(value: boolean): CommandBuilder; + circuitBreakerForceClosed(value: boolean): CommandBuilder; + statisticalWindowNumberOfBuckets(value: number): CommandBuilder; + statisticalWindowLength(value: number): CommandBuilder; + percentileWindowNumberOfBuckets(value: number): CommandBuilder; + percentileWindowLength(value: number): CommandBuilder; + circuitBreakerErrorThresholdPercentage(value: number): CommandBuilder; + run(value: (args: any) => Q.Promise): CommandBuilder; + fallbackTo(value: (...args: any[]) => Q.Promise): CommandBuilder; + context(value: any): CommandBuilder; + build(): Command; +} + +export interface CommandFactory { + getOrCreate(commandKey: string, commandGroup?: string): CommandBuilder; + resetCache(): void; +} + +export interface HealthCounts { + totalCount: number; + errorCount: number; + errorPercentage: number; +} + +export interface CommandMetrics { + markSuccess(): void; + markRejected(): void; + markFailure(): void; + markTimeout(): void; + markShortCircuited(): void; + incrementExecutionCount(): void; + decrementExecutionCount(): void; + getCurrentExecutionCount(): number; + addExecutionTime(value: number): void; + getRollingCount(type: any): number; + getExecutionTime(percentile: any): number; + getHealthCounts(): HealthCounts; + reset(): void; +} + +export interface MetricsProperties { + commandKey: string, + commandGroup: string, + statisticalWindowTimeInMilliSeconds?: number, + statisticalWindowNumberOfBuckets?: number, + percentileWindowTimeInMilliSeconds?: number, + percentileWindowNumberOfBuckets?: number +} + +export interface MetricsFactory { + getOrCreate(config: MetricsProperties): CommandMetrics; + resetCache(): void; + getAllMetrics(): Array; +} + +export interface CirctuiBreakerConfig { + circuitBreakerSleepWindowInMilliseconds: number, + commandKey: string, + circuitBreakerErrorThresholdPercentage: number, + circuitBreakerRequestVolumeThreshold: number, + commandGroup: string, + circuitBreakerForceClosed: boolean, + circuitBreakerForceOpened: boolean +} + +export interface CircuitBreaker { + allowRequest(): boolean; + allowSingleTest(): boolean; + isOpen(): boolean; + markSuccess(): void; +} + +export interface CircuitFactory { + getOrCreate(config: CirctuiBreakerConfig): CircuitBreaker; + getCache(): Array; + resetCache(): void; +} + +export interface HystrixSSEStream { + toObservable(): Rx.Observable +} + +export var commandFactory: CommandFactory; +export var metricsFactory: MetricsFactory; +export var circuitFactory: CircuitFactory; +export var hystrixSSEStream: HystrixSSEStream; +export var hystrixConfig: HystrixConfig; \ No newline at end of file diff --git a/hystrixjs/tsconfig.json b/hystrixjs/tsconfig.json index c23c0c6875..e1cb1a7c4d 100644 --- a/hystrixjs/tsconfig.json +++ b/hystrixjs/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/microsoft-sdk-soap/index.d.ts b/microsoft-sdk-soap/index.d.ts index 9effce35ad..de1c43db12 100644 --- a/microsoft-sdk-soap/index.d.ts +++ b/microsoft-sdk-soap/index.d.ts @@ -3,2968 +3,2869 @@ // Definitions by: Markus Mauch // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - -declare namespace Sdk -{ - interface IEntityView - { - attributes: AttributeCollection; - entityState: EntityState; - id: string; - logicalName: string; - relatedEntities: RelatedEntityCollection; - } - - interface IEntityCollectionView - { - entityName: string; - entities: Array; - minActiveRowVersion: string; - moreRecords: boolean; - pagingCookie: string; - totalRecordCount: number; - totalRecordCountLimitExceeded: boolean; - } - - interface IEntityReferenceView - { - Id: string; - Type: string; - Name: string; - } - - interface IEntityReferenceCollectionView extends Array - { - } - - class Q - { - /** - * Creates a link between records. - * @param entityName The logical name of the entity that is specified in the entityId parameter. - * @param entityId The ID of the record to which the related records are associated. - * @param relationship The name of the relationship to be used to create the link. - * @param relatedEntities A collection of Sdk.EntityReference objects to be associated. - */ - static associate( entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection ): Q.Promise; - /** - * Creates an entity record and returns a string representation of the GUID value that is the Id of the created entity. - * @param entity An entity instance. - */ - static create( entity: Sdk.Entity ): Q.Promise; - - /** - * Deletes an entity record - * @param entityName The LogicalName of the entity to delete. - * @param id An ID of the record to delete. - */ - static del( entityName: string, id: string ): Q.Promise; - - /** - * Removes a link between records. - * @param entityName The logical name of the entity that is specified in the entityId parameter. - * @param entityId The ID of the record to which the related records are disassociated. - * @param relationship The name of the relationship to be used to remove the link. - * @param relatedEntities A collection of Sdk.EntityReference objects to be disassociated. - */ - static disassociate( entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection ): Q.Promise; - - /** - * Executes a SOAP Request using the SOAPAction Execute. - * @param request A request object. - */ - static execute( request: Sdk.OrganizationRequest ): Q.Promise; - - /** - * Retrieves an entity instance. - * @param entityName The logical name of the entity to retrieve. - * @param id The id of the entity to retrieve. - * @param columnSet The columns of the entities to retrieve. - */ - static retrieve( entityName: string, id: string, columnSet: Sdk.ColumnSet ): Q.Promise; - - /** - * Retrieves the results of a query - * @param query An Sdk.Query.QueryByAttribute query. - */ - static retrieveMultiple( query: Sdk.Query.QueryByAttribute ): Q.Promise; - - /** - * Retrieves the results of a query - * @param query An Sdk.Query.QueryExpression query. - */ - static retrieveMultiple( query: Sdk.Query.QueryExpression ): Q.Promise; - - /** - * Retrieves the results of a query - * @param query An Sdk.Query.FetchExpression query. - */ - static retrieveMultiple( query: Sdk.Query.FetchExpression ): Q.Promise; - - /** - * Updates an entity instance. - * @param entity An entity instance to update. - */ - static update( entity: Entity ): Q.Promise; - } - - class ColumnSet - { - /** - * Specifies the attributes for which non- null values are returned from a query. - * @param columns Comma separated string values for attribute logical names. - */ - constructor( ...columns: string[] ); - - /** - * Specifies the attributes for which non- null values are returned from a query. - * @param columns An array of string values. - */ - constructor( columns: string[] ); - - /** - * Specifies the attributes for which non- null values are returned from a query. - * @param allColumns If Boolean true value is passed as the first parameter all columns will be included. (Not recommended for production code). - */ - constructor( allColumns: boolean ); - - /** - * Gets the collection of column names. - * @returns The collection of column names. - */ - getColumns(): Sdk.Collection; - - /** - * Adds a column to the collection. - * @param column The logical name of the attribute to add. - */ - addColumn( column: string ): void; - - /** - * Adds a string array of column names. - * @param columns A string array of column names. - */ - addColumns( columns: Array ): void; - - /** - * Sets the AllColumns property. - * @params allColumns A boolean value. - */ - setAllColumns( allColumns: boolean ): void; - - /** - * Whether all columns will be returned. - */ - getAllColumns(): boolean; - - /** - * Gets the number of columns. - */ - getCount(): number; - - - /// prototype methods - - /** - * Removes a column from the ColumnSet. - * @param columnName The logical name of an attribute to be removed from the ColumnSet. - * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false - */ - removeColumn( columnName: string, errorIfNotFound?: boolean ): void; - - /** - * The XML node with "" as the root element. - */ - toXml(): string; - - /** - * XML nodes for columnSet properties. - */ - toValueXml(): string; - } - - class ValueType - { - } - - class Collection - { - /** - * A Collection for a specified type. - * @param type The function that specifies the type. - * @param items An array of items to add to the collection. - */ - constructor( type: T, items?: Array ); - - /** - * Gets the type defined for the collection. - */ - getType(): T; - - /** - * Adds an item to the collection. - * @param item An item to add to the collection. - */ - add( item: T ): void; - - /** - * Adds an array of objects to the collection. - * @param items An array of items to add to the collection. - */ - addRange( items: any[] ): void; - - /** - * Removes all items from the collection. - */ - clear(): void; - - /** - * Returns whether an object exists within the collection. - * @param item The item to search in the collection. - */ - contains( item: T ): boolean; - - /** - * Returns whether an object exists within the collection. - * @param predicate A comparer function which is invoked for each item of the collection. - */ - contains( predicate: ( item: T ) => boolean ): boolean; - - /** - * Returns an Sdk.Collection that contains all the items of this collection that satisfy the specified predicate function. - * @param predicate A predicate function that takes a collection item as argument and returns a boolean. - */ - select( predicate: ( item: T ) => boolean ): Collection; - - /** - * Applies the action contained within a delegate function. - * @param fn Delegate function with parameters for item and index. - */ - forEach( fn: ( item: T, index: number ) => any ): void; - - /** - * Gets the item in the collection at the specified index. - * @param index The index of the item to return. - */ - getByIndex( index: number ): T; - - /** - * Removes an item from the collection. - * @param item A reference to the item to be removed. - */ - remove( item: T ): void; - - /** - * Gets a copy of the array of items in the collection. - */ - toArray(): Array; - - /** - * Returns the number of items in the collection. - */ - getCount(): number; - } - - class EntityCollection - { - /** - * Contains a collection of entity instances. - * @param entities Initializes a new instance of the EntityCollection class setting the Sdk.Collection of Sdk.Entity objects. - */ - constructor( entities: Sdk.Collection ); - - /** - * Adds an entity to the collection. - * @param entity - */ - addEntity( entity: Sdk.Entity ): void; - - /** - * Gets the collection of entities. - */ - getEntities(): Sdk.Collection; - - /** - * Gets an entity in the collection. - * @param index The index of the entity in the collection. - */ - getEntity( index: number ): Sdk.Entity; - - /** - * Gets an entity in the collection. - * @param id The id of the entity in the collection. - */ - getEntity( id: Sdk.Guid ): Sdk.Entity; - - /** - * Sets an item in the collection. - * @param index The index of the entity in the collection. - * @param value The Sdk.Entity value to set. - */ - setEntity( index: number, value: Sdk.Entity ): void; - - /** - * Sets an item in the collection. - * @param id The Sdk.Guid id of the entity in the collection. - * @param value The Sdk.Entity value to set. - */ - setEntity( id: Sdk.Guid, value: Sdk.Entity ): void; - - /** - * Gets the logical name of the entity. - */ - getEntityName(): string; - - /** - * Sets the logical name of the entity. - * @param name The logical name of the entity. - */ - setEntityName( name: string ): void; - - /** - * Gets the lowest active row version value. - */ - getMinActiveRowVersion(): string; - - /** - * Sets the lowest active row version value. - * @param minActiveRowVersion The lowest active row version value. - */ - setMinActiveRowVersion( minActiveRowVersion: string ): void; - - /** - * Gets whether there are more records available. - */ - getMoreRecords(): boolean; - - /** - * Sets whether there are more records available. - * @param moreRecords Whether there are more records available. - */ - setMoreRecords( moreRecords: boolean ): void; - - /** - * Gets the current paging information. - */ - getPagingCookie(): string; - - /** - * Sets the current paging information. - * @param pagingCookie The current paging information. - */ - setPagingCookie( pagingCookie: string ): void; - - /** - * Gets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. - */ - getTotalRecordCount(): number; - - /** - * Sets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. - * @param totalRecordCount The total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. - */ - setTotalRecordCount( totalRecordCount: number ): void; - - /** - * Gets whether the results of the query exceeds the total record count. - */ - getTotalRecordCountLimitExceeded(): boolean; - - /** - * Sets whether the results of the query exceeds the total record count. - * @param totalRecordCountLimitExceeded Whether the results of the query exceeds the total record count. - */ - setTotalRecordCountLimitExceeded( totalRecordCountLimitExceeded: boolean ): void; - - /** - * XML definition of an the child nodes of an entity. - */ - toValueXml(): string; - - /** - * Returns a view of the entity collection - */ - view(): IEntityCollectionView; - } - - class EntityReferenceCollection - { - /** - * Contains a collection of EntityReference instances. - * @param entityReferences Initializes a new instance of the EntityReferenceCollection class setting the Sdk.Collection of Sdk.EntityReference objects. - */ - constructor( entityReferences?: Sdk.Collection ); - - /** - * Gets the collection of entity references. - */ - getEntityReferences(): Sdk.Collection; - - /** - * Sets the collection of entity references. - * @param entityReferences The entity references - */ - setEntityReferences( entityReferences: Sdk.Collection ): void; - - - /// prototype methods - - /** - * Removes an entity reference to the collection. - * @param entityReference The entity reference to remove. - */ - remove( entityReference: Sdk.EntityReference ): void; - - /** - * Returns a view of the data in an entity reference collection instance. - */ - view(): IEntityReferenceCollectionView; - - /** - * Returns the values of serialized entity reference collection as XML nodes. - */ - toValueXml(): string; - } - - class RelatedEntityCollection extends EntityCollection - { - } - - class AttributeCollection extends Collection - { - constructor(); - - /** - * Adds an attribute to the Attribute Collection. - * @param attribute The attribute to add. - * @param isChanged Override the the attribute IsChanged value. - */ - add( attribute: AttributeBase, isChanged?: boolean ): void; - - /** - * Gets the attributes in the collection. - */ - getAttributes(): Collection; - - - /// prototype methods - - /** - * Allows for a delegate function to be applied to each attribute in the collection. - * @param fm The function to be applied. Function should have parameters for the attribute and the iterator i.e.: '(att,i)' - */ - forEach( fn: ( attribute: AttributeBase, index: number ) => any ): void; - - /** - * Returns all attributes in the collection. - */ - get(): Sdk.Collection; - - /** - * Returns the attribute with matching name. - * @param attribuetName - */ - get( attribuetName: string ): AttributeBase; - - /** - * Returns the attribute with matching index. - * @param attribuetName - */ - get( index: number ): AttributeBase; - - /** - * Gets an attribute at a given index. - * @param index The index. - */ - getAttributeByIndex( index: number ): AttributeBase; - - /** - * Gets an attribute with a given name. - * @param name The Logical name of the attribute. - */ - getAttributeByName( name: string ): AttributeBase; - - /** - * Gets an array of the names of attributes in a collection. - */ - getNames(): Array; - /** - * The XML for an attribute collection. - */ - toXml( action: string ): string; - } - - class FormattedValueCollection - { - } - - class RelatedEntitiesCollection - { - } - - class AttributeBase - { - /** - * Gets whether the value of the attribute has changed. - */ - getIsChanged(): boolean; - - /** - * Gets the logical name of the attribute. - */ - getName(): string; - - /** - * Gets the value type of the attribute. - */ - getType(): Sdk.ValueType; - - /** - * Gets the value of the attribute. - * The type of value depends on the type of attribute. - */ - getValue(): any; - - /** - * Whether the value of the attribute is set. - */ - isValueSet(): boolean; - - /** - * Sets whether the value of the attribute has changed. - * @param isChanged Whether the value of the attribute has changed. - */ - setIsChanged( isChanged: boolean ): void; - - /** - * Sets the name of the attribute - * @param name The name of the attribute. - */ - setName( name: string ): void; - - /** - * For internal use only. - * @param type The type of the attribute. - */ - setType( type: Sdk.ValueType ): void; - - /** - * Sets the general value of the attribute - * @param name The value of the attribute. - */ - setValue( value: any ): void; - - /// prototype methods - /** - * XML node for Attribute. - */ - toXml( action: string ): string; - } - - class Boolean extends AttributeBase - { - /** - * A Boolean Attribute. - * @param name The logical name of the attribute . - * @param value The value of the managed property. - */ - constructor( name: string, value?: boolean ) - - /** - * Gets the value of a Boolean attribute. - */ - getValue(): boolean; - - /** - * Sets the value of a Boolean attribute. - * @param value - */ - setValue( value: boolean ): void; - } - - class DateTime extends AttributeBase - { - /** - * A DateTime Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: Date ); - - /** - * Gets the value of a DateTime attribute. - */ - getValue(): Date; - - /** - * Sets the value of a DateTime attribute. - * @param value The value to set. - */ - setValue( value: Date ): void; - } - - class Decimal extends AttributeBase - { - /** - * A Decimal Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Decimal attribute. - */ - getValue(): number; - - /** - * Sets the value of a Decimal attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Double - { - /** - * A Double Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Double attribute. - */ - getValue(): number; - - /** - * Sets the value of a Double attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Guid extends AttributeBase - { - /** - * A Guid Attribute. - * @param name The logical name of the attribute. - * @param value" The value of the attribute - */ - constructor( name: string, value?: string ); - - /** - * Gets the value of a Guid attribute. - */ - getValue(): string; - - /** - * Sets the value of a Guid attribute. - * @param value The value to set. - */ - setValue( value: string ): void; - } - - class Int extends AttributeBase - { - /** - * An Integer Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of an Integer attribute. - */ - getValue(): number; - - /** - * Sets the value of an Integer attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Long extends AttributeBase - { - /** - * A Long Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Long attribute. - */ - getValue(): number; - - /** - * Sets the value of a Long attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class Lookup extends AttributeBase - { - /** - * A Lookup Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: EntityReference ); - - /** - * Gets the value of a Lookup attribute. - */ - getValue(): EntityReference; - - /** - * Sets the value of a Lookup attribute. - * @param value The value to set. - */ - setValue( value: EntityReference ): void; - } - - class Money extends AttributeBase - { - /** - * A Money Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a Money attribute. - */ - getValue(): number; - - /** - * Sets the value of a Money attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class OptionSet extends AttributeBase - { - /** - * An OptionSet Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: number ); - - /** - * Gets the value of a OptionSet attribute. - */ - getValue(): number; - - /** - * Sets the value of an OptionSet attribute. - * @param value The value to set. - */ - setValue( value: number ): void; - } - - class PartyList extends AttributeBase - { - /** - * A PartyList Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: EntityCollection ); - - /** - * Gets the value of a PartyList attribute. - */ - getValue(): EntityCollection; - - /** - * Sets the value of a PartyList attribute. - * @param value The value to set. - */ - setValue( value: EntityCollection ): void; - } - - class String extends AttributeBase - { - /** - * A String Attribute. - * @param name The logical name of the attribute. - * @param value The value of the attribute. - */ - constructor( name: string, value?: string ); - - /** - * Gets the value of a String attribute. - */ - getValue(): string; - - /** - * Sets the value of a String attribute. - * @param value The value to set. - */ - setValue( value: string ): void; - } - - class EntityState - { - } - - class Entity - { - /** - * Represents an instance of an entity (a record). - * @param type The logical name of the entity. - */ - constructor( type: string ); - - /** - * Gets the collection of attributes for the entity. - */ - getAttributes(): Sdk.AttributeCollection; - - /** - * Gets the collection of attributes for the entity. - * @param attributeName The attribute with matching name is returned. - */ - getAttributes( attributeName: string ): Sdk.AttributeBase; - - /** - * Gets the collection of attributes for the entity. - * @param index The attribute with matching index is returned. - */ - getAttributes( index: number ): Sdk.AttributeBase; - - /** - * Checks whether the entity has an attribute that satisfies the specified predicate. - * @param A comparer function that takes an Sdk.AttributeBase as argument and returns a boolean. - */ - containsAttribute( predicate: ( attribute: Sdk.AttributeBase ) => boolean ): boolean; - - /** - * Checks whether the entity has an attribute with the specified name. - * @param The name of the attribute. - */ - containsAttribute( name: string ): boolean; - - /** - * Sets the collection of attributes for the entity. - * @param attributes The collection of attributes for the entity. - */ - setAttributes( attributes: Sdk.AttributeCollection ): void; - - /** - * Gets the state of the entity. - */ - getEntityState(): Sdk.EntityState; - - /** - * Sets the state of the entity. - * @param state The state of the entity. - */ - setEntityState( state: Sdk.EntityState ): void; - - /** - * Gets the collection of formatted values for the entity attributes. - */ - getFormattedValues(): Sdk.FormattedValueCollection; - - /** - * Sets the collection of formatted values for the entity attributes. - * @param values" The collection of formatted values for the entity attributes. - */ - setFormattedValues( values: Sdk.FormattedValueCollection ): void; - - /** - * Gets the Id of the record represented by this entity instance. - */ - getId(): string; - - /** - * Sets the Id of the record represented by this entity instance. - * @param id The Id of the record represented by this entity instance. - * @param override Allow setting the Id property, for example when creating a new record from an existing one. - */ - setId( id: string, override?: boolean ): void; - - /** - * Gets the logical name of the entity. - */ - getType(): string; - - /** - * Sets the logical name of the entity. - * @param type The logical name of the entity. - */ - setType( type: string ): void; - - /** - * Gets a collection of related entities. - */ - getRelatedEntities(): Sdk.RelatedEntitiesCollection; - - /** - * Sets a collection of related entities. - * @param relatedEntities A collection of related entities. - */ - setRelatedEntities( relatedEntities: Sdk.RelatedEntitiesCollection ): void; - - /** - * Adds an attribute with an optional value to a newly instantiated Sdk.Entity - * @param attribute The attribute to add - * @param isChanged Whether the attribute should be considered changed, the default is true. - */ - addAttribute( attribute: Sdk.AttributeBase, isChanged?: boolean ): void; - - /** - * Adds an entity to the related entities. - * @param relationshipSchemaName The relationship SchemaName. - * @param entity The entity to add. - */ - addRelatedEntity( relationshipSchemaName: string, entity: Sdk.Entity ): void; - - /** - * Gets the value to indicate whether data for the entity has changed. - */ - getIsChanged(): boolean; - - /** - * Sets the value to indicate whether data for the entity has changed. - * @param isChanged The value to indicate whether data for the entity has changed. - */ - setIsChanged( isChanged: boolean ): void; - - /** - * Gets the value of the specified attribute. - * @param logicalName The logical name of the attribute. - */ - getValue( logicalName: string ): any; - - /** - * Generates properties for the entity based on metadata. - */ - initializeSubClass( metadata: Sdk.Mdq.IEntityMetadata ): void; - - /** - * Sets the value of the specified attribute. - * @param logicalName The logical name of the attribute. - * @param value The value for the attribute. Simple JavaScript types may be used for most attribute types. Sdk.EntityReference, Sdk.EntityCollection, and Sdk.BooleanManagedPropertyValue cannot use simple JavaScript types. - */ - setValue( logicalName: string, value: Object ): void; - - /** - * Generates an entity reference. - */ - toEntityReference(): Sdk.EntityReference; - - /** - * Overrides the default toString method. - */ - toString(): string; - - /** - * XML definition of an the child nodes of an entity. - * @param action - */ - toValueXml( action: string ): string; - - /** - * XML definition of an entity where the root node is . - */ - toXml( action: string ): string; - - /** - * Returns a view of the data in an entity instance - */ - view(): IEntityView; - } - - class EntityReference - { - /** - * Identifies a record. - * @param logicalName The logical name of the entity. - * @param id The id of the record. - * @param name The value of the primary attribute of the entity instance. This property can contain a value or null. This property is not automatically populated unless the EntityReference object has been retrieved from the server. - */ - constructor( logicalName: string, id: string, name?: string ); - - /** - * Gets the logicalName representing the type of referenced entity. - */ - getType(): string; - - /** - * Gets the Id value of the referenced entity. - */ - getId(): string; - - /** - * Gets the primary attribute value of the referenced entity. - */ - getName(): string; - - /** - * Sets the logicalName representing the type of referenced entity. - * @param type The logicalName representing the type of referenced entity. - */ - setType( type: string ): void; - - /** - * Sets the Id value of the entity. - * @param id The Id value of the entity. - */ - setId( id: string ): void; - - /** - * Sets the primary attribute value of the referenced entity. - * @param name The primary attribute value of the referenced entity. - */ - setName( name: string ): void; - - - /// prototype methods - - /** - * Returns a serialized entity reference where the root element is . - */ - toXml(): string; - - /** - * Returns the values of serialized entity reference as XML nodes. - */ - toValueXml(): string; - - /** - * Returns a view of the data in an EntityReference - */ - view(): IEntityReferenceView; - } - - class OrganizationRequest - { - /** - * Sets the request XML. - * @param xml The request XML. - */ - setRequestXml( xml: string ): void; - - /** - * Gets the request XML. - */ - getRequestXml(): string; - - /** - * Sets the response type. - * @param type A class that inherits from Sdk.OrganizationResponse. - */ - setResponseType( type: OrganizationResponse ): void; - - /** - * Gets the response type. - */ - getResponseType(): OrganizationResponse; - } - - class OrganizationResponse - { - } - - /** - * Contains the data that is needed to convert a query in FetchXML to a QueryExpression. - * @param fetchXml Sets the query to convert. - */ - class FetchXmlToQueryExpressionRequest extends Sdk.OrganizationRequest - { - constructor( fetchXml: string ); - - /** - * Sets the query to convert. - * @param The query to convert. - */ - setFetchXml( value: string ): void; - } - - /** - * Response to FetchXmlToQueryExpressionRequest. - * @param responseXml The response XML to the FetchXmlToQueryExpressionRequest. - */ - class FetchXmlToQueryExpressionResponse extends Sdk.OrganizationResponse - { - constructor( responseXml: string ); - - /** - * Gets the results of the query conversion. - */ - public getQuery(): Query.QueryExpression; - } - - /** - * Contains the data that is needed to convert a query, which is represented as a QueryExpression class, to its equivalent query, which is represented as FetchXML. - * @param query The query. - */ - class QueryExpressionToFetchXmlRequest extends Sdk.OrganizationRequest - { - constructor( query: Sdk.Query.QueryBase ); - - /** - * Sets the query to convert. +import * as Q from "q"; + +declare global { + namespace Sdk { + interface IEntityView { + attributes: AttributeCollection; + entityState: EntityState; + id: string; + logicalName: string; + relatedEntities: RelatedEntityCollection; + } + + interface IEntityCollectionView { + entityName: string; + entities: Array; + minActiveRowVersion: string; + moreRecords: boolean; + pagingCookie: string; + totalRecordCount: number; + totalRecordCountLimitExceeded: boolean; + } + + interface IEntityReferenceView { + Id: string; + Type: string; + Name: string; + } + + interface IEntityReferenceCollectionView extends Array { + } + + class Q { + /** + * Creates a link between records. + * @param entityName The logical name of the entity that is specified in the entityId parameter. + * @param entityId The ID of the record to which the related records are associated. + * @param relationship The name of the relationship to be used to create the link. + * @param relatedEntities A collection of Sdk.EntityReference objects to be associated. + */ + static associate(entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection): Q.Promise; + /** + * Creates an entity record and returns a string representation of the GUID value that is the Id of the created entity. + * @param entity An entity instance. + */ + static create(entity: Sdk.Entity): Q.Promise; + + /** + * Deletes an entity record + * @param entityName The LogicalName of the entity to delete. + * @param id An ID of the record to delete. + */ + static del(entityName: string, id: string): Q.Promise; + + /** + * Removes a link between records. + * @param entityName The logical name of the entity that is specified in the entityId parameter. + * @param entityId The ID of the record to which the related records are disassociated. + * @param relationship The name of the relationship to be used to remove the link. + * @param relatedEntities A collection of Sdk.EntityReference objects to be disassociated. + */ + static disassociate(entityName: string, entityId: string, relationship: string, relatedEntities: Sdk.Collection): Q.Promise; + + /** + * Executes a SOAP Request using the SOAPAction Execute. + * @param request A request object. + */ + static execute(request: Sdk.OrganizationRequest): Q.Promise; + + /** + * Retrieves an entity instance. + * @param entityName The logical name of the entity to retrieve. + * @param id The id of the entity to retrieve. + * @param columnSet The columns of the entities to retrieve. + */ + static retrieve(entityName: string, id: string, columnSet: Sdk.ColumnSet): Q.Promise; + + /** + * Retrieves the results of a query + * @param query An Sdk.Query.QueryByAttribute query. + */ + static retrieveMultiple(query: Sdk.Query.QueryByAttribute): Q.Promise; + + /** + * Retrieves the results of a query + * @param query An Sdk.Query.QueryExpression query. + */ + static retrieveMultiple(query: Sdk.Query.QueryExpression): Q.Promise; + + /** + * Retrieves the results of a query + * @param query An Sdk.Query.FetchExpression query. + */ + static retrieveMultiple(query: Sdk.Query.FetchExpression): Q.Promise; + + /** + * Updates an entity instance. + * @param entity An entity instance to update. + */ + static update(entity: Entity): Q.Promise; + } + + class ColumnSet { + /** + * Specifies the attributes for which non- null values are returned from a query. + * @param columns Comma separated string values for attribute logical names. + */ + constructor(...columns: string[]); + + /** + * Specifies the attributes for which non- null values are returned from a query. + * @param columns An array of string values. + */ + constructor(columns: string[]); + + /** + * Specifies the attributes for which non- null values are returned from a query. + * @param allColumns If Boolean true value is passed as the first parameter all columns will be included. (Not recommended for production code). + */ + constructor(allColumns: boolean); + + /** + * Gets the collection of column names. + * @returns The collection of column names. + */ + getColumns(): Sdk.Collection; + + /** + * Adds a column to the collection. + * @param column The logical name of the attribute to add. + */ + addColumn(column: string): void; + + /** + * Adds a string array of column names. + * @param columns A string array of column names. + */ + addColumns(columns: Array): void; + + /** + * Sets the AllColumns property. + * @params allColumns A boolean value. + */ + setAllColumns(allColumns: boolean): void; + + /** + * Whether all columns will be returned. + */ + getAllColumns(): boolean; + + /** + * Gets the number of columns. + */ + getCount(): number; + + + /// prototype methods + + /** + * Removes a column from the ColumnSet. + * @param columnName The logical name of an attribute to be removed from the ColumnSet. + * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false + */ + removeColumn(columnName: string, errorIfNotFound?: boolean): void; + + /** + * The XML node with "" as the root element. + */ + toXml(): string; + + /** + * XML nodes for columnSet properties. + */ + toValueXml(): string; + } + + class ValueType { + } + + class Collection + { + /** + * A Collection for a specified type. + * @param type The function that specifies the type. + * @param items An array of items to add to the collection. + */ + constructor(type: T, items?: Array); + + /** + * Gets the type defined for the collection. + */ + getType(): T; + + /** + * Adds an item to the collection. + * @param item An item to add to the collection. + */ + add(item: T): void; + + /** + * Adds an array of objects to the collection. + * @param items An array of items to add to the collection. + */ + addRange(items: any[]): void; + + /** + * Removes all items from the collection. + */ + clear(): void; + + /** + * Returns whether an object exists within the collection. + * @param item The item to search in the collection. + */ + contains(item: T): boolean; + + /** + * Returns whether an object exists within the collection. + * @param predicate A comparer function which is invoked for each item of the collection. + */ + contains(predicate: (item: T) => boolean): boolean; + + /** + * Returns an Sdk.Collection that contains all the items of this collection that satisfy the specified predicate function. + * @param predicate A predicate function that takes a collection item as argument and returns a boolean. + */ + select(predicate: (item: T) => boolean): Collection; + + /** + * Applies the action contained within a delegate function. + * @param fn Delegate function with parameters for item and index. + */ + forEach(fn: (item: T, index: number) => any): void; + + /** + * Gets the item in the collection at the specified index. + * @param index The index of the item to return. + */ + getByIndex(index: number): T; + + /** + * Removes an item from the collection. + * @param item A reference to the item to be removed. + */ + remove(item: T): void; + + /** + * Gets a copy of the array of items in the collection. + */ + toArray(): Array; + + /** + * Returns the number of items in the collection. + */ + getCount(): number; + } + + class EntityCollection { + /** + * Contains a collection of entity instances. + * @param entities Initializes a new instance of the EntityCollection class setting the Sdk.Collection of Sdk.Entity objects. + */ + constructor(entities: Sdk.Collection); + + /** + * Adds an entity to the collection. + * @param entity + */ + addEntity(entity: Sdk.Entity): void; + + /** + * Gets the collection of entities. + */ + getEntities(): Sdk.Collection; + + /** + * Gets an entity in the collection. + * @param index The index of the entity in the collection. + */ + getEntity(index: number): Sdk.Entity; + + /** + * Gets an entity in the collection. + * @param id The id of the entity in the collection. + */ + getEntity(id: Sdk.Guid): Sdk.Entity; + + /** + * Sets an item in the collection. + * @param index The index of the entity in the collection. + * @param value The Sdk.Entity value to set. + */ + setEntity(index: number, value: Sdk.Entity): void; + + /** + * Sets an item in the collection. + * @param id The Sdk.Guid id of the entity in the collection. + * @param value The Sdk.Entity value to set. + */ + setEntity(id: Sdk.Guid, value: Sdk.Entity): void; + + /** + * Gets the logical name of the entity. + */ + getEntityName(): string; + + /** + * Sets the logical name of the entity. + * @param name The logical name of the entity. + */ + setEntityName(name: string): void; + + /** + * Gets the lowest active row version value. + */ + getMinActiveRowVersion(): string; + + /** + * Sets the lowest active row version value. + * @param minActiveRowVersion The lowest active row version value. + */ + setMinActiveRowVersion(minActiveRowVersion: string): void; + + /** + * Gets whether there are more records available. + */ + getMoreRecords(): boolean; + + /** + * Sets whether there are more records available. + * @param moreRecords Whether there are more records available. + */ + setMoreRecords(moreRecords: boolean): void; + + /** + * Gets the current paging information. + */ + getPagingCookie(): string; + + /** + * Sets the current paging information. + * @param pagingCookie The current paging information. + */ + setPagingCookie(pagingCookie: string): void; + + /** + * Gets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. + */ + getTotalRecordCount(): number; + + /** + * Sets the total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. + * @param totalRecordCount The total number of records in the collection if ReturnTotalRecordCount was true when the query was executed. + */ + setTotalRecordCount(totalRecordCount: number): void; + + /** + * Gets whether the results of the query exceeds the total record count. + */ + getTotalRecordCountLimitExceeded(): boolean; + + /** + * Sets whether the results of the query exceeds the total record count. + * @param totalRecordCountLimitExceeded Whether the results of the query exceeds the total record count. + */ + setTotalRecordCountLimitExceeded(totalRecordCountLimitExceeded: boolean): void; + + /** + * XML definition of an the child nodes of an entity. + */ + toValueXml(): string; + + /** + * Returns a view of the entity collection + */ + view(): IEntityCollectionView; + } + + class EntityReferenceCollection { + /** + * Contains a collection of EntityReference instances. + * @param entityReferences Initializes a new instance of the EntityReferenceCollection class setting the Sdk.Collection of Sdk.EntityReference objects. + */ + constructor(entityReferences?: Sdk.Collection); + + /** + * Gets the collection of entity references. + */ + getEntityReferences(): Sdk.Collection; + + /** + * Sets the collection of entity references. + * @param entityReferences The entity references + */ + setEntityReferences(entityReferences: Sdk.Collection): void; + + + /// prototype methods + + /** + * Removes an entity reference to the collection. + * @param entityReference The entity reference to remove. + */ + remove(entityReference: Sdk.EntityReference): void; + + /** + * Returns a view of the data in an entity reference collection instance. + */ + view(): IEntityReferenceCollectionView; + + /** + * Returns the values of serialized entity reference collection as XML nodes. + */ + toValueXml(): string; + } + + class RelatedEntityCollection extends EntityCollection { + } + + class AttributeCollection extends Collection + { + constructor(); + + /** + * Adds an attribute to the Attribute Collection. + * @param attribute The attribute to add. + * @param isChanged Override the the attribute IsChanged value. + */ + add(attribute: AttributeBase, isChanged?: boolean): void; + + /** + * Gets the attributes in the collection. + */ + getAttributes(): Collection; + + + /// prototype methods + + /** + * Allows for a delegate function to be applied to each attribute in the collection. + * @param fm The function to be applied. Function should have parameters for the attribute and the iterator i.e.: '(att,i)' + */ + forEach(fn: (attribute: AttributeBase, index: number) => any): void; + + /** + * Returns all attributes in the collection. + */ + get(): Sdk.Collection; + + /** + * Returns the attribute with matching name. + * @param attribuetName + */ + get(attribuetName: string): AttributeBase; + + /** + * Returns the attribute with matching index. + * @param attribuetName + */ + get(index: number): AttributeBase; + + /** + * Gets an attribute at a given index. + * @param index The index. + */ + getAttributeByIndex(index: number): AttributeBase; + + /** + * Gets an attribute with a given name. + * @param name The Logical name of the attribute. + */ + getAttributeByName(name: string): AttributeBase; + + /** + * Gets an array of the names of attributes in a collection. + */ + getNames(): Array; + /** + * The XML for an attribute collection. + */ + toXml(action: string): string; + } + + class FormattedValueCollection { + } + + class RelatedEntitiesCollection { + } + + class AttributeBase { + /** + * Gets whether the value of the attribute has changed. + */ + getIsChanged(): boolean; + + /** + * Gets the logical name of the attribute. + */ + getName(): string; + + /** + * Gets the value type of the attribute. + */ + getType(): Sdk.ValueType; + + /** + * Gets the value of the attribute. + * The type of value depends on the type of attribute. + */ + getValue(): any; + + /** + * Whether the value of the attribute is set. + */ + isValueSet(): boolean; + + /** + * Sets whether the value of the attribute has changed. + * @param isChanged Whether the value of the attribute has changed. + */ + setIsChanged(isChanged: boolean): void; + + /** + * Sets the name of the attribute + * @param name The name of the attribute. + */ + setName(name: string): void; + + /** + * For internal use only. + * @param type The type of the attribute. + */ + setType(type: Sdk.ValueType): void; + + /** + * Sets the general value of the attribute + * @param name The value of the attribute. + */ + setValue(value: any): void; + + /// prototype methods + /** + * XML node for Attribute. + */ + toXml(action: string): string; + } + + class Boolean extends AttributeBase { + /** + * A Boolean Attribute. + * @param name The logical name of the attribute . + * @param value The value of the managed property. + */ + constructor(name: string, value?: boolean) + + /** + * Gets the value of a Boolean attribute. + */ + getValue(): boolean; + + /** + * Sets the value of a Boolean attribute. + * @param value + */ + setValue(value: boolean): void; + } + + class DateTime extends AttributeBase { + /** + * A DateTime Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: Date); + + /** + * Gets the value of a DateTime attribute. + */ + getValue(): Date; + + /** + * Sets the value of a DateTime attribute. + * @param value The value to set. + */ + setValue(value: Date): void; + } + + class Decimal extends AttributeBase { + /** + * A Decimal Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Decimal attribute. + */ + getValue(): number; + + /** + * Sets the value of a Decimal attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Double { + /** + * A Double Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Double attribute. + */ + getValue(): number; + + /** + * Sets the value of a Double attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Guid extends AttributeBase { + /** + * A Guid Attribute. + * @param name The logical name of the attribute. + * @param value" The value of the attribute + */ + constructor(name: string, value?: string); + + /** + * Gets the value of a Guid attribute. + */ + getValue(): string; + + /** + * Sets the value of a Guid attribute. + * @param value The value to set. + */ + setValue(value: string): void; + } + + class Int extends AttributeBase { + /** + * An Integer Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of an Integer attribute. + */ + getValue(): number; + + /** + * Sets the value of an Integer attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Long extends AttributeBase { + /** + * A Long Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Long attribute. + */ + getValue(): number; + + /** + * Sets the value of a Long attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class Lookup extends AttributeBase { + /** + * A Lookup Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: EntityReference); + + /** + * Gets the value of a Lookup attribute. + */ + getValue(): EntityReference; + + /** + * Sets the value of a Lookup attribute. + * @param value The value to set. + */ + setValue(value: EntityReference): void; + } + + class Money extends AttributeBase { + /** + * A Money Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a Money attribute. + */ + getValue(): number; + + /** + * Sets the value of a Money attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class OptionSet extends AttributeBase { + /** + * An OptionSet Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: number); + + /** + * Gets the value of a OptionSet attribute. + */ + getValue(): number; + + /** + * Sets the value of an OptionSet attribute. + * @param value The value to set. + */ + setValue(value: number): void; + } + + class PartyList extends AttributeBase { + /** + * A PartyList Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: EntityCollection); + + /** + * Gets the value of a PartyList attribute. + */ + getValue(): EntityCollection; + + /** + * Sets the value of a PartyList attribute. + * @param value The value to set. + */ + setValue(value: EntityCollection): void; + } + + class String extends AttributeBase { + /** + * A String Attribute. + * @param name The logical name of the attribute. + * @param value The value of the attribute. + */ + constructor(name: string, value?: string); + + /** + * Gets the value of a String attribute. + */ + getValue(): string; + + /** + * Sets the value of a String attribute. + * @param value The value to set. + */ + setValue(value: string): void; + } + + class EntityState { + } + + class Entity { + /** + * Represents an instance of an entity (a record). + * @param type The logical name of the entity. + */ + constructor(type: string); + + /** + * Gets the collection of attributes for the entity. + */ + getAttributes(): Sdk.AttributeCollection; + + /** + * Gets the collection of attributes for the entity. + * @param attributeName The attribute with matching name is returned. + */ + getAttributes(attributeName: string): Sdk.AttributeBase; + + /** + * Gets the collection of attributes for the entity. + * @param index The attribute with matching index is returned. + */ + getAttributes(index: number): Sdk.AttributeBase; + + /** + * Checks whether the entity has an attribute that satisfies the specified predicate. + * @param A comparer function that takes an Sdk.AttributeBase as argument and returns a boolean. + */ + containsAttribute(predicate: (attribute: Sdk.AttributeBase) => boolean): boolean; + + /** + * Checks whether the entity has an attribute with the specified name. + * @param The name of the attribute. + */ + containsAttribute(name: string): boolean; + + /** + * Sets the collection of attributes for the entity. + * @param attributes The collection of attributes for the entity. + */ + setAttributes(attributes: Sdk.AttributeCollection): void; + + /** + * Gets the state of the entity. + */ + getEntityState(): Sdk.EntityState; + + /** + * Sets the state of the entity. + * @param state The state of the entity. + */ + setEntityState(state: Sdk.EntityState): void; + + /** + * Gets the collection of formatted values for the entity attributes. + */ + getFormattedValues(): Sdk.FormattedValueCollection; + + /** + * Sets the collection of formatted values for the entity attributes. + * @param values" The collection of formatted values for the entity attributes. + */ + setFormattedValues(values: Sdk.FormattedValueCollection): void; + + /** + * Gets the Id of the record represented by this entity instance. + */ + getId(): string; + + /** + * Sets the Id of the record represented by this entity instance. + * @param id The Id of the record represented by this entity instance. + * @param override Allow setting the Id property, for example when creating a new record from an existing one. + */ + setId(id: string, override?: boolean): void; + + /** + * Gets the logical name of the entity. + */ + getType(): string; + + /** + * Sets the logical name of the entity. + * @param type The logical name of the entity. + */ + setType(type: string): void; + + /** + * Gets a collection of related entities. + */ + getRelatedEntities(): Sdk.RelatedEntitiesCollection; + + /** + * Sets a collection of related entities. + * @param relatedEntities A collection of related entities. + */ + setRelatedEntities(relatedEntities: Sdk.RelatedEntitiesCollection): void; + + /** + * Adds an attribute with an optional value to a newly instantiated Sdk.Entity + * @param attribute The attribute to add + * @param isChanged Whether the attribute should be considered changed, the default is true. + */ + addAttribute(attribute: Sdk.AttributeBase, isChanged?: boolean): void; + + /** + * Adds an entity to the related entities. + * @param relationshipSchemaName The relationship SchemaName. + * @param entity The entity to add. + */ + addRelatedEntity(relationshipSchemaName: string, entity: Sdk.Entity): void; + + /** + * Gets the value to indicate whether data for the entity has changed. + */ + getIsChanged(): boolean; + + /** + * Sets the value to indicate whether data for the entity has changed. + * @param isChanged The value to indicate whether data for the entity has changed. + */ + setIsChanged(isChanged: boolean): void; + + /** + * Gets the value of the specified attribute. + * @param logicalName The logical name of the attribute. + */ + getValue(logicalName: string): any; + + /** + * Generates properties for the entity based on metadata. + */ + initializeSubClass(metadata: Sdk.Mdq.IEntityMetadata): void; + + /** + * Sets the value of the specified attribute. + * @param logicalName The logical name of the attribute. + * @param value The value for the attribute. Simple JavaScript types may be used for most attribute types. Sdk.EntityReference, Sdk.EntityCollection, and Sdk.BooleanManagedPropertyValue cannot use simple JavaScript types. + */ + setValue(logicalName: string, value: Object): void; + + /** + * Generates an entity reference. + */ + toEntityReference(): Sdk.EntityReference; + + /** + * Overrides the default toString method. + */ + toString(): string; + + /** + * XML definition of an the child nodes of an entity. + * @param action + */ + toValueXml(action: string): string; + + /** + * XML definition of an entity where the root node is . + */ + toXml(action: string): string; + + /** + * Returns a view of the data in an entity instance + */ + view(): IEntityView; + } + + class EntityReference { + /** + * Identifies a record. + * @param logicalName The logical name of the entity. + * @param id The id of the record. + * @param name The value of the primary attribute of the entity instance. This property can contain a value or null. This property is not automatically populated unless the EntityReference object has been retrieved from the server. + */ + constructor(logicalName: string, id: string, name?: string); + + /** + * Gets the logicalName representing the type of referenced entity. + */ + getType(): string; + + /** + * Gets the Id value of the referenced entity. + */ + getId(): string; + + /** + * Gets the primary attribute value of the referenced entity. + */ + getName(): string; + + /** + * Sets the logicalName representing the type of referenced entity. + * @param type The logicalName representing the type of referenced entity. + */ + setType(type: string): void; + + /** + * Sets the Id value of the entity. + * @param id The Id value of the entity. + */ + setId(id: string): void; + + /** + * Sets the primary attribute value of the referenced entity. + * @param name The primary attribute value of the referenced entity. + */ + setName(name: string): void; + + + /// prototype methods + + /** + * Returns a serialized entity reference where the root element is . + */ + toXml(): string; + + /** + * Returns the values of serialized entity reference as XML nodes. + */ + toValueXml(): string; + + /** + * Returns a view of the data in an EntityReference + */ + view(): IEntityReferenceView; + } + + class OrganizationRequest { + /** + * Sets the request XML. + * @param xml The request XML. + */ + setRequestXml(xml: string): void; + + /** + * Gets the request XML. + */ + getRequestXml(): string; + + /** + * Sets the response type. + * @param type A class that inherits from Sdk.OrganizationResponse. + */ + setResponseType(type: OrganizationResponse): void; + + /** + * Gets the response type. + */ + getResponseType(): OrganizationResponse; + } + + class OrganizationResponse { + } + + /** + * Contains the data that is needed to convert a query in FetchXML to a QueryExpression. + * @param fetchXml Sets the query to convert. + */ + class FetchXmlToQueryExpressionRequest extends Sdk.OrganizationRequest { + constructor(fetchXml: string); + + /** + * Sets the query to convert. + * @param The query to convert. + */ + setFetchXml(value: string): void; + } + + /** + * Response to FetchXmlToQueryExpressionRequest. + * @param responseXml The response XML to the FetchXmlToQueryExpressionRequest. + */ + class FetchXmlToQueryExpressionResponse extends Sdk.OrganizationResponse { + constructor(responseXml: string); + + /** + * Gets the results of the query conversion. + */ + public getQuery(): Query.QueryExpression; + } + + /** + * Contains the data that is needed to convert a query, which is represented as a QueryExpression class, to its equivalent query, which is represented as FetchXML. * @param query The query. - * @param query */ - public setQuery( query: Sdk.Query.QueryBase ): void; + class QueryExpressionToFetchXmlRequest extends Sdk.OrganizationRequest { + constructor(query: Sdk.Query.QueryBase); + + /** + * Sets the query to convert. + * @param query The query. + * @param query + */ + public setQuery(query: Sdk.Query.QueryBase): void; + } + + /** + * Response to QueryExpressionToFetchXmlRequest. + */ + class QueryExpressionToFetchXmlResponse extends Sdk.OrganizationResponse { + constructor(responseXml: string); + + /** + * Gets the results of the query conversion. + */ + public getFetchXml(): string; + } + + /** + * Request to retrieve metadata and metadata changes. + * @param query The Sdk.Mdq.EntityQueryExpression that defines the query. + * @param clientVersionStamp The Sdk.Mdq.RetrieveMetadataChangesResponse.ServerVersionStamp value from a previous request. When included only the metadata changes since the previous request will be returned. + * @param deletedMetadataFilters An Sdk.Mdq.DeletedMetadataFilters enumeration value. When included the deleted metadata changes will be limited to the types defined by the enumeration. + */ + class RetrieveMetadataChangesRequest extends Sdk.OrganizationRequest { + constructor(query: Sdk.Mdq.EntityQueryExpression, clientVersionStamp?: string, deletedMetadataFilters?: Sdk.Mdq.DeletedMetadataFilters); + getEntityMetadata(): Sdk.Mdq.IEntityMetadata[]; + getServerVersionStamp(): string; + getDeletedMetadata(): Object; + } + + /** + * Response to RetrieveMetadataChangesRequest. + * @param resopnseXml The response XML. + */ + class RetrieveMetadataChangesResponse { + constructor(responseXml: string); + + /*** + * + */ + public getEntityMetadata(): Array; + + /*** + * + */ + public getServerVersionStamp(): string; + + /*** + * + */ + public getDeletedMetadata(): any; + } + + + /** + * Contains the data that is needed to set the state of an entity record. + * @param entityMoniker Sets the entity. + * @param state Sets the state of the entity record. + * @param status Sets the status that corresponds to the State property. + */ + class SetStateRequest extends Sdk.OrganizationRequest { + constructor(entityMoniker: EntityReference, state: number, status: number); + + /** + * Sets the entity. + * @param value The entity. + */ + public setEntityMoniker(value: EntityReference): void; + + /** + * Sets the state of the entity record. + * @param value The state of the entity record. + */ + setState(value: number): void; + + /** + * Sets the status that corresponds to the State property. + * @param value The status that corresponds to the State property. + */ + setStatus(value: number): void; + } + + /** + * Response to SetStateRequest. + */ + class SetStateResponse { + constructor(responseXml: string); + } } - /** - * Response to QueryExpressionToFetchXmlRequest. - */ - class QueryExpressionToFetchXmlResponse extends Sdk.OrganizationResponse - { - constructor( responseXml: string ); - - /** - * Gets the results of the query conversion. - */ - public getFetchXml(): string; - } - - /** - * Request to retrieve metadata and metadata changes. - * @param query The Sdk.Mdq.EntityQueryExpression that defines the query. - * @param clientVersionStamp The Sdk.Mdq.RetrieveMetadataChangesResponse.ServerVersionStamp value from a previous request. When included only the metadata changes since the previous request will be returned. - * @param deletedMetadataFilters An Sdk.Mdq.DeletedMetadataFilters enumeration value. When included the deleted metadata changes will be limited to the types defined by the enumeration. - */ - class RetrieveMetadataChangesRequest extends Sdk.OrganizationRequest - { - constructor( query: Sdk.Mdq.EntityQueryExpression, clientVersionStamp?: string, deletedMetadataFilters?: Sdk.Mdq.DeletedMetadataFilters ); - getEntityMetadata(): Sdk.Mdq.IEntityMetadata[]; - getServerVersionStamp(): string; - getDeletedMetadata(): Object; - } - - /** - * Response to RetrieveMetadataChangesRequest. - * @param resopnseXml The response XML. - */ - class RetrieveMetadataChangesResponse - { - constructor( responseXml: string ); - - /*** - * - */ - public getEntityMetadata(): Array; - - /*** - * - */ - public getServerVersionStamp(): string; - - /*** - * - */ - public getDeletedMetadata(): any; - } - - - /** - * Contains the data that is needed to set the state of an entity record. - * @param entityMoniker Sets the entity. - * @param state Sets the state of the entity record. - * @param status Sets the status that corresponds to the State property. - */ - class SetStateRequest extends Sdk.OrganizationRequest - { - constructor( entityMoniker: EntityReference, state: number, status: number ); - - /** - * Sets the entity. - * @param value The entity. - */ - public setEntityMoniker( value: EntityReference ): void; - - /** - * Sets the state of the entity record. - * @param value The state of the entity record. - */ - setState( value: number ): void; - - /** - * Sets the status that corresponds to the State property. - * @param value The status that corresponds to the State property. - */ - setStatus( value: number ): void; - } - - /** - * Response to SetStateRequest. - */ - class SetStateResponse - { - constructor( responseXml: string ); - } -} - -declare namespace Sdk.Query -{ - class QueryBase - { - /** - * Internal Use Only. - * @param type An Abstract class for different query classes to inherit from. - */ - constructor( type: string ); - - /** - * Gets the columns to include. - */ - getColumnSet(): Sdk.ColumnSet; - - /** - * Sets the columns to include. - * @param columns An Sdk.ColumnSet instance. - */ - setColumnSet( columns: Sdk.ColumnSet ): void; - - /** - * Sets the columns to include. - * @param columns An array of attribute logical names for the columns to return. - */ - setColumnSet( columns: Array ): void; - - /** - * Sets the columns to include. - * @param columns Pass each attribute logical name as an argument. - */ - setColumnSet( ...columns: string[] ): void; - - /** - * - */ - getQueryType(): string; - - /** - * Gets the logical name of the entity. - */ - getEntityName(): string; - - /** - * Sets the logical name of the entity. - * @param name The logical name of the entity. - */ - setEntityName( name: string ): void; - - /** - * Gets the number of pages and the number of entity instances per page returned from the query. - */ - getPageInfo(): Sdk.Query.PagingInfo; - - /** - * Sets the number of pages and the number of entity instances per page returned from the query. - * @param pageInfo The number of pages and the number of entity instances per page returned from the query. - */ - setPageInfo( pageInfo: Sdk.Query.PagingInfo ): void; - - /** - * Adds the specified column to the column set. - * @param columnName The logical name of the column to add. - */ - addColumn( columnName: string ): void; - - /** - * Removes a column from the ColumnSet used by the query. - * @param columnName The logical name of an attribute to be removed from the ColumnSet. - * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false. - */ - removeColumn( columnName: string, errorIfNotFound?: boolean ): void; - - /** - * Gets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. - */ - getOrders(): Sdk.Collection; - - /** - * Gets the number of rows to be returned. - */ - getTopCount(): number; - - /** - * Sets the number of rows to be returned. - * @param count The number of rows to be returned. - */ - setTopCount( count: number ): void; - - /** - * Gets the serialized QueryExpression. - */ - toXml(): string; - - /** - * Gets the serialized QueryExpression values. - */ - toValueXml(): string; - } - - class QueryByAttribute extends QueryBase - { - /** - * Initializes a new instance of the QueryByAttribute class setting the entity name. - * @param entityName The logical name of the entity. - * - */ - constructor( entityName: string ); - - /** - * Gets An Sdk.Collection of Sdk.AttributeBase attributes. - */ - getAttributeValues(): Sdk.Collection; - - /** - * Sets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. - * @param orders An Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. - */ - setOrders( orders: Sdk.Collection ): void; - - /// prototype methods - - /** - * Adds the attribute with values to include in the query. - * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. - */ - addAttributeValue( attributeValue: Sdk.AttributeBase ): void; - - /** - * Adds an order to apply to the results of the query. - * @param order An order expression. - */ - addOrder( order: Sdk.Query.OrderExpression ): void; - - /** - * Removes an attribute with values to include in the query. - * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. - * @param errorIfNotFound Whether to throw an error when the attribute to remove is not found. The default is false. - */ - removeAttributeValue( attributeValue: Sdk.AttributeBase, errorIfNotFound?: boolean ): void; - } - - class QueryExpression extends QueryBase - { - /** - * Initializes a new instance of the QueryExpression class setting the entity name. - * @param entityName The name of the entity. - */ - constructor( entityName: string ); - - /** - * Gets the complex condition and logical filter expressions that filter the results of the query. - */ - getCriteria(): FilterExpression; - - /** - * Sets the complex condition and logical filter expressions that filter the results of the query. - * @param criteria The query condition and filter criteria. - */ - setCriteria( criteria: FilterExpression ): void; - - /** - * Gets whether the results of the query contain duplicate entity instances. - */ - getDistinct(): boolean; - - /** - * Sets whether the results of the query contain duplicate entity instances. - */ - setDistinct( isDistinct: boolean ): void; - - /** - * Gets an Sdk.Collection of Sdk.Query.LinkEntity instances. - */ - getLinkEntities(): Sdk.Collection; - - /** - * Gets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. - */ - getNoLock(): boolean; - - /** - * Sets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. - * @param isNoLock True if there are no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query; otherwise, false. - */ - setNoLock( isNoLock: boolean ): void; - - /// prototype methods - - /** - * Contains a condition expression used to filter the results of the query. - * @param entityName The logical name of the entity in the condition expression. - * @param attributeName The logical name of the attribute in the condition expression. - * @param operator The condition operator. - * @param values The value(s) to compare. Use one of the following classes that inherit from Sdk.Query.ValueBase: - * Sdk.Query.Booleans - * Sdk.Query.BooleanManagedProperties - * Sdk.Query.Dates - * Sdk.Query.Decimals - * Sdk.Query.Doubles - * Sdk.Query.EntityReferences - * Sdk.Query.Guids - * Sdk.Query.Ints - * Sdk.Query.Longs - * Sdk.Query.Money - * Sdk.Query.OptionSets - * Sdk.Query.Strings - */ - addCondition( entityName: string, attributeName: string, conditionOperator: Sdk.Query.ConditionOperator, values: Sdk.Query.ValueBase ): void; - - /** - * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. - * @param firstParam An Sdk.Query.LinkEntity instance. - */ - addLink( firstParam: Sdk.Query.LinkEntity ): void; - - /** - * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. - * @param firstParam The name of entity to link from. - * @param linkFromAttributeName The name of the attribute to link from. - * @param linkToAttributeName The name of the attribute to link to. - * @param joinOperator The join operator. The default value is Inner - */ - addLink( firstParam: string, linkFromAttributeName: string, linkToAttributeName: string, joinOperator: Sdk.Query.JoinOperator ): void; - - /** - * Adds the specified order expression to the query expression. - * @param attributeName The name of the attribute. - * @param orderType The order, ascending or descending. Ascending is the default if not specified. - */ - addOrder( attributeName: string, orderType: Sdk.Query.OrderType ): void; - } - - class OrderExpression - { - } - - class ConditionExpression - { - /** - * Contains a condition expression used to filter the results of the query. - * @param name entityName The logical name of the entity in the condition expression. - * @param name attributeName The logical name of the attribute in the condition expression. - * @param name operator The condition operator. - * @param name values The value(s) to compare. - * Use one of the following classes that inherit from Sdk.Query.ValueBase: - * - Sdk.Query.Booleans - * - Sdk.Query.BooleanManagedProperties - * - Sdk.Query.Dates - * - Sdk.Query.Decimals - * - Sdk.Query.Doubles - * - Sdk.Query.EntityReferences - * - Sdk.Query.Guids - * - Sdk.Query.Ints - * - Sdk.Query.Longs - * - Sdk.Query.Money - * - Sdk.Query.OptionSets - * - Sdk.Query.Strings - */ - constructor( entityName: string, attributeName: string, operator: ConditionOperator, values?: ValueBase ); - - /** - * Returns the logical name of the entity in the condition expression. - */ - getEntityName(): string; - - /** - * Sets the logical name of the entity in the condition expression. - * @param name The logical name of the entity in the condition expression. - */ - setEntityName( name: string ): void; - - /** - * Returns the logical name of the attribute in the condition expression. - */ - getAttributeName(): string; - - /** - * Sets the logical name of the attribute in the condition expression. - * @param name The logical name of the attribute in the condition expression. - */ - setAttributeName( name: string ): void; - - /** - * Returns the condition operator. - */ - getOperator(): ConditionOperator; - - /** - * Sets the condition operator. - * @param operator The condition operator. - */ - setOperator( operator: ConditionOperator ): void; - - /** - * Returns the values for the attribute. - */ - getValues(): ValueBase; - - /** - * Sets the values for the attribute. - * @param The value(s) to compare - * Use one of the following classes that inherit from Sdk.Query.ValueBase: - * - Sdk.Query.Booleans - * - Sdk.Query.BooleanManagedProperties - * - Sdk.Query.Dates - * - Sdk.Query.Decimals - * - Sdk.Query.Doubles - * - Sdk.Query.EntityReferences - * - Sdk.Query.Guids - * - Sdk.Query.Ints - * - Sdk.Query.Longs - * - Sdk.Query.Money - * - Sdk.Query.OptionSets - * - Sdk.Query.Strings - */ - setValues( values: ValueBase ): void; - } - - /** - * Specifies complex condition and logical filter expressions used for filtering the results of the query. - * @param logicalOperator The filter operator. - */ - class FilterExpression - { - constructor( logicalOperator: LogicalOperator ); - - /** - * Adds a condition to the filter expression setting the attribute name, condition operator, and values. - * @param conditionExpression The expression that will set the condition. - */ - public addCondition( firstParam: ConditionExpression ): void; - - /** - * Adds a condition to the filter expression setting the attribute name, condition operator, and values. - * @param entityName The entityName of the new ConditionExpression that will be instantiated using the other parameters. - * @param attributeName The attribute name to use in the condition expression. - * @param conditionOperator The condition operator if the first parameter is a string. - * @param values The value(s) to compare. - * Use one of the following classes that - * - Sdk.Query.Booleans - * - Sdk.Query.BooleanManagedProperties - * - Sdk.Query.Dates - * - Sdk.Query.Decimals - * - Sdk.Query.Doubles - * - Sdk.Query.EntityReferences - * - Sdk.Query.Guids - * - Sdk.Query.Ints - * - Sdk.Query.Longs - * - Sdk.Query.Money - * - Sdk.Query.OptionSets - * - Sdk.Query.Strings - */ - public addCondition( entityName: string, attributeName: string, conditionOperator: ConditionOperator, values?: ValueBase ): void; - - /** - * Adds a child filter to the filter expression. - * @param filterExpression The filter to add. - */ - addFilter( filterExpression: FilterExpression ): void; - - /** - * Adds a child filter to the filter expression. - * @param logicalOperator Creates new FilterExpression with the specified logical operator and adds it. - */ - addFilter( logicalOperator: LogicalOperator ): void; - - /** - * Returns a collection of Sdk.Query.ConditionExpression values. - */ - getConditions(): Sdk.Collection; - - /** - * Gets the logical AND/OR filter operator. - */ - getFilterOperator(): LogicalOperator - - /** - * Returns an Sdk.Collection of Sdk.Query.FilterExpression. - */ - getFilters(): Sdk.Collection; - - /** - * Gets whether the expression is part of a quick find query. - */ - getIsQuickFindFilter(): boolean; - - /** - * Sets the filter operator. - * @param filterOperator The filter operator. - */ - setFilterOperator( filterOperator: LogicalOperator ): void; - - /** - * Sets whether the expression is part of a quick find query. - * @param isQuickFind True if the filter is part of a quick find query; otherwise, false. - */ - setIsQuickFindFilter( isQuickFind: boolean ): void; - } - - class FetchExpression - { - /** - * @param fetchXml The FetchXml to be used in a query. - */ - constructor( fetchXml: string ); - - /** - * Gets the FetchXml to be used in a query. - */ - public getFetchXml(): string; - - /** - * Sets the FetchXml to be used in a query. - * @param fetchXml The FetchXml to be used in a query. - */ - public setFetchXml( fetchXml: string ): void; - } - - class LinkEntity - { - /** - * Initializes a new instance of the Sdk.Query.LinkEntity class setting the required properties. - * @param linkFromEntityName The logical name of the entity to link from. - * @param linkToEntityName The logical name of the entity to link to. - * @param linkFromAttributeName The name of the attribute to link from. - * @param linkToAttributeName The name of the attribute to link to. - * @param joinOperator The join operator. - * @param entityAlias The string representing an alias for the linkToEntityName. - */ - constructor( - linkFromEntityName: string, - linkToEntityName: string, - linkFromAttributeName: string, - linkToAttributeName: string, - joinOperator: Sdk.Query.JoinOperator, - entityAlias: string ); - - /** - * Adds a linked entity. - * @param linkEntity An Sdk.Query.LinkEntity to add. - */ - public addLink( linkEntity: Sdk.Query.LinkEntity ): void; - - /** - * Gets the column set. - */ - public getColumns(): Sdk.ColumnSet; - - /** - * Sets the columns to include. - * @param columns An Sdk.ColumnSet instance. - */ - public setColumns( columns: Sdk.ColumnSet ): void; - - /** - * Sets the columns to include. - * @param columns An Array of attribute logical names for the columns to return. - */ - public setColumns( columns: string[] ): void; - - /** - * Sets the columns to include. - * @param columns Pass each attribute logical name as an argument. - */ - public setColumns( ...columns: string[] ): void; - - /** - * Gets the alias for the entity. - */ - public getEntityAlias(): string; - - /** - * Sets the alias for the entity. - * @param alias The alias for the entity. - */ - public setEntityAlias( alias: string ): void; - - /** - * Gets the join operator. - */ - public getJoinOperator(): Sdk.Query.JoinOperator; - - /** - * Sets the join operator. - * @param operator The join operator. - */ - public setJoinOperator( operator: Sdk.Query.JoinOperator ): void; - - /** - * Gets the complex condition and logical filter expressions that filter the results of the query. - */ - public getLinkCriteria(): Sdk.Query.FilterExpression; - - /** - * Sets the complex condition and logical filter expressions that filter the results of the query. - * @param criteria The complex condition and logical filter expressions that filter the results of the query. - */ - public setLinkCriteria( criteria: Sdk.Query.FilterExpression ): void; - - /** - * Gets the collection of Sdk.Query.LinkEntity that define links between multiple entity types. - */ - public getLinkEntities(): Sdk.Collection; - - /** - * Gets the logical name of the attribute of the entity that you are linking from. - */ - public getLinkFromAttributeName(): string; - - /** - * Sets the logical name of the attribute of the entity that you are linking from. - * @param name The logical name of the attribute of the entity that you are linking from. - */ - public setLinkFromAttributeName( name: string ): void; - - /** - * Gets the logical name of the entity that you are linking from. - */ - public getLinkFromEntityName(): string; - - /** - * Sets the logical name of the entity that you are linking from. - * @param name The logical name of the entity that you are linking from. - */ - public setLinkFromEntityName( name: string ): void; - - /** - * Gets the logical name of the attribute of the entity that you are linking to - */ - public getLinkToAttributeName(): string; - - /** - * Sets the logical name of the attribute of the entity that you are linking to. - * @param name The logical name of the attribute of the entity that you are linking to. - */ - public setLinkToAttributeName( name: string ): void; - - /** - * Gets the logical name of the entity that you are linking to. - */ - public getLinkToEntityName(): string; - - /** - * Sets the logical name of the entity that you are linking to. - * @param name The logical name of the entity that you are linking to. - */ - public setLinkToEntityName( name: string ): void; - - /** - * Gets the serialized link entity. - */ - public toXml(): string; - - /** - * Gets the serialized link entity values. - */ - public toValueXml(): string; - } - - class PagingInfo - { - /** - * Gets the number of entity instances returned per page. - */ - getCount(): number; - - /** - * Sets the number of entity instances returned per page. - * @param The number of entity instances returned per page - */ - setCount( count: number ): void; - - /** - * Gets the number of pages returned from the query. - */ - getPageNumber(): number; - - /** - * Sets the number of pages returned from the query. - * @param The number of pages returned from the query. - */ - setPageNumber( pages: number ): void; - - /** - * Gets the info used to page large result sets. - */ - getPagingCookie(): string; - - /** - * Sets the info used to page large result sets. - */ - setPagingCookie( cookie: string ): void; - - /** - * Gets whether the total number of records should be returned from the query. - */ - getReturnTotalRecordCount(): boolean; - - /** - * Sets whether the total number of records should be returned from the query. - * @param Specifies whether the TotalRecordCount should be set when the query is executed. - */ - setReturnTotalRecordCount( returnTotalRecordsCount: boolean ): void; - - - /// prototype methods - - /** - * Gets the serialized paging info. - * - toXml():string; - - /** - * Gets the serialized paging info values. - */ - toValueXml(): string; - } - - export enum ConditionOperator - { - Equal, - NotEqual, - GreaterThan, - LessThan, - GreaterEqual, - LessEqual, - Like, - NotLike, - In, - NotIn, - Between, - NotBetween, - Null, - NotNull, - Yesterday, - Today, - Tomorrow, - Last7Days, - Next7Days, - LastWeek, - ThisWeek, - NextWeek, - LastMonth, - ThisMonth, - NextMonth, - On, - OnOrBefore, - OnOrAfter, - LastYear, - ThisYear, - NextYear, - LastXHours, - NextXHours, - LastXDays, - NextXDays, - LastXWeeks, - NextXWeeks, - LastXMonths, - NextXMonths, - LastXYears, - NextXYears, - EqualUserId, - NotEqualUserId, - EqualBusinessId, - NotEqualBusinessId, - Mask, - NotMask, - Contains, - DoesNotContain, - EqualUserLanguage, - NotOn, - OlderThanXMonths, - BeginsWith, - DoesNotBeginWith, - EndsWith, - DoesNotEndWith, - ThisFiscalYear, - ThisFiscalPeriod, - NextFiscalYear, - NextFiscalPeriod, - LastFiscalYear, - LastFiscalPeriod, - LastXFiscalYears, - LastXFiscalPeriods, - NextXFiscalYears, - NextXFiscalPeriods, - InFiscalYear, - InFiscalPeriod, - InFiscalPeriodAndYear, - InOrBeforeFiscalPeriodAndYear, - InOrAfterFiscalPeriodAndYear, - EqualUserOrUserTeams, - EqualUserTeams, - } - - export enum JoinOperator - { - Inner, - LeftOuter, - Natural, - } - - export enum OrderType - { - Ascending, - Descending, - } - - export class ValueBase - { } - - /** - * Specifies Boolean values to be compared in the query. - * @param args An array of Boolean values. - */ - class Booleans extends ValueBase - { - constructor( args: boolean[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of boolean values. - */ - public getValues(): Sdk.Collection; - - - /** - * Specifies a Boolean value to be compared in the query. - * @param setValueArgs An array of boolean values. - */ - public setValues( setValueArgs: boolean[] ): void; - } - - /** - * Specifies the Date values to be compared in the query. - * @param args An array of Date values. - */ - class Dates extends ValueBase - { - constructor( args: Date[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of Date values. - */ - public getValues(): Sdk.Collection; + namespace Sdk.Query { + class QueryBase { + /** + * Internal Use Only. + * @param type An Abstract class for different query classes to inherit from. + */ + constructor(type: string); + + /** + * Gets the columns to include. + */ + getColumnSet(): Sdk.ColumnSet; + + /** + * Sets the columns to include. + * @param columns An Sdk.ColumnSet instance. + */ + setColumnSet(columns: Sdk.ColumnSet): void; + + /** + * Sets the columns to include. + * @param columns An array of attribute logical names for the columns to return. + */ + setColumnSet(columns: Array): void; + + /** + * Sets the columns to include. + * @param columns Pass each attribute logical name as an argument. + */ + setColumnSet(...columns: string[]): void; + + /** + * + */ + getQueryType(): string; + + /** + * Gets the logical name of the entity. + */ + getEntityName(): string; + + /** + * Sets the logical name of the entity. + * @param name The logical name of the entity. + */ + setEntityName(name: string): void; + + /** + * Gets the number of pages and the number of entity instances per page returned from the query. + */ + getPageInfo(): Sdk.Query.PagingInfo; + + /** + * Sets the number of pages and the number of entity instances per page returned from the query. + * @param pageInfo The number of pages and the number of entity instances per page returned from the query. + */ + setPageInfo(pageInfo: Sdk.Query.PagingInfo): void; + + /** + * Adds the specified column to the column set. + * @param columnName The logical name of the column to add. + */ + addColumn(columnName: string): void; + + /** + * Removes a column from the ColumnSet used by the query. + * @param columnName The logical name of an attribute to be removed from the ColumnSet. + * @param errorIfNotFound Whether to throw an error when the column to remove is not found. The default is false. + */ + removeColumn(columnName: string, errorIfNotFound?: boolean): void; + + /** + * Gets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. + */ + getOrders(): Sdk.Collection; + + /** + * Gets the number of rows to be returned. + */ + getTopCount(): number; + + /** + * Sets the number of rows to be returned. + * @param count The number of rows to be returned. + */ + setTopCount(count: number): void; + + /** + * Gets the serialized QueryExpression. + */ + toXml(): string; + + /** + * Gets the serialized QueryExpression values. + */ + toValueXml(): string; + } + + class QueryByAttribute extends QueryBase { + /** + * Initializes a new instance of the QueryByAttribute class setting the entity name. + * @param entityName The logical name of the entity. + * + */ + constructor(entityName: string); + + /** + * Gets An Sdk.Collection of Sdk.AttributeBase attributes. + */ + getAttributeValues(): Sdk.Collection; + + /** + * Sets an Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. + * @param orders An Sdk.Collection of Sdk.Query.OrderExpression instances that define the order in which the entity instances are returned from the query. + */ + setOrders(orders: Sdk.Collection): void; + + /// prototype methods + + /** + * Adds the attribute with values to include in the query. + * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. + */ + addAttributeValue(attributeValue: Sdk.AttributeBase): void; + + /** + * Adds an order to apply to the results of the query. + * @param order An order expression. + */ + addOrder(order: Sdk.Query.OrderExpression): void; + + /** + * Removes an attribute with values to include in the query. + * @param attributeValue One of the classes that inherit from Sdk.AttributeBase including the value to use as criteria. + * @param errorIfNotFound Whether to throw an error when the attribute to remove is not found. The default is false. + */ + removeAttributeValue(attributeValue: Sdk.AttributeBase, errorIfNotFound?: boolean): void; + } + + class QueryExpression extends QueryBase { + /** + * Initializes a new instance of the QueryExpression class setting the entity name. + * @param entityName The name of the entity. + */ + constructor(entityName: string); + + /** + * Gets the complex condition and logical filter expressions that filter the results of the query. + */ + getCriteria(): FilterExpression; + + /** + * Sets the complex condition and logical filter expressions that filter the results of the query. + * @param criteria The query condition and filter criteria. + */ + setCriteria(criteria: FilterExpression): void; + + /** + * Gets whether the results of the query contain duplicate entity instances. + */ + getDistinct(): boolean; + + /** + * Sets whether the results of the query contain duplicate entity instances. + */ + setDistinct(isDistinct: boolean): void; + + /** + * Gets an Sdk.Collection of Sdk.Query.LinkEntity instances. + */ + getLinkEntities(): Sdk.Collection; + + /** + * Gets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. + */ + getNoLock(): boolean; + + /** + * Sets a value that indicates that no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query. + * @param isNoLock True if there are no shared locks are issued against the data that would prohibit other transactions from modifying the data in the records returned from the query; otherwise, false. + */ + setNoLock(isNoLock: boolean): void; + + /// prototype methods + + /** + * Contains a condition expression used to filter the results of the query. + * @param entityName The logical name of the entity in the condition expression. + * @param attributeName The logical name of the attribute in the condition expression. + * @param operator The condition operator. + * @param values The value(s) to compare. Use one of the following classes that inherit from Sdk.Query.ValueBase: + * Sdk.Query.Booleans + * Sdk.Query.BooleanManagedProperties + * Sdk.Query.Dates + * Sdk.Query.Decimals + * Sdk.Query.Doubles + * Sdk.Query.EntityReferences + * Sdk.Query.Guids + * Sdk.Query.Ints + * Sdk.Query.Longs + * Sdk.Query.Money + * Sdk.Query.OptionSets + * Sdk.Query.Strings + */ + addCondition(entityName: string, attributeName: string, conditionOperator: Sdk.Query.ConditionOperator, values: Sdk.Query.ValueBase): void; + + /** + * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. + * @param firstParam An Sdk.Query.LinkEntity instance. + */ + addLink(firstParam: Sdk.Query.LinkEntity): void; + + /** + * Adds the specified link to the query expression setting the entity name to link to, the attribute name to link from and the attribute name to link to. + * @param firstParam The name of entity to link from. + * @param linkFromAttributeName The name of the attribute to link from. + * @param linkToAttributeName The name of the attribute to link to. + * @param joinOperator The join operator. The default value is Inner + */ + addLink(firstParam: string, linkFromAttributeName: string, linkToAttributeName: string, joinOperator: Sdk.Query.JoinOperator): void; + + /** + * Adds the specified order expression to the query expression. + * @param attributeName The name of the attribute. + * @param orderType The order, ascending or descending. Ascending is the default if not specified. + */ + addOrder(attributeName: string, orderType: Sdk.Query.OrderType): void; + } + + class OrderExpression { + } + + class ConditionExpression { + /** + * Contains a condition expression used to filter the results of the query. + * @param name entityName The logical name of the entity in the condition expression. + * @param name attributeName The logical name of the attribute in the condition expression. + * @param name operator The condition operator. + * @param name values The value(s) to compare. + * Use one of the following classes that inherit from Sdk.Query.ValueBase: + * - Sdk.Query.Booleans + * - Sdk.Query.BooleanManagedProperties + * - Sdk.Query.Dates + * - Sdk.Query.Decimals + * - Sdk.Query.Doubles + * - Sdk.Query.EntityReferences + * - Sdk.Query.Guids + * - Sdk.Query.Ints + * - Sdk.Query.Longs + * - Sdk.Query.Money + * - Sdk.Query.OptionSets + * - Sdk.Query.Strings + */ + constructor(entityName: string, attributeName: string, operator: ConditionOperator, values?: ValueBase); + + /** + * Returns the logical name of the entity in the condition expression. + */ + getEntityName(): string; + + /** + * Sets the logical name of the entity in the condition expression. + * @param name The logical name of the entity in the condition expression. + */ + setEntityName(name: string): void; + + /** + * Returns the logical name of the attribute in the condition expression. + */ + getAttributeName(): string; + + /** + * Sets the logical name of the attribute in the condition expression. + * @param name The logical name of the attribute in the condition expression. + */ + setAttributeName(name: string): void; + + /** + * Returns the condition operator. + */ + getOperator(): ConditionOperator; + + /** + * Sets the condition operator. + * @param operator The condition operator. + */ + setOperator(operator: ConditionOperator): void; + + /** + * Returns the values for the attribute. + */ + getValues(): ValueBase; + + /** + * Sets the values for the attribute. + * @param The value(s) to compare + * Use one of the following classes that inherit from Sdk.Query.ValueBase: + * - Sdk.Query.Booleans + * - Sdk.Query.BooleanManagedProperties + * - Sdk.Query.Dates + * - Sdk.Query.Decimals + * - Sdk.Query.Doubles + * - Sdk.Query.EntityReferences + * - Sdk.Query.Guids + * - Sdk.Query.Ints + * - Sdk.Query.Longs + * - Sdk.Query.Money + * - Sdk.Query.OptionSets + * - Sdk.Query.Strings + */ + setValues(values: ValueBase): void; + } + + /** + * Specifies complex condition and logical filter expressions used for filtering the results of the query. + * @param logicalOperator The filter operator. + */ + class FilterExpression { + constructor(logicalOperator: LogicalOperator); + + /** + * Adds a condition to the filter expression setting the attribute name, condition operator, and values. + * @param conditionExpression The expression that will set the condition. + */ + public addCondition(firstParam: ConditionExpression): void; + + /** + * Adds a condition to the filter expression setting the attribute name, condition operator, and values. + * @param entityName The entityName of the new ConditionExpression that will be instantiated using the other parameters. + * @param attributeName The attribute name to use in the condition expression. + * @param conditionOperator The condition operator if the first parameter is a string. + * @param values The value(s) to compare. + * Use one of the following classes that + * - Sdk.Query.Booleans + * - Sdk.Query.BooleanManagedProperties + * - Sdk.Query.Dates + * - Sdk.Query.Decimals + * - Sdk.Query.Doubles + * - Sdk.Query.EntityReferences + * - Sdk.Query.Guids + * - Sdk.Query.Ints + * - Sdk.Query.Longs + * - Sdk.Query.Money + * - Sdk.Query.OptionSets + * - Sdk.Query.Strings + */ + public addCondition(entityName: string, attributeName: string, conditionOperator: ConditionOperator, values?: ValueBase): void; + + /** + * Adds a child filter to the filter expression. + * @param filterExpression The filter to add. + */ + addFilter(filterExpression: FilterExpression): void; + + /** + * Adds a child filter to the filter expression. + * @param logicalOperator Creates new FilterExpression with the specified logical operator and adds it. + */ + addFilter(logicalOperator: LogicalOperator): void; + + /** + * Returns a collection of Sdk.Query.ConditionExpression values. + */ + getConditions(): Sdk.Collection; + + /** + * Gets the logical AND/OR filter operator. + */ + getFilterOperator(): LogicalOperator + + /** + * Returns an Sdk.Collection of Sdk.Query.FilterExpression. + */ + getFilters(): Sdk.Collection; + + /** + * Gets whether the expression is part of a quick find query. + */ + getIsQuickFindFilter(): boolean; + + /** + * Sets the filter operator. + * @param filterOperator The filter operator. + */ + setFilterOperator(filterOperator: LogicalOperator): void; + + /** + * Sets whether the expression is part of a quick find query. + * @param isQuickFind True if the filter is part of a quick find query; otherwise, false. + */ + setIsQuickFindFilter(isQuickFind: boolean): void; + } + + class FetchExpression { + /** + * @param fetchXml The FetchXml to be used in a query. + */ + constructor(fetchXml: string); + + /** + * Gets the FetchXml to be used in a query. + */ + public getFetchXml(): string; + + /** + * Sets the FetchXml to be used in a query. + * @param fetchXml The FetchXml to be used in a query. + */ + public setFetchXml(fetchXml: string): void; + } + + class LinkEntity { + /** + * Initializes a new instance of the Sdk.Query.LinkEntity class setting the required properties. + * @param linkFromEntityName The logical name of the entity to link from. + * @param linkToEntityName The logical name of the entity to link to. + * @param linkFromAttributeName The name of the attribute to link from. + * @param linkToAttributeName The name of the attribute to link to. + * @param joinOperator The join operator. + * @param entityAlias The string representing an alias for the linkToEntityName. + */ + constructor( + linkFromEntityName: string, + linkToEntityName: string, + linkFromAttributeName: string, + linkToAttributeName: string, + joinOperator: Sdk.Query.JoinOperator, + entityAlias: string); + + /** + * Adds a linked entity. + * @param linkEntity An Sdk.Query.LinkEntity to add. + */ + public addLink(linkEntity: Sdk.Query.LinkEntity): void; + + /** + * Gets the column set. + */ + public getColumns(): Sdk.ColumnSet; + + /** + * Sets the columns to include. + * @param columns An Sdk.ColumnSet instance. + */ + public setColumns(columns: Sdk.ColumnSet): void; + + /** + * Sets the columns to include. + * @param columns An Array of attribute logical names for the columns to return. + */ + public setColumns(columns: string[]): void; + + /** + * Sets the columns to include. + * @param columns Pass each attribute logical name as an argument. + */ + public setColumns(...columns: string[]): void; + + /** + * Gets the alias for the entity. + */ + public getEntityAlias(): string; + + /** + * Sets the alias for the entity. + * @param alias The alias for the entity. + */ + public setEntityAlias(alias: string): void; + + /** + * Gets the join operator. + */ + public getJoinOperator(): Sdk.Query.JoinOperator; + + /** + * Sets the join operator. + * @param operator The join operator. + */ + public setJoinOperator(operator: Sdk.Query.JoinOperator): void; + + /** + * Gets the complex condition and logical filter expressions that filter the results of the query. + */ + public getLinkCriteria(): Sdk.Query.FilterExpression; + + /** + * Sets the complex condition and logical filter expressions that filter the results of the query. + * @param criteria The complex condition and logical filter expressions that filter the results of the query. + */ + public setLinkCriteria(criteria: Sdk.Query.FilterExpression): void; + + /** + * Gets the collection of Sdk.Query.LinkEntity that define links between multiple entity types. + */ + public getLinkEntities(): Sdk.Collection; + + /** + * Gets the logical name of the attribute of the entity that you are linking from. + */ + public getLinkFromAttributeName(): string; + + /** + * Sets the logical name of the attribute of the entity that you are linking from. + * @param name The logical name of the attribute of the entity that you are linking from. + */ + public setLinkFromAttributeName(name: string): void; + + /** + * Gets the logical name of the entity that you are linking from. + */ + public getLinkFromEntityName(): string; + + /** + * Sets the logical name of the entity that you are linking from. + * @param name The logical name of the entity that you are linking from. + */ + public setLinkFromEntityName(name: string): void; + + /** + * Gets the logical name of the attribute of the entity that you are linking to + */ + public getLinkToAttributeName(): string; + + /** + * Sets the logical name of the attribute of the entity that you are linking to. + * @param name The logical name of the attribute of the entity that you are linking to. + */ + public setLinkToAttributeName(name: string): void; + + /** + * Gets the logical name of the entity that you are linking to. + */ + public getLinkToEntityName(): string; + + /** + * Sets the logical name of the entity that you are linking to. + * @param name The logical name of the entity that you are linking to. + */ + public setLinkToEntityName(name: string): void; + + /** + * Gets the serialized link entity. + */ + public toXml(): string; + + /** + * Gets the serialized link entity values. + */ + public toValueXml(): string; + } + + class PagingInfo { + /** + * Gets the number of entity instances returned per page. + */ + getCount(): number; + + /** + * Sets the number of entity instances returned per page. + * @param The number of entity instances returned per page + */ + setCount(count: number): void; + + /** + * Gets the number of pages returned from the query. + */ + getPageNumber(): number; + + /** + * Sets the number of pages returned from the query. + * @param The number of pages returned from the query. + */ + setPageNumber(pages: number): void; + + /** + * Gets the info used to page large result sets. + */ + getPagingCookie(): string; + + /** + * Sets the info used to page large result sets. + */ + setPagingCookie(cookie: string): void; + + /** + * Gets whether the total number of records should be returned from the query. + */ + getReturnTotalRecordCount(): boolean; + + /** + * Sets whether the total number of records should be returned from the query. + * @param Specifies whether the TotalRecordCount should be set when the query is executed. + */ + setReturnTotalRecordCount(returnTotalRecordsCount: boolean): void; + + + /// prototype methods + + /** + * Gets the serialized paging info. + * + toXml():string; + + /** + * Gets the serialized paging info values. + */ + toValueXml(): string; + } + + export enum ConditionOperator { + Equal, + NotEqual, + GreaterThan, + LessThan, + GreaterEqual, + LessEqual, + Like, + NotLike, + In, + NotIn, + Between, + NotBetween, + Null, + NotNull, + Yesterday, + Today, + Tomorrow, + Last7Days, + Next7Days, + LastWeek, + ThisWeek, + NextWeek, + LastMonth, + ThisMonth, + NextMonth, + On, + OnOrBefore, + OnOrAfter, + LastYear, + ThisYear, + NextYear, + LastXHours, + NextXHours, + LastXDays, + NextXDays, + LastXWeeks, + NextXWeeks, + LastXMonths, + NextXMonths, + LastXYears, + NextXYears, + EqualUserId, + NotEqualUserId, + EqualBusinessId, + NotEqualBusinessId, + Mask, + NotMask, + Contains, + DoesNotContain, + EqualUserLanguage, + NotOn, + OlderThanXMonths, + BeginsWith, + DoesNotBeginWith, + EndsWith, + DoesNotEndWith, + ThisFiscalYear, + ThisFiscalPeriod, + NextFiscalYear, + NextFiscalPeriod, + LastFiscalYear, + LastFiscalPeriod, + LastXFiscalYears, + LastXFiscalPeriods, + NextXFiscalYears, + NextXFiscalPeriods, + InFiscalYear, + InFiscalPeriod, + InFiscalPeriodAndYear, + InOrBeforeFiscalPeriodAndYear, + InOrAfterFiscalPeriodAndYear, + EqualUserOrUserTeams, + EqualUserTeams, + } + + export enum JoinOperator { + Inner, + LeftOuter, + Natural, + } + + export enum OrderType { + Ascending, + Descending, + } + + export class ValueBase + { } + + /** + * Specifies Boolean values to be compared in the query. + * @param args An array of Boolean values. + */ + class Booleans extends ValueBase { + constructor(args: boolean[]); + + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of boolean values. + */ + public getValues(): Sdk.Collection; + + + /** + * Specifies a Boolean value to be compared in the query. + * @param setValueArgs An array of boolean values. + */ + public setValues(setValueArgs: boolean[]): void; + } /** * Specifies the Date values to be compared in the query. - * @param setValueArgs An array of Date values. + * @param args An array of Date values. */ - public setValues( setValueArgs: Date[] ): void; - } + class Dates extends ValueBase { + constructor(args: Date[]); - /** - * Specifies the Decimal values to be compared in the query. - * @param args An array of Decimal values. - */ - class Decimals extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of Date values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Date values to be compared in the query. + * @param setValueArgs An array of Date values. + */ + public setValues(setValueArgs: Date[]): void; + } /** * Specifies the Decimal values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of Decimal values. */ - public setValues( setValueArgs: number[] ): void; - } + class Decimals extends ValueBase { + constructor(args: number[]); - /** - * Specifies the Double values to be compared in the query. - * @param args An array of Double values. - */ - class Doubles extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Decimal values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the Double values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of Double values. */ - public setValues( setValueArgs: number[] ): void; - } + class Doubles extends ValueBase { + constructor(args: number[]); - /** - * Specifies the Int values to be compared in the query. - * @param args An array of Int values. - */ - class Ints extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the Double values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** - * Returns the type of value with namespace prefix. + * Specifies the Int values to be compared in the query. + * @param args An array of Int values. */ - public getType(): string; + class Ints extends ValueBase { + constructor(args: number[]); - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Specifies the Int values to be compared in the query - * @param setValueArgs An array of number values. - */ - public setValues( setValueArgs: number[] ): void; - } + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Specifies the Long values to be compared in the query. - * @param args An array of Long values. - */ - class Longs extends ValueBase - { - constructor( args: number[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Int values to be compared in the query + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the Long values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of Long values. */ - public setValues( setValueArgs: number[] ): void; - } + class Longs extends ValueBase { + constructor(args: number[]); - /** - * Specifies the Sdk.EntityReference values to be compared in the query. - * @param args An array of Sdk.EntityReference values. - */ - class EntityReferences extends ValueBase - { - constructor( args: Sdk.EntityReference[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the Long values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** - * Returns the type of value with namespace prefix. + * Specifies the Sdk.EntityReference values to be compared in the query. + * @param args An array of Sdk.EntityReference values. */ - public getType(): string; + class EntityReferences extends ValueBase { + constructor(args: Sdk.EntityReference[]); + + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of Sdk.EntityReference values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the Long values to be compared in the query. + * @param setValueArgs An array of Sdk.EntityReference values. + */ + public setValues(setValueArgs: Sdk.EntityReference[]): void; + } /** - * Returns an Sdk.Collection of Sdk.EntityReference values. + * Specifies the Sdk.Query.Guids values to be compared in the query. + * @param args An array of GUID string values. */ - public getValues(): Sdk.Collection; + class Guids extends ValueBase { + constructor(args: string[]); - /** - * Specifies the Long values to be compared in the query. - * @param setValueArgs An array of Sdk.EntityReference values. - */ - public setValues( setValueArgs: Sdk.EntityReference[] ): void; - } + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Specifies the Sdk.Query.Guids values to be compared in the query. - * @param args An array of GUID string values. - */ - class Guids extends ValueBase - { - constructor( args: string[] ); + /** + * Returns an Sdk.Collection of GUID string values. + */ + public getValues(): Sdk.Collection; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of GUID string values. - */ - public getValues(): Sdk.Collection; - - /** - * Specifies the Long values to be compared in the query. - * @param setValueArgs An array of GUID string values. - */ - public setValues( setValueArgs: string[] ): void; - } - - /** - * Specifies the Money values to be compared in the query. - * @param args An array of number values. - */ - class Money extends ValueBase - { - constructor( args: number[] ); - - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; - - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Long values to be compared in the query. + * @param setValueArgs An array of GUID string values. + */ + public setValues(setValueArgs: string[]): void; + } /** * Specifies the Money values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of number values. */ - public setValues( setValueArgs: number[] ): void; - } + class Money extends ValueBase { + constructor(args: number[]); - /** - * Specifies the OptionSet values to be compared in the query. - * @param args An array of number values. - */ - class OptionSets extends ValueBase - { - constructor( args: number[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of number values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the Money values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the OptionSet values to be compared in the query. - * @param setValueArgs An array of number values. + * @param args An array of number values. */ - public setValues( setValueArgs: number[] ): void; - } + class OptionSets extends ValueBase { + constructor(args: number[]); - /** - * Specifies the String values to be compared in the query. - * @param args An array of String values. - */ - class Strings extends ValueBase - { - constructor( args: string[] ); + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; - /** - * Returns the type of value with namespace prefix. - */ - public getType(): string; + /** + * Returns an Sdk.Collection of number values. + */ + public getValues(): Sdk.Collection; - /** - * Returns an Sdk.Collection of String values. - */ - public getValues(): Sdk.Collection; + /** + * Specifies the OptionSet values to be compared in the query. + * @param setValueArgs An array of number values. + */ + public setValues(setValueArgs: number[]): void; + } /** * Specifies the String values to be compared in the query. - * @param setValueArgs An array of String values. + * @param args An array of String values. */ - public setValues( setValueArgs: string[] ): void + class Strings extends ValueBase { + constructor(args: string[]); + + /** + * Returns the type of value with namespace prefix. + */ + public getType(): string; + + /** + * Returns an Sdk.Collection of String values. + */ + public getValues(): Sdk.Collection; + + /** + * Specifies the String values to be compared in the query. + * @param setValueArgs An array of String values. + */ + public setValues(setValueArgs: string[]): void + } + + export enum LogicalOperator { + Or, + And, + } } - export enum LogicalOperator - { - Or, - And, - } -} - -declare namespace Sdk.Util -{ - /** - * Verifies the parameter is a string formatted as a GUID. - * @param value The value to check. - */ - function isGuid( value: string ): boolean; - - /** - * Verifies the parameter is a string formatted as a GUID or null. - * @param value The value to check. - */ - function isGuidOrNull( value: string ): boolean; - - /** - * Verifies the parameter is a valid enum value. - * @param enumeration The enumeration. - * @param value The value to check. - */ - - /** - * Returns an empty GUID. - */ - function getEmptyGuid(): string; - - /** - * Formats a string with the arguments from an array. - * @param string The string containing placeholders for items in the array. - * @param args An array of strings to replace the placeholders. - */ - function format( string: string, args: string[] ): string; - - /** - * - */ - function getError( resp: any ): string; - - /** - * Returns the clinent URL. - */ - function getClientUrl(): string; - - /** - * Provides a way to override the client Url when a client-side context is not available. - * @param url The client URL to use instead of the default. - */ - function setClientUrl( url: string ): void; - - /** - * - */ - function getXMLHttpRequest( action: string, async: boolean ): any; - - /** - * Creates an entity from XML. - * @param The serialized entity returned from the SOAP service as XML. - */ - function createEntityFromNode( node: string ): void; -} - -declare namespace Sdk.Xml -{ -} - -declare namespace Sdk.Mdq -{ - /** - * Defines a complex query to retrieve entity metadata. - * @param criteria The filter criteria for the metadata query. - * @param properties The properties to be returned by the query. - * @param attributeQuery A query expression for the entity attribute metadata to return. - * @param relationshipQuery A query expression for the entity relationship metadata to return. - * @param labelQuery A query expression for the labels to return. - */ - export class EntityQueryExpression - { - constructor( - criteria: Sdk.Mdq.MetadataFilterExpression, - properties: Sdk.Mdq.MetadataPropertiesExpression, - attributeQuery?: Sdk.Mdq.AttributeQueryExpression, - relationshipQuery?: Sdk.Mdq.RelationshipQueryExpression, - labelQuery?: Sdk.Mdq.LabelQueryExpression ); - } - - /** - * An enumeration that specifies the type of deleted metadata to retrieve. - */ - export enum DeletedMetadataFilters - { - All, // All deleted metadata - Attribute, // Deleted Attribute metadata - Default, // The value used if not set. Equals Entity - Entity, //Deleted Entity metadata - Label, //Deleted Label metadata - OptionSet, // Deleted OptionSet metadata - Relationship, //Deleted Relationship metadata - } - - /** - * Specifies complex condition and logical filter expressions used for filtering the results of a metadata query. - * @param filterOperator The logical AND/OR filter operator. - */ - - export class MetadataFilterExpression - { - constructor( filterOperator: Sdk.Mdq.LogicalOperator ); + namespace Sdk.Util { + /** + * Verifies the parameter is a string formatted as a GUID. + * @param value The value to check. + */ + function isGuid(value: string): boolean; /** - * Adds a condition. This method accepts either the properties to create a new Sdk.Mdq.MetadataConditionExpression or a Sdk.Mdq.MetadataConditionExpression as the first argument. - * @param propertyName The metadata property to evaluate. - * @param conditionOperator The condition operator. - * @param value The metadata value to evaluate. + * Verifies the parameter is a string formatted as a GUID or null. + * @param value The value to check. */ - public addCondition( - propertyName: SearchableEntityMetadataProperties|SearchableAttributeMetadataProperties|SearchableRelationshipMetadataProperties, - conditionOperator: MetadataConditionOperator, - value: Object ): void; - public addCondition( - propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator, value: any): void; - public addCondition( - propertyName: SearchableEntityMetadataProperties|SearchableAttributeMetadataProperties|SearchableRelationshipMetadataProperties, - conditionOperator: MetadataConditionOperator, - value: Object ): void; - addCondition(propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator): void; - public addCondition( - propertyName: SearchableEntityMetadataProperties|SearchableAttributeMetadataProperties|SearchableRelationshipMetadataProperties, - conditionOperator: MetadataConditionOperator, - value: Object): void; + function isGuidOrNull(value: string): boolean; + + /** + * Verifies the parameter is a valid enum value. + * @param enumeration The enumeration. + * @param value The value to check. + */ + + /** + * Returns an empty GUID. + */ + function getEmptyGuid(): string; + + /** + * Formats a string with the arguments from an array. + * @param string The string containing placeholders for items in the array. + * @param args An array of strings to replace the placeholders. + */ + function format(string: string, args: string[]): string; + + /** + * + */ + function getError(resp: any): string; + + /** + * Returns the clinent URL. + */ + function getClientUrl(): string; + + /** + * Provides a way to override the client Url when a client-side context is not available. + * @param url The client URL to use instead of the default. + */ + function setClientUrl(url: string): void; + + /** + * + */ + function getXMLHttpRequest(action: string, async: boolean): any; + + /** + * Creates an entity from XML. + * @param The serialized entity returned from the SOAP service as XML. + */ + function createEntityFromNode(node: string): void; } - /** - * Defines a complex query to retrieve attribute metadata for entities retrieved using an Sdk.Mdq.EntityQueryExpression. - * @param criteria The filter criteria for the metadata query. - * @param properties The properties to be returned by the query. - */ - export class AttributeQueryExpression - { - constructor( criteria: MetadataFilterExpression, properties: Sdk.Mdq.MetadataPropertiesExpression ); + namespace Sdk.Xml { } - /** - * Defines a complex query to retrieve entity relationship metadata for entities retrieved using an EntityQueryExpression. - * @param criteria The filter criteria for the metadata query. - * @param properties The properties to be returned by the query. - */ - export class RelationshipQueryExpression - { - constructor( criteria: MetadataFilterExpression, properties: Mdq.MetadataPropertiesExpression ); - } - - /** - * Defines the languages for the labels to be retrieved for metadata items that have labels. - * @param languages An array of LCID number values. - */ - export class LabelQueryExpression - { - constructor( languages: Array ); - } - - /** - * Logical operator. - */ - export enum LogicalOperator - { - And, - Or, - } - - /** - * Specifies the properties for which non-null values are returned from a query. - * @param allProperties Whether to retrieve all the properties of a metadata object. - * @param propertyNames: >An array of strings representing the metadata properties to retrieve. - */ - export class MetadataPropertiesExpression - { - constructor( allProperties: boolean, propertyNames?: Array ); - } - - export enum RelationshipMetadataProperties - { - AssociatedMenuConfiguration, - CascadeConfiguration, - HasChanged, - Entity1AssociatedMenuConfiguration, - Entity1IntersectAttribute, - Entity1LogicalName, - Entity2AssociatedMenuConfiguration, - Entity2IntersectAttribute, - Entity2LogicalName, - IntersectEntityName, - IsCustomizable, - IntroducedVersion, - IsCustomRelationship, - IsManaged, - IsValidForAdvancedFind, - MetadataId, - ReferencedAttribute, - ReferencedEntity, - ReferencingAttribute, - ReferencingEntity, - RelationshipType, - SchemaName, - SecurityTypes, - } - - export enum AttributeMetadataProperties - { - AttributeOf, - AttributeType, - AttributeTypeName, - CalculationOf, - CanBeSecuredForCreate, - CanBeSecuredForRead, - CanBeSecuredForUpdate, - CanModifyAdditionalSettings, - ColumnNumber, - DefaultFormValue, - DefaultValue, - DeprecatedVersion, - Description, - DisplayName, - EntityLogicalName, - Format, - FormatName, - ImeMode, - IntroducedVersion, - IsAuditEnabled, - IsCustomAttribute, - IsCustomizable, - IsManaged, - IsPrimaryId, - IsPrimaryName, - IsRenameable, - IsSecured, - IsValidForAdvancedFind, - IsValidForCreate, - IsValidForRead, - IsValidForUpdate, - LinkedAttributeId, - LogicalName, - MaxLength, - MaxValue, - MetadataId, - MinValue, - OptionSet, - Precision, - PrecisionSource, - RequiredLevel, - SchemaName, - Targets, - YomiOf, - } - - export enum EntityMetadataProperties - { - ActivityTypeMask, - Attributes, - AutoCreateAccessTeams, - AutoRouteToOwnerQueue, - CanBeInManyToMany, - CanBePrimaryEntityInRelationship, - CanBeRelatedEntityInRelationship, - CanCreateAttributes, - CanCreateCharts, - CanCreateForms, - CanCreateViews, - CanModifyAdditionalSettings, - CanTriggerWorkflow, - Description, - DisplayCollectionName, - DisplayName, - IconLargeName, - IconMediumName, - IconSmallName, - IntroducedVersion, - IsActivity, - IsActivityParty, - IsAIRUpdated, - IsAuditEnabled, - IsAvailableOffline, - IsBusinessProcessEnabled, - IsChildEntity, - IsConnectionsEnabled, - IsCustomEntity, - IsCustomizable, - IsDocumentManagementEnabled, - IsDuplicateDetectionEnabled, - IsEnabledForCharts, - IsImportable, - IsIntersect, - IsMailMergeEnabled, - IsManaged, - IsMappable, - IsQuickCreateEnabled, - IsReadingPaneEnabled, - IsRenameable, - IsValidForAdvancedFind, - IsValidForQueue, - IsVisibleInMobile, - IsVisibleInMobileClient, - LogicalName, - ManyToManyRelationships, - ManyToOneRelationships, - MetadataId, - ObjectTypeCode, - OneToManyRelationships, - OwnershipType, - PrimaryIdAttribute, - PrimaryImageAttribute, - PrimaryNameAttribute, - Privileges, - RecurrenceBaseEntityLogicalName, - ReportViewName, - SchemaName, - } - - export enum SearchableEntityMetadataProperties - { - ActivityTypeMask, - AutoCreateAccessTeams, - AutoRouteToOwnerQueue, - CanBeInManyToMany, - CanBePrimaryEntityInRelationship, - CanBeRelatedEntityInRelationship, - CanCreateAttributes, - CanCreateCharts, - CanCreateForms, - CanCreateViews, - CanModifyAdditionalSettings, - CanTriggerWorkflow, - IconLargeName, - IconMediumName, - IconSmallName, - IntroducedVersion, - IsActivity, - IsActivityParty, - IsAIRUpdated, - IsAuditEnabled, - IsAvailableOffline, - IsBusinessProcessEnabled, - IsChildEntity, - IsConnectionsEnabled, - IsCustomEntity, - IsCustomizable, - IsDocumentManagementEnabled, - IsDuplicateDetectionEnabled, - IsEnabledForCharts, - IsImportable, - IsIntersect, - IsMailMergeEnabled, - IsManaged, - IsMappable, - IsQuickCreateEnabled, - IsReadingPaneEnabled, - IsRenameable, - IsValidForAdvancedFind, - IsValidForQueue, - IsVisibleInMobile, - IsVisibleInMobileClient, - LogicalName, - MetadataId, - ObjectTypeCode, - OwnershipType, - PrimaryIdAttribute, - PrimaryImageAttribute, - PrimaryNameAttribute, - RecurrenceBaseEntityLogicalName, - ReportViewName, - SchemaName, - } - - export enum SearchableAttributeMetadataProperties - { - AttributeOf, - AttributeType, - CalculationOf, - CanBeSecuredForCreate, - CanBeSecuredForRead, - CanBeSecuredForUpdate, - CanModifyAdditionalSettings, - ColumnNumber, - DefaultFormValue, - DefaultValue, - DeprecatedVersion, - EntityLogicalName, - Format, - FormatName, - ImeMode, - IntroducedVersion, - IsAuditEnabled, - IsCustomAttribute, - IsCustomizable, - IsManaged, - IsPrimaryId, - IsPrimaryName, - IsRenameable, - IsSecured, - IsValidForAdvancedFind, - IsValidForCreate, - IsValidForRead, - IsValidForUpdate, - LinkedAttributeId, - LogicalName, - MaxLength, - MaxValue, - MetadataId, - MinValue, - Precision, - PrecisionSource, - RequiredLevel, - SchemaName, - YomiOf, - } - - export enum SearchableRelationshipMetadataProperties - { - HasChanged, - Entity1IntersectAttribute, - Entity1LogicalName, - Entity2IntersectAttribute, - Entity2LogicalName, - IntersectEntityName, - IsCustomizable, - IntroducedVersion, - IsCustomRelationship, - IsManaged, - IsValidForAdvancedFind, - MetadataId, - ReferencedAttribute, - ReferencedEntity, - ReferencingAttribute, - ReferencingEntity, - RelationshipType, - SchemaName, - SecurityTypes, - } - - export enum MetadataConditionOperator - { - Equals, - NotEquals, - In, - NotIn, - GreaterThan, - LessThan, - } - - export interface IEntityMetadata - { - ActivityTypeMask: number; - Attributes: IAttributeMetadata[]; - AutoCreateAccessTeams: any; - AutoRouteToOwnerQueue: boolean; - CanBeInManyToMany: ManagedProperty; - CanBePrimaryEntityInRelationship: ManagedProperty; - CanBeRelatedEntityInRelationship: ManagedProperty; - CanCreateAttributes: ManagedProperty; - CanCreateCharts: ManagedProperty; - CanCreateForms: ManagedProperty; - CanCreateViews: ManagedProperty; - CanModifyAdditionalSettings: ManagedProperty; - CanTriggerWorkflow: boolean; - Description: Label; - DisplayCollectionName: Label; - DisplayName: Label; - IconLargeName: string; - IconMediumName: string; - IconSmallName: string; - IntroducedVersion: any; - IsActivity: boolean; - IsActivityParty: boolean; - IsAIRUpdated: boolean; - IsAuditEnabled: ManagedProperty; - IsAvailableOffline: boolean; - IsBusinessProcessEnabled: boolean; - IsChildEntity: boolean; - IsConnectionsEnabled: ManagedProperty; - IsCustomEntity: boolean; - IsCustomizable: ManagedProperty; - IsDocumentManagementEnabled: boolean; - IsDuplicateDetectionEnabled: ManagedProperty; - IsEnabledForCharts: boolean; - IsImportable: boolean; - IsIntersect: boolean; - IsMailMergeEnabled: ManagedProperty; - IsManaged: boolean; - IsMappable: ManagedProperty; - IsQuickCreateEnabled: boolean; - IsReadingPaneEnabled: boolean; - IsRenameable: boolean; - IsValidForAdvancedFind: boolean; - IsValidForQueue: ManagedProperty; - IsVisibleInMobile: ManagedProperty; - IsVisibleInMobileClient: boolean; - LogicalName: string; - ManyToManyRelationships: ManyToManyRelationshipMetadata; - ManyToOneRelationships: OneToManyRelationshipMetadata; - MetadataId: string; - ObjectTypeCode: number; - OneToManyRelationships: OneToManyRelationshipMetadata; - OwnershipType: "BusinessOwned" | "BusinessParented" | "None OrganizationOwned" | "TeamOwned UserOwned"; - PrimaryIdAttribute: string; - PrimaryImageAttribute: string; - PrimaryNameAttribute: string; - Privileges: SecurityPrivilegeMetadata[]; - RecurrenceBaseEntityLogicalName: string; - ReportViewName: string; - SchemaName: string; - } - - export interface SecurityPrivilegeMetadata - { - CanBeBasic: boolean; - CanBeDeep: boolean; - CanBeEntityReference: boolean; - CanBeGlobal: boolean; - CanBeLocal: boolean; - CanBeParentEntityReference: boolean; - ExtensionData: boolean; - Name: string; - PrivilegeId: string; - PrivilegeType: "Append" | "AppendTo" | "Assign" | "Create" | "Delete" | "None" | "Read" | "Share" | "Write"; - } - - export interface OneToManyRelationshipMetadata - { - AssociatedMenuConfiguration: AssociatedMenuConfiguration; - CascadeConfiguration: CascadeConfiguration; - HasChanged: any; - IntroducedVersion: any; - IsCustomizable: ManagedProperty; - IsCustomRelationship: boolean; - IsHierarchical: any; - IsManaged: boolean; - IsValidForAdvancedFind: boolean; - MetadataId: string; - ReferencedAttribute: string; - ReferencedEntity: string; - ReferencingAttribute: string; - ReferencingEntity: string; - RelationshipType: string; - SchemaName: string; - SecurityTypes: any; - } - - export interface CascadeConfiguration - { - Assign: CascadeType; - Delete: CascadeType; - ExtensionData: CascadeType; - Merge: CascadeType; - Reparent: CascadeType; - Share: CascadeType; - Unshare: CascadeType; - } - - export type CascadeType = "Active" | "Cascade" | "NoCascade" | "UserOwned"; - - export interface ManyToManyRelationshipMetadata - { - Entity1AssociatedMenuConfiguration: AssociatedMenuConfiguration; - Entity1IntersectAttribute: string; - Entity1LogicalName: string; - Entity2AssociatedMenuConfiguration: AssociatedMenuConfiguration; - Entity2IntersectAttribute: string; - Entity2LogicalName: string; - HasChanged: boolean; - IntersectEntityName: string; - IntroducedVersion: any; - IsCustomizable: ManagedProperty; - IsCustomRelationship: boolean; - IsManaged: boolean; - IsValidForAdvancedFind: boolean; - MetadataId: string; - RelationshipType: RelationshipType; - SchemaName: string; - SecurityTypes: SecurityType; - } - - export interface AssociatedMenuConfiguration - { - Behavior: AssociatedMenuBehavior; - Group: AssociatedMenuGroup; - Label: Label; - Order: number; - } - - export type AssociatedMenuBehavior = "DoNotDisplay" | "UseCollectionName" | "UseLabel"; - - export type AssociatedMenuGroup = "Details" | "Marketing" | "Sales" | "Service"; - - export type RelationshipType = "Default" | "ManyToManyRelationship" | "OneToManyRelationship"; - - export type SecurityType = "Append" | "Inheritance" | "None" | "ParentChild" | "Pointer"; - - export interface IAttributeMetadata - { - AttributeOf: string; - AttributeType: "Customer" | "DateTime" | "Decimal" | "Double" | "EntityName" | "Integer" | "Lookup" | "ManagedProperty" | "Memo" | "Money" | "Owner" | "PartyList" | "Picklist" | "State" | "Status" | "Uniqueidentifier" | "Virtual" - AttributeTypeName: "BigIntType" | "BooleanType" | "CalendarRulesType" | "CustomerType" | "DateTimeType" | "DecimalType" | "DoubleType" | "EntityNameType" | "ImageType" | "IntegerType" | "LookupType" | "ManagedPropertyType" | "MemoType" | "MoneyType" | "OwnerType" | "PartyListType" | "PicklistType" | "StateType StatusType" | "StringType" | "UniqueidentifierType" | "VirtualType"; - CalculationOf: any; - CanBeSecuredForCreate: boolean; - CanBeSecuredForRead: boolean; - CanBeSecuredForUpdate: boolean; - CanModifyAdditionalSettings: ManagedProperty; - ColumnNumber: number; - DefaultFormValue: any; - DefaultValue: any; - DeprecatedVersion: any; - Description: Label; - DisplayName: Label; - EntityLogicalName: string; - Format: any; - FormatName: string; - ImeMode: any; - IntroducedVersion: any; - IsAuditEnabled: boolean; - IsCustomAttribute: boolean; - IsCustomizable: ManagedProperty; - IsManaged: boolean; - IsPrimaryId: boolean; - IsPrimaryName: boolean; - IsRenameable: ManagedProperty; - IsSecured: boolean; - IsValidForAdvancedFind: ManagedProperty; - IsValidForCreate: boolean; - IsValidForRead: boolean; - IsValidForUpdate: boolean; - LinkedAttributeId: string; - LogicalName: string; - MaxLength: number; - MaxValue: any; - MetadataId: string; - MinValue: number; - OptionSet: any; - Precision: any; - PrecisionSource: any; - RequiredLevel: ManagedProperty; - SchemaName: string; - Targets: string[]; - YomiOf: any; - } - - export interface ManagedProperty - { - CanBeChanged: boolean; - ManagedPropertyLogicalName: string; - Value: T; - } - - export interface Label - { - LocalizedLabels: LocalizedLabel[]; - UserLocalizedLabel: LocalizedLabel; - } - - export interface LocalizedLabel - { - Label: string; - LangaugeCode: number; - MetadataId: string; - HasChanged: boolean; - IsManaged: boolean; - } - - namespace ValueEnums - { - export enum OwnershipType - { - None, - OrganizationOwned, - TeamOwned, - UserOwned, + namespace Sdk.Mdq { + /** + * Defines a complex query to retrieve entity metadata. + * @param criteria The filter criteria for the metadata query. + * @param properties The properties to be returned by the query. + * @param attributeQuery A query expression for the entity attribute metadata to return. + * @param relationshipQuery A query expression for the entity relationship metadata to return. + * @param labelQuery A query expression for the labels to return. + */ + export class EntityQueryExpression { + constructor( + criteria: Sdk.Mdq.MetadataFilterExpression, + properties: Sdk.Mdq.MetadataPropertiesExpression, + attributeQuery?: Sdk.Mdq.AttributeQueryExpression, + relationshipQuery?: Sdk.Mdq.RelationshipQueryExpression, + labelQuery?: Sdk.Mdq.LabelQueryExpression); } - export enum AttributeTypeCode - { - BigInt, - Boolean, - CalendarRules, - Customer, - DateTime, - Decimal, - Double, - EntityName, - Integer, - Lookup, - ManagedProperty, - Memo, - Money, - Owner, - PartyList, - Picklist, - State, - Status, - String, - Uniqueidentifier, - Virtual, + /** + * An enumeration that specifies the type of deleted metadata to retrieve. + */ + export enum DeletedMetadataFilters { + All, // All deleted metadata + Attribute, // Deleted Attribute metadata + Default, // The value used if not set. Equals Entity + Entity, //Deleted Entity metadata + Label, //Deleted Label metadata + OptionSet, // Deleted OptionSet metadata + Relationship, //Deleted Relationship metadata } + /** + * Specifies complex condition and logical filter expressions used for filtering the results of a metadata query. + * @param filterOperator The logical AND/OR filter operator. + */ - export enum AttributeRequiredLevel - { - ApplicationRequired, - None, - Recommended, - SystemRequired, + export class MetadataFilterExpression { + constructor(filterOperator: Sdk.Mdq.LogicalOperator); + + /** + * Adds a condition. This method accepts either the properties to create a new Sdk.Mdq.MetadataConditionExpression or a Sdk.Mdq.MetadataConditionExpression as the first argument. + * @param propertyName The metadata property to evaluate. + * @param conditionOperator The condition operator. + * @param value The metadata value to evaluate. + */ + public addCondition( + propertyName: SearchableEntityMetadataProperties | SearchableAttributeMetadataProperties | SearchableRelationshipMetadataProperties, + conditionOperator: MetadataConditionOperator, + value: Object): void; + public addCondition( + propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator, value: any): void; + public addCondition( + propertyName: SearchableEntityMetadataProperties | SearchableAttributeMetadataProperties | SearchableRelationshipMetadataProperties, + conditionOperator: MetadataConditionOperator, + value: Object): void; + addCondition(propertyName: SearchableAttributeMetadataProperties, conditionOperator: MetadataConditionOperator): void; + public addCondition( + propertyName: SearchableEntityMetadataProperties | SearchableAttributeMetadataProperties | SearchableRelationshipMetadataProperties, + conditionOperator: MetadataConditionOperator, + value: Object): void; } - - export enum DateTimeFormat - { - DateAndTime, - DateOnly, + /** + * Defines a complex query to retrieve attribute metadata for entities retrieved using an Sdk.Mdq.EntityQueryExpression. + * @param criteria The filter criteria for the metadata query. + * @param properties The properties to be returned by the query. + */ + export class AttributeQueryExpression { + constructor(criteria: MetadataFilterExpression, properties: Sdk.Mdq.MetadataPropertiesExpression); } - export enum ImeMode - { - Active, - Auto, - Disabled, - Inactive, + /** + * Defines a complex query to retrieve entity relationship metadata for entities retrieved using an EntityQueryExpression. + * @param criteria The filter criteria for the metadata query. + * @param properties The properties to be returned by the query. + */ + export class RelationshipQueryExpression { + constructor(criteria: MetadataFilterExpression, properties: Mdq.MetadataPropertiesExpression); } - - - export enum IntegerFormat - { - Duration, - Language, - Locale, - None, - TimeZone, + /** + * Defines the languages for the labels to be retrieved for metadata items that have labels. + * @param languages An array of LCID number values. + */ + export class LabelQueryExpression { + constructor(languages: Array); } - - export enum SecurityTypes - { - Append, - Inheritance, - None, - ParentChild, - Pointer, + /** + * Logical operator. + */ + export enum LogicalOperator { + And, + Or, } - export enum StringFormat - { - Email, - PhoneticGuide, - Text, - TextArea, - TickerSymbol, - Url, - VersionNumber, + /** + * Specifies the properties for which non-null values are returned from a query. + * @param allProperties Whether to retrieve all the properties of a metadata object. + * @param propertyNames: >An array of strings representing the metadata properties to retrieve. + */ + export class MetadataPropertiesExpression { + constructor(allProperties: boolean, propertyNames?: Array); + } + + export enum RelationshipMetadataProperties { + AssociatedMenuConfiguration, + CascadeConfiguration, + HasChanged, + Entity1AssociatedMenuConfiguration, + Entity1IntersectAttribute, + Entity1LogicalName, + Entity2AssociatedMenuConfiguration, + Entity2IntersectAttribute, + Entity2LogicalName, + IntersectEntityName, + IsCustomizable, + IntroducedVersion, + IsCustomRelationship, + IsManaged, + IsValidForAdvancedFind, + MetadataId, + ReferencedAttribute, + ReferencedEntity, + ReferencingAttribute, + ReferencingEntity, + RelationshipType, + SchemaName, + SecurityTypes, + } + + export enum AttributeMetadataProperties { + AttributeOf, + AttributeType, + AttributeTypeName, + CalculationOf, + CanBeSecuredForCreate, + CanBeSecuredForRead, + CanBeSecuredForUpdate, + CanModifyAdditionalSettings, + ColumnNumber, + DefaultFormValue, + DefaultValue, + DeprecatedVersion, + Description, + DisplayName, + EntityLogicalName, + Format, + FormatName, + ImeMode, + IntroducedVersion, + IsAuditEnabled, + IsCustomAttribute, + IsCustomizable, + IsManaged, + IsPrimaryId, + IsPrimaryName, + IsRenameable, + IsSecured, + IsValidForAdvancedFind, + IsValidForCreate, + IsValidForRead, + IsValidForUpdate, + LinkedAttributeId, + LogicalName, + MaxLength, + MaxValue, + MetadataId, + MinValue, + OptionSet, + Precision, + PrecisionSource, + RequiredLevel, + SchemaName, + Targets, + YomiOf, + } + + export enum EntityMetadataProperties { + ActivityTypeMask, + Attributes, + AutoCreateAccessTeams, + AutoRouteToOwnerQueue, + CanBeInManyToMany, + CanBePrimaryEntityInRelationship, + CanBeRelatedEntityInRelationship, + CanCreateAttributes, + CanCreateCharts, + CanCreateForms, + CanCreateViews, + CanModifyAdditionalSettings, + CanTriggerWorkflow, + Description, + DisplayCollectionName, + DisplayName, + IconLargeName, + IconMediumName, + IconSmallName, + IntroducedVersion, + IsActivity, + IsActivityParty, + IsAIRUpdated, + IsAuditEnabled, + IsAvailableOffline, + IsBusinessProcessEnabled, + IsChildEntity, + IsConnectionsEnabled, + IsCustomEntity, + IsCustomizable, + IsDocumentManagementEnabled, + IsDuplicateDetectionEnabled, + IsEnabledForCharts, + IsImportable, + IsIntersect, + IsMailMergeEnabled, + IsManaged, + IsMappable, + IsQuickCreateEnabled, + IsReadingPaneEnabled, + IsRenameable, + IsValidForAdvancedFind, + IsValidForQueue, + IsVisibleInMobile, + IsVisibleInMobileClient, + LogicalName, + ManyToManyRelationships, + ManyToOneRelationships, + MetadataId, + ObjectTypeCode, + OneToManyRelationships, + OwnershipType, + PrimaryIdAttribute, + PrimaryImageAttribute, + PrimaryNameAttribute, + Privileges, + RecurrenceBaseEntityLogicalName, + ReportViewName, + SchemaName, + } + + export enum SearchableEntityMetadataProperties { + ActivityTypeMask, + AutoCreateAccessTeams, + AutoRouteToOwnerQueue, + CanBeInManyToMany, + CanBePrimaryEntityInRelationship, + CanBeRelatedEntityInRelationship, + CanCreateAttributes, + CanCreateCharts, + CanCreateForms, + CanCreateViews, + CanModifyAdditionalSettings, + CanTriggerWorkflow, + IconLargeName, + IconMediumName, + IconSmallName, + IntroducedVersion, + IsActivity, + IsActivityParty, + IsAIRUpdated, + IsAuditEnabled, + IsAvailableOffline, + IsBusinessProcessEnabled, + IsChildEntity, + IsConnectionsEnabled, + IsCustomEntity, + IsCustomizable, + IsDocumentManagementEnabled, + IsDuplicateDetectionEnabled, + IsEnabledForCharts, + IsImportable, + IsIntersect, + IsMailMergeEnabled, + IsManaged, + IsMappable, + IsQuickCreateEnabled, + IsReadingPaneEnabled, + IsRenameable, + IsValidForAdvancedFind, + IsValidForQueue, + IsVisibleInMobile, + IsVisibleInMobileClient, + LogicalName, + MetadataId, + ObjectTypeCode, + OwnershipType, + PrimaryIdAttribute, + PrimaryImageAttribute, + PrimaryNameAttribute, + RecurrenceBaseEntityLogicalName, + ReportViewName, + SchemaName, + } + + export enum SearchableAttributeMetadataProperties { + AttributeOf, + AttributeType, + CalculationOf, + CanBeSecuredForCreate, + CanBeSecuredForRead, + CanBeSecuredForUpdate, + CanModifyAdditionalSettings, + ColumnNumber, + DefaultFormValue, + DefaultValue, + DeprecatedVersion, + EntityLogicalName, + Format, + FormatName, + ImeMode, + IntroducedVersion, + IsAuditEnabled, + IsCustomAttribute, + IsCustomizable, + IsManaged, + IsPrimaryId, + IsPrimaryName, + IsRenameable, + IsSecured, + IsValidForAdvancedFind, + IsValidForCreate, + IsValidForRead, + IsValidForUpdate, + LinkedAttributeId, + LogicalName, + MaxLength, + MaxValue, + MetadataId, + MinValue, + Precision, + PrecisionSource, + RequiredLevel, + SchemaName, + YomiOf, + } + + export enum SearchableRelationshipMetadataProperties { + HasChanged, + Entity1IntersectAttribute, + Entity1LogicalName, + Entity2IntersectAttribute, + Entity2LogicalName, + IntersectEntityName, + IsCustomizable, + IntroducedVersion, + IsCustomRelationship, + IsManaged, + IsValidForAdvancedFind, + MetadataId, + ReferencedAttribute, + ReferencedEntity, + ReferencingAttribute, + ReferencingEntity, + RelationshipType, + SchemaName, + SecurityTypes, + } + + export enum MetadataConditionOperator { + Equals, + NotEquals, + In, + NotIn, + GreaterThan, + LessThan, + } + + export interface IEntityMetadata { + ActivityTypeMask: number; + Attributes: IAttributeMetadata[]; + AutoCreateAccessTeams: any; + AutoRouteToOwnerQueue: boolean; + CanBeInManyToMany: ManagedProperty; + CanBePrimaryEntityInRelationship: ManagedProperty; + CanBeRelatedEntityInRelationship: ManagedProperty; + CanCreateAttributes: ManagedProperty; + CanCreateCharts: ManagedProperty; + CanCreateForms: ManagedProperty; + CanCreateViews: ManagedProperty; + CanModifyAdditionalSettings: ManagedProperty; + CanTriggerWorkflow: boolean; + Description: Label; + DisplayCollectionName: Label; + DisplayName: Label; + IconLargeName: string; + IconMediumName: string; + IconSmallName: string; + IntroducedVersion: any; + IsActivity: boolean; + IsActivityParty: boolean; + IsAIRUpdated: boolean; + IsAuditEnabled: ManagedProperty; + IsAvailableOffline: boolean; + IsBusinessProcessEnabled: boolean; + IsChildEntity: boolean; + IsConnectionsEnabled: ManagedProperty; + IsCustomEntity: boolean; + IsCustomizable: ManagedProperty; + IsDocumentManagementEnabled: boolean; + IsDuplicateDetectionEnabled: ManagedProperty; + IsEnabledForCharts: boolean; + IsImportable: boolean; + IsIntersect: boolean; + IsMailMergeEnabled: ManagedProperty; + IsManaged: boolean; + IsMappable: ManagedProperty; + IsQuickCreateEnabled: boolean; + IsReadingPaneEnabled: boolean; + IsRenameable: boolean; + IsValidForAdvancedFind: boolean; + IsValidForQueue: ManagedProperty; + IsVisibleInMobile: ManagedProperty; + IsVisibleInMobileClient: boolean; + LogicalName: string; + ManyToManyRelationships: ManyToManyRelationshipMetadata; + ManyToOneRelationships: OneToManyRelationshipMetadata; + MetadataId: string; + ObjectTypeCode: number; + OneToManyRelationships: OneToManyRelationshipMetadata; + OwnershipType: "BusinessOwned" | "BusinessParented" | "None OrganizationOwned" | "TeamOwned UserOwned"; + PrimaryIdAttribute: string; + PrimaryImageAttribute: string; + PrimaryNameAttribute: string; + Privileges: SecurityPrivilegeMetadata[]; + RecurrenceBaseEntityLogicalName: string; + ReportViewName: string; + SchemaName: string; + } + + export interface SecurityPrivilegeMetadata { + CanBeBasic: boolean; + CanBeDeep: boolean; + CanBeEntityReference: boolean; + CanBeGlobal: boolean; + CanBeLocal: boolean; + CanBeParentEntityReference: boolean; + ExtensionData: boolean; + Name: string; + PrivilegeId: string; + PrivilegeType: "Append" | "AppendTo" | "Assign" | "Create" | "Delete" | "None" | "Read" | "Share" | "Write"; + } + + export interface OneToManyRelationshipMetadata { + AssociatedMenuConfiguration: AssociatedMenuConfiguration; + CascadeConfiguration: CascadeConfiguration; + HasChanged: any; + IntroducedVersion: any; + IsCustomizable: ManagedProperty; + IsCustomRelationship: boolean; + IsHierarchical: any; + IsManaged: boolean; + IsValidForAdvancedFind: boolean; + MetadataId: string; + ReferencedAttribute: string; + ReferencedEntity: string; + ReferencingAttribute: string; + ReferencingEntity: string; + RelationshipType: string; + SchemaName: string; + SecurityTypes: any; + } + + export interface CascadeConfiguration { + Assign: CascadeType; + Delete: CascadeType; + ExtensionData: CascadeType; + Merge: CascadeType; + Reparent: CascadeType; + Share: CascadeType; + Unshare: CascadeType; + } + + export type CascadeType = "Active" | "Cascade" | "NoCascade" | "UserOwned"; + + export interface ManyToManyRelationshipMetadata { + Entity1AssociatedMenuConfiguration: AssociatedMenuConfiguration; + Entity1IntersectAttribute: string; + Entity1LogicalName: string; + Entity2AssociatedMenuConfiguration: AssociatedMenuConfiguration; + Entity2IntersectAttribute: string; + Entity2LogicalName: string; + HasChanged: boolean; + IntersectEntityName: string; + IntroducedVersion: any; + IsCustomizable: ManagedProperty; + IsCustomRelationship: boolean; + IsManaged: boolean; + IsValidForAdvancedFind: boolean; + MetadataId: string; + RelationshipType: RelationshipType; + SchemaName: string; + SecurityTypes: SecurityType; + } + + export interface AssociatedMenuConfiguration { + Behavior: AssociatedMenuBehavior; + Group: AssociatedMenuGroup; + Label: Label; + Order: number; + } + + export type AssociatedMenuBehavior = "DoNotDisplay" | "UseCollectionName" | "UseLabel"; + + export type AssociatedMenuGroup = "Details" | "Marketing" | "Sales" | "Service"; + + export type RelationshipType = "Default" | "ManyToManyRelationship" | "OneToManyRelationship"; + + export type SecurityType = "Append" | "Inheritance" | "None" | "ParentChild" | "Pointer"; + + export interface IAttributeMetadata { + AttributeOf: string; + AttributeType: "Customer" | "DateTime" | "Decimal" | "Double" | "EntityName" | "Integer" | "Lookup" | "ManagedProperty" | "Memo" | "Money" | "Owner" | "PartyList" | "Picklist" | "State" | "Status" | "Uniqueidentifier" | "Virtual" + AttributeTypeName: "BigIntType" | "BooleanType" | "CalendarRulesType" | "CustomerType" | "DateTimeType" | "DecimalType" | "DoubleType" | "EntityNameType" | "ImageType" | "IntegerType" | "LookupType" | "ManagedPropertyType" | "MemoType" | "MoneyType" | "OwnerType" | "PartyListType" | "PicklistType" | "StateType StatusType" | "StringType" | "UniqueidentifierType" | "VirtualType"; + CalculationOf: any; + CanBeSecuredForCreate: boolean; + CanBeSecuredForRead: boolean; + CanBeSecuredForUpdate: boolean; + CanModifyAdditionalSettings: ManagedProperty; + ColumnNumber: number; + DefaultFormValue: any; + DefaultValue: any; + DeprecatedVersion: any; + Description: Label; + DisplayName: Label; + EntityLogicalName: string; + Format: any; + FormatName: string; + ImeMode: any; + IntroducedVersion: any; + IsAuditEnabled: boolean; + IsCustomAttribute: boolean; + IsCustomizable: ManagedProperty; + IsManaged: boolean; + IsPrimaryId: boolean; + IsPrimaryName: boolean; + IsRenameable: ManagedProperty; + IsSecured: boolean; + IsValidForAdvancedFind: ManagedProperty; + IsValidForCreate: boolean; + IsValidForRead: boolean; + IsValidForUpdate: boolean; + LinkedAttributeId: string; + LogicalName: string; + MaxLength: number; + MaxValue: any; + MetadataId: string; + MinValue: number; + OptionSet: any; + Precision: any; + PrecisionSource: any; + RequiredLevel: ManagedProperty; + SchemaName: string; + Targets: string[]; + YomiOf: any; + } + + export interface ManagedProperty { + CanBeChanged: boolean; + ManagedPropertyLogicalName: string; + Value: T; + } + + export interface Label { + LocalizedLabels: LocalizedLabel[]; + UserLocalizedLabel: LocalizedLabel; + } + + export interface LocalizedLabel { + Label: string; + LangaugeCode: number; + MetadataId: string; + HasChanged: boolean; + IsManaged: boolean; + } + + namespace ValueEnums { + export enum OwnershipType { + None, + OrganizationOwned, + TeamOwned, + UserOwned, + } + + export enum AttributeTypeCode { + BigInt, + Boolean, + CalendarRules, + Customer, + DateTime, + Decimal, + Double, + EntityName, + Integer, + Lookup, + ManagedProperty, + Memo, + Money, + Owner, + PartyList, + Picklist, + State, + Status, + String, + Uniqueidentifier, + Virtual, + } + + + export enum AttributeRequiredLevel { + ApplicationRequired, + None, + Recommended, + SystemRequired, + } + + + export enum DateTimeFormat { + DateAndTime, + DateOnly, + } + + export enum ImeMode { + Active, + Auto, + Disabled, + Inactive, + } + + + + export enum IntegerFormat { + Duration, + Language, + Locale, + None, + TimeZone, + } + + + export enum SecurityTypes { + Append, + Inheritance, + None, + ParentChild, + Pointer, + } + + export enum StringFormat { + Email, + PhoneticGuide, + Text, + TextArea, + TickerSymbol, + Url, + VersionNumber, + } } } -} -declare namespace Sdk.Mdq.ValueEnums -{ } + namespace Sdk.Mdq.ValueEnums + { } +} \ No newline at end of file diff --git a/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts b/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts index 2e55285870..3be28629c3 100644 --- a/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts +++ b/microsoft-sdk-soap/microsoft-sdk-soap-tests.ts @@ -1,4 +1,5 @@ +import * as Q from "q"; // QueryByAttribute var queryByAttribute = new Sdk.Query.QueryByAttribute( "account" ); @@ -17,4 +18,4 @@ queryExpression.addCondition( "account", "accountname", Sdk.Query.ConditionOpera Sdk.Q.retrieveMultiple( queryExpression ).then( entityCollection => { console.log( "Query matches " + entityCollection.getTotalRecordCount() + " records." ); -} ); \ No newline at end of file +} ); \ No newline at end of file diff --git a/microsoft-sdk-soap/tsconfig.json b/microsoft-sdk-soap/tsconfig.json index ef973bcb22..41ffa9a040 100644 --- a/microsoft-sdk-soap/tsconfig.json +++ b/microsoft-sdk-soap/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/mongoose-seeder/tsconfig.json b/mongoose-seeder/tsconfig.json index 143fcc1ce4..8e3f193dbf 100644 --- a/mongoose-seeder/tsconfig.json +++ b/mongoose-seeder/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/msportalfx-test/index.d.ts b/msportalfx-test/index.d.ts index a3fbc2d26f..c2d64f95d4 100644 --- a/msportalfx-test/index.d.ts +++ b/msportalfx-test/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Julio Casal // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; export = MsPortalTestFx; diff --git a/msportalfx-test/tsconfig.json b/msportalfx-test/tsconfig.json index 115af8c6ef..16c68ed3a8 100644 --- a/msportalfx-test/tsconfig.json +++ b/msportalfx-test/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/node-form/index.d.ts b/node-form/index.d.ts index 41781ee154..ddeb3d542f 100644 --- a/node-form/index.d.ts +++ b/node-form/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Roman Samec // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; export as namespace Validation; diff --git a/node-form/tsconfig.json b/node-form/tsconfig.json index 1bb627df73..d0fa4eb87b 100644 --- a/node-form/tsconfig.json +++ b/node-form/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/node-persist/index.d.ts b/node-persist/index.d.ts index 42d72fe587..bb8df33369 100644 --- a/node-persist/index.d.ts +++ b/node-persist/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import * as Q from "q"; diff --git a/node-persist/tsconfig.json b/node-persist/tsconfig.json index f6bd656274..b2563c2ac3 100644 --- a/node-persist/tsconfig.json +++ b/node-persist/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/o.js/index.d.ts b/o.js/index.d.ts index eaa6732c40..00a5f2b5ae 100644 --- a/o.js/index.d.ts +++ b/o.js/index.d.ts @@ -3,9 +3,9 @@ // Definitions by: Matteo Antony Mistretta , Brad Zacher // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - declare module 'o.js' { + import Q = require("q"); + interface Options { endpoint : string json ?: boolean diff --git a/o.js/tsconfig.json b/o.js/tsconfig.json index a72850afef..b16d5111e8 100644 --- a/o.js/tsconfig.json +++ b/o.js/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/orchestrator/index.d.ts b/orchestrator/index.d.ts index 23c8a0f507..c1eae16416 100644 --- a/orchestrator/index.d.ts +++ b/orchestrator/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Qubo // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; declare type Strings = string|string[]; diff --git a/orchestrator/tsconfig.json b/orchestrator/tsconfig.json index 1ce0c08b62..d3af83cd62 100644 --- a/orchestrator/tsconfig.json +++ b/orchestrator/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/pathwatcher/tsconfig.json b/pathwatcher/tsconfig.json index 199b1ce4e0..00b8e7052f 100644 --- a/pathwatcher/tsconfig.json +++ b/pathwatcher/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/promise-pg/index.d.ts b/promise-pg/index.d.ts index 5deba594a1..d93f13d8c0 100644 --- a/promise-pg/index.d.ts +++ b/promise-pg/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import * as stream from 'stream'; import * as pg from 'pg'; diff --git a/promise-pg/tsconfig.json b/promise-pg/tsconfig.json index 0f74dbb52b..b28fb9baa9 100644 --- a/promise-pg/tsconfig.json +++ b/promise-pg/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/promise-pool/index.d.ts b/promise-pool/index.d.ts index 810b629ee2..51af449480 100644 --- a/promise-pool/index.d.ts +++ b/promise-pool/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// import * as Q from "q"; /** diff --git a/promise-pool/tsconfig.json b/promise-pool/tsconfig.json index b72557a58b..f7be6ce41d 100644 --- a/promise-pool/tsconfig.json +++ b/promise-pool/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/q-io/index.d.ts b/q-io/index.d.ts index b69a9c72e0..783f70ddc4 100644 --- a/q-io/index.d.ts +++ b/q-io/index.d.ts @@ -4,7 +4,6 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// //TODO add support for q-io/http-apps //TODO add verified support for q-io/fs-mock @@ -15,94 +14,94 @@ declare namespace QioFS { //TODO how to define the multiple return types? use any for now? - export function open(path:string, options?:any):Q.Promise; + export function open(path: string, options?: any): Q.Promise; //export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; //export function open(path:string, options?:any):Q.Promise; //TODO how to define the multiple return types? use any for now? - export function read(path:string, options?:any):Q.Promise; + export function read(path: string, options?: any): Q.Promise; //export function read(path:string, options?:any):Q.Promise; //export function read(path:string, options?:any):Q.Promise; - export function write(path:string, content:Buffer, options?:any):Q.Promise; - export function write(path:string, content:string, options?:any):Q.Promise; + export function write(path: string, content: Buffer, options?: any): Q.Promise; + export function write(path: string, content: string, options?: any): Q.Promise; - export function append(path:string, content:Buffer, options?:any):Q.Promise; - export function append(path:string, content:string, options?:any):Q.Promise; + export function append(path: string, content: Buffer, options?: any): Q.Promise; + export function append(path: string, content: string, options?: any): Q.Promise; - export function copy(source:string, target:string):Q.Promise; - export function copyTree(source:string, target:string):Q.Promise; + export function copy(source: string, target: string): Q.Promise; + export function copyTree(source: string, target: string): Q.Promise; - export function list(path:string):Q.Promise; - export function listTree(path:string, guard?:(path:string, stat:any) => boolean):Q.Promise; - export function listDirectoryTree(path:string):Q.Promise; + export function list(path: string): Q.Promise; + export function listTree(path: string, guard?: (path: string, stat: any) => boolean): Q.Promise; + export function listDirectoryTree(path: string): Q.Promise; - export function makeDirectory(path:string, mode?:string):Q.Promise; - export function makeDirectory(path:string, mode?:number):Q.Promise; - export function makeTree(path:string, mode?:string):Q.Promise; - export function makeTree(path:string, mode?:number):Q.Promise; + export function makeDirectory(path: string, mode?: string): Q.Promise; + export function makeDirectory(path: string, mode?: number): Q.Promise; + export function makeTree(path: string, mode?: string): Q.Promise; + export function makeTree(path: string, mode?: number): Q.Promise; - export function remove(path:string):Q.Promise; - export function removeTree(path:string):Q.Promise; + export function remove(path: string): Q.Promise; + export function removeTree(path: string): Q.Promise; - export function rename(source:string, target:string):Q.Promise; - export function move(source:string, target:string):Q.Promise; + export function rename(source: string, target: string): Q.Promise; + export function move(source: string, target: string): Q.Promise; - export function link(source:string, target:any):Q.Promise; + export function link(source: string, target: any): Q.Promise; - export function symbolicCopy(source:string, target:string, type:string):Q.Promise; - export function symbolicLink(target:string, link:string, type:string):Q.Promise; + export function symbolicCopy(source: string, target: string, type: string): Q.Promise; + export function symbolicLink(target: string, link: string, type: string): Q.Promise; - export function chown(path:string, uid:number, gid:number):Q.Promise; - export function chmod(path:string, mode?:string):Q.Promise; - export function chmod(path:string, mode?:number):Q.Promise; + export function chown(path: string, uid: number, gid: number): Q.Promise; + export function chmod(path: string, mode?: string): Q.Promise; + export function chmod(path: string, mode?: number): Q.Promise; - export function stat(path:string):Q.Promise; - export function statLink(path:string):Q.Promise; - export function statFd(fd:number):Q.Promise; + export function stat(path: string): Q.Promise; + export function statLink(path: string): Q.Promise; + export function statFd(fd: number): Q.Promise; - export function exists(path:string):Q.Promise; + export function exists(path: string): Q.Promise; - export function isFile(path:string):Q.Promise; - export function isDirectory(path:string):Q.Promise; - export function isSymbolicLink(path:string):Q.Promise; + export function isFile(path: string): Q.Promise; + export function isDirectory(path: string): Q.Promise; + export function isSymbolicLink(path: string): Q.Promise; - export function lastModified(path:string):Q.Promise; - export function lastAccessed(path:string):Q.Promise; + export function lastModified(path: string): Q.Promise; + export function lastAccessed(path: string): Q.Promise; - export function split(path:string):string[]; - export function join(...paths:string[]):string; - export function join(paths:string[]):string; - export function resolve(...path:string[]):string; - export function resolve(paths:string[]):string; - export function normal(...path:string[]):string; - export function normal(paths:string[]):string; - export function absolute(path:string):string; + export function split(path: string): string[]; + export function join(...paths: string[]): string; + export function join(paths: string[]): string; + export function resolve(...path: string[]): string; + export function resolve(paths: string[]): string; + export function normal(...path: string[]): string; + export function normal(paths: string[]): string; + export function absolute(path: string): string; - export function canonical(path:string):Q.Promise; - export function readLink(path:string):Q.Promise; + export function canonical(path: string): Q.Promise; + export function readLink(path: string): Q.Promise; - export function contains(parent:string, child:string):boolean; + export function contains(parent: string, child: string): boolean; - export function relative(source:string, target:string):Q.Promise; + export function relative(source: string, target: string): Q.Promise; - export function relativeFromFile(source:string, target:string):string; - export function relativeFromDirectory(source:string, target:string):string; + export function relativeFromFile(source: string, target: string): string; + export function relativeFromDirectory(source: string, target: string): string; - export function isAbsolute(path:string):boolean; - export function isRelative(path:string):boolean; - export function isRoot(path:string):boolean; + export function isAbsolute(path: string): boolean; + export function isRelative(path: string): boolean; + export function isRoot(path: string): boolean; - export function root(path:string):string; - export function directory(path:string):string; - export function base(path:string, extension:string):string; - export function extension(path:string):string; + export function root(path: string): string; + export function directory(path: string): string; + export function base(path: string, extension: string): string; + export function extension(path: string): string; //this should return a q-io/fs-mock MockFS - export function reroot(path:string):typeof QioFS; + export function reroot(path: string): typeof QioFS; - export function toObject(path:string):{[path:string]:Buffer}; + export function toObject(path: string): { [path: string]: Buffer }; //listed but not implemented by Q-io //export function glob(pattern):Q.Promise; @@ -110,116 +109,116 @@ declare namespace QioFS { //TODO link this to node.js FS module (no lazy clones) interface Stats { - node:NodeStats; - size:number; + node: NodeStats; + size: number; } interface NodeStats { - isFile():boolean; - isDirectory():boolean; - isBlockDevice():boolean; - isCharacterDevice():boolean; - isSymbolicLink():boolean; - isFIFO():boolean; - isSocket():boolean; - node:NodeStats; - dev:number; - ino:number; - mode:number; - nlink:number; - uid:number; - gid:number; - rdev:number; - size:number; - blksize:number; - blocks:number; - atime:Date; - mtime:Date; - ctime:Date; + isFile(): boolean; + isDirectory(): boolean; + isBlockDevice(): boolean; + isCharacterDevice(): boolean; + isSymbolicLink(): boolean; + isFIFO(): boolean; + isSocket(): boolean; + node: NodeStats; + dev: number; + ino: number; + mode: number; + nlink: number; + uid: number; + gid: number; + rdev: number; + size: number; + blksize: number; + blocks: number; + atime: Date; + mtime: Date; + ctime: Date; } } declare namespace QioHTTP { - export function request(request:Request):Q.Promise; - export function request(url:string):Q.Promise; + export function request(request: Request): Q.Promise; + export function request(url: string): Q.Promise; - export function read(request:Request):Q.Promise; - export function read(url:string):Q.Promise; + export function read(request: Request): Q.Promise; + export function read(url: string): Q.Promise; - export function normalizeRequest(request:Request):Request; - export function normalizeRequest(url:string):Request; - export function normalizeResponse(response:Response):Response; + export function normalizeRequest(request: Request): Request; + export function normalizeRequest(url: string): Request; + export function normalizeResponse(response: Response): Response; interface Request { - url:string; - path:string; - scriptName:string; - pathInfo:string; - version:string[]; - method:string; - scheme:string; + url: string; + path: string; + scriptName: string; + pathInfo: string; + version: string[]; + method: string; + scheme: string; - host:string; - port:number; - remoteHost:string; - remotePort:number; + host: string; + port: number; + remoteHost: string; + remotePort: number; - headers:Headers; - agent:any; - body:any; - node:any; + headers: Headers; + agent: any; + body: any; + node: any; } interface Response { - status:number; - headers:Headers; - body:Qio.Reader - onclose:() => void; - node:any; + status: number; + headers: Headers; + body: Qio.Reader + onclose: () => void; + node: any; } interface Headers { - [name:string]:any; + [name: string]: any; // [name:string]:any[]; } interface Body extends Qio.Stream { } interface Application { - (req:Request):Q.Promise; + (req: Request): Q.Promise; } } declare namespace Qio { interface ForEachCallback { - (chunk:Buffer):Q.Promise; - (chunk:string):Q.Promise; + (chunk: Buffer): Q.Promise; + (chunk: string): Q.Promise; } interface ForEach { - forEach(callback:ForEachCallback):Q.Promise; + forEach(callback: ForEachCallback): Q.Promise; } interface Reader extends ForEach { - read(charset:string):Q.Promise; - read():Q.Promise; - close():void; + read(charset: string): Q.Promise; + read(): Q.Promise; + close(): void; node: NodeJS.ReadableStream; } interface Writer { - write(content:string):void; - write(content:Buffer):void; - flush():Q.Promise; - close():void; - destroy():void; + write(content: string): void; + write(content: Buffer): void; + flush(): Q.Promise; + close(): void; + destroy(): void; node: NodeJS.WritableStream; } interface Stream { - read(charset:string):Q.Promise; - read():Q.Promise; - write(content:string):void; - write(content:Buffer):void; - flush():Q.Promise; - close():void; - destroy():void; - node:any; + read(charset: string): Q.Promise; + read(): Q.Promise; + write(content: string): void; + write(content: Buffer): void; + flush(): Q.Promise; + close(): void; + destroy(): void; + node: any; } interface BufferReader extends QioBufferReader { @@ -227,31 +226,32 @@ declare namespace Qio { } } interface QioBufferReader { - new ():Qio.Reader; - read(stream:Qio.Reader, charset:string):string; - read(stream:Qio.Reader):Buffer; - join(buffers:Buffer[]):Buffer; + new (): Qio.Reader; + read(stream: Qio.Reader, charset: string): string; + read(stream: Qio.Reader): Buffer; + join(buffers: Buffer[]): Buffer; } interface QioBufferWriter { - (writer:Buffer):Qio.Writer; - Writer:Qio.Writer; + (writer: Buffer): Qio.Writer; + Writer: Qio.Writer; } interface QioBufferStream { - (buffer:Buffer, encoding:string):Qio.Stream + (buffer: Buffer, encoding: string): Qio.Stream } declare module "q-io/http" { -export = QioHTTP; + import * as Q from "q"; + export = QioHTTP; } declare module "q-io/fs" { -export = QioFS; + export = QioFS; } declare module "q-io/reader" { -export = QioBufferReader; + export = QioBufferReader; } declare module "q-io/writer" { -export = QioBufferWriter; + export = QioBufferWriter; } declare module "q-io/buffer-stream" { -export = QioBufferStream; + export = QioBufferStream; } diff --git a/q-io/q-io-tests.ts b/q-io/q-io-tests.ts index ae6d14d623..fb5e7e97c2 100644 --- a/q-io/q-io-tests.ts +++ b/q-io/q-io-tests.ts @@ -1,5 +1,3 @@ -import * as Q from 'q'; - var fs:typeof QioFS = require('q-io/fs'); var http:typeof QioHTTP = require('q-io/http'); diff --git a/q-io/tsconfig.json b/q-io/tsconfig.json index a0afa359c6..cccbe944b1 100644 --- a/q-io/tsconfig.json +++ b/q-io/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/q-retry/index.d.ts b/q-retry/index.d.ts index dbdf914b6c..2d06f97f2e 100644 --- a/q-retry/index.d.ts +++ b/q-retry/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: VILIC VANE // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from 'q'; export = Q; diff --git a/q-retry/tsconfig.json b/q-retry/tsconfig.json index 8b9a3250f4..19c7cb8412 100644 --- a/q-retry/tsconfig.json +++ b/q-retry/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/q/index.d.ts b/q/index.d.ts index 6b2deb3161..c4c1af5ec0 100644 --- a/q/index.d.ts +++ b/q/index.d.ts @@ -1,7 +1,8 @@ -// Type definitions for Q +// Type definitions for Q 1.0 // Project: https://github.com/kriskowal/q // Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.2 export = Q; export as namespace Q; @@ -21,12 +22,12 @@ declare function Q(value: T): Q.Promise; declare function Q(): Q.Promise; declare namespace Q { - type IWhenable = IPromise | T; - interface IPromise { + export type IWhenable = IPromise | T; + export interface IPromise { then(onFulfill?: (value: T) => IWhenable, onReject?: (error: any) => IWhenable): IPromise; } - interface Deferred { + export interface Deferred { promise: Promise; resolve(value?: IWhenable): void; reject(reason: any): void; @@ -34,7 +35,7 @@ declare namespace Q { makeNodeResolver(): (reason: any, value: T) => void; } - interface Promise { + export interface Promise { /** * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. @@ -167,7 +168,7 @@ declare namespace Q { inspect(): PromiseState; } - interface PromiseState { + export interface PromiseState { state: "fulfilled" | "rejected" | "pending"; value?: T; reason?: any; @@ -182,11 +183,8 @@ declare namespace Q { // If a non-promise value is provided, it will not reject or progress export function when(value: IWhenable, onFulfilled: (val: T) => IWhenable, onRejected?: (reason: any) => IWhenable, onProgress?: (progress: any) => any): Promise; - /** - * Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now. - * See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it. - */ - // export function try(method: Function, ...args: any[]): Promise; + function _try(method: Function, ...args: any[]): Promise; + export { _try as try }; export function fbind(method: (...args: any[]) => IWhenable, ...args: any[]): (...args: any[]) => Promise; diff --git a/q/q-tests.ts b/q/q-tests.ts index 7ebc35adb3..5f79d7f1e4 100644 --- a/q/q-tests.ts +++ b/q/q-tests.ts @@ -224,3 +224,14 @@ var p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val)); var p3: Q.Promise<[string, number]> = Q.all(y1); var p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val)); var p6: Q.Promise<[string, number]> = Q.all(y2); + + +Q.try(function () { + if (Math.random() % 2) { + throw new Error("The cloud is down!"); + } + return true; +}) +.catch(function (error) { + console.error("Couldn't sync to the cloud", error); +}); \ No newline at end of file diff --git a/q/v0/index.d.ts b/q/v0/index.d.ts new file mode 100644 index 0000000000..6b2deb3161 --- /dev/null +++ b/q/v0/index.d.ts @@ -0,0 +1,357 @@ +// Type definitions for Q +// Project: https://github.com/kriskowal/q +// Definitions by: Barrie Nemetchek , Andrew Gaspar , John Reilly +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = Q; +export as namespace Q; + +/** + * If value is a Q promise, returns the promise. + * If value is a promise from another library it is coerced into a Q promise (where possible). + */ +declare function Q(promise: Q.IPromise): Q.Promise; +/** + * If value is not a promise, returns a promise that is fulfilled with value. + */ +declare function Q(value: T): Q.Promise; +/** + * Calling with nothing at all creates a void promise + */ +declare function Q(): Q.Promise; + +declare namespace Q { + type IWhenable = IPromise | T; + interface IPromise { + then(onFulfill?: (value: T) => IWhenable, onReject?: (error: any) => IWhenable): IPromise; + } + + interface Deferred { + promise: Promise; + resolve(value?: IWhenable): void; + reject(reason: any): void; + notify(value: any): void; + makeNodeResolver(): (reason: any, value: T) => void; + } + + interface Promise { + /** + * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. + + * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished. + */ + fin(finallyCallback: () => any): Promise; + /** + * Like a finally clause, allows you to observe either the fulfillment or rejection of a promise, but to do so without modifying the final value. This is useful for collecting resources regardless of whether a job succeeded, like closing a database connection, shutting a server down, or deleting an unneeded key from an object. + + * finally returns a promise, which will become resolved with the same fulfillment value or rejection reason as promise. However, if callback returns a promise, the resolution of the returned promise will be delayed until the promise returned from callback is finished. + */ + finally(finallyCallback: () => any): Promise; + + /** + * The then method from the Promises/A+ specification, with an additional progress handler. + */ + then(onFulfill?: (value: T) => IWhenable, onReject?: (error: any) => IWhenable, onProgress?: Function): Promise; + + /** + * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. + * + * This is especially useful in conjunction with all + */ + spread(onFulfill: (...args: any[]) => IWhenable, onReject?: (reason: any) => IWhenable): Promise; + + fail(onRejected: (reason: any) => IWhenable): Promise; + + /** + * A sugar method, equivalent to promise.then(undefined, onRejected). + */ + catch(onRejected: (reason: any) => IWhenable): Promise; + + /** + * A sugar method, equivalent to promise.then(undefined, undefined, onProgress). + */ + progress(onProgress: (progress: any) => any): Promise; + + /** + * Much like then, but with different behavior around unhandled rejection. If there is an unhandled rejection, either because promise is rejected and no onRejected callback was provided, or because onFulfilled or onRejected threw an error or returned a rejected promise, the resulting rejection reason is thrown as an exception in a future turn of the event loop. + * + * This method should be used to terminate chains of promises that will not be passed elsewhere. Since exceptions thrown in then callbacks are consumed and transformed into rejections, exceptions at the end of the chain are easy to accidentally, silently ignore. By arranging for the exception to be thrown in a future turn of the event loop, so that it won't be caught, it causes an onerror event on the browser window, or an uncaughtException event on Node.js's process object. + * + * Exceptions thrown by done will have long stack traces, if Q.longStackSupport is set to true. If Q.onerror is set, exceptions will be delivered there instead of thrown in a future turn. + * + * The Golden Rule of done vs. then usage is: either return your promise to someone else, or if the chain ends with you, call done to terminate it. + */ + done(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any, onProgress?: (progress: any) => any): void; + + /** + * If callback is a function, assumes it's a Node.js-style callback, and calls it as either callback(rejectionReason) when/if promise becomes rejected, or as callback(null, fulfillmentValue) when/if promise becomes fulfilled. If callback is not a function, simply returns promise. + */ + nodeify(callback: (reason: any, value: any) => void): Promise; + + /** + * Returns a promise to get the named property of an object. Essentially equivalent to + * + * promise.then(function (o) { + * return o[propertyName]; + * }); + */ + get(propertyName: String): Promise; + set(propertyName: String, value: any): Promise; + delete(propertyName: String): Promise; + /** + * Returns a promise for the result of calling the named method of an object with the given array of arguments. The object itself is this in the function, just like a synchronous method call. Essentially equivalent to + * + * promise.then(function (o) { + * return o[methodName].apply(o, args); + * }); + */ + post(methodName: String, args: any[]): Promise; + /** + * Returns a promise for the result of calling the named method of an object with the given variadic arguments. The object itself is this in the function, just like a synchronous method call. + */ + invoke(methodName: String, ...args: any[]): Promise; + fapply(args: any[]): Promise; + fcall(...args: any[]): Promise; + + /** + * Returns a promise for an array of the property names of an object. Essentially equivalent to + * + * promise.then(function (o) { + * return Object.keys(o); + * }); + */ + keys(): Promise; + + /** + * A sugar method, equivalent to promise.then(function () { return value; }). + */ + thenResolve(value: U): Promise; + /** + * A sugar method, equivalent to promise.then(function () { throw reason; }). + */ + thenReject(reason: any): Promise; + + /** + * Attaches a handler that will observe the value of the promise when it becomes fulfilled, returning a promise for that same value, perhaps deferred but not replaced by the promise returned by the onFulfilled handler. + */ + tap(onFulfilled: (value: T) => any): Promise; + + timeout(ms: number, message?: string): Promise; + /** + * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. + */ + delay(ms: number): Promise; + + /** + * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true. + */ + isFulfilled(): boolean; + /** + * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false. + */ + isRejected(): boolean; + /** + * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. + */ + isPending(): boolean; + + valueOf(): any; + + /** + * Returns a "state snapshot" object, which will be in one of three forms: + * + * - { state: "pending" } + * - { state: "fulfilled", value: } + * - { state: "rejected", reason: } + */ + inspect(): PromiseState; + } + + interface PromiseState { + state: "fulfilled" | "rejected" | "pending"; + value?: T; + reason?: any; + } + + // If no value provided, returned promise will be of void type + export function when(): Promise; + + // if no fulfill, reject, or progress provided, returned promise will be of same type + export function when(value: IWhenable): Promise; + + // If a non-promise value is provided, it will not reject or progress + export function when(value: IWhenable, onFulfilled: (val: T) => IWhenable, onRejected?: (reason: any) => IWhenable, onProgress?: (progress: any) => any): Promise; + + /** + * Currently "impossible" (and I use the term loosely) to implement due to TypeScript limitations as it is now. + * See: https://github.com/Microsoft/TypeScript/issues/1784 for discussion on it. + */ + // export function try(method: Function, ...args: any[]): Promise; + + export function fbind(method: (...args: any[]) => IWhenable, ...args: any[]): (...args: any[]) => Promise; + + export function fcall(method: (...args: any[]) => T, ...args: any[]): Promise; + + export function send(obj: any, functionName: string, ...args: any[]): Promise; + export function invoke(obj: any, functionName: string, ...args: any[]): Promise; + export function mcall(obj: any, functionName: string, ...args: any[]): Promise; + + export function denodeify(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; + export function nbind(nodeFunction: Function, thisArg: any, ...args: any[]): (...args: any[]) => Promise; + export function nfbind(nodeFunction: Function, ...args: any[]): (...args: any[]) => Promise; + export function nfcall(nodeFunction: Function, ...args: any[]): Promise; + export function nfapply(nodeFunction: Function, args: any[]): Promise; + + export function ninvoke(nodeModule: any, functionName: string, ...args: any[]): Promise; + export function npost(nodeModule: any, functionName: string, args: any[]): Promise; + export function nsend(nodeModule: any, functionName: string, ...args: any[]): Promise; + export function nmcall(nodeModule: any, functionName: string, ...args: any[]): Promise; + + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D, E, F]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D, E]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C, D]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable, IWhenable]>): Promise<[A, B, C]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable<[IWhenable, IWhenable]>): Promise<[A, B]>; + /** + * Returns a promise that is fulfilled with an array containing the fulfillment value of each promise, or is rejected with the same rejection reason as the first promise to be rejected. + */ + export function all(promises: IWhenable[]>): Promise; + + /** + * Returns a promise for the first of an array of promises to become settled. + */ + export function race(promises: IWhenable[]): Promise; + + /** + * Returns a promise that is fulfilled with an array of promise state snapshots, but only after all the original promises have settled, i.e. become either fulfilled or rejected. + */ + export function allSettled(promises: IWhenable[]>): Promise[]>; + + export function allResolved(promises: IWhenable[]>): Promise[]>; + + /** + * Like then, but "spreads" the array into a variadic fulfillment handler. If any of the promises in the array are rejected, instead calls onRejected with the first rejected promise's rejection reason. + * This is especially useful in conjunction with all. + */ + export function spread(promises: IWhenable[], onFulfilled: (...args: T[]) => IWhenable, onRejected?: (reason: any) => IWhenable): Promise; + + /** + * Returns a promise that will have the same result as promise, except that if promise is not fulfilled or rejected before ms milliseconds, the returned promise will be rejected with an Error with the given message. If message is not supplied, the message will be "Timed out after " + ms + " ms". + */ + export function timeout(promise: Promise, ms: number, message?: string): Promise; + + /** + * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. + */ + export function delay(promise: Promise, ms: number): Promise; + /** + * Returns a promise that will have the same result as promise, but will only be fulfilled or rejected after at least ms milliseconds have passed. + */ + export function delay(value: T, ms: number): Promise; + /** + * Returns a promise that will be fulfilled with undefined after at least ms milliseconds have passed. + */ + export function delay(ms: number): Promise ; + /** + * Returns whether a given promise is in the fulfilled state. When the static version is used on non-promises, the result is always true. + */ + export function isFulfilled(promise: Promise): boolean; + /** + * Returns whether a given promise is in the rejected state. When the static version is used on non-promises, the result is always false. + */ + export function isRejected(promise: Promise): boolean; + /** + * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. + */ + export function isPending(promise: Promise): boolean; + + /** + * Returns a "deferred" object with a: + * promise property + * resolve(value) method + * reject(reason) method + * notify(value) method + * makeNodeResolver() method + */ + export function defer(): Deferred; + + /** + * Returns a promise that is rejected with reason. + */ + export function reject(reason?: any): Promise; + + export function Promise(resolver: (resolve: (val: IWhenable) => void , reject: (reason: any) => void , notify: (progress: any) => void ) => void ): Promise; + + /** + * Creates a new version of func that accepts any combination of promise and non-promise values, converting them to their fulfillment values before calling the original func. The returned version also always returns a promise: if func does a return or throw, then Q.promised(func) will return fulfilled or rejected promise, respectively. + * + * This can be useful for creating functions that accept either promises or non-promise values, and for ensuring that the function always returns a promise even in the face of unintentional thrown exceptions. + */ + export function promised(callback: (...args: any[]) => T): (...args: any[]) => Promise; + + /** + * Returns whether the given value is a Q promise. + */ + export function isPromise(object: any): boolean; + /** + * Returns whether the given value is a promise (i.e. it's an object with a then function). + */ + export function isPromiseAlike(object: any): boolean; + /** + * Returns whether a given promise is in the pending state. When the static version is used on non-promises, the result is always false. + */ + export function isPending(object: any): boolean; + /** + * If an object is not a promise, it is as "near" as possible. + * If a promise is rejected, it is as "near" as possible too. + * If it’s a fulfilled promise, the fulfillment value is nearer. + * If it’s a deferred promise and the deferred has been resolved, the + * resolution is "nearer". + */ + export function nearer(promise: Promise): T; + + /** + * This is an experimental tool for converting a generator function into a deferred function. This has the potential of reducing nested callbacks in engines that support yield. + */ + export function async(generatorFunction: any): (...args: any[]) => Promise; + export function nextTick(callback: Function): void; + + /** + * A settable property that will intercept any uncaught errors that would otherwise be thrown in the next tick of the event loop, usually as a result of done. Can be useful for getting the full stack trace of an error in browsers, which is not usually possible with window.onerror. + */ + export var onerror: (reason: any) => void; + /** + * A settable property that lets you turn on long stack trace support. If turned on, "stack jumps" will be tracked across asynchronous promise operations, so that if an uncaught error is thrown by done or a rejection reason's stack property is inspected in a rejection callback, a long stack trace is produced. + */ + export var longStackSupport: boolean; + + /** + * Calling resolve with a pending promise causes promise to wait on the passed promise, becoming fulfilled with its fulfillment value or rejected with its rejection reason (or staying pending forever, if the passed promise does). + * Calling resolve with a rejected promise causes promise to be rejected with the passed promise's rejection reason. + * Calling resolve with a fulfilled promise causes promise to be fulfilled with the passed promise's fulfillment value. + * Calling resolve with a non-promise value causes promise to be fulfilled with that value. + */ + export function resolve(object: IWhenable): Promise; + + /** + * Resets the global "Q" variable to the value it has before Q was loaded. + * This will either be undefined if there was no version or the version of Q which was already loaded before. + * @returns { The last version of Q. } + */ + export function noConflict(): typeof Q; +} diff --git a/q/v0/q-tests.ts b/q/v0/q-tests.ts new file mode 100644 index 0000000000..7ebc35adb3 --- /dev/null +++ b/q/v0/q-tests.ts @@ -0,0 +1,226 @@ +/// + + +import Q = require('q'); + +Q(8).then(x => console.log(x.toExponential())); +Q().then(() => console.log("nothing")); + +var delay = function (delay: number) { + var d = Q.defer(); + setTimeout(d.resolve, delay); + return d.promise; +}; + +Q.when(delay(1000), function (val: void) { + console.log('Hello, World!'); + return; +}); + +// Note from Q documentation: a deferred can be resolved with a value or a promise. +var otherPromise = Q.defer().promise; +Q.defer().resolve(otherPromise); + +Q.timeout(Q(new Date()), 1000, "My dates never arrived. :(").then(d => d.toJSON()); + +Q.delay(Q(8), 1000).then(x => x.toExponential()); +Q.delay(8, 1000).then(x => x.toExponential()); +Q.delay(Q("asdf"), 1000).then(x => x.length); +Q.delay("asdf", 1000).then(x => x.length); + +var eventualAdd = Q.promised((a?: number, b?: number) => a + b); +eventualAdd(Q(1), Q(2)).then(x => x.toExponential()); + +function eventually(eventually: T) { + return Q.delay(eventually, 1000); +}; + +var x = Q.all([1, 2, 3].map(eventually)); +Q.when(x, function (x) { + console.log(x); +}); + +Q.all([ + eventually(10), + eventually(20) +]).spread(function (x: number, y: number) { + console.log(x, y); +}); + +Q.all([ + eventually(10), + eventually(20) +]).then(function (results) { + let [x, y] = results; + console.log(x, y); +}); + + +Q.fcall(function () { }) + .then(function () { }) + .then(function () { }) + .then(function () { }) + .then(function (value4) { + // Do something with value4 + }, function (error) { + // Handle any error from step1 through step4 + }).done(); + +Q.allResolved([]) +.then(function (promises: Q.Promise[]) { + promises.forEach(function (promise) { + if (promise.isFulfilled()) { + var value = promise.valueOf(); + } else { + var exception = promise.valueOf().exception; + } + }) +}); + +Q(42) + .tap(() => "hello") + .tap(x => { + console.log(x); + }) + .then(x => { + console.log("42 == " + x); + }); + +declare var arrayPromise: Q.IPromise; +declare var stringPromise: Q.IPromise; +declare function returnsNumPromise(text: string): Q.Promise; +declare function returnsNumPromise(text: string): JQueryPromise; + +Q(arrayPromise) // type specification required + .then(arr => arr.join(',')) + .then(returnsNumPromise) // requires specification + .then(num => num.toFixed()); + +declare var jPromise: JQueryPromise; + +// if jQuery promises definition supported generics, this could be more interesting example +Q(jPromise).then(str => str.split(',')); +jPromise.then(returnsNumPromise); + +// watch the typing flow through from jQueryPromise to Q.Promise +Q(jPromise).then(str => str.split(',')); + +declare var promiseArray: Q.IPromise[]; +var qPromiseArray = promiseArray.map(p => Q(p)); +var myNums: any[] = [2, 3, Q(4), 5, Q(6), Q(7)]; + +Q.all(promiseArray).then(nums => nums.map(num => num.toPrecision(2)).join(',')); + +Q.all(myNums).then(nums => nums.map(Math.round)); + +Q.fbind((dateString?: string) => new Date(dateString), "11/11/1991")().then(d => d.toLocaleDateString()); + +Q.when(8, num => num + "!"); +Q.when(Q(8), num => num + "!").then(str => str.split(',')); +var voidPromise: Q.Promise = Q.when(); + +declare function saveToDisk(): Q.Promise; +declare function saveToCloud(): Q.Promise; +Q.allSettled([saveToDisk(), saveToCloud()]).spread(function (disk: any, cloud: any) { + console.log("saved to disk:", disk.state === "fulfilled"); + console.log("saved to cloud:", cloud.state === "fulfilled"); + + if (disk.state === "fulfilled") { + console.log("value was " + disk.value); + } + else if (disk.state === "rejected") { + console.log("rejected because " + disk.reason); + } +}).done(); + +var nodeStyle = (input: string, cb: Function) => { + cb(null, input); +}; + +Q.nfapply(nodeStyle, ["foo"]).done((result: string) => {}); +Q.nfcall(nodeStyle, "foo").done((result: string) => {}); +Q.denodeify(nodeStyle)('foo').done((result: string) => {}); +Q.nfbind(nodeStyle)('foo').done((result: string) => {}); + + +class Repo { + private items: any[] = [ + { name: 'Max', cute: false }, + { name: 'Annie', cute: true } + ]; + + find(options: any): Q.Promise { + var result = this.items; + + for (var key in options) { + result = result.filter(i => i[key] == options[key]); + } + + return Q(result); + } +} + +var kitty = new Repo(); +Q.nbind(kitty.find, kitty)({ cute: true }).done((kitties: any[]) => {}); + + +/* + * Test: Can "rethrow" rejected promises + */ +namespace TestCanRethrowRejectedPromises { + + interface Foo { + a: number; + } + + function nestedBar(): Q.Promise { + var deferred = Q.defer(); + + return deferred.promise; + } + + function bar(): Q.Promise { + return nestedBar() + .then((foo:Foo) => { + console.log("Lorem ipsum"); + }) + .fail((error) => { + console.log("Intermediate error handling"); + + /* + * Cannot do this, because: + * error TS2322: Type 'Promise' is not assignable to type 'Promise' + */ + //throw error; + + return Q.reject(error); + }) + ; + } + + bar() + .finally(() => { + console.log("Cleanup") + }) + .done() + ; + +} + +// test Q.Promise.all +var y1 = Q().then(() => { + var s = Q("hello"); + var n = Q(1); + return <[typeof s, typeof n]>[s, n]; +}); + +var y2 = Q().then(() => { + var s = "hello"; + var n = Q(1); + return <[typeof s, typeof n]>[s, n]; +}); + +var p2: Q.Promise<[string, number]> = y1.then(val => Q.all(val)); +var p3: Q.Promise<[string, number]> = Q.all(y1); +var p5: Q.Promise<[string, number]> = y2.then(val => Q.all(val)); +var p6: Q.Promise<[string, number]> = Q.all(y2); diff --git a/q/v0/tsconfig.json b/q/v0/tsconfig.json new file mode 100644 index 0000000000..c44ffeb935 --- /dev/null +++ b/q/v0/tsconfig.json @@ -0,0 +1,26 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "baseUrl": "../../", + "typeRoots": [ + "../../" + ], + "paths": { + "q": [ "q/v0" ] + }, + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "q-tests.ts" + ] +} \ No newline at end of file diff --git a/qajax/index.d.ts b/qajax/index.d.ts index 3476cb280e..fcfbea6649 100644 --- a/qajax/index.d.ts +++ b/qajax/index.d.ts @@ -3,8 +3,6 @@ // Definitions by: Boltmade // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// - import * as Q from "q"; export = Qajax; diff --git a/qajax/tsconfig.json b/qajax/tsconfig.json index 8ba8578ef5..17bb7d92b2 100644 --- a/qajax/tsconfig.json +++ b/qajax/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/run-sequence/tsconfig.json b/run-sequence/tsconfig.json index b03e01e277..2d7e6640db 100644 --- a/run-sequence/tsconfig.json +++ b/run-sequence/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/status-bar/tsconfig.json b/status-bar/tsconfig.json index 874ffb81d1..9fe41d5d67 100644 --- a/status-bar/tsconfig.json +++ b/status-bar/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/text-buffer/tsconfig.json b/text-buffer/tsconfig.json index 860c31d7f7..ebee922349 100644 --- a/text-buffer/tsconfig.json +++ b/text-buffer/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/twilio/index.d.ts b/twilio/index.d.ts index d186831e93..358f45ca01 100644 --- a/twilio/index.d.ts +++ b/twilio/index.d.ts @@ -3,9 +3,8 @@ // Definitions by: nickiannone , Ashley Brener // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -/// /// -/// + import Express = require("express"); import Http = require("http"); import Q = require("q"); diff --git a/twilio/tsconfig.json b/twilio/tsconfig.json index 997e9d8770..805d02ab2f 100644 --- a/twilio/tsconfig.json +++ b/twilio/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vso-node-api/index.d.ts b/vso-node-api/index.d.ts index 92b18209c1..51569f75a9 100644 --- a/vso-node-api/index.d.ts +++ b/vso-node-api/index.d.ts @@ -4,9 +4,9 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// -/// declare module 'vso-node-api/Serialization' { + import Q = require("q"); /** * Metadata for deserializing an enum field on a contract/type */ diff --git a/vso-node-api/tsconfig.json b/vso-node-api/tsconfig.json index 17db4a2513..feaeda0a61 100644 --- a/vso-node-api/tsconfig.json +++ b/vso-node-api/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From 3f3165e60bcf4b54f3215176fa409b27ce875668 Mon Sep 17 00:00:00 2001 From: codemannz Date: Wed, 15 Mar 2017 16:21:17 +1300 Subject: [PATCH 111/258] Update index.d.ts --- tinymce/index.d.ts | 170 ++++++++++++++++++++++++++++----------------- 1 file changed, 106 insertions(+), 64 deletions(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index a142e244ef..24e940229f 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -5,46 +5,51 @@ // Work In Progress -declare namespace TinyMce { +import 'jquery'; - export interface Static extends TinyMce.EditorManager { +declare namespace tinymce { - DOM: TinyMce.dom.DOMUtils; + var DOM: dom.DOMUtils; - PluginManager: TinyMce.AddOnManager; + var PluginManager: AddOnManager; - ScriptLoader: TinyMce.dom.ScriptLoader; + var ScriptLoader: dom.ScriptLoader; - ThemeManager: TinyMce.AddOnManager; + var ThemeManager: AddOnManager; - create(s: string, p: {}, root?: {}): void; + var EditorManager: EditorManager; - createNS(n: string, o: {}): {}; + var baseURL: string; - each(o: {}, cb: () => void, s?: {}): void; + var activeEditor: Editor; - explode(s: string, d: string): void; + function create(s: string, p: {}, root?: {}): void; - grep(a: any[], f: () => void): any[]; + function createNS(n: string, o: {}): {}; - inArray(item: any, arr: any[]): number; + function each(o: {}, cb: () => void, s?: {}): void; - is(obj: {}, type?: string): boolean; + function explode(s: string, d: string): void; - isArray(obj: {}): boolean; + function grep(a: any[], f: () => void): any[]; - makeMap(items: any[], delim?: string, map?: {}): {}; + function inArray(item: any, arr: any[]): number; - map(array: any[], callback: () => void): any[]; + function is(obj: {}, type?: string): boolean; - resolve(n: string, o?: {}): {}; + function isArray(obj: {}): boolean; - toArray(obj: {}): any[]; + function makeMap(items: any[], delim?: string, map?: {}): {}; - trim(s: string): string; + function map(array: any[], callback: () => void): any[]; - walk(o: {}, f: () => void, n?: string, s?: string): void; - } + function resolve(n: string, o?: {}): {}; + + function toArray(obj: {}): any[]; + + function trim(s: string): string; + + function walk(o: {}, f: () => void, n?: string, s?: string): void; export interface Settings { table_toolbar?: boolean; @@ -59,13 +64,13 @@ declare namespace TinyMce { hidden_input?: boolean; - init_instance_callback?: (editor: TinyMce.Editor) => void; + init_instance_callback?: (editor: Editor) => void; plugins?: string | string[]; selector?: string; - setup?: (edtor: TinyMce.Editor) => void; + setup?: (edtor: Editor) => void; target?: Element; @@ -283,7 +288,7 @@ declare namespace TinyMce { export interface AddOnManager { - add(id: string, addOn: (editor: TinyMce.Editor, url: string) => void): Theme | Plugin; + add(id: string, addOn: (editor: Editor, url: string) => void): Theme | Plugin; addComponents(pluginName: string, scripts: string[]): void; @@ -294,7 +299,9 @@ declare namespace TinyMce { requireLangPack(name: string, languages?: string): void; } - export interface Editor extends util.Observable { + export class Editor extends util.Observable { + + constructor(id:String, settings:Object, editorManager:tinymce.EditorManager); $: dom.DomQuery; @@ -438,15 +445,15 @@ declare namespace TinyMce { $: dom.DomQuery; - activeEditor: TinyMce.Editor; + activeEditor: Editor; - baseURI: TinyMce.util.URI; + baseURI: util.URI; baseURL: string; documentBaseURL: string; - editors: TinyMce.Editor[]; + editors: Editor[]; i18n: {}; @@ -458,23 +465,23 @@ declare namespace TinyMce { suffix: string; - add(editor: TinyMce.Editor): TinyMce.Editor; + add(editor: Editor): Editor; addI18n(code: string, items: {}): void; - createEditor(id: string, settings: {}): TinyMce.Editor; + createEditor(id: string, settings: {}): Editor; execCommand(cmd: string, ui?: boolean, value?: string): boolean; - get(id: string): TinyMce.Editor; + get(id: string): Editor; init(settings: Settings): Promise; overrideDefaults(defaultSettings: {}): void; - remove(selector: TinyMce.Editor): TinyMce.Editor; + remove(selector: Editor): Editor; - setActive(editor: TinyMce.Editor): void; + setActive(editor: Editor): void; translate(text: string): string; @@ -595,14 +602,9 @@ declare namespace TinyMce { } } - export interface FocusManager { - - isEditorUIElement(elm: Element): boolean; - } - - export class FocusManager implements FocusManager { - - constructor(editorManager: TinyMce.EditorManager); + class FocusManager { + constructor(); + static isEditorUIElement(elm: Element): boolean; } export interface Formatter { @@ -696,6 +698,48 @@ declare namespace TinyMce { open(args?: {}): void; } + export namespace ui { + export interface ControlSettings { + menu: ui.Menu; + } + + interface Collection { + + } + + interface Container { + add(items: any): Collection; + items(): Collection; + } + + interface Moveable { + moveRel(elm: Node, rel: string): Control; + } + + interface FloatPanel extends Control, Moveable { + + } + + interface Menu extends FloatPanel, Control, Container { + + } + + interface Factory { + create(settings: any): Control; + } + + export class Control { + constructor(); + + $el: JQuery; + on(name:String, callback:String):tinymce.ui.Control; + tooltip(): Control; + settings: ControlSettings; + disabled(state:Boolean): void; + active(state:Boolean): void; + } + } + export namespace dom { export interface BookmarkManager { @@ -745,7 +789,7 @@ declare namespace TinyMce { getOuterHTML(elm: string): string; - getParent(node: Node, selector: () => void, root?: Node): Node; + getParent(node: Node, selector: any, root?: Node): Node; getParents(node: Node, selector: () => void, root?: Node): T[]; @@ -1086,14 +1130,14 @@ declare namespace TinyMce { addNodeFilter(attributes: string, callback: () => void): void; - filterNode(node: TinyMce.html.Node): TinyMce.html.Node; + filterNode(node: html.Node): html.Node; - parse(html: string, args?: {}): TinyMce.html.Node; + parse(html: string, args?: {}): html.Node; } export class DomParser implements DomParser { - constructor(settings: {}, schema: TinyMce.html.Schema); + constructor(settings: {}, schema: html.Schema); } export interface Entities { @@ -1113,31 +1157,31 @@ declare namespace TinyMce { export interface Node { - append(node: TinyMce.html.Node): TinyMce.html.Node; + append(node: html.Node): html.Node; - attr(name: string, value?: string): string | TinyMce.html.Node; + attr(name: string, value?: string): string | html.Node; - clone(): TinyMce.html.Node; + clone(): html.Node; create(name: string, attrs: {}): void; - empty(): TinyMce.html.Node; + empty(): html.Node; - getAll(name: string): TinyMce.html.Node[]; + getAll(name: string): html.Node[]; - insert(node: TinyMce.html.Node, ref_node: TinyMce.html.Node, before?: boolean): TinyMce.html.Node; + insert(node: html.Node, ref_node: html.Node, before?: boolean): html.Node; isEmpty(elements: {}): boolean; - remove(): TinyMce.html.Node; + remove(): html.Node; - replace(node: TinyMce.html.Node): TinyMce.html.Node; + replace(node: html.Node): html.Node; unwrap(): void; - walk(prev?: boolean): TinyMce.html.Node; + walk(prev?: boolean): html.Node; - wrap(wrapperNode: TinyMce.html.Node): TinyMce.html.Node; + wrap(wrapperNode: html.Node): html.Node; } export class Node implements Node { @@ -1152,7 +1196,7 @@ declare namespace TinyMce { export class SaxParser implements SaxParser { - constructor(settings: {}, schema: TinyMce.html.Schema); + constructor(settings: {}, schema: html.Schema); } export interface Schema { @@ -1207,12 +1251,12 @@ declare namespace TinyMce { export interface Serializer { - serialize(node: TinyMce.html.Node): string; + serialize(node: html.Node): string; } export class Serializer implements Serializer { - constructor(settings: {}, schema: TinyMce.html.Schema); + constructor(settings: {}, schema: html.Schema); } export interface Styles { @@ -1253,7 +1297,7 @@ declare namespace TinyMce { export interface Color { - parse(value: {}): TinyMce.util.Color; + parse(value: {}): util.Color; toHex(): string; @@ -1279,7 +1323,7 @@ declare namespace TinyMce { setEditorInterval(callback: () => void, time: number): number; - setEditorTimeout(editor: TinyMce.Editor, callback: () => void, time: number): number; + setEditorTimeout(editor: Editor, callback: () => void, time: number): number; setInterval(callback: () => void, time: number): number; @@ -1343,7 +1387,7 @@ declare namespace TinyMce { setItem(key: string, value: string): void; } - export interface Observable { + export class Observable { fire(name: string, args?: {}, bubble?: boolean): {}; @@ -1391,7 +1435,7 @@ declare namespace TinyMce { getURI(noProtoHost: boolean): URI; - isSameOrigin(uri: TinyMce.util.URI): boolean; + isSameOrigin(uri: util.URI): boolean; setPath(path: string): void; @@ -1426,5 +1470,3 @@ declare namespace TinyMce { } } - -declare var tinymce: TinyMce.Static; From 2844f3c2b3a64bbe2869c8da54931b0871f273b2 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Wed, 15 Mar 2017 07:55:49 +0100 Subject: [PATCH 112/258] Fix generic contstraint --- jasmine/index.d.ts | 4 ++-- jasminewd2/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jasmine/index.d.ts b/jasmine/index.d.ts index f75a9f2127..caa1d12635 100644 --- a/jasmine/index.d.ts +++ b/jasmine/index.d.ts @@ -25,7 +25,7 @@ declare function beforeAll(action: (done: DoneFn) => void, timeout?: number): vo declare function afterAll(action: (done: DoneFn) => void, timeout?: number): void; declare function expect(spy: Function): jasmine.Matchers; -declare function expect>(actual: ArrayLike): jasmine.ArrayLikeMatchers; +declare function expect(actual: ArrayLike): jasmine.ArrayLikeMatchers; declare function expect(actual: T): jasmine.Matchers; declare function fail(e?: any): void; @@ -347,7 +347,7 @@ declare namespace jasmine { Any: Any; } - interface ArrayLikeMatchers> extends Matchers { + interface ArrayLikeMatchers extends Matchers> { toBe(expected: Expected>, expectationFailOutput?: any): boolean; toEqual(expected: Expected>, expectationFailOutput?: any): boolean; toContain(expected: T, expectationFailOutput?: any): boolean; diff --git a/jasminewd2/index.d.ts b/jasminewd2/index.d.ts index a4122c6639..3b8760709c 100644 --- a/jasminewd2/index.d.ts +++ b/jasminewd2/index.d.ts @@ -44,7 +44,7 @@ declare namespace jasmine { toThrowError(expected?: new (...args: any[]) => Error | Promise Error>, message?: string | RegExp | Promise): Promise; } - interface ArrayLikeMatchers> extends Matchers { + interface ArrayLikeMatchers extends Matchers> { toBe(expected: Expected>, expectationFailOutput?: any): Promise; toEqual(expected: Expected>, expectationFailOutput?: any): Promise; toContain(expected: T, expectationFailOutput?: any): Promise; From 03a3f340e457dbb28f5abafc655eaa496afd1720 Mon Sep 17 00:00:00 2001 From: Geert Jansen Date: Wed, 15 Mar 2017 09:49:37 +0100 Subject: [PATCH 113/258] Add name to header --- angular-material/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/angular-material/index.d.ts b/angular-material/index.d.ts index 64441a96be..a8196269a4 100644 --- a/angular-material/index.d.ts +++ b/angular-material/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Angular Material (angular.material module) 1.1 // Project: https://github.com/angular/material -// Definitions by: Blake Bigelow , Peter Hajdu , Davide Donadello +// Definitions by: Blake Bigelow , Peter Hajdu , Davide Donadello , Geert Jansen // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped import * as angular from 'angular'; From e990bd3aeb3c5e31486f487179dae4136c85e07d Mon Sep 17 00:00:00 2001 From: Stanny Nuytkens Date: Mon, 13 Mar 2017 21:28:16 +0100 Subject: [PATCH 114/258] Include inputOptions for bootbox.prompt --- bootbox/bootbox-tests.ts | 24 +++++++++++++++++++++++- bootbox/index.d.ts | 3 ++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bootbox/bootbox-tests.ts b/bootbox/bootbox-tests.ts index b5f32931ae..f5604d5312 100644 --- a/bootbox/bootbox-tests.ts +++ b/bootbox/bootbox-tests.ts @@ -38,7 +38,29 @@ bootbox.prompt({ console.log(result); } }); - +bootbox.prompt({ + title: "This is a prompt with a set of checkbox inputs!", + inputType: 'checkbox', + inputOptions: [ + { + text: 'Choice One', + value: '1', + group: 'Group 1' + }, + { + text: 'Choice Two', + value: '2', + group: 'Group 1' + }, + { + text: 'Choice Three', + value: '3' + } + ], + callback: function (result) { + console.log(result); + } +}); bootbox.dialog({ title: "Wassup?", diff --git a/bootbox/index.d.ts b/bootbox/index.d.ts index d5ceb5ef62..28d30e2ba0 100644 --- a/bootbox/index.d.ts +++ b/bootbox/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Bootbox 4.4.0 // Project: https://github.com/makeusabrew/bootbox -// Definitions by: Vincent Bortone , Kon Pik , Anup Kattel , Dominik Schroeter , Troy McKinnon +// Definitions by: Vincent Bortone , Kon Pik , Anup Kattel , Dominik Schroeter , Troy McKinnon , Stanny Nuytkens // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// @@ -44,6 +44,7 @@ interface BootboxPromptOptions extends BootboxBaseOptions { inputType?: "text" | "textarea" | "email" | "select" | "checkbox" | "date" | "time" | "number" | "password"; callback: (result: string) => any; buttons?: BootboxConfirmPromptButtonMap; + inputOptions?: { text: string, value: string, group?: string }[]; } /** Bootbox options available when setting defaults for modals */ From 9b6db1a1561a26ba5644587e1dad420645d112f1 Mon Sep 17 00:00:00 2001 From: Lukas Zech Date: Wed, 15 Mar 2017 10:29:20 +0100 Subject: [PATCH 115/258] Fix jasmine-query toContain typings --- jasmine-jquery/index.d.ts | 2 +- jasmine-jquery/jasmine-jquery-tests.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/jasmine-jquery/index.d.ts b/jasmine-jquery/index.d.ts index ebc14cee75..14eb26b380 100644 --- a/jasmine-jquery/index.d.ts +++ b/jasmine-jquery/index.d.ts @@ -241,7 +241,7 @@ declare namespace jasmine { * // returns true * expect($('
    ')).toContain('some-class') */ - toContain(selector: T): boolean; + toContain(selector: any): boolean; /** * Check if DOM element exists inside the given parent element. diff --git a/jasmine-jquery/jasmine-jquery-tests.ts b/jasmine-jquery/jasmine-jquery-tests.ts index 40aa9e8f88..440dff1b6c 100644 --- a/jasmine-jquery/jasmine-jquery-tests.ts +++ b/jasmine-jquery/jasmine-jquery-tests.ts @@ -8,7 +8,8 @@ describe("Jasmine jQuery extension", () => { expect($('
    ')).toHaveCss({ margin: "10px" }); expect($('')).toBeSelected(); expect($('
    ')).toBeVisible(); - expect($('
    ')).toContain('span.some-class'); + // NOTE: It is now necessary to explicitly add the generic parameter when using `toContain` + expect($('
    ')).toContain('span.some-class'); expect($('').addClass('js-something')).toBeMatchedBy('.js-something'); expect($('')).toExist(); expect($('
    ')).toHaveAttr('id', 'some-id'); From ee0f49ec1cd4b63aab4bbb630cb389db68f7e406 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Wed, 15 Mar 2017 11:11:30 +0100 Subject: [PATCH 116/258] Improve headers --- react-router-dom/index.d.ts | 1 + react-router/index.d.ts | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/react-router-dom/index.d.ts b/react-router-dom/index.d.ts index 7b827ba3d5..e255eb69f3 100644 --- a/react-router-dom/index.d.ts +++ b/react-router-dom/index.d.ts @@ -2,6 +2,7 @@ // Project: https://github.com/ReactTraining/react-router // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-router-dom' { import { diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 1e0f01510c..8dfd32d02b 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -1,7 +1,17 @@ // Type definitions for React Router 4.0 // Project: https://github.com/ReactTraining/react-router -// Definitions by: Sergey Buturlakin , Yuichi Murata , Václav Ostrožlík , Nathan Brown , Alex Wendland , Kostya Esmukov , Tanguy Krotoff +// Definitions by: Sergey Buturlakin +// Yuichi Murata +// Václav Ostrožlík +// Nathan Brown +// Alex Wendland +// Kostya Esmukov +// John Reilly +// Karol Janyst +// Dovydas Navickas +// Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 declare module 'react-router' { import * as React from 'react'; From 767724dd08d796fdebc6df8c88739d3d50e71a2e Mon Sep 17 00:00:00 2001 From: Tomino Date: Wed, 15 Mar 2017 10:15:35 +0000 Subject: [PATCH 117/258] Update index.d.ts Updating Cookie options to follow Express documentation https://expressjs.com/en/api.html#res.cookie Two properties `encode` and `sameSite` were missing --- express-serve-static-core/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/express-serve-static-core/index.d.ts b/express-serve-static-core/index.d.ts index a4ce9612e7..e42568b14c 100644 --- a/express-serve-static-core/index.d.ts +++ b/express-serve-static-core/index.d.ts @@ -161,6 +161,8 @@ interface CookieOptions { path?: string; domain?: string; secure?: boolean | 'auto'; + encode?: (val: string) => void; + sameSite?: boolean | string; } interface Errback { (err: Error): void; } From e4af32331d5eecd43f52252564cf2ccc06f1f133 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Wed, 15 Mar 2017 11:16:38 +0100 Subject: [PATCH 118/258] react-redux: add failing test for map{State|Dispatch}ToProps factories --- react-redux/react-redux-tests.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/react-redux/react-redux-tests.tsx b/react-redux/react-redux-tests.tsx index 5d1f32765f..4c7a55ea7b 100644 --- a/react-redux/react-redux-tests.tsx +++ b/react-redux/react-redux-tests.tsx @@ -56,10 +56,16 @@ interface ICounterStateProps { interface ICounterDispatchProps { onIncrement: () => void } +// with higher order functions connect( () => mapStateToProps, () => mapDispatchToProps )(Counter); +// with higher order functions using parameters +connect( + (initialState: CounterState, ownProps: {}) => mapStateToProps, + (dispatch: Dispatch, ownProps: {}) => mapDispatchToProps +)(Counter); // only first argument connect( () => mapStateToProps From 2cd144e34366074840e96a48bb99690270775079 Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Wed, 15 Mar 2017 11:18:12 +0100 Subject: [PATCH 119/258] react-redux: support map{State|Dispatch}ToProps factories in connect --- react-redux/index.d.ts | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/react-redux/index.d.ts b/react-redux/index.d.ts index 8daa310b51..1f300e02a6 100644 --- a/react-redux/index.d.ts +++ b/react-redux/index.d.ts @@ -49,18 +49,20 @@ export interface InferableComponentDecorator { export declare function connect(): InferableComponentDecorator; export declare function connect( - mapStateToProps?: FuncOrSelf>, - mapDispatchToProps?: FuncOrSelf | MapDispatchToPropsObject>, + mapStateToProps?: MapStateToProps | MapStateToPropsFactory, + mapDispatchToProps?: MapDispatchToProps | MapDispatchToPropsFactory, mergeProps?: MergeProps, options?: Options ): ComponentDecorator; -type FuncOrSelf = T | (() => T); - interface MapStateToProps { (state: any, ownProps?: TOwnProps): TStateProps; } +interface MapStateToPropsFactory { + (initialState: any, ownProps?: TOwnProps): MapStateToProps; +} + interface MapDispatchToPropsFunction { (dispatch: Dispatch, ownProps?: TOwnProps): TDispatchProps; } @@ -69,6 +71,13 @@ interface MapDispatchToPropsObject { [name: string]: ActionCreator; } +type MapDispatchToProps = + MapDispatchToPropsFunction | MapDispatchToPropsObject; + +interface MapDispatchToPropsFactory { + (dispatch: Dispatch, ownProps?: TOwnProps): MapDispatchToProps; +} + interface MergeProps { (stateProps: TStateProps, dispatchProps: TDispatchProps, ownProps: TOwnProps): TStateProps & TDispatchProps; } @@ -83,7 +92,7 @@ interface Options { */ pure?: boolean; /** - * If true, stores a ref to the wrapped component instance and makes it available via + * If true, stores a ref to the wrapped component instance and makes it available via * getWrappedInstance() method. Defaults to false. */ withRef?: boolean; From 9ada494d064c9c0451059a3220907eb493b48dd3 Mon Sep 17 00:00:00 2001 From: Ricky Blankenaufulland Date: Wed, 15 Mar 2017 11:47:50 +0100 Subject: [PATCH 120/258] fixed 'Definitions by' file headers --- gridstack/gridstack-tests.ts | 3 +-- gridstack/index.d.ts | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/gridstack/gridstack-tests.ts b/gridstack/gridstack-tests.ts index 0546bab506..9330d2019e 100644 --- a/gridstack/gridstack-tests.ts +++ b/gridstack/gridstack-tests.ts @@ -4,8 +4,7 @@ // Type definitions for Gridstack // Project: http://troolee.github.io/gridstack.js/ -// Definitions by: Pascal Senn -// Definitions by: Ricky Blankenaufulland +// Definitions by: Pascal Senn , Ricky Blankenaufulland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped var options = { diff --git a/gridstack/index.d.ts b/gridstack/index.d.ts index 7f557f4af6..17e4d43863 100644 --- a/gridstack/index.d.ts +++ b/gridstack/index.d.ts @@ -1,7 +1,6 @@ // Type definitions for Gridstack // Project: http://troolee.github.io/gridstack.js/ -// Definitions by: Pascal Senn -// Definitions by: Ricky Blankenaufulland +// Definitions by: Pascal Senn , Ricky Blankenaufulland // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped interface JQuery { From 32a3eb210b95afa9264db68b07ba3a16cf6d32da Mon Sep 17 00:00:00 2001 From: stonio Date: Wed, 15 Mar 2017 16:17:10 +0100 Subject: [PATCH 121/258] Update index.d.ts - Interface SpeakingURLOptions Rename interface `Options` to interface `SpeakingURLOptions` to avoid namespace conflict with other TypeScript definitions. --- speakingurl/index.d.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/speakingurl/index.d.ts b/speakingurl/index.d.ts index 289c1eb033..83e38fd7b8 100644 --- a/speakingurl/index.d.ts +++ b/speakingurl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for speakingurl 10.0 +// Type definitions for speakingurl 13.0 // Project: http://pid.github.io/speakingurl/ // Definitions by: Zlatko Andonovski // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,7 +7,7 @@ interface Dictionary { [x: string]: T; } -interface Options { +interface SpeakingURLOptions { separator?: string; lang?: string|boolean; symbols?: boolean; @@ -20,10 +20,10 @@ interface Options { custom?: string[]|Dictionary; } -declare function getSlug(input: string, options?: Options|string): string; +declare function getSlug(input: string, options?: SpeakingURLOptions|string): string; declare namespace getSlug { - export function createSlug(options: Options): (input: string) => string; + export function createSlug(options: SpeakingURLOptions): (input: string) => string; } -export = getSlug; \ No newline at end of file +export = getSlug; From bf8c07dd6b5629a029a4ea3e9fe0df30a3846e8b Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Thu, 16 Mar 2017 00:35:42 +0900 Subject: [PATCH 122/258] Add IRegisterOptions.invoke for @types/autobahn --- autobahn/autobahn-tests.ts | 2 +- autobahn/index.d.ts | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/autobahn/autobahn-tests.ts b/autobahn/autobahn-tests.ts index 141a43547e..d753e960fe 100644 --- a/autobahn/autobahn-tests.ts +++ b/autobahn/autobahn-tests.ts @@ -34,7 +34,7 @@ function test_client() { session.publish('com.myapp.hello', ['Hello, world!']); // 3) register a procedure for remoting - session.register('com.myapp.add2', myInstance.add2); + session.register('com.myapp.add2', myInstance.add2, { invoke: 'roundrobin' }); // 4) call a remote procedure session.call('com.myapp.add2', [2, 3]).then( diff --git a/autobahn/index.d.ts b/autobahn/index.d.ts index e93d3c065f..bb52fbb91c 100644 --- a/autobahn/index.d.ts +++ b/autobahn/index.d.ts @@ -177,6 +177,7 @@ declare namespace autobahn { interface IRegisterOptions { disclose_caller?: boolean; + invoke?: 'single' | 'roundrobin' | 'random' | 'first' | 'last'; } export class Connection { From b2e6c9b70e732b45a3a394b98593c285da98c4af Mon Sep 17 00:00:00 2001 From: Eunchong Yu Date: Thu, 16 Mar 2017 00:53:48 +0900 Subject: [PATCH 123/258] Increase version of @types/autobahn --- autobahn/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autobahn/index.d.ts b/autobahn/index.d.ts index bb52fbb91c..8a37bdf21b 100644 --- a/autobahn/index.d.ts +++ b/autobahn/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for AutobahnJS v0.9.6 +// Type definitions for AutobahnJS v0.9.7 // Project: http://autobahn.ws/js/ // Definitions by: Elad Zelingher , Andy Hawkins // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 2d6f2be00732d109b28c19a9544d7e6088bc9979 Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Mar 2017 11:40:55 -0700 Subject: [PATCH 124/258] gapi-tests.ts: Convert to UTF-8 (#15189) --- gapi/gapi-tests.ts | Bin 5944 -> 2971 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/gapi/gapi-tests.ts b/gapi/gapi-tests.ts index e3dc279596d38582ce406ee9bd017cae02d8bab1..3c70b9850d909d6d35ca9cb9828096abb11656ea 100644 GIT binary patch literal 2971 zcmd^BTW`}a6n?MN|8Rtm(m@x~AtY27h)WS=+{8r)AvAgEX=6z2U^``H>VN0haomiu zF$s+qULq?#KK{;kE}t1=a986THOdUZt|~P9R~EbyX@#mP@CvYd{T@5Vtf)<6L}u4u za?DFQX29~VC}FNu3AweE88bG+B^IheZPJBOivrV3m5lD%%?g3i?iS)mbG>3;_>!AU zi^?)%xenjmF9xo$ey`s<>GuHUwalzg61>T1umk=#0AbxrVJd|cybwPqsvO}NxqRzg zLUS2}%TnhHz=z!Iq=JqPf-``G03P5f8AI~%)%!Px4_;3X4<;XzVRMiSX2N7@iF)-| zWrplNC2hnFhap<>V|>I{;{m48*yM9`MbH}z(;09%1M*uTaE+iU7b`D7%z@W72Vp=e z3mU)GLgOriL1HgcJcsp-l$q<_>!0C zu=xUIB_?eq);o8a8x?o=}Tc+~%&k&L0!Y5!;k_91-iC|Fy*TVu@dh(#(<5I6}i{=9R*b zgf(K*Rfd?%m_k;O{;`-UYDe1AymUHnl2GckSB_^Ym&y81V~LvODNW4+-Kg{PihBC2 z8MHC>Glnc3KmA@8Z!;+zLntC10!i8!T7XJg9wMZ{?6F$GDY zGNLLvmA=&b8zjDlw`(l2<`NqF;@7qan_HdXpp$G-RpBvawZ+Zb!jVT2@b7PE5g4T2 z%t%Y!A1CLYJ3kgK57+4jj{|iMmd*nrbVK`8g5N=RG5Ep{E~y{h+WLt2==XjCMaZdi literal 5944 zcmeHL`)|}n5T2ha@jqColCLSTo1jW4Z9xTs8XhSktq?*LI+Du+lJoWKq#RNH^}_ef z+}wKoC<&mp0(A0uz22Rj`R466f9JwqB0tJhMzV{G_pxl_KaomiGQp^npX9Ra$q-Km zlIdK5|3kdHjCHwOmrL@M(t00ihjNTF>XeMy5@@f>E1Y{YKdn@*hVoLmOu+F}3cO8Z zAKX@0Rmz(3v4a&SxDN52GEDI%gA4_Jd&+qRDY-YF%e9Q>L&!(@D_Pd@bL<=9nqk!o zj81TsSU1JG30CEJs&qv>UdC$jx`Y*!h1aS6Cz#!Zyu`Qyl>(!rMrB0?@(pIfYVI&C ztwMrCHn8JB_YRfE*Wj4C+SmKtIhR{CE|W;Iq#;?h;EN{(E!WY=aH5?$XmG|oDbA#2 z+ye(QJgw>66Zutsmq+qUewK&e`WfD@%M-l65}jxicCeqw7OFKOejDR$%o)9>xHol7 zy}BL7x;1{Nao6$J(mo-F9%ef+^*EyJgLIL>>An6Ev#hN{XC1)x%sSjFq-(~5P+Hk*$ zy?xg18aRSkh2x%yL8@(`dR(osqwxafS zAEyu1yFW%m4bhYslkNasQjaL~nK=GC-)E}(^Jk9L&oXm-iP4@Xcu!&d^lrwN&m~5C z2DM1v7mrh5GSpn;xO_-8aUv_oQe9Cz&VbYjqjo)~e~IE_L|V&KmRUZ%D89PLJ|T+J z26A)+|NowbeIR{>)e*glmTr9(Ygf+1olVGc^~`2EW^Efhv+aeXZT(-4%D?GVmK|*u zJFz32ZT@?TyU}K^;68m9v2P!BM+&d|P(QQG@(WI7wa-e)tGZAjQKx5`!7ow=bx{s= zjM4NefKPq+)@uq!(Geq-DXj1!^>^PnPCM@WGqnZwJ=?&Xakon&)I`ihvqnwub>TX& zJ;lYfR-=Ux5n$gv#d}6vcJiz(?_gZ%*_Z!FZ?Eu$kRoSM~aNhriaJieugL3 zd$ez^rOsz^1EX7*9pRLh7&kM<9@cZ$u{;OP-f2F-EWZ#G%I7Xtjcb!l0`oRJZ>MxbQ zfL;ANL9l}nqR|>wa2*l&7@ZMmIZp0@R=Zd~KOHc543=$J(~$9@@?q z9*g?2MZD9kuRmu5D>O+Nt48?dNT25yn-Q#|?R9Q>rh_50^$06VSX69-mN(h|)6;zo zqZjjNuscU7j(X?!%~)z`(lg?}ffvu~`@-W$y&o>I&vv8K)DE)*qwl*>cRhrNA9HE> NVGCBk2ygbm|F^fEt8oAT From 3d8503a83556924996dfab1e8e499e6119bef35b Mon Sep 17 00:00:00 2001 From: micahriggan Date: Wed, 15 Mar 2017 13:59:01 -0500 Subject: [PATCH 125/258] Extending Angular module Updating to reflect the new way to extend the angular module. See angular-ui-router or ng-file-upload for supporting examples. --- angular-file-saver/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/angular-file-saver/index.d.ts b/angular-file-saver/index.d.ts index 7e1fb90b16..ad2baf93be 100644 --- a/angular-file-saver/index.d.ts +++ b/angular-file-saver/index.d.ts @@ -4,12 +4,12 @@ // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// - -declare namespace angular { +import * as angular from 'angular'; +declare module 'angular' { /** * A core Angular factory proving FileSaver functionality. */ - interface FileSaver { + export interface FileSaver { /** * Immediately starts saving a file * @param data: a Blob instance; @@ -18,4 +18,4 @@ declare namespace angular { */ saveAs(blob: Blob, fileName: string, disableBOM?: boolean): void; } -} \ No newline at end of file +} From abaabfb707d4aac204ddd3e23bdb8696c7dc5ce9 Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Thu, 16 Mar 2017 08:57:43 +1300 Subject: [PATCH 126/258] Fixed tests --- tinymce/tinymce-tests.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tinymce/tinymce-tests.ts b/tinymce/tinymce-tests.ts index 18dd5cfbc7..4e3b82f18d 100644 --- a/tinymce/tinymce-tests.ts +++ b/tinymce/tinymce-tests.ts @@ -1,3 +1,5 @@ +import tinymce = require('tinymce'); + tinymce.init( { selector: 'textarea', @@ -14,4 +16,4 @@ tinymce.init( ); -let t = new TinyMce.util.Color('#FFFFFF'); +let t = new tinymce.util.Color('#FFFFFF'); From 140bfd0640fcc0183adc4dae41824f2119bfab38 Mon Sep 17 00:00:00 2001 From: codemannz Date: Thu, 16 Mar 2017 08:58:40 +1300 Subject: [PATCH 127/258] Update index.d.ts --- tinymce/index.d.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index 24e940229f..59ead23021 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -7,6 +7,9 @@ import 'jquery'; +export = tinymce; +export as namespace tinymce; + declare namespace tinymce { var DOM: dom.DOMUtils; From 74fa59d462bf0112e90cb83577291e059baa43f5 Mon Sep 17 00:00:00 2001 From: codemannz Date: Thu, 16 Mar 2017 09:40:16 +1300 Subject: [PATCH 128/258] Update index.d.ts --- tinymce/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index 59ead23021..3884a1f0c4 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -53,6 +53,8 @@ declare namespace tinymce { function trim(s: string): string; function walk(o: {}, f: () => void, n?: string, s?: string): void; + + init(settings: Settings); export interface Settings { table_toolbar?: boolean; From 4854966e7ac7c115e3807c7b1f0aafb8ded50a4a Mon Sep 17 00:00:00 2001 From: codemannz Date: Thu, 16 Mar 2017 09:40:37 +1300 Subject: [PATCH 129/258] Update --- tinymce/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index 3884a1f0c4..501eaf5ef5 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -54,7 +54,7 @@ declare namespace tinymce { function walk(o: {}, f: () => void, n?: string, s?: string): void; - init(settings: Settings); + function init(settings: Settings); export interface Settings { table_toolbar?: boolean; From 9e1f287385289698d9f672a6ed78a6d5b351b5ea Mon Sep 17 00:00:00 2001 From: Andy Date: Wed, 15 Mar 2017 14:30:30 -0700 Subject: [PATCH 130/258] Add additional path mappings for "q" (#15195) --- event-stream/tsconfig.json | 3 +++ gulp-angular-templatecache/tsconfig.json | 3 +++ gulp-autoprefixer/tsconfig.json | 3 +++ gulp-batch/gulp-batch-tests.ts | 2 +- gulp-batch/tsconfig.json | 3 +++ gulp-cache/tsconfig.json | 3 +++ gulp-cached/tsconfig.json | 3 +++ gulp-changed/tsconfig.json | 3 +++ gulp-cheerio/tsconfig.json | 3 +++ gulp-coffeeify/tsconfig.json | 3 +++ gulp-coffeelint/tsconfig.json | 3 +++ gulp-concat/tsconfig.json | 3 +++ gulp-copy/tsconfig.json | 3 +++ gulp-csso/tsconfig.json | 3 +++ gulp-debug/tsconfig.json | 3 +++ gulp-dtsm/tsconfig.json | 3 +++ gulp-espower/tsconfig.json | 3 +++ gulp-file-include/tsconfig.json | 3 +++ gulp-filter/tsconfig.json | 3 +++ gulp-flatten/tsconfig.json | 3 +++ gulp-gh-pages/tsconfig.json | 3 +++ gulp-gzip/tsconfig.json | 3 +++ gulp-html-replace/tsconfig.json | 3 +++ gulp-htmlmin/tsconfig.json | 3 +++ gulp-if/tsconfig.json | 3 +++ gulp-inject/tsconfig.json | 3 +++ gulp-insert/tsconfig.json | 3 +++ gulp-install/tsconfig.json | 3 +++ gulp-istanbul/tsconfig.json | 3 +++ gulp-jade/tsconfig.json | 3 +++ gulp-jasmine-browser/tsconfig.json | 3 +++ gulp-json-editor/tsconfig.json | 3 +++ gulp-jspm/tsconfig.json | 3 +++ gulp-less/tsconfig.json | 3 +++ gulp-load-plugins/tsconfig.json | 3 +++ gulp-minify-css/tsconfig.json | 3 +++ gulp-minify-html/tsconfig.json | 3 +++ gulp-mocha/tsconfig.json | 3 +++ gulp-newer/tsconfig.json | 3 +++ gulp-ng-annotate/tsconfig.json | 3 +++ gulp-nodemon/tsconfig.json | 3 +++ gulp-plumber/tsconfig.json | 3 +++ gulp-remember/tsconfig.json | 3 +++ gulp-rename/tsconfig.json | 3 +++ gulp-replace/tsconfig.json | 3 +++ gulp-rev-replace/tsconfig.json | 3 +++ gulp-rev/tsconfig.json | 3 +++ gulp-ruby-sass/tsconfig.json | 3 +++ gulp-sass/tsconfig.json | 3 +++ gulp-shell/tsconfig.json | 3 +++ gulp-size/tsconfig.json | 3 +++ gulp-sort/tsconfig.json | 3 +++ gulp-sourcemaps/tsconfig.json | 3 +++ gulp-strip-debug/tsconfig.json | 3 +++ gulp-svg-sprite/tsconfig.json | 3 +++ gulp-task-listing/tsconfig.json | 3 +++ gulp-tsd/tsconfig.json | 3 +++ gulp-tslint/tsconfig.json | 3 +++ gulp-typedoc/tsconfig.json | 3 +++ gulp-typescript/tsconfig.json | 3 +++ gulp-uglify/tsconfig.json | 3 +++ gulp-useref/tsconfig.json | 3 +++ gulp-util/tsconfig.json | 3 +++ gulp-watch/tsconfig.json | 3 +++ gulp/index.d.ts | 1 - karma-coverage/tsconfig.json | 3 +++ karma/tsconfig.json | 3 +++ lazypipe/tsconfig.json | 3 +++ main-bower-files/tsconfig.json | 3 +++ merge2/tsconfig.json | 3 +++ vinyl-buffer/tsconfig.json | 3 +++ vinyl-paths/tsconfig.json | 3 +++ vinyl-source-stream/tsconfig.json | 3 +++ wiredep/tsconfig.json | 3 +++ 74 files changed, 217 insertions(+), 2 deletions(-) diff --git a/event-stream/tsconfig.json b/event-stream/tsconfig.json index 208ff51fe0..768497bcd8 100644 --- a/event-stream/tsconfig.json +++ b/event-stream/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-angular-templatecache/tsconfig.json b/gulp-angular-templatecache/tsconfig.json index eda0469b48..869b08da9a 100644 --- a/gulp-angular-templatecache/tsconfig.json +++ b/gulp-angular-templatecache/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-autoprefixer/tsconfig.json b/gulp-autoprefixer/tsconfig.json index 955f890f2b..35ad131268 100644 --- a/gulp-autoprefixer/tsconfig.json +++ b/gulp-autoprefixer/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-batch/gulp-batch-tests.ts b/gulp-batch/gulp-batch-tests.ts index a1e305c03b..c5936eb031 100644 --- a/gulp-batch/gulp-batch-tests.ts +++ b/gulp-batch/gulp-batch-tests.ts @@ -1,7 +1,7 @@ import * as gulp from "gulp"; import * as batch from "gulp-batch"; -gulp.task('default', function() { +gulp.task('default', () => { gulp.watch([ 'lib/**', 'test/**' ], batch((events: any, cb: any) => { events.on('data', console.log).on('end', cb); })); diff --git a/gulp-batch/tsconfig.json b/gulp-batch/tsconfig.json index eb09ea4f9c..1406137b98 100644 --- a/gulp-batch/tsconfig.json +++ b/gulp-batch/tsconfig.json @@ -15,6 +15,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-cache/tsconfig.json b/gulp-cache/tsconfig.json index 3126e1ef38..368718e5d1 100644 --- a/gulp-cache/tsconfig.json +++ b/gulp-cache/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-cached/tsconfig.json b/gulp-cached/tsconfig.json index 32f3759409..77ef9c0aa1 100644 --- a/gulp-cached/tsconfig.json +++ b/gulp-cached/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-changed/tsconfig.json b/gulp-changed/tsconfig.json index 4185d001ef..ab8e90a21d 100644 --- a/gulp-changed/tsconfig.json +++ b/gulp-changed/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-cheerio/tsconfig.json b/gulp-cheerio/tsconfig.json index 254698a94e..d6cdfaac69 100644 --- a/gulp-cheerio/tsconfig.json +++ b/gulp-cheerio/tsconfig.json @@ -12,6 +12,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-coffeeify/tsconfig.json b/gulp-coffeeify/tsconfig.json index 54406ca98a..67e213beda 100644 --- a/gulp-coffeeify/tsconfig.json +++ b/gulp-coffeeify/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-coffeelint/tsconfig.json b/gulp-coffeelint/tsconfig.json index 2cc883884b..f1d388ddb7 100644 --- a/gulp-coffeelint/tsconfig.json +++ b/gulp-coffeelint/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-concat/tsconfig.json b/gulp-concat/tsconfig.json index 1f4acfd285..0d4c2e1c52 100644 --- a/gulp-concat/tsconfig.json +++ b/gulp-concat/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-copy/tsconfig.json b/gulp-copy/tsconfig.json index cc4c620b9f..0111f96820 100644 --- a/gulp-copy/tsconfig.json +++ b/gulp-copy/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-csso/tsconfig.json b/gulp-csso/tsconfig.json index 706fd106af..9519eac9b6 100644 --- a/gulp-csso/tsconfig.json +++ b/gulp-csso/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-debug/tsconfig.json b/gulp-debug/tsconfig.json index accf822a92..dac4ba0725 100644 --- a/gulp-debug/tsconfig.json +++ b/gulp-debug/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-dtsm/tsconfig.json b/gulp-dtsm/tsconfig.json index 6003ac335b..872e75dd19 100644 --- a/gulp-dtsm/tsconfig.json +++ b/gulp-dtsm/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-espower/tsconfig.json b/gulp-espower/tsconfig.json index 1140a956aa..92f4388198 100644 --- a/gulp-espower/tsconfig.json +++ b/gulp-espower/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-file-include/tsconfig.json b/gulp-file-include/tsconfig.json index d166690ec5..d08b25fa2e 100644 --- a/gulp-file-include/tsconfig.json +++ b/gulp-file-include/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-filter/tsconfig.json b/gulp-filter/tsconfig.json index f217497fa9..c48a36bb69 100644 --- a/gulp-filter/tsconfig.json +++ b/gulp-filter/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-flatten/tsconfig.json b/gulp-flatten/tsconfig.json index 484a4e3aef..72d3110eaa 100644 --- a/gulp-flatten/tsconfig.json +++ b/gulp-flatten/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-gh-pages/tsconfig.json b/gulp-gh-pages/tsconfig.json index a6f5d411b1..44cffa6d99 100644 --- a/gulp-gh-pages/tsconfig.json +++ b/gulp-gh-pages/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-gzip/tsconfig.json b/gulp-gzip/tsconfig.json index 07e07f0cf5..4eea3f8d72 100644 --- a/gulp-gzip/tsconfig.json +++ b/gulp-gzip/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-html-replace/tsconfig.json b/gulp-html-replace/tsconfig.json index 25eff60770..e074dcc546 100644 --- a/gulp-html-replace/tsconfig.json +++ b/gulp-html-replace/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-htmlmin/tsconfig.json b/gulp-htmlmin/tsconfig.json index 5d12b48035..964d06a7a1 100644 --- a/gulp-htmlmin/tsconfig.json +++ b/gulp-htmlmin/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-if/tsconfig.json b/gulp-if/tsconfig.json index f9db5297cf..6ea4d6a30b 100644 --- a/gulp-if/tsconfig.json +++ b/gulp-if/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-inject/tsconfig.json b/gulp-inject/tsconfig.json index 0201da00d9..c243f76d43 100644 --- a/gulp-inject/tsconfig.json +++ b/gulp-inject/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-insert/tsconfig.json b/gulp-insert/tsconfig.json index e548f022fa..aa58483b8a 100644 --- a/gulp-insert/tsconfig.json +++ b/gulp-insert/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-install/tsconfig.json b/gulp-install/tsconfig.json index 0b4494f7cd..79ecdd6cf1 100644 --- a/gulp-install/tsconfig.json +++ b/gulp-install/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-istanbul/tsconfig.json b/gulp-istanbul/tsconfig.json index f7ca4e96c7..f860b33143 100644 --- a/gulp-istanbul/tsconfig.json +++ b/gulp-istanbul/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-jade/tsconfig.json b/gulp-jade/tsconfig.json index b746e232bf..6b9c5c22c4 100644 --- a/gulp-jade/tsconfig.json +++ b/gulp-jade/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-jasmine-browser/tsconfig.json b/gulp-jasmine-browser/tsconfig.json index e5b112e90f..c347d86d35 100644 --- a/gulp-jasmine-browser/tsconfig.json +++ b/gulp-jasmine-browser/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-json-editor/tsconfig.json b/gulp-json-editor/tsconfig.json index 85846b46fd..8d6021c6f8 100644 --- a/gulp-json-editor/tsconfig.json +++ b/gulp-json-editor/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-jspm/tsconfig.json b/gulp-jspm/tsconfig.json index fbf318afab..e52189d99a 100644 --- a/gulp-jspm/tsconfig.json +++ b/gulp-jspm/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-less/tsconfig.json b/gulp-less/tsconfig.json index be38992302..4c9110c114 100644 --- a/gulp-less/tsconfig.json +++ b/gulp-less/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-load-plugins/tsconfig.json b/gulp-load-plugins/tsconfig.json index 77238a0e61..4e3ea0ba8c 100644 --- a/gulp-load-plugins/tsconfig.json +++ b/gulp-load-plugins/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-minify-css/tsconfig.json b/gulp-minify-css/tsconfig.json index 2d59793675..0b04647f28 100644 --- a/gulp-minify-css/tsconfig.json +++ b/gulp-minify-css/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-minify-html/tsconfig.json b/gulp-minify-html/tsconfig.json index 3e37896bd2..2b5f377a6c 100644 --- a/gulp-minify-html/tsconfig.json +++ b/gulp-minify-html/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-mocha/tsconfig.json b/gulp-mocha/tsconfig.json index aef5d2d758..3405efd531 100644 --- a/gulp-mocha/tsconfig.json +++ b/gulp-mocha/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-newer/tsconfig.json b/gulp-newer/tsconfig.json index ac02863c9b..53fd3b5fd5 100644 --- a/gulp-newer/tsconfig.json +++ b/gulp-newer/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-ng-annotate/tsconfig.json b/gulp-ng-annotate/tsconfig.json index 16f68955bb..b8b4d4fc6d 100644 --- a/gulp-ng-annotate/tsconfig.json +++ b/gulp-ng-annotate/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-nodemon/tsconfig.json b/gulp-nodemon/tsconfig.json index dc91f8e066..9af358b797 100644 --- a/gulp-nodemon/tsconfig.json +++ b/gulp-nodemon/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-plumber/tsconfig.json b/gulp-plumber/tsconfig.json index 878facc1f7..9f00169b06 100644 --- a/gulp-plumber/tsconfig.json +++ b/gulp-plumber/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-remember/tsconfig.json b/gulp-remember/tsconfig.json index e8ecc18bdc..f8ae755cca 100644 --- a/gulp-remember/tsconfig.json +++ b/gulp-remember/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-rename/tsconfig.json b/gulp-rename/tsconfig.json index 8a3a2c34dd..7276696b70 100644 --- a/gulp-rename/tsconfig.json +++ b/gulp-rename/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-replace/tsconfig.json b/gulp-replace/tsconfig.json index 5624a977d3..8b78b80dcc 100644 --- a/gulp-replace/tsconfig.json +++ b/gulp-replace/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-rev-replace/tsconfig.json b/gulp-rev-replace/tsconfig.json index b3fb130952..dfbd0d502f 100644 --- a/gulp-rev-replace/tsconfig.json +++ b/gulp-rev-replace/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-rev/tsconfig.json b/gulp-rev/tsconfig.json index ea7647e39a..b1f1715d28 100644 --- a/gulp-rev/tsconfig.json +++ b/gulp-rev/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-ruby-sass/tsconfig.json b/gulp-ruby-sass/tsconfig.json index 9465184b37..b6c74a2dd8 100644 --- a/gulp-ruby-sass/tsconfig.json +++ b/gulp-ruby-sass/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-sass/tsconfig.json b/gulp-sass/tsconfig.json index 26e1b2af4c..bec0180414 100644 --- a/gulp-sass/tsconfig.json +++ b/gulp-sass/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-shell/tsconfig.json b/gulp-shell/tsconfig.json index 81356de73d..ac0bc0cf3a 100644 --- a/gulp-shell/tsconfig.json +++ b/gulp-shell/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-size/tsconfig.json b/gulp-size/tsconfig.json index b1be4ca1dc..fe93b09ba6 100644 --- a/gulp-size/tsconfig.json +++ b/gulp-size/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-sort/tsconfig.json b/gulp-sort/tsconfig.json index 87097c7ad2..1921a1884c 100644 --- a/gulp-sort/tsconfig.json +++ b/gulp-sort/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-sourcemaps/tsconfig.json b/gulp-sourcemaps/tsconfig.json index e9c6d80281..9ce9bf808f 100644 --- a/gulp-sourcemaps/tsconfig.json +++ b/gulp-sourcemaps/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-strip-debug/tsconfig.json b/gulp-strip-debug/tsconfig.json index db20e2db69..572113b3cf 100644 --- a/gulp-strip-debug/tsconfig.json +++ b/gulp-strip-debug/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-svg-sprite/tsconfig.json b/gulp-svg-sprite/tsconfig.json index 381d78b150..82b417934a 100644 --- a/gulp-svg-sprite/tsconfig.json +++ b/gulp-svg-sprite/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-task-listing/tsconfig.json b/gulp-task-listing/tsconfig.json index 1f3b796968..fb06f0a926 100644 --- a/gulp-task-listing/tsconfig.json +++ b/gulp-task-listing/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-tsd/tsconfig.json b/gulp-tsd/tsconfig.json index 4252bbc080..813e29fd74 100644 --- a/gulp-tsd/tsconfig.json +++ b/gulp-tsd/tsconfig.json @@ -14,6 +14,9 @@ "paths": { "q": [ "q/v0" ] }, + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-tslint/tsconfig.json b/gulp-tslint/tsconfig.json index 91d3edf8a3..46befdb599 100644 --- a/gulp-tslint/tsconfig.json +++ b/gulp-tslint/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-typedoc/tsconfig.json b/gulp-typedoc/tsconfig.json index 9d0f620269..f60478c1fa 100644 --- a/gulp-typedoc/tsconfig.json +++ b/gulp-typedoc/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-typescript/tsconfig.json b/gulp-typescript/tsconfig.json index fa6cbbc908..120791965a 100644 --- a/gulp-typescript/tsconfig.json +++ b/gulp-typescript/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-uglify/tsconfig.json b/gulp-uglify/tsconfig.json index 43db40e019..d0ae9de799 100644 --- a/gulp-uglify/tsconfig.json +++ b/gulp-uglify/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-useref/tsconfig.json b/gulp-useref/tsconfig.json index 132913f9d8..67e8c2aaed 100644 --- a/gulp-useref/tsconfig.json +++ b/gulp-useref/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-util/tsconfig.json b/gulp-util/tsconfig.json index 06b269e0ed..44b42dbad1 100644 --- a/gulp-util/tsconfig.json +++ b/gulp-util/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp-watch/tsconfig.json b/gulp-watch/tsconfig.json index 7062be6f7e..9822101d39 100644 --- a/gulp-watch/tsconfig.json +++ b/gulp-watch/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/gulp/index.d.ts b/gulp/index.d.ts index 9f3e7d96ba..fefd5b0fda 100644 --- a/gulp/index.d.ts +++ b/gulp/index.d.ts @@ -10,7 +10,6 @@ import Orchestrator = require("orchestrator"); import VinylFile = require("vinyl"); - declare type Strings = string|string[]; declare namespace gulp { diff --git a/karma-coverage/tsconfig.json b/karma-coverage/tsconfig.json index 57290fb7be..404aa4ec66 100644 --- a/karma-coverage/tsconfig.json +++ b/karma-coverage/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/karma/tsconfig.json b/karma/tsconfig.json index 2c74d40398..b2d5e469ba 100644 --- a/karma/tsconfig.json +++ b/karma/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/lazypipe/tsconfig.json b/lazypipe/tsconfig.json index 675e6f38cc..801cf4648a 100644 --- a/lazypipe/tsconfig.json +++ b/lazypipe/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/main-bower-files/tsconfig.json b/main-bower-files/tsconfig.json index fcdebedf3d..04b363ffc6 100644 --- a/main-bower-files/tsconfig.json +++ b/main-bower-files/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/merge2/tsconfig.json b/merge2/tsconfig.json index 4fd4d60c3f..64cf45c2a6 100644 --- a/merge2/tsconfig.json +++ b/merge2/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vinyl-buffer/tsconfig.json b/vinyl-buffer/tsconfig.json index 1208954da6..93296b534b 100644 --- a/vinyl-buffer/tsconfig.json +++ b/vinyl-buffer/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vinyl-paths/tsconfig.json b/vinyl-paths/tsconfig.json index 4aa2ca1faa..126374df8c 100644 --- a/vinyl-paths/tsconfig.json +++ b/vinyl-paths/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/vinyl-source-stream/tsconfig.json b/vinyl-source-stream/tsconfig.json index 580c625e75..ef3c4de3b7 100644 --- a/vinyl-source-stream/tsconfig.json +++ b/vinyl-source-stream/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true diff --git a/wiredep/tsconfig.json b/wiredep/tsconfig.json index 3794e2a3b2..69ee121ef9 100644 --- a/wiredep/tsconfig.json +++ b/wiredep/tsconfig.json @@ -11,6 +11,9 @@ "typeRoots": [ "../" ], + "paths": { + "q": [ "q/v0" ] + }, "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From aa125716cd1d08a2c1e0ebeeac09722ef1c9cc8d Mon Sep 17 00:00:00 2001 From: isoung Date: Wed, 15 Mar 2017 19:00:04 -0500 Subject: [PATCH 131/258] Added StepDefinitionOptions as a 1st arg to Before/After Cucumber supports the use of a timeout as the 1st argument in the Before/After hooks. --- cucumber/cucumber-tests.ts | 10 +++++++++- cucumber/index.d.ts | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cucumber/cucumber-tests.ts b/cucumber/cucumber-tests.ts index 3eb86b223f..802f610a62 100644 --- a/cucumber/cucumber-tests.ts +++ b/cucumber/cucumber-tests.ts @@ -3,7 +3,7 @@ import cucumber = require("cucumber"); function StepSample() { type Callback = cucumber.CallbackStepDefinition; - type Table = cucumber.TableDefinition; + type Table = cucumber.TableDefinition; type HookScenario = cucumber.HookScenario; type Hooks = cucumber.Hooks; var step = this; @@ -19,6 +19,14 @@ function StepSample() { scenario.isFailed() && callback.pending(); }); + hook.Before({ timeout: 1000 }, function(scenario: HookScenario, callback: Callback) { + callback(); + }); + + hook.After({ timeout: 1000 }, function(scenario: HookScenario, callback: Callback) { + callback(); + }); + hook.Around(function(scenario: HookScenario, runScenario: (error:string, callback?:Function)=>void) { scenario.isFailed() && runScenario(null, function(){ console.log('finish tasks'); diff --git a/cucumber/index.d.ts b/cucumber/index.d.ts index 99f31c5372..ca0ab2e865 100644 --- a/cucumber/index.d.ts +++ b/cucumber/index.d.ts @@ -70,9 +70,15 @@ declare namespace cucumber { typeName: string; } + interface HookOptions{ + timeout?: number; + } + export interface Hooks { Before(code: HookCode): void; + Before(options: HookOptions, code: HookCode): void; After(code: HookCode): void; + After(options: HookOptions, code: HookCode): void; Around(code: AroundCode):void; setDefaultTimeout(time:number): void; setWorldConstructor(world: () => void): void; From 72dba6b63cecd20ab1b7b9b82b8af19297caf067 Mon Sep 17 00:00:00 2001 From: isoung Date: Wed, 15 Mar 2017 19:02:15 -0500 Subject: [PATCH 132/258] Added name to contributors name --- cucumber/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cucumber/index.d.ts b/cucumber/index.d.ts index ca0ab2e865..2a7efcdb0e 100644 --- a/cucumber/index.d.ts +++ b/cucumber/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for cucumber-js // Project: https://github.com/cucumber/cucumber-js -// Definitions by: Abraão Alves , Jan Molak +// Definitions by: Abraão Alves , Jan Molak , Isaiah Soung // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped export = cucumber; From a15660c3c2bd064d68dd1ce8376ee833996c7671 Mon Sep 17 00:00:00 2001 From: Victor Palomo de Castro Date: Wed, 15 Mar 2017 21:08:41 -0300 Subject: [PATCH 133/258] Change drawerPosition type so it can match with DrawerPosition --- react-native/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-native/index.d.ts b/react-native/index.d.ts index c0d1884a97..62a7091e9f 100644 --- a/react-native/index.d.ts +++ b/react-native/index.d.ts @@ -2500,9 +2500,9 @@ declare module "react" { /** * Specifies the side of the screen from which the drawer will slide in. - * enum(DrawerConsts.DrawerPosition.Left, DrawerConsts.DrawerPosition.Right) + * enum(DrawerLayoutAndroid.positions.Left, DrawerLayoutAndroid.positions.Right) */ - drawerPosition?: any; + drawerPosition?: number; /** * Specifies the width of the drawer, more precisely the width of the From 1c1ceb45abb296f356986653074105897a6c6f3f Mon Sep 17 00:00:00 2001 From: codemannz Date: Thu, 16 Mar 2017 13:09:48 +1300 Subject: [PATCH 134/258] Update index.d.ts --- tinymce/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index 501eaf5ef5..07c19a0360 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -54,7 +54,7 @@ declare namespace tinymce { function walk(o: {}, f: () => void, n?: string, s?: string): void; - function init(settings: Settings); + function init(settings: Settings): void; export interface Settings { table_toolbar?: boolean; From 7f19bc16dd35f936659c97675d77669116172347 Mon Sep 17 00:00:00 2001 From: codemannz Date: Thu, 16 Mar 2017 13:33:33 +1300 Subject: [PATCH 135/258] Update index.d.ts --- tinymce/index.d.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index 07c19a0360..d6fa1846d9 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -7,8 +7,8 @@ import 'jquery'; -export = tinymce; -export as namespace tinymce; + + declare namespace tinymce { @@ -306,7 +306,7 @@ declare namespace tinymce { export class Editor extends util.Observable { - constructor(id:String, settings:Object, editorManager:tinymce.EditorManager); + constructor(id: string, settings: object, editorManager: tinymce.EditorManager); $: dom.DomQuery; @@ -737,11 +737,11 @@ declare namespace tinymce { constructor(); $el: JQuery; - on(name:String, callback:String):tinymce.ui.Control; + on(name: string, callback: string): tinymce.ui.Control; tooltip(): Control; settings: ControlSettings; - disabled(state:Boolean): void; - active(state:Boolean): void; + disabled(state: boolean): void; + active(state: boolean): void; } } From 3c81233edcd3b1e27d4c44f06dcdcbdffad8d18c Mon Sep 17 00:00:00 2001 From: codemannz Date: Thu, 16 Mar 2017 13:57:26 +1300 Subject: [PATCH 136/258] Update index.d.ts --- tinymce/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinymce/index.d.ts b/tinymce/index.d.ts index d6fa1846d9..04ac24d056 100644 --- a/tinymce/index.d.ts +++ b/tinymce/index.d.ts @@ -306,7 +306,7 @@ declare namespace tinymce { export class Editor extends util.Observable { - constructor(id: string, settings: object, editorManager: tinymce.EditorManager); + constructor(id: string, settings: Settings, editorManager: tinymce.EditorManager); $: dom.DomQuery; From 7484ef85d76e93c7bafe64b89c5a2434ea86ad8c Mon Sep 17 00:00:00 2001 From: Sean Nolan Date: Thu, 16 Mar 2017 14:04:45 +1300 Subject: [PATCH 137/258] Fixed tests --- tinymce/tinymce-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tinymce/tinymce-tests.ts b/tinymce/tinymce-tests.ts index 4e3b82f18d..09c3dd523b 100644 --- a/tinymce/tinymce-tests.ts +++ b/tinymce/tinymce-tests.ts @@ -1,4 +1,4 @@ -import tinymce = require('tinymce'); +import { tinymce } from 'tinymce'; tinymce.init( { From 8e76ee411e538cca53544b8621986214e847e132 Mon Sep 17 00:00:00 2001 From: Alessandro Vergani Date: Thu, 23 Feb 2017 10:51:56 +0100 Subject: [PATCH 138/258] Add missing catchReturn and catchThrow --- bluebird-global/index.d.ts | 2 ++ bluebird/bluebird-tests.ts | 9 +++++++++ bluebird/index.d.ts | 31 +++++++++++++++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/bluebird-global/index.d.ts b/bluebird-global/index.d.ts index e4c4920501..a705222e9d 100644 --- a/bluebird-global/index.d.ts +++ b/bluebird-global/index.d.ts @@ -80,6 +80,8 @@ declare global { // then: typeof Bluebird.prototype.then; thenReturn: typeof Bluebird.prototype.thenReturn; thenThrow: typeof Bluebird.prototype.thenThrow; + catchReturn: typeof Bluebird.prototype.catchReturn; + catchThrow: typeof Bluebird.prototype.catchThrow; throw: typeof Bluebird.prototype.throw; timeout: typeof Bluebird.prototype.timeout; toJSON: typeof Bluebird.prototype.toJSON; diff --git a/bluebird/bluebird-tests.ts b/bluebird/bluebird-tests.ts index c08a7bdc6b..b9fc8d0cef 100644 --- a/bluebird/bluebird-tests.ts +++ b/bluebird/bluebird-tests.ts @@ -506,6 +506,15 @@ fooProm = fooProm.thenThrow(err); // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +barProm = fooProm.catchReturn(bar); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + +// fooProm +fooProm = fooProm.catchThrow(err); + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + str = fooProm.toString(); obj = fooProm.toJSON(); diff --git a/bluebird/index.d.ts b/bluebird/index.d.ts index ecacedfd0d..3508a4e742 100644 --- a/bluebird/index.d.ts +++ b/bluebird/index.d.ts @@ -248,6 +248,37 @@ declare class Bluebird implements Bluebird.Thenable, Bluebird.Inspection; thenThrow(reason: Error): Bluebird; + /** + * Convenience method for: + * + * + * .catch(function() { + * return value; + * }); + * + * + * in the case where `value` doesn't change its value. That means `value` is bound at the time of calling `.catchReturn()` + */ + catchReturn(value: U): Bluebird; + catchReturn(predicate: (error: any) => boolean, value: U): Bluebird; + catchReturn(ErrorClass: new (...args: any[]) => E, value: U): Bluebird; + catchReturn(predicate: Object, value: U): Bluebird; + + /** + * Convenience method for: + * + * + * .catch(function() { + * throw reason; + * }); + * + * Same limitations apply as with `.catchReturn()`. + */ + catchThrow(reason: Error): Bluebird; + catchThrow(predicate: (error: any) => boolean, reason: Error): Bluebird; + catchThrow(ErrorClass: new (...args: any[]) => E, reason: Error): Bluebird; + catchThrow(predicate: Object, reason: Error): Bluebird; + /** * Convert to String. */ From 5da935de2b63c2d2eaed00af2a8723f42d9888d3 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 16 Mar 2017 09:32:41 +0100 Subject: [PATCH 139/258] Move all files from examples to test directory --- react-router/{examples => test}/Ambiguous.tsx | 0 react-router/{examples => test}/Animation.tsx | 0 react-router/{examples => test}/Auth.tsx | 0 react-router/{examples => test}/Basic.tsx | 0 .../{examples => test}/CustomLink.tsx | 0 .../{examples => test}/ModalGallery.tsx | 0 react-router/{examples => test}/NoMatch.tsx | 0 react-router/{examples => test}/Params.tsx | 0 .../PreventingTransitions.tsx | 0 react-router/{examples => test}/README.md | 0 react-router/{examples => test}/Recursive.tsx | 0 .../{examples => test}/RouteConfig.tsx | 0 react-router/{examples => test}/Sidebar.tsx | 0 react-router/tsconfig.json | 24 +++++++++---------- 14 files changed, 12 insertions(+), 12 deletions(-) rename react-router/{examples => test}/Ambiguous.tsx (100%) rename react-router/{examples => test}/Animation.tsx (100%) rename react-router/{examples => test}/Auth.tsx (100%) rename react-router/{examples => test}/Basic.tsx (100%) rename react-router/{examples => test}/CustomLink.tsx (100%) rename react-router/{examples => test}/ModalGallery.tsx (100%) rename react-router/{examples => test}/NoMatch.tsx (100%) rename react-router/{examples => test}/Params.tsx (100%) rename react-router/{examples => test}/PreventingTransitions.tsx (100%) rename react-router/{examples => test}/README.md (100%) rename react-router/{examples => test}/Recursive.tsx (100%) rename react-router/{examples => test}/RouteConfig.tsx (100%) rename react-router/{examples => test}/Sidebar.tsx (100%) diff --git a/react-router/examples/Ambiguous.tsx b/react-router/test/Ambiguous.tsx similarity index 100% rename from react-router/examples/Ambiguous.tsx rename to react-router/test/Ambiguous.tsx diff --git a/react-router/examples/Animation.tsx b/react-router/test/Animation.tsx similarity index 100% rename from react-router/examples/Animation.tsx rename to react-router/test/Animation.tsx diff --git a/react-router/examples/Auth.tsx b/react-router/test/Auth.tsx similarity index 100% rename from react-router/examples/Auth.tsx rename to react-router/test/Auth.tsx diff --git a/react-router/examples/Basic.tsx b/react-router/test/Basic.tsx similarity index 100% rename from react-router/examples/Basic.tsx rename to react-router/test/Basic.tsx diff --git a/react-router/examples/CustomLink.tsx b/react-router/test/CustomLink.tsx similarity index 100% rename from react-router/examples/CustomLink.tsx rename to react-router/test/CustomLink.tsx diff --git a/react-router/examples/ModalGallery.tsx b/react-router/test/ModalGallery.tsx similarity index 100% rename from react-router/examples/ModalGallery.tsx rename to react-router/test/ModalGallery.tsx diff --git a/react-router/examples/NoMatch.tsx b/react-router/test/NoMatch.tsx similarity index 100% rename from react-router/examples/NoMatch.tsx rename to react-router/test/NoMatch.tsx diff --git a/react-router/examples/Params.tsx b/react-router/test/Params.tsx similarity index 100% rename from react-router/examples/Params.tsx rename to react-router/test/Params.tsx diff --git a/react-router/examples/PreventingTransitions.tsx b/react-router/test/PreventingTransitions.tsx similarity index 100% rename from react-router/examples/PreventingTransitions.tsx rename to react-router/test/PreventingTransitions.tsx diff --git a/react-router/examples/README.md b/react-router/test/README.md similarity index 100% rename from react-router/examples/README.md rename to react-router/test/README.md diff --git a/react-router/examples/Recursive.tsx b/react-router/test/Recursive.tsx similarity index 100% rename from react-router/examples/Recursive.tsx rename to react-router/test/Recursive.tsx diff --git a/react-router/examples/RouteConfig.tsx b/react-router/test/RouteConfig.tsx similarity index 100% rename from react-router/examples/RouteConfig.tsx rename to react-router/test/RouteConfig.tsx diff --git a/react-router/examples/Sidebar.tsx b/react-router/test/Sidebar.tsx similarity index 100% rename from react-router/examples/Sidebar.tsx rename to react-router/test/Sidebar.tsx diff --git a/react-router/tsconfig.json b/react-router/tsconfig.json index c7af9e3fcf..c98755507a 100644 --- a/react-router/tsconfig.json +++ b/react-router/tsconfig.json @@ -14,17 +14,17 @@ }, "files": [ "index.d.ts", - "examples/Ambiguous.tsx", - "examples/Animation.tsx", - "examples/Auth.tsx", - "examples/Basic.tsx", - "examples/CustomLink.tsx", - "examples/ModalGallery.tsx", - "examples/NoMatch.tsx", - "examples/Params.tsx", - "examples/PreventingTransitions.tsx", - "examples/Recursive.tsx", - "examples/RouteConfig.tsx", - "examples/Sidebar.tsx" + "test/Ambiguous.tsx", + "test/Animation.tsx", + "test/Auth.tsx", + "test/Basic.tsx", + "test/CustomLink.tsx", + "test/ModalGallery.tsx", + "test/NoMatch.tsx", + "test/Params.tsx", + "test/PreventingTransitions.tsx", + "test/Recursive.tsx", + "test/RouteConfig.tsx", + "test/Sidebar.tsx" ] } From 029e384fa0531cdfcdf74fada54ebff5a899b32f Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 16 Mar 2017 09:52:31 +0100 Subject: [PATCH 140/258] Require TypeScript 2.2 due to the use of object --- react-router-dom/index.d.ts | 2 +- react-router/index.d.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/react-router-dom/index.d.ts b/react-router-dom/index.d.ts index e255eb69f3..b1c327cf80 100644 --- a/react-router-dom/index.d.ts +++ b/react-router-dom/index.d.ts @@ -2,7 +2,7 @@ // Project: https://github.com/ReactTraining/react-router // Definitions by: Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 declare module 'react-router-dom' { import { diff --git a/react-router/index.d.ts b/react-router/index.d.ts index 8dfd32d02b..f8482850b6 100644 --- a/react-router/index.d.ts +++ b/react-router/index.d.ts @@ -11,7 +11,7 @@ // Dovydas Navickas // Tanguy Krotoff // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.1 +// TypeScript Version: 2.2 declare module 'react-router' { import * as React from 'react'; From d241778babf5c234b32b265676b228cc9459ffb5 Mon Sep 17 00:00:00 2001 From: Tanguy Krotoff Date: Thu, 16 Mar 2017 10:58:03 +0100 Subject: [PATCH 141/258] react-router-bootstrap should use react-router v3 --- react-router-bootstrap/tsconfig.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/react-router-bootstrap/tsconfig.json b/react-router-bootstrap/tsconfig.json index 8e586637c7..c41b83b04f 100644 --- a/react-router-bootstrap/tsconfig.json +++ b/react-router-bootstrap/tsconfig.json @@ -15,7 +15,9 @@ ], "paths": { "history": ["history/v3"], - "history/*": ["history/v3/*"] + "history/*": ["history/v3/*"], + "react-router": ["react-router/v3"], + "react-router/*": ["react-router/v3/*"] }, "types": [], "noEmit": true, From 7daa75b30a414bc7a92595bce2e240d9b57a2fd1 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 16 Mar 2017 07:23:40 -0700 Subject: [PATCH 142/258] Fix typo in regexp (#15204) --- css-modules-require-hook/css-modules-require-hook-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/css-modules-require-hook/css-modules-require-hook-tests.ts b/css-modules-require-hook/css-modules-require-hook-tests.ts index ea80474dc5..93da1326bd 100644 --- a/css-modules-require-hook/css-modules-require-hook-tests.ts +++ b/css-modules-require-hook/css-modules-require-hook-tests.ts @@ -62,7 +62,7 @@ hook({ extensions: ['.scss', '.sass'] }); hook({ ignore: (file: string) => false }); hook({ ignore: 'unused' }); -hook({ ignore: /\.test\.(css|scss|sass)/$ }); +hook({ ignore: /\.test\.(css|scss|sass)$/ }); // // https://github.com/css-modules/css-modules-require-hook/blob/master/README.md#preprocesscss-function From 78c38a7f1965a11dd74a08f0722ce92eb011e0de Mon Sep 17 00:00:00 2001 From: "ioan.coleman90" Date: Thu, 16 Mar 2017 14:31:03 +0000 Subject: [PATCH 143/258] Changed stroke-opactiy to stroke-opacity --- mapbox-gl/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapbox-gl/index.d.ts b/mapbox-gl/index.d.ts index 64e8b8e573..e82c2de207 100644 --- a/mapbox-gl/index.d.ts +++ b/mapbox-gl/index.d.ts @@ -979,7 +979,7 @@ declare namespace mapboxgl { "circle-pitch-scale"?: "map" | "viewport"; "circle-stroke-width"?: number | StyleFunction; "circle-stroke-color"?: string | StyleFunction; - "circle-stroke-opactiy"?: number | StyleFunction; + "circle-stroke-opacity"?: number | StyleFunction; } } From bc91cc27065b82c3641795038bcf4996442cfc67 Mon Sep 17 00:00:00 2001 From: "ioan.coleman90" Date: Thu, 16 Mar 2017 14:48:53 +0000 Subject: [PATCH 144/258] Updating file version number --- mapbox-gl/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapbox-gl/index.d.ts b/mapbox-gl/index.d.ts index e82c2de207..b7a9064f86 100644 --- a/mapbox-gl/index.d.ts +++ b/mapbox-gl/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Mapbox GL JS v0.29.0 +// Type definitions for Mapbox GL JS v0.30.0 // Project: https://github.com/mapbox/mapbox-gl-js // Definitions by: Dominik Bruderer // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From c8190f4e646a038824c51bf636ebc45b3852e9f7 Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 16 Mar 2017 08:34:30 -0700 Subject: [PATCH 145/258] gapi.calendar-tests.ts: Convert to UTF-8 (#15208) --- gapi.calendar/gapi.calendar-tests.ts | Bin 9070 -> 4534 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/gapi.calendar/gapi.calendar-tests.ts b/gapi.calendar/gapi.calendar-tests.ts index 909e503846a038e58a583b4e930fcdeb0868b805..0438e5dc069b39fe47045aa71d1b9343ad3b7458 100644 GIT binary patch literal 4534 zcmb_g+iu%N5Pc7jf0(pDDLXbPyLY87;>d2J!i`g39?~=j*5pdsnB=m{r5rWzzxT{8 zmy}#NDT)SxC6jYGbDwdtO~>y=QRR}XxRxbNjV|bCt!H>L7P%}lVd(JXgnkhVah@7g zS^BL}>2+;|u{5`~sz*tZ$%V{yB~2aA9CMuNBJp2$MOD>F+6qhl?6{M6HEkykA3S{U z;o$?KB%xQjF*MGVEG14LNixzJ1qGQ$w`8Kq=yx);q)M`L*&=SG90f2m)@7}8 zxzpiH{eyTTUS?mw-0{ie_{GIr063uNhgYYUXK%YlKSoa&uqQkppT0ak2i5D(f+KEj zZdwnBO4ZH_qOtSN{Mbm5=`vq__NEn-Y;UtX+NSYbrq`sVls3k&3z}LQnv0rPgf{9g zxWLX8ey^%rrNSy*#-15&B$_s5%FifeNrzw>Y?1RV(F}NEmg9anVFSks)h!9WQItCG zzg1Z@>K(BYC_zxCh%;V#FvaKAc{0cHBD0c|F7`*=)}Y z!BD=@d3O;GSgjW_Y7_0SQl~6$|3af^yt2;IoI(MqJW>nfN2b%JKt$u2w8y#Rug{i~ zY!G#HyO~-ALebb{5 zd9H6%IdcW-QrT+MtFoLJ9Rweat7T9JF#w%jGh+vnt{Q7Yt^-r|Vk3T4=Bl>UOnk$rWp;)g9{Uazs;s=-qZjdpGGrl+k+|gR#KWn=AE%^X%@#@MyZcqZ3u5 zomChL99L&z-IlB_Q+X#(2`!G(S7sYM#;?{gG9;mMkXIcu(I5&_C)%NC@g;ud0CL&l zaNe!&X+STHLJWDf)J;*KcnBSd{M5^kz*ZG9;V-18j;xgLL65@o)*+o*16f9wu$jxN zsK#vb!!@SKlu8}Agh8*<4OEH1k7jRlWn9%1vaZEUvV-uXwD)=FA6E8*fZLOie>M^k zIq+klby)|=TM)Ca23>u3zMSxAh@hUm5_K6Au}6MYC0-6nc|%9=&0uRQwt8}YdX5QR z&IbLEh-&nTBbiH>01lU5y{H<*xzGN(9U=Y8LcI6gm|yJ;`xn||(mY$@Y2@N`0YH)O zE4LhF|FyL}mhWZS0Ad)L11|oq*8G5PLwVpDL#(VUYF7l@7ZDb0M=y;WL?NNtAdaG5 zoA2epp|YIWIsHh(6+IZ++Ry-=AccSopWx$%R#J={0S6vEe!RxA0uMZ1{Ajg|+_BPPD1h3=EE#_d{cP}}>(!HPrqJf?`SC_MHO@!M9k z)x+&X+#M@xj(&l*yxv57vBb{f9znZGpy%IH*@rH0Bv3&TGt5n6Lc`}ez0%o|uq0Z6 zLDi0~nL<0Kw(=a}ZNg5bY>je9&6hfpZJ%o2hH+54tiKJsbm3Zr=A9O^HpMoFnX`go zW4G)5*+Lkh3vo4dq2fTZl#lEgy0KMb`vrqp7(5nav@C7}-HMW8Lq&$*TrnM{K;I$#8)$EI>>D zH|q9S%m1LxU30 z;qjdju5p_gTqSGJaB4<{#2w~V2oDpR8DwJ;Gv)qQxP!kL_9)jmDqS@d?{YoI-mn`T zZ#-!C`|XqdO#gS=j&CMm-}(5q6Jb}tUm;x7TrXnH-HvhZhT%xNw%s@O=-3?$zVl*% V=PBuEV*iKuh^4Ed)nX|_; zv%5}OT7fLzc4yA@J-6Av{~Ct(LKQZ{v#=A6!$~*_`}#lEzu)w0tltM=8Ya3|g>Upd z35WHX4Xt7IIPB@yRQK1z4`EB+-|GJpz3+rwT_1_+TvvY#r~17sy0b`s8m~Uq=Ugjh zVJ!^x+7rbmdLN0?iN2@0GZ4?jc_13dGc2xN7Qd57XQ=z7WW(@#2k&9{RkSPVKMZe% zH{$zw{H$~pS*q}pIGsk_HYCv~YKtyg;f6lpgM}XHdZktS(gb}?gFRhKw)BS=^YA!Q$!&~ONtPQm-DH_6Y>3iWT1=uR-q-4;J+W0Ae}g4|l`E+5*>fy%)Zaowmcha9h{gtFCLs=L-v?k5jy()!V|%rjSwvXx$HQw={Sf zc$FBy*Q1CG$HI>Mgbmx?A4JdWNOLT46#fv82Mvjcg7+4_2NURvN5CsSI?(5C!~%XE zN6(!~0uYMTcOsTtiixg{!k@Ye3XltFE3E>fAPMZu^^Ht}g0rC!I~|DMIHJVXA%V-Z zUhCTrD_WUw%f7?NXC%5VPx_T4>t|fq)udwA@b7Mh{fClyPuJG8zU}MxTQs54lkWJ5 zc($Fn=Ld>~iKvc4Uw2u(5|+^!DejM>RY%c&PLH@d)pf_L%YG(G<{h#W*~;y9Tfb-8 zb0jaU)M#MWS)}1~x^Qt*oSm9Q{Y;u!l#vHg%)9m7=E>ugc!L}=-L&C<=WQtbQnZOb zvNImqR<`lnai%NIBiDyaY|+rg8T`8DFOEDA?pizboM*pN5>S$7v~_7Sk`7Mcs&dJs zt~9x3ZA^R4aD82~eP!a2>}dIe7$-`>2r)|5AS-W1-}}|ClmoVe2k_RWcUgC!2oB%M zkO4X@4|MBVg?II;w8v@Y_8CM^lli9|5esdrI5)+E8kjs=DYI@x99xZ`;!p#~Xk>)E zF7f+OM9Wk<=H9i4aLJn18we3|?I1#^5o9a!)Q+y1WqYzG7$@Q^n;S*@ba|RRf%%&p zRqg?~)OezxEAN;s?kL+$l>57EL4}9wQ^`7(mo3XeEoJ4o?pu8wNjuLNiJDs>kIP5W zI7OgoXVRFZsRz!nZB2RsA`i}GUVnA_!xjH_`M|OkJTA^(TcXfy4|12;)VmVP6?t|u znM>4Kd_PtG!=kcJ?T+T5a8zMSt?7cX`;TU01uZ+eWlDH2dP} zoXKe4$-8EOBwssY{rf7M$F$YkW!08C;+2&(d0nOQwd*CT4iwiGd(_8dBg1HyE%Hp( zjAbw~mp!KPOinvR{Kc5OC5u`<%c}()M%l@`ryT{&d{?PQC3n$RpDKe{cj)n&yg19W zrq?4{cVjNfZBL%f^C|YEi}P$pcbDhb^D*YTnmVN%+029qLAg|e1%K)nePlj`^k)JR2)(`SEHpR+5x6o10o6)OKGpt(xpUjdr>oF(JBU-@a zzABzy!2@*IPK_M*O#irouc;Oufp`G!3AcFAceZmfRnqenohTS8Z8p%gt;nAm*W`ut z*4GjB^gyOv$=^DA>O1pYsx|02(`zSoB90(ig9Tp}Ll^t9Ya;OO2~C)VkqPTEb1g$z z+e*0)K%vRfZ%iL#kv1;rx2*T?)fRHBfYM}3%RxO!XBhb|`r3B(W&Qow58SAcgsv-! zL8{W0vfsAeHiOd>aJP&0tnMqAsEHl(g7HYXv3sZG5_aYBV|#rH>Dr05&om*Y-g{Qt z<4RcVl#=d*PH-CNSKW3gp6=Eb>J`>ITf}m1)6(w)QGKR2oie)jTNSY%F;5TJu4{P6 z@suON&;%#;4I~}3kM%EA0`o5M!yHUx?`i&L54o(Fp~^^H(+aOWxo*((zC4!)gu>xa zay-_W>w2#)(FYm_!Vt53zs3YqO{Z09VE?|*_i`S#>QcCL4wr808K0c;eR20w3b$JR z?H+g;V(e4-G`Q^_u=utRN=dE02vxpI!b zFW<4ttqQjBSij-#O8JlI`$ZH}#&$HDcAQ713cyM0NGRk)rdux0`w8o*OMRIq7|qjh z$z zZ`7L++x_&V>j{X>J)Do)DT_r35;4!6NCM9SXz)bx(%+63xniv$(|=>#E=}xNj%N$A z5U64b;RG;glICT%TTkoCXHc*D#DU7=^A8B~9@DO-^Cgp$tU%{s`N$%TU7&B%hLX%a9Q^MRM~Y^7FpBhYW>OGPwL-I{zf0WP;GvWzVT-wJz1Bl z*bd(fbv81Q77umZq5@nph2%DGo(T1{hA#beX?JCzi|P1(Ye(GW&-LgFOxOE`UCh$A zHNoAJ9XI8Vul0LVPqnY<3B&T0-KIr$c18FZIsr$3R-~l)R_TsKhLqbW@wfX9rZJ^Qh%$X={W%k0qmN z#MArb$gxwI8`{CtZO`It_4!lyB-ZR{M7Cv!Wgc@~i34gG(QIo=Ym$w6wcIunyWCfm zo$N{6$BM%)Tb{>*lXH5p6H#BzgY4IyIvy1GOZU&}dD{Kp9UYc`U1vLaXVN_1d6l!B zo_q$%$;4A3)MG8pa;{aHZ~RKB-;11KB&zLhJMTZ!3B+bS!%!vio_A02ZWATFZK6Af Vy~DBMkaOp;o)wgxs{b?Z{R2avS2_Ry From 25d01b35ab1bccd4d06261b3c718776a872335a2 Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Thu, 16 Mar 2017 18:24:01 +0200 Subject: [PATCH 146/258] Extend Koa.Context interface: koa-router adds a new property into context object: https://github.com/alexmingoia/koa-router/tree/master#url-parameters, this commit reflects that change in the Koa.Context interface --- koa-router/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/koa-router/index.d.ts b/koa-router/index.d.ts index 8d78591165..771907aac4 100644 --- a/koa-router/index.d.ts +++ b/koa-router/index.d.ts @@ -13,6 +13,12 @@ import * as Koa from "koa"; +declare module "koa" { + interface Context { + params: any; + } +} + declare module Layer { export interface ILayerOptions { From c9ce056c1acba4510fedc58d3c9f3f03b3aff17a Mon Sep 17 00:00:00 2001 From: Pavel Ivanov Date: Thu, 16 Mar 2017 18:33:13 +0200 Subject: [PATCH 147/258] Add info about myself into the header --- koa-router/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koa-router/index.d.ts b/koa-router/index.d.ts index 771907aac4..f93c983bb0 100644 --- a/koa-router/index.d.ts +++ b/koa-router/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for koa-router v7.x // Project: https://github.com/alexmingoia/koa-router/ -// Definitions by: Jerry Chin +// Definitions by: Jerry Chin , Pavel Ivanov // Definitions: https://github.com/hellopao/DefinitelyTyped /* =================== USAGE =================== From ca622833a6a6d975e37ec74beae0b0be63f63f07 Mon Sep 17 00:00:00 2001 From: Wouter Hardeman Date: Thu, 16 Mar 2017 18:34:54 +0100 Subject: [PATCH 148/258] Updated @types/react-paginate to version 4.2.0 --- react-paginate/index.d.ts | 24 +++++++++++++++++------- react-paginate/react-paginate-tests.tsx | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/react-paginate/index.d.ts b/react-paginate/index.d.ts index aaa3931b74..fa1d928ce0 100644 --- a/react-paginate/index.d.ts +++ b/react-paginate/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for react-paginate 2.1.3 +// Type definitions for react-paginate 4.2.0 // Project: https://github.com/AdeleD/react-paginate -// Definitions by: Simon Hartcher +// Definitions by: Simon Hartcher , Wouter Hardeman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.1 @@ -10,7 +10,7 @@ interface ReactPaginateProps { /** * The total number of pages. */ - pageNum: number; + pageCount: number; /** * The range of pages displayed. @@ -43,19 +43,24 @@ interface ReactPaginateProps { breakClassName?: string | JSX.Element; /** - * The method to call when a page is clicked. + * The method to call when a page is clicked. Exposes the current page object as an argument. */ - clickCallback?: Function; + onPageChange?: Function; /** * The initial page selected. */ - initialSelected?: number; + initialPage?: number; /** * To override selected page with parent prop. */ - forceSelected?: number; + forcePage?: number; + + /** + * Disable `onPageChange` callback with initial page. Default: `false` + */ + disableInitialCallback?: boolean /** * The classname of the pagination container. @@ -101,6 +106,11 @@ interface ReactPaginateProps { * The classname for disabled `previous` and `next` buttons. */ disabledClassName?: string; + + /** + * The method is called to generate the `href` attribute value on tag `a` of each page element. + */ + hrefBuilder?: Function; } declare const ReactPaginate: React.ComponentClass; diff --git a/react-paginate/react-paginate-tests.tsx b/react-paginate/react-paginate-tests.tsx index 2ae495eacf..42a7c49c30 100644 --- a/react-paginate/react-paginate-tests.tsx +++ b/react-paginate/react-paginate-tests.tsx @@ -5,7 +5,7 @@ class Test extends React.Component<{}, {}> { public render() { return ( From 366da3f3c3eaff47db425846ef43011fb8e6e66e Mon Sep 17 00:00:00 2001 From: Wouter Hardeman Date: Thu, 16 Mar 2017 18:46:20 +0100 Subject: [PATCH 149/258] Added 'v' before version number to follow the guidelines --- react-paginate/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-paginate/index.d.ts b/react-paginate/index.d.ts index fa1d928ce0..363aeb8ea1 100644 --- a/react-paginate/index.d.ts +++ b/react-paginate/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for react-paginate 4.2.0 +// Type definitions for react-paginate v4.2.0 // Project: https://github.com/AdeleD/react-paginate // Definitions by: Simon Hartcher , Wouter Hardeman // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 8a5f3b9db713fce3c1da6daa71626fca2b42c8aa Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 19:09:45 +0100 Subject: [PATCH 150/258] the click callback accepts an event as its third param See https://github.com/electron/electron/blob/6d45052eeaf57faf239523b1b328cf37281ae030/lib/browser/api/menu-item.js#L52 --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index 0b98ae1944..b5a657ab61 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2492,7 +2492,7 @@ declare namespace Electron { /** * Callback when the menu item is clicked. */ - click?: (menuItem: MenuItem, browserWindow: BrowserWindow) => void; + click?: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void; /** * Can be normal, separator, submenu, checkbox or radio. */ From a207b07344f3720ca65c218a8766d8f7d1379f4b Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 19:10:12 +0100 Subject: [PATCH 151/258] Fix signature for menu item click instance method See https://github.com/electron/electron/blob/6d45052eeaf57faf239523b1b328cf37281ae030/lib/browser/api/menu-item.js#L44 --- electron/index.d.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index b5a657ab61..c7ba10f83c 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2455,7 +2455,11 @@ declare namespace Electron { */ constructor(options: MenuItemOptions); - click: (menuItem: MenuItem, browserWindow: BrowserWindow, event: Event) => void; + /** + * A Function that is fired when the MenuItem recieves a click event + */ + click: (event: Event, browserWindow: BrowserWindow, webContents: WebContents) => void; + /** * Read-only property. */ From 021ee30fe2aff40307a6cd4f3f00894f9c64c995 Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 19:10:25 +0100 Subject: [PATCH 152/258] Add tests to verify new signatures --- electron/test/main.ts | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/electron/test/main.ts b/electron/test/main.ts index 276a15d851..35a85a81dc 100644 --- a/electron/test/main.ts +++ b/electron/test/main.ts @@ -531,12 +531,19 @@ var winWindows = new BrowserWindow({ // menu-item // https://github.com/atom/electron/blob/master/docs/api/menu-item.md -var menuItem = new MenuItem({}); +var menuItem = new MenuItem({ + click: (menuItem: Electron.MenuItem, browserWindow: Electron.BrowserWindow, event: Electron.Event) => { + console.log('click', menuItem, browserWindow, event); + } +}); + +const fakeEvent: Electron.Event = { + preventDefault: () => { }, + sender: winWindows.webContents, +} menuItem.label = 'Hello World!'; -menuItem.click = (menuItem, browserWindow) => { - console.log('click', menuItem, browserWindow); -}; +menuItem.click(fakeEvent, winWindows, winWindows.webContents) // menu // https://github.com/atom/electron/blob/master/docs/api/menu.md From 262a66c3090af69a4d328bdbe70aae662353206a Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Thu, 16 Mar 2017 21:37:31 +0100 Subject: [PATCH 153/258] Add myself to the definitions list --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index c7ba10f83c..3fab5cdf63 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for Electron v1.4.8 // Project: http://electron.atom.io/ -// Definitions by: jedmao , rhysd , Milan Burda , aliib , Daniel Perez Alvarez +// Definitions by: jedmao , rhysd , Milan Burda , aliib , Daniel Perez Alvarez , Markus Olsson // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From a6c1c773a5aca88aa4ef7ecdd64c71af488b4b43 Mon Sep 17 00:00:00 2001 From: Markus Olsson Date: Fri, 17 Mar 2017 00:32:16 +0100 Subject: [PATCH 154/258] Spelling --- electron/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/electron/index.d.ts b/electron/index.d.ts index 3fab5cdf63..11103b3a18 100644 --- a/electron/index.d.ts +++ b/electron/index.d.ts @@ -2456,7 +2456,7 @@ declare namespace Electron { constructor(options: MenuItemOptions); /** - * A Function that is fired when the MenuItem recieves a click event + * A function that is fired when the MenuItem receives a click event */ click: (event: Event, browserWindow: BrowserWindow, webContents: WebContents) => void; From e3385bf72b718e9f59bc4a1205a266ed15c341c6 Mon Sep 17 00:00:00 2001 From: andy-ms Date: Thu, 16 Mar 2017 20:17:28 -0700 Subject: [PATCH 155/258] Add 'dir-resolve' --- dir-resolve/dir-resolve-tests.ts | 3 +++ dir-resolve/index.d.ts | 7 +++++++ dir-resolve/tsconfig.json | 22 ++++++++++++++++++++++ dir-resolve/tslint.json | 1 + 4 files changed, 33 insertions(+) create mode 100644 dir-resolve/dir-resolve-tests.ts create mode 100644 dir-resolve/index.d.ts create mode 100644 dir-resolve/tsconfig.json create mode 100644 dir-resolve/tslint.json diff --git a/dir-resolve/dir-resolve-tests.ts b/dir-resolve/dir-resolve-tests.ts new file mode 100644 index 0000000000..d84f9d0efc --- /dev/null +++ b/dir-resolve/dir-resolve-tests.ts @@ -0,0 +1,3 @@ +import resolve = require("dir-resolve"); + +resolve("module/package"); diff --git a/dir-resolve/index.d.ts b/dir-resolve/index.d.ts new file mode 100644 index 0000000000..0b8f425b0b --- /dev/null +++ b/dir-resolve/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for dir-resolve 1.0 +// Project: https://github.com/mwinche/dir-resolve +// Definitions by: Andy Hanson +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function resolve(path: string): string; +export = resolve; diff --git a/dir-resolve/tsconfig.json b/dir-resolve/tsconfig.json new file mode 100644 index 0000000000..1748792b1d --- /dev/null +++ b/dir-resolve/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "dir-resolve-tests.ts" + ] +} \ No newline at end of file diff --git a/dir-resolve/tslint.json b/dir-resolve/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/dir-resolve/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } From 78d4a9d2962c16b9874399d26c49c97f6f79f0eb Mon Sep 17 00:00:00 2001 From: David Findley Date: Thu, 16 Mar 2017 22:48:35 -0500 Subject: [PATCH 156/258] jwt-simple: Adding optional 'algorithm' param to decode() --- jwt-simple/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jwt-simple/index.d.ts b/jwt-simple/index.d.ts index 1ae8f18519..b70aa8c720 100644 --- a/jwt-simple/index.d.ts +++ b/jwt-simple/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for jwt-simple v0.5.0 +// Type definitions for jwt-simple v0.5.1 // Project: https://github.com/hokaccha/node-jwt-simple // Definitions by: Ken Fukuyama , Gael Magnan // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,7 +11,7 @@ * @param algorithm default is HS256 * @api public */ -export function decode(token: any, key: string, noVerify?: boolean): any; +export function decode(token: any, key: string, noVerify?: boolean, algorithm?: string): any; /** * Encode jwt * @param payload From 919f99e40f21f94e5a613f60cbd496048c5a87e8 Mon Sep 17 00:00:00 2001 From: Oskar Kapusta Date: Fri, 17 Mar 2017 14:27:46 +0100 Subject: [PATCH 157/258] Add socket_id to pusher-js ConnectionManager interface --- pusher-js/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/pusher-js/index.d.ts b/pusher-js/index.d.ts index ea097ff95f..0a9f3470b0 100644 --- a/pusher-js/index.d.ts +++ b/pusher-js/index.d.ts @@ -145,6 +145,7 @@ declare namespace pusher { key: string; options: any; //TODO: Timeline.js state: string; + socket_id: string; connection: any; //TODO: Type this encrypted: boolean; timeline: any; //TODO: Type this From 0416807752ccf85b7ff0c643235291ef3d7a0367 Mon Sep 17 00:00:00 2001 From: Jan Varwig Date: Fri, 17 Mar 2017 15:37:45 +0100 Subject: [PATCH 158/258] [react-textarea-autosize] Fix onChange signature --- react-textarea-autosize/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-textarea-autosize/index.d.ts b/react-textarea-autosize/index.d.ts index 647d19c6ac..2d07898200 100644 --- a/react-textarea-autosize/index.d.ts +++ b/react-textarea-autosize/index.d.ts @@ -19,7 +19,7 @@ declare module "react-textarea-autosize" { * Callback on value change * @param event */ - onChange?: (event: React.FormEvent) => void; + onChange?: (event: React.ChangeEvent) => void; /** * Callback on height change * @param height From e4566cbfc15637e31930a90a9bcaa75b8d25421e Mon Sep 17 00:00:00 2001 From: Mike Hill Date: Wed, 15 Mar 2017 11:30:49 -0500 Subject: [PATCH 159/258] Webpack: Add DllPlugin and DllReferencePlugin classes and properties --- webpack/index.d.ts | 78 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/webpack/index.d.ts b/webpack/index.d.ts index 28d1b33b40..ed706a7868 100644 --- a/webpack/index.d.ts +++ b/webpack/index.d.ts @@ -689,6 +689,84 @@ declare namespace webpack { constructor(definitions: {[key: string]: any}); } + class DllPlugin extends Plugin { + constructor(options: DllPlugin.Options | DllPlugin.Options[]); + } + + namespace DllPlugin { + interface Options { + /** + * The absolute path to the manifest json file (output). + */ + path: string, + + /** + * The name of the exposed DLL function (keep consistent with `output.library`). + */ + name: string, + + /** + * The context of requests in the manifest file. + * + * Defaults to the webpack context. + */ + context?: string + } + } + + class DllReferencePlugin extends Plugin { + constructor(options: DllReferencePlugin.Options); + } + + namespace DllReferencePlugin { + interface Options { + /** + * The context of requests in the manifest (or content property). + * + * This is an absolute path. + */ + context: string, + + /** + * An object containing `content` and `name`. + */ + manifest: { + content: string, + name: string + }, + + /** + * The prefix which is used for accessing the content of the DLL. + */ + scope?: string, + + /** + * The name where the DLL is exposed. + * + * Defaults to `manifest.name`. + * + * See also `externals`. + */ + name?: string, + + /** + * The type how the DLL is exposed. + * + * Defaults to `"var"`. + * + * See also `externals`. + */ + sourceType?: string, + + /** + * The mappings from the request to module ID. + * + * Defaults to `manifest.content`. + */ + content?: any + } + } + class EvalSourceMapDevToolPlugin extends Plugin { constructor(options?: false | string | EvalSourceMapDevToolPlugin.Options); } From 0f535159029908a2b5e068391b399e4d9a562d69 Mon Sep 17 00:00:00 2001 From: Josephine Lee Date: Fri, 17 Mar 2017 12:35:24 -0400 Subject: [PATCH 160/258] Update react-bootstrap typings for FormControl --- react-bootstrap/index.d.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/react-bootstrap/index.d.ts b/react-bootstrap/index.d.ts index 500babd6cf..167001a4dc 100644 --- a/react-bootstrap/index.d.ts +++ b/react-bootstrap/index.d.ts @@ -964,8 +964,10 @@ declare namespace ReactBootstrap { // interface FormControlProps extends React.HTMLProps { bsClass?: string; + bsSize?: Sizes; componentClass?: React.ReactType; id?: string; + inputRef?: (instance: HTMLInputElement) => void; type?: string; } interface FormControlClass extends React.ClassicComponentClass { From 9d3e3149d5ddc485b75bc14c5fe5a8b7f9507658 Mon Sep 17 00:00:00 2001 From: Ben Schwartz Date: Fri, 17 Mar 2017 13:08:27 -0400 Subject: [PATCH 161/258] Expand allowed cert and key types in Restify --- restify/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/restify/index.d.ts b/restify/index.d.ts index 8a85283d93..759a46c6d0 100644 --- a/restify/index.d.ts +++ b/restify/index.d.ts @@ -450,8 +450,8 @@ interface Server extends http.Server { interface ServerOptions { ca?: string; - certificate?: string; - key?: string; + certificate?: string | string[] | Buffer | Buffer[]; + key?: string | string[] | Buffer | Buffer[]; formatters?: Object; log?: Object; name?: string; From ebd423cc3d134a2d061a95e1567cd50f082eae69 Mon Sep 17 00:00:00 2001 From: Alexander Batukhtin Date: Fri, 17 Mar 2017 20:13:28 +0300 Subject: [PATCH 162/258] Speakeasy: added "digits" property to the TotpOptions interface. --- speakeasy/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/speakeasy/index.d.ts b/speakeasy/index.d.ts index 15ec90c09a..4e281f996f 100644 --- a/speakeasy/index.d.ts +++ b/speakeasy/index.d.ts @@ -49,6 +49,7 @@ interface TotpOptions { counter?: number; epoch?: number; secret?: string; + digits?: number; digest?: () => string; algorithm?: string; } From d18dc045edc38ad291d73f5f526d5a71e87db524 Mon Sep 17 00:00:00 2001 From: Josh Goldberg Date: Fri, 17 Mar 2017 10:54:51 -0700 Subject: [PATCH 163/258] Overhauled YouTube API typings Added completed docs comments, numeric values, and more informative literal types. Removed deprecated fields. With :heart: from Office Sway! --- youtube/index.d.ts | 1037 ++++++++++++++++++++++++++++++++++++++------ 1 file changed, 903 insertions(+), 134 deletions(-) diff --git a/youtube/index.d.ts b/youtube/index.d.ts index ca5d99550a..a45ec6a8c8 100644 --- a/youtube/index.d.ts +++ b/youtube/index.d.ts @@ -1,166 +1,935 @@ // Type definitions for YouTube // Project: https://developers.google.com/youtube/ -// Definitions by: Daz Wilkin , Ian Obermiller +// Definitions by: Daz Wilkin , +// Ian Obermiller , +// Josh Goldberg // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.1 -declare namespace YT { - interface EventArgs { - target: Player; - data: any; - } - - interface EventHandler { - (event: EventArgs): void; - } - - export interface Events { - onReady?: EventHandler; - onPlayback?: EventHandler; - onStateChange?: EventHandler; - onError?: EventHandler; - } - - export enum ListType { - search, - user_uploads, - playlist, +/** + * @see https://developers.google.com/youtube/iframe_api_reference + * @see https://developers.google.com/YouTube/player_parameters + */ +declare namespace YT +{ + /** + * State of a video player. + */ + export enum PlayerState + { + UNSTARTED = -1, + ENDED = 0, + PLAYING = 1, + PAUSED = 2, + BUFFERING = 3, + CUED = 5 } - export interface PlayerVars { - autohide?: number; - autoplay?: number; - cc_load_policy?: any; - color?: string; - controls?: number; - disablekb?: number; - enablejsapi?: number; + /** + * Known causes for player errors. + */ + export const enum PlayerError + { + /** + * The request contained an invalid parameter value. + */ + InvalidParam = 2, + + /** + * The requested content cannot be played in an HTML5 player. + */ + Html5Error = 5, + + /** + * The video requested was not found. + */ + VideoNotFound = 100, + + /** + * The owner of the requested video does not allow it to be played in embedded players. + */ + EmbeddingNotAllowed = 101, + + /** + * This error is the same as 101. It's just a 101 error in disguise! + */ + EmbeddingNotAllowed2 = 150 + } + + /** + * Whether to auto-hide video controls. + */ + export const enum AutoHide + { + /** + * Controls are visible throughout the video + */ + AlwaysVisible = 0, + + /** + * Progress bar and player controls slide out of view after a couple of seconds. + */ + HideAllControls = 1, + + /** + * Progress bar fades out while the player controls remain visible. + */ + HideProgressBar = 2 + } + + /** + * Whether to autoplay the video. + */ + export const enum AutoPlay + { + /** + * Video does not autoplay. + */ + NoAutoPlay = 0, + + /** + * Video will autoplay when loaded. + */ + AutoPlay = 1 + } + + /** + * Whether to use user-preferred or forced caption loading. + */ + export const enum ClosedCaptionsLoadPolicy + { + /** + * Defaults to the user's preferences. + */ + UserDefault = 0, + + /** + * For closed captions to be shown. + */ + ForceOn = 1 + } + + /** + * Allowed progress bar colors. + */ + export type ProgressBarColor = "red" | "white"; + + /** + * How video controls are shown. + */ + export const enum Controls + { + /** + * Player controls do not display. + */ + Hide = 0, + + /** + * Player controls display. + */ + ShowLoadPlayer = 1, + + /** + * Player controls display after a delay. + */ + ShowDelayLoadPlayer = 2 + } + + /** + * Whether to allow keyboard controls. + */ + export const enum KeyboardControls + { + /** + * Keyboard controls are enabled. + */ + Enable = 0, + + /** + * Keyboard controls are disabled. + */ + Disable = 1 + } + + /** + * Whether the JavaScript API should be enabled. + */ + export const enum JsApi + { + /** + * JavaScript API will be disabled. + */ + Disable = 0, + + /** + * JavaScript API will be enabled. + */ + Enable = 1 + } + + /** + * Whether to display the full-screen button. + */ + export const enum FullscreenButton + { + /** + * The full screen button is hidden. + */ + Hide = 0, + + /** + * The full screen button is visible. + */ + Show = 1 + } + + /** + * Whether to show video annotations. + */ + export const enum IvLoadPolicy + { + /** + * Video annotations will be shown. + */ + Show = 1, + + /** + * Video annotations will not be shown. + */ + Hide = 3 + } + + /** + * Which type of content loads in the player. + */ + export type ListType = ListTypePlayer | ListTypeSearch | ListTypeUserUploads; + + /** + * The requested video should be shown in the player. + */ + export type ListTypePlayer = "player"; + + /** + * A search area should be shown in the player. + */ + export type ListTypeSearch = "search"; + + /** + * The user's uploads should load in the player. + */ + export type ListTypeUserUploads = "user_uploads"; + + /** + * Whether a single video should be looped. + */ + export const enum Loop + { + /** + * Video or playlist will be played only once. + */ + SinglePlay = 0, + + /** + * Video or playlist will be played over and over again. + */ + Loop = 1 + } + + /** + * Comma separated list of video IDs to play after the URL path's video. + */ + export const enum ModestBranding + { + /** + * Player will contain full YouTube branding. + */ + Full = 0, + + /** + * YouTube logo will not display in the control bar. + */ + Modest = 1 + } + + /** + * Whether to show related videos after the video finishes. + */ + export const enum RelatedVideos + { + /** + * Hide related videos after playback is complete. + */ + Hide = 0, + + /** + * Show related videos after playback is complete. + */ + Show = 1 + } + + /** + * Whether to show video information before playing. + */ + export const enum ShowInfo + { + /** + * Hide video title and uploader before video starts playing. + */ + Hide = 0, + + /** + * Show video title and uploader before video starts playing. + */ + Show = 1 + } + + /** + * Base interface for events triggered by a player. + */ + export interface PlayerEvent + { + /** + * Video player corresponding to the event. + */ + target: Player; + } + + /** + * Event for player state change. + */ + export interface OnStateChangeEvent extends PlayerEvent + { + /** + * New player state. + */ + data: PlayerState; + } + + /** + * Event for playback quality change. + */ + export interface OnPlaybackQualityChangeEvent extends PlayerEvent + { + /** + * New playback quality. + */ + data: string; + } + + /** + * Event for playback rate change. + */ + export interface OnPlaybackRateChangeEvent extends PlayerEvent + { + /** + * New playback rate. + */ + data: number; + } + + /** + * Event for a player error. + */ + export interface OnErrorEvent extends PlayerEvent + { + /** + * Which type of error occurred. + */ + data: PlayerError; + } + + /** + * Handles a player event. + * + * @param event The triggering event. + */ + export interface PlayerEventHandler + { + (event: TEvent): void; + } + + /** + * YouTube player options. + */ + export interface PlayerOptions + { + /** + * Player width. + */ + width?: number; + + /** + * Player height + */ + height?: number; + + /** + * ID of the video to load. + */ + videoId: string; + + /** + * Player parameters. + */ + playerVars?: PlayerVars; + + /** + * Handlers for events fired by the player. + */ + events?: Events; + } + + /** + * Allowed suggested player video qualities. + */ + export type SuggestedVideoQuality = ( + VideoQualityDefault + | VideoQualitySmall + | VideoQualityMedium + | VideoQualityLarge + | VideoQualityHD720 + | VideoQualityHD1080 + | VideoQualityHighRes); + + /** + * Default video quality chosen by YouTube. + */ + export type VideoQualityDefault = "default"; + + /** + * Player height is 240px, and player dimensions are at least 320px by 240px for 4:3 aspect ratio. + */ + export type VideoQualitySmall = "small"; + + /** + * Player height is 360px, and player dimensions are 640px by 360px (for 16:9 aspect ratio) or 480px by 360px (for 4:3 aspect ratio). + */ + export type VideoQualityMedium = "medium"; + + /** + * Player height is 480px, and player dimensions are 853px by 480px (for 16:9 aspect ratio) or 640px by 480px (for 4:3 aspect ratio). + */ + export type VideoQualityLarge = "large"; + + /** + * Player height is 720px, and player dimensions are 1280px by 720px (for 16:9 aspect ratio) or 960px by 720px (for 4:3 aspect ratio). + */ + export type VideoQualityHD720 = "hd720"; + + /** + * Player height is 1080px, and player dimensions are 1920px by 1080px (for 16:9 aspect ratio) or 1440px by 1080px (for 4:3 aspect ratio). + */ + export type VideoQualityHD1080 = "hd1080"; + + /** + * Player height is greater than 1080px, which means that the player's aspect ratio is greater than 1920px by 1080px. + */ + export type VideoQualityHighRes = "highres"; + + /** + * Player parameters. + */ + export interface PlayerVars + { + /** + * Whether to autohide video controls (by default, HideProgressBar). + */ + autohide?: AutoHide; + + /** + * Whether to autoplay the video (by default, NoAutoPlay). + */ + autoplay?: AutoPlay; + + /** + * Whether to use user-preferred or forced caption loading (by default, UserDefault). + */ + cc_load_policy?: ClosedCaptionsLoadPolicy; + + /** + * Player progress bar color + */ + color?: ProgressBarColor; + + /** + * How video controls are shown (by default, ShowLoadPlayer). + */ + controls?: Controls; + + /** + * Whether to allow keyboard controls (by default, Enable). + */ + disablekb?: KeyboardControls; + + /** + * Whether the JavaScript API should be enabled (by default, Disable). + */ + enablejsapi?: JsApi; + + /** + * Time, in seconds from the beginning of the video, when to stop playing. + */ end?: number; - fs?: number; - iv_load_policy?: number; + + /** + * Whether to display the full-screen button (by default, Show). + */ + fs?: FullscreenButton; + + /** + * Player language as an ISO 639-1 two-letter language code or fully-specified locale. + */ + hl?: string; + + /** + * Whether to show video annotations (by default, Show). + */ + iv_load_policy?: IvLoadPolicy; + + /** + * Identifies content that will load. + * If listType is search, this is the search query. + * If listType is user_uploads, this is the YouTube user. + * If listType is playlist, this is the playlist ID, prepended by 'PL'. + */ list?: string; + + /** + * Which type of content loads in the player. + */ listType?: ListType; - loop?: number; - modestbranding?: number; + + /** + * Whether a single video should be looped (by default, SinglePlay). + */ + loop?: Loop; + + /** + * Whether to hide some YouTube branding (by default, Full). + */ + modestbranding?: ModestBranding; + + /** + * Origin domain for additional security if using the JavaScript API. + */ origin?: string; - playerpiid?: string; - playlist?: string[]; - playsinline?: number; - rel?: number; - showinfo?: number; + + /** + * Comma separated list of video IDs to play after the URL path's video. + */ + playlist?: string; + + /** + * Whether to show related videos after the video finishes (by default, Show). + */ + rel?: RelatedVideos; + + /** + * Whether to show video information before playing (by default, Show). + */ + showinfo?: ShowInfo; + + /** + * Time, in seconds from the beginning of the video, when to start playing. + */ start?: number; - theme?: string; - } + } - export interface PlayerOptions { - width?: string | number; - height?: string | number; - videoId?: string; - playerVars?: PlayerVars; - events?: Events; - } + /** + * Handlers for events fired by the player. + */ + export interface Events + { + /** + * Event fired when a player has finished loading and is ready to begin receiving API calls. + */ + onReady?: PlayerEventHandler; - interface VideoByIdParams { - videoId: string; - startSeconds?: number; - endSeconds?: number; - suggestedQuality?: string; - } + /** + * Event fired when the player's state changes. + */ + onStateChange?: PlayerEventHandler; - interface VideoByUrlParams { - mediaContentUrl: string; - startSeconds?: number; - endSeconds?: number; - suggestedQuality?: string; - } + /** + * Event fired when the playback quality of the player changes. + */ + onPlaybackQualityChange?: PlayerEventHandler; - export interface VideoData - { - video_id: string; - author: string; - title: string; - } + /** + * Event fired when the playback rate of the player changes. + */ + onPlaybackRateChange?: PlayerEventHandler; - export class Player { - // Constructor - constructor(id: string, playerOptions: PlayerOptions); - constructor(element: HTMLElement, playerOptions: PlayerOptions); + /** + * Event fired when an error in the player occurs + */ + onError?: PlayerEventHandler; - // Queueing functions - loadVideoById(videoId: string, startSeconds?: number, suggestedQuality?: string): void; - loadVideoById(VideoByIdParams: Object): void; - cueVideoById(videoId: string, startSeconds?: number, suggestedQuality?: string): void; - cueVideoById(VideoByIdParams: Object): void; + /** + * Event fired to indicate thath the player has loaded, or unloaded, a module + * with exposed API methods. This currently only occurs for closed captioning. + */ + onApiChange?: PlayerEventHandler; + } - loadVideoByUrl(mediaContentUrl: string, startSeconds?: number, suggestedQuality?: string): void; - loadVideoByUrl(VideoByUrlParams: Object): void; - cueVideoByUrl(mediaContentUrl: string, startSeconds?: number, suggestedQuality?: string): void; - cueVideoByUrl(VideoByUrlParams: Object): void; + /** + * Settings to load, play, or queue a video or playlist. + */ + export interface VideoOrPlaylistSettings { + /** + * Time, in seconds from the beginning of the (first) video, when to start playing. + */ + startSeconds?: number; - // Properties - size: any; + /** + * Time, in seconds from the end of the (first) video, when to end playing. + */ + endSeconds?: number; - // Playing - playVideo(): void; - pauseVideo(): void; - stopVideo(): void; - seekTo(seconds:number, allowSeekAhead:boolean): void; - clearVideo(): void; + /** + * Suggested video player quality. + */ + suggestedQuality?: SuggestedVideoQuality + } - // Playlist - nextVideo(): void; - previousVideo(): void; - playVideoAt(index: number): void; + /** + * Settings to play or queue a video by ID. + */ + export interface VideoByIdSettings extends VideoOrPlaylistSettings { + /** + * Video ID. + */ + videoId: string; + } - // Volume - mute(): void; - unMute(): void; - isMuted(): boolean; - setVolume(volume: number): void; - getVolume(): number; + /** + * Settings to play or queue a video by media content URL. + */ + export interface VideoByMediaContentUrlSettings extends VideoOrPlaylistSettings { + /** + * Fully qualified player URL. + */ + mediaContentUrl: string; + } - // Sizing - setSize(width: number, height: number): any; + /** + * Settings to load or queue a playlist. + */ + export interface IPlaylistSettings extends VideoOrPlaylistSettings { + /** + * Identifier for the listType videos list. + */ + list: string; - // Playback - getPlaybackRate(): number; - setPlaybackRate(suggestedRate:number): void; - getAvailablePlaybackRates(): number[]; + /** + * Which type of content loads in the player. + */ + listType?: ListType; - // Behavior - setLoop(loopPlaylists: boolean): void; - setShuffle(shufflePlaylist: boolean): void; + /** + * Start index of the playlist, if not 0. + */ + index?: number; + } - // Status - getVideoLoadedFraction(): number; - getPlayerState(): number; - getCurrentTime(): number; - getVideoStartBytes(): number; - getVideoBytesLoaded(): number; - getVideoBytesTotal(): number; + /** + * Creates and controls a YouTube player in an