mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 07:17:04 +00:00
adding office-runtime folder
This commit is contained in:
Vendored
+155
@@ -0,0 +1,155 @@
|
||||
// Type definitions for office-runtime
|
||||
// Project: http://dev.office.com/
|
||||
// Definitions by: Michael Zlatskovsky <https://github.com/Zlatkovsky>, Michelle Scharlock <https://github.com/mscharlock>
|
||||
// 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<Dialog>;
|
||||
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<string>;
|
||||
/**
|
||||
* @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<void>;
|
||||
/**
|
||||
* @beta
|
||||
* Removes an item for specified key and invokes a callback when finished. Returns a Promise.
|
||||
*
|
||||
*
|
||||
*/
|
||||
removeItem(key: string, callback?: (error?: Error) => void): Promise<void>;
|
||||
/**
|
||||
* @beta
|
||||
* Erases all AsyncStorage. Returns a Promise.
|
||||
*
|
||||
*/
|
||||
clear(callback?: (error?: Error) => void): Promise<void>;
|
||||
/**
|
||||
* @beta
|
||||
* Returns a Promise with all keys for your custom function.
|
||||
*
|
||||
*/
|
||||
getAllKeys(callback?: (error?: Error, keys?: string[]) => void): Promise<string[]>;
|
||||
/**
|
||||
* @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<void>;
|
||||
/**
|
||||
* @beta
|
||||
* Deletes a batch of keys, specified in the `keys` array.
|
||||
*
|
||||
*/
|
||||
multiRemove(keys: string[], callback?: (errors?: Error[]) => void): Promise<void>;/**
|
||||
/**
|
||||
* @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<string[][]>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @beta
|
||||
* Object representing the dialog box for Excel Custom Functions only.
|
||||
*
|
||||
*/
|
||||
interface Dialog {
|
||||
/**
|
||||
* @beta
|
||||
* Method that closes a dialog box.
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
})
|
||||
@@ -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"
|
||||
]
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user