Merge branch 'master' into flip-typesVersions

This commit is contained in:
Nathan Shively-Sanders 2020-08-20 13:26:12 -07:00
commit 8f306d1a78
79 changed files with 2133 additions and 628 deletions

View File

@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: "12"

View File

@ -48,6 +48,7 @@ tl.add({
const path = anime.path('#motionPath path');
test1.play();
test1.tick(10);
test2.reverse();
test3.pause();
tl.seek(4000);

View File

@ -89,6 +89,7 @@ declare namespace anime {
restart(): void;
reverse(): void;
seek(time: number): void;
tick(time: number): void;
began: boolean;
paused: boolean;

View File

@ -0,0 +1,22 @@
import bemmer from 'bemmer';
// $ExpectType Builder
bemmer.createBuilder('cn1', 'cn2', 'cn3');
// $ExpectType Builder
bemmer.create('cn1', 'cn2', 'cn3');
// $ExpectType Builder
const builder = bemmer.createBuilder('singleClassName');
// $ExpectType string
builder('test');
// $ExpectType string
builder('test', { foo: true });
// $ExpectType string
builder('test', { foo: 100, baz: 'stuff' });
// $ExpectType boolean
bemmer.isBuilder(builder);

13
types/bemmer/index.d.ts vendored Normal file
View File

@ -0,0 +1,13 @@
// Type definitions for bemmer 1.1
// Project: https://github.com/axross/bemmer
// Definitions by: Nathan <https://github.com/nweber-gh>
// Bryan <https://github.com/bdwain>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export interface Builder {
(classname?: string, modifiers?: { [index: string]: any }): string;
}
export function createBuilder(...classnames: string[]): Builder;
export function create(...classnames: string[]): Builder;
export function isBuilder(target: any): target is Builder;

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"allowSyntheticDefaultImports": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"bemmer-tests.ts"
]
}

1
types/bemmer/tslint.json Normal file
View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -288,6 +288,13 @@ const linearScaleChart: Chart = new Chart(ctx, {
},
xAxes: [{
type: 'time',
time: {
adapters: {
date: {
locale: 'de'
}
}
},
distribution: 'series',
ticks: {
source: 'data',

View File

@ -779,7 +779,12 @@ declare namespace Chart {
year?: string;
}
interface DateAdapterOptions {
date?: object;
}
interface TimeScale extends ChartScales {
adapters?: DateAdapterOptions;
displayFormats?: TimeDisplayFormat;
isoWeekday?: boolean;
max?: string;

View File

@ -20,12 +20,14 @@ const [GOOGLE_SERVICE_ACCOUNT_EMAIL, GOOGLE_PRIVATE_KEY] = ['email', 'key'];
console.log(doc.title);
await doc.updateProperties({ title: 'renamed doc' });
let sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
console.log(sheet.title);
console.log(sheet.rowCount);
let sheet = doc.sheetsByIndex[0]; // or use doc.sheetsById[id]
console.log(sheet.title);
console.log(sheet.rowCount);
// adding / removing sheets
const newSheet = await doc.addSheet({ title: 'hot new sheet!' });
const title = 'hot new sheet!';
await doc.addSheet({ title });
const newSheet = doc.sheetsByTitle[title];
await newSheet.delete();
// create a sheet and set the header row

View File

@ -1,4 +1,4 @@
// Type definitions for google-spreasheet 3.0
// Type definitions for google-spreadsheet 3.0
// Project: https://github.com/theoephraim/node-google-spreadsheet
// Definitions by: the-vampiire <https://github.com/the-vampiire>
// Federico Grandi <https://github.com/EndBug>
@ -1013,6 +1013,13 @@ export class GoogleSpreadsheet implements SpreadsheetBasicProperties {
*/
readonly sheetsByIndex: GoogleSpreadsheetWorksheet[];
/**
* @description
* object of child worksheets
* - keyed by the worksheet title
*/
readonly sheetsByTitle: { [title: string]: GoogleSpreadsheetWorksheet };
/**
* @description
* count of child worksheets

View File

@ -7,6 +7,7 @@ function test_graph() {
directed: true,
multigraph: true
});
g.setGraph({});
g.setEdge('a', 'b');
g.setEdge('a', 'b', 1.023, 'test');
g.setEdge({ v: 'a', w: 'b', name: 'test' }, 1.023);

View File

@ -362,7 +362,7 @@ declare module "graphlib" {
* @argument label - label value.
* @returns the graph, allowing this to be chained with other functions.
*/
setGraph(label: string): Graph;
setGraph(label: any): Graph;
/**
* Gets the graph label.

View File

@ -136,7 +136,7 @@ declare namespace inquirer {
/**
* Prompts the questions to the user.
*/
<T>(questions: QuestionCollection<T>): Promise<T> & { ui: PromptUI };
<T>(questions: QuestionCollection<T>, initialAnswers?: Partial<T>): Promise<T> & { ui: PromptUI };
/**
* Registers a new prompt-type.

View File

@ -73,3 +73,12 @@ inquirer.prompt([
previewColors: true
}
]);
inquirer.prompt([
{
name: 'foo',
default: 'bar'
}
], {
foo: 'baz'
});

View File

@ -54,13 +54,15 @@ declare global {
/** Optional comment */
c?: string;
}
type SettableState = Partial<Omit<State, "val">> & Pick<State, "val">;
type SettableState = Partial<Omit<State, 'val'>> & Pick<State, 'val'>;
type Session = any; // TODO: implement
type ObjectType = 'state' | 'channel' | 'device';
type CommonType = 'number' | 'string' | 'boolean' | 'array' | 'object' | 'mixed' | 'file';
type Languages = 'en' | 'de' | 'ru' | 'pt' | 'nl' | 'fr' | 'it' | 'es' | 'pl' | 'zh-cn';
// Objects are JSON-serializable
type ObjectField =
| string
@ -138,6 +140,17 @@ declare global {
/** Custom settings for this state */
custom?: Record<string, any>;
/**
* Settings for IOT adapters and how the state should be named in e.g. Alexa.
* The string "ignore" is a special case, causing the state to be ignored.
*/
smartName?: string | ({ [lang in Languages]?: string; } & {
/** Which kind of device this is */
smartType?: string | null;
/** Which value to set when the ON command is issued */
byOn?: string | null;
});
}
interface ChannelCommon extends ObjectCommon {
/** description of this channel */
@ -151,6 +164,12 @@ declare global {
custom?: undefined;
// TODO: any other definition for device?
}
interface EnumCommon extends ObjectCommon {
// Only states can have common.custom
custom?: undefined;
/** The IDs of the enum members */
members?: string[];
}
interface OtherCommon extends ObjectCommon {
[propName: string]: ObjectField | undefined;
@ -170,7 +189,7 @@ declare global {
enums?: Record<string, string>;
type: string; // specified in the derived interfaces
// Be strict with what we allow here. Read objects overwrite this with any.
common: StateCommon | ChannelCommon | DeviceCommon | OtherCommon;
common: StateCommon | ChannelCommon | DeviceCommon | EnumCommon | OtherCommon;
acl?: ObjectACL;
from?: string;
ts?: number;
@ -212,16 +231,24 @@ declare global {
common?: Partial<OtherCommon>;
}
interface EnumObject extends BaseObject {
type: 'enum';
common: EnumCommon;
}
interface PartialEnumObject extends Partial<Omit<EnumObject, 'common'>> {
common?: Partial<EnumCommon>;
}
interface OtherObject extends BaseObject {
type: 'adapter' | 'config' | 'enum' | 'group' | 'host' | 'info' | 'instance' | 'meta' | 'script' | 'user';
type: 'adapter' | 'config' | 'group' | 'host' | 'info' | 'instance' | 'meta' | 'script' | 'user';
common: OtherCommon;
}
interface PartialOtherObject extends Partial<Omit<OtherObject, 'common'>> {
common?: Partial<ObjectCommon>;
common?: Partial<OtherCommon>;
}
// Base type for Objects. Should not be used directly
type AnyObject = StateObject | ChannelObject | DeviceObject | FolderObject | OtherObject;
type AnyObject = StateObject | ChannelObject | DeviceObject | FolderObject | EnumObject | OtherObject;
// For all objects that are exposed to the user we need to tone the strictness down.
// Otherwise, every operation on objects becomes a pain to work with
@ -241,8 +268,9 @@ declare global {
| SettableObjectWorker<ChannelObject>
| SettableObjectWorker<DeviceObject>
| SettableObjectWorker<FolderObject>
| SettableObjectWorker<EnumObject>
| SettableObjectWorker<OtherObject>;
type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialFolderObject | PartialOtherObject;
type PartialObject = PartialStateObject | PartialChannelObject | PartialDeviceObject | PartialFolderObject | PartialEnumObject | PartialOtherObject;
/** Defines access rights for a single file */
interface FileACL {

View File

@ -497,3 +497,12 @@ adapter.getObjectAsync('id').then(obj => {
obj && obj.common && obj.common.alias && obj.common.alias.id;
obj && obj.common && obj.common.unit && obj.common.workingID;
});
declare let state: ioBroker.StateObject;
if (typeof state.common.smartName === "object") {
state.common.smartName.de && state.common.smartName.de.toUpperCase();
state.common.smartName.byOn && state.common.smartName.byOn.toUpperCase();
}
declare let enumObj: ioBroker.EnumObject;
enumObj.common.members && enumObj.common.members.map(() => 1);

19
types/jasmine-expect-jsx/index.d.ts vendored Normal file
View File

@ -0,0 +1,19 @@
// Type definitions for jasmine-expect-jsx 3.2
// Project: https://github.com/smacker/jasmine-expect-jsx#readme
// Definitions by: Nathan <https://github.com/nweber-gh>
// Bryan <https://github.com/bdwain>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// Minimum TypeScript Version: 3.2
/// <reference types="jasmine"/>
import * as React from 'react';
declare global {
namespace jasmine {
interface Matchers<T> {
toEqualJSX(element: Expected<T>): boolean;
toIncludeJSX(element: Expected<T>): boolean;
}
}
}

View File

@ -0,0 +1,18 @@
/// <reference types="../jasmine"/>
/// <reference types="./index"/>
describe('test suite', () => {
it('tests toEqualJSX method', () => {
const component = (
<div>hello world</div>
);
expect(component).toEqualJSX(<div>hello world</div>);
});
it('tests toIncludeJSX method', () => {
const component = (
<div><span>hello world</span></div>
);
expect(component).toIncludeJSX(<span>hello world</span>);
});
});

View File

@ -0,0 +1,25 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"jsx": "preserve",
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"esModuleInterop": true
},
"files": [
"index.d.ts",
"jasmine-expect-jsx-tests.tsx"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -1,6 +1,8 @@
// Type definitions for kurento-client 6.12
// Type definitions for kurento-client 6.14
// Project: https://github.com/Kurento/kurento-client-js, https://www.kurento.org
// Definitions by: James Hill <https://github.com/jhukdev>, Michel Albers <https://github.com/michelalbers>
// Definitions by: James Hill <https://github.com/jhukdev>
// Michel Albers <https://github.com/michelalbers>
// Joe Flateau <https://github.com/joeflateau>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
declare namespace kurento {
@ -31,7 +33,7 @@ declare namespace kurento {
create(type: 'MediaPipeline'): Promise<MediaPipeline>;
create(type: 'WebRtcEndpoint'): Promise<WebRtcEndpoint>;
create(type: 'RecorderEndpoint', options: RecorderEndpointOptions): Promise<RecorderEndpoint>;
on(event: 'OnIceCandidate', callback: (event: IceCandidate) => void): void;
on(event: 'OnIceCandidate', callback: (event: IceCandidateEvent) => void): void;
on(event: 'Error', callback: (error: Error) => void): void;
on(event: 'Recording' | 'Paused' | 'Stopped', callback: () => void): void;
getMediaobjectById(objectId: string): Promise<MediaPipeline | WebRtcEndpoint | RecorderEndpoint>;
@ -160,6 +162,15 @@ declare namespace kurento {
sdpMLineIndex: number;
}
interface IceCandidateEvent {
candidate: IceCandidate;
souce: string;
tags: object;
timestamp: string;
timestampMillis: string;
type: 'OnIceCandidate';
}
type Callback<T> = (error: Error, result: T) => void;
}

View File

@ -13,9 +13,18 @@ async () => {
pipeline.addTag('userId', '012345')
]);
const signaling = {
emit: (...args: any[]): void => {},
on(event: string, handler: (...args: any[]) => void): void {},
};
endpoint.addIceCandidate(candidate);
endpoint.on('OnIceCandidate', ({ candidate }) => {
signaling.emit(candidate.candidate);
});
signaling.on('icecandidate', candidate => {
const value = kurento.getComplexType('IceCandidate')(candidate);
endpoint.addIceCandidate(value);

View File

@ -251,7 +251,7 @@ declare namespace mapboxgl {
*/
queryRenderedFeatures(
pointOrBox?: PointLike | [PointLike, PointLike],
options?: { layers?: string[]; filter?: any[]; validate?: boolean },
options?: { layers?: string[]; filter?: any[] } & FilterOptions,
): MapboxGeoJSONFeature[];
/**
@ -269,8 +269,7 @@ declare namespace mapboxgl {
parameters?: {
sourceLayer?: string;
filter?: any[];
validate?: boolean;
},
} & FilterOptions,
): MapboxGeoJSONFeature[];
setStyle(style: mapboxgl.Style | string, options?: { diff?: boolean; localIdeographFontFamily?: string }): this;
@ -315,7 +314,7 @@ declare namespace mapboxgl {
getLayer(id: string): mapboxgl.Layer;
setFilter(layer: string, filter?: any[] | boolean | null): this;
setFilter(layer: string, filter?: any[] | boolean | null, options?: FilterOptions | null): this;
setLayerZoomRange(layerId: string, minzoom: number, maxzoom: number): this;
@ -1647,6 +1646,18 @@ declare namespace mapboxgl {
error: Error;
}
/**
* FilterOptions
*/
export interface FilterOptions {
/**
* Whether to check if the filter conforms to the Mapbox GL Style Specification.
* Disabling validation is a performance optimization that should only be used
* if you have previously validated the values you will be passing to this function.
*/
validate?: boolean | null;
}
/**
* AnimationOptions
*/

View File

@ -268,6 +268,14 @@ map.flyTo({
const features = map.queryRenderedFeatures([0, 0], { layers: ['custom'], validate: false });
features; // $ExpectType MapboxGeoJSONFeature[]
// querySourceFeatures
const features2 = map.querySourceFeatures('some_source', {
sourceLayer: 'source_layer',
filter: ['all'],
validate: null,
});
features2; // $ExpectType MapboxGeoJSONFeature[]
/**
* GeoJSONSource
*/
@ -823,6 +831,12 @@ map.showPadding = false;
expectType<mapboxgl.Map>(map.setFilter('layerId', true));
expectType<mapboxgl.Map>(map.setFilter('layerId', false));
map.setFilter('layerId', true, { validate: true });
map.setFilter('layerId', true, { validate: null });
map.setFilter('layerId', true, {});
// $ExpectError
map.setFilter('layerId', true, { some_option: 'some_string' });
// $ExpectType Map
map.setMinZoom(5);
// $ExpectType Map

View File

@ -250,13 +250,13 @@ export interface IColumn extends ISqlType {
primary: boolean;
}
declare class columns extends Array {
declare class columns extends Array<IColumn> {
public add(name: string, type: (() => ISqlType) | ISqlType, options?: IColumnOptions): number;
}
type IRow = (string | number | boolean | Date | Buffer | undefined)[];
declare class rows extends Array {
declare class rows extends Array<IRow> {
public add(...row: IRow): number;
}

View File

@ -249,3 +249,8 @@ async function test_msnodesqlv8() {
const result = await connection.query`SELECT * FROM sys.databases`;
await connection.close();
}
function test_rows_and_columnns() {
var table = new sql.Table('#temp_table3');
table.columns.forEach(col => col.name)
}

View File

@ -184,7 +184,7 @@ export interface MUIDataTableColumnOptions {
updateDirection: (params: any) => any,
) => string | React.ReactNode;
draggable?: boolean;
display?: 'true' | 'false' | 'excluded';
display?: boolean | string;
download?: boolean;
empty?: boolean;
filter?: boolean;
@ -210,7 +210,7 @@ export interface MUIDataTableIsRowCheck {
{
index: number;
dataIndex: number;
}
},
];
}

81
types/node-isbn/index.d.ts vendored Normal file
View File

@ -0,0 +1,81 @@
// Type definitions for node-isbn 1.6
// Project: https://github.com/palmerabollo/node-isbn#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { AxiosRequestConfig } from 'axios';
declare namespace isbn {
interface Isbn {
PROVIDER_NAMES: typeof PROVIDER_NAMES;
/**
* Provider API that gets chained before `resolve`. If this is specified, the
* `resolve` fn will honor this order.
*
* @param providers - Array of providers. Must be one of more from `isbn.PROVIDER_NAMES`
*
* @example
*
* ```
* isbn
* .provider([isbn.PROVIDER_NAMES.OPENLIBRARY, isbn.PROVIDER_NAMES.GOOGLE])
* .resolve(...)
* ```
*/
provider(providers: string[]): this;
/**
* Resolves book info, given an isbn
* @param isbn
*/
resolve(isbn: string, options: AxiosRequestConfig, callback?: ResolveCallback): void;
resolve(isnb: string, options?: AxiosRequestConfig): Promise<Book>;
resolve(isbn: string, callback: ResolveCallback): void;
}
const PROVIDER_NAMES: {
GOOGLE: 'google';
OPENLIBRARY: 'openlibrary';
WORLDCAT: 'worldcat';
ISBNDB: 'isbndb';
};
type BookLanguage = 'en' | 'es' | 'fr' | 'unknown';
interface ResolveCallback {
(error: Error | null, book: Book): void;
}
interface Book {
authors: string[];
categories: string[];
description?: string;
imageLinks?: {
smallThumbnail: string;
thumbnail: string;
};
industryIdentifiers: string[];
infoLink: string;
language: BookLanguage;
pageCount?: number;
previewLink: string;
printType: 'BOOK';
publishedDate: string;
publisher: string;
title: string;
}
}
/**
* A simple node.js module that resolves books by ISBN using multiple services:
* - Google Books API
* - Open Library Books API
* - WorldCat xISBN API
* - ISBNdb API using API key in the environment variable ISBNDB_API_KEY
*
* @see {@link https://github.com/palmerabollo/node-isbn#examples}
*/
declare const Isbn: isbn.Isbn;
export = Isbn;

View File

@ -0,0 +1,64 @@
/// <reference types="node" />
import isbn = require('node-isbn');
isbn.resolve('0735619670', (err, book) => {
if (err) {
console.log('Book not found', err);
} else {
console.log('Book found %j', book);
}
});
isbn.resolve('0735619670', { timeout: 15000 }, (err, book) => {
if (err) {
console.log('Book not found', err);
} else {
console.log('Book found %j', book);
}
});
isbn.resolve('0735619670')
.then(book => {
console.log('Book found %j', book);
})
.catch(err => {
console.log('Book not found', err);
});
isbn.provider(['openlibrary', 'google'])
.resolve('0735619670')
.then(book => {
console.log('Book found %j', book);
})
.catch(err => {
console.log('Book not found', err);
});
isbn.provider(['google'])
.resolve('0735619670')
.then(book => {
console.log('Book found %j', book);
})
.catch(err => {
console.log('Book not found', err);
});
isbn.provider([isbn.PROVIDER_NAMES.GOOGLE])
.resolve('0735619670')
.then(book => {
console.log('Book found %j', book);
})
.catch(err => {
console.log('Book not found', err);
});
const input = process.argv.slice(2)[0] || '0735619670';
isbn.resolve(input, (err, book) => {
if (err) {
console.log(`Book isbn:${input} not found`, err);
} else {
console.log(`Book isbn:${input} found %j`, book);
}
});

View File

@ -0,0 +1,6 @@
{
"private": true,
"dependencies": {
"axios": "^0.19.2"
}
}

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"node-isbn-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }

View File

@ -6,7 +6,7 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare class Notify {
constructor(title: string, options?: INotifyOption);
constructor(title: string, options?: Notify.NotifyOption);
/**
* Check is permission is needed for the user to receive notifications.
@ -54,65 +54,67 @@ declare class Notify {
handleEvent(e: Event): void;
}
/**
* Interface for the Notify's optional parameter.
*/
interface INotifyOption {
declare namespace Notify {
/**
* Interface for the Notify's optional parameter.
*/
interface NotifyOption {
/**
* notification message body
*/
body?: string;
/**
* notification message body
*/
body?: string;
/**
* path for icon to display in notification
*/
icon?: string;
/**
* path for icon to display in notification
*/
icon?: string;
/**
* unique identifier to stop duplicate notifications
*/
tag?: string;
/**
* unique identifier to stop duplicate notifications
*/
tag?: string;
/**
* number of seconds to close the notification automatically
*/
timeout?: number;
/**
* number of seconds to close the notification automatically
*/
timeout?: number;
/**
* whether this notification should be silent or not
*/
silent?: boolean;
/**
* whether this notification should be silent or not
*/
silent?: boolean;
/**
* callback when notification is shown
*/
notifyShow?(e: Event): any;
/**
* callback when notification is closed
*/
notifyClose?: Function;
/**
* callback when notification is clicked
*/
notifyClick?: Function;
/**
* callback when notification throws an error
*/
notifyError?: Function;
/**
* callback when user has granted permission
*/
permissionGranted?: Function;
/**
* callback when user has denied permission
*/
permissionDenied?: Function;
/**
* callback when notification is shown
*/
notifyShow?(e: Event): any;
/**
* callback when notification is closed
*/
notifyClose?: Function;
/**
* callback when notification is clicked
*/
notifyClick?: Function;
/**
* callback when notification throws an error
*/
notifyError?: Function;
/**
* callback when user has granted permission
*/
permissionGranted?: Function;
/**
* callback when user has denied permission
*/
permissionDenied?: Function;
/**
* whether we expect for user interaction or not
* in case value is true the timeout for closing the notification won't be set
*/
requireInteraction?: boolean;
/**
* whether we expect for user interaction or not
* in case value is true the timeout for closing the notification won't be set
*/
requireInteraction?: boolean;
}
}
export = Notify
export = Notify;

View File

@ -1,38 +1,41 @@
import Notify from 'notifyjs';
import Notify, { NotifyOption } from 'notifyjs';
function test_Notify_constructor() {
//Min
var n = new Notify("hoge")
var n = new Notify('hoge');
n.show();
//With option
n = new Notify("hoge", { body: "fuga" });
const option: NotifyOption = { body: 'fuga' };
n = new Notify('hoge', option);
n.show();
//With Full option
n = new Notify("hoge", {
body: "fuga",
icon: "./logo.png",
tag: "user",
n = new Notify('hoge', {
body: 'fuga',
icon: './logo.png',
tag: 'user',
timeout: 2,
silent: false,
notifyShow: (e: Event) => console.log("notifyShow", e),
notifyClose: () => console.log("notifyClose"),
notifyClick: () => console.log("notifyClick"),
notifyError: () => console.log("notifyError"),
permissionGranted: () => console.log("permissionGranted"),
permissionDenied: () => console.log("permissionDenied"),
requireInteraction: true
notifyShow: (e: Event) => console.log('notifyShow', e),
notifyClose: () => console.log('notifyClose'),
notifyClick: () => console.log('notifyClick'),
notifyError: () => console.log('notifyError'),
permissionGranted: () => console.log('permissionGranted'),
permissionDenied: () => console.log('permissionDenied'),
requireInteraction: true,
});
n.show();
}
function test_Notify_static_methods() {
Notify.needsPermission;
Notify.requestPermission();
Notify.requestPermission(() => console.log("onPermissionGrantedCallback"));
Notify.requestPermission(() => console.log("onPermissionGrantedCallback"), () => console.log("onPermissionDeniedCallback"));
Notify.requestPermission(() => console.log('onPermissionGrantedCallback'));
Notify.requestPermission(
() => console.log('onPermissionGrantedCallback'),
() => console.log('onPermissionDeniedCallback'),
);
Notify.isSupported();
Notify.permissionLevel;
}

View File

@ -9229,6 +9229,8 @@ declare namespace Office {
* When you use the `Time.setAsync` method to set the end time, you should use the `convertToUtcClientTime` method to convert the local time on
* the client to UTC for the server.
*
* **Important**: In the Windows client, you can't use this property to update the end of a recurrence.
*
* @remarks
*
* **{@link https://docs.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions | Minimum permission level}**: `ReadItem`
@ -9426,6 +9428,8 @@ declare namespace Office {
* When you use the `Time.setAsync` method to set the start time, you should use the `convertToUtcClientTime` method to convert the local time on
* the client to UTC for the server.
*
* **Important**: In the Windows client, you can't use this property to update the start of a recurrence.
*
* @remarks
*
* **{@link https://docs.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions | Minimum permission level}**: `ReadItem`
@ -11619,9 +11623,9 @@ declare namespace Office {
* append-on-send runs before on-send functionality.
*
* **Important**: If your add-in implements the on-send feature and calls `appendOnSendAsync` in the `ItemSend` handler,
* an error is returned as this scenario is not supported.
* the `appendOnSendAsync` call returns an error as this scenario is not supported.
*
* **Important**: To use `appendOnSendAsync`, the `AppendOnSend` extended permission must be included in the `ExtendedPermissions` node of the manifest.
* **Important**: To use `appendOnSendAsync`, the `ExtendedPermissions` manifest node must include the `AppendOnSend` extended permission.
*
* **Note**: To clear data from a previous `appendOnSendAsync` call, you can call it again with the `data` parameter set to `null`.
*
@ -11657,9 +11661,9 @@ declare namespace Office {
* append-on-send runs before on-send functionality.
*
* **Important**: If your add-in implements the on-send feature and calls `appendOnSendAsync` in the `ItemSend` handler,
* an error is returned as this scenario is not supported.
* the `appendOnSendAsync` call returns an error as this scenario is not supported.
*
* **Important**: To use `appendOnSendAsync`, the `AppendOnSend` extended permission must be included in the `ExtendedPermissions` node of the manifest.
* **Important**: To use `appendOnSendAsync`, the `ExtendedPermissions` manifest node must include the `AppendOnSend` extended permission.
*
* **Note**: To clear data from a previous `appendOnSendAsync` call, you can call it again with the `data` parameter set to `null`.
*
@ -11946,6 +11950,13 @@ declare namespace Office {
*
* **Important**: In Outlook on the web, `setSignatureAsync` only works on messages.
*
* **Important**: If your add-in implements the
* {@link https://docs.microsoft.com/office/dev/add-ins/outlook/autolaunch | event-based activation feature using `LaunchEvent` in the manifest},
* and calls `setSignatureAsync` in the event handler, the following behavior applies.
*
* - When the user composes a new item (including reply or forward), the signature is set but doesn't modify the form. This means
* if the user closes the form without making other edits, they won't be prompted to save changes.
*
* [Api set: Mailbox Preview]
*
* @remarks
@ -11976,6 +11987,13 @@ declare namespace Office {
*
* **Important**: In Outlook on the web, `setSignatureAsync` only works on messages.
*
* **Important**: If your add-in implements the
* {@link https://docs.microsoft.com/office/dev/add-ins/outlook/autolaunch | event-based activation feature using `LaunchEvent` in the manifest},
* and calls `setSignatureAsync` in the event handler, the following behavior applies.
*
* - When the user composes a new item (including reply or forward), the signature is set but doesn't modify the form. This means
* if the user closes the form without making other edits, they won't be prompted to save changes.
*
* [Api set: Mailbox Preview]
*
* @remarks
@ -17882,6 +17900,8 @@ declare namespace Office {
*
* The time must be in UTC; you can get the correct UTC time by using the `convertToUtcClientTime` method.
*
* **Important**: In the Windows client, you can't use this function to update the start or end of a recurrence.
*
* [Api set: Mailbox 1.1]
*
* @remarks
@ -17909,6 +17929,8 @@ declare namespace Office {
*
* The time must be in UTC; you can get the correct UTC time by using the `convertToUtcClientTime` method.
*
* **Important**: In the Windows client, you can't use this function to update the start or end of a recurrence.
*
* [Api set: Mailbox 1.1]
*
* @remarks

View File

@ -8934,6 +8934,8 @@ declare namespace Office {
* When you use the `Time.setAsync` method to set the end time, you should use the `convertToUtcClientTime` method to convert the local time on
* the client to UTC for the server.
*
* **Important**: In the Windows client, you can't use this property to update the end of a recurrence.
*
* @remarks
*
* **{@link https://docs.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions | Minimum permission level}**: `ReadItem`
@ -9089,6 +9091,8 @@ declare namespace Office {
* When you use the `Time.setAsync` method to set the start time, you should use the `convertToUtcClientTime` method to convert the local time on
* the client to UTC for the server.
*
* **Important**: In the Windows client, you can't use this property to update the start of a recurrence.
*
* @remarks
*
* **{@link https://docs.microsoft.com/office/dev/add-ins/outlook/understanding-outlook-add-in-permissions | Minimum permission level}**: `ReadItem`
@ -16227,6 +16231,8 @@ declare namespace Office {
*
* The time must be in UTC; you can get the correct UTC time by using the `convertToUtcClientTime` method.
*
* **Important**: In the Windows client, you can't use this function to update the start or end of a recurrence.
*
* [Api set: Mailbox 1.1]
*
* @remarks
@ -16254,6 +16260,8 @@ declare namespace Office {
*
* The time must be in UTC; you can get the correct UTC time by using the `convertToUtcClientTime` method.
*
* **Important**: In the Windows client, you can't use this function to update the start or end of a recurrence.
*
* [Api set: Mailbox 1.1]
*
* @remarks

View File

@ -486,12 +486,12 @@ namespace Parse {
fetchAllIfNeeded<T extends Object>(list: T[], options?: Object.FetchAllOptions): Promise<T[]>;
fetchAllIfNeededWithInclude<T extends Object>(
list: T[],
keys: string | Array<string | string[]>,
keys: keyof T['attributes'] | Array<keyof T['attributes']>,
options?: RequestOptions
): Promise<T[]>;
fetchAllWithInclude<T extends Object>(
list: T[],
keys: string | Array<string | string[]>,
keys: keyof T['attributes'] | Array<keyof T['attributes']>,
options?: RequestOptions,
): Promise<T[]>;
fromJSON<T extends Object>(json: any, override?: boolean): T;
@ -678,6 +678,7 @@ namespace Parse {
filter(callback: (currentObject: T, index: number, query: Query) => PromiseLike<boolean> | boolean, options?: Query.BatchOptions): Promise<T[]>;
endsWith<K extends (keyof T['attributes'] | keyof BaseAttributes)>(key: K, suffix: string): this;
equalTo<K extends (keyof T['attributes'] | keyof BaseAttributes)>(key: K, value: T['attributes'][K] | (T['attributes'][K] extends Object ? Pointer : never)): this;
exclude<K extends (keyof T['attributes'] | keyof BaseAttributes)>(...keys: K[]): this;
exists<K extends (keyof T['attributes'] | keyof BaseAttributes)>(key: K): this;
find(options?: Query.FindOptions): Promise<T[]>;
first(options?: Query.FirstOptions): Promise<T | undefined>;
@ -939,7 +940,7 @@ namespace Parse {
* schema.save();
* ```
*/
class Schema {
class Schema<T extends Object = any> {
constructor(className: string);
/**
@ -950,12 +951,12 @@ namespace Parse {
*/
static all(): Promise<Schema[]>;
addArray(name: string, options?: Schema.FieldOptions<any[]>): this;
addBoolean(name: string, options?: Schema.FieldOptions<boolean>): this;
addDate(name: string, options?: Schema.FieldOptions<Date>): this;
addArray(key: Schema.AttrType<T, any[]>, options?: Schema.FieldOptions<any[]>): this;
addBoolean(key: Schema.AttrType<T, boolean>, options?: Schema.FieldOptions<boolean>): this;
addDate(key: Schema.AttrType<T, Date>, options?: Schema.FieldOptions<Date>): this;
addField<T extends Schema.TYPE = any>(name: string, type?: T, options?: Schema.FieldOptions): this;
addFile(name: string, options?: Schema.FieldOptions<File>): this;
addGeoPoint(name: string, options?: Schema.FieldOptions<GeoPoint>): this;
addFile(key: Schema.AttrType<T, File>, options?: Schema.FieldOptions<File>): this;
addGeoPoint(key: Schema.AttrType<T, GeoPoint>, options?: Schema.FieldOptions<GeoPoint>): this;
/**
* Adding an Index to Create / Update a Schema
@ -969,8 +970,9 @@ namespace Parse {
*/
addIndex(name: string, index: Schema.Index): this;
addNumber(name: string, options?: Schema.FieldOptions<number>): this;
addObject(name: string, options?: Schema.FieldOptions<object>): this;
addNumber(key: Schema.AttrType<T, number>, options?: Schema.FieldOptions<number>): this;
addObject(key: Schema.AttrType<T, object>, options?: Schema.FieldOptions<object>): this;
/**
* Adding Pointer Field
@ -978,9 +980,9 @@ namespace Parse {
* @param targetClass Name of the target Pointer Class
* @return Returns the schema, so you can chain this call.
*/
addPointer(name: string, targetClass: string, options?: Schema.FieldOptions<Pointer>): this;
addPointer(key: Schema.AttrType<T, Object | Pointer>, targetClass: string, options?: Schema.FieldOptions<Pointer>): this;
addPolygon(name: string, options?: Schema.FieldOptions<Polygon>): this;
addPolygon(key: Schema.AttrType<T, Polygon>, options?: Schema.FieldOptions<Polygon>): this;
/**
* Adding Relation Field
@ -988,9 +990,9 @@ namespace Parse {
* @param targetClass Name of the target Pointer Class
* @return Returns the schema, so you can chain this call.
*/
addRelation(name: string, targetClass: string): this;
addRelation(key: Schema.AttrType<T, Relation>, targetClass: string, options?: Schema.FieldOptions<Relation>): this;
addString(name: string, options?: Schema.FieldOptions<string>): this;
addString(key: Schema.AttrType<T, string>, options?: Schema.FieldOptions<string>): this;
/**
* Removing a Schema from Parse Can only be used on Schema without objects
@ -1019,7 +1021,7 @@ namespace Parse {
get(): Promise<Schema>;
/**
* Removes all objects from a Schema (class) in Parse. EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
* Removes all objects from a Schema (class) in EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
*/
// TODO Fix Promise<any>
purge(): Promise<any>;
@ -1029,6 +1031,12 @@ namespace Parse {
*/
save(): Promise<Schema>;
/**
* Sets Class Level Permissions when creating / updating a Schema.
* EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
*/
setCLP(clp: Schema.CLP): this;
/**
* Update a Schema on Parse
*/
@ -1037,6 +1045,8 @@ namespace Parse {
namespace Schema {
type TYPE = 'String' | 'Number' | 'Boolean' | 'Date' | 'File' | 'GeoPoint' | 'Polygon' | 'Array' | 'Object' | 'Pointer' | 'Relation';
type FieldType = string | number | boolean | Date | File | GeoPoint | Polygon | any[] | object | Pointer | Relation;
type AttrType<T extends Object, V> = Extract<{ [K in keyof T['attributes']]: T['attributes'][K] extends V ? K : never }[keyof T['attributes']], string>;
interface FieldOptions
<T extends string | number | boolean | Date | File | GeoPoint | Polygon | any[] | object | Pointer | Relation = any> {
@ -1047,6 +1057,35 @@ namespace Parse {
interface Index {
[fieldName: string]: TYPE;
}
/**
* The id of a `_User` object or a role name prefixed by `'role:'`.
* @example
* '*': false, // public
* requiresAuthentication: false,
* 'role:Admin': true,
* 'idOfASpecificUser': true
*/
interface CLPField {
'*'?: boolean;
requiresAuthentication?: boolean;
/** `role:Admin` */
[userIdOrRoleName: string]: boolean | undefined;
}
interface CLP {
find?: CLPField;
get?: CLPField;
count?: CLPField;
create?: CLPField;
update?: CLPField;
delete?: CLPField;
addField?: CLPField;
/** Array of fields that point to a `_User` object's ID or a `Role` object's name */
readUserFields?: string[];
/** Array of fields that point to a `_User` object's ID or a `Role` object's name */
writeUserFields?: string[];
}
}
namespace Analytics {

View File

@ -167,6 +167,17 @@ function test_query() {
const testQuery = Parse.Query.or(query, query);
}
function test_query_exclude() {
const gameScore = new GameScore();
const query = new Parse.Query(GameScore);
// Show all keys, except the specified key.
query.exclude('place');
const testQuery = Parse.Query.or(query, query);
}
async function test_query_promise() {
// Test promise with a query
const findQuery = new Parse.Query('Test');
@ -932,6 +943,59 @@ async function test_schema(
schema.purge().then(results => {});
schema.save().then(results => {});
schema.update().then(results => {});
function testGenericType() {
interface iTestAttributes {
arrField: any[];
boolField: boolean;
stringField: string;
numField: number;
dateField: Date;
fileField: Parse.File;
geoPointField: Parse.GeoPoint;
polygonField: Parse.Polygon;
objectField: object;
relationField: Parse.Relation;
pointerField: Parse.Pointer | Parse.Object;
}
class TestObject extends Parse.Object<iTestAttributes> { }
const schema = new Parse.Schema<TestObject>('TestObject');
schema.addArray('arrField');
schema.addBoolean('boolField');
schema.addDate('dateField');
schema.addFile('fileField');
schema.addGeoPoint('geoPointField');
schema.addNumber('numField');
schema.addObject('objectField');
schema.addPointer('pointerField', 'FooClass');
schema.addPolygon('polygonField');
schema.addRelation('relationField', 'FooClass');
schema.addString('stringField');
// $ExpectError
schema.addArray('wrong');
// $ExpectError
schema.addBoolean('wrong');
// $ExpectError
schema.addDate('wrong');
// $ExpectError
schema.addFile('wrong');
// $ExpectError
schema.addGeoPoint('wrong');
// $ExpectError
schema.addNumber('wrong');
// $ExpectError
schema.addObject('wrong');
// $ExpectError
schema.addPointer('wrong', 'FooClass');
// $ExpectError
schema.addPolygon('wrong');
// $ExpectError
schema.addRelation('wrong', 'FooClass');
// $ExpectError
schema.addString('wrong');
}
}
function testObject() {
@ -1116,6 +1180,18 @@ function testObject() {
// $ExpectError
objTyped.fetchWithInclude([[[ 'example' ]]]);
// $ExpectType Promise<Object<{ example: string; }>[]>
Parse.Object.fetchAllIfNeededWithInclude([objTyped], 'example');
// $ExpectError
Parse.Object.fetchAllIfNeededWithInclude([objTyped], 'notAnAttribute');
// $ExpectType Promise<Object<{ example: string; }>[]>
Parse.Object.fetchAllWithInclude([objTyped], 'example');
// $ExpectError
Parse.Object.fetchAllWithInclude([objTyped], 'notAnAttribute');
}
function testGet(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) {

View File

@ -458,12 +458,12 @@ namespace Parse {
fetchAllIfNeeded<T extends Object>(list: T[], options?: Object.FetchAllOptions): Promise<T[]>;
fetchAllIfNeededWithInclude<T extends Object>(
list: T[],
keys: string | Array<string | string[]>,
keys: keyof T['attributes'] | Array<keyof T['attributes']>,
options?: RequestOptions
): Promise<T[]>;
fetchAllWithInclude<T extends Object>(
list: T[],
keys: string | Array<string | string[]>,
keys: keyof T['attributes'] | Array<keyof T['attributes']>,
options?: RequestOptions,
): Promise<T[]>;
fromJSON<T extends Object>(json: any, override?: boolean): T;
@ -650,6 +650,7 @@ namespace Parse {
filter(callback: (currentObject: T, index: number, query: Query) => PromiseLike<boolean> | boolean, options?: Query.BatchOptions): Promise<T[]>;
endsWith<K extends (keyof T['attributes'] | keyof BaseAttributes)>(key: K, suffix: string): this;
equalTo<K extends (keyof T['attributes'] | keyof BaseAttributes)>(key: K, value: T['attributes'][K] | (T['attributes'][K] extends Object ? Pointer : never)): this;
exclude<K extends (keyof T['attributes'] | keyof BaseAttributes)>(...keys: K[]): this;
exists<K extends (keyof T['attributes'] | keyof BaseAttributes)>(key: K): this;
find(options?: Query.FindOptions): Promise<T[]>;
first(options?: Query.FirstOptions): Promise<T | undefined>;
@ -912,7 +913,7 @@ namespace Parse {
* schema.save();
* ```
*/
class Schema {
class Schema<T extends Object = any> {
constructor(className: string);
/**
@ -923,12 +924,12 @@ namespace Parse {
*/
static all(): Promise<Schema[]>;
addArray(name: string, options?: Schema.FieldOptions<any[]>): this;
addBoolean(name: string, options?: Schema.FieldOptions<boolean>): this;
addDate(name: string, options?: Schema.FieldOptions<Date>): this;
addArray(key: Schema.AttrType<T, any[]>, options?: Schema.FieldOptions<any[]>): this;
addBoolean(key: Schema.AttrType<T, boolean>, options?: Schema.FieldOptions<boolean>): this;
addDate(key: Schema.AttrType<T, Date>, options?: Schema.FieldOptions<Date>): this;
addField<T extends Schema.TYPE = any>(name: string, type?: T, options?: Schema.FieldOptions): this;
addFile(name: string, options?: Schema.FieldOptions<File>): this;
addGeoPoint(name: string, options?: Schema.FieldOptions<GeoPoint>): this;
addFile(key: Schema.AttrType<T, File>, options?: Schema.FieldOptions<File>): this;
addGeoPoint(key: Schema.AttrType<T, GeoPoint>, options?: Schema.FieldOptions<GeoPoint>): this;
/**
* Adding an Index to Create / Update a Schema
@ -942,8 +943,9 @@ namespace Parse {
*/
addIndex(name: string, index: Schema.Index): this;
addNumber(name: string, options?: Schema.FieldOptions<number>): this;
addObject(name: string, options?: Schema.FieldOptions<object>): this;
addNumber(key: Schema.AttrType<T, number>, options?: Schema.FieldOptions<number>): this;
addObject(key: Schema.AttrType<T, object>, options?: Schema.FieldOptions<object>): this;
/**
* Adding Pointer Field
@ -951,9 +953,9 @@ namespace Parse {
* @param targetClass Name of the target Pointer Class
* @return Returns the schema, so you can chain this call.
*/
addPointer(name: string, targetClass: string, options?: Schema.FieldOptions<Pointer>): this;
addPointer(key: Schema.AttrType<T, Object | Pointer>, targetClass: string, options?: Schema.FieldOptions<Pointer>): this;
addPolygon(name: string, options?: Schema.FieldOptions<Polygon>): this;
addPolygon(key: Schema.AttrType<T, Polygon>, options?: Schema.FieldOptions<Polygon>): this;
/**
* Adding Relation Field
@ -961,9 +963,9 @@ namespace Parse {
* @param targetClass Name of the target Pointer Class
* @return Returns the schema, so you can chain this call.
*/
addRelation(name: string, targetClass: string): this;
addRelation(key: Schema.AttrType<T, Relation>, targetClass: string, options?: Schema.FieldOptions<Relation>): this;
addString(name: string, options?: Schema.FieldOptions<string>): this;
addString(key: Schema.AttrType<T, string>, options?: Schema.FieldOptions<string>): this;
/**
* Removing a Schema from Parse Can only be used on Schema without objects
@ -992,7 +994,7 @@ namespace Parse {
get(): Promise<Schema>;
/**
* Removes all objects from a Schema (class) in Parse. EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
* Removes all objects from a Schema (class) in EXERCISE CAUTION, running this will delete all objects for this schema and cannot be reversed
*/
// TODO Fix Promise<any>
purge(): Promise<any>;
@ -1002,6 +1004,12 @@ namespace Parse {
*/
save(): Promise<Schema>;
/**
* Sets Class Level Permissions when creating / updating a Schema.
* EXERCISE CAUTION, running this may override CLP for this schema and cannot be reversed
*/
setCLP(clp: Schema.CLP): this;
/**
* Update a Schema on Parse
*/
@ -1010,9 +1018,11 @@ namespace Parse {
namespace Schema {
type TYPE = 'String' | 'Number' | 'Boolean' | 'Date' | 'File' | 'GeoPoint' | 'Polygon' | 'Array' | 'Object' | 'Pointer' | 'Relation';
type FieldType = string | number | boolean | Date | File | GeoPoint | Polygon | any[] | object | Pointer | Relation;
type AttrType<T extends Object, V> = Extract<{ [K in keyof T['attributes']]: T['attributes'][K] extends V ? K : never }[keyof T['attributes']], string>;
interface FieldOptions
<T extends string | number | boolean | Date | File | GeoPoint | Polygon | any[] | object | Pointer | Relation = any> {
<T extends FieldType = any> {
required?: boolean;
defaultValue?: T;
}
@ -1020,6 +1030,35 @@ namespace Parse {
interface Index {
[fieldName: string]: TYPE;
}
/**
* The id of a `_User` object or a role name prefixed by `'role:'`.
* @example
* '*': false, // public
* requiresAuthentication: false,
* 'role:Admin': true,
* 'idOfASpecificUser': true
*/
interface CLPField {
'*'?: boolean;
requiresAuthentication?: boolean;
/** `role:Admin` */
[userIdOrRoleName: string]: boolean | undefined;
}
interface CLP {
find?: CLPField;
get?: CLPField;
count?: CLPField;
create?: CLPField;
update?: CLPField;
delete?: CLPField;
addField?: CLPField;
/** Array of fields that point to a `_User` object's ID or a `Role` object's name */
readUserFields?: string[];
/** Array of fields that point to a `_User` object's ID or a `Role` object's name */
writeUserFields?: string[];
}
}
namespace Analytics {

View File

@ -172,6 +172,17 @@ function test_query() {
const testQuery = Parse.Query.or(query, query);
}
function test_query_exclude() {
const gameScore = new GameScore();
const query = new Parse.Query(GameScore);
// Show all keys, except the specified key.
query.exclude('place');
const testQuery = Parse.Query.or(query, query);
}
async function test_query_promise() {
// Test promise with a query
const findQuery = new Parse.Query('Test');
@ -835,19 +846,18 @@ async function test_cancel_query() {
query.cancel();
}
type FieldType = string | number | boolean | Date | Parse.File | Parse.GeoPoint | any[] | object | Parse.Pointer | Parse.Polygon | Parse.Relation;
async function test_schema(
anyField: FieldType,
notString: Exclude<FieldType, string>,
notNumber: Exclude<FieldType, number>,
notboolean: Exclude<FieldType, boolean>,
notDate: Exclude<FieldType, Date>,
notFile: Exclude<FieldType, Parse.File>,
notGeopoint: Exclude<FieldType, Parse.GeoPoint[]>,
notArray: Exclude<FieldType, any[]>,
notObject: Exclude<FieldType, object>,
notPointer: Exclude<FieldType, Parse.Pointer>,
notPolygon: Exclude<FieldType, Parse.Polygon>
anyField: Parse.Schema.FieldType,
notString: Exclude<Parse.Schema.FieldType, string>,
notNumber: Exclude<Parse.Schema.FieldType, number>,
notboolean: Exclude<Parse.Schema.FieldType, boolean>,
notDate: Exclude<Parse.Schema.FieldType, Date>,
notFile: Exclude<Parse.Schema.FieldType, Parse.File>,
notGeopoint: Exclude<Parse.Schema.FieldType, Parse.GeoPoint[]>,
notArray: Exclude<Parse.Schema.FieldType, any[]>,
notObject: Exclude<Parse.Schema.FieldType, object>,
notPointer: Exclude<Parse.Schema.FieldType, Parse.Pointer>,
notPolygon: Exclude<Parse.Schema.FieldType, Parse.Polygon>
) {
Parse.Schema.all();
@ -931,11 +941,64 @@ async function test_schema(
schema.deleteField('defaultFieldString');
schema.deleteIndex('testIndex');
schema.delete().then(results => {});
schema.get().then(results => {});
schema.purge().then(results => {});
schema.save().then(results => {});
schema.update().then(results => {});
schema.delete().then(results => { });
schema.get().then(results => { });
schema.purge().then(results => { });
schema.save().then(results => { });
schema.update().then(results => { });
function testGenericType() {
interface iTestAttributes {
arrField: any[];
boolField: boolean;
stringField: string;
numField: number;
dateField: Date;
fileField: Parse.File;
geoPointField: Parse.GeoPoint;
polygonField: Parse.Polygon;
objectField: object;
relationField: Parse.Relation;
pointerField: Parse.Pointer | Parse.Object;
}
class TestObject extends Parse.Object<iTestAttributes> { }
const schema = new Parse.Schema<TestObject>('TestObject');
schema.addArray('arrField');
schema.addBoolean('boolField');
schema.addDate('dateField');
schema.addFile('fileField');
schema.addGeoPoint('geoPointField');
schema.addNumber('numField');
schema.addObject('objectField');
schema.addPointer('pointerField', 'FooClass');
schema.addPolygon('polygonField');
schema.addRelation('relationField', 'FooClass');
schema.addString('stringField');
// $ExpectError
schema.addArray('wrong');
// $ExpectError
schema.addBoolean('wrong');
// $ExpectError
schema.addDate('wrong');
// $ExpectError
schema.addFile('wrong');
// $ExpectError
schema.addGeoPoint('wrong');
// $ExpectError
schema.addNumber('wrong');
// $ExpectError
schema.addObject('wrong');
// $ExpectError
schema.addPointer('wrong', 'FooClass');
// $ExpectError
schema.addPolygon('wrong');
// $ExpectError
schema.addRelation('wrong', 'FooClass');
// $ExpectError
schema.addString('wrong');
}
}
function testObject() {
@ -1120,6 +1183,18 @@ function testObject() {
// $ExpectError
objTyped.fetchWithInclude([[[ 'example' ]]]);
// $ExpectType Promise<Object<{ example: string; }>[]>
Parse.Object.fetchAllIfNeededWithInclude([objTyped], 'example');
// $ExpectError
Parse.Object.fetchAllIfNeededWithInclude([objTyped], 'notAnAttribute');
// $ExpectType Promise<Object<{ example: string; }>[]>
Parse.Object.fetchAllWithInclude([objTyped], 'example');
// $ExpectError
Parse.Object.fetchAllWithInclude([objTyped], 'notAnAttribute');
}
function testGet(objUntyped: Parse.Object, objTyped: Parse.Object<{ example: number }>) {

View File

@ -4,8 +4,6 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
export {};
interface AssertionError {
msg: string;
actual: any;
@ -14,257 +12,262 @@ interface AssertionError {
stackStartFunction: any;
}
/**
* Throw an assertion error.
*/
export function fail(actual: any, expected: any, msg: string, operator: string): AssertionError;
// export as namespace proclaim;
export = proclaim;
declare function proclaim(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is truthy.
*/
export function ok(value: any, msg: string): AssertionError|void;
declare namespace proclaim {
/**
* Throw an assertion error.
*/
function fail(actual: any, expected: any, msg?: string, operator?: string): AssertionError;
/**
* Assert that value is falsy.
*/
export function notOk(value: any, msg: string): AssertionError|void;
/**
* Assert that value is truthy.
*/
const ok: typeof proclaim;
/**
* Assert that value is falsy.
*/
function notOk(value: any, msg?: string): AssertionError|void;
/**
* Assert that actual == expected.
*/
export function equal(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual == expected.
*/
function equal(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual != expected.
*/
export function notEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual != expected.
*/
function notEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual === expected.
*/
export function strictEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual === expected.
*/
function strictEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual !== expected.
*/
export function notStrictEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual !== expected.
*/
function notStrictEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual is deeply equal to expected.
*/
export function deepEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual is deeply equal to expected.
*/
function deepEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual is not deeply equal to expected.
*/
export function notDeepEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual is not deeply equal to expected.
*/
function notDeepEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual is deeply equal to expected, as determined by the strict equality operator ===.
*/
export function deepStrictEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual is deeply equal to expected, as determined by the strict equality operator ===.
*/
function deepStrictEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual is not deeply equal to expected, as determined by the strict not equal operator !==.
*/
export function notDeepStrictEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual is not deeply equal to expected, as determined by the strict not equal operator !==.
*/
function notDeepStrictEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that fn throws an error.
*/
export function throws(fn: () => void, expected: any, msg: string): AssertionError|void;
/**
* Assert that fn throws an error.
*/
function throws(fn: () => void, expected: any, msg?: string): AssertionError|void;
/**
* Assert that fn does not throw an error.
*/
export function doesNotThrow(fn: () => void, expected: any, msg: string): AssertionError|void;
/**
* Assert that fn does not throw an error.
*/
function doesNotThrow(fn: () => void, expected: any, msg?: string): AssertionError|void;
/**
* Assert that typeof actual === expected.
*/
export function isTypeOf(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that typeof actual === expected.
*/
function isTypeOf(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that typeof actual !== expected.
*/
export function isNotTypeOf(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that typeof actual !== expected.
*/
function isNotTypeOf(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual instanceof expected.
*/
export function isInstanceOf(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual instanceof expected.
*/
function isInstanceOf(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that !(actual instanceof expected).
*/
export function isNotInstanceOf(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that !(actual instanceof expected).
*/
function isNotInstanceOf(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that value is an array.
*/
export function isArray(value: any, msg: string): AssertionError|void;
/**
* Assert that value is an array.
*/
function isArray(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not an array.
*/
export function isNotArray(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not an array.
*/
function isNotArray(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is a boolean.
*/
export function isBoolean(value: any, msg: string): AssertionError|void;
/**
* Assert that value is a boolean.
*/
function isBoolean(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not a boolean.
*/
export function isNotBoolean(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not a boolean.
*/
function isNotBoolean(value: any, msg?: string): AssertionError|void;
/**
* Assert that value === true.
*/
export function isTrue(value: any, msg: string): AssertionError|void;
/**
* Assert that value === true.
*/
function isTrue(value: any, msg?: string): AssertionError|void;
/**
* Assert that value === false.
*/
export function isFalse(value: any, msg: string): AssertionError|void;
/**
* Assert that value === false.
*/
function isFalse(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is a function.
*/
export function isFunction(value: any, msg: string): AssertionError|void;
/**
* Assert that value is a function.
*/
function isFunction(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not a function.
*/
export function isNotFunction(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not a function.
*/
function isNotFunction(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is NaN.
*/
export function isNaN(value: any, msg: string): AssertionError|void;
/**
* Assert that value is NaN.
*/
function isNaN(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not NaN.
*/
export function isNotNaN(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not NaN.
*/
function isNotNaN(value: any, msg?: string): AssertionError|void;
/**
* Assert that value === null.
*/
export function isNull(value: any, msg: string): AssertionError|void;
/**
* Assert that value === null.
*/
function isNull(value: any, msg?: string): AssertionError|void;
/**
* Assert that value !== null.
*/
export function isNotNull(value: any, msg: string): AssertionError|void;
/**
* Assert that value !== null.
*/
function isNotNull(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is a number.
*/
export function isNumber(value: any, msg: string): AssertionError|void;
/**
* Assert that value is a number.
*/
function isNumber(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not a number.
*/
export function isNotNumber(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not a number.
*/
function isNotNumber(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is an object.
*/
export function isObject(value: any, msg: string): AssertionError|void;
/**
* Assert that value is an object.
*/
function isObject(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not an object.
*/
export function isNotObject(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not an object.
*/
function isNotObject(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is a string.
*/
export function isString(value: any, msg: string): AssertionError|void;
/**
* Assert that value is a string.
*/
function isString(value: any, msg?: string): AssertionError|void;
/**
* Assert that value is not a string.
*/
export function isNotString(value: any, msg: string): AssertionError|void;
/**
* Assert that value is not a string.
*/
function isNotString(value: any, msg?: string): AssertionError|void;
/**
* Assert that value === undefined.
*/
export function isUndefined(value: any, msg: string): AssertionError|void;
/**
* Assert that value === undefined.
*/
function isUndefined(value: any, msg?: string): AssertionError|void;
/**
* Assert that value !== undefined.
*/
export function isDefined(value: any, msg: string): AssertionError|void;
/**
* Assert that value !== undefined.
*/
function isDefined(value: any, msg?: string): AssertionError|void;
/**
* Assert that actual matches the RegExp in expected.
*/
export function match(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual matches the RegExp in expected.
*/
function match(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual does not match the RegExp in expected.
*/
export function notMatch(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual does not match the RegExp in expected.
*/
function notMatch(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that haystack contains needle.
*/
export function include(haystack: any, needle: any, msg: string): AssertionError|void;
/**
* Assert that haystack contains needle.
*/
function include(haystack: any, needle: any, msg?: string): AssertionError|void;
/**
* Assert that haystack does not contain needle.
*/
export function doesNotInclude(haystack: any, needle: any, msg: string): AssertionError|void;
/**
* Assert that haystack does not contain needle.
*/
function doesNotInclude(haystack: any, needle: any, msg?: string): AssertionError|void;
/**
* Assert that value.length === expected.
*/
export function lengthEquals(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that value.length === expected.
*/
function lengthEquals(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual < expected.
*/
export function lessThan(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual < expected.
*/
function lessThan(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual <= expected.
*/
export function lessThanOrEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual <= expected.
*/
function lessThanOrEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual > expected.
*/
export function greaterThan(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual > expected.
*/
function greaterThan(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that actual >= expected.
*/
export function greaterThanOrEqual(actual: any, expected: any, msg: string): AssertionError|void;
/**
* Assert that actual >= expected.
*/
function greaterThanOrEqual(actual: any, expected: any, msg?: string): AssertionError|void;
/**
* Assert that fn.length === expected.
*/
export function arity(fn: () => void, expected: any, msg: string): AssertionError|void;
/**
* Assert that fn.length === expected.
*/
function arity(fn: () => void, expected: any, msg?: string): AssertionError|void;
/**
* Assert that Math.abs(actual - expected) < (0.5 * Math.pow(10, -precision)).
*/
export function almostEqual(actual: any, expected: any, precision: number, msg: string): AssertionError|void;
/**
* Assert that Math.abs(actual - expected) < (0.5 * Math.pow(10, -precision)).
*/
function almostEqual(actual: any, expected: any, precision: number, msg?: string): AssertionError|void;
/**
* Assert that obj[property] is not enumerable.
*/
export function isNotEnumerable(object: object, property: any, msg: string): AssertionError|void;
/**
* Assert that obj[property] is not enumerable.
*/
function isNotEnumerable(object: object, property: any, msg?: string): AssertionError|void;
/**
* Assert that obj[property] is enumerable.
*/
export function isEnumerable(object: object, property: any, msg: string): AssertionError|void;
/**
* Assert that obj[property] is enumerable.
*/
function isEnumerable(object: object, property: any, msg?: string): AssertionError|void;
/**
* Assert that fn.name === expected.
*/
export function hasName(fn: () => void, expected: any, msg: string): AssertionError|void;
/**
* Assert that fn.name === expected.
*/
function hasName(fn: () => void, expected: any, msg?: string): AssertionError|void;
}

View File

@ -1,54 +1,108 @@
import proclaim = require('proclaim');
proclaim.fail('foo', 'bar', 'Foo equals bar', '===');
proclaim.fail('foo', 'bar', 'Foo equals bar');
proclaim.fail('foo', 'bar');
proclaim.ok(5, '5 equals true');
proclaim.ok.ok.ok.ok.ok.ok.fail('foo', 'bar', 'Foo equals bar', '===');
proclaim.ok(5);
proclaim.notOk(5, '5 equals false');
proclaim.notOk(5);
proclaim.equal('abc', 'bca', 'Foo equals bar');
proclaim.equal('abc', 'bca');
proclaim.notEqual('abc', 'bca', 'Foo equals bar');
proclaim.notEqual('abc', 'bca');
proclaim.strictEqual('abc', 'bca', 'Foo equals bar');
proclaim.strictEqual('abc', 'bca');
proclaim.notStrictEqual('abc', 'bca', 'Foo equals bar');
proclaim.notStrictEqual('abc', 'bca');
proclaim.deepEqual('abc', 'bca', 'Foo equals bar');
proclaim.deepEqual('abc', 'bca');
proclaim.notDeepEqual('abc', 'bca', 'Foo equals bar');
proclaim.notDeepEqual('abc', 'bca');
proclaim.deepStrictEqual('abc', 'bca', 'Foo equals bar');
proclaim.deepStrictEqual('abc', 'bca');
proclaim.notDeepStrictEqual('abc', 'bca', 'Foo equals bar');
proclaim.notDeepStrictEqual('abc', 'bca');
proclaim.throws(() => {}, {}, 'throws error');
proclaim.throws(() => {}, {});
proclaim.doesNotThrow(() => {}, {}, 'throws error');
proclaim.doesNotThrow(() => {}, {});
proclaim.isTypeOf('same type', 'same type', 'values match');
proclaim.isTypeOf('same type', 'same type');
proclaim.isNotTypeOf('same type', 'same type', 'values dont match');
proclaim.isNotTypeOf('same type', 'same type');
proclaim.isInstanceOf('same instance', 'same instance', 'instance match');
proclaim.isInstanceOf('same instance', 'same instance');
proclaim.isNotInstanceOf('same instance', 'same instance', 'instance dont match');
proclaim.isNotInstanceOf('same instance', 'same instance');
proclaim.isArray([], 'is array');
proclaim.isArray([]);
proclaim.isNotArray([], 'is array');
proclaim.isNotArray([]);
proclaim.isBoolean(true, 'is bool');
proclaim.isBoolean(true);
proclaim.isNotBoolean(true, 'is bool');
proclaim.isNotBoolean(true);
proclaim.isTrue(true, 'is true');
proclaim.isTrue(true);
proclaim.isFalse(false, 'is true');
proclaim.isFalse(false);
proclaim.isFunction('value here', 'value was a thing');
proclaim.isFunction('value here');
proclaim.isNotFunction('value here', 'value was a thing');
proclaim.isNotFunction('value here');
proclaim.isNaN('value here', 'value was a thing');
proclaim.isNaN('value here');
proclaim.isNotNaN('value here', 'value was a thing');
proclaim.isNotNaN('value here');
proclaim.isNull('value here', 'value was a thing');
proclaim.isNull('value here');
proclaim.isNotNull('value here', 'value was a thing');
proclaim.isNotNull('value here');
proclaim.isNumber('value here', 'value was a thing');
proclaim.isNumber('value here');
proclaim.isNotNumber('value here', 'value was a thing');
proclaim.isNotNumber('value here');
proclaim.isObject('value here', 'value was a thing');
proclaim.isObject('value here');
proclaim.isNotNull('value here', 'value was a thing');
proclaim.isNotNull('value here');
proclaim.isNotObject('value here', 'value was a thing');
proclaim.isNotObject('value here');
proclaim.isString('value here', 'value was a thing');
proclaim.isString('value here');
proclaim.isNotString('value here', 'value was a thing');
proclaim.isNotString('value here');
proclaim.isUndefined('value here', 'value was a thing');
proclaim.isUndefined('value here');
proclaim.isDefined('value here', 'value was a thing');
proclaim.isDefined('value here');
proclaim.match('a', 'a', 'match');
proclaim.match('a', 'a');
proclaim.notMatch('a', 'b', 'no match');
proclaim.notMatch('a', 'b');
proclaim.include([1, 2, 3], 5, 'no match');
proclaim.include([1, 2, 3], 5);
proclaim.doesNotInclude([1, 2, 3], 5, 'no match');
proclaim.doesNotInclude([1, 2, 3], 5);
proclaim.lengthEquals([1, 2, 3], 3, 'length equals');
proclaim.lengthEquals([1, 2, 3], 3);
proclaim.lessThan(5, 10, 'true');
proclaim.lessThan(5, 10);
proclaim.lessThanOrEqual(5, 10, 'true');
proclaim.lessThanOrEqual(5, 10);
proclaim.greaterThan(5, 10, 'false');
proclaim.greaterThan(5, 10);
proclaim.greaterThanOrEqual(5, 10, 'false');
proclaim.greaterThanOrEqual(5, 10);
proclaim.arity(() => {}, {}, 'no fn length');
proclaim.arity(() => {}, {});
proclaim.almostEqual(5, 10, 3, 'not almost equal');
proclaim.almostEqual(5, 10, 3);
proclaim.isNotEnumerable({}, {}, 'true');
proclaim.isNotEnumerable({}, {});
proclaim.isEnumerable({}, {}, 'true');
proclaim.isEnumerable({}, {});
proclaim.hasName(() => {}, 'name here', 'false');
proclaim.hasName(() => {}, 'name here');

View File

@ -58,6 +58,10 @@ declare namespace pull {
type Duplex<In, Out> = DuplexSource<In> & DuplexSink<Out>;
type DuplexThrough<In, Out> = DuplexSource<In> & DuplexSink<Out>;
type PossibleSource<T> = Source<T> | DuplexSource<T>;
type PossibleSink<T> = Sink<T> | DuplexSink<T>;
type PossibleThrough<In, Out> = Through<In, Out> | DuplexThrough<In, Out>;
const count: typeof countImport;
const empty: typeof emptyImport;
const error: typeof errorImport;
@ -90,146 +94,150 @@ declare namespace pull {
*/
declare function pull(): void;
declare function pull<Out>(source: pull.Source<Out>): pull.Source<Out>;
declare function pull<In, Out>(source: pull.Source<In>, t1: pull.Through<In, Out>): pull.Source<Out>;
declare function pull<Out>(source: pull.PossibleSource<Out>): pull.Source<Out>;
declare function pull<In, Out>(source: pull.PossibleSource<In>, t1: pull.PossibleThrough<In, Out>): pull.Source<Out>;
declare function pull<In, P1, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, Out>,
): pull.Source<Out>;
declare function pull<In, P1, P2, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, Out>,
): pull.Source<Out>;
declare function pull<In, P1, P2, P3, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, Out>,
): pull.Source<Out>;
declare function pull<In, P1, P2, P3, P4, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, Out>,
): pull.Source<Out>;
declare function pull<In, P1, P2, P3, P4, P5, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, P5>,
t6: pull.Through<P5, Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, P5>,
t6: pull.PossibleThrough<P5, Out>,
): pull.Source<Out>;
declare function pull<In, Out>(t1: pull.Through<In, Out>): pull.Through<In, Out>;
declare function pull<In, P1, Out>(t1: pull.Through<In, P1>, t2: pull.Through<P1, Out>): pull.Through<In, Out>;
declare function pull<In, P1, Out>(t1: pull.Through<In, P1>, t2: pull.PossibleThrough<P1, Out>): pull.Through<In, Out>;
declare function pull<In, P1, P2, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, Out>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, Out>,
): pull.Through<In, Out>;
declare function pull<In, P1, P2, P3, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, Out>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, Out>,
): pull.Through<In, Out>;
declare function pull<In, P1, P2, P3, P4, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, Out>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, Out>,
): pull.Through<In, Out>;
declare function pull<In, P1, P2, P3, P4, P5, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, P5>,
t6: pull.Through<P5, Out>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, P5>,
t6: pull.PossibleThrough<P5, Out>,
): pull.Through<In, Out>;
declare function pull<In>(sink: pull.Sink<In>): pull.Sink<In>;
declare function pull<In, Out>(t1: pull.Through<In, Out>, sink: pull.Sink<Out>): pull.Sink<In>;
declare function pull<In>(sink: pull.PossibleSink<In>): pull.Sink<In>;
declare function pull<In, Out>(t1: pull.PossibleThrough<In, Out>, sink: pull.PossibleSink<Out>): pull.Sink<In>;
declare function pull<In, P1, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, Out>,
sink: pull.Sink<Out>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, Out>,
sink: pull.PossibleSink<Out>,
): pull.Sink<In>;
declare function pull<In, P1, P2, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, Out>,
sink: pull.Sink<Out>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, Out>,
sink: pull.PossibleSink<Out>,
): pull.Sink<In>;
declare function pull<In, P1, P2, P3, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, Out>,
sink: pull.Sink<Out>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, Out>,
sink: pull.PossibleSink<Out>,
): pull.Sink<In>;
declare function pull<In, P1, P2, P3, P4, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, Out>,
sink: pull.Sink<Out>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, Out>,
sink: pull.PossibleSink<Out>,
): pull.Sink<In>;
declare function pull<In, P1, P2, P3, P4, P5, Out>(
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, P5>,
t6: pull.Through<P5, Out>,
sink: pull.Sink<Out>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, P5>,
t6: pull.PossibleThrough<P5, Out>,
sink: pull.PossibleSink<Out>,
): pull.Sink<In>;
declare function pull<InOut>(source: pull.Source<InOut>, sink: pull.Sink<InOut>): void;
declare function pull<In, Out>(source: pull.Source<In>, t1: pull.Through<In, Out>, sink: pull.Sink<Out>): void;
declare function pull<InOut>(source: pull.PossibleSource<InOut>, sink: pull.PossibleSink<InOut>): void;
declare function pull<In, Out>(
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, Out>,
sink: pull.PossibleSink<Out>,
): void;
declare function pull<In, P1, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, Out>,
sink: pull.Sink<Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, Out>,
sink: pull.PossibleSink<Out>,
): void;
declare function pull<In, P1, P2, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, Out>,
sink: pull.Sink<Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, Out>,
sink: pull.PossibleSink<Out>,
): void;
declare function pull<In, P1, P2, P3, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, Out>,
sink: pull.Sink<Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, Out>,
sink: pull.PossibleSink<Out>,
): void;
declare function pull<In, P1, P2, P3, P4, Out>(
source: pull.Source<In>,
t1: pull.Through<In, P1>,
t2: pull.Through<P1, P2>,
t3: pull.Through<P2, P3>,
t4: pull.Through<P3, P4>,
t5: pull.Through<P4, Out>,
sink: pull.Sink<Out>,
source: pull.PossibleSource<In>,
t1: pull.PossibleThrough<In, P1>,
t2: pull.PossibleThrough<P1, P2>,
t3: pull.PossibleThrough<P2, P3>,
t4: pull.PossibleThrough<P3, P4>,
t5: pull.PossibleThrough<P4, Out>,
sink: pull.PossibleSink<Out>,
): void;
declare function pull(
...pullStreams: ReadonlyArray<pull.Source<any> | pull.Sink<any> | pull.Through<any, any>>
...pullStreams: ReadonlyArray<pull.PossibleSource<any> | pull.PossibleSink<any> | pull.PossibleThrough<any, any>>
): pull.Source<any> | pull.Sink<any> | pull.Through<any, any> | void;
export = pull;

View File

@ -8,6 +8,19 @@ let source: pull.Source<string> = (end, cb) => {};
let through: pull.Through<string, string> = source => source;
let sink: pull.Sink<string> = source => {};
const duplexSource = {
source,
};
const duplexSink = {
sink,
};
const duplexThrough: pull.DuplexThrough<string, string> = {
source: (end, cb) => {},
sink: source => source,
};
function voidFunc(): void {}
type Void = ReturnType<typeof voidFunc>;
@ -15,24 +28,64 @@ type Void = ReturnType<typeof voidFunc>;
// Start with source and end with sink
let nothing: Void;
nothing = pull();
nothing = pull(source, sink);
nothing = pull(duplexSource, duplexSink);
nothing = pull(source, through, sink);
nothing = pull(duplexSource, through, duplexSink);
nothing = pull(source, through, through, sink);
nothing = pull(duplexSource, through, through, duplexSink);
nothing = pull(duplexSource, through, through, through, duplexSink);
nothing = pull(duplexSource, through, through, through, through, duplexSink);
// Start with source
source = pull(source);
source = pull(duplexSource);
source = pull(source, through);
source = pull(source, through, through);
source = pull(duplexSource, through);
source = pull(duplexSource, duplexThrough);
source = pull(source, duplexThrough, through);
source = pull(duplexSource, duplexThrough, through);
source = pull(source, duplexThrough, through, through);
source = pull(duplexSource, duplexThrough, through, through);
source = pull(source, duplexThrough, through, through, through, through);
source = pull(duplexSource, duplexThrough, through, through, through, through);
source = pull(source, duplexThrough, through, through, through, through, through);
source = pull(duplexSource, duplexThrough, through, through, through, through, through);
// End with sink
sink = pull(sink);
sink = pull(duplexSink);
sink = pull(through, sink);
sink = pull(through, through, sink);
sink = pull(duplexThrough, sink);
sink = pull(duplexThrough, duplexSink);
sink = pull(through, duplexThrough, sink);
sink = pull(through, duplexThrough, duplexSink);
sink = pull(through, duplexThrough, through, sink);
sink = pull(through, duplexThrough, through, duplexSink);
sink = pull(through, duplexThrough, through, through, sink);
sink = pull(through, duplexThrough, through, through, duplexSink);
sink = pull(through, duplexThrough, through, through, through, sink);
sink = pull(through, duplexThrough, through, through, through, duplexSink);
sink = pull(through, duplexThrough, through, through, through, through, sink);
sink = pull(through, duplexThrough, through, through, through, through, duplexSink);
// Through only
through = pull(through);
through = pull(through, through);
through = pull(through, duplexThrough);
through = pull(through, through, through);
through = pull(through, duplexThrough, through);
through = pull(through, duplexThrough, duplexThrough);
through = pull(through, through, through, duplexThrough);
through = pull(through, through, through, through, duplexThrough);
through = pull(through, through, through, through, through, duplexThrough);
const numberSource: pull.Source<number> = (end, cb) => {};
const parseNumber: pull.Through<string, number> = source => numberSource;

View File

@ -1,4 +1,4 @@
// Type definitions for react-autosuggest 9.3
// Type definitions for react-autosuggest 10.0
// Project: http://react-autosuggest.js.org/, https://github.com/moroshko/react-autosuggest
// Definitions by: Nicolas Schmitt <https://github.com/nicolas-schmitt>
// Philip Ottesen <https://github.com/pjo256>
@ -68,6 +68,7 @@ declare namespace Autosuggest {
onChange(event: React.FormEvent<any>, params: ChangeEvent): void;
onBlur?(event: React.FocusEvent<any>, params?: BlurEvent<TSuggestion>): void;
value: string;
ref?: React.Ref<HTMLInputElement>;
}
interface SuggestionSelectedEventData<TSuggestion> {

View File

@ -68,6 +68,7 @@ export class ReactAutosuggestBasicTest extends React.Component<any, any> {
suggestions: this.getSuggestions('')
};
// endregion region Rendering methods
inputRef = React.createRef<HTMLInputElement>();
render(): JSX.Element {
const {value, suggestions} = this.state;
@ -91,7 +92,8 @@ export class ReactAutosuggestBasicTest extends React.Component<any, any> {
placeholder: `Type 'c'`,
value,
onChange: (e, changeEvent) => this.onChange(e, changeEvent),
onBlur: (e) => { console.log(e.relatedTarget); }
onBlur: (e) => { console.log(e.relatedTarget); },
ref: this.inputRef
}}
theme={theme}/>;
}

View File

@ -1,4 +1,4 @@
// Type definitions for react-native-push-notification 3.0
// Type definitions for react-native-push-notification 5.0
// Project: https://github.com/zo0r/react-native-push-notification#readme
// Definitions by: Paito Anderson <https://github.com/PaitoAnderson>
// Tom Sawkins <https://github.com/tomSawkins>
@ -27,71 +27,111 @@ export interface PushNotification {
export interface PushNotificationOptions {
onRegister?: (token: { os: string; token: string }) => void;
onNotification?: (notification: PushNotification) => void;
senderID?: string;
onAction?: (notification: PushNotification) => void;
onRegistrationError?: (error: any) => void;
onRemoteFetch?: (notificationData: any) => void;
permissions?: PushNotificationPermissions;
popInitialNotification?: boolean;
requestPermissions?: boolean;
}
export type PriorityType = "max" | "high" | "low" | "min" | "default";
export type RepeatType = "week" | "day" | "hour" | "minute" | "time";
export type VisibilityType = "private" | "public" | "secret";
export type ImportanceType = "default" | "max" | "high" | "low" | "min" | "none" | "unspecified";
export class PushNotificationObject {
/* Android only properties */
id?: string;
ticker?: string;
showWhen?: boolean;
autoCancel?: boolean;
largeIcon?: string;
largeIconUrl?: string;
smallIcon?: string;
bigText?: string;
subText?: string;
bigPictureUrl?: string;
color?: string;
vibrate?: boolean;
vibration?: number;
tag?: string;
group?: string;
groupSummary?: boolean;
ongoing?: boolean;
priority?: PriorityType;
visibility?: VisibilityType;
importance?: ImportanceType;
priority?: "max" | "high" | "low" | "min" | "default";
visibility?: "private" | "public" | "secret";
importance?: "default" | "max" | "high" | "low" | "min" | "none" | "unspecified";
ignoreInForeground?: boolean;
shortcutId?: string;
channelId?: string;
onlyAlertOnce?: boolean;
messageId?: string;
actions?: string;
invokeApp?: boolean;
/* iOS only properties */
alertAction?: any;
category?: any;
userInfo?: any;
/* iOS and Android properties */
id?: number;
title?: string;
message: string;
userInfo?: any;
playSound?: boolean;
soundName?: string;
number?: string;
repeatType?: RepeatType;
repeatType?: "week" | "day" | "hour" | "minute" | "time";
repeatTime?: number;
actions?: string;
}
export class PushNotificationScheduleObject extends PushNotificationObject {
date: Date;
}
export class PushNotificationDeliveredObject {
identifier: string;
title: string;
body: string;
tag: string;
group: string;
}
export class PushNotificationScheduledLocalObject {
id: number;
date: Date;
title: string;
body: string;
soundName: string;
repeatInterval: number;
number: number;
}
export class ChannelObject {
channelId: string;
channelName: string;
channelDescription?: string;
soundName?: string;
importance?: number;
vibrate?: boolean;
}
export interface PushNotification {
configure(options: PushNotificationOptions): void;
unregister(): void;
localNotification(details: PushNotificationObject): void;
localNotificationSchedule(details: PushNotificationScheduleObject): void;
localNotification(notification: PushNotificationObject): void;
localNotificationSchedule(notification: PushNotificationScheduleObject): void;
requestPermissions(
permissions?: Array<"alert" | "badge" | "sound">
): Promise<PushNotificationPermissions>;
subscribeToTopic(topic: string): void;
presentLocalNotification(details: PushNotificationObject): void;
scheduleLocalNotification(details: PushNotificationScheduleObject): void;
cancelLocalNotifications(details: object): void;
unsubscribeFromTopic(topic: string): void;
presentLocalNotification(notification: PushNotificationObject): void;
scheduleLocalNotification(notification: PushNotificationScheduleObject): void;
cancelLocalNotifications(details: { id: string }): void;
clearLocalNotification(tag: string, notificationID: number): void;
cancelAllLocalNotifications(): void;
setApplicationIconBadgeNumber(badgeCount: number): void;
getApplicationIconBadgeNumber(callback: (badgeCount: number) => void): void;
getApplicationIconBadgeNumber(
callback: (badgeCount: number) => void
): void;
popInitialNotification(
callback: (notification: PushNotification | null) => void
): void;
@ -99,8 +139,30 @@ export interface PushNotification {
checkPermissions(
callback: (permissions: PushNotificationPermissions) => void
): void;
registerNotificationActions(actions: string[]): void;
clearAllNotifications(): void;
removeAllDeliveredNotifications(): void;
getDeliveredNotifications(
callback: (notifications: PushNotificationDeliveredObject[]) => void
): void;
getScheduledLocalNotifications(
callback: (notifications: PushNotificationScheduledLocalObject[]) => void
): void;
removeDeliveredNotifications(identifiers: string[]): void;
invokeApp(notification: PushNotificationObject): void;
getChannels(
callback: (channel_ids: string[]) => void
): void;
channelExists(
callback: (exists: boolean) => void
): void;
createChannel(
channel: ChannelObject,
callback: (created: boolean) => void
): void;
channelBlocked(
callback: (blocked: boolean) => void
): void;
deleteChannel(channel_id: string): void;
}
declare const PushNotification: PushNotification;

View File

@ -5,25 +5,36 @@ PushNotification.configure({
notification.finish("UIBackgroundFetchResultNoData");
},
onRegister: (token) => {},
senderID: 'XXX',
onAction: (notification) => {},
onRegistrationError: (err) => {},
onRemoteFetch: (notificationData) => {},
permissions: { alert: true, badge: true, sound: true },
popInitialNotification: false,
requestPermissions: true,
});
PushNotification.unregister();
PushNotification.localNotification = (details) => {};
PushNotification.localNotificationSchedule = (details) => {};
PushNotification.localNotification({ message: '' });
PushNotification.localNotificationSchedule({ date: new Date(), message: '' });
PushNotification.requestPermissions();
PushNotification.subscribeToTopic("topic");
PushNotification.presentLocalNotification = (details) => {};
PushNotification.scheduleLocalNotification = (details) => {};
PushNotification.cancelLocalNotifications = (details) => {};
PushNotification.presentLocalNotification({ message: '' });
PushNotification.scheduleLocalNotification({ date: new Date(), message: '' });
PushNotification.cancelLocalNotifications({ id: '123' });
PushNotification.cancelAllLocalNotifications();
PushNotification.setApplicationIconBadgeNumber(1);
PushNotification.getApplicationIconBadgeNumber((badgeCount) => {});
PushNotification.popInitialNotification((notification) => {});
PushNotification.checkPermissions((checkPermissions) => {});
PushNotification.abandonPermissions();
PushNotification.registerNotificationActions(['Accept', 'Reject', 'Yes', 'No']);
PushNotification.clearAllNotifications();
PushNotification.removeAllDeliveredNotifications();
PushNotification.getDeliveredNotifications((notifications) => {});
PushNotification.getScheduledLocalNotifications((notifications) => {});
PushNotification.removeDeliveredNotifications(['id']);
PushNotification.invokeApp({ message: '' });
PushNotification.getChannels((channels) => {});
PushNotification.channelExists((exists) => {});
PushNotification.createChannel({ channelId: 'id', channelName: 'name' }, (created) => {});
PushNotification.channelBlocked((blocked) => {});
PushNotification.deleteChannel('id');

View File

@ -1,4 +1,4 @@
// Type definitions for non-npm package recurly__recurly-js 4.13
// Type definitions for non-npm package recurly__recurly-js 4.14
// Project: https://github.com/recurly/recurly-js
// Definitions by: Dave Brudner <https://github.com/dbrudner>
// Chris Rogers <https://github.com/chrissrogers>

View File

@ -3,13 +3,27 @@ import { Emitter } from './emitter';
export type ThreeDSecureEvent = 'token' | 'error';
export interface ThreeDSecureEmitter extends Emitter<ThreeDSecureEvent> {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-threedsecureattach|ThreeDSecure.attach}
*/
attach: (el: HTMLElement) => void;
}
export type RiskOptions = {
/**
* `three_d_secure_action_token_id` returned by the Recurly API when 3-D Secure authentication is required for a
* transaction.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-recurlythreedsecure|ThreeDSecure}
*/
actionTokenId?: string;
};
export type ThreeDSecure = (riskOptions: RiskOptions) => ThreeDSecureEmitter;
export type Risk = () => { ThreeDSecure: ThreeDSecure };
export type Risk = () => {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-recurlythreedsecure|ThreeDSecure}
*/
ThreeDSecure: ThreeDSecure
};

View File

@ -1,12 +1,51 @@
export type Address = {
/**
* Cardholder first name
*/
first_name: string;
/**
* Cardholder last name
*/
last_name: string;
/**
* First line of a street address
*/
address1?: string;
/**
* Second line of a street address
*/
address2?: string;
/**
* Town or locality
*/
city?: string;
/**
* Province or region
*/
state?: string;
/**
* Postal code
*/
postal_code?: string;
/**
* {@link http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2| [ISO 3166-1 alpha-2]} country code
*/
country?: string;
/**
* Phone number
*/
phone?: string;
/**
* Customer VAT number. Used for VAT exclusion
*/
vat_number?: string;
};

View File

@ -1,15 +1,33 @@
import { Emitter } from './emitter';
export type AdyenOptions = {
/**
* Invoice Uuid from PendingPurchase
*/
invoiceUuid: string;
/**
* 2 Digit Country Code
*/
countryCode?: string;
/**
* Shopper locale for Payment Modal
*/
shopperLocale?: string;
/**
* Skin code provided by Adyen
*/
skinCode?: string;
};
export type AdyenEvent = 'token' | 'error';
export interface AdyenInstance extends Emitter<AdyenEvent> {
/**
* Invokes the Adyen Payment Modal
*/
start: (adyenOptions: AdyenOptions) => void;
}

View File

@ -2,11 +2,39 @@ import { Emitter } from './emitter';
import { CheckoutPricingInstance } from './pricing/checkout';
export type ApplePayConfig = {
/**
* Your ISO 3166 country code (ex: US). This is your country code as the merchant.
*/
country: string;
/**
* ISO 4217 purchase currency (ex: USD)
*/
currency: string;
/**
* Purchase description to display in the Apple Pay payment sheet.
*/
label: string;
/**
* Total cost to display in the Apple Pay payment sheet. Required if `options.pricing` is not provided.
*/
total: string;
/**
* If provided, will override `options.total` and provide the current total price on the CheckoutPricing instance
* when the Apple Pay flow is initiated.
*/
pricing?: CheckoutPricingInstance;
/**
* If provided, tokens generated by the `recurly.ApplePay` instance will include customer billing address from the
* form, overriding any billing address gathered from Apple Pay.
*
* See {@link https://developers.recurly.com/reference/recurly-js/index.html#getting-a-token|Getting a Token} for all
* compatible fields.
*/
form?: HTMLFormElement;
};
@ -20,6 +48,9 @@ export type ApplePayEvent =
| 'cancel';
export interface ApplePayInstance extends Emitter<ApplePayEvent> {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-applepayready|ApplePay.ready}
*/
ready: (cb?: VoidFunction) => void;
begin: (cb?: VoidFunction) => void;
}

View File

@ -1,15 +1,8 @@
import { RecurlyError } from './error';
import { TokenHandler } from './token';
export type BillingInfo = {
export type BillingInfoCommonFields = {
name_on_account: string;
routing_number?: string;
account_number?: string;
account_number_confirmation?: string;
account_type?: string;
sort_code?: string;
type?: string;
iban?: string;
address1?: string;
address2?: string;
city?: string;
@ -19,11 +12,52 @@ export type BillingInfo = {
vat_number?: string;
};
export type SepaBillingInfo = BillingInfoCommonFields & {
name_on_account: string;
/**
* The International Bank Account Number, up to 34 alphanumeric characters comprising a country code; two check
* digits; and a number that includes the domestic bank account number, branch identifier, and potential routing
* information.
*/
iban: string;
};
export type AccountInfo = BillingInfoCommonFields & {
account_number: string;
account_number_confirmation: string;
};
export type BacsBillingInfo = AccountInfo & {
type: 'bacs';
/**
* Bank identifier code for UK based banks.
*/
sort_code: string;
};
export type BecsBillingInfo = AccountInfo & {
type: 'becs';
branch_code: string;
};
export type BankAccountBillingInfo = AccountInfo & {
routing_number: string;
};
export type BillingInfo = SepaBillingInfo | BacsBillingInfo | BecsBillingInfo | BankAccountBillingInfo;
export type BankInfoOptions = {
/**
* The routing number for a bank (ex: 123456780)
*/
routingNumber: string;
};
export type BankInfoPayload = {
/**
* Bank institution name (ex: Bank of Recurly)
*/
bank_name: string;
};
@ -32,6 +66,13 @@ export type BankInfoHandler = (err: RecurlyError, bankInfo: BankInfoPayload) =>
export type BankInfo = (bankInfoOptions: BankInfoOptions, BankInfoHandler: BankInfoHandler) => void;
export type BankAccount = {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#getting-a-token-1|Getting a token}
*/
token: (data: HTMLFormElement | BillingInfo, tokenHandler: TokenHandler) => void;
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#recurlybankaccountbankinfo|BankInfo}
*/
bankInfo: BankInfo;
};

View File

@ -1,37 +1,153 @@
import { Emitter } from './emitter';
export type CommonElementStyle = {
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/color|color}
*/
fontColor?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-family|font-family}
*/
fontFamily?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-feature-settings|feature-settings}
*/
fontFeatureSettings?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-kerning|font-kerning}
*/
fontKerning?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-size|font-size}
*/
fontSize?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-smoothing|font-smoothing}
*/
fontSmooth?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch|font-stretch}
*/
fontStretch?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-style|font-style}
*/
fontStyle?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant|font-variant}
*/
fontVariant?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight|font-weight}
*/
fontWeight?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/letter-spacing|letter-spacing}
*/
letterSpacing?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/line-height|line-height}
*/
lineHeight?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/text-align|text-align}
*/
textAlign?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/text-decoration|text-decoration}
*/
textDecoration?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/text-rendering|text-rendering}
*/
textRendering?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/text-shadow|text-shadow}
*/
textShadow?: string;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/text-transform|text-transform}
*/
textTransform?: string;
};
export type CardElementOptions = {
/**
* If false, the card brand icon will be hidden
*/
displayIcon?: boolean;
/**
* Modifies the input type of the card field:
*
* 'text' - text input for all fields.
*
* 'mobileSelect' - if the user is using amobile device, a native expiry select interface will appear when entering the
* expiration date.
*
* 'select' - Expiration date will be input using a select field on all devices. Mobile devices will display an
* optimized interface.
*/
inputType?: string;
/**
* `tabindex` property to be applied to the outer iframe.
*/
tabIndex?: string;
/**
* Style to apply to input elements
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#styling-the-individual-card-elements|Styling the invididual card elements}
*/
style?: CommonElementStyle & {
/**
* Style to apply to input elements when they contain an invalid value.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#styling-the-individual-card-elements|Styling the invididual card elements}
*/
invalid?: CommonElementStyle;
placeholder?: {
/**
* Font color applied to all placeholder text.
*/
color?: string;
/**
* Font weight applied to all placeholder text.
*/
fontWeight?: string;
content?: {
/**
* Placeholder content (e.g. 'Card number', 'CVV')
*/
number?: string;
/**
* Placeholder content for the expiry input.
*/
expiry?: string;
/**
* Placeholder content for the card verification value input.
*/
cvv?: string;
};
};
@ -39,14 +155,48 @@ export type CardElementOptions = {
};
export type IndividualElementOptions = {
/**
* Enables contextual input formatting, injecting spaces to match the card brand, and forcing numeric input on expiry
* and cvv.
*/
format?: boolean;
/**
* Modifies the input type of the expiry fields. 'text' - normal text input. 'mobileSelect' - if the user is using a
* mobile device, a native select interface will appear. 'select' - A select field will display on all devices
*/
inputType?: string;
/**
* tabIndex property to be applied to the outer iframe.
*/
tabIndex?: string;
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#common-field-style-properties|Common field style properties}
*/
style?: CommonElementStyle & {
/**
* Style to apply to input elements when they contain an invalid value.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#styling-the-individual-card-elements|Styling the invididual card elements}
*/
invalid: CommonElementStyle;
/**
* @see {@link https://developer.mozilla.org/en-US/docs/Web/CSS/padding}
*/
padding?: string;
placeholder?: {
/**
* Font {@link https://developer.mozilla.org/en-US/docs/Web/CSS/color|color} applied to the placeholder text.
*/
color?: string;
/**
* Placeholder content (e.g. 'Card number', 'CVV')
*/
content?: string;
};
};
@ -57,21 +207,56 @@ export type Attach<ElementType> = (el: string | HTMLElement) => ElementType;
export type ElementEvent = 'change' | 'focus' | 'blur' | 'submit' | 'attach' | 'remove';
export interface CardElement extends Emitter<ElementEvent> {
/**
* Attaches an Element to the DOM, as a child of the specified parent target.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-elementattach|Element.attach}
*/
attach: Attach<CardElement>;
/**
* If an Element has been attached, removes the Element from the DOM. If it is not attached, does nothing.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-elementremove|Element.remove}
*/
remove: () => CardElement;
/**
* Updates the configuration of the Element.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-elementconfigure|Element.configure}
*/
configure: (options: CardElementOptions) => CardElement;
focus: () => CardElement;
}
export interface IndividualElement extends Emitter<ElementEvent> {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-elementattach|Element.attach}
*/
attach: Attach<IndividualElement>;
remove: () => Element;
configure: (options: IndividualElementOptions) => Element;
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-elementremove|Element.remove}
*/
remove: () => IndividualElement;
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-elementconfigure|Element.configure}
*/
configure: (options: IndividualElementOptions) => IndividualElement;
focus: () => IndividualElement;
}
export type ElementsInstanceEvents = 'submit';
export interface ElementsInstance extends Emitter<ElementsInstanceEvents> {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#the-card-element|The Card Element}
*/
CardElement: (cardElementOptions?: CardElementOptions) => CardElement;
CardNumberElement: (cardNumberElementOptions?: IndividualElementOptions) => IndividualElement;
CardMonthElement: (cardMonthElementOptions?: IndividualElementOptions) => IndividualElement;
CardYearElement: (cardYearElementOptions?: IndividualElementOptions) => IndividualElement;

View File

@ -1,5 +1,4 @@
import { Emitter } from './emitter';
import { TokenHandler } from './token';
export type BraintreeConfig = {
braintree: {
@ -24,8 +23,11 @@ export type PayPalStartOptions = {
};
export interface PayPalInstance extends Emitter<PayPalEvent> {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-paypalstart|PayPal.start}
*/
start: (payPalStartOptions?: PayPalStartOptions) => void;
token: TokenHandler;
destroy: VoidFunction;
}

View File

@ -4,18 +4,57 @@ import { PricingPromise } from './promise';
import { SubscriptionPricingState } from './subscription';
export type ItemAdjustment = {
/**
* Item code reference. If provided, the amount and tax properties will be populated from the given item. An itemCode
* may not be used to modify an adjustment in-place.
*/
itemCode: string;
/**
* Number of units
*/
quantity: number;
/**
* Currency code
*/
currency?: string;
/**
* Unique identifier. Use this value to modify an adjustment in-place.
*/
id?: string;
};
export type NonItemAdjustment = {
/**
* In unit price (1.0 for USD, etc)
*/
amount: number;
/**
* Number of units
*/
quantity: number;
/**
* Currency code
*/
currency?: string;
/**
* Whether this adjustment is tax exempt
*/
taxExempt: boolean;
/**
* Taxation code
*/
taxCode: string;
/**
* Unique identifier. Use this value to modify an adjustment in-place.
*/
id?: string;
};
@ -39,26 +78,89 @@ export type CheckoutPricingStateTax = {
export type CheckoutPrice = {
now: {
items: Item[];
/**
* Total cost of all subscriptions. This is part of the subtotal.
*/
subscriptions: string;
/**
* Total cost of all adjustments. This is part of the subtotal.
*/
adjustments: string;
/**
* Amount discounted with coupon use.
*/
discount: string;
/**
* Subtotal of the following pricing components.
*/
subtotal: string;
/**
* Total subscription taxation.
*/
taxes: string;
/**
* The gift card amount that will be applied to the purchase today.
*/
giftCard: string;
/**
* Total subscription cost due now.
*/
total: string;
};
next: {
items: Item[];
/**
* Total cost of all subscriptions. This is part of the subtotal due at the next billing cycle.
*/
subscriptions: string;
/**
* Total cost of all adjustments. This is part of the subtotal due at the next billing cycle.
*/
adjustments: string;
/**
* Amount discounted for next billing cycle with coupon use.
*/
discount: string;
/**
* Subtotal of the following pricing components due at the next billing cycle.
*/
subtotal: string;
/**
* Total subscription taxation due at the next billing cycle.
*/
taxes: string;
/**
* The gift card amount that will be applied to the next billing cycle cost.
*/
giftCard: string;
/**
* Total subscription cost due at the next billing cycle.
*/
total: string;
};
currency: {
/**
* ISO-4217 currency code.
*/
code: string;
/**
* Symbolic representation of currency_code.
*/
symbol: string;
};
taxes: CheckoutPricingStateTax[];
@ -80,6 +182,9 @@ export interface CheckoutPricingMethods {
}
export interface CheckoutPricingInstance extends CheckoutPricingMethods, PricingInstance<CheckoutPricingPromise> {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#fn-checkoutpricingattach|CheckoutPricing.attach}
*/
attach: (element: string | HTMLElement) => void;
}

View File

@ -33,6 +33,13 @@ export interface PricingInstance<PricingPromise> extends Emitter<PricingEvent> {
}
export type Pricing = {
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#pricing|Pricing}
*/
Checkout: () => CheckoutPricingInstance;
/**
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#pricing|Pricing}
*/
Subscription: () => SubscriptionPricingInstance;
};

View File

@ -8,6 +8,8 @@ import { RecurlyError } from '../error';
export interface PricingPromise<T, PricingMethods> extends Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the PricingPromise.
* @param onfulfilled The callback to execute when the PricingPromise is resolved.
* @param onrejected The callback to execute when the PricingPromise is rejected.
* @returns A PricingPromise for the completion of which ever callback is executed.
*/
then<TResult1 = T, TResult2 = never>(
@ -17,6 +19,7 @@ export interface PricingPromise<T, PricingMethods> extends Promise<T> {
/**
* Attaches a callback for only the rejection of the PricingPromise.
* @param onrejected The callback to execute when the PricingPromise is rejected.
* @returns A PricingPromise for the completion of the callback.
*/
catch<TResult = never>(
@ -27,6 +30,8 @@ export interface PricingPromise<T, PricingMethods> extends Promise<T> {
/**
* Attaches callbacks for the resolution and/or rejection of the PricingPromise, without returning a new promise.
* @param onfulfilled The callback to execute when the PricingPromise is resolved.
* @param onrejected The callback to execute when the PricingPromise is rejected.
*/
done(onfulfilled?: (value: T) => any, onrejected?: (reason: any) => any): T;
}

View File

@ -15,14 +15,91 @@ export type RecurlyEvent = 'change' | 'field:submit' | 'error';
export interface Recurly extends Emitter<RecurlyEvent> {
Adyen: Adyen;
/**
* Use Recurly.js to process Apple Pay transactions.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#apple-pay|ApplePay}
*/
ApplePay: ApplePay;
bankAccount: BankAccount;
/**
* Tokenize your users bank account information.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#us-bank-accounts|US Bank Accounts}
*/
bankAccount: BankAccount;
/**
* This identifies your site to Recurly servers.
*
* You can find your public key in the {@link https://app.recurly.com/go/developer/api_access|API Access section}
* of your admin app.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#configure|Configure}
*/
configure: Configure;
/**
* Elements allow sensitive customer payment information to be securely accepted via iframes.
* They are controlled in groups by an Elements instance.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#elements|Elements}
*/
Elements: Elements;
giftCard: GiftCard;
/**
* Use Recurly to process PayPal transactions using PayPal Business or Braintree.
*
* A PayPal transaction is handled entirely within the PayPal checkout flow in a new window.
* Your customer will authorize a transaction within PayPal. Recurly will then record the authorization and return a
* Recurly token to you as it does for other payment methods.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#paypal|PayPal}
*/
PayPal: PayPal;
/**
* Recurly automates complicated subscriptions, with many factors influencing the total price at checkout. With this
* in mind, Recurly.js provides a robust `recurly.Pricing.Checkout` class designed to make determining the actual
* checkout costs as simple and flexible as possible.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#pricing|Pricing}
*/
Pricing: Pricing;
/**
* Strong customer authentication for your users.
*
* Recurly.js provides a set of utilities that allow you to support 3-D Secure authentication on your checkout page
* seamlessly. For more information on 3-D Secure, see our
* {@link https://docs.recurly.com/docs/revised-payment-services-directive-psd2|Introduction to Strong Customer Authentication}
*
* Recurlys support for 3-D Secure utilizes both Recurly.js and our API. For a complete guide to this integration and
* get started, start with our
* {@link https://docs.recurly.com/docs/revised-payment-services-directive-psd2|Strong Customer Authentication (SCA) Integration Guide}
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#3d-secure|3D-Secure}
*/
Risk: Risk;
/**
* Recurly.js works with tokens, which represent secure and temporary storage for your customers sensitive billing
* information. They are stored directly on Recurly servers to reduce your PCI exposure.
*
* When your customers submit your billing form, youll need to interrupt the submit and ask Recurly.js to create a
* token from the form.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#getting-a-token|Token}
*/
token: Token;
/**
* Recurly.js bundles a few helpful methods for validating payment information prior to processing. These methods are
* used when generating tokens, but you can also use them to enhance your form validations and checkout flow.
*
* @see {@link https://developers.recurly.com/reference/recurly-js/index.html#validation|Validation}
*/
validate: Validate;
}

View File

@ -1,9 +1,7 @@
import { TokenHandler, BacsBillingInfo, BecsBillingInfo } from 'recurly__recurly-js';
export default function bankAccount() {
const formEl = document.querySelector('form');
if (!formEl) return;
window.recurly.bankAccount.token(formEl, (err, token) => {
const handleToken: TokenHandler = (err, token) => {
if (err) {
err.message;
err.code;
@ -11,7 +9,13 @@ export default function bankAccount() {
token.id;
token.type;
}
});
};
const formEl = document.querySelector('form');
if (formEl) {
window.recurly.bankAccount.token(formEl, handleToken);
}
const billingInfo = {
routing_number: '123456780',
@ -29,71 +33,75 @@ export default function bankAccount() {
vat_number: 'SE0000',
};
window.recurly.bankAccount.token(billingInfo, (err, token) => {
if (err) {
err.message;
err.code;
} else {
token.id;
token.type;
}
});
window.recurly.bankAccount.token(billingInfo, handleToken);
const div = document.querySelector('div');
if (div) {
// $ExpectError
window.recurly.bankAccount.token(document.querySelector('div'), handleToken);
}
// $ExpectError
window.recurly.bankAccount.token(document.querySelector('div'), (err, token) => {
if (err) {
err.message;
err.code;
} else {
token.id;
token.type;
}
});
window.recurly.bankAccount.token('selector', handleToken);
// $ExpectError
window.recurly.bankAccount.token('selector', (err, token) => {
if (err) {
err.message;
err.code;
} else {
token.id;
token.type;
}
});
const minimalBacsBillingInfo = {
const minimalBacsBillingInfo: BacsBillingInfo = {
type: 'bacs',
account_number: "1234",
account_number_confirmation: "1234",
sort_code: "1234",
name_on_account: "1234"
account_number: '1234',
account_number_confirmation: '1234',
sort_code: '1234',
name_on_account: '1234'
};
window.recurly.bankAccount.token(minimalBacsBillingInfo, (err, token) => {
if (err) {
err.message;
err.code;
} else {
token.id;
token.type;
}
});
window.recurly.bankAccount.token(minimalBacsBillingInfo, handleToken);
const missingNameOnAccountBacsBillingInfo = {
type: 'bacs',
account_number: "1234",
account_number_confirmation: "1234",
sort_code: "1234",
const minimalBecsBillingInfo: BecsBillingInfo = {
type: 'becs',
account_number: '1234',
account_number_confirmation: '1234',
branch_code: '1234',
name_on_account: '1234',
};
window.recurly.bankAccount.token(minimalBecsBillingInfo, handleToken);
// $ExpectError
window.recurly.bankAccount.token(missingNameOnAccountBacsBillingInfo, (err, token) => {
if (err) {
err.message;
err.code;
} else {
token.id;
token.type;
}
});
const missingNameOnAccountBacsBillingInfo: BacsBillingInfo = {
type: 'bacs',
account_number: '1234',
account_number_confirmation: '1234',
sort_code: '1234',
};
const wrongTypeOnAccountBacsBillingInfo: BacsBillingInfo = {
// $ExpectError
type: 'becs',
account_number: '1234',
account_number_confirmation: '1234',
sort_code: '1234',
};
const addressBecsBillingInfo: BecsBillingInfo = {
type: 'becs',
name_on_account: '1234',
account_number: '1234',
account_number_confirmation: '1234',
branch_code: '1234',
address1: 'asdf',
address2: 'asdf',
city: 'asdf',
state: 'asdf',
postal_code: 'asdf',
country: 'asdf',
vat_number: 'asdf'
};
window.recurly.bankAccount.token(addressBecsBillingInfo, handleToken);
const sepaBillingInfo = {
iban: 'my-iban-number',
name_on_account: 'name'
};
window.recurly.bankAccount.token(sepaBillingInfo, handleToken);
}

View File

@ -35,7 +35,7 @@ export default function elements() {
const el = document.querySelector('div');
if (el) {
cardElement.attach(el);
cardElement.attach(el).configure({}).focus().remove();
}
[
@ -44,7 +44,7 @@ export default function elements() {
elements.CardYearElement(elementOptions),
elements.CardCvvElement(elementOptions)
].forEach(element => {
element.attach('#recurly-elements');
element.attach('#recurly-elements').configure({}).focus().remove();
element.on('attach', () => {});
element.on('blur', () => {});
element.on('change', () => {});

View File

@ -84,4 +84,4 @@ export interface SwipeablePanelProps extends React.Props<SwipeablePanel> {
onClose: () => void;
}
export default class SwipeablePanel extends React.Component<SwipeablePanelProps, any> {}
export class SwipeablePanel extends React.Component<SwipeablePanelProps, any> {}

View File

@ -1,5 +1,5 @@
import * as React from 'react';
import SwipeablePanel from 'rn-swipeable-panel';
import { SwipeablePanel } from 'rn-swipeable-panel';
export const App: React.FC = () => {
const [isActive, setIsActive] = React.useState<boolean>(false);

View File

@ -5,5 +5,5 @@
type Point = [number, number];
declare function robustPointInPolygon(vs: Point[], point: Point): number;
declare function robustPointInPolygon(vs: Point[], point: Point): -1 | 0 | 1;
export = robustPointInPolygon;

View File

@ -3,6 +3,7 @@ import BaseClient = require('./BaseClient');
import StreamQuery = require('./StreamQuery');
import StreamStore = require('./StreamStore');
import { Endpoint, EndpointOptions } from './Endpoint';
import { Readable } from 'stream';
interface Constructor<T, Q extends BaseQuad = Quad> {
new (options: { endpoint: Endpoint; factory: DataFactory<Q>; }): T;
@ -40,7 +41,7 @@ declare namespace StreamClient {
interface Store<Q extends BaseQuad = Quad> {
endpoint: Endpoint;
get(graph: Quad['graph']): Promise<Stream<Q>>;
get(graph: Quad['graph']): Promise<Stream<Q> & Readable>;
post(stream: Stream): Promise<void>;
put(stream: Stream): Promise<void>;
}

View File

@ -7,7 +7,7 @@ declare namespace StreamQuery {
factory?: DataFactory<Q>;
}
type StreamQuery<Q extends BaseQuad = Quad> = Query<boolean, Stream<Q>, Readable, void>;
type StreamQuery<Q extends BaseQuad = Quad> = Query<boolean, Stream<Q> & Readable, Readable, void>;
}
interface StreamQuery<Q extends BaseQuad = Quad> extends StreamQuery.StreamQuery<Q> {}

View File

@ -72,8 +72,8 @@ async function streamingClient() {
});
// query.construct
const constructNoOptions: Stream<TestQuad> = await fullOptions.query.construct(query);
const constructFullOptions: Stream<TestQuad> = await fullOptions.query.construct(query, {
const constructNoOptions: Stream<TestQuad> & Readable = await fullOptions.query.construct(query);
const constructFullOptions: Stream<TestQuad> & Readable = await fullOptions.query.construct(query, {
headers,
operation: 'get'
});
@ -86,7 +86,7 @@ async function streamingClient() {
});
// store.get
const get: Stream<TestQuad> = await fullOptions.store.get(graph);
const get: Stream<TestQuad> & Readable = await fullOptions.store.get(graph);
// store.put
const put: Promise<void> = fullOptions.store.put(stream);

View File

@ -17,7 +17,7 @@ export interface Options {
}
export class modal {
constructor(options?: Options);
setContent(content: string | Element): void;
setContent(content: string | Node): void;
getContent(): HTMLDivElement;
destroy(): void;
open(): void;

View File

@ -6,6 +6,10 @@ instance.checkOverflow();
instance.close();
instance.close();
instance.setContent("string content");
instance.setContent(new Node());
instance.setContent(new DocumentFragment());
instance = new modal({
onOpen() {
this.checkOverflow();

View File

@ -310,6 +310,10 @@ declare module 'twit' {
in_reply_to_status_id?: number | string;
page?: number;
auto_populate_reply_metadata?: boolean;
list_id?: number | string;
name?: string;
description?: string;
mode?: 'public' | 'private';
}
export interface PromiseResponse {
data: Response;

View File

@ -17,3 +17,14 @@ t.stream('statuses/filter', {
track: ['#love', '#goscha'],
follow: ['40436619', '606663038', '14466815'],
});
t.post('lists/members/create_all', {
list_id: '1',
user_id: '1,2,3'
});
t.post('lists/create', {
name: 'foo',
description: 'foobar',
mode: 'public'
});

View File

@ -62,7 +62,7 @@ declare namespace WebpackDevMiddleware {
*/
mimeTypes?: MimeTypeMap | OverrideMimeTypeMap | null;
/** The public path that the middleware is bound to */
publicPath: string;
publicPath?: string;
/** Allows users to provide a custom reporter to handle logging within the module */
reporter?: Reporter | null;
/** Instructs the module to enable or disable the server-side rendering mode */

View File

@ -3,9 +3,16 @@ import webpack = require('webpack');
import webpackDevMiddleware = require('webpack-dev-middleware');
const compiler = webpack({});
const compilerWithPublicPath = webpack({
output: {
publicPath: '/assets/'
}
});
let webpackDevMiddlewareInstance = webpackDevMiddleware(compiler);
webpackDevMiddlewareInstance = webpackDevMiddleware(compilerWithPublicPath, {});
webpackDevMiddlewareInstance = webpackDevMiddleware(compiler, {
logLevel: 'silent',
logTime: true,

View File

@ -1,58 +1,92 @@
// Type definitions for non-npm package Media Session API 1.0
// Type definitions for non-npm package Media Session API 1.1
// Project: https://wicg.github.io/mediasession/
// Definitions by: Julien CROUZET <https://github.com/jucrouzet>
// Eana Hufwe <https://github.com/blueset>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
interface Navigator {
readonly mediaSession?: MediaSession;
readonly mediaSession?: MediaSession;
}
interface Window {
MediaSession?: MediaSession;
MediaSession?: MediaSession;
}
type MediaSessionPlaybackState = 'none' | 'paused' | 'playing';
type MediaSessionAction = 'play' | 'pause' | 'seekbackward' | 'seekforward' | 'seekto' | 'previoustrack' | 'nexttrack' | 'skipad' | 'stop';
interface MediaSession {
// Current media session playback state.
playbackState: MediaSessionPlaybackState;
// Current media session meta data.
metadata: MediaMetadata|null;
interface SetPositionState {
(playbackState?: MediaPositionState): void;
}
// Set/Unset actions handlers.
setActionHandler(action: MediaSessionAction, listener: (() => void)|null): void;
interface MediaSession {
// Current media session playback state.
playbackState: MediaSessionPlaybackState;
// Current media session meta data.
metadata: MediaMetadata | null;
// Set/Unset actions handlers.
setActionHandler(action: "seekto", listener: ((details: Required<Pick<MediaSessionActionDetails, "seekTime">> & MediaSessionActionDetails) => void) | null): void;
setActionHandler(action: MediaSessionAction, listener: ((details: MediaSessionActionDetails) => void) | null): void;
// Set/unset position state
setPositionState?: SetPositionState;
}
interface MediaImage {
// URL from which the user agent can fetch the images data.
src: string;
// Specify the MediaImage objects sizes. It follows the spec of sizes attribute in HTML link element.
sizes?: string;
// A hint as to the media type of the image.
type?: string;
// URL from which the user agent can fetch the images data.
src: string;
// Specify the MediaImage objects sizes. It follows the spec of sizes attribute in HTML link element.
sizes?: string;
// A hint as to the media type of the image.
type?: string;
}
interface MediaMetadataInit {
// Media's title.
title?: string;
// Media's artist.
artist?: string;
// Media's album.
album?: string;
// Media's artwork.
artwork?: MediaImage[];
// Media's title.
title?: string;
// Media's artist.
artist?: string;
// Media's album.
album?: string;
// Media's artwork.
artwork?: MediaImage[];
}
declare class MediaMetadata {
constructor(init?: MediaMetadataInit);
// Media's title.
title: string;
// Media's artist.
artist: string;
// Media's album.
album: string;
// Media's artwork.
artwork: MediaImage[];
constructor(init?: MediaMetadataInit);
// Media's title.
title: string;
// Media's artist.
artist: string;
// Media's album.
album: string;
// Media's artwork.
artwork: ReadonlyArray<MediaImage>;
}
interface MediaPositionState {
// Duration of media in seconds
duration?: number;
// Playback rate of media, positive for forward playback, negative for backward playback. This number should not be zero
playbackRate?: number;
// Last reported playback position in seconds, should be positive.
position?: number;
}
interface MediaSessionActionDetails {
// The action that the handler is associated with
action: MediaSessionAction;
// This MAY be provided when the action is seekbackward or seekforward. Stores number of seconds to move the playback time by.
seekOffset?: number;
// MUST be provided when action is seekto. Stores the time in seconds to move the playback time to.
seekTime?: number;
// MAY be provided when action is seekto. Stores true if the action is being called multiple times as part of a sequence and this is not the last call in that sequence.
fastSeek?: boolean;
}

View File

@ -5,31 +5,60 @@ const audio: HTMLAudioElement = document.createElement('audio');
audio.src = tracks[trackId];
function updatePlayingMedia(): void {
audio.src = tracks[trackId];
audio.src = tracks[trackId];
}
if ('mediaSession' in navigator && navigator.mediaSession) {
navigator.mediaSession.setActionHandler('previoustrack', (): void => {
trackId = (trackId + tracks.length - 1) % tracks.length;
updatePlayingMedia();
});
function updatePositionState() {
if (navigator.mediaSession && navigator.mediaSession.setPositionState) {
navigator.mediaSession.setPositionState({
duration: audio.duration,
playbackRate: audio.playbackRate,
position: audio.currentTime
});
}
}
navigator.mediaSession.setActionHandler('nexttrack', (): void => {
trackId = (trackId + 1) % tracks.length;
updatePlayingMedia();
});
navigator.mediaSession.setActionHandler('previoustrack', (): void => {
trackId = (trackId + tracks.length - 1) % tracks.length;
updatePlayingMedia();
});
navigator.mediaSession.metadata = new MediaMetadata({
title: 'Episode Title',
artist: 'Podcast Host',
album: 'Podcast Title',
artwork: [
{src: 'podcast.jpg', sizes: '128x128', type: 'image/jpeg'},
{src: 'podcast_hd.jpg', sizes: '256x256'},
{src: 'podcast_xhd.jpg', sizes: '1024x1024', type: 'image/jpeg'},
{src: 'podcast.png', sizes: '128x128', type: 'image/png'},
{src: 'podcast_hd.png', sizes: '256x256', type: 'image/png'},
{src: 'podcast.ico', sizes: '128x128 256x256', type: 'image/x-icon'}
]
});
navigator.mediaSession.setActionHandler('nexttrack', (): void => {
trackId = (trackId + 1) % tracks.length;
updatePlayingMedia();
});
navigator.mediaSession.setActionHandler('play', (): void => {
if (navigator.mediaSession) {
navigator.mediaSession.playbackState = "playing";
}
});
navigator.mediaSession.setActionHandler('pause', (): void => {
if (navigator.mediaSession) {
navigator.mediaSession.playbackState = "paused";
}
});
navigator.mediaSession.setActionHandler('seekto', (event) => {
if (event.fastSeek === false) {
audio.currentTime = event.seekTime;
}
updatePositionState();
});
navigator.mediaSession.metadata = new MediaMetadata({
title: 'Episode Title',
artist: 'Podcast Host',
album: 'Podcast Title',
artwork: [
{ src: 'podcast.jpg', sizes: '128x128', type: 'image/jpeg' },
{ src: 'podcast_hd.jpg', sizes: '256x256' },
{ src: 'podcast_xhd.jpg', sizes: '1024x1024', type: 'image/jpeg' },
{ src: 'podcast.png', sizes: '128x128', type: 'image/png' },
{ src: 'podcast_hd.png', sizes: '256x256', type: 'image/png' },
{ src: 'podcast.ico', sizes: '128x128 256x256', type: 'image/x-icon' }
]
});
}

View File

@ -129,6 +129,7 @@ export interface StringSchema<T extends string | null | undefined = string | und
): StringSchema<T>;
email(message?: StringLocale['email']): StringSchema<T>;
url(message?: StringLocale['url']): StringSchema<T>;
uuid(message?: StringLocale['uuid']): StringSchema<T>;
ensure(): StringSchema<T>;
trim(message?: StringLocale['trim']): StringSchema<T>;
lowercase(message?: StringLocale['lowercase']): StringSchema<T>;
@ -592,6 +593,7 @@ export interface StringLocale {
matches?: TestOptionsMessage<{ regex: RegExp }>;
email?: TestOptionsMessage<{ regex: RegExp }>;
url?: TestOptionsMessage<{ regex: RegExp }>;
uuid?: TestOptionsMessage<{ regex: RegExp }>;
trim?: TestOptionsMessage;
lowercase?: TestOptionsMessage;
uppercase?: TestOptionsMessage;

View File

@ -354,6 +354,9 @@ function strSchemaTests(strSchema: yup.StringSchema) {
strSchema.url('bad url');
strSchema.url(() => 'bad url');
strSchema.url(({ regex }) => `Does not match ${regex}`);
strSchema.uuid();
strSchema.uuid('invalid uuid');
strSchema.uuid(() => 'invalid uuid');
strSchema.ensure();
strSchema.trim();
strSchema.trim('trimmed');
@ -631,6 +634,7 @@ const exhaustiveLocalObjectconst: LocaleObject = {
matches: '${path} must match the following: "${regex}"',
email: '${path} must be a valid email',
url: '${path} must be a valid URL',
uuid: '${path} must be a valid UUID',
trim: '${path} must be a trimmed string',
lowercase: '${path} must be a lowercase string',
uppercase: '${path} must be a upper case string',