Modified tslint.json files to enable most rules. Cleaned up code to remove lint errors.

This commit is contained in:
Jim Bouquet
2018-04-06 16:15:11 -05:00
parent c5648fb940
commit bfaaf9272a
11 changed files with 211 additions and 438 deletions

View File

@@ -1,12 +1,12 @@
// Testing type definitions for clearbladejs Client SDK v1.0.0
// Testing type definitions for clearbladejs-client 1.0
// Project: https://github.com/ClearBlade/JavaScript-API
// Definitions by: Jim Bouquet <https://github.com/ClearBlade/>
// Definitions by: Jim Bouquet <https://github.com/ClearBlade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
var genericCallback = function(error: boolean, response: Resp) {};
let genericCallback = (error: boolean, response: Resp) => {};
///////////////////////////////////////
//ClearBlade object API invocations
// ClearBlade object API invocations
///////////////////////////////////////
ClearBlade.init({
systemKey: "abcdef",
@@ -24,34 +24,34 @@ ClearBlade.loginUserMqtt("test@test.com", "password", genericCallback);
ClearBlade.sendPush(["user1", "user2"], {data: "Test"}, "appId: string", genericCallback);
ClearBlade.getAllCollections(genericCallback);
var coll1 = ClearBlade.Collection("collectionID");
var coll2 = ClearBlade.Collection({ collectionName: "collectionName" });
var coll3 = ClearBlade.Collection({ collectionID: "collectionID" });
let coll1 = ClearBlade.Collection("collectionID");
let coll2 = ClearBlade.Collection({ collectionName: "collectionName" });
let coll3 = ClearBlade.Collection({ collectionID: "collectionID" });
var query1 = ClearBlade.Query("collectionID");
var query2 = ClearBlade.Query({ offset: 5, limit: 5, collectionID: "collectionID" });
var query3 = ClearBlade.Query({ collectionName: "collectionName" });
let query1 = ClearBlade.Query("collectionID");
let query2 = ClearBlade.Query({ offset: 5, limit: 5, collectionID: "collectionID" });
let query3 = ClearBlade.Query({ collectionName: "collectionName" });
var item1 = ClearBlade.Item({}, "collectionID");
var item2 = ClearBlade.Item({}, { collectionID: "collectionID" });
let item1 = ClearBlade.Item({}, "collectionID");
let item2 = ClearBlade.Item({}, { collectionID: "collectionID" });
var code = ClearBlade.Code();
var user = ClearBlade.User();
let code = ClearBlade.Code();
let user = ClearBlade.User();
var messaging = ClearBlade.Messaging({}, genericCallback);
var stats = ClearBlade.MessagingStats();
let messaging = ClearBlade.Messaging({}, genericCallback);
let stats = ClearBlade.MessagingStats();
var edge = ClearBlade.Edge();
var metrics = ClearBlade.Metrics();
var device = ClearBlade.Device();
var analytics = ClearBlade.Analytics();
var portal = ClearBlade.Portal("MyPortal");
var triggers = ClearBlade.Triggers();
let edge = ClearBlade.Edge();
let metrics = ClearBlade.Metrics();
let device = ClearBlade.Device();
let analytics = ClearBlade.Analytics();
let portal = ClearBlade.Portal("MyPortal");
let triggers = ClearBlade.Triggers();
ClearBlade.getEdges(query1.query, genericCallback);
///////////////////////////////////////
//Collection API invocations
// Collection API invocations
///////////////////////////////////////
coll1.fetch(query1.query, genericCallback);
coll1.create(ClearBlade.Item({}, ""), genericCallback);
@@ -61,7 +61,7 @@ coll1.columns(genericCallback);
coll1.count(query1.query, genericCallback);
///////////////////////////////////////
//Query API invocations
// Query API invocations
///////////////////////////////////////
query1.addSortToQuery(
query1,
@@ -91,14 +91,14 @@ query1.columns([]);
query1.remove(genericCallback);
///////////////////////////////////////
//Item API invocations
// Item API invocations
///////////////////////////////////////
item1.save(genericCallback);
item1.refresh(genericCallback);
item1.destroy(genericCallback);
///////////////////////////////////////
//Code API invocations
// Code API invocations
///////////////////////////////////////
code.create("codeName", "body: string", genericCallback);
code.update("codeName", "body: string", genericCallback);
@@ -109,7 +109,7 @@ code.getFailedServices(genericCallback);
code.getAllServices(genericCallback);
///////////////////////////////////////
//User API invocations
// User API invocations
///////////////////////////////////////
user.getUser(genericCallback);
user.setUser({}, genericCallback);
@@ -118,7 +118,7 @@ user.setPassword("old_password", "new_password", genericCallback);
user.count(query1.query, genericCallback);
///////////////////////////////////////
//Messaging API invocations
// Messaging API invocations
///////////////////////////////////////
messaging.getMessageHistoryWithTimeFrame("topic", 5, 10, 15, 20, genericCallback);
messaging.getMessageHistory("topic", 5, 15, genericCallback);
@@ -126,20 +126,20 @@ messaging.getAndDeleteMessageHistory("topic", 5, 10, 1, 20, genericCallback);
messaging.currentTopics(genericCallback);
messaging.publish("topic", {});
messaging.publishREST("topic", { payload: Object }, genericCallback);
var mcb = function(message: string) {};
let mcb = (message: string) => {};
messaging.subscribe("topic", {}, mcb);
messaging.unsubscribe("topic", {});
messaging.disconnect();
///////////////////////////////////////
//MessagingStats API invocations
// MessagingStats API invocations
///////////////////////////////////////
stats.getAveragePayloadSize("topic: string", 5, 5, genericCallback);
stats.getOpenConnections(genericCallback);
stats.getCurrentSubscribers("topic: string", genericCallback);
///////////////////////////////////////
//Edge API invocations
// Edge API invocations
///////////////////////////////////////
edge.updateEdgeByName("edgename", {changedColumn: "New value"}, genericCallback);
edge.deleteEdgeByName("edgename", genericCallback);
@@ -148,7 +148,7 @@ edge.columns(genericCallback);
edge.count(query1.query, genericCallback);
///////////////////////////////////////
//Metrics API invocations
// Metrics API invocations
///////////////////////////////////////
metrics.setQuery(query1.query);
metrics.getStatistics(genericCallback);
@@ -157,7 +157,7 @@ metrics.getDBConnections(genericCallback);
metrics.getLogs(genericCallback);
///////////////////////////////////////
//Device API invocations
// Device API invocations
///////////////////////////////////////
device.getDeviceByName("devicename", genericCallback);
device.updateDeviceByName("devicename", { object: Object }, true, genericCallback);
@@ -170,7 +170,7 @@ device.columns(genericCallback);
device.count(query1.query, genericCallback);
///////////////////////////////////////
//Analytics API invocations
// Analytics API invocations
///////////////////////////////////////
analytics.getStorage({}, genericCallback);
analytics.getCount({}, genericCallback);
@@ -179,13 +179,13 @@ analytics.getEventTotals({}, genericCallback);
analytics.getUserEvents({}, genericCallback);
///////////////////////////////////////
//Portal API invocations
// Portal API invocations
///////////////////////////////////////
portal.fetch(genericCallback);
portal.update({data: Object}, genericCallback);
///////////////////////////////////////
//Triggers API invocations
// Triggers API invocations
///////////////////////////////////////
triggers.fetchDefinitions(genericCallback);
triggers.create("triggername", {data: Object}, genericCallback);

View File

@@ -2,4 +2,4 @@ declare global {
var ClearBlade: ClearBladeGlobal;
}
export {};
export {};

View File

@@ -1,6 +1,6 @@
// Type definitions for clearbladejs Client SDK v1.0.0
// Type definitions for clearbladejs-client 1.0
// Project: https://github.com/ClearBlade/JavaScript-API
// Definitions by: Jim Bouquet <https://github.com/ClearBlade/>
// Definitions by: Jim Bouquet <https://github.com/ClearBlade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -52,9 +52,7 @@ interface APIUser {
authToken: string;
}
interface CbCallback {
(error: boolean, response: Resp): void;
}
type CbCallback = (error: boolean, response: Resp) => void;
interface ClearBladeGlobal extends ClearBladeInt {
MESSAGING_QOS_AT_MOST_ONCE: MessagingQOS.MESSAGING_QOS_AT_MOST_ONCE;
@@ -87,14 +85,14 @@ interface ClearBladeInt {
Query(
options: string | QueryOptionsWithName | QueryOptionsWithID
): QueryObj;
Item(data: Object, collectionID: string | ItemOptions): Item;
Item(data: object, collectionID: string | ItemOptions): Item;
Code(): Code;
User(): AppUser;
Messaging(options: MessagingOptions, callback: CbCallback): Messaging;
MessagingStats(): MessagingStats;
sendPush(
users: string[],
payload: Object,
payload: object,
appId: string,
callback: CbCallback
): void;
@@ -127,7 +125,7 @@ interface Collection {
fetch(query: Query, callback: CbCallback): void;
create(newItem: Item, callback: CbCallback): void;
update(query: Query, changes: Object, callback: CbCallback): void;
update(query: Query, changes: object, callback: CbCallback): void;
remove(query: Query, callback: CbCallback): void;
columns(callback: CbCallback): void;
count(query: Query, callback: CbCallback): void;
@@ -210,7 +208,7 @@ interface QueryObj {
or(query: QueryObj): void;
setPage(pageSize: number, pageNum: number): void;
fetch(callback: CbCallback): void;
update(changes: Object, callback: CbCallback): void;
update(changes: object, callback: CbCallback): void;
columns(columnsArray: string[]): void;
remove(callback: CbCallback): void;
}
@@ -218,7 +216,7 @@ interface QueryObj {
interface ItemOptions extends CollectionOptionsWithID {}
interface Item {
data: Object;
data: object;
save(callback: CbCallback): void;
refresh(callback: CbCallback): void;
@@ -235,7 +233,7 @@ interface Code {
create(name: string, body: string, callback: CbCallback): void;
update(name: string, body: string, callback: CbCallback): void;
delete(name: string, callback: CbCallback): void;
execute(name: string, params: Object, callback: CbCallback): void;
execute(name: string, params: object, callback: CbCallback): void;
getCompletedServices(callback: CbCallback): void;
getFailedServices(callback: CbCallback): void;
getAllServices(callback: CbCallback): void;
@@ -250,7 +248,7 @@ interface AppUser {
callTimeout: number;
getUser(callback: CbCallback): void;
setUser(data: Object, callback: CbCallback): void;
setUser(data: object, callback: CbCallback): void;
allUsers(query: Query, callback: CbCallback): void;
setPassword(
old_password: string,
@@ -292,8 +290,8 @@ interface Messaging {
callback: CbCallback
): void;
currentTopics(callback: CbCallback): void;
publish(topic: string, payload: Object): void;
publishREST(topic: string, payload: Object, callback: CbCallback): void;
publish(topic: string, payload: object): void;
publishREST(topic: string, payload: object, callback: CbCallback): void;
subscribe(
topic: string,
options: MessagingSubscribeOptions,
@@ -321,13 +319,11 @@ interface MessagingConfiguration extends CommonMessagingProperties {
password: string;
}
interface MessageCallback {
(message: string): void;
}
type MessageCallback = (message: string) => void;
interface MessagingSubscribeOptions {
qos?: MessagingQOS;
invocationContext?: Object;
invocationContext?: object;
onSuccess?: Function;
onFailure?: Function;
timeout?: number;
@@ -355,9 +351,9 @@ interface Edge {
systemKey: string;
systemSecret: string;
updateEdgeByName(name: string, object: Object, callback: CbCallback): void;
updateEdgeByName(name: string, object: object, callback: CbCallback): void;
deleteEdgeByName(name: string, callback: CbCallback): void;
create(newEdge: Object, name: string, callback: CbCallback): void;
create(newEdge: object, name: string, callback: CbCallback): void;
columns(callback: CbCallback): void;
count(query: Query, callback: CbCallback): void;
}
@@ -383,7 +379,7 @@ interface Device {
getDeviceByName(name: string, callback: CbCallback): void;
updateDeviceByName(
name: string,
object: Object,
object: object,
trigger: boolean,
callback: CbCallback
): void;
@@ -391,12 +387,12 @@ interface Device {
fetch(query: Query, callback: CbCallback): void;
update(
query: Query,
object: Object,
object: object,
trigger: boolean,
callback: CbCallback
): void;
delete(query: Query, callback: CbCallback): void;
create(newDevice: Object, callback: CbCallback): void;
create(newDevice: object, callback: CbCallback): void;
columns(callback: CbCallback): void;
count(query: Query, callback: CbCallback): void;
}
@@ -422,7 +418,7 @@ interface Portal {
systemSecret: string;
fetch(callback: CbCallback): void;
update(data: Object, callback: CbCallback): void;
update(data: object, callback: CbCallback): void;
}
interface Triggers {
@@ -432,8 +428,8 @@ interface Triggers {
systemSecret: string;
fetchDefinitions(callback: CbCallback): void;
create(name: string, data: Object, callback: CbCallback): void;
update(name: string, data: Object, callback: CbCallback): void;
create(name: string, data: object, callback: CbCallback): void;
update(name: string, data: object, callback: CbCallback): void;
delete(name: string, callback: CbCallback): void;
}

View File

@@ -1,79 +1,7 @@
{
"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
"no-empty-interface": false
}
}

View File

@@ -1,23 +1,26 @@
// Testing type definitions for clearbladejs-node 1.0
// Project: https://github.com/ClearBlade/Node-SDK
// Definitions by: Jim Bouquet <https://github.com/ClearBlade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { ClearBlade, Resp, QuerySortDirections, QueryConditions } from ".";
// Sample code for clearbladejs Node SDK v1.0.0 used to test typescript definitions
const constants = require("./constants.json");
var genericCallback = function(error: boolean, response: Resp) {};
const genericCallback = (error: boolean, response: Resp) => {};
///////////////////////////////////////
//ClearBlade object API invocations
// ClearBlade object API invocations
///////////////////////////////////////
ClearBlade.init({
email: "a@a.com",
password: "a",
systemKey: constants.systemKey,
systemSecret: constants.systemSecret,
URI: constants.URL,
messagingURI: constants.messageURL,
systemKey: "testkey",
systemSecret: "testsecret",
URI: "https://mycbplatform.com",
messagingURI: "mycbplatform.com",
callback: genericCallback
})
});
ClearBlade.setUser("test@test.com", "password");
ClearBlade.registerUser("test@test.com", "password", genericCallback);
@@ -38,34 +41,33 @@ ClearBlade.sendPush([], {}, "appId: string", genericCallback);
// makeKVPair(key: string, value: string): KeyValuePair;
// request(options: RequestOptions, callback: RequestCallback): void;
var coll1 = ClearBlade.Collection("collectionID");
var coll2 = ClearBlade.Collection({collectionName: "collectionName"});
var coll3 = ClearBlade.Collection({collectionID: "collectionID"});
const coll1 = ClearBlade.Collection("collectionID");
const coll2 = ClearBlade.Collection({collectionName: "collectionName"});
const coll3 = ClearBlade.Collection({collectionID: "collectionID"});
var query1 = ClearBlade.Query("collectionID");
var query2 = ClearBlade.Query({offset: 5, limit: 5, collectionID: "collectionID"});
var query3 = ClearBlade.Query({collectionName: "collectionName"});
var query4 = ClearBlade.Query({collection: "collectionID"});
const query1 = ClearBlade.Query("collectionID");
const query2 = ClearBlade.Query({offset: 5, limit: 5, collectionID: "collectionID"});
const query3 = ClearBlade.Query({collectionName: "collectionName"});
const query4 = ClearBlade.Query({collection: "collectionID"});
ClearBlade.addToQuery(query1, "key", "value");
ClearBlade.addFilterToQuery(query1, QueryConditions.QUERY_GREATERTHAN, "key", "value");
ClearBlade.addSortToQuery(query1, QuerySortDirections.QUERY_SORT_ASCENDING, "column1");
var opQueryStr = ClearBlade.parseOperationQuery(query1.query);
var parse1:string = ClearBlade.parseQuery(query1.query);
var parse2:string = ClearBlade.parseQuery(query1);
const opQueryStr = ClearBlade.parseOperationQuery(query1.query);
const parse1: string = ClearBlade.parseQuery(query1.query);
const parse2: string = ClearBlade.parseQuery(query1);
const item1 = ClearBlade.Item({}, "hello");
const item2 = ClearBlade.Item({}, {collectionID: "hello"});
var item1 = ClearBlade.Item({}, "hello");
var item2 = ClearBlade.Item({}, {collectionID: "hello"});
const code = ClearBlade.Code();
const user = ClearBlade.User();
var code = ClearBlade.Code();
var user = ClearBlade.User();
var messaging = ClearBlade.Messaging({}, genericCallback);
const messaging = ClearBlade.Messaging({}, genericCallback);
///////////////////////////////////////
//Collection API invocations
// Collection API invocations
///////////////////////////////////////
coll1.fetch(query1, genericCallback);
coll1.create(ClearBlade.Item({}, ""), genericCallback);
@@ -73,7 +75,7 @@ coll1.update(query1.query, {}, genericCallback);
coll1.remove(query1.query, genericCallback);
///////////////////////////////////////
//Query API invocations
// Query API invocations
///////////////////////////////////////
query1.ascending("string");
query1.descending("string");
@@ -90,26 +92,26 @@ query1.update({}, genericCallback);
query1.remove(genericCallback);
///////////////////////////////////////
//Item API invocations
// Item API invocations
///////////////////////////////////////
item1.save();
item1.refresh();
item1.destroy();
///////////////////////////////////////
//Code API invocations
// Code API invocations
///////////////////////////////////////
code.execute("codeName", {}, genericCallback);
///////////////////////////////////////
//User API invocations
// User API invocations
///////////////////////////////////////
user.getUser(genericCallback);
user.setUser({}, genericCallback);
user.allUsers(query1.query, genericCallback);
///////////////////////////////////////
//Messaging API invocations
// Messaging API invocations
///////////////////////////////////////
messaging.getMessageHistory("topic: string", 5, 15, genericCallback);
@@ -117,9 +119,6 @@ messaging.publish("topic: string", {});
messaging.subscribe("my/topic", {}, messageReceivedCb);
function messageReceivedCb (message: string) {
function messageReceivedCb(message: string) {
messaging.unsubscribe("my/topic");
}

View File

@@ -1,26 +1,26 @@
// Type definitions for clearbladejs Node SDK v1.0.0
// Type definitions for clearbladejs-node 1.0
// Project: https://github.com/ClearBlade/Node-SDK
// Definitions by: Jim Bouquet <https://github.com/ClearBlade/>
// Definitions by: Jim Bouquet <https://github.com/ClearBlade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
/// <reference types="request" />
import { Response, RequestCallback } from "request/index";
//import {//PacketCallback } from "mqtt";
// import {//PacketCallback } from "mqtt";
declare enum MessagingQOS {
export enum MessagingQOS {
MESSAGING_QOS_AT_MOST_ONCE = 0,
MESSAGING_QOS_AT_LEAST_ONCE = 1,
MESSAGING_QOS_EXACTLY_ONCE = 2
}
export interface Resp {
error(msg: any): never; // todo: figure out if we can have the compiler throw an error if someone adds code after this
error(msg: any): never;
success(msg: any): never;
}
export interface InitOptions {
export interface InitOptions {
systemKey: string;
systemSecret: string;
logging?: boolean;
@@ -49,7 +49,7 @@ export interface RequestOptions {
user?: APIUser;
}
export interface APIUser {
export interface APIUser {
email: string;
authToken: string;
}
@@ -58,9 +58,7 @@ export interface KeyValuePair {
[key: string]: any;
}
export interface CbCallback {
(error: boolean, response: Resp): void
}
export type CbCallback = (error: boolean, response: Resp) => void;
export default interface ClearBladeGlobal extends ClearBladeInt {
isCurrentUserAuthenticated(callback: CbCallback): void;
@@ -70,12 +68,12 @@ export interface ClearBladeInt {
addToQuery(queryObj: QueryObj, key: string, value: string): void;
addFilterToQuery(queryObj: QueryObj, condition: QueryConditions, key: string, value: QueryValue): void;
addSortToQuery(queryObj: QueryObj, direction: QuerySortDirections, column: string): void;
Code() :Code;
Collection(options: string | CollectionOptionsWithName | CollectionOptionsWithID) :Collection;
execute(error: Object, response: Object, callback: CbCallback): void;
Code(): Code;
Collection(options: string | CollectionOptionsWithName | CollectionOptionsWithID): Collection;
execute(error: object, response: object, callback: CbCallback): void;
init(options: InitOptions): void;
isObjectEmpty(obj: Object): boolean;
Item(data: Object, options: string | ItemOptions) :Item;
isObjectEmpty(obj: object): boolean;
Item(data: object, options: string | ItemOptions): Item;
logger(message: string): void;
loginAnon(callback: CbCallback): void;
loginUser(email: string, password: string, callback: CbCallback): void;
@@ -83,21 +81,21 @@ export interface ClearBladeInt {
makeKVPair(key: string, value: string): KeyValuePair;
parseOperationQuery(query: Query): string;
parseQuery(query: Query | QueryObj): string;
Query(options: string | QueryOptionsWithCollection | QueryOptionsWithName | QueryOptionsWithID) :QueryObj;
Query(options: string | QueryOptionsWithCollection | QueryOptionsWithName | QueryOptionsWithID): QueryObj;
registerUser(email: string, password: string, callback: CbCallback): void;
request(options: RequestOptions, callback: RequestCallback): void;
setUser(email: string, password: string): void;
User() :AppUser;
Messaging(options: MessagingOptions, callback: CbCallback) :Messaging;
sendPush(users: string[], payload: Object, appId: string, callback: CbCallback): void;
validateEmailPassword(email: string, password:string): void;
User(): AppUser;
Messaging(options: MessagingOptions, callback: CbCallback): Messaging;
sendPush(users: string[], payload: object, appId: string, callback: CbCallback): void;
validateEmailPassword(email: string, password: string): void;
}
export interface CollectionOptionsWithName {
export interface CollectionOptionsWithName {
collectionName: string;
}
export interface CollectionOptionsWithID {
export interface CollectionOptionsWithID {
collectionID: string;
}
@@ -110,16 +108,16 @@ export interface Collection {
fetch(query: QueryObj, callback: CbCallback): void;
create(newItem: Item, callback: CbCallback): void;
update(query: Query, changes: Object, callback: CbCallback): void;
update(query: Query, changes: object, callback: CbCallback): void;
remove(query: Query, callback: CbCallback): void;
}
export declare enum QuerySortDirections {
export enum QuerySortDirections {
QUERY_SORT_ASCENDING = 'ASC',
QUERY_SORT_DESCENDING = 'DESC'
}
export declare enum QueryConditions {
export enum QueryConditions {
QUERY_EQUAL = 'EQ',
QUERY_NOTEQUAL = 'NEQ',
QUERY_GREATERTHAN = 'GT',
@@ -131,17 +129,18 @@ export declare enum QueryConditions {
export type QueryValue = string|number|boolean;
export interface QueryOptions {
export interface QueryOptions {
offset?: number;
limit?: number;
}
export interface QueryOptionsWithCollection extends QueryOptions{
export interface QueryOptionsWithCollection extends QueryOptions {
collection: string;
}
export interface QueryOptionsWithName extends CollectionOptionsWithName, QueryOptions{}
export interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions{}
export interface QueryOptionsWithName extends CollectionOptionsWithName, QueryOptions {}
export interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions {}
export interface Query {
SELECTCOLUMNS?: string[];
@@ -152,11 +151,11 @@ export interface Query {
}
export interface QueryFilter {
[QueryConditions: string]: QueryFilterValue
[QueryConditions: string]: QueryFilterValue;
}
export interface QueryFilterValue {
[name: string]: QueryValue
[name: string]: QueryValue;
}
export interface QueryObj {
@@ -182,14 +181,14 @@ export interface QueryObj {
or(query: QueryObj): Query;
setPage(pageSize: number, pageNum: number): Query;
fetch(callback: CbCallback): void;
update(changes: Object, callback: CbCallback): void;
update(changes: object, callback: CbCallback): void;
remove(callback: CbCallback): void;
}
export interface ItemOptions extends CollectionOptionsWithID{}
export interface ItemOptions extends CollectionOptionsWithID {}
export interface Item {
data: Object;
data: object;
save(): void;
refresh(): void;
@@ -204,7 +203,7 @@ export interface Code {
callTimeout: number;
URIPrefix: string;
execute(name: string, params: Object, callback: CbCallback): void;
execute(name: string, params: object, callback: CbCallback): void;
}
export interface AppUser {
@@ -214,7 +213,7 @@ export interface AppUser {
systemSecret: string;
getUser(callback: CbCallback): void;
setUser(data: Object, callback: CbCallback): void;
setUser(data: object, callback: CbCallback): void;
allUsers(query: Query, callback: CbCallback): void;
}
@@ -223,12 +222,12 @@ export interface Messaging {
URI: string;
systemKey: string;
systemSecret: string;
client: Object;
client: object;
getMessageHistory(topic: string, startTime: number, count: number, callback: CbCallback): void;
publish(topic: string, payload: Object): void;
publish(topic: string, payload: object): void;
subscribe(topic: string, options: MessagingSubscribeOptions, messageCallback: MessageCallback): void;
unsubscribe(topic: string, callback?: (error?: Error, packet?: Object) => any): void;
unsubscribe(topic: string, callback?: (error?: Error, packet?: object) => any): void;
}
export interface CommonMessagingProperties {
@@ -237,7 +236,7 @@ export interface CommonMessagingProperties {
}
export interface MessagingOptions extends CommonMessagingProperties {
qos?: MessagingQOS
qos?: MessagingQOS;
}
export interface MessagingSubscribeOptions {
@@ -245,10 +244,6 @@ export interface MessagingSubscribeOptions {
timeout?: number;
}
export interface MessageCallback {
(message: string): void;
}
export type MessageCallback = (message: string) => void;
declare var ClearBlade: ClearBladeGlobal;
export {ClearBlade};
export let ClearBlade: ClearBladeGlobal;

View File

@@ -1,79 +1,7 @@
{
"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
"no-relative-import-in-test": false
}
}

View File

@@ -1,12 +1,12 @@
// Testing type definitions for clearbladejs Client SDK v1.0.0
// Testing type definitions for clearbladejs-server 1.0
// Project: https://github.com/ClearBlade/JavaScript-API
// Definitions by: Jim Bouquet <https://github.com/ClearBlade/>
// Definitions by: Jim Bouquet <https://github.com/ClearBlade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
var genericCallback = function(error: boolean, response: Resp) {};
const genericCallback = (error: boolean, response: Resp) => {};
///////////////////////////////////////
//ClearBlade object API invocations
// ClearBlade object API invocations
///////////////////////////////////////
ClearBlade.init({
systemKey: "abcdef",
@@ -27,7 +27,7 @@ ClearBlade.init({request: {
userid: "abcdef",
}});
var about = ClearBlade.about();
const about = ClearBlade.about();
ClearBlade.setUser("test@test.com", "authtoken", "userId");
ClearBlade.registerUser("test@test.com", "password", genericCallback);
ClearBlade.isCurrentUserAuthenticated(genericCallback);
@@ -36,32 +36,32 @@ ClearBlade.loginAnon(genericCallback);
ClearBlade.loginUser("test@test.com", "password", genericCallback);
ClearBlade.getAllCollections(genericCallback);
var edgeID = ClearBlade.edgeId();
var isEdge = ClearBlade.isEdge(genericCallback);
const edgeID = ClearBlade.edgeId();
const isEdge = ClearBlade.isEdge(genericCallback);
if (ClearBlade.isObjectEmpty({test: "test"})) {
ClearBlade.logger("Object is empty");
}
var kvPair = ClearBlade.makeKVPair("key", "value");
const kvPair = ClearBlade.makeKVPair("key", "value");
var coll1 = ClearBlade.Collection("collectionID");
var coll2 = ClearBlade.Collection({ collectionName: "collectionName" });
var coll3 = ClearBlade.Collection({ collectionID: "collectionID" });
var coll4 = ClearBlade.Collection({ collection: "collectionID" });
const coll1 = ClearBlade.Collection("collectionID");
const coll2 = ClearBlade.Collection({ collectionName: "collectionName" });
const coll3 = ClearBlade.Collection({ collectionID: "collectionID" });
const coll4 = ClearBlade.Collection({ collection: "collectionID" });
var query1 = ClearBlade.Query({ collectionID: "collectionID" });
var query2 = ClearBlade.Query({ collectionName: "collectionName" });
var query3 = ClearBlade.Query({ collection: "collectionID" });
const query1 = ClearBlade.Query({ collectionID: "collectionID" });
const query2 = ClearBlade.Query({ collectionName: "collectionName" });
const query3 = ClearBlade.Query({ collection: "collectionID" });
var item1 = ClearBlade.Item({}, "collectionID");
var item2 = ClearBlade.Item({}, { collectionID: "collectionID" });
const item1 = ClearBlade.Item({}, "collectionID");
const item2 = ClearBlade.Item({}, { collectionID: "collectionID" });
var code = ClearBlade.Code();
var deployment = ClearBlade.Deployment();
var user = ClearBlade.User();
const code = ClearBlade.Code();
const deployment = ClearBlade.Deployment();
const user = ClearBlade.User();
var messaging = ClearBlade.Messaging({}, genericCallback);
const messaging = ClearBlade.Messaging({}, genericCallback);
var device = ClearBlade.Device();
const device = ClearBlade.Device();
ClearBlade.addToQuery(query1, "key", "value");
ClearBlade.addSortToQuery(
@@ -78,9 +78,9 @@ ClearBlade.addFilterToQuery(
ClearBlade.newCollection("collectionName", genericCallback);
var parseOperation = ClearBlade.parseOperationQuery(query1.query);
var parseQuery1 = ClearBlade.parseQuery(query1);
var parseQuery2 = ClearBlade.parseQuery(query1.query);
const parseOperation = ClearBlade.parseOperationQuery(query1.query);
const parseQuery1 = ClearBlade.parseQuery(query1);
const parseQuery2 = ClearBlade.parseQuery(query1.query);
ClearBlade.createDevice("devicename", {type: "devicetype"}, false, genericCallback);
ClearBlade.deleteDevice("devicename", true, genericCallback);
@@ -90,7 +90,7 @@ ClearBlade.getAllDevicesForSystem(genericCallback);
ClearBlade.validateEmailPassword("test@test.com", "password");
///////////////////////////////////////
//Collection API invocations
// Collection API invocations
///////////////////////////////////////
coll1.addColumn({name: "column1"}, genericCallback);
coll1.dropColumn("column1", genericCallback);
@@ -103,7 +103,7 @@ coll1.columns(genericCallback);
coll1.count(query1.query, genericCallback);
///////////////////////////////////////
//Query API invocations
// Query API invocations
///////////////////////////////////////
query2.ascending("string");
query1.descending("string");
@@ -122,20 +122,20 @@ query1.columns([]);
query1.remove(genericCallback);
///////////////////////////////////////
//Item API invocations
// Item API invocations
///////////////////////////////////////
item1.save();
item1.refresh();
item1.destroy();
///////////////////////////////////////
//Code API invocations
// Code API invocations
///////////////////////////////////////
code.execute("codeName", {}, true, genericCallback);
code.getAllServices(genericCallback);
///////////////////////////////////////
//Deployment API invocations
// Deployment API invocations
///////////////////////////////////////
deployment.create("deploymentname", "deployment description", {}, genericCallback);
deployment.update("deploymentname", {}, genericCallback);
@@ -144,7 +144,7 @@ deployment.read("deploymentname", genericCallback);
deployment.readAll(query1, genericCallback);
///////////////////////////////////////
//User API invocations
// User API invocations
///////////////////////////////////////
user.getUser(genericCallback);
user.setUser({}, genericCallback);
@@ -153,7 +153,7 @@ user.allUsers(query1, genericCallback);
user.count(query1, genericCallback);
///////////////////////////////////////
//Messaging API invocations
// Messaging API invocations
///////////////////////////////////////
messaging.getMessageHistoryWithTimeFrame("topic", 5, 10, 15, 20, genericCallback);
messaging.getMessageHistory("topic", 5, 15, genericCallback);
@@ -162,7 +162,7 @@ messaging.getCurrentTopics(genericCallback);
messaging.publish("topic", "payload");
///////////////////////////////////////
//Device API invocations
// Device API invocations
///////////////////////////////////////
device.fetch(query1.query, genericCallback);
device.update(query1.query, { object: Object }, genericCallback);
@@ -170,10 +170,10 @@ device.delete(query1.query, genericCallback);
device.create({ newDevice: Object }, genericCallback);
///////////////////////////////////////
//Triggers API invocations
// Triggers API invocations
///////////////////////////////////////
ClearBlade.Trigger.Create(
"triggername",
"triggername",
{
system_key: "key",
name: "triggername",
@@ -186,7 +186,7 @@ ClearBlade.Trigger.Create(
ClearBlade.Trigger.Fetch("triggername", genericCallback);
///////////////////////////////////////
//Timers API invocations
// Timers API invocations
///////////////////////////////////////
ClearBlade.Timer.Create("timername", {}, genericCallback);
ClearBlade.Timer.Fetch("timername", genericCallback);

View File

@@ -2,4 +2,4 @@ declare global {
var ClearBlade: ClearBladeGlobal;
}
export {};
export {};

View File

@@ -1,6 +1,6 @@
// Type definitions for clearbladejs Server SDK v1.0.0
// Type definitions for clearbladejs-server 1.0
// Project: https://docs.clearblade.com/v/3/4-developer_reference/platformsdk/ClearBlade.js/
// Definitions by: Jim Bouquet <https://github.com/ClearBlade/>
// Definitions by: Jim Bouquet <https://github.com/ClearBlade>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.4
@@ -24,14 +24,14 @@ interface Resp {
success(msg: any): never;
}
declare var resp: Resp;
declare enum MessagingQOS {
MESSAGING_QOS_AT_MOST_ONCE = 0,
MESSAGING_QOS_AT_LEAST_ONCE = 1,
MESSAGING_QOS_EXACTLY_ONCE = 2
}
interface InitOptions {
interface InitOptions {
systemKey: string;
systemSecret: string;
logging?: boolean;
@@ -49,7 +49,7 @@ interface InitOptions {
callTimeout?: number;
}
interface APIUser {
interface APIUser {
email: string;
authToken: string;
user_id?: string;
@@ -59,9 +59,7 @@ interface KeyValuePair {
[key: string]: any;
}
interface CbCallback {
(error: boolean, response: Resp): void
}
type CbCallback = (error: boolean, response: Resp) => void;
interface ClearBladeGlobal extends ClearBladeInt {
user: APIUser;
@@ -76,18 +74,18 @@ interface ClearBladeInt {
addFilterToQuery(queryObj: QueryObj, condition: QueryConditions, key: string, value: QueryValue): void;
addSortToQuery(queryObj: QueryObj, direction: QuerySortDirections, column: string): void;
Code(): Code;
Collection(options: string | CollectionOptionsWithName | CollectionOptionsWithID | CollectionOptionsWithCollection) :Collection;
Collection(options: string | CollectionOptionsWithName | CollectionOptionsWithID | CollectionOptionsWithCollection): Collection;
Deployment(): Deployment;
Device(): Device;
edgeId(): string;
execute(error: Object, response: Object, callback: CbCallback): any;
execute(error: object, response: object, callback: CbCallback): any;
getAllCollections(callback: CbCallback): void;
http(): Object;
http(): object;
init(options: InitOptions | {request: BasicReq}): void;
isEdge(callback: CbCallback): boolean;
isCurrentUserAuthenticated(callback: CbCallback): void;
isObjectEmpty(obj: Object): boolean;
Item(data: Object, options: string | ItemOptions): Item;
isObjectEmpty(obj: object): boolean;
Item(data: object, options: string | ItemOptions): Item;
logger(message: string): void;
loginAnon(callback: CbCallback): void;
loginUser(email: string, password: string, callback: CbCallback): void;
@@ -107,18 +105,18 @@ interface ClearBladeInt {
updateDevice(name: string, data: object, causeTrigger: boolean, callback: CbCallback): void;
getDeviceByName(name: string, callback: CbCallback): void;
getAllDevicesForSystem(callback: CbCallback): void;
validateEmailPassword(email: string, password:string): void;
validateEmailPassword(email: string, password: string): void;
}
interface CollectionOptionsWithCollection {
interface CollectionOptionsWithCollection {
collection: string;
}
interface CollectionOptionsWithName {
interface CollectionOptionsWithName {
collectionName: string;
}
interface CollectionOptionsWithID {
interface CollectionOptionsWithID {
collectionID: string;
}
@@ -128,12 +126,12 @@ interface Collection {
systemKey: string;
systemSecret: string;
addColumn(options: Object, callback: CbCallback): void;
addColumn(options: object, callback: CbCallback): void;
dropColumn(name: string, callback: CbCallback): void;
deleteCollection(callback: CbCallback): void;
fetch(query: Query, callback: CbCallback): void;
create(newItem: Item, callback: CbCallback): void;
update(query: Query, changes: Object, callback: CbCallback): void;
update(query: Query, changes: object, callback: CbCallback): void;
remove(query: Query, callback: CbCallback): void;
columns(callback: CbCallback): void;
count(query: Query, callback: CbCallback): void;
@@ -156,14 +154,16 @@ declare enum QueryConditions {
type QueryValue = string|number|boolean;
interface QueryOptions {
interface QueryOptions {
offset?: number;
limit?: number;
}
interface QueryOptionsWithCollection extends CollectionOptionsWithCollection, QueryOptions{}
interface QueryOptionsWithName extends CollectionOptionsWithName, QueryOptions{}
interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions{}
interface QueryOptionsWithCollection extends CollectionOptionsWithCollection, QueryOptions {}
interface QueryOptionsWithName extends CollectionOptionsWithName, QueryOptions {}
interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions {}
interface Query {
SELECTCOLUMNS?: string[];
@@ -174,11 +174,11 @@ interface Query {
}
interface QueryFilter {
[QueryConditions: string]: QueryFilterValue
[QueryConditions: string]: QueryFilterValue;
}
interface QueryFilterValue {
[name: string]: QueryValue
[name: string]: QueryValue;
}
interface QueryObj {
@@ -204,15 +204,15 @@ interface QueryObj {
or(query: QueryObj): void;
setPage(pageSize: number, pageNum: number): void;
fetch(callback: CbCallback): void;
update(changes: Object, callback: CbCallback): void;
update(changes: object, callback: CbCallback): void;
columns(columnsArray: string[]): void;
remove(callback: CbCallback): void;
}
interface ItemOptions extends CollectionOptionsWithID{}
interface ItemOptions extends CollectionOptionsWithID {}
interface Item {
data: Object;
data: object;
save(): void;
refresh(): void;
@@ -224,11 +224,11 @@ interface Code {
systemKey: string;
systemSecret: string;
execute(name: string, params: Object, loggingEnabled: boolean, callback: CbCallback): void;
execute(name: string, params: object, loggingEnabled: boolean, callback: CbCallback): void;
getAllServices(callback: CbCallback): void;
}
interface DeploymentOptions{}
interface DeploymentOptions {}
interface Deployment {
user: APIUser;
@@ -249,8 +249,8 @@ interface AppUser {
systemSecret: string;
getUser(callback: CbCallback): void;
setUser(data: Object, callback: CbCallback): void;
setUsers(query: QueryObj, data: Object, callback: CbCallback): void;
setUser(data: object, callback: CbCallback): void;
setUsers(query: QueryObj, data: object, callback: CbCallback): void;
allUsers(query: QueryObj, callback: CbCallback): void;
count(query: QueryObj, callback: CbCallback): void;
}
@@ -275,9 +275,9 @@ interface Device {
systemSecret: string;
fetch(query: Query, callback: CbCallback): void;
update(query: Query, changes: Object, callback: CbCallback): void;
update(query: Query, changes: object, callback: CbCallback): void;
delete(query: Query, callback: CbCallback): void;
create(newDevice: Object, callback: CbCallback): void;
create(newDevice: object, callback: CbCallback): void;
}
declare enum TriggerModule {
@@ -320,7 +320,7 @@ interface TriggerInstance {
name: string;
systemKey: string;
Update(options: Object, callback: CbCallback): void;
Update(options: object, callback: CbCallback): void;
Delete(callback: CbCallback): void;
}
@@ -328,8 +328,8 @@ interface TimerInstance {
name: string;
systemKey: string;
Update(options: Object, callback: CbCallback): void;
Update(options: object, callback: CbCallback): void;
Delete(callback: CbCallback): void;
}
declare var ClearBlade: ClearBladeGlobal;
declare var ClearBlade: ClearBladeGlobal;

View File

@@ -1,79 +1,6 @@
{
"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
"no-empty-interface": false
}
}