mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-12 04:50:18 +00:00
Exposing more internal types
This commit is contained in:
Vendored
+48
-9
@@ -5,9 +5,7 @@
|
||||
|
||||
/// <reference path="lib/sharedb.d.ts" />
|
||||
|
||||
import { Doc, Query, Error, Action, RawOp, Op } from './lib/sharedb';
|
||||
|
||||
type UseCallback = ((request: {action: Action, agent: any, req: any, collection: string, id: string, query: any, op: RawOp}, callback: () => void) => void);
|
||||
import * as ShareDB from './lib/sharedb';
|
||||
|
||||
interface PubSubOptions {
|
||||
prefix?: string;
|
||||
@@ -24,13 +22,36 @@ declare class sharedb {
|
||||
addProjection(name: string, collection: string, fields: {}): any;
|
||||
listen(stream: any): void;
|
||||
close(callback?: (err: Error) => any): void;
|
||||
use(action: Action, fn: UseCallback);
|
||||
types: {
|
||||
register: () => void
|
||||
use(action: sharedb.UseAction, fn: sharedb.UseCallback);
|
||||
static types: {
|
||||
register: (type: { name?: string, uri?: string, [key: string]: any}) => void;
|
||||
};
|
||||
}
|
||||
|
||||
declare namespace sharedb {
|
||||
type UseAction = 'connect' | 'op' | 'doc' | 'query' | 'submit' | 'apply' | 'commit' | 'after submit' | 'receive';
|
||||
type UseCallback = ((request: {action: UseAction, agent: any, req: any, collection: string, id: string, query: any, op: ShareDB.RawOp}, callback: () => void) => void);
|
||||
|
||||
abstract class DB {
|
||||
projectsSnapshots: boolean;
|
||||
disableSubscribe: boolean;
|
||||
close(callback?: () => void): void;
|
||||
commit(collection: string, id: string, op: Op, snapshot, options, callback: (...args: any[]) => any): void;
|
||||
getSnapshot(collection: string, id: string, fields, options, callback: (...args: any[]) => any): void;
|
||||
getSnapshotBulk(collection: string, ids: string, fields, options, callback: (...args: any[]) => any): void;
|
||||
getOps(collection: string, id: string, from: number, to: number, options, callback: (...args: any[]) => any): void;
|
||||
getOpsToSnapshot(collection: string, id: string, from: number, snapshot: number, options, callback: (...args: any[]) => any): void;
|
||||
getOpsBulk(collection: string, fromMap, toMap, options, callback: (...args: any[]) => any): void;
|
||||
getCommittedOpVersion(collection: string, id: string, snapshot, op, options, callback: (...args: any[]) => any): void;
|
||||
query(collection: string, query: Query, fields, options, callback: (...args: any[]) => any): void;
|
||||
queryPoll(collection: string, query: Query, options, callback: (...args: any[]) => any): void;
|
||||
queryPollDoc(collection: string, id: string, query: Query, options, callback: (...args: any[]) => any): void;
|
||||
canPollDoc(): boolean;
|
||||
skipPoll(): boolean;
|
||||
}
|
||||
|
||||
class MemoryDB extends DB { }
|
||||
|
||||
abstract class PubSub {
|
||||
private static shallowCopy(obj: any);
|
||||
protected prefix?: string;
|
||||
@@ -56,8 +77,26 @@ declare namespace sharedb {
|
||||
|
||||
class Connection {
|
||||
constructor(ws: WebSocket);
|
||||
get(collectionName: string, documentID: string): Doc;
|
||||
createFetchQuery(collectionName: string, query: string, options: {results?: Query[]}, callback: (err: Error, results: any) => any): Query;
|
||||
createSubscribeQuery(collectionName: string, query: string, options: {results?: Query[]}, callback: (err: Error, results: any) => any): Query;
|
||||
get(collectionName: string, documentID: string): ShareDB.Doc;
|
||||
createFetchQuery(collectionName: string, query: string, options: {results?: ShareDB.Query[]}, callback: (err: Error, results: any) => any): ShareDB.Query;
|
||||
createSubscribeQuery(collectionName: string, query: string, options: {results?: ShareDB.Query[]}, callback: (err: Error, results: any) => any): ShareDB.Query;
|
||||
}
|
||||
type Doc = ShareDB.Doc;
|
||||
type Query = ShareDB.Query;
|
||||
type Error = ShareDB.Error;
|
||||
type Op = ShareDB.Op;
|
||||
type AddNumOp = ShareDB.AddNumOp;
|
||||
type ListMoveOp = ShareDB.ListMoveOp;
|
||||
type ListInsertOp = ShareDB.ListInsertOp;
|
||||
type ListDeleteOp = ShareDB.ListDeleteOp;
|
||||
type ListReplaceOp = ShareDB.ListReplaceOp;
|
||||
type StringInsertOp = ShareDB.StringInsertOp;
|
||||
type StringDeleteOp = ShareDB.StringDeleteOp;
|
||||
type ObjectInsertOp = ShareDB.ObjectInsertOp;
|
||||
type ObjectDeleteOp = ShareDB.ObjectDeleteOp;
|
||||
type ObjectReplaceOp = ShareDB.ObjectReplaceOp;
|
||||
type SubtypeOp = ShareDB.SubtypeOp;
|
||||
|
||||
type Path = ShareDB.Path;
|
||||
type ShareDBSourceOptions = ShareDB.ShareDBSourceOptions;
|
||||
}
|
||||
|
||||
Vendored
+18
-2
@@ -1,12 +1,28 @@
|
||||
/// <reference path="sharedb.d.ts" />
|
||||
import * as WebSocket from 'ws';
|
||||
import * as WS from 'ws';
|
||||
import * as ShareDB from './sharedb';
|
||||
|
||||
export class Connection {
|
||||
constructor(ws: WebSocket);
|
||||
constructor(ws: WebSocket | WS);
|
||||
get(collectionName: string, documentID: string): Doc;
|
||||
createFetchQuery(collectionName: string, query: string, options: {results?: Query[]}, callback: (err: Error, results: any) => any): Query;
|
||||
createSubscribeQuery(collectionName: string, query: string, options: {results?: Query[]}, callback: (err: Error, results: any) => any): Query;
|
||||
}
|
||||
export type Doc = ShareDB.Doc;
|
||||
export type Query = ShareDB.Query;
|
||||
export type Error = ShareDB.Error;
|
||||
export type Op = ShareDB.Op;
|
||||
export type AddNumOp = ShareDB.AddNumOp;
|
||||
export type ListMoveOp = ShareDB.ListMoveOp;
|
||||
export type ListInsertOp = ShareDB.ListInsertOp;
|
||||
export type ListDeleteOp = ShareDB.ListDeleteOp;
|
||||
export type ListReplaceOp = ShareDB.ListReplaceOp;
|
||||
export type StringInsertOp = ShareDB.StringInsertOp;
|
||||
export type StringDeleteOp = ShareDB.StringDeleteOp;
|
||||
export type ObjectInsertOp = ShareDB.ObjectInsertOp;
|
||||
export type ObjectDeleteOp = ShareDB.ObjectDeleteOp;
|
||||
export type ObjectReplaceOp = ShareDB.ObjectReplaceOp;
|
||||
export type SubtypeOp = ShareDB.SubtypeOp;
|
||||
|
||||
export type Path = ShareDB.Path;
|
||||
export type ShareDBSourceOptions = ShareDB.ShareDBSourceOptions;
|
||||
|
||||
Vendored
+29
-11
@@ -1,3 +1,5 @@
|
||||
import { EventEmitter } from 'events';
|
||||
|
||||
export type Path = ReadonlyArray<string|number>;
|
||||
export type Snapshot = number;
|
||||
|
||||
@@ -29,7 +31,6 @@ export interface RawOp {
|
||||
d: string;
|
||||
}
|
||||
export type OTType = 'ot-text' | 'ot-json0' | 'ot-text-tp2' | 'rich-text';
|
||||
export type Action = 'connect'|'op'|'doc'|'query'|'submit'|'apply'|'commit'|'after submit'|'receive';
|
||||
export interface Error {
|
||||
code: number;
|
||||
message: string;
|
||||
@@ -41,27 +42,44 @@ export interface ShareDBSourceOptions { source?: boolean; }
|
||||
|
||||
export type Callback = (err: Error) => any;
|
||||
|
||||
export class Doc {
|
||||
export type DocEvent = 'load' | 'create' | 'before op' | 'op' | 'del' | 'error' | 'no write pending' | 'nothing pending';
|
||||
|
||||
export class Doc extends EventEmitter {
|
||||
type: string;
|
||||
id: string;
|
||||
data: any;
|
||||
fetch: (callback: (err: Error) => void) => void;
|
||||
subscribe: (callback: (err: Error) => void) => void;
|
||||
on: (event: 'load'|'create'|'before op'|'op'|'del'|'error', callback: (...args: any[]) => any) => void;
|
||||
ingestSnapshot: (snapshot: Snapshot, callback: Callback) => void;
|
||||
destroy: () => void;
|
||||
|
||||
on(event: 'load' | 'no write pending' | 'nothing pending', callback: () => void): this;
|
||||
on(event: 'create', callback: (source: boolean) => void): this;
|
||||
on(event: 'op' | 'before op', callback: (ops: Op[], source: boolean) => void): this;
|
||||
on(event: 'del', callback: (data: any, source: boolean) => void): this;
|
||||
on(event: 'error', callback: (err: Error) => void): this;
|
||||
|
||||
addListener(event: 'load' | 'no write pending' | 'nothing pending', callback: () => void): this;
|
||||
addListener(event: 'create', callback: (source: boolean) => void): this;
|
||||
addListener(event: 'op' | 'before op', callback: (ops: Op[], source: boolean) => void): this;
|
||||
addListener(event: 'del', callback: (data: any, source: boolean) => void): this;
|
||||
addListener(event: 'error', callback: (err: Error) => void): this;
|
||||
|
||||
ingestSnapshot(snapshot: Snapshot, callback: Callback): void;
|
||||
destroy(): void;
|
||||
create(data: any, callback?: Callback): void;
|
||||
create(data: any, type?: OTType, callback?: Callback): void;
|
||||
create(data: any, type?: OTType, options?: ShareDBSourceOptions, callback?: Callback): void;
|
||||
submitOp: (data: ReadonlyArray<Op>, options?: ShareDBSourceOptions, callback?: Callback) => void;
|
||||
del: (options: ShareDBSourceOptions, callback: (err: Error) => void) => void;
|
||||
removeListener: (eventName: string, listener: () => any) => void;
|
||||
submitOp(data: ReadonlyArray<Op>, options?: ShareDBSourceOptions, callback?: Callback): void;
|
||||
del(options: ShareDBSourceOptions, callback: (err: Error) => void): void;
|
||||
whenNothingPending(callback: (err: Error) => void): void;
|
||||
}
|
||||
|
||||
export class Query {
|
||||
export type QueryEvent = 'ready' | 'error' | 'changed' | 'insert' | 'move' | 'remove' | 'extra';
|
||||
export class Query extends EventEmitter {
|
||||
ready: boolean;
|
||||
results: Doc[];
|
||||
extra: any;
|
||||
on: (event: 'ready'|'error'|'changed'|'insert'|'move'|'remove'|'extra', callback: (...args: any[]) => any) => any;
|
||||
destroy: () => void;
|
||||
on(event: QueryEvent, callback: (...args: any[]) => any): this;
|
||||
addListener(event: QueryEvent, callback: (...args: any[]) => any): this;
|
||||
removeListener(event: QueryEvent, listener: (...args: any[]) => any): this;
|
||||
destroy(): void;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user