mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Merge branch 'threejs-updates' of github.com:sethk/DefinitelyTyped into threejs-updates
This commit is contained in:
+259
-121
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`.
|
||||
|
||||
@@ -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.
|
||||
@@ -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.
|
||||
|
||||
|
||||
@@ -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",
|
||||
@@ -654,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",
|
||||
@@ -1146,6 +1158,12 @@
|
||||
"sourceRepoURL": "https://github.com/react-ga/react-ga",
|
||||
"asOfVersion": "2.3.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",
|
||||
@@ -1164,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",
|
||||
@@ -1272,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",
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"name": "definitely-typed",
|
||||
"version": "0.0.1",
|
||||
"version": "0.0.2",
|
||||
"homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
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.
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// Project: https://msdn.microsoft.com/en-us/library/dn142571.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-office" />
|
||||
/// <reference types="activex-dao" />
|
||||
|
||||
@@ -1,57 +1,426 @@
|
||||
let obj0 = new ActiveXObject('ADODB.Command');
|
||||
// Note -- running these tests under cscript requires some ES5 polyfills
|
||||
|
||||
let obj1 = new ActiveXObject('ADODB.Connection');
|
||||
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 obj2 = new ActiveXObject('ADODB.Parameter');
|
||||
|
||||
let obj3 = new ActiveXObject('ADODB.Record');
|
||||
|
||||
let obj4 = new ActiveXObject('ADODB.Recordset');
|
||||
|
||||
let obj5 = new ActiveXObject('ADODB.Stream');
|
||||
|
||||
// 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();
|
||||
|
||||
// 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);
|
||||
|
||||
// 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');
|
||||
conn.Open(); // pass connection details here
|
||||
|
||||
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;
|
||||
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>;
|
||||
};
|
||||
|
||||
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';
|
||||
|
||||
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(';');
|
||||
};
|
||||
|
||||
const printLine = () => WScript.Echo(new Array(26).join('-'));
|
||||
|
||||
{
|
||||
// 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
|
||||
{
|
||||
const conn = new ActiveXObject('ADODB.Connection');
|
||||
conn.Open(); // pass connection details here
|
||||
|
||||
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(0).Value;
|
||||
conn.Close();
|
||||
}
|
||||
|
||||
// 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
+219
-182
@@ -2,7 +2,7 @@
|
||||
// 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
|
||||
|
||||
declare namespace ADODB {
|
||||
const enum ADCPROP_ASYNCTHREADPRIORITY_ENUM {
|
||||
@@ -594,10 +594,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 +614,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 +659,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 +713,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 +726,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 +743,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 +784,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 +814,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 +842,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 +1019,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 +1028,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 +1051,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 +1094,23 @@ 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;
|
||||
set(obj: ADODB.Recordset, propertyName: 'Collect', parameterTypes: [any], newValue: any): void;
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
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;
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
@@ -1073,14 +1121,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>;
|
||||
}
|
||||
|
||||
@@ -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
+335
@@ -0,0 +1,335 @@
|
||||
// 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-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 ActiveXObject {
|
||||
new<K extends keyof ActiveXObjectNameMap = any>(progid: K): ActiveXObjectNameMap[K];
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es5", "scripthost"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.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,48 @@
|
||||
let engine = new ActiveXObject('DAO.DBEngine.120');
|
||||
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 +54,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
+197
-207
@@ -1,8 +1,8 @@
|
||||
// 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
|
||||
|
||||
declare namespace DAO {
|
||||
const enum _DAOSuppHelp {
|
||||
@@ -56,12 +56,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 +131,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 +320,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 +349,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 +369,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 +384,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 +402,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 +421,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 +476,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 +486,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 +503,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 +546,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 +591,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 +611,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 +644,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 +724,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 +770,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 +825,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 +840,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 +860,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,14 +873,13 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -875,36 +889,12 @@ interface ActiveXObject {
|
||||
|
||||
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>;
|
||||
}
|
||||
|
||||
@@ -279,7 +279,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,7 +293,7 @@ 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());
|
||||
enumerator.moveFirst();
|
||||
|
||||
Vendored
+1
-1
@@ -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" />
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
// copied from the definitions in activex-scripting
|
||||
interface Dictionary<TKey = any, TItem = any> {
|
||||
/** Add a new key and item to the dictionary. */
|
||||
Add(Key: TKey, Item: TItem): void;
|
||||
|
||||
/** Get the number of items in the dictionary. */
|
||||
readonly Count: number;
|
||||
|
||||
/** Determine if a given key is in the dictionary. */
|
||||
Exists(Key: TKey): boolean;
|
||||
HashVal(Key: TKey): any;
|
||||
|
||||
/** Set or get the item for a given key */
|
||||
Item(Key: TKey): TItem;
|
||||
|
||||
/** Get an array containing all items in the dictionary. */
|
||||
Items(): SafeArray<TItem>;
|
||||
|
||||
/** Change a key to a different key. */
|
||||
Key(Key: TKey): TKey;
|
||||
|
||||
/** Get an array containing all keys in the dictionary. */
|
||||
Keys(): SafeArray<TKey>;
|
||||
|
||||
/** Remove a given key from the dictionary. */
|
||||
Remove(Key: TKey): void;
|
||||
|
||||
/** Remove all information from the dictionary. */
|
||||
RemoveAll(): void;
|
||||
|
||||
/** Set or get the item for a given key */
|
||||
(Key: TKey): TItem;
|
||||
}
|
||||
|
||||
interface ActiveXObjectNameMap {
|
||||
'Scripting.Dictionary': Dictionary;
|
||||
}
|
||||
|
||||
const dict: Dictionary<string, number> = new ActiveXObject('Scripting.Dictionary');
|
||||
dict.Add('one', 1);
|
||||
dict.Add('two', 2);
|
||||
dict.Add('three', 3);
|
||||
|
||||
const keyEnumerator = new Enumerator(dict.Keys());
|
||||
keyEnumerator.moveFirst();
|
||||
while (!keyEnumerator.atEnd()) {
|
||||
const item = dict(keyEnumerator.item());
|
||||
const power = Math.pow(item, 2);
|
||||
}
|
||||
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.3
|
||||
|
||||
// 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: SafeArray<T> | { 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"
|
||||
]
|
||||
}
|
||||
Vendored
+119
-2304
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+833
-1753
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,18 @@
|
||||
// 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 +37,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 +60,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 +73,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 +148,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 +172,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 +212,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 +235,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 +253,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 +265,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 +326,4 @@ ${oError.reason}`;
|
||||
}
|
||||
WScript.Echo(msg);
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
Vendored
+35
-39
@@ -424,7 +424,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 +433,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 +497,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 +795,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 +804,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 +847,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 +1959,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 +1987,9 @@ declare namespace MSXML2 {
|
||||
|
||||
/** set item by name */
|
||||
setNamedItem(newItem: IXMLDOMNode): IXMLDOMNode;
|
||||
|
||||
/** collection of nodes */
|
||||
(index: number): IXMLDOMNode;
|
||||
}
|
||||
|
||||
/** Core DOM node interface */
|
||||
@@ -2090,10 +2090,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 +2103,9 @@ declare namespace MSXML2 {
|
||||
|
||||
/** reset the position of iterator */
|
||||
reset(): void;
|
||||
|
||||
/** collection of nodes */
|
||||
(index: number): IXMLDOMNode;
|
||||
}
|
||||
|
||||
/** structure for reporting parser errors */
|
||||
@@ -2238,10 +2239,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 +2258,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 +2405,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 +2426,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 +2489,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 +2732,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 +2754,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 */
|
||||
@@ -2787,12 +2789,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>;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
/// <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
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// 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-stdole" />
|
||||
/// <reference types="activex-office" />
|
||||
|
||||
Vendored
+1
-1
@@ -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" />
|
||||
|
||||
Vendored
+1
-5
@@ -2,7 +2,7 @@
|
||||
// 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
|
||||
|
||||
declare namespace stdole {
|
||||
type IPictureDisp = StdPicture;
|
||||
@@ -86,7 +86,3 @@ interface ActiveXObjectNameMap {
|
||||
StdFont: stdole.StdFont;
|
||||
StdPicture: stdole.StdPicture;
|
||||
}
|
||||
|
||||
interface SafeArray<T = any> {
|
||||
_brand: SafeArray<T>;
|
||||
}
|
||||
|
||||
@@ -1,21 +1,25 @@
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
const collectionToArray = <T>(col: any): T[] => {
|
||||
/// <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;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-const-enum": false
|
||||
"no-const-enum": false,
|
||||
"max-line-length": false
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
// 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-office" />
|
||||
/// <reference types="activex-vbide" />
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import AuthenticationContext, {
|
||||
AuthenticationContextOptions,
|
||||
TokenCallback,
|
||||
UserCallback
|
||||
} from "adal-angular";
|
||||
import AuthenticationContext = require("adal-angular");
|
||||
|
||||
const onLogin: TokenCallback = (errorDescription, idToken, error) => {
|
||||
const onLogin: AuthenticationContext.TokenCallback = (errorDescription, idToken, error) => {
|
||||
if (error) {
|
||||
console.error(errorDescription, error);
|
||||
return;
|
||||
@@ -14,7 +10,7 @@ const onLogin: TokenCallback = (errorDescription, idToken, error) => {
|
||||
}
|
||||
};
|
||||
|
||||
const onToken: TokenCallback = (errorDesc, token, error) => {
|
||||
const onToken: AuthenticationContext.TokenCallback = (errorDesc, token, error) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
return;
|
||||
@@ -22,7 +18,7 @@ const onToken: TokenCallback = (errorDesc, token, error) => {
|
||||
console.log('Making request with token:', token);
|
||||
};
|
||||
|
||||
const onUser: UserCallback = (error, user) => {
|
||||
const onUser: AuthenticationContext.UserCallback = (error, user) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
return;
|
||||
@@ -57,7 +53,7 @@ const acquireAnAccessToken = () => {
|
||||
);
|
||||
};
|
||||
|
||||
const config: AuthenticationContextOptions = {
|
||||
const config: AuthenticationContext.Options = {
|
||||
clientId: "7cee0f68-5051-41f6-9e45-80463d21d65d",
|
||||
redirectUri: "http://localhost:16969/",
|
||||
instance: "https://login.microsoftonline.com/",
|
||||
@@ -70,6 +66,7 @@ const config: AuthenticationContextOptions = {
|
||||
};
|
||||
|
||||
const authenticationContext = new AuthenticationContext(config);
|
||||
window.Logging.level = authenticationContext.CONSTANTS.LOGGING_LEVEL.ERROR;
|
||||
|
||||
if (authenticationContext.isCallback(window.location.hash)) {
|
||||
authenticationContext.handleWindowCallback();
|
||||
@@ -79,6 +76,11 @@ if (authenticationContext.isCallback(window.location.hash)) {
|
||||
acquireAnAccessToken();
|
||||
}
|
||||
|
||||
const injectedContext = AuthenticationContext.inject({
|
||||
clientId: "7cee0f68-5051-41f6-9e45-80463d21d65d",
|
||||
});
|
||||
injectedContext.handleWindowCallback();
|
||||
|
||||
setTimeout(() => {
|
||||
authenticationContext.logOut();
|
||||
}, 60000);
|
||||
|
||||
Vendored
+242
-139
@@ -1,142 +1,28 @@
|
||||
// Type definitions for adal-angular 1.0
|
||||
// Project: https://github.com/AzureAD/azure-activedirectory-library-for-js#readme
|
||||
// Definitions by: Daniel Perez Alvarez <https://github.com/unindented>
|
||||
// Anthony Ciccarello <https://github.com/aciccarello>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export enum LoggingLevel {
|
||||
ERROR = 0,
|
||||
WARNING = 1,
|
||||
INFO = 2,
|
||||
VERBOSE = 3
|
||||
}
|
||||
// In module contexts the class constructor function is the exported object
|
||||
export = AuthenticationContext;
|
||||
|
||||
export type RequestType = "LOGIN" | "RENEW_TOKEN" | "UNKNOWN";
|
||||
// This class is defined globally in not in a module context
|
||||
declare class AuthenticationContext {
|
||||
instance: string;
|
||||
config: AuthenticationContext.Options;
|
||||
callback: AuthenticationContext.TokenCallback;
|
||||
popUp: boolean;
|
||||
isAngular: boolean;
|
||||
|
||||
export type ResponseType = "id_token token" | "token";
|
||||
/**
|
||||
* Enum for request type
|
||||
*/
|
||||
REQUEST_TYPE: AuthenticationContext.RequestType;
|
||||
RESPONSE_TYPE: AuthenticationContext.ResponseType;
|
||||
CONSTANTS: AuthenticationContext.Constants;
|
||||
|
||||
export interface RequestInfo {
|
||||
/**
|
||||
* Object comprising of fields such as id_token/error, session_state, state, e.t.c.
|
||||
*/
|
||||
parameters: any;
|
||||
/**
|
||||
* Request type.
|
||||
*/
|
||||
requestType: RequestType;
|
||||
/**
|
||||
* Whether state is valid.
|
||||
*/
|
||||
stateMatch: boolean;
|
||||
/**
|
||||
* Unique guid used to match the response with the request.
|
||||
*/
|
||||
stateResponse: string;
|
||||
/**
|
||||
* Whether `requestType` contains `id_token`, `access_token` or error.
|
||||
*/
|
||||
valid: boolean;
|
||||
}
|
||||
|
||||
export interface UserInfo {
|
||||
/**
|
||||
* Username assigned from UPN or email.
|
||||
*/
|
||||
userName: string;
|
||||
/**
|
||||
* Properties parsed from `id_token`.
|
||||
*/
|
||||
profile: any;
|
||||
}
|
||||
|
||||
export type TokenCallback = (
|
||||
errorDesc: string | null,
|
||||
token: string,
|
||||
error: any
|
||||
) => void;
|
||||
|
||||
export type UserCallback = (errorDesc: string | null, user: UserInfo) => void;
|
||||
|
||||
export interface AuthenticationContextOptions {
|
||||
/**
|
||||
* Client ID assigned to your app by Azure Active Directory.
|
||||
*/
|
||||
clientId: string;
|
||||
/**
|
||||
* Endpoint at which you expect to receive tokens.Defaults to `window.location.href`.
|
||||
*/
|
||||
redirectUri: string;
|
||||
/**
|
||||
* Azure Active Directory instance. Defaults to `https://login.microsoftonline.com/`.
|
||||
*/
|
||||
instance?: string;
|
||||
/**
|
||||
* Your target tenant. Defaults to `common`.
|
||||
*/
|
||||
tenant?: string;
|
||||
/**
|
||||
* Query parameters to add to the authentication request.
|
||||
*/
|
||||
extraQueryParameter?: string;
|
||||
/**
|
||||
* Unique identifier used to map the request with the response. Defaults to RFC4122 version 4 guid (128 bits).
|
||||
*/
|
||||
correlationId?: string;
|
||||
/**
|
||||
* User defined function of handling the navigation to Azure AD authorization endpoint in case of login.
|
||||
*/
|
||||
displayCall?: (url: string) => void;
|
||||
/**
|
||||
* Set this to true to enable login in a popup winodow instead of a full redirect. Defaults to `false`.
|
||||
*/
|
||||
popUp?: boolean;
|
||||
/**
|
||||
* Set this to the resource to request on login. Defaults to `clientId`.
|
||||
*/
|
||||
loginResource?: string;
|
||||
/**
|
||||
* Set this to redirect the user to a custom login page.
|
||||
*/
|
||||
localLoginUrl?: string;
|
||||
/**
|
||||
* Redirects to start page after login. Defaults to `true`.
|
||||
*/
|
||||
navigateToLoginRequestUrl?: boolean;
|
||||
/**
|
||||
* Set this to redirect the user to a custom logout page.
|
||||
*/
|
||||
logOutUri?: string;
|
||||
/**
|
||||
* Redirects the user to postLogoutRedirectUri after logout. Defaults to `redirectUri`.
|
||||
*/
|
||||
postLogoutRedirectUri?: string;
|
||||
/**
|
||||
* Sets browser storage to either 'localStorage' or sessionStorage'. Defaults to `sessionStorage`.
|
||||
*/
|
||||
cacheLocation?: "localStorage" | "sessionStorage";
|
||||
/**
|
||||
* Array of keywords or URIs. Adal will attach a token to outgoing requests that have these keywords or URIs.
|
||||
*/
|
||||
endpoints?: { [resource: string]: string };
|
||||
/**
|
||||
* Array of keywords or URIs. Adal will not attach a token to outgoing requests that have these keywords or URIs.
|
||||
*/
|
||||
anonymousEndpoints?: string[];
|
||||
/**
|
||||
* If the cached token is about to be expired in the expireOffsetSeconds (in seconds), Adal will renew the token instead of using the cached token. Defaults to 300 seconds.
|
||||
*/
|
||||
expireOffsetSeconds?: number;
|
||||
/**
|
||||
* The number of milliseconds of inactivity before a token renewal response from AAD should be considered timed out. Defaults to 6 seconds.
|
||||
*/
|
||||
loadFrameTimeout?: number;
|
||||
/**
|
||||
* Callback to be invoked when a token is acquired.
|
||||
*/
|
||||
callback?: TokenCallback;
|
||||
}
|
||||
|
||||
export default class AuthenticationContext {
|
||||
constructor(options: AuthenticationContextOptions);
|
||||
constructor(options: AuthenticationContext.Options);
|
||||
/**
|
||||
* Initiates the login process by redirecting the user to Azure AD authorization endpoint.
|
||||
*/
|
||||
@@ -153,7 +39,7 @@ export default class AuthenticationContext {
|
||||
/**
|
||||
* If user object exists, returns it. Else creates a new user object by decoding `id_token` from the cache.
|
||||
*/
|
||||
getCachedUser(): UserInfo;
|
||||
getCachedUser(): AuthenticationContext.UserInfo;
|
||||
/**
|
||||
* Adds the passed callback to the array of callbacks for the specified resource.
|
||||
* @param resource A URI that identifies the resource for which the token is requested.
|
||||
@@ -163,14 +49,14 @@ export default class AuthenticationContext {
|
||||
registerCallback(
|
||||
expectedState: string,
|
||||
resource: string,
|
||||
callback: TokenCallback
|
||||
callback: AuthenticationContext.TokenCallback
|
||||
): void;
|
||||
/**
|
||||
* Acquires token from the cache if it is not expired. Otherwise sends request to AAD to obtain a new token.
|
||||
* @param resource Resource URI identifying the target resource.
|
||||
* @param callback The callback provided by the caller. It will be called with token or error.
|
||||
*/
|
||||
acquireToken(resource: string, callback: TokenCallback): void;
|
||||
acquireToken(resource: string, callback: AuthenticationContext.TokenCallback): void;
|
||||
/**
|
||||
* Acquires token (interactive flow using a popup window) by sending request to AAD to obtain a new token.
|
||||
* @param resource Resource URI identifying the target resource.
|
||||
@@ -182,7 +68,7 @@ export default class AuthenticationContext {
|
||||
resource: string,
|
||||
extraQueryParameters: string | null | undefined,
|
||||
claims: string | null | undefined,
|
||||
callback: TokenCallback
|
||||
callback: AuthenticationContext.TokenCallback
|
||||
): void;
|
||||
/**
|
||||
* Acquires token (interactive flow using a redirect) by sending request to AAD to obtain a new token. In this case the callback passed in the authentication request constructor will be called.
|
||||
@@ -217,7 +103,7 @@ export default class AuthenticationContext {
|
||||
* Calls the passed in callback with the user object or error message related to the user.
|
||||
* @param callback The callback provided by the caller. It will be called with user or error.
|
||||
*/
|
||||
getUser(callback: UserCallback): void;
|
||||
getUser(callback: AuthenticationContext.UserCallback): void;
|
||||
/**
|
||||
* Checks if the URL fragment contains access token, id token or error description.
|
||||
* @param hash Hash passed from redirect page.
|
||||
@@ -230,11 +116,11 @@ export default class AuthenticationContext {
|
||||
/**
|
||||
* Creates a request info object from the URL fragment and returns it.
|
||||
*/
|
||||
getRequestInfo(hash: string): RequestInfo;
|
||||
getRequestInfo(hash: string): AuthenticationContext.RequestInfo;
|
||||
/**
|
||||
* Saves token or error received in the response from AAD in the cache. In case of `id_token`, it also creates the user object.
|
||||
*/
|
||||
saveTokenFromHash(requestInfo: RequestInfo): void;
|
||||
saveTokenFromHash(requestInfo: AuthenticationContext.RequestInfo): void;
|
||||
/**
|
||||
* Gets resource for given endpoint if mapping is provided with config.
|
||||
* @param endpoint Resource URI identifying the target resource.
|
||||
@@ -252,7 +138,7 @@ export default class AuthenticationContext {
|
||||
* @param message Message to log.
|
||||
* @param error Error to log.
|
||||
*/
|
||||
log(level: LoggingLevel, message: string, error: any): void;
|
||||
log(level: AuthenticationContext.LoggingLevel, message: string, error: any): void;
|
||||
/**
|
||||
* Logs messages when logging level is set to 0.
|
||||
* @param message Message to log.
|
||||
@@ -274,4 +160,221 @@ export default class AuthenticationContext {
|
||||
* @param message Message to log.
|
||||
*/
|
||||
verbose(message: string): void;
|
||||
|
||||
/**
|
||||
* Logs Pii messages when Logging Level is set to 0 and window.piiLoggingEnabled is set to true.
|
||||
* @param message Message to log.
|
||||
* @param error Error to log.
|
||||
*/
|
||||
errorPii(message: string, error: any): void;
|
||||
|
||||
/**
|
||||
* Logs Pii messages when Logging Level is set to 1 and window.piiLoggingEnabled is set to true.
|
||||
* @param message Message to log.
|
||||
*/
|
||||
warnPii(message: string): void;
|
||||
|
||||
/**
|
||||
* Logs messages when Logging Level is set to 2 and window.piiLoggingEnabled is set to true.
|
||||
* @param message Message to log.
|
||||
*/
|
||||
infoPii(message: string): void;
|
||||
|
||||
/**
|
||||
* Logs messages when Logging Level is set to 3 and window.piiLoggingEnabled is set to true.
|
||||
* @param message Message to log.
|
||||
*/
|
||||
verbosePii(message: string): void;
|
||||
}
|
||||
|
||||
declare namespace AuthenticationContext {
|
||||
function inject(config: Options): AuthenticationContext;
|
||||
|
||||
type LoggingLevel = 0 | 1 | 2 | 3;
|
||||
|
||||
type RequestType = "LOGIN" | "RENEW_TOKEN" | "UNKNOWN";
|
||||
|
||||
type ResponseType = "id_token token" | "token";
|
||||
|
||||
interface RequestInfo {
|
||||
/**
|
||||
* Object comprising of fields such as id_token/error, session_state, state, e.t.c.
|
||||
*/
|
||||
parameters: any;
|
||||
/**
|
||||
* Request type.
|
||||
*/
|
||||
requestType: RequestType;
|
||||
/**
|
||||
* Whether state is valid.
|
||||
*/
|
||||
stateMatch: boolean;
|
||||
/**
|
||||
* Unique guid used to match the response with the request.
|
||||
*/
|
||||
stateResponse: string;
|
||||
/**
|
||||
* Whether `requestType` contains `id_token`, `access_token` or error.
|
||||
*/
|
||||
valid: boolean;
|
||||
}
|
||||
|
||||
interface UserInfo {
|
||||
/**
|
||||
* Username assigned from UPN or email.
|
||||
*/
|
||||
userName: string;
|
||||
/**
|
||||
* Properties parsed from `id_token`.
|
||||
*/
|
||||
profile: any;
|
||||
}
|
||||
|
||||
type TokenCallback = (
|
||||
errorDesc: string | null,
|
||||
token: string | null,
|
||||
error: any
|
||||
) => void;
|
||||
|
||||
type UserCallback = (errorDesc: string | null, user: UserInfo | null) => void;
|
||||
|
||||
/**
|
||||
* Configuration options for Authentication Context
|
||||
*/
|
||||
interface Options {
|
||||
/**
|
||||
* Client ID assigned to your app by Azure Active Directory.
|
||||
*/
|
||||
clientId: string;
|
||||
/**
|
||||
* Endpoint at which you expect to receive tokens.Defaults to `window.location.href`.
|
||||
*/
|
||||
redirectUri?: string;
|
||||
/**
|
||||
* Azure Active Directory instance. Defaults to `https://login.microsoftonline.com/`.
|
||||
*/
|
||||
instance?: string;
|
||||
/**
|
||||
* Your target tenant. Defaults to `common`.
|
||||
*/
|
||||
tenant?: string;
|
||||
/**
|
||||
* Query parameters to add to the authentication request.
|
||||
*/
|
||||
extraQueryParameter?: string;
|
||||
/**
|
||||
* Unique identifier used to map the request with the response. Defaults to RFC4122 version 4 guid (128 bits).
|
||||
*/
|
||||
correlationId?: string;
|
||||
/**
|
||||
* User defined function of handling the navigation to Azure AD authorization endpoint in case of login.
|
||||
*/
|
||||
displayCall?: (url: string) => void;
|
||||
/**
|
||||
* Set this to true to enable login in a popup winodow instead of a full redirect. Defaults to `false`.
|
||||
*/
|
||||
popUp?: boolean;
|
||||
/**
|
||||
* Set this to the resource to request on login. Defaults to `clientId`.
|
||||
*/
|
||||
loginResource?: string;
|
||||
/**
|
||||
* Set this to redirect the user to a custom login page.
|
||||
*/
|
||||
localLoginUrl?: string;
|
||||
/**
|
||||
* Redirects to start page after login. Defaults to `true`.
|
||||
*/
|
||||
navigateToLoginRequestUrl?: boolean;
|
||||
/**
|
||||
* Set this to redirect the user to a custom logout page.
|
||||
*/
|
||||
logOutUri?: string;
|
||||
/**
|
||||
* Redirects the user to postLogoutRedirectUri after logout. Defaults to `redirectUri`.
|
||||
*/
|
||||
postLogoutRedirectUri?: string;
|
||||
/**
|
||||
* Sets browser storage to either 'localStorage' or sessionStorage'. Defaults to `sessionStorage`.
|
||||
*/
|
||||
cacheLocation?: "localStorage" | "sessionStorage";
|
||||
/**
|
||||
* Array of keywords or URIs. Adal will attach a token to outgoing requests that have these keywords or URIs.
|
||||
*/
|
||||
endpoints?: { [resource: string]: string };
|
||||
/**
|
||||
* Array of keywords or URIs. Adal will not attach a token to outgoing requests that have these keywords or URIs.
|
||||
*/
|
||||
anonymousEndpoints?: string[];
|
||||
/**
|
||||
* If the cached token is about to be expired in the expireOffsetSeconds (in seconds), Adal will renew the token instead of using the cached token. Defaults to 300 seconds.
|
||||
*/
|
||||
expireOffsetSeconds?: number;
|
||||
/**
|
||||
* The number of milliseconds of inactivity before a token renewal response from AAD should be considered timed out. Defaults to 6 seconds.
|
||||
*/
|
||||
loadFrameTimeout?: number;
|
||||
/**
|
||||
* Callback to be invoked when a token is acquired.
|
||||
*/
|
||||
callback?: TokenCallback;
|
||||
}
|
||||
|
||||
interface LoggingConfig {
|
||||
level: LoggingLevel;
|
||||
log: (message: string) => void;
|
||||
piiLoggingEnabled: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enum for storage constants
|
||||
*/
|
||||
interface Constants {
|
||||
ACCESS_TOKEN: 'access_token';
|
||||
EXPIRES_IN: 'expires_in';
|
||||
ID_TOKEN: 'id_token';
|
||||
ERROR_DESCRIPTION: 'error_description';
|
||||
SESSION_STATE: 'session_state';
|
||||
STORAGE: {
|
||||
TOKEN_KEYS: 'adal.token.keys';
|
||||
ACCESS_TOKEN_KEY: 'adal.access.token.key';
|
||||
EXPIRATION_KEY: 'adal.expiration.key';
|
||||
STATE_LOGIN: 'adal.state.login';
|
||||
STATE_RENEW: 'adal.state.renew';
|
||||
NONCE_IDTOKEN: 'adal.nonce.idtoken';
|
||||
SESSION_STATE: 'adal.session.state';
|
||||
USERNAME: 'adal.username';
|
||||
IDTOKEN: 'adal.idtoken';
|
||||
ERROR: 'adal.error';
|
||||
ERROR_DESCRIPTION: 'adal.error.description';
|
||||
LOGIN_REQUEST: 'adal.login.request';
|
||||
LOGIN_ERROR: 'adal.login.error';
|
||||
RENEW_STATUS: 'adal.token.renew.status';
|
||||
};
|
||||
RESOURCE_DELIMETER: '|';
|
||||
LOADFRAME_TIMEOUT: '6000';
|
||||
TOKEN_RENEW_STATUS_CANCELED: 'Canceled';
|
||||
TOKEN_RENEW_STATUS_COMPLETED: 'Completed';
|
||||
TOKEN_RENEW_STATUS_IN_PROGRESS: 'In Progress';
|
||||
LOGGING_LEVEL: {
|
||||
ERROR: 0;
|
||||
WARN: 1;
|
||||
INFO: 2;
|
||||
VERBOSE: 3;
|
||||
};
|
||||
LEVEL_STRING_MAP: {
|
||||
0: 'ERROR:';
|
||||
1: 'WARNING:';
|
||||
2: 'INFO:';
|
||||
3: 'VERBOSE:';
|
||||
};
|
||||
POPUP_WIDTH: 483;
|
||||
POPUP_HEIGHT: 600;
|
||||
}
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
Logging: AuthenticationContext.LoggingConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,11 @@
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"adal-angular-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
@@ -1,6 +1,7 @@
|
||||
/// <reference types="node" />
|
||||
/// <reference types="lodash" />
|
||||
/// <reference types="benchmark" />
|
||||
/// <reference types="async" />
|
||||
|
||||
declare namespace adone {
|
||||
const _null: symbol;
|
||||
@@ -110,4 +111,6 @@ declare namespace adone {
|
||||
export const lodash: _.LoDashStatic;
|
||||
|
||||
export const benchmark: typeof tbenchmark;
|
||||
|
||||
export const async: typeof tasync;
|
||||
}
|
||||
|
||||
Vendored
+3
@@ -0,0 +1,3 @@
|
||||
export * from "async";
|
||||
|
||||
export as namespace tasync;
|
||||
@@ -1,5 +1,5 @@
|
||||
declare namespace adone {
|
||||
namespace application {
|
||||
namespace app {
|
||||
namespace I {
|
||||
type ArgumentType = ((x: string, index: number) => any) | RegExp;
|
||||
|
||||
@@ -12,7 +12,7 @@ declare namespace adone {
|
||||
| "append"
|
||||
| "count"
|
||||
| "set";
|
||||
nargs?: number | "+" | "*" | "?"
|
||||
nargs?: number | "+" | "*" | "?";
|
||||
type?: ArgumentType | ArgumentType[];
|
||||
verify?: (args: any, opts: any) => boolean; // TODO
|
||||
required?: boolean;
|
||||
@@ -49,7 +49,7 @@ declare namespace adone {
|
||||
name?: string;
|
||||
description?: string;
|
||||
subsystems?: SubsystemInfo[];
|
||||
commandsGroups?: Group[]
|
||||
commandsGroups?: Group[];
|
||||
}
|
||||
|
||||
interface SubsystemInfo {
|
||||
@@ -71,24 +71,24 @@ declare namespace adone {
|
||||
|
||||
namespace I {
|
||||
interface LoadSubsystemOptions {
|
||||
name?: string,
|
||||
description?: string,
|
||||
group?: string,
|
||||
transpile?: boolean
|
||||
name?: string;
|
||||
description?: string;
|
||||
group?: string;
|
||||
transpile?: boolean;
|
||||
}
|
||||
|
||||
interface CommonAddSubsystemInfo {
|
||||
name?: string,
|
||||
useFilename?: boolean
|
||||
description?: string,
|
||||
group?: string,
|
||||
configureArgs?: any[]
|
||||
transpile?: boolean,
|
||||
bind?: boolean | string
|
||||
name?: string;
|
||||
useFilename?: boolean;
|
||||
description?: string;
|
||||
group?: string;
|
||||
configureArgs?: any[];
|
||||
transpile?: boolean;
|
||||
bind?: boolean | string;
|
||||
}
|
||||
|
||||
interface AddSubsystemInfo extends CommonAddSubsystemInfo {
|
||||
subsystem: Subsystem | string,
|
||||
subsystem: Subsystem | string;
|
||||
}
|
||||
|
||||
interface SysInfo {
|
||||
@@ -109,7 +109,7 @@ declare namespace adone {
|
||||
}
|
||||
|
||||
interface AddSubsystemsFromOptions extends CommonAddSubsystemInfo {
|
||||
filter?: string[] | ((file: string) => boolean | Promise<boolean>)
|
||||
filter?: string[] | ((file: string) => boolean | Promise<boolean>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,25 +211,22 @@ declare namespace adone {
|
||||
_rejectionHandled(p: Promise<any>): void;
|
||||
|
||||
_signalExit(sigName: string): void;
|
||||
|
||||
}
|
||||
|
||||
namespace I {
|
||||
interface Command {
|
||||
// ?
|
||||
names: string[];
|
||||
// TODO
|
||||
}
|
||||
|
||||
interface Argument {
|
||||
// ?
|
||||
names: string[];
|
||||
// TODO
|
||||
}
|
||||
|
||||
interface PositionalArgument extends Argument {
|
||||
// ?
|
||||
}
|
||||
type PositionalArgument = Argument; // TODO
|
||||
|
||||
interface OptionalArgument extends Argument {
|
||||
// ?
|
||||
}
|
||||
type OptionalArgument = Argument; // TODO
|
||||
|
||||
interface DefineCommandFromSubsystemOptions {
|
||||
name?: string;
|
||||
+14
@@ -103,6 +103,13 @@ declare namespace adone.collection {
|
||||
*/
|
||||
readUInt16BE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 24bit unsigned be integer
|
||||
*
|
||||
* @param offset Offset to read from
|
||||
*/
|
||||
readUInt24BE(offset?: number): number;
|
||||
|
||||
/**
|
||||
* Reads a 32bit signed le integer
|
||||
*
|
||||
@@ -260,6 +267,13 @@ declare namespace adone.collection {
|
||||
*/
|
||||
writeUInt16BE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 24bit unsigned be integer
|
||||
*
|
||||
* @param offset Offset to write at
|
||||
*/
|
||||
writeUInt24BE(value: number, offset?: number): this;
|
||||
|
||||
/**
|
||||
* Writes a 32bit signed le integer
|
||||
*
|
||||
|
||||
+8
-3
@@ -4,13 +4,18 @@ declare namespace adone.collection {
|
||||
*/
|
||||
class FastLRU<K = any, V = any> {
|
||||
/**
|
||||
* @param size Cache size, unlimited by default
|
||||
* @param size
|
||||
*/
|
||||
constructor(size?: number, options?: {
|
||||
constructor(options?: {
|
||||
/**
|
||||
* Cache size, unlimited by default
|
||||
*/
|
||||
maxSize?: number;
|
||||
|
||||
/**
|
||||
* Function that is called when a value is deleted
|
||||
*/
|
||||
dispose?(key: K, value: V): void
|
||||
dispose?(key: K, value: V): void;
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@
|
||||
/// <reference path="./refcounted_cache.d.ts" />
|
||||
/// <reference path="./set.d.ts" />
|
||||
/// <reference path="./stack.d.ts" />
|
||||
/// <reference path="./timedout_map.d.ts" />
|
||||
/// <reference path="./time_map.d.ts" />
|
||||
|
||||
declare namespace adone {
|
||||
/**
|
||||
|
||||
+2
-7
@@ -6,7 +6,7 @@ declare namespace adone.collection {
|
||||
* The maximum size of the cache, checked by applying the length function to all values in the cache.
|
||||
* Default is Infinity
|
||||
*/
|
||||
max?: number;
|
||||
maxSize?: number;
|
||||
|
||||
/**
|
||||
* Maximum age in ms. Items are not pro-actively pruned out as they age,
|
||||
@@ -85,11 +85,6 @@ declare namespace adone.collection {
|
||||
* Represent an LRU cache
|
||||
*/
|
||||
class LRU<K = any, V = any> {
|
||||
/**
|
||||
* Creates an LRU cache of the given size
|
||||
*/
|
||||
constructor(max: number);
|
||||
|
||||
/**
|
||||
* Creates an LRU cache with the given options
|
||||
*/
|
||||
@@ -98,7 +93,7 @@ declare namespace adone.collection {
|
||||
/**
|
||||
* The length of the cache, setter resizes the cache
|
||||
*/
|
||||
max: number;
|
||||
maxSize: number;
|
||||
|
||||
/**
|
||||
* stale setting
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
declare namespace adone.collection {
|
||||
class NSCache<T = any> {
|
||||
constructor(size: number, namespaces: string[]);
|
||||
constructor(maxSize: number, namespaces: string[]);
|
||||
|
||||
resize(newSize: number): void;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@ declare namespace adone.collection {
|
||||
/**
|
||||
* Represents a Map that keeps keys only for a specified interval of time
|
||||
*/
|
||||
class TimedoutMap<K = any, V = any> extends Map<K, V> {
|
||||
class TimeMap<K = any, V = any> extends Map<K, V> {
|
||||
/**
|
||||
* @param timeout maximum age of the keys, 1000 by default
|
||||
* @param callback callback that is called with each key when the timeout is passed
|
||||
Vendored
+14
-19
@@ -320,12 +320,12 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given object is an adone subsystem
|
||||
*/
|
||||
export function subsystem(obj: any): obj is adone.application.Subsystem;
|
||||
export function subsystem(obj: any): obj is adone.app.Subsystem;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone application
|
||||
*/
|
||||
export function application(obj: any): obj is adone.application.Application;
|
||||
export function application(obj: any): obj is adone.app.Application;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an adone logger
|
||||
@@ -490,12 +490,17 @@ declare namespace adone {
|
||||
/**
|
||||
* Checks whether the given string is an IPv4 address
|
||||
*/
|
||||
export function ip4(str: string): boolean;
|
||||
export function ip4(str: string, options?: adone.regex.I.IP.Options): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given string is an IPv6 address
|
||||
*/
|
||||
export function ip6(str: string): boolean;
|
||||
export function ip6(str: string, options?: adone.regex.I.IP.Options): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given string is IPv4 or IPv6 address
|
||||
*/
|
||||
export function ip(str: string, options?: adone.regex.I.IP.Options): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is an array buffer
|
||||
@@ -628,21 +633,6 @@ declare namespace adone {
|
||||
requireTld?: boolean
|
||||
}): obj is string;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a valid IPv4 address
|
||||
*/
|
||||
export function ip(obj: any, version: 4): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a valid IPv6 address
|
||||
*/
|
||||
export function ip(obj: any, version: 6): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given object in a valid IPv4 or IPv6 address
|
||||
*/
|
||||
export function ip(obj: any): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is a valid UUIDv1 identifier
|
||||
*/
|
||||
@@ -680,5 +670,10 @@ declare namespace adone {
|
||||
export const openbsd: boolean;
|
||||
|
||||
export const aix: boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the given object is adone.multi.address.Multiaddr
|
||||
*/
|
||||
export function multiAddress(obj: any): boolean; // TODO: obj is adone.multi.address.Multiaddr
|
||||
}
|
||||
}
|
||||
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
declare namespace adone.math {
|
||||
namespace I.BigNumber {
|
||||
interface BufferConvertOptions {
|
||||
endian?: 1 | -1 | "big" | "little";
|
||||
size?: "auto" | number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a number of arbitrary precision
|
||||
*/
|
||||
class BigNumber {
|
||||
/**
|
||||
* Creates a BigNumber from the given value, the base is 10
|
||||
*/
|
||||
constructor(n: number | string | BigNumber);
|
||||
|
||||
/**
|
||||
* Creates a BigNumber from the given string and base
|
||||
*/
|
||||
constructor(n: string, base: number);
|
||||
|
||||
/**
|
||||
* Converts the number to a string in the given base
|
||||
*/
|
||||
toString(base?: number): string;
|
||||
|
||||
/**
|
||||
* Converts the bignum into a Number.
|
||||
* If the bignum is too big you'll lose precision or you'll get ±Infinity.
|
||||
*/
|
||||
toNumber(): number;
|
||||
|
||||
/**
|
||||
* Returns a new Buffer with the data from the bignum.
|
||||
*/
|
||||
toBuffer(opts?: I.BigNumber.BufferConvertOptions): Buffer;
|
||||
|
||||
/**
|
||||
* Returns a new bignum containing the instance value plus n
|
||||
*/
|
||||
add(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Return a new bignum containing the instance value minus n
|
||||
*/
|
||||
sub(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum containing the instance value multiplied by n
|
||||
*/
|
||||
mul(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum containing the instance value integrally divided by n
|
||||
*/
|
||||
div(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the absolute value of the instance
|
||||
*/
|
||||
abs(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the negative of the instance value
|
||||
*/
|
||||
neg(): BigNumber;
|
||||
|
||||
/**
|
||||
* Compares the instance value to n.
|
||||
*
|
||||
* Returns a positive integer if > n, a negative integer if < n, and 0 if == n
|
||||
*/
|
||||
cmp(n: number | string | BigNumber): number;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is greater than n (> n).
|
||||
*/
|
||||
gt(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is greater than or equal to n (>= n).
|
||||
*/
|
||||
ge(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is equal to n (== n).
|
||||
*/
|
||||
eq(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is less than n (< n).
|
||||
*/
|
||||
lt(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is less than or equal to n (<= n).
|
||||
*/
|
||||
le(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value bitwise AND (&)-ed with n.
|
||||
*/
|
||||
and(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value bitwise inclusive-OR (|)-ed with n.
|
||||
*/
|
||||
or(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value bitwise exclusive-OR (^)-ed with n.
|
||||
*/
|
||||
xor(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value modulo n.
|
||||
*/
|
||||
mod(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value raised to the nth power.
|
||||
*/
|
||||
pow(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value raised to the nth power modulo m.
|
||||
*/
|
||||
powm(n: number | string | BigNumber, m: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Computes the multiplicative inverse modulo m.
|
||||
*/
|
||||
invertm(m: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a random number from 0 to this -1
|
||||
*/
|
||||
rand(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a random number from this to upperBound - 1
|
||||
*/
|
||||
rand(upperBound: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Checks whether the bignum is:
|
||||
*
|
||||
* - certainly prime (true)
|
||||
*
|
||||
* - probably prime ('maybe')
|
||||
*
|
||||
* - certainly composite (false)
|
||||
*/
|
||||
probPrime(): boolean | "maybe";
|
||||
|
||||
/**
|
||||
* Returns the next prime number after this bignum
|
||||
*/
|
||||
nextPrime(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum that is the square root. This truncates.
|
||||
*/
|
||||
sqrt(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum that is the nth root. This truncates.
|
||||
*/
|
||||
root(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum that is the 2^n multiple. Equivalent of the << operator.
|
||||
*/
|
||||
shiftLeft(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum of the value integer divided by 2^n. Equivalent of the >> operator.
|
||||
*/
|
||||
shiftRight(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns the greatest common divisor of the current bignum with n as a new bignum.
|
||||
*/
|
||||
gcd(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns the Jacobi symbol (or Legendre symbol if n is prime) of the current bignum (= a) over n.
|
||||
* Note that n must be odd and >= 3. 0 <= a < n.
|
||||
* Returns -1 or 1
|
||||
*/
|
||||
jacobi(n: number | string | BigNumber): number;
|
||||
|
||||
/**
|
||||
* Returns the number of bits used to represent the current bignum
|
||||
*/
|
||||
bitLength(): number;
|
||||
|
||||
/**
|
||||
* Checks whether the bit at the given index is set
|
||||
*/
|
||||
isBitSet(n: number): boolean;
|
||||
|
||||
/**
|
||||
* Generates a probable prime number of length bits.
|
||||
*
|
||||
* @param bits the number of bits
|
||||
* @param safe If true, it will be a "safe" prime of the form p=2p'+1 where p' is also prime. Default: true
|
||||
*/
|
||||
static prime(bits: number, safe?: boolean): BigNumber;
|
||||
|
||||
/**
|
||||
* Creates a new bignum from a Buffer.
|
||||
*/
|
||||
static fromBuffer(buf: Buffer, opts?: I.BigNumber.BufferConvertOptions): BigNumber;
|
||||
|
||||
/**
|
||||
* One
|
||||
*/
|
||||
static ONE: BigNumber;
|
||||
|
||||
/**
|
||||
* Zero
|
||||
*/
|
||||
static ZERO: BigNumber;
|
||||
}
|
||||
}
|
||||
Vendored
+225
@@ -0,0 +1,225 @@
|
||||
declare namespace adone.math {
|
||||
/**
|
||||
* Represents a set of bits
|
||||
*/
|
||||
class BitSet {
|
||||
/**
|
||||
* Creates a new bitset of n bits
|
||||
*/
|
||||
constructor(n: number);
|
||||
|
||||
/**
|
||||
* Creates a new bitset from a dehydrated bitset
|
||||
*/
|
||||
constructor(key: string);
|
||||
|
||||
/**
|
||||
* Checks whether a bit at a specific index is set
|
||||
*/
|
||||
get(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Sets a single bit.
|
||||
* Returns true if set was successfull
|
||||
*/
|
||||
set(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Sets a range of bits.
|
||||
* Returns true if set was successfull
|
||||
*/
|
||||
setRange(from: number, to: number): boolean;
|
||||
|
||||
/**
|
||||
* Unsets a single bit.
|
||||
* Returns true if unset was successfull
|
||||
*/
|
||||
unset(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Unsets a range of bits.
|
||||
* Returns true if unset was successfull
|
||||
*/
|
||||
unsetRange(from: number, to: number): boolean;
|
||||
|
||||
/**
|
||||
* Toggles a single bit
|
||||
*/
|
||||
toggle(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Toggles a range of bits
|
||||
*/
|
||||
toggleRange(from: number, to: number): boolean;
|
||||
|
||||
/**
|
||||
* Clears the entire bitset
|
||||
*/
|
||||
clear(): boolean;
|
||||
|
||||
/**
|
||||
* Clones the set
|
||||
*/
|
||||
clone(): BitSet;
|
||||
|
||||
/**
|
||||
* Turns the bitset into a comma separated string that skips leading & trailing 0 words.
|
||||
* Ends with the number of leading 0s and MAX_BIT.
|
||||
* Useful if you need the bitset to be an object key (eg dynamic programming).
|
||||
* Can rehydrate by passing the result into the constructor
|
||||
*/
|
||||
dehydrate(): string;
|
||||
|
||||
/**
|
||||
* Performs a bitwise AND on 2 bitsets or 1 bitset and 1 index.
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
and(value: number | BitSet): BitSet;
|
||||
|
||||
/**
|
||||
* Performs a bitwise OR on 2 bitsets or 1 bitset and 1 index.
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
or(value: number | BitSet): BitSet;
|
||||
|
||||
/**
|
||||
* Performs a bitwise XOR on 2 bitsets or 1 bitset and 1 index.
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
xor(value: number | BitSet): BitSet;
|
||||
|
||||
/**
|
||||
* Runs a custom function on every set bit.
|
||||
* Faster than iterating over the entire bitset with a get().
|
||||
* If the callback returns `false` it stops iterating.
|
||||
*/
|
||||
forEach(callback: ((idx: number) => void | boolean)): void;
|
||||
|
||||
/**
|
||||
* Performs a circular shift bitset by an offset
|
||||
*
|
||||
* @param n number of positions that the bitset that will be shifted to the right. Using a negative number will result in a left shift.
|
||||
*/
|
||||
circularShift(n: number): BitSet;
|
||||
|
||||
/**
|
||||
* Gets the cardinality (count of set bits) for the entire bitset
|
||||
*/
|
||||
getCardinality(): number;
|
||||
|
||||
/**
|
||||
* Gets the indices of all set bits
|
||||
*/
|
||||
getIndices(): number[];
|
||||
|
||||
/**
|
||||
* Checks if one bitset is subset of another.
|
||||
*/
|
||||
isSubsetOf(other: BitSet): boolean;
|
||||
|
||||
/**
|
||||
* Quickly determines if a bitset is empty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
|
||||
/**
|
||||
* Quickly determines if both bitsets are equal (faster than checking if the XOR of the two is === 0).
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
isEqual(other: BitSet): boolean;
|
||||
|
||||
/**
|
||||
* Gets a string representation of the entire bitset, including leading 0s
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* Finds first set bit (useful for processing queues, breadth-first tree searches, etc.).
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by nextSetBit)
|
||||
*/
|
||||
ffs(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds first zero (unset bit).
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by nextUnsetBit)
|
||||
*/
|
||||
ffz(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds last set bit.
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by previousSetBit)
|
||||
*/
|
||||
fls(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds last zero (unset bit).
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by previousUnsetBit)
|
||||
*/
|
||||
flz(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds first set bit, starting at a given index.
|
||||
* Return -1 if not found
|
||||
*
|
||||
* @param idx the starting index for the next set bit
|
||||
*/
|
||||
nextSetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Finds first unset bit, starting at a given index.
|
||||
* Return -1 if not found
|
||||
*
|
||||
* @param idx the starting index for the next unset bit
|
||||
*/
|
||||
nextUnsetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Finds last set bit, up to a given index.
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param idx the starting index for the next unset bit (going in reverse)
|
||||
*/
|
||||
previousSetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Finds last unset bit, up to a given index.
|
||||
* Returns -1 if not found
|
||||
*/
|
||||
previousUnsetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Converts the bitset to a math.Long number
|
||||
*/
|
||||
toLong(): Long;
|
||||
|
||||
/**
|
||||
* Reads an unsigned integer of the given bits from the given offset
|
||||
*
|
||||
* @param bits number of bits, 1 by default
|
||||
* @param offset offset, 0 by default
|
||||
*/
|
||||
readUInt(bits?: number, offset?: number): number;
|
||||
|
||||
/**
|
||||
* Writes the given unsigned integer
|
||||
*
|
||||
* @param val integer
|
||||
* @param bits number of bits to write, 1 by default
|
||||
* @param offset write offset, 0 by default
|
||||
*/
|
||||
writeUInt(val: number, bits?: number, offset?: number): void;
|
||||
|
||||
/**
|
||||
* Creates a new BitSet from the given math.Long number
|
||||
*/
|
||||
static fromLong(l: Long): BitSet;
|
||||
}
|
||||
}
|
||||
+1287
File diff suppressed because it is too large
Load Diff
Vendored
+20
-742
@@ -1,3 +1,7 @@
|
||||
/// <reference path="./bignumber.d.ts" />
|
||||
/// <reference path="./bitset.d.ts" />
|
||||
/// <reference path="./decimal.d.ts" />
|
||||
/// <reference path="./long.d.ts" />
|
||||
/// <reference path="./matrix.d.ts" />
|
||||
/// <reference path="./simd.d.ts" />
|
||||
|
||||
@@ -6,748 +10,6 @@ declare namespace adone {
|
||||
* math related things
|
||||
*/
|
||||
namespace math {
|
||||
namespace I {
|
||||
interface LowHighBits {
|
||||
/**
|
||||
* The low (signed) 32 bits of the long
|
||||
*/
|
||||
low: number;
|
||||
/**
|
||||
* The high (signed) 32 bits of the long
|
||||
*/
|
||||
high: number;
|
||||
}
|
||||
type Longable = Long | number | string | LowHighBits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a 64 bit two's-complement integer
|
||||
*/
|
||||
class Long {
|
||||
low: number;
|
||||
high: number;
|
||||
unsigned: boolean;
|
||||
|
||||
/**
|
||||
* @param low The low (signed) 32 bits of the long
|
||||
* @param high The high (signed) 32 bits of the long
|
||||
* @param unsigned Whether unsigned or not, defaults to false for signed
|
||||
*/
|
||||
constructor(low?: number, high?: number, unsigned?: boolean);
|
||||
|
||||
/**
|
||||
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer
|
||||
*/
|
||||
toInt(): number;
|
||||
|
||||
/**
|
||||
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa)
|
||||
*/
|
||||
toNumber(): number;
|
||||
|
||||
/**
|
||||
* Converts the Long to a string written in the specified radix
|
||||
*
|
||||
* @param radix Radix (2-36), 10 by default
|
||||
*/
|
||||
toString(radix?: number): string;
|
||||
|
||||
inspect(): string;
|
||||
|
||||
/**
|
||||
* Gets the high 32 bits as a signed integer
|
||||
*/
|
||||
getHighBits(): number;
|
||||
|
||||
/**
|
||||
* Gets the high 32 bits as an unsigned integer
|
||||
*/
|
||||
getHighBitsUnsigned(): number;
|
||||
|
||||
/**
|
||||
* Gets the low 32 bits as a signed integer
|
||||
*/
|
||||
getLowBits(): number;
|
||||
|
||||
/**
|
||||
* Gets the low 32 bits as an unsigned integer
|
||||
*/
|
||||
getLowBitsUnsigned(): number;
|
||||
|
||||
/**
|
||||
* Gets the number of bits needed to represent the absolute value of this Long
|
||||
*/
|
||||
getNumBitsAbs(): number;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals zero
|
||||
*/
|
||||
isZero(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is negative
|
||||
*/
|
||||
isNegative(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is positive
|
||||
*/
|
||||
isPositive(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is odd
|
||||
*/
|
||||
isOdd(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is even
|
||||
*/
|
||||
isEven(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals the specified's
|
||||
*/
|
||||
equals(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than the specified's
|
||||
*/
|
||||
lessThan(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than or equal the specified's
|
||||
*/
|
||||
lessThanOrEqual(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than the specified's
|
||||
*/
|
||||
greaterThan(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than or equal the specified's
|
||||
*/
|
||||
greaterThanOrEqual(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Compares this Long's value with the specified's.
|
||||
* Returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
|
||||
*/
|
||||
compare(other: I.Longable): number;
|
||||
|
||||
/**
|
||||
* Negates this Long's value
|
||||
*/
|
||||
negate(): Long;
|
||||
|
||||
/**
|
||||
* Returns the sum of this and the specified Long
|
||||
*/
|
||||
add(addend: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the difference of this and the specified Long
|
||||
*/
|
||||
sub(subtrahend: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the product of this and the specified Long
|
||||
*/
|
||||
mul(multiplier: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long divided by the specified
|
||||
*/
|
||||
div(divisor: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long modulo the specified
|
||||
*/
|
||||
mod(divisor: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise NOT of this Long
|
||||
*/
|
||||
not(): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise AND of this Long and the specified
|
||||
*/
|
||||
and(other: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise OR of this Long and the specifieds
|
||||
*/
|
||||
or(other: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise XOR of this Long and the given one
|
||||
*/
|
||||
xor(other: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the left by the given amount
|
||||
*/
|
||||
shl(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits arithmetically shifted to the right by the given amount
|
||||
*/
|
||||
shr(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits logically shifted to the right by the given amount
|
||||
*/
|
||||
shru(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Converts this Long to signed
|
||||
*/
|
||||
toSigned(): Long;
|
||||
|
||||
/**
|
||||
* Converts this Long to unsigned
|
||||
*/
|
||||
toUnsigned(): Long;
|
||||
|
||||
/**
|
||||
* Converts this Long to an array of bytes, big-endian by default
|
||||
*
|
||||
* @param le Whether to return an array in little-endian format
|
||||
*/
|
||||
toBytes(le?: boolean): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to an array of bytes in little-endian format
|
||||
*/
|
||||
toBytesLE(): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to an array of bytes in big-endian format
|
||||
*/
|
||||
toBytesBE(): number[];
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given 32 bit integer value
|
||||
*/
|
||||
static fromInt(value: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned
|
||||
*/
|
||||
static fromNumber(value?: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits
|
||||
*/
|
||||
static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representation of the given string, written using the specified radix
|
||||
*/
|
||||
static fromString(str: string, unsigned?: boolean, radix?: number): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representation of the given string, written using the specified radix
|
||||
*/
|
||||
static fromString(str: string, radix?: number): Long;
|
||||
|
||||
/**
|
||||
* Converts the specified value to a Long
|
||||
*/
|
||||
static fromValue(val: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Minimum signed value
|
||||
*/
|
||||
static MIN_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Maximum signed value
|
||||
*/
|
||||
static MAX_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Maximum unsigned value
|
||||
*/
|
||||
static MAX_UNSIGNED_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Signed zero
|
||||
*/
|
||||
static ZERO: Long;
|
||||
|
||||
/**
|
||||
* Unsigned zero
|
||||
*/
|
||||
static UZERO: Long;
|
||||
|
||||
/**
|
||||
* Signed one
|
||||
*/
|
||||
static ONE: Long;
|
||||
|
||||
/**
|
||||
* Unsigned one
|
||||
*/
|
||||
static UONE: Long;
|
||||
|
||||
/**
|
||||
* Signed negative one
|
||||
*/
|
||||
static NEG_ONE: Long;
|
||||
}
|
||||
|
||||
namespace I.BigNumber {
|
||||
interface BufferConvertOptions {
|
||||
endian?: 1 | -1 | "big" | "little";
|
||||
size?: "auto" | number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a number of arbitrary precision
|
||||
*/
|
||||
class BigNumber {
|
||||
/**
|
||||
* Creates a BigNumber from the given value, the base is 10
|
||||
*/
|
||||
constructor(n: number | string | BigNumber);
|
||||
|
||||
/**
|
||||
* Creates a BigNumber from the given string and base
|
||||
*/
|
||||
constructor(n: string, base: number);
|
||||
|
||||
/**
|
||||
* Converts the number to a string in the given base
|
||||
*/
|
||||
toString(base?: number): string;
|
||||
|
||||
/**
|
||||
* Converts the bignum into a Number.
|
||||
* If the bignum is too big you'll lose precision or you'll get ±Infinity.
|
||||
*/
|
||||
toNumber(): number;
|
||||
|
||||
/**
|
||||
* Returns a new Buffer with the data from the bignum.
|
||||
*/
|
||||
toBuffer(opts?: I.BigNumber.BufferConvertOptions): Buffer;
|
||||
|
||||
/**
|
||||
* Returns a new bignum containing the instance value plus n
|
||||
*/
|
||||
add(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Return a new bignum containing the instance value minus n
|
||||
*/
|
||||
sub(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum containing the instance value multiplied by n
|
||||
*/
|
||||
mul(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum containing the instance value integrally divided by n
|
||||
*/
|
||||
div(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the absolute value of the instance
|
||||
*/
|
||||
abs(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the negative of the instance value
|
||||
*/
|
||||
neg(): BigNumber;
|
||||
|
||||
/**
|
||||
* Compares the instance value to n.
|
||||
*
|
||||
* Returns a positive integer if > n, a negative integer if < n, and 0 if == n
|
||||
*/
|
||||
cmp(n: number | string | BigNumber): number;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is greater than n (> n).
|
||||
*/
|
||||
gt(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is greater than or equal to n (>= n).
|
||||
*/
|
||||
ge(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is equal to n (== n).
|
||||
*/
|
||||
eq(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is less than n (< n).
|
||||
*/
|
||||
lt(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Checks whether the instance value is less than or equal to n (<= n).
|
||||
*/
|
||||
le(n: number | string | BigNumber): boolean;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value bitwise AND (&)-ed with n.
|
||||
*/
|
||||
and(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value bitwise inclusive-OR (|)-ed with n.
|
||||
*/
|
||||
or(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value bitwise exclusive-OR (^)-ed with n.
|
||||
*/
|
||||
xor(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value modulo n.
|
||||
*/
|
||||
mod(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value raised to the nth power.
|
||||
*/
|
||||
pow(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum with the instance value raised to the nth power modulo m.
|
||||
*/
|
||||
powm(n: number | string | BigNumber, m: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Computes the multiplicative inverse modulo m.
|
||||
*/
|
||||
invertm(m: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a random number from 0 to this -1
|
||||
*/
|
||||
rand(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a random number from this to upperBound - 1
|
||||
*/
|
||||
rand(upperBound: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Checks whether the bignum is:
|
||||
*
|
||||
* - certainly prime (true)
|
||||
*
|
||||
* - probably prime ('maybe')
|
||||
*
|
||||
* - certainly composite (false)
|
||||
*/
|
||||
probPrime(): boolean | "maybe";
|
||||
|
||||
/**
|
||||
* Returns the next prime number after this bignum
|
||||
*/
|
||||
nextPrime(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum that is the square root. This truncates.
|
||||
*/
|
||||
sqrt(): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum that is the nth root. This truncates.
|
||||
*/
|
||||
root(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum that is the 2^n multiple. Equivalent of the << operator.
|
||||
*/
|
||||
shiftLeft(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns a new bignum of the value integer divided by 2^n. Equivalent of the >> operator.
|
||||
*/
|
||||
shiftRight(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns the greatest common divisor of the current bignum with n as a new bignum.
|
||||
*/
|
||||
gcd(n: number | string | BigNumber): BigNumber;
|
||||
|
||||
/**
|
||||
* Returns the Jacobi symbol (or Legendre symbol if n is prime) of the current bignum (= a) over n.
|
||||
* Note that n must be odd and >= 3. 0 <= a < n.
|
||||
* Returns -1 or 1
|
||||
*/
|
||||
jacobi(n: number | string | BigNumber): number;
|
||||
|
||||
/**
|
||||
* Returns the number of bits used to represent the current bignum
|
||||
*/
|
||||
bitLength(): number;
|
||||
|
||||
/**
|
||||
* Checks whether the bit at the given index is set
|
||||
*/
|
||||
isBitSet(n: number): boolean;
|
||||
|
||||
/**
|
||||
* Generates a probable prime number of length bits.
|
||||
*
|
||||
* @param bits the number of bits
|
||||
* @param safe If true, it will be a "safe" prime of the form p=2p'+1 where p' is also prime. Default: true
|
||||
*/
|
||||
static prime(bits: number, safe?: boolean): BigNumber;
|
||||
|
||||
/**
|
||||
* Creates a new bignum from a Buffer.
|
||||
*/
|
||||
static fromBuffer(buf: Buffer, opts?: I.BigNumber.BufferConvertOptions): BigNumber;
|
||||
|
||||
/**
|
||||
* One
|
||||
*/
|
||||
static ONE: BigNumber;
|
||||
|
||||
/**
|
||||
* Zero
|
||||
*/
|
||||
static ZERO: BigNumber;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a set of bits
|
||||
*/
|
||||
class BitSet {
|
||||
/**
|
||||
* Creates a new bitset of n bits
|
||||
*/
|
||||
constructor(n: number);
|
||||
|
||||
/**
|
||||
* Creates a new bitset from a dehydrated bitset
|
||||
*/
|
||||
constructor(key: string);
|
||||
|
||||
/**
|
||||
* Checks whether a bit at a specific index is set
|
||||
*/
|
||||
get(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Sets a single bit.
|
||||
* Returns true if set was successfull
|
||||
*/
|
||||
set(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Sets a range of bits.
|
||||
* Returns true if set was successfull
|
||||
*/
|
||||
setRange(from: number, to: number): boolean;
|
||||
|
||||
/**
|
||||
* Unsets a single bit.
|
||||
* Returns true if unset was successfull
|
||||
*/
|
||||
unset(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Unsets a range of bits.
|
||||
* Returns true if unset was successfull
|
||||
*/
|
||||
unsetRange(from: number, to: number): boolean;
|
||||
|
||||
/**
|
||||
* Toggles a single bit
|
||||
*/
|
||||
toggle(idx: number): boolean;
|
||||
|
||||
/**
|
||||
* Toggles a range of bits
|
||||
*/
|
||||
toggleRange(from: number, to: number): boolean;
|
||||
|
||||
/**
|
||||
* Clears the entire bitset
|
||||
*/
|
||||
clear(): boolean;
|
||||
|
||||
/**
|
||||
* Clones the set
|
||||
*/
|
||||
clone(): BitSet;
|
||||
|
||||
/**
|
||||
* Turns the bitset into a comma separated string that skips leading & trailing 0 words.
|
||||
* Ends with the number of leading 0s and MAX_BIT.
|
||||
* Useful if you need the bitset to be an object key (eg dynamic programming).
|
||||
* Can rehydrate by passing the result into the constructor
|
||||
*/
|
||||
dehydrate(): string;
|
||||
|
||||
/**
|
||||
* Performs a bitwise AND on 2 bitsets or 1 bitset and 1 index.
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
and(value: number | BitSet): BitSet;
|
||||
|
||||
/**
|
||||
* Performs a bitwise OR on 2 bitsets or 1 bitset and 1 index.
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
or(value: number | BitSet): BitSet;
|
||||
|
||||
/**
|
||||
* Performs a bitwise XOR on 2 bitsets or 1 bitset and 1 index.
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
xor(value: number | BitSet): BitSet;
|
||||
|
||||
/**
|
||||
* Runs a custom function on every set bit.
|
||||
* Faster than iterating over the entire bitset with a get().
|
||||
* If the callback returns `false` it stops iterating.
|
||||
*/
|
||||
forEach(callback: ((idx: number) => void | boolean)): void;
|
||||
|
||||
/**
|
||||
* Performs a circular shift bitset by an offset
|
||||
*
|
||||
* @param n number of positions that the bitset that will be shifted to the right. Using a negative number will result in a left shift.
|
||||
*/
|
||||
circularShift(n: number): BitSet;
|
||||
|
||||
/**
|
||||
* Gets the cardinality (count of set bits) for the entire bitset
|
||||
*/
|
||||
getCardinality(): number;
|
||||
|
||||
/**
|
||||
* Gets the indices of all set bits
|
||||
*/
|
||||
getIndices(): number[];
|
||||
|
||||
/**
|
||||
* Checks if one bitset is subset of another.
|
||||
*/
|
||||
isSubsetOf(other: BitSet): boolean;
|
||||
|
||||
/**
|
||||
* Quickly determines if a bitset is empty
|
||||
*/
|
||||
isEmpty(): boolean;
|
||||
|
||||
/**
|
||||
* Quickly determines if both bitsets are equal (faster than checking if the XOR of the two is === 0).
|
||||
* Both bitsets must have the same number of words, no length check is performed to prevent and overflow.
|
||||
*/
|
||||
isEqual(other: BitSet): boolean;
|
||||
|
||||
/**
|
||||
* Gets a string representation of the entire bitset, including leading 0s
|
||||
*/
|
||||
toString(): string;
|
||||
|
||||
/**
|
||||
* Finds first set bit (useful for processing queues, breadth-first tree searches, etc.).
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by nextSetBit)
|
||||
*/
|
||||
ffs(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds first zero (unset bit).
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by nextUnsetBit)
|
||||
*/
|
||||
ffz(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds last set bit.
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by previousSetBit)
|
||||
*/
|
||||
fls(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds last zero (unset bit).
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param startWord the word to start with (only used internally by previousUnsetBit)
|
||||
*/
|
||||
flz(startWord?: number): number;
|
||||
|
||||
/**
|
||||
* Finds first set bit, starting at a given index.
|
||||
* Return -1 if not found
|
||||
*
|
||||
* @param idx the starting index for the next set bit
|
||||
*/
|
||||
nextSetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Finds first unset bit, starting at a given index.
|
||||
* Return -1 if not found
|
||||
*
|
||||
* @param idx the starting index for the next unset bit
|
||||
*/
|
||||
nextUnsetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Finds last set bit, up to a given index.
|
||||
* Returns -1 if not found
|
||||
*
|
||||
* @param idx the starting index for the next unset bit (going in reverse)
|
||||
*/
|
||||
previousSetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Finds last unset bit, up to a given index.
|
||||
* Returns -1 if not found
|
||||
*/
|
||||
previousUnsetBit(idx: number): number;
|
||||
|
||||
/**
|
||||
* Converts the bitset to a math.Long number
|
||||
*/
|
||||
toLong(): Long;
|
||||
|
||||
/**
|
||||
* Reads an unsigned integer of the given bits from the given offset
|
||||
*
|
||||
* @param bits number of bits, 1 by default
|
||||
* @param offset offset, 0 by default
|
||||
*/
|
||||
readUInt(bits?: number, offset?: number): number;
|
||||
|
||||
/**
|
||||
* Writes the given unsigned integer
|
||||
*
|
||||
* @param val integer
|
||||
* @param bits number of bits to write, 1 by default
|
||||
* @param offset write offset, 0 by default
|
||||
*/
|
||||
writeUInt(val: number, bits?: number, offset?: number): void;
|
||||
|
||||
/**
|
||||
* Creates a new BitSet from the given math.Long number
|
||||
*/
|
||||
static fromLong(l: Long): BitSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a random number from min to max - 1
|
||||
*
|
||||
@@ -755,5 +17,21 @@ declare namespace adone {
|
||||
* @param max upper bound, default is 0xFFFFFFFF
|
||||
*/
|
||||
function random(min?: number, max?: number): number;
|
||||
|
||||
/**
|
||||
* Returns the maximum value from the given array
|
||||
*
|
||||
* @param array array of values
|
||||
* @param score function to calculate the element score value
|
||||
*/
|
||||
function max<T>(array: T[], score?: (x: T) => any): T;
|
||||
|
||||
/**
|
||||
* Returns the minimum value from the given array
|
||||
*
|
||||
* @param array array of values
|
||||
* @param score function to calculate the element score value
|
||||
*/
|
||||
function min<T>(array: T[], score?: (x: T) => any): T;
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+293
@@ -0,0 +1,293 @@
|
||||
declare namespace adone.math {
|
||||
namespace I {
|
||||
interface LowHighBits {
|
||||
/**
|
||||
* The low (signed) 32 bits of the long
|
||||
*/
|
||||
low: number;
|
||||
/**
|
||||
* The high (signed) 32 bits of the long
|
||||
*/
|
||||
high: number;
|
||||
}
|
||||
type Longable = Long | number | string | LowHighBits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a 64 bit two's-complement integer
|
||||
*/
|
||||
class Long {
|
||||
low: number;
|
||||
high: number;
|
||||
unsigned: boolean;
|
||||
|
||||
/**
|
||||
* @param low The low (signed) 32 bits of the long
|
||||
* @param high The high (signed) 32 bits of the long
|
||||
* @param unsigned Whether unsigned or not, defaults to false for signed
|
||||
*/
|
||||
constructor(low?: number, high?: number, unsigned?: boolean);
|
||||
|
||||
/**
|
||||
* Converts the Long to a 32 bit integer, assuming it is a 32 bit integer
|
||||
*/
|
||||
toInt(): number;
|
||||
|
||||
/**
|
||||
* Converts the Long to a the nearest floating-point representation of this value (double, 53 bit mantissa)
|
||||
*/
|
||||
toNumber(): number;
|
||||
|
||||
/**
|
||||
* Converts the Long to a string written in the specified radix
|
||||
*
|
||||
* @param radix Radix (2-36), 10 by default
|
||||
*/
|
||||
toString(radix?: number): string;
|
||||
|
||||
inspect(): string;
|
||||
|
||||
/**
|
||||
* Gets the high 32 bits as a signed integer
|
||||
*/
|
||||
getHighBits(): number;
|
||||
|
||||
/**
|
||||
* Gets the high 32 bits as an unsigned integer
|
||||
*/
|
||||
getHighBitsUnsigned(): number;
|
||||
|
||||
/**
|
||||
* Gets the low 32 bits as a signed integer
|
||||
*/
|
||||
getLowBits(): number;
|
||||
|
||||
/**
|
||||
* Gets the low 32 bits as an unsigned integer
|
||||
*/
|
||||
getLowBitsUnsigned(): number;
|
||||
|
||||
/**
|
||||
* Gets the number of bits needed to represent the absolute value of this Long
|
||||
*/
|
||||
getNumBitsAbs(): number;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals zero
|
||||
*/
|
||||
isZero(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is negative
|
||||
*/
|
||||
isNegative(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is positive
|
||||
*/
|
||||
isPositive(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is odd
|
||||
*/
|
||||
isOdd(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is even
|
||||
*/
|
||||
isEven(): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value equals the specified's
|
||||
*/
|
||||
equals(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than the specified's
|
||||
*/
|
||||
lessThan(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is less than or equal the specified's
|
||||
*/
|
||||
lessThanOrEqual(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than the specified's
|
||||
*/
|
||||
greaterThan(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Tests if this Long's value is greater than or equal the specified's
|
||||
*/
|
||||
greaterThanOrEqual(other: I.Longable): boolean;
|
||||
|
||||
/**
|
||||
* Compares this Long's value with the specified's.
|
||||
* Returns 0 if they are the same, 1 if the this is greater and -1 if the given one is greater
|
||||
*/
|
||||
compare(other: I.Longable): number;
|
||||
|
||||
/**
|
||||
* Negates this Long's value
|
||||
*/
|
||||
negate(): Long;
|
||||
|
||||
/**
|
||||
* Returns the sum of this and the specified Long
|
||||
*/
|
||||
add(addend: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the difference of this and the specified Long
|
||||
*/
|
||||
sub(subtrahend: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the product of this and the specified Long
|
||||
*/
|
||||
mul(multiplier: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long divided by the specified
|
||||
*/
|
||||
div(divisor: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long modulo the specified
|
||||
*/
|
||||
mod(divisor: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise NOT of this Long
|
||||
*/
|
||||
not(): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise AND of this Long and the specified
|
||||
*/
|
||||
and(other: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise OR of this Long and the specifieds
|
||||
*/
|
||||
or(other: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns the bitwise XOR of this Long and the given one
|
||||
*/
|
||||
xor(other: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits shifted to the left by the given amount
|
||||
*/
|
||||
shl(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits arithmetically shifted to the right by the given amount
|
||||
*/
|
||||
shr(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Returns this Long with bits logically shifted to the right by the given amount
|
||||
*/
|
||||
shru(numBits: number | Long): Long;
|
||||
|
||||
/**
|
||||
* Converts this Long to signed
|
||||
*/
|
||||
toSigned(): Long;
|
||||
|
||||
/**
|
||||
* Converts this Long to unsigned
|
||||
*/
|
||||
toUnsigned(): Long;
|
||||
|
||||
/**
|
||||
* Converts this Long to an array of bytes, big-endian by default
|
||||
*
|
||||
* @param le Whether to return an array in little-endian format
|
||||
*/
|
||||
toBytes(le?: boolean): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to an array of bytes in little-endian format
|
||||
*/
|
||||
toBytesLE(): number[];
|
||||
|
||||
/**
|
||||
* Converts this Long to an array of bytes in big-endian format
|
||||
*/
|
||||
toBytesBE(): number[];
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given 32 bit integer value
|
||||
*/
|
||||
static fromInt(value: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the given value, provided that it is a finite number. Otherwise, zero is returned
|
||||
*/
|
||||
static fromNumber(value?: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representing the 64 bit integer that comes by concatenating the given low and high bits. Each is assumed to use 32 bits
|
||||
*/
|
||||
static fromBits(lowBits: number, highBits: number, unsigned?: boolean): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representation of the given string, written using the specified radix
|
||||
*/
|
||||
static fromString(str: string, unsigned?: boolean, radix?: number): Long;
|
||||
|
||||
/**
|
||||
* Returns a Long representation of the given string, written using the specified radix
|
||||
*/
|
||||
static fromString(str: string, radix?: number): Long;
|
||||
|
||||
/**
|
||||
* Converts the specified value to a Long
|
||||
*/
|
||||
static fromValue(val: I.Longable): Long;
|
||||
|
||||
/**
|
||||
* Minimum signed value
|
||||
*/
|
||||
static MIN_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Maximum signed value
|
||||
*/
|
||||
static MAX_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Maximum unsigned value
|
||||
*/
|
||||
static MAX_UNSIGNED_VALUE: Long;
|
||||
|
||||
/**
|
||||
* Signed zero
|
||||
*/
|
||||
static ZERO: Long;
|
||||
|
||||
/**
|
||||
* Unsigned zero
|
||||
*/
|
||||
static UZERO: Long;
|
||||
|
||||
/**
|
||||
* Signed one
|
||||
*/
|
||||
static ONE: Long;
|
||||
|
||||
/**
|
||||
* Unsigned one
|
||||
*/
|
||||
static UONE: Long;
|
||||
|
||||
/**
|
||||
* Signed negative one
|
||||
*/
|
||||
static NEG_ONE: Long;
|
||||
}
|
||||
}
|
||||
Vendored
+10
-2
@@ -2,9 +2,17 @@ declare namespace adone {
|
||||
namespace regex {
|
||||
function filename(): RegExp;
|
||||
|
||||
function ip4(): RegExp;
|
||||
namespace I.IP {
|
||||
interface Options {
|
||||
exact?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
function ip6(): RegExp;
|
||||
function ip(options?: I.IP.Options): RegExp;
|
||||
|
||||
function ip4(options?: I.IP.Options): RegExp;
|
||||
|
||||
function ip6(options?: I.IP.Options): RegExp;
|
||||
|
||||
function protocol(): RegExp;
|
||||
|
||||
|
||||
Vendored
+1
-1
@@ -5,7 +5,7 @@
|
||||
// TypeScript Version: 2.4
|
||||
|
||||
/// <reference path="./adone.d.ts" />
|
||||
/// <reference path="./glosses/application.d.ts" />
|
||||
/// <reference path="./glosses/app.d.ts" />
|
||||
/// <reference path="./glosses/archives.d.ts" />
|
||||
/// <reference path="./glosses/assertion.d.ts" />
|
||||
/// <reference path="./glosses/collections/index.d.ts" />
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace applicationTests {
|
||||
Subsystem,
|
||||
runCli,
|
||||
Application
|
||||
} = adone.application;
|
||||
} = adone.app;
|
||||
|
||||
namespace DApplicationTests {
|
||||
{
|
||||
@@ -56,6 +56,11 @@ namespace adoneTests.collection.ByteArray {
|
||||
const b: number = buffer.readUInt16BE(10);
|
||||
}
|
||||
|
||||
namespace readUInt24BE {
|
||||
const a: number = buffer.readUInt24BE();
|
||||
const b: number = buffer.readUInt24BE(10);
|
||||
}
|
||||
|
||||
namespace readInt32LE {
|
||||
const a: number = buffer.readInt32LE();
|
||||
const b: number = buffer.readInt32LE(10);
|
||||
@@ -162,6 +167,11 @@ namespace adoneTests.collection.ByteArray {
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt16BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeUInt24BE {
|
||||
const a: adone.collection.ByteArray = buffer.writeUInt24BE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeUInt24BE(10, 10);
|
||||
}
|
||||
|
||||
namespace writeInt32LE {
|
||||
const a: adone.collection.ByteArray = buffer.writeInt32LE(10);
|
||||
const b: adone.collection.ByteArray = buffer.writeInt32LE(10, 10);
|
||||
|
||||
@@ -6,8 +6,8 @@ namespace adoneTests.collection.FastLRU {
|
||||
} = adone;
|
||||
|
||||
new FastLRU();
|
||||
new FastLRU(100);
|
||||
new FastLRU<string, number>(100, { dispose: (key: string, value: number) => null });
|
||||
new FastLRU({ maxSize: 100 });
|
||||
new FastLRU<string, number>({ maxSize: 100, dispose: (key: string, value: number) => null });
|
||||
{ const a: number = new FastLRU().size; }
|
||||
{ const a: number | undefined = new FastLRU<string, number>().get("key"); }
|
||||
new FastLRU<string, number>().set("key", 123);
|
||||
|
||||
@@ -8,15 +8,14 @@ namespace adoneTests.collection.LRU {
|
||||
type LRU = adone.collection.LRU;
|
||||
|
||||
new LRU();
|
||||
new LRU(100);
|
||||
new LRU({ maxSize: 100 });
|
||||
new LRU({});
|
||||
new LRU({ max: 100 });
|
||||
new LRU<string, number>({ dispose: (key: string, value: number) => null });
|
||||
new LRU<string, number>({ maxAge: 100 });
|
||||
new LRU<string, number>({ noDisposeOnSet: false });
|
||||
new LRU<string, number>({ stale: true });
|
||||
{ const a: number = new LRU<string, number>().max; }
|
||||
{ new LRU<string, number>().max = 100; }
|
||||
{ const a: number = new LRU<string, number>().maxSize; }
|
||||
{ new LRU<string, number>().maxSize = 100; }
|
||||
{ const a: boolean = new LRU<string, number>().allowStale; }
|
||||
{ new LRU<string, number>().allowStale = false; }
|
||||
{ const a: number = new LRU<string, number>().maxAge; }
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace adoneTests.collection.TimedoutMap {
|
||||
const {
|
||||
collection: {
|
||||
TimeMap
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type TimeMap<K = any, V = any> = adone.collection.TimeMap<K, V>;
|
||||
|
||||
new TimeMap();
|
||||
new TimeMap(1000);
|
||||
new TimeMap<string, number>(1000, (key: string) => null);
|
||||
{
|
||||
const a: TimeMap<string, number> = new TimeMap<string, number>().forEach((value: number, key: string) => null);
|
||||
}
|
||||
{
|
||||
const a: TimeMap<string, number> = new TimeMap<string, number>().forEach(function (value: number, key: string) {
|
||||
const a: number = this.a;
|
||||
}, { a: 1 });
|
||||
}
|
||||
{ const a: boolean = new TimeMap<string, number>().delete("123"); }
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
namespace adoneTests.collection.TimedoutMap {
|
||||
const {
|
||||
collection: {
|
||||
TimedoutMap
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type TimedoutMap<K = any, V = any> = adone.collection.TimedoutMap<K, V>;
|
||||
|
||||
new TimedoutMap();
|
||||
new TimedoutMap(1000);
|
||||
new TimedoutMap<string, number>(1000, (key: string) => null);
|
||||
{
|
||||
const a: TimedoutMap<string, number> = new TimedoutMap<string, number>().forEach((value: number, key: string) => null);
|
||||
}
|
||||
{
|
||||
const a: TimedoutMap<string, number> = new TimedoutMap<string, number>().forEach(function (value: number, key: string) {
|
||||
const a: number = this.a;
|
||||
}, { a: 1 });
|
||||
}
|
||||
{ const a: boolean = new TimedoutMap<string, number>().delete("123"); }
|
||||
}
|
||||
@@ -345,7 +345,11 @@ namespace isTests {
|
||||
{ const a: boolean = is.binaryExtension("mp3"); }
|
||||
{ const a: boolean = is.binaryPath("a.mp3"); }
|
||||
{ const a: boolean = is.ip4("192.168.1.1"); }
|
||||
{ const a: boolean = is.ip4("192.168.1.1", { exact: true }); }
|
||||
{ const a: boolean = is.ip6("::192.168.1.1"); }
|
||||
{ const a: boolean = is.ip6("::192.168.1.1", { exact: true }); }
|
||||
{ const a: boolean = is.ip("::192.168.1.1"); }
|
||||
{ const a: boolean = is.ip("::192.168.1.1", { exact: true }); }
|
||||
{
|
||||
const a: boolean = is.arrayBuffer({});
|
||||
const b: any = 2;
|
||||
@@ -492,4 +496,7 @@ namespace isTests {
|
||||
b.charCodeAt(0);
|
||||
}
|
||||
}
|
||||
{
|
||||
const a: boolean = is.multiAddress(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
namespace mathTests.bignumberTests {
|
||||
const {
|
||||
math: {
|
||||
BigNumber
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type BigNumber = adone.math.BigNumber;
|
||||
|
||||
new BigNumber(10);
|
||||
new BigNumber("10");
|
||||
new BigNumber(new BigNumber(10));
|
||||
new BigNumber("10", 2);
|
||||
|
||||
{ const a: string = new BigNumber(1).toString(); }
|
||||
{ const a: string = new BigNumber(1).toString(2); }
|
||||
|
||||
{ const a: number = new BigNumber(1).toNumber(); }
|
||||
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer(); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({}); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: 1 }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: -1 }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: "big" }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: "little" }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ size: 1 }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ size: "auto" }); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).add(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).add("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).add(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).sub(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).sub("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).sub(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).mul(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).mul("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).mul(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).div(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).div("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).div(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).abs(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).neg(); }
|
||||
|
||||
{ const a: number = new BigNumber(10).cmp(1); }
|
||||
{ const a: number = new BigNumber(10).cmp("1"); }
|
||||
{ const a: number = new BigNumber(10).cmp(new BigNumber(1)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).gt(1); }
|
||||
{ const a: boolean = new BigNumber(10).gt("1"); }
|
||||
{ const a: boolean = new BigNumber(10).gt(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).ge(1); }
|
||||
{ const a: boolean = new BigNumber(10).ge("1"); }
|
||||
{ const a: boolean = new BigNumber(10).ge(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).eq(1); }
|
||||
{ const a: boolean = new BigNumber(10).eq("1"); }
|
||||
{ const a: boolean = new BigNumber(10).eq(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).lt(1); }
|
||||
{ const a: boolean = new BigNumber(10).lt("1"); }
|
||||
{ const a: boolean = new BigNumber(10).lt(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).le(1); }
|
||||
{ const a: boolean = new BigNumber(10).le("1"); }
|
||||
{ const a: boolean = new BigNumber(10).le(new BigNumber(10)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).and(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).and("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).and(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).or(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).or("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).or(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).xor(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).xor("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).xor(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).mod(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).mod("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).mod(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).pow(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).pow("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).pow(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).powm(1, 1); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm("1", 1); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(new BigNumber(1), 1); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(1, "1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm("1", "1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(new BigNumber(1), "1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(1, new BigNumber(1)); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm("1", new BigNumber(1)); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(new BigNumber(1), new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).invertm(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).invertm("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).invertm(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).rand(); }
|
||||
{ const a: BigNumber = new BigNumber(10).rand(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).rand("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).rand(new BigNumber(1)); }
|
||||
|
||||
{ const a: boolean | "maybe" = new BigNumber(10).probPrime(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).nextPrime(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).sqrt(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).root(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).root("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).root(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).shiftLeft(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftLeft("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftLeft(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).shiftRight(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftRight("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftRight(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).gcd(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).gcd("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).gcd(new BigNumber(1)); }
|
||||
|
||||
{ const a: number = new BigNumber(10).jacobi(1); }
|
||||
{ const a: number = new BigNumber(10).jacobi("1"); }
|
||||
{ const a: number = new BigNumber(10).jacobi(new BigNumber(1)); }
|
||||
|
||||
{ const a: number = new BigNumber(10).bitLength(); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).isBitSet(10); }
|
||||
|
||||
{ const a: BigNumber = BigNumber.prime(10); }
|
||||
{ const a: BigNumber = BigNumber.prime(10, true); }
|
||||
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10)); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: "little" }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: -1 }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: 1 }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: "big" }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { size: "auto" }); }
|
||||
|
||||
{ const a: BigNumber = BigNumber.ONE; }
|
||||
{ const a: BigNumber = BigNumber.ZERO; }
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
namespace mathTests.bitsetTests {
|
||||
const {
|
||||
math: {
|
||||
BitSet
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type BitSet = adone.math.BitSet;
|
||||
|
||||
new BitSet(10);
|
||||
new BitSet(new BitSet(10).dehydrate());
|
||||
|
||||
{ const a: boolean = new BitSet(10).get(0); }
|
||||
{ const a: boolean = new BitSet(10).set(0); }
|
||||
{ const a: boolean = new BitSet(10).setRange(0, 10); }
|
||||
{ const a: boolean = new BitSet(10).unset(0); }
|
||||
{ const a: boolean = new BitSet(10).unsetRange(0, 10); }
|
||||
{ const a: boolean = new BitSet(10).toggle(0); }
|
||||
{ const a: boolean = new BitSet(10).toggleRange(0, 10); }
|
||||
{ const a: boolean = new BitSet(10).clear(); }
|
||||
{ const a: BitSet = new BitSet(10).clone(); }
|
||||
{ const a: string = new BitSet(10).dehydrate(); }
|
||||
|
||||
{ const a: BitSet = new BitSet(10).and(1); }
|
||||
{ const a: BitSet = new BitSet(10).and(new BitSet(10)); }
|
||||
|
||||
{ const a: BitSet = new BitSet(10).or(1); }
|
||||
{ const a: BitSet = new BitSet(10).or(new BitSet(10)); }
|
||||
|
||||
{ const a: BitSet = new BitSet(10).xor(1); }
|
||||
{ const a: BitSet = new BitSet(10).xor(new BitSet(10)); }
|
||||
|
||||
new BitSet(10).forEach((x: number) => {});
|
||||
new BitSet(10).forEach((x: number) => false);
|
||||
|
||||
{ const a: BitSet = new BitSet(10).circularShift(10); }
|
||||
{ const a: number = new BitSet(10).getCardinality(); }
|
||||
{ const a: number[] = new BitSet(10).getIndices(); }
|
||||
{ const a: boolean = new BitSet(10).isSubsetOf(new BitSet(10)); }
|
||||
{ const a: boolean = new BitSet(10).isEmpty(); }
|
||||
{ const a: boolean = new BitSet(10).isEqual(new BitSet(10)); }
|
||||
{ const a: string = new BitSet(10).toString(); }
|
||||
{ const a: number = new BitSet(10).ffs(); }
|
||||
{ const a: number = new BitSet(10).ffs(1); }
|
||||
{ const a: number = new BitSet(10).ffz(); }
|
||||
{ const a: number = new BitSet(10).ffz(1); }
|
||||
{ const a: number = new BitSet(10).fls(); }
|
||||
{ const a: number = new BitSet(10).fls(1); }
|
||||
{ const a: number = new BitSet(10).flz(); }
|
||||
{ const a: number = new BitSet(10).flz(1); }
|
||||
{ const a: number = new BitSet(10).nextSetBit(1); }
|
||||
{ const a: number = new BitSet(10).nextUnsetBit(1); }
|
||||
{ const a: number = new BitSet(10).previousSetBit(1); }
|
||||
{ const a: number = new BitSet(10).previousUnsetBit(1); }
|
||||
{ const a: number = new BitSet(10).readUInt(); }
|
||||
{ const a: number = new BitSet(10).readUInt(1); }
|
||||
{ const a: number = new BitSet(10).readUInt(1, 2); }
|
||||
{ new BitSet(10).writeUInt(1); }
|
||||
{ new BitSet(10).writeUInt(1, 2); }
|
||||
{ new BitSet(10).writeUInt(1, 2, 3); }
|
||||
{ const a: BitSet = BitSet.fromLong(new adone.math.Long(10, 20)); }
|
||||
}
|
||||
@@ -0,0 +1,445 @@
|
||||
namespace mathTests.decimalTest {
|
||||
const {
|
||||
math: {
|
||||
Decimal
|
||||
}
|
||||
} = adone;
|
||||
|
||||
type Decimal = adone.math.Decimal;
|
||||
|
||||
new Decimal(0);
|
||||
new Decimal("0");
|
||||
new Decimal(new Decimal(0));
|
||||
|
||||
new Decimal(0).e.toExponential();
|
||||
new Decimal(0).d[0].toExponential();
|
||||
new Decimal(0).s.toExponential();
|
||||
|
||||
const d = new Decimal(0);
|
||||
|
||||
{ const a: Decimal = d.abs(); }
|
||||
{ const a: Decimal = d.absoluteValue(); }
|
||||
|
||||
{ const a: Decimal = d.ceil(); }
|
||||
|
||||
{ const a: number = d.comparedTo(1); }
|
||||
{ const a: number = d.comparedTo("1"); }
|
||||
{ const a: number = d.comparedTo(d); }
|
||||
{ const a: number = d.cmp(1); }
|
||||
{ const a: number = d.cmp("1"); }
|
||||
{ const a: number = d.cmp(d); }
|
||||
|
||||
{ const a: Decimal = d.cos(); }
|
||||
{ const a: Decimal = d.cosine(); }
|
||||
|
||||
{ const a: Decimal = d.cubeRoot(); }
|
||||
{ const a: Decimal = d.cbrt(); }
|
||||
|
||||
{ const a: number = d.decimalPlaces(); }
|
||||
{ const a: number = d.dp(); }
|
||||
|
||||
{ const a: Decimal = d.dividedBy(1); }
|
||||
{ const a: Decimal = d.dividedBy("1"); }
|
||||
{ const a: Decimal = d.dividedBy(d); }
|
||||
{ const a: Decimal = d.div(1); }
|
||||
{ const a: Decimal = d.div("1"); }
|
||||
{ const a: Decimal = d.div(d); }
|
||||
|
||||
{ const a: Decimal = d.dividedToIntegerBy(1); }
|
||||
{ const a: Decimal = d.dividedToIntegerBy("1"); }
|
||||
{ const a: Decimal = d.dividedToIntegerBy(d); }
|
||||
{ const a: Decimal = d.divToInt(1); }
|
||||
{ const a: Decimal = d.divToInt("1"); }
|
||||
{ const a: Decimal = d.divToInt(d); }
|
||||
|
||||
{ const a: boolean = d.equals(1); }
|
||||
{ const a: boolean = d.equals("1"); }
|
||||
{ const a: boolean = d.equals(d); }
|
||||
{ const a: boolean = d.eq(1); }
|
||||
{ const a: boolean = d.eq("1"); }
|
||||
{ const a: boolean = d.eq(d); }
|
||||
|
||||
{ const a: Decimal = d.floor(); }
|
||||
|
||||
{ const a: boolean = d.greaterThan(1); }
|
||||
{ const a: boolean = d.greaterThan("1"); }
|
||||
{ const a: boolean = d.greaterThan(d); }
|
||||
{ const a: boolean = d.gt(1); }
|
||||
{ const a: boolean = d.gt("1"); }
|
||||
{ const a: boolean = d.gt(d); }
|
||||
|
||||
{ const a: boolean = d.greaterThanOrEqualTo(1); }
|
||||
{ const a: boolean = d.greaterThanOrEqualTo("1"); }
|
||||
{ const a: boolean = d.greaterThanOrEqualTo(d); }
|
||||
{ const a: boolean = d.gte(1); }
|
||||
{ const a: boolean = d.gte("1"); }
|
||||
{ const a: boolean = d.gte(d); }
|
||||
|
||||
{ const a: Decimal = d.hyperbolicCosine(); }
|
||||
{ const a: Decimal = d.cosh(); }
|
||||
|
||||
{ const a: Decimal = d.hyperbolicSine(); }
|
||||
{ const a: Decimal = d.sinh(); }
|
||||
|
||||
{ const a: Decimal = d.hyperbolicTangent(); }
|
||||
{ const a: Decimal = d.tanh(); }
|
||||
|
||||
{ const a: Decimal = d.inverseCosine(); }
|
||||
{ const a: Decimal = d.acos(); }
|
||||
|
||||
{ const a: Decimal = d.inverseHyperbolicCosine(); }
|
||||
{ const a: Decimal = d.acosh(); }
|
||||
|
||||
{ const a: Decimal = d.inverseHyperbolicSine(); }
|
||||
{ const a: Decimal = d.asinh(); }
|
||||
|
||||
{ const a: Decimal = d.inverseHyperbolicTangent(); }
|
||||
{ const a: Decimal = d.atanh(); }
|
||||
|
||||
{ const a: Decimal = d.inverseSine(); }
|
||||
{ const a: Decimal = d.asin(); }
|
||||
|
||||
{ const a: Decimal = d.inverseTangent(); }
|
||||
{ const a: Decimal = d.atan(); }
|
||||
|
||||
{ const a: boolean = d.isFinite(); }
|
||||
|
||||
{ const a: boolean = d.isInteger(); }
|
||||
{ const a: boolean = d.isInt(); }
|
||||
|
||||
{ const a: boolean = d.isNaN(); }
|
||||
|
||||
{ const a: boolean = d.isNegative(); }
|
||||
{ const a: boolean = d.isNeg(); }
|
||||
|
||||
{ const a: boolean = d.isPositive(); }
|
||||
{ const a: boolean = d.isPos(); }
|
||||
|
||||
{ const a: boolean = d.isZero(); }
|
||||
|
||||
{ const a: boolean = d.lessThan(1); }
|
||||
{ const a: boolean = d.lessThan("1"); }
|
||||
{ const a: boolean = d.lessThan(d); }
|
||||
{ const a: boolean = d.lt(1); }
|
||||
{ const a: boolean = d.lt("1"); }
|
||||
{ const a: boolean = d.lt(d); }
|
||||
|
||||
{ const a: boolean = d.lessThanOrEqualTo(1); }
|
||||
{ const a: boolean = d.lessThanOrEqualTo("1"); }
|
||||
{ const a: boolean = d.lessThanOrEqualTo(d); }
|
||||
{ const a: boolean = d.lte(1); }
|
||||
{ const a: boolean = d.lte("1"); }
|
||||
{ const a: boolean = d.lte(d); }
|
||||
|
||||
{ const a: Decimal = d.logarithm(); }
|
||||
{ const a: Decimal = d.logarithm(1); }
|
||||
{ const a: Decimal = d.logarithm("1"); }
|
||||
{ const a: Decimal = d.logarithm(d); }
|
||||
{ const a: Decimal = d.log(); }
|
||||
{ const a: Decimal = d.log(1); }
|
||||
{ const a: Decimal = d.log("1"); }
|
||||
{ const a: Decimal = d.log(d); }
|
||||
|
||||
{ const a: Decimal = d.minus(1); }
|
||||
{ const a: Decimal = d.minus("1"); }
|
||||
{ const a: Decimal = d.minus(d); }
|
||||
{ const a: Decimal = d.sub(1); }
|
||||
{ const a: Decimal = d.sub("1"); }
|
||||
{ const a: Decimal = d.sub(d); }
|
||||
|
||||
{ const a: Decimal = d.modulo(1); }
|
||||
{ const a: Decimal = d.modulo("1"); }
|
||||
{ const a: Decimal = d.modulo(d); }
|
||||
{ const a: Decimal = d.mod(1); }
|
||||
{ const a: Decimal = d.mod("1"); }
|
||||
{ const a: Decimal = d.mod(d); }
|
||||
|
||||
{ const a: Decimal = d.naturalExponential(); }
|
||||
{ const a: Decimal = d.exp(); }
|
||||
|
||||
{ const a: Decimal = d.naturalLogarithm(); }
|
||||
{ const a: Decimal = d.ln(); }
|
||||
|
||||
{ const a: Decimal = d.negated(); }
|
||||
{ const a: Decimal = d.neg(); }
|
||||
|
||||
{ const a: Decimal = d.plus(1); }
|
||||
{ const a: Decimal = d.plus("1"); }
|
||||
{ const a: Decimal = d.plus(d); }
|
||||
{ const a: Decimal = d.add(1); }
|
||||
{ const a: Decimal = d.add("1"); }
|
||||
{ const a: Decimal = d.add(d); }
|
||||
|
||||
{ const a: number = d.precision(); }
|
||||
{ const a: number = d.precision(true); }
|
||||
{ const a: number = d.sd(); }
|
||||
{ const a: number = d.sd(true); }
|
||||
|
||||
{ const a: Decimal = d.round(); }
|
||||
|
||||
{ const a: Decimal = d.sine(); }
|
||||
{ const a: Decimal = d.sin(); }
|
||||
|
||||
{ const a: Decimal = d.squareRoot(); }
|
||||
{ const a: Decimal = d.sqrt(); }
|
||||
|
||||
{ const a: Decimal = d.tangent(); }
|
||||
{ const a: Decimal = d.tan(); }
|
||||
|
||||
{ const a: Decimal = d.times(1); }
|
||||
{ const a: Decimal = d.times("1"); }
|
||||
{ const a: Decimal = d.times(d); }
|
||||
{ const a: Decimal = d.mul(1); }
|
||||
{ const a: Decimal = d.mul("1"); }
|
||||
{ const a: Decimal = d.mul(d); }
|
||||
|
||||
{ const a: string = d.toBinary(); }
|
||||
{ const a: string = d.toBinary(1); }
|
||||
{ const a: string = d.toBinary(1, 1); }
|
||||
|
||||
{ const a: Decimal = d.toDecimalPlaces(); }
|
||||
{ const a: Decimal = d.toDecimalPlaces(1); }
|
||||
{ const a: Decimal = d.toDecimalPlaces(1, 1); }
|
||||
{ const a: Decimal = d.toDP(); }
|
||||
{ const a: Decimal = d.toDP(1); }
|
||||
{ const a: Decimal = d.toDP(1, 1); }
|
||||
|
||||
{ const a: string = d.toExponential(); }
|
||||
{ const a: string = d.toExponential(1); }
|
||||
{ const a: string = d.toExponential(1, 1); }
|
||||
|
||||
{ const a: string = d.toFixed(); }
|
||||
{ const a: string = d.toFixed(1); }
|
||||
{ const a: string = d.toFixed(1, 1); }
|
||||
|
||||
{ const a: Decimal[] = d.toFraction(); }
|
||||
{ const a: Decimal[] = d.toFraction(1); }
|
||||
{ const a: Decimal[] = d.toFraction("1"); }
|
||||
{ const a: Decimal[] = d.toFraction(d); }
|
||||
|
||||
{ const a: string = d.toHexadecimal(); }
|
||||
{ const a: string = d.toHexadecimal(1); }
|
||||
{ const a: string = d.toHexadecimal(1, 1); }
|
||||
{ const a: string = d.toHex(); }
|
||||
{ const a: string = d.toHex(1); }
|
||||
{ const a: string = d.toHex(1, 1); }
|
||||
|
||||
{ const a: string = d.toJSON(); }
|
||||
|
||||
{ const a: Decimal = d.toNearest(); }
|
||||
{ const a: Decimal = d.toNearest(1); }
|
||||
{ const a: Decimal = d.toNearest("1"); }
|
||||
{ const a: Decimal = d.toNearest(d); }
|
||||
{ const a: Decimal = d.toNearest(d, 1); }
|
||||
|
||||
{ const a: number = d.toNumber(); }
|
||||
|
||||
{ const a: string = d.toOctal(); }
|
||||
{ const a: string = d.toOctal(1); }
|
||||
{ const a: string = d.toOctal(1, 1); }
|
||||
|
||||
{ const a: Decimal = d.toPower(1); }
|
||||
{ const a: Decimal = d.toPower("1"); }
|
||||
{ const a: Decimal = d.toPower(d); }
|
||||
{ const a: Decimal = d.pow(1); }
|
||||
{ const a: Decimal = d.pow("1"); }
|
||||
{ const a: Decimal = d.pow(d); }
|
||||
|
||||
{ const a: string = d.toPrecision(); }
|
||||
{ const a: string = d.toPrecision(1); }
|
||||
{ const a: string = d.toPrecision(1, 1); }
|
||||
|
||||
{ const a: Decimal = d.toSignificantDigits(); }
|
||||
{ const a: Decimal = d.toSignificantDigits(1); }
|
||||
{ const a: Decimal = d.toSignificantDigits(1, 1); }
|
||||
{ const a: Decimal = d.toSD(); }
|
||||
{ const a: Decimal = d.toSD(1); }
|
||||
{ const a: Decimal = d.toSD(1, 1); }
|
||||
|
||||
{ const a: string = d.toString(); }
|
||||
|
||||
{ const a: Decimal = d.truncated(); }
|
||||
{ const a: Decimal = d.trunc(); }
|
||||
|
||||
{ const a: string = d.valueOf(); }
|
||||
|
||||
{ const a: Decimal = Decimal.abs(1); }
|
||||
{ const a: Decimal = Decimal.abs("1"); }
|
||||
{ const a: Decimal = Decimal.abs(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.acos(1); }
|
||||
{ const a: Decimal = Decimal.acos("1"); }
|
||||
{ const a: Decimal = Decimal.acos(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.acosh(1); }
|
||||
{ const a: Decimal = Decimal.acosh("1"); }
|
||||
{ const a: Decimal = Decimal.acosh(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.asin(1); }
|
||||
{ const a: Decimal = Decimal.asin("1"); }
|
||||
{ const a: Decimal = Decimal.asin(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.asinh(1); }
|
||||
{ const a: Decimal = Decimal.asinh("1"); }
|
||||
{ const a: Decimal = Decimal.asinh(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.atan(1); }
|
||||
{ const a: Decimal = Decimal.atan("1"); }
|
||||
{ const a: Decimal = Decimal.atan(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.atan2(1, 1); }
|
||||
{ const a: Decimal = Decimal.atan2("1", "1"); }
|
||||
{ const a: Decimal = Decimal.atan2(d, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.cbrt(1); }
|
||||
{ const a: Decimal = Decimal.cbrt("1"); }
|
||||
{ const a: Decimal = Decimal.cbrt(d); }
|
||||
|
||||
{ const a: typeof Decimal = Decimal.clone({}); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ crypto: true }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ defaults: true }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ maxE: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ minE: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ modulo: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ precision: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ rounding: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ toExpNeg: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({ toExpPos: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.clone({}); }
|
||||
|
||||
{ const a: typeof Decimal = Decimal.config({ crypto: true }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ defaults: true }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ maxE: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ minE: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ modulo: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ precision: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ rounding: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ toExpNeg: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.config({ toExpPos: 1 }); }
|
||||
|
||||
{ const a: typeof Decimal = Decimal.set({ crypto: true }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ defaults: true }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ maxE: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ minE: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ modulo: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ precision: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ rounding: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ toExpNeg: 1 }); }
|
||||
{ const a: typeof Decimal = Decimal.set({ toExpPos: 1 }); }
|
||||
|
||||
{ const a: Decimal = Decimal.cos(1); }
|
||||
{ const a: Decimal = Decimal.cos("1"); }
|
||||
{ const a: Decimal = Decimal.cos(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.div(1, 1); }
|
||||
{ const a: Decimal = Decimal.div("1", "1"); }
|
||||
{ const a: Decimal = Decimal.div(d, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.exp(1); }
|
||||
{ const a: Decimal = Decimal.exp("1"); }
|
||||
{ const a: Decimal = Decimal.exp(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.floor(1); }
|
||||
{ const a: Decimal = Decimal.floor("1"); }
|
||||
{ const a: Decimal = Decimal.floor(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.hypot(1); }
|
||||
{ const a: Decimal = Decimal.hypot("1"); }
|
||||
{ const a: Decimal = Decimal.hypot(d); }
|
||||
{ const a: Decimal = Decimal.hypot(1, 1); }
|
||||
{ const a: Decimal = Decimal.hypot("1", "1"); }
|
||||
{ const a: Decimal = Decimal.hypot(d, d); }
|
||||
{ const a: Decimal = Decimal.hypot(1, 1, 1); }
|
||||
{ const a: Decimal = Decimal.hypot("1", "1", "1"); }
|
||||
{ const a: Decimal = Decimal.hypot(d, d, d); }
|
||||
{ const a: Decimal = Decimal.hypot(1, 1, 1, 1, 1, 1, 1, 1, 1, d, 1, 1, 1, "1", d); }
|
||||
|
||||
{ const a: boolean = Decimal.isDecimal(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.ln(1); }
|
||||
{ const a: Decimal = Decimal.ln("1"); }
|
||||
{ const a: Decimal = Decimal.ln(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.log(1); }
|
||||
{ const a: Decimal = Decimal.log("1"); }
|
||||
{ const a: Decimal = Decimal.log(d); }
|
||||
{ const a: Decimal = Decimal.log(1, 2); }
|
||||
{ const a: Decimal = Decimal.log("1", 2); }
|
||||
{ const a: Decimal = Decimal.log(d, 2); }
|
||||
|
||||
{ const a: Decimal = Decimal.log2(1); }
|
||||
{ const a: Decimal = Decimal.log2("1"); }
|
||||
{ const a: Decimal = Decimal.log2(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.log10(1); }
|
||||
{ const a: Decimal = Decimal.log10("1"); }
|
||||
{ const a: Decimal = Decimal.log10(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.min(1, "1", 1, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.max(1, "1", 1, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.mul(1, 1); }
|
||||
{ const a: Decimal = Decimal.mul("1", "1"); }
|
||||
{ const a: Decimal = Decimal.mul(d, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.pow(1, 1); }
|
||||
{ const a: Decimal = Decimal.pow("1", "1"); }
|
||||
{ const a: Decimal = Decimal.pow(d, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.random(); }
|
||||
{ const a: Decimal = Decimal.random(1); }
|
||||
|
||||
{ const a: Decimal = Decimal.round(1); }
|
||||
{ const a: Decimal = Decimal.round("1"); }
|
||||
{ const a: Decimal = Decimal.round(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.sign(1); }
|
||||
{ const a: Decimal = Decimal.sign("1"); }
|
||||
{ const a: Decimal = Decimal.sign(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.sin(1); }
|
||||
{ const a: Decimal = Decimal.sin("1"); }
|
||||
{ const a: Decimal = Decimal.sin(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.sinh(1); }
|
||||
{ const a: Decimal = Decimal.sinh("1"); }
|
||||
{ const a: Decimal = Decimal.sinh(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.sqrt(1); }
|
||||
{ const a: Decimal = Decimal.sqrt("1"); }
|
||||
{ const a: Decimal = Decimal.sqrt(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.sub(1, 1); }
|
||||
{ const a: Decimal = Decimal.sub("1", "1"); }
|
||||
{ const a: Decimal = Decimal.sub(d, d); }
|
||||
|
||||
{ const a: Decimal = Decimal.tan(1); }
|
||||
{ const a: Decimal = Decimal.tan("1"); }
|
||||
{ const a: Decimal = Decimal.tan(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.tanh(1); }
|
||||
{ const a: Decimal = Decimal.tanh("1"); }
|
||||
{ const a: Decimal = Decimal.tanh(d); }
|
||||
|
||||
{ const a: Decimal = Decimal.trunc(1); }
|
||||
{ const a: Decimal = Decimal.trunc("1"); }
|
||||
{ const a: Decimal = Decimal.trunc(d); }
|
||||
|
||||
{ const a: number = Decimal.precision; }
|
||||
{ const a: number = Decimal.rounding; }
|
||||
{ const a: number = Decimal.toExpNeg; }
|
||||
{ const a: number = Decimal.minE; }
|
||||
{ const a: boolean = Decimal.crypto; }
|
||||
{ const a: number = Decimal.modulo; }
|
||||
{ const a: number = Decimal.ROUND_UP; }
|
||||
{ const a: number = Decimal.ROUND_DOWN; }
|
||||
{ const a: number = Decimal.ROUND_CEIL; }
|
||||
{ const a: number = Decimal.ROUND_FLOOR; }
|
||||
{ const a: number = Decimal.ROUND_HALF_UP; }
|
||||
{ const a: number = Decimal.ROUND_HALF_DOWN; }
|
||||
{ const a: number = Decimal.ROUND_HALF_EVEN; }
|
||||
{ const a: number = Decimal.ROUND_HALF_CEIL; }
|
||||
{ const a: number = Decimal.ROUND_HALF_FLOOR; }
|
||||
{ const a: number = Decimal.EUCLID; }
|
||||
}
|
||||
@@ -1,469 +1,7 @@
|
||||
namespace mathTests {
|
||||
const { math } = adone;
|
||||
|
||||
namespace LongTests {
|
||||
new math.Long();
|
||||
new math.Long(0);
|
||||
new math.Long(0, 0);
|
||||
new math.Long(0, 0, true);
|
||||
|
||||
namespace toInt {
|
||||
const a: number = new math.Long().toInt();
|
||||
}
|
||||
|
||||
namespace toNumber {
|
||||
const a: number = new math.Long().toNumber();
|
||||
}
|
||||
|
||||
namespace toString {
|
||||
const a: string = new math.Long().toString();
|
||||
const b: string = new math.Long().toString(16);
|
||||
}
|
||||
|
||||
namespace getHighBits {
|
||||
const a: number = new math.Long().getHighBits();
|
||||
}
|
||||
|
||||
namespace getLowBits {
|
||||
const a: number = new math.Long().getLowBits();
|
||||
}
|
||||
|
||||
namespace getLowBitsUnsigned {
|
||||
const a: number = new math.Long().getLowBitsUnsigned();
|
||||
}
|
||||
|
||||
namespace getHighBitsUnsigned {
|
||||
const a: number = new math.Long().getHighBitsUnsigned();
|
||||
}
|
||||
|
||||
namespace getNumBitsAbs {
|
||||
const a: number = new math.Long().getNumBitsAbs();
|
||||
}
|
||||
|
||||
namespace isZero {
|
||||
const a: boolean = new math.Long().isZero();
|
||||
}
|
||||
|
||||
namespace isNegative {
|
||||
const a: boolean = new math.Long().isNegative();
|
||||
}
|
||||
|
||||
namespace isPositive {
|
||||
const a: boolean = new math.Long().isPositive();
|
||||
}
|
||||
|
||||
namespace isOdd {
|
||||
const a: boolean = new math.Long().isOdd();
|
||||
}
|
||||
|
||||
namespace isEven {
|
||||
const a: boolean = new math.Long().isEven();
|
||||
}
|
||||
|
||||
namespace equals {
|
||||
const a = new math.Long();
|
||||
const b: boolean = a.equals(new math.Long());
|
||||
const c: boolean = a.equals(1);
|
||||
const d: boolean = a.equals("1");
|
||||
const e: boolean = a.equals({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace lessThan {
|
||||
const a = new math.Long();
|
||||
const b: boolean = a.lessThan(new math.Long());
|
||||
const c: boolean = a.lessThan(1);
|
||||
const d: boolean = a.lessThan("1");
|
||||
const e: boolean = a.lessThan({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace lessThanOrEqual {
|
||||
const a = new math.Long();
|
||||
const b: boolean = a.lessThanOrEqual(new math.Long());
|
||||
const c: boolean = a.lessThanOrEqual(1);
|
||||
const d: boolean = a.lessThanOrEqual("1");
|
||||
const e: boolean = a.lessThanOrEqual({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace greaterThan {
|
||||
const a = new math.Long();
|
||||
const b: boolean = a.greaterThan(new math.Long());
|
||||
const c: boolean = a.greaterThan(1);
|
||||
const d: boolean = a.greaterThan("1");
|
||||
const e: boolean = a.greaterThan({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace greaterThanOrEqual {
|
||||
const a = new math.Long();
|
||||
const b: boolean = a.greaterThanOrEqual(new math.Long());
|
||||
const c: boolean = a.greaterThanOrEqual(1);
|
||||
const d: boolean = a.greaterThanOrEqual("1");
|
||||
const e: boolean = a.greaterThanOrEqual({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace compareTests {
|
||||
const a = new math.Long();
|
||||
const b: number = a.compare(new math.Long());
|
||||
const c: number = a.compare(1);
|
||||
const d: number = a.compare("1");
|
||||
const e: number = a.compare({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace negate {
|
||||
const a: adone.math.Long = new math.Long().negate();
|
||||
}
|
||||
|
||||
namespace add {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.add(new math.Long());
|
||||
const c: adone.math.Long = a.add(1);
|
||||
const d: adone.math.Long = a.add("1");
|
||||
const e: adone.math.Long = a.add({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace sub {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.sub(new math.Long());
|
||||
const c: adone.math.Long = a.sub(1);
|
||||
const d: adone.math.Long = a.sub("1");
|
||||
const e: adone.math.Long = a.sub({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace mul {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.mul(new math.Long());
|
||||
const c: adone.math.Long = a.mul(1);
|
||||
const d: adone.math.Long = a.mul("1");
|
||||
const e: adone.math.Long = a.mul({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace div {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.div(new math.Long());
|
||||
const c: adone.math.Long = a.div(1);
|
||||
const d: adone.math.Long = a.div("1");
|
||||
const e: adone.math.Long = a.div({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace mod {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.mod(new math.Long());
|
||||
const c: adone.math.Long = a.mod(1);
|
||||
const d: adone.math.Long = a.mod("1");
|
||||
const e: adone.math.Long = a.mod({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace not {
|
||||
const a: adone.math.Long = new math.Long().not();
|
||||
}
|
||||
|
||||
namespace and {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.and(new math.Long());
|
||||
const c: adone.math.Long = a.and(1);
|
||||
const d: adone.math.Long = a.and("1");
|
||||
const e: adone.math.Long = a.and({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace or {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.or(new math.Long());
|
||||
const c: adone.math.Long = a.or(1);
|
||||
const d: adone.math.Long = a.or("1");
|
||||
const e: adone.math.Long = a.or({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace xor {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.xor(new math.Long());
|
||||
const c: adone.math.Long = a.xor(1);
|
||||
const d: adone.math.Long = a.xor("1");
|
||||
const e: adone.math.Long = a.xor({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace shl {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.shl(new math.Long());
|
||||
const c: adone.math.Long = a.shl(1);
|
||||
}
|
||||
|
||||
namespace shr {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.shr(new math.Long());
|
||||
const c: adone.math.Long = a.shr(1);
|
||||
}
|
||||
|
||||
namespace shru {
|
||||
const a = new math.Long();
|
||||
const b: adone.math.Long = a.shr(new math.Long());
|
||||
const c: adone.math.Long = a.shr(1);
|
||||
}
|
||||
|
||||
namespace toSigned {
|
||||
const a: adone.math.Long = new math.Long().toSigned();
|
||||
}
|
||||
|
||||
namespace toUnsigned {
|
||||
const a: adone.math.Long = new math.Long().toUnsigned();
|
||||
}
|
||||
|
||||
namespace toBytes {
|
||||
const a: number[] = new math.Long().toBytes();
|
||||
}
|
||||
|
||||
namespace toBytesLE {
|
||||
const a: number[] = new math.Long().toBytesLE();
|
||||
}
|
||||
|
||||
namespace static {
|
||||
namespace fromInt {
|
||||
const a: adone.math.Long = math.Long.fromInt(123);
|
||||
const b: adone.math.Long = math.Long.fromInt(123, true);
|
||||
}
|
||||
|
||||
namespace fromNumber {
|
||||
const a: adone.math.Long = math.Long.fromNumber(123);
|
||||
const b: adone.math.Long = math.Long.fromNumber(123, true);
|
||||
}
|
||||
|
||||
namespace fromBits {
|
||||
const a: adone.math.Long = math.Long.fromBits(0, 0);
|
||||
const b: adone.math.Long = math.Long.fromBits(123, 0, true);
|
||||
}
|
||||
|
||||
namespace fromString {
|
||||
const a: adone.math.Long = math.Long.fromString("123");
|
||||
const b: adone.math.Long = math.Long.fromString("123", true);
|
||||
const c: adone.math.Long = math.Long.fromString("123", 16);
|
||||
const d: adone.math.Long = math.Long.fromString("123", true, 16);
|
||||
}
|
||||
|
||||
namespace fromValue {
|
||||
const a: adone.math.Long = math.Long.fromValue(new math.Long());
|
||||
const b: adone.math.Long = math.Long.fromValue(1);
|
||||
const c: adone.math.Long = math.Long.fromValue("1");
|
||||
const e: adone.math.Long = math.Long.fromValue({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace constants {
|
||||
const a: adone.math.Long = math.Long.MIN_VALUE;
|
||||
const b: adone.math.Long = math.Long.MAX_VALUE;
|
||||
const c: adone.math.Long = math.Long.MAX_UNSIGNED_VALUE;
|
||||
const d: adone.math.Long = math.Long.ZERO;
|
||||
const e: adone.math.Long = math.Long.UZERO;
|
||||
const f: adone.math.Long = math.Long.ONE;
|
||||
const g: adone.math.Long = math.Long.UONE;
|
||||
const h: adone.math.Long = math.Long.NEG_ONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace BigNumberTests {
|
||||
const { BigNumber } = math;
|
||||
type BigNumber = adone.math.BigNumber;
|
||||
|
||||
new BigNumber(10);
|
||||
new BigNumber("10");
|
||||
new BigNumber(new BigNumber(10));
|
||||
new BigNumber("10", 2);
|
||||
|
||||
{ const a: string = new BigNumber(1).toString(); }
|
||||
{ const a: string = new BigNumber(1).toString(2); }
|
||||
|
||||
{ const a: number = new BigNumber(1).toNumber(); }
|
||||
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer(); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({}); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: 1 }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: -1 }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: "big" }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ endian: "little" }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ size: 1 }); }
|
||||
{ const a: Buffer = new BigNumber(1).toBuffer({ size: "auto" }); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).add(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).add("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).add(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).sub(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).sub("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).sub(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).mul(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).mul("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).mul(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).div(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).div("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).div(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).abs(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).neg(); }
|
||||
|
||||
{ const a: number = new BigNumber(10).cmp(1); }
|
||||
{ const a: number = new BigNumber(10).cmp("1"); }
|
||||
{ const a: number = new BigNumber(10).cmp(new BigNumber(1)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).gt(1); }
|
||||
{ const a: boolean = new BigNumber(10).gt("1"); }
|
||||
{ const a: boolean = new BigNumber(10).gt(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).ge(1); }
|
||||
{ const a: boolean = new BigNumber(10).ge("1"); }
|
||||
{ const a: boolean = new BigNumber(10).ge(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).eq(1); }
|
||||
{ const a: boolean = new BigNumber(10).eq("1"); }
|
||||
{ const a: boolean = new BigNumber(10).eq(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).lt(1); }
|
||||
{ const a: boolean = new BigNumber(10).lt("1"); }
|
||||
{ const a: boolean = new BigNumber(10).lt(new BigNumber(10)); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).le(1); }
|
||||
{ const a: boolean = new BigNumber(10).le("1"); }
|
||||
{ const a: boolean = new BigNumber(10).le(new BigNumber(10)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).and(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).and("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).and(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).or(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).or("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).or(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).xor(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).xor("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).xor(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).mod(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).mod("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).mod(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).pow(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).pow("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).pow(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).powm(1, 1); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm("1", 1); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(new BigNumber(1), 1); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(1, "1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm("1", "1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(new BigNumber(1), "1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(1, new BigNumber(1)); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm("1", new BigNumber(1)); }
|
||||
{ const a: BigNumber = new BigNumber(10).powm(new BigNumber(1), new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).invertm(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).invertm("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).invertm(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).rand(); }
|
||||
{ const a: BigNumber = new BigNumber(10).rand(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).rand("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).rand(new BigNumber(1)); }
|
||||
|
||||
{ const a: boolean | "maybe" = new BigNumber(10).probPrime(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).nextPrime(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).sqrt(); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).root(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).root("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).root(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).shiftLeft(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftLeft("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftLeft(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).shiftRight(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftRight("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).shiftRight(new BigNumber(1)); }
|
||||
|
||||
{ const a: BigNumber = new BigNumber(10).gcd(1); }
|
||||
{ const a: BigNumber = new BigNumber(10).gcd("1"); }
|
||||
{ const a: BigNumber = new BigNumber(10).gcd(new BigNumber(1)); }
|
||||
|
||||
{ const a: number = new BigNumber(10).jacobi(1); }
|
||||
{ const a: number = new BigNumber(10).jacobi("1"); }
|
||||
{ const a: number = new BigNumber(10).jacobi(new BigNumber(1)); }
|
||||
|
||||
{ const a: number = new BigNumber(10).bitLength(); }
|
||||
|
||||
{ const a: boolean = new BigNumber(10).isBitSet(10); }
|
||||
|
||||
{ const a: BigNumber = BigNumber.prime(10); }
|
||||
{ const a: BigNumber = BigNumber.prime(10, true); }
|
||||
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10)); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: "little" }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: -1 }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: 1 }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { endian: "big" }); }
|
||||
{ const a: BigNumber = BigNumber.fromBuffer(Buffer.alloc(10), { size: "auto" }); }
|
||||
|
||||
{ const a: BigNumber = BigNumber.ONE; }
|
||||
{ const a: BigNumber = BigNumber.ZERO; }
|
||||
}
|
||||
|
||||
namespace bitSetTests {
|
||||
const { BitSet } = math;
|
||||
type BitSet = adone.math.BitSet;
|
||||
|
||||
new BitSet(10);
|
||||
new BitSet(new BitSet(10).dehydrate());
|
||||
|
||||
{ const a: boolean = new BitSet(10).get(0); }
|
||||
{ const a: boolean = new BitSet(10).set(0); }
|
||||
{ const a: boolean = new BitSet(10).setRange(0, 10); }
|
||||
{ const a: boolean = new BitSet(10).unset(0); }
|
||||
{ const a: boolean = new BitSet(10).unsetRange(0, 10); }
|
||||
{ const a: boolean = new BitSet(10).toggle(0); }
|
||||
{ const a: boolean = new BitSet(10).toggleRange(0, 10); }
|
||||
{ const a: boolean = new BitSet(10).clear(); }
|
||||
{ const a: BitSet = new BitSet(10).clone(); }
|
||||
{ const a: string = new BitSet(10).dehydrate(); }
|
||||
|
||||
{ const a: BitSet = new BitSet(10).and(1); }
|
||||
{ const a: BitSet = new BitSet(10).and(new BitSet(10)); }
|
||||
|
||||
{ const a: BitSet = new BitSet(10).or(1); }
|
||||
{ const a: BitSet = new BitSet(10).or(new BitSet(10)); }
|
||||
|
||||
{ const a: BitSet = new BitSet(10).xor(1); }
|
||||
{ const a: BitSet = new BitSet(10).xor(new BitSet(10)); }
|
||||
|
||||
new BitSet(10).forEach((x: number) => {});
|
||||
new BitSet(10).forEach((x: number) => false);
|
||||
|
||||
{ const a: BitSet = new BitSet(10).circularShift(10); }
|
||||
{ const a: number = new BitSet(10).getCardinality(); }
|
||||
{ const a: number[] = new BitSet(10).getIndices(); }
|
||||
{ const a: boolean = new BitSet(10).isSubsetOf(new BitSet(10)); }
|
||||
{ const a: boolean = new BitSet(10).isEmpty(); }
|
||||
{ const a: boolean = new BitSet(10).isEqual(new BitSet(10)); }
|
||||
{ const a: string = new BitSet(10).toString(); }
|
||||
{ const a: number = new BitSet(10).ffs(); }
|
||||
{ const a: number = new BitSet(10).ffs(1); }
|
||||
{ const a: number = new BitSet(10).ffz(); }
|
||||
{ const a: number = new BitSet(10).ffz(1); }
|
||||
{ const a: number = new BitSet(10).fls(); }
|
||||
{ const a: number = new BitSet(10).fls(1); }
|
||||
{ const a: number = new BitSet(10).flz(); }
|
||||
{ const a: number = new BitSet(10).flz(1); }
|
||||
{ const a: number = new BitSet(10).nextSetBit(1); }
|
||||
{ const a: number = new BitSet(10).nextUnsetBit(1); }
|
||||
{ const a: number = new BitSet(10).previousSetBit(1); }
|
||||
{ const a: number = new BitSet(10).previousUnsetBit(1); }
|
||||
{ const a: number = new BitSet(10).readUInt(); }
|
||||
{ const a: number = new BitSet(10).readUInt(1); }
|
||||
{ const a: number = new BitSet(10).readUInt(1, 2); }
|
||||
{ new BitSet(10).writeUInt(1); }
|
||||
{ new BitSet(10).writeUInt(1, 2); }
|
||||
{ new BitSet(10).writeUInt(1, 2, 3); }
|
||||
{ const a: BitSet = BitSet.fromLong(new adone.math.Long(10, 20)); }
|
||||
}
|
||||
const {
|
||||
math
|
||||
} = adone;
|
||||
|
||||
namespace randomTests {
|
||||
const { random } = math;
|
||||
@@ -471,4 +9,22 @@ namespace mathTests {
|
||||
random(100);
|
||||
random(0, 10);
|
||||
}
|
||||
|
||||
namespace maxTests {
|
||||
const { max } = math;
|
||||
max([]);
|
||||
{ const a: number = max([1, 2, 3]); }
|
||||
{ const a: string = max(["1", "2", "3"]); }
|
||||
{ const a: string = max(["1", "2", "3"], (a) => a.length); }
|
||||
{ const a: number = max([1, 2, 3], (a) => a.toExponential()); }
|
||||
}
|
||||
|
||||
namespace minTests {
|
||||
const { min } = math;
|
||||
min([]);
|
||||
{ const a: number = min([1, 2, 3]); }
|
||||
{ const a: string = min(["1", "2", "3"]); }
|
||||
{ const a: string = min(["1", "2", "3"], (a) => a.length); }
|
||||
{ const a: number = min([1, 2, 3], (a) => a.toExponential()); }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,261 @@
|
||||
namespace mathTests.longTests {
|
||||
const {
|
||||
math: {
|
||||
Long
|
||||
}
|
||||
} = adone;
|
||||
|
||||
new Long();
|
||||
new Long(0);
|
||||
new Long(0, 0);
|
||||
new Long(0, 0, true);
|
||||
|
||||
namespace toInt {
|
||||
const a: number = new Long().toInt();
|
||||
}
|
||||
|
||||
namespace toNumber {
|
||||
const a: number = new Long().toNumber();
|
||||
}
|
||||
|
||||
namespace toString {
|
||||
const a: string = new Long().toString();
|
||||
const b: string = new Long().toString(16);
|
||||
}
|
||||
|
||||
namespace getHighBits {
|
||||
const a: number = new Long().getHighBits();
|
||||
}
|
||||
|
||||
namespace getLowBits {
|
||||
const a: number = new Long().getLowBits();
|
||||
}
|
||||
|
||||
namespace getLowBitsUnsigned {
|
||||
const a: number = new Long().getLowBitsUnsigned();
|
||||
}
|
||||
|
||||
namespace getHighBitsUnsigned {
|
||||
const a: number = new Long().getHighBitsUnsigned();
|
||||
}
|
||||
|
||||
namespace getNumBitsAbs {
|
||||
const a: number = new Long().getNumBitsAbs();
|
||||
}
|
||||
|
||||
namespace isZero {
|
||||
const a: boolean = new Long().isZero();
|
||||
}
|
||||
|
||||
namespace isNegative {
|
||||
const a: boolean = new Long().isNegative();
|
||||
}
|
||||
|
||||
namespace isPositive {
|
||||
const a: boolean = new Long().isPositive();
|
||||
}
|
||||
|
||||
namespace isOdd {
|
||||
const a: boolean = new Long().isOdd();
|
||||
}
|
||||
|
||||
namespace isEven {
|
||||
const a: boolean = new Long().isEven();
|
||||
}
|
||||
|
||||
namespace equals {
|
||||
const a = new Long();
|
||||
const b: boolean = a.equals(new Long());
|
||||
const c: boolean = a.equals(1);
|
||||
const d: boolean = a.equals("1");
|
||||
const e: boolean = a.equals({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace lessThan {
|
||||
const a = new Long();
|
||||
const b: boolean = a.lessThan(new Long());
|
||||
const c: boolean = a.lessThan(1);
|
||||
const d: boolean = a.lessThan("1");
|
||||
const e: boolean = a.lessThan({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace lessThanOrEqual {
|
||||
const a = new Long();
|
||||
const b: boolean = a.lessThanOrEqual(new Long());
|
||||
const c: boolean = a.lessThanOrEqual(1);
|
||||
const d: boolean = a.lessThanOrEqual("1");
|
||||
const e: boolean = a.lessThanOrEqual({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace greaterThan {
|
||||
const a = new Long();
|
||||
const b: boolean = a.greaterThan(new Long());
|
||||
const c: boolean = a.greaterThan(1);
|
||||
const d: boolean = a.greaterThan("1");
|
||||
const e: boolean = a.greaterThan({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace greaterThanOrEqual {
|
||||
const a = new Long();
|
||||
const b: boolean = a.greaterThanOrEqual(new Long());
|
||||
const c: boolean = a.greaterThanOrEqual(1);
|
||||
const d: boolean = a.greaterThanOrEqual("1");
|
||||
const e: boolean = a.greaterThanOrEqual({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace compareTests {
|
||||
const a = new Long();
|
||||
const b: number = a.compare(new Long());
|
||||
const c: number = a.compare(1);
|
||||
const d: number = a.compare("1");
|
||||
const e: number = a.compare({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace negate {
|
||||
const a: adone.math.Long = new Long().negate();
|
||||
}
|
||||
|
||||
namespace add {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.add(new Long());
|
||||
const c: adone.math.Long = a.add(1);
|
||||
const d: adone.math.Long = a.add("1");
|
||||
const e: adone.math.Long = a.add({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace sub {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.sub(new Long());
|
||||
const c: adone.math.Long = a.sub(1);
|
||||
const d: adone.math.Long = a.sub("1");
|
||||
const e: adone.math.Long = a.sub({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace mul {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.mul(new Long());
|
||||
const c: adone.math.Long = a.mul(1);
|
||||
const d: adone.math.Long = a.mul("1");
|
||||
const e: adone.math.Long = a.mul({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace div {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.div(new Long());
|
||||
const c: adone.math.Long = a.div(1);
|
||||
const d: adone.math.Long = a.div("1");
|
||||
const e: adone.math.Long = a.div({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace mod {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.mod(new Long());
|
||||
const c: adone.math.Long = a.mod(1);
|
||||
const d: adone.math.Long = a.mod("1");
|
||||
const e: adone.math.Long = a.mod({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace not {
|
||||
const a: adone.math.Long = new Long().not();
|
||||
}
|
||||
|
||||
namespace and {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.and(new Long());
|
||||
const c: adone.math.Long = a.and(1);
|
||||
const d: adone.math.Long = a.and("1");
|
||||
const e: adone.math.Long = a.and({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace or {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.or(new Long());
|
||||
const c: adone.math.Long = a.or(1);
|
||||
const d: adone.math.Long = a.or("1");
|
||||
const e: adone.math.Long = a.or({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace xor {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.xor(new Long());
|
||||
const c: adone.math.Long = a.xor(1);
|
||||
const d: adone.math.Long = a.xor("1");
|
||||
const e: adone.math.Long = a.xor({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace shl {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.shl(new Long());
|
||||
const c: adone.math.Long = a.shl(1);
|
||||
}
|
||||
|
||||
namespace shr {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.shr(new Long());
|
||||
const c: adone.math.Long = a.shr(1);
|
||||
}
|
||||
|
||||
namespace shru {
|
||||
const a = new Long();
|
||||
const b: adone.math.Long = a.shr(new Long());
|
||||
const c: adone.math.Long = a.shr(1);
|
||||
}
|
||||
|
||||
namespace toSigned {
|
||||
const a: adone.math.Long = new Long().toSigned();
|
||||
}
|
||||
|
||||
namespace toUnsigned {
|
||||
const a: adone.math.Long = new Long().toUnsigned();
|
||||
}
|
||||
|
||||
namespace toBytes {
|
||||
const a: number[] = new Long().toBytes();
|
||||
}
|
||||
|
||||
namespace toBytesLE {
|
||||
const a: number[] = new Long().toBytesLE();
|
||||
}
|
||||
|
||||
namespace static {
|
||||
namespace fromInt {
|
||||
const a: adone.math.Long = Long.fromInt(123);
|
||||
const b: adone.math.Long = Long.fromInt(123, true);
|
||||
}
|
||||
|
||||
namespace fromNumber {
|
||||
const a: adone.math.Long = Long.fromNumber(123);
|
||||
const b: adone.math.Long = Long.fromNumber(123, true);
|
||||
}
|
||||
|
||||
namespace fromBits {
|
||||
const a: adone.math.Long = Long.fromBits(0, 0);
|
||||
const b: adone.math.Long = Long.fromBits(123, 0, true);
|
||||
}
|
||||
|
||||
namespace fromString {
|
||||
const a: adone.math.Long = Long.fromString("123");
|
||||
const b: adone.math.Long = Long.fromString("123", true);
|
||||
const c: adone.math.Long = Long.fromString("123", 16);
|
||||
const d: adone.math.Long = Long.fromString("123", true, 16);
|
||||
}
|
||||
|
||||
namespace fromValue {
|
||||
const a: adone.math.Long = Long.fromValue(new Long());
|
||||
const b: adone.math.Long = Long.fromValue(1);
|
||||
const c: adone.math.Long = Long.fromValue("1");
|
||||
const e: adone.math.Long = Long.fromValue({ low: 0, high: 0 });
|
||||
}
|
||||
|
||||
namespace constants {
|
||||
const a: adone.math.Long = Long.MIN_VALUE;
|
||||
const b: adone.math.Long = Long.MAX_VALUE;
|
||||
const c: adone.math.Long = Long.MAX_UNSIGNED_VALUE;
|
||||
const d: adone.math.Long = Long.ZERO;
|
||||
const e: adone.math.Long = Long.UZERO;
|
||||
const f: adone.math.Long = Long.ONE;
|
||||
const g: adone.math.Long = Long.UONE;
|
||||
const h: adone.math.Long = Long.NEG_ONE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,11 @@ namespace adoneTests.regex {
|
||||
regex.filename().test("a");
|
||||
regex.idn().test("a");
|
||||
regex.ip4().test("a");
|
||||
regex.ip4({ exact: true }).test("a");
|
||||
regex.ip6().test("a");
|
||||
regex.ip6({ exact: true }).test("a");
|
||||
regex.ip().test("a");
|
||||
regex.ip({ exact: true }).test("a");
|
||||
regex.protocol().test("a");
|
||||
regex.punycode().test("a");
|
||||
regex.shebang().test("a");
|
||||
|
||||
@@ -65,4 +65,9 @@ namespace AdoneRootTests {
|
||||
const b = new adone.benchmark.Benchmark.Suite();
|
||||
b.add(() => {}).add("", () => {}).run();
|
||||
}
|
||||
|
||||
namespace asyncTests {
|
||||
adone.async.all([], () => {});
|
||||
adone.async.forEach([], () => {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,9 @@
|
||||
"files": [
|
||||
"adone-tests.ts",
|
||||
"adone.d.ts",
|
||||
"async.d.ts",
|
||||
"benchmark.d.ts",
|
||||
"glosses/app.d.ts",
|
||||
"glosses/archives.d.ts",
|
||||
"glosses/assertion.d.ts",
|
||||
"glosses/collections/array_set.d.ts",
|
||||
@@ -44,7 +46,7 @@
|
||||
"glosses/collections/refcounted_cache.d.ts",
|
||||
"glosses/collections/set.d.ts",
|
||||
"glosses/collections/stack.d.ts",
|
||||
"glosses/collections/timedout_map.d.ts",
|
||||
"glosses/collections/time_map.d.ts",
|
||||
"glosses/compressors.d.ts",
|
||||
"glosses/crypto/asn1.d.ts",
|
||||
"glosses/crypto/ed25519.d.ts",
|
||||
@@ -58,7 +60,11 @@
|
||||
"glosses/fast.d.ts",
|
||||
"glosses/fs.d.ts",
|
||||
"glosses/is.d.ts",
|
||||
"glosses/math/bignumber.d.ts",
|
||||
"glosses/math/bitset.d.ts",
|
||||
"glosses/math/decimal.d.ts",
|
||||
"glosses/math/index.d.ts",
|
||||
"glosses/math/long.d.ts",
|
||||
"glosses/math/matrix.d.ts",
|
||||
"glosses/math/simd.d.ts",
|
||||
"glosses/meta.d.ts",
|
||||
@@ -90,7 +96,7 @@
|
||||
"glosses/utils.d.ts",
|
||||
"glosses/vault.d.ts",
|
||||
"index.d.ts",
|
||||
"test/glosses/application.ts",
|
||||
"test/glosses/app.ts",
|
||||
"test/glosses/archives.ts",
|
||||
"test/glosses/assertion.ts",
|
||||
"test/glosses/collections/array_set.ts",
|
||||
@@ -111,7 +117,7 @@
|
||||
"test/glosses/collections/refcounted_cache.ts",
|
||||
"test/glosses/collections/set.ts",
|
||||
"test/glosses/collections/stack.ts",
|
||||
"test/glosses/collections/timedout_map.ts",
|
||||
"test/glosses/collections/time_map.ts",
|
||||
"test/glosses/compressors.ts",
|
||||
"test/glosses/crypto/asn1.ts",
|
||||
"test/glosses/crypto/ed25519.ts",
|
||||
@@ -124,7 +130,11 @@
|
||||
"test/glosses/fast.ts",
|
||||
"test/glosses/fs.ts",
|
||||
"test/glosses/is.ts",
|
||||
"test/glosses/math/bignumber.ts",
|
||||
"test/glosses/math/bitset.ts",
|
||||
"test/glosses/math/decimal.ts",
|
||||
"test/glosses/math/index.ts",
|
||||
"test/glosses/math/long.ts",
|
||||
"test/glosses/math/matrix.ts",
|
||||
"test/glosses/math/simd.ts",
|
||||
"test/glosses/meta.ts",
|
||||
|
||||
@@ -21,9 +21,9 @@ type MyEntity = AFrame.Entity<{
|
||||
material: THREE.Material;
|
||||
sound: { pause(): void };
|
||||
}>;
|
||||
const camera = document.querySelector<MyEntity>('a-entity[camera]').components.camera;
|
||||
const material = document.querySelector<MyEntity>('a-entity[material]').components.material;
|
||||
document.querySelector<MyEntity>('a-entity[sound]').components.sound.pause();
|
||||
const camera = (document.querySelector('a-entity[camera]') as MyEntity).components.camera;
|
||||
const material = (document.querySelector('a-entity[material]') as MyEntity).components.material;
|
||||
(document.querySelector('a-entity[sound]') as MyEntity).components.sound.pause();
|
||||
|
||||
entity.getDOMAttribute('geometry').primitive;
|
||||
|
||||
@@ -38,21 +38,82 @@ entity.addEventListener('child-detached', (event) => {
|
||||
});
|
||||
|
||||
// Components
|
||||
const Component = AFRAME.registerComponent('test', {});
|
||||
|
||||
interface TestComponent extends AFrame.Component {
|
||||
multiply: (f: number) => number;
|
||||
|
||||
data: {
|
||||
myProperty: any[],
|
||||
string: string,
|
||||
num: number
|
||||
};
|
||||
|
||||
system: TestSystem;
|
||||
}
|
||||
|
||||
const Component = AFRAME.registerComponent<TestComponent>('test-component', {
|
||||
schema: {
|
||||
myProperty: {
|
||||
default: [],
|
||||
parse() { return [true]; },
|
||||
},
|
||||
string: { type: 'string' },
|
||||
num: 0
|
||||
},
|
||||
init() {
|
||||
this.data.num = 0;
|
||||
},
|
||||
update() {},
|
||||
tick() {},
|
||||
remove() {},
|
||||
pause() {},
|
||||
play() {},
|
||||
|
||||
multiply(this: TestComponent, f: number) {
|
||||
// Reference to system because both were registered with the same name.
|
||||
return f * this.data.num * this.system.data.counter;
|
||||
}
|
||||
});
|
||||
|
||||
// Scene
|
||||
const scene = document.querySelector('a-scene');
|
||||
scene.hasLoaded;
|
||||
|
||||
// System
|
||||
const system = scene.systems['systemName'];
|
||||
|
||||
interface TestSystem extends AFrame.System {
|
||||
data: {
|
||||
counter: number;
|
||||
};
|
||||
}
|
||||
|
||||
const testSystem: AFrame.SystemDefinition<TestSystem> = {
|
||||
schema: {
|
||||
counter: 0
|
||||
},
|
||||
|
||||
init() {
|
||||
this.data.counter = 1;
|
||||
}
|
||||
};
|
||||
|
||||
AFRAME.registerSystem('test-component', testSystem);
|
||||
|
||||
// Register Custom Geometry
|
||||
AFRAME.registerGeometry('a-test-geometry', {
|
||||
|
||||
interface TestGeometry extends AFrame.Geometry {
|
||||
schema: AFrame.MultiPropertySchema<{
|
||||
groupIndex: number;
|
||||
}>;
|
||||
}
|
||||
|
||||
AFRAME.registerGeometry<TestGeometry>('a-test-geometry', {
|
||||
schema: {
|
||||
groupIndex: { default: 0 }
|
||||
},
|
||||
init(data) {
|
||||
this.geometry = new THREE.Geometry();
|
||||
const temp = data.groupIndex;
|
||||
temp;
|
||||
}
|
||||
});
|
||||
|
||||
Vendored
+93
-78
@@ -2,6 +2,7 @@
|
||||
// Project: https://aframe.io/
|
||||
// Definitions by: Paul Shannon <https://github.com/devpaul>
|
||||
// Roberto Ritger <https://github.com/bertoritger>
|
||||
// Trygve Wastvedt <https://github.com/twastvedt>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -19,7 +20,7 @@ declare var hasNativeWebVRImplementation: boolean;
|
||||
interface Document {
|
||||
createElement(tagName: string): AFrame.Entity;
|
||||
querySelector(selectors: 'a-scene'): AFrame.Scene;
|
||||
querySelector<T extends AFrame.Entity<any>>(selectors: string): T;
|
||||
querySelector(selectors: string): AFrame.Entity<any>;
|
||||
querySelectorAll(selectors: string): NodeListOf<AFrame.Entity<any> | Element>;
|
||||
}
|
||||
|
||||
@@ -36,15 +37,15 @@ declare namespace AFrame {
|
||||
components: { [ key: string ]: ComponentDescriptor };
|
||||
geometries: { [ key: string ]: GeometryDescriptor };
|
||||
primitives: { [ key: string ]: Entity };
|
||||
registerComponent(name: string, component: ComponentDefinition): ComponentConstructor;
|
||||
registerComponent<T extends Component>(name: string, component: ComponentDefinition<T>): ComponentConstructor<T>;
|
||||
registerElement(name: string, element: ANode): void;
|
||||
registerGeometry(name: string, geometry: GeometryDefinition): Geometry;
|
||||
registerGeometry<T extends Geometry>(name: string, geometry: GeometryDefinition<T>): GeometryConstructor<T>;
|
||||
registerPrimitive(name: string, primitive: PrimitiveDefinition): void;
|
||||
registerShader(name: string, shader: any): void;
|
||||
registerSystem(name: string, definition: SystemDefinition): void;
|
||||
registerShader<T extends Shader>(name: string, shader: T): ShaderConstructor<T>;
|
||||
registerSystem<T extends System>(name: string, definition: SystemDefinition<T>): SystemConstructor<T>;
|
||||
schema: SchemaUtils;
|
||||
shaders: { [ key: string ]: ShaderDescriptor };
|
||||
systems: { [key: string]: System };
|
||||
systems: { [key: string]: SystemConstructor };
|
||||
THREE: typeof THREE;
|
||||
TWEEN: typeof TWEEN;
|
||||
utils: Utils;
|
||||
@@ -89,54 +90,39 @@ declare namespace AFrame {
|
||||
tick(): void;
|
||||
}
|
||||
|
||||
interface Component {
|
||||
interface Component<T extends { [key: string]: any } = any, S extends System = System> {
|
||||
attrName?: string;
|
||||
data?: any;
|
||||
data: T;
|
||||
dependencies?: string[];
|
||||
el: Entity;
|
||||
id: string;
|
||||
multiple?: boolean;
|
||||
name: string;
|
||||
schema: Schema;
|
||||
schema: Schema<T>;
|
||||
system: S | undefined;
|
||||
|
||||
init(data?: any): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
remove(): void;
|
||||
tick?(time: number, timeDelta: number): void;
|
||||
update(oldData: any): void;
|
||||
updateSchema?(): void;
|
||||
init(this: this, data?: T): void;
|
||||
pause(this: this): void;
|
||||
play(this: this): void;
|
||||
remove(this: this): void;
|
||||
tick?(this: this, time: number, timeDelta: number): void;
|
||||
update(this: this, oldData: T): void;
|
||||
updateSchema?(this: this): void;
|
||||
|
||||
extendSchema(update: Schema): void;
|
||||
flushToDOM(): void;
|
||||
extendSchema(this: this, update: Schema): void;
|
||||
flushToDOM(this: this): void;
|
||||
}
|
||||
|
||||
interface ComponentConstructor {
|
||||
new (el: Entity, name: string, id: string): Component;
|
||||
interface ComponentConstructor<T extends Component> {
|
||||
new (el: Entity, attrValue: string, id: string): T;
|
||||
}
|
||||
|
||||
interface ComponentDefinition {
|
||||
dependencies?: string[];
|
||||
el?: Entity;
|
||||
id?: string;
|
||||
multiple?: boolean;
|
||||
schema?: Schema;
|
||||
type ComponentDefinition<T extends Component = Component> = Partial<T>;
|
||||
|
||||
init?(data?: any): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
remove?(): void;
|
||||
tick?(time: number, timeDelta: number): void;
|
||||
update?(oldData: any): void;
|
||||
updateSchema?(): void;
|
||||
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface ComponentDescriptor {
|
||||
Component: Component;
|
||||
dependencies: string[] | null;
|
||||
multiple: boolean | null;
|
||||
interface ComponentDescriptor<T extends Component = Component> {
|
||||
Component: ComponentConstructor<T>;
|
||||
dependencies: string[] | undefined;
|
||||
multiple: boolean | undefined;
|
||||
|
||||
// internal APIs2
|
||||
// parse
|
||||
@@ -144,7 +130,6 @@ declare namespace AFrame {
|
||||
// schema
|
||||
// stringify
|
||||
// type
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface Coordinate {
|
||||
@@ -153,8 +138,14 @@ declare namespace AFrame {
|
||||
z: number;
|
||||
}
|
||||
|
||||
interface DefaultComponents {
|
||||
position: Component<Coordinate>;
|
||||
rotation: Component<Coordinate>;
|
||||
scale: Component<Coordinate>;
|
||||
}
|
||||
|
||||
interface Entity<C = ObjectMap<Component>> extends ANode {
|
||||
components: C;
|
||||
components: C & DefaultComponents;
|
||||
isPlaying: boolean;
|
||||
object3D: THREE.Object3D;
|
||||
object3DMap: ObjectMap<THREE.Object3D>;
|
||||
@@ -165,8 +156,8 @@ declare namespace AFrame {
|
||||
/**
|
||||
* @deprecated since 0.4.0
|
||||
*/
|
||||
getComputedAttribute<T = Component>(attr: string): T;
|
||||
getDOMAttribute<T = any>(attr: string): T;
|
||||
getComputedAttribute(attr: string): Component;
|
||||
getDOMAttribute(attr: string): any;
|
||||
getObject3D(type: string): THREE.Object3D;
|
||||
getOrCreateObject3D(type: string, construct: any): THREE.Object3D;
|
||||
is(stateName: string): boolean;
|
||||
@@ -179,7 +170,6 @@ declare namespace AFrame {
|
||||
|
||||
// getAttribute specific usages
|
||||
getAttribute(type: string): any;
|
||||
getAttribute<T = Component>(attr: string): T;
|
||||
getAttribute(type: 'position' | 'rotation' | 'scale'): Coordinate;
|
||||
|
||||
// setAttribute specific usages
|
||||
@@ -192,12 +182,18 @@ declare namespace AFrame {
|
||||
addEventListener(type: string, listener: EventListenerOrEventListenerObject, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
type DetailEvent<D> = Event & { detail: D };
|
||||
type DetailEvent<D> = Event & {
|
||||
detail: D;
|
||||
target: EventTarget & Entity;
|
||||
};
|
||||
|
||||
interface EntityEventMap {
|
||||
'child-attached': DetailEvent<{ el: Element | Entity }>;
|
||||
'child-detached': DetailEvent<{ el: Element | Entity }>;
|
||||
'componentchanged': DetailEvent<{ name: string }>;
|
||||
'componentchanged': DetailEvent<{
|
||||
name: string,
|
||||
id: string
|
||||
}>;
|
||||
'componentremoved': DetailEvent<{
|
||||
name: string,
|
||||
id: string,
|
||||
@@ -215,23 +211,28 @@ declare namespace AFrame {
|
||||
interface Geometry {
|
||||
name: string;
|
||||
geometry: THREE.Geometry;
|
||||
schema: Schema;
|
||||
update(data: object): void;
|
||||
[ key: string ]: any;
|
||||
schema: Schema<any>;
|
||||
|
||||
init(this: this, data: { [P in keyof this['schema']]: any }): void;
|
||||
// Would like the above to be:
|
||||
// init?(this: this, data?: { [P in keyof T['schema']]: T['schema'][P]['default'] } ): void;
|
||||
// I think this is prevented by the following issue: https://github.com/Microsoft/TypeScript/issues/21760.
|
||||
}
|
||||
|
||||
interface GeometryDefinition extends ComponentDefinition {
|
||||
geometry?: THREE.Geometry;
|
||||
interface GeometryConstructor<T extends Geometry> {
|
||||
new (): T;
|
||||
}
|
||||
|
||||
interface GeometryDescriptor {
|
||||
Geometry: Geometry;
|
||||
type GeometryDefinition<T extends Geometry = Geometry> = Partial<T>;
|
||||
|
||||
interface GeometryDescriptor<T extends Geometry = Geometry> {
|
||||
Geometry: GeometryConstructor<T>;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
interface MultiPropertySchema {
|
||||
[ key: string ]: SinglePropertySchema<any>;
|
||||
}
|
||||
type MultiPropertySchema<T extends { [key: string ]: any }> = {
|
||||
[P in keyof T]: SinglePropertySchema<T[P]> | T[P];
|
||||
};
|
||||
|
||||
interface PrimitiveDefinition {
|
||||
defaultComponents?: any; // TODO cleanup type
|
||||
@@ -240,8 +241,9 @@ declare namespace AFrame {
|
||||
transforms?: any; // TODO cleanup type
|
||||
}
|
||||
|
||||
type PropertyTypes = 'array' | 'boolean' | 'color' | 'int' | 'number' | 'selector' |
|
||||
'selectorAll' | 'src' | 'string' | 'vec2' | 'vec3' | 'vec4';
|
||||
type PropertyTypes = 'array' | 'asset' | 'audio' | 'boolean' | 'color' |
|
||||
'int' | 'map' | 'model' | 'number' | 'selector' | 'selectorAll' |
|
||||
'string' | 'vec2' | 'vec3' | 'vec4';
|
||||
|
||||
type SceneEvents = 'enter-vr' | 'exit-vr' | 'loaded' | 'renderstart';
|
||||
|
||||
@@ -265,7 +267,7 @@ declare namespace AFrame {
|
||||
addEventListener(type: SceneEvents, listener: EventListener, useCapture?: boolean): void;
|
||||
}
|
||||
|
||||
type Schema = SinglePropertySchema<any> | MultiPropertySchema;
|
||||
type Schema<T = { [key: string]: any }> = SinglePropertySchema<T> | MultiPropertySchema<T>;
|
||||
|
||||
interface SchemaUtils {
|
||||
isSingleProperty(schema: Schema): boolean;
|
||||
@@ -274,11 +276,25 @@ declare namespace AFrame {
|
||||
|
||||
interface Shader {
|
||||
name: string;
|
||||
schema: Schema;
|
||||
data: { [key: string]: any };
|
||||
schema: Schema<this['data']>;
|
||||
material: THREE.Material;
|
||||
vertexShader: string;
|
||||
fragmentShader: string;
|
||||
|
||||
init(this: this, data?: this['data']): void;
|
||||
tick?(this: this, time: number, timeDelta: number): void;
|
||||
update(this: this, oldData: this['data']): void;
|
||||
}
|
||||
|
||||
interface ShaderDescriptor {
|
||||
Shader: Shader;
|
||||
interface ShaderConstructor<T extends Shader> {
|
||||
new (): T;
|
||||
}
|
||||
|
||||
type ShaderDefinition<T extends Shader = Shader> = Partial<T>;
|
||||
|
||||
interface ShaderDescriptor<T extends Shader = Shader> {
|
||||
Shader: ShaderConstructor<T>;
|
||||
schema: Schema;
|
||||
}
|
||||
|
||||
@@ -287,27 +303,23 @@ declare namespace AFrame {
|
||||
'default'?: T;
|
||||
parse?(value: string): T;
|
||||
stringify?(value: T): string;
|
||||
[ key: string ]: any;
|
||||
}
|
||||
|
||||
interface System {
|
||||
data: any;
|
||||
schema: Schema;
|
||||
init(): void;
|
||||
pause(): void;
|
||||
play(): void;
|
||||
tick?(): void;
|
||||
data: { [key: string]: any };
|
||||
schema: Schema<this['data']>;
|
||||
init(this: this): void;
|
||||
pause(this: this): void;
|
||||
play(this: this): void;
|
||||
tick?(this: this, t: number, dt: number): void;
|
||||
}
|
||||
|
||||
interface SystemDefinition {
|
||||
schema?: Schema;
|
||||
init?(): void;
|
||||
pause?(): void;
|
||||
play?(): void;
|
||||
tick?(): void;
|
||||
[ key: string ]: any;
|
||||
interface SystemConstructor<T extends System = System> {
|
||||
new (scene: Scene): T;
|
||||
}
|
||||
|
||||
type SystemDefinition<T extends System = System> = Partial<T>;
|
||||
|
||||
interface Utils {
|
||||
coordinates: {
|
||||
isCoordinate(value: string): boolean;
|
||||
@@ -326,5 +338,8 @@ declare namespace AFrame {
|
||||
diff(a: object, b: object): object;
|
||||
extend(target: object, ... source: object[]): object;
|
||||
extendDeep(target: object, ... source: object[]): object;
|
||||
|
||||
throttle(tickFunction: () => void, minimumInterval: number, optionalContext?: {}): (t: number, dt: number) => void;
|
||||
throttleTick(tickFunction: (t: number, dt: number) => void, minimumInterval: number, optionalContext?: {}): (t: number, dt: number) => void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"no-unnecessary-generics": false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ var mongoConnectionString = "mongodb://127.0.0.1/agenda";
|
||||
|
||||
var agenda = new Agenda({ db: { address: mongoConnectionString } });
|
||||
|
||||
agenda.define('delete old users', (job, done) => {
|
||||
|
||||
agenda.define<{ foo: Error }>('delete old users', (job, done) => {
|
||||
done(job.attrs.data.foo)
|
||||
});
|
||||
|
||||
agenda.on('ready', () => {
|
||||
@@ -62,7 +62,7 @@ agenda.schedule('tomorrow at noon', ['printAnalyticsReport', 'sendNotifications'
|
||||
|
||||
agenda.now('do the hokey pokey');
|
||||
|
||||
var job = agenda.create('printAnalyticsReport', { userCount: 100 });
|
||||
var job = agenda.create<{ userCount: number }>('printAnalyticsReport', { userCount: 100 });
|
||||
job.save(function(err) {
|
||||
console.log("Job successfully saved");
|
||||
});
|
||||
|
||||
Vendored
+31
-26
@@ -1,6 +1,7 @@
|
||||
// Type definitions for Agenda v1.0.0
|
||||
// Project: https://github.com/rschmukler/agenda
|
||||
// Type definitions for Agenda v1.0.3
|
||||
// Project: https://github.com/agenda/agenda
|
||||
// Definitions by: Meir Gottlieb <https://github.com/meirgottlieb>
|
||||
// Jeff Principe <https://github.com/princjef>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -89,14 +90,14 @@ declare class Agenda extends EventEmitter {
|
||||
* @param name The name of the job.
|
||||
* @param data Data to associated with the job.
|
||||
*/
|
||||
create(name: string, data?: any): Agenda.Job;
|
||||
create<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(name: string, data?: T): Agenda.Job<T>;
|
||||
|
||||
/**
|
||||
* Find all Jobs matching `query` and pass same back in cb().
|
||||
* @param query
|
||||
* @param cb
|
||||
*/
|
||||
jobs(query: any, cb: ResultCallback<Agenda.Job[]>): void;
|
||||
jobs<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(query: any, cb: ResultCallback<Agenda.Job<T>[]>): void;
|
||||
|
||||
/**
|
||||
* Removes all jobs in the database without defined behaviors. Useful if you change a definition name and want
|
||||
@@ -113,8 +114,8 @@ declare class Agenda extends EventEmitter {
|
||||
* @param options The options for the job.
|
||||
* @param handler The handler to execute.
|
||||
*/
|
||||
define(name: string, handler: (job: Agenda.Job, done: (err?: Error) => void) => void): void;
|
||||
define(name: string, options: Agenda.JobOptions, handler: (job: Agenda.Job, done: (err?: Error) => void) => void): void;
|
||||
define<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(name: string, handler: (job: Agenda.Job<T>, done: (err?: Error) => void) => void): void;
|
||||
define<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(name: string, options: Agenda.JobOptions, handler: (job: Agenda.Job<T>, done: (err?: Error) => void) => void): void;
|
||||
|
||||
/**
|
||||
* Runs job name at the given interval. Optionally, data and options can be passed in.
|
||||
@@ -124,8 +125,8 @@ declare class Agenda extends EventEmitter {
|
||||
* @param options An optional argument that will be passed to job.repeatEvery.
|
||||
* @param cb An optional callback function which will be called when the job has been persisted in the database.
|
||||
*/
|
||||
every(interval: number | string, names: string, data?: any, options?: any, cb?: ResultCallback<Agenda.Job>): Agenda.Job;
|
||||
every(interval: number | string, names: string[], data?: any, options?: any, cb?: ResultCallback<Agenda.Job[]>): Agenda.Job[];
|
||||
every<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(interval: number | string, names: string, data?: T, options?: any, cb?: ResultCallback<Agenda.Job<T>>): Agenda.Job<T>;
|
||||
every<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(interval: number | string, names: string[], data?: T, options?: any, cb?: ResultCallback<Agenda.Job<T>[]>): Agenda.Job<T>[];
|
||||
|
||||
/**
|
||||
* Schedules a job to run name once at a given time.
|
||||
@@ -134,8 +135,8 @@ declare class Agenda extends EventEmitter {
|
||||
* @param data An optional argument that will be passed to the processing function under job.attrs.data.
|
||||
* @param cb An optional callback function which will be called when the job has been persisted in the database.
|
||||
*/
|
||||
schedule(when: Date | string, names: string, data?: any, cb?: ResultCallback<Agenda.Job>): Agenda.Job;
|
||||
schedule(when: Date | string, names: string[], data?: any, cb?: ResultCallback<Agenda.Job[]>): Agenda.Job[];
|
||||
schedule<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(when: Date | string, names: string, data?: T, cb?: ResultCallback<Agenda.Job<T>>): Agenda.Job<T>;
|
||||
schedule<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(when: Date | string, names: string[], data?: T, cb?: ResultCallback<Agenda.Job<T>[]>): Agenda.Job<T>[];
|
||||
|
||||
/**
|
||||
* Schedules a job to run name once immediately.
|
||||
@@ -143,7 +144,7 @@ declare class Agenda extends EventEmitter {
|
||||
* @param data An optional argument that will be passed to the processing function under job.attrs.data.
|
||||
* @param cb An optional callback function which will be called when the job has been persisted in the database.
|
||||
*/
|
||||
now(name: string, data?: any, cb?: ResultCallback<Agenda.Job>): Agenda.Job;
|
||||
now<T extends Agenda.JobAttributesData = Agenda.JobAttributesData>(name: string, data?: T, cb?: ResultCallback<Agenda.Job<T>>): Agenda.Job<T>;
|
||||
|
||||
/**
|
||||
* Cancels any jobs matching the passed mongodb-native query, and removes them from the database.
|
||||
@@ -242,10 +243,14 @@ declare namespace Agenda {
|
||||
}
|
||||
}
|
||||
|
||||
interface JobAttributesData {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* The database record associated with a job.
|
||||
*/
|
||||
interface JobAttributes {
|
||||
interface JobAttributes<T extends JobAttributesData = JobAttributesData> {
|
||||
/**
|
||||
* The record identity.
|
||||
*/
|
||||
@@ -264,7 +269,7 @@ declare namespace Agenda {
|
||||
/**
|
||||
* The job details.
|
||||
*/
|
||||
data: { [name: string]: any };
|
||||
data: T;
|
||||
|
||||
/**
|
||||
* The priority of the job.
|
||||
@@ -330,12 +335,12 @@ declare namespace Agenda {
|
||||
/**
|
||||
* A scheduled job.
|
||||
*/
|
||||
interface Job {
|
||||
interface Job<T extends JobAttributesData = JobAttributesData> {
|
||||
|
||||
/**
|
||||
* The database record associated with the job.
|
||||
*/
|
||||
attrs: JobAttributes;
|
||||
attrs: JobAttributes<T>;
|
||||
|
||||
/**
|
||||
* The agenda that created the job.
|
||||
@@ -348,54 +353,54 @@ declare namespace Agenda {
|
||||
* @param options An optional argument that can include a timezone field. The timezone should be a string as
|
||||
* accepted by moment-timezone and is considered when using an interval in the cron string format.
|
||||
*/
|
||||
repeatEvery(interval: string | number, options?: { timezone?: string }): Job
|
||||
repeatEvery(interval: string | number, options?: { timezone?: string }): Job<T>
|
||||
|
||||
/**
|
||||
* Specifies a time when the job should repeat. [Possible values](https://github.com/matthewmueller/date#examples).
|
||||
* @param time
|
||||
*/
|
||||
repeatAt(time: string): Job
|
||||
repeatAt(time: string): Job<T>
|
||||
|
||||
/**
|
||||
* Disables the job.
|
||||
*/
|
||||
disable(): Job;
|
||||
disable(): Job<T>;
|
||||
|
||||
/**
|
||||
* Enables the job.
|
||||
*/
|
||||
enable(): Job;
|
||||
enable(): Job<T>;
|
||||
|
||||
/**
|
||||
* Ensure that only one instance of this job exists with the specified properties
|
||||
* @param value The properties associated with the job that must be unqiue.
|
||||
* @param opts
|
||||
*/
|
||||
unique(value: any, opts?: { insertOnly?: boolean }): Job;
|
||||
unique(value: any, opts?: { insertOnly?: boolean }): Job<T>;
|
||||
|
||||
/**
|
||||
* Specifies the next time at which the job should run.
|
||||
* @param time The next time at which the job should run.
|
||||
*/
|
||||
schedule(time: string | Date): Job;
|
||||
schedule(time: string | Date): Job<T>;
|
||||
|
||||
/**
|
||||
* Specifies the priority weighting of the job.
|
||||
* @param value The priority of the job (lowest|low|normal|high|highest|number).
|
||||
*/
|
||||
priority(value: string | number): Job;
|
||||
priority(value: string | number): Job<T>;
|
||||
|
||||
/**
|
||||
* Sets job.attrs.failedAt to now, and sets job.attrs.failReason to reason.
|
||||
* @param reason A message or Error object that indicates why the job failed.
|
||||
*/
|
||||
fail(reason: string | Error): Job;
|
||||
fail(reason: string | Error): Job<T>;
|
||||
|
||||
/**
|
||||
* Runs the given job and calls callback(err, job) upon completion. Normally you never need to call this manually
|
||||
* @param cb Called when the job is completed.
|
||||
*/
|
||||
run(cb?: ResultCallback<Job>): Job;
|
||||
run(cb?: ResultCallback<Job<T>>): Job<T>;
|
||||
|
||||
/**
|
||||
* Returns true if the job is running; otherwise, returns false.
|
||||
@@ -406,7 +411,7 @@ declare namespace Agenda {
|
||||
* Saves the job into the database.
|
||||
* @param cb Called when the job is saved.
|
||||
*/
|
||||
save(cb?: ResultCallback<Job>): Job;
|
||||
save(cb?: ResultCallback<Job<T>>): Job<T>;
|
||||
|
||||
/**
|
||||
* Removes the job from the database and cancels the job.
|
||||
@@ -424,7 +429,7 @@ declare namespace Agenda {
|
||||
/**
|
||||
* Calculates next time the job should run
|
||||
*/
|
||||
computeNextRunAt(): Job;
|
||||
computeNextRunAt(): Job<T>;
|
||||
}
|
||||
|
||||
interface JobOptions {
|
||||
|
||||
@@ -2,16 +2,16 @@ import * as algoliasearch from 'algoliasearch';
|
||||
import {
|
||||
ClientOptions,
|
||||
SynonymOption,
|
||||
AlgoliaApiKeyOptions,
|
||||
ApiKeyOptions,
|
||||
SearchSynonymOptions,
|
||||
AlgoliaResponse,
|
||||
AlgoliaSecuredApiOptions,
|
||||
AlgoliaIndexSettings,
|
||||
AlgoliaQueryParameters,
|
||||
AlgoliaIndex,
|
||||
SecuredApiOptions,
|
||||
Index,
|
||||
Response,
|
||||
IndexSettings,
|
||||
QueryParameters,
|
||||
} from 'algoliasearch';
|
||||
|
||||
let _algoliaResponse: AlgoliaResponse = {
|
||||
let _algoliaResponse: Response = {
|
||||
hits: [{}, {}],
|
||||
page: 0,
|
||||
nbHits: 12,
|
||||
@@ -33,7 +33,7 @@ let _synonymOption: SynonymOption = {
|
||||
replaceExistingSynonyms: false,
|
||||
};
|
||||
|
||||
let _algoliaApiKeyOptions: AlgoliaApiKeyOptions = {
|
||||
let _algoliaApiKeyOptions: ApiKeyOptions = {
|
||||
validity: 0,
|
||||
maxQueriesPerIPPerHour: 0,
|
||||
indexes: [''],
|
||||
@@ -48,14 +48,14 @@ let _searchSynonymOptions: SearchSynonymOptions = {
|
||||
hitsPerPage: 0,
|
||||
};
|
||||
|
||||
let _algoliaSecuredApiOptions: AlgoliaSecuredApiOptions = {
|
||||
let _algoliaSecuredApiOptions: SecuredApiOptions = {
|
||||
filters: '',
|
||||
validUntil: 0,
|
||||
restrictIndices: '',
|
||||
userToken: '',
|
||||
};
|
||||
|
||||
let _algoliaIndexSettings: AlgoliaIndexSettings = {
|
||||
let _algoliaIndexSettings: IndexSettings = {
|
||||
attributesToIndex: [''],
|
||||
attributesForFaceting: [''],
|
||||
unretrievableAttributes: [''],
|
||||
@@ -63,7 +63,7 @@ let _algoliaIndexSettings: AlgoliaIndexSettings = {
|
||||
ranking: [''],
|
||||
customRanking: [''],
|
||||
replicas: [''],
|
||||
maxValuesPerFacet: '',
|
||||
maxValuesPerFacet: 100,
|
||||
attributesToHighlight: [''],
|
||||
attributesToSnippet: [''],
|
||||
highlightPreTag: '',
|
||||
@@ -96,13 +96,13 @@ let _algoliaIndexSettings: AlgoliaIndexSettings = {
|
||||
placeholders: '',
|
||||
};
|
||||
|
||||
let _algoliaQueryParameters: AlgoliaQueryParameters = {
|
||||
let _algoliaQueryParameters: QueryParameters = {
|
||||
query: '',
|
||||
filters: '',
|
||||
attributesToRetrieve: [''],
|
||||
restrictSearchableAttributes: [''],
|
||||
facets: '',
|
||||
maxValuesPerFacet: '',
|
||||
maxValuesPerFacet: 2,
|
||||
attributesToHighlight: [''],
|
||||
attributesToSnippet: [''],
|
||||
highlightPreTag: '',
|
||||
@@ -147,7 +147,20 @@ let _algoliaQueryParameters: AlgoliaQueryParameters = {
|
||||
minProximity: 0,
|
||||
};
|
||||
|
||||
let index: AlgoliaIndex = algoliasearch('', '').initIndex('');
|
||||
let index: Index = algoliasearch('', '').initIndex('');
|
||||
|
||||
let search = index.search({ query: '' });
|
||||
|
||||
index.search({ query: '' }, (err, res) => {});
|
||||
|
||||
// partialUpdateObject
|
||||
index.partialUpdateObject({}, () => {});
|
||||
index.partialUpdateObject({}, false, () => {});
|
||||
index.partialUpdateObject({}).then(() => {});
|
||||
index.partialUpdateObject({}, false).then(() => {});
|
||||
|
||||
// partialUpdateObjects
|
||||
index.partialUpdateObjects([{}], () => {});
|
||||
index.partialUpdateObjects([{}], false, () => {});
|
||||
index.partialUpdateObjects([{}]).then(() => {});
|
||||
index.partialUpdateObjects([{}], false).then(() => {});
|
||||
|
||||
Vendored
+576
-715
File diff suppressed because it is too large
Load Diff
Vendored
+624
@@ -0,0 +1,624 @@
|
||||
// Type definitions for algoliasearch-client-js 3.27.0
|
||||
// Project: https://github.com/algolia/algoliasearch-client-js
|
||||
// Definitions by: Baptiste Coquelle <https://github.com/cbaptiste>
|
||||
// Haroen Viaene <https://github.com/haroenv>
|
||||
// Aurélien Hervé <https://github.com/aherve>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
declare namespace algoliasearch {
|
||||
/*
|
||||
Interface for the algolia client object
|
||||
*/
|
||||
interface Client {
|
||||
/**
|
||||
* Initialization of the index
|
||||
* https://github.com/algolia/algoliasearch-client-js#init-index---initindex
|
||||
*/
|
||||
initIndex(indexName: string): Index;
|
||||
/**
|
||||
* Query on multiple index
|
||||
* https://github.com/algolia/algoliasearch-client-js#multiple-queries---multiplequeries
|
||||
*/
|
||||
search(
|
||||
queries: {
|
||||
indexName: string;
|
||||
query: string;
|
||||
params: QueryParameters;
|
||||
}[],
|
||||
cb: (err: Error, res: MultiResponse) => void
|
||||
): void;
|
||||
/**
|
||||
* Query on multiple index
|
||||
* https://github.com/algolia/algoliasearch-client-js#multiple-queries---multiplequeries
|
||||
*/
|
||||
search(
|
||||
queries: {
|
||||
indexName: string;
|
||||
query: string;
|
||||
params: QueryParameters;
|
||||
}[]
|
||||
): Promise<MultiResponse>;
|
||||
/**
|
||||
* Query for facet values of a specific facet
|
||||
*/
|
||||
searchForFacetValues(
|
||||
queries: [{ indexName: string; params: SearchForFacetValues.Parameters }]
|
||||
): Promise<SearchForFacetValues.Response[]>;
|
||||
/**
|
||||
* clear browser cache
|
||||
* https://github.com/algolia/algoliasearch-client-js#cache
|
||||
*/
|
||||
clearCache(): void;
|
||||
/**
|
||||
* Add a header to be sent with all upcoming requests
|
||||
*/
|
||||
setExtraHeader(name: string, value: string): void;
|
||||
/**
|
||||
* Get the value of an extra header
|
||||
*/
|
||||
getExtraHeader(name: string): string;
|
||||
/**
|
||||
* remove an extra header for all upcoming requests
|
||||
*/
|
||||
unsetExtraHeader(name: string): void;
|
||||
}
|
||||
/**
|
||||
* Interface for the index algolia object
|
||||
*/
|
||||
interface Index {
|
||||
/**
|
||||
* Gets a specific object
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObject(objectID: string, cb: (err: Error, res: {}) => void): void;
|
||||
/**
|
||||
* Gets specific attributes from an object
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObject(
|
||||
objectID: string,
|
||||
attributes: string[],
|
||||
cb: (err: Error, res: {}) => void
|
||||
): void;
|
||||
/**
|
||||
* Gets a list of objects
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObjects(
|
||||
objectIDs: string[],
|
||||
cb: (err: Error, res: { results: {}[] }) => void
|
||||
): void;
|
||||
/**
|
||||
* Gets a list of objects
|
||||
* https://github.com/algolia/algoliasearch-client-js#find-by-ids---getobjects
|
||||
*/
|
||||
getObjects(objectIDs: string[]): Promise<{ results: {}[] }>;
|
||||
/**
|
||||
* Clear cache of an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#cache
|
||||
*/
|
||||
clearCache(): void;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-in-an-index---search
|
||||
*/
|
||||
search(
|
||||
params: QueryParameters,
|
||||
cb: (err: Error, res: Response) => void
|
||||
): void;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#search-in-an-index---search
|
||||
*/
|
||||
search(params: QueryParameters): Promise<Response>;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search-for-facet-values/
|
||||
*/
|
||||
searchForFacetValues(
|
||||
options: SearchForFacetValues.Parameters
|
||||
): Promise<SearchForFacetValues.Response>;
|
||||
/**
|
||||
* Search in an index
|
||||
* https://www.algolia.com/doc/api-reference/api-methods/search-for-facet-values/
|
||||
*/
|
||||
searchForFacetValues(
|
||||
options: SearchForFacetValues.Parameters,
|
||||
cb: (err: Error, res: SearchForFacetValues.Response) => void
|
||||
): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string, cb: (err: Error, res: BrowseResponse) => void): void;
|
||||
/**
|
||||
* Browse an index
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browse(query: string): Promise<BrowseResponse>;
|
||||
/**
|
||||
* Browse an index from a cursor
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browseFrom(
|
||||
cursor: string,
|
||||
cb: (err: Error, res: BrowseResponse) => void
|
||||
): void;
|
||||
/**
|
||||
* Browse an index from a cursor
|
||||
* https://github.com/algolia/algoliasearch-client-js#backup--export-an-index---browse
|
||||
*/
|
||||
browseFrom(cursor: string): Promise<BrowseResponse>;
|
||||
}
|
||||
/**
|
||||
* Interface describing available options when initializing a client
|
||||
*/
|
||||
interface ClientOptions {
|
||||
/**
|
||||
* Timeout for requests to our servers, in milliseconds
|
||||
* default: 15s (node), 2s (browser)
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Protocol to use when communicating with algolia
|
||||
* default: current protocol(browser), https(node)
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
protocol?: string;
|
||||
/**
|
||||
* (node only) httpAgent instance to use when communicating with servers.
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
httpAgent?: any;
|
||||
/**
|
||||
* read: array of read hosts to use to call servers, computed automatically
|
||||
* write: array of read hosts to use to call servers, computed automatically
|
||||
* https://github.com/algolia/algoliasearch-client-js#client-options
|
||||
*/
|
||||
hosts?: { read?: string[]; write?: string[] };
|
||||
}
|
||||
interface BrowseResponse {
|
||||
cursor?: string;
|
||||
hits: {}[];
|
||||
params: string;
|
||||
query: string;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
|
||||
interface QueryParameters {
|
||||
/**
|
||||
* Query string used to perform the search
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#query
|
||||
*/
|
||||
query?: string;
|
||||
/**
|
||||
* Filter the query with numeric, facet or/and tag filters
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#filters
|
||||
*/
|
||||
filters?: string;
|
||||
/**
|
||||
* A string that contains the list of attributes you want to retrieve in order to minimize the size of the JSON answer.
|
||||
* default: *
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestoretrieve
|
||||
*/
|
||||
attributesToRetrieve?: string[];
|
||||
/**
|
||||
* List of attributes you want to use for textual search
|
||||
* default: attributeToIndex
|
||||
* https://github.com/algolia/algoliasearch-client-js#restrictsearchableattributes
|
||||
*/
|
||||
restrictSearchableAttributes?: string[];
|
||||
/**
|
||||
* You can use facets to retrieve only a part of your attributes declared in attributesForFaceting attributes
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#facets
|
||||
*/
|
||||
facets?: string;
|
||||
/**
|
||||
* Limit the number of facet values returned for each facet.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#maxvaluesperfacet
|
||||
*/
|
||||
maxValuesPerFacet?: number;
|
||||
/**
|
||||
* Default list of attributes to highlight. If set to null, all indexed attributes are highlighted.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestohighlight
|
||||
*/
|
||||
attributesToHighlight?: string[];
|
||||
/**
|
||||
* Default list of attributes to snippet alongside the number of words to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#attributestosnippet
|
||||
*/
|
||||
attributesToSnippet?: string[];
|
||||
/**
|
||||
* Specify the string that is inserted before the highlighted parts in the query result
|
||||
* default: <em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightpretag
|
||||
*/
|
||||
highlightPreTag?: string;
|
||||
/**
|
||||
* Specify the string that is inserted after the highlighted parts in the query result
|
||||
* default: </em>
|
||||
* https://github.com/algolia/algoliasearch-client-js#highlightposttag
|
||||
*/
|
||||
highlightPostTag?: string;
|
||||
/**
|
||||
* String used as an ellipsis indicator when a snippet is truncated.
|
||||
* default: …
|
||||
* https://github.com/algolia/algoliasearch-client-js#snippetellipsistext
|
||||
*/
|
||||
snippetEllipsisText?: string;
|
||||
/**
|
||||
* If set to true, restrict arrays in highlights and snippets to items that matched the query at least partially else return all array items in highlights and snippets
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#restricthighlightandsnippetarrays
|
||||
*/
|
||||
restrictHighlightAndSnippetArrays?: boolean;
|
||||
/**
|
||||
* Pagination parameter used to select the number of hits per page
|
||||
* default: 20
|
||||
* https://github.com/algolia/algoliasearch-client-js#hitsperpage
|
||||
*/
|
||||
hitsPerPage?: number;
|
||||
/**
|
||||
* Pagination parameter used to select the page to retrieve.
|
||||
* default: 0
|
||||
* https://github.com/algolia/algoliasearch-client-js#page
|
||||
*/
|
||||
page?: number;
|
||||
/**
|
||||
* Offset of the first hit to return
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#offset
|
||||
*/
|
||||
offset?: number;
|
||||
/**
|
||||
* Number of hits to return.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#length
|
||||
*/
|
||||
length?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept one typo.
|
||||
* default: 4
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor1typo
|
||||
*/
|
||||
minWordSizefor1Typo?: number;
|
||||
/**
|
||||
* The minimum number of characters needed to accept two typo.
|
||||
* fault: 8
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
*/
|
||||
minWordSizefor2Typos?: number;
|
||||
/**
|
||||
* This option allows you to control the number of typos allowed in the result set:
|
||||
* default: true
|
||||
* 'true' The typo tolerance is enabled and all matching hits are retrieved
|
||||
* 'false' The typo tolerance is disabled. All results with typos will be hidden.
|
||||
* 'min' Only keep results with the minimum number of typos
|
||||
* 'strict' Hits matching with 2 typos are not retrieved if there are some matching without typos.
|
||||
* https://github.com/algolia/algoliasearch-client-js#minwordsizefor2typos
|
||||
*/
|
||||
typoTolerance?: boolean;
|
||||
/**
|
||||
* If set to false, disables typo tolerance on numeric tokens (numbers).
|
||||
* default:
|
||||
* https://github.com/algolia/algoliasearch-client-js#allowtyposonnumerictokens
|
||||
*/
|
||||
allowTyposOnNumericTokens?: boolean;
|
||||
/**
|
||||
* If set to true, plural won't be considered as a typo
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#ignoreplurals
|
||||
*/
|
||||
ignorePlurals?: boolean;
|
||||
/**
|
||||
* List of attributes on which you want to disable typo tolerance
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#disabletypotoleranceonattributes
|
||||
*/
|
||||
disableTypoToleranceOnAttributes?: string;
|
||||
/**
|
||||
* Search for entries around a given location
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlng
|
||||
*/
|
||||
aroundLatLng?: string;
|
||||
/**
|
||||
* Search for entries around a given latitude/longitude automatically computed from user IP address.
|
||||
* default: ""
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundlatlngviaip
|
||||
*/
|
||||
aroundLatLngViaIP?: string;
|
||||
/**
|
||||
* Control the radius associated with a geo search. Defined in meters.
|
||||
* default: null
|
||||
* You can specify aroundRadius=all if you want to compute the geo distance without filtering in a geo area
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundradius
|
||||
*/
|
||||
aroundRadius?: number | 'all';
|
||||
/**
|
||||
* Control the precision of a geo search
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#aroundprecision
|
||||
*/
|
||||
aroundPrecision?: number;
|
||||
/**
|
||||
* Define the minimum radius used for a geo search when aroundRadius is not set.
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#minimumaroundradius
|
||||
*/
|
||||
minimumAroundRadius?: number;
|
||||
/**
|
||||
* Search entries inside a given area defined by the two extreme points of a rectangle
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#insideboundingbox
|
||||
*/
|
||||
insideBoundingBox?: number[][];
|
||||
/**
|
||||
* Selects how the query words are interpreted
|
||||
* default: 'prefixLast'
|
||||
* 'prefixAll' All query words are interpreted as prefixes. This option is not recommended.
|
||||
* 'prefixLast' Only the last word is interpreted as a prefix (default behavior).
|
||||
* 'prefixNone' No query word is interpreted as a prefix. This option is not recommended.
|
||||
* https://github.com/algolia/algoliasearch-client-js#querytype
|
||||
*/
|
||||
queryType?: any;
|
||||
/**
|
||||
* Search entries inside a given area defined by a set of points
|
||||
* defauly: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#insidepolygon
|
||||
*/
|
||||
insidePolygon?: number[][];
|
||||
/**
|
||||
* This option is used to select a strategy in order to avoid having an empty result page
|
||||
* default: 'none'
|
||||
* 'lastWords' When a query does not return any results, the last word will be added as optional
|
||||
* 'firstWords' When a query does not return any results, the first word will be added as optional
|
||||
* 'allOptional' When a query does not return any results, a second trial will be made with all words as optional
|
||||
* 'none' No specific processing is done when a query does not return any results
|
||||
* https://github.com/algolia/algoliasearch-client-js#removewordsifnoresults
|
||||
*/
|
||||
removeWordsIfNoResults?: string;
|
||||
/**
|
||||
* Enables the advanced query syntax
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#advancedsyntax
|
||||
*/
|
||||
advancedSyntax?: boolean;
|
||||
/**
|
||||
* A string that contains the comma separated list of words that should be considered as optional when found in the query
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#optionalwords
|
||||
*/
|
||||
optionalWords?: string[];
|
||||
/**
|
||||
* Remove stop words from the query before executing it
|
||||
* default: false
|
||||
* true|false: enable or disable stop words for all 41 supported languages; or
|
||||
* a list of language ISO codes (as a comma-separated string) for which stop words should be enable
|
||||
* https://github.com/algolia/algoliasearch-client-js#removestopwords
|
||||
*/
|
||||
removeStopWords?: string[];
|
||||
/**
|
||||
* List of attributes on which you want to disable the computation of exact criteria
|
||||
* default: []
|
||||
* https://github.com/algolia/algoliasearch-client-js#disableexactonattributes
|
||||
*/
|
||||
disableExactOnAttributes?: string[];
|
||||
/**
|
||||
* This parameter control how the exact ranking criterion is computed when the query contains one word
|
||||
* default: attribute
|
||||
* 'none': no exact on single word query
|
||||
* 'word': exact set to 1 if the query word is found in the record
|
||||
* 'attribute': exact set to 1 if there is an attribute containing a string equals to the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#exactonsinglewordquery
|
||||
*/
|
||||
exactOnSingleWordQuery?: string;
|
||||
/**
|
||||
* Specify the list of approximation that should be considered as an exact match in the ranking formula
|
||||
* default: ['ignorePlurals', 'singleWordSynonym']
|
||||
* 'ignorePlurals': alternative words added by the ignorePlurals feature
|
||||
* 'singleWordSynonym': single-word synonym (For example "NY" = "NYC")
|
||||
* 'multiWordsSynonym': multiple-words synonym
|
||||
* https://github.com/algolia/algoliasearch-client-js#alternativesasexact
|
||||
*/
|
||||
alternativesAsExact?: any;
|
||||
/**
|
||||
* If set to 1, enables the distinct feature, disabled by default, if the attributeForDistinct index setting is set.
|
||||
* https://github.com/algolia/algoliasearch-client-js#distinct
|
||||
*/
|
||||
distinct?: any;
|
||||
/**
|
||||
* If set to true, the result hits will contain ranking information in the _rankingInfo attribute.
|
||||
* default: false
|
||||
* https://github.com/algolia/algoliasearch-client-js#getrankinginfo
|
||||
*/
|
||||
getRankingInfo?: boolean;
|
||||
/**
|
||||
* All numerical attributes are automatically indexed as numerical filters
|
||||
* default: ''
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericattributestoindex
|
||||
*/
|
||||
numericAttributesToIndex?: string[];
|
||||
/**
|
||||
* @deprecated please use filters instead
|
||||
* A string that contains the comma separated list of numeric filters you want to apply.
|
||||
* https://github.com/algolia/algoliasearch-client-js#numericfilters-deprecated
|
||||
*/
|
||||
numericFilters?: string[];
|
||||
/**
|
||||
* @deprecated
|
||||
* Filter the query by a set of tags.
|
||||
* https://github.com/algolia/algoliasearch-client-js#tagfilters-deprecated
|
||||
*/
|
||||
tagFilters?: string;
|
||||
/**
|
||||
* @deprecated
|
||||
* Filter the query by a set of facets.
|
||||
* https://github.com/algolia/algoliasearch-client-js#facetfilters-deprecated
|
||||
*/
|
||||
facetFilters?: string;
|
||||
/**
|
||||
* If set to false, this query will not be taken into account in the analytics feature.
|
||||
* default true
|
||||
* https://github.com/algolia/algoliasearch-client-js#analytics
|
||||
*/
|
||||
analytics?: boolean;
|
||||
/**
|
||||
* If set, tag your query with the specified identifiers
|
||||
* default: null
|
||||
* https://github.com/algolia/algoliasearch-client-js#analyticstags
|
||||
*/
|
||||
analyticsTags?: string[];
|
||||
/**
|
||||
* If set to false, the search will not use the synonyms defined for the targeted index.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#synonyms
|
||||
*/
|
||||
synonyms?: boolean;
|
||||
/**
|
||||
* If set to false, words matched via synonym expansion will not be replaced by the matched synonym in the highlighted result.
|
||||
* default: true
|
||||
* https://github.com/algolia/algoliasearch-client-js#replacesynonymsinhighlight
|
||||
*/
|
||||
replaceSynonymsInHighlight?: boolean;
|
||||
/**
|
||||
* Configure the precision of the proximity ranking criterion
|
||||
* default: 1
|
||||
* https://github.com/algolia/algoliasearch-client-js#minproximity
|
||||
*/
|
||||
minProximity?: number;
|
||||
|
||||
nbShards?: number;
|
||||
userData?: string | object;
|
||||
}
|
||||
|
||||
interface AlgoliaResponse {
|
||||
/**
|
||||
* Contains all the hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* Current page
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* Number of total hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* Number of pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbPage: number;
|
||||
/**
|
||||
* Number of hits per pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* Engine processing time (excluding network transfer)
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* Query used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* GET parameters used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
params: string;
|
||||
facets: {
|
||||
[facetName: string]: { [facetValue: string]: number };
|
||||
};
|
||||
}
|
||||
|
||||
namespace SearchForFacetValues {
|
||||
interface Parameters extends QueryParameters {
|
||||
/**
|
||||
* The facet to search in
|
||||
*/
|
||||
facetName: string;
|
||||
/**
|
||||
* The query for the search in this facet
|
||||
*/
|
||||
facetQuery: string;
|
||||
}
|
||||
|
||||
interface Response {
|
||||
facetHits: { value: string; highlighted: string; count: number }[];
|
||||
exhaustiveFacetsCount: boolean;
|
||||
processingTimeMS: number;
|
||||
}
|
||||
}
|
||||
|
||||
interface Response {
|
||||
/**
|
||||
* Contains all the hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hits: any[];
|
||||
/**
|
||||
* Current page
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
page: number;
|
||||
/**
|
||||
* Number of total hits matching the query
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbHits: number;
|
||||
/**
|
||||
* Number of pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
nbPages: number;
|
||||
/**
|
||||
* Number of hits per pages
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
hitsPerPage: number;
|
||||
/**
|
||||
* Engine processing time (excluding network transfer)
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
processingTimeMS: number;
|
||||
/**
|
||||
* Query used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
query: string;
|
||||
/**
|
||||
* GET parameters used to perform the search
|
||||
* https://github.com/algolia/algoliasearch-client-js#response-format
|
||||
*/
|
||||
params: string;
|
||||
facets?: {
|
||||
[facetName: string]: { [facetValue: string]: number };
|
||||
};
|
||||
}
|
||||
|
||||
interface MultiResponse {
|
||||
results: Response[];
|
||||
}
|
||||
}
|
||||
|
||||
declare function algoliasearch(
|
||||
applicationId: string,
|
||||
apiKey: string,
|
||||
options?: algoliasearch.ClientOptions
|
||||
): algoliasearch.Client;
|
||||
export = algoliasearch;
|
||||
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"lite/index.d.ts",
|
||||
"algoliasearch-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+577
@@ -0,0 +1,577 @@
|
||||
// Type definitions for amazon-cognito-auth-js 1.2
|
||||
// Project: https://github.com/aws/amazon-cognito-auth-js
|
||||
// Definitions by: Scott Escue <https://github.com/scottescue>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
|
||||
/*
|
||||
* Create global variable to provide access to types when used without module
|
||||
* loading.
|
||||
*/
|
||||
export as namespace AmazonCognitoIdentity;
|
||||
|
||||
// Stubs the XDomainRequest built-in from older IE browsers, does not follow the project's interface naming convention
|
||||
export interface XDomainRequest {
|
||||
readonly responseText: string;
|
||||
timeout: number;
|
||||
onprogress: () => void;
|
||||
ontimeout: () => void;
|
||||
onerror: () => void;
|
||||
onload: () => void;
|
||||
|
||||
open(method: string, url: string): void;
|
||||
send(data: string): void;
|
||||
abort(): void;
|
||||
}
|
||||
|
||||
export interface CognitoSessionData {
|
||||
/**
|
||||
* The session's Id token.
|
||||
*/
|
||||
IdToken?: CognitoIdToken;
|
||||
|
||||
/**
|
||||
* The session's refresh token.
|
||||
*/
|
||||
RefreshToken?: CognitoRefreshToken;
|
||||
|
||||
/**
|
||||
* The session's access token.
|
||||
*/
|
||||
AccessToken?: CognitoAccessToken;
|
||||
|
||||
/**
|
||||
* The session's token scopes.
|
||||
*/
|
||||
TokenScopes?: CognitoTokenScopes;
|
||||
|
||||
/**
|
||||
* The session's state.
|
||||
*/
|
||||
State?: string;
|
||||
}
|
||||
|
||||
export interface CognitoAuthOptions {
|
||||
/**
|
||||
* Required: User pool application client id.
|
||||
*/
|
||||
ClientId: string;
|
||||
|
||||
/**
|
||||
* Required: The application/user-pools Cognito web hostname,this is set at the Cognito console.
|
||||
*/
|
||||
AppWebDomain: string;
|
||||
|
||||
/**
|
||||
* Optional: The token scopes
|
||||
*/
|
||||
TokenScopesArray?: ReadonlyArray<string>;
|
||||
|
||||
/**
|
||||
* Required: Required: The redirect Uri, which will be launched after authentication as signed in.
|
||||
*/
|
||||
RedirectUriSignIn: string;
|
||||
|
||||
/**
|
||||
* Required: The redirect Uri, which will be launched when signed out.
|
||||
*/
|
||||
RedirectUriSignOut: string;
|
||||
|
||||
/**
|
||||
* Optional: Pre-selected identity provider (this allows to automatically trigger social provider authentication flow).
|
||||
*/
|
||||
IdentityProvider?: string;
|
||||
|
||||
/**
|
||||
* Optional: UserPoolId for the configured cognito userPool.
|
||||
*/
|
||||
UserPoolId?: string;
|
||||
|
||||
/**
|
||||
* Optional: boolean flag indicating if the data collection is enabled to support cognito advanced security features. By default, this flag is set to true.
|
||||
*/
|
||||
AdvancedSecurityDataCollectionFlag?: boolean;
|
||||
}
|
||||
|
||||
export interface CognitoAuthUserHandler {
|
||||
onSuccess: (authSession: CognitoAuthSession) => void;
|
||||
onFailure: (err: any) => void;
|
||||
}
|
||||
|
||||
export interface CognitoConstants {
|
||||
DOMAIN_SCHEME: string;
|
||||
DOMAIN_PATH_SIGNIN: string;
|
||||
DOMAIN_PATH_TOKEN: string;
|
||||
DOMAIN_PATH_SIGNOUT: string;
|
||||
DOMAIN_QUERY_PARAM_REDIRECT_URI: string;
|
||||
DOMAIN_QUERY_PARAM_SIGNOUT_URI: string;
|
||||
DOMAIN_QUERY_PARAM_RESPONSE_TYPE: string;
|
||||
DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER: string;
|
||||
DOMAIN_QUERY_PARAM_USERCONTEXTDATA: string;
|
||||
CLIENT_ID: string;
|
||||
STATE: string;
|
||||
SCOPE: string;
|
||||
TOKEN: string;
|
||||
CODE: string;
|
||||
POST: string;
|
||||
PARAMETERERROR: string;
|
||||
SCOPETYPEERROR: string;
|
||||
QUESTIONMARK: string;
|
||||
POUNDSIGN: string;
|
||||
COLONDOUBLESLASH: string;
|
||||
SLASH: string;
|
||||
AMPERSAND: string;
|
||||
EQUALSIGN: string;
|
||||
SPACE: string;
|
||||
CONTENTTYPE: string;
|
||||
CONTENTTYPEVALUE: string;
|
||||
AUTHORIZATIONCODE: string;
|
||||
IDTOKEN: string;
|
||||
ACCESSTOKEN: string;
|
||||
REFRESHTOKEN: string;
|
||||
ERROR: string;
|
||||
ERROR_DESCRIPTION: string;
|
||||
STRINGTYPE: string;
|
||||
STATELENGTH: number;
|
||||
STATEORIGINSTRING: string;
|
||||
WITHCREDENTIALS: string;
|
||||
UNDEFINED: string;
|
||||
SELF: string;
|
||||
HOSTNAMEREGEX: RegExp;
|
||||
QUERYPARAMETERREGEX1: RegExp;
|
||||
QUERYPARAMETERREGEX2: RegExp;
|
||||
HEADER: { 'Content-Type': string };
|
||||
}
|
||||
|
||||
export class CognitoIdToken {
|
||||
/**
|
||||
* Constructs a new CognitoIdToken object
|
||||
* @param IdToken The JWT Id token
|
||||
*/
|
||||
constructor(IdToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getJwtToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for id token.
|
||||
* @param idToken The JWT Id token
|
||||
*/
|
||||
setJwtToken(idToken: string): void;
|
||||
|
||||
/**
|
||||
* @returns the token's expiration (exp member).
|
||||
*/
|
||||
getExpiration(): number;
|
||||
|
||||
/**
|
||||
* @returns the token's payload.
|
||||
*/
|
||||
decodePayload(): object;
|
||||
}
|
||||
|
||||
export class CognitoRefreshToken {
|
||||
/**
|
||||
* Constructs a new CognitoRefreshToken object
|
||||
* @param RefreshToken The JWT refresh token.
|
||||
*/
|
||||
constructor(RefreshToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for refresh token.
|
||||
* @param refreshToken The JWT refresh token.
|
||||
*/
|
||||
setToken(refreshToken: string): void;
|
||||
}
|
||||
|
||||
export class CognitoAccessToken {
|
||||
/**
|
||||
* Constructs a new CognitoAccessToken object
|
||||
* @param AccessToken The JWT access token.
|
||||
*/
|
||||
constructor(AccessToken: string);
|
||||
|
||||
/**
|
||||
* @returns the record's token.
|
||||
*/
|
||||
getJwtToken(): string;
|
||||
|
||||
/**
|
||||
* Sets new value for access token.
|
||||
* @param accessToken The JWT access token.
|
||||
*/
|
||||
setJwtToken(accessToken: string): void;
|
||||
|
||||
/**
|
||||
* @returns the token's expiration (exp member).
|
||||
*/
|
||||
getExpiration(): number;
|
||||
|
||||
/**
|
||||
* @returns the username from payload.
|
||||
*/
|
||||
getUsername(): string;
|
||||
|
||||
/**
|
||||
* @returns the token's payload.
|
||||
*/
|
||||
decodePayload(): object;
|
||||
}
|
||||
|
||||
export class CognitoTokenScopes {
|
||||
/**
|
||||
* Constructs a new CognitoTokenScopes object
|
||||
* @param TokenScopesArray The token scopes
|
||||
*/
|
||||
constructor(TokenScopesArray: ReadonlyArray<string>);
|
||||
|
||||
/**
|
||||
* @returns the token scopes.
|
||||
*/
|
||||
getScopes(): string[];
|
||||
|
||||
/**
|
||||
* Sets new value for token scopes.
|
||||
* @param tokenScopes The token scopes
|
||||
*/
|
||||
setTokenScopes(tokenScopes: ReadonlyArray<string>): void;
|
||||
}
|
||||
|
||||
export class CognitoAuthSession {
|
||||
/**
|
||||
* Constructs a new CognitoUserSession object
|
||||
* @param sessionData The session's tokens, scopes, and state.
|
||||
*/
|
||||
constructor(sessionData: CognitoSessionData);
|
||||
|
||||
/**
|
||||
* @returns the session's Id token
|
||||
*/
|
||||
getIdToken(): CognitoIdToken;
|
||||
|
||||
/**
|
||||
* Set a new Id token
|
||||
* @param IdToken The session's Id token.
|
||||
*/
|
||||
setIdToken(IdToken: CognitoIdToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's refresh token
|
||||
*/
|
||||
getRefreshToken(): CognitoRefreshToken;
|
||||
|
||||
/**
|
||||
* Set a new Refresh token
|
||||
* @param RefreshToken The session's refresh token.
|
||||
*/
|
||||
setRefreshToken(RefreshToken: CognitoRefreshToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's access token
|
||||
*/
|
||||
getAccessToken(): CognitoAccessToken;
|
||||
|
||||
/**
|
||||
* Set a new Access token
|
||||
* @param AccessToken The session's access token.
|
||||
*/
|
||||
setAccessToken(AccessToken: CognitoAccessToken): void;
|
||||
|
||||
/**
|
||||
* @returns the session's token scopes
|
||||
*/
|
||||
getTokenScopes(): CognitoTokenScopes;
|
||||
|
||||
/**
|
||||
* Set new token scopes
|
||||
* @param tokenScopes The session's token scopes.
|
||||
*/
|
||||
setTokenScopes(tokenScopes: CognitoTokenScopes): void;
|
||||
|
||||
/**
|
||||
* @returns the session's state
|
||||
*/
|
||||
getState(): string;
|
||||
|
||||
/**
|
||||
* Set new state
|
||||
* @param state The session's state.
|
||||
*/
|
||||
setState(State: string): void;
|
||||
|
||||
/**
|
||||
* Checks to see if the session is still valid based on session expiry information found
|
||||
* in Access and Id Tokens and the current time
|
||||
* @returns if the session is still valid
|
||||
*/
|
||||
isValid(): boolean;
|
||||
}
|
||||
|
||||
export class CognitoAuth {
|
||||
/**
|
||||
* Called on success or error.
|
||||
*/
|
||||
userhandler: CognitoAuthUserHandler;
|
||||
|
||||
/**
|
||||
* Constructs a new CognitoAuth object
|
||||
* @param options Creation options
|
||||
*/
|
||||
constructor(options: CognitoAuthOptions);
|
||||
|
||||
/**
|
||||
* @returns the constants
|
||||
*/
|
||||
getCognitoConstants(): CognitoConstants;
|
||||
|
||||
/**
|
||||
* @returns the client id
|
||||
*/
|
||||
getClientId(): string;
|
||||
|
||||
/**
|
||||
* @returns the app web domain
|
||||
*/
|
||||
getAppWebDomain(): string;
|
||||
|
||||
/**
|
||||
* method for getting the current user of the application from the local storage
|
||||
*
|
||||
* @returns the user retrieved from storage
|
||||
*/
|
||||
getCurrentUser(): string;
|
||||
|
||||
/**
|
||||
* method for setting the current user's name
|
||||
* @param Username the user's name
|
||||
*/
|
||||
setUser(Username: string): void;
|
||||
|
||||
/**
|
||||
* sets response type to 'code'
|
||||
*/
|
||||
useCodeGrantFlow(): void;
|
||||
|
||||
/**
|
||||
* sets response type to 'token'
|
||||
*/
|
||||
useImplicitFlow(): void;
|
||||
|
||||
/**
|
||||
* @returns the current session for this user
|
||||
*/
|
||||
getSignInUserSession(): CognitoAuthSession;
|
||||
|
||||
/**
|
||||
* @returns the user's username
|
||||
*/
|
||||
getUsername(): string;
|
||||
|
||||
/**
|
||||
* @param Username the user's username
|
||||
*/
|
||||
setUsername(Username: string): void;
|
||||
|
||||
/**
|
||||
* @returns the user's state
|
||||
*/
|
||||
getState(): string;
|
||||
|
||||
/**
|
||||
* @param State the user's state
|
||||
*/
|
||||
setState(State: string): void;
|
||||
|
||||
/**
|
||||
* This is used to get a session, either from the session object or from the local storage, or by using a refresh token
|
||||
* @param RedirectUriSignIn Required: The redirect Uri, which will be launched after authentication.
|
||||
* @param TokenScopesArray Required: The token scopes, it is an array of strings specifying all scopes for the tokens.
|
||||
*/
|
||||
getSession(): void;
|
||||
|
||||
/**
|
||||
* Parse the http request response and proceed according to different response types.
|
||||
* @param httpRequestResponse the http request response
|
||||
*/
|
||||
parseCognitoWebResponse(httpRequestResponse: string): void;
|
||||
|
||||
/**
|
||||
* Get the query parameter map and proceed according to code response type.
|
||||
* @param Query parameter map
|
||||
*/
|
||||
getCodeQueryParameter(map: ReadonlyMap<string, string>): void;
|
||||
|
||||
/**
|
||||
* Get the query parameter map and proceed according to token response type.
|
||||
* @param Query parameter map
|
||||
*/
|
||||
getTokenQueryParameter(map: ReadonlyMap<string, string>): void;
|
||||
|
||||
/**
|
||||
* Get cached tokens and scopes and return a new session using all the cached data.
|
||||
* @returns the auth session
|
||||
*/
|
||||
getCachedSession(): CognitoAuthSession;
|
||||
|
||||
/**
|
||||
* This is used to get last signed in user from local storage
|
||||
* @returns the last user name
|
||||
*/
|
||||
getLastUser(): string;
|
||||
|
||||
/**
|
||||
* This is used to save the session tokens and scopes to local storage.
|
||||
*/
|
||||
cacheTokensScopes(): void;
|
||||
|
||||
/**
|
||||
* Compare two sets if they are identical.
|
||||
* @param set1 one set
|
||||
* @param set2 the other set
|
||||
* @returns boolean value is true if two sets are identical
|
||||
*/
|
||||
compareSets(set1: ReadonlySet<any>, set2: ReadonlySet<any>): boolean;
|
||||
|
||||
/**
|
||||
* Get the hostname from url.
|
||||
* @param url the url string
|
||||
* @returns hostname string
|
||||
*/
|
||||
getHostName(url: string): string;
|
||||
|
||||
/**
|
||||
* Get http query parameters and return them as a map.
|
||||
* @param url the url string
|
||||
* @param splitMark query parameters split mark (prefix)
|
||||
* @returns map
|
||||
*/
|
||||
getQueryParameters(url: string, splitMark: string): Map<string, string>;
|
||||
|
||||
/**
|
||||
* helper function to generate a random string
|
||||
* @param length the length of string
|
||||
* @param chars a original string
|
||||
* @returns a random value.
|
||||
*/
|
||||
generateRandomString(length: number, chars: string): string;
|
||||
|
||||
/**
|
||||
* This is used to clear the session tokens and scopes from local storage
|
||||
*/
|
||||
clearCachedTokensScopes(): void;
|
||||
|
||||
/**
|
||||
* This is used to build a user session from tokens retrieved in the authentication result
|
||||
* @param refreshToken Successful auth response from server.
|
||||
*/
|
||||
refreshSession(refreshToken: string): void;
|
||||
|
||||
/**
|
||||
* Make the http POST request.
|
||||
* @param header header JSON object
|
||||
* @param body body JSON object
|
||||
* @param url string
|
||||
* @param onSuccess callback
|
||||
* @param onFailure callback
|
||||
*/
|
||||
makePOSTRequest(header: object, body: object, url: string,
|
||||
onSuccess: (responseText: string) => void,
|
||||
onFailure: (responseText: string) => void): void;
|
||||
|
||||
/**
|
||||
* Create the XHR object
|
||||
* @param method which method to call
|
||||
* @param url the url string
|
||||
* @returns xhr
|
||||
*/
|
||||
createCORSRequest(method: string, url: string): XMLHttpRequest | XDomainRequest;
|
||||
|
||||
/**
|
||||
* The http POST request onFailure callback.
|
||||
* @param err the error object
|
||||
*/
|
||||
onFailure(err: any): void;
|
||||
|
||||
/**
|
||||
* The http POST request onSuccess callback when refreshing tokens.
|
||||
* @param jsonData tokens
|
||||
*/
|
||||
onSuccessRefreshToken(jsonData: string): void;
|
||||
|
||||
/**
|
||||
* The http POST request onSuccess callback when exchanging code for tokens.
|
||||
* @param jsonData tokens
|
||||
*/
|
||||
onSuccessExchangeForToken(jsonData: string): void;
|
||||
|
||||
/**
|
||||
* Launch Cognito Auth UI page.
|
||||
* @param URL the url to launch
|
||||
*/
|
||||
launchUri(URL: string): void;
|
||||
|
||||
/**
|
||||
* @returns scopes string
|
||||
*/
|
||||
getSpaceSeperatedScopeString(): string;
|
||||
|
||||
/**
|
||||
* Create the FQDN(fully qualified domain name) for authorization endpoint.
|
||||
* @returns url
|
||||
*/
|
||||
getFQDNSignIn(): string;
|
||||
|
||||
/**
|
||||
* Sign out the user.
|
||||
*/
|
||||
signOut(): void;
|
||||
|
||||
/**
|
||||
* Create the FQDN(fully qualified domain name) for signout endpoint.
|
||||
* @returns url
|
||||
*/
|
||||
getFQDNSignOut(): string;
|
||||
|
||||
/**
|
||||
* This method returns the encoded data string used for cognito advanced security feature.
|
||||
* This would be generated only when developer has included the JS used for collecting the
|
||||
* data on their client. Please refer to documentation to know more about using AdvancedSecurity
|
||||
* features
|
||||
*/
|
||||
getUserContextData(): string;
|
||||
|
||||
/**
|
||||
* Helper method to let the user know if he has either a valid cached session
|
||||
* or a valid authenticated session from the app integration callback.
|
||||
* @returns userSignedIn
|
||||
*/
|
||||
isUserSignedIn(): boolean;
|
||||
}
|
||||
|
||||
export class DateHelper {
|
||||
/**
|
||||
* @returns The current time in "ddd MMM D HH:mm:ss UTC YYYY" format.
|
||||
*/
|
||||
getNowString(): string;
|
||||
}
|
||||
|
||||
export class StorageHelper {
|
||||
/**
|
||||
* This is used to get a storage object
|
||||
* @returns the storage
|
||||
*/
|
||||
constructor();
|
||||
|
||||
/**
|
||||
* This is used to return the storage
|
||||
* @returns the storage
|
||||
*/
|
||||
getStorage(): Storage;
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
import * as lib from 'amazon-cognito-auth-js';
|
||||
|
||||
const idToken: lib.CognitoIdToken = new lib.CognitoIdToken('fak3T0ken1==');
|
||||
idToken.decodePayload(); // $ExpectType object
|
||||
idToken.setJwtToken('fak3T0ken2=='); // $ExpectType void
|
||||
idToken.getJwtToken(); // $ExpectType string
|
||||
idToken.getExpiration(); // $ExpectType number
|
||||
|
||||
const refreshToken: lib.CognitoRefreshToken = new lib.CognitoRefreshToken('refreshplease==');
|
||||
refreshToken.setToken('refreshagainplease=='); // $ExpectType void
|
||||
refreshToken.getToken(); // $ExpectType string
|
||||
|
||||
const accessToken: lib.CognitoAccessToken = new lib.CognitoAccessToken('fak3T0ken3==');
|
||||
accessToken.decodePayload(); // $ExpectType object
|
||||
accessToken.setJwtToken('fak3T0ken4=='); // $ExpectType void
|
||||
accessToken.getJwtToken(); // $ExpectType string
|
||||
accessToken.getExpiration(); // $ExpectType number
|
||||
accessToken.getUsername(); // $ExpectType string
|
||||
|
||||
const tokenScopes: lib.CognitoTokenScopes = new lib.CognitoTokenScopes(['email', 'custom1']);
|
||||
tokenScopes.setTokenScopes(['openid']); // $ExpectType void
|
||||
tokenScopes.getScopes(); // $ExpectType string[]
|
||||
|
||||
let sessionData: lib.CognitoSessionData = {};
|
||||
let authSession: lib.CognitoAuthSession = new lib.CognitoAuthSession(sessionData);
|
||||
|
||||
sessionData = {
|
||||
IdToken: idToken,
|
||||
RefreshToken: refreshToken,
|
||||
AccessToken: accessToken,
|
||||
TokenScopes: tokenScopes,
|
||||
State: '/myapp/home'
|
||||
};
|
||||
authSession = new lib.CognitoAuthSession(sessionData);
|
||||
|
||||
authSession.setIdToken(new lib.CognitoIdToken('fak3T0ken5==')); // $ExpectType void
|
||||
authSession.setRefreshToken(new lib.CognitoRefreshToken('refreshmeyetagain==')); // $ExpectType void
|
||||
authSession.setAccessToken(new lib.CognitoAccessToken('fak3T0ken6==')); // $ExpectType void
|
||||
authSession.setTokenScopes(new lib.CognitoTokenScopes(['email'])); // $ExpectType void
|
||||
authSession.setState('/myapp/login'); // $ExpectType void
|
||||
authSession.getIdToken(); // $ExpectType CognitoIdToken
|
||||
authSession.getRefreshToken(); // $ExpectType CognitoRefreshToken
|
||||
authSession.getAccessToken(); // $ExpectType CognitoAccessToken
|
||||
authSession.getTokenScopes(); // $ExpectType CognitoTokenScopes
|
||||
authSession.getState(); // $ExpectType string
|
||||
|
||||
let authOptions: lib.CognitoAuthOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout'
|
||||
};
|
||||
let auth: lib.CognitoAuth = new lib.CognitoAuth(authOptions);
|
||||
|
||||
authOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
TokenScopesArray: ['email', 'openid'],
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout',
|
||||
IdentityProvider: 'Facebook',
|
||||
UserPoolId: 'us-east-1_faKE4ReAl',
|
||||
AdvancedSecurityDataCollectionFlag: true
|
||||
};
|
||||
auth = new lib.CognitoAuth(authOptions);
|
||||
|
||||
auth.getClientId(); // $ExpectType string
|
||||
auth.getAppWebDomain(); // $ExpectType string
|
||||
auth.getCurrentUser(); // $ExpectType string
|
||||
auth.setUser('jane.doe'); // $ExpectType void
|
||||
auth.useCodeGrantFlow(); // $ExpectType void
|
||||
auth.useImplicitFlow(); // $ExpectType void
|
||||
auth.getSignInUserSession(); // $ExpectType CognitoAuthSession
|
||||
auth.getUsername(); // $ExpectType string
|
||||
auth.setUsername('john.doe'); // $ExpectType void
|
||||
auth.getState(); // $ExpectType string
|
||||
auth.setState('/myhost/default.htm'); // $ExpectType void
|
||||
auth.getSession(); // $ExpectType void
|
||||
auth.parseCognitoWebResponse('url&stuff=true'); // $ExpectType void
|
||||
auth.getCodeQueryParameter(new Map()); // $ExpectType void
|
||||
auth.getTokenQueryParameter(new Map()); // $ExpectType void
|
||||
auth.getCachedSession(); // $ExpectType CognitoAuthSession
|
||||
auth.getLastUser(); // $ExpectType string
|
||||
auth.cacheTokensScopes(); // $ExpectType void
|
||||
auth.compareSets(new Set(['1']), new Set(['1'])); // $ExpectType boolean
|
||||
auth.getHostName('https://site.com/page?size=10'); // $ExpectType string
|
||||
auth.getQueryParameters('http://site.com?1=1&2=2', '?'); // $ExpectType Map<string, string>
|
||||
auth.generateRandomString(5, '159erf'); // $ExpectType string
|
||||
auth.clearCachedTokensScopes(); // $ExpectType void
|
||||
auth.refreshSession('refreshToken=='); // $ExpectType void
|
||||
// $ExpectType void
|
||||
auth.makePOSTRequest({ 'Content-Type': 'application/json' }, { pool: '2' },
|
||||
'https://auth.com/signin',
|
||||
(data) => console.log(data),
|
||||
(error) => console.log(error));
|
||||
auth.createCORSRequest('POST', '/myapp/login'); // $ExpectType XMLHttpRequest | XDomainRequest
|
||||
auth.onFailure('request failed'); // $ExpectType void
|
||||
auth.onSuccessRefreshToken('{"name":"John", "age":31}'); // $ExpectType void
|
||||
auth.onSuccessExchangeForToken('{"name":"Jane", "age":30}'); // $ExpectType void
|
||||
auth.launchUri('https://auth.com/login'); // $ExpectType void
|
||||
auth.getSpaceSeperatedScopeString(); // $ExpectType string
|
||||
auth.getFQDNSignIn(); // $ExpectType string
|
||||
auth.signOut(); // $ExpectType void
|
||||
auth.getFQDNSignOut(); // $ExpectType string
|
||||
auth.getUserContextData(); // $ExpectType string
|
||||
auth.isUserSignedIn(); // $ExpectType boolean
|
||||
|
||||
const userHandler: lib.CognitoAuthUserHandler = {
|
||||
onSuccess: (authSession: lib.CognitoAuthSession) => console.log(authSession),
|
||||
onFailure: (error: any) => console.log(error)
|
||||
};
|
||||
auth.userhandler = userHandler;
|
||||
|
||||
const constants: lib.CognitoConstants = auth.getCognitoConstants();
|
||||
constants.DOMAIN_SCHEME; // $ExpectType string
|
||||
constants.DOMAIN_PATH_SIGNIN; // $ExpectType string
|
||||
constants.DOMAIN_PATH_TOKEN; // $ExpectType string
|
||||
constants.DOMAIN_PATH_SIGNOUT; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_REDIRECT_URI; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_SIGNOUT_URI; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_RESPONSE_TYPE; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_IDENTITY_PROVIDER; // $ExpectType string
|
||||
constants.DOMAIN_QUERY_PARAM_USERCONTEXTDATA; // $ExpectType string
|
||||
constants.CLIENT_ID; // $ExpectType string
|
||||
constants.STATE; // $ExpectType string
|
||||
constants.SCOPE; // $ExpectType string
|
||||
constants.TOKEN; // $ExpectType string
|
||||
constants.CODE; // $ExpectType string
|
||||
constants.POST; // $ExpectType string
|
||||
constants.PARAMETERERROR; // $ExpectType string
|
||||
constants.SCOPETYPEERROR; // $ExpectType string
|
||||
constants.QUESTIONMARK; // $ExpectType string
|
||||
constants.POUNDSIGN; // $ExpectType string
|
||||
constants.COLONDOUBLESLASH; // $ExpectType string
|
||||
constants.SLASH; // $ExpectType string
|
||||
constants.AMPERSAND; // $ExpectType string
|
||||
constants.EQUALSIGN; // $ExpectType string
|
||||
constants.SPACE; // $ExpectType string
|
||||
constants.CONTENTTYPE; // $ExpectType string
|
||||
constants.CONTENTTYPEVALUE; // $ExpectType string
|
||||
constants.AUTHORIZATIONCODE; // $ExpectType string
|
||||
constants.IDTOKEN; // $ExpectType string
|
||||
constants.ACCESSTOKEN; // $ExpectType string
|
||||
constants.REFRESHTOKEN; // $ExpectType string
|
||||
constants.ERROR; // $ExpectType string
|
||||
constants.ERROR_DESCRIPTION; // $ExpectType string
|
||||
constants.STRINGTYPE; // $ExpectType string
|
||||
constants.STATELENGTH; // $ExpectType number
|
||||
constants.STATEORIGINSTRING; // $ExpectType string
|
||||
constants.WITHCREDENTIALS; // $ExpectType string
|
||||
constants.UNDEFINED; // $ExpectType string
|
||||
constants.SELF; // $ExpectType string
|
||||
constants.HOSTNAMEREGEX; // $ExpectType RegExp
|
||||
constants.QUERYPARAMETERREGEX1; // $ExpectType RegExp
|
||||
constants.QUERYPARAMETERREGEX2; // $ExpectType RegExp
|
||||
constants.HEADER['Content-Type']; // $ExpectType string
|
||||
|
||||
const dateHelper: lib.DateHelper = new lib.DateHelper();
|
||||
dateHelper.getNowString(); // $ExpectType string
|
||||
|
||||
const storageHelper: lib.StorageHelper = new lib.StorageHelper();
|
||||
storageHelper.getStorage(); // $ExpectType Storage
|
||||
@@ -0,0 +1,22 @@
|
||||
AmazonCognitoIdentity.CognitoIdToken; // $ExpectType typeof CognitoIdToken
|
||||
AmazonCognitoIdentity.CognitoRefreshToken; // $ExpectType typeof CognitoRefreshToken
|
||||
AmazonCognitoIdentity.CognitoAccessToken; // $ExpectType typeof CognitoAccessToken
|
||||
AmazonCognitoIdentity.CognitoTokenScopes; // $ExpectType typeof CognitoTokenScopes
|
||||
AmazonCognitoIdentity.CognitoAuthSession; // $ExpectType typeof CognitoAuthSession
|
||||
AmazonCognitoIdentity.CognitoAuth; // $ExpectType typeof CognitoAuth
|
||||
AmazonCognitoIdentity.DateHelper; // $ExpectType typeof DateHelper
|
||||
AmazonCognitoIdentity.StorageHelper; // $ExpectType typeof StorageHelper
|
||||
|
||||
const sessionData: AmazonCognitoIdentity.CognitoSessionData = {};
|
||||
new AmazonCognitoIdentity.CognitoAuthSession(sessionData);
|
||||
|
||||
const authOptions: AmazonCognitoIdentity.CognitoAuthOptions = {
|
||||
ClientId: '1a2b3c4d5e6f7g',
|
||||
AppWebDomain: 'myapp.auth.us-east-1.amazoncognito.com',
|
||||
RedirectUriSignIn: 'https://myapp.com/login',
|
||||
RedirectUriSignOut: 'https://myapp.com/logout'
|
||||
};
|
||||
const auth = new AmazonCognitoIdentity.CognitoAuth(authOptions);
|
||||
auth.userhandler; // $ExpectType CognitoAuthUserHandler
|
||||
auth.getCognitoConstants(); // $ExpectType CognitoConstants
|
||||
auth.createCORSRequest('', ''); // $ExpectType XMLHttpRequest | XDomainRequest
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"dom",
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/amazon-cognito-auth-js-tests.ts",
|
||||
"test/amazon-cognito-auth-js-umd-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import Message = require('amp-message');
|
||||
|
||||
// $ExpectType Message
|
||||
new Message(new Buffer('aaa'));
|
||||
|
||||
// $ExpectType Message
|
||||
new Message([new Buffer('aaa'), new Buffer('bbb')]);
|
||||
|
||||
const message = new Message([new Buffer('aaa'), new Buffer('bbb')]);
|
||||
|
||||
// $ExpectType string
|
||||
message.inspect();
|
||||
|
||||
// $ExpectType Buffer
|
||||
message.toBuffer();
|
||||
|
||||
// $ExpectType number
|
||||
message.push(new Buffer('ccc'));
|
||||
|
||||
// $ExpectType Buffer | undefined
|
||||
message.pop();
|
||||
|
||||
// $ExpectType Buffer | undefined
|
||||
message.shift();
|
||||
|
||||
// $ExpectType number
|
||||
message.unshift(new Buffer('ddd'));
|
||||
|
||||
// $ExpectError
|
||||
new Message();
|
||||
|
||||
// $ExpectError
|
||||
new Message(1);
|
||||
|
||||
// $ExpectError
|
||||
new Message({});
|
||||
|
||||
// $ExpectError
|
||||
new Message('aaa');
|
||||
|
||||
// $ExpectError
|
||||
message.push(1);
|
||||
|
||||
// $ExpectError
|
||||
message.push({});
|
||||
|
||||
// $ExpectError
|
||||
message.push('aaa');
|
||||
|
||||
// $ExpectError
|
||||
message.unshift(1);
|
||||
|
||||
// $ExpectError
|
||||
message.unshift({});
|
||||
|
||||
// $ExpectError
|
||||
message.unshift('aaa');
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user