mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
Merge branch 'master' into update-other-tests-for-3.7
This commit is contained in:
@@ -2850,6 +2850,12 @@
|
||||
"sourceRepoURL": "https://github.com/stream-utils/raw-body",
|
||||
"asOfVersion": "2.3.0"
|
||||
},
|
||||
{
|
||||
"libraryName": "re2",
|
||||
"typingsPackageName": "re2",
|
||||
"sourceRepoURL": "https://github.com/uhop/node-re2",
|
||||
"asOfVersion": "1.10.3"
|
||||
},
|
||||
{
|
||||
"libraryName": "react-chartjs-2",
|
||||
"typingsPackageName": "react-chartjs-2",
|
||||
|
||||
38
types/async-eventemitter/async-eventemitter-tests.ts
Normal file
38
types/async-eventemitter/async-eventemitter-tests.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import * as AsyncEventEmitter from 'async-eventemitter';
|
||||
|
||||
const ee = new AsyncEventEmitter<{
|
||||
sync: (a: string) => void;
|
||||
// "sync-multiple": (a: string, b: number) => void,
|
||||
async: (data?: { a: string; b: boolean }) => Promise<any>;
|
||||
// "illegal-async": (data: string, data2: number) => Promise<any>,
|
||||
'premature-resolve': (
|
||||
data: number,
|
||||
resolve?: (result: any) => void,
|
||||
) => Promise<any>;
|
||||
'premature-resolve-empty': (
|
||||
data: number,
|
||||
resolve?: () => void,
|
||||
) => Promise<any>;
|
||||
'is-empty': () => any;
|
||||
}>();
|
||||
|
||||
ee.emit('sync', 'yes');
|
||||
ee.emit('async', { a: 'a', b: true });
|
||||
ee.emit('async');
|
||||
ee.emit('is-empty');
|
||||
ee.emit('premature-resolve', 1);
|
||||
|
||||
(async () => {
|
||||
// await new Promise((resolve) => ee.emit("async", undefined, resolve)); // fail
|
||||
// await new Promise((resolve) => ee.emit("premature-resolve", undefined, resolve)); // Should fail
|
||||
await new Promise(resolve => ee.emit('premature-resolve', 1, resolve));
|
||||
})();
|
||||
|
||||
ee.on('is-empty', () => {});
|
||||
ee.on('async', async data => {
|
||||
`Reach the end of async function and ${data}`;
|
||||
});
|
||||
ee.on('premature-resolve', async (data, resolve) => {
|
||||
if (resolve) resolve(true);
|
||||
'does not reach here';
|
||||
});
|
||||
107
types/async-eventemitter/index.d.ts
vendored
Normal file
107
types/async-eventemitter/index.d.ts
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
// Type definitions for async-eventemitter 0.2
|
||||
// Project: https://www.npmjs.com/package/async-eventemitter (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
|
||||
// Definitions by: patarapolw <https://github.com/patarapolw>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.5
|
||||
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
/**
|
||||
* The API and behavior of AsyncEventEmitter is as far as possible and meaningful identical to
|
||||
* that of the native EventEmitter. However there are some important differences which should be noted.
|
||||
* - Data sent to event listeners (eg emit(data)) must always be zero or one argument, and can not be a function.
|
||||
* - Event listeners will always recieve the data object, which may or may not be undefined.
|
||||
* - The second argument can only be a callback, and will only be supplied if the event listener has an arity of two or more (eg function(e, next){}).
|
||||
* - Event listeners with an arity of one or zero (eg without a callback argument specified) will be treated as synchronous.
|
||||
* - Even if all event listeners are synchronous, they will still be executed asynchronously (through setImmediate) and thus code suceeding .emit() will be executed before any event listeners.
|
||||
* - Interupt the callback chain in async listeners by calling the callback with the error as the first parameter; in sync listeners by throwing an Error.
|
||||
* @see https://www.npmjs.com/package/async-eventemitter#important-differences-between-asynceventemitter-the-native-eventemitter
|
||||
*/
|
||||
export = AsyncEventEmitter;
|
||||
|
||||
/**
|
||||
* An EventEmitter that supports serial execution of asynchronous event listeners.
|
||||
* It also supports event listeners without callbacks (synchronous), as well as
|
||||
* interrupting the call-chain (similar to the DOM's e.stopPropagation()).
|
||||
*/
|
||||
declare class AsyncEventEmitter<
|
||||
T extends AsyncEventEmitter.EventMap
|
||||
> extends EventEmitter {
|
||||
/**
|
||||
* Executes all listeners for the event in order with the supplied data argument.
|
||||
* The optional callback is called when all of the listeners are done.
|
||||
* @param event EventMap key (event name)
|
||||
* @param args EventMap parameters
|
||||
* @see https://www.npmjs.com/package/async-eventemitter#important-differences-between-asynceventemitter-the-native-eventemitter
|
||||
*/
|
||||
emit<E extends keyof T>(
|
||||
event: E & string,
|
||||
...args: Parameters<T[E]>
|
||||
): boolean;
|
||||
/**
|
||||
* Adds a listener to the beginning of the listeners array for the specified event.
|
||||
* @param event EventMap key (event name)
|
||||
* @param listener EventMap value (event function)
|
||||
* @see https://www.npmjs.com/package/async-eventemitter#important-differences-between-asynceventemitter-the-native-eventemitter
|
||||
*/
|
||||
first<E extends keyof T>(event: E & string, listener: T[E]): this;
|
||||
/**
|
||||
* Adds a listener at the specified index in the listeners array for the specified event.
|
||||
* @param event EventMap key (event name)
|
||||
* @param index Index to insert at
|
||||
* @param listener EventMap value (event function)
|
||||
* @see https://www.npmjs.com/package/async-eventemitter#important-differences-between-asynceventemitter-the-native-eventemitter
|
||||
*/
|
||||
at<E extends keyof T>(event: E & string, index: number, listener: T[E]): this;
|
||||
/**
|
||||
* Adds a listener before the target listener in the listeners array for the specified event.
|
||||
* @param event EventMap key (event name)
|
||||
* @param target Listener to insert before
|
||||
* @param listener EventMap value (event function)
|
||||
* @see https://www.npmjs.com/package/async-eventemitter#important-differences-between-asynceventemitter-the-native-eventemitter
|
||||
*/
|
||||
before<E extends keyof T>(
|
||||
event: E & string,
|
||||
target: T[E],
|
||||
listener: T[E],
|
||||
): this;
|
||||
/**
|
||||
* Adds a listener after the target listener in the listeners array for the specified event.
|
||||
* @param event EventMap key (event name)
|
||||
* @param target Listener to insert before
|
||||
* @param listener EventMap value (event function)
|
||||
* @see https://www.npmjs.com/package/async-eventemitter#important-differences-between-asynceventemitter-the-native-eventemitter
|
||||
*/
|
||||
after<E extends keyof T>(
|
||||
event: E & string,
|
||||
target: T[E],
|
||||
listener: T[E],
|
||||
): this;
|
||||
|
||||
// https://github.com/andywer/typed-emitter/blob/master/index.d.ts
|
||||
addListener<E extends keyof T>(event: E & string, listener: T[E]): this;
|
||||
on<E extends keyof T>(event: E & string, listener: T[E]): this;
|
||||
once<E extends keyof T>(event: E & string, listener: T[E]): this;
|
||||
prependListener<E extends keyof T>(event: E & string, listener: T[E]): this;
|
||||
prependOnceListener<E extends keyof T>(
|
||||
event: E & string,
|
||||
listener: T[E],
|
||||
): this;
|
||||
|
||||
removeAllListeners(event?: keyof T & string): this;
|
||||
removeListener<E extends keyof T>(event: E & string, listener: T[E]): this;
|
||||
|
||||
eventNames(): Array<keyof T & string>;
|
||||
listeners<E extends keyof T>(event: E & string): Array<T[E]>;
|
||||
listenerCount(event: keyof T & string): number;
|
||||
|
||||
getMaxListeners(): number;
|
||||
setMaxListeners(maxListeners: number): this;
|
||||
}
|
||||
|
||||
declare namespace AsyncEventEmitter {
|
||||
type AsyncListener<T, R> = ((data: T, callback: (result?: R) => void) => Promise<R>) | ((data: T, callback: (result?: R) => void) => void);
|
||||
interface EventMap {
|
||||
[event: string]: AsyncListener<any, any>;
|
||||
}
|
||||
}
|
||||
23
types/async-eventemitter/tsconfig.json
Normal file
23
types/async-eventemitter/tsconfig.json
Normal 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",
|
||||
"async-eventemitter-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/cleave.js/options/index.d.ts
vendored
1
types/cleave.js/options/index.d.ts
vendored
@@ -44,6 +44,7 @@ export interface CleaveOptions {
|
||||
copyDelimiter?: boolean;
|
||||
delimiter?: string;
|
||||
delimiters?: ReadonlyArray<string>;
|
||||
delimiterLazyShow?: boolean;
|
||||
initValue?: any;
|
||||
lowercase?: boolean;
|
||||
numericOnly?: boolean;
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
import compassVerticalRhythm = require('compass-vertical-rhythm');
|
||||
|
||||
compassVerticalRhythm({ baseFontSize: '16px' });
|
||||
compassVerticalRhythm({ baseLineHeight: 1.5 });
|
||||
compassVerticalRhythm({ baseLineHeight: '16px' });
|
||||
compassVerticalRhythm({ rhythmUnit: '%' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'ch' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'em' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'ex' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'px' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'rem' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'vh' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'vmin' });
|
||||
compassVerticalRhythm({ rhythmUnit: 'vw' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderWidth: '16px' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'solid' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'none' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'hidden' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'dashed' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'dotted' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'double' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'groove' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'ridge' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'inset' });
|
||||
compassVerticalRhythm({ defaultRhythmBorderStyle: 'outset' });
|
||||
compassVerticalRhythm({ roundToNearestHalfLine: true });
|
||||
compassVerticalRhythm({ minLinePadding: '2px' });
|
||||
|
||||
const cvr = compassVerticalRhythm({
|
||||
baseFontSize: '16px',
|
||||
baseLineHeight: 1.5,
|
||||
rhythmUnit: 'rem',
|
||||
defaultRhythmBorderWidth: '1px',
|
||||
defaultRhythmBorderStyle: 'solid',
|
||||
roundToNearestHalfLine: true,
|
||||
minLinePadding: '2px',
|
||||
});
|
||||
|
||||
cvr.rhythm();
|
||||
cvr.rhythm(1);
|
||||
cvr.rhythm(1, '16px');
|
||||
cvr.rhythm(1, '16px', 4);
|
||||
|
||||
cvr.establishBaseline().fontSize;
|
||||
cvr.establishBaseline().lineHeight;
|
||||
|
||||
cvr.linesForFontSize('16px');
|
||||
|
||||
cvr.adjustFontSizeTo('32px', 1, '16px').fontSize;
|
||||
cvr.adjustFontSizeTo('32px', 1, '16px').lineHeight;
|
||||
cvr.adjustFontSizeTo('32px', 'auto', '16px');
|
||||
cvr.adjustFontSizeTo('32px', null, '16px');
|
||||
cvr.adjustFontSizeTo('32px', 1);
|
||||
cvr.adjustFontSizeTo('32px');
|
||||
41
types/compass-vertical-rhythm/index.d.ts
vendored
Normal file
41
types/compass-vertical-rhythm/index.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
// Type definitions for compass-vertical-rhythm 1.4
|
||||
// Project: https://github.com/KyleAMathews/compass-vertical-rhythm
|
||||
// Definitions by: Luis Rodrigues <https://github.com/goblindegook>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
export = compassVerticalRhythm;
|
||||
|
||||
interface Options {
|
||||
baseFontSize?: string;
|
||||
baseLineHeight?: number | string;
|
||||
rhythmUnit?: '%' | 'em' | 'ex' | 'ch' | 'px' | 'rem' | 'vw' | 'vh' | 'vmin';
|
||||
defaultRhythmBorderWidth?: string;
|
||||
defaultRhythmBorderStyle?:
|
||||
| 'solid'
|
||||
| 'none'
|
||||
| 'hidden'
|
||||
| 'dashed'
|
||||
| 'dotted'
|
||||
| 'double'
|
||||
| 'groove'
|
||||
| 'ridge'
|
||||
| 'inset'
|
||||
| 'outset';
|
||||
roundToNearestHalfLine?: boolean;
|
||||
minLinePadding?: string;
|
||||
}
|
||||
|
||||
interface VerticalRhythmStyles {
|
||||
fontSize: string;
|
||||
lineHeight: string;
|
||||
}
|
||||
|
||||
interface VerticalRhythm {
|
||||
rhythm(lines?: number, fontSize?: string, offset?: number): number;
|
||||
establishBaseline(): VerticalRhythmStyles;
|
||||
linesForFontSize(fontSize: string): number;
|
||||
adjustFontSizeTo(toSize: string, lines?: number | 'auto' | null, fromSize?: string): VerticalRhythmStyles;
|
||||
}
|
||||
|
||||
declare function compassVerticalRhythm(options: Options): VerticalRhythm;
|
||||
16
types/compass-vertical-rhythm/tsconfig.json
Normal file
16
types/compass-vertical-rhythm/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": ["es6"],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": ["../"],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": ["index.d.ts", "compass-vertical-rhythm-tests.ts"]
|
||||
}
|
||||
1
types/compass-vertical-rhythm/tslint.json
Normal file
1
types/compass-vertical-rhythm/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
21
types/draftjs-to-html/draftjs-to-html-tests.ts
Normal file
21
types/draftjs-to-html/draftjs-to-html-tests.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import draftToHtml from 'draftjs-to-html';
|
||||
|
||||
const editorContent = {
|
||||
blocks: [
|
||||
{
|
||||
key: '355iu',
|
||||
text: 'test',
|
||||
type: 'unstyled',
|
||||
depth: 0,
|
||||
inlineStyleRanges: [],
|
||||
entityRanges: [],
|
||||
data: {
|
||||
'text-align': 'center',
|
||||
},
|
||||
},
|
||||
],
|
||||
entityMap: {},
|
||||
};
|
||||
|
||||
// $ExpectType string
|
||||
draftToHtml(editorContent);
|
||||
21
types/draftjs-to-html/index.d.ts
vendored
Normal file
21
types/draftjs-to-html/index.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// Type definitions for draftjs-to-html 0.8
|
||||
// Project: https://github.com/jpuri/draftjs-to-html#readme
|
||||
// Definitions by: Ivan Zverev <https://github.com/1cheese>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.9
|
||||
|
||||
import { RawDraftContentState } from 'draft-js';
|
||||
|
||||
interface HashtagConfig {
|
||||
trigger?: string;
|
||||
separator?: string;
|
||||
}
|
||||
|
||||
declare function draftToHtml(
|
||||
editorContent: RawDraftContentState,
|
||||
hashtagConfig?: HashtagConfig,
|
||||
directional?: boolean,
|
||||
customEntityTransform?: (...args: any[]) => any,
|
||||
): string;
|
||||
|
||||
export = draftToHtml;
|
||||
26
types/draftjs-to-html/tsconfig.json
Normal file
26
types/draftjs-to-html/tsconfig.json
Normal file
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"jsx": "react",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"esModuleInterop": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"draftjs-to-html-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/draftjs-to-html/tslint.json
Normal file
3
types/draftjs-to-html/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
67
types/ej.web.all/index.d.ts
vendored
67
types/ej.web.all/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for non-npm package ej.web.all 17.2
|
||||
// Type definitions for non-npm package ej.web.all 17.3
|
||||
// Project: http://help.syncfusion.com/js/typescript
|
||||
// Definitions by: Syncfusion <https://github.com/syncfusion>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
/*!
|
||||
* filename: ej.web.all.d.ts
|
||||
* version : 17.2.0.46
|
||||
* version : 17.3.0.9-beta
|
||||
* Copyright Syncfusion Inc. 2001 - 2019. All rights reserved.
|
||||
* Use of this code is subject to the terms of our license.
|
||||
* A copy of the current license can be obtained at any time by e-mailing
|
||||
@@ -37663,7 +37663,7 @@ declare namespace ej {
|
||||
/** Specifies the print option of the report.
|
||||
* @Default {ej.ReportViewer.PrintOptions.Default}
|
||||
*/
|
||||
printOptions?: ej.ReportViewer.PrintOptions|string;
|
||||
printOption?: ej.ReportViewer.PrintOptions|string;
|
||||
|
||||
/** Specifies the processing mode of the report.
|
||||
* @Default {ej.ReportViewer.ProcessingMode.Remote}
|
||||
@@ -38247,6 +38247,16 @@ declare namespace ej {
|
||||
* @Default {auto}
|
||||
*/
|
||||
popupWidth?: string;
|
||||
|
||||
/** Specifies the width of the parameter item. By default, the item width value is set as "185px".
|
||||
* @Default {185px}
|
||||
*/
|
||||
itemWidth?: string;
|
||||
|
||||
/** Specifies the width of the parameter label. By default, the parameter label width value is set as "110px".
|
||||
* @Default {110px}
|
||||
*/
|
||||
labelWidth?: string;
|
||||
}
|
||||
|
||||
enum ExportOptions {
|
||||
@@ -38254,8 +38264,8 @@ declare namespace ej {
|
||||
///Specifies the All property in ExportOptions to get all available options.
|
||||
All,
|
||||
|
||||
///Specifies the PDF property in ExportOptions to get PDF option.
|
||||
PDF,
|
||||
///Specifies the Pdf property in ExportOptions to get Pdf option.
|
||||
Pdf,
|
||||
|
||||
///Specifies the Word property in ExportOptions to get Word option.
|
||||
Word,
|
||||
@@ -38263,8 +38273,17 @@ declare namespace ej {
|
||||
///Specifies the Excel property in ExportOptions to get Excel option.
|
||||
Excel,
|
||||
|
||||
///Specifies the HTML property in ExportOptions to get HTML option.
|
||||
HTML
|
||||
///Specifies the Html property in ExportOptions to get Html option.
|
||||
Html,
|
||||
|
||||
///Specifies the PPT property in ExportOptions to get PPT option.
|
||||
PPT,
|
||||
|
||||
///Specifies the CSV property in ExportOptions to get CSV option.
|
||||
CSV,
|
||||
|
||||
///Specifies the customItems property in ExportOptions to get customItems option.
|
||||
CustomItems
|
||||
}
|
||||
|
||||
|
||||
@@ -49665,6 +49684,11 @@ declare namespace ej {
|
||||
*/
|
||||
locale?: string;
|
||||
|
||||
/** Shows or hides the create, edit, and delete options in data source and dataset panels.
|
||||
* @Default {ej.ReportDesigner.Permission.All}
|
||||
*/
|
||||
permissionSettings?: PermissionSettings;
|
||||
|
||||
/** Gets or sets the list of custom data extension items.
|
||||
* @Default {[]}
|
||||
*/
|
||||
@@ -49680,6 +49704,11 @@ declare namespace ej {
|
||||
*/
|
||||
reportPath?: string;
|
||||
|
||||
/** Gets or sets the report type.
|
||||
* @Default {ej.ReportDesigner.ReportType.RDL}
|
||||
*/
|
||||
reportType?: string;
|
||||
|
||||
/** Gets or sets the reports server URL.
|
||||
* @Default {null}
|
||||
*/
|
||||
@@ -49872,6 +49901,14 @@ declare namespace ej {
|
||||
showConfigurePane?: boolean;
|
||||
}
|
||||
|
||||
export interface PermissionSettings {
|
||||
|
||||
/** Shows or hides the create, edit and delete options in data source pane with the help of ej.ReportDesigner.Permission enum.
|
||||
* @Default {ej.ReportDesigner.Permission.All}
|
||||
*/
|
||||
dataSource?: ej.ReportDesigner.Permission|string;
|
||||
}
|
||||
|
||||
export interface ReportDataExtension {
|
||||
|
||||
/** Gets or sets the name of the datasource type.
|
||||
@@ -49946,6 +49983,22 @@ declare namespace ej {
|
||||
templateId?: string;
|
||||
}
|
||||
|
||||
enum Permission {
|
||||
|
||||
///Shows or hides create option in data source pane.
|
||||
Create,
|
||||
|
||||
///Shows or hides the edit option in data source pane.
|
||||
Edit,
|
||||
|
||||
///Shows or hides the delete option in data source pane.
|
||||
Delete,
|
||||
|
||||
///Shows all the options in data source pane.
|
||||
All
|
||||
}
|
||||
|
||||
|
||||
enum ToolbarItems {
|
||||
|
||||
///Creates a new, blank report.
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* This is stub file for gapi.client.{{=it.name}} definition tests */
|
||||
/* IMPORTANT.
|
||||
* This file was automatically generated by https://github.com/Bolisov/google-api-typings-generator. Please do not edit it manually.
|
||||
* In case of any problems please post issue to https://github.com/Bolisov/google-api-typings-generator
|
||||
* This file was generated by https://github.com/Maxim-Mazurok/google-api-typings-generator/tree/patch-1. Please do not edit it manually.
|
||||
* In case of any problems please post issue to https://github.com/Maxim-Mazurok/google-api-typings-generator or https://github.com/Bolisov/google-api-typings-generator
|
||||
**/
|
||||
gapi.load('client', () => {
|
||||
/** now we can use gapi.client */
|
||||
@@ -12,13 +12,13 @@ gapi.load('client', () => {
|
||||
/** declare client_id registered in Google Developers Console */
|
||||
const client_id = '<<PUT YOUR CLIENT ID HERE>>';
|
||||
const scope = [
|
||||
/** View and manage the files in your Google Drive */
|
||||
/** See, edit, create, and delete all of your Google Drive files */
|
||||
'https://www.googleapis.com/auth/drive',
|
||||
/** View and manage Google Drive files and folders that you have opened or created with this app */
|
||||
'https://www.googleapis.com/auth/drive.file',
|
||||
/** View the files in your Google Drive */
|
||||
/** See and download all your Google Drive files */
|
||||
'https://www.googleapis.com/auth/drive.readonly',
|
||||
/** View and manage your spreadsheets in Google Drive */
|
||||
/** See, edit, create, and delete your spreadsheets in Google Drive */
|
||||
'https://www.googleapis.com/auth/spreadsheets',
|
||||
/** View your Google Spreadsheets */
|
||||
'https://www.googleapis.com/auth/spreadsheets.readonly',
|
||||
@@ -57,11 +57,11 @@ gapi.load('client', () => {
|
||||
* collaborator changes. If there are no collaborators, the spreadsheet
|
||||
* should reflect your changes.
|
||||
*/
|
||||
await gapi.client.spreadsheets.batchUpdate({
|
||||
await gapi.client.sheets.spreadsheets.batchUpdate({
|
||||
spreadsheetId: "spreadsheetId",
|
||||
});
|
||||
/** Creates a spreadsheet, returning the newly created spreadsheet. */
|
||||
await gapi.client.spreadsheets.create({
|
||||
await gapi.client.sheets.spreadsheets.create({
|
||||
});
|
||||
/**
|
||||
* Returns the spreadsheet at the given ID.
|
||||
@@ -86,7 +86,7 @@ gapi.load('client', () => {
|
||||
* return only the portions of the spreadsheet that intersect the requested
|
||||
* ranges. Ranges are specified using A1 notation.
|
||||
*/
|
||||
await gapi.client.spreadsheets.get({
|
||||
await gapi.client.sheets.spreadsheets.get({
|
||||
includeGridData: true,
|
||||
ranges: "ranges",
|
||||
spreadsheetId: "spreadsheetId",
|
||||
@@ -115,7 +115,7 @@ gapi.load('client', () => {
|
||||
* For large spreadsheets, it is recommended to retrieve only the specific
|
||||
* fields of the spreadsheet that you want.
|
||||
*/
|
||||
await gapi.client.spreadsheets.getByDataFilter({
|
||||
await gapi.client.sheets.spreadsheets.getByDataFilter({
|
||||
spreadsheetId: "spreadsheetId",
|
||||
});
|
||||
}
|
||||
|
||||
582
types/gapi.client.sheets/index.d.ts
vendored
582
types/gapi.client.sheets/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
12
types/gray-percentage/gray-percentage-tests.ts
Normal file
12
types/gray-percentage/gray-percentage-tests.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import grayPercentage = require('gray-percentage');
|
||||
|
||||
grayPercentage(1);
|
||||
grayPercentage(1, 1);
|
||||
grayPercentage(1, 'cool');
|
||||
grayPercentage(1, 'slate');
|
||||
grayPercentage(1, 'warm');
|
||||
grayPercentage(1, 1, true);
|
||||
|
||||
function testReturnValue(value: string): void {}
|
||||
|
||||
testReturnValue(grayPercentage(1));
|
||||
12
types/gray-percentage/index.d.ts
vendored
Normal file
12
types/gray-percentage/index.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
// Type definitions for gray-percentage 2.0
|
||||
// Project: https://github.com/KyleAMathews/gray-percentage
|
||||
// Definitions by: Luis Rodrigues <https://github.com/goblindegook>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = grayPercentage;
|
||||
|
||||
declare function grayPercentage(
|
||||
lightness: number,
|
||||
hue?: number | 'cool' | 'slate' | 'warm',
|
||||
darkBackground?: boolean,
|
||||
): string;
|
||||
@@ -18,6 +18,6 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"re2-tests.ts"
|
||||
"gray-percentage-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/gray-percentage/tslint.json
Normal file
1
types/gray-percentage/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
@@ -4,3 +4,5 @@ hdKey.derive('m/1/42');
|
||||
hdKey.privateKey;
|
||||
hdKey.publicKey;
|
||||
hdKey.chainCode;
|
||||
hdKey.toJSON();
|
||||
HDKey.fromJSON({ xpriv: '', xpub: '' });
|
||||
|
||||
3
types/hdkey/index.d.ts
vendored
3
types/hdkey/index.d.ts
vendored
@@ -1,6 +1,7 @@
|
||||
// Type definitions for hdkey 0.7
|
||||
// Project: https://github.com/cryptocoinjs/hdkey
|
||||
// Definitions by: Leonid Logvinov <https://github.com/LogvinovLeon>
|
||||
// Tvrtko Majstorovic <https://github.com/TvrtkoM>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/// <reference types="node"/>
|
||||
@@ -12,5 +13,7 @@ declare class HDNode {
|
||||
chainCode: Buffer;
|
||||
constructor();
|
||||
derive(path: string): HDNode;
|
||||
toJSON(): { xpriv: string; xpub: string };
|
||||
static fromJSON(obj: { xpriv: string; xpub: string }): HDNode;
|
||||
}
|
||||
export = HDNode;
|
||||
|
||||
13
types/isstream/index.d.ts
vendored
Normal file
13
types/isstream/index.d.ts
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
// Type definitions for isstream 0.1
|
||||
// Project: https://github.com/rvagg/isstream
|
||||
// Definitions by: Matthew Peveler <https://github.com/MasterOdin>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
declare function isStream(obj: any): boolean;
|
||||
declare namespace isStream {
|
||||
function isReadable(obj: any): boolean;
|
||||
function isWritable(obj: any): boolean;
|
||||
function isDuplex(obj: any): boolean;
|
||||
}
|
||||
|
||||
export = isStream;
|
||||
42
types/isstream/isstream-tests.ts
Normal file
42
types/isstream/isstream-tests.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
/// <reference types="node" />
|
||||
|
||||
import isStream = require('isstream');
|
||||
import { isDuplex, isReadable, isWritable } from 'isstream';
|
||||
import { Stream, Readable, Writable, Duplex } from 'stream';
|
||||
|
||||
const objs = [
|
||||
new Stream(),
|
||||
new Readable(),
|
||||
new Writable(),
|
||||
new Duplex(),
|
||||
'string',
|
||||
10
|
||||
];
|
||||
|
||||
for (let i = 0; i < objs.length; i++) {
|
||||
let type = 'not a stream';
|
||||
if (isStream.isDuplex(objs[i])) {
|
||||
type = 'duplex';
|
||||
} else if (isStream.isWritable(objs[i])) {
|
||||
type = 'writable';
|
||||
} else if (isStream.isReadable(objs[i])) {
|
||||
type = 'readable';
|
||||
} else if (isStream(objs[i])) {
|
||||
type = 'stream';
|
||||
}
|
||||
console.log(`${i}. ${type}`);
|
||||
}
|
||||
|
||||
for (let i = 0; i < objs.length; i++) {
|
||||
let type = 'not a stream';
|
||||
if (isDuplex(objs[i])) {
|
||||
type = 'duplex';
|
||||
} else if (isWritable(objs[i])) {
|
||||
type = 'writable';
|
||||
} else if (isReadable(objs[i])) {
|
||||
type = 'readable';
|
||||
} else if (isStream(objs[i])) {
|
||||
type = 'stream';
|
||||
}
|
||||
console.log(`${i}. ${type}`);
|
||||
}
|
||||
24
types/isstream/tsconfig.json
Normal file
24
types/isstream/tsconfig.json
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6",
|
||||
"dom"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"isstream-tests.ts"
|
||||
]
|
||||
}
|
||||
3
types/isstream/tslint.json
Normal file
3
types/isstream/tslint.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
1
types/json-rules-engine/index.d.ts
vendored
1
types/json-rules-engine/index.d.ts
vendored
@@ -78,6 +78,7 @@ export class Rule {
|
||||
| 'equal'
|
||||
| 'notEqual'
|
||||
| 'lessThan'
|
||||
| 'lessthanInclusive'
|
||||
| 'greaterThan'
|
||||
| 'greaterThanInclusive'
|
||||
| 'in'
|
||||
|
||||
302
types/kendo-ui/index.d.ts
vendored
302
types/kendo-ui/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Kendo UI Professional v2019.2.619
|
||||
// Type definitions for Kendo UI Professional v2019.3.917
|
||||
// Project: http://www.telerik.com/kendo-ui
|
||||
// Definitions by: Telerik <https://github.com/telerik>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -1191,6 +1191,13 @@ declare namespace kendo.data {
|
||||
field?: string;
|
||||
dir?: string;
|
||||
aggregates?: DataSourceGroupItemAggregate[];
|
||||
compare?: (a: DataSourceGroupCompareItem, b: DataSourceGroupCompareItem) => number;
|
||||
}
|
||||
|
||||
interface DataSourceGroupCompareItem {
|
||||
field: string;
|
||||
value: any;
|
||||
items: any[];
|
||||
}
|
||||
|
||||
interface DataSourceSchema {
|
||||
@@ -1717,7 +1724,7 @@ declare namespace kendo.ui {
|
||||
highlightFirst?: boolean;
|
||||
ignoreCase?: boolean;
|
||||
minLength?: number;
|
||||
noDataTemplate?: string|Function;
|
||||
noDataTemplate?: string|Function|boolean;
|
||||
placeholder?: string;
|
||||
popup?: any;
|
||||
separator?: string|any;
|
||||
@@ -2241,7 +2248,7 @@ declare namespace kendo.ui {
|
||||
ignoreCase?: boolean;
|
||||
index?: number;
|
||||
minLength?: number;
|
||||
noDataTemplate?: string|Function;
|
||||
noDataTemplate?: string|Function|boolean;
|
||||
placeholder?: string;
|
||||
popup?: ComboBoxPopup;
|
||||
suggest?: boolean;
|
||||
@@ -2306,8 +2313,7 @@ declare namespace kendo.ui {
|
||||
|
||||
constructor(element: Element, options?: ConfirmOptions);
|
||||
|
||||
|
||||
|
||||
open(): kendo.ui.Confirm;
|
||||
}
|
||||
|
||||
interface ConfirmMessages {
|
||||
@@ -2317,7 +2323,11 @@ declare namespace kendo.ui {
|
||||
|
||||
interface ConfirmOptions {
|
||||
name?: string;
|
||||
content?: string;
|
||||
messages?: ConfirmMessages;
|
||||
title?: string | boolean;
|
||||
initOpen?(e: DialogEvent): void;
|
||||
open?(e: DialogEvent): void;
|
||||
}
|
||||
interface ConfirmEvent {
|
||||
sender: Confirm;
|
||||
@@ -3014,7 +3024,7 @@ declare namespace kendo.ui {
|
||||
ignoreCase?: boolean;
|
||||
index?: number;
|
||||
minLength?: number;
|
||||
noDataTemplate?: string|Function;
|
||||
noDataTemplate?: string|Function|boolean;
|
||||
popup?: DropDownListPopup;
|
||||
optionLabel?: string|any;
|
||||
optionLabelTemplate?: string|Function;
|
||||
@@ -3160,7 +3170,7 @@ declare namespace kendo.ui {
|
||||
loadOnDemand?: boolean;
|
||||
messages?: DropDownTreeMessages;
|
||||
minLength?: number;
|
||||
noDataTemplate?: string|Function;
|
||||
noDataTemplate?: string|Function|boolean;
|
||||
placeholder?: string;
|
||||
popup?: DropDownTreePopup;
|
||||
headerTemplate?: string|Function;
|
||||
@@ -3595,7 +3605,7 @@ declare namespace kendo.ui {
|
||||
resizable?: boolean | EditorResizable;
|
||||
serialization?: EditorSerialization;
|
||||
stylesheets?: any;
|
||||
tools?: EditorTool[];
|
||||
tools?: EditorTool[]|string[];
|
||||
imageBrowser?: EditorImageBrowser;
|
||||
fileBrowser?: EditorFileBrowser;
|
||||
change?(e: EditorEvent): void;
|
||||
@@ -3626,6 +3636,112 @@ declare namespace kendo.ui {
|
||||
}
|
||||
|
||||
|
||||
class Filter extends kendo.ui.Widget {
|
||||
|
||||
static fn: Filter;
|
||||
|
||||
options: FilterOptions;
|
||||
|
||||
dataSource: kendo.data.DataSource;
|
||||
|
||||
element: JQuery;
|
||||
wrapper: JQuery;
|
||||
|
||||
static extend(proto: Object): Filter;
|
||||
|
||||
constructor(element: Element, options?: FilterOptions);
|
||||
|
||||
|
||||
applyFilter(): void;
|
||||
|
||||
}
|
||||
|
||||
interface FilterField {
|
||||
defaultValue?: any;
|
||||
editorTemplate?: string|Function;
|
||||
label?: string;
|
||||
name?: string;
|
||||
type?: string;
|
||||
}
|
||||
|
||||
interface FilterMessages {
|
||||
and?: string;
|
||||
apply?: string;
|
||||
or?: string;
|
||||
}
|
||||
|
||||
interface FilterOperatorsBoolean {
|
||||
eq?: string;
|
||||
neq?: string;
|
||||
}
|
||||
|
||||
interface FilterOperatorsDate {
|
||||
eq?: string;
|
||||
neq?: string;
|
||||
isnull?: string;
|
||||
isnotnull?: string;
|
||||
gte?: string;
|
||||
gt?: string;
|
||||
lte?: string;
|
||||
lt?: string;
|
||||
}
|
||||
|
||||
interface FilterOperatorsNumber {
|
||||
eq?: string;
|
||||
neq?: string;
|
||||
isnull?: string;
|
||||
isnotnull?: string;
|
||||
gte?: string;
|
||||
gt?: string;
|
||||
lte?: string;
|
||||
lt?: string;
|
||||
}
|
||||
|
||||
interface FilterOperatorsString {
|
||||
eq?: string;
|
||||
neq?: string;
|
||||
isnull?: string;
|
||||
isnotnull?: string;
|
||||
isempty?: string;
|
||||
isnotempty?: string;
|
||||
startswith?: string;
|
||||
contains?: string;
|
||||
doesnotcontain?: string;
|
||||
endswith?: string;
|
||||
isnullorempty?: string;
|
||||
isnotnullorempty?: string;
|
||||
}
|
||||
|
||||
interface FilterOperators {
|
||||
string?: FilterOperatorsString;
|
||||
number?: FilterOperatorsNumber;
|
||||
date?: FilterOperatorsDate;
|
||||
boolean?: FilterOperatorsBoolean;
|
||||
}
|
||||
|
||||
interface FilterOptions {
|
||||
name?: string;
|
||||
applyButton?: boolean;
|
||||
dataSource?: kendo.data.DataSource;
|
||||
expression?: any;
|
||||
expressionPreview?: boolean;
|
||||
fields?: FilterField[];
|
||||
mainLogic?: string;
|
||||
messages?: FilterMessages;
|
||||
operators?: FilterOperators;
|
||||
change?(e: FilterChangeEvent): void;
|
||||
}
|
||||
interface FilterEvent {
|
||||
sender: Filter;
|
||||
preventDefault: Function;
|
||||
isDefaultPrevented(): boolean;
|
||||
}
|
||||
|
||||
interface FilterChangeEvent extends FilterEvent {
|
||||
expression?: any;
|
||||
}
|
||||
|
||||
|
||||
class FilterMenu extends kendo.ui.Widget {
|
||||
|
||||
static fn: FilterMenu;
|
||||
@@ -5279,7 +5395,7 @@ declare namespace kendo.ui {
|
||||
ignoreCase?: boolean;
|
||||
index?: number;
|
||||
minLength?: number;
|
||||
noDataTemplate?: string|Function;
|
||||
noDataTemplate?: string|Function|boolean;
|
||||
placeholder?: string;
|
||||
popup?: MultiColumnComboBoxPopup;
|
||||
suggest?: boolean;
|
||||
@@ -5416,7 +5532,7 @@ declare namespace kendo.ui {
|
||||
ignoreCase?: boolean;
|
||||
minLength?: number;
|
||||
maxSelectedItems?: number;
|
||||
noDataTemplate?: string|Function;
|
||||
noDataTemplate?: string|Function|boolean;
|
||||
placeholder?: string;
|
||||
popup?: MultiSelectPopup;
|
||||
headerTemplate?: string|Function;
|
||||
@@ -5966,6 +6082,9 @@ declare namespace kendo.ui {
|
||||
collapse(element: string, useAnimation: boolean): kendo.ui.PanelBar;
|
||||
collapse(element: Element, useAnimation: boolean): kendo.ui.PanelBar;
|
||||
collapse(element: JQuery, useAnimation: boolean): kendo.ui.PanelBar;
|
||||
dataItem(node: JQuery): kendo.data.Node;
|
||||
dataItem(node: Element): kendo.data.Node;
|
||||
dataItem(node: string): kendo.data.Node;
|
||||
destroy(): void;
|
||||
enable(element: string, enable: boolean): void;
|
||||
enable(element: Element, enable: boolean): void;
|
||||
@@ -6317,6 +6436,7 @@ declare namespace kendo.ui {
|
||||
class Popup extends kendo.ui.Widget {
|
||||
|
||||
static fn: Popup;
|
||||
static TabKeyTrap: any;
|
||||
|
||||
options: PopupOptions;
|
||||
|
||||
@@ -7749,6 +7869,68 @@ declare namespace kendo.ui {
|
||||
checked?: any;
|
||||
}
|
||||
|
||||
class Rating extends kendo.ui.Widget {
|
||||
|
||||
static fn: Rating;
|
||||
|
||||
options: RatingOptions;
|
||||
|
||||
|
||||
element: JQuery;
|
||||
wrapper: JQuery;
|
||||
container: JQuery;
|
||||
|
||||
static extend(proto: Object): Rating;
|
||||
|
||||
constructor(element: Element, options?: RatingOptions);
|
||||
|
||||
value(value: number): void;
|
||||
reset(): void;
|
||||
enable(enable: boolean): void;
|
||||
readonly(enable: boolean): void;
|
||||
setOptions(options: any): void;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
interface RatingOptions {
|
||||
name?: string;
|
||||
min?: number;
|
||||
max?: number;
|
||||
selection: string | "continuous" | "single";
|
||||
precision: string | "item" | "half";
|
||||
label?: boolean | RatingLabel;
|
||||
tooltip?: boolean;
|
||||
itemTemplate?: string|Function;
|
||||
selectedTemplate?: string|Function;
|
||||
hoveredTemplate?: string|Function;
|
||||
selectValueOnFocus?: number;
|
||||
enabled?: boolean;
|
||||
readonly?: boolean;
|
||||
change?(e: RatingChangeEvent): void;
|
||||
select?(e: RatingSelectEvent): void;
|
||||
}
|
||||
|
||||
interface RatingLabel {
|
||||
template: string|Function;
|
||||
}
|
||||
|
||||
interface RatingEvent {
|
||||
sender: Rating;
|
||||
preventDefault: Function;
|
||||
isDefaultPrevented(): boolean;
|
||||
}
|
||||
|
||||
interface RatingChangeEvent extends RatingEvent {
|
||||
target?: Element;
|
||||
oldValue?: number;
|
||||
newValue?: number;
|
||||
}
|
||||
|
||||
interface RatingSelectEvent extends RatingEvent {
|
||||
target?: Element;
|
||||
}
|
||||
|
||||
|
||||
class TabStrip extends kendo.ui.Widget {
|
||||
|
||||
static fn: TabStrip;
|
||||
@@ -7971,6 +8153,93 @@ declare namespace kendo.ui {
|
||||
interface TimePickerOpenEvent extends TimePickerEvent {
|
||||
}
|
||||
|
||||
class Timeline extends kendo.ui.Widget {
|
||||
|
||||
static fn: Timeline;
|
||||
|
||||
options: TimelineOptions;
|
||||
|
||||
dataSource: kendo.data.DataSource;
|
||||
|
||||
element: JQuery;
|
||||
wrapper: JQuery;
|
||||
|
||||
static extend(proto: Object): Timeline;
|
||||
|
||||
constructor(element: Element, options?: TimelineOptions);
|
||||
|
||||
|
||||
expand(event: string): void;
|
||||
expand(event: Element): void;
|
||||
expand(event: JQuery): void;
|
||||
collapse(event: string): void;
|
||||
collapse(event: Element): void;
|
||||
collapse(event: JQuery): void;
|
||||
open(event: string): void;
|
||||
open(event: Element): void;
|
||||
open(event: JQuery): void;
|
||||
destroy(): void;
|
||||
next(): void;
|
||||
previous(): void;
|
||||
redraw(): void;
|
||||
setDataSource(dataSource: kendo.data.DataSource): void;
|
||||
|
||||
}
|
||||
|
||||
interface TimelineOptions {
|
||||
name?: string;
|
||||
alternatingMode?: boolean;
|
||||
orientation?: string;
|
||||
collapsibleEvents?: boolean;
|
||||
dataActionsField?: string;
|
||||
dataDescriptionField?: string;
|
||||
dataDateField?: string;
|
||||
dataImagesField?: string;
|
||||
dataSubTitleField?: string;
|
||||
dataTitleField?: string;
|
||||
dataSource?: kendo.data.DataSource|any;
|
||||
eventTemplate?: string|Function;
|
||||
dateformat?: string;
|
||||
eventHeight?: number;
|
||||
eventWidth?: number;
|
||||
showDateLabels?: boolean;
|
||||
change?(e: TimelineChangeEvent): void;
|
||||
dataBound?(e: TimelineDataBoundEvent): void;
|
||||
expand?(e: TimelineExpandEvent): void;
|
||||
collapse?(e: TimelineCollapseEvent): void;
|
||||
actionClick?(e: TimelineActionClickEvent): void;
|
||||
navigate?(e: TimelineNavigateEvent): void;
|
||||
}
|
||||
interface TimelineEvent {
|
||||
sender: Timeline;
|
||||
preventDefault: Function;
|
||||
isDefaultPrevented(): boolean;
|
||||
}
|
||||
|
||||
interface TimelineChangeEvent extends TimelineEvent {
|
||||
dataItem?: kendo.data.Model;
|
||||
eventContainer?: JQuery;
|
||||
}
|
||||
|
||||
interface TimelineDataBoundEvent extends TimelineEvent {
|
||||
}
|
||||
|
||||
interface TimelineExpandEvent extends TimelineEvent {
|
||||
dataItem?: kendo.data.Model;
|
||||
}
|
||||
|
||||
interface TimelineCollapseEvent extends TimelineEvent {
|
||||
dataItem?: kendo.data.Model;
|
||||
}
|
||||
|
||||
interface TimelineActionClickEvent extends TimelineEvent {
|
||||
dataItem?: kendo.data.Model;
|
||||
element?: JQuery;
|
||||
}
|
||||
|
||||
interface TimelineNavigateEvent extends TimelineEvent {
|
||||
action?: string;
|
||||
}
|
||||
|
||||
class ToolBar extends kendo.ui.Widget {
|
||||
|
||||
@@ -10485,6 +10754,7 @@ declare namespace kendo.dataviz.ui {
|
||||
|
||||
interface ArcGaugeOptions {
|
||||
name?: string;
|
||||
centerTemplate?: string|Function;
|
||||
color?: string;
|
||||
colors?: ArcGaugeColor[];
|
||||
gaugeArea?: ArcGaugeGaugeArea;
|
||||
@@ -21626,6 +21896,10 @@ interface JQuery {
|
||||
kendoEditor(options: kendo.ui.EditorOptions): JQuery;
|
||||
data(key: "kendoEditor"): kendo.ui.Editor;
|
||||
|
||||
kendoFilter(): JQuery;
|
||||
kendoFilter(options: kendo.ui.FilterOptions): JQuery;
|
||||
data(key: "kendoFilter"): kendo.ui.Filter;
|
||||
|
||||
kendoFilterMenu(): JQuery;
|
||||
kendoFilterMenu(options: kendo.ui.FilterMenuOptions): JQuery;
|
||||
data(key: "kendoFilterMenu"): kendo.ui.FilterMenu;
|
||||
@@ -21854,6 +22128,10 @@ interface JQuery {
|
||||
kendoSwitch(options: kendo.ui.SwitchOptions): JQuery;
|
||||
data(key: "kendoSwitch"): kendo.ui.Switch;
|
||||
|
||||
kendoRating(): JQuery;
|
||||
kendoRating(options: kendo.ui.RatingOptions): JQuery;
|
||||
data(key: "kendoRating"): kendo.ui.Rating;
|
||||
|
||||
kendoTabStrip(): JQuery;
|
||||
kendoTabStrip(options: kendo.ui.TabStripOptions): JQuery;
|
||||
data(key: "kendoTabStrip"): kendo.ui.TabStrip;
|
||||
@@ -21862,6 +22140,10 @@ interface JQuery {
|
||||
kendoTimePicker(options: kendo.ui.TimePickerOptions): JQuery;
|
||||
data(key: "kendoTimePicker"): kendo.ui.TimePicker;
|
||||
|
||||
kendoTimeline(): JQuery;
|
||||
kendoTimeline(options: kendo.ui.TimelineOptions): JQuery;
|
||||
data(key: "kendoTimeline"): kendo.ui.Timeline;
|
||||
|
||||
kendoToolBar(): JQuery;
|
||||
kendoToolBar(options: kendo.ui.ToolBarOptions): JQuery;
|
||||
data(key: "kendoToolBar"): kendo.ui.ToolBar;
|
||||
|
||||
11
types/libnpmsearch/index.d.ts
vendored
11
types/libnpmsearch/index.d.ts
vendored
@@ -28,9 +28,18 @@ declare namespace search {
|
||||
date?: Date;
|
||||
}
|
||||
|
||||
interface Score {
|
||||
final: number;
|
||||
detail: {
|
||||
quality: number;
|
||||
popularity: number;
|
||||
maintenance: number;
|
||||
};
|
||||
}
|
||||
|
||||
interface DetailedResult {
|
||||
package: Result;
|
||||
score: number;
|
||||
score: Score;
|
||||
searchScore: number;
|
||||
}
|
||||
|
||||
|
||||
30
types/lodash/common/object.d.ts
vendored
30
types/lodash/common/object.d.ts
vendored
@@ -815,7 +815,7 @@ declare module "../index" {
|
||||
defaults<TObject, TSource>(
|
||||
object: TObject,
|
||||
source: TSource
|
||||
): TSource & TObject;
|
||||
): NonNullable<TSource & TObject>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -824,7 +824,7 @@ declare module "../index" {
|
||||
object: TObject,
|
||||
source1: TSource1,
|
||||
source2: TSource2
|
||||
): TSource2 & TSource1 & TObject;
|
||||
): NonNullable<TSource2 & TSource1 & TObject>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -834,7 +834,7 @@ declare module "../index" {
|
||||
source1: TSource1,
|
||||
source2: TSource2,
|
||||
source3: TSource3
|
||||
): TSource3 & TSource2 & TSource1 & TObject;
|
||||
): NonNullable<TSource3 & TSource2 & TSource1 & TObject>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -845,12 +845,12 @@ declare module "../index" {
|
||||
source2: TSource2,
|
||||
source3: TSource3,
|
||||
source4: TSource4
|
||||
): TSource4 & TSource3 & TSource2 & TSource1 & TObject;
|
||||
): NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & TObject>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TObject>(object: TObject): TObject;
|
||||
defaults<TObject>(object: TObject): NonNullable<TObject>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -867,7 +867,7 @@ declare module "../index" {
|
||||
*/
|
||||
defaults<TSource>(
|
||||
source: TSource
|
||||
): LoDashImplicitWrapper<TSource & TValue>;
|
||||
): LoDashImplicitWrapper<NonNullable<TSource & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -875,7 +875,7 @@ declare module "../index" {
|
||||
defaults<TSource1, TSource2>(
|
||||
source1: TSource1,
|
||||
source2: TSource2
|
||||
): LoDashImplicitWrapper<TSource2 & TSource1 & TValue>;
|
||||
): LoDashImplicitWrapper<NonNullable<TSource2 & TSource1 & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -884,7 +884,7 @@ declare module "../index" {
|
||||
source1: TSource1,
|
||||
source2: TSource2,
|
||||
source3: TSource3
|
||||
): LoDashImplicitWrapper<TSource3 & TSource2 & TSource1 & TValue>;
|
||||
): LoDashImplicitWrapper<NonNullable<TSource3 & TSource2 & TSource1 & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -894,12 +894,12 @@ declare module "../index" {
|
||||
source2: TSource2,
|
||||
source3: TSource3,
|
||||
source4: TSource4
|
||||
): LoDashImplicitWrapper<TSource4 & TSource3 & TSource2 & TSource1 & TValue>;
|
||||
): LoDashImplicitWrapper<NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults(): LoDashImplicitWrapper<TValue>;
|
||||
defaults(): LoDashImplicitWrapper<NonNullable<TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -913,7 +913,7 @@ declare module "../index" {
|
||||
*/
|
||||
defaults<TSource>(
|
||||
source: TSource
|
||||
): LoDashExplicitWrapper<TSource & TValue>;
|
||||
): LoDashExplicitWrapper<NonNullable<TSource & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -921,7 +921,7 @@ declare module "../index" {
|
||||
defaults<TSource1, TSource2>(
|
||||
source1: TSource1,
|
||||
source2: TSource2
|
||||
): LoDashExplicitWrapper<TSource2 & TSource1 & TValue>;
|
||||
): LoDashExplicitWrapper<NonNullable<TSource2 & TSource1 & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -930,7 +930,7 @@ declare module "../index" {
|
||||
source1: TSource1,
|
||||
source2: TSource2,
|
||||
source3: TSource3
|
||||
): LoDashExplicitWrapper<TSource3 & TSource2 & TSource1 & TValue>;
|
||||
): LoDashExplicitWrapper<NonNullable<TSource3 & TSource2 & TSource1 & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
@@ -940,12 +940,12 @@ declare module "../index" {
|
||||
source2: TSource2,
|
||||
source3: TSource3,
|
||||
source4: TSource4
|
||||
): LoDashExplicitWrapper<TSource4 & TSource3 & TSource2 & TSource1 & TValue>;
|
||||
): LoDashExplicitWrapper<NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults(): LoDashExplicitWrapper<TValue>;
|
||||
defaults(): LoDashExplicitWrapper<NonNullable<TValue>>;
|
||||
|
||||
/**
|
||||
* @see _.defaults
|
||||
|
||||
16
types/lodash/fp.d.ts
vendored
16
types/lodash/fp.d.ts
vendored
@@ -468,16 +468,16 @@ declare namespace _ {
|
||||
interface LodashDefaults {
|
||||
<TSource>(source: TSource): LodashDefaults1x1<TSource>;
|
||||
<TObject>(source: lodash.__, object: TObject): LodashDefaults1x2<TObject>;
|
||||
<TObject, TSource>(source: TSource, object: TObject): TSource & TObject;
|
||||
<TObject, TSource>(source: TSource, object: TObject): NonNullable<TSource & TObject>;
|
||||
}
|
||||
type LodashDefaults1x1<TSource> = <TObject>(object: TObject) => TSource & TObject;
|
||||
type LodashDefaults1x2<TObject> = <TSource>(source: TSource) => TSource & TObject;
|
||||
type LodashDefaults1x1<TSource> = <TObject>(object: TObject) => NonNullable<TSource & TObject>;
|
||||
type LodashDefaults1x2<TObject> = <TSource>(source: TSource) => NonNullable<TSource & TObject>;
|
||||
interface LodashDefaultsAll {
|
||||
<TObject, TSource>(object: [TObject, TSource]): TSource & TObject;
|
||||
<TObject, TSource1, TSource2>(object: [TObject, TSource1, TSource2]): TSource2 & TSource1 & TObject;
|
||||
<TObject, TSource1, TSource2, TSource3>(object: [TObject, TSource1, TSource2, TSource3]): TSource3 & TSource2 & TSource1 & TObject;
|
||||
<TObject, TSource1, TSource2, TSource3, TSource4>(object: [TObject, TSource1, TSource2, TSource3, TSource4]): TSource4 & TSource3 & TSource2 & TSource1 & TObject;
|
||||
<TObject>(object: [TObject]): TObject;
|
||||
<TObject, TSource>(object: [TObject, TSource]): NonNullable<TSource & TObject>;
|
||||
<TObject, TSource1, TSource2>(object: [TObject, TSource1, TSource2]): NonNullable<TSource2 & TSource1 & TObject>;
|
||||
<TObject, TSource1, TSource2, TSource3>(object: [TObject, TSource1, TSource2, TSource3]): NonNullable<TSource3 & TSource2 & TSource1 & TObject>;
|
||||
<TObject, TSource1, TSource2, TSource3, TSource4>(object: [TObject, TSource1, TSource2, TSource3, TSource4]): NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & TObject>;
|
||||
<TObject>(object: [TObject]): NonNullable<TObject>;
|
||||
(object: ReadonlyArray<any>): any;
|
||||
}
|
||||
interface LodashDefaultsDeep {
|
||||
|
||||
4
types/lodash/ts3.1/common/array.d.ts
vendored
4
types/lodash/ts3.1/common/array.d.ts
vendored
@@ -488,7 +488,9 @@ declare module "../index" {
|
||||
*/
|
||||
flatten(): T extends Many<infer U> ? CollectionChain<U> : CollectionChain<T>;
|
||||
}
|
||||
type Flat<T> = (T extends List<any> ? never : T);
|
||||
|
||||
type Flat<T> = T extends string ? T : (T extends List<any> ? never : T);
|
||||
|
||||
interface LoDashStatic {
|
||||
/**
|
||||
* Recursively flattens a nested array.
|
||||
|
||||
30
types/lodash/ts3.1/common/object.d.ts
vendored
30
types/lodash/ts3.1/common/object.d.ts
vendored
@@ -479,23 +479,23 @@ declare module "../index" {
|
||||
* @param sources The source objects.
|
||||
* @return The destination object.
|
||||
*/
|
||||
defaults<TObject, TSource>(object: TObject, source: TSource): TSource & TObject;
|
||||
defaults<TObject, TSource>(object: TObject, source: TSource): NonNullable<TSource & TObject>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): TSource2 & TSource1 & TObject;
|
||||
defaults<TObject, TSource1, TSource2>(object: TObject, source1: TSource1, source2: TSource2): NonNullable<TSource2 & TSource1 & TObject>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3): TSource3 & TSource2 & TSource1 & TObject;
|
||||
defaults<TObject, TSource1, TSource2, TSource3>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3): NonNullable<TSource3 & TSource2 & TSource1 & TObject>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): TSource4 & TSource3 & TSource2 & TSource1 & TObject;
|
||||
defaults<TObject, TSource1, TSource2, TSource3, TSource4>(object: TObject, source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & TObject>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TObject>(object: TObject): TObject;
|
||||
defaults<TObject>(object: TObject): NonNullable<TObject>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
@@ -505,23 +505,23 @@ declare module "../index" {
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource>(source: TSource): Object<TSource & T>;
|
||||
defaults<TSource>(source: TSource): Object<NonNullable<TSource & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource1, TSource2>(source1: TSource1, source2: TSource2): Object<TSource2 & TSource1 & T>;
|
||||
defaults<TSource1, TSource2>(source1: TSource1, source2: TSource2): Object<NonNullable<TSource2 & TSource1 & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource1, TSource2, TSource3>(source1: TSource1, source2: TSource2, source3: TSource3): Object<TSource3 & TSource2 & TSource1 & T>;
|
||||
defaults<TSource1, TSource2, TSource3>(source1: TSource1, source2: TSource2, source3: TSource3): Object<NonNullable<TSource3 & TSource2 & TSource1 & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource1, TSource2, TSource3, TSource4>(source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): Object<TSource4 & TSource3 & TSource2 & TSource1 & T>;
|
||||
defaults<TSource1, TSource2, TSource3, TSource4>(source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): Object<NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults(): Object<T>;
|
||||
defaults(): Object<NonNullable<T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
@@ -531,23 +531,23 @@ declare module "../index" {
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource>(source: TSource): ObjectChain<TSource & T>;
|
||||
defaults<TSource>(source: TSource): ObjectChain<NonNullable<TSource & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource1, TSource2>(source1: TSource1, source2: TSource2): ObjectChain<TSource2 & TSource1 & T>;
|
||||
defaults<TSource1, TSource2>(source1: TSource1, source2: TSource2): ObjectChain<NonNullable<TSource2 & TSource1 & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource1, TSource2, TSource3>(source1: TSource1, source2: TSource2, source3: TSource3): ObjectChain<TSource3 & TSource2 & TSource1 & T>;
|
||||
defaults<TSource1, TSource2, TSource3>(source1: TSource1, source2: TSource2, source3: TSource3): ObjectChain<NonNullable<TSource3 & TSource2 & TSource1 & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults<TSource1, TSource2, TSource3, TSource4>(source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): ObjectChain<TSource4 & TSource3 & TSource2 & TSource1 & T>;
|
||||
defaults<TSource1, TSource2, TSource3, TSource4>(source1: TSource1, source2: TSource2, source3: TSource3, source4: TSource4): ObjectChain<NonNullable<TSource4 & TSource3 & TSource2 & TSource1 & T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
defaults(): ObjectChain<T>;
|
||||
defaults(): ObjectChain<NonNullable<T>>;
|
||||
/**
|
||||
* @see _.defaults
|
||||
*/
|
||||
|
||||
@@ -497,6 +497,9 @@ _.chain([1, 2, 3, 4]).unshift(5, 6); // $ExpectType CollectionChain<number>
|
||||
_.flattenDeep([1, [2, [3, [4, 5]]]]); // $ExpectType number[]
|
||||
_.flattenDeep({0: 1, 1: [2, [3, [4, 5]]], length: 2}); // $ExpectType number[]
|
||||
|
||||
_.flattenDeep(['x']); // $ExpectType string[]
|
||||
_.flattenDeep(['x', ['y']]); // $ExpectType string[]
|
||||
|
||||
_.flattenDeep<number>([1, 2, 3]); // $ExpectType number[]
|
||||
_.flattenDeep<number>([[1, 2, 3]]); // $ExpectType number[]
|
||||
_.flattenDeep<number>([1, [2, [3, [4, 5]]]]); // $ExpectType number[]
|
||||
|
||||
18
types/mongoose-paginate-v2/index.d.ts
vendored
18
types/mongoose-paginate-v2/index.d.ts
vendored
@@ -3,6 +3,7 @@
|
||||
// Definitions by: Linus Brolin <https://github.com/linusbrolin>
|
||||
// simonxca <https://github.com/simonxca>
|
||||
// woutgg <https://github.com/woutgg>
|
||||
// oktapodia <https://github.com/oktapodia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
//
|
||||
@@ -27,7 +28,7 @@ declare module 'mongoose' {
|
||||
customLabels?: CustomLabels;
|
||||
collation?: CollationOptions;
|
||||
/* tslint:disable-next-line: ban-types */
|
||||
populate?: Object[] | string[] | Object | string;
|
||||
populate?: Object[] | string[] | Object | string | QueryPopulateOptions;
|
||||
lean?: boolean;
|
||||
leanWithId?: boolean;
|
||||
offset?: number;
|
||||
@@ -35,6 +36,21 @@ declare module 'mongoose' {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
interface QueryPopulateOptions {
|
||||
/** space delimited path(s) to populate */
|
||||
path: string;
|
||||
/** optional fields to select */
|
||||
select?: any;
|
||||
/** optional query conditions to match */
|
||||
match?: any;
|
||||
/** optional model to use for population */
|
||||
model?: string | Model<any>;
|
||||
/** optional query options like sort, limit, etc */
|
||||
options?: any;
|
||||
/** deep populate */
|
||||
populate?: QueryPopulateOptions | QueryPopulateOptions[];
|
||||
}
|
||||
|
||||
interface PaginateResult<T> {
|
||||
docs: T[];
|
||||
total: number;
|
||||
|
||||
@@ -43,6 +43,9 @@ router.get('/users.json', (req: Request, res: Response) => {
|
||||
options.sort = { username: (descending ? -1 : 1) };
|
||||
options.collation = { locale: 'en_US', strength: 1 };
|
||||
options.populate = '';
|
||||
options.populate = {
|
||||
path: '',
|
||||
};
|
||||
options.lean = true;
|
||||
options.leanWithId = false;
|
||||
options.offset = 0;
|
||||
|
||||
24
types/mongoose-paginate/index.d.ts
vendored
24
types/mongoose-paginate/index.d.ts
vendored
@@ -2,7 +2,7 @@
|
||||
// Project: https://github.com/edwardhotchkiss/mongoose-paginate
|
||||
// Definitions by: Linus Brolin <https://github.com/linusbrolin>, simonxca <https://github.com/simonxca>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
/// <reference types="mongoose" />
|
||||
|
||||
@@ -10,7 +10,12 @@ declare module 'mongoose' {
|
||||
export interface PaginateOptions {
|
||||
select?: Object | string;
|
||||
sort?: Object | string;
|
||||
populate?: Array<Object> | Array<string> | Object | string;
|
||||
populate?:
|
||||
| Array<Object>
|
||||
| Array<string>
|
||||
| Object
|
||||
| string
|
||||
| QueryPopulateOptions;
|
||||
lean?: boolean;
|
||||
leanWithId?: boolean;
|
||||
offset?: number;
|
||||
@@ -18,6 +23,21 @@ declare module 'mongoose' {
|
||||
limit?: number;
|
||||
}
|
||||
|
||||
interface QueryPopulateOptions {
|
||||
/** space delimited path(s) to populate */
|
||||
path: string;
|
||||
/** optional fields to select */
|
||||
select?: any;
|
||||
/** optional query conditions to match */
|
||||
match?: any;
|
||||
/** optional model to use for population */
|
||||
model?: string | Model<any>;
|
||||
/** optional query options like sort, limit, etc */
|
||||
options?: any;
|
||||
/** deep populate */
|
||||
populate?: QueryPopulateOptions | QueryPopulateOptions[];
|
||||
}
|
||||
|
||||
export interface PaginateResult<T> {
|
||||
docs: Array<T>;
|
||||
total: number;
|
||||
|
||||
@@ -44,6 +44,9 @@ router.get('/users.json', function(req: Request, res: Response) {
|
||||
options.select = 'email username';
|
||||
options.sort = { 'username': (descending ? -1 : 1) };
|
||||
options.populate = '';
|
||||
options.populate = {
|
||||
path: '',
|
||||
};
|
||||
options.lean = true;
|
||||
options.leanWithId = false;
|
||||
options.offset = 0;
|
||||
|
||||
183
types/parse/index.d.ts
vendored
183
types/parse/index.d.ts
vendored
@@ -19,6 +19,64 @@
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
declare enum ErrorCode {
|
||||
OTHER_CAUSE = -1,
|
||||
INTERNAL_SERVER_ERROR = 1,
|
||||
CONNECTION_FAILED = 100,
|
||||
OBJECT_NOT_FOUND = 101,
|
||||
INVALID_QUERY = 102,
|
||||
INVALID_CLASS_NAME = 103,
|
||||
MISSING_OBJECT_ID = 104,
|
||||
INVALID_KEY_NAME = 105,
|
||||
INVALID_POINTER = 106,
|
||||
INVALID_JSON = 107,
|
||||
COMMAND_UNAVAILABLE = 108,
|
||||
NOT_INITIALIZED = 109,
|
||||
INCORRECT_TYPE = 111,
|
||||
INVALID_CHANNEL_NAME = 112,
|
||||
PUSH_MISCONFIGURED = 115,
|
||||
OBJECT_TOO_LARGE = 116,
|
||||
OPERATION_FORBIDDEN = 119,
|
||||
CACHE_MISS = 120,
|
||||
INVALID_NESTED_KEY = 121,
|
||||
INVALID_FILE_NAME = 122,
|
||||
INVALID_ACL = 123,
|
||||
TIMEOUT = 124,
|
||||
INVALID_EMAIL_ADDRESS = 125,
|
||||
MISSING_CONTENT_TYPE = 126,
|
||||
MISSING_CONTENT_LENGTH = 127,
|
||||
INVALID_CONTENT_LENGTH = 128,
|
||||
FILE_TOO_LARGE = 129,
|
||||
FILE_SAVE_ERROR = 130,
|
||||
DUPLICATE_VALUE = 137,
|
||||
INVALID_ROLE_NAME = 139,
|
||||
EXCEEDED_QUOTA = 140,
|
||||
SCRIPT_FAILED = 141,
|
||||
VALIDATION_ERROR = 142,
|
||||
INVALID_IMAGE_DATA = 150,
|
||||
UNSAVED_FILE_ERROR = 151,
|
||||
INVALID_PUSH_TIME_ERROR = 152,
|
||||
FILE_DELETE_ERROR = 153,
|
||||
REQUEST_LIMIT_EXCEEDED = 155,
|
||||
INVALID_EVENT_NAME = 160,
|
||||
USERNAME_MISSING = 200,
|
||||
PASSWORD_MISSING = 201,
|
||||
USERNAME_TAKEN = 202,
|
||||
EMAIL_TAKEN = 203,
|
||||
EMAIL_MISSING = 204,
|
||||
EMAIL_NOT_FOUND = 205,
|
||||
SESSION_MISSING = 206,
|
||||
MUST_CREATE_USER_THROUGH_SIGNUP = 207,
|
||||
ACCOUNT_ALREADY_LINKED = 208,
|
||||
INVALID_SESSION_TOKEN = 209,
|
||||
LINKED_ID_MISSING = 250,
|
||||
INVALID_LINKED_SESSION = 251,
|
||||
UNSUPPORTED_SERVICE = 252,
|
||||
AGGREGATE_ERROR = 600,
|
||||
FILE_READ_ERROR = 601,
|
||||
X_DOMAIN_REQUEST = 602
|
||||
}
|
||||
|
||||
declare namespace Parse {
|
||||
|
||||
let applicationId: string;
|
||||
@@ -906,76 +964,67 @@ subscription.on('close', () => {});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Error {
|
||||
static OTHER_CAUSE: ErrorCode.OTHER_CAUSE;
|
||||
static INTERNAL_SERVER_ERROR: ErrorCode.INTERNAL_SERVER_ERROR;
|
||||
static CONNECTION_FAILED: ErrorCode.CONNECTION_FAILED;
|
||||
static OBJECT_NOT_FOUND: ErrorCode.OBJECT_NOT_FOUND;
|
||||
static INVALID_QUERY: ErrorCode.INVALID_QUERY;
|
||||
static INVALID_CLASS_NAME: ErrorCode.INVALID_CLASS_NAME;
|
||||
static MISSING_OBJECT_ID: ErrorCode.MISSING_OBJECT_ID;
|
||||
static INVALID_KEY_NAME: ErrorCode.INVALID_KEY_NAME;
|
||||
static INVALID_POINTER: ErrorCode.INVALID_POINTER;
|
||||
static INVALID_JSON: ErrorCode.INVALID_JSON;
|
||||
static COMMAND_UNAVAILABLE: ErrorCode.COMMAND_UNAVAILABLE;
|
||||
static NOT_INITIALIZED: ErrorCode.NOT_INITIALIZED;
|
||||
static INCORRECT_TYPE: ErrorCode.INCORRECT_TYPE;
|
||||
static INVALID_CHANNEL_NAME: ErrorCode.INVALID_CHANNEL_NAME;
|
||||
static PUSH_MISCONFIGURED: ErrorCode.PUSH_MISCONFIGURED;
|
||||
static OBJECT_TOO_LARGE: ErrorCode.OBJECT_TOO_LARGE;
|
||||
static OPERATION_FORBIDDEN: ErrorCode.OPERATION_FORBIDDEN;
|
||||
static CACHE_MISS: ErrorCode.CACHE_MISS;
|
||||
static INVALID_NESTED_KEY: ErrorCode.INVALID_NESTED_KEY;
|
||||
static INVALID_FILE_NAME: ErrorCode.INVALID_FILE_NAME;
|
||||
static INVALID_ACL: ErrorCode.INVALID_ACL;
|
||||
static TIMEOUT: ErrorCode.TIMEOUT;
|
||||
static INVALID_EMAIL_ADDRESS: ErrorCode.INVALID_EMAIL_ADDRESS;
|
||||
static MISSING_CONTENT_TYPE: ErrorCode.MISSING_CONTENT_TYPE;
|
||||
static MISSING_CONTENT_LENGTH: ErrorCode.MISSING_CONTENT_LENGTH;
|
||||
static INVALID_CONTENT_LENGTH: ErrorCode.INVALID_CONTENT_LENGTH;
|
||||
static FILE_TOO_LARGE: ErrorCode.FILE_TOO_LARGE;
|
||||
static FILE_SAVE_ERROR: ErrorCode.FILE_SAVE_ERROR;
|
||||
static DUPLICATE_VALUE: ErrorCode.DUPLICATE_VALUE;
|
||||
static INVALID_ROLE_NAME: ErrorCode.INVALID_ROLE_NAME;
|
||||
static EXCEEDED_QUOTA: ErrorCode.EXCEEDED_QUOTA;
|
||||
static SCRIPT_FAILED: ErrorCode.SCRIPT_FAILED;
|
||||
static VALIDATION_ERROR: ErrorCode.VALIDATION_ERROR;
|
||||
static INVALID_IMAGE_DATA: ErrorCode.INVALID_IMAGE_DATA;
|
||||
static UNSAVED_FILE_ERROR: ErrorCode.UNSAVED_FILE_ERROR;
|
||||
static INVALID_PUSH_TIME_ERROR: ErrorCode.INVALID_PUSH_TIME_ERROR;
|
||||
static FILE_DELETE_ERROR: ErrorCode.FILE_DELETE_ERROR;
|
||||
static REQUEST_LIMIT_EXCEEDED: ErrorCode.REQUEST_LIMIT_EXCEEDED;
|
||||
static INVALID_EVENT_NAME: ErrorCode.INVALID_EVENT_NAME;
|
||||
static USERNAME_MISSING: ErrorCode.USERNAME_MISSING;
|
||||
static PASSWORD_MISSING: ErrorCode.PASSWORD_MISSING;
|
||||
static USERNAME_TAKEN: ErrorCode.USERNAME_TAKEN;
|
||||
static EMAIL_TAKEN: ErrorCode.EMAIL_TAKEN;
|
||||
static EMAIL_MISSING: ErrorCode.EMAIL_MISSING;
|
||||
static EMAIL_NOT_FOUND: ErrorCode.EMAIL_NOT_FOUND;
|
||||
static SESSION_MISSING: ErrorCode.SESSION_MISSING;
|
||||
static MUST_CREATE_USER_THROUGH_SIGNUP: ErrorCode.MUST_CREATE_USER_THROUGH_SIGNUP;
|
||||
static ACCOUNT_ALREADY_LINKED: ErrorCode.ACCOUNT_ALREADY_LINKED;
|
||||
static INVALID_SESSION_TOKEN: ErrorCode.INVALID_SESSION_TOKEN;
|
||||
static LINKED_ID_MISSING: ErrorCode.LINKED_ID_MISSING;
|
||||
static INVALID_LINKED_SESSION: ErrorCode.INVALID_LINKED_SESSION;
|
||||
static UNSUPPORTED_SERVICE: ErrorCode.UNSUPPORTED_SERVICE;
|
||||
static AGGREGATE_ERROR: ErrorCode.AGGREGATE_ERROR;
|
||||
static FILE_READ_ERROR: ErrorCode.FILE_READ_ERROR;
|
||||
static X_DOMAIN_REQUEST: ErrorCode.X_DOMAIN_REQUEST;
|
||||
|
||||
code: ErrorCode;
|
||||
message: string;
|
||||
code: ErrorCode;
|
||||
message: string;
|
||||
|
||||
constructor(code: ErrorCode, message: string);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to inline the codes in order to make compilation work without this type definition as dependency.
|
||||
*/
|
||||
const enum ErrorCode {
|
||||
|
||||
OTHER_CAUSE = -1,
|
||||
INTERNAL_SERVER_ERROR = 1,
|
||||
CONNECTION_FAILED = 100,
|
||||
OBJECT_NOT_FOUND = 101,
|
||||
INVALID_QUERY = 102,
|
||||
INVALID_CLASS_NAME = 103,
|
||||
MISSING_OBJECT_ID = 104,
|
||||
INVALID_KEY_NAME = 105,
|
||||
INVALID_POINTER = 106,
|
||||
INVALID_JSON = 107,
|
||||
COMMAND_UNAVAILABLE = 108,
|
||||
NOT_INITIALIZED = 109,
|
||||
INCORRECT_TYPE = 111,
|
||||
INVALID_CHANNEL_NAME = 112,
|
||||
PUSH_MISCONFIGURED = 115,
|
||||
OBJECT_TOO_LARGE = 116,
|
||||
OPERATION_FORBIDDEN = 119,
|
||||
CACHE_MISS = 120,
|
||||
INVALID_NESTED_KEY = 121,
|
||||
INVALID_FILE_NAME = 122,
|
||||
INVALID_ACL = 123,
|
||||
TIMEOUT = 124,
|
||||
INVALID_EMAIL_ADDRESS = 125,
|
||||
MISSING_CONTENT_TYPE = 126,
|
||||
MISSING_CONTENT_LENGTH = 127,
|
||||
INVALID_CONTENT_LENGTH = 128,
|
||||
FILE_TOO_LARGE = 129,
|
||||
FILE_SAVE_ERROR = 130,
|
||||
DUPLICATE_VALUE = 137,
|
||||
INVALID_ROLE_NAME = 139,
|
||||
EXCEEDED_QUOTA = 140,
|
||||
SCRIPT_FAILED = 141,
|
||||
VALIDATION_ERROR = 142,
|
||||
INVALID_IMAGE_DATA = 150,
|
||||
UNSAVED_FILE_ERROR = 151,
|
||||
INVALID_PUSH_TIME_ERROR = 152,
|
||||
FILE_DELETE_ERROR = 153,
|
||||
REQUEST_LIMIT_EXCEEDED = 155,
|
||||
INVALID_EVENT_NAME = 160,
|
||||
USERNAME_MISSING = 200,
|
||||
PASSWORD_MISSING = 201,
|
||||
USERNAME_TAKEN = 202,
|
||||
EMAIL_TAKEN = 203,
|
||||
EMAIL_MISSING = 204,
|
||||
EMAIL_NOT_FOUND = 205,
|
||||
SESSION_MISSING = 206,
|
||||
MUST_CREATE_USER_THROUGH_SIGNUP = 207,
|
||||
ACCOUNT_ALREADY_LINKED = 208,
|
||||
INVALID_SESSION_TOKEN = 209,
|
||||
LINKED_ID_MISSING = 250,
|
||||
INVALID_LINKED_SESSION = 251,
|
||||
UNSUPPORTED_SERVICE = 252,
|
||||
AGGREGATE_ERROR = 600,
|
||||
FILE_READ_ERROR = 601,
|
||||
X_DOMAIN_REQUEST = 602
|
||||
constructor(code: ErrorCode, message: string);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,6 +76,16 @@ function test_object() {
|
||||
|
||||
}
|
||||
|
||||
function test_errors() {
|
||||
try {
|
||||
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, 'sdfds');
|
||||
} catch (error) {
|
||||
if (error.code !== 1) {
|
||||
console.error('Error code did not match expected number.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function test_query() {
|
||||
|
||||
const gameScore = new GameScore();
|
||||
|
||||
154
types/pubnub/index.d.ts
vendored
154
types/pubnub/index.d.ts
vendored
@@ -19,6 +19,8 @@ declare class Pubnub {
|
||||
|
||||
static generateUUID(): string;
|
||||
|
||||
channelGroups: Pubnub.ChannelGroups;
|
||||
|
||||
setUUID(uuid: string): void;
|
||||
|
||||
getUUID(): string;
|
||||
@@ -31,25 +33,30 @@ declare class Pubnub {
|
||||
|
||||
publish(
|
||||
params: Pubnub.PublishParameters,
|
||||
callback: (status: Pubnub.PublishStatus, response: Pubnub.PublishResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.PublishStatus,
|
||||
response: Pubnub.PublishResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
publish(
|
||||
params: Pubnub.PublishParameters
|
||||
): Promise<Pubnub.PublishResponse>;
|
||||
publish(params: Pubnub.PublishParameters): Promise<Pubnub.PublishResponse>;
|
||||
|
||||
fire(
|
||||
params: Pubnub.FireParameters,
|
||||
callback: (status: Pubnub.PublishStatus, response: Pubnub.PublishResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.PublishStatus,
|
||||
response: Pubnub.PublishResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
fire(
|
||||
params: Pubnub.FireParameters
|
||||
): Promise<Pubnub.PublishResponse>;
|
||||
fire(params: Pubnub.FireParameters): Promise<Pubnub.PublishResponse>;
|
||||
|
||||
history(
|
||||
params: Pubnub.HistoryParameters,
|
||||
callback: (status: Pubnub.HistoryStatus, response: Pubnub.HistoryResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.HistoryStatus,
|
||||
response: Pubnub.HistoryResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
subscribe(params: Pubnub.SubscribeParameters): void;
|
||||
@@ -66,48 +73,50 @@ declare class Pubnub {
|
||||
|
||||
hereNow(
|
||||
params: Pubnub.HereNowParameters,
|
||||
callback: (status: Pubnub.HereNowStatus, response: Pubnub.HereNowResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.HereNowStatus,
|
||||
response: Pubnub.HereNowResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
hereNow(
|
||||
params: Pubnub.HereNowParameters
|
||||
): Promise<Pubnub.HereNowResponse>;
|
||||
hereNow(params: Pubnub.HereNowParameters): Promise<Pubnub.HereNowResponse>;
|
||||
|
||||
whereNow(
|
||||
params: Pubnub.WhereNowParameters,
|
||||
callback: (status: Pubnub.WhereNowStatus, response: Pubnub.WhereNowResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.WhereNowStatus,
|
||||
response: Pubnub.WhereNowResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
whereNow(
|
||||
params: Pubnub.WhereNowParameters
|
||||
): Promise<Pubnub.WhereNowResponse>;
|
||||
whereNow(params: Pubnub.WhereNowParameters): Promise<Pubnub.WhereNowResponse>;
|
||||
|
||||
getState(
|
||||
params: Pubnub.GetStateParameters,
|
||||
callback: (status: Pubnub.GetStateStatus, state: Pubnub.GetStateResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.GetStateStatus,
|
||||
state: Pubnub.GetStateResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
getState(
|
||||
params: Pubnub.GetStateParameters
|
||||
): Promise<Pubnub.GetStateResponse>;
|
||||
getState(params: Pubnub.GetStateParameters): Promise<Pubnub.GetStateResponse>;
|
||||
|
||||
setState(
|
||||
params: Pubnub.SetStateParameters,
|
||||
callback: (status: Pubnub.SetStateStatus, state: Pubnub.SetStateResponse) => void
|
||||
callback: (
|
||||
status: Pubnub.SetStateStatus,
|
||||
state: Pubnub.SetStateResponse,
|
||||
) => void,
|
||||
): void;
|
||||
|
||||
setState(
|
||||
params: Pubnub.SetStateParameters
|
||||
): Promise<Pubnub.SetStateResponse>;
|
||||
setState(params: Pubnub.SetStateParameters): Promise<Pubnub.SetStateResponse>;
|
||||
|
||||
grant(
|
||||
params: Pubnub.GrantParameters,
|
||||
callback: (status: Pubnub.GrantStatus, response: {}) => void
|
||||
callback: (status: Pubnub.GrantStatus, response: {}) => void,
|
||||
): void;
|
||||
|
||||
grant(
|
||||
params: Pubnub.GrantParameters
|
||||
): Promise<{}>;
|
||||
grant(params: Pubnub.GrantParameters): Promise<{}>;
|
||||
|
||||
encrypt(
|
||||
data: string,
|
||||
@@ -118,8 +127,10 @@ declare class Pubnub {
|
||||
decrypt(
|
||||
data: string | object,
|
||||
customCipherKey?: string,
|
||||
options?: Pubnub.CryptoParameters
|
||||
options?: Pubnub.CryptoParameters,
|
||||
): any;
|
||||
|
||||
time(): Promise<Pubnub.FetchTimeResponse>;
|
||||
}
|
||||
|
||||
declare namespace Pubnub {
|
||||
@@ -269,6 +280,84 @@ declare namespace Pubnub {
|
||||
channelGroups?: string[];
|
||||
}
|
||||
|
||||
// channelGroups
|
||||
interface ChannelGroups {
|
||||
addChannels(
|
||||
params: AddChannelParameters,
|
||||
callback: (status: ChannelGroupStatus) => void
|
||||
): void;
|
||||
|
||||
addChannels(
|
||||
params: AddChannelParameters
|
||||
): Promise<{}>;
|
||||
|
||||
removeChannels(
|
||||
params: RemoveChannelParameters,
|
||||
callback: (status: ChannelGroupStatus) => void
|
||||
): void;
|
||||
|
||||
removeChannels(
|
||||
params: RemoveChannelParameters
|
||||
): Promise<{}>;
|
||||
|
||||
listChannels(
|
||||
params: ListChannelsParameters,
|
||||
callback: (status: ChannelGroupStatus, response: ListChannelsResponse) => void
|
||||
): void;
|
||||
|
||||
listChannels(
|
||||
params: ListChannelsParameters
|
||||
): Promise<ListChannelsResponse>;
|
||||
|
||||
listGroups(
|
||||
callback: (status: ChannelGroupStatus, response: ListAllGroupsResponse) => void
|
||||
): void;
|
||||
|
||||
listGroups(): Promise<ListAllGroupsResponse>;
|
||||
|
||||
deleteGroup(
|
||||
params: DeleteGroupParameters,
|
||||
callback: (status: ChannelGroupStatus) => void
|
||||
): void;
|
||||
|
||||
deleteGroup(
|
||||
params: DeleteGroupParameters
|
||||
): Promise<{}>;
|
||||
}
|
||||
|
||||
interface AddChannelParameters {
|
||||
channels: string[];
|
||||
channelGroup: string;
|
||||
}
|
||||
|
||||
interface RemoveChannelParameters {
|
||||
channels: string[];
|
||||
channelGroup: string;
|
||||
}
|
||||
|
||||
interface ListChannelsParameters {
|
||||
channelGroup: string;
|
||||
}
|
||||
|
||||
interface DeleteGroupParameters {
|
||||
channelGroup: string;
|
||||
}
|
||||
|
||||
interface ListAllGroupsResponse {
|
||||
groups: string[];
|
||||
}
|
||||
|
||||
interface ListChannelsResponse {
|
||||
channels: string[];
|
||||
}
|
||||
|
||||
interface ChannelGroupStatus {
|
||||
error: boolean;
|
||||
errorData?: Error;
|
||||
operation: string; // see Pubnub.Operations
|
||||
statusCode?: number;
|
||||
}
|
||||
|
||||
// addListener
|
||||
interface ListenerParameters {
|
||||
status?(statusEvent: StatusEvent): void;
|
||||
@@ -383,6 +472,11 @@ declare namespace Pubnub {
|
||||
mode?: string;
|
||||
}
|
||||
|
||||
// fetch time
|
||||
interface FetchTimeResponse {
|
||||
timetoken: number;
|
||||
}
|
||||
|
||||
interface Categories {
|
||||
PNNetworkUpCategory: string;
|
||||
PNNetworkDownCategory: string;
|
||||
|
||||
@@ -115,3 +115,48 @@ const mySecret = {
|
||||
pubnub.decrypt(mySecret, undefined, cryptoOptions);
|
||||
pubnub.decrypt('mySecretString', undefined, cryptoOptions);
|
||||
pubnub.encrypt('egrah5rwgrehwqh5eh3hwfwef', undefined, cryptoOptions);
|
||||
|
||||
pubnub.time().then(response => console.log(response));
|
||||
|
||||
const channelGroup = 'channel-group-1';
|
||||
const channels = ['channel-1'];
|
||||
|
||||
pubnub.channelGroups
|
||||
.addChannels({ channelGroup, channels })
|
||||
.then(response => console.log(response));
|
||||
|
||||
pubnub.channelGroups
|
||||
.listChannels({ channelGroup })
|
||||
.then(response => console.log(response));
|
||||
|
||||
pubnub.channelGroups.listGroups().then(response => console.log(response));
|
||||
|
||||
pubnub.channelGroups
|
||||
.removeChannels({ channelGroup, channels })
|
||||
.then(response => console.log(response));
|
||||
|
||||
pubnub.channelGroups
|
||||
.deleteGroup({ channelGroup })
|
||||
.then(response => console.log(response));
|
||||
|
||||
pubnub.channelGroups.addChannels({ channelGroup, channels }, status =>
|
||||
console.log(status),
|
||||
);
|
||||
|
||||
pubnub.channelGroups.listChannels({ channelGroup }, (status, response) => {
|
||||
console.log(status);
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
pubnub.channelGroups.listGroups((status, response) => {
|
||||
console.log(status);
|
||||
console.log(response);
|
||||
});
|
||||
|
||||
pubnub.channelGroups.removeChannels({ channelGroup, channels }, status =>
|
||||
console.log(status),
|
||||
);
|
||||
|
||||
pubnub.channelGroups.deleteGroup({ channelGroup }, status =>
|
||||
console.log(status),
|
||||
);
|
||||
|
||||
23
types/puppeteer/index.d.ts
vendored
23
types/puppeteer/index.d.ts
vendored
@@ -1,10 +1,11 @@
|
||||
// Type definitions for puppeteer 1.19
|
||||
// Type definitions for puppeteer 1.20
|
||||
// Project: https://github.com/GoogleChrome/puppeteer#readme
|
||||
// Definitions by: Marvin Hagemeister <https://github.com/marvinhagemeister>
|
||||
// Christopher Deutsch <https://github.com/cdeutsch>
|
||||
// Konstantin Simon Maria Möllers <https://github.com/ksm2>
|
||||
// Simon Schick <https://github.com/SimonSchick>
|
||||
// Serban Ghita <https://github.com/SerbanGhita>
|
||||
// Dave Cardwell <https://github.com/davecardwell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -220,7 +221,7 @@ export interface Evalable {
|
||||
): Promise<WrapElementHandle<R>>;
|
||||
}
|
||||
|
||||
export interface JSEvalable {
|
||||
export interface JSEvalable<A = any> {
|
||||
/**
|
||||
* Evaluates a function in the browser context.
|
||||
* If the function, passed to the frame.evaluate, returns a Promise, then frame.evaluate would wait for the promise to resolve and return its value.
|
||||
@@ -228,7 +229,7 @@ export interface JSEvalable {
|
||||
* @param fn Function to be evaluated in browser context
|
||||
* @param args Arguments to pass to `fn`
|
||||
*/
|
||||
evaluate<T extends EvaluateFn>(
|
||||
evaluate<T extends EvaluateFn<A>>(
|
||||
pageFunction: T,
|
||||
...args: SerializableOrJSHandle[],
|
||||
): Promise<EvaluateFnReturnType<T>>;
|
||||
@@ -240,7 +241,7 @@ export interface JSEvalable {
|
||||
* @param args Arguments to pass to `fn`
|
||||
*/
|
||||
evaluateHandle(
|
||||
pageFunction: (...args: any[]) => any,
|
||||
pageFunction: (arg1: A, ...args: any[]) => any,
|
||||
...args: SerializableOrJSHandle[],
|
||||
): Promise<JSHandle>;
|
||||
}
|
||||
@@ -516,7 +517,7 @@ export interface EmulateOptions {
|
||||
userAgent?: string;
|
||||
}
|
||||
|
||||
export type EvaluateFn = string | ((...args: any[]) => any);
|
||||
export type EvaluateFn<T = any> = string | ((arg1: T, ...args: any[]) => any);
|
||||
export type EvaluateFnReturnType<T extends EvaluateFn> = T extends ((...args: any[]) => infer R) ? R : any;
|
||||
|
||||
export type LoadEvent =
|
||||
@@ -759,7 +760,7 @@ export interface Worker extends JSEvalable {
|
||||
/**
|
||||
* Represents an in-page DOM element. ElementHandles can be created with the page.$ method.
|
||||
*/
|
||||
export interface ElementHandle<E extends Element = Element> extends JSHandle, Evalable {
|
||||
export interface ElementHandle<E extends Element = Element> extends JSHandle<E>, Evalable {
|
||||
/**
|
||||
* The method runs element.querySelector within the page.
|
||||
* If no element matches the selector, the return value resolve to null.
|
||||
@@ -828,6 +829,14 @@ export interface ElementHandle<E extends Element = Element> extends JSHandle, Ev
|
||||
screenshot(options?: Base64ScreenShotOptions): Promise<string>;
|
||||
screenshot(options?: BinaryScreenShotOptions): Promise<Buffer>;
|
||||
screenshot(options?: ScreenshotOptions): Promise<string | Buffer>;
|
||||
/**
|
||||
* Triggers a change and input event once all the provided options have been selected. If there's no <select> element
|
||||
* matching selector, the method throws an error.
|
||||
* @param values Values of options to select. If the <select> has the multiple attribute, all values are considered, otherwise only the first one is taken into account.
|
||||
* @returns An array of option values that have been successfully selected.
|
||||
* @since 1.12.0
|
||||
*/
|
||||
select(...values: string[]): Promise<string[]>;
|
||||
/**
|
||||
* This method scrolls element into view if needed, and then uses touchscreen.tap to tap in the center of the element.
|
||||
* If the element is detached from DOM, the method throws an error.
|
||||
@@ -853,7 +862,7 @@ export interface ExecutionContext extends JSEvalable {
|
||||
}
|
||||
|
||||
/** JSHandle represents an in-page JavaScript object. */
|
||||
export interface JSHandle {
|
||||
export interface JSHandle<T = any> extends JSEvalable<T> {
|
||||
/**
|
||||
* Returns a ElementHandle
|
||||
*/
|
||||
|
||||
@@ -663,3 +663,23 @@ puppeteer.launch().then(async browser => {
|
||||
const isMultiple: boolean = fileChooser.isMultiple();
|
||||
await fileChooser.accept(['/foo/bar']);
|
||||
});
|
||||
|
||||
// .evaluate and .evaluateHandle on ElementHandle and JSHandle, and elementHandle.select
|
||||
(async () => {
|
||||
const browser = await puppeteer.launch();
|
||||
const page = await browser.newPage();
|
||||
|
||||
const elementHandle = (await page.$('.something')) as puppeteer.ElementHandle<HTMLDivElement>;
|
||||
elementHandle.evaluate(element => {
|
||||
element; // $ExpectType HTMLDivElement
|
||||
});
|
||||
elementHandle.evaluateHandle(element => {
|
||||
element; // $ExpectType HTMLDivElement
|
||||
});
|
||||
|
||||
const jsHandle = await page.evaluateHandle(() => 'something');
|
||||
jsHandle.evaluate(obj => {});
|
||||
jsHandle.evaluateHandle(handle => {});
|
||||
|
||||
const selected: string[] = await elementHandle.select('a', 'b', 'c');
|
||||
})();
|
||||
|
||||
7
types/re2/index.d.ts
vendored
7
types/re2/index.d.ts
vendored
@@ -1,7 +0,0 @@
|
||||
// Type definitions for re2 1.10
|
||||
// Project: http://github.com/uhop/node-re2
|
||||
// Definitions by: Jamie Magee <https://github.com/JamieMagee>
|
||||
// Michael Kriese <https://github.com/ViceIce>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export class RE2 extends RegExp {}
|
||||
@@ -1,8 +0,0 @@
|
||||
import { RE2 } from 're2';
|
||||
|
||||
const re = new RE2('\\w+');
|
||||
re.test('abc');
|
||||
|
||||
const Regex = RE2;
|
||||
const re2 = new Regex('\\s+');
|
||||
re2.compile();
|
||||
469
types/react-calendar-timeline/index.d.ts
vendored
469
types/react-calendar-timeline/index.d.ts
vendored
@@ -1,131 +1,366 @@
|
||||
// Type definitions for react-calendar-timeline v0.16.3
|
||||
// Type definitions for react-calendar-timeline v0.26.6
|
||||
// Project: https://github.com/namespace-ee/react-calendar-timeline
|
||||
// Definitions by: Rajab Shakirov <https://github.com/radziksh>
|
||||
// Alex Maclean <https://github.com/acemac>
|
||||
// Andrii Los <https://github.com/rip21>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
// TypeScript Version: 3.5
|
||||
|
||||
/// <reference types="react"/>
|
||||
import * as React from 'react';
|
||||
import { Moment } from 'moment';
|
||||
|
||||
declare module "react-calendar-timeline" {
|
||||
|
||||
export interface TimelineGroup {
|
||||
id: number;
|
||||
title: React.ReactNode;
|
||||
rightTitle?: React.ReactNode;
|
||||
}
|
||||
declare module 'react-calendar-timeline' {
|
||||
export interface TimelineGroupBase {
|
||||
id: number;
|
||||
title: React.ReactNode;
|
||||
rightTitle?: React.ReactNode;
|
||||
}
|
||||
|
||||
export interface TimelineItem {
|
||||
id: number;
|
||||
group: number;
|
||||
title?: React.ReactNode;
|
||||
start_time: any;
|
||||
end_time: any;
|
||||
canMove?: boolean;
|
||||
canResize?: boolean | "left" | "right" | "both";
|
||||
canChangeGroup?: boolean;
|
||||
className?: string;
|
||||
itemProps?: {};
|
||||
}
|
||||
export interface TimelineItemBase<DateType> {
|
||||
id: number;
|
||||
group: number;
|
||||
title?: React.ReactNode;
|
||||
start_time: DateType;
|
||||
end_time: DateType;
|
||||
canMove?: boolean;
|
||||
canResize?: boolean | 'left' | 'right' | 'both';
|
||||
canChangeGroup?: boolean;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
itemProps?: React.HTMLAttributes<HTMLDivElement>;
|
||||
}
|
||||
|
||||
export interface TimelineContext {
|
||||
visibletimeStart: number,
|
||||
visibleTimeEnd: number,
|
||||
timelineWidth: number
|
||||
}
|
||||
export type TimelineItem<CustomItemFields, DateType = number> = TimelineItemBase<DateType> & CustomItemFields;
|
||||
export type TimelineGroup<CustomGroupFields> = TimelineGroupBase & CustomGroupFields;
|
||||
|
||||
export interface TimelineTimeSteps {
|
||||
second: number,
|
||||
minute: number,
|
||||
hour: number,
|
||||
day: number,
|
||||
month: number,
|
||||
year: number
|
||||
}
|
||||
export interface TimelineContext {
|
||||
timelineWidth: number;
|
||||
visibleTimeStart: number;
|
||||
visibleTimeEnd: number;
|
||||
canvasTimeStart: number;
|
||||
canvasTimeEnd: number;
|
||||
}
|
||||
|
||||
export interface TimelineHeaderLabelFormat {
|
||||
yearShort: string,
|
||||
yearLong: string,
|
||||
monthShort: string,
|
||||
monthMedium: string,
|
||||
monthMediumLong: string,
|
||||
monthLong: string,
|
||||
dayShort: string,
|
||||
dayLong: string,
|
||||
hourShort: string,
|
||||
hourMedium: string,
|
||||
hourMediumLong: string,
|
||||
hourLong: string,
|
||||
time: string
|
||||
}
|
||||
export interface ItemContext {
|
||||
dimensions: {
|
||||
collisionLeft: number;
|
||||
collisionWidth: number;
|
||||
height: number;
|
||||
isDragging: boolean;
|
||||
left: number;
|
||||
order: {
|
||||
group: {
|
||||
id: string;
|
||||
};
|
||||
index: number;
|
||||
};
|
||||
originalLeft: number;
|
||||
stack: boolean;
|
||||
top: number | null;
|
||||
width: number;
|
||||
};
|
||||
useResizeHandle: boolean;
|
||||
title: string;
|
||||
canMove: boolean;
|
||||
canResizeLeft: boolean;
|
||||
canResizeRight: boolean;
|
||||
selected: boolean;
|
||||
dragging: boolean;
|
||||
dragStart: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
dragTime: number;
|
||||
dragGroupDelta: number;
|
||||
resizing: boolean;
|
||||
resizeEdge: 'left' | 'right';
|
||||
resizeStart: number;
|
||||
resizeTime: number;
|
||||
width: boolean;
|
||||
}
|
||||
|
||||
export interface ReactCalendarTimelineProps {
|
||||
groups: TimelineGroup[];
|
||||
items: TimelineItem[];
|
||||
keys?:{
|
||||
groupIdKey: string;
|
||||
groupTitleKey: string;
|
||||
itemIdKey: string;
|
||||
itemTitleKey: string;
|
||||
itemGroupKey: string;
|
||||
itemTimeStartKey: string;
|
||||
itemTimeEndKey: string;
|
||||
};
|
||||
defaultTimeStart?: any;
|
||||
defaultTimeEnd?: any;
|
||||
visibleTimeStart?: any;
|
||||
visibleTimeEnd?: any;
|
||||
selected?: number[];
|
||||
sidebarWidth?: number;
|
||||
sidebarContent?: React.ReactNode;
|
||||
rightSidebarWidth?: number;
|
||||
rightSidebarContent?: React.ReactNode;
|
||||
dragSnap?: number;
|
||||
minResizeWidth?: number;
|
||||
stickyOffset?: number;
|
||||
stickyHeader?: boolean;
|
||||
headerRef?: any;
|
||||
lineHeight?: number;
|
||||
headerLabelGroupHeight?: number;
|
||||
headerLabelHeight?: number;
|
||||
itemHeightRatio?: number;
|
||||
minZoom?: number;
|
||||
maxZoom?: number;
|
||||
clickTolerance?: number;
|
||||
canMove?: boolean;
|
||||
canChangeGroup?: boolean;
|
||||
canResize?: boolean | "left" | "right" | "both";
|
||||
useResizeHandle?: boolean;
|
||||
showCursorLine?: boolean;
|
||||
stackItems?: boolean;
|
||||
traditionalZoom?: boolean;
|
||||
itemTouchSendsClick?: boolean;
|
||||
timeSteps?: TimelineTimeSteps,
|
||||
onItemMove?(itemId: number, dragTime: number, newGroupOrder: number): any;
|
||||
onItemResize?(itemId: number, newResizeEnd: number, edge: "left" | "right"): any;
|
||||
onItemSelect?(itemId: number, e: any, time: number): any;
|
||||
onItemClick?(itemId: number, e: any, time: number): any;
|
||||
onItemDoubleClick?(itemId: number, e: any, time: number): any;
|
||||
onCanvasClick?(groupId:number, time:number, e:any): any;
|
||||
onCanvasDoubleClick?(group: TimelineGroup, time: number, e: any): any;
|
||||
onCanvasContextMenu?(group: TimelineGroup, time: number, e: any): any;
|
||||
onZoom?(timelineContext: TimelineContext): any;
|
||||
moveResizeValidator?(action:"move" | "resize", itemId: number, time: number, resizeEdge: "left" | "right"): any;
|
||||
headerLabelFormats?: TimelineHeaderLabelFormat,
|
||||
subHeaderLabelFormats?: TimelineHeaderLabelFormat,
|
||||
onTimeChange?(visibleTimeStart: number, visibleTimeEnd: number, updateScrollCanvas: (start: number, end: number) => void): any;
|
||||
onTimeInit?(canvasTimeStart: number, canvasTimeEnd: number): any;
|
||||
onBoundsChange?(canvasTimeStart: number, canvasTimeEnd: number): any;
|
||||
itemRenderer?: (props: {item: TimelineItem, context: TimelineContext}) => React.ReactElement<{}>;
|
||||
groupRenderer?: (props: {group: TimelineGroup, isRightSidebar: boolean}) => React.ReactElement<{}>;
|
||||
minimumWidthForItemContentVisibility?: number;
|
||||
children?: any;
|
||||
}
|
||||
export interface TimeFormat {
|
||||
long: string;
|
||||
mediumLong: string;
|
||||
medium: string;
|
||||
short: string;
|
||||
}
|
||||
|
||||
export const defaultHeaderLabelFormats: TimelineHeaderLabelFormat;
|
||||
export const defaultSubHeaderLabelFormats: TimelineHeaderLabelFormat;
|
||||
export interface LabelFormat {
|
||||
year: TimeFormat;
|
||||
month: TimeFormat;
|
||||
week: TimeFormat;
|
||||
day: TimeFormat;
|
||||
hour: TimeFormat;
|
||||
minute: TimeFormat;
|
||||
}
|
||||
|
||||
let ReactCalendarTimeline : React.ClassicComponentClass<ReactCalendarTimelineProps>;
|
||||
export default ReactCalendarTimeline;
|
||||
|
||||
export interface ItemRendererGetItemPropsReturnType {
|
||||
key: number;
|
||||
ref: React.Ref<any>;
|
||||
className: string;
|
||||
onMouseDown: React.MouseEventHandler;
|
||||
onMouseUp: React.MouseEventHandler;
|
||||
onTouchStart: React.TouchEventHandler;
|
||||
onTouchEnd: React.TouchEventHandler;
|
||||
onDoubleClick: React.MouseEventHandler;
|
||||
onContextMenu: React.ReactEventHandler;
|
||||
style: React.CSSProperties;
|
||||
}
|
||||
|
||||
export type GetItemsProps = Partial<Omit<ItemRendererGetItemPropsReturnType, 'key' | 'ref'>>;
|
||||
|
||||
export interface ItemRendererGetResizePropsReturnType {
|
||||
left?: {
|
||||
key: number;
|
||||
ref: React.Ref<any>;
|
||||
className: string;
|
||||
};
|
||||
right?: {
|
||||
key: number;
|
||||
ref: React.Ref<any>;
|
||||
className: string;
|
||||
};
|
||||
}
|
||||
|
||||
export type GetResizeProps = {
|
||||
leftStyle?: React.CSSProperties;
|
||||
rightStyle?: React.CSSProperties;
|
||||
leftClassName?: string;
|
||||
rightClassName?: string;
|
||||
};
|
||||
|
||||
export interface ReactCalendarItemRendererProps<
|
||||
CustomItem extends TimelineItemBase<any> = TimelineItemBase<number>
|
||||
> {
|
||||
item: CustomItem;
|
||||
itemContext: ItemContext;
|
||||
getItemProps: (
|
||||
props: GetItemsProps,
|
||||
) => {
|
||||
key: number;
|
||||
ref: React.Ref<any>;
|
||||
className: string;
|
||||
onMouseDown: React.MouseEventHandler;
|
||||
onMouseUp: React.MouseEventHandler;
|
||||
onTouchStart: React.TouchEventHandler;
|
||||
onTouchEnd: React.TouchEventHandler;
|
||||
onDoubleClick: React.MouseEventHandler;
|
||||
onContextMenu: React.ReactEventHandler;
|
||||
style: React.CSSProperties;
|
||||
};
|
||||
getResizeProps: (propsOverride?: GetResizeProps) => ItemRendererGetResizePropsReturnType;
|
||||
}
|
||||
|
||||
export interface ReactCalendarGroupRendererProps<CustomGroup extends TimelineGroupBase = TimelineGroupBase> {
|
||||
group: CustomGroup;
|
||||
isRightSidebar?: boolean;
|
||||
}
|
||||
|
||||
export interface OnItemDragObjectBase {
|
||||
eventType: 'move' | 'resize';
|
||||
itemId: number;
|
||||
time: number;
|
||||
}
|
||||
|
||||
export interface OnItemDragObjectMove extends OnItemDragObjectBase {
|
||||
eventType: 'move';
|
||||
newGroupOrder: number;
|
||||
}
|
||||
|
||||
export interface OnItemDragObjectResize extends OnItemDragObjectBase {
|
||||
eventType: 'resize';
|
||||
edge?: 'left' | 'right';
|
||||
}
|
||||
|
||||
export interface TimelineKeys {
|
||||
groupIdKey: string;
|
||||
groupTitleKey: string;
|
||||
groupRightTitleKey: string;
|
||||
itemIdKey: string;
|
||||
itemTitleKey: string;
|
||||
itemDivTitleKey: string;
|
||||
itemGroupKey: string;
|
||||
itemTimeStartKey: string;
|
||||
itemTimeEndKey: string;
|
||||
}
|
||||
|
||||
export interface ReactCalendarTimelineProps<
|
||||
CustomItem extends TimelineItemBase<any> = TimelineItemBase<number>,
|
||||
CustomGroup extends TimelineGroupBase = TimelineGroupBase
|
||||
> {
|
||||
groups: CustomGroup[];
|
||||
items: CustomItem[];
|
||||
keys?: TimelineKeys;
|
||||
defaultTimeStart?: Date | Moment;
|
||||
defaultTimeEnd?: Date | Moment;
|
||||
visibleTimeStart?: Date | Moment;
|
||||
visibleTimeEnd?: Date | Moment;
|
||||
selected?: number[];
|
||||
sidebarWidth?: number;
|
||||
sidebarContent?: React.ReactNode;
|
||||
rightSidebarWidth?: number;
|
||||
rightSidebarContent?: React.ReactNode;
|
||||
dragSnap?: number;
|
||||
minResizeWidth?: number;
|
||||
lineHeight?: number;
|
||||
itemHeightRatio?: number;
|
||||
minZoom?: number;
|
||||
maxZoom?: number;
|
||||
clickTolerance?: number;
|
||||
canMove?: boolean;
|
||||
canChangeGroup?: boolean;
|
||||
canResize?: false | true | 'left' | 'right' | 'both';
|
||||
useResizeHandle?: boolean;
|
||||
stackItems?: boolean;
|
||||
traditionalZoom?: boolean;
|
||||
itemTouchSendsClick?: boolean;
|
||||
timeSteps?: TimelineTimeSteps;
|
||||
scrollRef?: React.Ref<any>;
|
||||
onItemDrag?(itemDragObject: OnItemDragObjectMove | OnItemDragObjectResize): void;
|
||||
onItemMove?(itemId: number, dragTime: number, newGroupOrder: number): void;
|
||||
onItemResize?(itemId: number, endTimeOrStartTime: number, edge: 'left' | 'right'): void;
|
||||
onItemSelect?(itemId: number, e: any, time: number): void;
|
||||
onItemDeselect?(e: React.SyntheticEvent): void;
|
||||
onItemClick?(itemId: number, e: React.SyntheticEvent, time: number): void;
|
||||
onItemDoubleClick?(itemId: number, e: React.SyntheticEvent, time: number): void;
|
||||
onItemContextMenu?(itemId: number, e: React.SyntheticEvent, time: number): void;
|
||||
onCanvasClick?(groupId: number, time: number, e: React.SyntheticEvent): void;
|
||||
onCanvasDoubleClick?(group: CustomGroup, time: number, e: React.SyntheticEvent): void;
|
||||
onCanvasContextMenu?(group: CustomGroup, time: number, e: React.SyntheticEvent): void;
|
||||
onZoom?(timelineContext: TimelineContext): void;
|
||||
moveResizeValidator?(
|
||||
action: 'move' | 'resize',
|
||||
itemId: number,
|
||||
time: number,
|
||||
resizeEdge: 'left' | 'right',
|
||||
): number;
|
||||
onTimeChange?(
|
||||
visibleTimeStart: number,
|
||||
visibleTimeEnd: number,
|
||||
updateScrollCanvas: (start: number, end: number) => void,
|
||||
): any;
|
||||
onBoundsChange?(canvasTimeStart: number, canvasTimeEnd: number): any;
|
||||
itemRenderer?: (props: ReactCalendarItemRendererProps<CustomItem>) => React.ReactNode;
|
||||
groupRenderer?: (props: ReactCalendarGroupRendererProps<CustomGroup>) => React.ReactNode;
|
||||
resizeDetector?: (containerResizeDetector: any) => void;
|
||||
verticalLineClassNamesForTime?: (start: number, end: number) => string[] | undefined;
|
||||
horizontalLineClassNamesForGroup?: (group: CustomGroup) => string[];
|
||||
|
||||
// Fields that are in propTypes but not documented
|
||||
headerRef?: React.Ref<any>;
|
||||
}
|
||||
|
||||
export interface TimelineTimeSteps {
|
||||
second: number;
|
||||
minute: number;
|
||||
hour: number;
|
||||
day: number;
|
||||
month: number;
|
||||
year: number;
|
||||
}
|
||||
|
||||
export class TimelineMarkers extends React.Component {}
|
||||
|
||||
export interface CustomMarkerChildrenProps {
|
||||
styles: React.CSSProperties;
|
||||
date: number;
|
||||
}
|
||||
export interface MarkerProps {
|
||||
date: Date | number;
|
||||
children?: (props: CustomMarkerChildrenProps) => React.ReactNode;
|
||||
}
|
||||
|
||||
export class CustomMarker extends React.Component<MarkerProps> {}
|
||||
|
||||
export interface TodayMarkerProps extends MarkerProps {
|
||||
interval?: number;
|
||||
}
|
||||
export class TodayMarker extends React.Component<TodayMarkerProps> {}
|
||||
|
||||
export type CursorMarkerProps = Omit<MarkerProps, 'date'>;
|
||||
export class CursorMarker extends React.Component<CursorMarkerProps> {}
|
||||
|
||||
export class TimelineHeaders extends React.Component<React.HTMLAttributes<Element>> {}
|
||||
|
||||
export interface TimelineHeaderProps {
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
calendarHeaderStyle?: React.CSSProperties;
|
||||
calendarHeaderClassName?: string;
|
||||
headerRef?: React.Ref<any>;
|
||||
}
|
||||
export class TimelineHeader extends React.Component<TimelineHeaderProps> {}
|
||||
|
||||
export interface SidebarHeaderChildrenFnProps<Data> {
|
||||
getRootProps: (propsToOverride?: { style: React.CSSProperties }) => { style: React.CSSProperties };
|
||||
data: Data;
|
||||
}
|
||||
|
||||
export interface SidebarHeaderProps<Data> {
|
||||
variant?: 'left' | 'right';
|
||||
headerData?: Data;
|
||||
children: (props: SidebarHeaderChildrenFnProps<Data>) => React.ReactNode;
|
||||
}
|
||||
export class SidebarHeader<Data = any> extends React.Component<SidebarHeaderProps<Data>> {}
|
||||
|
||||
export type Unit = 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'year';
|
||||
|
||||
export interface IntervalContext {
|
||||
interval: { startTime: number; endTime: number; labelWidth: number; left: number };
|
||||
intervalText: string;
|
||||
}
|
||||
export interface GetIntervalProps {
|
||||
interval?: Interval;
|
||||
style?: React.CSSProperties;
|
||||
onClick?: React.MouseEventHandler;
|
||||
}
|
||||
export interface IntervalRenderer<Data> {
|
||||
intervalContext: IntervalContext;
|
||||
getIntervalProps: (props?: GetIntervalProps) => Required<GetIntervalProps> & { key: string | number };
|
||||
data?: Data;
|
||||
}
|
||||
export interface DateHeaderProps<Data> {
|
||||
style?: React.CSSProperties;
|
||||
className?: string;
|
||||
unit?: Unit | 'primaryHeader';
|
||||
labelFormat?: string | (([startTime, endTime]: [Moment, Moment], unit: Unit, labelWidth: number) => string);
|
||||
intervalRenderer?: (props?: IntervalRenderer<Data>) => React.ReactNode;
|
||||
headerData?: Data;
|
||||
children?: (props: SidebarHeaderChildrenFnProps<Data>) => React.ReactNode;
|
||||
height?: number;
|
||||
}
|
||||
export class DateHeader<Data = any> extends React.Component<DateHeaderProps<Data>> {}
|
||||
export interface Interval {
|
||||
startTime: Moment;
|
||||
endTime: Moment;
|
||||
}
|
||||
export interface HeaderContext {
|
||||
intervals: { startTime: Moment; endTime: Moment }[];
|
||||
unit: string;
|
||||
}
|
||||
export interface CustomHeaderPropsChildrenFnProps<Data> {
|
||||
timelineContext: TimelineContext;
|
||||
headerContext: HeaderContext;
|
||||
getIntervalProps: (props?: GetIntervalProps) => Required<GetIntervalProps> & { key: string | number };
|
||||
getRootProps: (propsToOverride?: { style: React.CSSProperties }) => { style: React.CSSProperties };
|
||||
showPeriod: (startDate: Moment | number, endDate: Moment | number) => void;
|
||||
data: Data;
|
||||
}
|
||||
export interface CustomHeaderProps<Data> {
|
||||
unit?: Unit;
|
||||
headerData?: Data;
|
||||
height?: number;
|
||||
children: (props?: CustomHeaderPropsChildrenFnProps<Data>) => React.ReactNode;
|
||||
}
|
||||
export class CustomHeader<Data = any> extends React.Component<CustomHeaderProps<Data>> {}
|
||||
|
||||
export const defaultKeys: TimelineKeys;
|
||||
export const defaultTimeSteps: TimelineTimeSteps;
|
||||
export const defaultHeaderFormats: LabelFormat;
|
||||
|
||||
export default class ReactCalendarTimeline<
|
||||
CustomItem extends TimelineItemBase<any> = TimelineItemBase<number>,
|
||||
CustomGroup extends TimelineGroupBase = TimelineGroupBase
|
||||
> extends React.Component<ReactCalendarTimelineProps<CustomItem, CustomGroup>> {}
|
||||
}
|
||||
|
||||
6
types/react-calendar-timeline/package.json
Normal file
6
types/react-calendar-timeline/package.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"moment": "^2.0.0"
|
||||
}
|
||||
}
|
||||
@@ -1,30 +1,314 @@
|
||||
import * as React from "react";
|
||||
import ReactCalendarTimeline from 'react-calendar-timeline';
|
||||
// Don't want to add this as a dependency, because it is only used for tests.
|
||||
declare const moment: any;
|
||||
import * as React from 'react';
|
||||
import { useState } from 'react';
|
||||
import Timeline, {
|
||||
TimelineGroupBase,
|
||||
TimelineItemBase,
|
||||
TimelineItem,
|
||||
TimelineGroup,
|
||||
TimelineHeaders,
|
||||
SidebarHeader,
|
||||
DateHeader,
|
||||
CustomHeader,
|
||||
} from 'react-calendar-timeline';
|
||||
import * as moment from 'moment';
|
||||
import { Moment } from 'moment';
|
||||
|
||||
const groups = [
|
||||
{id: 1, title: 'group 1'},
|
||||
{id: 2, title: 'group 2'}
|
||||
]
|
||||
const groups1 = [{ id: 1, title: 'group 1' }, { id: 2, title: 'group 2' }] as TimelineGroupBase[];
|
||||
|
||||
const items = [
|
||||
{id: 1, group: 1, title: 'item 1', start_time: moment(), end_time: moment().add(1, 'hour')},
|
||||
{id: 2, group: 2, title: 'item 2', start_time: moment().add(-0.5, 'hour'), end_time: moment().add(0.5, 'hour')},
|
||||
{id: 3, group: 1, title: 'item 3', start_time: moment().add(2, 'hour'), end_time: moment().add(3, 'hour')}
|
||||
]
|
||||
const items1 = [
|
||||
{ id: 1, group: 1, title: 'item 1', start_time: moment(), end_time: moment().add(1, 'hour') },
|
||||
{ id: 2, group: 2, title: 'item 2', start_time: moment().add(-0.5, 'hour'), end_time: moment().add(0.5, 'hour') },
|
||||
{ id: 3, group: 1, title: 'item 3', start_time: moment().add(2, 'hour'), end_time: moment().add(3, 'hour') },
|
||||
] as TimelineItemBase<Moment>[];
|
||||
|
||||
class ExampleOfUsingReactCalendarTimeline extends React.Component {
|
||||
render(){
|
||||
return(
|
||||
<div>
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
Rendered by react!
|
||||
<ReactCalendarTimeline groups={groups}
|
||||
items={items}
|
||||
defaultTimeStart={moment().add(-12, 'hour')}
|
||||
defaultTimeEnd={moment().add(12, 'hour')}
|
||||
/>
|
||||
<Timeline<TimelineItemBase<Moment>>
|
||||
groups={groups1}
|
||||
items={items1}
|
||||
defaultTimeStart={moment().add(-12, 'hour')}
|
||||
defaultTimeEnd={moment().add(12, 'hour')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
type TimelineGroupCustom = TimelineGroup<{ data: string }>;
|
||||
type TimelineItemCustom = TimelineItem<{ data: string }, Moment>;
|
||||
|
||||
const groups2 = [
|
||||
{ id: 1, title: 'group 1', data: '1' },
|
||||
{ id: 2, title: 'group 2', data: '1' },
|
||||
] as TimelineGroupCustom[];
|
||||
|
||||
const items2 = [
|
||||
{ id: 1, group: 1, title: 'item 1', start_time: moment(), end_time: moment().add(1, 'hour'), data: '1' },
|
||||
{
|
||||
id: 2,
|
||||
group: 2,
|
||||
title: 'item 2',
|
||||
start_time: moment().add(-0.5, 'hour'),
|
||||
end_time: moment().add(0.5, 'hour'),
|
||||
data: '1',
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
group: 1,
|
||||
title: 'item 3',
|
||||
start_time: moment().add(2, 'hour'),
|
||||
end_time: moment().add(3, 'hour'),
|
||||
data: '1',
|
||||
},
|
||||
] as TimelineItemCustom[];
|
||||
|
||||
class ExampleOfUsingReactCalendarTimelineWithCustomGroupAndItemExtension extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<div>
|
||||
Rendered by react!
|
||||
<Timeline<TimelineItemCustom, TimelineGroupCustom>
|
||||
groups={groups2}
|
||||
items={items2}
|
||||
defaultTimeStart={moment().add(-12, 'hour')}
|
||||
defaultTimeEnd={moment().add(12, 'hour')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const Example: React.FC = () => (
|
||||
<Timeline groups={groups2} items={items2}>
|
||||
<TimelineHeaders>
|
||||
<SidebarHeader>
|
||||
{({ getRootProps }) => {
|
||||
return <div {...getRootProps()}>Left</div>;
|
||||
}}
|
||||
</SidebarHeader>
|
||||
<DateHeader unit="primaryHeader" />
|
||||
<DateHeader />
|
||||
<CustomHeader height={50} headerData={{ someData: 'data' }} unit="year">
|
||||
{({ headerContext: { intervals }, getRootProps, getIntervalProps, showPeriod, data }) => {
|
||||
return (
|
||||
<div {...getRootProps()}>
|
||||
{intervals.map(interval => {
|
||||
const intervalStyle = {
|
||||
lineHeight: '30px',
|
||||
textAlign: 'center',
|
||||
borderLeft: '1px solid black',
|
||||
cursor: 'pointer',
|
||||
backgroundColor: 'Turquoise',
|
||||
color: 'white',
|
||||
} as React.CSSProperties;
|
||||
return (
|
||||
<div
|
||||
onClick={() => {
|
||||
showPeriod(interval.startTime, interval.endTime);
|
||||
}}
|
||||
{...getIntervalProps({
|
||||
interval,
|
||||
style: intervalStyle,
|
||||
})}
|
||||
>
|
||||
<div className="sticky">{interval.startTime.format('YYYY')}</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
}}
|
||||
</CustomHeader>
|
||||
</TimelineHeaders>
|
||||
</Timeline>
|
||||
);
|
||||
|
||||
const groups = [{ id: 1, title: 'group 1' }, { id: 2, title: 'group 2' }] as TimelineGroupBase[];
|
||||
|
||||
const items = [
|
||||
{ id: 1, group: 1, title: 'item 1', start_time: 1, end_time: 1 },
|
||||
{ id: 2, group: 2, title: 'item 2', start_time: 1, end_time: 1 },
|
||||
{ id: 3, group: 1, title: 'item 3', start_time: 1, end_time: 1 },
|
||||
] as TimelineItemBase<number>[];
|
||||
|
||||
const defaultTimeStart = moment()
|
||||
.startOf('day')
|
||||
.toDate();
|
||||
const defaultTimeEnd = moment()
|
||||
.startOf('day')
|
||||
.add(1, 'day')
|
||||
.toDate();
|
||||
|
||||
const Resize = () => {
|
||||
const [itemsState, setItems] = useState(items);
|
||||
|
||||
return (
|
||||
<Timeline
|
||||
groups={groups}
|
||||
items={items}
|
||||
itemTouchSendsClick={false}
|
||||
stackItems
|
||||
itemHeightRatio={0.75}
|
||||
canMove={true}
|
||||
canResize={'both'}
|
||||
defaultTimeStart={defaultTimeStart}
|
||||
defaultTimeEnd={defaultTimeEnd}
|
||||
onItemMove={(itemId, dragTime, newGroupOrder) => {
|
||||
const group = groups[newGroupOrder];
|
||||
|
||||
setItems(
|
||||
itemsState.map(item =>
|
||||
item.id === itemId
|
||||
? {
|
||||
...item,
|
||||
...{
|
||||
start_time: dragTime,
|
||||
end_time: dragTime + (item.end_time - item.start_time),
|
||||
group: group.id,
|
||||
},
|
||||
}
|
||||
: item,
|
||||
),
|
||||
);
|
||||
|
||||
console.log('Moved', itemId, dragTime, newGroupOrder);
|
||||
}}
|
||||
onItemResize={(itemId, time, edge) => {
|
||||
setItems(
|
||||
itemsState.map(item =>
|
||||
item.id === itemId
|
||||
? {
|
||||
...item,
|
||||
...{
|
||||
start_time: edge === 'left' ? time : item.start_time,
|
||||
end_time: edge === 'left' ? item.end_time : time,
|
||||
},
|
||||
}
|
||||
: item,
|
||||
),
|
||||
);
|
||||
|
||||
console.log('Resized', itemId, time, edge);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
const TimelineDragTest = () => {
|
||||
const [itemsState, setItems] = useState(items);
|
||||
const [draggedItem, setDraggedItem] = useState<
|
||||
{ item: TimelineItemBase<number>; group: TimelineGroupBase; time: number } | undefined
|
||||
>(undefined);
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Timeline
|
||||
groups={groups}
|
||||
items={items}
|
||||
itemTouchSendsClick={false}
|
||||
stackItems
|
||||
itemHeightRatio={0.75}
|
||||
canMove={true}
|
||||
canResize={'both'}
|
||||
defaultTimeStart={defaultTimeStart}
|
||||
defaultTimeEnd={defaultTimeEnd}
|
||||
onItemMove={(itemId, dragTime, newGroupOrder) => {
|
||||
const group = groups[newGroupOrder];
|
||||
|
||||
setItems(
|
||||
itemsState.map(item =>
|
||||
item.id === itemId
|
||||
? {
|
||||
...item,
|
||||
...{
|
||||
start_time: dragTime,
|
||||
end_time: dragTime + (item.end_time - item.start_time),
|
||||
group: group.id,
|
||||
},
|
||||
}
|
||||
: item,
|
||||
),
|
||||
);
|
||||
setDraggedItem(undefined);
|
||||
console.log('Moved', itemId, dragTime, newGroupOrder);
|
||||
}}
|
||||
onItemResize={(itemId, time, edge) => {
|
||||
setItems(
|
||||
itemsState.map(item =>
|
||||
item.id === itemId
|
||||
? {
|
||||
...item,
|
||||
...{
|
||||
start_time: edge === 'left' ? time : item.start_time,
|
||||
end_time: edge === 'left' ? item.end_time : time,
|
||||
},
|
||||
}
|
||||
: item,
|
||||
),
|
||||
);
|
||||
setDraggedItem(undefined);
|
||||
|
||||
console.log('Resized', itemId, time, edge);
|
||||
}}
|
||||
onItemDrag={itemDragObject => {
|
||||
if (itemDragObject.eventType === 'move') {
|
||||
const { itemId, newGroupOrder, time } = itemDragObject;
|
||||
let item = draggedItem ? draggedItem.item : undefined;
|
||||
if (!item) {
|
||||
item = itemsState.find(i => i.id === itemId);
|
||||
}
|
||||
setDraggedItem({ item: item, group: groups[newGroupOrder], time });
|
||||
}
|
||||
}}
|
||||
/>
|
||||
{draggedItem && (
|
||||
<div
|
||||
style={{
|
||||
position: 'fixed',
|
||||
left: 100,
|
||||
bottom: 50,
|
||||
background: 'rgba(0, 0, 0, 0.5)',
|
||||
color: 'white',
|
||||
padding: 10,
|
||||
|
||||
fontSize: 20,
|
||||
borderRadius: 5,
|
||||
zIndex: 85,
|
||||
}}
|
||||
>
|
||||
{`${moment(draggedItem.time).format('LLL')}, ${draggedItem.group ? draggedItem.group.title : ''}`}
|
||||
</div>
|
||||
)}
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const Basic: React.FC = () => {
|
||||
return (
|
||||
<Timeline
|
||||
groups={groups}
|
||||
items={items}
|
||||
sidebarContent={<div>Above The Left</div>}
|
||||
itemTouchSendsClick={false}
|
||||
stackItems
|
||||
itemHeightRatio={0.75}
|
||||
canMove={false}
|
||||
canResize={false}
|
||||
defaultTimeStart={defaultTimeStart}
|
||||
defaultTimeEnd={defaultTimeEnd}
|
||||
>
|
||||
<TimelineHeaders className="sticky">
|
||||
<SidebarHeader>
|
||||
{({ getRootProps }) => {
|
||||
return <div {...getRootProps()}>Left</div>;
|
||||
}}
|
||||
</SidebarHeader>
|
||||
<DateHeader unit="primaryHeader" />
|
||||
<DateHeader />
|
||||
</TimelineHeaders>
|
||||
</Timeline>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -22,4 +22,4 @@
|
||||
"index.d.ts",
|
||||
"react-calendar-timeline-tests.tsx"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
11
types/react-copy-to-clipboard/index.d.ts
vendored
11
types/react-copy-to-clipboard/index.d.ts
vendored
@@ -1,7 +1,8 @@
|
||||
// Type definitions for react-copy-to-clipboard 4.2
|
||||
// Type definitions for react-copy-to-clipboard 4.3
|
||||
// Project: https://github.com/nkbt/react-copy-to-clipboard
|
||||
// Definitions by: Meno Abels <https://github.com/mabels>
|
||||
// Bernabe <https://github.com/BernabeFelix>
|
||||
// Ward Delabastita <https://github.com/wdlb>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -13,13 +14,15 @@ export = CopyToClipboard;
|
||||
|
||||
declare namespace CopyToClipboard {
|
||||
interface Options {
|
||||
debug: boolean;
|
||||
message: string;
|
||||
debug?: boolean;
|
||||
format?: "text/html" | "text/plain";
|
||||
message?: string;
|
||||
}
|
||||
|
||||
interface Props {
|
||||
children: React.ReactNode;
|
||||
text: string;
|
||||
onCopy?(a: string, b: boolean): void;
|
||||
onCopy?(text: string, result: boolean): void;
|
||||
options?: Options;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,22 @@
|
||||
import * as React from "react";
|
||||
import CopyToClipboard = require("react-copy-to-clipboard");
|
||||
|
||||
export class Test extends React.Component {
|
||||
export class OnlyRequiredProps extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<CopyToClipboard text={"Hello World"}>
|
||||
<button>Copy to clipboard with button</button>
|
||||
</CopyToClipboard>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export class AllProps extends React.Component {
|
||||
render() {
|
||||
return (
|
||||
<CopyToClipboard text={"Hello World"}
|
||||
onCopy={() => {}}>
|
||||
onCopy={() => {}}
|
||||
options={{debug: true, message: "message", format: "text/plain"}}>
|
||||
<span>Copy to clipboard with span</span>
|
||||
</CopyToClipboard>
|
||||
);
|
||||
|
||||
@@ -2,11 +2,20 @@
|
||||
// Project: https://github.com/hiddentao/react-native-modal-filter-picker#readme
|
||||
// Definitions by: Chang Yanwei <https://github.com/ywchang>
|
||||
// Cheng Gibson <https://github.com/nossbigg>
|
||||
// Zheng Arnaud <https://github.com/arnaud-zg>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
import { StyleProp, ViewStyle, TextStyle, KeyboardAvoidingView, ModalProps, ListViewProps } from 'react-native';
|
||||
import {
|
||||
StyleProp,
|
||||
ViewStyle,
|
||||
TextStyle,
|
||||
KeyboardAvoidingView,
|
||||
ModalProps,
|
||||
ListViewProps,
|
||||
FlatListProps,
|
||||
} from 'react-native';
|
||||
|
||||
export interface ModalFilterPickerOption {
|
||||
label: string;
|
||||
@@ -27,7 +36,7 @@ export interface ModalFilterPickerProps<T extends ModalFilterPickerOption> {
|
||||
showFilter?: boolean;
|
||||
modal?: ModalProps;
|
||||
selectedOption?: string;
|
||||
listViewProps?: Partial<ListViewProps>;
|
||||
listViewProps?: Partial<ListViewProps | FlatListProps<T>>;
|
||||
renderOption?: (option: T, isSelected: boolean) => JSX.Element;
|
||||
renderList?: () => JSX.Element;
|
||||
renderCancelButton?: () => JSX.Element;
|
||||
@@ -35,7 +44,7 @@ export interface ModalFilterPickerProps<T extends ModalFilterPickerOption> {
|
||||
autoFocus?: boolean;
|
||||
|
||||
// styling props
|
||||
overlayStyle?: StyleProp<KeyboardAvoidingView>;
|
||||
overlayStyle?: StyleProp<KeyboardAvoidingView | ViewStyle>;
|
||||
listContainerStyle?: StyleProp<ViewStyle>;
|
||||
filterTextInputContainerStyle?: StyleProp<ViewStyle>;
|
||||
filterTextInputStyle?: StyleProp<TextStyle>;
|
||||
|
||||
6
types/react-native-privacy-snapshot/index.d.ts
vendored
Normal file
6
types/react-native-privacy-snapshot/index.d.ts
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
// Type definitions for react-native-privacy-snapshot 1.0
|
||||
// Project: https://github.com/kayla-tech/react-native-privacy-snapshot#readme
|
||||
// Definitions by: Matthew Bajorek <https://github.com/mattbajorek>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export function enabled(isEnabled: boolean): void;
|
||||
@@ -0,0 +1,4 @@
|
||||
import PrivacySnapshot = require('react-native-privacy-snapshot');
|
||||
|
||||
PrivacySnapshot.enabled(true);
|
||||
PrivacySnapshot.enabled(false);
|
||||
23
types/react-native-privacy-snapshot/tsconfig.json
Normal file
23
types/react-native-privacy-snapshot/tsconfig.json
Normal 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",
|
||||
"react-native-privacy-snapshot-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/react-native-privacy-snapshot/tslint.json
Normal file
1
types/react-native-privacy-snapshot/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
5
types/react-native/index.d.ts
vendored
5
types/react-native/index.d.ts
vendored
@@ -23,6 +23,7 @@
|
||||
// Mike Martin <https://github.com/mcmar>
|
||||
// Theo Henry de Villeneuve <https://github.com/theohdv>
|
||||
// Eli White <https://github.com/TheSavior>
|
||||
// Romain Faust <https://github.com/romain-faust>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -8213,6 +8214,10 @@ export namespace Animated {
|
||||
|
||||
interface LoopAnimationConfig {
|
||||
iterations?: number; // default -1 for infinite
|
||||
/**
|
||||
* Defaults to `true`
|
||||
*/
|
||||
resetBeforeIteration?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
21
types/react-redux/index.d.ts
vendored
21
types/react-redux/index.d.ts
vendored
@@ -16,19 +16,12 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 3.0
|
||||
|
||||
// Known Issue:
|
||||
// There is a known issue in TypeScript, which doesn't allow decorators to change the signature of the classes
|
||||
// they are decorating. Due to this, if you are using @connect() decorator in your code,
|
||||
// you will see a bunch of errors from TypeScript. The current workaround is to use connect() as a function call on
|
||||
// a separate line instead of as a decorator. Discussed in this github issue:
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/20796
|
||||
|
||||
import {
|
||||
Component,
|
||||
ComponentClass,
|
||||
ComponentType,
|
||||
StatelessComponent,
|
||||
Context
|
||||
Context,
|
||||
NamedExoticComponent
|
||||
} from 'react';
|
||||
|
||||
import {
|
||||
@@ -49,7 +42,7 @@ export interface DispatchProp<A extends Action = AnyAction> {
|
||||
}
|
||||
|
||||
export type AdvancedComponentDecorator<TProps, TOwnProps> =
|
||||
(component: ComponentType<TProps>) => ComponentClass<TOwnProps>;
|
||||
(component: ComponentType<TProps>) => NamedExoticComponent<TOwnProps>;
|
||||
|
||||
/**
|
||||
* A property P will be present if:
|
||||
@@ -93,10 +86,10 @@ export type GetProps<C> = C extends ComponentType<infer P> ? P : never;
|
||||
|
||||
// Applies LibraryManagedAttributes (proper handling of defaultProps
|
||||
// and propTypes), as well as defines WrappedComponent.
|
||||
export type ConnectedComponentClass<
|
||||
export type ConnectedComponent<
|
||||
C extends ComponentType<any>,
|
||||
P
|
||||
> = ComponentClass<JSX.LibraryManagedAttributes<C, P>> & hoistNonReactStatics.NonReactStatics<C> & {
|
||||
> = NamedExoticComponent<JSX.LibraryManagedAttributes<C, P>> & hoistNonReactStatics.NonReactStatics<C> & {
|
||||
WrappedComponent: C;
|
||||
};
|
||||
|
||||
@@ -106,7 +99,7 @@ export type ConnectedComponentClass<
|
||||
export type InferableComponentEnhancerWithProps<TInjectedProps, TNeedsProps> =
|
||||
<C extends ComponentType<Matching<TInjectedProps, GetProps<C>>>>(
|
||||
component: C
|
||||
) => ConnectedComponentClass<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
|
||||
) => ConnectedComponent<C, Omit<GetProps<C>, keyof Shared<TInjectedProps, GetProps<C>>> & TNeedsProps>;
|
||||
|
||||
// Injects props and removes them from the prop requirements.
|
||||
// Will not pass through the injected props if they are passed in during
|
||||
@@ -362,7 +355,7 @@ export interface Options<State = {}, TStateProps = {}, TOwnProps = {}, TMergedPr
|
||||
* Connects a React component to a Redux store. It is the base for {@link connect} but is less opinionated about
|
||||
* how to combine <code>state</code>, <code>props</code>, and <code>dispatch</code> into your final props. It makes no
|
||||
* assumptions about defaults or memoization of results, leaving those responsibilities to the caller.It does not
|
||||
* modify the component class passed to it; instead, it returns a new, connected component class for you to use.
|
||||
* modify the component class passed to it; instead, it returns a new, connected component for you to use.
|
||||
*
|
||||
* @param selectorFactory The selector factory. See SelectorFactory type for details.
|
||||
* @param connectOptions If specified, further customizes the behavior of the connector. Additionally, any extra
|
||||
|
||||
@@ -430,15 +430,6 @@ function mapDispatchToProps(dispatch: Dispatch) {
|
||||
};
|
||||
}
|
||||
|
||||
connect(
|
||||
mapStateToProps,
|
||||
mapDispatchToProps
|
||||
)(Counter);
|
||||
|
||||
@connect(mapStateToProps)
|
||||
class CounterContainer extends React.Component<any, any> {
|
||||
}
|
||||
|
||||
// Ensure connect's first two arguments can be replaced by wrapper functions
|
||||
interface CounterStateProps {
|
||||
value: number;
|
||||
@@ -621,10 +612,10 @@ const WrappedTestComponent = connect()(TestComponent);
|
||||
|
||||
// return value of the connect()(TestComponent) is assignable to a ComponentClass<TestProp>
|
||||
// ie: DispatchProp has been removed through decoration
|
||||
const ADecoratedTestComponent: React.ComponentClass<TestProp> = WrappedTestComponent;
|
||||
const ADecoratedTestComponent: React.NamedExoticComponent<TestProp> = WrappedTestComponent;
|
||||
<WrappedTestComponent property1={42} />;
|
||||
|
||||
const ATestComponent: React.ComponentClass<TestProp> = TestComponent; // $ExpectError
|
||||
const ATestComponent: React.NamedExoticComponent<TestProp> = TestComponent; // $ExpectError
|
||||
|
||||
// stateless functions
|
||||
interface HelloMessageProps {
|
||||
@@ -764,7 +755,7 @@ function TestMergedPropsInference() {
|
||||
return { dispatch: 'string' };
|
||||
}
|
||||
|
||||
const ConnectedWithOwnAndState: React.ComponentClass<OwnProps> = connect<StateProps, void, OwnProps, MergedProps>(
|
||||
const ConnectedWithOwnAndState: React.NamedExoticComponent<OwnProps> = connect<StateProps, void, OwnProps, MergedProps>(
|
||||
mapStateToProps,
|
||||
undefined,
|
||||
(stateProps: StateProps) => ({
|
||||
@@ -772,7 +763,7 @@ function TestMergedPropsInference() {
|
||||
}),
|
||||
)(MergedPropsComponent);
|
||||
|
||||
const ConnectedWithOwnAndDispatch: React.ComponentClass<OwnProps> = connect<void, DispatchProps, OwnProps, MergedProps>(
|
||||
const ConnectedWithOwnAndDispatch: React.NamedExoticComponent<OwnProps> = connect<void, DispatchProps, OwnProps, MergedProps>(
|
||||
undefined,
|
||||
mapDispatchToProps,
|
||||
(stateProps: undefined, dispatchProps: DispatchProps) => ({
|
||||
@@ -780,7 +771,7 @@ function TestMergedPropsInference() {
|
||||
}),
|
||||
)(MergedPropsComponent);
|
||||
|
||||
const ConnectedWithOwn: React.ComponentClass<OwnProps> = connect<void, void, OwnProps, MergedProps>(
|
||||
const ConnectedWithOwn: React.NamedExoticComponent<OwnProps> = connect<void, void, OwnProps, MergedProps>(
|
||||
undefined,
|
||||
undefined,
|
||||
() => ({
|
||||
@@ -1450,3 +1441,15 @@ function testConnectedPropsWithStateAndActions() {
|
||||
|
||||
const ConnectedComponent = connect(Component);
|
||||
}
|
||||
|
||||
function testConnectReturnType() {
|
||||
const TestComponent: React.FC = () => null;
|
||||
|
||||
const Test = connect()(TestComponent);
|
||||
|
||||
const myHoc1 = <P, >(C: React.ComponentClass<P>): React.ComponentType<P> => C;
|
||||
myHoc1(Test); // $ExpectError
|
||||
|
||||
const myHoc2 = <P, >(C: React.FC<P>): React.ComponentType<P> => C;
|
||||
myHoc2(Test);
|
||||
}
|
||||
|
||||
1051
types/relay-runtime/index.d.ts
vendored
1051
types/relay-runtime/index.d.ts
vendored
File diff suppressed because it is too large
Load Diff
5
types/relay-runtime/lib/handlers/RelayDefaultHandlerProvider.d.ts
vendored
Normal file
5
types/relay-runtime/lib/handlers/RelayDefaultHandlerProvider.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { Handler } from '../store/RelayStoreTypes';
|
||||
|
||||
export type HandlerProvider = (handle: string) => any;
|
||||
|
||||
export function RelayDefaultHandlerProvider(handle: string): Handler;
|
||||
3
types/relay-runtime/lib/handlers/RelayDefaultMissingFieldHandlers.d.ts
vendored
Normal file
3
types/relay-runtime/lib/handlers/RelayDefaultMissingFieldHandlers.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { MissingFieldHandler } from '../store/RelayStoreTypes';
|
||||
|
||||
export const missingViewerFieldHandler: MissingFieldHandler;
|
||||
@@ -1,11 +1,10 @@
|
||||
import { DataID, Variables } from '../../../lib/util/RelayRuntimeTypes';
|
||||
import {
|
||||
DataID,
|
||||
RecordSourceProxy,
|
||||
RecordProxy,
|
||||
Variables,
|
||||
ReadOnlyRecordProxy,
|
||||
HandleFieldPayload,
|
||||
ReadonlyRecordProxy,
|
||||
} from '../../../index';
|
||||
} from '../../../lib/store/RelayStoreTypes';
|
||||
|
||||
export interface ConnectionMetadata {
|
||||
path: ReadonlyArray<string> | null | undefined;
|
||||
@@ -30,7 +29,7 @@ export function createEdge(
|
||||
export function deleteNode(record: RecordProxy, nodeID: DataID): void;
|
||||
|
||||
export function getConnection(
|
||||
record: ReadonlyRecordProxy,
|
||||
record: ReadOnlyRecordProxy,
|
||||
key: string,
|
||||
filters?: Variables | null,
|
||||
): RecordProxy | null | undefined;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DataID } from '../../../index';
|
||||
import { DataID } from '../../../lib/util/RelayRuntimeTypes';
|
||||
|
||||
export interface EdgeRecord extends Record<string, unknown> {
|
||||
cursor: unknown;
|
||||
|
||||
59
types/relay-runtime/lib/mutations/RelayDeclarativeMutationConfig.d.ts
vendored
Normal file
59
types/relay-runtime/lib/mutations/RelayDeclarativeMutationConfig.d.ts
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
import { Variables } from '../util/RelayRuntimeTypes';
|
||||
import { ConcreteRequest } from '../util/RelayConcreteNode';
|
||||
import { SelectorStoreUpdater } from '../store/RelayStoreTypes';
|
||||
|
||||
export type MutationTypes = 'RANGE_ADD' | 'RANGE_DELETE' | 'NODE_DELETE';
|
||||
|
||||
export type RangeOperations = 'append' | 'prepend';
|
||||
export type RangeBehaviorsFunction = (connectionArgs: { [name: string]: unknown }) => RangeOperations;
|
||||
export interface RangeBehaviorsObject {
|
||||
[key: string]: RangeOperations;
|
||||
}
|
||||
export type RangeBehaviors = RangeBehaviorsFunction | RangeBehaviorsObject;
|
||||
|
||||
export interface RangeAddConfig {
|
||||
type: 'RANGE_ADD';
|
||||
parentName?: string;
|
||||
parentID?: string;
|
||||
connectionInfo?: ReadonlyArray<{
|
||||
key: string;
|
||||
filters?: Variables;
|
||||
rangeBehavior: string;
|
||||
}>;
|
||||
connectionName?: string;
|
||||
edgeName: string;
|
||||
rangeBehaviors?: RangeBehaviors;
|
||||
}
|
||||
|
||||
export interface RangeDeleteConfig {
|
||||
type: 'RANGE_DELETE';
|
||||
parentName?: string;
|
||||
parentID?: string;
|
||||
connectionKeys?: ReadonlyArray<{
|
||||
key: string;
|
||||
filters?: Variables;
|
||||
}>;
|
||||
connectionName?: string;
|
||||
deletedIDFieldName: string | ReadonlyArray<string>;
|
||||
pathToConnection: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
export interface NodeDeleteConfig {
|
||||
type: 'NODE_DELETE';
|
||||
parentName?: string;
|
||||
parentID?: string;
|
||||
connectionName?: string;
|
||||
deletedIDFieldName: string;
|
||||
}
|
||||
|
||||
export type DeclarativeMutationConfig = RangeAddConfig | RangeDeleteConfig | NodeDeleteConfig;
|
||||
|
||||
export function convert(
|
||||
configs: DeclarativeMutationConfig[],
|
||||
request: ConcreteRequest,
|
||||
optimisticUpdater?: SelectorStoreUpdater,
|
||||
updater?: SelectorStoreUpdater,
|
||||
): {
|
||||
optimisticUpdater: SelectorStoreUpdater;
|
||||
updater: SelectorStoreUpdater;
|
||||
};
|
||||
18
types/relay-runtime/lib/mutations/applyOptimisticMutation.d.ts
vendored
Normal file
18
types/relay-runtime/lib/mutations/applyOptimisticMutation.d.ts
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
import { DeclarativeMutationConfig } from './RelayDeclarativeMutationConfig';
|
||||
import { Disposable, Variables } from '../util/RelayRuntimeTypes';
|
||||
import { GraphQLTaggedNode } from '../query/RelayModernGraphQLTag';
|
||||
import { SelectorStoreUpdater, Environment } from '../store/RelayStoreTypes';
|
||||
|
||||
export interface OptimisticMutationConfig {
|
||||
configs?: ReadonlyArray<DeclarativeMutationConfig> | null;
|
||||
mutation: GraphQLTaggedNode;
|
||||
variables: Variables;
|
||||
optimisticUpdater?: SelectorStoreUpdater | null;
|
||||
optimisticResponse?: object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Higher-level helper function to execute a mutation against a specific
|
||||
* environment.
|
||||
*/
|
||||
export function applyOptimisticMutation(environment: Environment, config: OptimisticMutationConfig): Disposable;
|
||||
3
types/relay-runtime/lib/mutations/commitLocalUpdate.d.ts
vendored
Normal file
3
types/relay-runtime/lib/mutations/commitLocalUpdate.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
import { Environment, StoreUpdater } from '../store/RelayStoreTypes';
|
||||
|
||||
export function commitLocalUpdate(environment: Environment, updater: StoreUpdater): void;
|
||||
36
types/relay-runtime/lib/mutations/commitMutation.d.ts
vendored
Normal file
36
types/relay-runtime/lib/mutations/commitMutation.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import { PayloadError, UploadableMap } from '../network/RelayNetworkTypes';
|
||||
import { Disposable, Variables } from '../util/RelayRuntimeTypes';
|
||||
import { DeclarativeMutationConfig } from './RelayDeclarativeMutationConfig';
|
||||
import { GraphQLTaggedNode } from '../query/RelayModernGraphQLTag';
|
||||
import { SelectorStoreUpdater } from '../store/RelayStoreTypes';
|
||||
import { RelayModernEnvironment as Environment } from '../store/RelayModernEnvironment';
|
||||
|
||||
export interface MutationParameters {
|
||||
readonly variables: Variables;
|
||||
readonly response: unknown;
|
||||
readonly rawResponse?: unknown;
|
||||
}
|
||||
|
||||
export interface MutationConfig<TOperation extends MutationParameters> {
|
||||
configs?: ReadonlyArray<DeclarativeMutationConfig>;
|
||||
mutation: GraphQLTaggedNode;
|
||||
variables: TOperation['variables'];
|
||||
uploadables?: UploadableMap;
|
||||
onCompleted?:
|
||||
| ((response: TOperation['response'], errors: ReadonlyArray<PayloadError> | null | undefined) => void)
|
||||
| null;
|
||||
onError?: ((error: Error) => void) | null;
|
||||
optimisticUpdater?: SelectorStoreUpdater | null;
|
||||
optimisticResponse?: TOperation['response'] | null;
|
||||
updater?: SelectorStoreUpdater<TOperation['response']> | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Higher-level helper function to execute a mutation against a specific
|
||||
* environment.
|
||||
*/
|
||||
export function commitMutation<TOperation extends MutationParameters = MutationParameters>(
|
||||
environment: Environment,
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
config: MutationConfig<TOperation>,
|
||||
): Disposable;
|
||||
5
types/relay-runtime/lib/network/RelayNetwork.d.ts
vendored
Normal file
5
types/relay-runtime/lib/network/RelayNetwork.d.ts
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { FetchFunction, SubscribeFunction, Network } from './RelayNetworkTypes';
|
||||
|
||||
export const RelayNetwork: {
|
||||
create(fetchFn: FetchFunction, subscribeFn?: SubscribeFunction): Network;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import { RequestParameters } from '../util/RelayConcreteNode';
|
||||
import { Variables, CacheConfig, UploadableMap, GraphQLResponse } from '../../index';
|
||||
import { Variables, CacheConfig } from '../util/RelayRuntimeTypes';
|
||||
import { UploadableMap, GraphQLResponse } from './RelayNetworkTypes';
|
||||
|
||||
export interface RelayNetworkLog {
|
||||
label: string;
|
||||
|
||||
95
types/relay-runtime/lib/network/RelayNetworkTypes.d.ts
vendored
Normal file
95
types/relay-runtime/lib/network/RelayNetworkTypes.d.ts
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
import { RequestParameters } from '../util/RelayConcreteNode';
|
||||
import { Variables, CacheConfig, Disposable } from '../util/RelayRuntimeTypes';
|
||||
import { ObservableFromValue, RelayObservable } from './RelayObservable';
|
||||
|
||||
/**
|
||||
* An interface for fetching the data for one or more (possibly interdependent)
|
||||
* queries.
|
||||
*/
|
||||
export interface Network {
|
||||
execute: ExecuteFunction;
|
||||
}
|
||||
export type LogRequestInfoFunction = (arg: any) => void;
|
||||
|
||||
export interface PayloadData {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface PayloadError {
|
||||
message: string;
|
||||
locations?: Array<{
|
||||
line: number;
|
||||
column: number;
|
||||
}>;
|
||||
severity?: 'CRITICAL' | 'ERROR' | 'WARNING'; // Not officially part of the spec, but used at Facebook
|
||||
}
|
||||
|
||||
export interface PayloadExtensions {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* The shape of a GraphQL response as dictated by the
|
||||
* [spec](https://graphql.github.io/graphql-spec/June2018/#sec-Response-Format)
|
||||
*/
|
||||
export interface GraphQLResponseWithData {
|
||||
data: PayloadData;
|
||||
errors?: PayloadError[];
|
||||
extensions?: PayloadExtensions;
|
||||
label?: string;
|
||||
path?: string[] | number[];
|
||||
}
|
||||
export interface GraphQLResponseWithoutData {
|
||||
data?: PayloadData;
|
||||
errors: PayloadError[];
|
||||
extensions?: PayloadExtensions;
|
||||
label?: string;
|
||||
path?: Array<string | number>;
|
||||
}
|
||||
export type GraphQLResponse = GraphQLResponseWithData | GraphQLResponseWithoutData;
|
||||
|
||||
/**
|
||||
* A function that returns an Observable representing the response of executing
|
||||
* a GraphQL operation.
|
||||
*/
|
||||
export type ExecuteFunction = (
|
||||
request: RequestParameters,
|
||||
variables: Variables,
|
||||
cacheConfig: CacheConfig,
|
||||
uploadables?: UploadableMap | null,
|
||||
) => RelayObservable<GraphQLResponse>;
|
||||
|
||||
/**
|
||||
* A function that executes a GraphQL operation with request/response semantics.
|
||||
*
|
||||
* May return an Observable or Promise of a plain GraphQL server response, or
|
||||
* a composed ExecutePayload object supporting additional metadata.
|
||||
*/
|
||||
export type FetchFunction = (
|
||||
request: RequestParameters,
|
||||
variables: Variables,
|
||||
cacheConfig: CacheConfig,
|
||||
uploadables?: UploadableMap | null,
|
||||
) => ObservableFromValue<GraphQLResponse>;
|
||||
|
||||
export interface LegacyObserver<T> {
|
||||
onCompleted?: () => void;
|
||||
onError?: (error: Error) => void;
|
||||
onNext?: (data: T) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that executes a GraphQL subscription operation, returning zero or
|
||||
* more raw server responses over time.
|
||||
*/
|
||||
export type SubscribeFunction = (
|
||||
request: RequestParameters,
|
||||
variables: Variables,
|
||||
cacheConfig: CacheConfig,
|
||||
observer?: LegacyObserver<GraphQLResponse>,
|
||||
) => RelayObservable<GraphQLResponse> | Disposable;
|
||||
|
||||
export type Uploadable = File | Blob;
|
||||
export interface UploadableMap {
|
||||
[key: string]: Uploadable;
|
||||
}
|
||||
190
types/relay-runtime/lib/network/RelayObservable.d.ts
vendored
Normal file
190
types/relay-runtime/lib/network/RelayObservable.d.ts
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/**
|
||||
* A Subscription object is returned from .subscribe(), which can be
|
||||
* unsubscribed or checked to see if the resulting subscription has closed.
|
||||
*/
|
||||
export interface Subscription {
|
||||
unsubscribe(): void;
|
||||
readonly closed: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* An Observer is an object of optional callback functions provided to
|
||||
* .subscribe(). Each callback function is invoked when that event occurs.
|
||||
*/
|
||||
export interface Observer<T> {
|
||||
readonly start?: (subscription: Subscription) => void;
|
||||
readonly next?: (value: T) => void;
|
||||
readonly error?: (error: Error) => void;
|
||||
readonly complete?: () => void;
|
||||
readonly unsubscribe?: (subscription: Subscription) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Sink is an object of methods provided by Observable during construction.
|
||||
* The methods are to be called to trigger each event. It also contains a closed
|
||||
* field to see if the resulting subscription has closed.
|
||||
*/
|
||||
export interface Sink<T> {
|
||||
next(value: T): void;
|
||||
error(error: Error, isUncaughtThrownError?: boolean): void;
|
||||
complete(): void;
|
||||
readonly closed: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A Source is the required argument when constructing a new Observable. Similar
|
||||
* to a Promise constructor, this is a function which is invoked with a Sink,
|
||||
* and may return either a cleanup function or a Subscription instance (for use
|
||||
* when composing Observables).
|
||||
*/
|
||||
export type Source<T> = (sink: Sink<T>) => void | Subscription | (() => unknown);
|
||||
|
||||
/**
|
||||
* A Subscribable is an interface describing any object which can be subscribed.
|
||||
*
|
||||
* Note: A sink may be passed directly to .subscribe() as its observer,
|
||||
* allowing for easily composing Subscribables.
|
||||
*/
|
||||
export interface Subscribable<T> {
|
||||
subscribe(observer: Observer<T> | Sink<T>): Subscription;
|
||||
}
|
||||
|
||||
export type ObservableFromValue<T> = Subscribable<T> | Promise<T> | T;
|
||||
|
||||
/**
|
||||
* Limited implementation of ESObservable, providing the limited set of behavior
|
||||
* Relay networking requires.
|
||||
*
|
||||
* Observables retain the benefit of callbacks which can be called
|
||||
* synchronously, avoiding any UI jitter, while providing a compositional API,
|
||||
* which simplifies logic and prevents mishandling of errors compared to
|
||||
* the direct use of callback functions.
|
||||
*
|
||||
* ESObservable: https://github.com/tc39/proposal-observable
|
||||
*/
|
||||
export class RelayObservable<T> implements Subscribable<T> {
|
||||
// Use RelayObservable.create(source);
|
||||
private constructor(source: never);
|
||||
|
||||
static create<V>(source: Source<V>): RelayObservable<V>;
|
||||
|
||||
/**
|
||||
* When an emitted error event is not handled by an Observer, it is reported
|
||||
* to the host environment (what the ESObservable spec refers to as
|
||||
* "HostReportErrors()").
|
||||
*
|
||||
* The default implementation in development rethrows thrown errors, and
|
||||
* logs emitted error events to the console, while in production does nothing
|
||||
* (swallowing unhandled errors).
|
||||
*
|
||||
* Called during application initialization, this method allows
|
||||
* application-specific handling of unhandled errors. Allowing, for example,
|
||||
* integration with error logging or developer tools.
|
||||
*
|
||||
* A second parameter `isUncaughtThrownError` is true when the unhandled error
|
||||
* was thrown within an Observer handler, and false when the unhandled error
|
||||
* was an unhandled emitted event.
|
||||
*
|
||||
* - Uncaught thrown errors typically represent avoidable errors thrown from
|
||||
* application code, which should be handled with a try/catch block, and
|
||||
* usually have useful stack traces.
|
||||
*
|
||||
* - Unhandled emitted event errors typically represent unavoidable events in
|
||||
* application flow such as network failure, and may not have useful
|
||||
* stack traces.
|
||||
*/
|
||||
static onUnhandledError(callback: (error: Error, isUncaughtThrownError: boolean) => void): void;
|
||||
|
||||
/**
|
||||
* Accepts various kinds of data sources, and always returns a RelayObservable
|
||||
* useful for accepting the result of a user-provided FetchFunction.
|
||||
*/
|
||||
static from<V>(obj: ObservableFromValue<V>): RelayObservable<V>;
|
||||
|
||||
/**
|
||||
* Similar to promise.catch(), observable.catch() handles error events, and
|
||||
* provides an alternative observable to use in it's place.
|
||||
*
|
||||
* If the catch handler throws a new error, it will appear as an error event
|
||||
* on the resulting Observable.
|
||||
*/
|
||||
catch<U>(fn: (error: Error) => RelayObservable<U>): RelayObservable<T | U>;
|
||||
|
||||
/**
|
||||
* Returns a new Observable which first yields values from this Observable,
|
||||
* then yields values from the next Observable. This is useful for chaining
|
||||
* together Observables of finite length.
|
||||
*/
|
||||
concat<U>(next: RelayObservable<U>): RelayObservable<T | U>;
|
||||
|
||||
/**
|
||||
* Returns a new Observable which returns the same values as this one, but
|
||||
* modified so that the provided Observer is called to perform a side-effects
|
||||
* for all events emitted by the source.
|
||||
*
|
||||
* Any errors that are thrown in the side-effect Observer are unhandled, and
|
||||
* do not affect the source Observable or its Observer.
|
||||
*
|
||||
* This is useful for when debugging your Observables or performing other
|
||||
* side-effects such as logging or performance monitoring.
|
||||
*/
|
||||
do(observer: Observer<T>): RelayObservable<T>;
|
||||
|
||||
/**
|
||||
* Returns a new Observable which returns the same values as this one, but
|
||||
* modified so that the finally callback is performed after completion,
|
||||
* whether normal or due to error or unsubscription.
|
||||
*
|
||||
* This is useful for cleanup such as resource finalization.
|
||||
*/
|
||||
finally(fn: () => unknown): RelayObservable<T>;
|
||||
|
||||
/**
|
||||
* Returns a new Observable which is identical to this one, unless this
|
||||
* Observable completes before yielding any values, in which case the new
|
||||
* Observable will yield the values from the alternate Observable.
|
||||
*
|
||||
* If this Observable does yield values, the alternate is never subscribed to.
|
||||
*
|
||||
* This is useful for scenarios where values may come from multiple sources
|
||||
* which should be tried in order, i.e. from a cache before a network.
|
||||
*/
|
||||
ifEmpty<U>(alternate: RelayObservable<U>): RelayObservable<T | U>;
|
||||
|
||||
/**
|
||||
* Observable's primary API: returns an unsubscribable Subscription to the
|
||||
* source of this Observable.
|
||||
*
|
||||
* Note: A sink may be passed directly to .subscribe() as its observer,
|
||||
* allowing for easily composing Observables.
|
||||
*/
|
||||
subscribe(observer: Observer<T> | Sink<T>): Subscription;
|
||||
|
||||
/**
|
||||
* Returns a new Observerable where each value has been transformed by
|
||||
* the mapping function.
|
||||
*/
|
||||
map<U>(fn: (value: T) => U): RelayObservable<U>;
|
||||
|
||||
/**
|
||||
* Returns a new Observable where each value is replaced with a new Observable
|
||||
* by the mapping function, the results of which returned as a single
|
||||
* merged Observable.
|
||||
*/
|
||||
mergeMap<U>(fn: (value: T) => ObservableFromValue<U>): RelayObservable<U>;
|
||||
|
||||
/**
|
||||
* Returns a new Observable which first mirrors this Observable, then when it
|
||||
* completes, waits for `pollInterval` milliseconds before re-subscribing to
|
||||
* this Observable again, looping in this manner until unsubscribed.
|
||||
*
|
||||
* The returned Observable never completes.
|
||||
*/
|
||||
poll(pollInterval: number): RelayObservable<T>;
|
||||
|
||||
/**
|
||||
* Returns a Promise which resolves when this Observable yields a first value
|
||||
* or when it completes with no value.
|
||||
*/
|
||||
toPromise(): Promise<T | undefined>;
|
||||
}
|
||||
9
types/relay-runtime/lib/network/RelayQueryResponseCache.d.ts
vendored
Normal file
9
types/relay-runtime/lib/network/RelayQueryResponseCache.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GraphQLResponse } from '../network/RelayNetworkTypes';
|
||||
import { Variables } from '../util/RelayRuntimeTypes';
|
||||
|
||||
export default class RelayQueryResponseCache {
|
||||
constructor(config: { size: number; ttl: number });
|
||||
clear(): void;
|
||||
get(queryID: string, variables: Variables): GraphQLResponse | null;
|
||||
set(queryID: string, variables: Variables, payload: GraphQLResponse): void;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import { RelayNetworkLoggerTransaction } from './RelayNetworkLoggerTransaction';
|
||||
import { RequestParameters } from '../util/RelayConcreteNode';
|
||||
import { Variables, FetchFunction, SubscribeFunction } from '../../index';
|
||||
import { Variables } from '../util/RelayRuntimeTypes';
|
||||
import { FetchFunction, SubscribeFunction } from './RelayNetworkTypes';
|
||||
|
||||
export type GraphiQLPrinter = (request: RequestParameters, variables: Variables) => string;
|
||||
export interface NetworkLogger {
|
||||
|
||||
34
types/relay-runtime/lib/query/RelayModernGraphQLTag.d.ts
vendored
Normal file
34
types/relay-runtime/lib/query/RelayModernGraphQLTag.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
import {
|
||||
ReaderFragment,
|
||||
ReaderPaginationFragment,
|
||||
ReaderRefetchableFragment,
|
||||
ReaderInlineDataFragment,
|
||||
} from '../util/ReaderNode';
|
||||
import { ConcreteRequest } from '../util/RelayConcreteNode';
|
||||
|
||||
// The type of a graphql`...` tagged template expression.
|
||||
export type GraphQLTaggedNode = ReaderFragment | ConcreteRequest | (() => ReaderFragment | ConcreteRequest);
|
||||
|
||||
/**
|
||||
* Runtime function to correspond to the `graphql` tagged template function.
|
||||
* All calls to this function should be transformed by the plugin.
|
||||
*/
|
||||
export function graphql(strings: unknown): GraphQLTaggedNode;
|
||||
|
||||
export function getNode(taggedNode: unknown): unknown;
|
||||
|
||||
export function isFragment(node: GraphQLTaggedNode): boolean;
|
||||
|
||||
export function isRequest(node: GraphQLTaggedNode): boolean;
|
||||
|
||||
export function isInlineDataFragment(node: GraphQLTaggedNode): boolean;
|
||||
|
||||
export function getFragment(taggedNode: GraphQLTaggedNode): ReaderFragment;
|
||||
|
||||
export function getPaginationFragment(taggedNode: GraphQLTaggedNode): ReaderPaginationFragment | null;
|
||||
|
||||
export function getRefetchableFragment(taggedNode: GraphQLTaggedNode): ReaderRefetchableFragment | null;
|
||||
|
||||
export function getRequest(taggedNode: GraphQLTaggedNode): ConcreteRequest;
|
||||
|
||||
export function getInlineDataFragment(taggedNode: GraphQLTaggedNode): ReaderInlineDataFragment;
|
||||
10
types/relay-runtime/lib/query/fetchQuery.d.ts
vendored
Normal file
10
types/relay-runtime/lib/query/fetchQuery.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import { OperationType, CacheConfig } from '../util/RelayRuntimeTypes';
|
||||
import { Environment } from '../store/RelayStoreTypes';
|
||||
import { GraphQLTaggedNode } from './RelayModernGraphQLTag';
|
||||
|
||||
export function fetchQuery<T extends OperationType>(
|
||||
environment: Environment,
|
||||
taggedNode: GraphQLTaggedNode,
|
||||
variables: T['variables'],
|
||||
cacheConfig?: CacheConfig | null,
|
||||
): Promise<T['response']>;
|
||||
82
types/relay-runtime/lib/store/RelayConnection.d.ts
vendored
Normal file
82
types/relay-runtime/lib/store/RelayConnection.d.ts
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { Variables } from '../util/RelayRuntimeTypes';
|
||||
import { RequestDescriptor, TypedSnapshot, RecordMap } from './RelayStoreTypes';
|
||||
import { ReaderLinkedField } from '../util/ReaderNode';
|
||||
|
||||
export type ConnectionID = string;
|
||||
|
||||
export interface ConnectionRecord {
|
||||
__id: ConnectionID;
|
||||
__typename: string;
|
||||
events: ConnectionInternalEvent[];
|
||||
}
|
||||
|
||||
export interface ConnectionMap {
|
||||
[key: string]: ConnectionRecord;
|
||||
}
|
||||
|
||||
export type GetConnectionEvents = (connectionID: ConnectionID) => ReadonlyArray<ConnectionInternalEvent>;
|
||||
|
||||
export type ConnectionInternalEvent =
|
||||
| {
|
||||
kind: string;
|
||||
args: Variables;
|
||||
connectionID: ConnectionID;
|
||||
edgeIDs: ReadonlyArray<string>;
|
||||
pageInfo: PageInfo;
|
||||
request: RequestDescriptor;
|
||||
}
|
||||
| {
|
||||
kind: string;
|
||||
args: Variables;
|
||||
connectionID: ConnectionID;
|
||||
edgeID: string;
|
||||
request: RequestDescriptor;
|
||||
};
|
||||
|
||||
export type ConnectionEvent<TEdge> =
|
||||
| {
|
||||
kind: 'fetch';
|
||||
args: Variables;
|
||||
edges: ReadonlyArray<TEdge>;
|
||||
pageInfo: PageInfo;
|
||||
}
|
||||
| { kind: 'update'; edgeData: { [key: string]: TEdge } }
|
||||
| { kind: 'insert'; args: Variables; edge: TEdge };
|
||||
|
||||
export interface ConnectionResolver<TEdge, TState> {
|
||||
initialize(): TState;
|
||||
reduce(state: TState, event: ConnectionEvent<TEdge>): TState;
|
||||
}
|
||||
|
||||
export interface ConnectionReferenceObject<TEdge> {
|
||||
__connection: ConnectionReference<TEdge>;
|
||||
}
|
||||
|
||||
export interface ConnectionReference<TEdge> {
|
||||
variables: Variables;
|
||||
edgesField: ReaderLinkedField;
|
||||
id: ConnectionID;
|
||||
label: string;
|
||||
}
|
||||
|
||||
export interface ConnectionSnapshot<TEdge, TState> {
|
||||
edgeSnapshots: { [key: string]: TypedSnapshot<TEdge> };
|
||||
id: ConnectionID;
|
||||
reference: ConnectionReference<TEdge>;
|
||||
seenRecords: RecordMap;
|
||||
state: TState;
|
||||
}
|
||||
|
||||
export interface PageInfo {
|
||||
endCursor: string;
|
||||
hasNextPage: boolean;
|
||||
hasPrevPage: boolean;
|
||||
startCursor: string;
|
||||
}
|
||||
|
||||
export const CONNECTION_KEY: string;
|
||||
export const CONNECTION_TYPENAME: string;
|
||||
|
||||
export function createConnectionID(parentID: string, label: string): ConnectionID;
|
||||
|
||||
export function createConnectionRecord(connectionID: ConnectionID): ConnectionRecord;
|
||||
82
types/relay-runtime/lib/store/RelayModernEnvironment.d.ts
vendored
Normal file
82
types/relay-runtime/lib/store/RelayModernEnvironment.d.ts
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
import { HandlerProvider } from '../handlers/RelayDefaultHandlerProvider';
|
||||
import {
|
||||
LogFunction,
|
||||
OperationLoader,
|
||||
Store,
|
||||
MissingFieldHandler,
|
||||
OperationTracker,
|
||||
LoggerProvider,
|
||||
Logger,
|
||||
OptimisticUpdate,
|
||||
OperationDescriptor,
|
||||
SelectorStoreUpdater,
|
||||
NormalizationSelector,
|
||||
StoreUpdater,
|
||||
SingularReaderSelector,
|
||||
Snapshot,
|
||||
OptimisticResponseConfig,
|
||||
Environment,
|
||||
} from './RelayStoreTypes';
|
||||
import { Network, PayloadData, GraphQLResponse, UploadableMap } from '../network/RelayNetworkTypes';
|
||||
import { TaskScheduler } from './RelayModernQueryExecutor';
|
||||
import { RelayOperationTracker } from './RelayOperationTracker';
|
||||
import { LoggerTransactionConfig } from '../network/RelayNetworkLoggerTransaction';
|
||||
import { Disposable, CacheConfig } from '../util/RelayRuntimeTypes';
|
||||
import { RelayObservable } from '../network/RelayObservable';
|
||||
|
||||
export interface EnvironmentConfig {
|
||||
configName?: string;
|
||||
handlerProvider?: HandlerProvider;
|
||||
log?: LogFunction;
|
||||
operationLoader?: OperationLoader;
|
||||
network: Network;
|
||||
scheduler?: TaskScheduler;
|
||||
store: Store;
|
||||
missingFieldHandlers?: ReadonlyArray<MissingFieldHandler>;
|
||||
operationTracker?: OperationTracker;
|
||||
loggerProvider?: LoggerProvider;
|
||||
}
|
||||
|
||||
export class RelayModernEnvironment implements Environment {
|
||||
readonly configName: string | null | undefined;
|
||||
constructor(config: EnvironmentConfig);
|
||||
getStore(): Store;
|
||||
getNetwork(): Network;
|
||||
getOperationTracker(): RelayOperationTracker;
|
||||
getLogger(config: LoggerTransactionConfig): Logger;
|
||||
applyUpdate(optimisticUpdate: OptimisticUpdate): Disposable;
|
||||
revertUpdate(update: OptimisticUpdate): void;
|
||||
replaceUpdate(update: OptimisticUpdate, newUpdate: OptimisticUpdate): void;
|
||||
applyMutation(optimisticConfig: OptimisticResponseConfig): Disposable;
|
||||
check(readSelector: NormalizationSelector): boolean;
|
||||
commitPayload(operationDescriptor: OperationDescriptor, payload: PayloadData): void;
|
||||
commitUpdate(updater: StoreUpdater): void;
|
||||
lookup(readSelector: SingularReaderSelector): Snapshot;
|
||||
subscribe(snapshot: Snapshot, callback: (snapshot: Snapshot) => void): Disposable;
|
||||
retain(selector: NormalizationSelector): Disposable;
|
||||
execute(data: {
|
||||
operation: OperationDescriptor;
|
||||
cacheConfig?: CacheConfig | null;
|
||||
updater?: SelectorStoreUpdater | null;
|
||||
}): RelayObservable<GraphQLResponse>;
|
||||
executeMutation({
|
||||
operation,
|
||||
optimisticResponse,
|
||||
optimisticUpdater,
|
||||
updater,
|
||||
uploadables,
|
||||
}: {
|
||||
operation: OperationDescriptor;
|
||||
optimisticUpdater?: SelectorStoreUpdater | null;
|
||||
optimisticResponse?: object | null;
|
||||
updater?: SelectorStoreUpdater | null;
|
||||
uploadables?: UploadableMap | null;
|
||||
}): RelayObservable<GraphQLResponse>;
|
||||
executeWithSource({
|
||||
operation,
|
||||
source,
|
||||
}: {
|
||||
operation: OperationDescriptor;
|
||||
source: RelayObservable<GraphQLResponse>;
|
||||
}): RelayObservable<GraphQLResponse>;
|
||||
}
|
||||
12
types/relay-runtime/lib/store/RelayModernOperationDescriptor.d.ts
vendored
Normal file
12
types/relay-runtime/lib/store/RelayModernOperationDescriptor.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
import { ConcreteRequest } from '../util/RelayConcreteNode';
|
||||
import { Variables } from '../util/RelayRuntimeTypes';
|
||||
import { OperationDescriptor, RequestDescriptor } from './RelayStoreTypes';
|
||||
/**
|
||||
* Creates an instance of the `OperationDescriptor` type defined in
|
||||
* `RelayStoreTypes` given an operation and some variables. The input variables
|
||||
* are filtered to exclude variables that do not match defined arguments on the
|
||||
* operation, and default values are populated for null values.
|
||||
*/
|
||||
export function createOperationDescriptor(request: ConcreteRequest, variables: Variables): OperationDescriptor;
|
||||
|
||||
export function createRequestDescriptor(request: ConcreteRequest, variables: Variables): RequestDescriptor;
|
||||
29
types/relay-runtime/lib/store/RelayModernQueryExecutor.d.ts
vendored
Normal file
29
types/relay-runtime/lib/store/RelayModernQueryExecutor.d.ts
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
import {
|
||||
OperationDescriptor,
|
||||
OperationLoader,
|
||||
OperationTracker,
|
||||
OptimisticResponseConfig,
|
||||
PublishQueue,
|
||||
SelectorStoreUpdater,
|
||||
} from './RelayStoreTypes';
|
||||
import { GraphQLResponse } from '../network/RelayNetworkTypes';
|
||||
import { Sink, RelayObservable } from '../network/RelayObservable';
|
||||
import { GetDataID } from './RelayResponseNormalizer';
|
||||
|
||||
export interface ExecuteConfig {
|
||||
getDataID: GetDataID;
|
||||
operation: OperationDescriptor;
|
||||
operationLoader: OperationLoader;
|
||||
operationTracker?: OperationTracker;
|
||||
optimisticConfig: OptimisticResponseConfig;
|
||||
publishQueue: PublishQueue;
|
||||
scheduler?: TaskScheduler;
|
||||
sink: Sink<GraphQLResponse>;
|
||||
source: RelayObservable<GraphQLResponse>;
|
||||
updater?: SelectorStoreUpdater;
|
||||
}
|
||||
|
||||
export interface TaskScheduler {
|
||||
cancel: (id: string) => void;
|
||||
schedule: (fn: () => void) => string;
|
||||
}
|
||||
85
types/relay-runtime/lib/store/RelayModernRecord.d.ts
vendored
Normal file
85
types/relay-runtime/lib/store/RelayModernRecord.d.ts
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
import { Record } from './RelayStoreTypes';
|
||||
import { DataID } from '../util/RelayRuntimeTypes';
|
||||
|
||||
export class RelayModernRecord {
|
||||
/**
|
||||
* Clone a record.
|
||||
*/
|
||||
clone(record: Record): Record;
|
||||
|
||||
/**
|
||||
* Copies all fields from `source` to `sink`, excluding `__id` and `__typename`.
|
||||
*
|
||||
* NOTE: This function does not treat `id` specially. To preserve the id,
|
||||
* manually reset it after calling this function. Also note that values are
|
||||
* copied by reference and not value; callers should ensure that values are
|
||||
* copied on write.
|
||||
*/
|
||||
copyFields(source: Record, sink: Record): void;
|
||||
|
||||
/**
|
||||
* Create a new record.
|
||||
*/
|
||||
create(dataID: DataID, typeName: string): Record;
|
||||
|
||||
/**
|
||||
* Get the record's `id` if available or the client-generated identifier.
|
||||
*/
|
||||
getDataID(record: Record): DataID;
|
||||
|
||||
/**
|
||||
* Get the concrete type of the record.
|
||||
*/
|
||||
getType(record: Record): string;
|
||||
|
||||
/**
|
||||
* Get a scalar (non-link) field value.
|
||||
*/
|
||||
getValue(record: Record, storageKey: string): unknown;
|
||||
|
||||
/**
|
||||
* Get the value of a field as a reference to another record. Throws if the
|
||||
* field has a different type.
|
||||
*/
|
||||
getLinkedRecordID(record: Record, storageKey: string): DataID | null;
|
||||
|
||||
/**
|
||||
* Get the value of a field as a list of references to other records. Throws if
|
||||
* the field has a different type.
|
||||
*/
|
||||
getLinkedRecordIDs(record: Record, storageKey: string): DataID[] | null;
|
||||
|
||||
/**
|
||||
* Compares the fields of a previous and new record, returning either the
|
||||
* previous record if all fields are equal or a new record (with merged fields)
|
||||
* if any fields have changed.
|
||||
*/
|
||||
update(prevRecord: Record, nextRecord: Record): Record;
|
||||
|
||||
/**
|
||||
* Returns a new record with the contents of the given records. Fields in the
|
||||
* second record will overwrite identical fields in the first record.
|
||||
*/
|
||||
merge(record1: Record, record2: Record): Record;
|
||||
|
||||
/**
|
||||
* Prevent modifications to the record. Attempts to call `set*` functions on a
|
||||
* frozen record will fatal at runtime.
|
||||
*/
|
||||
freeze(record: Record): void;
|
||||
|
||||
/**
|
||||
* Set the value of a storageKey to a scalar.
|
||||
*/
|
||||
setValue(record: Record, storageKey: string, value: any): void;
|
||||
|
||||
/**
|
||||
* Set the value of a field to a reference to another record.
|
||||
*/
|
||||
setLinkedRecordID(record: Record, storageKey: string, linkedID: DataID): void;
|
||||
|
||||
/**
|
||||
* Set the value of a field to a list of references other records.
|
||||
*/
|
||||
setLinkedRecordIDs(record: Record, storageKey: string, linkedIDs: DataID[] | null): void;
|
||||
}
|
||||
115
types/relay-runtime/lib/store/RelayModernSelector.d.ts
vendored
Normal file
115
types/relay-runtime/lib/store/RelayModernSelector.d.ts
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
import { ReaderFragment } from '../util/ReaderNode';
|
||||
import {
|
||||
SingularReaderSelector,
|
||||
PluralReaderSelector,
|
||||
ReaderSelector,
|
||||
RequestDescriptor,
|
||||
NormalizationSelector,
|
||||
} from './RelayStoreTypes';
|
||||
import { DataID, Variables } from '../util/RelayRuntimeTypes';
|
||||
import { NormalizationSelectableNode } from '../util/NormalizationNode';
|
||||
|
||||
/**
|
||||
* Given the result `item` from a parent that fetched `fragment`, creates a
|
||||
* selector that can be used to read the results of that fragment for that item.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* Given two fragments as follows:
|
||||
*
|
||||
* ```
|
||||
* fragment Parent on User {
|
||||
* id
|
||||
* ...Child
|
||||
* }
|
||||
* fragment Child on User {
|
||||
* name
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* And given some object `parent` that is the results of `Parent` for id "4",
|
||||
* the results of `Child` can be accessed by first getting a selector and then
|
||||
* using that selector to `lookup()` the results against the environment:
|
||||
*
|
||||
* ```
|
||||
* const childSelector = getSingularSelector(queryVariables, Child, parent);
|
||||
* const childData = environment.lookup(childSelector).data;
|
||||
* ```
|
||||
*/
|
||||
export function getSingularSelector(fragment: ReaderFragment, item: unknown): SingularReaderSelector;
|
||||
|
||||
/**
|
||||
* Given the result `items` from a parent that fetched `fragment`, creates a
|
||||
* selector that can be used to read the results of that fragment on those
|
||||
* items. This is similar to `getSingularSelector` but for "plural" fragments that
|
||||
* expect an array of results and therefore return an array of selectors.
|
||||
*/
|
||||
export function getPluralSelector(fragment: ReaderFragment, items: unknown[]): PluralReaderSelector;
|
||||
|
||||
export function getSelector(fragment: ReaderFragment, item: unknown | unknown[]): ReaderSelector;
|
||||
|
||||
/**
|
||||
* Given a mapping of keys -> results and a mapping of keys -> fragments,
|
||||
* extracts the selectors for those fragments from the results.
|
||||
*
|
||||
* The canonical use-case for this function is ReactRelayFragmentContainer, which
|
||||
* uses this function to convert (props, fragments) into selectors so that it
|
||||
* can read the results to pass to the inner component.
|
||||
*/
|
||||
export function getSelectorsFromObject(
|
||||
fragments: { [key: string]: ReaderFragment },
|
||||
object: { [key: string]: any },
|
||||
): { [key: string]: ReaderSelector };
|
||||
|
||||
/**
|
||||
* Given a mapping of keys -> results and a mapping of keys -> fragments,
|
||||
* extracts a mapping of keys -> id(s) of the results.
|
||||
*
|
||||
* Similar to `getSelectorsFromObject()`, this function can be useful in
|
||||
* determining the "identity" of the props passed to a component.
|
||||
*/
|
||||
export function getDataIDsFromObject(
|
||||
fragments: { [key: string]: ReaderFragment },
|
||||
object: { [key: string]: any },
|
||||
): { [key: string]: DataID | DataID[] };
|
||||
|
||||
export function getDataIDsFromFragment(fragment: ReaderFragment, item: unknown | unknown[]): DataID | DataID[];
|
||||
|
||||
/**
|
||||
* Given a mapping of keys -> results and a mapping of keys -> fragments,
|
||||
* extracts the merged variables that would be in scope for those
|
||||
* fragments/results.
|
||||
*
|
||||
* This can be useful in determing what varaibles were used to fetch the data
|
||||
* for a Relay container, for example.
|
||||
*/
|
||||
export function getVariablesFromObject(
|
||||
fragments: { [key: string]: ReaderFragment },
|
||||
object: { [key: string]: any },
|
||||
): Variables;
|
||||
|
||||
export function getVariablesFromFragment(fragment: ReaderFragment, item: unknown | unknown[]): Variables;
|
||||
|
||||
export function getVariablesFromSingularFragment(fragment: ReaderFragment, item: unknown): Variables;
|
||||
|
||||
export function getVariablesFromPluralFragment(fragment: ReaderFragment, items: unknown[]): Variables;
|
||||
|
||||
/**
|
||||
* Determine if two selectors are equal (represent the same selection). Note
|
||||
* that this function returns `false` when the two queries/fragments are
|
||||
* different objects, even if they select the same fields.
|
||||
*/
|
||||
export function areEqualSelectors(thisSelector: SingularReaderSelector, thatSelector: SingularReaderSelector): boolean;
|
||||
|
||||
export function createReaderSelector(
|
||||
fragment: ReaderFragment,
|
||||
dataID: DataID,
|
||||
variables: Variables,
|
||||
request: RequestDescriptor,
|
||||
): SingularReaderSelector;
|
||||
|
||||
export function createNormalizationSelector(
|
||||
node: NormalizationSelectableNode,
|
||||
dataID: DataID,
|
||||
variables: Variables,
|
||||
): NormalizationSelector;
|
||||
46
types/relay-runtime/lib/store/RelayModernStore.d.ts
vendored
Normal file
46
types/relay-runtime/lib/store/RelayModernStore.d.ts
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
import {
|
||||
Store,
|
||||
MutableRecordSource,
|
||||
Scheduler,
|
||||
OperationLoader,
|
||||
RecordSource,
|
||||
NormalizationSelector,
|
||||
ReaderSelector,
|
||||
Snapshot,
|
||||
RequestDescriptor,
|
||||
} from './RelayStoreTypes';
|
||||
import { Disposable } from '../util/RelayRuntimeTypes';
|
||||
import {
|
||||
ConnectionReference,
|
||||
ConnectionResolver,
|
||||
ConnectionSnapshot,
|
||||
ConnectionInternalEvent,
|
||||
ConnectionID,
|
||||
} from './RelayConnection';
|
||||
|
||||
export class RelayModernStore implements Store {
|
||||
constructor(source: MutableRecordSource, gcScheduler?: Scheduler, operationLoader?: OperationLoader | null);
|
||||
getSource(): RecordSource;
|
||||
check(selector: NormalizationSelector): boolean;
|
||||
retain(selector: NormalizationSelector): Disposable;
|
||||
lookup(selector: ReaderSelector): Snapshot;
|
||||
notify(): ReadonlyArray<RequestDescriptor>;
|
||||
publish(source: RecordSource): void;
|
||||
subscribe(snapshot: Snapshot, callback: (snapshot: Snapshot) => void): Disposable;
|
||||
holdGC(): Disposable;
|
||||
toJSON(): unknown;
|
||||
lookupConnection_UNSTABLE<TEdge, TState>(
|
||||
connectionReference: ConnectionReference<TEdge>,
|
||||
resolver: ConnectionResolver<TEdge, TState>,
|
||||
): ConnectionSnapshot<TEdge, TState>;
|
||||
|
||||
subscribeConnection_UNSTABLE<TEdge, TState>(
|
||||
snapshot: ConnectionSnapshot<TEdge, TState>,
|
||||
resolver: ConnectionResolver<TEdge, TState>,
|
||||
callback: (state: TState) => void,
|
||||
): Disposable;
|
||||
publishConnectionEvents_UNSTABLE(events: ConnectionInternalEvent[], final: boolean): void;
|
||||
getConnectionEvents_UNSTABLE(connectionID: ConnectionID): ReadonlyArray<ConnectionInternalEvent>;
|
||||
snapshot(): void;
|
||||
restore(): void;
|
||||
}
|
||||
19
types/relay-runtime/lib/store/RelayOperationTracker.d.ts
vendored
Normal file
19
types/relay-runtime/lib/store/RelayOperationTracker.d.ts
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
import { RequestDescriptor } from './RelayStoreTypes';
|
||||
|
||||
export class RelayOperationTracker {
|
||||
/**
|
||||
* Update the map of current processing operations with the set of
|
||||
* affected owners and notify subscribers
|
||||
*/
|
||||
update(pendingOperation: RequestDescriptor, affectedOwners: Set<RequestDescriptor>): void;
|
||||
|
||||
/**
|
||||
* Once pending operation is completed we need to remove it
|
||||
* from all tracking maps
|
||||
*/
|
||||
complete(pendingOperation: RequestDescriptor): void;
|
||||
|
||||
_resolveOwnerResolvers(owner: RequestDescriptor): void;
|
||||
|
||||
getPromiseForPendingOperationsAffectingOwner(owner: RequestDescriptor): Promise<void> | null;
|
||||
}
|
||||
21
types/relay-runtime/lib/store/RelayRecordSource.d.ts
vendored
Normal file
21
types/relay-runtime/lib/store/RelayRecordSource.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { MutableRecordSource, RecordMap, Record } from './RelayStoreTypes';
|
||||
import { DataID } from '../util/RelayRuntimeTypes';
|
||||
import { RecordState } from './RelayRecordState';
|
||||
|
||||
export class RelayRecordSource {
|
||||
constructor(records?: RecordMap);
|
||||
|
||||
static create(records?: RecordMap): MutableRecordSource;
|
||||
|
||||
clear(): void;
|
||||
delete(dataID: DataID): void;
|
||||
get(dataID: DataID): Record;
|
||||
getRecordIDs(): string[];
|
||||
getStatus(dataID: DataID): RecordState;
|
||||
has(dataID: DataID): boolean;
|
||||
load(dataID: DataID, callback: (error: Error | null | undefined, record: Record | null | undefined) => void): void;
|
||||
remove(dataID: DataID): void;
|
||||
set(dataID: DataID, record: Record): void;
|
||||
size(): number;
|
||||
toJSON(): Record;
|
||||
}
|
||||
1
types/relay-runtime/lib/store/RelayRecordState.d.ts
vendored
Normal file
1
types/relay-runtime/lib/store/RelayRecordState.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export type RecordState = 'EXISTENT' | 'NONEXISTENT' | 'UNKNOWN';
|
||||
21
types/relay-runtime/lib/store/RelayResponseNormalizer.d.ts
vendored
Normal file
21
types/relay-runtime/lib/store/RelayResponseNormalizer.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
import { RequestDescriptor, MutableRecordSource, NormalizationSelector, RelayResponsePayload } from './RelayStoreTypes';
|
||||
import { PayloadData } from '../network/RelayNetworkTypes';
|
||||
|
||||
export type GetDataID = (fieldValue: { [key: string]: any }, typeName: string) => any;
|
||||
|
||||
export interface NormalizationOptions {
|
||||
getDataID: GetDataID;
|
||||
path?: ReadonlyArray<string>;
|
||||
request: RequestDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes the results of a query and standard GraphQL response, writing the
|
||||
* normalized records/fields into the given MutableRecordSource.
|
||||
*/
|
||||
export function normalize(
|
||||
recordSource: MutableRecordSource,
|
||||
selector: NormalizationSelector,
|
||||
response: PayloadData,
|
||||
options: NormalizationOptions,
|
||||
): RelayResponsePayload;
|
||||
781
types/relay-runtime/lib/store/RelayStoreTypes.d.ts
vendored
Normal file
781
types/relay-runtime/lib/store/RelayStoreTypes.d.ts
vendored
Normal file
@@ -0,0 +1,781 @@
|
||||
import { ReaderFragment } from '../util/ReaderNode';
|
||||
import { Variables, Disposable, DataID, CacheConfig } from '../util/RelayRuntimeTypes';
|
||||
import { ConcreteRequest, RequestParameters } from '../util/RelayConcreteNode';
|
||||
import { RequestIdentifier } from '../util/getRequestIdentifier';
|
||||
import {
|
||||
NormalizationSelectableNode,
|
||||
NormalizationSplitOperation,
|
||||
NormalizationScalarField,
|
||||
NormalizationLinkedField,
|
||||
} from '../util/NormalizationNode';
|
||||
import { Environment, RecordState, GraphQLResponse, StoreUpdater, SelectorStoreUpdater } from '../..';
|
||||
import {
|
||||
ConnectionReference,
|
||||
ConnectionResolver,
|
||||
ConnectionSnapshot,
|
||||
ConnectionInternalEvent,
|
||||
ConnectionID,
|
||||
} from './RelayConnection';
|
||||
import { LoggerTransactionConfig } from '../network/RelayNetworkLoggerTransaction';
|
||||
import { PayloadData, Network, UploadableMap, PayloadError } from '../network/RelayNetworkTypes';
|
||||
import { RelayObservable } from '../network/RelayObservable';
|
||||
import { RelayOperationTracker } from './RelayOperationTracker';
|
||||
|
||||
export type FragmentReference = unknown;
|
||||
export type OperationTracker = RelayOperationTracker;
|
||||
|
||||
/*
|
||||
* An individual cached graph object.
|
||||
*/
|
||||
export interface Record {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* A collection of records keyed by id.
|
||||
*/
|
||||
export interface RecordMap {
|
||||
// theoretically, this should be `[dataID: DataID]`, but `DataID` is a string.
|
||||
[dataID: string]: Record;
|
||||
}
|
||||
|
||||
export interface FragmentMap {
|
||||
[key: string]: ReaderFragment;
|
||||
}
|
||||
|
||||
/**
|
||||
* The results of a selector given a store/RecordSource.
|
||||
*/
|
||||
export interface SelectorData {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface SingularReaderSelector {
|
||||
kind: string;
|
||||
dataID: string;
|
||||
node: ReaderFragment;
|
||||
owner: RequestDescriptor;
|
||||
variables: Variables;
|
||||
}
|
||||
|
||||
export type ReaderSelector = SingularReaderSelector | PluralReaderSelector;
|
||||
|
||||
export interface PluralReaderSelector {
|
||||
kind: string;
|
||||
selectors: ReadonlyArray<SingularReaderSelector>;
|
||||
}
|
||||
|
||||
export interface RequestDescriptor {
|
||||
identifier: RequestIdentifier;
|
||||
node: ConcreteRequest;
|
||||
variables: Variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* A selector defines the starting point for a traversal into the graph for the
|
||||
* purposes of targeting a subgraph.
|
||||
*/
|
||||
export interface NormalizationSelector {
|
||||
dataID: string;
|
||||
node: NormalizationSelectableNode;
|
||||
variables: Variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* A representation of a selector and its results at a particular point in time.
|
||||
*/
|
||||
export interface TypedSnapshot<TData> {
|
||||
data: TData;
|
||||
isMissingData: boolean;
|
||||
seenRecords: RecordMap;
|
||||
selector: SingularReaderSelector;
|
||||
}
|
||||
export type Snapshot = TypedSnapshot<SelectorData>;
|
||||
|
||||
/**
|
||||
* An operation selector describes a specific instance of a GraphQL operation
|
||||
* with variables applied.
|
||||
*
|
||||
* - `root`: a selector intended for processing server results or retaining
|
||||
* response data in the store.
|
||||
* - `fragment`: a selector intended for use in reading or subscribing to
|
||||
* the results of the the operation.
|
||||
*/
|
||||
export interface OperationDescriptor {
|
||||
fragment: SingularReaderSelector;
|
||||
request: RequestDescriptor;
|
||||
root: NormalizationSelector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Arbitrary data e.g. received by a container as props.
|
||||
*/
|
||||
export interface Props {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of the `relay` property set on React context by the React/Relay
|
||||
* integration layer (e.g. QueryRenderer, FragmentContainer, etc).
|
||||
*/
|
||||
export interface RelayContext {
|
||||
environment: Environment;
|
||||
variables: Variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* The results of reading the results of a FragmentMap given some input
|
||||
* `Props`.
|
||||
*/
|
||||
export interface FragmentSpecResults {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* A utility for resolving and subscribing to the results of a fragment spec
|
||||
* (key -> fragment mapping) given some "props" that determine the root ID
|
||||
* and variables to use when reading each fragment. When props are changed via
|
||||
* `setProps()`, the resolver will update its results and subscriptions
|
||||
* accordingly. Internally, the resolver:
|
||||
* - Converts the fragment map & props map into a map of `Selector`s.
|
||||
* - Removes any resolvers for any props that became null.
|
||||
* - Creates resolvers for any props that became non-null.
|
||||
* - Updates resolvers with the latest props.
|
||||
*/
|
||||
export interface FragmentSpecResolver {
|
||||
/**
|
||||
* Stop watching for changes to the results of the fragments.
|
||||
*/
|
||||
dispose(): void;
|
||||
|
||||
/**
|
||||
* Get the current results.
|
||||
*/
|
||||
resolve(): FragmentSpecResults;
|
||||
|
||||
/**
|
||||
* Update the resolver with new inputs. Call `resolve()` to get the updated
|
||||
* results.
|
||||
*/
|
||||
setProps(props: Props): void;
|
||||
|
||||
/**
|
||||
* Override the variables used to read the results of the fragments. Call
|
||||
* `resolve()` to get the updated results.
|
||||
*/
|
||||
setVariables(variables: Variables, node: ConcreteRequest): void;
|
||||
|
||||
/**
|
||||
* Subscribe to resolver updates.
|
||||
* Overrides existing callback (if one has been specified).
|
||||
*/
|
||||
setCallback(callback: () => void): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A read-only interface for accessing cached graph data.
|
||||
*/
|
||||
export interface RecordSource {
|
||||
get(dataID: string): Record;
|
||||
getRecordIDs(): string[];
|
||||
getStatus(dataID: string): RecordState;
|
||||
has(dataID: string): boolean;
|
||||
size(): number;
|
||||
toJSON(): { [key: string]: Record };
|
||||
}
|
||||
|
||||
/**
|
||||
* A read/write interface for accessing and updating graph data.
|
||||
*/
|
||||
export interface MutableRecordSource extends RecordSource {
|
||||
clear(): void;
|
||||
delete(dataID: string): void;
|
||||
remove(dataID: string): void;
|
||||
set(dataID: string, record: Record): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface for keeping multiple views of data consistent across an
|
||||
* application.
|
||||
*/
|
||||
export interface Store {
|
||||
/**
|
||||
* Get a read-only view of the store's internal RecordSource.
|
||||
*/
|
||||
getSource(): RecordSource;
|
||||
|
||||
/**
|
||||
* Determine if the selector can be resolved with data in the store (i.e. no
|
||||
* fields are missing).
|
||||
*/
|
||||
check(selector: NormalizationSelector): boolean;
|
||||
|
||||
/**
|
||||
* Read the results of a selector from in-memory records in the store.
|
||||
* Optionally takes an owner, corresponding to the operation that
|
||||
* owns this selector (fragment).
|
||||
*/
|
||||
lookup(selector: SingularReaderSelector): Snapshot;
|
||||
|
||||
/**
|
||||
* Notify subscribers (see `subscribe`) of any data that was published
|
||||
* (`publish()`) since the last time `notify` was called.
|
||||
*
|
||||
* Also this method should return an array of the affected fragment owners
|
||||
*/
|
||||
notify(): ReadonlyArray<RequestDescriptor>;
|
||||
|
||||
/**
|
||||
* Publish new information (e.g. from the network) to the store, updating its
|
||||
* internal record source. Subscribers are not immediately notified - this
|
||||
* occurs when `notify()` is called.
|
||||
*/
|
||||
publish(source: RecordSource): void;
|
||||
|
||||
/**
|
||||
* Ensure that all the records necessary to fulfill the given selector are
|
||||
* retained in-memory. The records will not be eligible for garbage collection
|
||||
* until the returned reference is disposed.
|
||||
*/
|
||||
retain(selector: NormalizationSelector): Disposable;
|
||||
|
||||
/**
|
||||
* Subscribe to changes to the results of a selector. The callback is called
|
||||
* when `notify()` is called *and* records have been published that affect the
|
||||
* selector results relative to the last `notify()`.
|
||||
*/
|
||||
subscribe(snapshot: Snapshot, callback: (snapshot: Snapshot) => void): Disposable;
|
||||
|
||||
/**
|
||||
* The method should disable garbage collection until
|
||||
* the returned reference is disposed.
|
||||
*/
|
||||
holdGC(): Disposable;
|
||||
|
||||
lookupConnection_UNSTABLE<TEdge, TState>(
|
||||
connectionReference: ConnectionReference<TEdge>,
|
||||
resolver: ConnectionResolver<TEdge, TState>,
|
||||
): ConnectionSnapshot<TEdge, TState>;
|
||||
|
||||
subscribeConnection_UNSTABLE<TEdge, TState>(
|
||||
snapshot: ConnectionSnapshot<TEdge, TState>,
|
||||
resolver: ConnectionResolver<TEdge, TState>,
|
||||
callback: (state: TState) => void,
|
||||
): Disposable;
|
||||
|
||||
/**
|
||||
* Publish connection events, updating the store's list of events. As with
|
||||
* publish(), subscribers are only notified after notify() is called.
|
||||
*/
|
||||
publishConnectionEvents_UNSTABLE(events: ConnectionInternalEvent[], final: boolean): void;
|
||||
|
||||
/**
|
||||
* Get a read-only view of the store's internal connection events for a given
|
||||
* connection.
|
||||
*/
|
||||
getConnectionEvents_UNSTABLE(connectionID: ConnectionID): ReadonlyArray<ConnectionInternalEvent>;
|
||||
|
||||
/**
|
||||
* Record a backup/snapshot of the current state of the store, including
|
||||
* records and derived data such as fragment and connection subscriptions.
|
||||
* This state can be restored with restore().
|
||||
*/
|
||||
snapshot(): void;
|
||||
|
||||
/**
|
||||
* Reset the state of the store to the point that snapshot() was last called.
|
||||
*/
|
||||
restore(): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A type that accepts a callback and schedules it to run at some future time.
|
||||
* By convention, implementations should not execute the callback immediately.
|
||||
*/
|
||||
export type Scheduler = (callback: () => void) => void;
|
||||
|
||||
/**
|
||||
* An interface for imperatively getting/setting properties of a `Record`. This interface
|
||||
* is designed to allow the appearance of direct Record manipulation while
|
||||
* allowing different implementations that may e.g. create a changeset of
|
||||
* the modifications.
|
||||
*/
|
||||
export interface RecordProxy {
|
||||
copyFieldsFrom(source: RecordProxy): void;
|
||||
getDataID(): DataID;
|
||||
getLinkedRecord(name: string, args?: Variables): RecordProxy;
|
||||
getLinkedRecords(name: string, args?: Variables): RecordProxy[];
|
||||
getOrCreateLinkedRecord(name: string, typeName: string, args?: Variables): RecordProxy;
|
||||
getType(): string;
|
||||
getValue(name: string, args?: Variables): any;
|
||||
setLinkedRecord(record: RecordProxy, name: string, args?: Variables): RecordProxy;
|
||||
setLinkedRecords(records: RecordProxy[], name: string, args?: Variables): RecordProxy;
|
||||
setValue(value: any, name: string, args?: Variables): RecordProxy;
|
||||
}
|
||||
|
||||
export interface ReadOnlyRecordProxy {
|
||||
getDataID(): DataID;
|
||||
getLinkedRecord(name: string, args?: Variables): RecordProxy;
|
||||
getLinkedRecords(name: string, args?: Variables): RecordProxy[];
|
||||
getType(): string;
|
||||
getValue(name: string, args?: Variables): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* An interface for imperatively getting/setting properties of a `RecordSource`. This interface
|
||||
* is designed to allow the appearance of direct RecordSource manipulation while
|
||||
* allowing different implementations that may e.g. create a changeset of
|
||||
* the modifications.
|
||||
*/
|
||||
export interface RecordSourceProxy {
|
||||
create(dataID: DataID, typeName: string): RecordProxy;
|
||||
delete(dataID: DataID): void;
|
||||
get(dataID: DataID): RecordProxy;
|
||||
getRoot(): RecordProxy;
|
||||
}
|
||||
|
||||
export interface ReadOnlyRecordSourceProxy {
|
||||
get(dataID: DataID): ReadOnlyRecordProxy;
|
||||
getRoot(): ReadOnlyRecordProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extends the RecordSourceProxy interface with methods for accessing the root
|
||||
* fields of a Selector.
|
||||
*/
|
||||
export interface RecordSourceSelectorProxy extends RecordSourceProxy {
|
||||
getRootField(fieldName: string): RecordProxy;
|
||||
getPluralRootField(fieldName: string): RecordProxy[];
|
||||
insertConnectionEdge_UNSTABLE(connectionID: ConnectionID, args: Variables, edge: RecordProxy): void;
|
||||
}
|
||||
|
||||
export interface Logger {
|
||||
log(message: string, ...values: any[]): void;
|
||||
flushLogs(): void;
|
||||
}
|
||||
|
||||
export interface LoggerProvider {
|
||||
getLogger(config: LoggerTransactionConfig): Logger;
|
||||
}
|
||||
|
||||
export type LogEvent =
|
||||
| {
|
||||
name: string;
|
||||
transactionID: number;
|
||||
info: any;
|
||||
}
|
||||
| {
|
||||
name: string;
|
||||
transactionID: number;
|
||||
params: RequestParameters;
|
||||
variables: Variables;
|
||||
}
|
||||
| {
|
||||
name: string;
|
||||
transactionID: number;
|
||||
response: GraphQLResponse;
|
||||
}
|
||||
| {
|
||||
name: string;
|
||||
transactionID: number;
|
||||
error: Error;
|
||||
}
|
||||
| {
|
||||
name: string;
|
||||
transactionID: number;
|
||||
}
|
||||
| {
|
||||
name: string;
|
||||
transactionID: number;
|
||||
};
|
||||
export type LogFunction = (logEvent: LogEvent) => void;
|
||||
export type LogRequestInfoFunction = (arg: any) => void;
|
||||
|
||||
/**
|
||||
* The public API of Relay core. Represents an encapsulated environment with its
|
||||
* own in-memory cache.
|
||||
*/
|
||||
export interface Environment {
|
||||
/**
|
||||
* Determine if the selector can be resolved with data in the store (i.e. no
|
||||
* fields are missing).
|
||||
*
|
||||
* Note that this operation effectively "executes" the selector against the
|
||||
* cache and therefore takes time proportional to the size/complexity of the
|
||||
* selector.
|
||||
*/
|
||||
check(selector: NormalizationSelector): boolean;
|
||||
|
||||
/**
|
||||
* Subscribe to changes to the results of a selector. The callback is called
|
||||
* when data has been committed to the store that would cause the results of
|
||||
* the snapshot's selector to change.
|
||||
*/
|
||||
subscribe(snapshot: Snapshot, callback: (snapshot: Snapshot) => void): Disposable;
|
||||
|
||||
/**
|
||||
* Ensure that all the records necessary to fulfill the given selector are
|
||||
* retained in-memory. The records will not be eligible for garbage collection
|
||||
* until the returned reference is disposed.
|
||||
*/
|
||||
retain(selector: NormalizationSelector): Disposable;
|
||||
|
||||
/**
|
||||
* Apply an optimistic update to the environment. The mutation can be reverted
|
||||
* by calling `dispose()` on the returned value.
|
||||
*/
|
||||
applyUpdate(optimisticUpdate: OptimisticUpdateFunction): Disposable;
|
||||
|
||||
/**
|
||||
* Apply an optimistic mutation response and/or updater. The mutation can be
|
||||
* reverted by calling `dispose()` on the returned value.
|
||||
*/
|
||||
applyMutation(optimisticConfig: OptimisticResponseConfig): Disposable;
|
||||
|
||||
/**
|
||||
* Commit an updater to the environment. This mutation cannot be reverted and
|
||||
* should therefore not be used for optimistic updates. This is mainly
|
||||
* intended for updating fields from client schema extensions.
|
||||
*/
|
||||
commitUpdate(updater: StoreUpdater): void;
|
||||
|
||||
/**
|
||||
* Commit a payload to the environment using the given operation selector.
|
||||
*/
|
||||
commitPayload(operationDescriptor: OperationDescriptor, payload: PayloadData): void;
|
||||
|
||||
/**
|
||||
* Get the environment's internal Network.
|
||||
*/
|
||||
getNetwork(): Network;
|
||||
|
||||
/**
|
||||
* Get the environment's internal Store.
|
||||
*/
|
||||
getStore(): Store;
|
||||
|
||||
/**
|
||||
* Get an instance of a logger
|
||||
*/
|
||||
getLogger(config: LoggerTransactionConfig): Logger;
|
||||
|
||||
/**
|
||||
* Returns the environment specific OperationTracker.
|
||||
*/
|
||||
getOperationTracker(): RelayOperationTracker;
|
||||
|
||||
/**
|
||||
* Read the results of a selector from in-memory records in the store.
|
||||
* Optionally takes an owner, corresponding to the operation that
|
||||
* owns this selector (fragment).
|
||||
*/
|
||||
lookup(selector: SingularReaderSelector): Snapshot;
|
||||
|
||||
/**
|
||||
* Send a query to the server with Observer semantics: one or more
|
||||
* responses may be returned (via `next`) over time followed by either
|
||||
* the request completing (`completed`) or an error (`error`).
|
||||
*
|
||||
* Networks/servers that support subscriptions may choose to hold the
|
||||
* subscription open indefinitely such that `complete` is not called.
|
||||
*
|
||||
* Note: Observables are lazy, so calling this method will do nothing until
|
||||
* the result is subscribed to: environment.execute({...}).subscribe({...}).
|
||||
*/
|
||||
execute(config: {
|
||||
operation: OperationDescriptor;
|
||||
cacheConfig?: CacheConfig;
|
||||
updater?: SelectorStoreUpdater;
|
||||
}): RelayObservable<GraphQLResponse>;
|
||||
|
||||
/**
|
||||
* Returns an Observable of GraphQLResponse resulting from executing the
|
||||
* provided Mutation operation, the result of which is then normalized and
|
||||
* committed to the publish queue along with an optional optimistic response
|
||||
* or updater.
|
||||
*
|
||||
* Note: Observables are lazy, so calling this method will do nothing until
|
||||
* the result is subscribed to:
|
||||
* environment.executeMutation({...}).subscribe({...}).
|
||||
*/
|
||||
executeMutation({
|
||||
operation,
|
||||
optimisticUpdater,
|
||||
optimisticResponse,
|
||||
updater,
|
||||
uploadables,
|
||||
}: {
|
||||
operation: OperationDescriptor;
|
||||
optimisticUpdater?: SelectorStoreUpdater;
|
||||
optimisticResponse?: object;
|
||||
updater?: SelectorStoreUpdater;
|
||||
uploadables?: UploadableMap;
|
||||
}): RelayObservable<GraphQLResponse>;
|
||||
|
||||
/**
|
||||
* Returns an Observable of GraphQLResponse resulting from executing the
|
||||
* provided Query or Subscription operation responses, the result of which is
|
||||
* then normalized and comitted to the publish queue.
|
||||
*
|
||||
* Note: Observables are lazy, so calling this method will do nothing until
|
||||
* the result is subscribed to:
|
||||
* environment.executeWithSource({...}).subscribe({...}).
|
||||
*/
|
||||
executeWithSource({
|
||||
operation,
|
||||
source,
|
||||
}: {
|
||||
operation: OperationDescriptor;
|
||||
source: RelayObservable<GraphQLResponse>;
|
||||
}): RelayObservable<GraphQLResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* The results of reading data for a fragment. This is similar to a `Selector`,
|
||||
* but references the (fragment) node by name rather than by value.
|
||||
*/
|
||||
export interface FragmentPointer {
|
||||
__id: DataID;
|
||||
__fragments: { [fragmentName: string]: Variables };
|
||||
__fragmentOwner: RequestDescriptor;
|
||||
}
|
||||
|
||||
/**
|
||||
* The partial shape of an object with a '...Fragment @module(name: "...")'
|
||||
* selection
|
||||
*/
|
||||
export interface ModuleImportPointer {
|
||||
__fragmentPropName: string;
|
||||
__module_component: any;
|
||||
fragmentRefs: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* A callback for resolving a Selector from a source.
|
||||
*/
|
||||
export type AsyncLoadCallback = (loadingState: LoadingState) => void;
|
||||
export interface LoadingState {
|
||||
status: 'aborted' | 'complete' | 'error' | 'missing';
|
||||
error?: Error;
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of records affected by an update operation.
|
||||
*/
|
||||
export interface UpdatedRecords {
|
||||
[dataID: string]: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that updates a store (via a proxy) given the results of a "handle"
|
||||
* field payload.
|
||||
*/
|
||||
export class Handler {
|
||||
update: (store: RecordSourceProxy, fieldPayload: HandleFieldPayload) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* A payload that is used to initialize or update a "handle" field with
|
||||
* information from the server.
|
||||
*/
|
||||
export interface HandleFieldPayload {
|
||||
// The arguments that were fetched.
|
||||
args: Variables;
|
||||
// The __id of the record containing the source/handle field.
|
||||
dataID: DataID;
|
||||
// The (storage) key at which the original server data was written.
|
||||
fieldKey: string;
|
||||
// The name of the handle.
|
||||
handle: string;
|
||||
// The (storage) key at which the handle's data should be written by the
|
||||
// handler.
|
||||
handleKey: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A payload that represents data necessary to process the results of an object
|
||||
* with a `@module` fragment spread:
|
||||
* - data: The GraphQL response value for the @match field.
|
||||
* - dataID: The ID of the store object linked to by the @match field.
|
||||
* - operationReference: A reference to a generated module containing the
|
||||
* SplitOperation with which to normalize the field's `data`.
|
||||
* - variables: Query variables.
|
||||
* - typeName: the type that matched.
|
||||
*
|
||||
* The dataID, variables, and fragmentName can be used to create a Selector
|
||||
* which can in turn be used to normalize and publish the data. The dataID and
|
||||
* typeName can also be used to construct a root record for normalization.
|
||||
*/
|
||||
export interface ModuleImportPayload {
|
||||
data: PayloadData;
|
||||
dataID: DataID;
|
||||
operationReference: any;
|
||||
path: ReadonlyArray<string>;
|
||||
typeName: string;
|
||||
variables: Variables;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data emitted after processing a Defer or Stream node during normalization
|
||||
* that describes how to process the corresponding response chunk when it
|
||||
* arrives.
|
||||
*/
|
||||
export interface DeferPlaceholder {
|
||||
kind: 'defer';
|
||||
data: PayloadData;
|
||||
label: string;
|
||||
path: ReadonlyArray<string>;
|
||||
selector: NormalizationSelector;
|
||||
typeName: string;
|
||||
}
|
||||
export interface StreamPlaceholder {
|
||||
kind: 'stream';
|
||||
label: string;
|
||||
path: ReadonlyArray<string>;
|
||||
parentID: DataID;
|
||||
node: NormalizationSelectableNode;
|
||||
variables: Variables;
|
||||
}
|
||||
export type IncrementalDataPlaceholder = DeferPlaceholder | StreamPlaceholder;
|
||||
|
||||
/**
|
||||
* A user-supplied object to load a generated operation (SplitOperation) AST
|
||||
* by a module reference. The exact format of a module reference is left to
|
||||
* the application, but it must be a plain JavaScript value (string, number,
|
||||
* or object/array of same).
|
||||
*/
|
||||
export interface OperationLoader {
|
||||
/**
|
||||
* Synchronously load an operation, returning either the node or null if it
|
||||
* cannot be resolved synchronously.
|
||||
*/
|
||||
get(reference: any): NormalizationSplitOperation;
|
||||
|
||||
/**
|
||||
* Asynchronously load an operation.
|
||||
*/
|
||||
load(reference: any): Promise<NormalizationSplitOperation>;
|
||||
}
|
||||
|
||||
/**
|
||||
* A function that receives a proxy over the store and may trigger side-effects
|
||||
* (indirectly) by calling `set*` methods on the store or its record proxies.
|
||||
*/
|
||||
export type StoreUpdater = (store: RecordSourceProxy) => void;
|
||||
|
||||
/**
|
||||
* Similar to StoreUpdater, but accepts a proxy tied to a specific selector in
|
||||
* order to easily access the root fields of a query/mutation as well as a
|
||||
* second argument of the response object of the mutation.
|
||||
*/
|
||||
export type SelectorStoreUpdater<T = {}> = (store: RecordSourceSelectorProxy, data: T) => void;
|
||||
|
||||
/**
|
||||
* A set of configs that can be used to apply an optimistic update into the
|
||||
* store.
|
||||
*/
|
||||
export type OptimisticUpdate = OptimisticUpdateFunction | OptimisticUpdateRelayPayload;
|
||||
|
||||
export interface OptimisticUpdateFunction {
|
||||
storeUpdater: StoreUpdater;
|
||||
}
|
||||
|
||||
export interface OptimisticUpdateRelayPayload {
|
||||
operation: OperationDescriptor;
|
||||
payload: RelayResponsePayload;
|
||||
updater: SelectorStoreUpdater;
|
||||
}
|
||||
|
||||
export interface OptimisticResponseConfig {
|
||||
operation: OperationDescriptor;
|
||||
response: PayloadData;
|
||||
updater: SelectorStoreUpdater;
|
||||
}
|
||||
|
||||
/**
|
||||
* A set of handlers that can be used to provide substitute data for missing
|
||||
* fields when reading a selector from a source.
|
||||
*/
|
||||
export type MissingFieldHandler =
|
||||
| {
|
||||
kind: string;
|
||||
handle: (
|
||||
field: NormalizationScalarField,
|
||||
record: Record,
|
||||
args: Variables,
|
||||
store: ReadOnlyRecordSourceProxy,
|
||||
) => any;
|
||||
}
|
||||
| {
|
||||
kind: string;
|
||||
handle: (
|
||||
field: NormalizationLinkedField,
|
||||
record: Record,
|
||||
args: Variables,
|
||||
store: ReadOnlyRecordSourceProxy,
|
||||
) => DataID;
|
||||
}
|
||||
| {
|
||||
kind: string;
|
||||
handle: (
|
||||
field: NormalizationLinkedField,
|
||||
record: Record,
|
||||
args: Variables,
|
||||
store: ReadOnlyRecordSourceProxy,
|
||||
) => DataID[];
|
||||
};
|
||||
|
||||
/**
|
||||
* The results of normalizing a query.
|
||||
*/
|
||||
export interface RelayResponsePayload {
|
||||
connectionEvents: ConnectionInternalEvent[];
|
||||
errors: PayloadError[];
|
||||
fieldPayloads: HandleFieldPayload[];
|
||||
incrementalPlaceholders: IncrementalDataPlaceholder[];
|
||||
moduleImportPayloads: ModuleImportPayload[];
|
||||
source: MutableRecordSource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public interface for Publish Queue
|
||||
*/
|
||||
export interface PublishQueue {
|
||||
/**
|
||||
* Schedule applying an optimistic updates on the next `run()`.
|
||||
*/
|
||||
applyUpdate(updater: OptimisticUpdate): void;
|
||||
|
||||
/**
|
||||
* Schedule reverting an optimistic updates on the next `run()`.
|
||||
*/
|
||||
revertUpdate(updater: OptimisticUpdate): void;
|
||||
|
||||
/**
|
||||
* Schedule a revert of all optimistic updates on the next `run()`.
|
||||
*/
|
||||
revertAll(): void;
|
||||
|
||||
/**
|
||||
* Schedule applying a payload to the store on the next `run()`.
|
||||
*/
|
||||
commitPayload(operation: OperationDescriptor, payload: RelayResponsePayload, updater?: SelectorStoreUpdater): void;
|
||||
|
||||
/**
|
||||
* Schedule an updater to mutate the store on the next `run()` typically to
|
||||
* update client schema fields.
|
||||
*/
|
||||
commitUpdate(updater: StoreUpdater): void;
|
||||
|
||||
/**
|
||||
* Schedule a publish to the store from the provided source on the next
|
||||
* `run()`. As an example, to update the store with substituted fields that
|
||||
* are missing in the store.
|
||||
*/
|
||||
commitSource(source: RecordSource): void;
|
||||
|
||||
/**
|
||||
* Execute all queued up operations from the other public methods.
|
||||
*/
|
||||
run(): ReadonlyArray<RequestDescriptor>;
|
||||
}
|
||||
79
types/relay-runtime/lib/store/RelayStoreUtils.d.ts
vendored
Normal file
79
types/relay-runtime/lib/store/RelayStoreUtils.d.ts
vendored
Normal file
@@ -0,0 +1,79 @@
|
||||
import { NormalizationArgument, NormalizationHandle, NormalizationField } from '../util/NormalizationNode';
|
||||
import { ReaderArgument, ReaderField } from '../util/ReaderNode';
|
||||
import { Variables } from '../util/RelayRuntimeTypes';
|
||||
|
||||
export interface Arguments {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the values of field/fragment arguments as an object keyed by argument
|
||||
* names. Guaranteed to return a result with stable ordered nested values.
|
||||
*/
|
||||
export function getArgumentValues(
|
||||
args: ReadonlyArray<NormalizationArgument | ReaderArgument>,
|
||||
variables: Variables,
|
||||
): Arguments;
|
||||
|
||||
/**
|
||||
* Given a handle field and variable values, returns a key that can be used to
|
||||
* uniquely identify the combination of the handle name and argument values.
|
||||
*
|
||||
* Note: the word "storage" here refers to the fact this key is primarily used
|
||||
* when writing the results of a key in a normalized graph or "store". This
|
||||
* name was used in previous implementations of Relay internals and is also
|
||||
* used here for consistency.
|
||||
*/
|
||||
export function getHandleStorageKey(handleField: NormalizationHandle, variables: Variables): string;
|
||||
|
||||
/**
|
||||
* Given a field and variable values, returns a key that can be used to
|
||||
* uniquely identify the combination of the field name and argument values.
|
||||
*
|
||||
* Note: the word "storage" here refers to the fact this key is primarily used
|
||||
* when writing the results of a key in a normalized graph or "store". This
|
||||
* name was used in previous implementations of Relay internals and is also
|
||||
* used here for consistency.
|
||||
*/
|
||||
export function getStorageKey(
|
||||
field: NormalizationField | NormalizationHandle | ReaderField,
|
||||
variables: Variables,
|
||||
): string;
|
||||
|
||||
/**
|
||||
* Given a `name` (eg. "foo") and an object representing argument values
|
||||
* (eg. `{orberBy: "name", first: 10}`) returns a unique storage key
|
||||
* (ie. `foo{"first":10,"orderBy":"name"}`).
|
||||
*
|
||||
* This differs from getStorageKey which requires a ConcreteNode where arguments
|
||||
* are assumed to already be sorted into a stable order.
|
||||
*/
|
||||
export function getStableStorageKey(name: string, args: Arguments): string;
|
||||
|
||||
/**
|
||||
* Given a name and argument values, format a storage key.
|
||||
*
|
||||
* Arguments and the values within them are expected to be ordered in a stable
|
||||
* alphabetical ordering.
|
||||
*/
|
||||
export function formatStorageKey(name: string, argValues: Arguments): string;
|
||||
|
||||
/**
|
||||
* Given Variables and a variable name, return a variable value with
|
||||
* all values in a stable order.
|
||||
*/
|
||||
export function getStableVariableValue(name: string, variables: Variables): unknown;
|
||||
|
||||
export function getModuleComponentKey(documentName: string): string;
|
||||
export function getModuleOperationKey(documentName: string): string;
|
||||
|
||||
export const FRAGMENTS_KEY: string;
|
||||
export const FRAGMENT_OWNER_KEY: string;
|
||||
export const FRAGMENT_PROP_NAME_KEY: string;
|
||||
export const MODULE_COMPONENT_KEY: string; // alias returned by Reader
|
||||
export const ID_KEY: string;
|
||||
export const REF_KEY: string;
|
||||
export const REFS_KEY: string;
|
||||
export const ROOT_ID: string;
|
||||
export const ROOT_TYPE: string;
|
||||
export const TYPENAME_KEY: string;
|
||||
9
types/relay-runtime/lib/store/createFragmentSpecResolver.d.ts
vendored
Normal file
9
types/relay-runtime/lib/store/createFragmentSpecResolver.d.ts
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
import { RelayContext, FragmentMap, Props, FragmentSpecResolver } from './RelayStoreTypes';
|
||||
|
||||
export function createFragmentSpecResolver(
|
||||
context: RelayContext,
|
||||
containerName: string,
|
||||
fragments: FragmentMap,
|
||||
props: Props,
|
||||
callback?: () => void,
|
||||
): FragmentSpecResolver;
|
||||
1
types/relay-runtime/lib/store/isRelayModernEnvironment.d.ts
vendored
Normal file
1
types/relay-runtime/lib/store/isRelayModernEnvironment.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function isRelayModernEnvironment(environment: any): boolean;
|
||||
20
types/relay-runtime/lib/subscription/requestSubscription.d.ts
vendored
Normal file
20
types/relay-runtime/lib/subscription/requestSubscription.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import { DeclarativeMutationConfig } from '../mutations/RelayDeclarativeMutationConfig';
|
||||
import { GraphQLTaggedNode } from '../query/RelayModernGraphQLTag';
|
||||
import { Variables, Disposable } from '../util/RelayRuntimeTypes';
|
||||
import { SelectorStoreUpdater, Environment } from '../store/RelayStoreTypes';
|
||||
|
||||
export interface GraphQLSubscriptionConfig<TSubscriptionPayload> {
|
||||
configs?: ReadonlyArray<DeclarativeMutationConfig>;
|
||||
subscription: GraphQLTaggedNode;
|
||||
variables: Variables;
|
||||
onCompleted?: () => void;
|
||||
onError?: (error: Error) => void;
|
||||
onNext?: (response: TSubscriptionPayload | null | undefined) => void;
|
||||
updater?: SelectorStoreUpdater;
|
||||
}
|
||||
|
||||
export function requestSubscription<TSubscriptionPayload>(
|
||||
environment: Environment,
|
||||
// tslint:disable-next-line no-unnecessary-generics
|
||||
config: GraphQLSubscriptionConfig<TSubscriptionPayload>,
|
||||
): Disposable;
|
||||
@@ -94,6 +94,29 @@ export interface NormalizationVariable {
|
||||
readonly variableName: string;
|
||||
}
|
||||
|
||||
export interface NormalizationConnection {
|
||||
kind: string;
|
||||
label: string;
|
||||
name: string;
|
||||
args: ReadonlyArray<NormalizationArgument>;
|
||||
edges: NormalizationLinkedField;
|
||||
pageInfo: NormalizationLinkedField;
|
||||
}
|
||||
|
||||
export interface NormalizationLocalArgumentDefinition {
|
||||
kind: string;
|
||||
name: string;
|
||||
type: string;
|
||||
defaultValue: any;
|
||||
}
|
||||
|
||||
export interface NormalizationModuleImport {
|
||||
kind: string;
|
||||
documentName: string;
|
||||
fragmentPropName: string;
|
||||
fragmentName: string;
|
||||
}
|
||||
|
||||
export interface NormalizationLocalArgument {
|
||||
readonly kind: string; // 'LocalArgument';
|
||||
readonly name: string;
|
||||
|
||||
22
types/relay-runtime/lib/util/ReaderNode.d.ts
vendored
22
types/relay-runtime/lib/util/ReaderNode.d.ts
vendored
@@ -162,3 +162,25 @@ export interface ReaderPaginationFragment extends ReaderFragment {
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface ReaderConnection {
|
||||
readonly kind: string;
|
||||
readonly label: string;
|
||||
readonly name: string;
|
||||
readonly args: ReadonlyArray<ReaderArgument>;
|
||||
readonly edges: ReaderLinkedField;
|
||||
readonly pageInfo: ReaderLinkedField;
|
||||
}
|
||||
|
||||
export interface ReaderInlineDataFragmentSpread {
|
||||
readonly kind: string;
|
||||
readonly name: string;
|
||||
readonly selections: ReadonlyArray<ReaderSelection>;
|
||||
}
|
||||
|
||||
export interface ReaderModuleImport {
|
||||
readonly kind: string;
|
||||
readonly documentName: string;
|
||||
readonly fragmentPropName: string;
|
||||
readonly fragmentName: string;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface RequestParameters {
|
||||
readonly metadata: { [key: string]: unknown };
|
||||
}
|
||||
|
||||
declare const RelayConcreteNode: {
|
||||
export const RelayConcreteNode: {
|
||||
CONDITION: 'Condition';
|
||||
CLIENT_EXTENSION: 'ClientExtension';
|
||||
DEFER: 'Defer';
|
||||
@@ -42,5 +42,3 @@ declare const RelayConcreteNode: {
|
||||
STREAM: 'Stream';
|
||||
VARIABLE: 'Variable';
|
||||
};
|
||||
|
||||
export default RelayConcreteNode;
|
||||
|
||||
8
types/relay-runtime/lib/util/RelayFeatureFlags.d.ts
vendored
Normal file
8
types/relay-runtime/lib/util/RelayFeatureFlags.d.ts
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
export interface FeatureFlags {
|
||||
ENABLE_VARIABLE_CONNECTION_KEY: boolean;
|
||||
ENABLE_CONNECTION_RESOLVERS: boolean;
|
||||
ENABLE_PARTIAL_RENDERING_DEFAULT: boolean;
|
||||
USE_RECORD_SOURCE_MAP_IMPL: boolean;
|
||||
}
|
||||
|
||||
export const RelayFeatureFlags: FeatureFlags;
|
||||
115
types/relay-runtime/lib/util/RelayProfiler.d.ts
vendored
Normal file
115
types/relay-runtime/lib/util/RelayProfiler.d.ts
vendored
Normal file
@@ -0,0 +1,115 @@
|
||||
export type Handler = (name: string, callback: () => void) => void;
|
||||
export type ProfileHandler = (name: string, state?: any) => (error?: Error) => void;
|
||||
|
||||
/**
|
||||
* Instruments methods to allow profiling various parts of Relay. Profiling code
|
||||
* in Relay consists of three steps:
|
||||
*
|
||||
* - Instrument the function to be profiled.
|
||||
* - Attach handlers to the instrumented function.
|
||||
* - Run the code which triggers the handlers.
|
||||
*
|
||||
* Handlers attached to instrumented methods are called with an instrumentation
|
||||
* name and a callback that must be synchronously executed:
|
||||
*
|
||||
* instrumentedMethod.attachHandler(function(name, callback) {
|
||||
* const start = performance.now();
|
||||
* callback();
|
||||
* console.log('Duration', performance.now() - start);
|
||||
* });
|
||||
*
|
||||
* Handlers for profiles are callbacks that return a stop method:
|
||||
*
|
||||
* RelayProfiler.attachProfileHandler('profileName', (name, state) => {
|
||||
* const start = performance.now();
|
||||
* return function stop(name, state) {
|
||||
* console.log(`Duration (${name})`, performance.now() - start);
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* In order to reduce the impact on performance in production, instrumented
|
||||
* methods and profilers with names that begin with `@` will only be measured
|
||||
* if `__DEV__` is true. This should be used for very hot functions.
|
||||
*/
|
||||
|
||||
export const RelayProfiler: {
|
||||
/**
|
||||
* Instruments methods on a class or object. This re-assigns the method in
|
||||
* order to preserve function names in stack traces (which are detected by
|
||||
* modern debuggers via heuristics). Example usage:
|
||||
*
|
||||
* const RelayStore = { primeCache: function() {...} };
|
||||
* RelayProfiler.instrumentMethods(RelayStore, {
|
||||
* primeCache: 'RelayStore.primeCache'
|
||||
* });
|
||||
*
|
||||
* RelayStore.primeCache.attachHandler(...);
|
||||
*
|
||||
* As a result, the methods will be replaced by wrappers that provide the
|
||||
* `attachHandler` and `detachHandler` methods.
|
||||
*/
|
||||
instrumentMethods(object: () => void | object, names: { [key: string]: string }): void;
|
||||
|
||||
/**
|
||||
* Wraps the supplied function with one that provides the `attachHandler` and
|
||||
* `detachHandler` methods. Example usage:
|
||||
*
|
||||
* const printRelayQuery =
|
||||
* RelayProfiler.instrument('printRelayQuery', printRelayQuery);
|
||||
*
|
||||
* printRelayQuery.attachHandler(...);
|
||||
*
|
||||
* NOTE: The instrumentation assumes that no handlers are attached or detached
|
||||
* in the course of executing another handler.
|
||||
*/
|
||||
instrument<T extends () => void>(name: string, originalFunction: T): T;
|
||||
|
||||
/**
|
||||
* Attaches a handler to all methods instrumented with the supplied name.
|
||||
*
|
||||
* function createRenderer() {
|
||||
* return RelayProfiler.instrument('render', function() {...});
|
||||
* }
|
||||
* const renderA = createRenderer();
|
||||
* const renderB = createRenderer();
|
||||
*
|
||||
* // Only profiles `renderA`.
|
||||
* renderA.attachHandler(...);
|
||||
*
|
||||
* // Profiles both `renderA` and `renderB`.
|
||||
* RelayProfiler.attachAggregateHandler('render', ...);
|
||||
*
|
||||
*/
|
||||
attachAggregateHandler(name: string, handler: Handler): void;
|
||||
|
||||
/**
|
||||
* Detaches a handler attached via `attachAggregateHandler`.
|
||||
*/
|
||||
detachAggregateHandler(name: string, handler: Handler): void;
|
||||
|
||||
/**
|
||||
* Instruments profiling for arbitrarily asynchronous code by a name.
|
||||
*
|
||||
* const timerProfiler = RelayProfiler.profile('timeout');
|
||||
* setTimeout(function() {
|
||||
* timerProfiler.stop();
|
||||
* }, 1000);
|
||||
*
|
||||
* RelayProfiler.attachProfileHandler('timeout', ...);
|
||||
*
|
||||
* Arbitrary state can also be passed into `profile` as a second argument. The
|
||||
* attached profile handlers will receive this as the second argument.
|
||||
*/
|
||||
profile(name: string, state?: any): { stop: (error?: Error) => void };
|
||||
|
||||
/**
|
||||
* Attaches a handler to profiles with the supplied name. You can also
|
||||
* attach to the special name '*' which is a catch all.
|
||||
*/
|
||||
attachProfileHandler(name: string, handler: ProfileHandler): void;
|
||||
|
||||
/**
|
||||
* Detaches a handler attached via `attachProfileHandler`.
|
||||
*/
|
||||
detachProfileHandler(name: string, handler: ProfileHandler): void;
|
||||
};
|
||||
41
types/relay-runtime/lib/util/RelayRuntimeTypes.d.ts
vendored
Normal file
41
types/relay-runtime/lib/util/RelayRuntimeTypes.d.ts
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Represents any resource that must be explicitly disposed of. The most common
|
||||
* use-case is as a return value for subscriptions, where calling `dispose()`
|
||||
* would cancel the subscription.
|
||||
*/
|
||||
export interface Disposable {
|
||||
dispose(): void;
|
||||
}
|
||||
|
||||
export type DataID = string;
|
||||
|
||||
// Variables
|
||||
export interface Variables {
|
||||
[name: string]: any;
|
||||
}
|
||||
|
||||
export interface OperationType {
|
||||
readonly variables: Variables;
|
||||
readonly response: unknown;
|
||||
}
|
||||
|
||||
/**
|
||||
* Settings for how a query response may be cached.
|
||||
*
|
||||
* - `force`: causes a query to be issued unconditionally, irrespective of the
|
||||
* state of any configured response cache.
|
||||
* - `poll`: causes a query to live update by polling at the specified interval
|
||||
* in milliseconds. (This value will be passed to setTimeout.)
|
||||
* - `liveConfigId`: causes a query to live update by calling GraphQLLiveQuery,
|
||||
* it represents a configuration of gateway when doing live query
|
||||
* - `metadata`: user-supplied metadata.
|
||||
* - `transactionId`: a user-supplied value, intended for use as a unique id for
|
||||
* a given instance of executing an operation.
|
||||
*/
|
||||
export interface CacheConfig {
|
||||
force?: boolean | null;
|
||||
poll?: number | null;
|
||||
liveConfigId?: string | null;
|
||||
metadata?: { [key: string]: unknown };
|
||||
transactionId?: string | null;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user