From 0be3316701cd58db2c5c30f23837ea8f6e5dc675 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 10:40:23 +0200 Subject: [PATCH 01/15] Type Definiton for Frozen Mountain WebSync 3 --- types/fm-websync/fm-websync-tests.ts | 19 ++ types/fm-websync/index.d.ts | 484 +++++++++++++++++++++++++++ types/fm-websync/package.json | 11 + types/fm-websync/tsconfig.json | 19 ++ types/fm-websync/tslint.json | 1 + 5 files changed, 534 insertions(+) create mode 100644 types/fm-websync/fm-websync-tests.ts create mode 100644 types/fm-websync/index.d.ts create mode 100644 types/fm-websync/package.json create mode 100644 types/fm-websync/tsconfig.json create mode 100644 types/fm-websync/tslint.json diff --git a/types/fm-websync/fm-websync-tests.ts b/types/fm-websync/fm-websync-tests.ts new file mode 100644 index 0000000000..aeb665e5ae --- /dev/null +++ b/types/fm-websync/fm-websync-tests.ts @@ -0,0 +1,19 @@ +const client = fm.websync.client.initialize( { + requestUrl: "", + onSuccess: args => console.log( `Init success: {args.clientId}` ), + onFailure: args => console.log( `Init failure: {args.clientId}` ), + onComplete: args => console.log( `Init complete: {args.clientId}` ) +} ); + +client.subscribe( { + channel: "/my/channel", + onReceive: args => console.log( `Receive data: {args.data}` ), + onFailure: args => console.log( `Subscribe failure: {args.data}` ), + onComplete: args => console.log( `Subscribe complete` ) +} ); + +client.disconnect( { + onSuccess: args => console.log( `Disconnect success: {args.clientId}` ), + onFailure: args => console.log( `Disconnect failure: {args.clientId}` ), + onComplete: args => console.log( `Disconnect complete: {args.clientId}` ) +} ); \ No newline at end of file diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts new file mode 100644 index 0000000000..ae3677b986 --- /dev/null +++ b/types/fm-websync/index.d.ts @@ -0,0 +1,484 @@ +// Type definitions for fm-websync 3 +// Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) +// Definitions by: Markus Mauch +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare namespace fm +{ + export namespace websync + { + interface initializeConfig + { + /** + * If set to true, an asynchronous disconnect request will be launched when the page unloads. If set to false, no automatic disconnection will be attempted. If set to an object, then a disconnect request will be launched when the page unloads using the object as the disconnect configuration. (See disconnectConfig for details.) Note that automatic disconnects are a best-effort. The only way to guarantee success is to execute the disconnect synchronously and target a request URL on the same domain as the page ({ sync: true, requestUrl: '...relative path.../request.ashx' }). Defaults to false. + */ + autoDisconnect?: boolean; + + /** + * The amount of time in milliseconds to add to the delay between each reconnect attempt in the event of network failure. Defaults to 3000 (3 seconds). + */ + + backoffInterval?: number; + + /** + * The URL of the HTML frame to be used with HTML5 postMessage for cross-domain environments. Must have the same domain as requestUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server ClientHandler registered in web.config with "frame" added to the query. + */ + clientFrameUrl?: string; + + /** + * The domain key to send with each request. If using WebSync On-Demand, this should be set to the public or private API key specified in the Frozen Mountain Portal. If using WebSync Server, this should be used only if grouping connections. Defaults to "11111111-1111-1111-1111-111111111111". + */ + key?: string; + + /** + * The callback to invoke after onSuccess or onFailure. See initializeCompleteArgs for callback argument details. + */ + onComplete?: ( args: initializeCompleteArgs ) => void; + + /** + * The callback to invoke if the initialize fails. Defaults to an alert of the error. See initializeFailureArgs for callback argument details. + */ + onFailure?: ( args: initializeFailureArgs ) => void; + + /** + * The callback to invoke if the initialize succeeds. See initializeSuccessArgs for callback argument details. + */ + onSuccess?: ( args: initializeSuccessArgs ) => void; + + /** + * Whether or not to suppress the alerting of a failure if the client is already initialized. + */ + quiet?: boolean; + + /** + * The URL of the WebSync request handler. This URL typically ends with request.ashx. Must have the same domain as clientFrameUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server RequestHandler registered in web.config. + */ + requestUrl?: string; + + /** + * The number of times to retry a request in the event of network failure before considering it failed and invoking the corresponding OnFailure callback. Defaults to 3. + */ + retries?: number; + + /** + * The URLs to use for streaming connections. Three properties are available: + * + * requestUrl: string + * Same as the root requestUrl parameter, but used for streaming connections. Must have the same domain as stream.clientFrameUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the WebSync Server RequestHandler registered in web.config. + * clientFrameUrl: string + * Same as the root clientFrameUrl parameter, but used for streaming connections. Must have the same domain as stream.requestUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the WebSync Server ClientHandler registered in web.config with "frame" added to the query. + * timeout: number + * Same as the root timeout parameter, but used for streaming connections. Defaults to the root timeout + 25000 (25 seconds). + */ + stream? : any; + + /** + * The number of milliseconds to wait for a standard request to return a response before it is cancelled and a new attempt is made. Defaults to 15000 (15 seconds). + */ + timeout?: number; + + /** + * The token sent with every client request identifying it for query-based load balancing. Defaults to the current timestamp. + */ + + token?: string; + + /** + * An object specifying URLs to be used for specific client methods. Overrides initializeConfig.requestUrl for the specified method type, but can be overridden by the requestUrl specified in individual method configurations. + * + * connect: string + * The URL to use for all client.connect requests. + * + * bind: string + * The URL to use for all client.bind requests. + * + * unbind: string + * The URL to use for all client.unbind requests. + * + * subscribe: string + * The URL to use for all client.subscribe requests. + * + * unsubscribe: string + * The URL to use for all client.unsubscribe requests. + * + * publish: string + * The URL to use for all client.publish requests. + * + * disconnect: string + * The URL to use for all client.disconnect requests. + */ + urls?: any; + } + + interface baseArgs + {} + + interface baseRequestConfig + { + /** + * Extra meta data to associate with the request/response. + */ + meta?: any; + + /** + * The URL of the proxy to use for this request. + */ + requestUrl?: string; + + /** + * Whether to ignore errors when parsing the server response. If true, any errors thrown while parsing the JSON response received from the server will be ignored. Defaults to false. + */ + suppressErrors?: boolean; + + /** + * Whether the request should be executed asynchronously. If true, the request will be executed synchronously if supported by the browser; otherwise, it will be executed asynchronously. All browsers support synchronous requests if the request URL is the same domain as the page. Synchronous requests are not supported in IE6 and IE7 for cross-domain environments. Defaults to false. + */ + sync?: boolean; + } + + interface connectConfig extends baseRequestConfig + { + /** + * The callback to invoke after onSuccess or onFailure. See connectCompleteArgs for callback argument details. + */ + onComplete?: ( args: connectCompleteArgs ) => void; + + /** + * The callback to invoke if the connect fails. Defaults to an alert of the error. See connectFailureArgs for callback argument details. + */ + onFailure?: ( args: connectFailureArgs ) => void; + + /** + * The callback to invoke if the streaming connection fails. See streamFailureArgs for callback argument details. + * This method will be invoked if (a) the connection was lost, automatic retries succeeded, but the client had idled on the server (and so needs to reconnect), or (b) the connection was lost and automatic retries failed. In the former case, willReconnect is true, and in the latter case, willReconnect is false. + * See client for more details on these two scenarios. + * If willReconnect is true, the client will automatically reconnect. If the reconnect succeeds, the callback specified by onSuccess will be invoked with isReconnect set to true. If the reconnect fails, the callback specified by onFailure will be invoked with isReconnect set to false. + * With the exception of UI updates, invocations of this callback with willReconnect set to true can be ignored. + */ + onStreamFailure?: ( args: streamFailureArgs ) => void; + + /** + * The callback to invoke if the connect succeeds. See connectSuccessArgs for callback argument details. + */ + onSuccess?: ( args: connectSuccessArgs ) => void; + + /** + * The callback to invoke when a message is received on a channel that has no local callback specified to handle it. See receiveArgs for callback argument details. + * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client.unsetHandler. + */ + onUnhandledReceive?: Function; + + /** + * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number of retries specified by initializeConfig.retries. If false, the client will stop reconnecting if all retry attempts fail. + */ + stayConnected?: boolean; + } + + interface subscribeConfig extends baseRequestConfig + { + /** + * The channel to which the client should be subscribed. Must start with a forward slash (/). Overrides channels. + */ + channel?: String; + + /** + * The channels to which the client should be subscribed. Each must start with a forward slash (/). Overrides channel. + */ + channels?: String[]; + + /** + * The callback to invoke after onSuccess or onFailure. See subscribeCompleteArgs for callback argument details. + */ + onComplete?: ( args: subscribeCompleteArgs ) => void; + + /** + * (OptionalThe callback to invoke if the subscribe fails. See subscribeFailureArgs for callback argument details. + */ + onFailure?: ( args: subscribeFailureArgs ) => void; + + /** + * The callback to invoke when data is received on the channel(s). See receiveArgs for callback argument details. + */ + onReceive?: ( args: receiveArgs ) => void; + + /** + * Subscribers extension. The callback to invoke when a subscribers change notification is received (i.e. when a client subscribes to or unsubscribes from the channel(s)). + * The current subscribe request will trigger this callback. See subscribersChangeArgs for callback argument details. + */ + onSubscribersChange?: ( args: subscribersChangeArgs ) => void; + + /** + * The callback to invoke if the subscribe succeeds. See subscribeSuccessArgs for callback argument details. + */ + onSuccess?: ( args: subscribeSuccessArgs ) => void; + } + + interface baseCompleteArgs extends baseResponseArgs + { + } + + interface initializeCompleteArgs extends baseArgs + { + } + + interface initializeFailureArgs extends baseArgs + { + } + + interface initializeSuccessArgs extends baseArgs + { + } + + interface subscribeSuccessArgs extends baseSuccessArgs + { + /** + * The channel to which the client was subscribed. Must start with a forward slash (/). + */ + channel: string; + + /** + * The channels to which the client was subscribed. Each must start with a forward slash (/). + */ + channels: string[]; + + /** + * Whether the call to client.subscribe was triggered by a reconnection after network failure. + */ + isResubscribe: boolean; + + /** + * Subscribers extension. The active subscribed clients on the just-subscribed channel(s). + */ + subscribedClients: fm.websync.subscribedClient[]; + } + + interface subscribeCompleteArgs extends baseCompleteArgs + { + /** + * Whether the call to client.subscribe was triggered by a reconnection after network failure. + */ + isResubscribe: boolean; + } + + interface subscribeFailureArgs extends baseFailureArgs + { + /** + * Whether the call to client.subscribe was triggered by a reconnection after network failure. + */ + isResubscribe: boolean; + } + + interface baseFailureArgs extends baseResponseArgs + { + /** + * The error generated while completing the request. + */ + error: string; + } + + interface baseResponseArgs extends baseArgs + { + /** + * The singleton client. + */ + client: fm.websync.client; + + /** + * The ID of the singleton client. + */ + clientId: string; + + /** + * Extra meta data associated with the request/response. + */ + meta: any; + + /** + * The date/time the message was processed on the server. + */ + timestamp: Date; + } + + interface baseSuccessArgs extends baseResponseArgs + { + + } + + interface connectSuccessArgs extends baseResponseArgs + { + /** + * Whether the call to client.connect was triggered by a reconnection after network failure. + */ + isReconnect: boolean; + } + + interface connectFailureArgs extends baseResponseArgs + { + /** + * The error generated while completing the request. + */ + error: string; + + /** + * Whether the call to client.connect was triggered by a reconnection after network failure. + */ + isReconnect: boolean; + + /** + * Whether or not to reconnect automatically after this callback has finished execution. + */ + reconnect: boolean; + } + + interface streamFailureArgs extends baseResponseArgs + { + /** + * The error generated while completing the request. + */ + error: string; + + /** + * Whether the client will automatically reconnect after the callback returns. + */ + willReconnect: boolean; + } + + interface connectCompleteArgs extends baseResponseArgs + { + /** + * Whether the call to client.connect was triggered by a reconnection after network failure. + */ + isReconnect: boolean; + } + + interface receiveArgs extends baseResponseArgs + { + /** + * The channel over which the data was published. + */ + channel: string; + + /** + * The published data. + */ + data: any; + + /** + * Details about the client publishing the data. + */ + publishingClient: fm.websync.publishingClient; + } + + interface subscribersChangeArgs extends baseSuccessArgs + { + /** + * The details of the change that occurred. + */ + change?: fm.websync.subscribersChange + + /** + * The channel on which the change occurred. + */ + channel?: string; + } + + interface publishingClient + { + /** + * The publishing client's bound records. + */ + boundRecords: any; + + /** + * The publishing client's unique identifier. + */ + id: string; + } + + interface subscribersChange + { + /** + * The clients who subscribed to or unsubscribed from the channel. + */ + clients : fm.websync.subscribedClient[]; + + /** + * The type of the change, either "subscribe" or "unsubscribe". + */ + type: string; + } + + interface subscribedClient + { + /** + * The subscribed client's bound records. + */ + boundRecords: any; + + /** + * The subscribed client's unique identifier. + */ + id: string; + } + + interface disconnectConfig extends baseRequestConfig + { + /** + * The callback to invoke after onSuccess or onFailure. See disconnectCompleteArgs for callback argument details. + */ + onComplete: ( args: disconnectCompleteArgs ) => void; + + /** + * The callback to invoke if the disconnect fails. See disconnectFailureArgs for callback argument details. + */ + onFailure: ( args: disconnectFailureArgs ) => void; + + /** + * The callback to invoke if the disconnect succeeds. See disconnectSuccessArgs for callback argument details. + */ + onSuccess: ( args: disconnectSuccessArgs ) => void; + } + + interface disconnectCompleteArgs extends baseCompleteArgs + { + } + + interface disconnectFailureArgs extends baseFailureArgs + { + } + + interface disconnectSuccessArgs extends baseSuccessArgs + { + } + + export class client + { + /** + * Sets up and maintains a streaming connection to the server. + * While this method will typically run asychronously, the WebSync client is designed to be used without (much) consideration for its asynchronous nature. To that end, any calls to methods that require an active connection, like bind, subscribe and publish, will be queued automatically and executed once this method has completed successfully. + * + * @param connectConfig + */ + public connect( config: connectConfig ): client; + + /** + * + * @param config Takes down a streaming connection to the server and unsubscribes the client. + * After the disconnect completes successfully, any further calls to methods that require an active connection, like bind, subscribe and publish, will be queued automatically and executed only if/when the client reconnects. + */ + public disconnect( config: disconnectConfig ): client; + + /** + * Initializes the client according to the specified configuration. + * This method must always be called first. While is always executes synchronously, callbacks are allowed for the purposes of method chaining. + */ + public static initialize( config: initializeConfig ): client; + + /** + * Subscribes the client to receive messages on one or more channels. + * When the subscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the subscribed channel(s), including any modifications made on the server. + */ + public subscribe( config: subscribeConfig ): client; + } + } +} diff --git a/types/fm-websync/package.json b/types/fm-websync/package.json new file mode 100644 index 0000000000..6843239469 --- /dev/null +++ b/types/fm-websync/package.json @@ -0,0 +1,11 @@ +{ + "name": "fm-websync", + "version": "1.0.0", + "description": "Type definitions for Frozen Mountain WebSync 3", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "Markus Mauch", + "license": "ISC" +} diff --git a/types/fm-websync/tsconfig.json b/types/fm-websync/tsconfig.json new file mode 100644 index 0000000000..76193744be --- /dev/null +++ b/types/fm-websync/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "none", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "fm-websync-tests.ts" + ] +} diff --git a/types/fm-websync/tslint.json b/types/fm-websync/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/fm-websync/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } From 2cef5f24fff8f9e8a5204d71e118435ac34adcbb Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 11:08:30 +0200 Subject: [PATCH 02/15] remove package.json --- types/fm-websync/package.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 types/fm-websync/package.json diff --git a/types/fm-websync/package.json b/types/fm-websync/package.json deleted file mode 100644 index 6843239469..0000000000 --- a/types/fm-websync/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "fm-websync", - "version": "1.0.0", - "description": "Type definitions for Frozen Mountain WebSync 3", - "main": "index.js", - "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" - }, - "author": "Markus Mauch", - "license": "ISC" -} From 67156299739bf7094811cad6b97bca234cc96e7e Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 11:26:09 +0200 Subject: [PATCH 03/15] changed module system to commonjs --- types/fm-websync/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fm-websync/tsconfig.json b/types/fm-websync/tsconfig.json index 76193744be..7d22ec59f0 100644 --- a/types/fm-websync/tsconfig.json +++ b/types/fm-websync/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "none", + "module": "commonjs", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, From 79deb2bdefe2100fc3f3c7188ba6547ed79bbe5d Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 11:30:13 +0200 Subject: [PATCH 04/15] added es6, dom to lib --- types/fm-websync/tsconfig.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/fm-websync/tsconfig.json b/types/fm-websync/tsconfig.json index 7d22ec59f0..1ec64935da 100644 --- a/types/fm-websync/tsconfig.json +++ b/types/fm-websync/tsconfig.json @@ -8,6 +8,9 @@ "typeRoots": [ "../" ], + "lib": [ + "es6", "dom" + ], "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true From c2ab4891c4abef81fd6a3ae011f87a0c59462ec5 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 11:38:30 +0200 Subject: [PATCH 05/15] file ends with newline now --- types/fm-websync/fm-websync-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/fm-websync/fm-websync-tests.ts b/types/fm-websync/fm-websync-tests.ts index aeb665e5ae..6bdfd5de95 100644 --- a/types/fm-websync/fm-websync-tests.ts +++ b/types/fm-websync/fm-websync-tests.ts @@ -16,4 +16,4 @@ client.disconnect( { onSuccess: args => console.log( `Disconnect success: {args.clientId}` ), onFailure: args => console.log( `Disconnect failure: {args.clientId}` ), onComplete: args => console.log( `Disconnect complete: {args.clientId}` ) -} ); \ No newline at end of file +} ); From effd1ecd56b1753cc2f232aea5cf3ecda8a57d50 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 11:47:59 +0200 Subject: [PATCH 06/15] Changed replaced Function and String Comply with max line length --- types/fm-websync/index.d.ts | 61 +++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 19 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index ae3677b986..f118ebe051 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -10,7 +10,10 @@ declare namespace fm interface initializeConfig { /** - * If set to true, an asynchronous disconnect request will be launched when the page unloads. If set to false, no automatic disconnection will be attempted. If set to an object, then a disconnect request will be launched when the page unloads using the object as the disconnect configuration. (See disconnectConfig for details.) Note that automatic disconnects are a best-effort. The only way to guarantee success is to execute the disconnect synchronously and target a request URL on the same domain as the page ({ sync: true, requestUrl: '...relative path.../request.ashx' }). Defaults to false. + * If set to true, an asynchronous disconnect request will be launched when the page unloads. If set to false, no automatic disconnection will be attempted. + * If set to an object, then a disconnect request will be launched when the page unloads using the object as the disconnect configuration. + * (See disconnectConfig for details.) Note that automatic disconnects are a best-effort. The only way to guarantee success is to execute the disconnect synchronously + * and target a request URL on the same domain as the page ({ sync: true, requestUrl: '...relative path.../request.ashx' }). Defaults to false. */ autoDisconnect?: boolean; @@ -21,12 +24,15 @@ declare namespace fm backoffInterval?: number; /** - * The URL of the HTML frame to be used with HTML5 postMessage for cross-domain environments. Must have the same domain as requestUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server ClientHandler registered in web.config with "frame" added to the query. + * The URL of the HTML frame to be used with HTML5 postMessage for cross-domain environments. Must have the same domain as requestUrl. + * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server + * ClientHandler registered in web.config with "frame" added to the query. */ clientFrameUrl?: string; /** - * The domain key to send with each request. If using WebSync On-Demand, this should be set to the public or private API key specified in the Frozen Mountain Portal. If using WebSync Server, this should be used only if grouping connections. Defaults to "11111111-1111-1111-1111-111111111111". + * The domain key to send with each request. If using WebSync On-Demand, this should be set to the public or private API key specified in the Frozen Mountain Portal. + * If using WebSync Server, this should be used only if grouping connections. Defaults to "11111111-1111-1111-1111-111111111111". */ key?: string; @@ -51,7 +57,9 @@ declare namespace fm quiet?: boolean; /** - * The URL of the WebSync request handler. This URL typically ends with request.ashx. Must have the same domain as clientFrameUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server RequestHandler registered in web.config. + * The URL of the WebSync request handler. This URL typically ends with request.ashx. Must have the same domain as clientFrameUrl. + * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the + * WebSync Server RequestHandler registered in web.config. */ requestUrl?: string; @@ -64,9 +72,13 @@ declare namespace fm * The URLs to use for streaming connections. Three properties are available: * * requestUrl: string - * Same as the root requestUrl parameter, but used for streaming connections. Must have the same domain as stream.clientFrameUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the WebSync Server RequestHandler registered in web.config. + * Same as the root requestUrl parameter, but used for streaming connections. Must have the same domain as stream.clientFrameUrl. + * Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the + * WebSync Server RequestHandler registered in web.config. * clientFrameUrl: string - * Same as the root clientFrameUrl parameter, but used for streaming connections. Must have the same domain as stream.requestUrl. Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the WebSync Server ClientHandler registered in web.config with "frame" added to the query. + * Same as the root clientFrameUrl parameter, but used for streaming connections. Must have the same domain as stream.requestUrl. + * Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the + * WebSync Server ClientHandler registered in web.config with "frame" added to the query. * timeout: number * Same as the root timeout parameter, but used for streaming connections. Defaults to the root timeout + 25000 (25 seconds). */ @@ -84,7 +96,8 @@ declare namespace fm token?: string; /** - * An object specifying URLs to be used for specific client methods. Overrides initializeConfig.requestUrl for the specified method type, but can be overridden by the requestUrl specified in individual method configurations. + * An object specifying URLs to be used for specific client methods. Overrides initializeConfig.requestUrl for the specified method type, but can be overridden + * by the requestUrl specified in individual method configurations. * * connect: string * The URL to use for all client.connect requests. @@ -126,12 +139,15 @@ declare namespace fm requestUrl?: string; /** - * Whether to ignore errors when parsing the server response. If true, any errors thrown while parsing the JSON response received from the server will be ignored. Defaults to false. + * Whether to ignore errors when parsing the server response. If true, any errors thrown while parsing the JSON response received from the server will be ignored. + * Defaults to false. */ suppressErrors?: boolean; /** - * Whether the request should be executed asynchronously. If true, the request will be executed synchronously if supported by the browser; otherwise, it will be executed asynchronously. All browsers support synchronous requests if the request URL is the same domain as the page. Synchronous requests are not supported in IE6 and IE7 for cross-domain environments. Defaults to false. + * Whether the request should be executed asynchronously. If true, the request will be executed synchronously if supported by the browser; otherwise, + * it will be executed asynchronously. All browsers support synchronous requests if the request URL is the same domain as the page. Synchronous requests + * are not supported in IE6 and IE7 for cross-domain environments. Defaults to false. */ sync?: boolean; } @@ -150,9 +166,11 @@ declare namespace fm /** * The callback to invoke if the streaming connection fails. See streamFailureArgs for callback argument details. - * This method will be invoked if (a) the connection was lost, automatic retries succeeded, but the client had idled on the server (and so needs to reconnect), or (b) the connection was lost and automatic retries failed. In the former case, willReconnect is true, and in the latter case, willReconnect is false. + * This method will be invoked if (a) the connection was lost, automatic retries succeeded, but the client had idled on the server (and so needs to reconnect), + * or (b) the connection was lost and automatic retries failed. In the former case, willReconnect is true, and in the latter case, willReconnect is false. * See client for more details on these two scenarios. - * If willReconnect is true, the client will automatically reconnect. If the reconnect succeeds, the callback specified by onSuccess will be invoked with isReconnect set to true. If the reconnect fails, the callback specified by onFailure will be invoked with isReconnect set to false. + * If willReconnect is true, the client will automatically reconnect. If the reconnect succeeds, the callback specified by onSuccess will be invoked with isReconnect set to true. + * If the reconnect fails, the callback specified by onFailure will be invoked with isReconnect set to false. * With the exception of UI updates, invocations of this callback with willReconnect set to true can be ignored. */ onStreamFailure?: ( args: streamFailureArgs ) => void; @@ -164,12 +182,13 @@ declare namespace fm /** * The callback to invoke when a message is received on a channel that has no local callback specified to handle it. See receiveArgs for callback argument details. - * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client.unsetHandler. + * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client. */ - onUnhandledReceive?: Function; + onUnhandledReceive?: ( args: receiveArgs ) => void; /** - * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number of retries specified by initializeConfig.retries. If false, the client will stop reconnecting if all retry attempts fail. + * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number + * of retries specified by initializeConfig.retries. If false, the client will stop reconnecting if all retry attempts fail. */ stayConnected?: boolean; } @@ -179,12 +198,12 @@ declare namespace fm /** * The channel to which the client should be subscribed. Must start with a forward slash (/). Overrides channels. */ - channel?: String; + channel?: string; /** * The channels to which the client should be subscribed. Each must start with a forward slash (/). Overrides channel. */ - channels?: String[]; + channels?: string[]; /** * The callback to invoke after onSuccess or onFailure. See subscribeCompleteArgs for callback argument details. @@ -455,7 +474,9 @@ declare namespace fm { /** * Sets up and maintains a streaming connection to the server. - * While this method will typically run asychronously, the WebSync client is designed to be used without (much) consideration for its asynchronous nature. To that end, any calls to methods that require an active connection, like bind, subscribe and publish, will be queued automatically and executed once this method has completed successfully. + * While this method will typically run asychronously, the WebSync client is designed to be used without (much) consideration for its asynchronous nature. + * To that end, any calls to methods that require an active connection, like bind, subscribe and publish, will be queued automatically and executed once this + * method has completed successfully. * * @param connectConfig */ @@ -464,7 +485,8 @@ declare namespace fm /** * * @param config Takes down a streaming connection to the server and unsubscribes the client. - * After the disconnect completes successfully, any further calls to methods that require an active connection, like bind, subscribe and publish, will be queued automatically and executed only if/when the client reconnects. + * After the disconnect completes successfully, any further calls to methods that require an active connection, like bind, subscribe and publish, will be queued + * automatically and executed only if/when the client reconnects. */ public disconnect( config: disconnectConfig ): client; @@ -476,7 +498,8 @@ declare namespace fm /** * Subscribes the client to receive messages on one or more channels. - * When the subscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the subscribed channel(s), including any modifications made on the server. + * When the subscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the subscribed channel(s), + * including any modifications made on the server. */ public subscribe( config: subscribeConfig ): client; } From 94ef450a22604098cea52b7e1b8089b136e080ef Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 11:58:23 +0200 Subject: [PATCH 07/15] removed iplicit public --- types/fm-websync/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index f118ebe051..887d63039f 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -480,7 +480,7 @@ declare namespace fm * * @param connectConfig */ - public connect( config: connectConfig ): client; + connect( config: connectConfig ): client; /** * @@ -488,20 +488,20 @@ declare namespace fm * After the disconnect completes successfully, any further calls to methods that require an active connection, like bind, subscribe and publish, will be queued * automatically and executed only if/when the client reconnects. */ - public disconnect( config: disconnectConfig ): client; + disconnect( config: disconnectConfig ): client; /** * Initializes the client according to the specified configuration. * This method must always be called first. While is always executes synchronously, callbacks are allowed for the purposes of method chaining. */ - public static initialize( config: initializeConfig ): client; + static initialize( config: initializeConfig ): client; /** * Subscribes the client to receive messages on one or more channels. * When the subscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the subscribed channel(s), * including any modifications made on the server. */ - public subscribe( config: subscribeConfig ): client; + subscribe( config: subscribeConfig ): client; } } } From c8852512f9e677e2ba1763d728176dbcc8a53926 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 13:48:46 +0200 Subject: [PATCH 08/15] removed empty interfaces --- types/fm-websync/index.d.ts | 90 ++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 32 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index 887d63039f..90cf5268e6 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -39,7 +39,7 @@ declare namespace fm /** * The callback to invoke after onSuccess or onFailure. See initializeCompleteArgs for callback argument details. */ - onComplete?: ( args: initializeCompleteArgs ) => void; + onComplete?: ( args: baseArgs ) => void; /** * The callback to invoke if the initialize fails. Defaults to an alert of the error. See initializeFailureArgs for callback argument details. @@ -49,7 +49,7 @@ declare namespace fm /** * The callback to invoke if the initialize succeeds. See initializeSuccessArgs for callback argument details. */ - onSuccess?: ( args: initializeSuccessArgs ) => void; + onSuccess?: ( args: baseArgs ) => void; /** * Whether or not to suppress the alerting of a failure if the client is already initialized. @@ -124,7 +124,9 @@ declare namespace fm } interface baseArgs - {} + { + [key: string]: any; + } interface baseRequestConfig { @@ -231,24 +233,16 @@ declare namespace fm */ onSuccess?: ( args: subscribeSuccessArgs ) => void; } - - interface baseCompleteArgs extends baseResponseArgs - { - } - - interface initializeCompleteArgs extends baseArgs - { - } interface initializeFailureArgs extends baseArgs { - } - - interface initializeSuccessArgs extends baseArgs - { + /** + * The error generated while initializing. + */ + error: string; } - interface subscribeSuccessArgs extends baseSuccessArgs + interface subscribeSuccessArgs extends baseResponseArgs { /** * The channel to which the client was subscribed. Must start with a forward slash (/). @@ -271,7 +265,7 @@ declare namespace fm subscribedClients: fm.websync.subscribedClient[]; } - interface subscribeCompleteArgs extends baseCompleteArgs + interface subscribeCompleteArgs extends baseResponseArgs { /** * Whether the call to client.subscribe was triggered by a reconnection after network failure. @@ -318,11 +312,6 @@ declare namespace fm timestamp: Date; } - interface baseSuccessArgs extends baseResponseArgs - { - - } - interface connectSuccessArgs extends baseResponseArgs { /** @@ -388,7 +377,7 @@ declare namespace fm publishingClient: fm.websync.publishingClient; } - interface subscribersChangeArgs extends baseSuccessArgs + interface subscribersChangeArgs extends baseResponseArgs { /** * The details of the change that occurred. @@ -445,29 +434,58 @@ declare namespace fm /** * The callback to invoke after onSuccess or onFailure. See disconnectCompleteArgs for callback argument details. */ - onComplete: ( args: disconnectCompleteArgs ) => void; + onComplete?: ( args: baseResponseArgs ) => void; /** * The callback to invoke if the disconnect fails. See disconnectFailureArgs for callback argument details. */ - onFailure: ( args: disconnectFailureArgs ) => void; + onFailure?: ( args: baseFailureArgs ) => void; /** * The callback to invoke if the disconnect succeeds. See disconnectSuccessArgs for callback argument details. */ - onSuccess: ( args: disconnectSuccessArgs ) => void; + onSuccess?: ( args: baseResponseArgs ) => void; } - interface disconnectCompleteArgs extends baseCompleteArgs + interface unsubscribeSuccessArgs extends baseResponseArgs { + /** + * The channel from which the client was unsubscribed. Must start with a forward slash (/). + */ + channel: string; + + /** + * The channels from which the client was unsubscribed. Each must start with a forward slash (/). + */ + channels: string[]; } - interface disconnectFailureArgs extends baseFailureArgs - { - } - - interface disconnectSuccessArgs extends baseSuccessArgs + interface unsubscribeConfig extends baseRequestConfig { + /** + * The channel from which the client should be unsubscribed. Must start with a forward slash (/). Overrides channels. + */ + channel: string; + + /** + * The channels from which the client should be unsubscribed. Each must start with a forward slash (/). Overrides channel. + */ + channels: String[]; + + /** + * The callback to invoke after onSuccess or onFailure. See unsubscribeCompleteArgs for callback argument details. + */ + onComplete: ( args: baseResponseArgs ) => void; + + /** + * The callback to invoke if the unsubscribe fails. See unsubscribeFailureArgs for callback argument details. + */ + onFailure: ( args: baseFailureArgs ) => void; + + /** + * The callback to invoke if the unsubscribe succeeds. See unsubscribeSuccessArgs for callback argument details. + */ + onSuccess: ( args: unsubscribeSuccessArgs ) => void; } export class client @@ -502,6 +520,14 @@ declare namespace fm * including any modifications made on the server. */ subscribe( config: subscribeConfig ): client; + + /** + * Unsubscribes the client from receiving messages on one or more channels. + * When the unsubscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the unsubscribed channel(s), + * including any modifications made on the server. + * @param config + */ + unsubscribe( config: unsubscribeConfig ): client; } } } From 780b002919ba79572c308f063378d498c2b02c60 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 14:26:21 +0200 Subject: [PATCH 09/15] trimmed trailing whitespaces --- types/fm-websync/index.d.ts | 132 ++++++++++++++++++------------------ 1 file changed, 66 insertions(+), 66 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index 90cf5268e6..686554d62e 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -19,58 +19,58 @@ declare namespace fm /** * The amount of time in milliseconds to add to the delay between each reconnect attempt in the event of network failure. Defaults to 3000 (3 seconds). - */ - + */ + backoffInterval?: number; - + /** * The URL of the HTML frame to be used with HTML5 postMessage for cross-domain environments. Must have the same domain as requestUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server * ClientHandler registered in web.config with "frame" added to the query. */ clientFrameUrl?: string; - + /** * The domain key to send with each request. If using WebSync On-Demand, this should be set to the public or private API key specified in the Frozen Mountain Portal. * If using WebSync Server, this should be used only if grouping connections. Defaults to "11111111-1111-1111-1111-111111111111". - */ + */ key?: string; - + /** * The callback to invoke after onSuccess or onFailure. See initializeCompleteArgs for callback argument details. */ onComplete?: ( args: baseArgs ) => void; - + /** * The callback to invoke if the initialize fails. Defaults to an alert of the error. See initializeFailureArgs for callback argument details. - */ + */ onFailure?: ( args: initializeFailureArgs ) => void; - + /** * The callback to invoke if the initialize succeeds. See initializeSuccessArgs for callback argument details. */ onSuccess?: ( args: baseArgs ) => void; - + /** * Whether or not to suppress the alerting of a failure if the client is already initialized. */ quiet?: boolean; - + /** * The URL of the WebSync request handler. This URL typically ends with request.ashx. Must have the same domain as clientFrameUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the * WebSync Server RequestHandler registered in web.config. */ requestUrl?: string; - + /** * The number of times to retry a request in the event of network failure before considering it failed and invoking the corresponding OnFailure callback. Defaults to 3. */ retries?: number; - + /** * The URLs to use for streaming connections. Three properties are available: - * + * * requestUrl: string * Same as the root requestUrl parameter, but used for streaming connections. Must have the same domain as stream.clientFrameUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the streamHost web.config attribute, if specified) and the path to the @@ -83,25 +83,25 @@ declare namespace fm * Same as the root timeout parameter, but used for streaming connections. Defaults to the root timeout + 25000 (25 seconds). */ stream? : any; - + /** * The number of milliseconds to wait for a standard request to return a response before it is cancelled and a new attempt is made. Defaults to 15000 (15 seconds). */ timeout?: number; - + /** * The token sent with every client request identifying it for query-based load balancing. Defaults to the current timestamp. */ - + token?: string; - + /** * An object specifying URLs to be used for specific client methods. Overrides initializeConfig.requestUrl for the specified method type, but can be overridden * by the requestUrl specified in individual method configurations. - * + * * connect: string * The URL to use for all client.connect requests. - * + * * bind: string * The URL to use for all client.bind requests. * @@ -122,7 +122,7 @@ declare namespace fm */ urls?: any; } - + interface baseArgs { [key: string]: any; @@ -134,18 +134,18 @@ declare namespace fm * Extra meta data to associate with the request/response. */ meta?: any; - + /** * The URL of the proxy to use for this request. */ requestUrl?: string; - + /** * Whether to ignore errors when parsing the server response. If true, any errors thrown while parsing the JSON response received from the server will be ignored. * Defaults to false. */ suppressErrors?: boolean; - + /** * Whether the request should be executed asynchronously. If true, the request will be executed synchronously if supported by the browser; otherwise, * it will be executed asynchronously. All browsers support synchronous requests if the request URL is the same domain as the page. Synchronous requests @@ -163,9 +163,9 @@ declare namespace fm /** * The callback to invoke if the connect fails. Defaults to an alert of the error. See connectFailureArgs for callback argument details. - */ + */ onFailure?: ( args: connectFailureArgs ) => void; - + /** * The callback to invoke if the streaming connection fails. See streamFailureArgs for callback argument details. * This method will be invoked if (a) the connection was lost, automatic retries succeeded, but the client had idled on the server (and so needs to reconnect), @@ -176,22 +176,22 @@ declare namespace fm * With the exception of UI updates, invocations of this callback with willReconnect set to true can be ignored. */ onStreamFailure?: ( args: streamFailureArgs ) => void; - + /** * The callback to invoke if the connect succeeds. See connectSuccessArgs for callback argument details. */ onSuccess?: ( args: connectSuccessArgs ) => void; - + /** * The callback to invoke when a message is received on a channel that has no local callback specified to handle it. See receiveArgs for callback argument details. * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client. */ onUnhandledReceive?: ( args: receiveArgs ) => void; - + /** * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number * of retries specified by initializeConfig.retries. If false, the client will stop reconnecting if all retry attempts fail. - */ + */ stayConnected?: boolean; } @@ -201,39 +201,39 @@ declare namespace fm * The channel to which the client should be subscribed. Must start with a forward slash (/). Overrides channels. */ channel?: string; - + /** * The channels to which the client should be subscribed. Each must start with a forward slash (/). Overrides channel. */ channels?: string[]; - + /** * The callback to invoke after onSuccess or onFailure. See subscribeCompleteArgs for callback argument details. */ onComplete?: ( args: subscribeCompleteArgs ) => void; - + /** * (OptionalThe callback to invoke if the subscribe fails. See subscribeFailureArgs for callback argument details. */ onFailure?: ( args: subscribeFailureArgs ) => void; - + /** * The callback to invoke when data is received on the channel(s). See receiveArgs for callback argument details. */ onReceive?: ( args: receiveArgs ) => void; - + /** * Subscribers extension. The callback to invoke when a subscribers change notification is received (i.e. when a client subscribes to or unsubscribes from the channel(s)). * The current subscribe request will trigger this callback. See subscribersChangeArgs for callback argument details. */ onSubscribersChange?: ( args: subscribersChangeArgs ) => void; - + /** * The callback to invoke if the subscribe succeeds. See subscribeSuccessArgs for callback argument details. */ onSuccess?: ( args: subscribeSuccessArgs ) => void; } - + interface initializeFailureArgs extends baseArgs { /** @@ -246,19 +246,19 @@ declare namespace fm { /** * The channel to which the client was subscribed. Must start with a forward slash (/). - */ + */ channel: string; - + /** * The channels to which the client was subscribed. Each must start with a forward slash (/). */ channels: string[]; - + /** * Whether the call to client.subscribe was triggered by a reconnection after network failure. */ isResubscribe: boolean; - + /** * Subscribers extension. The active subscribed clients on the just-subscribed channel(s). */ @@ -295,17 +295,17 @@ declare namespace fm * The singleton client. */ client: fm.websync.client; - + /** * The ID of the singleton client. */ clientId: string; - + /** * Extra meta data associated with the request/response. */ meta: any; - + /** * The date/time the message was processed on the server. */ @@ -331,7 +331,7 @@ declare namespace fm * Whether the call to client.connect was triggered by a reconnection after network failure. */ isReconnect: boolean; - + /** * Whether or not to reconnect automatically after this callback has finished execution. */ @@ -365,12 +365,12 @@ declare namespace fm * The channel over which the data was published. */ channel: string; - + /** * The published data. */ data: any; - + /** * Details about the client publishing the data. */ @@ -383,7 +383,7 @@ declare namespace fm * The details of the change that occurred. */ change?: fm.websync.subscribersChange - + /** * The channel on which the change occurred. */ @@ -396,7 +396,7 @@ declare namespace fm * The publishing client's bound records. */ boundRecords: any; - + /** * The publishing client's unique identifier. */ @@ -422,7 +422,7 @@ declare namespace fm * The subscribed client's bound records. */ boundRecords: any; - + /** * The subscribed client's unique identifier. */ @@ -435,12 +435,12 @@ declare namespace fm * The callback to invoke after onSuccess or onFailure. See disconnectCompleteArgs for callback argument details. */ onComplete?: ( args: baseResponseArgs ) => void; - + /** * The callback to invoke if the disconnect fails. See disconnectFailureArgs for callback argument details. */ onFailure?: ( args: baseFailureArgs ) => void; - + /** * The callback to invoke if the disconnect succeeds. See disconnectSuccessArgs for callback argument details. */ @@ -453,7 +453,7 @@ declare namespace fm * The channel from which the client was unsubscribed. Must start with a forward slash (/). */ channel: string; - + /** * The channels from which the client was unsubscribed. Each must start with a forward slash (/). */ @@ -465,27 +465,27 @@ declare namespace fm /** * The channel from which the client should be unsubscribed. Must start with a forward slash (/). Overrides channels. */ - channel: string; - + channel?: string; + /** * The channels from which the client should be unsubscribed. Each must start with a forward slash (/). Overrides channel. */ - channels: String[]; - + channels?: string[]; + /** * The callback to invoke after onSuccess or onFailure. See unsubscribeCompleteArgs for callback argument details. */ - onComplete: ( args: baseResponseArgs ) => void; - + onComplete?: ( args: baseResponseArgs ) => void; + /** * The callback to invoke if the unsubscribe fails. See unsubscribeFailureArgs for callback argument details. */ - onFailure: ( args: baseFailureArgs ) => void; - + onFailure?: ( args: baseFailureArgs ) => void; + /** * The callback to invoke if the unsubscribe succeeds. See unsubscribeSuccessArgs for callback argument details. */ - onSuccess: ( args: unsubscribeSuccessArgs ) => void; + onSuccess?: ( args: unsubscribeSuccessArgs ) => void; } export class client @@ -495,13 +495,13 @@ declare namespace fm * While this method will typically run asychronously, the WebSync client is designed to be used without (much) consideration for its asynchronous nature. * To that end, any calls to methods that require an active connection, like bind, subscribe and publish, will be queued automatically and executed once this * method has completed successfully. - * - * @param connectConfig + * + * @param connectConfig */ connect( config: connectConfig ): client; /** - * + * * @param config Takes down a streaming connection to the server and unsubscribes the client. * After the disconnect completes successfully, any further calls to methods that require an active connection, like bind, subscribe and publish, will be queued * automatically and executed only if/when the client reconnects. @@ -525,7 +525,7 @@ declare namespace fm * Unsubscribes the client from receiving messages on one or more channels. * When the unsubscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the unsubscribed channel(s), * including any modifications made on the server. - * @param config + * @param config */ unsubscribe( config: unsubscribeConfig ): client; } From 16f0645371f3fa47886c33e89089ba98b164bd9d Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 14:27:11 +0200 Subject: [PATCH 10/15] beautifier --- types/fm-websync/index.d.ts | 172 +++++++++++++++--------------------- 1 file changed, 73 insertions(+), 99 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index 686554d62e..c69dea19c4 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -3,70 +3,67 @@ // Definitions by: Markus Mauch // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -declare namespace fm -{ - export namespace websync - { - interface initializeConfig - { +declare namespace fm { + export namespace websync { + interface initializeConfig { /** * If set to true, an asynchronous disconnect request will be launched when the page unloads. If set to false, no automatic disconnection will be attempted. * If set to an object, then a disconnect request will be launched when the page unloads using the object as the disconnect configuration. * (See disconnectConfig for details.) Note that automatic disconnects are a best-effort. The only way to guarantee success is to execute the disconnect synchronously * and target a request URL on the same domain as the page ({ sync: true, requestUrl: '...relative path.../request.ashx' }). Defaults to false. */ - autoDisconnect?: boolean; + autoDisconnect ? : boolean; /** * The amount of time in milliseconds to add to the delay between each reconnect attempt in the event of network failure. Defaults to 3000 (3 seconds). */ - backoffInterval?: number; + backoffInterval ? : number; /** * The URL of the HTML frame to be used with HTML5 postMessage for cross-domain environments. Must have the same domain as requestUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server * ClientHandler registered in web.config with "frame" added to the query. */ - clientFrameUrl?: string; + clientFrameUrl ? : string; /** * The domain key to send with each request. If using WebSync On-Demand, this should be set to the public or private API key specified in the Frozen Mountain Portal. * If using WebSync Server, this should be used only if grouping connections. Defaults to "11111111-1111-1111-1111-111111111111". */ - key?: string; + key ? : string; /** * The callback to invoke after onSuccess or onFailure. See initializeCompleteArgs for callback argument details. */ - onComplete?: ( args: baseArgs ) => void; + onComplete ? : (args: baseArgs) => void; /** * The callback to invoke if the initialize fails. Defaults to an alert of the error. See initializeFailureArgs for callback argument details. */ - onFailure?: ( args: initializeFailureArgs ) => void; + onFailure ? : (args: initializeFailureArgs) => void; /** * The callback to invoke if the initialize succeeds. See initializeSuccessArgs for callback argument details. */ - onSuccess?: ( args: baseArgs ) => void; + onSuccess ? : (args: baseArgs) => void; /** * Whether or not to suppress the alerting of a failure if the client is already initialized. */ - quiet?: boolean; + quiet ? : boolean; /** * The URL of the WebSync request handler. This URL typically ends with request.ashx. Must have the same domain as clientFrameUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the * WebSync Server RequestHandler registered in web.config. */ - requestUrl?: string; + requestUrl ? : string; /** * The number of times to retry a request in the event of network failure before considering it failed and invoking the corresponding OnFailure callback. Defaults to 3. */ - retries?: number; + retries ? : number; /** * The URLs to use for streaming connections. Three properties are available: @@ -82,18 +79,18 @@ declare namespace fm * timeout: number * Same as the root timeout parameter, but used for streaming connections. Defaults to the root timeout + 25000 (25 seconds). */ - stream? : any; + stream ? : any; /** * The number of milliseconds to wait for a standard request to return a response before it is cancelled and a new attempt is made. Defaults to 15000 (15 seconds). */ - timeout?: number; + timeout ? : number; /** * The token sent with every client request identifying it for query-based load balancing. Defaults to the current timestamp. */ - token?: string; + token ? : string; /** * An object specifying URLs to be used for specific client methods. Overrides initializeConfig.requestUrl for the specified method type, but can be overridden @@ -120,51 +117,48 @@ declare namespace fm * disconnect: string * The URL to use for all client.disconnect requests. */ - urls?: any; + urls ? : any; } - interface baseArgs - { + interface baseArgs { [key: string]: any; } - interface baseRequestConfig - { + interface baseRequestConfig { /** * Extra meta data to associate with the request/response. */ - meta?: any; + meta ? : any; /** * The URL of the proxy to use for this request. */ - requestUrl?: string; + requestUrl ? : string; /** * Whether to ignore errors when parsing the server response. If true, any errors thrown while parsing the JSON response received from the server will be ignored. * Defaults to false. */ - suppressErrors?: boolean; + suppressErrors ? : boolean; /** * Whether the request should be executed asynchronously. If true, the request will be executed synchronously if supported by the browser; otherwise, * it will be executed asynchronously. All browsers support synchronous requests if the request URL is the same domain as the page. Synchronous requests * are not supported in IE6 and IE7 for cross-domain environments. Defaults to false. */ - sync?: boolean; + sync ? : boolean; } - interface connectConfig extends baseRequestConfig - { + interface connectConfig extends baseRequestConfig { /** * The callback to invoke after onSuccess or onFailure. See connectCompleteArgs for callback argument details. */ - onComplete?: ( args: connectCompleteArgs ) => void; + onComplete ? : (args: connectCompleteArgs) => void; /** * The callback to invoke if the connect fails. Defaults to an alert of the error. See connectFailureArgs for callback argument details. */ - onFailure?: ( args: connectFailureArgs ) => void; + onFailure ? : (args: connectFailureArgs) => void; /** * The callback to invoke if the streaming connection fails. See streamFailureArgs for callback argument details. @@ -175,75 +169,72 @@ declare namespace fm * If the reconnect fails, the callback specified by onFailure will be invoked with isReconnect set to false. * With the exception of UI updates, invocations of this callback with willReconnect set to true can be ignored. */ - onStreamFailure?: ( args: streamFailureArgs ) => void; + onStreamFailure ? : (args: streamFailureArgs) => void; /** * The callback to invoke if the connect succeeds. See connectSuccessArgs for callback argument details. */ - onSuccess?: ( args: connectSuccessArgs ) => void; + onSuccess ? : (args: connectSuccessArgs) => void; /** * The callback to invoke when a message is received on a channel that has no local callback specified to handle it. See receiveArgs for callback argument details. * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client. */ - onUnhandledReceive?: ( args: receiveArgs ) => void; + onUnhandledReceive ? : (args: receiveArgs) => void; /** * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number * of retries specified by initializeConfig.retries. If false, the client will stop reconnecting if all retry attempts fail. */ - stayConnected?: boolean; + stayConnected ? : boolean; } - interface subscribeConfig extends baseRequestConfig - { + interface subscribeConfig extends baseRequestConfig { /** * The channel to which the client should be subscribed. Must start with a forward slash (/). Overrides channels. */ - channel?: string; + channel ? : string; /** * The channels to which the client should be subscribed. Each must start with a forward slash (/). Overrides channel. */ - channels?: string[]; + channels ? : string[]; /** * The callback to invoke after onSuccess or onFailure. See subscribeCompleteArgs for callback argument details. */ - onComplete?: ( args: subscribeCompleteArgs ) => void; + onComplete ? : (args: subscribeCompleteArgs) => void; /** * (OptionalThe callback to invoke if the subscribe fails. See subscribeFailureArgs for callback argument details. */ - onFailure?: ( args: subscribeFailureArgs ) => void; + onFailure ? : (args: subscribeFailureArgs) => void; /** * The callback to invoke when data is received on the channel(s). See receiveArgs for callback argument details. */ - onReceive?: ( args: receiveArgs ) => void; + onReceive ? : (args: receiveArgs) => void; /** * Subscribers extension. The callback to invoke when a subscribers change notification is received (i.e. when a client subscribes to or unsubscribes from the channel(s)). * The current subscribe request will trigger this callback. See subscribersChangeArgs for callback argument details. */ - onSubscribersChange?: ( args: subscribersChangeArgs ) => void; + onSubscribersChange ? : (args: subscribersChangeArgs) => void; /** * The callback to invoke if the subscribe succeeds. See subscribeSuccessArgs for callback argument details. */ - onSuccess?: ( args: subscribeSuccessArgs ) => void; + onSuccess ? : (args: subscribeSuccessArgs) => void; } - interface initializeFailureArgs extends baseArgs - { + interface initializeFailureArgs extends baseArgs { /** * The error generated while initializing. */ error: string; } - interface subscribeSuccessArgs extends baseResponseArgs - { + interface subscribeSuccessArgs extends baseResponseArgs { /** * The channel to which the client was subscribed. Must start with a forward slash (/). */ @@ -265,32 +256,28 @@ declare namespace fm subscribedClients: fm.websync.subscribedClient[]; } - interface subscribeCompleteArgs extends baseResponseArgs - { + interface subscribeCompleteArgs extends baseResponseArgs { /** * Whether the call to client.subscribe was triggered by a reconnection after network failure. */ isResubscribe: boolean; } - interface subscribeFailureArgs extends baseFailureArgs - { + interface subscribeFailureArgs extends baseFailureArgs { /** * Whether the call to client.subscribe was triggered by a reconnection after network failure. */ isResubscribe: boolean; } - interface baseFailureArgs extends baseResponseArgs - { + interface baseFailureArgs extends baseResponseArgs { /** * The error generated while completing the request. */ error: string; } - interface baseResponseArgs extends baseArgs - { + interface baseResponseArgs extends baseArgs { /** * The singleton client. */ @@ -312,16 +299,14 @@ declare namespace fm timestamp: Date; } - interface connectSuccessArgs extends baseResponseArgs - { + interface connectSuccessArgs extends baseResponseArgs { /** * Whether the call to client.connect was triggered by a reconnection after network failure. */ isReconnect: boolean; } - interface connectFailureArgs extends baseResponseArgs - { + interface connectFailureArgs extends baseResponseArgs { /** * The error generated while completing the request. */ @@ -338,8 +323,7 @@ declare namespace fm reconnect: boolean; } - interface streamFailureArgs extends baseResponseArgs - { + interface streamFailureArgs extends baseResponseArgs { /** * The error generated while completing the request. */ @@ -351,16 +335,14 @@ declare namespace fm willReconnect: boolean; } - interface connectCompleteArgs extends baseResponseArgs - { + interface connectCompleteArgs extends baseResponseArgs { /** * Whether the call to client.connect was triggered by a reconnection after network failure. */ isReconnect: boolean; } - interface receiveArgs extends baseResponseArgs - { + interface receiveArgs extends baseResponseArgs { /** * The channel over which the data was published. */ @@ -377,21 +359,19 @@ declare namespace fm publishingClient: fm.websync.publishingClient; } - interface subscribersChangeArgs extends baseResponseArgs - { + interface subscribersChangeArgs extends baseResponseArgs { /** * The details of the change that occurred. */ - change?: fm.websync.subscribersChange + change ? : fm.websync.subscribersChange /** * The channel on which the change occurred. */ - channel?: string; + channel ? : string; } - interface publishingClient - { + interface publishingClient { /** * The publishing client's bound records. */ @@ -403,12 +383,11 @@ declare namespace fm id: string; } - interface subscribersChange - { + interface subscribersChange { /** * The clients who subscribed to or unsubscribed from the channel. */ - clients : fm.websync.subscribedClient[]; + clients: fm.websync.subscribedClient[]; /** * The type of the change, either "subscribe" or "unsubscribe". @@ -416,8 +395,7 @@ declare namespace fm type: string; } - interface subscribedClient - { + interface subscribedClient { /** * The subscribed client's bound records. */ @@ -429,26 +407,24 @@ declare namespace fm id: string; } - interface disconnectConfig extends baseRequestConfig - { + interface disconnectConfig extends baseRequestConfig { /** * The callback to invoke after onSuccess or onFailure. See disconnectCompleteArgs for callback argument details. */ - onComplete?: ( args: baseResponseArgs ) => void; + onComplete ? : (args: baseResponseArgs) => void; /** * The callback to invoke if the disconnect fails. See disconnectFailureArgs for callback argument details. */ - onFailure?: ( args: baseFailureArgs ) => void; + onFailure ? : (args: baseFailureArgs) => void; /** * The callback to invoke if the disconnect succeeds. See disconnectSuccessArgs for callback argument details. */ - onSuccess?: ( args: baseResponseArgs ) => void; + onSuccess ? : (args: baseResponseArgs) => void; } - interface unsubscribeSuccessArgs extends baseResponseArgs - { + interface unsubscribeSuccessArgs extends baseResponseArgs { /** * The channel from which the client was unsubscribed. Must start with a forward slash (/). */ @@ -460,36 +436,34 @@ declare namespace fm channels: string[]; } - interface unsubscribeConfig extends baseRequestConfig - { + interface unsubscribeConfig extends baseRequestConfig { /** * The channel from which the client should be unsubscribed. Must start with a forward slash (/). Overrides channels. */ - channel?: string; + channel ? : string; /** * The channels from which the client should be unsubscribed. Each must start with a forward slash (/). Overrides channel. */ - channels?: string[]; + channels ? : string[]; /** * The callback to invoke after onSuccess or onFailure. See unsubscribeCompleteArgs for callback argument details. */ - onComplete?: ( args: baseResponseArgs ) => void; + onComplete ? : (args: baseResponseArgs) => void; /** * The callback to invoke if the unsubscribe fails. See unsubscribeFailureArgs for callback argument details. */ - onFailure?: ( args: baseFailureArgs ) => void; + onFailure ? : (args: baseFailureArgs) => void; /** * The callback to invoke if the unsubscribe succeeds. See unsubscribeSuccessArgs for callback argument details. */ - onSuccess?: ( args: unsubscribeSuccessArgs ) => void; + onSuccess ? : (args: unsubscribeSuccessArgs) => void; } - export class client - { + export class client { /** * Sets up and maintains a streaming connection to the server. * While this method will typically run asychronously, the WebSync client is designed to be used without (much) consideration for its asynchronous nature. @@ -498,7 +472,7 @@ declare namespace fm * * @param connectConfig */ - connect( config: connectConfig ): client; + connect(config: connectConfig): client; /** * @@ -506,20 +480,20 @@ declare namespace fm * After the disconnect completes successfully, any further calls to methods that require an active connection, like bind, subscribe and publish, will be queued * automatically and executed only if/when the client reconnects. */ - disconnect( config: disconnectConfig ): client; + disconnect(config: disconnectConfig): client; /** * Initializes the client according to the specified configuration. * This method must always be called first. While is always executes synchronously, callbacks are allowed for the purposes of method chaining. */ - static initialize( config: initializeConfig ): client; + static initialize(config: initializeConfig): client; /** * Subscribes the client to receive messages on one or more channels. * When the subscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the subscribed channel(s), * including any modifications made on the server. */ - subscribe( config: subscribeConfig ): client; + subscribe(config: subscribeConfig): client; /** * Unsubscribes the client from receiving messages on one or more channels. @@ -527,7 +501,7 @@ declare namespace fm * including any modifications made on the server. * @param config */ - unsubscribe( config: unsubscribeConfig ): client; + unsubscribe(config: unsubscribeConfig): client; } } } From 721c8f294a9130c9169f2a5ef2bb0ad4f1dd6cd7 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 14:27:54 +0200 Subject: [PATCH 11/15] beautify --- types/fm-websync/index.d.ts | 82 ++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index c69dea19c4..6e3d221ed0 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -12,58 +12,58 @@ declare namespace fm { * (See disconnectConfig for details.) Note that automatic disconnects are a best-effort. The only way to guarantee success is to execute the disconnect synchronously * and target a request URL on the same domain as the page ({ sync: true, requestUrl: '...relative path.../request.ashx' }). Defaults to false. */ - autoDisconnect ? : boolean; + autoDisconnect?: boolean; /** * The amount of time in milliseconds to add to the delay between each reconnect attempt in the event of network failure. Defaults to 3000 (3 seconds). */ - backoffInterval ? : number; + backoffInterval?: number; /** * The URL of the HTML frame to be used with HTML5 postMessage for cross-domain environments. Must have the same domain as requestUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the WebSync Server * ClientHandler registered in web.config with "frame" added to the query. */ - clientFrameUrl ? : string; + clientFrameUrl?: string; /** * The domain key to send with each request. If using WebSync On-Demand, this should be set to the public or private API key specified in the Frozen Mountain Portal. * If using WebSync Server, this should be used only if grouping connections. Defaults to "11111111-1111-1111-1111-111111111111". */ - key ? : string; + key?: string; /** * The callback to invoke after onSuccess or onFailure. See initializeCompleteArgs for callback argument details. */ - onComplete ? : (args: baseArgs) => void; + onComplete?: (args: baseArgs) => void; /** * The callback to invoke if the initialize fails. Defaults to an alert of the error. See initializeFailureArgs for callback argument details. */ - onFailure ? : (args: initializeFailureArgs) => void; + onFailure?: (args: initializeFailureArgs) => void; /** * The callback to invoke if the initialize succeeds. See initializeSuccessArgs for callback argument details. */ - onSuccess ? : (args: baseArgs) => void; + onSuccess?: (args: baseArgs) => void; /** * Whether or not to suppress the alerting of a failure if the client is already initialized. */ - quiet ? : boolean; + quiet?: boolean; /** * The URL of the WebSync request handler. This URL typically ends with request.ashx. Must have the same domain as clientFrameUrl. * Defaults to a dynamically generated URL based on the host of the client script URL (or the host web.config attribute, if specified) and the path to the * WebSync Server RequestHandler registered in web.config. */ - requestUrl ? : string; + requestUrl?: string; /** * The number of times to retry a request in the event of network failure before considering it failed and invoking the corresponding OnFailure callback. Defaults to 3. */ - retries ? : number; + retries?: number; /** * The URLs to use for streaming connections. Three properties are available: @@ -79,18 +79,18 @@ declare namespace fm { * timeout: number * Same as the root timeout parameter, but used for streaming connections. Defaults to the root timeout + 25000 (25 seconds). */ - stream ? : any; + stream?: any; /** * The number of milliseconds to wait for a standard request to return a response before it is cancelled and a new attempt is made. Defaults to 15000 (15 seconds). */ - timeout ? : number; + timeout?: number; /** * The token sent with every client request identifying it for query-based load balancing. Defaults to the current timestamp. */ - token ? : string; + token?: string; /** * An object specifying URLs to be used for specific client methods. Overrides initializeConfig.requestUrl for the specified method type, but can be overridden @@ -117,7 +117,7 @@ declare namespace fm { * disconnect: string * The URL to use for all client.disconnect requests. */ - urls ? : any; + urls?: any; } interface baseArgs { @@ -128,37 +128,37 @@ declare namespace fm { /** * Extra meta data to associate with the request/response. */ - meta ? : any; + meta?: any; /** * The URL of the proxy to use for this request. */ - requestUrl ? : string; + requestUrl?: string; /** * Whether to ignore errors when parsing the server response. If true, any errors thrown while parsing the JSON response received from the server will be ignored. * Defaults to false. */ - suppressErrors ? : boolean; + suppressErrors?: boolean; /** * Whether the request should be executed asynchronously. If true, the request will be executed synchronously if supported by the browser; otherwise, * it will be executed asynchronously. All browsers support synchronous requests if the request URL is the same domain as the page. Synchronous requests * are not supported in IE6 and IE7 for cross-domain environments. Defaults to false. */ - sync ? : boolean; + sync?: boolean; } interface connectConfig extends baseRequestConfig { /** * The callback to invoke after onSuccess or onFailure. See connectCompleteArgs for callback argument details. */ - onComplete ? : (args: connectCompleteArgs) => void; + onComplete?: (args: connectCompleteArgs) => void; /** * The callback to invoke if the connect fails. Defaults to an alert of the error. See connectFailureArgs for callback argument details. */ - onFailure ? : (args: connectFailureArgs) => void; + onFailure?: (args: connectFailureArgs) => void; /** * The callback to invoke if the streaming connection fails. See streamFailureArgs for callback argument details. @@ -169,62 +169,62 @@ declare namespace fm { * If the reconnect fails, the callback specified by onFailure will be invoked with isReconnect set to false. * With the exception of UI updates, invocations of this callback with willReconnect set to true can be ignored. */ - onStreamFailure ? : (args: streamFailureArgs) => void; + onStreamFailure?: (args: streamFailureArgs) => void; /** * The callback to invoke if the connect succeeds. See connectSuccessArgs for callback argument details. */ - onSuccess ? : (args: connectSuccessArgs) => void; + onSuccess?: (args: connectSuccessArgs) => void; /** * The callback to invoke when a message is received on a channel that has no local callback specified to handle it. See receiveArgs for callback argument details. * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client. */ - onUnhandledReceive ? : (args: receiveArgs) => void; + onUnhandledReceive?: (args: receiveArgs) => void; /** * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number * of retries specified by initializeConfig.retries. If false, the client will stop reconnecting if all retry attempts fail. */ - stayConnected ? : boolean; + stayConnected?: boolean; } interface subscribeConfig extends baseRequestConfig { /** * The channel to which the client should be subscribed. Must start with a forward slash (/). Overrides channels. */ - channel ? : string; + channel?: string; /** * The channels to which the client should be subscribed. Each must start with a forward slash (/). Overrides channel. */ - channels ? : string[]; + channels?: string[]; /** * The callback to invoke after onSuccess or onFailure. See subscribeCompleteArgs for callback argument details. */ - onComplete ? : (args: subscribeCompleteArgs) => void; + onComplete?: (args: subscribeCompleteArgs) => void; /** * (OptionalThe callback to invoke if the subscribe fails. See subscribeFailureArgs for callback argument details. */ - onFailure ? : (args: subscribeFailureArgs) => void; + onFailure?: (args: subscribeFailureArgs) => void; /** * The callback to invoke when data is received on the channel(s). See receiveArgs for callback argument details. */ - onReceive ? : (args: receiveArgs) => void; + onReceive?: (args: receiveArgs) => void; /** * Subscribers extension. The callback to invoke when a subscribers change notification is received (i.e. when a client subscribes to or unsubscribes from the channel(s)). * The current subscribe request will trigger this callback. See subscribersChangeArgs for callback argument details. */ - onSubscribersChange ? : (args: subscribersChangeArgs) => void; + onSubscribersChange?: (args: subscribersChangeArgs) => void; /** * The callback to invoke if the subscribe succeeds. See subscribeSuccessArgs for callback argument details. */ - onSuccess ? : (args: subscribeSuccessArgs) => void; + onSuccess?: (args: subscribeSuccessArgs) => void; } interface initializeFailureArgs extends baseArgs { @@ -363,12 +363,12 @@ declare namespace fm { /** * The details of the change that occurred. */ - change ? : fm.websync.subscribersChange + change?: fm.websync.subscribersChange /** * The channel on which the change occurred. */ - channel ? : string; + channel?: string; } interface publishingClient { @@ -411,17 +411,17 @@ declare namespace fm { /** * The callback to invoke after onSuccess or onFailure. See disconnectCompleteArgs for callback argument details. */ - onComplete ? : (args: baseResponseArgs) => void; + onComplete?: (args: baseResponseArgs) => void; /** * The callback to invoke if the disconnect fails. See disconnectFailureArgs for callback argument details. */ - onFailure ? : (args: baseFailureArgs) => void; + onFailure?: (args: baseFailureArgs) => void; /** * The callback to invoke if the disconnect succeeds. See disconnectSuccessArgs for callback argument details. */ - onSuccess ? : (args: baseResponseArgs) => void; + onSuccess?: (args: baseResponseArgs) => void; } interface unsubscribeSuccessArgs extends baseResponseArgs { @@ -440,27 +440,27 @@ declare namespace fm { /** * The channel from which the client should be unsubscribed. Must start with a forward slash (/). Overrides channels. */ - channel ? : string; + channel?: string; /** * The channels from which the client should be unsubscribed. Each must start with a forward slash (/). Overrides channel. */ - channels ? : string[]; + channels?: string[]; /** * The callback to invoke after onSuccess or onFailure. See unsubscribeCompleteArgs for callback argument details. */ - onComplete ? : (args: baseResponseArgs) => void; + onComplete?: (args: baseResponseArgs) => void; /** * The callback to invoke if the unsubscribe fails. See unsubscribeFailureArgs for callback argument details. */ - onFailure ? : (args: baseFailureArgs) => void; + onFailure?: (args: baseFailureArgs) => void; /** * The callback to invoke if the unsubscribe succeeds. See unsubscribeSuccessArgs for callback argument details. */ - onSuccess ? : (args: unsubscribeSuccessArgs) => void; + onSuccess?: (args: unsubscribeSuccessArgs) => void; } export class client { From f400b97404ff6f01ff6476e0cdd9b6e022670b64 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Fri, 30 Jun 2017 14:36:13 +0200 Subject: [PATCH 12/15] method signature instead of property signature of function type --- types/fm-websync/index.d.ts | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index 6e3d221ed0..14c9cae027 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -1,10 +1,10 @@ -// Type definitions for fm-websync 3 +// Type definitions for fm-websync 3.0 // Project: https://github.com/baz/foo (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.) // Definitions by: Markus Mauch // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare namespace fm { - export namespace websync { + namespace websync { interface initializeConfig { /** * If set to true, an asynchronous disconnect request will be launched when the page unloads. If set to false, no automatic disconnection will be attempted. @@ -36,17 +36,17 @@ declare namespace fm { /** * The callback to invoke after onSuccess or onFailure. See initializeCompleteArgs for callback argument details. */ - onComplete?: (args: baseArgs) => void; + onComplete?(args: baseArgs): void; /** * The callback to invoke if the initialize fails. Defaults to an alert of the error. See initializeFailureArgs for callback argument details. */ - onFailure?: (args: initializeFailureArgs) => void; + onFailure?(args: initializeFailureArgs): void; /** * The callback to invoke if the initialize succeeds. See initializeSuccessArgs for callback argument details. */ - onSuccess?: (args: baseArgs) => void; + onSuccess?(args: baseArgs): void; /** * Whether or not to suppress the alerting of a failure if the client is already initialized. @@ -153,12 +153,12 @@ declare namespace fm { /** * The callback to invoke after onSuccess or onFailure. See connectCompleteArgs for callback argument details. */ - onComplete?: (args: connectCompleteArgs) => void; + onComplete?(args: connectCompleteArgs): void; /** * The callback to invoke if the connect fails. Defaults to an alert of the error. See connectFailureArgs for callback argument details. */ - onFailure?: (args: connectFailureArgs) => void; + onFailure?(args: connectFailureArgs): void; /** * The callback to invoke if the streaming connection fails. See streamFailureArgs for callback argument details. @@ -169,18 +169,18 @@ declare namespace fm { * If the reconnect fails, the callback specified by onFailure will be invoked with isReconnect set to false. * With the exception of UI updates, invocations of this callback with willReconnect set to true can be ignored. */ - onStreamFailure?: (args: streamFailureArgs) => void; + onStreamFailure?(args: streamFailureArgs): void; /** * The callback to invoke if the connect succeeds. See connectSuccessArgs for callback argument details. */ - onSuccess?: (args: connectSuccessArgs) => void; + onSuccess?(args: connectSuccessArgs): void; /** * The callback to invoke when a message is received on a channel that has no local callback specified to handle it. See receiveArgs for callback argument details. * This can occur if (a) a client is manually subscribed to a channel by the server or (b) a client subscribed to a channel and then manually removed the local callback using client. */ - onUnhandledReceive?: (args: receiveArgs) => void; + onUnhandledReceive?(args: receiveArgs): void; /** * Whether to always attempt to stay connected in the event of network failure. If true, the client will continually reconnect, even after exhausting the specified number @@ -203,28 +203,28 @@ declare namespace fm { /** * The callback to invoke after onSuccess or onFailure. See subscribeCompleteArgs for callback argument details. */ - onComplete?: (args: subscribeCompleteArgs) => void; + onComplete?(args: subscribeCompleteArgs): void; /** * (OptionalThe callback to invoke if the subscribe fails. See subscribeFailureArgs for callback argument details. */ - onFailure?: (args: subscribeFailureArgs) => void; + onFailure?(args: subscribeFailureArgs): void; /** * The callback to invoke when data is received on the channel(s). See receiveArgs for callback argument details. */ - onReceive?: (args: receiveArgs) => void; + onReceive?(args: receiveArgs): void; /** * Subscribers extension. The callback to invoke when a subscribers change notification is received (i.e. when a client subscribes to or unsubscribes from the channel(s)). * The current subscribe request will trigger this callback. See subscribersChangeArgs for callback argument details. */ - onSubscribersChange?: (args: subscribersChangeArgs) => void; + onSubscribersChange?(args: subscribersChangeArgs): void; /** * The callback to invoke if the subscribe succeeds. See subscribeSuccessArgs for callback argument details. */ - onSuccess?: (args: subscribeSuccessArgs) => void; + onSuccess?(args: subscribeSuccessArgs): void; } interface initializeFailureArgs extends baseArgs { @@ -363,7 +363,7 @@ declare namespace fm { /** * The details of the change that occurred. */ - change?: fm.websync.subscribersChange + change?: fm.websync.subscribersChange; /** * The channel on which the change occurred. @@ -411,17 +411,17 @@ declare namespace fm { /** * The callback to invoke after onSuccess or onFailure. See disconnectCompleteArgs for callback argument details. */ - onComplete?: (args: baseResponseArgs) => void; + onComplete?(args: baseResponseArgs): void; /** * The callback to invoke if the disconnect fails. See disconnectFailureArgs for callback argument details. */ - onFailure?: (args: baseFailureArgs) => void; + onFailure?(args: baseFailureArgs): void; /** * The callback to invoke if the disconnect succeeds. See disconnectSuccessArgs for callback argument details. */ - onSuccess?: (args: baseResponseArgs) => void; + onSuccess?(args: baseResponseArgs): void; } interface unsubscribeSuccessArgs extends baseResponseArgs { @@ -450,20 +450,20 @@ declare namespace fm { /** * The callback to invoke after onSuccess or onFailure. See unsubscribeCompleteArgs for callback argument details. */ - onComplete?: (args: baseResponseArgs) => void; + onComplete?(args: baseResponseArgs): void; /** * The callback to invoke if the unsubscribe fails. See unsubscribeFailureArgs for callback argument details. */ - onFailure?: (args: baseFailureArgs) => void; + onFailure?(args: baseFailureArgs): void; /** * The callback to invoke if the unsubscribe succeeds. See unsubscribeSuccessArgs for callback argument details. */ - onSuccess?: (args: unsubscribeSuccessArgs) => void; + onSuccess?(args: unsubscribeSuccessArgs): void; } - export class client { + class client { /** * Sets up and maintains a streaming connection to the server. * While this method will typically run asychronously, the WebSync client is designed to be used without (much) consideration for its asynchronous nature. From e87ba7e90c6b7972811d01f21fc9a015d2a917f8 Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Mon, 3 Jul 2017 12:41:37 +0200 Subject: [PATCH 13/15] add reconnect method --- types/fm-websync/index.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index 14c9cae027..0a3f42958c 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -488,6 +488,12 @@ declare namespace fm { */ static initialize(config: initializeConfig): client; + /** + * Reconnects after a stream failure using either the most recent connectConfig or the one specified. + * This method should only be called from the callback specified by onSreamFailure and only if the args.willReconnect flag is set to false. Otherwise, the client will reconnect automatically. + */ + reconnect( config?: connectConfig ): client; + /** * Subscribes the client to receive messages on one or more channels. * When the subscribe completes successfully, the callback specified by onSuccess will be invoked, passing in the subscribed channel(s), From 77c99dec1769e5fda17e96dba3ebe28d53df878b Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Thu, 13 Jul 2017 15:29:11 +0200 Subject: [PATCH 14/15] Corrected line length --- types/fm-websync/.gitignore | 1 + types/fm-websync/index.d.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 types/fm-websync/.gitignore diff --git a/types/fm-websync/.gitignore b/types/fm-websync/.gitignore new file mode 100644 index 0000000000..600d2d33ba --- /dev/null +++ b/types/fm-websync/.gitignore @@ -0,0 +1 @@ +.vscode \ No newline at end of file diff --git a/types/fm-websync/index.d.ts b/types/fm-websync/index.d.ts index 0a3f42958c..1e1abc2083 100644 --- a/types/fm-websync/index.d.ts +++ b/types/fm-websync/index.d.ts @@ -490,7 +490,8 @@ declare namespace fm { /** * Reconnects after a stream failure using either the most recent connectConfig or the one specified. - * This method should only be called from the callback specified by onSreamFailure and only if the args.willReconnect flag is set to false. Otherwise, the client will reconnect automatically. + * This method should only be called from the callback specified by onSreamFailure and only if the args.willReconnect flag is set to false. + * Otherwise, the client will reconnect automatically. */ reconnect( config?: connectConfig ): client; From 65abd5a215c2c05c939f3a4862634dec9bc8617b Mon Sep 17 00:00:00 2001 From: Markus Mauch Date: Thu, 13 Jul 2017 15:48:28 +0200 Subject: [PATCH 15/15] Unues gitignore --- types/fm-websync/.gitignore | 1 - 1 file changed, 1 deletion(-) delete mode 100644 types/fm-websync/.gitignore diff --git a/types/fm-websync/.gitignore b/types/fm-websync/.gitignore deleted file mode 100644 index 600d2d33ba..0000000000 --- a/types/fm-websync/.gitignore +++ /dev/null @@ -1 +0,0 @@ -.vscode \ No newline at end of file