mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-07 00:07:07 +00:00
Merge branch 'master' into master
This commit is contained in:
@@ -1,2 +1,7 @@
|
||||
# Auto detect text files and perform LF normalization
|
||||
* text=auto
|
||||
|
||||
# Checkout NPM package files with forced LF lineendings
|
||||
# to prevent git conflicts when running npm commands
|
||||
package.json text eol=lf
|
||||
package-lock.json text eol=lf
|
||||
|
||||
+632
-270
File diff suppressed because it is too large
Load Diff
@@ -10,7 +10,7 @@ Please fill in this template.
|
||||
Select one of these and delete the others:
|
||||
|
||||
If adding a new definition:
|
||||
- [ ] The package does not provide its own types, and you can not add them.
|
||||
- [ ] The package does not already provide its own types, or cannot have its `.d.ts` files generated via `--declaration`
|
||||
- [ ] If this is for an NPM package, match the name. If not, do not conflict with the name of an NPM package.
|
||||
- [ ] Create it with `dts-gen --dt`, not by basing it on an existing project.
|
||||
- [ ] `tslint.json` should be present, and `tsconfig.json` should have `noImplicitAny`, `noImplicitThis`, `strictNullChecks`, and `strictFunctionTypes` set to `true`.
|
||||
|
||||
@@ -49,3 +49,6 @@ npm-debug.log
|
||||
|
||||
# yarn
|
||||
yarn.lock
|
||||
|
||||
# pnpm
|
||||
shrinkwrap.yaml
|
||||
|
||||
@@ -87,6 +87,7 @@ Primero, haz un [fork](https://guides.github.com/activities/forking/) en este re
|
||||
|
||||
* `cd types/my-package-to-edit`
|
||||
* Haz cambios. Recuerda editar las pruebas.
|
||||
Si realiza cambios importantes, no olvide [actualizar una versión principal](#quiero-actualizar-un-paquete-a-una-nueva-versión-principal).
|
||||
* También puede que quieras añadirte la sección "Definitions by" en el encabezado del paquete.
|
||||
- Esto hará que seas notificado (a través de tu nombre de usuario en GitHub) cada vez que alguien haga un pull request o issue sobre el paquete.
|
||||
- Haz esto añadiendo tu nombre al final de la línea, así como en `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
|
||||
@@ -87,6 +87,7 @@ First, [fork](https://guides.github.com/activities/forking/) this repository, in
|
||||
|
||||
* `cd types/my-package-to-edit`
|
||||
* Make changes. Remember to edit tests.
|
||||
If you make breaking changes, do not forget to [update a major version](#i-want-to-update-a-package-to-a-new-major-version).
|
||||
* You may also want to add yourself to "Definitions by" section of the package header.
|
||||
- This will cause you to be notified (via your GitHub username) whenever someone makes a pull request or issue about the package.
|
||||
- Do this by adding your name to the end of the line, as in `// Definitions by: Alice <https://github.com/alice>, Bob <https://github.com/bob>`.
|
||||
@@ -105,7 +106,7 @@ If it doesn't, you can do so yourself in the comment associated with the PR.
|
||||
|
||||
#### Create a new package
|
||||
|
||||
If you are the library author, or can make a pull request to the library, [bundle types](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) instead of publishing to DefinitelyTyped.
|
||||
If you are the library author and your package is written in TypeScript, [bundle the autogenerated declaration files](http://www.typescriptlang.org/docs/handbook/declaration-files/publishing.html) in your package instead of publishing to DefinitelyTyped.
|
||||
|
||||
If you are adding typings for an NPM package, create a directory with the same name.
|
||||
If the package you are adding typings for is not on NPM, make sure the name you choose for it does not conflict with the name of a package on NPM.
|
||||
@@ -120,7 +121,7 @@ Your package should have this structure:
|
||||
| tsconfig.json | This allows you to run `tsc` within the package. |
|
||||
| tslint.json | Enables linting. |
|
||||
|
||||
Generate these by running `npm install -g dts-gen` and `dts-gen --dt --name my-package-name --template module`.
|
||||
Generate these by running `npx dts-gen --dt --name my-package-name --template module` if you have npm ≥ 5.2.0, `npm install -g dts-gen` and `dts-gen --dt --name my-package-name --template module` otherwise.
|
||||
See all options at [dts-gen](https://github.com/Microsoft/dts-gen).
|
||||
|
||||
You may edit the `tsconfig.json` to add new files, to add `"target": "es6"` (needed for async functions), to add to `"lib"`, or to add the `"jsx"` compiler option.
|
||||
@@ -239,7 +240,8 @@ If types are part of a web standard, they should be contributed to [TSJS-lib-gen
|
||||
|
||||
#### A package uses `export =`, but I prefer to use default imports. Can I change `export =` to `export default`?
|
||||
|
||||
If default imports work in your environment, consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option.
|
||||
If you are using TypeScript 2.7 or later, use `--esModuleInterop` in your project.
|
||||
Otherwise, if default imports work in your environment (e.g. Webpack, SystemJS, esm), consider turning on the [`--allowSyntheticDefaultImports`](http://www.typescriptlang.org/docs/handbook/compiler-options.html) compiler option.
|
||||
Do not change the type definition if it is accurate.
|
||||
For an NPM package, `export =` is accurate if `node -p 'require("foo")'` is the export, and `export default` is accurate if `node -p 'require("foo").default'` is the export.
|
||||
|
||||
|
||||
Vendored
-35
@@ -1,35 +0,0 @@
|
||||
// Type definitions for glue
|
||||
// Project: https://github.com/hapijs/glue
|
||||
// Definitions by: Gareth Parker
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.7
|
||||
|
||||
declare module "glue" {
|
||||
|
||||
import { Server, ServerOptions } from "hapi";
|
||||
|
||||
export interface Options {
|
||||
relativeTo: string;
|
||||
preConnections?: (Server:Server, next:(err:any)=>void ) => void;
|
||||
preRegister?: (Server:Server, next:(err:any)=>void ) => void;
|
||||
}
|
||||
|
||||
interface Plugin {
|
||||
plugin: string | {
|
||||
register:string;
|
||||
options?:any;
|
||||
};
|
||||
options?: any;
|
||||
routes?: any
|
||||
}
|
||||
|
||||
interface Manifest {
|
||||
server: ServerOptions;
|
||||
register?: {
|
||||
plugins: Array<Plugin>
|
||||
}
|
||||
}
|
||||
|
||||
export function compose(manifest: Manifest, options?: Options): Server;
|
||||
|
||||
}
|
||||
+44
-8
@@ -124,7 +124,7 @@
|
||||
"libraryName": "axe-core",
|
||||
"typingsPackageName": "axe-core",
|
||||
"sourceRepoURL": "https://github.com/dequelabs/axe-core",
|
||||
"asOfVersion": "2.0.7"
|
||||
"asOfVersion": "3.0.3"
|
||||
},
|
||||
{
|
||||
"libraryName": "axios",
|
||||
@@ -174,7 +174,7 @@
|
||||
"sourceRepoURL": "https://github.com/MikeMcl/bignumber.js/",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
{
|
||||
"libraryName": "bingmaps",
|
||||
"typingsPackageName": "bingmaps",
|
||||
"sourceRepoURL": "https://github.com/Microsoft/Bing-Maps-V8-TypeScript-Definitions",
|
||||
@@ -210,6 +210,12 @@
|
||||
"sourceRepoURL": "https://github.com/blakeembrey/camel-case",
|
||||
"asOfVersion": "1.2.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "catalog",
|
||||
"typingsPackageName": "catalog",
|
||||
"sourceRepoURL": "https://github.com/interactivethings/catalog",
|
||||
"asOfVersion": "3.5.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "chalk",
|
||||
"typingsPackageName": "chalk",
|
||||
@@ -234,6 +240,12 @@
|
||||
"sourceRepoURL": "https://github.com/saltyrtc/chunked-dc-js",
|
||||
"asOfVersion": "0.2.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "colors.js (colors)",
|
||||
"typingsPackageName": "colors",
|
||||
"sourceRepoURL": "https://github.com/Marak/colors.js",
|
||||
"asOfVersion": "1.2.1"
|
||||
},
|
||||
{
|
||||
"libraryName": "commander",
|
||||
"typingsPackageName": "commander",
|
||||
@@ -648,6 +660,12 @@
|
||||
"sourceRepoURL": "https://github.com/ashtuchkin/iconv-lite",
|
||||
"asOfVersion": "0.4.14"
|
||||
},
|
||||
{
|
||||
"libraryName": "ids",
|
||||
"typingsPackageName": "ids",
|
||||
"sourceRepoURL": "https://github.com/bpmn-io/ids",
|
||||
"asOfVersion": "0.2.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "immutability-helper",
|
||||
"typingsPackageName": "immutability-helper",
|
||||
@@ -990,12 +1008,6 @@
|
||||
"sourceRepoURL": "https://github.com/blakeembrey/param-case",
|
||||
"asOfVersion": "1.1.2"
|
||||
},
|
||||
{
|
||||
"libraryName": "parse5",
|
||||
"typingsPackageName": "parse5",
|
||||
"sourceRepoURL": "https://github.com/inikulin/parse5",
|
||||
"asOfVersion": "3.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "pascal-case",
|
||||
"typingsPackageName": "pascal-case",
|
||||
@@ -1140,6 +1152,18 @@
|
||||
"sourceRepoURL": "https://github.com/react-ga/react-ga",
|
||||
"asOfVersion": "2.3.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-monaco-editor",
|
||||
"typingsPackageName": "react-monaco-editor",
|
||||
"sourceRepoURL": "https://github.com/superRaytin/react-monaco-editor",
|
||||
"asOfVersion": "0.16.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-collapsible",
|
||||
"typingsPackageName": "react-native-collapsible",
|
||||
"sourceRepoURL": "https://github.com/oblador/react-native-collapsible",
|
||||
"asOfVersion": "0.11.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-elements",
|
||||
"typingsPackageName": "react-native-elements",
|
||||
@@ -1158,6 +1182,12 @@
|
||||
"sourceRepoURL": "https://github.com/idehub/react-native-google-analytics-bridge",
|
||||
"asOfVersion": "5.3.3"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-linear-gradient",
|
||||
"typingsPackageName": "react-native-linear-gradient",
|
||||
"sourceRepoURL": "https://github.com/react-native-community/react-native-linear-gradient",
|
||||
"asOfVersion": "2.4.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-native-modal",
|
||||
"typingsPackageName": "react-native-modal",
|
||||
@@ -1266,6 +1296,12 @@
|
||||
"sourceRepoURL": "https://github.com/router5/router5",
|
||||
"asOfVersion": "5.0.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "rrule",
|
||||
"typingsPackageName": "rrule",
|
||||
"sourceRepoURL": "https://github.com/jakubroztocil/rrule",
|
||||
"asOfVersion": "2.2.9"
|
||||
},
|
||||
{
|
||||
"libraryName": "rvo2",
|
||||
"typingsPackageName": "rvo2",
|
||||
|
||||
+25
-25
@@ -1,27 +1,27 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "definitely-typed",
|
||||
"version": "0.0.1",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"compile-scripts": "tsc -p scripts",
|
||||
"not-needed": "node scripts/not-needed.js",
|
||||
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed",
|
||||
"lint": "dtslint types"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dtslint": "github:Microsoft/dtslint#production",
|
||||
"types-publisher": "Microsoft/types-publisher#production"
|
||||
}
|
||||
"private": true,
|
||||
"name": "definitely-typed",
|
||||
"version": "0.0.2",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/DefinitelyTyped/DefinitelyTyped.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"bugs": {
|
||||
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped/issues"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.8.0"
|
||||
},
|
||||
"scripts": {
|
||||
"compile-scripts": "tsc -p scripts",
|
||||
"not-needed": "node scripts/not-needed.js",
|
||||
"test": "node node_modules/types-publisher/bin/tester/test.js --run-from-definitely-typed",
|
||||
"lint": "dtslint types"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dtslint": "github:Microsoft/dtslint#production",
|
||||
"types-publisher": "Microsoft/types-publisher#production"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
import drawTriangle = require("a-big-triangle");
|
||||
|
||||
const gl = new WebGLRenderingContext();
|
||||
|
||||
drawTriangle(gl); // $ExpectType void
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
// Type definitions for a-big-triangle 1.0
|
||||
// Project: https://github.com/mikolalysenko/a-big-triangle
|
||||
// Definitions by: Mathias Paumgarten <https://github.com/MathiasPaumgarten>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function createABigTriangle(gl: WebGLRenderingContext): void;
|
||||
|
||||
export = createABigTriangle;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"a-big-triangle-tests.ts"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.4.1/index.js
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.5.0/index.js
|
||||
|
||||
import * as AcceptLanguageParser from 'accept-language-parser';
|
||||
|
||||
@@ -23,3 +23,9 @@ const l3: AcceptLanguageParser.Language = {
|
||||
const parsed1: AcceptLanguageParser.Language[] = AcceptLanguageParser.parse('');
|
||||
const pick1: string | null = AcceptLanguageParser.pick([''], '');
|
||||
const pick2: string | null = AcceptLanguageParser.pick([''], [l1, l2, l3]);
|
||||
const pick3: string | null = AcceptLanguageParser.pick([''], '', {});
|
||||
const pick4: string | null = AcceptLanguageParser.pick([''], '', { loose: true });
|
||||
|
||||
const pickOptions: AcceptLanguageParser.PickOptions = {
|
||||
loose: true
|
||||
};
|
||||
|
||||
+10
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for accept-language-parser 1.4
|
||||
// Type definitions for accept-language-parser 1.5
|
||||
// Project: https://github.com/opentable/accept-language-parser
|
||||
// Definitions by: Niklas Wulf <https://github.com/kampfgnom>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -7,7 +7,11 @@
|
||||
// https://github.com/opentable/accept-language-parser/blob/v1.4.1/index.js
|
||||
|
||||
export function parse(acceptLanguage: string): Language[];
|
||||
export function pick(supportedLanguages: string[], acceptLanguage: string | Language[]): string | null;
|
||||
export function pick(
|
||||
supportedLanguages: string[],
|
||||
acceptLanguage: string | Language[],
|
||||
options?: PickOptions
|
||||
): string | null;
|
||||
|
||||
export interface Language {
|
||||
code: string;
|
||||
@@ -15,3 +19,7 @@ export interface Language {
|
||||
region?: string;
|
||||
quality: number;
|
||||
}
|
||||
|
||||
export interface PickOptions {
|
||||
loose?: boolean;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
import AceDiff = require('ace-diff');
|
||||
|
||||
new AceDiff(); // $ExpectError
|
||||
|
||||
const aceDiffConstructorOpts = {
|
||||
element: '.acediff',
|
||||
left: { content: 'left content' },
|
||||
right: { content: 'right content' },
|
||||
};
|
||||
new AceDiff(aceDiffConstructorOpts); // $ExpectType AceDiff
|
||||
|
||||
const differ = new AceDiff(aceDiffConstructorOpts);
|
||||
|
||||
differ.getEditors(); // $ExpectType { left: any; right: any; }
|
||||
differ.setOptions(); // $ExpectError
|
||||
const aceDiffOpts = {
|
||||
diffGranularity: 'broad' as 'broad', // workaround: cast to avoid https://github.com/Microsoft/TypeScript/issues/11465#issuecomment-252453037
|
||||
};
|
||||
differ.setOptions(aceDiffOpts); // $ExpectType void
|
||||
differ.getNumDiffs(); // $ExpectType number
|
||||
differ.diff(); // $ExpectType void
|
||||
differ.destroy(); // $ExpectType void
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
// Type definitions for ace-diff 2.1
|
||||
// Project: https://ace-diff.github.io/ace-diff/
|
||||
// Definitions by: Mike Dodge <https://github.com/innovation-team>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export as namespace AceDiff;
|
||||
|
||||
export = AceDiff;
|
||||
|
||||
declare class AceDiff {
|
||||
constructor(opts: AceDiff.AceDiffConstructorOpts);
|
||||
getEditors(): {
|
||||
left: any;
|
||||
right: any;
|
||||
};
|
||||
setOptions(options: AceDiff.AceDiffOpts): void;
|
||||
getNumDiffs(): number;
|
||||
diff(): void;
|
||||
destroy(): void;
|
||||
}
|
||||
declare namespace AceDiff {
|
||||
interface AceDiffLROpts {
|
||||
content?: string | null;
|
||||
mode?: string;
|
||||
theme?: string;
|
||||
editable?: boolean;
|
||||
copyLinkEnabled?: boolean;
|
||||
}
|
||||
|
||||
interface AceDiffConstructorOpts extends AceDiffOpts {
|
||||
element: string | HTMLElement;
|
||||
left: AceDiffLROpts;
|
||||
right: AceDiffLROpts;
|
||||
}
|
||||
|
||||
interface AceDiffOpts {
|
||||
mode?: string;
|
||||
theme?: string;
|
||||
diffGranularity?: 'specific' | 'broad';
|
||||
showDiffs?: boolean;
|
||||
showConnectors?: boolean;
|
||||
maxDiffs?: number;
|
||||
left?: AceDiffLROpts;
|
||||
right?: AceDiffLROpts;
|
||||
classes?: {
|
||||
diff: string;
|
||||
connector: string;
|
||||
newCodeConnectorLinkContent: string;
|
||||
deletedCodeConnectorLinkContent: string;
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"ace-diff-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+57
-23
@@ -101,6 +101,29 @@ declare namespace AceAjax {
|
||||
transformAction(state: any, action: any, editor: any, session: any, param: any): any;
|
||||
}
|
||||
|
||||
export interface OptionProvider {
|
||||
|
||||
/**
|
||||
* Sets a Configuration Option
|
||||
**/
|
||||
setOption(optionName: string, optionValue: any): void;
|
||||
|
||||
/**
|
||||
* Sets Configuration Options
|
||||
**/
|
||||
setOptions(keyValueTuples: any): void;
|
||||
|
||||
/**
|
||||
* Get a Configuration Option
|
||||
**/
|
||||
getOption(name: string):any;
|
||||
|
||||
/**
|
||||
* Get Configuration Options
|
||||
**/
|
||||
getOptions():any;
|
||||
}
|
||||
|
||||
////////////////
|
||||
/// Ace
|
||||
////////////////
|
||||
@@ -495,7 +518,7 @@ declare namespace AceAjax {
|
||||
* Stores all the data about [[Editor `Editor`]] state providing easy way to change editors state.
|
||||
* `EditSession` can be attached to only one [[Document `Document`]]. Same `Document` can be attached to several `EditSession`s.
|
||||
**/
|
||||
export interface IEditSession {
|
||||
export interface IEditSession extends OptionProvider {
|
||||
|
||||
selection: Selection;
|
||||
|
||||
@@ -1074,7 +1097,7 @@ declare namespace AceAjax {
|
||||
* The `Editor` manages the [[EditSession]] (which manages [[Document]]s), as well as the [[VirtualRenderer]], which draws everything to the screen.
|
||||
* Event sessions dealing with the mouse and keyboard are bubbled up from `Document` to the `Editor`, which decides what to do with them.
|
||||
**/
|
||||
export interface Editor {
|
||||
export interface Editor extends OptionProvider {
|
||||
|
||||
on(ev: string, callback: (e: any) => any): void;
|
||||
|
||||
@@ -1113,26 +1136,6 @@ declare namespace AceAjax {
|
||||
|
||||
execCommand(command:string, args?: any): void;
|
||||
|
||||
/**
|
||||
* Sets a Configuration Option
|
||||
**/
|
||||
setOption(optionName: any, optionValue: any): void;
|
||||
|
||||
/**
|
||||
* Sets Configuration Options
|
||||
**/
|
||||
setOptions(keyValueTuples: any): void;
|
||||
|
||||
/**
|
||||
* Get a Configuration Option
|
||||
**/
|
||||
getOption(name: any):any;
|
||||
|
||||
/**
|
||||
* Get Configuration Options
|
||||
**/
|
||||
getOptions():any;
|
||||
|
||||
/**
|
||||
* Get rid of console warning by setting this to Infinity
|
||||
**/
|
||||
@@ -2692,7 +2695,7 @@ declare namespace AceAjax {
|
||||
/**
|
||||
* The class that is responsible for drawing everything you see on the screen!
|
||||
**/
|
||||
export interface VirtualRenderer {
|
||||
export interface VirtualRenderer extends OptionProvider {
|
||||
|
||||
scroller: any;
|
||||
|
||||
@@ -3036,6 +3039,37 @@ declare namespace AceAjax {
|
||||
**/
|
||||
new(container: HTMLElement, theme?: string): VirtualRenderer;
|
||||
}
|
||||
|
||||
export interface Completer {
|
||||
/**
|
||||
* Provides possible completion results asynchronously using the given callback.
|
||||
* @param editor The editor to associate with
|
||||
* @param session The `EditSession` to refer to
|
||||
* @param pos An object containing the row and column
|
||||
* @param prefix The prefixing string before the current position
|
||||
* @param callback Function to provide the results or error
|
||||
*/
|
||||
getCompletions: (editor: Editor, session: IEditSession, pos: Position, prefix: string, callback: CompletionCallback) => void;
|
||||
|
||||
/**
|
||||
* Provides tooltip information about a completion result.
|
||||
* @param item The completion result
|
||||
*/
|
||||
getDocTooltip?: (item: Completion) => void;
|
||||
}
|
||||
|
||||
export interface Completion {
|
||||
value: string;
|
||||
meta: string;
|
||||
type?: string;
|
||||
caption?: string;
|
||||
snippet?: any;
|
||||
score?: number;
|
||||
exactMatch?: number;
|
||||
docHTML?: string;
|
||||
}
|
||||
|
||||
export type CompletionCallback = (error: Error, results: Completion[]) => void;
|
||||
}
|
||||
|
||||
declare var ace: AceAjax.Ace;
|
||||
|
||||
+332
-5
@@ -1,6 +1,7 @@
|
||||
import * as express from 'express';
|
||||
|
||||
import { BasicCard, Carousel, ImageDisplays, List, OptionItem, RichResponse } from './response-builder';
|
||||
import { BasicCard, BrowseCarousel, BrowseItem, Carousel, ImageDisplays, List, MediaObject,
|
||||
MediaResponse, MediaValues, OptionItem, RichResponse, SimpleResponse } from './response-builder';
|
||||
import { ActionPaymentTransactionConfig, Cart, GooglePaymentTransactionConfig, LineItem,
|
||||
Location, Order, OrderUpdate, TransactionDecision, TransactionValues } from './transactions';
|
||||
|
||||
@@ -30,6 +31,8 @@ export enum StandardIntents {
|
||||
DELIVERY_ADDRESS,
|
||||
/** App fires TRANSACTION_DECISION intent when action asks for transaction decision. */
|
||||
TRANSACTION_DECISION,
|
||||
/** App fires PLACE intent when action asks for place. */
|
||||
PLACE,
|
||||
/** App fires CONFIRMATION intent when requesting affirmation from user. */
|
||||
CONFIRMATION,
|
||||
/** App fires DATETIME intent when requesting date/time from user. */
|
||||
@@ -45,7 +48,11 @@ export enum StandardIntents {
|
||||
/** App fires REGISTER_UPDATE intent when requesting user to register for proactive updates. */
|
||||
REGISTER_UPDATE,
|
||||
/** App receives CONFIGURE_UPDATES intent to indicate a REGISTER_UPDATE intent should be sent. */
|
||||
CONFIGURE_UPDATES
|
||||
CONFIGURE_UPDATES,
|
||||
/** App fires LINK intent to request user to open to link. */
|
||||
LINK,
|
||||
/** App receives MEDIA_STATUS intent when the MediaResponse status is updated from user. */
|
||||
MEDIA_STATUS
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,6 +108,10 @@ export enum BuiltInArgNames {
|
||||
* Transactions decision argument.
|
||||
*/
|
||||
TRANSACTION_DECISION_VALUE,
|
||||
/**
|
||||
* Place value argument.
|
||||
*/
|
||||
PLACE,
|
||||
/**
|
||||
* Confirmation argument.
|
||||
*/
|
||||
@@ -126,7 +137,11 @@ export enum BuiltInArgNames {
|
||||
*/
|
||||
NEW_SURFACE,
|
||||
/** Update registration value argument. */
|
||||
REGISTER_UPDATE
|
||||
REGISTER_UPDATE,
|
||||
/** Link request result argument. */
|
||||
LINK,
|
||||
/** MediaStatus value argument. */
|
||||
MEDIA_STATUS
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,6 +188,14 @@ export enum SurfaceCapabilities {
|
||||
* The ability to output on a screen
|
||||
*/
|
||||
SCREEN_OUTPUT,
|
||||
/**
|
||||
* The ability to output a MediaResponse
|
||||
*/
|
||||
MEDIA_RESPONSE_AUDIO,
|
||||
/**
|
||||
* The ability to open a web URL
|
||||
*/
|
||||
WEB_BROWSER
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,6 +246,18 @@ export enum SignInStatus {
|
||||
ERROR
|
||||
}
|
||||
|
||||
/**
|
||||
* SKU (Stock Keeping Units) types for Play Package Entitlements.
|
||||
*/
|
||||
export enum EntitlementSkuTypes {
|
||||
/** In app purchase */
|
||||
IN_APP,
|
||||
/** In app subscription */
|
||||
SUBSCRIPTION,
|
||||
/** Paid app. */
|
||||
APP
|
||||
}
|
||||
|
||||
/**
|
||||
* Possible update trigger time context frequencies.
|
||||
*/
|
||||
@@ -259,10 +294,15 @@ export interface UserName {
|
||||
familyName: string;
|
||||
}
|
||||
|
||||
export interface LocationCoordinates {
|
||||
latitude: number;
|
||||
longitude: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* User's permissioned device location.
|
||||
* Location information.
|
||||
*/
|
||||
export interface DeviceLocation {
|
||||
export interface Location {
|
||||
/** Coordinates: {latitude, longitude}. Requested with SupportedPermissions.DEVICE_PRECISE_LOCATION. */
|
||||
coordinates: Coordinates;
|
||||
/** Full, formatted street address. Requested with SupportedPermissions.DEVICE_PRECISE_LOCATION. */
|
||||
@@ -273,6 +313,22 @@ export interface DeviceLocation {
|
||||
city: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* User's permissioned device location.
|
||||
*/
|
||||
export type DeviceLocation = Location;
|
||||
|
||||
/**
|
||||
* Place information.
|
||||
*/
|
||||
export interface Place extends Location {
|
||||
/**
|
||||
* Used with Places API to fetch details of a place.
|
||||
* See {@link https://developers.google.com/places/web-service/place-id}
|
||||
*/
|
||||
placeId: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coordinates containing latitude and longitude
|
||||
*/
|
||||
@@ -309,6 +365,33 @@ export interface User {
|
||||
userStorage: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Google Play Android App Package Entitlements.
|
||||
*/
|
||||
export interface PackageEntitlement {
|
||||
/** Name of the Android app package. */
|
||||
packageName: string;
|
||||
/** List of entitlements for a given app. */
|
||||
entitlements: Entitlement[];
|
||||
}
|
||||
|
||||
/**
|
||||
* A user's digital entitlement.
|
||||
*/
|
||||
export interface Entitlement {
|
||||
/** Product SKU. Matches getSku() in Google Play InApp Billing API. */
|
||||
sku: string;
|
||||
/** The type of SKU. One of EntitlementSkuType. */
|
||||
skuType: string;
|
||||
/** For in app purchases/subscriptions, relevant details. */
|
||||
inAppDetails: {
|
||||
/** JSON data of the in app purchase. */
|
||||
inAppPurchaseData: object;
|
||||
/** Matches IN_APP_DATA_SIGNATURE from getPurchases() method in Play InApp Billing API. */
|
||||
inAppDataSignature: object;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Actions on Google Surface.
|
||||
*/
|
||||
@@ -437,6 +520,16 @@ export class AssistantApp {
|
||||
*/
|
||||
readonly Transactions: typeof TransactionValues;
|
||||
|
||||
/**
|
||||
* Values related to supporting {@link Media}.
|
||||
*/
|
||||
readonly Media: typeof MediaValues;
|
||||
|
||||
/**
|
||||
* SKU (Stock Keeping Units) types for Play Package Entitlements.
|
||||
*/
|
||||
readonly EntitlementSkuTypes: typeof EntitlementSkuTypes;
|
||||
|
||||
/**
|
||||
* Possible update trigger time context frequencies.
|
||||
*/
|
||||
@@ -923,6 +1016,80 @@ export class AssistantApp {
|
||||
*/
|
||||
askForDeliveryAddress(reason: string, dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Asks user to provide a geo-located place, possibly using contextual information,
|
||||
* like a store near the user's location or a contact's address.
|
||||
*
|
||||
* Developer provides custom text prompts to tailor the request handled by Google.
|
||||
*
|
||||
* @example
|
||||
* // For DialogflowApp:
|
||||
*
|
||||
* // Dialogflow Actions
|
||||
* const Actions = {
|
||||
* WELCOME: 'input.welcome',
|
||||
* PLACE: 'get.place' // Create Dialogflow Action with actions_intent_PLACE event
|
||||
* };
|
||||
*
|
||||
* const app = new DialogflowApp({request, response});
|
||||
*
|
||||
* function handleWelcome (app) {
|
||||
* const requestPrompt = 'Where do you want to get picked up?';
|
||||
* const permissionContext = 'To find a place to pick you up';
|
||||
* app.askForPlace(requestPrompt, permissionContext);
|
||||
* }
|
||||
*
|
||||
* function handlePlace (app) {
|
||||
* const place = app.getPlace();
|
||||
* if (place) {
|
||||
* app.tell(`Ah, I see. You want to get picked up at ${place.address}`);
|
||||
* } else {
|
||||
* app.tell(`Sorry, I couldn't find where you want to get picked up`);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(Actions.WELCOME, handleWelcome);
|
||||
* actionMap.set(Actions.PLACE, handlePlace);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* // For ActionsSdkApp:
|
||||
* const app = new ActionsSdkApp({ request, response });
|
||||
*
|
||||
* function handleWelcome (app) {
|
||||
* const requestPrompt = 'Where do you want to get picked up?';
|
||||
* const permissionContext = 'To find a place to pick you up';
|
||||
* app.askForPlace(requestPrompt, permissionContext);
|
||||
* }
|
||||
*
|
||||
* function handlePlace (app) {
|
||||
* const place = app.getPlace();
|
||||
* if (place) {
|
||||
* app.tell(`Ah, I see. You want to get picked up at ${place.address}`);
|
||||
* } else {
|
||||
* app.tell(`Sorry, I couldn't find where you want to get picked up`);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionsMap = new Map();
|
||||
* actionsMap.set(app.StandardIntents.MAIN, handleWelcome);
|
||||
* actionsMap.set(app.StandardIntents.PLACE, handlePlace);
|
||||
* app.handleRequest(actionsMap);
|
||||
*
|
||||
* @param requestPrompt This is the initial response by location sub-dialog.
|
||||
* For example: "Where do you want to get picked up?"
|
||||
* @param permissionContext This is the context for seeking permissions.
|
||||
* For example: "To find a place to pick you up"
|
||||
* Prompt to user: "*To find a place to pick you up*, I just need to check your location.
|
||||
* Can I get that from Google?".
|
||||
* @param dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant.
|
||||
* @return HTTP response.
|
||||
* @actionssdk
|
||||
* @dialogflow
|
||||
*/
|
||||
askForPlace(requestPrompt: string, permissionContext: string, dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Asks user for a confirmation.
|
||||
*
|
||||
@@ -1131,6 +1298,72 @@ export class AssistantApp {
|
||||
*/
|
||||
askToRegisterDailyUpdate(intent: string, intentArguments: IntentArgument[], dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Requests the user to transfer to a linked out Android app intent. Using this feature
|
||||
* requires verifying the linked app in the (Actions console)[console.actions.google.com].
|
||||
*
|
||||
* @example
|
||||
* // For DialogflowApp:
|
||||
*
|
||||
* // Dialogflow Actions
|
||||
* const WELCOME_ACTION = 'input.welcome';
|
||||
* const HANDLE_LINK = 'handle.link'; // Create Dialogflow Action with actions_intent_LINK event
|
||||
*
|
||||
* const app = new DialogflowApp({ request, response });
|
||||
*
|
||||
* console.log('Request headers: ' + JSON.stringify(request.headers));
|
||||
* console.log('Request body: ' + JSON.stringify(request.body));
|
||||
*
|
||||
* function requestLink (app) {
|
||||
* app.askToDeepLink('Great! Looks like we can do that in the app.', 'Google',
|
||||
* 'example://gizmos', 'com.example.gizmos', 'handle this for you');
|
||||
* }
|
||||
*
|
||||
* function handleLink (app) {
|
||||
* const linkStatus = app.getLinkStatus();
|
||||
* app.tell('Okay maybe we can take care of that another time.');
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(WELCOME_ACTION, requestLink);
|
||||
* actionMap.set(HANDLE_LINK, handleLink);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* // For ActionsSdkApp
|
||||
* const app = new ActionsSdkApp({ request, response });
|
||||
*
|
||||
* console.log('Request headers: ' + JSON.stringify(request.headers));
|
||||
* console.log('Request body: ' + JSON.stringify(request.body));
|
||||
*
|
||||
* function requestLink (app) {
|
||||
* app.askToDeepLink('Great! Looks like we can do that in the app.', 'Google',
|
||||
* 'example://gizmos', 'com.example.gizmos', 'handle this for you.');
|
||||
* }
|
||||
*
|
||||
* function handleLink (app) {
|
||||
* const linkStatus = app.getLinkStatus();
|
||||
* app.tell('Okay maybe we can take care of that another time.');
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.MAIN, requestLink);
|
||||
* actionMap.set(app.StandardIntents.LINK, handleLink);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @param prompt A simple response to prepend to the link request.
|
||||
* @param destinationName The name of the link destination.
|
||||
* @param url URL of Android deep link.
|
||||
* @param packageName Android app package name to which to link.
|
||||
* @param reason The reason to transfer the user. This may be appended to a
|
||||
* Google-specified prompt.
|
||||
* @param dialogState JSON object the app uses to hold dialog state that
|
||||
* will be circulated back by Assistant. Used in {@link ActionsSdkApp}.
|
||||
* @return HTTP response.
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
askToDeepLink(prompt: string | SimpleResponse | null, destinationName: string, url: string, packageName: string, reason?: string | null, dialogState?: object): express.Response | null;
|
||||
|
||||
/**
|
||||
* Gets the {@link User} object.
|
||||
* The user object contains information about the user, including
|
||||
@@ -1209,6 +1442,20 @@ export class AssistantApp {
|
||||
*/
|
||||
getLastSeen(): Date | null;
|
||||
|
||||
/**
|
||||
* Get the the list of all digital goods that your user purchased from
|
||||
* your published Android apps. To enable this feature, see the instructions
|
||||
* in the (documentation)[https://developers.google.com/actions/identity/digital-goods].
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request, response});
|
||||
* const packageEntitlements = app.getPackageEntitlements();
|
||||
*
|
||||
* @return The list of digital goods purchased by the user in
|
||||
* any verified Android app package. Null if no Package Entitlements present in the request.
|
||||
*/
|
||||
getPackageEntitlements(): PackageEntitlement[] | null;
|
||||
|
||||
/**
|
||||
* If granted permission to device's location in previous intent, returns device's
|
||||
* location (see {@link AssistantApp#askForPermissions|askForPermissions}).
|
||||
@@ -1273,6 +1520,15 @@ export class AssistantApp {
|
||||
*/
|
||||
getTransactionDecision(): TransactionDecision;
|
||||
|
||||
/**
|
||||
* Gets the user provided place. Use after askForPlace.
|
||||
*
|
||||
* @return Place information given by the user. Null if no place given.
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getPlace(): Place | null;
|
||||
|
||||
/**
|
||||
* Gets confirmation decision. Use after askForConfirmation.
|
||||
*
|
||||
@@ -1304,6 +1560,31 @@ export class AssistantApp {
|
||||
*/
|
||||
getSignInStatus(): string;
|
||||
|
||||
/**
|
||||
* Get status of MEDIA_STATUS intent.
|
||||
*
|
||||
* @example
|
||||
* const app = new DialogflowApp({request: request, response: response});
|
||||
*
|
||||
* function mediaStatusIntent (app) {
|
||||
* const status = app.getMediaStatus();
|
||||
* if (status === app.Media.Status.FINISHED) {
|
||||
* app.tell('Oh, I see you are done playing the media!');
|
||||
* } else {
|
||||
* app.tell(`I don't understand the current media status: ${status}`);
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* const actionMap = new Map();
|
||||
* actionMap.set(app.StandardIntents.MEDIA_STATUS, mediaStatusIntent);
|
||||
* app.handleRequest(actionMap);
|
||||
*
|
||||
* @return Result of media status intent.
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getMediaStatus(): MediaValues.Status | null;
|
||||
|
||||
/**
|
||||
* Returns true if user device has a given surface capability.
|
||||
*
|
||||
@@ -1464,6 +1745,16 @@ export class AssistantApp {
|
||||
*/
|
||||
isUpdateRegistered(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the status of a link request. Used with
|
||||
* {@link AssistantApp#askToDeepLink}
|
||||
*
|
||||
* @return The status code of the request to link.
|
||||
* @dialogflow
|
||||
* @actionssdk
|
||||
*/
|
||||
getLinkStatus(): number;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Response Builders
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1500,6 +1791,13 @@ export class AssistantApp {
|
||||
*/
|
||||
buildCarousel(): Carousel;
|
||||
|
||||
/**
|
||||
* Constructs a Browse Carousel with chainable property setters.
|
||||
*
|
||||
* @return Constructed Browse Carousel.
|
||||
*/
|
||||
buildBrowseCarousel(): BrowseCarousel;
|
||||
|
||||
/**
|
||||
* Constructs OptionItem with chainable property setters.
|
||||
*
|
||||
@@ -1512,6 +1810,15 @@ export class AssistantApp {
|
||||
*/
|
||||
buildOptionItem(key?: string, synonyms?: string | string[]): OptionItem;
|
||||
|
||||
/**
|
||||
* Constructs BrowseItem for the Browse Carousel with chainable property setters.
|
||||
*
|
||||
* @param title The displayed title of the Browse Carousel card.
|
||||
* @param url The URL linked to by clicking the card.
|
||||
* @return Constructed BrowseItem.
|
||||
*/
|
||||
buildBrowseItem(title?: string, url?: string): BrowseItem;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Transaction Builders
|
||||
// ---------------------------------------------------------------------------
|
||||
@@ -1552,4 +1859,24 @@ export class AssistantApp {
|
||||
* @return Constructed OrderUpdate.
|
||||
*/
|
||||
buildOrderUpdate(orderId: string, isGoogleOrderId: boolean): OrderUpdate;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Media Builders
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Constructs Media Response with chainable property setters.
|
||||
*
|
||||
* @return Constructed Media Response.
|
||||
*/
|
||||
buildMediaResponse(): MediaResponse;
|
||||
|
||||
/**
|
||||
* Constructs MediaObject with chainable property setters.
|
||||
*
|
||||
* @param name Name of media file.
|
||||
* @param contentUrl Location of media file.
|
||||
* @return Constructed MediaObject.
|
||||
*/
|
||||
buildMediaObject(name: string, contentUrl: string): MediaObject;
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -1,4 +1,4 @@
|
||||
// Type definitions for actions-on-google 1.8
|
||||
// Type definitions for actions-on-google 1.10
|
||||
// Project: https://github.com/actions-on-google/actions-on-google-nodejs
|
||||
// Definitions by: Joel Hegg <https://github.com/joelhegg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
+298
@@ -27,6 +27,53 @@ export enum ImageDisplays {
|
||||
CROPPED
|
||||
}
|
||||
|
||||
/**
|
||||
* Values related to supporting media.
|
||||
*/
|
||||
export namespace MediaValues {
|
||||
/**
|
||||
* Type of the media within a MediaResponse.
|
||||
*/
|
||||
enum Type {
|
||||
/**
|
||||
* Unspecified.
|
||||
*/
|
||||
MEDIA_TYPE_UNSPECIFIED,
|
||||
/**
|
||||
* Audio stream.
|
||||
*/
|
||||
AUDIO
|
||||
}
|
||||
|
||||
/**
|
||||
* List of media control status' returned.
|
||||
*/
|
||||
enum Status {
|
||||
/**
|
||||
* Unspecified.
|
||||
*/
|
||||
UNSPECIFIED,
|
||||
/**
|
||||
* Finished.
|
||||
*/
|
||||
FINISHED
|
||||
}
|
||||
|
||||
/**
|
||||
* List of possible item types.
|
||||
*/
|
||||
enum ImageType {
|
||||
/**
|
||||
* Icon.
|
||||
*/
|
||||
ICON,
|
||||
/**
|
||||
* Large image.
|
||||
*/
|
||||
LARGE
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple Response type.
|
||||
*/
|
||||
@@ -155,6 +202,22 @@ export class RichResponse {
|
||||
*/
|
||||
addBasicCard(basicCard: BasicCard): RichResponse;
|
||||
|
||||
/**
|
||||
* Adds media to this response.
|
||||
*
|
||||
* @param mediaResponse MediaResponse to include in response.
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addMediaResponse(mediaResponse: MediaResponse): RichResponse;
|
||||
|
||||
/**
|
||||
* Adds a Browse Carousel to list of items.
|
||||
*
|
||||
* @param browseCarousel Browse Carousel to present to user
|
||||
* @return Returns current constructed RichResponse.
|
||||
*/
|
||||
addBrowseCarousel(browseCarousel: string | BrowseCarousel): RichResponse;
|
||||
|
||||
/**
|
||||
* Adds a single suggestion or list of suggestions to list of items.
|
||||
*
|
||||
@@ -325,6 +388,43 @@ export class List {
|
||||
addItems(optionItems: OptionItem | OptionItem[]): List;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing BrowseCarousel with chainable interface.
|
||||
*/
|
||||
export class BrowseCarousel {
|
||||
/**
|
||||
* Constructor for BrowseCarousel. Accepts optional BrowseCarousel to
|
||||
* clone or list of items to copy.
|
||||
*
|
||||
* @param carousel Either a carousel to clone
|
||||
* or an array of BrowseItem to initialize a new carousel
|
||||
*/
|
||||
constructor(carousel?: BrowseCarousel | BrowseItem[]);
|
||||
|
||||
/**
|
||||
* List of 2-20 items to show in this carousel. Required.
|
||||
*/
|
||||
items: BrowseItem[];
|
||||
|
||||
/**
|
||||
* Adds a single item or list of items to the carousel.
|
||||
*
|
||||
* @param browseItems BrowseItems to add.
|
||||
* @return Returns current constructed BrowseCarousel.
|
||||
*/
|
||||
addItems(browseItems: BrowseItem | BrowseItem[]): BrowseCarousel;
|
||||
|
||||
/**
|
||||
* Sets the display options for the images in this carousel.
|
||||
* Use one of the image display constants. If none is chosen,
|
||||
* ImageDisplays.DEFAULT will be enforced.
|
||||
*
|
||||
* @param option The option for displaying the image.
|
||||
* @return Returns current constructed BrowseCarousel.
|
||||
*/
|
||||
setImageDisplay(option: ImageDisplays): BrowseCarousel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Carousel with chainable interface.
|
||||
*/
|
||||
@@ -350,6 +450,120 @@ export class Carousel {
|
||||
* @return Returns current constructed Carousel.
|
||||
*/
|
||||
addItems(optionItems: OptionItem | OptionItem[]): Carousel;
|
||||
|
||||
/**
|
||||
* Sets the display options for the images in this carousel.
|
||||
* Use one of the image display constants. If none is chosen,
|
||||
* ImageDisplays.DEFAULT will be enforced.
|
||||
*
|
||||
* @param option The option for displaying the image.
|
||||
* @return Returns current constructed Carousel.
|
||||
*/
|
||||
setImageDisplay(option: ImageDisplays): Carousel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing Option Items with chainable interface.
|
||||
*/
|
||||
export class BrowseItem {
|
||||
/**
|
||||
* Constructor for BrowseItem. Accepts a title and URL for the Browse Item
|
||||
* card.
|
||||
*
|
||||
* @param title The title of the Browse Item card.
|
||||
* @param url The URL of the link opened by clicking the Browse Item card.
|
||||
*/
|
||||
constructor(title?: string, url?: string);
|
||||
|
||||
/**
|
||||
* Title of the browse item. Required.
|
||||
*/
|
||||
title: string;
|
||||
|
||||
/**
|
||||
* Description text of the item. Optional.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Footer text of the item. Optional.
|
||||
*/
|
||||
footer?: string;
|
||||
|
||||
/**
|
||||
* Image to show on item. Optional.
|
||||
*/
|
||||
image?: Image;
|
||||
|
||||
/**
|
||||
* Url to that clicking the card opens. Optional.
|
||||
*/
|
||||
openUrlAction?: object;
|
||||
|
||||
/**
|
||||
* @return Returns the possible valid values for URL type hints
|
||||
*/
|
||||
urlTypeHints(): object;
|
||||
|
||||
/**
|
||||
* Sets the title for this Browse Item.
|
||||
*
|
||||
* @param title Title to show on item.
|
||||
* @return Returns current constructed BrowseItem.
|
||||
*/
|
||||
setTitle(title: string): BrowseItem;
|
||||
|
||||
/**
|
||||
* Sets the description for this Browse Item.
|
||||
*
|
||||
* @param description Description to show on item.
|
||||
* @return Returns current constructed BrowseItem.
|
||||
*/
|
||||
setDescription(description: string): BrowseItem;
|
||||
|
||||
/**
|
||||
* Sets the footer for this Browse Item.
|
||||
*
|
||||
* @param footerText text to show on item.
|
||||
* @return Returns current constructed BrowseItem.
|
||||
*/
|
||||
setFooter(footerText: string): BrowseItem;
|
||||
|
||||
/**
|
||||
* Sets the image for this Browse Item.
|
||||
*
|
||||
* @param url Image source URL.
|
||||
* @param accessibilityText Text to replace for image for accessibility.
|
||||
* @param width Width of the image.
|
||||
* @param height Height of the image.
|
||||
* @return Returns current constructed BrowseItem.
|
||||
*/
|
||||
setImage(url: string, accessibilityText: string, width?: number, height?: number): BrowseItem;
|
||||
|
||||
/**
|
||||
* Sets the Open URL action - which includes the url and possibly the typeHint
|
||||
*
|
||||
* @param url Image source URL.
|
||||
* @param urlTypeHint One of the typeHints enumerated by this.urlTypeHints()
|
||||
* @return Returns the current constructed BrowseItem
|
||||
*/
|
||||
setOpenUrlAction(url: string, urlTypeHint?: string): BrowseItem;
|
||||
|
||||
/**
|
||||
* Sets the URL target of the BrowseItem card
|
||||
*
|
||||
* @param url Image source URL.
|
||||
* @return Returns the current constructed BrowseItem
|
||||
*/
|
||||
setUrl(url: string): BrowseItem;
|
||||
|
||||
/**
|
||||
* Sets the URL type hint for the BrowseItem card
|
||||
*
|
||||
* @param urlTypeHint One of the typeHints enumerated by this.urlTypeHints()
|
||||
* @return Returns the current constructed BrowseItem
|
||||
*/
|
||||
setUrlTypeHint(urlTypeHint: string): BrowseItem;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -430,6 +644,90 @@ export class OptionItem {
|
||||
addSynonyms(synonyms: string | string[]): OptionItem;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing MediaResponse with chainable interface.
|
||||
*/
|
||||
export class MediaResponse {
|
||||
/**
|
||||
* Constructor for MediaResponse.
|
||||
* @param mediaType Type of the media which defaults to MediaValues.Type.AUDIO
|
||||
*/
|
||||
constructor(mediaType: MediaValues.Type);
|
||||
|
||||
/**
|
||||
* Array of MediaObject held in the MediaResponse.
|
||||
*/
|
||||
mediaObjects: MediaObject[];
|
||||
|
||||
/**
|
||||
* Type of the media within this MediaResponse
|
||||
*/
|
||||
mediaType: MediaValues.Type;
|
||||
|
||||
/**
|
||||
* Adds a single media file or list of media files to the cart.
|
||||
*
|
||||
* @param items Single or Array of MediaObject to add.
|
||||
* @return Returns current constructed MediaResponse.
|
||||
*/
|
||||
addMediaObjects(items: MediaObject | MediaObject[]): MediaResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for initializing and constructing MediaObject with chainable interface.
|
||||
*/
|
||||
export class MediaObject {
|
||||
/**
|
||||
* Constructor for MediaObject.
|
||||
*
|
||||
* @param name Name of the MediaObject.
|
||||
* @param contentUrl URL of the MediaObject.
|
||||
*/
|
||||
constructor(name: string, contentUrl: string);
|
||||
|
||||
/**
|
||||
* Name of the MediaObject.
|
||||
*/
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* MediaObject URL.
|
||||
*/
|
||||
contentUrl: string;
|
||||
|
||||
/**
|
||||
* Description of the MediaObject.
|
||||
*/
|
||||
description?: string;
|
||||
|
||||
/**
|
||||
* Large image.
|
||||
*/
|
||||
largeImage?: Image;
|
||||
|
||||
/**
|
||||
* Icon image.
|
||||
*/
|
||||
icon?: Image;
|
||||
|
||||
/**
|
||||
* Set the description of the item.
|
||||
*
|
||||
* @param description Description of the item.
|
||||
* @return Returns current constructed MediaObject.
|
||||
*/
|
||||
setDescription(description: string): MediaObject;
|
||||
|
||||
/**
|
||||
* Sets the image for this item.
|
||||
*
|
||||
* @param url Image source URL.
|
||||
* @param type Type of image (LARGE or ICON).
|
||||
* @return Returns current constructed MediaObject.
|
||||
*/
|
||||
setImage(url: string, type: MediaValues.ImageType): MediaObject;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if given text contains SSML.
|
||||
* @param text Text to check.
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
let app = new ActiveXObject('Access.Application');
|
||||
app.UserControl = true;
|
||||
|
||||
@@ -6,7 +8,7 @@ app.DoCmd.OpenForm('MyForm', Access.AcFormView.acNormal, '', 'LastName="Smith"')
|
||||
|
||||
// change the contents of a textbox
|
||||
// tslint:disable-next-line:no-unnecessary-type-assertion
|
||||
let textbox = app.Forms.Item('MyForm').Controls.Item('MyTextBox') as Access.TextBox;
|
||||
let textbox = app.Forms('MyForm').Controls('MyTextBox') as Access.TextBox;
|
||||
textbox.Text = 'Not Smith';
|
||||
|
||||
// save the current record on the active form
|
||||
|
||||
Vendored
+795
-1508
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,57 +1,429 @@
|
||||
let obj0 = new ActiveXObject('ADODB.Command');
|
||||
// Note -- running these tests under cscript requires some ES5 polyfills
|
||||
|
||||
let obj1 = new ActiveXObject('ADODB.Connection');
|
||||
/// <reference types="windows-script-host" />
|
||||
/// <reference types="activex-scripting" />
|
||||
|
||||
let obj2 = new ActiveXObject('ADODB.Parameter');
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
let obj3 = new ActiveXObject('ADODB.Record');
|
||||
const toSafeArray = <T>(...items: T[]): SafeArray<T> => {
|
||||
const dict: Scripting.Dictionary<number, T> = new ActiveXObject('Scripting.Dictionary');
|
||||
items.forEach((x, index) => dict.Add(index, x));
|
||||
return dict.Items();
|
||||
};
|
||||
|
||||
let obj4 = new ActiveXObject('ADODB.Recordset');
|
||||
const toConnectionString = (o: { [index: string]: any }) => {
|
||||
o.Provider = o.Provider || 'sqloledb';
|
||||
o['Data Source'] = o['Data Source'] || 'Server';
|
||||
o['Integrated Security'] = o['Integrated Security'] || 'SSPI';
|
||||
|
||||
let obj5 = new ActiveXObject('ADODB.Stream');
|
||||
const parts: string[] = [];
|
||||
for (const key in o) {
|
||||
let val = o[key];
|
||||
if (typeof val === 'string') { val = `'${val}'`; }
|
||||
parts.push(`${key}=${val}`);
|
||||
}
|
||||
return parts.join(';');
|
||||
};
|
||||
|
||||
// open connection to an Excel file
|
||||
let pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx';
|
||||
let conn = new ActiveXObject('ADODB.Connection');
|
||||
conn.Provider = 'Microsoft.ACE.OLEDB.12.0';
|
||||
conn.ConnectionString = `Data Source="${pathToExcelFile}";Extended Properties="Excel 12.0;HDR=Yes"`;
|
||||
conn.Open();
|
||||
const printLine = () => WScript.Echo(new Array(26).join('-'));
|
||||
|
||||
// create a Command to access the data
|
||||
let cmd = new ActiveXObject('ADODB.Command');
|
||||
cmd.ActiveConnection = conn;
|
||||
cmd.CommandText = 'SELECT DISTINCT LastName, CityName FROM [Sheet1$]';
|
||||
// get a Recordset
|
||||
let rs = cmd.Execute();
|
||||
// build a string from the Recordset
|
||||
let s = rs.GetString(ADODB.StringFormatEnum.adClipString, -1, '\t', '\n', '(NULL)');
|
||||
rs.Close();
|
||||
WScript.Echo(s);
|
||||
{
|
||||
// open connection to an Excel file
|
||||
const pathToExcelFile = 'C:\\path\\to\\excel\\file.xlsx';
|
||||
const conn = new ActiveXObject('ADODB.Connection');
|
||||
conn.ConnectionString = toConnectionString({
|
||||
Provider: 'Microsoft.ACE.OLEDB.12.0',
|
||||
'Data Source': pathToExcelFile,
|
||||
'Extended Properties': "Excel 12.0;HDR=Yes"
|
||||
});
|
||||
conn.Open();
|
||||
|
||||
// create a Command to access the data
|
||||
const cmd = new ActiveXObject('ADODB.Command');
|
||||
cmd.ActiveConnection = conn;
|
||||
cmd.CommandText = 'SELECT DISTINCT LastName, CityName FROM [Sheet1$]';
|
||||
// get a Recordset
|
||||
const rs = cmd.Execute() as ADODB.Recordset;
|
||||
// build a string from the Recordset
|
||||
const s = rs.GetString(ADODB.StringFormatEnum.adClipString, -1, '\t', '\n', '(NULL)');
|
||||
rs.Close();
|
||||
WScript.Echo(s);
|
||||
}
|
||||
|
||||
// create a disconnected recordset -- https://support.microsoft.com/en-us/help/184397/how-to-create-ado-disconnected-recordsets-in-vba-c-java
|
||||
(() => {
|
||||
conn = new ActiveXObject('ADODB.Connection');
|
||||
{
|
||||
const conn = new ActiveXObject('ADODB.Connection');
|
||||
conn.Open(); // pass connection details here
|
||||
|
||||
rs = new ActiveXObject('ADODB.Recordset');
|
||||
const rs = new ActiveXObject('ADODB.Recordset');
|
||||
rs.CursorLocation = ADODB.CursorLocationEnum.adUseClient;
|
||||
rs.Open('SELECT * FROM Table1', conn, ADODB.CursorTypeEnum.adOpenForwardOnly, ADODB.LockTypeEnum.adLockBatchOptimistic);
|
||||
rs.ActiveConnection = null;
|
||||
|
||||
const v = rs.Fields.Item(0).Value;
|
||||
const v = rs(0).Value;
|
||||
conn.Close();
|
||||
})();
|
||||
|
||||
// helper function
|
||||
const toSafeArray = <T>(...items: T[]): SafeArray<T> => {
|
||||
const dict = new ActiveXObject('Scripting.Dictionary');
|
||||
items.forEach((x, index) => dict.Add(index, x));
|
||||
return dict.Items() as SafeArray<T>;
|
||||
};
|
||||
}
|
||||
|
||||
// update with SafeArray
|
||||
(() => {
|
||||
{
|
||||
const rs = new ActiveXObject('ADODB.Recordset');
|
||||
rs.Open(); // missing connection details here
|
||||
const fields = toSafeArray('FirstName', 'LastName', 'DOB');
|
||||
const values = toSafeArray<any>('Plony', 'Almony', new Date(1980, 1, 1).getVarDate());
|
||||
rs.Update(fields, values);
|
||||
})();
|
||||
rs.Close();
|
||||
}
|
||||
|
||||
const withConnection = (initialCatalog: string, fn: (conn: ADODB.Connection) => void) => {
|
||||
let conn: ADODB.Connection | null = new ActiveXObject('ADODB.Connection');
|
||||
const connectionString = toConnectionString({
|
||||
'Initial Catalog': initialCatalog
|
||||
});
|
||||
try {
|
||||
conn.Open(connectionString);
|
||||
fn(conn);
|
||||
} catch (e) {
|
||||
WScript.Echo(e.message);
|
||||
} finally {
|
||||
if (conn.State === ADODB.ObjectStateEnum.adStateOpen) {
|
||||
conn.Close();
|
||||
}
|
||||
conn = null;
|
||||
}
|
||||
};
|
||||
|
||||
const withRs = (catalogOrConnection: string | ADODB.Connection, tableOrCommand: string | ADODB.Command, fn: (rs: ADODB.Recordset) => void,
|
||||
type: ADODB.CursorTypeEnum = ADODB.CursorTypeEnum.adOpenUnspecified,
|
||||
location: ADODB.CursorLocationEnum = ADODB.CursorLocationEnum.adUseNone,
|
||||
lockType: ADODB.LockTypeEnum = ADODB.LockTypeEnum.adLockOptimistic
|
||||
) => {
|
||||
let connection = catalogOrConnection;
|
||||
if (typeof connection === 'string') {
|
||||
// expand catalog to full connection string
|
||||
connection = toConnectionString({
|
||||
'Initial Catalog': connection
|
||||
});
|
||||
}
|
||||
|
||||
let rs: ADODB.Recordset | null = null;
|
||||
try {
|
||||
if (typeof tableOrCommand === 'string') {
|
||||
rs = new ActiveXObject('ADODB.Recordset');
|
||||
rs.CursorLocation = location;
|
||||
rs.LockType = lockType;
|
||||
rs.Open(tableOrCommand, connection, type, lockType, ADODB.CommandTypeEnum.adCmdTable);
|
||||
} else {
|
||||
tableOrCommand.ActiveConnection = connection;
|
||||
rs = tableOrCommand.Execute() as ADODB.Recordset;
|
||||
}
|
||||
fn(rs);
|
||||
} catch (e) {
|
||||
WScript.Echo(e.message);
|
||||
} finally {
|
||||
if (rs && rs.State === ADODB.ObjectStateEnum.adStateOpen) {
|
||||
rs.Close();
|
||||
}
|
||||
rs = null;
|
||||
}
|
||||
};
|
||||
|
||||
const withEmployees = (fn: (rs: ADODB.Recordset) => void, type: ADODB.CursorTypeEnum) =>
|
||||
withRs('Northwind', 'Employees', fn, type, ADODB.CursorLocationEnum.adUseClient);
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249882.aspx
|
||||
{
|
||||
withConnection('Northwind', conn => {
|
||||
withEmployees(rs => {
|
||||
const FName = 'first name';
|
||||
const LName = 'last name';
|
||||
|
||||
rs.AddNew();
|
||||
rs('FirstName').Value = FName;
|
||||
rs('LastName').Value = LName;
|
||||
rs.Update();
|
||||
WScript.Echo('New record added.');
|
||||
}, ADODB.CursorTypeEnum.adOpenKeyset);
|
||||
});
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249434.aspx
|
||||
{
|
||||
withConnection('Northwind', conn => {
|
||||
withEmployees(rs => {
|
||||
// Set PageSize to five to display names and hire dates of five employees at a time
|
||||
rs.PageSize = 5;
|
||||
const pageCount = rs.PageCount;
|
||||
|
||||
WScript.Echo(`There are ${pageCount} pages, each containing ${rs.PageSize} or fewer records`.trim());
|
||||
|
||||
for (let i = 1; i <= pageCount; i++) {
|
||||
rs.AbsolutePage = i;
|
||||
|
||||
for (let iRecord = 1; iRecord <= rs.PageSize; iRecord++) {
|
||||
// First column in row contains page number on
|
||||
// first record of each page. Otherwise, the column
|
||||
// contains a non-breaking space.
|
||||
const page = iRecord === 1 ? `Page ${i} of ${rs.PageCount}` : '';
|
||||
|
||||
// First and last name are in first column.
|
||||
const name = `${rs('FirstName')} ${rs('LastName')}`;
|
||||
|
||||
// Hire date in second column.
|
||||
const hireDate = new Date(rs('HireDate').Value as VarDate).toString();
|
||||
|
||||
// Write the row
|
||||
WScript.Echo([page, name, hireDate].join('\t'));
|
||||
|
||||
// Get next record.
|
||||
rs.MoveNext();
|
||||
|
||||
if (rs.EOF) { break; }
|
||||
}
|
||||
}
|
||||
}, ADODB.CursorTypeEnum.adOpenStatic);
|
||||
});
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj250117.aspx
|
||||
{
|
||||
withConnection('Northwind', conn => {
|
||||
withEmployees(rs => {
|
||||
WScript.Echo(['AbsolutePosition', 'Name', 'Hire Date'].join('\t'));
|
||||
|
||||
while (!rs.EOF) {
|
||||
// First column in row contains AbsolutePosition value.
|
||||
const recordCount = `${rs.AbsolutePosition} of ${rs.RecordCount}`;
|
||||
|
||||
// First and last name are in first column.
|
||||
const name = `${rs('FirstName')} ${rs('LastName')}`;
|
||||
|
||||
// Hire date in second column.
|
||||
const hireDate = new Date(rs('HireDate').Value as VarDate).toString();
|
||||
|
||||
WScript.Echo([recordCount, name, hireDate].join('\t'));
|
||||
}
|
||||
}, ADODB.CursorTypeEnum.adOpenStatic);
|
||||
});
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249824.aspx
|
||||
{
|
||||
withConnection('Northwind', conn => {
|
||||
WScript.Echo('Enter city name, and press ENTER:');
|
||||
const cityName = WScript.StdIn.ReadLine();
|
||||
|
||||
const cmdContact = new ActiveXObject('ADODB.Command');
|
||||
cmdContact.CommandText = 'SELECT ContactName FROM Customers WHERE City = ?';
|
||||
cmdContact.ActiveConnection = conn;
|
||||
|
||||
// create parameter and insert variable value
|
||||
const param = cmdContact.CreateParameter('CityName', ADODB.DataTypeEnum.adChar, ADODB.ParameterDirectionEnum.adParamInput, 30, cityName);
|
||||
cmdContact.Parameters.Append(param);
|
||||
|
||||
let rsContact: ADODB.Recordset | null = null;
|
||||
try {
|
||||
// Open a recordset using the command object
|
||||
rsContact = cmdContact.Execute() as ADODB.Recordset;
|
||||
|
||||
while (!rsContact.EOF) {
|
||||
WScript.Echo(rsContact('ContactName'));
|
||||
rsContact.MoveNext();
|
||||
}
|
||||
} catch (e) {
|
||||
WScript.Echo(e.message);
|
||||
} finally {
|
||||
if (rsContact && rsContact.State === ADODB.ObjectStateEnum.adStateOpen) {
|
||||
rsContact.Close();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249056.aspx
|
||||
// https://msdn.microsoft.com/en-us/library/jj249494.aspx
|
||||
{
|
||||
WScript.Echo('Enter royalty value, and press ENTER:');
|
||||
const iRoyalty = parseInt(WScript.StdIn.ReadLine(), 10);
|
||||
if (iRoyalty > -1) {
|
||||
withConnection('pubs', conn => {
|
||||
const cmdByRoyalty = new ActiveXObject('ADODB.Command');
|
||||
cmdByRoyalty.CommandText = 'byroyalty';
|
||||
cmdByRoyalty.CommandType = ADODB.CommandTypeEnum.adCmdStoredProc;
|
||||
cmdByRoyalty.CommandTimeout = 15;
|
||||
|
||||
// The stored procedure called above is as follows:
|
||||
/*
|
||||
CREATE PROCEDURE byroyalty
|
||||
@percentage int
|
||||
AS
|
||||
SELECT au_id from titleauthor
|
||||
WHERE titleauthor.royaltyper = @percentage
|
||||
GO
|
||||
*/
|
||||
|
||||
const prmByRoyalty = new ActiveXObject('ADODB.Parameter');
|
||||
prmByRoyalty.Type = ADODB.DataTypeEnum.adInteger;
|
||||
prmByRoyalty.Size = 3;
|
||||
prmByRoyalty.Direction = ADODB.ParameterDirectionEnum.adParamInput;
|
||||
prmByRoyalty.Value = iRoyalty;
|
||||
cmdByRoyalty.Parameters.Append(prmByRoyalty);
|
||||
|
||||
// open byRoyalty recordset via Command
|
||||
withRs(conn, cmdByRoyalty, rsByRoyalty => {
|
||||
// open authors recordset directly
|
||||
withRs(conn, 'Authors', rsAuthor => {
|
||||
while (!rsByRoyalty.EOF) {
|
||||
// set filter
|
||||
rsAuthor.Filter = `au_id='${rsByRoyalty('au_id')}'`;
|
||||
|
||||
// write author name
|
||||
WScript.Echo(`${rsAuthor('au_fname')} ${rsAuthor('au_lname')}`);
|
||||
}
|
||||
|
||||
// get next record
|
||||
rsByRoyalty.MoveNext();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj250032.aspx
|
||||
{
|
||||
withRs('Northwind', 'Suppliers', rsSuppliers => {
|
||||
WScript.Echo(['Field Value', 'Defined Size', 'Actual Size'].join('\t'));
|
||||
while (!rsSuppliers.EOF) {
|
||||
const fld = rsSuppliers('CompanyName');
|
||||
WScript.Echo([fld.Value, fld.DefinedSize, fld.ActualSize].join('\t'));
|
||||
}
|
||||
rsSuppliers.MoveNext();
|
||||
});
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249928.aspx
|
||||
{
|
||||
withRs('Northwind', 'Customers', rs => {
|
||||
const loop20 = () => {
|
||||
const start = new Date().getTime();
|
||||
|
||||
// loop through the recordset 20 times
|
||||
for (let i = 0; i < 20; i++) {
|
||||
rs.MoveFirst();
|
||||
while (!rs.EOF) {
|
||||
// do something with the record
|
||||
const strTemp = rs('CompanyName').Value as string;
|
||||
rs.MoveNext();
|
||||
}
|
||||
}
|
||||
|
||||
const end = new Date().getTime();
|
||||
return end - start;
|
||||
};
|
||||
|
||||
const noCache = loop20();
|
||||
|
||||
// cache records in groups of 30
|
||||
rs.MoveFirst();
|
||||
rs.CacheSize = 30;
|
||||
|
||||
const cache = loop20();
|
||||
|
||||
WScript.Echo(`No cache: ${noCache}; with cache: ${cache}`);
|
||||
}, ADODB.CursorTypeEnum.adOpenUnspecified, ADODB.CursorLocationEnum.adUseClient);
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249157.aspx
|
||||
{
|
||||
const printAuthorRecordset = (caption: string, rs: ADODB.Recordset) => {
|
||||
printLine();
|
||||
WScript.Echo(`**${caption}**`);
|
||||
while (!rs.EOF) {
|
||||
// write current row's data
|
||||
const name = `${rs('au_fname')} ${rs('au_lname')}`;
|
||||
WScript.Echo(name);
|
||||
|
||||
// get next record
|
||||
rs.MoveNext;
|
||||
}
|
||||
};
|
||||
|
||||
WScript.Echo('Enter last name of author to find (e.g., Ringer) and then press ENTER:');
|
||||
const lastName = WScript.StdIn.ReadLine() || '';
|
||||
if (lastName.length > 0) {
|
||||
withConnection('pubs', conn => {
|
||||
// command object parameters
|
||||
const cmdAuthor = new ActiveXObject('ADODB.Command');
|
||||
cmdAuthor.CommandText = 'SELECT * FROM Authors WHERE au_name = ?';
|
||||
const lastNameParameter = cmdAuthor.CreateParameter('Last Name', ADODB.DataTypeEnum.adChar, ADODB.ParameterDirectionEnum.adParamInput, 20, lastName);
|
||||
cmdAuthor.Parameters.Append(lastNameParameter);
|
||||
cmdAuthor.ActiveConnection = conn;
|
||||
|
||||
// recordset from command.execute
|
||||
const rsAuthor = cmdAuthor.Execute() as ADODB.Recordset;
|
||||
|
||||
// recordset from connection.execute
|
||||
const rsAuthor2 = conn.Execute('SELECT * FROM Authors') as ADODB.Recordset;
|
||||
|
||||
const errs = collectionToArray(conn.Errors);
|
||||
if (errs.length > 0) {
|
||||
for (const err of errs) {
|
||||
WScript.Echo(err);
|
||||
}
|
||||
}
|
||||
conn.Errors.Clear();
|
||||
|
||||
printAuthorRecordset('Command.Execute results', rsAuthor);
|
||||
printAuthorRecordset('Connection.Execute results', rsAuthor2);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/jj249466.aspx
|
||||
{
|
||||
withConnection('Northwind', conn => {
|
||||
const sql = 'SELECT * FROM Customers';
|
||||
withRs(conn, sql, rs => {
|
||||
rs.MoveFirst();
|
||||
if (rs.RecordCount === 0) {
|
||||
WScript.Echo(`No records matched for '${sql}'`);
|
||||
return;
|
||||
}
|
||||
|
||||
// print headings for each field name
|
||||
WScript.Echo(collectionToArray(rs.Fields).map(fld => fld.Name).join('\t'));
|
||||
|
||||
// JScript doesn't support multi-dimensional arrays
|
||||
// so we'll convert the returned array to a single
|
||||
// dimensional JScript array and then display the data.
|
||||
const safeArray = rs.GetRows();
|
||||
const data = new VBArray(safeArray).toArray();
|
||||
|
||||
const fieldCount = rs.Fields.Count;
|
||||
|
||||
data.forEach((cellValue, index) => {
|
||||
const currentField = index % fieldCount;
|
||||
|
||||
// don't print tab character for first and last columns
|
||||
if (currentField > 0 && currentField < fieldCount - 1) {
|
||||
WScript.StdOut.Write('\t');
|
||||
}
|
||||
|
||||
const displayValue = cellValue === null ? '-null-' : cellValue;
|
||||
if (currentField === fieldCount - 1) {
|
||||
WScript.StdOut.WriteLine(displayValue);
|
||||
} else {
|
||||
WScript.StdOut.Write(displayValue);
|
||||
}
|
||||
});
|
||||
}, ADODB.CursorTypeEnum.adOpenKeyset, ADODB.CursorLocationEnum.adUseClient, ADODB.LockTypeEnum.adLockOptimistic);
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+220
-182
@@ -2,7 +2,9 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/jj249010.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace ADODB {
|
||||
const enum ADCPROP_ASYNCTHREADPRIORITY_ENUM {
|
||||
@@ -594,10 +596,19 @@ declare namespace ADODB {
|
||||
adXactSyncPhaseOne = 1048576,
|
||||
}
|
||||
|
||||
class Bookmark {
|
||||
private 'ADODB.Bookmark_typekey': Bookmark;
|
||||
private constructor();
|
||||
}
|
||||
|
||||
class Command {
|
||||
private 'ADODB.Command_typekey': Command;
|
||||
private constructor();
|
||||
ActiveConnection: Connection;
|
||||
|
||||
/**
|
||||
* Sets or returns a String value that contains a definition for a connection if the connection is closed, or a Variant containing the current Connection object if the connection is open. Default is a null object reference.
|
||||
*/
|
||||
ActiveConnection: string | Connection | null;
|
||||
Cancel(): void;
|
||||
CommandStream: any;
|
||||
CommandText: string;
|
||||
@@ -605,28 +616,40 @@ declare namespace ADODB {
|
||||
CommandType: CommandTypeEnum;
|
||||
|
||||
/**
|
||||
* @param string [Name='']
|
||||
* @param ADODB.DataTypeEnum [Type=0]
|
||||
* @param ADODB.ParameterDirectionEnum [Direction=1]
|
||||
* @param number [Size=0]
|
||||
* @param Name [Name='']
|
||||
* @param Type [Type=0]
|
||||
* @param Direction [Direction=1]
|
||||
* @param Size [Size=0]
|
||||
*/
|
||||
CreateParameter(Name?: string, Type?: DataTypeEnum, Direction?: ParameterDirectionEnum, Size?: number, Value?: any): Parameter;
|
||||
Dialect: string;
|
||||
|
||||
/** @param number [Options=-1] */
|
||||
Execute(RecordsAffected?: number, Parameters?: SafeArray, Options?: number): Recordset;
|
||||
/**
|
||||
* @param Options [Options=-1]
|
||||
*
|
||||
* The **RecordsAffected** parameter is meant to take a variable to be modified by reference, which is not supported by Javascript
|
||||
*
|
||||
* The return value is as follows:
|
||||
*
|
||||
* * If the **adExecuteNoRecords** option is passed in, the method will return `null`. Otherwise:
|
||||
* * If the command specifies a row-returning query, then the method will return a new read-only, forward-only **Recordset** object with the results.
|
||||
* * If the command isn't intended to return results (e.g. an `UPDATE` statement), a closed empty **Recordset** will be returned.
|
||||
*/
|
||||
Execute(RecordsAffected?: undefined, Parameters?: SafeArray, Options?: number): Recordset | null;
|
||||
Name: string;
|
||||
NamedParameters: boolean;
|
||||
readonly Parameters: Parameters;
|
||||
Prepared: boolean;
|
||||
readonly Properties: Properties;
|
||||
readonly State: number;
|
||||
readonly State: ObjectStateEnum;
|
||||
}
|
||||
|
||||
class Connection {
|
||||
private 'ADODB.Connection_typekey': Connection;
|
||||
private constructor();
|
||||
Attributes: number;
|
||||
|
||||
/** Sum of one or more of the values in the **XactAttributeEnum** enum */
|
||||
Attributes: XactAttributeEnum;
|
||||
BeginTrans(): number;
|
||||
Cancel(): void;
|
||||
Close(): void;
|
||||
@@ -638,23 +661,45 @@ declare namespace ADODB {
|
||||
DefaultDatabase: string;
|
||||
readonly Errors: Errors;
|
||||
|
||||
/** @param number [Options=-1] */
|
||||
Execute(CommandText: string, RecordsAffected: any, Options?: number): Recordset;
|
||||
/**
|
||||
* @param Options [Options=-1]
|
||||
*
|
||||
* The **RecordsAffected** parameter is meant to take a variable to be modified by reference, which is not supported by Javascript
|
||||
*
|
||||
* The return value is as follows:
|
||||
*
|
||||
* * If the **adExecuteNoRecords** option is passed in, the method will return `null`. Otherwise:
|
||||
* * If **CommandText** specifies a row-returning query, then the method will return a new read-only, forward-only **Recordset** object with the results
|
||||
* * If **CommandText** isn't intended to return results (e.g. an `UPDATE` statement), a closed empty **Recordset** will be returned.
|
||||
*/
|
||||
Execute(CommandText: string, RecordsAffected?: undefined, Options?: CommandTypeEnum | ExecuteOptionEnum): Recordset | null;
|
||||
IsolationLevel: IsolationLevelEnum;
|
||||
Mode: ConnectModeEnum;
|
||||
|
||||
/**
|
||||
* @param string [ConnectionString='']
|
||||
* @param string [UserID='']
|
||||
* @param string [Password='']
|
||||
* @param number [Options=-1]
|
||||
* @param ConnectionString [ConnectionString='']
|
||||
* @param UserID [UserID='']
|
||||
* @param Password [Password='']
|
||||
* @param Options [Options=-1]
|
||||
*/
|
||||
Open(ConnectionString?: string, UserID?: string, Password?: string, Options?: number): void;
|
||||
OpenSchema(Schema: SchemaEnum, Restrictions?: any, SchemaID?: any): Recordset;
|
||||
|
||||
/**
|
||||
* Returns a Recordset object that contains schema information
|
||||
* @param Schema Type of schema query to run
|
||||
* @param Restrictions A SafeArray of query constraints; depends on the [type of the schema query](https://msdn.microsoft.com/en-us/library/jj249359.aspx)
|
||||
*/
|
||||
OpenSchema(Schema: SchemaEnum, Restrictions?: SafeArray<string>): Recordset;
|
||||
|
||||
/**
|
||||
* Returns a Recordset object that contains schema information, for a provider-specific schema query type
|
||||
* @param SchemaID The GUID for a provider-schema query not defined by the OLE DB specification.
|
||||
*/
|
||||
OpenSchema(Schema: SchemaEnum.adSchemaProviderSpecific, Restrictions: SafeArray<string>, SchemaID: string): Recordset;
|
||||
readonly Properties: Properties;
|
||||
Provider: string;
|
||||
RollbackTrans(): void;
|
||||
readonly State: number;
|
||||
readonly State: ObjectStateEnum;
|
||||
readonly Version: string;
|
||||
}
|
||||
|
||||
@@ -670,13 +715,12 @@ declare namespace ADODB {
|
||||
readonly SQLState: string;
|
||||
}
|
||||
|
||||
class Errors {
|
||||
private 'ADODB.Errors_typekey': Errors;
|
||||
private constructor();
|
||||
interface Errors {
|
||||
Clear(): void;
|
||||
readonly Count: number;
|
||||
Item(Index: any): Error;
|
||||
Refresh(): void;
|
||||
(Index: any): Error;
|
||||
}
|
||||
|
||||
class Field {
|
||||
@@ -684,7 +728,9 @@ declare namespace ADODB {
|
||||
private constructor();
|
||||
readonly ActualSize: number;
|
||||
AppendChunk(Data: any): void;
|
||||
Attributes: number;
|
||||
|
||||
/** Sum of one or more of the values in the **FieldAttributeEnum** enum */
|
||||
Attributes: FieldAttributeEnum;
|
||||
DataFormat: any;
|
||||
DefinedSize: number;
|
||||
GetChunk(Length: number): any;
|
||||
@@ -699,37 +745,37 @@ declare namespace ADODB {
|
||||
Value: any;
|
||||
}
|
||||
|
||||
class Fields {
|
||||
private 'ADODB.Fields_typekey': Fields;
|
||||
private constructor();
|
||||
|
||||
interface Fields {
|
||||
/**
|
||||
* @param number [DefinedSize=0]
|
||||
* @param ADODB.FieldAttributeEnum [Attrib=-1]
|
||||
* @param DefinedSize [DefinedSize=0]
|
||||
* @param Attrib [Attrib=-1]
|
||||
*/
|
||||
_Append(Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum): void;
|
||||
|
||||
/**
|
||||
* @param number [DefinedSize=0]
|
||||
* @param ADODB.FieldAttributeEnum [Attrib=-1]
|
||||
* @param DefinedSize [DefinedSize=0]
|
||||
* @param Attrib [Attrib=-1]
|
||||
*/
|
||||
Append(Name: string, Type: DataTypeEnum, DefinedSize?: number, Attrib?: FieldAttributeEnum, FieldValue?: any): void;
|
||||
CancelUpdate(): void;
|
||||
readonly Count: number;
|
||||
Delete(Index: any): void;
|
||||
Item(Index: any): Field;
|
||||
Delete(Index: string | number): void;
|
||||
Item(Index: string | number): Field;
|
||||
Refresh(): void;
|
||||
|
||||
/** @param ADODB.ResyncEnum [ResyncValues=2] */
|
||||
/** @param ResyncValues [ResyncValues=2] */
|
||||
Resync(ResyncValues?: ResyncEnum): void;
|
||||
Update(): void;
|
||||
(Index: string | number): Field;
|
||||
}
|
||||
|
||||
class Parameter {
|
||||
private 'ADODB.Parameter_typekey': Parameter;
|
||||
private constructor();
|
||||
AppendChunk(Val: any): void;
|
||||
Attributes: number;
|
||||
|
||||
/** Sum of one or more of the values in the **ParameterAttributesEnum** enum */
|
||||
Attributes: ParameterAttributesEnum;
|
||||
Direction: ParameterDirectionEnum;
|
||||
Name: string;
|
||||
NumericScale: number;
|
||||
@@ -740,28 +786,28 @@ declare namespace ADODB {
|
||||
Value: any;
|
||||
}
|
||||
|
||||
class Parameters {
|
||||
private 'ADODB.Parameters_typekey': Parameters;
|
||||
private constructor();
|
||||
interface Parameters {
|
||||
Append(Object: any): void;
|
||||
readonly Count: number;
|
||||
Delete(Index: any): void;
|
||||
Item(Index: any): Parameter;
|
||||
Delete(Index: string | number): void;
|
||||
Item(Index: string | number): Parameter;
|
||||
Refresh(): void;
|
||||
(Index: string | number): Parameter;
|
||||
}
|
||||
|
||||
class Properties {
|
||||
private 'ADODB.Properties_typekey': Properties;
|
||||
private constructor();
|
||||
interface Properties {
|
||||
readonly Count: number;
|
||||
Item(Index: any): Property;
|
||||
Item(Index: string | number): Property;
|
||||
Refresh(): void;
|
||||
(Index: string | number): Property;
|
||||
}
|
||||
|
||||
class Property {
|
||||
private 'ADODB.Property_typekey': Property;
|
||||
private constructor();
|
||||
Attributes: number;
|
||||
|
||||
/** Sum of one or more of the values in the **PropertyAttributesEnum** enum */
|
||||
Attributes: PropertyAttributesEnum;
|
||||
readonly Name: string;
|
||||
readonly Type: DataTypeEnum;
|
||||
Value: any;
|
||||
@@ -770,23 +816,27 @@ declare namespace ADODB {
|
||||
class Record {
|
||||
private 'ADODB.Record_typekey': Record;
|
||||
private constructor();
|
||||
ActiveConnection: any;
|
||||
|
||||
/**
|
||||
* Sets or returns a String value that contains a definition for a connection if the connection is closed, or a Variant containing the current Connection object if the connection is open. Default is a null object reference.
|
||||
*/
|
||||
ActiveConnection: string | Connection | null;
|
||||
Cancel(): void;
|
||||
Close(): void;
|
||||
|
||||
/**
|
||||
* @param string [Source='']
|
||||
* @param string [Destination='']
|
||||
* @param string [UserName='']
|
||||
* @param string [Password='']
|
||||
* @param ADODB.CopyRecordOptionsEnum [Options=-1]
|
||||
* @param boolean [Async=false]
|
||||
* @param Source [Source='']
|
||||
* @param Destination [Destination='']
|
||||
* @param UserName [UserName='']
|
||||
* @param Password [Password='']
|
||||
* @param Options [Options=-1]
|
||||
* @param Async [Async=false]
|
||||
*/
|
||||
CopyRecord(Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: CopyRecordOptionsEnum, Async?: boolean): string;
|
||||
|
||||
/**
|
||||
* @param string [Source='']
|
||||
* @param boolean [Async=false]
|
||||
* @param Source [Source='']
|
||||
* @param Async [Async=false]
|
||||
*/
|
||||
DeleteRecord(Source?: string, Async?: boolean): void;
|
||||
readonly Fields: Fields;
|
||||
@@ -794,137 +844,174 @@ declare namespace ADODB {
|
||||
Mode: ConnectModeEnum;
|
||||
|
||||
/**
|
||||
* @param string [Source='']
|
||||
* @param string [Destination='']
|
||||
* @param string [UserName='']
|
||||
* @param string [Password='']
|
||||
* @param ADODB.MoveRecordOptionsEnum [Options=-1]
|
||||
* @param boolean [Async=false]
|
||||
* @param Source [Source='']
|
||||
* @param Destination [Destination='']
|
||||
* @param UserName [UserName='']
|
||||
* @param Password [Password='']
|
||||
* @param Options [Options=-1]
|
||||
* @param Async [Async=false]
|
||||
*/
|
||||
MoveRecord(Source?: string, Destination?: string, UserName?: string, Password?: string, Options?: MoveRecordOptionsEnum, Async?: boolean): string;
|
||||
|
||||
/**
|
||||
* @param ADODB.ConnectModeEnum [Mode=0]
|
||||
* @param ADODB.RecordCreateOptionsEnum [CreateOptions=-1]
|
||||
* @param ADODB.RecordOpenOptionsEnum [Options=-1]
|
||||
* @param string [UserName='']
|
||||
* @param string [Password='']
|
||||
* Source may be:
|
||||
* * A URL. If the protocol for the URL is http, then the Internet Provider will be invoked by default. If the URL points to a node that contains an executable script (such as an .ASP page), then a Record containing the source rather than the executed contents is opened by default. Use the Options argument to modify this behavior.
|
||||
* * A Record object. A Record object opened from another Record will clone the original Record object.
|
||||
* * A Command object. The opened Record object represents the single row returned by executing the Command. If the results contain more than a single row, the contents of the first row are placed in the record and an error may be added to the Errors collection.
|
||||
* * A SQL SELECT statement. The opened Record object represents the single row returned by executing the contents of the string. If the results contain more than a single row, the contents of the first row are placed in the record and an error may be added to the Errors collection.
|
||||
* * A table name.
|
||||
*
|
||||
* @param Mode [Mode=0]
|
||||
* @param CreateOptions [CreateOptions=-1]
|
||||
* @param Options [Options=-1]
|
||||
* @param UserName [UserName='']
|
||||
* @param Password [Password='']
|
||||
*/
|
||||
Open(Source: any, ActiveConnection: any, Mode?: ConnectModeEnum, CreateOptions?: RecordCreateOptionsEnum, Options?: RecordOpenOptionsEnum, UserName?: string, Password?: string): void;
|
||||
Open(Source?: string | Record | Recordset | Command, ActiveConnection?: string | Connection, Mode?: ConnectModeEnum, CreateOptions?: RecordCreateOptionsEnum, Options?: RecordOpenOptionsEnum, UserName?: string, Password?: string): void;
|
||||
readonly ParentURL: string;
|
||||
readonly Properties: Properties;
|
||||
readonly RecordType: RecordTypeEnum;
|
||||
Source: any;
|
||||
Source: string | Recordset | Command;
|
||||
readonly State: ObjectStateEnum;
|
||||
}
|
||||
|
||||
class Recordset {
|
||||
private 'ADODB.Recordset_typekey': Recordset;
|
||||
private constructor();
|
||||
interface Recordset {
|
||||
_xClone(): Recordset;
|
||||
|
||||
/** @param ADODB.AffectEnum [AffectRecords=3] */
|
||||
/** @param AffectRecords [AffectRecords=3] */
|
||||
_xResync(AffectRecords?: AffectEnum): void;
|
||||
|
||||
/**
|
||||
* @param string [FileName='']
|
||||
* @param ADODB.PersistFormatEnum [PersistFormat=0]
|
||||
* @param FileName [FileName='']
|
||||
* @param PersistFormat [PersistFormat=0]
|
||||
*/
|
||||
_xSave(FileName?: string, PersistFormat?: PersistFormatEnum): void;
|
||||
AbsolutePage: PositionEnum;
|
||||
AbsolutePosition: PositionEnum;
|
||||
readonly ActiveCommand: any;
|
||||
ActiveConnection: any;
|
||||
AddNew(FieldList?: any, Values?: any): void;
|
||||
readonly ActiveCommand?: Command;
|
||||
|
||||
/**
|
||||
* Sets or returns a String value that contains a definition for a connection if the connection is closed, or a Variant containing the current Connection object if the connection is open. Default is a null object reference.
|
||||
*/
|
||||
ActiveConnection: string | Connection | null;
|
||||
AddNew(): void;
|
||||
AddNew(Fields: SafeArray<string | number>, Values: SafeArray): void;
|
||||
AddNew(Field: string, Value: any): void;
|
||||
readonly BOF: boolean;
|
||||
Bookmark: any;
|
||||
Bookmark: Bookmark;
|
||||
CacheSize: number;
|
||||
Cancel(): void;
|
||||
|
||||
/** @param ADODB.AffectEnum [AffectRecords=3] */
|
||||
/** @param AffectRecords [AffectRecords=3] */
|
||||
CancelBatch(AffectRecords?: AffectEnum): void;
|
||||
CancelUpdate(): void;
|
||||
|
||||
/** @param ADODB.LockTypeEnum [LockType=-1] */
|
||||
/** @param LockType [LockType=-1] */
|
||||
Clone(LockType?: LockTypeEnum): Recordset;
|
||||
Close(): void;
|
||||
Collect(Index: any): any;
|
||||
CompareBookmarks(Bookmark1: any, Bookmark2: any): CompareEnum;
|
||||
CompareBookmarks(Bookmark1: Bookmark, Bookmark2: Bookmark): CompareEnum;
|
||||
CursorLocation: CursorLocationEnum;
|
||||
CursorType: CursorTypeEnum;
|
||||
DataMember: string;
|
||||
DataSource: any;
|
||||
|
||||
/** @param ADODB.AffectEnum [AffectRecords=1] */
|
||||
/** @param AffectRecords [AffectRecords=1] */
|
||||
Delete(AffectRecords?: AffectEnum): void;
|
||||
readonly EditMode: EditModeEnum;
|
||||
readonly EOF: boolean;
|
||||
readonly Fields: Fields;
|
||||
Filter: any;
|
||||
|
||||
/**
|
||||
* @param number [SkipRecords=0]
|
||||
* @param ADODB.SearchDirectionEnum [SearchDirection=1]
|
||||
* Sets or returns one of the following:
|
||||
* * Criteria string — a string made up of one or more individual clauses concatenated with AND or OR operators.
|
||||
* * Array of bookmarks — an array of unique bookmark values that point to records in the Recordset object.
|
||||
* * A FilterGroupEnum value
|
||||
*/
|
||||
Find(Criteria: string, SkipRecords?: number, SearchDirection?: SearchDirectionEnum, Start?: any): void;
|
||||
|
||||
/** @param number [Rows=-1] */
|
||||
GetRows(Rows?: number, Start?: any, Fields?: any): any;
|
||||
Filter: string | SafeArray<Bookmark> | FilterGroupEnum;
|
||||
|
||||
/**
|
||||
* @param ADODB.StringFormatEnum [StringFormat=2]
|
||||
* @param number [NumRows=-1]
|
||||
* @param string [ColumnDelimeter='']
|
||||
* @param string [RowDelimeter='']
|
||||
* @param string [NullExpr='']
|
||||
* @param SkipRecords [SkipRecords=0]
|
||||
* @param SearchDirection [SearchDirection=1]
|
||||
*/
|
||||
Find(Criteria: string, SkipRecords?: number, SearchDirection?: SearchDirectionEnum, Start?: Bookmark): void;
|
||||
|
||||
/** @param Rows [Rows=-1] */
|
||||
GetRows(Rows?: number, Start?: string | Bookmark | BookmarkEnum, Fields?: string | SafeArray<string | number>): SafeArray;
|
||||
|
||||
/**
|
||||
* @param StringFormat [StringFormat=2]
|
||||
* @param NumRows [NumRows=-1]
|
||||
* @param ColumnDelimeter [ColumnDelimeter='']
|
||||
* @param RowDelimeter [RowDelimeter='']
|
||||
* @param NullExpr [NullExpr='']
|
||||
*/
|
||||
GetString(StringFormat?: StringFormatEnum, NumRows?: number, ColumnDelimeter?: string, RowDelimeter?: string, NullExpr?: string): string;
|
||||
Index: string;
|
||||
LockType: LockTypeEnum;
|
||||
MarshalOptions: MarshalOptionsEnum;
|
||||
MaxRecords: number;
|
||||
Move(NumRecords: number, Start?: any): void;
|
||||
Move(NumRecords: number, Start?: string | Bookmark | BookmarkEnum): void;
|
||||
MoveFirst(): void;
|
||||
MoveLast(): void;
|
||||
MoveNext(): void;
|
||||
MovePrevious(): void;
|
||||
NextRecordset(RecordsAffected?: any): Recordset;
|
||||
|
||||
/** Since Javascript doesn't support byref parameters, the RecordsAffected parameter cannot be used */
|
||||
NextRecordset(): Recordset;
|
||||
|
||||
/**
|
||||
* @param ADODB.CursorTypeEnum [CursorType=-1]
|
||||
* @param ADODB.LockTypeEnum [LockType=-1]
|
||||
* @param number [Options=-1]
|
||||
* @param CursorType [CursorType=-1]
|
||||
* @param LockType [LockType=-1]
|
||||
* @param Options [Options=-1]
|
||||
*/
|
||||
Open(Source: any, ActiveConnection: any, CursorType?: CursorTypeEnum, LockType?: LockTypeEnum, Options?: number): void;
|
||||
Open(Source: Command, ActiveConnection: null, CursorType?: CursorTypeEnum, LockType?: LockTypeEnum, Options?: CommandTypeEnum | ExecuteOptionEnum): void;
|
||||
Open(Source?: Stream): void;
|
||||
|
||||
/**
|
||||
* @param CursorType [CursorType=-1]
|
||||
* @param LockType [LockType=-1]
|
||||
* @param Options [Options=-1]
|
||||
*/
|
||||
Open(Source: string, ActiveConnection: string | Connection, CursorType?: CursorTypeEnum, LockType?: LockTypeEnum, Options?: CommandTypeEnum | ExecuteOptionEnum): void;
|
||||
readonly PageCount: number;
|
||||
PageSize: number;
|
||||
readonly Properties: Properties;
|
||||
readonly RecordCount: number;
|
||||
|
||||
/** @param number [Options=-1] */
|
||||
/** @param Options [Options=-1] */
|
||||
Requery(Options?: number): void;
|
||||
|
||||
/**
|
||||
* @param ADODB.AffectEnum [AffectRecords=3]
|
||||
* @param ADODB.ResyncEnum [ResyncValues=2]
|
||||
* @param AffectRecords [AffectRecords=3]
|
||||
* @param ResyncValues [ResyncValues=2]
|
||||
*/
|
||||
Resync(AffectRecords?: AffectEnum, ResyncValues?: ResyncEnum): void;
|
||||
|
||||
/** @param ADODB.PersistFormatEnum [PersistFormat=0] */
|
||||
Save(Destination: any, PersistFormat?: PersistFormatEnum): void;
|
||||
/** @param PersistFormat [PersistFormat=0] */
|
||||
Save(Destination: string | Stream, PersistFormat?: PersistFormatEnum): void;
|
||||
|
||||
/** @param ADODB.SeekEnum [SeekOption=1] */
|
||||
/**
|
||||
* @param SeekOption [SeekOption=1]
|
||||
*
|
||||
* For a single-column index, pass in a single value to seek in the column of the index
|
||||
*
|
||||
* For a multi-column index, pass in a SafeArray containing the multiple values to seek in the columns of the index.
|
||||
*/
|
||||
Seek(KeyValues: any, SeekOption?: SeekEnum): void;
|
||||
Sort: string;
|
||||
Source: any;
|
||||
readonly State: number;
|
||||
Source: string | Command;
|
||||
readonly State: ObjectStateEnum;
|
||||
readonly Status: number;
|
||||
StayInSync: boolean;
|
||||
Supports(CursorOptions: CursorOptionEnum): boolean;
|
||||
Update(Fields?: string | SafeArray<string | number>, Values?: any): void;
|
||||
Update(): void;
|
||||
Update(Fields: SafeArray<string | number>, Values: SafeArray): void;
|
||||
Update(Field: string, Value: any): void;
|
||||
|
||||
/** @param ADODB.AffectEnum [AffectRecords=3] */
|
||||
/** @param AffectRecords [AffectRecords=3] */
|
||||
UpdateBatch(AffectRecords?: AffectEnum): void;
|
||||
(FieldIndex: string | number): Field;
|
||||
}
|
||||
|
||||
class Stream {
|
||||
@@ -934,7 +1021,7 @@ declare namespace ADODB {
|
||||
Charset: string;
|
||||
Close(): void;
|
||||
|
||||
/** @param number [CharNumber=-1] */
|
||||
/** @param CharNumber [CharNumber=-1] */
|
||||
CopyTo(DestStream: Stream, CharNumber?: number): void;
|
||||
readonly EOS: boolean;
|
||||
Flush(): void;
|
||||
@@ -943,21 +1030,21 @@ declare namespace ADODB {
|
||||
Mode: ConnectModeEnum;
|
||||
|
||||
/**
|
||||
* @param ADODB.ConnectModeEnum [Mode=0]
|
||||
* @param ADODB.StreamOpenOptionsEnum [Options=-1]
|
||||
* @param string [UserName='']
|
||||
* @param string [Password='']
|
||||
* @param Mode [Mode=0]
|
||||
* @param Options [Options=-1]
|
||||
* @param UserName [UserName='']
|
||||
* @param Password [Password='']
|
||||
*/
|
||||
Open(Source: any, Mode?: ConnectModeEnum, Options?: StreamOpenOptionsEnum, UserName?: string, Password?: string): void;
|
||||
Open(Source?: string | Record, Mode?: ConnectModeEnum, Options?: StreamOpenOptionsEnum, UserName?: string, Password?: string): void;
|
||||
Position: number;
|
||||
|
||||
/** @param number [NumBytes=-1] */
|
||||
/** @param NumBytes [NumBytes=-1] */
|
||||
Read(NumBytes?: number): any;
|
||||
|
||||
/** @param number [NumChars=-1] */
|
||||
/** @param NumChars [NumChars=-1] */
|
||||
ReadText(NumChars?: number): string;
|
||||
|
||||
/** @param ADODB.SaveOptionsEnum [Options=1] */
|
||||
/** @param Options [Options=1] */
|
||||
SaveToFile(FileName: string, Options?: SaveOptionsEnum): void;
|
||||
SetEOS(): void;
|
||||
readonly Size: number;
|
||||
@@ -966,7 +1053,7 @@ declare namespace ADODB {
|
||||
Type: StreamTypeEnum;
|
||||
Write(Buffer: any): void;
|
||||
|
||||
/** @param ADODB.StreamWriteEnum [Options=0] */
|
||||
/** @param Options [Options=0] */
|
||||
WriteText(Data: string, Options?: StreamWriteEnum): void;
|
||||
}
|
||||
|
||||
@@ -1009,60 +1096,22 @@ declare namespace ADODB {
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
on(
|
||||
obj: ADODB.Connection, event: 'BeginTransComplete', argNames: ['TransactionLevel', 'pError', 'adStatus', 'pConnection'], handler: (
|
||||
this: ADODB.Connection, parameter: {
|
||||
readonly TransactionLevel: number, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pConnection: ADODB.Connection}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Connection, event: 'CommitTransComplete' | 'ConnectComplete' | 'InfoMessage' | 'RollbackTransComplete', argNames: ['pError', 'adStatus', 'pConnection'],
|
||||
handler: (this: ADODB.Connection, parameter: {readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pConnection: ADODB.Connection}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Connection, event: 'Disconnect', argNames: ['adStatus', 'pConnection'], handler: (
|
||||
this: ADODB.Connection, parameter: {adStatus: ADODB.EventStatusEnum, readonly pConnection: ADODB.Connection}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Connection, event: 'ExecuteComplete', argNames: ADODB.EventHelperTypes.Connection_ExecuteComplete_ArgNames, handler: (
|
||||
this: ADODB.Connection, parameter: ADODB.EventHelperTypes.Connection_ExecuteComplete_Parameter) => void): void;
|
||||
on(
|
||||
obj: ADODB.Connection, event: 'WillConnect', argNames: ADODB.EventHelperTypes.Connection_WillConnect_ArgNames, handler: (
|
||||
this: ADODB.Connection, parameter: ADODB.EventHelperTypes.Connection_WillConnect_Parameter) => void): void;
|
||||
on(
|
||||
obj: ADODB.Connection, event: 'WillExecute', argNames: ADODB.EventHelperTypes.Connection_WillExecute_ArgNames, handler: (
|
||||
this: ADODB.Connection, parameter: ADODB.EventHelperTypes.Connection_WillExecute_Parameter) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'EndOfRecordset', argNames: ['fMoreData', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {fMoreData: boolean, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'FetchComplete', argNames: ['pError', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'FetchProgress', argNames: ['Progress', 'MaxProgress', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {readonly Progress: number, readonly MaxProgress: number, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'FieldChangeComplete', argNames: ['cFields', 'Fields', 'pError', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {
|
||||
readonly cFields: number, readonly Fields: any, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'MoveComplete' | 'RecordsetChangeComplete', argNames: ['adReason', 'pError', 'adStatus', 'pRecordset'],
|
||||
handler: (
|
||||
this: ADODB.Recordset, parameter: {
|
||||
readonly adReason: ADODB.EventReasonEnum, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'RecordChangeComplete', argNames: ['adReason', 'cRecords', 'pError', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {
|
||||
readonly adReason: ADODB.EventReasonEnum, readonly cRecords: number, readonly pError: ADODB.Error,
|
||||
adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'WillChangeField', argNames: ['cFields', 'Fields', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {readonly cFields: number, readonly Fields: any, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'WillChangeRecord', argNames: ['adReason', 'cRecords', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {
|
||||
readonly adReason: ADODB.EventReasonEnum, readonly cRecords: number, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(
|
||||
obj: ADODB.Recordset, event: 'WillChangeRecordset' | 'WillMove', argNames: ['adReason', 'adStatus', 'pRecordset'], handler: (
|
||||
this: ADODB.Recordset, parameter: {readonly adReason: ADODB.EventReasonEnum, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Connection, event: 'BeginTransComplete', argNames: ['TransactionLevel', 'pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {readonly TransactionLevel: number, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pConnection: ADODB.Connection}) => void): void;
|
||||
on(obj: ADODB.Connection, event: 'CommitTransComplete' | 'ConnectComplete' | 'InfoMessage' | 'RollbackTransComplete', argNames: ['pError', 'adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pConnection: ADODB.Connection}) => void): void;
|
||||
on(obj: ADODB.Connection, event: 'Disconnect', argNames: ['adStatus', 'pConnection'], handler: (this: ADODB.Connection, parameter: {adStatus: ADODB.EventStatusEnum, readonly pConnection: ADODB.Connection}) => void): void;
|
||||
on(obj: ADODB.Connection, event: 'ExecuteComplete', argNames: ADODB.EventHelperTypes.Connection_ExecuteComplete_ArgNames, handler: (this: ADODB.Connection, parameter: ADODB.EventHelperTypes.Connection_ExecuteComplete_Parameter) => void): void;
|
||||
on(obj: ADODB.Connection, event: 'WillConnect', argNames: ADODB.EventHelperTypes.Connection_WillConnect_ArgNames, handler: (this: ADODB.Connection, parameter: ADODB.EventHelperTypes.Connection_WillConnect_Parameter) => void): void;
|
||||
on(obj: ADODB.Connection, event: 'WillExecute', argNames: ADODB.EventHelperTypes.Connection_WillExecute_ArgNames, handler: (this: ADODB.Connection, parameter: ADODB.EventHelperTypes.Connection_WillExecute_Parameter) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'EndOfRecordset', argNames: ['fMoreData', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {fMoreData: boolean, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'FetchComplete', argNames: ['pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'FetchProgress', argNames: ['Progress', 'MaxProgress', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly Progress: number, readonly MaxProgress: number, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'FieldChangeComplete', argNames: ['cFields', 'Fields', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly cFields: number, readonly Fields: any, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'MoveComplete' | 'RecordsetChangeComplete', argNames: ['adReason', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly adReason: ADODB.EventReasonEnum, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'RecordChangeComplete', argNames: ['adReason', 'cRecords', 'pError', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly adReason: ADODB.EventReasonEnum, readonly cRecords: number, readonly pError: ADODB.Error, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'WillChangeField', argNames: ['cFields', 'Fields', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly cFields: number, readonly Fields: any, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'WillChangeRecord', argNames: ['adReason', 'cRecords', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly adReason: ADODB.EventReasonEnum, readonly cRecords: number, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
on(obj: ADODB.Recordset, event: 'WillChangeRecordset' | 'WillMove', argNames: ['adReason', 'adStatus', 'pRecordset'], handler: (this: ADODB.Recordset, parameter: {readonly adReason: ADODB.EventReasonEnum, adStatus: ADODB.EventStatusEnum, readonly pRecordset: ADODB.Recordset}) => void): void;
|
||||
set(obj: ADODB.Recordset, propertyName: 'Collect', parameterTypes: [any], newValue: any): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
@@ -1073,14 +1122,3 @@ interface ActiveXObjectNameMap {
|
||||
'ADODB.Recordset': ADODB.Recordset;
|
||||
'ADODB.Stream': ADODB.Stream;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: ADODB.Errors): Enumerator<ADODB.Error>;
|
||||
new(col: ADODB.Fields): Enumerator<ADODB.Field>;
|
||||
new(col: ADODB.Parameters): Enumerator<ADODB.Parameter>;
|
||||
new(col: ADODB.Properties): Enumerator<ADODB.Property>;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Vendored
+332
@@ -0,0 +1,332 @@
|
||||
// Type definitions for Microsoft ADO Extensions 6.0 for DDL and Security - ADOX 6.0
|
||||
// Project: https://docs.microsoft.com/en-us/sql/ado/reference/adox-api/adox-object-model
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
/// <reference types="activex-adodb" />
|
||||
|
||||
declare namespace ADOX {
|
||||
const enum ActionEnum {
|
||||
adAccessDeny = 3,
|
||||
adAccessGrant = 1,
|
||||
adAccessRevoke = 4,
|
||||
adAccessSet = 2,
|
||||
}
|
||||
|
||||
const enum AllowNullsEnum {
|
||||
adIndexNullsAllow = 0,
|
||||
adIndexNullsDisallow = 1,
|
||||
adIndexNullsIgnore = 2,
|
||||
adIndexNullsIgnoreAny = 4,
|
||||
}
|
||||
|
||||
const enum ColumnAttributesEnum {
|
||||
adColFixed = 1,
|
||||
adColNullable = 2,
|
||||
}
|
||||
|
||||
const enum InheritTypeEnum {
|
||||
adInheritBoth = 3,
|
||||
adInheritContainers = 2,
|
||||
adInheritNone = 0,
|
||||
adInheritNoPropogate = 4,
|
||||
adInheritObjects = 1,
|
||||
}
|
||||
|
||||
const enum KeyTypeEnum {
|
||||
adKeyForeign = 2,
|
||||
adKeyPrimary = 1,
|
||||
adKeyUnique = 3,
|
||||
}
|
||||
|
||||
const enum ObjectTypeEnum {
|
||||
adPermObjColumn = 2,
|
||||
adPermObjDatabase = 3,
|
||||
adPermObjProcedure = 4,
|
||||
adPermObjProviderSpecific = -1,
|
||||
adPermObjTable = 1,
|
||||
adPermObjView = 5,
|
||||
}
|
||||
|
||||
const enum RightsEnum {
|
||||
adRightCreate = 16384,
|
||||
adRightDelete = 65536,
|
||||
adRightDrop = 256,
|
||||
adRightExclusive = 512,
|
||||
adRightExecute = 536870912,
|
||||
adRightFull = 268435456,
|
||||
adRightInsert = 32768,
|
||||
adRightMaximumAllowed = 33554432,
|
||||
adRightNone = 0,
|
||||
adRightRead = -2147483648,
|
||||
adRightReadDesign = 1024,
|
||||
adRightReadPermissions = 131072,
|
||||
adRightReference = 8192,
|
||||
adRightUpdate = 1073741824,
|
||||
adRightWithGrant = 4096,
|
||||
adRightWriteDesign = 2048,
|
||||
adRightWriteOwner = 524288,
|
||||
adRightWritePermissions = 262144,
|
||||
}
|
||||
|
||||
const enum RuleEnum {
|
||||
adRICascade = 1,
|
||||
adRINone = 0,
|
||||
adRISetDefault = 3,
|
||||
adRISetNull = 2,
|
||||
}
|
||||
|
||||
const enum SortOrderEnum {
|
||||
adSortAscending = 1,
|
||||
adSortDescending = 2,
|
||||
}
|
||||
|
||||
class Catalog {
|
||||
private constructor();
|
||||
private 'ADOX.Catalog_typekey': Catalog;
|
||||
|
||||
/** Can be set to a Connection object or a string. Returns the active Connection object, or `null` */
|
||||
ActiveConnection: string | ADODB.Connection | null;
|
||||
|
||||
/**
|
||||
* The **Create** method creates and opens a new ADO Connection to the data source specified in _ConnectString_. If successful, the new **Connection** object is assigned to the **ActiveConnection** property.
|
||||
*
|
||||
* An error will occur if the provider does not support creating new catalogs.
|
||||
*
|
||||
* @param ConnectString Connection string
|
||||
*/
|
||||
Create(ConnectString: string): void;
|
||||
|
||||
/**
|
||||
* @param ObjectTypeId Specifies the GUID for a provider object type not defined by the OLE DB specification
|
||||
*/
|
||||
GetObjectOwner(ObjectName: string, ObjectType: ObjectTypeEnum.adPermObjProviderSpecific, ObjectTypeId: any): string;
|
||||
GetObjectOwner(ObjectName: string, ObjectType: ObjectTypeEnum): string;
|
||||
readonly Groups: Groups;
|
||||
readonly Procedures: Procedures;
|
||||
|
||||
/**
|
||||
* @param UserName Specifies the name of the **User** or **Group** to own the object
|
||||
* @param ObjectTypeId Specifies the GUID for a provider object type that is not defined by the OLE DB specification
|
||||
*/
|
||||
SetObjectOwner(ObjectName: string, ObjectType: ObjectTypeEnum.adPermObjProviderSpecific, UserName: string, ObjectTypeId: any): void;
|
||||
SetObjectOwner(ObjectName: string, ObjectType: ObjectTypeEnum, UserName: string): void;
|
||||
readonly Tables: Tables;
|
||||
readonly Users: Users;
|
||||
readonly Views: Views;
|
||||
}
|
||||
|
||||
class Column {
|
||||
private constructor();
|
||||
private 'ADOX.Column_typekey': Column;
|
||||
Attributes: ColumnAttributesEnum;
|
||||
DefinedSize: number;
|
||||
Name: string;
|
||||
NumericScale: number;
|
||||
ParentCatalog: Catalog;
|
||||
Precision: number;
|
||||
readonly Properties: ADODB.Properties;
|
||||
RelatedColumn: string;
|
||||
SortOrder: SortOrderEnum;
|
||||
Type: ADODB.DataTypeEnum;
|
||||
}
|
||||
|
||||
interface Columns {
|
||||
/**
|
||||
* @param Type [Type=202]
|
||||
* @param DefinedSize [DefinedSize=0]
|
||||
*/
|
||||
Append(Item: Column | string, Type?: ADODB.DataTypeEnum, DefinedSize?: number): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): Column;
|
||||
Refresh(): void;
|
||||
(Item: string | number): Column;
|
||||
}
|
||||
|
||||
class Group {
|
||||
private constructor();
|
||||
private 'ADOX.Group_typekey': Group;
|
||||
|
||||
/**
|
||||
* @param Name Specifies the name of the object for which to set permissions. Pass `null` if you want to get the permissions for the object container.
|
||||
* @param ObjectTypeId Specifies the GUID for a provider object type not defined by the OLE DB specification.
|
||||
*/
|
||||
GetPermissions(Name: string | null, ObjectType: ObjectTypeEnum.adPermObjProviderSpecific, ObjectTypeId: any): RightsEnum;
|
||||
GetPermissions(Name: string | null, ObjectType: ObjectTypeEnum): RightsEnum;
|
||||
Name: string;
|
||||
ParentCatalog: Catalog;
|
||||
readonly Properties: ADODB.Properties;
|
||||
|
||||
/**
|
||||
* @param Rights A bitmask of one or more of the **RightsEnum** constants, that indicates the rights to set.
|
||||
* @param Inherit [Inherit=0]
|
||||
* @param ObjectTypeId Specifies the GUID for a provider object type not defined by the OLE DB specification.
|
||||
*/
|
||||
SetPermissions(Name: string, ObjectType: ObjectTypeEnum.adPermObjProviderSpecific, Action: ActionEnum, Rights: RightsEnum, Inherit: InheritTypeEnum, ObjectTypeId: any): void;
|
||||
SetPermissions(Name: string, ObjectType: ObjectTypeEnum, Action: ActionEnum, Rights: RightsEnum, Inherit?: InheritTypeEnum): void;
|
||||
readonly Users: Users;
|
||||
}
|
||||
|
||||
interface Groups {
|
||||
Append(Item: Group | string): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): Group;
|
||||
Refresh(): void;
|
||||
(Item: string | number): Group;
|
||||
}
|
||||
|
||||
class Index {
|
||||
private constructor();
|
||||
private 'ADOX.Index_typekey': Index;
|
||||
Clustered: boolean;
|
||||
readonly Columns: Columns;
|
||||
IndexNulls: AllowNullsEnum;
|
||||
Name: string;
|
||||
PrimaryKey: boolean;
|
||||
readonly Properties: ADODB.Properties;
|
||||
Unique: boolean;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface Indexes {
|
||||
Append(Item: Index | string, Columns?: string | SafeArray<string>): void; // is this actually two overloads, one with [Index] and one with [string,string | SafeArray<string>]?
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): Index;
|
||||
Refresh(): void;
|
||||
(Item: string | number): Index;
|
||||
}
|
||||
|
||||
class Key {
|
||||
private constructor();
|
||||
private 'ADOX.Key_typekey': Key;
|
||||
readonly Columns: Columns;
|
||||
DeleteRule: RuleEnum;
|
||||
Name: string;
|
||||
RelatedTable: string;
|
||||
Type: KeyTypeEnum;
|
||||
UpdateRule: RuleEnum;
|
||||
}
|
||||
|
||||
interface Keys {
|
||||
/**
|
||||
* @param Type [Type=1]
|
||||
* @param RelatedTable [RelatedTable='']
|
||||
* @param RelatedColumn [RelatedColumn='']
|
||||
*/
|
||||
Append(Item: Key | string, Type?: KeyTypeEnum, Column?: string | SafeArray<string>, RelatedTable?: string, RelatedColumn?: string): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): Key;
|
||||
Refresh(): void;
|
||||
(Item: string | number): Key;
|
||||
}
|
||||
|
||||
class Procedure {
|
||||
private constructor();
|
||||
private 'ADOX.Procedure_typekey': Procedure;
|
||||
Command: ADODB.Command;
|
||||
readonly DateCreated: VarDate | null;
|
||||
readonly DateModified: VarDate | null;
|
||||
readonly Name: string;
|
||||
}
|
||||
|
||||
interface Procedures {
|
||||
Append(Name: string, Command: ADODB.Command): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): Procedure;
|
||||
Refresh(): void;
|
||||
(Item: string | number): Procedure;
|
||||
}
|
||||
|
||||
class Table {
|
||||
private constructor();
|
||||
private 'ADOX.Table_typekey': Table;
|
||||
readonly Columns: Columns;
|
||||
readonly DateCreated: VarDate;
|
||||
readonly DateModified: VarDate;
|
||||
readonly Indexes: Indexes;
|
||||
readonly Keys: Keys;
|
||||
Name: string;
|
||||
ParentCatalog: Catalog;
|
||||
readonly Properties: ADODB.Properties;
|
||||
readonly Type: string;
|
||||
}
|
||||
|
||||
interface Tables {
|
||||
Append(Item: Table | string): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): Table;
|
||||
Refresh(): void;
|
||||
(Item: string | number): Table;
|
||||
}
|
||||
|
||||
class User {
|
||||
private constructor();
|
||||
private 'ADOX.User_typekey': User;
|
||||
ChangePassword(OldPassword: string, NewPassword: string): void;
|
||||
|
||||
/**
|
||||
* @param Name Specifies the name of the object for which to set permissions. Pass `null` if you want to get the permissions for the object container.
|
||||
* @param ObjectTypeId Specifies the GUID for a provider object type not defined by the OLE DB specification.
|
||||
*/
|
||||
GetPermissions(Name: string | null, ObjectType: ObjectTypeEnum.adPermObjProviderSpecific, ObjectTypeId: any): RightsEnum;
|
||||
GetPermissions(Name: string | null, ObjectType: ObjectTypeEnum): RightsEnum;
|
||||
readonly Groups: Groups;
|
||||
Name: string;
|
||||
ParentCatalog: Catalog;
|
||||
readonly Properties: ADODB.Properties;
|
||||
|
||||
/**
|
||||
* @param Rights A bitmask of one or more of the **RightsEnum** constants, that indicates the rights to set.
|
||||
* @param Inherit [Inherit=0]
|
||||
* @param ObjectTypeId Specifies the GUID for a provider object type not defined by the OLE DB specification.
|
||||
*/
|
||||
SetPermissions(Name: string, ObjectType: ObjectTypeEnum.adPermObjProviderSpecific, Action: ActionEnum, Rights: RightsEnum, Inherit: InheritTypeEnum, ObjectTypeId: any): void;
|
||||
SetPermissions(Name: string, ObjectType: ObjectTypeEnum, Action: ActionEnum, Rights: RightsEnum, Inherit?: InheritTypeEnum): void;
|
||||
}
|
||||
|
||||
interface Users {
|
||||
/** @param Password [Password=''] */
|
||||
Append(Item: User | string, Password?: string): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): User;
|
||||
Refresh(): void;
|
||||
(Item: string | number): User;
|
||||
}
|
||||
|
||||
class View {
|
||||
private constructor();
|
||||
private 'ADOX.View_typekey': View;
|
||||
Command: ADODB.Command;
|
||||
readonly DateCreated: VarDate;
|
||||
readonly DateModified: VarDate;
|
||||
readonly Name: string;
|
||||
}
|
||||
|
||||
interface Views {
|
||||
Append(Name: string, Command: ADODB.Command): void;
|
||||
readonly Count: number;
|
||||
Delete(Item: string | number): void;
|
||||
Item(Item: string | number): View;
|
||||
Refresh(): void;
|
||||
(Item: string | number): View;
|
||||
}
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
'ADOX.Catalog': ADOX.Catalog;
|
||||
'ADOX.Column': ADOX.Column;
|
||||
'ADOX.Group': ADOX.Group;
|
||||
'ADOX.Index': ADOX.Index;
|
||||
'ADOX.Key': ADOX.Key;
|
||||
'ADOX.Table': ADOX.Table;
|
||||
'ADOX.User': ADOX.User;
|
||||
}
|
||||
@@ -18,7 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"colors-tests.ts",
|
||||
"safe.d.ts"
|
||||
"activex-adox-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
@@ -1,27 +1,50 @@
|
||||
let engine = new ActiveXObject('DAO.DBEngine.120');
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
const dbOpenSnapshot = DAO.RecordsetTypeEnum.dbOpenSnapshot;
|
||||
|
||||
let engine = new ActiveXObject('DAO.DBEngine');
|
||||
let dbsNorthwind = engine.OpenDatabase('c:\\path\\to\\northwind.mdb');
|
||||
|
||||
// adding a record to a recordset -- https://msdn.microsoft.com/VBA/Access-VBA/articles/add-a-record-to-a-dao-recordset
|
||||
let rstShippers = dbsNorthwind.OpenRecordset('Shippers');
|
||||
rstShippers.AddNew();
|
||||
rstShippers.Fields.Item('CompanyName').Value = 'Global Parcel Service';
|
||||
// Set remaining fields
|
||||
rstShippers.Update();
|
||||
rstShippers.Close();
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/add-a-record-to-a-dao-recordset
|
||||
{
|
||||
// adding a record to a recordset
|
||||
const rstShippers = dbsNorthwind.OpenRecordset('Shippers');
|
||||
rstShippers.AddNew();
|
||||
rstShippers('CompanyName').Value = 'Global Parcel Service';
|
||||
// Set remaining fields
|
||||
rstShippers.Update();
|
||||
rstShippers.Close();
|
||||
}
|
||||
|
||||
// create a QueryDef with the given SQL -- https://msdn.microsoft.com/VBA/Access-VBA/articles/build-sql-statements-that-include-variables-and-controls
|
||||
let sql = 'SELECT * FROM Orders WHERE OrderDate > #3-31-2006#';
|
||||
let qdf = dbsNorthwind.CreateQueryDef('Second quarter', sql);
|
||||
// using parameters
|
||||
sql = `
|
||||
PARAMETERS QuarterStart DATETIME
|
||||
SELECT *
|
||||
FROM Orders
|
||||
WHERE OrderDate > QuarterStart
|
||||
`;
|
||||
qdf = dbsNorthwind.CreateQueryDef('Second quarter (parameters)', sql);
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/build-sql-statements-that-include-variables-and-controls
|
||||
{
|
||||
// create a QueryDef with the given SQL
|
||||
let sql = 'SELECT * FROM Orders WHERE OrderDate > #3-31-2006#';
|
||||
let qdf = dbsNorthwind.CreateQueryDef('Second quarter', sql);
|
||||
// using parameters
|
||||
sql = `
|
||||
PARAMETERS QuarterStart DATETIME
|
||||
SELECT *
|
||||
FROM Orders
|
||||
WHERE OrderDate > QuarterStart
|
||||
`;
|
||||
qdf = dbsNorthwind.CreateQueryDef('Second quarter (parameters)', sql);
|
||||
WScript.Echo(`Field names: ${collectionToArray(qdf.Fields).map(fld => fld.Name).join(', ')}`);
|
||||
}
|
||||
|
||||
// count the number of records in a Recordset -- https://msdn.microsoft.com/VBA/Access-VBA/articles/count-the-number-of-records-in-a-dao-recordset
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/count-the-number-of-records-in-a-dao-recordset
|
||||
/** Count the number of records in a Recordset */
|
||||
const findRecordCount = (dbs: DAO.Database, sql: string) => {
|
||||
let count = 0;
|
||||
const rstRecords = dbs.OpenRecordset(sql);
|
||||
@@ -33,113 +56,119 @@ const findRecordCount = (dbs: DAO.Database, sql: string) => {
|
||||
return count;
|
||||
};
|
||||
|
||||
// delete records from a Recordset -- https://msdn.microsoft.com/VBA/Access-VBA/articles/delete-a-record-from-a-dao-recordset
|
||||
rstShippers = dbsNorthwind.OpenRecordset('SELECT * FROM Shippers ORDER BY CompanyName, ShipperID', DAO.RecordsetTypeEnum.dbOpenDynaset);
|
||||
if (!rstShippers.EOF) {
|
||||
let name = rstShippers.Fields.Item('CompanyName').Value;
|
||||
rstShippers.MoveNext();
|
||||
while (!rstShippers.EOF) {
|
||||
const recordName: string = rstShippers.Fields.Item('CompanyName').Value;
|
||||
if (recordName === name) {
|
||||
rstShippers.Delete();
|
||||
} else {
|
||||
name = recordName;
|
||||
}
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/delete-a-record-from-a-dao-recordset
|
||||
{
|
||||
// delete records from a Recordset
|
||||
const rstShippers = dbsNorthwind.OpenRecordset('SELECT * FROM Shippers ORDER BY CompanyName, ShipperID', DAO.RecordsetTypeEnum.dbOpenDynaset);
|
||||
if (!rstShippers.EOF) {
|
||||
let name = rstShippers('CompanyName').Value;
|
||||
rstShippers.MoveNext();
|
||||
while (!rstShippers.EOF) {
|
||||
const recordName: string = rstShippers('CompanyName').Value;
|
||||
if (recordName === name) {
|
||||
rstShippers.Delete();
|
||||
} else {
|
||||
name = recordName;
|
||||
}
|
||||
rstShippers.MoveNext();
|
||||
}
|
||||
}
|
||||
rstShippers.Close();
|
||||
}
|
||||
rstShippers.Close();
|
||||
|
||||
// copy entire records to an array -- https://msdn.microsoft.com/VBA/Access-VBA/articles/extract-data-from-a-record-in-a-dao-recordset
|
||||
let rstEmployees = dbsNorthwind.OpenRecordset('SELECT FirstName, LastName, Title FROM Employees', DAO.RecordsetTypeEnum.dbOpenSnapshot);
|
||||
let records = new VBArray<string>(rstEmployees.GetRows(3));
|
||||
let recordCount = records.ubound(2) + 1;
|
||||
let columnCount = records.ubound(1) + 1;
|
||||
for (let row = 0; row < recordCount; row += 1) {
|
||||
for (let column = 0; column < columnCount; column += 1) {
|
||||
WScript.Echo(records.getItem(column, row));
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/extract-data-from-a-record-in-a-dao-recordset
|
||||
{
|
||||
// copy entire records to an array
|
||||
const rstEmployees = dbsNorthwind.OpenRecordset('SELECT FirstName, LastName, Title FROM Employees', dbOpenSnapshot);
|
||||
const records = new VBArray<string>(rstEmployees.GetRows(3));
|
||||
const recordCount = records.ubound(2) + 1;
|
||||
const columnCount = records.ubound(1) + 1;
|
||||
for (let row = 0; row < recordCount; row += 1) {
|
||||
for (let column = 0; column < columnCount; column += 1) {
|
||||
WScript.Echo(records.getItem(column, row));
|
||||
}
|
||||
}
|
||||
if (rstEmployees.EOF) { WScript.Echo('At end of recordset'); }
|
||||
rstEmployees.Close();
|
||||
}
|
||||
if (rstEmployees.EOF) { WScript.Echo('At end of recordset'); }
|
||||
rstEmployees.Close();
|
||||
|
||||
// find a record in a dynaset-type or snapshot-type DAO Recordset -- https://msdn.microsoft.com/en-us/vba/access-vba/articles/find-a-record-in-a-dynaset-type-or-snapshot-type-dao-recordset
|
||||
const findOrdersWithoutDetails = () => {
|
||||
{
|
||||
const orders: number[] = [];
|
||||
const rstOrders = dbsNorthwind.OpenRecordset('SELECT * FROM Orders ORDER BY OrderID', DAO.RecordsetTypeEnum.dbOpenSnapshot);
|
||||
const rstOrderDetails = dbsNorthwind.OpenRecordset('SELECT * FROM [Order Details] ORDER BY OrderID', DAO.RecordsetTypeEnum.dbOpenSnapshot);
|
||||
const rstOrders = dbsNorthwind.OpenRecordset('SELECT * FROM Orders ORDER BY OrderID', dbOpenSnapshot);
|
||||
const rstOrderDetails = dbsNorthwind.OpenRecordset('SELECT * FROM [Order Details] ORDER BY OrderID', dbOpenSnapshot);
|
||||
|
||||
const closeRecordsets = () => {
|
||||
rstOrders.Close();
|
||||
rstOrderDetails.Close();
|
||||
};
|
||||
if (rstOrders.EOF || rstOrderDetails.EOF) {
|
||||
closeRecordsets();
|
||||
return;
|
||||
}
|
||||
|
||||
while (!rstOrders.EOF) {
|
||||
const orderID = rstOrders.Fields.Item('OrderID').Value;
|
||||
rstOrderDetails.FindFirst(`OrderID=${orderID}`);
|
||||
if (rstOrderDetails.NoMatch) {
|
||||
orders.push(orderID);
|
||||
if (!rstOrders.EOF && !rstOrderDetails.EOF) {
|
||||
while (!rstOrders.EOF) {
|
||||
const orderID = rstOrders('OrderID').Value;
|
||||
rstOrderDetails.FindFirst(`OrderID=${orderID}`);
|
||||
if (rstOrderDetails.NoMatch) {
|
||||
orders.push(orderID);
|
||||
}
|
||||
rstOrders.MoveNext();
|
||||
}
|
||||
rstOrders.MoveNext();
|
||||
}
|
||||
closeRecordsets();
|
||||
return orders;
|
||||
};
|
||||
|
||||
// find a record in a table-type DAO Recordset -- https://msdn.microsoft.com/VBA/Access-VBA/articles/find-a-record-in-a-table-type-dao-recordset
|
||||
rstOrders.Close();
|
||||
rstOrderDetails.Close();
|
||||
|
||||
WScript.Echo(orders.join('\n'));
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/find-a-record-in-a-table-type-dao-recordset
|
||||
/** Find a record in a table-type DAO Recordset */
|
||||
const getHireDate = (employeeID: number) => {
|
||||
let hireDate: Date | undefined;
|
||||
const rstEmployees = dbsNorthwind.OpenRecordset('Employees');
|
||||
rstEmployees.Index = 'PrimaryKey';
|
||||
rstEmployees.Seek('=', employeeID);
|
||||
if (!rstEmployees.NoMatch) {
|
||||
hireDate = new Date(rstEmployees.Fields.Item('HireDate').Value as VarDate);
|
||||
hireDate = new Date(rstEmployees('HireDate').Value as VarDate);
|
||||
}
|
||||
return hireDate;
|
||||
};
|
||||
|
||||
// manipulate multiple fields with DAO -- https://msdn.microsoft.com/VBA/Access-VBA/articles/manipulate-multivalued-fields-with-dao
|
||||
const browseMultiValueField = () => {
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/manipulate-multivalued-fields-with-dao
|
||||
{
|
||||
// manipulate multiple fields with DAO
|
||||
const rs = dbsNorthwind.OpenRecordset('Tasks');
|
||||
rs.MoveFirst();
|
||||
while (!rs.EOF) {
|
||||
WScript.Echo(rs.Fields.Item('TaskName').Value);
|
||||
const childRs = rs.Fields.Item('AssignedTo').Value as DAO.Recordset;
|
||||
WScript.Echo(rs('TaskName').Value);
|
||||
const childRs = rs('AssignedTo').Value as DAO.Recordset;
|
||||
if (childRs.EOF) { continue; }
|
||||
childRs.MoveFirst();
|
||||
while (!childRs.EOF) {
|
||||
WScript.Echo('\t' + childRs.Fields.Item('Value').Value);
|
||||
WScript.Echo('\t' + childRs('Value').Value);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// modifying an existing record in a DAO Recordset -- https://msdn.microsoft.com/VBA/Access-VBA/articles/modify-an-existing-record-in-a-dao-recordset
|
||||
const changeTitleWithoutTransaction = () => {
|
||||
rstEmployees = dbsNorthwind.OpenRecordset('Employees');
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/modify-an-existing-record-in-a-dao-recordset
|
||||
{
|
||||
// modifying an existing record in a DAO Recordset
|
||||
const rstEmployees = dbsNorthwind.OpenRecordset('Employees');
|
||||
while (!rstEmployees.EOF) {
|
||||
if (rstEmployees.Fields.Item('Title').Value === 'Sales Representative') {
|
||||
if (rstEmployees('Title').Value === 'Sales Representative') {
|
||||
rstEmployees.Edit();
|
||||
rstEmployees.Fields.Item('Title').Value = 'Account Executive';
|
||||
rstEmployees('Title').Value = 'Account Executive';
|
||||
rstEmployees.Update();
|
||||
}
|
||||
rstEmployees.MoveNext();
|
||||
}
|
||||
rstEmployees.Close();
|
||||
};
|
||||
}
|
||||
|
||||
// using transactions in a DAO Recordset -- https://msdn.microsoft.com/VBA/Access-VBA/articles/use-transactions-in-a-dao-recordset
|
||||
// https://msdn.microsoft.com/VBA/Access-VBA/articles/use-transactions-in-a-dao-recordset
|
||||
/** using transactions in a DAO Recordset */
|
||||
const changeTitleWithTransaction = (commitTransaction: boolean) => {
|
||||
const currentWorkspace = engine.Workspaces.Item(0);
|
||||
rstEmployees = dbsNorthwind.OpenRecordset('Employees');
|
||||
const currentWorkspace = engine.Workspaces(0);
|
||||
const rstEmployees = dbsNorthwind.OpenRecordset('Employees');
|
||||
currentWorkspace.BeginTrans();
|
||||
while (!rstEmployees.EOF) {
|
||||
if (rstEmployees.Fields.Item('Title').Value === 'Sales Representative') {
|
||||
if (rstEmployees('Title').Value === 'Sales Representative') {
|
||||
rstEmployees.Edit();
|
||||
rstEmployees.Fields.Item('Title').Value = 'Account Executive';
|
||||
rstEmployees('Title').Value = 'Account Executive';
|
||||
rstEmployees.Update();
|
||||
}
|
||||
rstEmployees.MoveNext();
|
||||
|
||||
Vendored
+199
-211
@@ -1,8 +1,10 @@
|
||||
// Type definitions for Microsoft Office 14.0 Access Database Engine Object Library - DAO 14.0
|
||||
// Type definitions for Microsoft Office 16.0 Access Database Engine Object Library - DAO 16.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/dn124645.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.4
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace DAO {
|
||||
const enum _DAOSuppHelp {
|
||||
@@ -56,12 +58,15 @@ declare namespace DAO {
|
||||
}
|
||||
|
||||
const enum DatabaseTypeEnum {
|
||||
/** @deprecated */
|
||||
dbDecrypt = 4,
|
||||
/** @deprecated */
|
||||
dbEncrypt = 2,
|
||||
dbVersion10 = 1,
|
||||
dbVersion11 = 8,
|
||||
dbVersion120 = 128,
|
||||
dbVersion140 = 256,
|
||||
dbVersion150 = 512,
|
||||
dbVersion20 = 16,
|
||||
dbVersion30 = 32,
|
||||
dbVersion40 = 64,
|
||||
@@ -128,6 +133,15 @@ declare namespace DAO {
|
||||
dbRefreshCache = 8,
|
||||
}
|
||||
|
||||
const enum ISAMStatsEnum {
|
||||
DiskReads = 0,
|
||||
DiskWrites = 1,
|
||||
LocksPlaced = 4,
|
||||
LocksReleased = 5,
|
||||
ReadsFromCache = 2,
|
||||
ReadsFromReadAheadCache = 3,
|
||||
}
|
||||
|
||||
const enum LanguageConstants {
|
||||
dbLangArabic = ';LANGID=0x0401;CP=1256;COUNTRY=0',
|
||||
dbLangChineseSimplified = ';LANGID=0x0804;CP=936;COUNTRY=0',
|
||||
@@ -308,18 +322,26 @@ declare namespace DAO {
|
||||
dbUseODBC = 1,
|
||||
}
|
||||
|
||||
type Bookmark = SafeArray<number>;
|
||||
|
||||
class ComplexType {
|
||||
private 'DAO.ComplexType_typekey': ComplexType;
|
||||
private constructor();
|
||||
readonly Fields: Fields;
|
||||
}
|
||||
|
||||
class Connection {
|
||||
private 'DAO.Connection_typekey': Connection;
|
||||
private constructor();
|
||||
Cancel(): void;
|
||||
Close(): void;
|
||||
readonly Connect: string;
|
||||
CreateQueryDef(Name?: any, SQLText?: any): QueryDef;
|
||||
CreateQueryDef(Name?: string, SQLText?: string): QueryDef;
|
||||
readonly Database: Database;
|
||||
Execute(Query: string, Options?: any): void;
|
||||
Execute(Query: string, Options?: RecordsetOptionEnum): void;
|
||||
readonly hDbc: number;
|
||||
readonly Name: string;
|
||||
OpenRecordset(Name: string, Type?: any, Options?: any, LockEdit?: any): Recordset;
|
||||
OpenRecordset(Name: string, Type?: RecordsetTypeEnum, Options?: RecordsetOptionEnum, LockEdit?: LockTypeEnum): Recordset;
|
||||
readonly QueryDefs: QueryDefs;
|
||||
QueryTimeout: number;
|
||||
readonly RecordsAffected: number;
|
||||
@@ -329,12 +351,11 @@ declare namespace DAO {
|
||||
readonly Updatable: boolean;
|
||||
}
|
||||
|
||||
class Connections {
|
||||
private 'DAO.Connections_typekey': Connections;
|
||||
private constructor();
|
||||
interface Connections {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Connection;
|
||||
Item(Item: number | string): Connection;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Connection;
|
||||
}
|
||||
|
||||
class Container {
|
||||
@@ -350,12 +371,11 @@ declare namespace DAO {
|
||||
UserName: string;
|
||||
}
|
||||
|
||||
class Containers {
|
||||
private 'DAO.Containers_typekey': Containers;
|
||||
private constructor();
|
||||
interface Containers {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Container;
|
||||
Item(Item: number | string): Container;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Container;
|
||||
}
|
||||
|
||||
class Database {
|
||||
@@ -366,16 +386,16 @@ declare namespace DAO {
|
||||
Connect: string;
|
||||
readonly Connection: Connection;
|
||||
readonly Containers: Containers;
|
||||
CreateProperty(Name?: any, Type?: any, Value?: any, DDL?: any): Property;
|
||||
CreateQueryDef(Name?: any, SQLText?: any): QueryDef;
|
||||
CreateRelation(Name?: any, Table?: any, ForeignTable?: any, Attributes?: any): Relation;
|
||||
CreateTableDef(Name?: any, Attributes?: any, SourceTableName?: any, Connect?: any): TableDef;
|
||||
CreateProperty(Name?: string, Type?: DataTypeEnum, Value?: any, DDL?: boolean): Property;
|
||||
CreateQueryDef(Name?: string, SQLText?: string): QueryDef;
|
||||
CreateRelation(Name?: string, Table?: string, ForeignTable?: string, Attributes?: RelationAttributeEnum): Relation;
|
||||
CreateTableDef(Name?: string, Attributes?: TableDefAttributeEnum, SourceTableName?: string, Connect?: string): TableDef;
|
||||
DesignMasterID: string;
|
||||
Execute(Query: string, Options?: any): void;
|
||||
MakeReplica(PathName: string, Description: string, Options?: any): void;
|
||||
Execute(Query: string, Options?: RecordsetOptionEnum): void;
|
||||
MakeReplica(PathName: string, Description: string, Options?: ReplicaTypeEnum): void;
|
||||
readonly Name: string;
|
||||
NewPassword(bstrOld: string, bstrNew: string): void;
|
||||
OpenRecordset(Name: string, Type?: any, Options?: any, LockEdit?: any): Recordset;
|
||||
OpenRecordset(Name: string, Type?: RecordsetTypeEnum, Options?: RecordsetOptionEnum, LockEdit?: LockTypeEnum): Recordset;
|
||||
PopulatePartial(DbPathName: string): void;
|
||||
readonly Properties: Properties;
|
||||
readonly QueryDefs: QueryDefs;
|
||||
@@ -384,19 +404,18 @@ declare namespace DAO {
|
||||
readonly Recordsets: Recordsets;
|
||||
readonly Relations: Relations;
|
||||
readonly ReplicaID: string;
|
||||
Synchronize(DbPathName: string, ExchangeType?: any): void;
|
||||
Synchronize(DbPathName: string, ExchangeType?: SynchronizeTypeEnum): void;
|
||||
readonly TableDefs: TableDefs;
|
||||
readonly Transactions: boolean;
|
||||
readonly Updatable: boolean;
|
||||
readonly Version: string;
|
||||
}
|
||||
|
||||
class Databases {
|
||||
private 'DAO.Databases_typekey': Databases;
|
||||
private constructor();
|
||||
interface Databases {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Database;
|
||||
Item(Item: number | string): Database;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Database;
|
||||
}
|
||||
|
||||
class DBEngine {
|
||||
@@ -404,26 +423,51 @@ declare namespace DAO {
|
||||
private constructor();
|
||||
BeginTrans(): void;
|
||||
|
||||
/** @param number [Option=0] */
|
||||
/** @param Option [Option=0] */
|
||||
CommitTrans(Option?: number): void;
|
||||
CompactDatabase(SrcName: string, DstName: string, DstLocale?: any, Options?: any, SrcLocale?: any): void;
|
||||
CreateDatabase(Name: string, Locale: string, Option?: any): Database;
|
||||
CreateWorkspace(Name: string, UserName: string, Password: string, UseType?: any): Workspace;
|
||||
|
||||
/**
|
||||
* Compact a closed database
|
||||
*
|
||||
* @param DstLocale Specify one of the following:
|
||||
* * the locale, using one of the language constants
|
||||
* * the password, in the form `;pwd=MyNewPassword'`
|
||||
* * both the constant and a password, e.g. `dbLangGreek + ';pwd=MyNewPassword'`
|
||||
*
|
||||
* @param Options `dbEncrypt` and `dbDecrypt` are deprecated, and unsupported for ACCDB
|
||||
* @param password Deprecated, and unsupported for ACCDB
|
||||
*/
|
||||
CompactDatabase(SrcName: string, DstName: string, DstLocale?: LanguageConstants | string, Options?: DatabaseTypeEnum, password?: string): void;
|
||||
|
||||
/**
|
||||
* @param Locale Specify one of the following:
|
||||
* * the locale, using one of the language constants
|
||||
* * the password, in the form `;pwd=MyNewPassword'`
|
||||
* * both the constant and a password, e.g. `dbLangGreek + ';pwd=MyNewPassword'`
|
||||
*/
|
||||
CreateDatabase(Name: string, Locale: LanguageConstants | string, Option?: DatabaseTypeEnum): Database;
|
||||
CreateWorkspace(Name: string, UserName: string, Password: string, UseType?: WorkspaceTypeEnum): Workspace;
|
||||
readonly DefaultPassword: string;
|
||||
DefaultType: number;
|
||||
readonly DefaultUser: string;
|
||||
readonly Errors: Errors;
|
||||
Idle(Action?: any): void;
|
||||
Idle(Action?: IdleEnum): void;
|
||||
IniPath: string;
|
||||
ISAMStats(StatNum: number, Reset?: any): number;
|
||||
|
||||
/** Returns various statistics from the Jet engine */
|
||||
ISAMStats(StatNum: ISAMStatsEnum, Reset?: boolean): number;
|
||||
LoginTimeout: number;
|
||||
OpenConnection(Name: string, Options?: any, ReadOnly?: any, Connect?: any): Connection;
|
||||
OpenDatabase(Name: string, Options?: any, ReadOnly?: any, Connect?: any): Database;
|
||||
|
||||
/**
|
||||
* @param Connect ODBC connection string; prepend with `ODBC;`
|
||||
*/
|
||||
OpenConnection(Name: string, Options?: DriverPromptEnum | RecordsetOptionEnum.dbRunAsync, ReadOnly?: boolean, Connect?: string): Connection;
|
||||
OpenDatabase(Name: string, Exclusive?: boolean, ReadOnly?: boolean, Connect?: string): Database;
|
||||
readonly Properties: Properties;
|
||||
RegisterDatabase(Dsn: string, Driver: string, Silent: boolean, Attributes: string): void;
|
||||
RepairDatabase(Name: string): void;
|
||||
Rollback(): void;
|
||||
SetOption(Option: number, Value: any): void;
|
||||
SetOption(Option: SetOptionEnum, Value: any): void;
|
||||
SystemDB: string;
|
||||
readonly Version: string;
|
||||
readonly Workspaces: Workspaces;
|
||||
@@ -434,9 +478,9 @@ declare namespace DAO {
|
||||
private constructor();
|
||||
readonly AllPermissions: number;
|
||||
readonly Container: string;
|
||||
CreateProperty(Name?: any, Type?: any, Value?: any, DDL?: any): Property;
|
||||
readonly DateCreated: any;
|
||||
readonly LastUpdated: any;
|
||||
CreateProperty(Name?: string, Type?: DataTypeEnum, Value?: any, DDL?: boolean): Property;
|
||||
readonly DateCreated: VarDate;
|
||||
readonly LastUpdated: VarDate;
|
||||
readonly Name: string;
|
||||
Owner: string;
|
||||
Permissions: number;
|
||||
@@ -444,12 +488,11 @@ declare namespace DAO {
|
||||
UserName: string;
|
||||
}
|
||||
|
||||
class Documents {
|
||||
private 'DAO.Documents_typekey': Documents;
|
||||
private constructor();
|
||||
interface Documents {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Document;
|
||||
Item(Item: number | string): Document;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Document;
|
||||
}
|
||||
|
||||
class Error {
|
||||
@@ -462,33 +505,38 @@ declare namespace DAO {
|
||||
readonly Source: string;
|
||||
}
|
||||
|
||||
class Errors {
|
||||
private 'DAO.Errors_typekey': Errors;
|
||||
private constructor();
|
||||
interface Errors {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Error;
|
||||
Refresh(): void;
|
||||
(Item: any): Error;
|
||||
}
|
||||
|
||||
class Field {
|
||||
private 'DAO.Field_typekey': Field;
|
||||
private constructor();
|
||||
private 'DAO.Field2_typekey': Field;
|
||||
AllowZeroLength: boolean;
|
||||
AppendChunk(Val: any): void;
|
||||
AppendOnly: boolean;
|
||||
Attributes: number;
|
||||
readonly CollatingOrder: number;
|
||||
readonly CollectionIndex: number;
|
||||
CreateProperty(Name?: any, Type?: any, Value?: any, DDL?: any): Property;
|
||||
readonly ComplexType: ComplexType;
|
||||
CreateProperty(Name?: string, Type?: DataTypeEnum, Value?: any, DDL?: boolean): Property;
|
||||
readonly DataUpdatable: boolean;
|
||||
DefaultValue: any;
|
||||
Expression: string;
|
||||
readonly FieldSize: number;
|
||||
ForeignName: string;
|
||||
GetChunk(Offset: number, Bytes: number): any;
|
||||
readonly IsComplex: boolean;
|
||||
LoadFromFile(FileName: string): void;
|
||||
Name: string;
|
||||
OrdinalPosition: number;
|
||||
readonly OriginalValue: any;
|
||||
readonly Properties: Properties;
|
||||
Required: boolean;
|
||||
SaveToFile(FileName: string): void;
|
||||
Size: number;
|
||||
readonly SourceField: string;
|
||||
readonly SourceTable: string;
|
||||
@@ -500,44 +548,42 @@ declare namespace DAO {
|
||||
readonly VisibleValue: any;
|
||||
}
|
||||
|
||||
class Fields {
|
||||
private 'DAO.Fields_typekey': Fields;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface Fields {
|
||||
Append(Field: Field): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): Field;
|
||||
Item(Item: number | string): Field;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Field;
|
||||
}
|
||||
|
||||
class Group {
|
||||
private 'DAO.Group_typekey': Group;
|
||||
private constructor();
|
||||
CreateUser(Name?: any, PID?: any, Password?: any): User;
|
||||
CreateUser(Name?: string, PID?: string, Password?: string): User;
|
||||
Name: string;
|
||||
readonly PID: string;
|
||||
readonly Properties: Properties;
|
||||
readonly Users: Users;
|
||||
}
|
||||
|
||||
class Groups {
|
||||
private 'DAO.Groups_typekey': Groups;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface Groups {
|
||||
Append(Group: Group): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): Group;
|
||||
Item(Item: number | string): Group;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Group;
|
||||
}
|
||||
|
||||
class Index {
|
||||
private 'DAO.Index_typekey': Index;
|
||||
private constructor();
|
||||
Clustered: boolean;
|
||||
CreateField(Name?: any, Type?: any, Size?: any): Field;
|
||||
CreateProperty(Name?: any, Type?: any, Value?: any, DDL?: any): Property;
|
||||
CreateField(Name?: string): Field;
|
||||
CreateProperty(Name?: string, Type?: DataTypeEnum, Value?: any, DDL?: boolean): Property;
|
||||
readonly DistinctCount: number;
|
||||
Fields: any;
|
||||
Fields: Fields;
|
||||
readonly Foreign: boolean;
|
||||
IgnoreNulls: boolean;
|
||||
Name: string;
|
||||
@@ -547,14 +593,14 @@ declare namespace DAO {
|
||||
Unique: boolean;
|
||||
}
|
||||
|
||||
class Indexes {
|
||||
private 'DAO.Indexes_typekey': Indexes;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface Indexes {
|
||||
Append(Index: Index): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): Index;
|
||||
Item(Item: number | string): Index;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Index;
|
||||
}
|
||||
|
||||
class Parameter {
|
||||
@@ -567,53 +613,20 @@ declare namespace DAO {
|
||||
Value: any;
|
||||
}
|
||||
|
||||
class Parameters {
|
||||
private 'DAO.Parameters_typekey': Parameters;
|
||||
private constructor();
|
||||
interface Parameters {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Parameter;
|
||||
Item(Item: number | string): Parameter;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Parameter;
|
||||
}
|
||||
|
||||
/** DAO 3.0 DBEngine (private) */
|
||||
class PrivDBEngine {
|
||||
private 'DAO.PrivDBEngine_typekey': PrivDBEngine;
|
||||
private constructor();
|
||||
BeginTrans(): void;
|
||||
|
||||
/** @param number [Option=0] */
|
||||
CommitTrans(Option?: number): void;
|
||||
CompactDatabase(SrcName: string, DstName: string, DstLocale?: any, Options?: any, SrcLocale?: any): void;
|
||||
CreateDatabase(Name: string, Locale: string, Option?: any): Database;
|
||||
CreateWorkspace(Name: string, UserName: string, Password: string, UseType?: any): Workspace;
|
||||
readonly DefaultPassword: string;
|
||||
DefaultType: number;
|
||||
readonly DefaultUser: string;
|
||||
readonly Errors: Errors;
|
||||
Idle(Action?: any): void;
|
||||
IniPath: string;
|
||||
ISAMStats(StatNum: number, Reset?: any): number;
|
||||
LoginTimeout: number;
|
||||
OpenConnection(Name: string, Options?: any, ReadOnly?: any, Connect?: any): Connection;
|
||||
OpenDatabase(Name: string, Options?: any, ReadOnly?: any, Connect?: any): Database;
|
||||
readonly Properties: Properties;
|
||||
RegisterDatabase(Dsn: string, Driver: string, Silent: boolean, Attributes: string): void;
|
||||
RepairDatabase(Name: string): void;
|
||||
Rollback(): void;
|
||||
SetOption(Option: number, Value: any): void;
|
||||
SystemDB: string;
|
||||
readonly Version: string;
|
||||
readonly Workspaces: Workspaces;
|
||||
}
|
||||
|
||||
class Properties {
|
||||
private 'DAO.Properties_typekey': Properties;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface Properties {
|
||||
Append(Property: Property): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): Property;
|
||||
Item(Item: number | string): Property;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Property;
|
||||
}
|
||||
|
||||
class Property {
|
||||
@@ -633,81 +646,78 @@ declare namespace DAO {
|
||||
Cancel(): void;
|
||||
Close(): void;
|
||||
Connect: string;
|
||||
CreateProperty(Name?: any, Type?: any, Value?: any, DDL?: any): Property;
|
||||
readonly DateCreated: any;
|
||||
Execute(Options?: any): void;
|
||||
CreateProperty(Name?: string, Type?: DataTypeEnum, Value?: any, DDL?: boolean): Property;
|
||||
readonly DateCreated: VarDate;
|
||||
Execute(Options?: RecordsetOptionEnum): void;
|
||||
readonly Fields: Fields;
|
||||
readonly hStmt: number;
|
||||
readonly LastUpdated: any;
|
||||
readonly LastUpdated: VarDate;
|
||||
MaxRecords: number;
|
||||
Name: string;
|
||||
ODBCTimeout: number;
|
||||
OpenRecordset(Type?: any, Options?: any, LockEdit?: any): Recordset;
|
||||
OpenRecordset(Type?: RecordsetTypeEnum, Options?: RecordsetOptionEnum, LockEdit?: LockTypeEnum): Recordset;
|
||||
readonly Parameters: Parameters;
|
||||
Prepare: any;
|
||||
Prepare: QueryDefStateEnum;
|
||||
readonly Properties: Properties;
|
||||
readonly RecordsAffected: number;
|
||||
ReturnsRecords: boolean;
|
||||
SQL: string;
|
||||
readonly StillExecuting: boolean;
|
||||
readonly Type: number;
|
||||
readonly Type: QueryDefTypeEnum;
|
||||
readonly Updatable: boolean;
|
||||
}
|
||||
|
||||
class QueryDefs {
|
||||
private 'DAO.QueryDefs_typekey': QueryDefs;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface QueryDefs {
|
||||
Append(QueryDef: QueryDef): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): QueryDef;
|
||||
Item(Item: number | string): QueryDef;
|
||||
Refresh(): void;
|
||||
(Item: number | string): QueryDef;
|
||||
}
|
||||
|
||||
class Recordset {
|
||||
private 'DAO.Recordset_typekey': Recordset;
|
||||
private constructor();
|
||||
interface Recordset {
|
||||
AbsolutePosition: number;
|
||||
AddNew(): void;
|
||||
readonly BatchCollisionCount: number;
|
||||
readonly BatchCollisions: any;
|
||||
readonly BatchCollisions: SafeArray<Bookmark>;
|
||||
BatchSize: number;
|
||||
readonly BOF: boolean;
|
||||
Bookmark: SafeArray<number>;
|
||||
Bookmark: Bookmark;
|
||||
readonly Bookmarkable: boolean;
|
||||
CacheSize: number;
|
||||
CacheStart: SafeArray<number>;
|
||||
CacheStart: Bookmark;
|
||||
Cancel(): void;
|
||||
|
||||
/** @param number [UpdateType=1] */
|
||||
/** @param UpdateType [UpdateType=1] */
|
||||
CancelUpdate(UpdateType?: number): void;
|
||||
Clone(): Recordset;
|
||||
Close(): void;
|
||||
Collect(Item: any): any;
|
||||
Connection: Connection;
|
||||
CopyQueryDef(): QueryDef;
|
||||
readonly DateCreated: any;
|
||||
readonly DateCreated: VarDate;
|
||||
Delete(): void;
|
||||
Edit(): void;
|
||||
readonly EditMode: number;
|
||||
readonly EditMode: EditModeEnum;
|
||||
readonly EOF: boolean;
|
||||
readonly Fields: Fields;
|
||||
FillCache(Rows?: any, StartBookmark?: any): void;
|
||||
FillCache(Rows?: number, StartBookmark?: string): void;
|
||||
Filter: string;
|
||||
FindFirst(Criteria: string): void;
|
||||
FindLast(Criteria: string): void;
|
||||
FindNext(Criteria: string): void;
|
||||
FindPrevious(Criteria: string): void;
|
||||
GetRows(NumRows?: any): any;
|
||||
GetRows(NumRows?: number): any;
|
||||
readonly hStmt: number;
|
||||
Index: string;
|
||||
readonly LastModified: SafeArray<number>;
|
||||
readonly LastUpdated: any;
|
||||
readonly LastModified: Bookmark;
|
||||
readonly LastUpdated: VarDate;
|
||||
LockEdits: boolean;
|
||||
Move(Rows: number, StartBookmark?: any): void;
|
||||
Move(Rows: number, StartBookmark?: Bookmark): void;
|
||||
MoveFirst(): void;
|
||||
|
||||
/** @param number [Options=0] */
|
||||
/** @param Options [Options=0] */
|
||||
MoveLast(Options?: number): void;
|
||||
MoveNext(): void;
|
||||
MovePrevious(): void;
|
||||
@@ -716,45 +726,44 @@ declare namespace DAO {
|
||||
readonly NoMatch: boolean;
|
||||
readonly ODBCFetchCount: number;
|
||||
readonly ODBCFetchDelay: number;
|
||||
OpenRecordset(Type?: any, Options?: any): Recordset;
|
||||
OpenRecordset(Type?: RecordsetTypeEnum, Options?: RecordsetOptionEnum): Recordset;
|
||||
readonly Parent: Database;
|
||||
PercentPosition: number;
|
||||
readonly Properties: Properties;
|
||||
readonly RecordCount: number;
|
||||
readonly RecordStatus: number;
|
||||
Requery(NewQueryDef?: any): void;
|
||||
Requery(NewQueryDef?: QueryDef): void;
|
||||
readonly Restartable: boolean;
|
||||
Seek(
|
||||
Comparison: string, Key1: any, Key2?: any, Key3?: any, Key4?: any, Key5?: any, Key6?: any, Key7?: any, Key8?: any, Key9?: any, Key10?: any, Key11?: any, Key12?: any, Key13?: any): void;
|
||||
Seek(Comparison: string, Key1: any, Key2?: any, Key3?: any, Key4?: any, Key5?: any, Key6?: any, Key7?: any, Key8?: any, Key9?: any, Key10?: any, Key11?: any, Key12?: any, Key13?: any): void;
|
||||
Sort: string;
|
||||
readonly StillExecuting: boolean;
|
||||
readonly Transactions: boolean;
|
||||
readonly Type: number;
|
||||
readonly Type: RecordsetTypeEnum;
|
||||
readonly Updatable: boolean;
|
||||
|
||||
/**
|
||||
* @param number [UpdateType=1]
|
||||
* @param boolean [Force=false]
|
||||
* @param UpdateType [UpdateType=1]
|
||||
* @param Force [Force=false]
|
||||
*/
|
||||
Update(UpdateType?: number, Force?: boolean): void;
|
||||
UpdateOptions: number;
|
||||
Update(UpdateType?: UpdateTypeEnum, Force?: boolean): void;
|
||||
UpdateOptions: UpdateCriteriaEnum;
|
||||
readonly ValidationRule: string;
|
||||
readonly ValidationText: string;
|
||||
(FieldIndex: number | string): Field;
|
||||
}
|
||||
|
||||
class Recordsets {
|
||||
private 'DAO.Recordsets_typekey': Recordsets;
|
||||
private constructor();
|
||||
interface Recordsets {
|
||||
readonly Count: number;
|
||||
Item(Item: any): Recordset;
|
||||
Item(Item: number | string): Recordset;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Recordset;
|
||||
}
|
||||
|
||||
class Relation {
|
||||
private 'DAO.Relation_typekey': Relation;
|
||||
private constructor();
|
||||
Attributes: number;
|
||||
CreateField(Name?: any, Type?: any, Size?: any): Field;
|
||||
Attributes: RelationAttributeEnum;
|
||||
CreateField(Name?: string): Field;
|
||||
readonly Fields: Fields;
|
||||
ForeignTable: string;
|
||||
Name: string;
|
||||
@@ -763,55 +772,53 @@ declare namespace DAO {
|
||||
Table: string;
|
||||
}
|
||||
|
||||
class Relations {
|
||||
private 'DAO.Relations_typekey': Relations;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface Relations {
|
||||
Append(Relation: Relation): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): Relation;
|
||||
Item(Item: number | string): Relation;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Relation;
|
||||
}
|
||||
|
||||
class TableDef {
|
||||
private 'DAO.TableDef_typekey': TableDef;
|
||||
private constructor();
|
||||
Attributes: number;
|
||||
Attributes: TableDefAttributeEnum;
|
||||
readonly ConflictTable: string;
|
||||
Connect: string;
|
||||
CreateField(Name?: any, Type?: any, Size?: any): Field;
|
||||
CreateIndex(Name?: any): Index;
|
||||
CreateProperty(Name?: any, Type?: any, Value?: any, DDL?: any): Property;
|
||||
readonly DateCreated: any;
|
||||
CreateField(Name?: string, Type?: DataTypeEnum, Size?: number): Field;
|
||||
CreateIndex(Name?: string): Index;
|
||||
CreateProperty(Name?: string, Type?: DataTypeEnum, Value?: any, DDL?: boolean): Property;
|
||||
readonly DateCreated: VarDate;
|
||||
readonly Fields: Fields;
|
||||
readonly Indexes: Indexes;
|
||||
readonly LastUpdated: any;
|
||||
readonly LastUpdated: VarDate;
|
||||
Name: string;
|
||||
OpenRecordset(Type?: any, Options?: any): Recordset;
|
||||
OpenRecordset(Type?: RecordsetTypeEnum, Options?: RecordsetOptionEnum): Recordset;
|
||||
readonly Properties: Properties;
|
||||
readonly RecordCount: number;
|
||||
RefreshLink(): void;
|
||||
ReplicaFilter: any;
|
||||
ReplicaFilter: string | boolean;
|
||||
SourceTableName: string;
|
||||
readonly Updatable: boolean;
|
||||
ValidationRule: string;
|
||||
ValidationText: string;
|
||||
}
|
||||
|
||||
class TableDefs {
|
||||
private 'DAO.TableDefs_typekey': TableDefs;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface TableDefs {
|
||||
Append(TableDef: TableDef): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): TableDef;
|
||||
Item(Item: number | string): TableDef;
|
||||
Refresh(): void;
|
||||
(Item: number | string): TableDef;
|
||||
}
|
||||
|
||||
class User {
|
||||
private 'DAO.User_typekey': User;
|
||||
private constructor();
|
||||
CreateGroup(Name?: any, PID?: any): Group;
|
||||
CreateGroup(Name?: string, PID?: string): Group;
|
||||
readonly Groups: Groups;
|
||||
Name: string;
|
||||
NewPassword(bstrOld: string, bstrNew: string): void;
|
||||
@@ -820,14 +827,13 @@ declare namespace DAO {
|
||||
readonly Properties: Properties;
|
||||
}
|
||||
|
||||
class Users {
|
||||
private 'DAO.Users_typekey': Users;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface Users {
|
||||
Append(User: User): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): User;
|
||||
Item(Item: number | string): User;
|
||||
Refresh(): void;
|
||||
(Item: number | string): User;
|
||||
}
|
||||
|
||||
class Workspace {
|
||||
@@ -836,12 +842,19 @@ declare namespace DAO {
|
||||
BeginTrans(): void;
|
||||
Close(): void;
|
||||
|
||||
/** @param number [Options=0] */
|
||||
/** @param Options [Options=0] */
|
||||
CommitTrans(Options?: number): void;
|
||||
readonly Connections: Connections;
|
||||
CreateDatabase(Name: string, Connect: string, Option?: any): Database;
|
||||
CreateGroup(Name?: any, PID?: any): Group;
|
||||
CreateUser(Name?: any, PID?: any, Password?: any): User;
|
||||
|
||||
/**
|
||||
* @param Connect Specify one of the following:
|
||||
* * the locale, using one of the language constants
|
||||
* * the password, in the form `;pwd=MyNewPassword'`
|
||||
* * both the constant and a password, e.g. `dbLangGreek + ';pwd=MyNewPassword'`
|
||||
*/
|
||||
CreateDatabase(Name: string, Connect: string, Option?: DatabaseTypeEnum): Database;
|
||||
CreateGroup(Name?: string, PID?: string): Group;
|
||||
CreateUser(Name?: string, PID?: string, Password?: string): User;
|
||||
readonly Databases: Databases;
|
||||
DefaultCursorDriver: number;
|
||||
readonly Groups: Groups;
|
||||
@@ -849,8 +862,12 @@ declare namespace DAO {
|
||||
IsolateODBCTrans: number;
|
||||
LoginTimeout: number;
|
||||
Name: string;
|
||||
OpenConnection(Name: string, Options?: any, ReadOnly?: any, Connect?: any): Connection;
|
||||
OpenDatabase(Name: string, Options?: any, ReadOnly?: any, Connect?: any): Database;
|
||||
|
||||
/**
|
||||
* @param Connect ODBC connection string; prepend with `ODBC;`
|
||||
*/
|
||||
OpenConnection(Name: string, Options?: DriverPromptEnum | RecordsetOptionEnum.dbRunAsync, ReadOnly?: boolean, Connect?: string): Connection;
|
||||
OpenDatabase(Name: string, Exclusive?: boolean, ReadOnly?: boolean, Connect?: string): Database;
|
||||
readonly Properties: Properties;
|
||||
Rollback(): void;
|
||||
readonly Type: number;
|
||||
@@ -858,53 +875,24 @@ declare namespace DAO {
|
||||
readonly Users: Users;
|
||||
}
|
||||
|
||||
class Workspaces {
|
||||
private 'DAO.Workspaces_typekey': Workspaces;
|
||||
private constructor();
|
||||
Append(Object: any): void;
|
||||
interface Workspaces {
|
||||
Append(Workspace: Workspace): void;
|
||||
readonly Count: number;
|
||||
Delete(Name: string): void;
|
||||
Item(Item: any): Workspace;
|
||||
Item(Item: number | string): Workspace;
|
||||
Refresh(): void;
|
||||
(Item: number | string): Workspace;
|
||||
}
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
'DAO.DBEngine': DAO.DBEngine;
|
||||
'DAO.DBEngine.120': DAO.DBEngine;
|
||||
'DAO.Field': DAO.Field;
|
||||
'DAO.Group': DAO.Group;
|
||||
'DAO.Index': DAO.Index;
|
||||
'DAO.PrivateDBEngine': DAO.PrivDBEngine;
|
||||
'DAO.PrivateDBEngine': DAO.DBEngine;
|
||||
'DAO.QueryDef': DAO.QueryDef;
|
||||
'DAO.Relation': DAO.Relation;
|
||||
'DAO.TableDef': DAO.TableDef;
|
||||
'DAO.User': DAO.User;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: DAO.Connections): Enumerator<DAO.Connection>;
|
||||
new(col: DAO.Containers): Enumerator<DAO.Container>;
|
||||
new(col: DAO.Databases): Enumerator<DAO.Database>;
|
||||
new(col: DAO.Documents): Enumerator<DAO.Document>;
|
||||
new(col: DAO.Errors): Enumerator<DAO.Error>;
|
||||
new(col: DAO.Fields): Enumerator<DAO.Field>;
|
||||
new(col: DAO.Groups): Enumerator<DAO.Group>;
|
||||
new(col: DAO.Indexes): Enumerator<DAO.Index>;
|
||||
new(col: DAO.Parameters): Enumerator<DAO.Parameter>;
|
||||
new(col: DAO.Properties): Enumerator<DAO.Property>;
|
||||
new(col: DAO.QueryDefs): Enumerator<DAO.QueryDef>;
|
||||
new(col: DAO.Recordsets): Enumerator<DAO.Recordset>;
|
||||
new(col: DAO.Relations): Enumerator<DAO.Relation>;
|
||||
new(col: DAO.TableDefs): Enumerator<DAO.TableDef>;
|
||||
new(col: DAO.Users): Enumerator<DAO.User>;
|
||||
new(col: DAO.Workspaces): Enumerator<DAO.Workspace>;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Vendored
+3
-6
@@ -2,7 +2,9 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/windows/desktop/bb773938(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.5
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace DiskQuotaTypeLibrary {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
@@ -136,7 +138,6 @@ interface ActiveXObject {
|
||||
on(
|
||||
obj: DiskQuotaTypeLibrary.DiskQuotaControl, event: 'OnUserNameChanged', argNames: ['pUser'], handler: (
|
||||
this: DiskQuotaTypeLibrary.DiskQuotaControl, parameter: {readonly pUser: DiskQuotaTypeLibrary.DIDiskQuotaUser}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
@@ -146,7 +147,3 @@ interface ActiveXObjectNameMap {
|
||||
interface EnumeratorConstructor {
|
||||
new(col: DiskQuotaTypeLibrary.DiskQuotaControl): Enumerator<DiskQuotaTypeLibrary.DIDiskQuotaUser>;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
/// <reference types="activex-msforms" />
|
||||
/// <reference types="activex-scripting" />
|
||||
|
||||
// some helpers
|
||||
const toSafeArray = <T>(...items: T[]): SafeArray<T> => {
|
||||
const dict = new ActiveXObject('Scripting.Dictionary');
|
||||
const dict: Scripting.Dictionary<number, T> = new ActiveXObject('Scripting.Dictionary');
|
||||
items.forEach((x, index) => dict.Add(index, x));
|
||||
return dict.Items() as SafeArray<T>;
|
||||
return dict.Items();
|
||||
};
|
||||
const inCollection = <T = any>(collection: { Item(index: any): T }, index: string | number): T | undefined => {
|
||||
let item: T | undefined;
|
||||
@@ -279,7 +280,7 @@ const setColumnVisibility = (visible: boolean) => {
|
||||
const data = sheet.Range("L2", sheet.Range('L100').End(Excel.XlDirection.xlUp)).Value() as SafeArray;
|
||||
sheet.Range('L1', sheet.Range('L100').End(Excel.XlDirection.xlUp)).ClearContents();
|
||||
|
||||
const combobox = sheet.OLEObjects('ComboBox1').Object as MSForms.ComboBox2;
|
||||
const combobox = sheet.OLEObjects('ComboBox1').Object as MSForms.ComboBox;
|
||||
combobox.Clear();
|
||||
ActiveXObject.set(combobox, 'List', [], data);
|
||||
combobox.ListIndex = -1;
|
||||
@@ -293,13 +294,19 @@ const setColumnVisibility = (visible: boolean) => {
|
||||
const dict = new ActiveXObject('Scripting.Dictionary');
|
||||
arr.forEach(x => ActiveXObject.set(dict, 'Item', [x], true));
|
||||
|
||||
const combobox = sheet.OLEObjects('ComboBox1').Object as MSForms.ComboBox2;
|
||||
const combobox = sheet.OLEObjects('ComboBox1').Object as MSForms.ComboBox;
|
||||
combobox.Clear();
|
||||
const enumerator = new Enumerator(dict.Items());
|
||||
|
||||
// iterate over keys using Enumerator
|
||||
const enumerator = new Enumerator(dict);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
combobox.AddItem(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
|
||||
// alternatively, make a JS array out of the keys, and iterate using forEach
|
||||
// new VBArray(dict.Keys()).toArray().forEach(x => combobox.AddItem(x));
|
||||
})();
|
||||
})();
|
||||
|
||||
|
||||
Vendored
-1
@@ -9723,7 +9723,6 @@ interface ActiveXObject {
|
||||
set(obj: Excel.Workbook, propertyName: 'Colors', parameterTypes: [any], newValue: any): void;
|
||||
set(obj: Excel.Range, propertyName: 'Value', parameterTypes: [Excel.XlRangeValueDataType], newValue: any): void;
|
||||
set(obj: Excel.Range, propertyName: 'Value', newValue: any): void; // because Value is defined on the type as a method, not a property
|
||||
new <K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/// <reference types="activex-iwshruntimelibrary" />
|
||||
/// <reference types="windows-script-host" />
|
||||
/// <reference types="activex-scripting" />
|
||||
|
||||
const collectionToArray = <T>(col: { Item(index: any): T } | SafeArray<T>) => {
|
||||
const collectionToArray = <T>(col: { Item(index: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
@@ -12,9 +13,9 @@ const collectionToArray = <T>(col: { Item(index: any): T } | SafeArray<T>) => {
|
||||
};
|
||||
|
||||
const toSafeArray = <T>(...items: T[]): SafeArray<T> => {
|
||||
const dict = new ActiveXObject('Scripting.Dictionary');
|
||||
const dict: Scripting.Dictionary<number, T> = new ActiveXObject('Scripting.Dictionary');
|
||||
items.forEach((x, index) => dict.Add(index, x));
|
||||
return dict.Items() as SafeArray<T>;
|
||||
return dict.Items();
|
||||
};
|
||||
|
||||
const VB = {
|
||||
@@ -422,7 +423,7 @@ the job?
|
||||
document.GroupBroadcastReceipts = true;
|
||||
|
||||
const jobIDs = document.Submit('');
|
||||
collectionToArray(jobIDs).forEach(jobID => WScript.Echo(`The job ID is ${jobID}`));
|
||||
new VBArray(jobIDs).toArray().forEach(jobID => WScript.Echo(`The job ID is ${jobID}`));
|
||||
|
||||
while (recipients.Count > 0) {
|
||||
recipients.Remove(1);
|
||||
|
||||
Vendored
-1
@@ -2011,7 +2011,6 @@ interface ActiveXObject {
|
||||
this: FAXCOMEXLib.FaxServer, parameter: {readonly riid: stdole.GUID, ppvObj: undefined}) => void): void;
|
||||
on(obj: FAXCOMEXLib.FaxAccount, event: 'AddRef' | 'Release', handler: (this: FAXCOMEXLib.FaxAccount, parameter: {}) => void): void;
|
||||
on(obj: FAXCOMEXLib.FaxServer, event: 'AddRef' | 'Release', handler: (this: FAXCOMEXLib.FaxServer, parameter: {}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Vendored
+1
-2
@@ -2,7 +2,7 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/jj602751.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-adodb" />
|
||||
/// <reference types="activex-msxml2" />
|
||||
@@ -1168,7 +1168,6 @@ interface ActiveXObject {
|
||||
on(obj: InfoPath.Button, event: 'AddRef' | 'Release', handler: (this: InfoPath.Button, parameter: {}) => void): void;
|
||||
on(obj: InfoPath.DataDOM, event: 'AddRef' | 'Release', handler: (this: InfoPath.DataDOM, parameter: {}) => void): void;
|
||||
on(obj: InfoPath.XDocument, event: 'AddRef' | 'Release', handler: (this: InfoPath.XDocument, parameter: {}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/// <reference types="activex-scripting" />
|
||||
|
||||
const dict: Scripting.Dictionary<string, number> = new ActiveXObject('Scripting.Dictionary');
|
||||
dict.Add('one', 1);
|
||||
dict.Add('two', 2);
|
||||
dict.Add('three', 3);
|
||||
|
||||
const keyEnumerator = new Enumerator(dict);
|
||||
keyEnumerator.moveFirst();
|
||||
while (!keyEnumerator.atEnd()) {
|
||||
const item = dict(keyEnumerator.item());
|
||||
const power = Math.pow(item, 2);
|
||||
}
|
||||
|
||||
const keysArray = new VBArray(dict.Keys()).toArray();
|
||||
const itemsArray = new VBArray(dict.Items()).toArray();
|
||||
for (let i = 0; i < keysArray.length; i++) {
|
||||
const key = keysArray[i];
|
||||
const item = itemsArray[i];
|
||||
}
|
||||
Vendored
+111
@@ -0,0 +1,111 @@
|
||||
// Type definitions for Javascript Automation interop 0.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/ff521046(v=vs.85).aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
interface ActiveXObjectNameMap { }
|
||||
|
||||
interface ActiveXObject {
|
||||
new <K extends keyof ActiveXObjectNameMap>(progid: K): ActiveXObjectNameMap[K];
|
||||
new(s: string): any;
|
||||
}
|
||||
declare var ActiveXObject: ActiveXObject;
|
||||
|
||||
/**
|
||||
* Represents an Automation SAFEARRAY
|
||||
*/
|
||||
declare class SafeArray<T = any> {
|
||||
private constructor();
|
||||
private SafeArray_typekey: SafeArray<T>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows enumerating over a COM collection, which may not have indexed item access.
|
||||
*/
|
||||
interface Enumerator<T = any> {
|
||||
/**
|
||||
* Returns true if the current item is the last one in the collection, or the collection is empty,
|
||||
* or the current item is undefined.
|
||||
*/
|
||||
atEnd(): boolean;
|
||||
|
||||
/**
|
||||
* Returns the current item in the collection
|
||||
*/
|
||||
item(): T;
|
||||
|
||||
/**
|
||||
* Resets the current item in the collection to the first item. If there are no items in the collection,
|
||||
* the current item is set to undefined.
|
||||
*/
|
||||
moveFirst(): void;
|
||||
|
||||
/**
|
||||
* Moves the current item to the next item in the collection. If the enumerator is at the end of
|
||||
* the collection or the collection is empty, the current item is set to undefined.
|
||||
*/
|
||||
moveNext(): void;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new <T = any>(collection: { Item(index: any): T }): Enumerator<T>;
|
||||
// new (collection: any): Enumerator;
|
||||
}
|
||||
|
||||
declare var Enumerator: EnumeratorConstructor;
|
||||
|
||||
/**
|
||||
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions.
|
||||
*/
|
||||
interface VBArray<T = any> {
|
||||
/**
|
||||
* Returns the number of dimensions (1-based).
|
||||
*/
|
||||
dimensions(): number;
|
||||
|
||||
/**
|
||||
* Takes an index for each dimension in the array, and returns the item at the corresponding location.
|
||||
*/
|
||||
getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
|
||||
|
||||
/**
|
||||
* Returns the smallest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
lbound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the largest available index for a given dimension.
|
||||
* @param dimension 1-based dimension (defaults to 1)
|
||||
*/
|
||||
ubound(dimension?: number): number;
|
||||
|
||||
/**
|
||||
* Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions,
|
||||
* each successive dimension is appended to the end of the array.
|
||||
* Example: [[1,2,3],[4,5,6]] becomes [1,2,3,4,5,6]
|
||||
*/
|
||||
toArray(): T[];
|
||||
}
|
||||
|
||||
interface VBArrayConstructor {
|
||||
new <T = any>(safeArray: SafeArray<T>): VBArray<T>;
|
||||
}
|
||||
|
||||
declare var VBArray: VBArrayConstructor;
|
||||
|
||||
/** Automation date (VT_DATE) */
|
||||
declare class VarDate {
|
||||
private constructor();
|
||||
private VarDate_typekey: VarDate;
|
||||
}
|
||||
|
||||
interface DateConstructor {
|
||||
new(vd: VarDate): Date;
|
||||
}
|
||||
|
||||
interface Date {
|
||||
getVarDate: () => VarDate;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [ "../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"activex-interop-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -1,3 +1,16 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
const wshn = new ActiveXObject('WScript.Network');
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/s6wt333f(v=vs.84).aspx
|
||||
|
||||
+122
-33
@@ -1,14 +1,15 @@
|
||||
// Type definitions for Windows Script Host Object Model - IWshRuntimeLibrary 1.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/9bbdkx3k(v=vs.84).aspx
|
||||
// Type definitions for Windows Script Host Runtime Object Model 0.0
|
||||
// Project: https://msdn.microsoft.com/en-us/library/9bbdkx3k.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace IWshRuntimeLibrary {
|
||||
type WindowStyle = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
|
||||
type ShortcutWindowStyle = 1 | 3 | 7;
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum ButtonType {
|
||||
OK,
|
||||
OKCancel,
|
||||
@@ -19,7 +20,6 @@ declare namespace IWshRuntimeLibrary {
|
||||
CancelTryagainContinue
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum EventType {
|
||||
AuditFailure = 5,
|
||||
AuditSuccess = 4,
|
||||
@@ -29,7 +29,6 @@ declare namespace IWshRuntimeLibrary {
|
||||
Warning = 2
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum IconType {
|
||||
Stop = 16,
|
||||
QuestionMark = 32,
|
||||
@@ -37,7 +36,6 @@ declare namespace IWshRuntimeLibrary {
|
||||
InformationMark = 64,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum PopupType {
|
||||
SecondButtonDefault = 256,
|
||||
ThirdButtonDefault = 512,
|
||||
@@ -46,7 +44,6 @@ declare namespace IWshRuntimeLibrary {
|
||||
RTL = 1048576,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum PopupSelection {
|
||||
NoButton = -1,
|
||||
OK = 1,
|
||||
@@ -60,14 +57,12 @@ declare namespace IWshRuntimeLibrary {
|
||||
Continue = 11,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WshExecStatus {
|
||||
WshFailed = 2,
|
||||
WshFinished = 1,
|
||||
WshRunning = 0,
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum WshWindowStyle {
|
||||
WshHide = 0,
|
||||
WshMaximizedFocus = 3,
|
||||
@@ -77,24 +72,91 @@ declare namespace IWshRuntimeLibrary {
|
||||
WshNormalNoFocus = 4,
|
||||
}
|
||||
|
||||
class TextStream {
|
||||
private 'IWshRuntimeLibrary.TextStream_typekey': TextStream;
|
||||
private constructor();
|
||||
readonly AtEndOfLine: boolean;
|
||||
readonly AtEndOfStream: boolean;
|
||||
Close(): void;
|
||||
readonly Column: number;
|
||||
readonly Line: number;
|
||||
Read(Characters: number): string;
|
||||
ReadAll(): string;
|
||||
ReadLine(): string;
|
||||
Skip(Characters: number): void;
|
||||
SkipLine(): void;
|
||||
Write(Text: string): void;
|
||||
WriteBlankLines(Lines: number): void;
|
||||
class TextStreamBase {
|
||||
/**
|
||||
* The column number of the current character position in an input stream.
|
||||
*/
|
||||
Column: number;
|
||||
|
||||
/** @param string [Text=''] */
|
||||
WriteLine(Text?: string): void;
|
||||
/**
|
||||
* The current line number in an input stream.
|
||||
*/
|
||||
Line: number;
|
||||
|
||||
/**
|
||||
* Closes a text stream.
|
||||
* It is not necessary to close standard streams; they close automatically when the process ends. If
|
||||
* you close a standard stream, be aware that any other pointers to that standard stream become invalid.
|
||||
*/
|
||||
Close(): void;
|
||||
}
|
||||
|
||||
class TextStreamWriter extends TextStreamBase {
|
||||
private 'IWshRuntimeLibrary.TextStreamWriter_typekey': TextStreamWriter;
|
||||
private constructor();
|
||||
|
||||
/**
|
||||
* Sends a string to an output stream.
|
||||
*/
|
||||
Write(s: string): void;
|
||||
|
||||
/**
|
||||
* Sends a specified number of blank lines (newline characters) to an output stream.
|
||||
*/
|
||||
WriteBlankLines(intLines: number): void;
|
||||
|
||||
/**
|
||||
* Sends a string followed by a newline character to an output stream.
|
||||
*/
|
||||
WriteLine(s: string): void;
|
||||
}
|
||||
|
||||
class TextStreamReader extends TextStreamBase {
|
||||
private 'IWshRuntimeLibrary.TextStreamReader_typekey': TextStreamReader;
|
||||
private constructor();
|
||||
|
||||
/**
|
||||
* Returns a specified number of characters from an input stream, starting at the current pointer position.
|
||||
* Does not return until the ENTER key is pressed.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
Read(characters: number): string;
|
||||
|
||||
/**
|
||||
* Returns all characters from an input stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadAll(): string;
|
||||
|
||||
/**
|
||||
* Returns an entire line from an input stream.
|
||||
* Although this method extracts the newline character, it does not add it to the returned string.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
*/
|
||||
ReadLine(): string;
|
||||
|
||||
/**
|
||||
* Skips a specified number of characters when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode; causes an error in writing or appending mode.
|
||||
* @param characters Positive number of characters to skip forward. (Backward skipping is not supported.)
|
||||
*/
|
||||
Skip(characters: number): void;
|
||||
|
||||
/**
|
||||
* Skips the next line when reading from an input text stream.
|
||||
* Can only be used on a stream in reading mode, not writing or appending mode.
|
||||
*/
|
||||
SkipLine(): void;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a line.
|
||||
*/
|
||||
AtEndOfLine: boolean;
|
||||
|
||||
/**
|
||||
* Indicates whether the stream pointer position is at the end of a stream.
|
||||
*/
|
||||
AtEndOfStream: boolean;
|
||||
}
|
||||
|
||||
/** Generic Collection Object */
|
||||
@@ -109,7 +171,7 @@ declare namespace IWshRuntimeLibrary {
|
||||
interface WshEnvironment {
|
||||
Count(): number;
|
||||
Item(Name: string): string;
|
||||
readonly length: number;
|
||||
readonly Length: number;
|
||||
Remove(Name: string): void;
|
||||
(Name: string): string;
|
||||
}
|
||||
@@ -121,9 +183,9 @@ declare namespace IWshRuntimeLibrary {
|
||||
readonly ExitCode: number;
|
||||
readonly ProcessID: number;
|
||||
readonly Status: WshExecStatus;
|
||||
readonly StdErr: TextStream;
|
||||
readonly StdIn: TextStream;
|
||||
readonly StdOut: TextStream;
|
||||
readonly StdErr: TextStreamWriter;
|
||||
readonly StdIn: TextStreamReader;
|
||||
readonly StdOut: TextStreamWriter;
|
||||
Terminate(): void;
|
||||
}
|
||||
|
||||
@@ -336,13 +398,40 @@ declare namespace IWshRuntimeLibrary {
|
||||
TargetPath: string;
|
||||
}
|
||||
}
|
||||
declare namespace WSHControllerLibrary {
|
||||
class WSHController {
|
||||
private 'WSHControllerLibrary.WSHController_typekey': WSHController;
|
||||
private constructor();
|
||||
CreateScript(Command: string, Server?: any): any;
|
||||
}
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
set(obj: IWshRuntimeLibrary.WshEnvironment, propertyName: 'Item', parameterTypes: [string], newValue: string): void;
|
||||
new <K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
declare namespace ScriptSigner {
|
||||
class Signer {
|
||||
private 'ScriptSigner.Signer_typekey': Signer;
|
||||
private constructor();
|
||||
|
||||
/** @param Store [Store='my'] */
|
||||
Sign(FileExtension: string, Text: string, Certificate: string, Store?: string): string;
|
||||
|
||||
/** @param Store [Store='my'] */
|
||||
SignFile(FileName: string, Certificate: string, Store?: string): void;
|
||||
|
||||
/** @param ShowUI [ShowUI=false] */
|
||||
Verify(FileExtension: string, Text: string, ShowUI?: boolean): boolean;
|
||||
|
||||
/** @param ShowUI [ShowUI=false] */
|
||||
VerifyFile(FileName: string, ShowUI?: boolean): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
'WSHController': WSHControllerLibrary.WSHController;
|
||||
'Scripting.Signer': ScriptSigner.Signer;
|
||||
'WScript.Network': IWshRuntimeLibrary.WshNetwork;
|
||||
'WScript.Shell': IWshRuntimeLibrary.WshShell;
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
set(obj: IWshRuntimeLibrary.WshEnvironment, propertyName: 'Item', parameterTypes: [string], newValue: string): void;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
@@ -21,4 +20,4 @@
|
||||
"index.d.ts",
|
||||
"activex-iwshruntimelibrary-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
(() => {
|
||||
// https://wiki.openoffice.org/wiki/Documentation/DevGuide/ProUNO/Bridge/Automation_Bridge
|
||||
|
||||
|
||||
Vendored
+3
-4
@@ -2,7 +2,9 @@
|
||||
// Project: https://api.libreoffice.org/
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare class type {
|
||||
private typekey: type;
|
||||
@@ -12,9 +14,6 @@ declare class sequence<T = any> {
|
||||
private typekey: sequence<T>;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line no-empty-interface
|
||||
interface SafeArray<T = any> {}
|
||||
|
||||
declare namespace com.sun.star {
|
||||
namespace accessibility {
|
||||
/**
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Vendored
+119
-2305
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
let htmlfile = new ActiveXObject('htmlfile');
|
||||
let htmldoc = htmlfile.createDocumentFromUrl('https://msdn.microsoft.com/en-us/library/aa741317(v=vs.85).aspx', 'null');
|
||||
let length = htmldoc.all.length;
|
||||
|
||||
Vendored
+834
-1755
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms764708(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const dom = new ActiveXObject('Msxml2.DOMDocument.6.0');
|
||||
dom.async = false;
|
||||
dom.resolveExternals = false;
|
||||
dom.loadXML('<a>A</a>');
|
||||
WScript.Echo(`dom: ${dom.xml}`);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms766390(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
|
||||
doc.load('test.xml');
|
||||
WScript.Echo(`doc: ${doc.xml}`);
|
||||
})();
|
||||
}
|
||||
|
||||
const MakeDOM = () => {
|
||||
try {
|
||||
@@ -37,7 +39,7 @@ const LoadDOM = (file: string) => {
|
||||
};
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms759105(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const doc = new ActiveXObject('Msxml2.DOMDocument.6.0');
|
||||
doc.async = false;
|
||||
doc.resolveExternals = false;
|
||||
@@ -60,10 +62,10 @@ const LoadDOM = (file: string) => {
|
||||
`;
|
||||
doc.loadXML(xml);
|
||||
doc.save('saved.xml');
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms764656(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const doc = LoadDOM('test.xml')!;
|
||||
const xsl = (LoadDOM('test.xsl')! as any) as MSXML2.IXMLDOMNode;
|
||||
|
||||
@@ -73,10 +75,10 @@ const LoadDOM = (file: string) => {
|
||||
const out = MakeDOM()!;
|
||||
doc.transformNodeToObject(xsl, out);
|
||||
WScript.Echo('\ndoc.transformNodeToObject:\n' + out.xml);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms763685(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const dom = MakeDOM()!;
|
||||
|
||||
// Create a processing instruction targeted for xml.
|
||||
@@ -148,10 +150,10 @@ const LoadDOM = (file: string) => {
|
||||
|
||||
// Save the XML document to a file.
|
||||
dom.save("dynamDom.xml");
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms757050(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const dom = LoadDOM("stocks.xml")!;
|
||||
try {
|
||||
// Query a single node.
|
||||
@@ -172,17 +174,17 @@ const LoadDOM = (file: string) => {
|
||||
} catch (e) {
|
||||
WScript.Echo(e.description);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms757064(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const xhr = new ActiveXObject("Msxml2.XMLHTTP.6.0");
|
||||
xhr.open("GET", "http://localhost/sxh/contact.asp?SearchID=John Doe", false);
|
||||
xhr.send();
|
||||
|
||||
const doc = xhr.responseXML;
|
||||
WScript.Echo(doc.xml);
|
||||
})();
|
||||
}
|
||||
|
||||
const xmlValidation = (fn: (x: MSXML2.DOMDocument60) => void) => {
|
||||
// Create and initialize the DOMDocument object
|
||||
@@ -212,16 +214,16 @@ ${x.xml}
|
||||
};
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms766449(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const validateFile = (filename: string) => xmlValidation(x => x.load(filename));
|
||||
|
||||
let sOutput = validateFile("nn-valid.xml");
|
||||
sOutput = sOutput + validateFile("nn-notValid.xml");
|
||||
WScript.Echo(sOutput);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms767542(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const validateFile = (filename: string) => xmlValidation(x => {
|
||||
// Configure DOM properties for namespace selection.
|
||||
x.setProperty("SelectionLanguage", "XPath");
|
||||
@@ -235,10 +237,10 @@ ${x.xml}
|
||||
let sOutput = validateFile("sl-valid.xml");
|
||||
sOutput = sOutput + validateFile("sl-notValid.xml");
|
||||
WScript.Echo(sOutput);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms766439(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const validateFile = (filename: string) => xmlValidation(xd => {
|
||||
// Create a schema cache and add books.xsd to it.
|
||||
const xs = new ActiveXObject('Msxml2.XMLSchemaCache');
|
||||
@@ -253,10 +255,10 @@ ${x.xml}
|
||||
let sOutput = validateFile("sc-valid.xml");
|
||||
sOutput = sOutput + validateFile("sc-notValid.xml");
|
||||
WScript.Echo(sOutput);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms767636(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
const validateFile = (filename: string) => xmlValidation(x => {
|
||||
x.setProperty("UseInlineSchema", true);
|
||||
x.load(filename);
|
||||
@@ -265,10 +267,10 @@ ${x.xml}
|
||||
let sOutput = validateFile("valid.xml");
|
||||
sOutput = sOutput + validateFile("notValid.xml");
|
||||
WScript.Echo(sOutput);
|
||||
})();
|
||||
}
|
||||
|
||||
// https://msdn.microsoft.com/en-us/library/ms757833(v=vs.85).aspx
|
||||
(() => {
|
||||
{
|
||||
// Load an XML document into a DOM instance.
|
||||
const oXMLDoc = LoadDOM("books.xml")!;
|
||||
|
||||
@@ -326,4 +328,4 @@ ${oError.reason}`;
|
||||
}
|
||||
WScript.Echo(msg);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
Vendored
+38
-41
@@ -2,7 +2,9 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/ms763742.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace MSXML2 {
|
||||
/** Schema Object Model Content Types */
|
||||
@@ -424,7 +426,7 @@ declare namespace MSXML2 {
|
||||
createEntityReference(name: string): IXMLDOMEntityReference;
|
||||
|
||||
/** create a node of the specified node type and name */
|
||||
createNode(type: any, name: string, namespaceURI: string): IXMLDOMNode;
|
||||
createNode(type: DOMNodeType.NODE_ATTRIBUTE | DOMNodeType.NODE_CDATA_SECTION | DOMNodeType.NODE_COMMENT | DOMNodeType.NODE_DOCUMENT_FRAGMENT | DOMNodeType.NODE_TEXT | DOMNodeType.NODE_ELEMENT | DOMNodeType.NODE_ENTITY_REFERENCE | DOMNodeType.NODE_PROCESSING_INSTRUCTION, name: string, namespaceURI: string): IXMLDOMNode;
|
||||
|
||||
/** create a processing instruction node */
|
||||
createProcessingInstruction(target: string, data: string): IXMLDOMProcessingInstruction;
|
||||
@@ -433,7 +435,7 @@ declare namespace MSXML2 {
|
||||
createTextNode(data: string): IXMLDOMText;
|
||||
|
||||
/** the data type of the node */
|
||||
dataType: any;
|
||||
dataType: string | null;
|
||||
|
||||
/** pointer to the definition of the node in the DTD or schema */
|
||||
readonly definition: IXMLDOMNode;
|
||||
@@ -497,7 +499,7 @@ declare namespace MSXML2 {
|
||||
readonly nodeTypeString: string;
|
||||
|
||||
/** value stored in the node */
|
||||
nodeValue: any;
|
||||
nodeValue: string | null;
|
||||
|
||||
/** register an ondataavailable event handler */
|
||||
readonly ondataavailable: any;
|
||||
@@ -795,8 +797,7 @@ declare namespace MSXML2 {
|
||||
getAllResponseHeaders(ppwszHeaders: string): void;
|
||||
GetCookie(pwszUrl: string, pwszName: string, dwFlags: number, pcCookies: number, ppCookies: tagXHR_COOKIE): void;
|
||||
getResponseHeader(pwszHeader: string, ppwszValue: string): void;
|
||||
open(
|
||||
pwszMethod: string, pwszUrl: string, pStatusCallback: IXMLHTTPRequest2Callback, pwszUserName: string, pwszPassword: string, pwszProxyUserName: string, pwszProxyPassword: string): void;
|
||||
open(pwszMethod: string, pwszUrl: string, pStatusCallback: IXMLHTTPRequest2Callback, pwszUserName: string, pwszPassword: string, pwszProxyUserName: string, pwszProxyPassword: string): void;
|
||||
send(pBody: ISequentialStream, cbBody: number): void;
|
||||
SetCookie(pCookie: tagXHR_COOKIE, pdwCookieState: number): void;
|
||||
SetCustomResponseStream(pSequentialStream: ISequentialStream): void;
|
||||
@@ -805,11 +806,11 @@ declare namespace MSXML2 {
|
||||
}
|
||||
|
||||
/** IMXNamespacePrefixes interface */
|
||||
class IMXNamespacePrefixes {
|
||||
private 'MSXML2.IMXNamespacePrefixes_typekey': IMXNamespacePrefixes;
|
||||
private constructor();
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IMXNamespacePrefixes {
|
||||
item(index: number): string;
|
||||
readonly length: number;
|
||||
(index: number): string;
|
||||
}
|
||||
|
||||
/** XML Schema */
|
||||
@@ -848,21 +849,21 @@ declare namespace MSXML2 {
|
||||
}
|
||||
|
||||
/** XML Schema Item Collection */
|
||||
class ISchemaItemCollection {
|
||||
private 'MSXML2.ISchemaItemCollection_typekey': ISchemaItemCollection;
|
||||
private constructor();
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface ISchemaItemCollection {
|
||||
item(index: number): ISchemaItem;
|
||||
itemByName(name: string): ISchemaItem;
|
||||
itemByQName(name: string, namespaceURI: string): ISchemaItem;
|
||||
readonly length: number;
|
||||
(index: number): ISchemaItem;
|
||||
}
|
||||
|
||||
/** XML Schema String Collection */
|
||||
class ISchemaStringCollection {
|
||||
private 'MSXML2.ISchemaStringCollection_typekey': ISchemaStringCollection;
|
||||
private constructor();
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface ISchemaStringCollection {
|
||||
item(index: number): string;
|
||||
readonly length: number;
|
||||
(index: number): string;
|
||||
}
|
||||
|
||||
class ISequentialStream {
|
||||
@@ -1960,10 +1961,8 @@ declare namespace MSXML2 {
|
||||
hasFeature(feature: string, version: string): boolean;
|
||||
}
|
||||
|
||||
class IXMLDOMNamedNodeMap {
|
||||
private 'MSXML2.IXMLDOMNamedNodeMap_typekey': IXMLDOMNamedNodeMap;
|
||||
private constructor();
|
||||
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IXMLDOMNamedNodeMap {
|
||||
/** lookup item by name */
|
||||
getNamedItem(name: string): IXMLDOMNode;
|
||||
|
||||
@@ -1990,6 +1989,9 @@ declare namespace MSXML2 {
|
||||
|
||||
/** set item by name */
|
||||
setNamedItem(newItem: IXMLDOMNode): IXMLDOMNode;
|
||||
|
||||
/** collection of nodes */
|
||||
(index: number): IXMLDOMNode;
|
||||
}
|
||||
|
||||
/** Core DOM node interface */
|
||||
@@ -2090,10 +2092,8 @@ declare namespace MSXML2 {
|
||||
readonly xml: string;
|
||||
}
|
||||
|
||||
class IXMLDOMNodeList {
|
||||
private 'MSXML2.IXMLDOMNodeList_typekey': IXMLDOMNodeList;
|
||||
private constructor();
|
||||
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IXMLDOMNodeList {
|
||||
/** collection of nodes */
|
||||
item(index: number): IXMLDOMNode;
|
||||
|
||||
@@ -2105,6 +2105,9 @@ declare namespace MSXML2 {
|
||||
|
||||
/** reset the position of iterator */
|
||||
reset(): void;
|
||||
|
||||
/** collection of nodes */
|
||||
(index: number): IXMLDOMNode;
|
||||
}
|
||||
|
||||
/** structure for reporting parser errors */
|
||||
@@ -2238,10 +2241,8 @@ declare namespace MSXML2 {
|
||||
}
|
||||
|
||||
/** XML Schemas Collection */
|
||||
class IXMLDOMSchemaCollection {
|
||||
private 'MSXML2.IXMLDOMSchemaCollection_typekey': IXMLDOMSchemaCollection;
|
||||
private constructor();
|
||||
|
||||
// tslint:disable-next-line:interface-name
|
||||
interface IXMLDOMSchemaCollection {
|
||||
/** add a new schema */
|
||||
add(namespaceURI: string, var_1: any): void;
|
||||
|
||||
@@ -2259,6 +2260,9 @@ declare namespace MSXML2 {
|
||||
|
||||
/** remove schema by namespaceURI */
|
||||
remove(namespaceURI: string): void;
|
||||
|
||||
/** Get namespaceURI for schema by index */
|
||||
(index: number): string;
|
||||
}
|
||||
|
||||
class IXMLDOMText {
|
||||
@@ -2403,7 +2407,7 @@ declare namespace MSXML2 {
|
||||
|
||||
/**
|
||||
* set <xsl:param> values
|
||||
* @param string [namespaceURI='']
|
||||
* @param namespaceURI [namespaceURI='0']
|
||||
*/
|
||||
addParameter(baseName: string, parameter: any, namespaceURI?: string): void;
|
||||
|
||||
@@ -2424,7 +2428,7 @@ declare namespace MSXML2 {
|
||||
|
||||
/**
|
||||
* set XSL mode and it's namespace
|
||||
* @param string [namespaceURI='']
|
||||
* @param namespaceURI [namespaceURI='0']
|
||||
*/
|
||||
setStartMode(mode: string, namespaceURI?: string): void;
|
||||
|
||||
@@ -2487,7 +2491,7 @@ declare namespace MSXML2 {
|
||||
popContext(): void;
|
||||
pushContext(): void;
|
||||
|
||||
/** @param boolean [fDeep=true] */
|
||||
/** @param fDeep [fDeep=true] */
|
||||
pushNodeContext(contextNode: IXMLDOMNode, fDeep?: boolean): void;
|
||||
reset(): void;
|
||||
}
|
||||
@@ -2730,10 +2734,7 @@ declare namespace MSXML2 {
|
||||
}
|
||||
|
||||
/** XML Schema Cache 6.0 */
|
||||
class XMLSchemaCache60 {
|
||||
private 'MSXML2.XMLSchemaCache60_typekey': XMLSchemaCache60;
|
||||
private constructor();
|
||||
|
||||
interface XMLSchemaCache60 {
|
||||
/** add a new schema */
|
||||
add(namespaceURI: string, var_1: any): void;
|
||||
|
||||
@@ -2755,6 +2756,9 @@ declare namespace MSXML2 {
|
||||
remove(namespaceURI: string): void;
|
||||
validate(): void;
|
||||
validateOnLoad: boolean;
|
||||
|
||||
/** Get namespaceURI for schema by index */
|
||||
(index: number): string;
|
||||
}
|
||||
|
||||
/** XSL Stylesheet Cache 6.0 */
|
||||
@@ -2773,7 +2777,6 @@ declare namespace MSXML2 {
|
||||
interface ActiveXObject {
|
||||
on(obj: MSXML2.DOMDocument60, event: 'ondataavailable' | 'onreadystatechange', handler: (this: MSXML2.DOMDocument60, parameter: {}) => void): void;
|
||||
on(obj: MSXML2.FreeThreadedDOMDocument60, event: 'ondataavailable' | 'onreadystatechange', handler: (this: MSXML2.FreeThreadedDOMDocument60, parameter: {}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
@@ -2787,12 +2790,6 @@ interface ActiveXObjectNameMap {
|
||||
'Msxml2.SAXXMLReader': MSXML2.SAXXMLReader60;
|
||||
'Msxml2.ServerXMLHTTP': MSXML2.ServerXMLHTTP60;
|
||||
'Msxml2.XMLHTTP': MSXML2.XMLHTTP60;
|
||||
'Msxml2.XMLHTTP.6.0': MSXML2.XMLHTTP60;
|
||||
'Msxml2.XMLSchemaCache': MSXML2.XMLSchemaCache60;
|
||||
'Msxml2.XMLSchemaCache.6.0': MSXML2.XMLSchemaCache60;
|
||||
'Msxml2.XSLTemplate': MSXML2.XSLTemplate60;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
/// <reference types="activex-word" />
|
||||
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
let app = new ActiveXObject('Word.Application');
|
||||
app.Visible = true;
|
||||
let dlg = app.FileDialog(Office.MsoFileDialogType.msoFileDialogFolderPicker);
|
||||
dlg.AllowMultiSelect = true;
|
||||
dlg.Title = 'Select one or more folders';
|
||||
dlg.Execute();
|
||||
let enumerator = new Enumerator(dlg.SelectedItems);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
WScript.Echo(enumerator.item);
|
||||
for (const item of collectionToArray(dlg.SelectedItems)) {
|
||||
WScript.Echo(item);
|
||||
}
|
||||
|
||||
let enumerator2 = new Enumerator(app.COMAddIns);
|
||||
enumerator2.moveFirst();
|
||||
while (!enumerator2.atEnd()) {
|
||||
const item = enumerator2.item();
|
||||
for (const item of collectionToArray(app.COMAddIns)) {
|
||||
WScript.Echo(`COM Addin: ${item.Description} -- ${item.ProgId}`);
|
||||
}
|
||||
|
||||
Vendored
+602
-512
File diff suppressed because it is too large
Load Diff
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+2
-2
@@ -2,8 +2,9 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/vba/vba-outlook
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
/// <reference types="activex-stdole" />
|
||||
/// <reference types="activex-office" />
|
||||
|
||||
@@ -5855,7 +5856,6 @@ interface ActiveXObject {
|
||||
on(obj: Outlook.TaskRequestDeclineItem, event: 'AfterWrite' | 'BeforeRead' | 'Read' | 'Unload', handler: (this: Outlook.TaskRequestDeclineItem, parameter: {}) => void): void;
|
||||
on(obj: Outlook.TaskRequestItem, event: 'AfterWrite' | 'BeforeRead' | 'Read' | 'Unload', handler: (this: Outlook.TaskRequestItem, parameter: {}) => void): void;
|
||||
on(obj: Outlook.TaskRequestUpdateItem, event: 'AfterWrite' | 'BeforeRead' | 'Read' | 'Unload', handler: (this: Outlook.TaskRequestUpdateItem, parameter: {}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const collectionToArray = <T>(col: any): T[] => {
|
||||
const collectionToArray = <T>(col: {Item(index: any): T}): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
@@ -13,8 +13,8 @@ const collectionToArray = <T>(col: any): T[] => {
|
||||
const app = new ActiveXObject('PowerPoint.Application');
|
||||
(() => {
|
||||
// delete empty textboxes in PowerPoint
|
||||
collectionToArray<PowerPoint.Slide>(app.ActivePresentation.Slides).forEach(slide => {
|
||||
collectionToArray<PowerPoint.Shape>(slide.Shapes).filter(shape =>
|
||||
collectionToArray(app.ActivePresentation.Slides).forEach(slide => {
|
||||
collectionToArray(slide.Shapes).filter(shape =>
|
||||
shape.Type === Office.MsoShapeType.msoTextBox
|
||||
&& shape.TextFrame.TextRange.Text.trim() === ''
|
||||
).forEach(shape => shape.Delete());
|
||||
|
||||
Vendored
+1
-2
@@ -2,7 +2,7 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/fp161225.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-office" />
|
||||
/// <reference types="activex-vbide" />
|
||||
@@ -5374,7 +5374,6 @@ interface ActiveXObject {
|
||||
this: PowerPoint.Application, parameter: {readonly Sel: PowerPoint.Selection, Cancel: boolean}) => void): void;
|
||||
on(obj: PowerPoint.Application, event: 'WindowSelectionChange', argNames: ['Sel'], handler: (this: PowerPoint.Application, parameter: {readonly Sel: PowerPoint.Selection}) => void): void;
|
||||
on(obj: PowerPoint.OLEControl, event: 'GotFocus' | 'LostFocus', handler: (this: PowerPoint.OLEControl, parameter: {}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
// Note -- running these tests under cscript requires some ES5 polyfills
|
||||
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
|
||||
Vendored
+7
-2
@@ -4,6 +4,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace Scripting {
|
||||
// tslint:disable-next-line:no-const-enum
|
||||
const enum CompareMethod {
|
||||
@@ -489,8 +491,7 @@ declare namespace Scripting {
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new <K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
set(obj: Scripting.Dictionary, propertyName: 'Item', parameterTypes: [any], newValue: any): void;
|
||||
set<TKey = any, TValue = any>(obj: Scripting.Dictionary<TKey, TValue>, propertyName: 'Item', parameterTypes: [TKey], newValue: TValue): void;
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
@@ -498,3 +499,7 @@ interface ActiveXObjectNameMap {
|
||||
'Scripting.Encoder': Scripting.Encoder;
|
||||
'Scripting.FileSystemObject': Scripting.FileSystemObject;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new <TKey>(dict: Scripting.Dictionary<TKey>): Enumerator<TKey>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Vendored
+2
-5
@@ -4,6 +4,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace SHDocVw {
|
||||
// tslint:disable-next-line no-const-enum
|
||||
const enum BrowserBarConstants {
|
||||
@@ -1562,7 +1564,6 @@ interface ActiveXObject {
|
||||
on(obj: SHDocVw.ShellNameSpace, event: 'DoubleClick' | 'Initialized' | 'SelectionChange', handler: (this: SHDocVw.ShellNameSpace, parameter: {}) => void): void;
|
||||
on(obj: SHDocVw.WebBrowser, event: 'DownloadBegin' | 'DownloadComplete' | 'OnQuit', handler: (this: SHDocVw.WebBrowser, parameter: {}) => void): void;
|
||||
on(obj: SHDocVw.WebBrowser_V1, event: 'DownloadBegin' | 'DownloadComplete' | 'WindowActivate' | 'WindowMove' | 'WindowResize', handler: (this: SHDocVw.WebBrowser_V1, parameter: {}) => void): void;
|
||||
new <K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
@@ -1571,7 +1572,3 @@ interface ActiveXObjectNameMap {
|
||||
'Shell.UIHelper': SHDocVw.ShellUIHelper;
|
||||
'ShellNameSpace.ShellNameSpace': SHDocVw.ShellNameSpace;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: SHDocVw.ShellWindows): Enumerator<SHDocVw.InternetExplorer>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/// <reference types="activex-iwshruntimelibrary" />
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
const shell = new ActiveXObject('Shell.Application');
|
||||
|
||||
|
||||
Vendored
-1
@@ -1001,7 +1001,6 @@ interface ActiveXObject {
|
||||
on(
|
||||
obj: Shell32.ShellFolderViewOC, event: 'BeginDrag' | 'DefaultVerbInvoked' | 'EnumDone' | 'SelectionChanged' | 'VerbInvoked',
|
||||
handler: (this: Shell32.ShellFolderViewOC, parameter: {}) => void): void;
|
||||
new <K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
Vendored
+9
-6
@@ -2,17 +2,25 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/hh272953.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace stdole {
|
||||
type IFontDisp = StdFont;
|
||||
|
||||
type IPictureDisp = StdPicture;
|
||||
|
||||
type OLE_COLOR = number;
|
||||
|
||||
type OLE_XPOS_CONTAINER = number;
|
||||
|
||||
type OLE_XPOS_PIXELS = number;
|
||||
|
||||
type OLE_YPOS_CONTAINER = number;
|
||||
|
||||
type OLE_YPOS_PIXELS = number;
|
||||
|
||||
const enum LoadPictureConstants {
|
||||
Color = 4,
|
||||
Default = 0,
|
||||
@@ -79,14 +87,9 @@ declare namespace stdole {
|
||||
|
||||
interface ActiveXObject {
|
||||
on(obj: stdole.StdFont, event: 'FontChanged', argNames: ['PropertyName'], handler: (this: stdole.StdFont, parameter: {readonly PropertyName: string}) => void): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
StdFont: stdole.StdFont;
|
||||
StdPicture: stdole.StdPicture;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,21 +1,26 @@
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const collectionToArray = <T>(col: any): T[] => {
|
||||
/// <reference types="windows-script-host" />
|
||||
/// <reference types="activex-word" />
|
||||
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
while (!enumerator.atEnd()) {
|
||||
results.push(enumerator.item());
|
||||
enumerator.moveNext();
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
const app = new ActiveXObject('Word.Application');
|
||||
const projects = collectionToArray<VBIDE.VBProject>(app.VBE.VBProjects);
|
||||
projects.forEach(project => {
|
||||
app.Visible = true;
|
||||
|
||||
for (const project of collectionToArray(app.VBE.VBProjects)) {
|
||||
WScript.Echo(`Name: ${project.Name}`);
|
||||
|
||||
collectionToArray<VBIDE.Reference>(project.References)
|
||||
.forEach(reference => {
|
||||
WScript.Echo(` ${reference.Name} ${reference.Major}.${reference.Minor} -- ${reference.FullPath}`);
|
||||
});
|
||||
});
|
||||
for (const reference of collectionToArray(project.References)) {
|
||||
WScript.Echo(` ${reference.Name} ${reference.Major}.${reference.Minor} -- ${reference.FullPath}`);
|
||||
}
|
||||
}
|
||||
|
||||
app.Quit();
|
||||
|
||||
Vendored
+26
-54
@@ -2,7 +2,7 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/vba/language-reference-vba/articles/collections-visual-basic-add-in-model
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-office" />
|
||||
|
||||
@@ -99,14 +99,13 @@ declare namespace VBIDE {
|
||||
readonly VBE: VBE;
|
||||
}
|
||||
|
||||
class Addins {
|
||||
private 'VBIDE.Addins_typekey': Addins;
|
||||
private constructor();
|
||||
interface Addins {
|
||||
readonly Count: number;
|
||||
Item(index: any): AddIn;
|
||||
readonly Parent: any;
|
||||
Update(): void;
|
||||
readonly VBE: VBE;
|
||||
(index: any): AddIn;
|
||||
}
|
||||
|
||||
class Application {
|
||||
@@ -125,13 +124,13 @@ declare namespace VBIDE {
|
||||
readonly CountOfLines: number;
|
||||
CreateEventProc(EventName: string, ObjectName: string): number;
|
||||
|
||||
/** @param number [Count=1] */
|
||||
/** @param Count [Count=1] */
|
||||
DeleteLines(StartLine: number, Count?: number): void;
|
||||
|
||||
/**
|
||||
* @param boolean [WholeWord=false]
|
||||
* @param boolean [MatchCase=false]
|
||||
* @param boolean [PatternSearch=false]
|
||||
* @param WholeWord [WholeWord=false]
|
||||
* @param MatchCase [MatchCase=false]
|
||||
* @param PatternSearch [PatternSearch=false]
|
||||
*/
|
||||
Find(Target: string, StartLine: number, StartColumn: number, EndLine: number, EndColumn: number, WholeWord?: boolean, MatchCase?: boolean, PatternSearch?: boolean): boolean;
|
||||
InsertLines(Line: number, String: string): void;
|
||||
@@ -161,14 +160,13 @@ declare namespace VBIDE {
|
||||
readonly Window: Window;
|
||||
}
|
||||
|
||||
class CodePanes {
|
||||
private 'VBIDE.CodePanes_typekey': CodePanes;
|
||||
private constructor();
|
||||
interface CodePanes {
|
||||
readonly Count: number;
|
||||
Current: CodePane;
|
||||
Item(index: any): CodePane;
|
||||
readonly Parent: VBE;
|
||||
readonly VBE: VBE;
|
||||
(index: any): CodePane;
|
||||
}
|
||||
|
||||
class CommandBarEvents {
|
||||
@@ -185,9 +183,7 @@ declare namespace VBIDE {
|
||||
readonly Parent: Components;
|
||||
}
|
||||
|
||||
class Components {
|
||||
private 'VBIDE.Components_typekey': Components;
|
||||
private constructor();
|
||||
interface Components {
|
||||
Add(ComponentType: vbext_ComponentType): Component;
|
||||
readonly Application: Application;
|
||||
readonly Count: number;
|
||||
@@ -196,6 +192,7 @@ declare namespace VBIDE {
|
||||
readonly Parent: VBProject;
|
||||
Remove(Component: Component): void;
|
||||
readonly VBE: VBE;
|
||||
(index: any): Component;
|
||||
}
|
||||
|
||||
class Events {
|
||||
@@ -205,15 +202,14 @@ declare namespace VBIDE {
|
||||
ReferencesEvents(VBProject: VBProject): ReferencesEvents;
|
||||
}
|
||||
|
||||
class LinkedWindows {
|
||||
private 'VBIDE.LinkedWindows_typekey': LinkedWindows;
|
||||
private constructor();
|
||||
interface LinkedWindows {
|
||||
Add(Window: Window): void;
|
||||
readonly Count: number;
|
||||
Item(index: any): Window;
|
||||
readonly Parent: Window;
|
||||
Remove(Window: Window): void;
|
||||
readonly VBE: VBE;
|
||||
(index: any): Window;
|
||||
}
|
||||
|
||||
class ProjectTemplate {
|
||||
@@ -223,14 +219,13 @@ declare namespace VBIDE {
|
||||
readonly Parent: Application;
|
||||
}
|
||||
|
||||
class Properties {
|
||||
private 'VBIDE.Properties_typekey': Properties;
|
||||
private constructor();
|
||||
interface Properties {
|
||||
readonly Application: Application;
|
||||
readonly Count: number;
|
||||
Item(index: any): Property;
|
||||
readonly Parent: any;
|
||||
readonly VBE: VBE;
|
||||
(index: any): Property;
|
||||
}
|
||||
|
||||
class Property {
|
||||
@@ -263,9 +258,7 @@ declare namespace VBIDE {
|
||||
readonly VBE: VBE;
|
||||
}
|
||||
|
||||
class References {
|
||||
private 'VBIDE.References_typekey': References;
|
||||
private constructor();
|
||||
interface References {
|
||||
AddFromFile(FileName: string): Reference;
|
||||
AddFromGuid(Guid: string, Major: number, Minor: number): Reference;
|
||||
readonly Count: number;
|
||||
@@ -273,6 +266,7 @@ declare namespace VBIDE {
|
||||
readonly Parent: VBProject;
|
||||
Remove(Reference: Reference): void;
|
||||
readonly VBE: VBE;
|
||||
(index: any): Reference;
|
||||
}
|
||||
|
||||
class ReferencesEvents {
|
||||
@@ -298,13 +292,11 @@ declare namespace VBIDE {
|
||||
readonly VBE: VBE;
|
||||
}
|
||||
|
||||
class VBComponents {
|
||||
private 'VBIDE.VBComponents_typekey': VBComponents;
|
||||
private constructor();
|
||||
interface VBComponents {
|
||||
Add(ComponentType: vbext_ComponentType): VBComponent;
|
||||
AddCustom(ProgId: string): VBComponent;
|
||||
|
||||
/** @param number [index=0] */
|
||||
/** @param index [index=0] */
|
||||
AddMTDesigner(index?: number): VBComponent;
|
||||
readonly Count: number;
|
||||
Import(FileName: string): VBComponent;
|
||||
@@ -312,6 +304,7 @@ declare namespace VBIDE {
|
||||
readonly Parent: VBProject;
|
||||
Remove(VBComponent: VBComponent): void;
|
||||
readonly VBE: VBE;
|
||||
(index: any): VBComponent;
|
||||
}
|
||||
|
||||
class VBE {
|
||||
@@ -354,9 +347,7 @@ declare namespace VBIDE {
|
||||
readonly VBE: VBE;
|
||||
}
|
||||
|
||||
class VBProjects {
|
||||
private 'VBIDE.VBProjects_typekey': VBProjects;
|
||||
private constructor();
|
||||
interface VBProjects {
|
||||
Add(Type: vbext_ProjectType): VBProject;
|
||||
readonly Count: number;
|
||||
Item(index: any): VBProject;
|
||||
@@ -364,6 +355,7 @@ declare namespace VBIDE {
|
||||
readonly Parent: VBE;
|
||||
Remove(lpc: VBProject): void;
|
||||
readonly VBE: VBE;
|
||||
(index: any): VBProject;
|
||||
}
|
||||
|
||||
class Window {
|
||||
@@ -386,38 +378,18 @@ declare namespace VBIDE {
|
||||
WindowState: vbext_WindowState;
|
||||
}
|
||||
|
||||
class Windows {
|
||||
private 'VBIDE.Windows_typekey': Windows;
|
||||
private constructor();
|
||||
interface Windows {
|
||||
readonly Count: number;
|
||||
CreateToolWindow(AddInInst: AddIn, ProgId: string, Caption: string, GuidPosition: string, DocObj: any): Window;
|
||||
Item(index: any): Window;
|
||||
readonly Parent: Application;
|
||||
readonly VBE: VBE;
|
||||
(index: any): Window;
|
||||
}
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
on(
|
||||
obj: VBIDE.CommandBarEvents, event: 'Click', argNames: ['CommandBarControl', 'handled', 'CancelDefault'], handler: (
|
||||
this: VBIDE.CommandBarEvents, parameter: {readonly CommandBarControl: any, readonly handled: boolean, readonly CancelDefault: boolean}) => void): void;
|
||||
on(obj: VBIDE.CommandBarEvents, event: 'Click', argNames: ['CommandBarControl', 'handled', 'CancelDefault'], handler: (this: VBIDE.CommandBarEvents, parameter: {readonly CommandBarControl: any, readonly handled: boolean, readonly CancelDefault: boolean}) => void): void;
|
||||
on(obj: VBIDE.References, event: 'ItemAdded' | 'ItemRemoved', argNames: ['Reference'], handler: (this: VBIDE.References, parameter: {readonly Reference: VBIDE.Reference}) => void): void;
|
||||
on(
|
||||
obj: VBIDE.ReferencesEvents, event: 'ItemAdded' | 'ItemRemoved', argNames: ['Reference'], handler: (
|
||||
this: VBIDE.ReferencesEvents, parameter: {readonly Reference: VBIDE.Reference}) => void): void;
|
||||
}
|
||||
|
||||
interface EnumeratorConstructor {
|
||||
new(col: VBIDE.Addins): Enumerator<VBIDE.AddIn>;
|
||||
new(col: VBIDE.CodePanes): Enumerator<VBIDE.CodePane>;
|
||||
new(col: VBIDE.Components): Enumerator<VBIDE.Component>;
|
||||
new(col: VBIDE.LinkedWindows | VBIDE.Windows): Enumerator<VBIDE.Window>;
|
||||
new(col: VBIDE.Properties): Enumerator<VBIDE.Property>;
|
||||
new(col: VBIDE.References): Enumerator<VBIDE.Reference>;
|
||||
new(col: VBIDE.VBComponents): Enumerator<VBIDE.VBComponent>;
|
||||
new(col: VBIDE.VBProjects): Enumerator<VBIDE.VBProject>;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
on(obj: VBIDE.ReferencesEvents, event: 'ItemAdded' | 'ItemRemoved', argNames: ['Reference'], handler: (this: VBIDE.ReferencesEvents, parameter: {readonly Reference: VBIDE.Reference}) => void): void;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
// Note -- running these tests under cscript requires some ES5 polyfills
|
||||
|
||||
const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
@@ -11,6 +13,9 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
return results;
|
||||
};
|
||||
|
||||
WScript.Echo('Hello, world');
|
||||
WScript.Quit();
|
||||
|
||||
// source -- https://msdn.microsoft.com/en-us/library/windows/desktop/ms630826(v=vs.85).aspx
|
||||
{
|
||||
const cd = new ActiveXObject('WIA.CommonDialog');
|
||||
@@ -51,7 +56,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Properties).forEach(p => {
|
||||
for (const p of collectionToArray(dev.Properties)) {
|
||||
let s = `${p.Name} (${p.PropertyID}) = `;
|
||||
if (p.IsVector) {
|
||||
s += '[vector of data]';
|
||||
@@ -84,7 +89,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
}
|
||||
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,7 +117,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
{
|
||||
const img = cd.ShowAcquireImage();
|
||||
if (img) {
|
||||
collectionToArray(img.Properties).forEach(p => {
|
||||
for (const p of collectionToArray(img.Properties)) {
|
||||
let contents = '';
|
||||
if (p.IsVector) {
|
||||
contents = '[vector data not emitted]';
|
||||
@@ -124,7 +129,7 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
contents = p.Value;
|
||||
}
|
||||
WScript.Echo(`${p.Name} (${p.PropertyID}) = ${contents}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -133,12 +138,12 @@ const collectionToArray = <T>(col: { Item(key: any): T }): T[] => {
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
const actionEvent = WIA.WiaEventFlag.ActionEvent;
|
||||
collectionToArray(dev.Events).forEach(e => {
|
||||
for (const e of collectionToArray(dev.Events)) {
|
||||
const msg = (e.Type & actionEvent) === actionEvent ?
|
||||
`${e.Name} is an Action event` :
|
||||
`${e.Name} is not an Action event`;
|
||||
WScript.Echo(msg);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -208,14 +213,14 @@ Frame count = ${img.FrameCount}}
|
||||
// Create an imageprocess object and enumerate filters
|
||||
{
|
||||
const ip = new ActiveXObject('WIA.ImageProcess');
|
||||
collectionToArray(ip.FilterInfos).forEach(fi => {
|
||||
for (const fi of collectionToArray(ip.FilterInfos)) {
|
||||
const s = [
|
||||
fi.Name,
|
||||
new Array(51).join('='),
|
||||
fi.Description
|
||||
].join('\n');
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Create an imageprocess object and create one of each available filter
|
||||
@@ -269,11 +274,11 @@ Frame count = ${img.FrameCount}}
|
||||
WScript.Echo(s);
|
||||
};
|
||||
|
||||
collectionToArray(ip.FilterInfos).forEach(fi => {
|
||||
for (const fi of collectionToArray(ip.FilterInfos)) {
|
||||
ip.Filters.Add(fi.FilterID);
|
||||
listProperties(ip.Filters(1));
|
||||
ip.Filters.Remove(1);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// List the supported transfer formats
|
||||
@@ -308,14 +313,14 @@ Frame count = ${img.FrameCount}}
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Items).forEach(item => {
|
||||
for (const item of collectionToArray(dev.Items)) {
|
||||
let s: string = item.Properties("Item Name").Value;
|
||||
if (item.Properties.Exists("Item Time Stamp")) {
|
||||
const v: WIA.Vector = item.Properties("Item Time Stamp").Value;
|
||||
if (v.Count === 8) { s += ` (${v.Date})`; }
|
||||
}
|
||||
WScript.Echo(s);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,16 +345,16 @@ Frame count = ${img.FrameCount}}
|
||||
}
|
||||
|
||||
// List all available devices by name and deviceid
|
||||
collectionToArray(dm.DeviceInfos).forEach(di => {
|
||||
for (const di of collectionToArray(dm.DeviceInfos)) {
|
||||
const name: string = di.Properties("Name").Value;
|
||||
WScript.Echo(`${name} (${di.DeviceID})`);
|
||||
});
|
||||
}
|
||||
|
||||
// Display all the properties for the selected device
|
||||
{
|
||||
const dev = cd.ShowSelectDevice();
|
||||
if (dev) {
|
||||
collectionToArray(dev.Properties).forEach(p => {
|
||||
for (const p of collectionToArray(dev.Properties)) {
|
||||
const name = `${p.Name} (${p.PropertyID})`;
|
||||
let contents: string;
|
||||
if (p.IsVector) {
|
||||
@@ -360,7 +365,7 @@ Frame count = ${img.FrameCount}}
|
||||
contents = p.Value;
|
||||
}
|
||||
WScript.Echo(`${name} = ${contents}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,7 +435,7 @@ Frame count = ${img.FrameCount}}
|
||||
if (args[0] === 'connect') {
|
||||
const deviceID = args[1].substr(12);
|
||||
const device = dm.DeviceInfos(deviceID).Connect();
|
||||
collectionToArray(device.Items).forEach(item => {
|
||||
for (const item of collectionToArray(device.Items)) {
|
||||
const img = item.Transfer();
|
||||
img.SaveFile(`C:\\${item.Properties('Item Name').Value}.${img.FileExtension}`);
|
||||
|
||||
@@ -445,7 +450,7 @@ Frame count = ${img.FrameCount}}
|
||||
WScript.Echo(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
WScript.Quit();
|
||||
}
|
||||
break;
|
||||
|
||||
Vendored
+2
-1
@@ -4,6 +4,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
|
||||
declare namespace WIA {
|
||||
/** String versions of globally unique identifiers (GUIDs) that identify common Device and Item commands. */
|
||||
const enum CommandID {
|
||||
@@ -791,7 +793,6 @@ declare namespace WIA {
|
||||
}
|
||||
|
||||
interface ActiveXObject {
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
on(obj: WIA.DeviceManager, event: 'OnEvent', argNames: ['EventID', 'DeviceID', 'ItemID'], handler: (
|
||||
this: WIA.DeviceManager, parameter: { readonly EventID: string, readonly DeviceID: string, readonly ItemID: string }) => void): void;
|
||||
set<TItem>(obj: WIA.Vector<TItem>, propertyName: 'Item', parameterTypes: [number], newValue: TItem): void;
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
"es5"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
/// <reference types="windows-script-host" />
|
||||
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const collectionToArray = <T>(col: any): T[] => {
|
||||
const collectionToArray = <T>(col: {Item(index: any): T}): T[] => {
|
||||
const results: T[] = [];
|
||||
const enumerator = new Enumerator<T>(col);
|
||||
enumerator.moveFirst();
|
||||
@@ -233,7 +235,7 @@ const activeDoc = app.ActiveDocument;
|
||||
|
||||
// looping through a collection -- https://msdn.microsoft.com/en-us/vba/word-vba/articles/looping-through-a-collection
|
||||
(() => {
|
||||
collectionToArray<Word.Document>(app.Documents)
|
||||
collectionToArray(app.Documents)
|
||||
.forEach(openDocument => WScript.Echo(openDocument.Name));
|
||||
|
||||
const strMarks = collectionToArray<Word.Bookmark>(activeDoc.Bookmarks)
|
||||
|
||||
Vendored
+2
-2
@@ -2,8 +2,9 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/fp179696.aspx
|
||||
// Definitions by: Zev Spitz <https://github.com/zspitz>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.6
|
||||
|
||||
/// <reference types="activex-interop" />
|
||||
/// <reference types="activex-office" />
|
||||
/// <reference types="activex-vbide" />
|
||||
/// <reference types="activex-stdole" />
|
||||
@@ -12496,7 +12497,6 @@ interface ActiveXObject {
|
||||
set(obj: Word.Document, propertyName: 'ActiveWritingStyle', parameterTypes: [any], newValue: string): void;
|
||||
set(obj: Word.Document, propertyName: 'Compatibility', parameterTypes: [Word.WdCompatibility], newValue: boolean): void;
|
||||
set(obj: Word.System, propertyName: 'PrivateProfileString', parameterTypes: [string, string, string], newValue: string): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es5",
|
||||
"scripthost"
|
||||
],
|
||||
"lib": ["es5"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user