Skip to content

Commit

Permalink
Adding release files
Browse files Browse the repository at this point in the history
  • Loading branch information
24SevenOffice committed Mar 15, 2019
1 parent 9ae52e0 commit bf5ef5a
Show file tree
Hide file tree
Showing 8 changed files with 782 additions and 8 deletions.
7 changes: 0 additions & 7 deletions .gitignore

This file was deleted.

144 changes: 144 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
import { DocumentClient, ConnectionPolicy, NewDocument, RequestOptions, DocumentOptions, FeedOptions, SqlQuerySpec } from 'documentdb';
export default class DocumentDBClient<TEntity extends NewDocument> {
private host;
private key;
private databaseId;
private collectionId;
private _client;
private _policy;
private offerSelfLink;
private offerReserved;
private _washDocuments;
constructor(host: string, key: string, databaseId: string, collectionId: string);
readonly policy: ConnectionPolicy;
washDocuments: boolean;
/**
* Fetches entities from an asynchronious iterator
* @param iterator an async iterable iterator
* @param quantity number of items to fetch, any number below zero will fetch all
*/
static fromAsyncIterable<TEntity>(iterator: AsyncIterableIterator<TEntity>, quantity?: number): Promise<TEntity[]>;
/**
* Reads a document by its id
* @param id
* @param options
*/
readDocument(id: string, options?: RequestOptions): Promise<{
resource: TEntity;
etag: string;
headers: any;
}>;
/**
* Reads a document by its document id
* @param document
* @param options
*/
readDocument(document: TEntity, options?: RequestOptions): Promise<{
resource: TEntity;
etag: string;
headers: any;
}>;
/**
* Query for the documents with paging using ContinuationToken
* @param query
* @param options
*/
queryDocuments(query: string | SqlQuerySpec, options?: FeedOptions): Promise<{
resources: TEntity[];
continuationToken: string;
headers: any;
}>;
/**
* Iterate through documents asynchronious with `for await()`
* @param query
* @param options
*/
iterateDocuments(query: string | SqlQuerySpec, options?: FeedOptions): AsyncIterableIterator<TEntity>;
/**
* Creates a new document that doesn't exists.
* @param document
* @param options
*/
createDocument(document: TEntity, options?: DocumentOptions): Promise<{
resource: TEntity;
headers: any;
}>;
/**
* Updates a document that exists by patching the changes, will retry 3 times before giving up.
* @param document
* @param options
*/
updateDocument(document: Partial<TEntity>, options?: RequestOptions): Promise<{
resource: TEntity;
headers: any;
}>;
/**
* Replaces a document that exists.
* @param document
* @param options
*/
replaceDocument(document: TEntity, options?: RequestOptions): Promise<{
resource: TEntity;
headers: any;
}>;
/**
* Creates a new document or replacing it if it exists
* @param document
* @param options
*/
upsertDocument(document: TEntity, options?: DocumentOptions): Promise<{
resource: TEntity;
headers: any;
}>;
/**
* Deletes a document by its document id
* @param document
*/
deleteDocument(document: TEntity, options?: RequestOptions): Promise<{
resource: void;
headers: any;
}>;
/**
* Deletes a document by its id
* @param id
*/
deleteDocument(id: string, options?: RequestOptions): Promise<{
resource: void;
headers: any;
}>;
/**
* Get the current throughput (RU/s)
*/
getThroughput(): Promise<number>;
/**
* Set the throughput (RU/s) to any number between 400 and 10000
* @param value RU/s
*/
setThroughput(value: number): Promise<boolean>;
/**
* Increase the throughput (RU/s), defaults to 200. Will never exceed 10000
* @param value RU/s
*/
increaseThroughput(value?: number): Promise<number>;
/**
* Decrease the throughput (RU/s), defaults to 200. Will never go below 400
* @param value RU/s
*/
decreaseThroughput(value?: number): Promise<number>;
private reserveOffer;
private getOffer;
protected readonly client: DocumentClient;
protected createDatabaseLink(): string;
protected createCollectionLink(): string;
protected createDocumentLink(id: string): string;
protected createDocumentLink(document: TEntity): string;
private executeNext;
private makeEntity;
private makeDocument;
private delay;
private transformError;
private validateOptions;
private getHeaders;
private apply;
private isClass;
}
Loading

0 comments on commit bf5ef5a

Please sign in to comment.