From 925480dba41ecb7c010c933f16ffa2afcc50915b Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 30 Aug 2018 12:24:41 -0700 Subject: [PATCH 01/39] Adding details on the OfficeRuntime namespace which affects custom functions --- types/office-js/index.d.ts | 95 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 99d7ddac1b..0ed0eb0516 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -17200,6 +17200,101 @@ declare namespace OfficeExtension { //////////////////////////////////////////////////////////////// +//////////////////////////////////////////////////////////////// +////////////////////// Begin OfficeRuntime ///////////////////// +//////////////////////////////////////////////////////////////// + +declare namespace OfficeRuntime { + function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; + const AsyncStorage: AsyncStorage; + + // tslint:disable-next-line:interface-name + interface AsyncStorage { + getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; + setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; + removeItem(key: string, callback?: (error?: Error) => void): Promise; + clear(callback?: (error?: Error) => void): Promise; + getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; + multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; + multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise; + multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; + } + + interface Dialog { + close(): Promise; + } + + // (copied from richapi/office-dialog/src/dialog.ts) + interface DisplayWebDialogOptions { + /** + * + * True if dialog opens in IFRAME + * + * [Api set: Dialog 1.2] + */ + displayInIFrame?: boolean; + /** + * + * The height of dialog as a percentage of window + * + * ex. '50%', '50' + * + * [Api set: Dialog 1.2] + */ + height?: string; + + /** + * + * The width of dialog as a percentage of window + * + * ex. '50%', '50' + * + * [Api set: Dialog 1.2] + */ + width?: string; + + /** + * + * True if title is hidden + * + * [Api set: Dialog 1.2] + */ + hideTitle?: boolean; + + /** + * + * Callback that is run when the dialog sends a message to its parent + * + * [Api set: Dialog 1.X] + */ + onMessage?: (message: string, dialog?: Dialog) => void; + + /** + * + * Callback that is run when the dialog is closed + * + * [Api set: Dialog 1.X] + */ + onClose?: () => void; + + /** + * + * Callback that is run when the dialog sends an error + * + * [Api set: Dialog 1.X] + */ + onRuntimeError?: (error: Error, dialog?: Dialog) => void; + } + } + + + +//////////////////////////////////////////////////////////////// +////////////////////// End OfficeRuntime ////////////////////// +//////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// ////////////////////// Begin OfficeCore //////////////////////// From 5c4969bc9b07ce29a6cf53d04f0a90c573c136eb Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 10 Sep 2018 12:32:41 -0700 Subject: [PATCH 02/39] adding information about officeruntime and customfunctionsmapping --- .../custom-functions-mapping-tests.ts | 30 ++++ types/custom-functions-mapping/index.d.ts | 30 ++++ types/custom-functions-mapping/tsconfig.json | 23 +++ types/custom-functions-mapping/tslint.json | 79 +++++++++ types/office-js/index.d.ts | 15 +- types/office-runtime/index.d.ts | 155 ++++++++++++++++++ types/office-runtime/office-runtime-tests.ts | 77 +++++++++ types/office-runtime/tsconfig.json | 23 +++ types/office-runtime/tslint.json | 79 +++++++++ 9 files changed, 506 insertions(+), 5 deletions(-) create mode 100644 types/custom-functions-mapping/custom-functions-mapping-tests.ts create mode 100644 types/custom-functions-mapping/index.d.ts create mode 100644 types/custom-functions-mapping/tsconfig.json create mode 100644 types/custom-functions-mapping/tslint.json create mode 100644 types/office-runtime/index.d.ts create mode 100644 types/office-runtime/office-runtime-tests.ts create mode 100644 types/office-runtime/tsconfig.json create mode 100644 types/office-runtime/tslint.json diff --git a/types/custom-functions-mapping/custom-functions-mapping-tests.ts b/types/custom-functions-mapping/custom-functions-mapping-tests.ts new file mode 100644 index 0000000000..23305c7ac4 --- /dev/null +++ b/types/custom-functions-mapping/custom-functions-mapping-tests.ts @@ -0,0 +1,30 @@ +async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + handler.setResult(dollars) +} + +async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { + var shouldStop = false; + handler.onCanceled = () => shouldStop = true; + await pause(1000); + + if (shouldStop) { + return null; + } + + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +async function getStockValuesNowWithNoCancelling(ticker: string) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +function add10(n: number) { + return n + 10; +} + + +declare function pause(ms: number): Promise + diff --git a/types/custom-functions-mapping/index.d.ts b/types/custom-functions-mapping/index.d.ts new file mode 100644 index 0000000000..7e743aa228 --- /dev/null +++ b/types/custom-functions-mapping/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for Custom Functions +// Project: http://dev.office.com +// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/* +office-js +Copyright (c) Microsoft Corporation +*/ + +declare const CustomFunctionMappings: { [key: string]: Function }; + +declare namespace CustomFunctions { + interface StreamingHandler extends CancelableHandler { + /* + * Sets the returned result for a streaming custom function. + * @beta + */ + setResult: (value: T) => void; + } + + interface CancelableHandler { + /* + * Handles what should occur when a custom function is canceled. + * @beta + */ + onCanceled: () => void; + } +} \ No newline at end of file diff --git a/types/custom-functions-mapping/tsconfig.json b/types/custom-functions-mapping/tsconfig.json new file mode 100644 index 0000000000..5c54e3ed5b --- /dev/null +++ b/types/custom-functions-mapping/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "target": "es6", + }, + "files": [ + "index.d.ts", + "office-runtime-tests.ts" + ] +} \ No newline at end of file diff --git a/types/custom-functions-mapping/tslint.json b/types/custom-functions-mapping/tslint.json new file mode 100644 index 0000000000..5c50b51e66 --- /dev/null +++ b/types/custom-functions-mapping/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} \ No newline at end of file diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 0ed0eb0516..5dc7b9deb0 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -17198,10 +17198,13 @@ declare namespace OfficeExtension { //////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// -////////////////////// Begin OfficeRuntime ///////////////////// + + + +//////////////////////////////////////////////////////////////// +//////////////// Begin OfficeRuntime namespace ///////////////// //////////////////////////////////////////////////////////////// declare namespace OfficeRuntime { @@ -17286,16 +17289,18 @@ declare namespace OfficeRuntime { onRuntimeError?: (error: Error, dialog?: Dialog) => void; } } - - //////////////////////////////////////////////////////////////// -////////////////////// End OfficeRuntime ////////////////////// +//////////////// End OfficeRuntime namespace /////////////////// //////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// ////////////////////// Begin OfficeCore //////////////////////// //////////////////////////////////////////////////////////////// diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts new file mode 100644 index 0000000000..4e45c8dc82 --- /dev/null +++ b/types/office-runtime/index.d.ts @@ -0,0 +1,155 @@ +// Type definitions for office-runtime +// Project: http://dev.office.com/ +// Definitions by: Michael Zlatskovsky , Michelle Scharlock +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Typescript Version: 2.4 + +/* +office-runtime +Copyright (c) Microsoft Corporation +*/ + +declare namespace OfficeRuntime { + function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; + const AsyncStorage: AsyncStorage; + + // tslint:disable-next-line:interface-name + /** + * Asynchronous, global, and persistent key-value storage for Excel Custom Functions only. + * @beta + * + * @remarks + * Each add-in instance has its own storage partition, unique to a user and their device. + * + * The default amount of total storage allowed per add-in is 5MB. + * + * Each method listed below returns a Promise object. + * + */ + interface AsyncStorage { + /** + * @beta + * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. + * + */ + getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; + /** + * @beta + * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. + * + */ + setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; + /** + * @beta + * Removes an item for specified key and invokes a callback when finished. Returns a Promise. + * + * + */ + removeItem(key: string, callback?: (error?: Error) => void): Promise; + /** + * @beta + * Erases all AsyncStorage. Returns a Promise. + * + */ + clear(callback?: (error?: Error) => void): Promise; + /** + * @beta + * Returns a Promise with all keys for your custom function. + * + */ + getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; + /** + * @beta + * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. + * + */ + multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; + /** + * @beta + * Deletes a batch of keys, specified in the `keys` array. + * + */ + multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise;/** + /** + * @beta + * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. + * + */ + multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; + } + + /** + * @beta + * Object representing the dialog box for Excel Custom Functions only. + * + */ + interface Dialog { + /** + * @beta + * Method that closes a dialog box. + */ + close(): Promise; + } + + /** + * + * Provides options for how a dialog is displayed for Excel Custom Functions only. + * + */ + interface DisplayWebDialogOptions { + /** + * @beta + * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. + * + * [Api set: Dialog 1.2] + */ + displayInIFrame?: boolean; + /** + * @beta + * Defines the height of the dialog box as a percentage of the current display. + * + * [Api set: Dialog 1.2] + */ + height?: string; + + /** + * @beta + * Defines the width of the dialog box as a percentage of the current display. + * + * [Api set: Dialog 1.2] + */ + width?: string; + + /** + * @beta + * True if title is hidden from the dialog box. + * + * [Api set: Dialog 1.2] + */ + hideTitle?: boolean; + + /** + * @beta + * Callback that is run when the dialog box sends a message to its parent. + * + * + */ + onMessage?: (message: string, dialog?: Dialog) => void; + + /** + * @beta + * Callback that is run when the dialog box is closed. + * + * + */ + onClose?: () => void; + + /** + * @beta + * Callback that is run when the dialog box sends an error. + * + * + */ + onRuntimeError?: (error: Error, dialog?: Dialog) => void; + } + } diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts new file mode 100644 index 0000000000..a8d8f09675 --- /dev/null +++ b/types/office-runtime/office-runtime-tests.ts @@ -0,0 +1,77 @@ +/* +office-runtime +Copyright (c) Microsoft Corporation +*/ + +OfficeRuntime.AsyncStorage.getItem("foo", () => { + //do a thing +}) +OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) + +OfficeRuntime.AsyncStorage.setItem("foo", "bar"); +OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)) + +OfficeRuntime.AsyncStorage.removeItem("foo"); +OfficeRuntime.AsyncStorage.removeItem("foo", () => { + //do a thing +}) + +OfficeRuntime.AsyncStorage.clear(); +OfficeRuntime.AsyncStorage.clear(() => { + //do a thing +}) + +OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { + keys.forEach(item => console.log(item)); +}) +OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { + if (error) { + console.error(error); + } else { + keys.forEach(item => console.log(item)); + } +}) + +OfficeRuntime.AsyncStorage.multiSet( + [["username", "foo"], ["yearOfBirth", "2001"]], + errors => { + errors.filter(error => error != null).forEach(error => console.log(error)); + } +) + +OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); +OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)) + +OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( + values => { + console.log(values[0][1]) + console.log(values[1][1]) + } +) + + +OfficeRuntime.displayWebDialog("https://localhost:3000", { + height: '50', + width: '50%', + displayInIFrame: false, + hideTitle: true, +     onMessage: (message, dialog) => { +         console.log(message); +             dialog.close(); +             } + } +) + + +OfficeRuntime.displayWebDialog("https://localhost:3000", { + onClose: () => { + console.log("closed"); + } +}) + +OfficeRuntime.displayWebDialog("https://localhost:3000", { + onRuntimeError: (error, dialog) => { + console.log(error); + dialog.close(); + } +}) \ No newline at end of file diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json new file mode 100644 index 0000000000..5c54e3ed5b --- /dev/null +++ b/types/office-runtime/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "target": "es6", + }, + "files": [ + "index.d.ts", + "office-runtime-tests.ts" + ] +} \ No newline at end of file diff --git a/types/office-runtime/tslint.json b/types/office-runtime/tslint.json new file mode 100644 index 0000000000..5c50b51e66 --- /dev/null +++ b/types/office-runtime/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} \ No newline at end of file From 9493093b60eb072648362ab0c27b8a6accac9304 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 10 Sep 2018 17:11:51 -0700 Subject: [PATCH 03/39] Adjusting folder name to be the right name --- .../custom-function-mappings-tests.ts} | 0 .../index.d.ts | 0 .../tsconfig.json | 0 .../tslint.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename types/{custom-functions-mapping/custom-functions-mapping-tests.ts => custom-function-mapping/custom-function-mappings-tests.ts} (100%) rename types/{custom-functions-mapping => custom-function-mapping}/index.d.ts (100%) rename types/{custom-functions-mapping => custom-function-mapping}/tsconfig.json (100%) rename types/{custom-functions-mapping => custom-function-mapping}/tslint.json (100%) diff --git a/types/custom-functions-mapping/custom-functions-mapping-tests.ts b/types/custom-function-mapping/custom-function-mappings-tests.ts similarity index 100% rename from types/custom-functions-mapping/custom-functions-mapping-tests.ts rename to types/custom-function-mapping/custom-function-mappings-tests.ts diff --git a/types/custom-functions-mapping/index.d.ts b/types/custom-function-mapping/index.d.ts similarity index 100% rename from types/custom-functions-mapping/index.d.ts rename to types/custom-function-mapping/index.d.ts diff --git a/types/custom-functions-mapping/tsconfig.json b/types/custom-function-mapping/tsconfig.json similarity index 100% rename from types/custom-functions-mapping/tsconfig.json rename to types/custom-function-mapping/tsconfig.json diff --git a/types/custom-functions-mapping/tslint.json b/types/custom-function-mapping/tslint.json similarity index 100% rename from types/custom-functions-mapping/tslint.json rename to types/custom-function-mapping/tslint.json From af4cc764aaaf581a5cf17a562f88b585086b13e1 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 10:09:02 -0700 Subject: [PATCH 04/39] Changing weird spacing --- .../custom-function-mappings-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/custom-function-mapping/custom-function-mappings-tests.ts b/types/custom-function-mapping/custom-function-mappings-tests.ts index 23305c7ac4..98fe35fd9f 100644 --- a/types/custom-function-mapping/custom-function-mappings-tests.ts +++ b/types/custom-function-mapping/custom-function-mappings-tests.ts @@ -1,10 +1,10 @@ async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) + handler.setResult(dollars) } async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; + var shouldStop = false; handler.onCanceled = () => shouldStop = true; await pause(1000); @@ -17,8 +17,8 @@ async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.Ca } async function getStockValuesNowWithNoCancelling(ticker: string) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; } function add10(n: number) { From 560a12f67bedbb6de5095780d25a90dae7c696f5 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 10:17:20 -0700 Subject: [PATCH 05/39] Fixing spacing --- types/custom-function-mapping/index.d.ts | 30 ++++++++++++------------ 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/types/custom-function-mapping/index.d.ts b/types/custom-function-mapping/index.d.ts index 7e743aa228..78384f45f4 100644 --- a/types/custom-function-mapping/index.d.ts +++ b/types/custom-function-mapping/index.d.ts @@ -12,19 +12,19 @@ Copyright (c) Microsoft Corporation declare const CustomFunctionMappings: { [key: string]: Function }; declare namespace CustomFunctions { - interface StreamingHandler extends CancelableHandler { - /* - * Sets the returned result for a streaming custom function. - * @beta - */ - setResult: (value: T) => void; - } + interface StreamingHandler extends CancelableHandler { + /* + * Sets the returned result for a streaming custom function. + * @beta + */ + setResult: (value: T) => void; + } - interface CancelableHandler { - /* - * Handles what should occur when a custom function is canceled. - * @beta - */ - onCanceled: () => void; - } -} \ No newline at end of file + interface CancelableHandler { + /* + * Handles what should occur when a custom function is canceled. + * @beta + */ + onCanceled: () => void; + } +} From ac169cae549037b64d59288c495d80f248aff108 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 10:21:03 -0700 Subject: [PATCH 06/39] Updating "cfs only" language and removing API set #s --- types/office-runtime/index.d.ts | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts index 4e45c8dc82..43f26cf1c7 100644 --- a/types/office-runtime/index.d.ts +++ b/types/office-runtime/index.d.ts @@ -15,7 +15,7 @@ declare namespace OfficeRuntime { // tslint:disable-next-line:interface-name /** - * Asynchronous, global, and persistent key-value storage for Excel Custom Functions only. + * Asynchronous, global, and persistent key-value storage that can be used by Excel custom functions. * @beta * * @remarks @@ -80,7 +80,7 @@ declare namespace OfficeRuntime { /** * @beta - * Object representing the dialog box for Excel Custom Functions only. + * Object representing the dialog box. * */ interface Dialog { @@ -93,7 +93,7 @@ declare namespace OfficeRuntime { /** * - * Provides options for how a dialog is displayed for Excel Custom Functions only. + * Provides options for how a dialog is displayed. * */ interface DisplayWebDialogOptions { @@ -101,14 +101,12 @@ declare namespace OfficeRuntime { * @beta * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. * - * [Api set: Dialog 1.2] */ displayInIFrame?: boolean; /** * @beta * Defines the height of the dialog box as a percentage of the current display. * - * [Api set: Dialog 1.2] */ height?: string; @@ -116,18 +114,9 @@ declare namespace OfficeRuntime { * @beta * Defines the width of the dialog box as a percentage of the current display. * - * [Api set: Dialog 1.2] */ width?: string; - - /** - * @beta - * True if title is hidden from the dialog box. - * - * [Api set: Dialog 1.2] - */ - hideTitle?: boolean; - + /** * @beta * Callback that is run when the dialog box sends a message to its parent. From 7482d84a2ca3a2a5ecd6a384cb2f9ae381c42078 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 10:41:05 -0700 Subject: [PATCH 07/39] Added comments, got rid of extra *s --- types/office-runtime/index.d.ts | 47 ++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 18 deletions(-) diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts index 43f26cf1c7..e2974889f5 100644 --- a/types/office-runtime/index.d.ts +++ b/types/office-runtime/index.d.ts @@ -9,12 +9,23 @@ office-runtime Copyright (c) Microsoft Corporation */ +/* +OfficeRuntime defines a new runtime which can be used by Excel custom functions. +*/ declare namespace OfficeRuntime { + /* + A function which allows you to use a dialog box in Office Runtime, which can be used by Excel custom functions. + */ function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; + + /* + * Defines the AsyncStorage constant which allows asynchronous, global, and persistent key-value storage which can be used by Excel custom functions. + */ + const AsyncStorage: AsyncStorage; // tslint:disable-next-line:interface-name - /** + /* * Asynchronous, global, and persistent key-value storage that can be used by Excel custom functions. * @beta * @@ -27,50 +38,50 @@ declare namespace OfficeRuntime { * */ interface AsyncStorage { - /** + /* * @beta * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. * */ getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; - /** + /* * @beta * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. * */ setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; - /** + /* * @beta * Removes an item for specified key and invokes a callback when finished. Returns a Promise. * * */ removeItem(key: string, callback?: (error?: Error) => void): Promise; - /** + /* * @beta * Erases all AsyncStorage. Returns a Promise. * */ clear(callback?: (error?: Error) => void): Promise; - /** + /* * @beta * Returns a Promise with all keys for your custom function. * */ getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; - /** + /* * @beta * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. * */ multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; - /** + /* * @beta * Deletes a batch of keys, specified in the `keys` array. * */ multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise;/** - /** + /* * @beta * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. * @@ -78,46 +89,46 @@ declare namespace OfficeRuntime { multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; } - /** + /* * @beta * Object representing the dialog box. * */ interface Dialog { - /** + /* * @beta * Method that closes a dialog box. */ close(): Promise; } - /** + /* * * Provides options for how a dialog is displayed. * */ interface DisplayWebDialogOptions { - /** + /* * @beta * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. * */ displayInIFrame?: boolean; - /** + /* * @beta * Defines the height of the dialog box as a percentage of the current display. * */ height?: string; - /** + /* * @beta * Defines the width of the dialog box as a percentage of the current display. * */ width?: string; - /** + /* * @beta * Callback that is run when the dialog box sends a message to its parent. * @@ -125,7 +136,7 @@ declare namespace OfficeRuntime { */ onMessage?: (message: string, dialog?: Dialog) => void; - /** + /* * @beta * Callback that is run when the dialog box is closed. * @@ -133,7 +144,7 @@ declare namespace OfficeRuntime { */ onClose?: () => void; - /** + /* * @beta * Callback that is run when the dialog box sends an error. * From 14d170f2f20d2d746581ffd5d611dea6bb038a7a Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 10:43:44 -0700 Subject: [PATCH 08/39] Changing "do a thing" to less colloquial lang --- types/office-runtime/office-runtime-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts index a8d8f09675..c34bb679bd 100644 --- a/types/office-runtime/office-runtime-tests.ts +++ b/types/office-runtime/office-runtime-tests.ts @@ -4,7 +4,7 @@ Copyright (c) Microsoft Corporation */ OfficeRuntime.AsyncStorage.getItem("foo", () => { - //do a thing + //perform an action }) OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) @@ -13,12 +13,12 @@ OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error OfficeRuntime.AsyncStorage.removeItem("foo"); OfficeRuntime.AsyncStorage.removeItem("foo", () => { - //do a thing + //perform an action }) OfficeRuntime.AsyncStorage.clear(); OfficeRuntime.AsyncStorage.clear(() => { - //do a thing + //perform an action }) OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { @@ -74,4 +74,4 @@ OfficeRuntime.displayWebDialog("https://localhost:3000", { console.log(error); dialog.close(); } -}) \ No newline at end of file +}) From bb35fabd6628e196af5dbc581c45da69f48562e6 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 10:45:36 -0700 Subject: [PATCH 09/39] Fixing } --- types/office-runtime/office-runtime-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts index c34bb679bd..5cd093aca5 100644 --- a/types/office-runtime/office-runtime-tests.ts +++ b/types/office-runtime/office-runtime-tests.ts @@ -58,7 +58,7 @@ OfficeRuntime.displayWebDialog("https://localhost:3000", {      onMessage: (message, dialog) => {          console.log(message);              dialog.close(); -             } +  } } ) From 67c6c1ff3b2a45c05ece16a097579488edefeffc Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 10:55:59 -0700 Subject: [PATCH 10/39] extracting runtime info from office-js --- types/office-js/index.d.ts | 97 -------------------------------------- 1 file changed, 97 deletions(-) diff --git a/types/office-js/index.d.ts b/types/office-js/index.d.ts index 5dc7b9deb0..024a72f6e9 100644 --- a/types/office-js/index.d.ts +++ b/types/office-js/index.d.ts @@ -17203,103 +17203,6 @@ declare namespace OfficeExtension { -//////////////////////////////////////////////////////////////// -//////////////// Begin OfficeRuntime namespace ///////////////// -//////////////////////////////////////////////////////////////// - -declare namespace OfficeRuntime { - function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; - const AsyncStorage: AsyncStorage; - - // tslint:disable-next-line:interface-name - interface AsyncStorage { - getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; - setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; - removeItem(key: string, callback?: (error?: Error) => void): Promise; - clear(callback?: (error?: Error) => void): Promise; - getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; - multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; - multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise; - multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; - } - - interface Dialog { - close(): Promise; - } - - // (copied from richapi/office-dialog/src/dialog.ts) - interface DisplayWebDialogOptions { - /** - * - * True if dialog opens in IFRAME - * - * [Api set: Dialog 1.2] - */ - displayInIFrame?: boolean; - /** - * - * The height of dialog as a percentage of window - * - * ex. '50%', '50' - * - * [Api set: Dialog 1.2] - */ - height?: string; - - /** - * - * The width of dialog as a percentage of window - * - * ex. '50%', '50' - * - * [Api set: Dialog 1.2] - */ - width?: string; - - /** - * - * True if title is hidden - * - * [Api set: Dialog 1.2] - */ - hideTitle?: boolean; - - /** - * - * Callback that is run when the dialog sends a message to its parent - * - * [Api set: Dialog 1.X] - */ - onMessage?: (message: string, dialog?: Dialog) => void; - - /** - * - * Callback that is run when the dialog is closed - * - * [Api set: Dialog 1.X] - */ - onClose?: () => void; - - /** - * - * Callback that is run when the dialog sends an error - * - * [Api set: Dialog 1.X] - */ - onRuntimeError?: (error: Error, dialog?: Dialog) => void; - } - } - -//////////////////////////////////////////////////////////////// -//////////////// End OfficeRuntime namespace /////////////////// -//////////////////////////////////////////////////////////////// - - - -//////////////////////////////////////////////////////////////// - - - //////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// ////////////////////// Begin OfficeCore //////////////////////// From 45c4082cf2b4f9256141705fb4f3d608dc03d41f Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 11:14:11 -0700 Subject: [PATCH 11/39] adding custom functions mapping test --- .../custom-function-runtime-tests.ts} | 16 +++++++++------- .../index.d.ts | 0 .../tsconfig.json | 0 .../tslint.json | 0 4 files changed, 9 insertions(+), 7 deletions(-) rename types/{custom-function-mapping/custom-function-mappings-tests.ts => custom-function-runtime/custom-function-runtime-tests.ts} (86%) rename types/{custom-function-mapping => custom-function-runtime}/index.d.ts (100%) rename types/{custom-function-mapping => custom-function-runtime}/tsconfig.json (100%) rename types/{custom-function-mapping => custom-function-runtime}/tslint.json (100%) diff --git a/types/custom-function-mapping/custom-function-mappings-tests.ts b/types/custom-function-runtime/custom-function-runtime-tests.ts similarity index 86% rename from types/custom-function-mapping/custom-function-mappings-tests.ts rename to types/custom-function-runtime/custom-function-runtime-tests.ts index 98fe35fd9f..47953776b3 100644 --- a/types/custom-function-mapping/custom-function-mappings-tests.ts +++ b/types/custom-function-runtime/custom-function-runtime-tests.ts @@ -1,3 +1,11 @@ +function ADD10(n: number) { + return n + 10; +} + +declare const CustomFunctionMappings: { + ["addTen"]: ADD10(); +}; + async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); handler.setResult(dollars) @@ -13,7 +21,7 @@ async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.Ca } const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; + return dollars; } async function getStockValuesNowWithNoCancelling(ticker: string) { @@ -21,10 +29,4 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { return dollars; } -function add10(n: number) { - return n + 10; -} - - declare function pause(ms: number): Promise - diff --git a/types/custom-function-mapping/index.d.ts b/types/custom-function-runtime/index.d.ts similarity index 100% rename from types/custom-function-mapping/index.d.ts rename to types/custom-function-runtime/index.d.ts diff --git a/types/custom-function-mapping/tsconfig.json b/types/custom-function-runtime/tsconfig.json similarity index 100% rename from types/custom-function-mapping/tsconfig.json rename to types/custom-function-runtime/tsconfig.json diff --git a/types/custom-function-mapping/tslint.json b/types/custom-function-runtime/tslint.json similarity index 100% rename from types/custom-function-mapping/tslint.json rename to types/custom-function-runtime/tslint.json From abf058fa3fe808213416d8b75ac10cb19a841d4d Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 12:17:58 -0700 Subject: [PATCH 12/39] resolving []s --- types/custom-function-runtime/custom-function-runtime-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/custom-function-runtime/custom-function-runtime-tests.ts b/types/custom-function-runtime/custom-function-runtime-tests.ts index 47953776b3..d23e2e60e6 100644 --- a/types/custom-function-runtime/custom-function-runtime-tests.ts +++ b/types/custom-function-runtime/custom-function-runtime-tests.ts @@ -3,7 +3,7 @@ function ADD10(n: number) { } declare const CustomFunctionMappings: { - ["addTen"]: ADD10(); + "addTen": ADD10(); }; async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { From 834e29e43ec32a74db44f381d3600d27e03f600d Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 12:19:34 -0700 Subject: [PATCH 13/39] removing tslint comment --- types/office-runtime/index.d.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts index e2974889f5..103ce050ea 100644 --- a/types/office-runtime/index.d.ts +++ b/types/office-runtime/index.d.ts @@ -23,8 +23,7 @@ declare namespace OfficeRuntime { */ const AsyncStorage: AsyncStorage; - - // tslint:disable-next-line:interface-name + /* * Asynchronous, global, and persistent key-value storage that can be used by Excel custom functions. * @beta From 9a70a86938fa0e346f48ff6a904e9192265eb702 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 12:21:00 -0700 Subject: [PATCH 14/39] fixing indents --- types/custom-function-runtime/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/custom-function-runtime/index.d.ts b/types/custom-function-runtime/index.d.ts index 78384f45f4..3bab36de3c 100644 --- a/types/custom-function-runtime/index.d.ts +++ b/types/custom-function-runtime/index.d.ts @@ -26,5 +26,5 @@ declare namespace CustomFunctions { * @beta */ onCanceled: () => void; - } + } } From 227590b7ddd4727ed0d1f986b5d6857f306c149f Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 12:34:39 -0700 Subject: [PATCH 15/39] making update to json so it works --- types/custom-function-runtime/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/custom-function-runtime/tsconfig.json b/types/custom-function-runtime/tsconfig.json index 5c54e3ed5b..0609e72ad0 100644 --- a/types/custom-function-runtime/tsconfig.json +++ b/types/custom-function-runtime/tsconfig.json @@ -14,7 +14,7 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "target": "es6", + "target": "es6" }, "files": [ "index.d.ts", From 67fdb51a92b67e2be47c8294dffe9516603f012f Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 12:46:29 -0700 Subject: [PATCH 16/39] changes to office-runtime --- types/office-runtime/office-runtime-tests.ts | 10 ++-------- types/office-runtime/tsconfig.json | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts index 5cd093aca5..910a8494b2 100644 --- a/types/office-runtime/office-runtime-tests.ts +++ b/types/office-runtime/office-runtime-tests.ts @@ -53,14 +53,8 @@ OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( OfficeRuntime.displayWebDialog("https://localhost:3000", { height: '50', width: '50%', - displayInIFrame: false, - hideTitle: true, -     onMessage: (message, dialog) => { -         console.log(message); -             dialog.close(); -  } - } -) + displayInIFrame: false +}) OfficeRuntime.displayWebDialog("https://localhost:3000", { diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json index 5c54e3ed5b..0609e72ad0 100644 --- a/types/office-runtime/tsconfig.json +++ b/types/office-runtime/tsconfig.json @@ -14,7 +14,7 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "target": "es6", + "target": "es6" }, "files": [ "index.d.ts", From 303526502696c3b05e8697ecf806a5618135e428 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 13:04:02 -0700 Subject: [PATCH 17/39] editing out , in json --- types/custom-function-runtime/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/custom-function-runtime/tsconfig.json b/types/custom-function-runtime/tsconfig.json index 5c54e3ed5b..b3da8763ec 100644 --- a/types/custom-function-runtime/tsconfig.json +++ b/types/custom-function-runtime/tsconfig.json @@ -14,10 +14,10 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "target": "es6", + "target": "es6" }, "files": [ "index.d.ts", "office-runtime-tests.ts" ] -} \ No newline at end of file +} From a90d61163c97734bb857d6e84cb012855a0dca37 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 13:09:53 -0700 Subject: [PATCH 18/39] Editing out the other , I thought I'd fixed locally --- types/office-runtime/tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json index 5c54e3ed5b..b3da8763ec 100644 --- a/types/office-runtime/tsconfig.json +++ b/types/office-runtime/tsconfig.json @@ -14,10 +14,10 @@ "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true, - "target": "es6", + "target": "es6" }, "files": [ "index.d.ts", "office-runtime-tests.ts" ] -} \ No newline at end of file +} From 93b35befe87be0678b0c8eb9b07df8c3b5845fdf Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Thu, 13 Sep 2018 14:15:39 -0700 Subject: [PATCH 19/39] Rename custom-function-runtime-tests.ts to custom-functions-runtime-tests.ts --- ...unction-runtime-tests.ts => custom-functions-runtime-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename types/custom-function-runtime/{custom-function-runtime-tests.ts => custom-functions-runtime-tests.ts} (100%) diff --git a/types/custom-function-runtime/custom-function-runtime-tests.ts b/types/custom-function-runtime/custom-functions-runtime-tests.ts similarity index 100% rename from types/custom-function-runtime/custom-function-runtime-tests.ts rename to types/custom-function-runtime/custom-functions-runtime-tests.ts From 5dc7e31dfb60ac9161b44be3ecedea74e66c30b6 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 14:19:53 -0700 Subject: [PATCH 20/39] updated to functionS --- .../custom-functions-runtime-tests.ts} | 0 .../index.d.ts | 0 .../tsconfig.json | 0 .../tslint.json | 0 4 files changed, 0 insertions(+), 0 deletions(-) rename types/{custom-function-runtime/custom-function-runtime-tests.ts => custom-functions-runtime/custom-functions-runtime-tests.ts} (100%) rename types/{custom-function-runtime => custom-functions-runtime}/index.d.ts (100%) rename types/{custom-function-runtime => custom-functions-runtime}/tsconfig.json (100%) rename types/{custom-function-runtime => custom-functions-runtime}/tslint.json (100%) diff --git a/types/custom-function-runtime/custom-function-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts similarity index 100% rename from types/custom-function-runtime/custom-function-runtime-tests.ts rename to types/custom-functions-runtime/custom-functions-runtime-tests.ts diff --git a/types/custom-function-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts similarity index 100% rename from types/custom-function-runtime/index.d.ts rename to types/custom-functions-runtime/index.d.ts diff --git a/types/custom-function-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json similarity index 100% rename from types/custom-function-runtime/tsconfig.json rename to types/custom-functions-runtime/tsconfig.json diff --git a/types/custom-function-runtime/tslint.json b/types/custom-functions-runtime/tslint.json similarity index 100% rename from types/custom-function-runtime/tslint.json rename to types/custom-functions-runtime/tslint.json From 5ef968bffe590447cceaeaeb5702b72d43e70460 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 14:24:21 -0700 Subject: [PATCH 21/39] changing folder name --- .../custom-functions-runtime-tests.ts | 32 ++++++++ types/custom-functions-runtime/index.d.ts | 30 +++++++ types/custom-functions-runtime/tsconfig.json | 23 ++++++ types/custom-functions-runtime/tslint.json | 79 +++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts create mode 100644 types/custom-functions-runtime/index.d.ts create mode 100644 types/custom-functions-runtime/tsconfig.json create mode 100644 types/custom-functions-runtime/tslint.json diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts new file mode 100644 index 0000000000..d23e2e60e6 --- /dev/null +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -0,0 +1,32 @@ +function ADD10(n: number) { + return n + 10; +} + +declare const CustomFunctionMappings: { + "addTen": ADD10(); +}; + +async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + handler.setResult(dollars) +} + +async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { + var shouldStop = false; + handler.onCanceled = () => shouldStop = true; + await pause(1000); + + if (shouldStop) { + return null; + } + + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +async function getStockValuesNowWithNoCancelling(ticker: string) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +declare function pause(ms: number): Promise diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts new file mode 100644 index 0000000000..3bab36de3c --- /dev/null +++ b/types/custom-functions-runtime/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for Custom Functions +// Project: http://dev.office.com +// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/* +office-js +Copyright (c) Microsoft Corporation +*/ + +declare const CustomFunctionMappings: { [key: string]: Function }; + +declare namespace CustomFunctions { + interface StreamingHandler extends CancelableHandler { + /* + * Sets the returned result for a streaming custom function. + * @beta + */ + setResult: (value: T) => void; + } + + interface CancelableHandler { + /* + * Handles what should occur when a custom function is canceled. + * @beta + */ + onCanceled: () => void; + } +} diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json new file mode 100644 index 0000000000..b3da8763ec --- /dev/null +++ b/types/custom-functions-runtime/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "target": "es6" + }, + "files": [ + "index.d.ts", + "office-runtime-tests.ts" + ] +} diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json new file mode 100644 index 0000000000..5c50b51e66 --- /dev/null +++ b/types/custom-functions-runtime/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} \ No newline at end of file From 39cd8a54cd0bbd265415980ce7076afd45ee2383 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Thu, 13 Sep 2018 17:32:08 -0700 Subject: [PATCH 22/39] trying to delete just office runtime --- .../custom-functions-runtime-tests.ts | 32 ---- types/custom-function-runtime/index.d.ts | 30 ---- types/custom-function-runtime/tsconfig.json | 23 --- types/custom-function-runtime/tslint.json | 79 --------- types/office-runtime/index.d.ts | 154 ------------------ types/office-runtime/office-runtime-tests.ts | 77 --------- types/office-runtime/tsconfig.json | 23 --- types/office-runtime/tslint.json | 79 --------- 8 files changed, 497 deletions(-) delete mode 100644 types/custom-function-runtime/custom-functions-runtime-tests.ts delete mode 100644 types/custom-function-runtime/index.d.ts delete mode 100644 types/custom-function-runtime/tsconfig.json delete mode 100644 types/custom-function-runtime/tslint.json delete mode 100644 types/office-runtime/index.d.ts delete mode 100644 types/office-runtime/office-runtime-tests.ts delete mode 100644 types/office-runtime/tsconfig.json delete mode 100644 types/office-runtime/tslint.json diff --git a/types/custom-function-runtime/custom-functions-runtime-tests.ts b/types/custom-function-runtime/custom-functions-runtime-tests.ts deleted file mode 100644 index d23e2e60e6..0000000000 --- a/types/custom-function-runtime/custom-functions-runtime-tests.ts +++ /dev/null @@ -1,32 +0,0 @@ -function ADD10(n: number) { - return n + 10; -} - -declare const CustomFunctionMappings: { - "addTen": ADD10(); -}; - -async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) -} - -async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; - handler.onCanceled = () => shouldStop = true; - await pause(1000); - - if (shouldStop) { - return null; - } - - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -async function getStockValuesNowWithNoCancelling(ticker: string) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -declare function pause(ms: number): Promise diff --git a/types/custom-function-runtime/index.d.ts b/types/custom-function-runtime/index.d.ts deleted file mode 100644 index 3bab36de3c..0000000000 --- a/types/custom-function-runtime/index.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Type definitions for Custom Functions -// Project: http://dev.office.com -// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 - -/* -office-js -Copyright (c) Microsoft Corporation -*/ - -declare const CustomFunctionMappings: { [key: string]: Function }; - -declare namespace CustomFunctions { - interface StreamingHandler extends CancelableHandler { - /* - * Sets the returned result for a streaming custom function. - * @beta - */ - setResult: (value: T) => void; - } - - interface CancelableHandler { - /* - * Handles what should occur when a custom function is canceled. - * @beta - */ - onCanceled: () => void; - } -} diff --git a/types/custom-function-runtime/tsconfig.json b/types/custom-function-runtime/tsconfig.json deleted file mode 100644 index b3da8763ec..0000000000 --- a/types/custom-function-runtime/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "target": "es6" - }, - "files": [ - "index.d.ts", - "office-runtime-tests.ts" - ] -} diff --git a/types/custom-function-runtime/tslint.json b/types/custom-function-runtime/tslint.json deleted file mode 100644 index 5c50b51e66..0000000000 --- a/types/custom-function-runtime/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts deleted file mode 100644 index 103ce050ea..0000000000 --- a/types/office-runtime/index.d.ts +++ /dev/null @@ -1,154 +0,0 @@ -// Type definitions for office-runtime -// Project: http://dev.office.com/ -// Definitions by: Michael Zlatskovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Typescript Version: 2.4 - -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -/* -OfficeRuntime defines a new runtime which can be used by Excel custom functions. -*/ -declare namespace OfficeRuntime { - /* - A function which allows you to use a dialog box in Office Runtime, which can be used by Excel custom functions. - */ - function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; - - /* - * Defines the AsyncStorage constant which allows asynchronous, global, and persistent key-value storage which can be used by Excel custom functions. - */ - - const AsyncStorage: AsyncStorage; - - /* - * Asynchronous, global, and persistent key-value storage that can be used by Excel custom functions. - * @beta - * - * @remarks - * Each add-in instance has its own storage partition, unique to a user and their device. - * - * The default amount of total storage allowed per add-in is 5MB. - * - * Each method listed below returns a Promise object. - * - */ - interface AsyncStorage { - /* - * @beta - * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. - * - */ - getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; - /* - * @beta - * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. - * - */ - setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; - /* - * @beta - * Removes an item for specified key and invokes a callback when finished. Returns a Promise. - * - * - */ - removeItem(key: string, callback?: (error?: Error) => void): Promise; - /* - * @beta - * Erases all AsyncStorage. Returns a Promise. - * - */ - clear(callback?: (error?: Error) => void): Promise; - /* - * @beta - * Returns a Promise with all keys for your custom function. - * - */ - getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; - /* - * @beta - * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. - * - */ - multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; - /* - * @beta - * Deletes a batch of keys, specified in the `keys` array. - * - */ - multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise;/** - /* - * @beta - * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. - * - */ - multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; - } - - /* - * @beta - * Object representing the dialog box. - * - */ - interface Dialog { - /* - * @beta - * Method that closes a dialog box. - */ - close(): Promise; - } - - /* - * - * Provides options for how a dialog is displayed. - * - */ - interface DisplayWebDialogOptions { - /* - * @beta - * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. - * - */ - displayInIFrame?: boolean; - /* - * @beta - * Defines the height of the dialog box as a percentage of the current display. - * - */ - height?: string; - - /* - * @beta - * Defines the width of the dialog box as a percentage of the current display. - * - */ - width?: string; - - /* - * @beta - * Callback that is run when the dialog box sends a message to its parent. - * - * - */ - onMessage?: (message: string, dialog?: Dialog) => void; - - /* - * @beta - * Callback that is run when the dialog box is closed. - * - * - */ - onClose?: () => void; - - /* - * @beta - * Callback that is run when the dialog box sends an error. - * - * - */ - onRuntimeError?: (error: Error, dialog?: Dialog) => void; - } - } diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts deleted file mode 100644 index 5cd093aca5..0000000000 --- a/types/office-runtime/office-runtime-tests.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -OfficeRuntime.AsyncStorage.getItem("foo", () => { - //perform an action -}) -OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.setItem("foo", "bar"); -OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)) - -OfficeRuntime.AsyncStorage.removeItem("foo"); -OfficeRuntime.AsyncStorage.removeItem("foo", () => { - //perform an action -}) - -OfficeRuntime.AsyncStorage.clear(); -OfficeRuntime.AsyncStorage.clear(() => { - //perform an action -}) - -OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { - keys.forEach(item => console.log(item)); -}) -OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { - if (error) { - console.error(error); - } else { - keys.forEach(item => console.log(item)); - } -}) - -OfficeRuntime.AsyncStorage.multiSet( - [["username", "foo"], ["yearOfBirth", "2001"]], - errors => { - errors.filter(error => error != null).forEach(error => console.log(error)); - } -) - -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( - values => { - console.log(values[0][1]) - console.log(values[1][1]) - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - height: '50', - width: '50%', - displayInIFrame: false, - hideTitle: true, -     onMessage: (message, dialog) => { -         console.log(message); -             dialog.close(); -  } - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onClose: () => { - console.log("closed"); - } -}) - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onRuntimeError: (error, dialog) => { - console.log(error); - dialog.close(); - } -}) diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json deleted file mode 100644 index b3da8763ec..0000000000 --- a/types/office-runtime/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "target": "es6" - }, - "files": [ - "index.d.ts", - "office-runtime-tests.ts" - ] -} diff --git a/types/office-runtime/tslint.json b/types/office-runtime/tslint.json deleted file mode 100644 index 5c50b51e66..0000000000 --- a/types/office-runtime/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file From 81d2dbd04f56292524247b6d7dba74ea808e12c0 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 09:49:11 -0700 Subject: [PATCH 23/39] getting rid of cfs and only having office-runtime --- .../custom-functions-runtime-tests.ts | 32 -------- types/custom-functions-runtime/index.d.ts | 30 ------- types/custom-functions-runtime/tsconfig.json | 23 ------ types/custom-functions-runtime/tslint.json | 79 ------------------- 4 files changed, 164 deletions(-) delete mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts delete mode 100644 types/custom-functions-runtime/index.d.ts delete mode 100644 types/custom-functions-runtime/tsconfig.json delete mode 100644 types/custom-functions-runtime/tslint.json diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts deleted file mode 100644 index d23e2e60e6..0000000000 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ /dev/null @@ -1,32 +0,0 @@ -function ADD10(n: number) { - return n + 10; -} - -declare const CustomFunctionMappings: { - "addTen": ADD10(); -}; - -async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) -} - -async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; - handler.onCanceled = () => shouldStop = true; - await pause(1000); - - if (shouldStop) { - return null; - } - - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -async function getStockValuesNowWithNoCancelling(ticker: string) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -declare function pause(ms: number): Promise diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts deleted file mode 100644 index 3bab36de3c..0000000000 --- a/types/custom-functions-runtime/index.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Type definitions for Custom Functions -// Project: http://dev.office.com -// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 - -/* -office-js -Copyright (c) Microsoft Corporation -*/ - -declare const CustomFunctionMappings: { [key: string]: Function }; - -declare namespace CustomFunctions { - interface StreamingHandler extends CancelableHandler { - /* - * Sets the returned result for a streaming custom function. - * @beta - */ - setResult: (value: T) => void; - } - - interface CancelableHandler { - /* - * Handles what should occur when a custom function is canceled. - * @beta - */ - onCanceled: () => void; - } -} diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json deleted file mode 100644 index b3da8763ec..0000000000 --- a/types/custom-functions-runtime/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "target": "es6" - }, - "files": [ - "index.d.ts", - "office-runtime-tests.ts" - ] -} diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json deleted file mode 100644 index 5c50b51e66..0000000000 --- a/types/custom-functions-runtime/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file From 4f528489961fe0c9c60724b2a03698832cc1e541 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 10:16:04 -0700 Subject: [PATCH 24/39] removing custom-functions-runtime --- .../custom-functions-runtime-tests.ts | 32 -------- types/custom-functions-runtime/index.d.ts | 30 ------- types/custom-functions-runtime/tsconfig.json | 23 ------ types/custom-functions-runtime/tslint.json | 79 ------------------- 4 files changed, 164 deletions(-) delete mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts delete mode 100644 types/custom-functions-runtime/index.d.ts delete mode 100644 types/custom-functions-runtime/tsconfig.json delete mode 100644 types/custom-functions-runtime/tslint.json diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts deleted file mode 100644 index d23e2e60e6..0000000000 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ /dev/null @@ -1,32 +0,0 @@ -function ADD10(n: number) { - return n + 10; -} - -declare const CustomFunctionMappings: { - "addTen": ADD10(); -}; - -async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) -} - -async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; - handler.onCanceled = () => shouldStop = true; - await pause(1000); - - if (shouldStop) { - return null; - } - - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -async function getStockValuesNowWithNoCancelling(ticker: string) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -declare function pause(ms: number): Promise diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts deleted file mode 100644 index 3bab36de3c..0000000000 --- a/types/custom-functions-runtime/index.d.ts +++ /dev/null @@ -1,30 +0,0 @@ -// Type definitions for Custom Functions -// Project: http://dev.office.com -// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.4 - -/* -office-js -Copyright (c) Microsoft Corporation -*/ - -declare const CustomFunctionMappings: { [key: string]: Function }; - -declare namespace CustomFunctions { - interface StreamingHandler extends CancelableHandler { - /* - * Sets the returned result for a streaming custom function. - * @beta - */ - setResult: (value: T) => void; - } - - interface CancelableHandler { - /* - * Handles what should occur when a custom function is canceled. - * @beta - */ - onCanceled: () => void; - } -} diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json deleted file mode 100644 index b3da8763ec..0000000000 --- a/types/custom-functions-runtime/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "target": "es6" - }, - "files": [ - "index.d.ts", - "office-runtime-tests.ts" - ] -} diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json deleted file mode 100644 index 5c50b51e66..0000000000 --- a/types/custom-functions-runtime/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file From 664c623c087367d0bf0422ae90b6380cfdfe7606 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 10:17:53 -0700 Subject: [PATCH 25/39] deleting officeruntime so I can recreate it properly --- types/office-runtime/office-runtime-tests.ts | 71 -------------------- 1 file changed, 71 deletions(-) delete mode 100644 types/office-runtime/office-runtime-tests.ts diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts deleted file mode 100644 index 910a8494b2..0000000000 --- a/types/office-runtime/office-runtime-tests.ts +++ /dev/null @@ -1,71 +0,0 @@ -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -OfficeRuntime.AsyncStorage.getItem("foo", () => { - //perform an action -}) -OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.setItem("foo", "bar"); -OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)) - -OfficeRuntime.AsyncStorage.removeItem("foo"); -OfficeRuntime.AsyncStorage.removeItem("foo", () => { - //perform an action -}) - -OfficeRuntime.AsyncStorage.clear(); -OfficeRuntime.AsyncStorage.clear(() => { - //perform an action -}) - -OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { - keys.forEach(item => console.log(item)); -}) -OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { - if (error) { - console.error(error); - } else { - keys.forEach(item => console.log(item)); - } -}) - -OfficeRuntime.AsyncStorage.multiSet( - [["username", "foo"], ["yearOfBirth", "2001"]], - errors => { - errors.filter(error => error != null).forEach(error => console.log(error)); - } -) - -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( - values => { - console.log(values[0][1]) - console.log(values[1][1]) - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - height: '50', - width: '50%', - displayInIFrame: false -}) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onClose: () => { - console.log("closed"); - } -}) - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onRuntimeError: (error, dialog) => { - console.log(error); - dialog.close(); - } -}) From 3f604e91ae271eb7b0e79549066e134b3d45af6d Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 11:37:46 -0700 Subject: [PATCH 26/39] adding office-runtime folder --- types/office-runtime/index.d.ts | 155 +++++++++++++++++++ types/office-runtime/office-runtime-tests.ts | 77 +++++++++ types/office-runtime/tsconfig.json | 23 +++ types/office-runtime/tslint.json | 79 ++++++++++ 4 files changed, 334 insertions(+) create mode 100644 types/office-runtime/index.d.ts create mode 100644 types/office-runtime/office-runtime-tests.ts create mode 100644 types/office-runtime/tsconfig.json create mode 100644 types/office-runtime/tslint.json diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts new file mode 100644 index 0000000000..4e45c8dc82 --- /dev/null +++ b/types/office-runtime/index.d.ts @@ -0,0 +1,155 @@ +// Type definitions for office-runtime +// Project: http://dev.office.com/ +// Definitions by: Michael Zlatskovsky , Michelle Scharlock +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// Typescript Version: 2.4 + +/* +office-runtime +Copyright (c) Microsoft Corporation +*/ + +declare namespace OfficeRuntime { + function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; + const AsyncStorage: AsyncStorage; + + // tslint:disable-next-line:interface-name + /** + * Asynchronous, global, and persistent key-value storage for Excel Custom Functions only. + * @beta + * + * @remarks + * Each add-in instance has its own storage partition, unique to a user and their device. + * + * The default amount of total storage allowed per add-in is 5MB. + * + * Each method listed below returns a Promise object. + * + */ + interface AsyncStorage { + /** + * @beta + * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. + * + */ + getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; + /** + * @beta + * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. + * + */ + setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; + /** + * @beta + * Removes an item for specified key and invokes a callback when finished. Returns a Promise. + * + * + */ + removeItem(key: string, callback?: (error?: Error) => void): Promise; + /** + * @beta + * Erases all AsyncStorage. Returns a Promise. + * + */ + clear(callback?: (error?: Error) => void): Promise; + /** + * @beta + * Returns a Promise with all keys for your custom function. + * + */ + getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; + /** + * @beta + * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. + * + */ + multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; + /** + * @beta + * Deletes a batch of keys, specified in the `keys` array. + * + */ + multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise;/** + /** + * @beta + * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. + * + */ + multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; + } + + /** + * @beta + * Object representing the dialog box for Excel Custom Functions only. + * + */ + interface Dialog { + /** + * @beta + * Method that closes a dialog box. + */ + close(): Promise; + } + + /** + * + * Provides options for how a dialog is displayed for Excel Custom Functions only. + * + */ + interface DisplayWebDialogOptions { + /** + * @beta + * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. + * + * [Api set: Dialog 1.2] + */ + displayInIFrame?: boolean; + /** + * @beta + * Defines the height of the dialog box as a percentage of the current display. + * + * [Api set: Dialog 1.2] + */ + height?: string; + + /** + * @beta + * Defines the width of the dialog box as a percentage of the current display. + * + * [Api set: Dialog 1.2] + */ + width?: string; + + /** + * @beta + * True if title is hidden from the dialog box. + * + * [Api set: Dialog 1.2] + */ + hideTitle?: boolean; + + /** + * @beta + * Callback that is run when the dialog box sends a message to its parent. + * + * + */ + onMessage?: (message: string, dialog?: Dialog) => void; + + /** + * @beta + * Callback that is run when the dialog box is closed. + * + * + */ + onClose?: () => void; + + /** + * @beta + * Callback that is run when the dialog box sends an error. + * + * + */ + onRuntimeError?: (error: Error, dialog?: Dialog) => void; + } + } diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts new file mode 100644 index 0000000000..a8d8f09675 --- /dev/null +++ b/types/office-runtime/office-runtime-tests.ts @@ -0,0 +1,77 @@ +/* +office-runtime +Copyright (c) Microsoft Corporation +*/ + +OfficeRuntime.AsyncStorage.getItem("foo", () => { + //do a thing +}) +OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) + +OfficeRuntime.AsyncStorage.setItem("foo", "bar"); +OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)) + +OfficeRuntime.AsyncStorage.removeItem("foo"); +OfficeRuntime.AsyncStorage.removeItem("foo", () => { + //do a thing +}) + +OfficeRuntime.AsyncStorage.clear(); +OfficeRuntime.AsyncStorage.clear(() => { + //do a thing +}) + +OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { + keys.forEach(item => console.log(item)); +}) +OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { + if (error) { + console.error(error); + } else { + keys.forEach(item => console.log(item)); + } +}) + +OfficeRuntime.AsyncStorage.multiSet( + [["username", "foo"], ["yearOfBirth", "2001"]], + errors => { + errors.filter(error => error != null).forEach(error => console.log(error)); + } +) + +OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); +OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)) + +OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( + values => { + console.log(values[0][1]) + console.log(values[1][1]) + } +) + + +OfficeRuntime.displayWebDialog("https://localhost:3000", { + height: '50', + width: '50%', + displayInIFrame: false, + hideTitle: true, +     onMessage: (message, dialog) => { +         console.log(message); +             dialog.close(); +             } + } +) + + +OfficeRuntime.displayWebDialog("https://localhost:3000", { + onClose: () => { + console.log("closed"); + } +}) + +OfficeRuntime.displayWebDialog("https://localhost:3000", { + onRuntimeError: (error, dialog) => { + console.log(error); + dialog.close(); + } +}) \ No newline at end of file diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json new file mode 100644 index 0000000000..0609e72ad0 --- /dev/null +++ b/types/office-runtime/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "target": "es6" + }, + "files": [ + "index.d.ts", + "office-runtime-tests.ts" + ] +} \ No newline at end of file diff --git a/types/office-runtime/tslint.json b/types/office-runtime/tslint.json new file mode 100644 index 0000000000..5c50b51e66 --- /dev/null +++ b/types/office-runtime/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} \ No newline at end of file From e4928b84bcb018dbc872107c6aa8d6c83fc5b8d4 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:28:51 -0700 Subject: [PATCH 27/39] adding custom functions --- .../custom-functions-runtime-tests.ts | 32 ++++++++ types/custom-functions-runtime/index.d.ts | 30 +++++++ types/custom-functions-runtime/tsconfig.json | 23 ++++++ types/custom-functions-runtime/tslint.json | 79 +++++++++++++++++++ 4 files changed, 164 insertions(+) create mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts create mode 100644 types/custom-functions-runtime/index.d.ts create mode 100644 types/custom-functions-runtime/tsconfig.json create mode 100644 types/custom-functions-runtime/tslint.json diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts new file mode 100644 index 0000000000..d23e2e60e6 --- /dev/null +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -0,0 +1,32 @@ +function ADD10(n: number) { + return n + 10; +} + +declare const CustomFunctionMappings: { + "addTen": ADD10(); +}; + +async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + handler.setResult(dollars) +} + +async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { + var shouldStop = false; + handler.onCanceled = () => shouldStop = true; + await pause(1000); + + if (shouldStop) { + return null; + } + + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +async function getStockValuesNowWithNoCancelling(ticker: string) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +declare function pause(ms: number): Promise diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts new file mode 100644 index 0000000000..3bab36de3c --- /dev/null +++ b/types/custom-functions-runtime/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for Custom Functions +// Project: http://dev.office.com +// Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + +/* +office-js +Copyright (c) Microsoft Corporation +*/ + +declare const CustomFunctionMappings: { [key: string]: Function }; + +declare namespace CustomFunctions { + interface StreamingHandler extends CancelableHandler { + /* + * Sets the returned result for a streaming custom function. + * @beta + */ + setResult: (value: T) => void; + } + + interface CancelableHandler { + /* + * Handles what should occur when a custom function is canceled. + * @beta + */ + onCanceled: () => void; + } +} diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json new file mode 100644 index 0000000000..b3da8763ec --- /dev/null +++ b/types/custom-functions-runtime/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "target": "es6" + }, + "files": [ + "index.d.ts", + "office-runtime-tests.ts" + ] +} diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json new file mode 100644 index 0000000000..5c50b51e66 --- /dev/null +++ b/types/custom-functions-runtime/tslint.json @@ -0,0 +1,79 @@ +{ + "extends": "dtslint/dt.json", + "rules": { + "adjacent-overload-signatures": false, + "array-type": false, + "arrow-return-shorthand": false, + "ban-types": false, + "callable-types": false, + "comment-format": false, + "dt-header": false, + "eofline": false, + "export-just-namespace": false, + "import-spacing": false, + "interface-name": false, + "interface-over-type-literal": false, + "jsdoc-format": false, + "max-line-length": false, + "member-access": false, + "new-parens": false, + "no-any-union": false, + "no-boolean-literal-compare": false, + "no-conditional-assignment": false, + "no-consecutive-blank-lines": false, + "no-construct": false, + "no-declare-current-package": false, + "no-duplicate-imports": false, + "no-duplicate-variable": false, + "no-empty-interface": false, + "no-for-in-array": false, + "no-inferrable-types": false, + "no-internal-module": false, + "no-irregular-whitespace": false, + "no-mergeable-namespace": false, + "no-misused-new": false, + "no-namespace": false, + "no-object-literal-type-assertion": false, + "no-padding": false, + "no-redundant-jsdoc": false, + "no-redundant-jsdoc-2": false, + "no-redundant-undefined": false, + "no-reference-import": false, + "no-relative-import-in-test": false, + "no-self-import": false, + "no-single-declare-module": false, + "no-string-throw": false, + "no-unnecessary-callback-wrapper": false, + "no-unnecessary-class": false, + "no-unnecessary-generics": false, + "no-unnecessary-qualifier": false, + "no-unnecessary-type-assertion": false, + "no-useless-files": false, + "no-var-keyword": false, + "no-var-requires": false, + "no-void-expression": false, + "no-trailing-whitespace": false, + "object-literal-key-quotes": false, + "object-literal-shorthand": false, + "one-line": false, + "one-variable-per-declaration": false, + "only-arrow-functions": false, + "prefer-conditional-expression": false, + "prefer-const": false, + "prefer-declare-function": false, + "prefer-for-of": false, + "prefer-method-signature": false, + "prefer-template": false, + "radix": false, + "semicolon": false, + "space-before-function-paren": false, + "space-within-parens": false, + "strict-export-declare-modifiers": false, + "trim-file": false, + "triple-equals": false, + "typedef-whitespace": false, + "unified-signatures": false, + "void-return": false, + "whitespace": false + } +} \ No newline at end of file From 2bc6766ea52b9f3fb7fdceb5a3755436f5bd1a52 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:30:08 -0700 Subject: [PATCH 28/39] removed office runtime --- types/office-runtime/index.d.ts | 155 ------------------- types/office-runtime/office-runtime-tests.ts | 77 --------- types/office-runtime/tsconfig.json | 23 --- types/office-runtime/tslint.json | 79 ---------- 4 files changed, 334 deletions(-) delete mode 100644 types/office-runtime/index.d.ts delete mode 100644 types/office-runtime/office-runtime-tests.ts delete mode 100644 types/office-runtime/tsconfig.json delete mode 100644 types/office-runtime/tslint.json diff --git a/types/office-runtime/index.d.ts b/types/office-runtime/index.d.ts deleted file mode 100644 index 4e45c8dc82..0000000000 --- a/types/office-runtime/index.d.ts +++ /dev/null @@ -1,155 +0,0 @@ -// Type definitions for office-runtime -// Project: http://dev.office.com/ -// Definitions by: Michael Zlatskovsky , Michelle Scharlock -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// Typescript Version: 2.4 - -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -declare namespace OfficeRuntime { - function displayWebDialog(url: string, options: DisplayWebDialogOptions): Promise; - const AsyncStorage: AsyncStorage; - - // tslint:disable-next-line:interface-name - /** - * Asynchronous, global, and persistent key-value storage for Excel Custom Functions only. - * @beta - * - * @remarks - * Each add-in instance has its own storage partition, unique to a user and their device. - * - * The default amount of total storage allowed per add-in is 5MB. - * - * Each method listed below returns a Promise object. - * - */ - interface AsyncStorage { - /** - * @beta - * Retrieves an object based on a key and invokes a callback when finished. Returns a Promise. - * - */ - getItem(key: string, callback?: (error?: Error, result?: string) => void): Promise; - /** - * @beta - * Assigns the value for a key-value pair and invokes a callback when finished. Returns a Promise. - * - */ - setItem(key: string, value: string, callback?: (error?: Error) => void): Promise; - /** - * @beta - * Removes an item for specified key and invokes a callback when finished. Returns a Promise. - * - * - */ - removeItem(key: string, callback?: (error?: Error) => void): Promise; - /** - * @beta - * Erases all AsyncStorage. Returns a Promise. - * - */ - clear(callback?: (error?: Error) => void): Promise; - /** - * @beta - * Returns a Promise with all keys for your custom function. - * - */ - getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise; - /** - * @beta - * Stores multiple key-value pairs in one batch. Returns a Promise. When a key doesn't exist, returns null. - * - */ - multiSet(keyValuePairs: string[][], callback?: (errors?: Error[]) => void): Promise; - /** - * @beta - * Deletes a batch of keys, specified in the `keys` array. - * - */ - multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise;/** - /** - * @beta - * Fetches a batch of keys, specified in the `keys` array. When a key doesn't exist, returns null. - * - */ - multiGet(keys: string[], callback?: (errors?: Error[], result?: string[][]) => void): Promise; - } - - /** - * @beta - * Object representing the dialog box for Excel Custom Functions only. - * - */ - interface Dialog { - /** - * @beta - * Method that closes a dialog box. - */ - close(): Promise; - } - - /** - * - * Provides options for how a dialog is displayed for Excel Custom Functions only. - * - */ - interface DisplayWebDialogOptions { - /** - * @beta - * Determines whether the dialog box displays as a popup (false) or within an IFrame (true). This setting is only applicable to custom functions running on Excel Online. - * - * [Api set: Dialog 1.2] - */ - displayInIFrame?: boolean; - /** - * @beta - * Defines the height of the dialog box as a percentage of the current display. - * - * [Api set: Dialog 1.2] - */ - height?: string; - - /** - * @beta - * Defines the width of the dialog box as a percentage of the current display. - * - * [Api set: Dialog 1.2] - */ - width?: string; - - /** - * @beta - * True if title is hidden from the dialog box. - * - * [Api set: Dialog 1.2] - */ - hideTitle?: boolean; - - /** - * @beta - * Callback that is run when the dialog box sends a message to its parent. - * - * - */ - onMessage?: (message: string, dialog?: Dialog) => void; - - /** - * @beta - * Callback that is run when the dialog box is closed. - * - * - */ - onClose?: () => void; - - /** - * @beta - * Callback that is run when the dialog box sends an error. - * - * - */ - onRuntimeError?: (error: Error, dialog?: Dialog) => void; - } - } diff --git a/types/office-runtime/office-runtime-tests.ts b/types/office-runtime/office-runtime-tests.ts deleted file mode 100644 index a8d8f09675..0000000000 --- a/types/office-runtime/office-runtime-tests.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* -office-runtime -Copyright (c) Microsoft Corporation -*/ - -OfficeRuntime.AsyncStorage.getItem("foo", () => { - //do a thing -}) -OfficeRuntime.AsyncStorage.getItem("foo").then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.setItem("foo", "bar"); -OfficeRuntime.AsyncStorage.setItem("foo", "bar").then(error => console.log(error)) - -OfficeRuntime.AsyncStorage.removeItem("foo"); -OfficeRuntime.AsyncStorage.removeItem("foo", () => { - //do a thing -}) - -OfficeRuntime.AsyncStorage.clear(); -OfficeRuntime.AsyncStorage.clear(() => { - //do a thing -}) - -OfficeRuntime.AsyncStorage.getAllKeys().then(keys => { - keys.forEach(item => console.log(item)); -}) -OfficeRuntime.AsyncStorage.getAllKeys((error, keys) => { - if (error) { - console.error(error); - } else { - keys.forEach(item => console.log(item)); - } -}) - -OfficeRuntime.AsyncStorage.multiSet( - [["username", "foo"], ["yearOfBirth", "2001"]], - errors => { - errors.filter(error => error != null).forEach(error => console.log(error)); - } -) - -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]); -OfficeRuntime.AsyncStorage.multiRemove(["foo", "bar"]).then(value => console.log(value)) - -OfficeRuntime.AsyncStorage.multiGet(["username", "yearOfBirth"]).then( - values => { - console.log(values[0][1]) - console.log(values[1][1]) - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - height: '50', - width: '50%', - displayInIFrame: false, - hideTitle: true, -     onMessage: (message, dialog) => { -         console.log(message); -             dialog.close(); -             } - } -) - - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onClose: () => { - console.log("closed"); - } -}) - -OfficeRuntime.displayWebDialog("https://localhost:3000", { - onRuntimeError: (error, dialog) => { - console.log(error); - dialog.close(); - } -}) \ No newline at end of file diff --git a/types/office-runtime/tsconfig.json b/types/office-runtime/tsconfig.json deleted file mode 100644 index 0609e72ad0..0000000000 --- a/types/office-runtime/tsconfig.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "compilerOptions": { - "module": "commonjs", - "lib": [ - "es6", - "dom" - ], - "noImplicitAny": true, - "noImplicitThis": true, - "strictNullChecks": false, - "strictFunctionTypes": true, - "baseUrl": "../", - "typeRoots": ["../"], - "types": [], - "noEmit": true, - "forceConsistentCasingInFileNames": true, - "target": "es6" - }, - "files": [ - "index.d.ts", - "office-runtime-tests.ts" - ] -} \ No newline at end of file diff --git a/types/office-runtime/tslint.json b/types/office-runtime/tslint.json deleted file mode 100644 index 5c50b51e66..0000000000 --- a/types/office-runtime/tslint.json +++ /dev/null @@ -1,79 +0,0 @@ -{ - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file From 1def2646d99d0776bec722e3b390e70eadcb59cc Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:32:50 -0700 Subject: [PATCH 29/39] renaming file --- .../custom-functions-runtime-tests.ts | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts deleted file mode 100644 index d23e2e60e6..0000000000 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ /dev/null @@ -1,32 +0,0 @@ -function ADD10(n: number) { - return n + 10; -} - -declare const CustomFunctionMappings: { - "addTen": ADD10(); -}; - -async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) -} - -async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; - handler.onCanceled = () => shouldStop = true; - await pause(1000); - - if (shouldStop) { - return null; - } - - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -async function getStockValuesNowWithNoCancelling(ticker: string) { - const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - return dollars; -} - -declare function pause(ms: number): Promise From 2d4a4a2b63b7af3b861b2903d4a20cee686817ab Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:33:57 -0700 Subject: [PATCH 30/39] AHA finally fixing error --- types/custom-functions-runtime/tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/custom-functions-runtime/tsconfig.json b/types/custom-functions-runtime/tsconfig.json index b3da8763ec..3c8cbbaf27 100644 --- a/types/custom-functions-runtime/tsconfig.json +++ b/types/custom-functions-runtime/tsconfig.json @@ -18,6 +18,6 @@ }, "files": [ "index.d.ts", - "office-runtime-tests.ts" + "custom-functions-runtime-tests.ts" ] } From 45c99bd450b06254c9bdcfc1f0b2a20c66f3842d Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 14:34:54 -0700 Subject: [PATCH 31/39] making it ts --- .../custom-functions-runtime-tests.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 types/custom-functions-runtime/custom-functions-runtime-tests.ts diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts new file mode 100644 index 0000000000..d23e2e60e6 --- /dev/null +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -0,0 +1,32 @@ +function ADD10(n: number) { + return n + 10; +} + +declare const CustomFunctionMappings: { + "addTen": ADD10(); +}; + +async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + handler.setResult(dollars) +} + +async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { + var shouldStop = false; + handler.onCanceled = () => shouldStop = true; + await pause(1000); + + if (shouldStop) { + return null; + } + + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +async function getStockValuesNowWithNoCancelling(ticker: string) { + const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); + return dollars; +} + +declare function pause(ms: number): Promise From 1de741110df077610c545f26db3debe99319e740 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 15:08:55 -0700 Subject: [PATCH 32/39] Ok CFMapp now doesn't have errors but tests still not working --- .../custom-functions-runtime/custom-functions-runtime-tests.ts | 3 ++- types/custom-functions-runtime/index.d.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index d23e2e60e6..0cdec4960a 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -2,7 +2,7 @@ function ADD10(n: number) { return n + 10; } -declare const CustomFunctionMappings: { +const CustomFunctionMappings: { "addTen": ADD10(); }; @@ -30,3 +30,4 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { } declare function pause(ms: number): Promise +n \ No newline at end of file diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index 3bab36de3c..0173a4d0ed 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -9,7 +9,7 @@ office-js Copyright (c) Microsoft Corporation */ -declare const CustomFunctionMappings: { [key: string]: Function }; +declare let CustomFunctionMappings: { [key: string]: Function }; declare namespace CustomFunctions { interface StreamingHandler extends CancelableHandler { From 51363d2e62481891fa71ed5362ca8d17f11bc50d Mon Sep 17 00:00:00 2001 From: mscharlock Date: Fri, 14 Sep 2018 15:13:54 -0700 Subject: [PATCH 33/39] update to tests so it now runs --- .../custom-functions-runtime-tests.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 0cdec4960a..4882c6bcd2 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -2,8 +2,8 @@ function ADD10(n: number) { return n + 10; } -const CustomFunctionMappings: { - "addTen": ADD10(); +CustomFunctionMappings = { + "addTen": ADD10 }; async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { @@ -30,4 +30,3 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { } declare function pause(ms: number): Promise -n \ No newline at end of file From 130faec254a0be3139c310fccf9b12d94fc932f9 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Mon, 17 Sep 2018 09:52:24 -0700 Subject: [PATCH 34/39] Getting rid of excessive lint things --- types/custom-functions-runtime/tslint.json | 80 +--------------------- 1 file changed, 2 insertions(+), 78 deletions(-) diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index 5c50b51e66..f93cf8562a 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,79 +1,3 @@ { - "extends": "dtslint/dt.json", - "rules": { - "adjacent-overload-signatures": false, - "array-type": false, - "arrow-return-shorthand": false, - "ban-types": false, - "callable-types": false, - "comment-format": false, - "dt-header": false, - "eofline": false, - "export-just-namespace": false, - "import-spacing": false, - "interface-name": false, - "interface-over-type-literal": false, - "jsdoc-format": false, - "max-line-length": false, - "member-access": false, - "new-parens": false, - "no-any-union": false, - "no-boolean-literal-compare": false, - "no-conditional-assignment": false, - "no-consecutive-blank-lines": false, - "no-construct": false, - "no-declare-current-package": false, - "no-duplicate-imports": false, - "no-duplicate-variable": false, - "no-empty-interface": false, - "no-for-in-array": false, - "no-inferrable-types": false, - "no-internal-module": false, - "no-irregular-whitespace": false, - "no-mergeable-namespace": false, - "no-misused-new": false, - "no-namespace": false, - "no-object-literal-type-assertion": false, - "no-padding": false, - "no-redundant-jsdoc": false, - "no-redundant-jsdoc-2": false, - "no-redundant-undefined": false, - "no-reference-import": false, - "no-relative-import-in-test": false, - "no-self-import": false, - "no-single-declare-module": false, - "no-string-throw": false, - "no-unnecessary-callback-wrapper": false, - "no-unnecessary-class": false, - "no-unnecessary-generics": false, - "no-unnecessary-qualifier": false, - "no-unnecessary-type-assertion": false, - "no-useless-files": false, - "no-var-keyword": false, - "no-var-requires": false, - "no-void-expression": false, - "no-trailing-whitespace": false, - "object-literal-key-quotes": false, - "object-literal-shorthand": false, - "one-line": false, - "one-variable-per-declaration": false, - "only-arrow-functions": false, - "prefer-conditional-expression": false, - "prefer-const": false, - "prefer-declare-function": false, - "prefer-for-of": false, - "prefer-method-signature": false, - "prefer-template": false, - "radix": false, - "semicolon": false, - "space-before-function-paren": false, - "space-within-parens": false, - "strict-export-declare-modifiers": false, - "trim-file": false, - "triple-equals": false, - "typedef-whitespace": false, - "unified-signatures": false, - "void-return": false, - "whitespace": false - } -} \ No newline at end of file + "extends": "dtslint/dt.json" +} From acce8fa96d87ba62253c15ae4374473482e8d2f1 Mon Sep 17 00:00:00 2001 From: Michelle Scharlock Date: Mon, 17 Sep 2018 17:13:42 -0700 Subject: [PATCH 35/39] Update to tslint.json --- types/custom-functions-runtime/tslint.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index f93cf8562a..916693cb02 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,3 +1,6 @@ { "extends": "dtslint/dt.json" + "rules": { + "semicolon": false, + } } From 1bf25df514d5a8aede2123f8dd23e34b6291301c Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 17 Sep 2018 17:24:36 -0700 Subject: [PATCH 36/39] update to json so it's not broken --- .../custom-functions-runtime-tests.ts | 6 +++--- types/custom-functions-runtime/tslint.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 4882c6bcd2..0186416e95 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -2,8 +2,8 @@ function ADD10(n: number) { return n + 10; } -CustomFunctionMappings = { - "addTen": ADD10 +CustomFunctionMappings = { + addTen: ADD10 }; async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { @@ -12,7 +12,7 @@ async function getStockValues(ticker: string, handler: CustomFunctions.Streaming } async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { - var shouldStop = false; + let shouldStop = false; handler.onCanceled = () => shouldStop = true; await pause(1000); diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index 916693cb02..837163b606 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,6 +1,6 @@ { - "extends": "dtslint/dt.json" + "extends": "dtslint/dt.json", "rules": { - "semicolon": false, + "semicolon": false } } From abfae224423083b98141e8e2623cc8bc9b0a6732 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 17 Sep 2018 17:37:25 -0700 Subject: [PATCH 37/39] Fix failures --- types/custom-functions-runtime/index.d.ts | 8 ++++---- types/custom-functions-runtime/tslint.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/types/custom-functions-runtime/index.d.ts b/types/custom-functions-runtime/index.d.ts index 0173a4d0ed..e233a869fd 100644 --- a/types/custom-functions-runtime/index.d.ts +++ b/types/custom-functions-runtime/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for Custom Functions +// Type definitions for Custom Functions 1.4 // Project: http://dev.office.com // Definitions by: OfficeDev , Michael Zlatkovsky , Michelle Scharlock // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -14,7 +14,7 @@ declare let CustomFunctionMappings: { [key: string]: Function }; declare namespace CustomFunctions { interface StreamingHandler extends CancelableHandler { /* - * Sets the returned result for a streaming custom function. + * Sets the returned result for a streaming custom function. * @beta */ setResult: (value: T) => void; @@ -22,8 +22,8 @@ declare namespace CustomFunctions { interface CancelableHandler { /* - * Handles what should occur when a custom function is canceled. - * @beta + * Handles what should occur when a custom function is canceled. + * @beta */ onCanceled: () => void; } diff --git a/types/custom-functions-runtime/tslint.json b/types/custom-functions-runtime/tslint.json index 837163b606..a62d0d4e68 100644 --- a/types/custom-functions-runtime/tslint.json +++ b/types/custom-functions-runtime/tslint.json @@ -1,6 +1,6 @@ { "extends": "dtslint/dt.json", "rules": { - "semicolon": false + "ban-types": false } } From 23a045349226125eab25097aa6ec389d429c5008 Mon Sep 17 00:00:00 2001 From: mscharlock Date: Mon, 17 Sep 2018 17:42:40 -0700 Subject: [PATCH 38/39] Fix lint issue --- .../custom-functions-runtime-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 0186416e95..9d01cc64e6 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -8,7 +8,7 @@ CustomFunctionMappings = { async function getStockValues(ticker: string, handler: CustomFunctions.StreamingHandler) { const dollars = await (await fetch(`myService.com/prices/${ticker}`)).json(); - handler.setResult(dollars) + handler.setResult(dollars); } async function getStockValuesOneTime(ticker: string, handler: CustomFunctions.CancelableHandler) { @@ -29,4 +29,4 @@ async function getStockValuesNowWithNoCancelling(ticker: string) { return dollars; } -declare function pause(ms: number): Promise +declare function pause(ms: number): Promise; From 5ced13eaee0e3c1e60edef0bd5838f28eeebc6ad Mon Sep 17 00:00:00 2001 From: mscharlock Date: Tue, 18 Sep 2018 10:00:30 -0700 Subject: [PATCH 39/39] adding a note on the test fcn --- types/custom-functions-runtime/custom-functions-runtime-tests.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/types/custom-functions-runtime/custom-functions-runtime-tests.ts b/types/custom-functions-runtime/custom-functions-runtime-tests.ts index 9d01cc64e6..335e5a1f95 100644 --- a/types/custom-functions-runtime/custom-functions-runtime-tests.ts +++ b/types/custom-functions-runtime/custom-functions-runtime-tests.ts @@ -1,3 +1,4 @@ +/* Note that this is a sample function for the purpose of running the below CustomFunctionsMappings test */ function ADD10(n: number) { return n + 10; }