mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
Merge branch 'master' into office-js-in-preview
This commit is contained in:
+1
-1
@@ -1567,7 +1567,7 @@
|
||||
/types/hapi/v12/ @jasonswearingen
|
||||
/types/hapi/v15/ @jasonswearingen
|
||||
/types/hapi/v16/ @jasonswearingen @AJamesPhillips
|
||||
/types/hapi/ @BorntraegerMarc @rafaelsouzaf @jhsimms @SimonSchick
|
||||
/types/hapi/ @rafaelsouzaf @jhsimms @SimonSchick
|
||||
/types/hapi-auth-basic/ @AJamesPhillips @saboya
|
||||
/types/hapi-auth-jwt2/v7/ @warrenseymour
|
||||
/types/hapi-auth-jwt2/ @warrenseymour @SimonSchick
|
||||
|
||||
@@ -40,3 +40,7 @@ function testPromiseRejection() {
|
||||
return value.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function testGithubTicket28081Regression() {
|
||||
Promise.resolve([3]).map((n: number) => true);
|
||||
}
|
||||
|
||||
Vendored
+46
-46
@@ -67,52 +67,52 @@ declare global {
|
||||
* Patch all instance method
|
||||
*/
|
||||
interface Promise<T> {
|
||||
all: typeof Bluebird.prototype.all;
|
||||
any: typeof Bluebird.prototype.any;
|
||||
asCallback: typeof Bluebird.prototype.asCallback;
|
||||
bind: typeof Bluebird.prototype.bind;
|
||||
call: typeof Bluebird.prototype.call;
|
||||
cancel: typeof Bluebird.prototype.cancel;
|
||||
// catch: typeof Bluebird.prototype.catch;
|
||||
caught: typeof Bluebird.prototype.caught;
|
||||
delay: typeof Bluebird.prototype.delay;
|
||||
disposer: typeof Bluebird.prototype.disposer;
|
||||
done: typeof Bluebird.prototype.done;
|
||||
each: typeof Bluebird.prototype.each;
|
||||
error: typeof Bluebird.prototype.error;
|
||||
filter: typeof Bluebird.prototype.filter;
|
||||
// finally: typeof Bluebird.prototype.finally;
|
||||
get: typeof Bluebird.prototype.get;
|
||||
isCancelled: typeof Bluebird.prototype.isCancelled;
|
||||
isFulfilled: typeof Bluebird.prototype.isFulfilled;
|
||||
isPending: typeof Bluebird.prototype.isPending;
|
||||
isRejected: typeof Bluebird.prototype.isRejected;
|
||||
isResolved: typeof Bluebird.prototype.isResolved;
|
||||
lastly: typeof Bluebird.prototype.lastly;
|
||||
map: typeof Bluebird.prototype.map;
|
||||
mapSeries: typeof Bluebird.prototype.mapSeries;
|
||||
nodeify: typeof Bluebird.prototype.nodeify;
|
||||
props: typeof Bluebird.prototype.props;
|
||||
race: typeof Bluebird.prototype.race;
|
||||
reason: typeof Bluebird.prototype.reason;
|
||||
reduce: typeof Bluebird.prototype.reduce;
|
||||
reflect: typeof Bluebird.prototype.reflect;
|
||||
return: typeof Bluebird.prototype.return;
|
||||
some: typeof Bluebird.prototype.some;
|
||||
spread: typeof Bluebird.prototype.spread;
|
||||
suppressUnhandledRejections: typeof Bluebird.prototype.suppressUnhandledRejections;
|
||||
tap: typeof Bluebird.prototype.tap;
|
||||
tapCatch: typeof Bluebird.prototype.tapCatch;
|
||||
// then: typeof Bluebird.prototype.then;
|
||||
thenReturn: typeof Bluebird.prototype.thenReturn;
|
||||
thenThrow: typeof Bluebird.prototype.thenThrow;
|
||||
catchReturn: typeof Bluebird.prototype.catchReturn;
|
||||
catchThrow: typeof Bluebird.prototype.catchThrow;
|
||||
throw: typeof Bluebird.prototype.throw;
|
||||
timeout: typeof Bluebird.prototype.timeout;
|
||||
toJSON: typeof Bluebird.prototype.toJSON;
|
||||
toString: typeof Bluebird.prototype.toString;
|
||||
value: typeof Bluebird.prototype.value;
|
||||
all: Bluebird<T>["all"];
|
||||
any: Bluebird<T>["any"];
|
||||
asCallback: Bluebird<T>["asCallback"];
|
||||
bind: Bluebird<T>["bind"];
|
||||
call: Bluebird<T>["call"];
|
||||
cancel: Bluebird<T>["cancel"];
|
||||
// catch: Bluebird<T>["catch"];
|
||||
caught: Bluebird<T>["caught"];
|
||||
delay: Bluebird<T>["delay"];
|
||||
disposer: Bluebird<T>["disposer"];
|
||||
done: Bluebird<T>["done"];
|
||||
each: Bluebird<T>["each"];
|
||||
error: Bluebird<T>["error"];
|
||||
filter: Bluebird<T>["filter"];
|
||||
// finally: Bluebird<T>["finally"];
|
||||
get: Bluebird<T>["get"];
|
||||
isCancelled: Bluebird<T>["isCancelled"];
|
||||
isFulfilled: Bluebird<T>["isFulfilled"];
|
||||
isPending: Bluebird<T>["isPending"];
|
||||
isRejected: Bluebird<T>["isRejected"];
|
||||
isResolved: Bluebird<T>["isResolved"];
|
||||
lastly: Bluebird<T>["lastly"];
|
||||
map: Bluebird<T>["map"];
|
||||
mapSeries: Bluebird<T>["mapSeries"];
|
||||
nodeify: Bluebird<T>["nodeify"];
|
||||
props: Bluebird<T>["props"];
|
||||
race: Bluebird<T>["race"];
|
||||
reason: Bluebird<T>["reason"];
|
||||
reduce: Bluebird<T>["reduce"];
|
||||
reflect: Bluebird<T>["reflect"];
|
||||
return: Bluebird<T>["return"];
|
||||
some: Bluebird<T>["some"];
|
||||
spread: Bluebird<T>["spread"];
|
||||
suppressUnhandledRejections: Bluebird<T>["suppressUnhandledRejections"];
|
||||
tap: Bluebird<T>["tap"];
|
||||
tapCatch: Bluebird<T>["tapCatch"];
|
||||
// then: Bluebird<T>["then"];
|
||||
thenReturn: Bluebird<T>["thenReturn"];
|
||||
thenThrow: Bluebird<T>["thenThrow"];
|
||||
catchReturn: Bluebird<T>["catchReturn"];
|
||||
catchThrow: Bluebird<T>["catchThrow"];
|
||||
throw: Bluebird<T>["throw"];
|
||||
timeout: Bluebird<T>["timeout"];
|
||||
toJSON: Bluebird<T>["toJSON"];
|
||||
toString: Bluebird<T>["toString"];
|
||||
value: Bluebird<T>["value"];
|
||||
|
||||
/*
|
||||
* Copy&paste ::then and ::catch from lib.es2015.promise.d.ts, because Bluebird's typings are not
|
||||
|
||||
@@ -452,6 +452,7 @@ function gauge_examples() {
|
||||
max: 100,
|
||||
units: " %",
|
||||
width: 10,
|
||||
fullCircle: true,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+6
@@ -276,6 +276,12 @@ export interface ChartConfiguration {
|
||||
* Set width of gauge chart.
|
||||
*/
|
||||
width?: number;
|
||||
/**
|
||||
* Whether this should be displayed
|
||||
* as a full circle instead of a
|
||||
* half circle.
|
||||
*/
|
||||
fullCircle?: boolean;
|
||||
};
|
||||
|
||||
spline?: {
|
||||
|
||||
Vendored
+1
@@ -4959,6 +4959,7 @@ declare namespace chrome.runtime {
|
||||
|
||||
export interface ConnectInfo {
|
||||
name?: string;
|
||||
includeTlsChannelId?: boolean;
|
||||
}
|
||||
|
||||
export interface InstalledDetails {
|
||||
|
||||
Vendored
+11
-6
@@ -15,7 +15,7 @@ declare function CodeMirror(callback: (host: HTMLElement) => void , options?: Co
|
||||
declare namespace CodeMirror {
|
||||
export var Doc : CodeMirror.DocConstructor;
|
||||
export var Pos: CodeMirror.PositionConstructor;
|
||||
export var Pass: any;
|
||||
export var Pass: {toString(): "CodeMirror.PASS"};
|
||||
|
||||
function countColumn(line: string, index: number | null, tabSize: number): number;
|
||||
function fromTextArea(host: HTMLTextAreaElement, options?: EditorConfiguration): CodeMirror.EditorFromTextArea;
|
||||
@@ -129,6 +129,10 @@ declare namespace CodeMirror {
|
||||
state: any;
|
||||
}
|
||||
|
||||
interface KeyMap {
|
||||
[keyName: string]: false | string | ((instance: Editor) => void | typeof Pass);
|
||||
}
|
||||
|
||||
interface Editor {
|
||||
|
||||
/** Tells you whether the editor currently has focus. */
|
||||
@@ -159,11 +163,11 @@ declare namespace CodeMirror {
|
||||
Maps added in this way have a higher precedence than the extraKeys and keyMap options, and between them,
|
||||
the maps added earlier have a lower precedence than those added later, unless the bottom argument was passed,
|
||||
in which case they end up below other keymaps added with this method. */
|
||||
addKeyMap(map: any, bottom?: boolean): void;
|
||||
addKeyMap(map: string | KeyMap, bottom?: boolean): void;
|
||||
|
||||
/** Disable a keymap added with addKeyMap.Either pass in the keymap object itself , or a string,
|
||||
which will be compared against the name property of the active keymaps. */
|
||||
removeKeyMap(map: any): void;
|
||||
removeKeyMap(map: string | KeyMap): void;
|
||||
|
||||
/** Enable a highlighting overlay.This is a stateless mini - mode that can be used to add extra highlighting.
|
||||
For example, the search add - on uses it to highlight the term that's currently being searched.
|
||||
@@ -716,8 +720,9 @@ declare namespace CodeMirror {
|
||||
}
|
||||
|
||||
interface EditorChangeCancellable extends CodeMirror.EditorChange {
|
||||
/** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact. */
|
||||
update(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void;
|
||||
/** may be used to modify the change. All three arguments to update are optional, and can be left off to leave the existing value for that field intact.
|
||||
If the change came from undo/redo, `update` is undefined and the change cannot be modified. */
|
||||
update?(from?: CodeMirror.Position, to?: CodeMirror.Position, text?: string[]): void;
|
||||
|
||||
cancel(): void;
|
||||
}
|
||||
@@ -780,7 +785,7 @@ declare namespace CodeMirror {
|
||||
keyMap?: string;
|
||||
|
||||
/** Can be used to specify extra keybindings for the editor, alongside the ones defined by keyMap. Should be either null, or a valid keymap value. */
|
||||
extraKeys?: any;
|
||||
extraKeys?: string | KeyMap;
|
||||
|
||||
/** Whether CodeMirror should scroll or wrap for long lines. Defaults to false (scroll). */
|
||||
lineWrapping?: boolean;
|
||||
|
||||
@@ -4,7 +4,18 @@ var myCodeMirror: CodeMirror.Editor = CodeMirror(document.body);
|
||||
|
||||
var myCodeMirror2: CodeMirror.Editor = CodeMirror(document.body, {
|
||||
value: "function myScript(){return 100;}\n",
|
||||
mode: "javascript"
|
||||
mode: "javascript",
|
||||
extraKeys: {
|
||||
Enter: (cm) => { console.log("save"); },
|
||||
Esc: (cm) => { return CodeMirror.Pass; }
|
||||
}
|
||||
});
|
||||
|
||||
// $ExpectError
|
||||
var myCodeMirror2_1: CodeMirror.Editor = CodeMirror(document.body, {
|
||||
extraKeys: {
|
||||
"Shift-Enter": (cm) => { return 42; } // not a valid return value
|
||||
}
|
||||
});
|
||||
|
||||
var range = myCodeMirror2.findWordAt(CodeMirror.Pos(0, 2));
|
||||
@@ -13,9 +24,9 @@ var head = range.head;
|
||||
var from = range.from();
|
||||
var to = range.to();
|
||||
|
||||
var myTextArea: HTMLTextAreaElement;
|
||||
var myTextArea: HTMLTextAreaElement = undefined!;
|
||||
var myCodeMirror3: CodeMirror.Editor = CodeMirror(function (elt) {
|
||||
myTextArea.parentNode.replaceChild(elt, myTextArea);
|
||||
myTextArea.parentNode!.replaceChild(elt, myTextArea);
|
||||
}, { value: myTextArea.value });
|
||||
|
||||
var myCodeMirror4: CodeMirror.Editor = CodeMirror.fromTextArea(myTextArea);
|
||||
@@ -67,6 +78,15 @@ myCodeMirror.on(
|
||||
(instance: CodeMirror.Editor, line: CodeMirror.LineHandle, element: HTMLElement) => { }
|
||||
);
|
||||
|
||||
myCodeMirror.on(
|
||||
"beforeChange",
|
||||
(instance: CodeMirror.Editor, change: CodeMirror.EditorChangeCancellable) => {
|
||||
// $ExpectError
|
||||
change.update();
|
||||
if (change.update != null) change.update();
|
||||
}
|
||||
);
|
||||
|
||||
CodeMirror.registerHelper("lint", "javascript", {});
|
||||
|
||||
myCodeMirror.isReadOnly();
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": false,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
|
||||
Vendored
+1
-1
@@ -61,7 +61,7 @@ interface CopyWebpackPluginConfiguration {
|
||||
}
|
||||
|
||||
interface CopyWebpackPlugin {
|
||||
new (patterns?: CopyPattern[], options?: CopyWebpackPluginConfiguration): Plugin
|
||||
new (patterns?: (string | CopyPattern)[], options?: CopyWebpackPluginConfiguration): Plugin
|
||||
}
|
||||
|
||||
declare const copyWebpackPlugin: CopyWebpackPlugin
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"styled-components": "^3.3.2"
|
||||
"opentracing": ">=0.14.1"
|
||||
}
|
||||
}
|
||||
-29
@@ -1,29 +0,0 @@
|
||||
import Span = require('./span');
|
||||
import SpanContext = require('./span_context');
|
||||
|
||||
declare class Reference {
|
||||
/**
|
||||
* @return The Reference type (e.g., REFERENCE_CHILD_OF or
|
||||
* REFERENCE_FOLLOWS_FROM).
|
||||
*/
|
||||
type(): string;
|
||||
|
||||
/**
|
||||
* @return The SpanContext being referred to (e.g., the
|
||||
* parent in a REFERENCE_CHILD_OF Reference).
|
||||
*/
|
||||
referencedContext(): SpanContext;
|
||||
|
||||
/**
|
||||
* Initialize a new Reference instance.
|
||||
*
|
||||
* @param type - the Reference type constant (e.g.,
|
||||
* REFERENCE_CHILD_OF or REFERENCE_FOLLOWS_FROM).
|
||||
* @param referencedContext - the SpanContext being referred
|
||||
* to. As a convenience, a Span instance may be passed in instead
|
||||
* (in which case its .context() is used here).
|
||||
*/
|
||||
constructor(type: string, referencedContext: SpanContext | Span);
|
||||
}
|
||||
|
||||
export = Reference;
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
import Tracer = require('./tracer');
|
||||
import SpanContext = require('./span_context');
|
||||
import { Span } from 'opentracing';
|
||||
|
||||
declare class Span {
|
||||
declare class DatadogSpan extends Span {
|
||||
/**
|
||||
* Returns the SpanContext object associated with this Span.
|
||||
*/
|
||||
@@ -117,4 +118,4 @@ declare class Span {
|
||||
finish(finishTime?: number): void;
|
||||
}
|
||||
|
||||
export = Span;
|
||||
export = DatadogSpan;
|
||||
|
||||
+4
-2
@@ -1,3 +1,5 @@
|
||||
import { SpanContext } from 'opentracing';
|
||||
|
||||
/**
|
||||
* SpanContext represents Span state that must propagate to descendant Spans
|
||||
* and across process boundaries.
|
||||
@@ -8,7 +10,7 @@
|
||||
* identify or otherwise contextualize the associated Span instance (e.g., a
|
||||
* <trace_id, span_id, sampled> tuple).
|
||||
*/
|
||||
declare class SpanContext {
|
||||
declare class DatadogSpanContext extends SpanContext {
|
||||
/**
|
||||
* Use to create references to parent spans.
|
||||
*/
|
||||
@@ -35,4 +37,4 @@ interface SpanContextLike {
|
||||
spanId: number;
|
||||
}
|
||||
|
||||
export = SpanContext;
|
||||
export = DatadogSpanContext;
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import Span = require('./span');
|
||||
import Reference = require('./reference');
|
||||
import SpanContext = require('./span_context');
|
||||
|
||||
interface SpanOptions {
|
||||
/**
|
||||
* a parent SpanContext (or Span, for convenience) that the newly-started
|
||||
* span will be the child of (per REFERENCE_CHILD_OF). If specified,
|
||||
* `references` must be unspecified.
|
||||
*/
|
||||
childOf?: Span | SpanContext;
|
||||
|
||||
/**
|
||||
* an array of Reference instances, each pointing to a causal parent
|
||||
* SpanContext. If specified, `fields.childOf` must be unspecified.
|
||||
*/
|
||||
references?: Reference[];
|
||||
|
||||
/**
|
||||
* set of key-value pairs which will be set as tags on the newly created
|
||||
* Span. Ownership of the object is passed to the created span for
|
||||
* efficiency reasons (the caller should not modify this object after
|
||||
* calling startSpan).
|
||||
*/
|
||||
tags?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
|
||||
/**
|
||||
* a manually specified start time for the created Span object. The time
|
||||
* should be specified in milliseconds as Unix timestamp. Decimal value are
|
||||
* supported to represent time values with sub-millisecond accuracy.
|
||||
*/
|
||||
startTime?: number;
|
||||
}
|
||||
|
||||
export = SpanOptions;
|
||||
+3
-83
@@ -1,91 +1,11 @@
|
||||
import SpanOptions = require('./span_options');
|
||||
import Span = require('./span');
|
||||
import SpanContext = require('./span_context');
|
||||
import { Tracer } from 'opentracing';
|
||||
|
||||
/**
|
||||
* Tracer is the entry-point between the instrumentation API and the tracing
|
||||
* implementation.
|
||||
*/
|
||||
declare class Tracer {
|
||||
/**
|
||||
* Starts and returns a new Span representing a logical unit of work.
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* // Start a new (parentless) root Span:
|
||||
* var parent = Tracer.startSpan('DoWork');
|
||||
*
|
||||
* // Start a new (child) Span:
|
||||
* var child = Tracer.startSpan('load-from-db', {
|
||||
* childOf: parent.context(),
|
||||
* });
|
||||
*
|
||||
* // Start a new async (FollowsFrom) Span:
|
||||
* var child = Tracer.startSpan('async-cache-write', {
|
||||
* references: [
|
||||
* opentracing.followsFrom(parent.context())
|
||||
* ],
|
||||
* });
|
||||
*
|
||||
* @param name - the name of the operation (REQUIRED).
|
||||
* @param options - options for the newly created span.
|
||||
* @return A new Span object.
|
||||
*/
|
||||
startSpan(name: string, options?: SpanOptions): Span;
|
||||
declare class DatadogTracer extends Tracer {
|
||||
|
||||
/**
|
||||
* Injects the given SpanContext instance for cross-process propagation
|
||||
* within `carrier`. The expected type of `carrier` depends on the value of
|
||||
* `format.
|
||||
*
|
||||
* OpenTracing defines a common set of `format` values (see
|
||||
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
|
||||
* an expected carrier type.
|
||||
*
|
||||
* Consider this pseudocode example:
|
||||
*
|
||||
* var clientSpan = ...;
|
||||
* ...
|
||||
* // Inject clientSpan into a text carrier.
|
||||
* var headersCarrier = {};
|
||||
* Tracer.inject(clientSpan.context(), Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
|
||||
* // Incorporate the textCarrier into the outbound HTTP request header
|
||||
* // map.
|
||||
* Object.assign(outboundHTTPReq.headers, headersCarrier);
|
||||
* // ... send the httpReq
|
||||
*
|
||||
* @param spanContext - the SpanContext to inject into the
|
||||
* carrier object. As a convenience, a Span instance may be passed
|
||||
* in instead (in which case its .context() is used for the
|
||||
* inject()).
|
||||
* @param format - the format of the carrier.
|
||||
* @param carrier - see the documentation for the chosen `format`
|
||||
* for a description of the carrier object.
|
||||
*/
|
||||
inject(spanContext: SpanContext | Span, format: string, carrier: any): void;
|
||||
|
||||
/**
|
||||
* Returns a SpanContext instance extracted from `carrier` in the given
|
||||
* `format`.
|
||||
*
|
||||
* OpenTracing defines a common set of `format` values (see
|
||||
* FORMAT_TEXT_MAP, FORMAT_HTTP_HEADERS, and FORMAT_BINARY), and each has
|
||||
* an expected carrier type.
|
||||
*
|
||||
* Consider this pseudocode example:
|
||||
*
|
||||
* // Use the inbound HTTP request's headers as a text map carrier.
|
||||
* var headersCarrier = inboundHTTPReq.headers;
|
||||
* var wireCtx = Tracer.extract(Tracer.FORMAT_HTTP_HEADERS, headersCarrier);
|
||||
* var serverSpan = Tracer.startSpan('...', { childOf : wireCtx });
|
||||
*
|
||||
* @param format - the format of the carrier.
|
||||
* @param carrier - the type of the carrier object is determined by
|
||||
* the format.
|
||||
* @return The extracted SpanContext, or null if no such SpanContext could
|
||||
* be found in `carrier`
|
||||
*/
|
||||
extract(format: string, carrier: any): SpanContext | null;
|
||||
}
|
||||
|
||||
export = Tracer;
|
||||
export = DatadogTracer;
|
||||
|
||||
Vendored
+405
-58
@@ -1,122 +1,414 @@
|
||||
// Type definitions for echarts
|
||||
// Type definitions for echarts 4.1.0
|
||||
// Project: http://echarts.baidu.com/
|
||||
// Definitions by: Xie Jingyang <https://github.com/xieisabug>
|
||||
// AntiMoron <https://github.com/AntiMoron>
|
||||
// Liveangela <https://github.com/liveangela>
|
||||
// Ovilia <https://github.com/Ovilia>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
declare namespace echarts {
|
||||
function init(dom: HTMLDivElement | HTMLCanvasElement, theme?: object | string, opts?: {
|
||||
devicePixelRatio?: number
|
||||
renderer?: string
|
||||
width?: number | string
|
||||
height?: number | string
|
||||
}): ECharts;
|
||||
/**
|
||||
* Creates an ECharts instance, and returns an echartsInstance. You shall
|
||||
* not initialize multiple ECharts instances on a single container.
|
||||
*
|
||||
* @param {HTMLDivElement | HTMLCanvasElement} dom Instance container,
|
||||
* usually is a `div` element with height and width defined.
|
||||
* @param {object | string} [theme] Theme to be applied.
|
||||
* This can be a configuring object of a theme, or a theme name
|
||||
* registered through [echarts.registerTheme](https://echarts.apache.org/api.html#echarts.registerTheme).
|
||||
* @param {object} [opts] Chart configurations.
|
||||
* @param {number} [opts.devicePixelRatio] Ratio of one physical pixel to
|
||||
* the size of one device independent pixels. Browser's
|
||||
* `window.devicePixelRatio` is used by default.
|
||||
* @param {string} [opts.renderer] Supports `'canvas'` or `'svg'`.
|
||||
* See [Render by Canvas or SVG](https://echarts.apache.org/tutorial.html#Render%20by%20Canvas%20or%20SVG).
|
||||
* @param {number} [opts.width] Specify width explicitly, in pixel.
|
||||
* If setting to `null`/`undefined`/`'auto'`, width of `dom`
|
||||
* (instance container) will be used.
|
||||
* @param {number} [opts.height] Specify height explicitly, in pixel.
|
||||
* If setting to `null`/`undefined`/`'auto'`, height of `dom`
|
||||
* (instance container) will be used.
|
||||
*/
|
||||
function init(
|
||||
dom: HTMLDivElement | HTMLCanvasElement,
|
||||
theme?: object | string,
|
||||
opts?: {
|
||||
devicePixelRatio?: number
|
||||
renderer?: string
|
||||
width?: number | string
|
||||
height?: number | string
|
||||
}
|
||||
): ECharts
|
||||
|
||||
const graphic: Graphic;
|
||||
/**
|
||||
* Connects interaction of multiple chart series. For example:
|
||||
*
|
||||
```js
|
||||
// set group id of each instance respectively.
|
||||
chart1.group = 'group1';
|
||||
chart2.group = 'group1';
|
||||
echarts.connect('group1');
|
||||
// or incoming instance array that need to be linked.
|
||||
echarts.connect([chart1, chart2]);
|
||||
```
|
||||
*
|
||||
* @param group Group id in string, or array of chart instance.
|
||||
*/
|
||||
function connect(group: string | ECharts[]): void
|
||||
|
||||
interface Graphic {
|
||||
clipPointsByRect(points: number[][], rect: ERectangle): number[][];
|
||||
clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle;
|
||||
LinearGradient: { new(x: number, y: number, x2: number, y2: number, colorStops: object[], globalCoord?: boolean): LinearGradient }
|
||||
}
|
||||
/**
|
||||
* Disconnects interaction of multiple chart series. To have one single
|
||||
* instance to be removed, you can set `group` of chart instance to be null.
|
||||
*
|
||||
* @param {string} group Group id in string.
|
||||
*/
|
||||
function disConnect(group: string): void
|
||||
|
||||
function connect(group: string | string[]): void;
|
||||
/**
|
||||
* Destroys chart instance, after which the instance cannot be used any
|
||||
* more.
|
||||
*
|
||||
* @param target Chart instance or container.
|
||||
*/
|
||||
function dispose(target: ECharts | HTMLDivElement | HTMLCanvasElement)
|
||||
: void
|
||||
|
||||
function disConnect(group: string): void;
|
||||
/**
|
||||
* Returns chart instance of dom container.
|
||||
*
|
||||
* @param target Chart container.
|
||||
*/
|
||||
function getInstanceByDom(target: HTMLDivElement | HTMLCanvasElement)
|
||||
: ECharts
|
||||
|
||||
function dispose(target: ECharts | HTMLDivElement | HTMLCanvasElement): void;
|
||||
/**
|
||||
* Registers available maps. This can only be used after including
|
||||
* [geo](https://echarts.apache.org/option.html#geo)
|
||||
* component or chart series of
|
||||
* [map](https://echarts.apache.org/option.html#series-map).
|
||||
*
|
||||
* @param {string} mapName Map name, referring to `map` value set in
|
||||
* [geo](https://echarts.apache.org/option.html#geo)
|
||||
* component or
|
||||
* [map](https://echarts.apache.org/option.html#series-map).
|
||||
* @param {object} geoJson Data in GeoJson format. See
|
||||
* [http://geojson.org/](http://geojson.org/) for more format information.
|
||||
* @param {object} [specialAreas] Zoomed part of a specific area in the map
|
||||
* for better visual effect.
|
||||
* See [USA Population Estimates example](https://ecomfe.github.io/echarts-examples/public/editor.html?c=map-usa).
|
||||
*/
|
||||
function registerMap(
|
||||
mapName: string,
|
||||
geoJson: object,
|
||||
specialAreas?: object
|
||||
): void
|
||||
|
||||
function getInstanceByDom(target: HTMLDivElement | HTMLCanvasElement): ECharts;
|
||||
|
||||
function registerMap(mapName: string, geoJson: object, specialAreas?: object): void;
|
||||
|
||||
function registerTheme(themeName: string, theme: object): void;
|
||||
/**
|
||||
* Registers a theme, should be specified when
|
||||
* [initialize the chart instance](https://echarts.apache.org/api.html#echarts.init).
|
||||
*
|
||||
* @param {string} themeName Theme name.
|
||||
* @param {object} theme Theme configurations.
|
||||
*/
|
||||
function registerTheme(themeName: string, theme: object): void
|
||||
|
||||
interface MapObj {
|
||||
/** geoJson data for map */
|
||||
/**
|
||||
* geoJson data for map
|
||||
*/
|
||||
geoJson: object,
|
||||
/** special areas fro map */
|
||||
/**
|
||||
* special areas fro map
|
||||
*/
|
||||
specialAreas: object
|
||||
}
|
||||
|
||||
function getMap(mapName: string): MapObj;
|
||||
/**
|
||||
* Get a registed map.
|
||||
*
|
||||
* @param {string} mapName Map name.
|
||||
* @return {MapObj} Map data.
|
||||
*/
|
||||
function getMap(mapName: string): MapObj
|
||||
|
||||
interface LinearGradient {
|
||||
colorStops: object[];
|
||||
global: boolean;
|
||||
type: string;
|
||||
x: number
|
||||
x2: number
|
||||
y: number
|
||||
y2: number
|
||||
/**
|
||||
* Util methods about graphics.
|
||||
*/
|
||||
const graphic: Graphic;
|
||||
|
||||
interface Graphic {
|
||||
/**
|
||||
* Clip the given points by the given rectangular.
|
||||
*
|
||||
* @param {number[][]} points The points to be clipped,
|
||||
* like [[23, 44], [12, 15], ...].
|
||||
* @param {ERectangle} rect The rectangular that is used to clip points.
|
||||
*/
|
||||
clipPointsByRect(points: number[][], rect: ERectangle): number[][];
|
||||
|
||||
/**
|
||||
* Clip the first input rectangular by the second input rectangular.
|
||||
*
|
||||
* @param {ERectangle} targetRect The rectangular to be clipped.
|
||||
* @param {ERectangle} rect The rectangular that is used to clip
|
||||
* targetRect.
|
||||
*/
|
||||
clipRectByRect(targetRect: ERectangle, rect: ERectangle): ERectangle;
|
||||
}
|
||||
|
||||
interface ECharts {
|
||||
/**
|
||||
* Group name to be used in chart connection
|
||||
*/
|
||||
group: string
|
||||
|
||||
setOption(option: EChartOption, notMerge?: boolean, notRefreshImmediately?: boolean): void
|
||||
/**
|
||||
* Configuration item, data, universal interface, all parameters and
|
||||
* data can all be modified through `setOption`. ECharts will merge
|
||||
* new parameters and data, and then refresh chart.
|
||||
*
|
||||
* @param {EChartOption} option Configuration item and data. Please
|
||||
* refer to [configuration item manual](https://echarts.apache.org/option.html)
|
||||
* for more information.
|
||||
* @param {boolean} [notMerge=false] Whether not to merge with previous
|
||||
* `option`
|
||||
* @param {boolean} [lazyUpdate=false] Whether not to update chart
|
||||
* immediately
|
||||
*/
|
||||
setOption(
|
||||
option: EChartOption,
|
||||
notMerge?: boolean,
|
||||
lazyUpdate?: boolean
|
||||
) : void
|
||||
|
||||
/**
|
||||
* Configuration item, data, universal interface, all parameters and
|
||||
* data can all be modified through `setOption`. ECharts will merge
|
||||
* new parameters and data, and then refresh chart.
|
||||
*
|
||||
* @param {EChartOption} option Configuration item and data. Please
|
||||
* refer to [configuration item manual](https://echarts.apache.org/option.html)
|
||||
* for more information.
|
||||
* @param {EChartsOptionConfig} [opts] Options about how to setOption
|
||||
*/
|
||||
setOption(option: EChartOption, opts?: EChartsOptionConfig): void
|
||||
|
||||
/**
|
||||
* Gets width of ECharts instance container.
|
||||
*
|
||||
* @return {number} Width.
|
||||
*/
|
||||
getWidth(): number
|
||||
|
||||
/**
|
||||
* Gets height of ECharts instance container.
|
||||
*
|
||||
* @return {number} Height.
|
||||
*/
|
||||
getHeight(): number
|
||||
|
||||
/**
|
||||
* Gets DOM element of ECharts instance container.
|
||||
*
|
||||
* @return {HTMLCanvasElement|HTMLDivElement} DOM container.
|
||||
*/
|
||||
getDom(): HTMLCanvasElement | HTMLDivElement
|
||||
|
||||
getOption(): object
|
||||
/**
|
||||
* Gets `option` object maintained in current instance, which contains
|
||||
* configuration item and data merged from previous `setOption`
|
||||
* operations by users, along with user interaction states.
|
||||
* For example, switching of legend, zooming area of data zoom,
|
||||
* and so on. Therefore, a new instance that is exactly the same
|
||||
* can be recovered from this option.
|
||||
*/
|
||||
getOption(): EChartOption
|
||||
|
||||
resize(): void
|
||||
/**
|
||||
* Resizes chart, which should be called manually when container size
|
||||
* changes. When `opts` is not provided, DOM size is used.
|
||||
*
|
||||
* @param {EChartsResizeOption} opts Specify parameters explicitly.
|
||||
*/
|
||||
resize(opts?: EChartsResizeOption): void
|
||||
|
||||
/**
|
||||
* Triggers chart action, like chart switch `legendToggleSelect`,
|
||||
* zoom data area `dataZoom`, show tooltip `showTip` and so on.
|
||||
* See [action](https://echarts.apache.org/api.html#action) and
|
||||
* [events](https://echarts.apache.org/api.html#events)
|
||||
* for more information.
|
||||
*
|
||||
* @param payload Trigger multiple actions through `batch` attribute.
|
||||
*/
|
||||
dispatchAction(payload: object): void
|
||||
|
||||
/**
|
||||
* Binds event-handling function.
|
||||
* There are two kinds of events in ECharts, one of which is mouse
|
||||
* events, which will be triggered when the mouse clicks certain
|
||||
* element in the chart, the other kind will be triggered after
|
||||
* `dispatchAction` is called. Every action has a corresponding
|
||||
* event.
|
||||
* If event is triggered externally by `dispatchAction`, and there
|
||||
* is batch attribute in action to trigger batch action, then the
|
||||
* corresponding response event parameters be in batch.
|
||||
*
|
||||
* @param {string} eventName Event names are all in lower-cases,
|
||||
* for example, `'click'`, `'mousemove'`, `'legendselected'`
|
||||
* @param {Function} handler Event-handling function, whose format
|
||||
* is as following:
|
||||
```js
|
||||
(event: object)
|
||||
```
|
||||
* @param {object} [context] context of callback function, what
|
||||
* `this` refers to.
|
||||
*/
|
||||
on(eventName: string, handler: Function, context?: object): void
|
||||
|
||||
/**
|
||||
* Unbind event-handler function.
|
||||
*
|
||||
* @param {string} eventName Event names are all in lower-cases,
|
||||
* for example, `'click'`, `'mousemove'`, `'legendselected'`
|
||||
* @param {Function} [handler] The function to be unbound could be
|
||||
* passed. Otherwise, all event functions of this type will be
|
||||
* unbound.
|
||||
*/
|
||||
off(eventName: string, handler?: Function): void
|
||||
|
||||
showLoading(type?: string, opts?: object): void
|
||||
/**
|
||||
* Convert a point from logical coordinate (e.g., in geo, cartesian,
|
||||
* graph, ...) to pixel coordinate.
|
||||
*
|
||||
* @param {EChartsConvertFinder} finder Indicate in which coordinate
|
||||
* system conversion is performed.
|
||||
* Generally, index or id or name can be used to specify
|
||||
* coordinate system.
|
||||
* @param {string | any[]} value The value to be converted.
|
||||
*/
|
||||
convertToPixel(finder: EChartsConvertFinder, value: string | any[])
|
||||
: string | any[]
|
||||
|
||||
/**
|
||||
* Convert a point from pixel coordinate to logical coordinate
|
||||
* (e.g., in geo, cartesian, graph, ...).
|
||||
*
|
||||
* @param {EChartsConvertFinder} finder Indicate in which coordinate
|
||||
* system conversion is performed.
|
||||
* Generally, index or id or name can be used to specify
|
||||
* coordinate system.
|
||||
* @param {string | any[]} value The value to be converted.
|
||||
*/
|
||||
convertFromPixel(finder: EChartsConvertFinder, value: any[] | string)
|
||||
: any[] | string
|
||||
|
||||
/**
|
||||
* Determine whether the given point is in the given coordinate systems or series.
|
||||
*
|
||||
* @param {EChartsConvertFinder} finder Indicate in which coordinate
|
||||
* system conversion is performed.
|
||||
* Generally, index or id or name can be used to specify
|
||||
* coordinate system.
|
||||
* @param {string | any[]} value The value to be judged, in pixel
|
||||
* coordinate system.
|
||||
*/
|
||||
containPixel(finder: EChartsConvertFinder, value: any[]): boolean
|
||||
|
||||
/**
|
||||
* Shows loading animation. You can call this interface manually before
|
||||
* data is loaded, and call `hideLoading` to hide loading animation
|
||||
* after data is loaded.
|
||||
*
|
||||
* @param {string} [type='default']
|
||||
* @param {EChartsLoadingOption} [opts]
|
||||
*/
|
||||
showLoading(type?: string, opts?: EChartsLoadingOption): void
|
||||
|
||||
/**
|
||||
* Hides animation loading effect.
|
||||
*/
|
||||
hideLoading(): void
|
||||
|
||||
/**
|
||||
* Exports chart image; returns a base64 URL; can be set to `src` of
|
||||
* `Image`.
|
||||
*
|
||||
* @param opts Options.
|
||||
*/
|
||||
getDataURL(opts: {
|
||||
/** 导出的格式,可选 png, jpeg */
|
||||
// Exporting format, can be either png, or jpeg
|
||||
type?: string,
|
||||
/** 导出的图片分辨率比例,默认为 1。*/
|
||||
// Resolution ratio of exporting image, 1 by default.
|
||||
pixelRatio?: number,
|
||||
/** 导出的图片背景色,默认使用 option 里的 backgroundColor */
|
||||
backgroundColor?: string
|
||||
// Background color of exporting image, use backgroundColor in
|
||||
// option by default.
|
||||
backgroundColor?: string,
|
||||
// Excluded components list. e.g. ['toolbox']
|
||||
excludeComponents?: string[]
|
||||
}): string
|
||||
|
||||
/**
|
||||
* Exports connected chart image; returns a base64 url; can be set to
|
||||
* `src` of `Image`. Position of charts in exported image are
|
||||
* related to that of the container.
|
||||
*
|
||||
* @param opts Options.
|
||||
*/
|
||||
getConnectedDataURL(opts: {
|
||||
/** 导出的格式,可选 png, jpeg */
|
||||
// Exporting format, can be either png, or jpeg
|
||||
type: string,
|
||||
/** 导出的图片分辨率比例,默认为 1。 */
|
||||
// Resolution ratio of exporting image, 1 by default.
|
||||
pixelRatio: number,
|
||||
/** 导出的图片背景色,默认使用 option 里的 backgroundColor */
|
||||
backgroundColor: string
|
||||
// Background color of exporting image, use backgroundColor in
|
||||
// option by default.
|
||||
backgroundColor: string,
|
||||
// Excluded components list. e.g. ['toolbox']
|
||||
excludeComponents?: string[]
|
||||
}): string
|
||||
|
||||
/**
|
||||
* The method is used in rendering millions of data
|
||||
* (e.g. rendering geo data). In these scenario, the entire size of
|
||||
* data is probably up to 10 or 100 MB, even using binary format.
|
||||
* So chunked load data and rendering is required. When using
|
||||
* `appendData`, the graphic elements that have been rendered will
|
||||
* not be cleared, but keep rendering new graphic elements.
|
||||
*
|
||||
* @param opts Data options.
|
||||
*/
|
||||
appendData(opts: {
|
||||
// Specify which series the data will be appended to.
|
||||
seriesIndex?: string,
|
||||
// The data to be appended.
|
||||
data?: any[]|TypedArray,
|
||||
}): void
|
||||
|
||||
/**
|
||||
* Clears current instance; removes all components and charts in
|
||||
* current instance.
|
||||
*/
|
||||
clear(): void
|
||||
|
||||
/**
|
||||
* Returns whether current instance has been disposed.
|
||||
*
|
||||
* @return {boolean} Whether has been disposed.
|
||||
*/
|
||||
isDisposed(): boolean
|
||||
|
||||
/**
|
||||
* Disposes instance. Once disposed, the instance can not be used again.
|
||||
*/
|
||||
dispose(): void
|
||||
|
||||
/** 转换逻辑点到像素 */
|
||||
convertToPixel(finder: ConvertFinder | string, value: string | any[]): string | any[]
|
||||
|
||||
convertFromPixel(finder: ConvertFinder | string, value: any[] | string): any[] | string
|
||||
|
||||
containPixel(finder: ConvertFinder | string,
|
||||
/** 要被判断的点,为像素坐标值,以 echarts 实例的 dom 节点的左上角为坐标 [0, 0] 点。*/
|
||||
value: any[]): boolean
|
||||
|
||||
getModel(): {
|
||||
getComponent(finder: string): any;
|
||||
}
|
||||
}
|
||||
|
||||
interface ConvertFinder {
|
||||
type TypedArray = Int8Array | Uint8Array | Int16Array | Uint16Array
|
||||
| Int32Array | Uint32Array | Uint8ClampedArray | Float32Array
|
||||
| Float64Array;
|
||||
|
||||
interface EChartsConvertFinder {
|
||||
seriesIndex?: number,
|
||||
seriesId?: string,
|
||||
seriesName?: string,
|
||||
@@ -193,6 +485,29 @@ declare namespace echarts {
|
||||
zAxis3D?: object
|
||||
}
|
||||
|
||||
interface EChartsOptionConfig {
|
||||
notMerge?: boolean,
|
||||
lazyUpdate?: boolean,
|
||||
silent?: boolean
|
||||
}
|
||||
|
||||
interface EChartsResizeOption {
|
||||
/**
|
||||
* Chart width.
|
||||
*/
|
||||
width?: number | string,
|
||||
|
||||
/**
|
||||
* Chart height.
|
||||
*/
|
||||
heiight?: number | string,
|
||||
|
||||
/**
|
||||
* Specify whether or not to prevent triggering events.
|
||||
*/
|
||||
silent?: boolean
|
||||
}
|
||||
|
||||
interface EChartTitleOption {
|
||||
show?: boolean;
|
||||
text?: string;
|
||||
@@ -219,6 +534,38 @@ declare namespace echarts {
|
||||
shadowOffsetX?: number,
|
||||
shadowOffsetY?: number,
|
||||
}
|
||||
|
||||
interface EChartsLoadingOption {
|
||||
/**
|
||||
* Loading text.
|
||||
* @default 'loading'
|
||||
*/
|
||||
text?: string,
|
||||
|
||||
/**
|
||||
* Loading circle color.
|
||||
* @default '#c23531'
|
||||
*/
|
||||
color?: string,
|
||||
|
||||
/**
|
||||
* Loading text color.
|
||||
* @default '#000'
|
||||
*/
|
||||
textColor?: string,
|
||||
|
||||
/**
|
||||
* Mask background color.
|
||||
* @default 'rgba(255, 255, 255, 0.8)'
|
||||
*/
|
||||
maskColor?: string,
|
||||
|
||||
/**
|
||||
* Zlevel of loading. If not 0, it creates a new canvas for loading.
|
||||
* @default 0
|
||||
*/
|
||||
zlevel?: 0
|
||||
}
|
||||
}
|
||||
|
||||
declare module 'echarts' {
|
||||
|
||||
+2
-3
@@ -1,12 +1,11 @@
|
||||
import React = require('react');
|
||||
|
||||
import { EmojiData } from '..';
|
||||
|
||||
import { Emoji, EmojiProps, I18n } from '.';
|
||||
import { Emoji, EmojiData, EmojiProps, I18n, CategoryName } from '..';
|
||||
|
||||
export interface Props {
|
||||
emojis?: Array<string|EmojiData>;
|
||||
hasStickyPosition?: boolean;
|
||||
id: CategoryName;
|
||||
name: string;
|
||||
native: boolean;
|
||||
perLine: number;
|
||||
|
||||
-31
@@ -1,31 +0,0 @@
|
||||
import React = require('react');
|
||||
|
||||
import { EmojiData, EmojiSkin } from '..';
|
||||
|
||||
export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string;
|
||||
export type EmojiSet = 'apple'|'google'|'twitter'|'emojione'|'messenger'|'facebook';
|
||||
export type EmojiSheetSize = 16|20|32|64;
|
||||
|
||||
export interface Props {
|
||||
onOver?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
onLeave?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
onClick?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
/** defaults to returning a png from unpkg.com-hosted emoji-datasource-${set} */
|
||||
backgroundImageFn?: BackgroundImageFn;
|
||||
native?: boolean;
|
||||
forceSize?: boolean;
|
||||
tooltip?: boolean;
|
||||
/** defaults to 1 */
|
||||
skin?: EmojiSkin;
|
||||
/** defaults to 64 */
|
||||
sheetSize?: EmojiSheetSize;
|
||||
/** defaults to 'apple' */
|
||||
set?: EmojiSet;
|
||||
size: number;
|
||||
emoji: string|EmojiData;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line strict-export-declare-modifiers
|
||||
declare const Emoji: React.SFC<Props>;
|
||||
|
||||
export { Emoji as default };
|
||||
@@ -0,0 +1,8 @@
|
||||
import React = require('react');
|
||||
|
||||
import { EmojiProps } from '../..';
|
||||
|
||||
// tslint:disable-next-line strict-export-declare-modifiers
|
||||
declare const Emoji: React.StatelessComponent<EmojiProps>;
|
||||
|
||||
export { Emoji as default };
|
||||
@@ -0,0 +1,12 @@
|
||||
import React = require('react');
|
||||
|
||||
import { EmojiProps, Data } from '../..';
|
||||
|
||||
export interface NimbleEmojiProps extends EmojiProps {
|
||||
data: Data;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line strict-export-declare-modifiers
|
||||
declare const NimbleEmoji: React.SFC<NimbleEmojiProps>;
|
||||
|
||||
export { NimbleEmoji as default };
|
||||
+4
-2
@@ -1,4 +1,6 @@
|
||||
// The other exports on the components folder are not public API
|
||||
export { default as Category, Props as CategoryProps } from './category';
|
||||
export { default as Emoji, Props as EmojiProps, BackgroundImageFn, EmojiSet, EmojiSheetSize } from './emoji';
|
||||
export { default as Picker, Props as PickerProps, I18n, PartialI18n, CustomEmoji } from './picker';
|
||||
export { default as Emoji } from './emoji/emoji';
|
||||
export { default as NimbleEmoji, NimbleEmojiProps } from './emoji/nimble-emoji';
|
||||
export { default as Picker } from './picker/picker';
|
||||
export { default as NimblePicker, NimblePickerProps } from './picker/nimble-picker';
|
||||
|
||||
-54
@@ -1,54 +0,0 @@
|
||||
import React = require('react');
|
||||
|
||||
import { EmojiData, EmojiSkin } from '..';
|
||||
|
||||
import { Category, Emoji, EmojiProps, BackgroundImageFn, EmojiSet, EmojiSheetSize } from '.';
|
||||
|
||||
// tslint:disable-next-line interface-name
|
||||
export interface I18n {
|
||||
search: string;
|
||||
categories: Record<'search'|'recent'|'people'|'nature'|'foods'|'activity'|'places'|'objects'|'symbols'|'flags'|'custom', string>;
|
||||
notfound: string;
|
||||
}
|
||||
|
||||
export type PartialI18n = Partial<Pick<I18n, 'search'|'notfound'> & { categories: Partial<I18n['categories']>}>;
|
||||
|
||||
export interface CustomEmoji {
|
||||
// id is overridden by short_names[0]
|
||||
name: string;
|
||||
/** Must contain at least one name. The first name is used as the unique id. */
|
||||
short_names: string[];
|
||||
emoticons?: string[];
|
||||
keywords?: string[];
|
||||
imageUrl: string;
|
||||
}
|
||||
|
||||
export interface Props {
|
||||
/** NOTE: default is not preventable */
|
||||
onClick?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
perLine?: number;
|
||||
emojiSize?: number;
|
||||
i18n?: PartialI18n;
|
||||
style?: React.CSSProperties;
|
||||
title?: string;
|
||||
emoji?: string;
|
||||
color?: string;
|
||||
set?: EmojiSet;
|
||||
skin?: EmojiSkin;
|
||||
native?: boolean;
|
||||
backgroundImageFn?: BackgroundImageFn;
|
||||
sheetSize?: EmojiSheetSize;
|
||||
emojisToShowFilter?(emoji: EmojiData): boolean;
|
||||
showPreview?: boolean;
|
||||
emojiTooltip?: boolean;
|
||||
include?: string[];
|
||||
exclude?: string[];
|
||||
recent?: string[];
|
||||
autoFocus?: boolean;
|
||||
/** NOTE: custom emoji are copied into a singleton object on every new mount */
|
||||
custom: CustomEmoji[];
|
||||
}
|
||||
|
||||
export default class Picker extends React.PureComponent<Props> {
|
||||
// everything inside it is supposed to be private
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import React = require('react');
|
||||
|
||||
import { Data, PickerProps } from '../..';
|
||||
|
||||
export interface NimblePickerProps extends PickerProps {
|
||||
data: Data;
|
||||
}
|
||||
|
||||
export default class NimblePicker extends React.PureComponent<NimblePickerProps> {
|
||||
// everything inside it is supposed to be private
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import React = require('react');
|
||||
|
||||
import { PickerProps } from '../..';
|
||||
|
||||
export default class Picker extends React.PureComponent<PickerProps> {
|
||||
// everything inside it is supposed to be private
|
||||
}
|
||||
Vendored
+21
-6
@@ -1,15 +1,30 @@
|
||||
export { default as emojiIndex, EmojiData, EmojiSkin } from './utils/emoji-index';
|
||||
export { default as store, StoreHandlers } from './utils/store';
|
||||
export { default as frequently } from './utils/frequently';
|
||||
export { Data } from './utils/data';
|
||||
|
||||
export {
|
||||
PickerProps,
|
||||
EmojiProps,
|
||||
I18n,
|
||||
PartialI18n,
|
||||
CategoryName
|
||||
} from './utils/shared-props';
|
||||
|
||||
export {
|
||||
emojiIndex,
|
||||
nimbleEmojiIndex,
|
||||
EmojiData,
|
||||
CustomEmoji,
|
||||
EmojiSkin
|
||||
} from './utils/emoji-index';
|
||||
|
||||
export {
|
||||
Picker,
|
||||
PickerProps,
|
||||
I18n,
|
||||
PartialI18n,
|
||||
CustomEmoji,
|
||||
NimblePicker,
|
||||
NimblePickerProps,
|
||||
Emoji,
|
||||
EmojiProps,
|
||||
NimbleEmoji,
|
||||
NimbleEmojiProps,
|
||||
Category,
|
||||
CategoryProps
|
||||
} from './components';
|
||||
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
export interface Data {
|
||||
compressed: boolean;
|
||||
categories: Category[];
|
||||
emojis: { [key: string]: Emoji };
|
||||
aliases: { [key: string]: string };
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: string;
|
||||
name: string;
|
||||
emojis: string[];
|
||||
}
|
||||
|
||||
export interface Emoji {
|
||||
name?: string;
|
||||
a?: string;
|
||||
unified?: string;
|
||||
b?: string;
|
||||
non_qualified?: string;
|
||||
c?: string;
|
||||
has_img_apple?: boolean;
|
||||
d?: boolean;
|
||||
has_img_google?: boolean;
|
||||
e?: boolean;
|
||||
has_img_twitter?: boolean;
|
||||
f?: boolean;
|
||||
has_img_emojione?: boolean;
|
||||
g?: boolean;
|
||||
has_img_facebook?: boolean;
|
||||
h?: boolean;
|
||||
has_img_messenger?: boolean;
|
||||
i?: boolean;
|
||||
keywords?: string[];
|
||||
j?: string[];
|
||||
sheet?: number[];
|
||||
k?: number[];
|
||||
emoticons?: string[];
|
||||
l?: string[];
|
||||
text?: string;
|
||||
m?: string;
|
||||
short_names?: string[];
|
||||
n?: string[];
|
||||
added_in?: number;
|
||||
o?: number;
|
||||
sheet_x?: number;
|
||||
sheet_y?: number;
|
||||
skin_variations?: { [key: string]: SkinVariation };
|
||||
obsoleted_by?: string;
|
||||
obsoletes?: string;
|
||||
}
|
||||
|
||||
export interface SkinVariation {
|
||||
unified: string;
|
||||
non_qualified: null | string;
|
||||
image: string;
|
||||
sheet_x: number;
|
||||
sheet_y: number;
|
||||
added_in: string;
|
||||
has_img_apple: boolean;
|
||||
has_img_google: boolean;
|
||||
has_img_twitter: boolean;
|
||||
has_img_emojione: boolean;
|
||||
has_img_facebook: boolean;
|
||||
has_img_messenger: boolean;
|
||||
obsoleted_by?: string;
|
||||
obsoletes?: string;
|
||||
}
|
||||
|
||||
export function buildSearch(emoji: Emoji): string;
|
||||
|
||||
export function compress(emoji: Emoji): void;
|
||||
|
||||
export function uncompress(data: Data): void;
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
export type EmojiSkin = 1|2|3|4|5|6;
|
||||
|
||||
export interface EmojiData {
|
||||
id: string;
|
||||
name: string;
|
||||
colons: string;
|
||||
/** Reverse mapping to keyof emoticons */
|
||||
emoticons: string[];
|
||||
unified: string;
|
||||
skin: EmojiSkin|null;
|
||||
native: string;
|
||||
}
|
||||
|
||||
// tslint:disable-next-line strict-export-declare-modifiers
|
||||
declare const _default: {
|
||||
search(query: ''): null
|
||||
search(query: string): EmojiData|null
|
||||
|
||||
emojis: { [emoji: string]: EmojiData }
|
||||
|
||||
/** Mapping of string to keyof emojis */
|
||||
emoticons: { [emoticon: string]: string }
|
||||
};
|
||||
|
||||
export { _default as default };
|
||||
@@ -0,0 +1,14 @@
|
||||
import { EmojiData } from './nimble-emoji-index';
|
||||
|
||||
// tslint:disable-next-line strict-export-declare-modifiers
|
||||
declare const _default: {
|
||||
search(query: ''): null;
|
||||
search(query: string): EmojiData|null;
|
||||
|
||||
emojis: { [emoji: string]: EmojiData };
|
||||
|
||||
/** Mapping of string to keyof emojis */
|
||||
emoticons: { [emoticon: string]: string };
|
||||
};
|
||||
|
||||
export { _default as default };
|
||||
@@ -0,0 +1,2 @@
|
||||
export { default as emojiIndex } from './emoji-index';
|
||||
export { default as nimbleEmojiIndex, EmojiData, CustomEmoji, EmojiSkin } from './nimble-emoji-index';
|
||||
@@ -0,0 +1,40 @@
|
||||
import { Data } from "../data";
|
||||
|
||||
import { CategoryName } from '../shared-props';
|
||||
|
||||
export type EmojiSkin = 1 | 2 | 3 | 4 | 5 | 6;
|
||||
|
||||
export interface BaseEmoji {
|
||||
id: string;
|
||||
name: string;
|
||||
colons: string;
|
||||
/** Reverse mapping to keyof emoticons */
|
||||
emoticons: string[];
|
||||
unified: string;
|
||||
skin: EmojiSkin | null;
|
||||
native: string;
|
||||
}
|
||||
|
||||
export interface CustomEmoji {
|
||||
// id is overridden by short_names[0]
|
||||
id?: string;
|
||||
// colons is overridden by :id:
|
||||
colons?: string;
|
||||
name: string;
|
||||
/** Must contain at least one name. The first name is used as the unique id. */
|
||||
short_names: string[];
|
||||
emoticons?: string[];
|
||||
keywords?: string[];
|
||||
imageUrl: string;
|
||||
}
|
||||
|
||||
export type EmojiData = BaseEmoji | CustomEmoji;
|
||||
|
||||
export default class NimbleEmojiIndex {
|
||||
constructor(data: Data);
|
||||
search(query: ''): null;
|
||||
search(query: string): EmojiData[]|null;
|
||||
emojis: { [emoji: string]: EmojiData };
|
||||
/** Mapping of string to keyof emojis */
|
||||
emoticons: { [emoticon: string]: string };
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import React = require('react');
|
||||
|
||||
import { EmojiData, EmojiSkin, CustomEmoji } from './emoji-index/nimble-emoji-index';
|
||||
|
||||
export type BackgroundImageFn = (set: EmojiSet, sheetSize: EmojiSheetSize) => string;
|
||||
export type EmojiSet = 'apple' | 'google' | 'twitter' | 'emojione' | 'messenger' | 'facebook';
|
||||
export type EmojiSheetSize = 16 | 20 | 32 | 64;
|
||||
|
||||
export interface EmojiProps {
|
||||
onOver?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
onLeave?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
onClick?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
fallback?(emoji: EmojiData, props: EmojiProps): React.Component;
|
||||
/** defaults to returning a png from unpkg.com-hosted emoji-datasource-${set} */
|
||||
backgroundImageFn?: BackgroundImageFn;
|
||||
native?: boolean;
|
||||
forceSize?: boolean;
|
||||
tooltip?: boolean;
|
||||
/** defaults to 1 */
|
||||
skin?: EmojiSkin;
|
||||
/** defaults to 64 */
|
||||
sheetSize?: EmojiSheetSize;
|
||||
/** defaults to 52 */
|
||||
sheetColumns?: number;
|
||||
/** defaults to 52 */
|
||||
sheetRows?: number;
|
||||
/** defaults to 'apple' */
|
||||
set?: EmojiSet;
|
||||
size: number;
|
||||
emoji: string | EmojiData;
|
||||
html?: boolean;
|
||||
/** data is omitted here as it should be used for NimbleEmoji only - not emoji */
|
||||
}
|
||||
|
||||
export type CategoryName = 'search' | 'recent' | 'people' | 'nature' | 'foods' | 'activity' | 'places' | 'objects' | 'symbols' | 'flags' | 'custom';
|
||||
|
||||
// tslint:disable-next-line interface-name
|
||||
export interface I18n {
|
||||
search: string;
|
||||
categories: Record<CategoryName, string>;
|
||||
notfound: string;
|
||||
skintext: string;
|
||||
}
|
||||
|
||||
export type PartialI18n = Partial<Pick<I18n, 'search' | 'notfound'> & { categories: Partial<I18n['categories']> }>;
|
||||
|
||||
export interface CustomIcons {
|
||||
categories: Record<CategoryName, () => React.Component>;
|
||||
}
|
||||
|
||||
export interface PickerProps {
|
||||
/** NOTE: default is not preventable */
|
||||
onClick?(emoji: EmojiData, e: React.MouseEvent<HTMLElement>): void;
|
||||
onSelect?(emoji: EmojiData): void;
|
||||
onSkinChange?(skin: EmojiSkin): void;
|
||||
perLine?: number;
|
||||
emojiSize?: number;
|
||||
i18n?: PartialI18n;
|
||||
style?: React.CSSProperties;
|
||||
title?: string;
|
||||
emoji?: string;
|
||||
color?: string;
|
||||
set?: EmojiSet;
|
||||
skin?: EmojiSkin;
|
||||
defaultSkin?: EmojiSkin;
|
||||
native?: boolean;
|
||||
backgroundImageFn?: BackgroundImageFn;
|
||||
sheetSize?: EmojiSheetSize;
|
||||
emojisToShowFilter?(emoji: EmojiData): boolean;
|
||||
showPreview?: boolean;
|
||||
showSkinTones?: boolean;
|
||||
emojiTooltip?: boolean;
|
||||
include?: CategoryName[];
|
||||
exclude?: CategoryName[];
|
||||
recent?: string[];
|
||||
autoFocus?: boolean;
|
||||
/** NOTE: custom emoji are copied into a singleton object on every new mount */
|
||||
custom: CustomEmoji[];
|
||||
skinEmoji?: string;
|
||||
notFound?(): React.Component;
|
||||
notFoundEmoji?: string;
|
||||
icons?: CustomIcons;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Port of https://github.com/missive/emoji-mart/blob/master/src/components/emoji.js
|
||||
// Port of https://github.com/missive/emoji-mart/blob/v2.8.0/stories/index.js
|
||||
|
||||
import React = require('react');
|
||||
|
||||
|
||||
Vendored
+2
-3
@@ -1,9 +1,8 @@
|
||||
// Type definitions for emoji-mart 2.2
|
||||
// Type definitions for emoji-mart 2.8
|
||||
// Project: https://github.com/missive/emoji-mart
|
||||
// Definitions by: Diogo Franco <https://github.com/Kovensky>
|
||||
// Nick Winans <https://github.com/Nicell>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
// These definitions should work with 2.3, but the tests doesn't pass on 2.3.
|
||||
|
||||
export * from './dist-es';
|
||||
|
||||
@@ -20,11 +20,17 @@
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"dist-es/components/category.d.ts",
|
||||
"dist-es/components/emoji.d.ts",
|
||||
"dist-es/components/emoji/emoji.d.ts",
|
||||
"dist-es/components/emoji/nimble-emoji.d.ts",
|
||||
"dist-es/components/index.d.ts",
|
||||
"dist-es/components/picker.d.ts",
|
||||
"dist-es/utils/emoji-index.d.ts",
|
||||
"dist-es/components/picker/picker.d.ts",
|
||||
"dist-es/components/picker/nimble-picker.d.ts",
|
||||
"dist-es/utils/emoji-index/emoji-index.d.ts",
|
||||
"dist-es/utils/emoji-index/nimble-emoji-index.d.ts",
|
||||
"dist-es/utils/emoji-index/index.d.ts",
|
||||
"dist-es/utils/data.d.ts",
|
||||
"dist-es/utils/frequently.d.ts",
|
||||
"dist-es/utils/shared-props.d.ts",
|
||||
"dist-es/utils/store.d.ts",
|
||||
"dist-es/index.d.ts",
|
||||
"emoji-mart-tests.tsx"
|
||||
|
||||
Vendored
+5
-1
@@ -1,6 +1,7 @@
|
||||
// Type definitions for express-fileupload 0.1
|
||||
// Type definitions for express-fileupload 0.4
|
||||
// Project: https://github.com/richardgirges/express-fileupload#readme
|
||||
// Definitions by: Gintautas Miselis <https://github.com/Naktibalda>
|
||||
// Sefa Ilkimen <https://github.com/silkimen>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -28,13 +29,16 @@ declare namespace fileUpload {
|
||||
encoding: string;
|
||||
mimetype: string;
|
||||
data: Buffer;
|
||||
truncated: boolean;
|
||||
mv(path: string, callback: (err: any) => void): void;
|
||||
mv(path: string): Promise<void>;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
debug?: boolean;
|
||||
safeFileNames?: boolean;
|
||||
preserveExtension?: boolean | string | number;
|
||||
abortOnLimit?: boolean;
|
||||
[property: string]: any;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,13 +95,15 @@ const withSourceAndArgsAndContextTyped = createBatchResolver<
|
||||
SomeTestResult,
|
||||
SomeTestArgs,
|
||||
SomeTestContext
|
||||
>(async (sources, args, context) => {
|
||||
>(async (sources, args, context, info) => {
|
||||
// $ExpectType ReadonlyArray<SomeTestSource>
|
||||
const verifySources = sources;
|
||||
// $ExpectType string
|
||||
const verifyArgs = args.someArg;
|
||||
// $ExpectType string
|
||||
const verifyContext = context.someContextProp;
|
||||
// $ExpectType GraphQLResolveInfo
|
||||
const verifyInfo = info;
|
||||
|
||||
const result = await asyncBatchFunction(sources);
|
||||
return result;
|
||||
|
||||
+4
-1
@@ -4,6 +4,8 @@
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { GraphQLResolveInfo } from 'graphql';
|
||||
|
||||
/**
|
||||
* Creates a GraphQL.js field resolver that batches together multiple resolves
|
||||
* together that share the *exact* same GraphQL field selection.
|
||||
@@ -45,5 +47,6 @@ export type ResolverFunction<TSource, TArgs, TContext, TReturn> = (
|
||||
export type BatchResolveFunction<TSource, TArgs, TContext, TReturn> = (
|
||||
sources: ReadonlyArray<TSource>,
|
||||
args: TArgs,
|
||||
context: TContext
|
||||
context: TContext,
|
||||
info: GraphQLResolveInfo
|
||||
) => TReturn[] | Promise<TReturn[]>;
|
||||
|
||||
Vendored
+2
-3
@@ -1,7 +1,6 @@
|
||||
// Type definitions for hapi 17.0
|
||||
// Project: https://github.com/hapijs/hapi
|
||||
// Definitions by: Marc Bornträger <https://github.com/BorntraegerMarc>
|
||||
// Rafael Souza Fijalkowski <https://github.com/rafaelsouzaf>
|
||||
// Definitions by: Rafael Souza Fijalkowski <https://github.com/rafaelsouzaf>
|
||||
// Justin Simms <https://github.com/jhsimms>
|
||||
// Simon Schick <https://github.com/SimonSchick>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -3790,7 +3789,7 @@ export class Server extends Podium {
|
||||
* * path - the route path.
|
||||
* [See docs](https://github.com/hapijs/hapi/blob/master/API.md#-servertablehost)
|
||||
*/
|
||||
table(host?: string): Array<{settings: ServerRoute; method: Util.HTTP_METHODS_PARTIAL_LOWERCASE, path: string}>; // TODO I am not sure if the ServerRoute is the object expected here
|
||||
table(host?: string): RequestRoute[];
|
||||
}
|
||||
|
||||
/* + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
|
||||
@@ -19,4 +19,11 @@ server.route({
|
||||
server.start();
|
||||
const table = server.table();
|
||||
console.log(table);
|
||||
console.log(table[0].method);
|
||||
console.log(table[0].path);
|
||||
console.log(table[0].vhost);
|
||||
console.log(table[0].realm);
|
||||
console.log(table[0].settings);
|
||||
console.log(table[0].fingerprint);
|
||||
console.log(table[0].auth);
|
||||
console.log('Server started at: ' + server.info.uri);
|
||||
|
||||
Vendored
+3
-2
@@ -8,6 +8,7 @@
|
||||
// Synarque <https://github.com/synarque>
|
||||
// Justin Rockwood <https://github.com/jrockwood>
|
||||
// Keith Kelly <https://github.com/kwkelly>
|
||||
// Junyoung Clare Jang <https://github.com/Ailrun>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
// TypeScript Version: 2.3
|
||||
@@ -116,12 +117,12 @@ declare namespace inquirer {
|
||||
* Receive the user input and should return true if the value is valid, and an error message (String)
|
||||
* otherwise. If false is returned, a default error message is provided.
|
||||
*/
|
||||
validate?(input: string, answers?: T): boolean | string | Promise<boolean | string>;
|
||||
validate?(input: any, answers?: T): boolean | string | Promise<boolean | string>;
|
||||
/**
|
||||
* Receive the user input and return the filtered value to be used inside the program.
|
||||
* The value returned will be added to the Answers hash.
|
||||
*/
|
||||
filter?(input: string): string | Promise<string>;
|
||||
filter?(input: string): any;
|
||||
/**
|
||||
* Receive the user input and return the transformed value to be displayed to the user. The
|
||||
* transformation only impacts what is shown while editing. It does not impact the answers
|
||||
|
||||
@@ -670,3 +670,17 @@ var questions = [
|
||||
inquirer.createPromptModule({ output: process.stderr })(questions, function(answers) {
|
||||
console.log(JSON.stringify(answers, null, " "));
|
||||
});
|
||||
|
||||
// Work with JS inquirer but rejected by typing.
|
||||
inquirer.prompt([
|
||||
{
|
||||
type: "input",
|
||||
name: "listOfThings",
|
||||
filter(value: string): string[] {
|
||||
return ["abc", "def"];
|
||||
},
|
||||
validate(value: string[]): boolean {
|
||||
return value.length > 0;
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
Vendored
+46
@@ -0,0 +1,46 @@
|
||||
// Type definitions for is-uuid 1.0
|
||||
// Project: https://github.com/afram/is-uuid#readme
|
||||
// Definitions by: André Thériault <https://github.com/tedre191>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
/**
|
||||
* Returns true if the value is a v1 UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function v1(value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value is a v2 UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function v2(value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value is a v3 UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function v3(value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value is a v4 UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function v4(value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value is a v5 UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function v5(value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true if the value is a nil UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function nil(value: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns true for v1 - v5 UUID. Will return false for nil UUID
|
||||
* @param value The value to test
|
||||
*/
|
||||
export function anyNonNil(value: string): boolean;
|
||||
@@ -0,0 +1,10 @@
|
||||
import * as isUUID from 'is-uuid';
|
||||
|
||||
isUUID.v1('857b3f0a-a777-11e5-bf7f-feff819cdc9f');
|
||||
isUUID.v2('9a7b330a-a736-21e5-af7f-feaf819cdc9f');
|
||||
isUUID.v3('0a7b330a-a736-35ea-8f7f-feaf019cdc00');
|
||||
isUUID.v4('c51c80c2-66a1-442a-91e2-4f55b4256a72');
|
||||
isUUID.v5('5a2de30a-a736-5aea-8f7f-ad0f019cdc00');
|
||||
|
||||
isUUID.anyNonNil('c51c80c2-66a1-442a-91e2-4f55b4256a72');
|
||||
isUUID.nil('00000000-0000-0000-0000-000000000000');
|
||||
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strictFunctionTypes": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"is-uuid-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Vendored
+15
-3
@@ -146,12 +146,24 @@ interface JQueryStatic {
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
|
||||
* by passing an HTML string.
|
||||
*
|
||||
* @param element_elementArray A DOM element to wrap in a jQuery object.
|
||||
* An array containing a set of DOM elements to wrap in a jQuery object.
|
||||
* @param element A DOM element to wrap in a jQuery object.
|
||||
* @see \`{@link https://api.jquery.com/jQuery/ }\`
|
||||
* @since 1.0
|
||||
*/
|
||||
<T extends Element>(element_elementArray: T | ArrayLike<T>): JQuery<T>;
|
||||
// Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810)
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
<T extends Element>(element: T): JQuery<T>;
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
|
||||
* by passing an HTML string.
|
||||
*
|
||||
* @param elementArray An array containing a set of DOM elements to wrap in a jQuery object.
|
||||
* @see \`{@link https://api.jquery.com/jQuery/ }\`
|
||||
* @since 1.0
|
||||
*/
|
||||
// Using a unified signature is not possible due to a TypeScript 2.4 bug (DefinitelyTyped#27810)
|
||||
// tslint:disable-next-line:unified-signatures
|
||||
<T extends Element>(elementArray: T[]): JQuery<T>;
|
||||
/**
|
||||
* Return a collection of matched elements either found in the DOM based on passed argument(s) or created
|
||||
* by passing an HTML string.
|
||||
|
||||
@@ -69,6 +69,12 @@ function JQueryStatic() {
|
||||
// $ExpectType JQuery<Element>
|
||||
$<Element>();
|
||||
|
||||
// $ExpectType JQuery<HTMLSelectElement>
|
||||
$(new HTMLSelectElement());
|
||||
|
||||
// $ExpectType JQuery<HTMLSelectElement>
|
||||
$([new HTMLSelectElement()]);
|
||||
|
||||
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/19597#issuecomment-378218432
|
||||
function issue_19597_378218432() {
|
||||
const myDiv = $(document.createElement('div'));
|
||||
|
||||
Vendored
+20
-11
@@ -10,8 +10,16 @@ import { Metadata } from './api/metadata';
|
||||
import { Bulk } from './bulk';
|
||||
import { Cache } from './cache'
|
||||
import { OAuth2, Streaming } from '.';
|
||||
import { HttpApiOptions } from './http-api'
|
||||
|
||||
export type Callback<T> = (err: Error, result: T) => void;
|
||||
export type Callback<T> = (err: Error | null, result: T) => void;
|
||||
// The type for these options was determined by looking at the usage
|
||||
// of the options object in Connection.create and other methods
|
||||
// go to http://jsforce.github.io/jsforce/doc/connection.js.html#line568
|
||||
// and search for options
|
||||
export interface RestApiOptions {
|
||||
headers?: { [x: string]: string }
|
||||
}
|
||||
|
||||
// These are pulled out because according to http://jsforce.github.io/jsforce/doc/connection.js.html#line49
|
||||
// the oauth options can either be in the `oauth2` proeprty OR spread across the main connection
|
||||
@@ -93,24 +101,24 @@ export type ConnectionEvent = "refresh";
|
||||
*/
|
||||
export abstract class BaseConnection extends EventEmitter {
|
||||
_baseUrl(): string;
|
||||
request(info: RequestInfo | string, options?: Object, callback?: (err: Error, Object: object) => void): Promise<Object>;
|
||||
request(info: RequestInfo | string, options?: HttpApiOptions, callback?: (err: Error, Object: object) => void): Promise<Object>;
|
||||
query<T>(soql: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult<T>) => void): Query<QueryResult<T>>;
|
||||
queryMore<T>(locator: string, options?: ExecuteOptions, callback?: (err: Error, result: QueryResult<T>) => void): Promise<QueryResult<T>>;
|
||||
create<T>(type: string, records: Record<T> | Array<Record<T>>, options?: Object,
|
||||
create<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
insert<T>(type: string, records: Record<T> | Array<Record<T>>, options?: Object,
|
||||
insert<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
retrieve<T>(type: string, ids: string | string[], options?: Object,
|
||||
retrieve<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
||||
callback?: (err: Error, result: Record<T> | Array<Record<T>>) => void): Promise<(Record<T> | Array<Record<T>>)>;
|
||||
update<T>(type: string, records: Record<T> | Array<Record<T>>, options?: Object,
|
||||
update<T>(type: string, records: Record<T> | Array<Record<T>>, options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | Array<Record<T>>) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
upsert<T>(type: string, records: Record<T> | Array<Record<T>>, extIdField: string, options?: Object,
|
||||
upsert<T>(type: string, records: Record<T> | Array<Record<T>>, extIdField: string, options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
del<T>(type: string, ids: string | string[], options?: Object,
|
||||
del<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
delete<T>(type: string, ids: string | string[], options?: Object,
|
||||
delete<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
destroy<T>(type: string, ids: string | string[], options?: Object,
|
||||
destroy<T>(type: string, ids: string | string[], options?: RestApiOptions,
|
||||
callback?: (err: Error, result: RecordResult | RecordResult[]) => void): Promise<(RecordResult | RecordResult[])>;
|
||||
describe$: {
|
||||
/** Returns a value from the cache if it exists, otherwise calls Connection.describe */
|
||||
@@ -124,7 +132,8 @@ export abstract class BaseConnection extends EventEmitter {
|
||||
clear(): void;
|
||||
}
|
||||
describeGlobal<T>(callback?: (err: Error, result: DescribeGlobalResult) => void): Promise<DescribeGlobalResult>;
|
||||
sobject<T>(resource: string): SObject<T>;
|
||||
// we want any object to be accepted if the user doesn't decide to give an explicit type
|
||||
sobject<T = object>(resource: string): SObject<T>;
|
||||
}
|
||||
|
||||
export class Connection extends BaseConnection {
|
||||
|
||||
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
export interface HttpApiOptions {
|
||||
responseType?: string;
|
||||
transport?: object;
|
||||
noContentResponse?: object
|
||||
}
|
||||
Vendored
+1
-1
@@ -6,7 +6,7 @@
|
||||
// Tim Noonan <https://github.com/tnoonan-salesforce>
|
||||
// Abraham White <https://github.com/whiteabelincoln>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
export * from './api/analytics';
|
||||
export * from './api/chatter';
|
||||
|
||||
+393
-56
@@ -4,12 +4,9 @@ import * as express from 'express';
|
||||
import * as glob from 'glob';
|
||||
|
||||
import * as sf from 'jsforce';
|
||||
|
||||
export interface DummyRecord {
|
||||
thing: boolean;
|
||||
other: number;
|
||||
person: string;
|
||||
}
|
||||
import { RecordReference, Record } from 'jsforce/record';
|
||||
import { SObject } from 'jsforce/salesforce-object';
|
||||
import { RecordResult } from 'jsforce/record-result';
|
||||
|
||||
const salesforceConnection: sf.Connection = new sf.Connection({
|
||||
instanceUrl: '',
|
||||
@@ -20,7 +17,390 @@ const salesforceConnection: sf.Connection = new sf.Connection({
|
||||
},
|
||||
});
|
||||
|
||||
salesforceConnection.sobject<DummyRecord>("Dummy").select(["thing", "other"]);
|
||||
async function testSObject(connection: sf.Connection) {
|
||||
interface DummyRecord {
|
||||
thing: boolean;
|
||||
other: number;
|
||||
person: string;
|
||||
}
|
||||
|
||||
const dummySObject: SObject<DummyRecord> = connection.sobject<DummyRecord>('Dummy');
|
||||
|
||||
// currently untyped, but some future change may make this stricter
|
||||
const restApiOptions = {
|
||||
headers: { Bearer: 'I have no idea what this wants' }
|
||||
};
|
||||
|
||||
{ // Test SObject.record
|
||||
// $ExpectType RecordReference<DummyRecord>
|
||||
dummySObject.record('50130000000014C');
|
||||
}
|
||||
|
||||
{ // Test SObject.retrieve
|
||||
// with single id
|
||||
// $ExpectType Record<DummyRecord>
|
||||
await dummySObject.retrieve('50130000000014C');
|
||||
// with single id and rest api options
|
||||
// $ExpectType Record<DummyRecord>
|
||||
await dummySObject.retrieve('50130000000014C', restApiOptions);
|
||||
|
||||
// with single id and callback
|
||||
dummySObject.retrieve('50130000000014C', restApiOptions, (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType Record<DummyRecord>
|
||||
});
|
||||
|
||||
// with ids array
|
||||
// $ExpectType Record<DummyRecord>[]
|
||||
await dummySObject.retrieve(['IIIIDDD']);
|
||||
// with ids array and rest api options
|
||||
// $ExpectType Record<DummyRecord>[]
|
||||
await dummySObject.retrieve(['IIIIDDD'], restApiOptions);
|
||||
|
||||
// with ids array and callback
|
||||
dummySObject.retrieve(['50130000000014C'], restApiOptions, (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType Record<DummyRecord>[]
|
||||
});
|
||||
|
||||
salesforceConnection.sobject<any>("ContentVersion").retrieve("world", {
|
||||
test: "test"
|
||||
}, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType any
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.update
|
||||
// if we require that records have an id field this will fail
|
||||
// //$ExpectError
|
||||
await dummySObject.update({ thing: false });
|
||||
|
||||
// If we require that the records have an Id field
|
||||
// await dummySObject.update({ thing: false, Id: 'asdf' }); // $ExpectType RecordResult
|
||||
|
||||
// invalid field
|
||||
// $ExpectError
|
||||
await dummySObject.update({ asdf: false });
|
||||
|
||||
// with rest api options
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.update({ thing: false }, restApiOptions);
|
||||
|
||||
// with callback
|
||||
dummySObject.update({ thing: false }, (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
dummySObject.update({ thing: false }, restApiOptions, (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
// with multiple records
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.update([{ thing: false }]);
|
||||
|
||||
// with multiple records and api options
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.update([{ thing: false }], restApiOptions);
|
||||
|
||||
// with multiple records and callback
|
||||
dummySObject.update([{ thing: false }], restApiOptions, (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
|
||||
dummySObject.update([{ thing: false }], (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.updated
|
||||
// $ExpectType UpdatedRecordsInfo
|
||||
await dummySObject.updated(new Date(), new Date());
|
||||
|
||||
// $ExpectType UpdatedRecordsInfo
|
||||
await dummySObject.updated(new Date(), 'hi');
|
||||
|
||||
// $ExpectType UpdatedRecordsInfo
|
||||
await dummySObject.updated('hi', new Date());
|
||||
|
||||
// $ExpectType UpdatedRecordsInfo
|
||||
await dummySObject.updated('hi', 'hi');
|
||||
|
||||
dummySObject.updated(new Date(), 'hi', (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType UpdatedRecordsInfo
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.upsert
|
||||
const updateData = {
|
||||
Id: 'Some ID',
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
};
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.upsert(updateData, 'Id');
|
||||
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.upsert(updateData, 'Id', restApiOptions);
|
||||
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.upsert([updateData], 'Id');
|
||||
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.upsert([updateData], 'Id', restApiOptions);
|
||||
|
||||
dummySObject.upsert(updateData, 'Id', (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
dummySObject.upsert(updateData, 'Id', restApiOptions, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
dummySObject.upsert([updateData], 'Id', (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
|
||||
dummySObject.upsert([updateData], 'Id', restApiOptions, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.find
|
||||
}
|
||||
|
||||
{ // Test SObject.findOne
|
||||
salesforceConnection.sobject("ContentVersion").findOne<any>({ Id: '' }, (err, contentVersion) => {
|
||||
err; // $ExpectType Error | null
|
||||
contentVersion; // $ExpectType any
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.select
|
||||
|
||||
dummySObject.select(["thing", "other"]);
|
||||
|
||||
// note the following should never compile:
|
||||
// $ExpectError
|
||||
dummySObject.select(["lol"]);
|
||||
}
|
||||
|
||||
{ // Test SObject.create
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.create({
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
});
|
||||
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.create({
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
}, restApiOptions);
|
||||
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.create([{
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
}]);
|
||||
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.create([{
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
}], restApiOptions);
|
||||
|
||||
dummySObject.create([{
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
}], (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
|
||||
dummySObject.create([{
|
||||
thing: true,
|
||||
other: 1,
|
||||
person: 'hi'
|
||||
}], restApiOptions, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
|
||||
salesforceConnection.sobject("Account").create({
|
||||
Name: "Test Acc 2",
|
||||
BillingStreet: "Maplestory street",
|
||||
BillingPostalCode: "ME4 666"
|
||||
}, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
// callback and rest api options
|
||||
salesforceConnection.sobject("ContentVersion").create({
|
||||
OwnerId: '',
|
||||
Title: 'hello',
|
||||
PathOnClient: './hello-world.jpg',
|
||||
VersionData: '{ Test: Data }'
|
||||
}, restApiOptions, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
salesforceConnection.sobject("ContentDocumentLink").create({
|
||||
ContentDocumentId: '',
|
||||
LinkedEntityId: '',
|
||||
ShareType: "I"
|
||||
}, (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.createBulk
|
||||
// $ExpectType Batch
|
||||
dummySObject.createBulk();
|
||||
// $ExpectType Batch
|
||||
dummySObject.createBulk('hi.csv');
|
||||
// $ExpectType Batch
|
||||
dummySObject.createBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]);
|
||||
// $ExpectType Batch
|
||||
dummySObject.createBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.createBulk('hi.csv', (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.deleteBulk and aliases
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteBulk();
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteBulk('hi.csv');
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]);
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.deleteBulk('hi.csv', (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyBulk();
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyBulk('hi.csv');
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]);
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.destroyBulk('hi.csv', (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.deleteHardBulk and aliases
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteHardBulk();
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteHardBulk('hi.csv');
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]);
|
||||
// $ExpectType Batch
|
||||
dummySObject.deleteHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.deleteHardBulk('hi.csv', (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyHardBulk();
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyHardBulk('hi.csv');
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }]);
|
||||
// $ExpectType Batch
|
||||
dummySObject.destroyHardBulk([{ Id: 'hi', thing: true, other: 1, person: 'you' }], (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.destroyHardBulk('hi.csv', (err, res) => {
|
||||
err; // $ExpectType Error | null
|
||||
res; // $ExpectType RecordResult[]
|
||||
});
|
||||
}
|
||||
|
||||
{ // Test SObject.destroy and aliases
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.del('Id');
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.destroy('Id');
|
||||
// $ExpectType RecordResult
|
||||
await dummySObject.delete('Id');
|
||||
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.del(['Id']);
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.destroy(['Id']);
|
||||
// $ExpectType RecordResult[]
|
||||
await dummySObject.delete(['Id']);
|
||||
|
||||
dummySObject.del('Id', (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
dummySObject.destroy('Id', (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
dummySObject.delete('Id', (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult
|
||||
});
|
||||
|
||||
dummySObject.del(['Id'], (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.destroy(['Id'], (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
dummySObject.delete(['Id'], (err, ret) => {
|
||||
err; // $ExpectType Error | null
|
||||
ret; // $ExpectType RecordResult[]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const requestInfo: sf.RequestInfo = {
|
||||
body: '',
|
||||
@@ -38,51 +418,6 @@ const queryOptions: sf.ExecuteOptions = {
|
||||
};
|
||||
salesforceConnection.query('SELECT Id, Name FROM Account', queryOptions);
|
||||
|
||||
// note the following should never compile:
|
||||
// salesforceConnection.sobject<DummyRecord>("Dummy").select(["lol"]);
|
||||
|
||||
salesforceConnection.sobject("Account").create({
|
||||
Name: "Test Acc 2",
|
||||
BillingStreet: "Maplestory street",
|
||||
BillingPostalCode: "ME4 666"
|
||||
}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => {
|
||||
if (err || !Array.isArray(ret) && !ret.success) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
salesforceConnection.sobject("ContentVersion").create({
|
||||
OwnerId: '',
|
||||
Title: 'hello',
|
||||
PathOnClient: './hello-world.jpg',
|
||||
VersionData: '{ Test: Data }'
|
||||
}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => {
|
||||
if (err || !Array.isArray(ret) && !ret.success) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
salesforceConnection.sobject<any>("ContentVersion").retrieve("world", {
|
||||
test: "test"
|
||||
}, (err: Error, ret) => {
|
||||
if (err) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
salesforceConnection.sobject("ContentVersion").findOne<any>({ Id: '' }, (err, contentVersion) => {
|
||||
});
|
||||
|
||||
salesforceConnection.sobject("ContentDocumentLink").create({
|
||||
ContentDocumentId: '',
|
||||
LinkedEntityId: '',
|
||||
ShareType: "I"
|
||||
}, (err: Error, ret: sf.RecordResult | sf.RecordResult[]) => {
|
||||
if (err || !Array.isArray(ret) && !ret.success) {
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
sf.Date.YESTERDAY;
|
||||
|
||||
salesforceConnection.sobject<any>('Coverage__c')
|
||||
@@ -230,7 +565,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
},
|
||||
feedElementType: 'FeedItem',
|
||||
subjectId: 'me'
|
||||
}, (err: Error, result: any) => {
|
||||
}, (err: Error | null, result: any) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
@@ -242,7 +577,7 @@ async function testChatter(conn: sf.Connection): Promise<void> {
|
||||
text: 'This is new comment on the post'
|
||||
}]
|
||||
}
|
||||
}, (err: Error, result: any) => {
|
||||
}, (err: Error | null, result: any) => {
|
||||
if (err) {
|
||||
throw err;
|
||||
}
|
||||
@@ -366,13 +701,15 @@ async function testDescribe() {
|
||||
object.fields.forEach(field => {
|
||||
const type: sf.FieldType = field.type;
|
||||
// following should never compile
|
||||
// const fail = type === 'hey'
|
||||
// $ExpectError
|
||||
const fail = type === 'hey';
|
||||
|
||||
const isString = type === 'string';
|
||||
});
|
||||
|
||||
// following should never compile (if StrictNullChecks is on)
|
||||
// object.keyPrefix.length;
|
||||
// $ExpectError
|
||||
object.keyPrefix.length;
|
||||
|
||||
console.log(`${sobject.name} Label: `, object.label);
|
||||
|
||||
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
import { Callback } from './connection';
|
||||
import { Record } from './record';
|
||||
|
||||
export class QuickAction {
|
||||
/**
|
||||
* Retrieve default field values in the action for the given record
|
||||
* @param contextId Id of record
|
||||
* @param callback Callback function
|
||||
*/
|
||||
defaultValues(contextId: string, callback?: Callback<Record>): Promise<Record>;
|
||||
/** Retrieve default field values in the action */
|
||||
defaultValues(callback?: Callback<Record>): Promise<Record>;
|
||||
/**
|
||||
* Describe the action's information (including layout, etc.)
|
||||
* @param callback Callback function
|
||||
*/
|
||||
describe(callback?: Callback<QuickActionDescribeInfo>): Promise<QuickActionDescribeInfo>;
|
||||
/**
|
||||
* Execute the action for given context id and record information
|
||||
* @param contextId Context record ID of the action
|
||||
* @param record Input record information for the action
|
||||
* @param callback Callback function
|
||||
*/
|
||||
execute<T>(contextId: string, record: Record<T>, callback?: Callback<QuickActionResult>): Promise<QuickActionResult>;
|
||||
}
|
||||
|
||||
// TODO: figure out the actual shape of this. the docs don't have it
|
||||
export type QuickActionResult = object;
|
||||
|
||||
export interface QuickActionInfo {
|
||||
/** Type of the action (e.g. Create, Update, Post, LogACall) */
|
||||
type: string;
|
||||
/** Name of the action */
|
||||
name: string;
|
||||
/** Label of the action */
|
||||
label: string;
|
||||
/** Endpoint URL information of the action */
|
||||
urls: object;
|
||||
}
|
||||
|
||||
export interface QuickActionDescribeInfo {
|
||||
/** Object type used for the action */
|
||||
contextSobjectType: string;
|
||||
/** Object type of the action to target */
|
||||
targetSobjectType: string;
|
||||
/** Field name in the target object which refers parent(context) object record ID */
|
||||
targetParentField: string;
|
||||
/** Record type of the targeted record */
|
||||
targetRecordTypeId: string;
|
||||
/** Layout sections that comprise an action */
|
||||
layout: object;
|
||||
}
|
||||
Vendored
+72
-42
@@ -5,74 +5,103 @@ import { DescribeSObjectResult } from './describe-result';
|
||||
import { Query } from './query';
|
||||
import { Record, RecordReference } from './record';
|
||||
import { RecordResult } from './record-result';
|
||||
import { Connection } from './connection';
|
||||
import { Connection, RestApiOptions, Callback } from './connection';
|
||||
import { SalesforceId } from './salesforce-id';
|
||||
import { Batch, BatchResultInfo } from './batch';
|
||||
import { QuickAction, QuickActionInfo } from './quick-action';
|
||||
|
||||
export class SObject<T> {
|
||||
record(id: SalesforceId): RecordReference<T>;
|
||||
retrieve(id: SalesforceId, options?: Object, callback?: (err: Error, record: Record<T>) => void): Promise<Record<T>>;
|
||||
retrieve(ids: SalesforceId[], options?: Object, callback?: (err: Error, ret: Array<Record<T>>) => void): Promise<Array<Record<T>>>;
|
||||
update(record: Partial<T>, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult>;
|
||||
update(records: Array<Partial<T>>, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise<RecordResult[]>;
|
||||
upsert(records: Record<T>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult>;
|
||||
upsert(records: Array<Record<T>>, extIdField: SalesforceId, options?: Object, callback?: (err: Error, ret: RecordResult[]) => void): Promise<RecordResult[]>;
|
||||
upsertBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult[] | BatchResultInfo[]) => void): Batch;
|
||||
retrieve(id: SalesforceId, callback?: Callback<Record<T>>): Promise<Record<T>>;
|
||||
retrieve(id: SalesforceId, options?: object, callback?: Callback<Record<T>>): Promise<Record<T>>;
|
||||
retrieve(ids: SalesforceId[], callback?: Callback<Array<Record<T>>>): Promise<Array<Record<T>>>;
|
||||
retrieve(ids: SalesforceId[], options?: object, callback?: Callback<Array<Record<T>>>): Promise<Array<Record<T>>>;
|
||||
// Should update require that the record Id field be provided?
|
||||
update(record: Partial<T>, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
update(record: Partial<T>, options?: RestApiOptions, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
update(records: Array<Partial<T>>, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
update(records: Array<Partial<T>>, options?: RestApiOptions, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
// should input really be optional? the documentation says so, but how can you actually update without it?
|
||||
updateBulk(input?: Record[] | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
updated(start: string | Date, end: string | Date, callback?: Callback<UpdatedRecordsInfo>): Promise<UpdatedRecordsInfo>;
|
||||
upsert(records: Record<T>, extIdField: string, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
upsert(records: Record<T>, extIdField: string, options?: RestApiOptions, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
upsert(records: Array<Record<T>>, extIdField: string, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
upsert(records: Array<Record<T>>, extIdField: string, options?: RestApiOptions, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
upsertBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[] | BatchResultInfo[]>): Batch;
|
||||
|
||||
find<T>(query?: any, callback?: (err: Error, ret: T[]) => void): Query<T>;
|
||||
find<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T[]) => void): Query<T>;
|
||||
find<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T[]) => void): Query<T>;
|
||||
find<T>(query?: object | string, callback?: Callback<Array<Record<T>>>): Query<Array<Record<T>>>;
|
||||
find<T>(query?: object | string, fields?: Object | string[] | string, callback?: Callback<Array<Record<T>>>): Query<Array<Record<T>>>;
|
||||
find<T>(query?: object | string, fields?: Object | string[] | string, options?: FindOptions, callback?: Callback<Array<Record<T>>>): Query<Array<Record<T>>>;
|
||||
|
||||
findOne<T>(query?: any, callback?: (err: Error, ret: T) => void): Query<T>;
|
||||
findOne<T>(query?: any, fields?: Object | string[] | string, callback?: (err: Error, ret: T) => void): Query<T>;
|
||||
findOne<T>(query?: any, fields?: Object | string[] | string, options?: Object, callback?: (err: Error, ret: T) => void): Query<T>;
|
||||
findOne<T>(query?: object | string, callback?: Callback<Record<T>>): Query<Record<T>>;
|
||||
findOne<T>(query?: object | string, fields?: Object | string[] | string, callback?: Callback<Record<T>>): Query<Record<T>>;
|
||||
findOne<T>(query?: object | string, fields?: Object | string[] | string, options?: FindOptions, callback?: Callback<Record<T>>): Query<Record<T>>;
|
||||
|
||||
approvalLayouts$: {
|
||||
/** Returns a value from the cache if it exists, otherwise calls SObject.approvalLayouts */
|
||||
(callback?: (layoutInfo: ApprovalLayoutInfo) => void): ApprovalLayoutInfo;
|
||||
(callback?: Callback<ApprovalLayoutInfo>): ApprovalLayoutInfo;
|
||||
clear(): void;
|
||||
}
|
||||
approvalLayouts(callback?: (layoutInfo: ApprovalLayoutInfo) => void): Promise<ApprovalLayoutInfo>;
|
||||
bulkload(operation: string, options?: { extIdField?: string }, input?: Array<Record<T>> | stream.Stream[] | string[], callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
approvalLayouts(callback?: Callback<ApprovalLayoutInfo>): Promise<ApprovalLayoutInfo>;
|
||||
bulkload(operation: string, options?: { extIdField?: string }, input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
compactLayouts$: {
|
||||
/** Returns a value from the cache if it exists, otherwise calls SObject.compactLayouts */
|
||||
(callback?: CompactLayoutInfo): CompactLayoutInfo;
|
||||
(callback?: Callback<CompactLayoutInfo>): CompactLayoutInfo;
|
||||
clear(): void;
|
||||
}
|
||||
compactLayouts(callback?: CompactLayoutInfo): Promise<CompactLayoutInfo>;
|
||||
count(conditions?: Object | string, callback?: (err: Error, num: number) => void): Promise<number>;
|
||||
create(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise<RecordResult | RecordResult[]>;
|
||||
createBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
del(ids: string | string[], callback?: (err: Error, ret: any) => void): void;
|
||||
destroy(ids: string | string[], callback?: (err: Error, ret: any) => void): void;
|
||||
delete(ids: string | string[], callback?: (err: Error, ret: any) => void): void;
|
||||
deleteBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
destroyBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
destroyHardBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
deleted(start: Date | string, end: Date | string, callback?: (info: DeletedRecordsInfo) => void): Promise<DeletedRecordsInfo>;
|
||||
deleteHardBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
describe(callback?: (err: Error, ret: DescribeSObjectResult) => void): Promise<DescribeSObjectResult>;
|
||||
compactLayouts(callback?: Callback<CompactLayoutInfo>): Promise<CompactLayoutInfo>;
|
||||
count(conditions?: object | string, callback?: Callback<number>): Query<number>;
|
||||
create(record: T, options?: RestApiOptions, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
create(record: T, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
create(record: Array<T>, options?: RestApiOptions, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
create(record: Array<T>, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
createBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
del(id: string, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
del(ids: string[], callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
destroy(id: string, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
destroy(ids: string[], callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
delete(id: string, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
delete(ids: string[], callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
deleteBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
destroyBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
destroyHardBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
deleted(start: Date | string, end: Date | string, callback?: Callback<DeletedRecordsInfo>): Promise<DeletedRecordsInfo>;
|
||||
deleteHardBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
describe(callback?: Callback<DescribeSObjectResult>): Promise<DescribeSObjectResult>;
|
||||
describe$: {
|
||||
/** Returns a value from the cache if it exists, otherwise calls SObject.describe */
|
||||
(callback?: (err: Error, ret: DescribeSObjectResult) => void): DescribeSObjectResult;
|
||||
(callback?: Callback<DescribeSObjectResult>): DescribeSObjectResult;
|
||||
clear(): void;
|
||||
}
|
||||
insert(options: any | any[], callback?: (err: Error, ret: RecordResult | RecordResult[]) => void): Promise<RecordResult | RecordResult[]>;
|
||||
insertBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: (err: Error, ret: RecordResult) => void): Batch;
|
||||
insert(record: Record<T>, callback?: Callback<RecordResult>): Promise<RecordResult>;
|
||||
insert(records: Array<Record<T>>, callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
insertBulk(input?: Array<Record<T>> | stream.Stream | string, callback?: Callback<RecordResult[]>): Batch;
|
||||
/** Returns a value from the cache if it exists, otherwise calls SObject.layouts */
|
||||
layouts$: {
|
||||
(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): LayoutInfo;
|
||||
(layoutName?: string, callback?: Callback<LayoutInfo>): LayoutInfo;
|
||||
clear(): void;
|
||||
}
|
||||
layouts(layoutName?: string, callback?: (err: Error, info: LayoutInfo) => void): Promise<LayoutInfo>;
|
||||
layouts(layoutName?: string, callback?: Callback<LayoutInfo>): Promise<LayoutInfo>;
|
||||
listview(id: string): ListView;
|
||||
listviews(callback?: (err: Error, info: ListViewsInfo) => void): Promise<ListViewsInfo>;
|
||||
listviews(callback?: Callback<ListViewsInfo>): Promise<ListViewsInfo>;
|
||||
quickAction(actionName: string): QuickAction;
|
||||
quickActions(callback?: (err: Error, info: any) => void): Promise<any>;
|
||||
recent(callback?: (err: Error, ret: RecordResult) => void): Promise<RecordResult>;
|
||||
select(callback?: (err: Error, ret: T[]) => void): Query<T[]>;
|
||||
quickActions(callback?: Callback<QuickActionInfo[]>): Promise<QuickActionInfo[]>;
|
||||
recent(callback?: Callback<RecordResult[]>): Promise<RecordResult[]>;
|
||||
select(callback?: Callback<T[]>): Query<T[]>;
|
||||
// TODO:use a typed pluck to turn `fields` into a subset of T's fields so that the output is slimmed down appropriately
|
||||
select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: (err: Error, ret: Array<Partial<T>>) => void): Query<Array<Partial<T>>>;
|
||||
select(fields?: {[P in keyof T]: boolean} | Array<(keyof T)> | (keyof T), callback?: Callback<Array<Partial<T>>>): Query<Array<Partial<T>>>;
|
||||
}
|
||||
|
||||
export interface FindOptions {
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
skip?: number;
|
||||
}
|
||||
|
||||
export interface UpdatedRecordsInfo {
|
||||
latestDateCovered: string;
|
||||
ids: string[];
|
||||
}
|
||||
|
||||
export interface ApprovalLayoutInfo {
|
||||
@@ -104,4 +133,5 @@ export class ListView {
|
||||
}
|
||||
|
||||
export class ListViewsInfo { }
|
||||
export class QuickAction { }
|
||||
// TODO: Remove this export
|
||||
export { QuickAction } // for compatibility if anyone had imported it from this file
|
||||
|
||||
Vendored
+1
@@ -536,6 +536,7 @@ declare namespace Knex {
|
||||
acquireConnectionTimeout?: number;
|
||||
useNullAsDefault?: boolean;
|
||||
searchPath?: string | string[];
|
||||
asyncStackTraces?: boolean;
|
||||
}
|
||||
|
||||
interface ConnectionConfig {
|
||||
|
||||
+4
@@ -90,3 +90,7 @@ declare module "moment" {
|
||||
|
||||
type TemplateFunction = ((this: DurationFormatSettings) => string);
|
||||
}
|
||||
|
||||
declare function momentDurationFormatSetup(_moment: typeof moment): void;
|
||||
|
||||
export = momentDurationFormatSetup;
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
import moment = require("moment");
|
||||
import momentDurationFormatSetup = require("moment-duration-format");
|
||||
|
||||
momentDurationFormatSetup(moment);
|
||||
@@ -18,6 +18,7 @@
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"moment-duration-format-tests.ts"
|
||||
"moment-duration-format-tests.ts",
|
||||
"test/module-tests.ts"
|
||||
]
|
||||
}
|
||||
Vendored
+208
-113
@@ -1,125 +1,220 @@
|
||||
// Type definitions for N3
|
||||
// Type definitions for N3 1.0
|
||||
// Project: https://github.com/RubenVerborgh/N3.js
|
||||
// Definitions by: Fred Eisele <https://github.com/phreed>
|
||||
// Ruben Taelman <https://github.com/rubensworks>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.1
|
||||
|
||||
/// <reference types="node" />
|
||||
|
||||
|
||||
import * as fs from "fs";
|
||||
import * as stream from "stream";
|
||||
import * as RDF from "rdf-js";
|
||||
import { EventEmitter } from "events";
|
||||
|
||||
declare namespace N3 {
|
||||
|
||||
type ErrorCallback = (err: Error, result: any) => void;
|
||||
|
||||
interface Prefixes {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
interface LiteralValue {
|
||||
value: string | number;
|
||||
}
|
||||
|
||||
interface Triple {
|
||||
subject: string,
|
||||
predicate: string,
|
||||
object: string,
|
||||
graph?: string
|
||||
}
|
||||
|
||||
interface BlankTriple {
|
||||
predicate: string,
|
||||
object: string
|
||||
}
|
||||
|
||||
|
||||
interface ParserConstructor {
|
||||
new (options?: ParserOptions): N3Parser;
|
||||
(options?: ParserOptions): N3Parser;
|
||||
}
|
||||
const Parser: ParserConstructor;
|
||||
|
||||
interface StreamParserConstructor {
|
||||
new (options?: ParserOptions): N3StreamParser;
|
||||
(options?: ParserOptions): N3StreamParser;
|
||||
}
|
||||
const StreamParser: StreamParserConstructor;
|
||||
|
||||
interface ParserOptions {
|
||||
format?: string,
|
||||
prefixes?: string[]
|
||||
}
|
||||
|
||||
interface ParseCallback {
|
||||
(error: Error, triple: Triple, prefixes: Prefixes): void;
|
||||
}
|
||||
|
||||
interface Logger {
|
||||
(message?: any, ...optionalParams: any[]): void;
|
||||
}
|
||||
interface N3Parser {
|
||||
parse(input: string, callback: ParseCallback): void;
|
||||
parse(subject: string, predicate: string, object: string): void;
|
||||
parse(triple: Triple): void;
|
||||
parse(stream: fs.ReadStream, log: Logger): void;
|
||||
}
|
||||
|
||||
interface N3StreamParser extends N3Parser, fs.WriteStream {
|
||||
pipe<T extends NodeJS.WritableStream | N3StreamWriter>(consumer: T): T;
|
||||
}
|
||||
|
||||
|
||||
interface WriterConstructor {
|
||||
new (options?: WriterOptions): N3Writer;
|
||||
(options?: WriterOptions): N3Writer;
|
||||
|
||||
new (fd: any, options?: WriterOptions): N3Writer;
|
||||
(fd: any, options?: WriterOptions): N3Writer;
|
||||
}
|
||||
const Writer: WriterConstructor;
|
||||
|
||||
interface N3Writer {
|
||||
addTriple(subject: string, predicate: string, object: string): void;
|
||||
addTriple(subject: string, predicate: string, object: string[]): void;
|
||||
addTriple(triple: Triple): void;
|
||||
end(err?: ErrorCallback, result?: any): void;
|
||||
blank(ns: string, name: string): string;
|
||||
blank(triple: BlankTriple[]): string;
|
||||
list(triple: string[]): string[];
|
||||
}
|
||||
|
||||
function StreamWriter(options: WriterOptions): N3StreamWriter;
|
||||
|
||||
interface N3StreamWriter extends N3Writer {
|
||||
pipe(consumer: NodeJS.WritableStream): void;
|
||||
pipe(consumer: stream.Writable): void;
|
||||
}
|
||||
|
||||
interface WriterOptions {
|
||||
format?: string,
|
||||
prefixes?: Prefixes
|
||||
}
|
||||
|
||||
interface N3StoreWriter extends N3Writer {
|
||||
find(subject: string, predicate: string | null, object: string | null): Triple[];
|
||||
}
|
||||
function Store(): N3StoreWriter;
|
||||
|
||||
namespace Util {
|
||||
function createLiteral(value: any): string;
|
||||
function createLiteral(value: any, type: string): string;
|
||||
|
||||
function isIRI(value: string): boolean;
|
||||
function isLiteral(value: string): boolean;
|
||||
function getLiteralValue(value: string): string;
|
||||
function getLiteralLanguage(value: string): string;
|
||||
function getLiteralType(value: string): string;
|
||||
function isBlank(value: string): boolean;
|
||||
function isPrefixedName(name: string): boolean;
|
||||
function expandPrefixedName(name: string, prefixes: Prefixes): string;
|
||||
}
|
||||
export interface Prefixes {
|
||||
[key: string]: RDF.NamedNode;
|
||||
}
|
||||
|
||||
export = N3;
|
||||
export class Term implements RDF.Term {
|
||||
termType: "NamedNode" | "BlankNode" | "Literal" | "Variable" | "DefaultGraph";
|
||||
id: string;
|
||||
value: string;
|
||||
constructor(iri: string);
|
||||
toJSON(): string;
|
||||
equals(other: RDF.Term): boolean;
|
||||
static subclass(type: any): void;
|
||||
}
|
||||
|
||||
export class NamedNode extends Term implements RDF.NamedNode {
|
||||
termType: "NamedNode";
|
||||
value: string;
|
||||
constructor(iri: string);
|
||||
}
|
||||
|
||||
export class BlankNode extends Term implements RDF.BlankNode {
|
||||
static nextId: number;
|
||||
termType: "BlankNode";
|
||||
value: string;
|
||||
constructor(name: string);
|
||||
}
|
||||
|
||||
export class Variable extends Term implements RDF.Variable {
|
||||
termType: "Variable";
|
||||
value: string;
|
||||
constructor(name: string);
|
||||
}
|
||||
|
||||
export class Literal extends Term implements RDF.Literal {
|
||||
static readonly langStringDatatype: NamedNode;
|
||||
termType: "Literal";
|
||||
value: string;
|
||||
language: string;
|
||||
datatype: RDF.NamedNode;
|
||||
datatypeString: string;
|
||||
constructor(id: string);
|
||||
}
|
||||
|
||||
export class DefaultGraph extends Term implements RDF.DefaultGraph {
|
||||
termType: "DefaultGraph";
|
||||
value: "";
|
||||
constructor();
|
||||
}
|
||||
|
||||
export class Quad implements RDF.Quad {
|
||||
constructor(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term);
|
||||
subject: RDF.Term;
|
||||
predicate: RDF.Term;
|
||||
object: RDF.Term;
|
||||
graph: RDF.Term;
|
||||
equals(other: RDF.Quad): boolean;
|
||||
toJSON(): string;
|
||||
}
|
||||
|
||||
export class Triple extends Quad implements RDF.Triple {}
|
||||
|
||||
export namespace DataFactory {
|
||||
function namedNode(value: string): RDF.NamedNode;
|
||||
function blankNode(value?: string): RDF.BlankNode;
|
||||
function literal(value: string | number, languageOrDatatype?: string | RDF.NamedNode): RDF.Literal;
|
||||
function variable(value: string): RDF.Variable;
|
||||
function defaultGraph(): RDF.DefaultGraph;
|
||||
function triple(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term): RDF.Quad;
|
||||
function quad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): RDF.Quad;
|
||||
}
|
||||
|
||||
export type ErrorCallback = (err: Error, result: any) => void;
|
||||
export type QuadCallback = (result: Quad) => void;
|
||||
export type QuadPredicate = (result: Quad) => boolean;
|
||||
|
||||
export type OTerm = RDF.Term | string | null;
|
||||
|
||||
export type Logger = (message?: any, ...optionalParams: any[]) => void;
|
||||
|
||||
export interface BlankTriple {
|
||||
predicate: RDF.Term;
|
||||
object: RDF.Term;
|
||||
}
|
||||
|
||||
export interface ParserConstructor {
|
||||
new (options?: ParserOptions): N3Parser;
|
||||
(options?: ParserOptions): N3Parser;
|
||||
}
|
||||
export const Parser: ParserConstructor;
|
||||
|
||||
export interface ParserOptions {
|
||||
format?: string;
|
||||
prefixes?: string[];
|
||||
factory?: RDF.DataFactory;
|
||||
baseIRI?: string;
|
||||
}
|
||||
|
||||
export type ParseCallback = (error: Error, quad: Quad, prefixes: Prefixes) => void;
|
||||
|
||||
export interface N3Parser {
|
||||
parse(input: string, callback: ParseCallback): void;
|
||||
}
|
||||
|
||||
export interface StreamParserConstructor {
|
||||
new (options?: ParserOptions): N3StreamParser;
|
||||
(options?: ParserOptions): N3StreamParser;
|
||||
}
|
||||
export const StreamParser: StreamParserConstructor;
|
||||
|
||||
export interface N3StreamParser extends RDF.Stream, NodeJS.WritableStream, RDF.Sink {
|
||||
// Below are the NodeJS.ReadableStream methods,
|
||||
// we can not extend the interface directly,
|
||||
// as `read` clashes with RDF.Sink.
|
||||
readable: boolean;
|
||||
// read(size?: number): string | Buffer; // Overwritten by RDF.Stream
|
||||
setEncoding(encoding: string | null): void;
|
||||
pause(): this;
|
||||
resume(): this;
|
||||
isPaused(): boolean;
|
||||
pipe<T extends NodeJS.WritableStream | RDF.Stream>(destination: T, options?: { end?: boolean; }): T;
|
||||
unpipe(destination?: NodeJS.WritableStream | RDF.Stream): void;
|
||||
unshift(chunk: string | Buffer): void;
|
||||
wrap(oldStream: NodeJS.ReadableStream | RDF.Stream): NodeJS.ReadableStream;
|
||||
}
|
||||
|
||||
export interface WriterOptions {
|
||||
format?: string;
|
||||
prefixes?: Prefixes;
|
||||
}
|
||||
|
||||
export interface WriterConstructor {
|
||||
new (options?: WriterOptions): N3Writer;
|
||||
new (fd: any, options?: WriterOptions): N3Writer;
|
||||
(options?: WriterOptions): N3Writer;
|
||||
(fd: any, options?: WriterOptions): N3Writer;
|
||||
}
|
||||
export const Writer: WriterConstructor;
|
||||
|
||||
export interface N3Writer {
|
||||
quadToString(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term, graph?: RDF.Term): string;
|
||||
quadsToString(quads: RDF.Quad[]): string;
|
||||
addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void;
|
||||
addQuad(quad: RDF.Quad): void;
|
||||
addQuads(quads: RDF.Quad[]): void;
|
||||
end(err?: ErrorCallback, result?: string): void;
|
||||
blank(predicate: RDF.Term, object: RDF.Term): RDF.Term;
|
||||
blank(triple: BlankTriple | RDF.Quad | BlankTriple[] | RDF.Quad[]): RDF.Term;
|
||||
list(triple: RDF.Term[]): RDF.Term[];
|
||||
}
|
||||
|
||||
export interface StreamWriterConstructor {
|
||||
new (options?: WriterOptions): N3StreamWriter;
|
||||
new (fd: any, options?: WriterOptions): N3StreamWriter;
|
||||
(options?: WriterOptions): N3StreamWriter;
|
||||
(fd: any, options?: WriterOptions): N3StreamWriter;
|
||||
}
|
||||
export const StreamWriter: StreamWriterConstructor;
|
||||
|
||||
export interface N3StreamWriter extends NodeJS.ReadWriteStream, RDF.Source {}
|
||||
|
||||
export interface N3Store extends RDF.Sink {
|
||||
readonly size: number;
|
||||
addQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void;
|
||||
addQuad(quad: RDF.Quad): void;
|
||||
addQuads(quads: RDF.Quad[]): void;
|
||||
removeQuad(subject: RDF.Term, predicate: RDF.Term, object: RDF.Term | RDF.Term[], graph?: RDF.Term, done?: () => void): void;
|
||||
removeQuad(quad: RDF.Quad): void;
|
||||
removeQuads(quads: RDF.Quad[]): void;
|
||||
getQuads(subject: OTerm, predicate: OTerm, object: OTerm | OTerm[], graph: OTerm): Quad[];
|
||||
countQuads(subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): number;
|
||||
forEach(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): void;
|
||||
every(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean;
|
||||
some(callback: QuadPredicate, subject: OTerm, predicate: OTerm, object: OTerm, graph: OTerm): boolean;
|
||||
getSubjects(predicate: OTerm, object: OTerm, graph: OTerm): RDF.Term[];
|
||||
forSubjects(callback: QuadCallback, predicate: OTerm, object: OTerm, graph: OTerm): void;
|
||||
getPredicates(subject: OTerm, object: OTerm, graph: OTerm): RDF.Term[];
|
||||
forPredicates(callback: QuadCallback, subject: OTerm, object: OTerm, graph: OTerm): void;
|
||||
getObjects(subject: OTerm, predicate: OTerm, graph: OTerm): RDF.Term[];
|
||||
forObjects(callback: QuadCallback, subject: OTerm, predicate: OTerm, graph: OTerm): void;
|
||||
getGraphs(subject: OTerm, predicate: OTerm, object: OTerm): RDF.Term[];
|
||||
forGraphs(callback: QuadCallback, subject: OTerm, predicate: OTerm, object: OTerm): void;
|
||||
createBlankNode(suggestedName?: string): BlankNode;
|
||||
|
||||
// match, removeMatches and deleteGraph are missing for full RDF.Store adherence
|
||||
remove(stream: stream.Stream): EventEmitter;
|
||||
}
|
||||
export interface StoreConstructor {
|
||||
new (triples?: RDF.Quad[], options?: StoreOptions): N3Store;
|
||||
(triples?: RDF.Quad[], options?: StoreOptions): N3Store;
|
||||
}
|
||||
export const Store: StoreConstructor;
|
||||
|
||||
export interface StoreOptions {
|
||||
factory?: RDF.DataFactory;
|
||||
}
|
||||
|
||||
export namespace Util {
|
||||
function isNamedNode(value: RDF.Term | null): boolean;
|
||||
function isBlankNode(value: RDF.Term | null): boolean;
|
||||
function isLiteral(value: RDF.Term | null): boolean;
|
||||
function isVariable(value: RDF.Term | null): boolean;
|
||||
function isDefaultGraph(value: RDF.Term | null): boolean;
|
||||
function inDefaultGraph(value: RDF.Quad): boolean;
|
||||
function prefix(iri: string, factory?: RDF.DataFactory): (suffix: string) => RDF.NamedNode;
|
||||
function prefixes(defaultPrefixes: Prefixes, factory?: RDF.DataFactory): (iri: string) => (suffix: string) => RDF.NamedNode;
|
||||
}
|
||||
|
||||
+99
-97
@@ -1,10 +1,10 @@
|
||||
import * as N3 from "n3";
|
||||
import * as RDF from "rdf-js";
|
||||
import * as fs from "fs";
|
||||
import * as stream from "stream";
|
||||
|
||||
function test_serialize() {
|
||||
|
||||
var writer: N3.N3Writer = N3.Writer(
|
||||
const writer: N3.N3Writer = new N3.Writer(
|
||||
{
|
||||
format: "ttl",
|
||||
prefixes: {
|
||||
@@ -13,169 +13,171 @@ function test_serialize() {
|
||||
g: "http://base.google.com/ns/1.0"
|
||||
}
|
||||
});
|
||||
writer.addTriple({
|
||||
subject: "subject-name",
|
||||
predicate: "predicate-name",
|
||||
object: N3.Util.createLiteral(12)
|
||||
});
|
||||
writer.addQuad(N3.DataFactory.quad(
|
||||
N3.DataFactory.namedNode("subject-name"),
|
||||
N3.DataFactory.namedNode("predicate-name"),
|
||||
N3.DataFactory.literal(12)
|
||||
));
|
||||
|
||||
writer.end((error, result) => {
|
||||
console.log(`result ${result}`);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
/*
|
||||
The following tests are taken from ...
|
||||
https://github.com/RubenVerborgh/N3.js/blob/master/README.md
|
||||
*/
|
||||
|
||||
function test_doc_rdf_to_triples_1() {
|
||||
var parser = N3.Parser();
|
||||
parser.parse('@prefix c: <http://example.org/cartoons#>.\n' +
|
||||
'c:Tom a c:Cat.\n' +
|
||||
'c:Jerry a c:Mouse;\n' +
|
||||
' c:smarterThan c:Tom.',
|
||||
function (error: Error, triple: N3.Triple, prefixes: N3.Prefixes) {
|
||||
if (triple)
|
||||
console.log(triple.subject, triple.predicate, triple.object, '.');
|
||||
const parser: N3.N3Parser = new N3.Parser();
|
||||
parser.parse(`@prefix c: <http://example.org/cartoons#>.
|
||||
c:Tom a c:Cat.
|
||||
c:Jerry a c:Mouse;
|
||||
c:smarterThan c:Tom.`,
|
||||
(error: Error, quad: RDF.Quad, prefixes: N3.Prefixes) => {
|
||||
if (quad)
|
||||
console.log(quad.subject, quad.predicate, quad.object, quad.graph, '.');
|
||||
else
|
||||
console.log("# That's all, folks!", prefixes)
|
||||
console.log("# That's all, folks!", prefixes);
|
||||
});
|
||||
}
|
||||
|
||||
function test_doc_rdf_to_triples_2() {
|
||||
var parser1 = N3.Parser({ format: 'N-Triples' });
|
||||
var parser2 = N3.Parser({ format: 'application/trig' });
|
||||
const parser1: N3.N3Parser = new N3.Parser({ format: 'N-Triples' });
|
||||
const parser2: N3.N3Parser = new N3.Parser({ format: 'application/trig' });
|
||||
// Notation3 (N3) is supported only through the format argument:
|
||||
|
||||
var parser3 = N3.Parser({ format: 'N3' });
|
||||
var parser4 = N3.Parser({ format: 'Notation3' });
|
||||
var parser5 = N3.Parser({ format: 'text/n3' });
|
||||
const parser3: N3.N3Parser = N3.Parser({ format: 'N3' });
|
||||
const parser4: N3.N3Parser = N3.Parser({ format: 'Notation3' });
|
||||
const parser5: N3.N3Parser = N3.Parser({ format: 'text/n3' });
|
||||
}
|
||||
|
||||
function test_doc_rdf_stream_to_triples_1() {
|
||||
var parser = N3.Parser();
|
||||
var rdfStream = fs.createReadStream('cartoons.ttl');
|
||||
parser.parse(rdfStream, console.log);
|
||||
const parser: N3.N3Parser = new N3.Parser();
|
||||
parser.parse('abc', console.log);
|
||||
|
||||
var streamParser = N3.StreamParser();
|
||||
var rdfStream = fs.createReadStream('cartoons.ttl');
|
||||
rdfStream.pipe(streamParser);
|
||||
const streamParser: N3.N3StreamParser = N3.StreamParser();
|
||||
const quad: RDF.Quad = streamParser.read();
|
||||
const rdfStream = fs.createReadStream('cartoons.ttl');
|
||||
const pipedStreamParser: N3.N3StreamParser = rdfStream.pipe(streamParser);
|
||||
streamParser.pipe(new class SlowConsumer extends stream.Writable {
|
||||
constructor() {
|
||||
super({ objectMode: true });
|
||||
this._write = function (triple, encoding, done) {
|
||||
console.log(triple);
|
||||
this._write = (quad: RDF.Quad, encoding, done) => {
|
||||
console.log(quad);
|
||||
setTimeout(done, 1000);
|
||||
};
|
||||
}
|
||||
});
|
||||
}());
|
||||
}
|
||||
|
||||
function test_doc_from_triples_to_string() {
|
||||
var writer = N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } });
|
||||
writer.addTriple('http://example.org/cartoons#Tom',
|
||||
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
|
||||
'http://example.org/cartoons#Cat');
|
||||
writer.addTriple({
|
||||
subject: 'http://example.org/cartoons#Tom',
|
||||
predicate: 'http://example.org/cartoons#name',
|
||||
object: '"Tom"'
|
||||
});
|
||||
writer.end(function (error, result) { console.log(result); });
|
||||
const writer: N3.N3Writer = new N3.Writer({ prefixes: { c: 'http://example.org/cartoons#' } });
|
||||
writer.addQuad(N3.DataFactory.quad(
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Tom'),
|
||||
N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Cat')
|
||||
));
|
||||
writer.addQuad(N3.DataFactory.quad(
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Tom'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#name'),
|
||||
N3.DataFactory.literal('Tom'),
|
||||
));
|
||||
writer.end((error, result: string) => { console.log(result); });
|
||||
|
||||
var writer1 = N3.Writer({ format: 'N-Triples' });
|
||||
var writer2 = N3.Writer({ format: 'application/trig' });
|
||||
const writer1: N3.N3Writer = N3.Writer({ format: 'N-Triples' });
|
||||
const writer2: N3.N3Writer = N3.Writer({ format: 'application/trig' });
|
||||
}
|
||||
|
||||
function test_doc_from_triples_to_rdf_stream() {
|
||||
var writer = N3.Writer(process.stdout, { prefixes: { c: 'http://example.org/cartoons#' } });
|
||||
writer.addTriple('http://example.org/cartoons#Tom',
|
||||
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
|
||||
'http://example.org/cartoons#Cat');
|
||||
writer.addTriple({
|
||||
subject: 'http://example.org/cartoons#Tom',
|
||||
predicate: 'http://example.org/cartoons#name',
|
||||
object: '"Tom"'
|
||||
});
|
||||
const writer: N3.N3Writer = new N3.Writer(process.stdout, { prefixes: { c: N3.DataFactory.namedNode('http://example.org/cartoons#') } });
|
||||
writer.addQuad(N3.DataFactory.quad(
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Tom'),
|
||||
N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Cat'),
|
||||
));
|
||||
writer.addQuad(N3.DataFactory.quad(
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Tom'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#name'),
|
||||
N3.DataFactory.literal('Tom'),
|
||||
));
|
||||
writer.end();
|
||||
}
|
||||
|
||||
function test_doc_from_triple_stream_to_rdf_stream() {
|
||||
var streamParser = new N3.StreamParser(),
|
||||
inputStream = fs.createReadStream('cartoons.ttl'),
|
||||
streamWriter = /* new */ N3.StreamWriter({ prefixes: { c: 'http://example.org/cartoons#' } });
|
||||
const streamParser: N3.N3StreamParser = new N3.StreamParser();
|
||||
const inputStream = fs.createReadStream('cartoons.ttl');
|
||||
const streamWriter: N3.N3StreamWriter = new N3.StreamWriter({ prefixes: { c: N3.DataFactory.namedNode('http://example.org/cartoons#') } });
|
||||
inputStream.pipe(streamParser);
|
||||
streamParser.pipe(streamWriter);
|
||||
streamWriter.pipe(process.stdout);
|
||||
}
|
||||
|
||||
function test_doc_blank_nodes_and_lists() {
|
||||
var writer = N3.Writer({
|
||||
const writer: N3.N3Writer = new N3.Writer({
|
||||
prefixes: {
|
||||
c: 'http://example.org/cartoons#',
|
||||
foaf: 'http://xmlns.com/foaf/0.1/'
|
||||
}
|
||||
});
|
||||
writer.addTriple(writer.blank('http://xmlns.com/foaf/0.1/givenName', '"Tom"@en'),
|
||||
'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
|
||||
'http://example.org/cartoons#Cat');
|
||||
writer.addTriple('http://example.org/cartoons#Jerry',
|
||||
'http://xmlns.com/foaf/0.1/knows',
|
||||
writer.addQuad(writer.blank(N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/givenName'), N3.DataFactory.literal('Tom', 'en')),
|
||||
N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Cat'));
|
||||
writer.addQuad(N3.DataFactory.namedNode('http://example.org/cartoons#Jerry'),
|
||||
N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/knows'),
|
||||
writer.blank([{
|
||||
predicate: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#type',
|
||||
object: 'http://example.org/cartoons#Cat'
|
||||
predicate: N3.DataFactory.namedNode('http://www.w3.org/1999/02/22-rdf-syntax-ns#type'),
|
||||
object: N3.DataFactory.namedNode('http://example.org/cartoons#Cat')
|
||||
}, {
|
||||
predicate: 'http://xmlns.com/foaf/0.1/givenName',
|
||||
object: '"Tom"@en',
|
||||
predicate: N3.DataFactory.namedNode('http://xmlns.com/foaf/0.1/givenName'),
|
||||
object: N3.DataFactory.literal('Tom', 'en'),
|
||||
}]));
|
||||
writer.addTriple('http://example.org/cartoons#Mammy',
|
||||
'http://example.org/cartoons#hasPets',
|
||||
writer.addQuad(N3.DataFactory.namedNode('http://example.org/cartoons#Mammy'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#hasPets'),
|
||||
writer.list([
|
||||
'http://example.org/cartoons#Tom',
|
||||
'http://example.org/cartoons#Jerry'
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Tom'),
|
||||
N3.DataFactory.namedNode('http://example.org/cartoons#Jerry')
|
||||
]));
|
||||
writer.end(function (error, result) { console.log(result); });
|
||||
writer.end((error, result) => { console.log(result); });
|
||||
}
|
||||
|
||||
function test_doc_storing() {
|
||||
var store = N3.Store();
|
||||
store.addTriple('http://ex.org/Pluto', 'http://ex.org/type', 'http://ex.org/Dog');
|
||||
store.addTriple('http://ex.org/Mickey', 'http://ex.org/type', 'http://ex.org/Mouse');
|
||||
const store: N3.N3Store = new N3.Store();
|
||||
store.addQuad(N3.DataFactory.namedNode('http://ex.org/Pluto'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Dog'));
|
||||
store.addQuad(N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse')));
|
||||
store.addQuads([N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))]);
|
||||
store.removeQuad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'));
|
||||
store.removeQuad(N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse')));
|
||||
store.removeQuads([N3.DataFactory.quad(N3.DataFactory.namedNode('http://ex.org/Mickey'), N3.DataFactory.namedNode('http://ex.org/type'), N3.DataFactory.namedNode('http://ex.org/Mouse'))]);
|
||||
|
||||
var mickey = store.find('http://ex.org/Mickey', null, null)[0];
|
||||
const bnode1: RDF.BlankNode = store.createBlankNode();
|
||||
const bnode2: RDF.BlankNode = store.createBlankNode('abc');
|
||||
|
||||
const mickey: RDF.Quad = store.getQuads(N3.DataFactory.namedNode('http://ex.org/Mickey'), null, null, null)[0];
|
||||
console.log(mickey.subject, mickey.predicate, mickey.object, '.');
|
||||
}
|
||||
|
||||
function test_doc_utility() {
|
||||
var N3Util = N3.Util;
|
||||
N3Util.isIRI('http://example.org/cartoons#Mickey'); // true
|
||||
const N3Util = N3.Util;
|
||||
N3Util.isNamedNode(N3.DataFactory.namedNode('http://example.org/cartoons#Mickey')); // true
|
||||
|
||||
N3Util.isLiteral('"Mickey Mouse"'); // true
|
||||
N3Util.getLiteralValue('"Mickey Mouse"'); // 'Mickey Mouse'
|
||||
N3Util.isLiteral('"Mickey Mouse"@en'); // true
|
||||
N3Util.getLiteralLanguage('"Mickey Mouse"@en'); // 'en'
|
||||
N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true
|
||||
N3Util.getLiteralType('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // 'http://www.w3.org/2001/XMLSchema#integer'
|
||||
N3Util.isLiteral('"http://example.org/"'); // true
|
||||
N3Util.getLiteralValue('"http://example.org/"'); // 'http://example.org/'
|
||||
N3Util.isLiteral(N3.DataFactory.literal('Mickey Mouse')); // true
|
||||
N3Util.isLiteral(N3.DataFactory.literal('Mickey Mouse', 'en')); // true
|
||||
N3Util.isLiteral(N3.DataFactory.literal('3', N3.DataFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer'))); // true
|
||||
N3Util.isLiteral(N3.DataFactory.literal('http://example.org/')); // true
|
||||
|
||||
N3Util.isLiteral('"This word is "quoted"!"'); // true
|
||||
N3Util.isLiteral('"3"^^http://www.w3.org/2001/XMLSchema#integer'); // true
|
||||
N3Util.isLiteral(N3.DataFactory.literal('This word is "quoted"!')); // true
|
||||
N3Util.isLiteral(N3.DataFactory.literal('3', N3.DataFactory.namedNode('http://www.w3.org/2001/XMLSchema#integer'))); // true
|
||||
|
||||
new N3.Parser().parse('<a> <b> "This word is \\"quoted\\"!".', console.log);
|
||||
// { subject: 'a', predicate: 'b', object: '"This word is "quoted"!"' }
|
||||
|
||||
N3Util.createLiteral('My text', 'en-gb');
|
||||
N3Util.createLiteral('123', 'http://www.w3.org/2001/XMLSchema#integer');
|
||||
N3Util.createLiteral(123);
|
||||
N3Util.createLiteral(false);
|
||||
N3Util.isBlankNode(N3.DataFactory.blankNode('b1')); // true
|
||||
N3Util.isNamedNode(N3.DataFactory.blankNode('b1')); // false
|
||||
N3Util.isLiteral(N3.DataFactory.blankNode('b1')); // false
|
||||
|
||||
N3Util.isBlank('_:b1'); // true
|
||||
N3Util.isIRI('_:b1'); // false
|
||||
N3Util.isLiteral('_:b1'); // false
|
||||
|
||||
var prefixes: N3.Prefixes = { rdfs: 'http://www.w3.org/2000/01/rdf-schema#' };
|
||||
N3Util.isPrefixedName('rdfs:label'); // true;
|
||||
N3Util.expandPrefixedName('rdfs:label', prefixes); // http://www.w3.org/2000/01/rdf-schema#label
|
||||
const prefixes: N3.Prefixes = { rdfs: N3.DataFactory.namedNode('http://www.w3.org/2000/01/rdf-schema#') };
|
||||
const namedNode1: RDF.NamedNode = N3Util.prefix('http://www.w3.org/2000/01/rdf-schema#')('label');
|
||||
const namedNode2: RDF.NamedNode = N3Util.prefixes(prefixes)('rdfs')('label');
|
||||
}
|
||||
|
||||
@@ -21,4 +21,4 @@
|
||||
"index.d.ts",
|
||||
"n3-tests.ts"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
+1
-77
@@ -1,79 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
"adjacent-overload-signatures": false,
|
||||
"array-type": false,
|
||||
"arrow-return-shorthand": false,
|
||||
"ban-types": false,
|
||||
"callable-types": false,
|
||||
"comment-format": false,
|
||||
"dt-header": false,
|
||||
"eofline": false,
|
||||
"export-just-namespace": false,
|
||||
"import-spacing": false,
|
||||
"interface-name": false,
|
||||
"interface-over-type-literal": false,
|
||||
"jsdoc-format": false,
|
||||
"max-line-length": false,
|
||||
"member-access": false,
|
||||
"new-parens": false,
|
||||
"no-any-union": false,
|
||||
"no-boolean-literal-compare": false,
|
||||
"no-conditional-assignment": false,
|
||||
"no-consecutive-blank-lines": false,
|
||||
"no-construct": false,
|
||||
"no-declare-current-package": false,
|
||||
"no-duplicate-imports": false,
|
||||
"no-duplicate-variable": false,
|
||||
"no-empty-interface": false,
|
||||
"no-for-in-array": false,
|
||||
"no-inferrable-types": false,
|
||||
"no-internal-module": false,
|
||||
"no-irregular-whitespace": false,
|
||||
"no-mergeable-namespace": false,
|
||||
"no-misused-new": false,
|
||||
"no-namespace": false,
|
||||
"no-object-literal-type-assertion": false,
|
||||
"no-padding": false,
|
||||
"no-redundant-jsdoc": false,
|
||||
"no-redundant-jsdoc-2": false,
|
||||
"no-redundant-undefined": false,
|
||||
"no-reference-import": false,
|
||||
"no-relative-import-in-test": false,
|
||||
"no-self-import": false,
|
||||
"no-single-declare-module": false,
|
||||
"no-string-throw": false,
|
||||
"no-unnecessary-callback-wrapper": false,
|
||||
"no-unnecessary-class": false,
|
||||
"no-unnecessary-generics": false,
|
||||
"no-unnecessary-qualifier": false,
|
||||
"no-unnecessary-type-assertion": false,
|
||||
"no-useless-files": false,
|
||||
"no-var-keyword": false,
|
||||
"no-var-requires": false,
|
||||
"no-void-expression": false,
|
||||
"no-trailing-whitespace": false,
|
||||
"object-literal-key-quotes": false,
|
||||
"object-literal-shorthand": false,
|
||||
"one-line": false,
|
||||
"one-variable-per-declaration": false,
|
||||
"only-arrow-functions": false,
|
||||
"prefer-conditional-expression": false,
|
||||
"prefer-const": false,
|
||||
"prefer-declare-function": false,
|
||||
"prefer-for-of": false,
|
||||
"prefer-method-signature": false,
|
||||
"prefer-template": false,
|
||||
"radix": false,
|
||||
"semicolon": false,
|
||||
"space-before-function-paren": false,
|
||||
"space-within-parens": false,
|
||||
"strict-export-declare-modifiers": false,
|
||||
"trim-file": false,
|
||||
"triple-equals": false,
|
||||
"typedef-whitespace": false,
|
||||
"unified-signatures": false,
|
||||
"void-return": false,
|
||||
"whitespace": false
|
||||
}
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
|
||||
Vendored
+29
-5
@@ -26,6 +26,7 @@
|
||||
// Lishude <https://github.com/islishude>
|
||||
// Andrew Makarov <https://github.com/r3nya>
|
||||
// Zane Hannan AU <https://github.com/ZaneHannanAU>
|
||||
// Thomas den Hollander <https://github.com/ThomasdenH>
|
||||
// Eugene Y. Q. Shen <https://github.com/eyqs>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
@@ -172,6 +173,10 @@ interface SymbolConstructor {
|
||||
readonly asyncIterator: symbol;
|
||||
}
|
||||
declare var Symbol: SymbolConstructor;
|
||||
interface SharedArrayBuffer {
|
||||
readonly byteLength: number;
|
||||
slice(begin?: number, end?: number): SharedArrayBuffer;
|
||||
}
|
||||
|
||||
// Node.js ESNEXT support
|
||||
interface String {
|
||||
@@ -349,13 +354,13 @@ declare var Buffer: {
|
||||
new(array: Uint8Array): Buffer;
|
||||
/**
|
||||
* Produces a Buffer backed by the same allocated memory as
|
||||
* the given {ArrayBuffer}.
|
||||
* the given {ArrayBuffer}/{SharedArrayBuffer}.
|
||||
*
|
||||
*
|
||||
* @param arrayBuffer The ArrayBuffer with which to share memory.
|
||||
* @deprecated since v10.0.0 - Use `Buffer.from(arrayBuffer[, byteOffset[, length]])` instead.
|
||||
*/
|
||||
new(arrayBuffer: ArrayBuffer): Buffer;
|
||||
new(arrayBuffer: ArrayBuffer | SharedArrayBuffer): Buffer;
|
||||
/**
|
||||
* Allocates a new buffer containing the given {array} of octets.
|
||||
*
|
||||
@@ -379,8 +384,7 @@ declare var Buffer: {
|
||||
*
|
||||
* @param arrayBuffer The .buffer property of any TypedArray or a new ArrayBuffer()
|
||||
*/
|
||||
from(arrayBuffer: ArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
// from(arrayBuffer: SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
from(arrayBuffer: ArrayBuffer | SharedArrayBuffer, byteOffset?: number, length?: number): Buffer;
|
||||
/**
|
||||
* Creates a new Buffer using the passed {data}
|
||||
* @param data data to create a new Buffer
|
||||
@@ -418,7 +422,7 @@ declare var Buffer: {
|
||||
* @param string string to test.
|
||||
* @param encoding encoding used to evaluate (defaults to 'utf8')
|
||||
*/
|
||||
byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer /*| SharedArrayBuffer */, encoding?: string): number;
|
||||
byteLength(string: string | NodeJS.TypedArray | DataView | ArrayBuffer | SharedArrayBuffer, encoding?: string): number;
|
||||
/**
|
||||
* Returns a buffer which is the result of concatenating all the buffers in the list together.
|
||||
*
|
||||
@@ -2770,6 +2774,7 @@ declare module "dns" {
|
||||
|
||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void;
|
||||
export function setServers(servers: string[]): void;
|
||||
export function getServers(): string[];
|
||||
|
||||
// Error codes
|
||||
export var NODATA: string;
|
||||
@@ -2796,6 +2801,25 @@ declare module "dns" {
|
||||
export var LOADIPHLPAPI: string;
|
||||
export var ADDRGETNETWORKPARAMS: string;
|
||||
export var CANCELLED: string;
|
||||
|
||||
export class Resolver {
|
||||
getServers: typeof getServers;
|
||||
setServers: typeof setServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
reverse: typeof reverse;
|
||||
cancel(): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "net" {
|
||||
|
||||
@@ -446,6 +446,11 @@ function bufferTests() {
|
||||
const arrUint8: Uint8Array = new Uint8Array(2);
|
||||
const buf5: Buffer = Buffer.from(arrUint8);
|
||||
const buf6: Buffer = Buffer.from(buf1);
|
||||
const sharedArrayBuffer: SharedArrayBuffer = {
|
||||
byteLength: 10,
|
||||
slice: (begin?: number, end?: number) => sharedArrayBuffer
|
||||
};
|
||||
const buf7: Buffer = Buffer.from(sharedArrayBuffer);
|
||||
}
|
||||
|
||||
// Class Method: Buffer.from(arrayBuffer[, byteOffset[, length]])
|
||||
@@ -3388,6 +3393,14 @@ namespace dns_tests {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
{
|
||||
const resolver = new dns.Resolver();
|
||||
resolver.setServers(["4.4.4.4"]);
|
||||
resolver.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolver.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
Vendored
+20
@@ -2646,6 +2646,7 @@ declare module "dns" {
|
||||
|
||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void;
|
||||
export function setServers(servers: string[]): void;
|
||||
export function getServers(): string[];
|
||||
|
||||
// Error codes
|
||||
export var NODATA: string;
|
||||
@@ -2672,6 +2673,25 @@ declare module "dns" {
|
||||
export var LOADIPHLPAPI: string;
|
||||
export var ADDRGETNETWORKPARAMS: string;
|
||||
export var CANCELLED: string;
|
||||
|
||||
export class Resolver {
|
||||
getServers: typeof getServers;
|
||||
setServers: typeof setServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
reverse: typeof reverse;
|
||||
cancel(): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "net" {
|
||||
|
||||
@@ -3127,6 +3127,14 @@ namespace dns_tests {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
{
|
||||
const resolver = new dns.Resolver();
|
||||
resolver.setServers(["4.4.4.4"]);
|
||||
resolver.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolver.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
Vendored
+20
@@ -2728,6 +2728,7 @@ declare module "dns" {
|
||||
|
||||
export function reverse(ip: string, callback: (err: NodeJS.ErrnoException, hostnames: string[]) => void): void;
|
||||
export function setServers(servers: string[]): void;
|
||||
export function getServers(): string[];
|
||||
|
||||
// Error codes
|
||||
export var NODATA: string;
|
||||
@@ -2754,6 +2755,25 @@ declare module "dns" {
|
||||
export var LOADIPHLPAPI: string;
|
||||
export var ADDRGETNETWORKPARAMS: string;
|
||||
export var CANCELLED: string;
|
||||
|
||||
export class Resolver {
|
||||
getServers: typeof getServers;
|
||||
setServers: typeof setServers;
|
||||
resolve: typeof resolve;
|
||||
resolve4: typeof resolve4;
|
||||
resolve6: typeof resolve6;
|
||||
resolveAny: typeof resolveAny;
|
||||
resolveCname: typeof resolveCname;
|
||||
resolveMx: typeof resolveMx;
|
||||
resolveNaptr: typeof resolveNaptr;
|
||||
resolveNs: typeof resolveNs;
|
||||
resolvePtr: typeof resolvePtr;
|
||||
resolveSoa: typeof resolveSoa;
|
||||
resolveSrv: typeof resolveSrv;
|
||||
resolveTxt: typeof resolveTxt;
|
||||
reverse: typeof reverse;
|
||||
cancel(): void;
|
||||
}
|
||||
}
|
||||
|
||||
declare module "net" {
|
||||
|
||||
@@ -3160,6 +3160,14 @@ namespace dns_tests {
|
||||
const _addresses: string[] | dns.RecordWithTtl[] = addresses;
|
||||
});
|
||||
}
|
||||
{
|
||||
const resolver = new dns.Resolver();
|
||||
resolver.setServers(["4.4.4.4"]);
|
||||
resolver.resolve("nodejs.org", (err, addresses) => {
|
||||
const _addresses: string[] = addresses;
|
||||
});
|
||||
resolver.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
|
||||
Vendored
+668
-334
File diff suppressed because it is too large
Load Diff
Vendored
+11
-2
@@ -1,4 +1,4 @@
|
||||
// Type definitions for p-retry 1.0
|
||||
// Type definitions for p-retry 2.0
|
||||
// Project: https://github.com/sindresorhus/p-retry#readme
|
||||
// Definitions by: BendingBender <https://github.com/BendingBender>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -8,7 +8,7 @@ import { OperationOptions } from 'retry';
|
||||
|
||||
export = pRetry;
|
||||
|
||||
declare function pRetry<T>(input: (attemptCount: number) => PromiseLike<T> | T, options?: OperationOptions): Promise<T>;
|
||||
declare function pRetry<T>(input: (attemptCount: number) => PromiseLike<T> | T, options?: pRetry.Options): Promise<T>;
|
||||
|
||||
declare namespace pRetry {
|
||||
class AbortError extends Error {
|
||||
@@ -16,4 +16,13 @@ declare namespace pRetry {
|
||||
readonly originalError: Error;
|
||||
constructor(message: string | Error);
|
||||
}
|
||||
|
||||
interface FailedAttemptError extends Error {
|
||||
attemptNumber: number;
|
||||
attemptsLeft: number;
|
||||
}
|
||||
|
||||
interface Options extends OperationOptions {
|
||||
onFailedAttempt?: (error: FailedAttemptError) => void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,11 @@ const run = () => fetch('https://sindresorhus.com/unicorn')
|
||||
return response.text();
|
||||
});
|
||||
|
||||
pRetry(run, {retries: 5}).then(result => {
|
||||
pRetry(run, {
|
||||
retries: 5,
|
||||
onFailedAttempt: error => {
|
||||
console.log(`Attempt ${error.attemptNumber} failed. There are ${error.attemptsLeft} attempts left.`);
|
||||
}
|
||||
}).then(result => {
|
||||
const str: string = result;
|
||||
});
|
||||
|
||||
Vendored
+1
-1
@@ -45,7 +45,7 @@ declare class Strategy implements passport.Strategy {
|
||||
* @param {Object} info
|
||||
* @api public
|
||||
*/
|
||||
success(user: any, info: any): void;
|
||||
success(user: any, info?: any): void;
|
||||
|
||||
/**
|
||||
* Fail authentication, with optional `challenge` and `status`, defaulting
|
||||
|
||||
@@ -33,7 +33,7 @@ export class Strategy extends passport.Strategy {
|
||||
|
||||
var self = this;
|
||||
|
||||
function verified(err: Error, user: any, info: any) {
|
||||
function verified(err: Error, user: any, info?: any) {
|
||||
if (err) {
|
||||
return self.error(err);
|
||||
}
|
||||
@@ -43,6 +43,6 @@ export class Strategy extends passport.Strategy {
|
||||
self.success(user, info);
|
||||
}
|
||||
|
||||
verified(null, {}, {});
|
||||
verified(null, {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,8 @@ import * as puppeteer from "puppeteer";
|
||||
// Get the "viewport" of the page, as reported by the page.
|
||||
const dimensions = await page.evaluate(() => {
|
||||
return {
|
||||
width: document.documentElement.clientWidth,
|
||||
height: document.documentElement.clientHeight,
|
||||
width: document.documentElement!.clientWidth,
|
||||
height: document.documentElement!.clientHeight,
|
||||
deviceScaleFactor: window.devicePixelRatio
|
||||
};
|
||||
});
|
||||
@@ -300,7 +300,7 @@ puppeteer.launch().then(async browser => {
|
||||
someElement; // $ExpectType ElementHandle<HTMLDivElement>
|
||||
|
||||
// If one passes an ElementHandle, puppeteer will unwrap its DOM reference instead
|
||||
await page.$eval('.hello-world', (e, x1: HTMLDivElement) => x1.noWrap, someElement);
|
||||
await page.$eval('.hello-world', (e, x1) => (x1 as any).noWrap, someElement);
|
||||
|
||||
browser.close();
|
||||
})();
|
||||
|
||||
+2
-1
@@ -6,11 +6,12 @@
|
||||
|
||||
import * as React from 'react';
|
||||
import { ImageURISource } from 'react-native';
|
||||
import * as moment from 'moment';
|
||||
|
||||
export interface DatePickerProps {
|
||||
mode?: 'date' | 'datetime' | 'time';
|
||||
androidMode?: 'default' | 'calendar' | 'spinner';
|
||||
date?: string | Date;
|
||||
date?: string | Date | moment.Moment;
|
||||
format?: string;
|
||||
iconSource?: ImageURISource;
|
||||
iconComponent?: JSX.Element;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"moment": ">=2.14.0"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
import { Component } from "react";
|
||||
import { Icon, IconProps, ImageSource } from "./Icon";
|
||||
|
||||
export const FA5Style: {
|
||||
regular: 0;
|
||||
light: 1;
|
||||
solid: 2;
|
||||
brand: 3;
|
||||
};
|
||||
|
||||
export type ValueOf<T> = T[keyof T];
|
||||
|
||||
// borrowed from
|
||||
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html
|
||||
export type Omit<T, K> = Pick<T, Exclude<keyof T, K>>;
|
||||
|
||||
export type FontAwesome5IconVariants = keyof Omit<typeof FA5Style, "regular">;
|
||||
|
||||
// modified from https://stackoverflow.com/a/49725198/1105281
|
||||
export type AllowOnlyOne<T, Keys extends keyof T = keyof T> = Omit<T, Keys> &
|
||||
{
|
||||
[K in Keys]-?: Partial<Pick<T, K>> &
|
||||
Partial<Record<Exclude<Keys, K>, undefined>>
|
||||
}[Keys];
|
||||
|
||||
export type FontAwesome5IconProps = AllowOnlyOne<
|
||||
{ [K in FontAwesome5IconVariants]?: boolean } & IconProps,
|
||||
FontAwesome5IconVariants
|
||||
>;
|
||||
|
||||
export default class FontAwesome5Icon extends Component<
|
||||
FontAwesome5IconProps,
|
||||
any
|
||||
> {
|
||||
static getImageSource(
|
||||
name: string,
|
||||
size?: number,
|
||||
color?: string,
|
||||
fa5Style?: ValueOf<typeof FA5Style>
|
||||
): Promise<ImageSource>;
|
||||
static loadFont(file?: string): Promise<void>;
|
||||
static hasIcon(name: string): boolean;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { Component } from "react";
|
||||
import FontAwesome5Icon, { FontAwesome5IconProps } from "./FontAwesome5";
|
||||
|
||||
export type FontAwesome5ProIconProps = FontAwesome5IconProps;
|
||||
export { FA5Style } from "./FontAwesome5";
|
||||
export default FontAwesome5Icon;
|
||||
@@ -3,6 +3,8 @@ import { View, Text, TabBarIOS } from 'react-native';
|
||||
import { createIconSet } from 'react-native-vector-icons';
|
||||
import MaterialIcon from 'react-native-vector-icons/MaterialIcons';
|
||||
import FontAwesomeIcon from 'react-native-vector-icons/FontAwesome';
|
||||
import FontAwesome5Icon from 'react-native-vector-icons/FontAwesome5';
|
||||
import FontAwesome5ProIcon from 'react-native-vector-icons/FontAwesome5Pro';
|
||||
import Ionicon from 'react-native-vector-icons/Ionicons';
|
||||
|
||||
const glyphMap = {
|
||||
@@ -27,6 +29,9 @@ class Example extends React.Component {
|
||||
<View>
|
||||
{/* Normal Icon */}
|
||||
<MaterialIcon size={30} color="red" name="exit" />
|
||||
<FontAwesome5Icon size={10} name="handshake" />
|
||||
<FontAwesome5Icon size={10} name="handshake" solid />
|
||||
<FontAwesome5ProIcon size={10} name="parachute-box" light />
|
||||
|
||||
{/* Icon button */}
|
||||
<FontAwesomeIcon.Button
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
"EvilIcons.d.ts",
|
||||
"Feather.d.ts",
|
||||
"FontAwesome.d.ts",
|
||||
"FontAwesome5.d.ts",
|
||||
"FontAwesome5Pro.d.ts",
|
||||
"Foundation.d.ts",
|
||||
"Ionicons.d.ts",
|
||||
"MaterialCommunityIcons.d.ts",
|
||||
|
||||
+2
-2
@@ -15,9 +15,9 @@ declare class MessageQueue {
|
||||
|
||||
declare module "react-native/Libraries/BatchedBridge/BatchedBridge" {
|
||||
const BatchedBridge: MessageQueue;
|
||||
export = BatchedBridge;
|
||||
export default BatchedBridge;
|
||||
}
|
||||
|
||||
declare module "react-native/Libraries/BatchedBridge/MessageQueue" {
|
||||
export = MessageQueue;
|
||||
export default MessageQueue;
|
||||
}
|
||||
|
||||
Vendored
+26
-19
@@ -4754,7 +4754,7 @@ declare class MaskedViewComponent extends React.Component<MaskedViewIOSProps> {}
|
||||
declare const MaskedViewBase: Constructor<NativeMethodsMixin> & typeof MaskedViewComponent;
|
||||
export class MaskedViewIOS extends MaskedViewBase {}
|
||||
|
||||
export interface ModalProps {
|
||||
export interface ModalBaseProps {
|
||||
// Only `animated` is documented. The JS code says `animated` is
|
||||
// deprecated and `animationType` is preferred.
|
||||
animated?: boolean;
|
||||
@@ -4784,35 +4784,42 @@ export interface ModalProps {
|
||||
* The `onShow` prop allows passing a function that will be called once the modal has been shown.
|
||||
*/
|
||||
onShow?: (event: NativeSyntheticEvent<any>) => void;
|
||||
}
|
||||
|
||||
export interface ModalPropsIOS {
|
||||
/**
|
||||
* The `presentationStyle` determines the style of modal to show
|
||||
*/
|
||||
presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen";
|
||||
|
||||
/**
|
||||
* The `supportedOrientations` prop allows the modal to be rotated to any of the specified orientations.
|
||||
* On iOS, the modal is still restricted by what's specified in your app's Info.plist's UISupportedInterfaceOrientations field.
|
||||
* @platform ios
|
||||
*/
|
||||
supportedOrientations?: (
|
||||
| "portrait"
|
||||
| "portrait-upside-down"
|
||||
| "landscape"
|
||||
| "landscape-left"
|
||||
| "landscape-right")[];
|
||||
supportedOrientations?: Array<"portrait" | "portrait-upside-down" | "landscape" | "landscape-left" | "landscape-right">;
|
||||
|
||||
/**
|
||||
* The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed.
|
||||
*/
|
||||
onDismiss?: () => void;
|
||||
|
||||
/**
|
||||
* The `onOrientationChange` callback is called when the orientation changes while the modal is being displayed.
|
||||
* The orientation provided is only 'portrait' or 'landscape'. This callback is also called on initial render, regardless of the current orientation.
|
||||
* @platform ios
|
||||
*/
|
||||
onOrientationChange?: (event?: NativeSyntheticEvent<any>) => void;
|
||||
/**
|
||||
* The `onDismiss` prop allows passing a function that will be called once the modal has been dismissed.
|
||||
* @platform ios
|
||||
*/
|
||||
onDismiss?: () => void;
|
||||
/**
|
||||
* The `presentationStyle` determines the style of modal to show
|
||||
* @platform ios
|
||||
*/
|
||||
presentationStyle?: "fullScreen" | "pageSheet" | "formSheet" | "overFullScreen";
|
||||
}
|
||||
|
||||
export interface ModalPropsAndroid {
|
||||
/**
|
||||
* Controls whether to force hardware acceleration for the underlying window.
|
||||
*/
|
||||
hardwareAccelerated?: boolean;
|
||||
}
|
||||
|
||||
|
||||
export type ModalProps = ModalBaseProps & ModalPropsIOS & ModalPropsAndroid;
|
||||
|
||||
export class Modal extends React.Component<ModalProps> {}
|
||||
|
||||
/**
|
||||
|
||||
@@ -71,6 +71,7 @@ import {
|
||||
TextInputSubmitEditingEventData,
|
||||
WebView,
|
||||
KeyboardAvoidingView,
|
||||
Modal,
|
||||
} from "react-native";
|
||||
|
||||
declare module "react-native" {
|
||||
@@ -754,3 +755,7 @@ const AlertIOSTest = () => {
|
||||
'email-address'
|
||||
);
|
||||
}
|
||||
|
||||
const ModalTest = () => (
|
||||
<Modal hardwareAccelerated />
|
||||
)
|
||||
|
||||
Vendored
+5
-3
@@ -11,7 +11,6 @@
|
||||
// Qibang Sun <https://github.com/bang88>
|
||||
// Sergei Butko: <https://github.com/svbutko>
|
||||
// Veit Lehmann: <https://github.com/levito>
|
||||
// Roberto Huertas: <https://github.com/robertohuertasm>
|
||||
// Steven Miller <https://github.com/YourGamesBeOver>
|
||||
// Armando Assuncao <https://github.com/ArmandoAssuncao>
|
||||
// Ciaran Liedeman <https://github.com/cliedeman>
|
||||
@@ -19,6 +18,7 @@
|
||||
// Jérémy Magrin <https://github.com/magrinj>
|
||||
// Luca Campana <https://github.com/TizioFittizio>
|
||||
// Ullrich Schaefer <https://github.com/stigi>
|
||||
// Linus Unnebäck <https://github.com/LinusU>
|
||||
// Yosuke Seki <https://github.com/jshosomichi>
|
||||
// Jake <https://github.com/jakebooyah>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
@@ -446,7 +446,8 @@ export type NavigationStackAction =
|
||||
| NavigationReplaceAction
|
||||
| NavigationPopAction
|
||||
| NavigationPushAction
|
||||
| NavigationPopToTopAction;
|
||||
| NavigationPopToTopAction
|
||||
| NavigationCompleteTransitionAction;
|
||||
|
||||
export type NavigationTabAction =
|
||||
| NavigationInitAction
|
||||
@@ -588,7 +589,8 @@ export interface NavigationScreenProp<S, P = NavigationParams> {
|
||||
openDrawer: () => any;
|
||||
closeDrawer: () => any;
|
||||
toggleDrawer: () => any;
|
||||
getParam: <T extends keyof P>(param: T, fallback?: P[T]) => P[T];
|
||||
getParam<T extends keyof P>(param: T, fallback: NonNullable<P[T]>): NonNullable<P[T]>;
|
||||
getParam<T extends keyof P>(param: T): P[T];
|
||||
setParams: (newParams: Partial<P>) => boolean;
|
||||
addListener: (
|
||||
eventName: 'willBlur' | 'willFocus' | 'didFocus' | 'didBlur',
|
||||
|
||||
@@ -497,6 +497,7 @@ const CustomHeaderStack = createStackNavigator({
|
||||
|
||||
interface ScreenProps {
|
||||
name: string;
|
||||
optionalAge?: number;
|
||||
onPlay(): void;
|
||||
}
|
||||
|
||||
@@ -513,9 +514,16 @@ class SetParamsTest extends React.Component<NavigationScreenProps<ScreenProps>>
|
||||
|
||||
render() {
|
||||
const name = this.props.navigation.getParam('name');
|
||||
const age = this.props.navigation.getParam('optionalAge');
|
||||
|
||||
// $ExpectType number | undefined
|
||||
this.props.navigation.getParam('optionalAge');
|
||||
|
||||
// $ExpectType number
|
||||
this.props.navigation.getParam('optionalAge', 0);
|
||||
|
||||
return (
|
||||
<Text>My name is {name}</Text>
|
||||
<Text>My name is {name} and I am {age} years old.</Text>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// Type definitions for react-router-hash-link 1.2
|
||||
// Project: https://github.com/rafrex/react-router-hash-link (Does not have to be to GitHub, but prefer linking to a source code repository rather than to a project website.)
|
||||
// Definitions by: Sam Baeck <https://github.com/zoompie>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import * as React from 'react';
|
||||
import { LinkProps, NavLinkProps } from 'react-router-dom';
|
||||
|
||||
export interface HashLinkProps extends LinkProps {
|
||||
smooth?: boolean;
|
||||
scroll?: (element: HTMLElement) => void;
|
||||
}
|
||||
|
||||
export class HashLink extends React.Component<HashLinkProps, any> {}
|
||||
|
||||
export interface NavHashLinkProps extends NavLinkProps, HashLinkProps {}
|
||||
|
||||
export class NavHashLink extends React.Component<NavHashLinkProps, any> {}
|
||||
@@ -0,0 +1,24 @@
|
||||
import * as H from 'history';
|
||||
import * as React from 'react';
|
||||
import { match } from 'react-router';
|
||||
import { HashLink, NavHashLink, NavHashLinkProps } from 'react-router-hash-link';
|
||||
|
||||
interface Props extends NavHashLinkProps {
|
||||
extraProp: string;
|
||||
}
|
||||
|
||||
const getIsActive = (extraProp: string) => (match: match<any>, location: H.Location) => !!extraProp;
|
||||
|
||||
export default function(props: Props) {
|
||||
const {extraProp, ...rest} = props;
|
||||
const isActive = getIsActive(extraProp);
|
||||
return (
|
||||
<NavHashLink {...rest} isActive={isActive} />
|
||||
);
|
||||
}
|
||||
|
||||
<HashLink to="url" />;
|
||||
|
||||
const acceptRef = (node: HTMLAnchorElement | null) => {
|
||||
};
|
||||
<HashLink to="/url" replace={true} innerRef={acceptRef} />;
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"jsx": "react",
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"react-router-hash-link-tests.tsx"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
+2
-2
@@ -189,13 +189,13 @@ export type RowMouseEventHandlerParams = {
|
||||
index: number;
|
||||
};
|
||||
index: number;
|
||||
event: React.SyntheticEvent<React.MouseEvent<any>>;
|
||||
event: React.MouseEvent<any>;
|
||||
};
|
||||
|
||||
export type HeaderMouseEventHandlerParams = {
|
||||
dataKey: string;
|
||||
columnData: any;
|
||||
event: React.SyntheticEvent<React.MouseEvent<any>>;
|
||||
event: React.MouseEvent<any>;
|
||||
};
|
||||
|
||||
// ref: https://github.com/bvaughn/react-virtualized/blob/master/docs/Table.md
|
||||
|
||||
Vendored
+1
@@ -1459,6 +1459,7 @@ declare namespace React {
|
||||
interface ImgHTMLAttributes<T> extends HTMLAttributes<T> {
|
||||
alt?: string;
|
||||
crossOrigin?: "anonymous" | "use-credentials" | "";
|
||||
decoding?: "async" | "auto" | "sync";
|
||||
height?: number | string;
|
||||
sizes?: string;
|
||||
src?: string;
|
||||
|
||||
Vendored
+3
@@ -10,6 +10,7 @@
|
||||
// Jamie Saunders <https://github.com/jrsaunde>
|
||||
// Paul Melnikow <https://github.com/paulmelnikow>
|
||||
// Harry Cruse <https://github.com/crusectrl>
|
||||
// Andrew Palugniok <https://github.com/apalugniok>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
@@ -917,6 +918,7 @@ export interface XAxisProps extends EventAttributes {
|
||||
// see label section at http://recharts.org/#/en-US/api/XAxis
|
||||
label?: string | number | Label | LabelProps;
|
||||
allowDuplicatedCategory?: boolean;
|
||||
stroke?: string;
|
||||
}
|
||||
|
||||
export class XAxis extends React.Component<XAxisProps> { }
|
||||
@@ -968,6 +970,7 @@ export interface YAxisProps extends EventAttributes {
|
||||
reversed?: boolean;
|
||||
// see label section at http://recharts.org/#/en-US/api/YAxis
|
||||
label?: string | number | Label | LabelProps;
|
||||
stroke?: string;
|
||||
}
|
||||
|
||||
export class YAxis extends React.Component<YAxisProps> { }
|
||||
|
||||
@@ -90,7 +90,7 @@ class Component extends React.Component<{}, ComponentState> {
|
||||
<XAxis dataKey="name">
|
||||
<Label fontSize="8px">X axis - name</Label>
|
||||
</XAxis>
|
||||
<YAxis>
|
||||
<YAxis stroke="#8884d8">
|
||||
<Label>Y axis</Label>
|
||||
</YAxis>
|
||||
<CartesianGrid vertical={true} horizontal={false} verticalFill={["#fafafa", "#c8c8c8"]} />
|
||||
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// Type definitions for reconnect-core 1.3
|
||||
// Project: https://www.npmjs.com/package/reconnect-core
|
||||
// Definitions by: James Bromwell <https://github.com/thw0rted>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.8
|
||||
|
||||
import { Backoff, ExponentialOptions } from "backoff";
|
||||
import { EventEmitter } from "events";
|
||||
import { Stream } from "stream";
|
||||
|
||||
declare namespace reconnect {
|
||||
// TODO: Once DT supports TS 3.0, use new Generic Rest Parameter feature for
|
||||
// ArgType. Current definitions only support one parameter passed to
|
||||
// connect() but the library actually allows any number of args.
|
||||
type CustomModule<ArgType, ConnectionType> =
|
||||
(opts?: ModuleOptions<ConnectionType>, cb?: (con: ConnectionType) => void) => Instance<ArgType, ConnectionType>;
|
||||
|
||||
interface ModuleOptions<ConnectionType> extends ExponentialOptions {
|
||||
immediate?: boolean;
|
||||
failAfter?: number;
|
||||
onConnect?: (con: ConnectionType) => void;
|
||||
strategy?: "fibonacci" | "exponential" | Backoff;
|
||||
}
|
||||
|
||||
interface Instance<ArgType, ConnectionType> extends EventEmitter {
|
||||
connect(opts: ArgType): this;
|
||||
listen(opts: ArgType): this;
|
||||
disconnect(): this;
|
||||
reset(): void;
|
||||
|
||||
readonly connected: boolean;
|
||||
reconnect: boolean;
|
||||
|
||||
on(event: "backoff", cb: (n: number, delay: number, err?: any) => void): this;
|
||||
on(event: "connect" | "connection", cb: (con: ConnectionType) => void): this;
|
||||
on(event: "disconnect", cb: (err?: any) => void): this;
|
||||
on(event: "error" | "fail", cb: (err: any) => void): this;
|
||||
on(event: "reconnect", cb: (n: number, delay: number) => void): this;
|
||||
}
|
||||
}
|
||||
|
||||
type ConnectFunction<ArgType, ConnectionType> =
|
||||
(this: reconnect.Instance<ArgType, ConnectionType>, opts: ArgType) => ConnectionType;
|
||||
declare function reconnect<ArgType, ConnectionType>(
|
||||
cf: ConnectFunction<ArgType, ConnectionType>): reconnect.CustomModule<ArgType, ConnectionType>;
|
||||
|
||||
export = reconnect;
|
||||
@@ -0,0 +1,44 @@
|
||||
import reconnect = require("reconnect-core");
|
||||
import { NetConnectOpts, Socket, connect } from "net";
|
||||
|
||||
// Approximation of example from docs
|
||||
const module: reconnect.CustomModule<NetConnectOpts | string | number, Socket> = reconnect(arg => {
|
||||
// TS can't resolve passing even the simplest union types to function overloads :-/
|
||||
// (see TS issue #14107)
|
||||
if (typeof arg === "string") {
|
||||
return connect(arg);
|
||||
} else if (typeof arg === "number") {
|
||||
return connect(arg);
|
||||
} else {
|
||||
return connect(arg);
|
||||
}
|
||||
});
|
||||
|
||||
const opts: reconnect.ModuleOptions<Socket> = {
|
||||
failAfter: Infinity,
|
||||
immediate: false,
|
||||
initialDelay: 1e3,
|
||||
maxDelay: 30e3,
|
||||
randomisationFactor: 0,
|
||||
strategy: "fibonacci",
|
||||
onConnect: sock => {
|
||||
sock.on("data", console.log);
|
||||
},
|
||||
};
|
||||
|
||||
const conn = module(opts);
|
||||
|
||||
conn.on("connect", con => con.address())
|
||||
.on("reconnect", (n, delay) => {
|
||||
n.toExponential();
|
||||
delay.toFixed();
|
||||
})
|
||||
.on("disconnect", console.log)
|
||||
.on("error", console.log)
|
||||
.connect(12345);
|
||||
|
||||
conn.disconnect();
|
||||
|
||||
conn.reconnect = false;
|
||||
|
||||
conn.reset();
|
||||
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"baseUrl": "../",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"lib": [
|
||||
"es2016"
|
||||
],
|
||||
"module": "commonjs",
|
||||
"noEmit": true,
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"target": "es6",
|
||||
"types": [],
|
||||
"typeRoots": [
|
||||
"../"
|
||||
]
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"reconnect-core-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json"
|
||||
}
|
||||
@@ -774,7 +774,7 @@ const selectedData: Select2.OptionData[] = $("#mySelect2").select2("data");
|
||||
// jQuery Generic
|
||||
|
||||
declare let select: HTMLSelectElement;
|
||||
const $select: JQuery<HTMLSelectElement> = $(select) as JQuery<HTMLSelectElement>;
|
||||
const $select: JQuery<HTMLSelectElement> = $(select);
|
||||
|
||||
select = $select.select2().get(0);
|
||||
select = $select.select2({tags: true}).get(0);
|
||||
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
// Type definitions for shallow-equals 1.0
|
||||
// Project: https://github.com/hughsk/shallow-equals
|
||||
// Definitions by: Ross Solomon <https://github.com/rsolomon>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
export = shallow_equals;
|
||||
|
||||
declare function shallow_equals<A, B>(
|
||||
a?: A,
|
||||
b?: B,
|
||||
compare?: (objA: A, objB: B) => boolean,
|
||||
): boolean;
|
||||
@@ -0,0 +1,19 @@
|
||||
import shallowEquals = require('shallow-equals');
|
||||
|
||||
interface A {
|
||||
foo: string;
|
||||
}
|
||||
|
||||
interface B {
|
||||
foo: string;
|
||||
bar?: string;
|
||||
}
|
||||
|
||||
const a: A = { foo: 'bar' };
|
||||
const b: B = { foo: 'baz' };
|
||||
function compare(a: A, b: B) {
|
||||
return false;
|
||||
}
|
||||
|
||||
shallowEquals(a, b);
|
||||
shallowEquals(a, b, compare);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user