From 4d7b0c1f0a204a6816e82b7d2410bd82a7358e37 Mon Sep 17 00:00:00 2001 From: Jim Bouquet Date: Thu, 5 Apr 2018 17:10:03 -0500 Subject: [PATCH 1/5] Added type definitions for clearbladejs-client, clearbladejs-server, and clearbladejs-node. --- .../clearbladejs-client-tests.ts | 193 ++++++++ types/clearbladejs-client/global.d.ts | 5 + types/clearbladejs-client/index.d.ts | 441 ++++++++++++++++++ types/clearbladejs-client/tsconfig.json | 32 ++ types/clearbladejs-client/tslint.json | 79 ++++ .../clearbladejs-node-tests.ts | 128 +++++ types/clearbladejs-node/index.d.ts | 256 ++++++++++ types/clearbladejs-node/tsconfig.json | 34 ++ types/clearbladejs-node/tslint.json | 79 ++++ .../clearbladejs-server-tests.ts | 192 ++++++++ types/clearbladejs-server/global.d.ts | 5 + types/clearbladejs-server/index.d.ts | 336 +++++++++++++ types/clearbladejs-server/tsconfig.json | 32 ++ types/clearbladejs-server/tslint.json | 79 ++++ 14 files changed, 1891 insertions(+) create mode 100644 types/clearbladejs-client/clearbladejs-client-tests.ts create mode 100644 types/clearbladejs-client/global.d.ts create mode 100644 types/clearbladejs-client/index.d.ts create mode 100644 types/clearbladejs-client/tsconfig.json create mode 100644 types/clearbladejs-client/tslint.json create mode 100644 types/clearbladejs-node/clearbladejs-node-tests.ts create mode 100644 types/clearbladejs-node/index.d.ts create mode 100644 types/clearbladejs-node/tsconfig.json create mode 100644 types/clearbladejs-node/tslint.json create mode 100644 types/clearbladejs-server/clearbladejs-server-tests.ts create mode 100644 types/clearbladejs-server/global.d.ts create mode 100644 types/clearbladejs-server/index.d.ts create mode 100644 types/clearbladejs-server/tsconfig.json create mode 100644 types/clearbladejs-server/tslint.json diff --git a/types/clearbladejs-client/clearbladejs-client-tests.ts b/types/clearbladejs-client/clearbladejs-client-tests.ts new file mode 100644 index 0000000000..9aece4b19a --- /dev/null +++ b/types/clearbladejs-client/clearbladejs-client-tests.ts @@ -0,0 +1,193 @@ +// Testing type definitions for clearbladejs Client SDK v1.0.0 +// Project: https://github.com/ClearBlade/JavaScript-API +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +var genericCallback = function(error: boolean, response: Resp) {}; + +/////////////////////////////////////// +//ClearBlade object API invocations +/////////////////////////////////////// +ClearBlade.init({ + systemKey: "abcdef", + systemSecret: "abcdefg", + callback: genericCallback +}); + +ClearBlade.setUser("test@test.com", "password"); +ClearBlade.registerUser("test@test.com", "password", genericCallback); +ClearBlade.isCurrentUserAuthenticated(genericCallback); +ClearBlade.logoutUser(genericCallback); +ClearBlade.loginAnon(genericCallback); +ClearBlade.loginUser("test@test.com", "password", genericCallback); +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" }); + +var query1 = ClearBlade.Query("collectionID"); +var query2 = ClearBlade.Query({ offset: 5, limit: 5, collectionID: "collectionID" }); +var query3 = ClearBlade.Query({ collectionName: "collectionName" }); + +var item1 = ClearBlade.Item({}, "collectionID"); +var item2 = ClearBlade.Item({}, { collectionID: "collectionID" }); + +var code = ClearBlade.Code(); +var user = ClearBlade.User(); + +var messaging = ClearBlade.Messaging({}, genericCallback); +var 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(); + +ClearBlade.getEdges(query1.query, genericCallback); + +/////////////////////////////////////// +//Collection API invocations +/////////////////////////////////////// +coll1.fetch(query1.query, genericCallback); +coll1.create(ClearBlade.Item({}, ""), genericCallback); +coll1.update(query1.query, {}, genericCallback); +coll1.remove(query1.query, genericCallback); +coll1.columns(genericCallback); +coll1.count(query1.query, genericCallback); + +/////////////////////////////////////// +//Query API invocations +/////////////////////////////////////// +query1.addSortToQuery( + query1, + QuerySortDirections.QUERY_SORT_ASCENDING, + "column1" +); +query1.addFilterToQuery( + query1, + QueryConditions.QUERY_GREATERTHAN, + "key", + "value" +); +query1.ascending("string"); +query1.descending("string"); +query1.equalTo("string", "string"); +query1.greaterThan("string", 2); +query1.greaterThanEqualTo("string", false); +query1.lessThan("string", "string"); +query1.lessThanEqualTo("string", "string"); +query1.notEqualTo("string", "string"); +query1.matches("string", new RegExp(/.*/)); +query1.or(query2); +query1.setPage(1, 1); +query1.fetch(genericCallback); +query1.update({}, genericCallback); +query1.columns([]); +query1.remove(genericCallback); + +/////////////////////////////////////// +//Item API invocations +/////////////////////////////////////// +item1.save(genericCallback); +item1.refresh(genericCallback); +item1.destroy(genericCallback); + +/////////////////////////////////////// +//Code API invocations +/////////////////////////////////////// +code.create("codeName", "body: string", genericCallback); +code.update("codeName", "body: string", genericCallback); +code.delete("codeName", genericCallback); +code.execute("codeName", {}, genericCallback); +code.getCompletedServices(genericCallback); +code.getFailedServices(genericCallback); +code.getAllServices(genericCallback); + +/////////////////////////////////////// +//User API invocations +/////////////////////////////////////// +user.getUser(genericCallback); +user.setUser({}, genericCallback); +user.allUsers(query1.query, genericCallback); +user.setPassword("old_password", "new_password", genericCallback); +user.count(query1.query, genericCallback); + +/////////////////////////////////////// +//Messaging API invocations +/////////////////////////////////////// +messaging.getMessageHistoryWithTimeFrame("topic", 5, 10, 15, 20, genericCallback); +messaging.getMessageHistory("topic", 5, 15, genericCallback); +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) {}; +messaging.subscribe("topic", {}, mcb); +messaging.unsubscribe("topic", {}); +messaging.disconnect(); + +/////////////////////////////////////// +//MessagingStats API invocations +/////////////////////////////////////// +stats.getAveragePayloadSize("topic: string", 5, 5, genericCallback); +stats.getOpenConnections(genericCallback); +stats.getCurrentSubscribers("topic: string", genericCallback); + +/////////////////////////////////////// +//Edge API invocations +/////////////////////////////////////// +edge.updateEdgeByName("edgename", {changedColumn: "New value"}, genericCallback); +edge.deleteEdgeByName("edgename", genericCallback); +edge.create({newEdge: Object}, "edgename", genericCallback); +edge.columns(genericCallback); +edge.count(query1.query, genericCallback); + +/////////////////////////////////////// +//Metrics API invocations +/////////////////////////////////////// +metrics.setQuery(query1.query); +metrics.getStatistics(genericCallback); +metrics.getStatisticsHistory(genericCallback); +metrics.getDBConnections(genericCallback); +metrics.getLogs(genericCallback); + +/////////////////////////////////////// +//Device API invocations +/////////////////////////////////////// +device.getDeviceByName("devicename", genericCallback); +device.updateDeviceByName("devicename", { object: Object }, true, genericCallback); +device.deleteDeviceByName("devicename", genericCallback); +device.fetch(query1.query, genericCallback); +device.update(query1.query, { object: Object }, false, genericCallback); +device.delete(query1.query, genericCallback); +device.create({ newDevice: Object }, genericCallback); +device.columns(genericCallback); +device.count(query1.query, genericCallback); + +/////////////////////////////////////// +//Analytics API invocations +/////////////////////////////////////// +analytics.getStorage({}, genericCallback); +analytics.getCount({}, genericCallback); +analytics.getEventList({}, genericCallback); +analytics.getEventTotals({}, genericCallback); +analytics.getUserEvents({}, genericCallback); + +/////////////////////////////////////// +//Portal API invocations +/////////////////////////////////////// +portal.fetch(genericCallback); +portal.update({data: Object}, genericCallback); + +/////////////////////////////////////// +//Triggers API invocations +/////////////////////////////////////// +triggers.fetchDefinitions(genericCallback); +triggers.create("triggername", {data: Object}, genericCallback); +triggers.update("triggername", {data: Object}, genericCallback); +triggers.delete("triggername", genericCallback); diff --git a/types/clearbladejs-client/global.d.ts b/types/clearbladejs-client/global.d.ts new file mode 100644 index 0000000000..7f70ed08f7 --- /dev/null +++ b/types/clearbladejs-client/global.d.ts @@ -0,0 +1,5 @@ +declare global { + var ClearBlade: ClearBladeGlobal; +} + +export {}; \ No newline at end of file diff --git a/types/clearbladejs-client/index.d.ts b/types/clearbladejs-client/index.d.ts new file mode 100644 index 0000000000..3c7ebd40f1 --- /dev/null +++ b/types/clearbladejs-client/index.d.ts @@ -0,0 +1,441 @@ +// Type definitions for clearbladejs Client SDK v1.0.0 +// Project: https://github.com/ClearBlade/JavaScript-API +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// +// TypeScript Version: 2.1 + +/// + +interface Resp { + error(msg: any): never; // todo: figure out if we can have the compiler throw an error if someone adds code after this + success(msg: any): never; +} + +declare enum MessagingQOS { + MESSAGING_QOS_AT_MOST_ONCE = 0, + MESSAGING_QOS_AT_LEAST_ONCE = 1, + MESSAGING_QOS_EXACTLY_ONCE = 2 +} + +interface InitOptions { + systemKey: string; + systemSecret: string; + masterSecret?: string; + logging?: boolean; + callback?: CbCallback; + email?: string; + password?: string; + registerUser?: boolean; + useUser?: APIUser; + URI?: string; + messagingURI?: string; + messagingPort?: number; + defaultQoS?: MessagingQOS; + callTimeout?: number; + messagingAuthPort?: number; +} + +interface RequestOptions { + method?: string; + endpoint?: string; + body?: string; + qs?: string; + URI?: string; + useUser?: boolean; + authToken?: string; + timeout?: number; + user?: APIUser; +} + +interface APIUser { + email: string; + authToken: string; +} + +interface CbCallback { + (error: boolean, response: Resp): void; +} + +interface ClearBladeGlobal extends ClearBladeInt { + MESSAGING_QOS_AT_MOST_ONCE: MessagingQOS.MESSAGING_QOS_AT_MOST_ONCE; + MESSAGING_QOS_AT_LEAST_ONCE: MessagingQOS.MESSAGING_QOS_AT_LEAST_ONCE; + MESSAGING_QOS_EXACTLY_ONCE: MessagingQOS.MESSAGING_QOS_EXACTLY_ONCE; + + request(options: RequestOptions, callback: CbCallback): void; +} + +interface ClearBladeInt { + systemKey: string; + systemSecret: string; + masterSecret: string; + URI: string; + messagingURI: string; + messagingPort: number; + logging: boolean; + defaultQoS: MessagingQOS; + + init(options: InitOptions): void; + setUser(email: string, password: string): void; + registerUser(email: string, password: string, callback: CbCallback): void; + isCurrentUserAuthenticated(callback: CbCallback): void; + logoutUser(callback: CbCallback): void; + loginAnon(callback: CbCallback): void; + loginUser(email: string, password: string, callback: CbCallback): void; + loginUserMqtt(email: string, password: string, callback: CbCallback): void; + registerMasterCallback(callback: CbCallback): void; + Collection(options: string | CollectionOptionsWithName | CollectionOptionsWithID): Collection; + Query( + options: string | QueryOptionsWithName | QueryOptionsWithID + ): QueryObj; + Item(data: Object, collectionID: string | ItemOptions): Item; + Code(): Code; + User(): AppUser; + Messaging(options: MessagingOptions, callback: CbCallback): Messaging; + MessagingStats(): MessagingStats; + sendPush( + users: string[], + payload: Object, + appId: string, + callback: CbCallback + ): void; + getEdges(query: Query, callback: CbCallback): void; + Edge(): Edge; + Metrics(): Metrics; + Device(): Device; + Analytics(): Analytics; + Portal(name: string): Portal; + Triggers(): Triggers; + + getAllCollections(callback: CbCallback): void; +} +interface CollectionOptionsWithName { + collectionName: string; +} + +interface CollectionOptionsWithID { + collectionID: string; +} + +interface Collection { + name: string; + endpoint: string; + isUsingCollectionName: boolean; + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + fetch(query: Query, callback: CbCallback): void; + create(newItem: Item, 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; +} + +declare const enum QuerySortDirections { + QUERY_SORT_ASCENDING = "ASC", + QUERY_SORT_DESCENDING = "DESC" +} + +declare const enum QueryConditions { + QUERY_EQUAL = "EQ", + QUERY_NOTEQUAL = "NEQ", + QUERY_GREATERTHAN = "GT", + QUERY_GREATERTHAN_EQUAL = "GTE", + QUERY_LESSTHAN = "LT", + QUERY_LESSTHAN_EQUAL = "LTE", + QUERY_MATCHES = "RE" +} + +type QueryValue = string | number | boolean; + +interface QueryOptions { + offset?: number; + limit?: number; +} + +interface QueryOptionsWithName + extends CollectionOptionsWithName, + QueryOptions {} +interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions {} + +interface Query { + SELECTCOLUMNS?: string[]; + SORT?: QuerySortDirections; + FILTERS?: QueryFilter[]; + PAGESIZE?: number; + PAGENUM?: number; +} + +interface QueryFilter { + [QueryConditions: string]: QueryFilterValue; +} + +interface QueryFilterValue { + [name: string]: QueryValue; +} + +interface QueryObj { + endpoint: string; + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + query: Query; + OR: Query[]; + offset: number; + limit: number; + + addSortToQuery( + query: QueryObj, + direction: QuerySortDirections, + column: string + ): void; + addFilterToQuery( + query: QueryObj, + condition: QueryConditions, + key: string, + value: QueryValue + ): void; + ascending(field: string): void; + descending(field: string): void; + equalTo(field: string, value: QueryValue): void; + greaterThan(field: string, value: QueryValue): void; + greaterThanEqualTo(field: string, value: QueryValue): void; + lessThan(field: string, value: QueryValue): void; + lessThanEqualTo(field: string, value: QueryValue): void; + notEqualTo(field: string, value: QueryValue): void; + matches(field: string, pattern: RegExp): void; + or(query: QueryObj): void; + setPage(pageSize: number, pageNum: number): void; + fetch(callback: CbCallback): void; + update(changes: Object, callback: CbCallback): void; + columns(columnsArray: string[]): void; + remove(callback: CbCallback): void; +} + +interface ItemOptions extends CollectionOptionsWithID {} + +interface Item { + data: Object; + + save(callback: CbCallback): void; + refresh(callback: CbCallback): void; + destroy(callback: CbCallback): void; +} + +interface Code { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + callTimeout: number; + + 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; + getCompletedServices(callback: CbCallback): void; + getFailedServices(callback: CbCallback): void; + getAllServices(callback: CbCallback): void; +} + +interface AppUser { + user: APIUser; + URI: string; + endpoint: string; + systemKey: string; + systemSecret: string; + callTimeout: number; + + getUser(callback: CbCallback): void; + setUser(data: Object, callback: CbCallback): void; + allUsers(query: Query, callback: CbCallback): void; + setPassword( + old_password: string, + new_password: string, + callback: CbCallback + ): void; + count(query: Query, callback: CbCallback): void; +} + +interface Messaging { + user: APIUser; + URI: string; + endpoint: string; + systemKey: string; + systemSecret: string; + callTimeout: number; + client: Paho.MQTT.Client; + + getMessageHistoryWithTimeFrame( + topic: string, + count: number, + last: number, + start: number, + stop: number, + callback: CbCallback + ): void; + getMessageHistory( + topic: string, + last: number, + count: number, + callback: CbCallback + ): void; + getAndDeleteMessageHistory( + topic: string, + count: number, + last: number, + start: number, + stop: number, + callback: CbCallback + ): void; + currentTopics(callback: CbCallback): void; + publish(topic: string, payload: Object): void; + publishREST(topic: string, payload: Object, callback: CbCallback): void; + subscribe( + topic: string, + options: MessagingSubscribeOptions, + messageCallback: MessageCallback + ): void; + unsubscribe(topic: string, options: MessagingSubscribeOptions): void; + disconnect(): void; +} + +interface CommonMessagingProperties { + cleanSession?: boolean; + useSSL?: boolean; + hosts?: string; + ports?: string; + onSuccess?: Function; + onFailure?: Function; +} + +interface MessagingOptions extends CommonMessagingProperties { + qos?: MessagingQOS; +} + +interface MessagingConfiguration extends CommonMessagingProperties { + userName: string; + password: string; +} + +interface MessageCallback { + (message: string): void; +} + +interface MessagingSubscribeOptions { + qos?: MessagingQOS; + invocationContext?: Object; + onSuccess?: Function; + onFailure?: Function; + timeout?: number; +} + +interface MessagingStats { + user: APIUser; + URI: string; + endpoint: string; + systemKey: string; + + getAveragePayloadSize( + topic: string, + start: number, + stop: number, + callback: CbCallback + ): void; + getOpenConnections(callback: CbCallback): void; + getCurrentSubscribers(topic: string, callback: CbCallback): void; +} + +interface Edge { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + updateEdgeByName(name: string, object: Object, callback: CbCallback): void; + deleteEdgeByName(name: string, callback: CbCallback): void; + create(newEdge: Object, name: string, callback: CbCallback): void; + columns(callback: CbCallback): void; + count(query: Query, callback: CbCallback): void; +} + +interface Metrics { + user: APIUser; + URI: string; + systemKey: string; + + setQuery(query: Query): void; + getStatistics(callback: CbCallback): void; + getStatisticsHistory(callback: CbCallback): void; + getDBConnections(callback: CbCallback): void; + getLogs(callback: CbCallback): void; +} + +interface Device { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + getDeviceByName(name: string, callback: CbCallback): void; + updateDeviceByName( + name: string, + object: Object, + trigger: boolean, + callback: CbCallback + ): void; + deleteDeviceByName(name: string, callback: CbCallback): void; + fetch(query: Query, callback: CbCallback): void; + update( + query: Query, + object: Object, + trigger: boolean, + callback: CbCallback + ): void; + delete(query: Query, callback: CbCallback): void; + create(newDevice: Object, callback: CbCallback): void; + columns(callback: CbCallback): void; + count(query: Query, callback: CbCallback): void; +} + +interface Analytics { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + getStorage(filter: QueryFilter, callback: CbCallback): void; + getCount(filter: QueryFilter, callback: CbCallback): void; + getEventList(filter: QueryFilter, callback: CbCallback): void; + getEventTotals(filter: QueryFilter, callback: CbCallback): void; + getUserEvents(filter: QueryFilter, callback: CbCallback): void; +} + +interface Portal { + name: string; + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + fetch(callback: CbCallback): void; + update(data: Object, callback: CbCallback): void; +} + +interface Triggers { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + fetchDefinitions(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; +} + +declare var ClearBlade: ClearBladeGlobal; diff --git a/types/clearbladejs-client/tsconfig.json b/types/clearbladejs-client/tsconfig.json new file mode 100644 index 0000000000..b360802518 --- /dev/null +++ b/types/clearbladejs-client/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "target": "ES5", + "moduleResolution": "node", + "module": "none", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + ".", + "../", + "../../node_modules/" + ], + "types": ["node"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clearbladejs-client-tests.ts", + "global.d.ts" + ], + "exclude": [ + "**/clearbladejs-node/*", + "**/clearbladejs-server/*" + ] +} \ No newline at end of file diff --git a/types/clearbladejs-client/tslint.json b/types/clearbladejs-client/tslint.json new file mode 100644 index 0000000000..a4c53997aa --- /dev/null +++ b/types/clearbladejs-client/tslint.json @@ -0,0 +1,79 @@ +{ + "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 newline at end of file diff --git a/types/clearbladejs-node/clearbladejs-node-tests.ts b/types/clearbladejs-node/clearbladejs-node-tests.ts new file mode 100644 index 0000000000..b600332ca2 --- /dev/null +++ b/types/clearbladejs-node/clearbladejs-node-tests.ts @@ -0,0 +1,128 @@ +import { ClearBlade, Resp, QuerySortDirections, QueryConditions } from "."; + +// Sample code for clearbladejs Node SDK v1.0.0 used to test typescript definitions +// Project: https://github.com/ClearBlade/Node-SDK +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +const constants = require("./constants.json"); + +var genericCallback = function(error: boolean, response: Resp) {}; + +/////////////////////////////////////// +//ClearBlade object API invocations +/////////////////////////////////////// +ClearBlade.init({ + email: "a@a.com", + password: "a", + systemKey: constants.systemKey, + systemSecret: constants.systemSecret, + URI: constants.URL, + messagingURI: constants.messageURL, + callback: genericCallback +}) + +ClearBlade.setUser("test@test.com", "password"); +ClearBlade.registerUser("test@test.com", "password", genericCallback); +ClearBlade.isCurrentUserAuthenticated(genericCallback); +if (!ClearBlade.isObjectEmpty({prop: "test"})) { + ClearBlade.logger("Object is not empty"); +} + +ClearBlade.validateEmailPassword("test@test.com", "password"); + +ClearBlade.logoutUser(genericCallback); +ClearBlade.loginAnon(genericCallback); +ClearBlade.loginUser("test@test.com", "password", genericCallback); + +ClearBlade.sendPush([], {}, "appId: string", genericCallback); + +// execute(error: Object, response: Object, callback: ClearBladeCallback): void; +// 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"}); + +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"}); + +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); + + +var item1 = ClearBlade.Item({}, "hello"); +var item2 = ClearBlade.Item({}, {collectionID: "hello"}); + +var code = ClearBlade.Code(); +var user = ClearBlade.User(); + +var messaging = ClearBlade.Messaging({}, genericCallback); + +/////////////////////////////////////// +//Collection API invocations +/////////////////////////////////////// +coll1.fetch(query1, genericCallback); +coll1.create(ClearBlade.Item({}, ""), genericCallback); +coll1.update(query1.query, {}, genericCallback); +coll1.remove(query1.query, genericCallback); + +/////////////////////////////////////// +//Query API invocations +/////////////////////////////////////// +query1.ascending("string"); +query1.descending("string"); +query1.equalTo("string", "string"); +query1.greaterThan("string", 2); +query1.greaterThanEqualTo("string", false); +query1.lessThan("string", "string"); +query1.lessThanEqualTo("string", "string"); +query1.notEqualTo("string", "string"); +query1.or(query2); +query1.setPage(1, 1); +query1.fetch(genericCallback); +query1.update({}, genericCallback); +query1.remove(genericCallback); + +/////////////////////////////////////// +//Item API invocations +/////////////////////////////////////// +item1.save(); +item1.refresh(); +item1.destroy(); + +/////////////////////////////////////// +//Code API invocations +/////////////////////////////////////// +code.execute("codeName", {}, genericCallback); + +/////////////////////////////////////// +//User API invocations +/////////////////////////////////////// +user.getUser(genericCallback); +user.setUser({}, genericCallback); +user.allUsers(query1.query, genericCallback); + +/////////////////////////////////////// +//Messaging API invocations +/////////////////////////////////////// +messaging.getMessageHistory("topic: string", 5, 15, genericCallback); + +messaging.publish("topic: string", {}); + +messaging.subscribe("my/topic", {}, messageReceivedCb); + +function messageReceivedCb (message: string) { + messaging.unsubscribe("my/topic"); +} + + + diff --git a/types/clearbladejs-node/index.d.ts b/types/clearbladejs-node/index.d.ts new file mode 100644 index 0000000000..a80ecc21d5 --- /dev/null +++ b/types/clearbladejs-node/index.d.ts @@ -0,0 +1,256 @@ +import { Response, RequestCallback } from "request/index"; +import { MqttClient, PacketCallback } from "mqtt"; + +// Type definitions for clearbladejs Node SDK v1.0.0 +// Project: https://github.com/ClearBlade/Node-SDK +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// +// TypeScript Version: 2.1 + +/// +/// + +declare 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 + success(msg: any): never; +} + +export interface InitOptions { + systemKey: string; + systemSecret: string; + logging?: boolean; + callback?: CbCallback; + email?: string; + password?: string; + registerUser?: boolean; + useUser?: APIUser; + URI?: string; + messagingURI?: string; + messagingPort?: number; + defaultQoS?: MessagingQOS; + callTimeout?: number; +} + +export interface RequestOptions { + systemKey: string; + systemSecret: string; + method?: string; + endpoint?: string; + body?: string; + qs?: string; + URI?: string; + useUser?: boolean; + authToken?: string; + user?: APIUser; +} + +export interface APIUser { + email: string; + authToken: string; +} + +export interface KeyValuePair { + [key: string]: any; +} + +export interface CbCallback { + (error: boolean, response: Resp): void +} + +export default interface ClearBladeGlobal extends ClearBladeInt { + isCurrentUserAuthenticated(callback: CbCallback): void; +} + +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; + init(options: InitOptions): void; + 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; + logoutUser(callback: CbCallback): void; + makeKVPair(key: string, value: string): KeyValuePair; + parseOperationQuery(query: Query): string; + parseQuery(query: Query | QueryObj): string; + 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; +} + +export interface CollectionOptionsWithName { + collectionName: string; +} + +export interface CollectionOptionsWithID { + collectionID: string; +} + +export interface Collection { + endpoint: string; + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + fetch(query: QueryObj, callback: CbCallback): void; + create(newItem: Item, callback: CbCallback): void; + update(query: Query, changes: Object, callback: CbCallback): void; + remove(query: Query, callback: CbCallback): void; +} + +export declare const enum QuerySortDirections { + QUERY_SORT_ASCENDING = 'ASC', + QUERY_SORT_DESCENDING = 'DESC' +} + +export declare const enum QueryConditions { + QUERY_EQUAL = 'EQ', + QUERY_NOTEQUAL = 'NEQ', + QUERY_GREATERTHAN = 'GT', + QUERY_GREATERTHAN_EQUAL = 'GTE', + QUERY_LESSTHAN = 'LT', + QUERY_LESSTHAN_EQUAL = 'LTE', + QUERY_MATCHES = 'RE' +} + +export type QueryValue = string|number|boolean; + +export interface QueryOptions { + offset?: number; + limit?: number; +} + +export interface QueryOptionsWithCollection extends QueryOptions{ + collection: string; +} + +export interface QueryOptionsWithName extends CollectionOptionsWithName, QueryOptions{} +export interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions{} + +export interface Query { + SELECTCOLUMNS?: string[]; + SORT?: QuerySortDirections; + FILTERS?: QueryFilter[]; + PAGESIZE?: number; + PAGENUM?: number; +} + +export interface QueryFilter { + [QueryConditions: string]: QueryFilterValue +} + +export interface QueryFilterValue { + [name: string]: QueryValue +} + +export interface QueryObj { + endpoint: string; + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + query: Query; + OR: Query[]; + offset: number; + limit: number; + + ascending(field: string): Query; + descending(field: string): Query; + equalTo(field: string, value: QueryValue): Query; + greaterThan(field: string, value: QueryValue): Query; + greaterThanEqualTo(field: string, value: QueryValue): Query; + lessThan(field: string, value: QueryValue): Query; + lessThanEqualTo(field: string, value: QueryValue): Query; + notEqualTo(field: string, value: QueryValue): Query; + matches(field: string, pattern: string): Query; + or(query: QueryObj): Query; + setPage(pageSize: number, pageNum: number): Query; + fetch(callback: CbCallback): void; + update(changes: Object, callback: CbCallback): void; + remove(callback: CbCallback): void; +} + +export interface ItemOptions extends CollectionOptionsWithID{} + +export interface Item { + data: Object; + + save(): void; + refresh(): void; + destroy(): void; +} + +export interface Code { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + callTimeout: number; + URIPrefix: string; + + execute(name: string, params: Object, callback: CbCallback): void; +} + +export interface AppUser { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + getUser(callback: CbCallback): void; + setUser(data: Object, callback: CbCallback): void; + allUsers(query: Query, callback: CbCallback): void; +} + +export interface Messaging { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + client: MqttClient; + + getMessageHistory(topic: string, startTime: number, count: number, callback: CbCallback): void; + publish(topic: string, payload: Object): void; + subscribe(topic: string, options: MessagingSubscribeOptions, messageCallback: MessageCallback): void; + unsubscribe(topic: string, callback?: PacketCallback): void; +} + +export interface CommonMessagingProperties { + hosts?: string; + ports?: string; +} + +export interface MessagingOptions extends CommonMessagingProperties { + qos?: MessagingQOS +} + +export interface MessagingSubscribeOptions { + qos?: MessagingQOS; + timeout?: number; +} + +export interface MessageCallback { + (message: string): void; +} + +declare var ClearBlade: ClearBladeGlobal; + +export {ClearBlade}; diff --git a/types/clearbladejs-node/tsconfig.json b/types/clearbladejs-node/tsconfig.json new file mode 100644 index 0000000000..da91170d85 --- /dev/null +++ b/types/clearbladejs-node/tsconfig.json @@ -0,0 +1,34 @@ +{ + "compileOnSave": true, + "compilerOptions": { + "target": "ES5", + "module": "es6", + "moduleResolution": "Node", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": false, + "noStrictGenericChecks": false, + "strictNullChecks": false, + "strictFunctionTypes": false, + "baseUrl": "../", + "typeRoots": [ + ".", + "../", + "../../node_modules/" + ], + "types": ["node"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clearbladejs-node-tests.ts", + "../../node_modules/mqtt/types/index.d.ts" + ], + "exclude": [ + "**/clearbladejs-client/*", + "**/clearbladejs-server/*" + ] +} \ No newline at end of file diff --git a/types/clearbladejs-node/tslint.json b/types/clearbladejs-node/tslint.json new file mode 100644 index 0000000000..a4c53997aa --- /dev/null +++ b/types/clearbladejs-node/tslint.json @@ -0,0 +1,79 @@ +{ + "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 newline at end of file diff --git a/types/clearbladejs-server/clearbladejs-server-tests.ts b/types/clearbladejs-server/clearbladejs-server-tests.ts new file mode 100644 index 0000000000..ea7c179df2 --- /dev/null +++ b/types/clearbladejs-server/clearbladejs-server-tests.ts @@ -0,0 +1,192 @@ +// Testing type definitions for clearbladejs Client SDK v1.0.0 +// Project: https://github.com/ClearBlade/JavaScript-API +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +var genericCallback = function(error: boolean, response: Resp) {}; + +/////////////////////////////////////// +//ClearBlade object API invocations +/////////////////////////////////////// +ClearBlade.init({ + systemKey: "abcdef", + systemSecret: "abcdefg", + callback: genericCallback +}); + +ClearBlade.init({request: { + isLogging: false, + params: { + param1: "1", + param2: 2 + }, + systemKey: "abcdef", + systemSecret: "abcdef", + userEmail: "test@test.com", + userToken: "abcdef", + userid: "abcdef", +}}); + +var about = ClearBlade.about(); +ClearBlade.setUser("test@test.com", "authtoken", "userId"); +ClearBlade.registerUser("test@test.com", "password", genericCallback); +ClearBlade.isCurrentUserAuthenticated(genericCallback); +ClearBlade.logoutUser(genericCallback); +ClearBlade.loginAnon(genericCallback); +ClearBlade.loginUser("test@test.com", "password", genericCallback); + +ClearBlade.getAllCollections(genericCallback); +var edgeID = ClearBlade.edgeId(); +var isEdge = ClearBlade.isEdge(genericCallback); +if (ClearBlade.isObjectEmpty({test: "test"})) { + ClearBlade.logger("Object is empty"); +} +var 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" }); + +var query1 = ClearBlade.Query({ collectionID: "collectionID" }); +var query2 = ClearBlade.Query({ collectionName: "collectionName" }); +var query3 = ClearBlade.Query({ collection: "collectionID" }); + +var item1 = ClearBlade.Item({}, "collectionID"); +var item2 = ClearBlade.Item({}, { collectionID: "collectionID" }); + +var code = ClearBlade.Code(); +var deployment = ClearBlade.Deployment(); +var user = ClearBlade.User(); + +var messaging = ClearBlade.Messaging({}, genericCallback); + +var device = ClearBlade.Device(); + +ClearBlade.addToQuery(query1, "key", "value"); +ClearBlade.addSortToQuery( + query1, + QuerySortDirections.QUERY_SORT_ASCENDING, + "column1" +); +ClearBlade.addFilterToQuery( + query1, + QueryConditions.QUERY_GREATERTHAN, + "key", + "value" +); + +ClearBlade.newCollection("collectionName", genericCallback); + +var parseOperation = ClearBlade.parseOperationQuery(query1.query); +var parseQuery1 = ClearBlade.parseQuery(query1); +var parseQuery2 = ClearBlade.parseQuery(query1.query); + +ClearBlade.createDevice("devicename", {type: "devicetype"}, false, genericCallback); +ClearBlade.deleteDevice("devicename", true, genericCallback); +ClearBlade.updateDevice("devicename", {type: "devicetype"}, true, genericCallback); +ClearBlade.getDeviceByName("devicename", genericCallback); +ClearBlade.getAllDevicesForSystem(genericCallback); +ClearBlade.validateEmailPassword("test@test.com", "password"); + +/////////////////////////////////////// +//Collection API invocations +/////////////////////////////////////// +coll1.addColumn({name: "column1"}, genericCallback); +coll1.dropColumn("column1", genericCallback); +coll1.deleteCollection(genericCallback); +coll1.fetch(query1.query, genericCallback); +coll1.create(ClearBlade.Item({}, ""), genericCallback); +coll1.update(query1.query, {}, genericCallback); +coll1.remove(query1.query, genericCallback); +coll1.columns(genericCallback); +coll1.count(query1.query, genericCallback); + +/////////////////////////////////////// +//Query API invocations +/////////////////////////////////////// +query2.ascending("string"); +query1.descending("string"); +query1.equalTo("string", "string"); +query1.greaterThan("string", 2); +query1.greaterThanEqualTo("string", false); +query1.lessThan("string", "string"); +query1.lessThanEqualTo("string", "string"); +query1.notEqualTo("string", "string"); +query1.matches("string", ".*"); +query1.or(query2); +query1.setPage(1, 1); +query1.fetch(genericCallback); +query1.update({}, genericCallback); +query1.columns([]); +query1.remove(genericCallback); + +/////////////////////////////////////// +//Item API invocations +/////////////////////////////////////// +item1.save(); +item1.refresh(); +item1.destroy(); + +/////////////////////////////////////// +//Code API invocations +/////////////////////////////////////// +code.execute("codeName", {}, true, genericCallback); +code.getAllServices(genericCallback); + +/////////////////////////////////////// +//Deployment API invocations +/////////////////////////////////////// +deployment.create("deploymentname", "deployment description", {}, genericCallback); +deployment.update("deploymentname", {}, genericCallback); +deployment.delete("deploymentname", genericCallback); +deployment.read("deploymentname", genericCallback); +deployment.readAll(query1, genericCallback); + +/////////////////////////////////////// +//User API invocations +/////////////////////////////////////// +user.getUser(genericCallback); +user.setUser({}, genericCallback); +user.setUsers(query2, {name: "Fred"}, genericCallback); +user.allUsers(query1, genericCallback); +user.count(query1, genericCallback); + +/////////////////////////////////////// +//Messaging API invocations +/////////////////////////////////////// +messaging.getMessageHistoryWithTimeFrame("topic", 5, 10, 15, 20, genericCallback); +messaging.getMessageHistory("topic", 5, 15, genericCallback); +messaging.getAndDeleteMessageHistory("topic", 5, 10, 1, 20, genericCallback); +messaging.getCurrentTopics(genericCallback); +messaging.publish("topic", "payload"); + +/////////////////////////////////////// +//Device API invocations +/////////////////////////////////////// +device.fetch(query1.query, genericCallback); +device.update(query1.query, { object: Object }, genericCallback); +device.delete(query1.query, genericCallback); +device.create({ newDevice: Object }, genericCallback); + +/////////////////////////////////////// +//Triggers API invocations +/////////////////////////////////////// +ClearBlade.Trigger.Create( + "triggername", + { + system_key: "key", + name: "triggername", + def_module: TriggerModule.DEVICE, + def_name: "someName", + key_value_pairs: [], + service_name: "ServiceName" + }, + genericCallback); +ClearBlade.Trigger.Fetch("triggername", genericCallback); + +/////////////////////////////////////// +//Timers API invocations +/////////////////////////////////////// +ClearBlade.Timer.Create("timername", {}, genericCallback); +ClearBlade.Timer.Fetch("timername", genericCallback); diff --git a/types/clearbladejs-server/global.d.ts b/types/clearbladejs-server/global.d.ts new file mode 100644 index 0000000000..7f70ed08f7 --- /dev/null +++ b/types/clearbladejs-server/global.d.ts @@ -0,0 +1,5 @@ +declare global { + var ClearBlade: ClearBladeGlobal; +} + +export {}; \ No newline at end of file diff --git a/types/clearbladejs-server/index.d.ts b/types/clearbladejs-server/index.d.ts new file mode 100644 index 0000000000..7333b04cb9 --- /dev/null +++ b/types/clearbladejs-server/index.d.ts @@ -0,0 +1,336 @@ +// Type definitions for clearbladejs Server SDK v1.0.0 +// Project: https://docs.clearblade.com/v/3/4-developer_reference/platformsdk/ClearBlade.js/ +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// +// TypeScript Version: 2.1 + +/// + +interface BasicReq { + readonly isLogging: boolean; + readonly params: { + [id: string]: any; + }; + readonly systemKey: string; + readonly systemSecret: string; + readonly userEmail: string; + readonly userToken: string; + readonly userid: string; +} +type ReqTypes = BasicReq; +declare var req: ReqTypes; +interface Resp { + error(msg: any): never; + 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 { + systemKey: string; + systemSecret: string; + logging?: boolean; + callback?: CbCallback; + authToken?: string; + userToken?: string; + email?: string; + password?: string; + registerUser?: boolean; + useUser?: APIUser; + URI?: string; + messagingURI?: string; + messagingPort?: number; + defaultQoS?: MessagingQOS; + callTimeout?: number; +} + +interface APIUser { + email: string; + authToken: string; + user_id?: string; +} + +interface KeyValuePair { + [key: string]: any; +} + +interface CbCallback { + (error: boolean, response: Resp): void +} + +interface ClearBladeGlobal extends ClearBladeInt { + user: APIUser; +} + +interface ClearBladeInt { + Trigger: TriggerClass; + Timer: TimerClass; + + about(): string; + 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 | CollectionOptionsWithCollection) :Collection; + Deployment(): Deployment; + Device(): Device; + edgeId(): string; + execute(error: Object, response: Object, callback: CbCallback): any; + getAllCollections(callback: CbCallback): void; + 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; + logger(message: string): void; + loginAnon(callback: CbCallback): void; + loginUser(email: string, password: string, callback: CbCallback): void; + logoutUser(callback: CbCallback): void; + makeKVPair(key: string, value: string): KeyValuePair; + Messaging(options: MessagingOptions, callback: CbCallback): Messaging; + newCollection(name: string, callback: CbCallback): void; + Query(options: QueryOptionsWithCollection | QueryOptionsWithName | QueryOptionsWithID): QueryObj; + parseOperationQuery(query: Query): string; + parseQuery(query: Query | QueryObj): string; + registerUser(email: string, password: string, callback: CbCallback): void; + setUser(email: string, authToken: string, userId: string): void; + User(): AppUser; + + createDevice(name: string, data: object, causeTrigger: boolean, callback: CbCallback): void; + deleteDevice(name: string, causeTrigger: boolean, callback: CbCallback): void; + 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; +} + +interface CollectionOptionsWithCollection { + collection: string; +} + +interface CollectionOptionsWithName { + collectionName: string; +} + +interface CollectionOptionsWithID { + collectionID: string; +} + +interface Collection { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + 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; + remove(query: Query, callback: CbCallback): void; + columns(callback: CbCallback): void; + count(query: Query, callback: CbCallback): void; +} + +declare const enum QuerySortDirections { + QUERY_SORT_ASCENDING = 'ASC', + QUERY_SORT_DESCENDING = 'DESC' +} + +declare const enum QueryConditions { + QUERY_EQUAL = 'EQ', + QUERY_NOTEQUAL = 'NEQ', + QUERY_GREATERTHAN = 'GT', + QUERY_GREATERTHAN_EQUAL = 'GTE', + QUERY_LESSTHAN = 'LT', + QUERY_LESSTHAN_EQUAL = 'LTE', + QUERY_MATCHES = 'RE' +} + +type QueryValue = string|number|boolean; + +interface QueryOptions { + offset?: number; + limit?: number; +} + +interface QueryOptionsWithCollection extends CollectionOptionsWithCollection, QueryOptions{} +interface QueryOptionsWithName extends CollectionOptionsWithName, QueryOptions{} +interface QueryOptionsWithID extends CollectionOptionsWithID, QueryOptions{} + +interface Query { + SELECTCOLUMNS?: string[]; + SORT?: QuerySortDirections; + FILTERS?: QueryFilter[]; + PAGESIZE?: number; + PAGENUM?: number; +} + +interface QueryFilter { + [QueryConditions: string]: QueryFilterValue +} + +interface QueryFilterValue { + [name: string]: QueryValue +} + +interface QueryObj { + id: string; + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + query: Query; + OR: Query[]; + offset: number; + limit: number; + + ascending(field: string): void; + descending(field: string): void; + equalTo(field: string, value: QueryValue): void; + greaterThan(field: string, value: QueryValue): void; + greaterThanEqualTo(field: string, value: QueryValue): void; + lessThan(field: string, value: QueryValue): void; + lessThanEqualTo(field: string, value: QueryValue): void; + notEqualTo(field: string, value: QueryValue): void; + matches(field: string, pattern: QueryValue): void; + or(query: QueryObj): void; + setPage(pageSize: number, pageNum: number): void; + fetch(callback: CbCallback): void; + update(changes: Object, callback: CbCallback): void; + columns(columnsArray: string[]): void; + remove(callback: CbCallback): void; +} + +interface ItemOptions extends CollectionOptionsWithID{} + +interface Item { + data: Object; + + save(): void; + refresh(): void; + destroy(): void; +} + +interface Code { + user: APIUser; + systemKey: string; + systemSecret: string; + + execute(name: string, params: Object, loggingEnabled: boolean, callback: CbCallback): void; + getAllServices(callback: CbCallback): void; +} + +interface DeploymentOptions{} + +interface Deployment { + user: APIUser; + systemKey: string; + systemSecret: string; + + create(name: string, description: string, options: DeploymentOptions, callback: CbCallback): void; + update(name: string, options: DeploymentOptions, callback: CbCallback): void; + delete(name: string, callback: CbCallback): void; + read(name: string, callback: CbCallback): void; + readAll(query: QueryObj, callback: CbCallback): void; +} + +interface AppUser { + user: APIUser; + URI: string; + systemKey: string; + systemSecret: string; + + getUser(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; +} + +interface Messaging { + user: APIUser; + systemKey: string; + systemSecret: string; + + getMessageHistoryWithTimeFrame(topic: string, count: number, last: number, start: number, stop: number, callback: CbCallback): void; + getMessageHistory(topic: string, start: number, count: number, callback: CbCallback): void; + getAndDeleteMessageHistory(topic: string, count: number, last: number, start: number, stop: number, callback: CbCallback): void; + getCurrentTopics(callback: CbCallback): void; + publish(topic: string, payload: string | ArrayBuffer): void; +} + +interface MessagingOptions {} + +interface Device { + URI: string; + systemKey: string; + systemSecret: string; + + fetch(query: Query, callback: CbCallback): void; + update(query: Query, changes: Object, callback: CbCallback): void; + delete(query: Query, callback: CbCallback): void; + create(newDevice: Object, callback: CbCallback): void; +} + +declare const enum TriggerModule { + DEVICE = "Device", + Data = "Data", + MESSAGING = "Messaging", + USER = "User" +} + +interface TriggerCreateOptions { + system_key: string; + name: string; + def_module: TriggerModule; + def_name: string; + key_value_pairs: KeyValuePair[]; + service_name: string; +} + +interface TriggerClass { + Create(name: string, options: TriggerCreateOptions, callback: CbCallback): void; + Fetch(name: string, callback: CbCallback): void; +} + +interface TimerCreateOptions { + description?: string; + start_time?: Date; + repeats?: number; + frequency?: number; + service_name?: string; + user_id?: string; + user_token?: string; +} + +interface TimerClass { + Create(name: string, options: TimerCreateOptions, callback: CbCallback): void; + Fetch(name: string, callback: CbCallback): void; +} + +interface TriggerInstance { + name: string; + systemKey: string; + + Update(options: Object, callback: CbCallback): void; + Delete(callback: CbCallback): void; +} + +interface TimerInstance { + name: string; + systemKey: string; + + Update(options: Object, callback: CbCallback): void; + Delete(callback: CbCallback): void; +} + +declare var ClearBlade: ClearBladeGlobal; \ No newline at end of file diff --git a/types/clearbladejs-server/tsconfig.json b/types/clearbladejs-server/tsconfig.json new file mode 100644 index 0000000000..a49f8d53d9 --- /dev/null +++ b/types/clearbladejs-server/tsconfig.json @@ -0,0 +1,32 @@ +{ + "compilerOptions": { + "target": "ES5", + "moduleResolution": "node", + "module": "none", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + ".", + "../", + "../../node_modules/" + ], + "types": ["node"], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "clearbladejs-server-tests.ts", + "global.d.ts" + ], + "exclude": [ + "**/clearbladejs-client/*", + "**/clearbladejs-node/*" + ] +} \ No newline at end of file diff --git a/types/clearbladejs-server/tslint.json b/types/clearbladejs-server/tslint.json new file mode 100644 index 0000000000..a4c53997aa --- /dev/null +++ b/types/clearbladejs-server/tslint.json @@ -0,0 +1,79 @@ +{ + "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 newline at end of file From dd43368fe0a4e6056aac0302a6097c7afc1cfab2 Mon Sep 17 00:00:00 2001 From: Jim Bouquet Date: Thu, 5 Apr 2018 17:47:17 -0500 Subject: [PATCH 2/5] Modified tsconfig.json files based on errors received from dtslint. Removed const in enum declarations based on errors received from tsLint --- types/clearbladejs-client/index.d.ts | 6 +++--- types/clearbladejs-client/tsconfig.json | 9 +++------ types/clearbladejs-node/index.d.ts | 12 ++++++------ types/clearbladejs-node/tsconfig.json | 18 ++++++------------ types/clearbladejs-server/index.d.ts | 12 ++++++------ types/clearbladejs-server/tsconfig.json | 11 +++-------- 6 files changed, 27 insertions(+), 41 deletions(-) diff --git a/types/clearbladejs-client/index.d.ts b/types/clearbladejs-client/index.d.ts index 3c7ebd40f1..dcc7048cb8 100644 --- a/types/clearbladejs-client/index.d.ts +++ b/types/clearbladejs-client/index.d.ts @@ -3,7 +3,7 @@ // Definitions by: Jim Bouquet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -// TypeScript Version: 2.1 +// TypeScript Version: 2.4 /// @@ -134,12 +134,12 @@ interface Collection { count(query: Query, callback: CbCallback): void; } -declare const enum QuerySortDirections { +declare enum QuerySortDirections { QUERY_SORT_ASCENDING = "ASC", QUERY_SORT_DESCENDING = "DESC" } -declare const enum QueryConditions { +declare enum QueryConditions { QUERY_EQUAL = "EQ", QUERY_NOTEQUAL = "NEQ", QUERY_GREATERTHAN = "GT", diff --git a/types/clearbladejs-client/tsconfig.json b/types/clearbladejs-client/tsconfig.json index b360802518..7821d7db9e 100644 --- a/types/clearbladejs-client/tsconfig.json +++ b/types/clearbladejs-client/tsconfig.json @@ -1,8 +1,7 @@ { "compilerOptions": { "target": "ES5", - "moduleResolution": "node", - "module": "none", + "module": "commonjs", "lib": [ "es6" ], @@ -12,11 +11,9 @@ "strictFunctionTypes": true, "baseUrl": "../", "typeRoots": [ - ".", - "../", - "../../node_modules/" + "../" ], - "types": ["node"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/clearbladejs-node/index.d.ts b/types/clearbladejs-node/index.d.ts index a80ecc21d5..63b12af7e6 100644 --- a/types/clearbladejs-node/index.d.ts +++ b/types/clearbladejs-node/index.d.ts @@ -1,3 +1,6 @@ +/// +/// + import { Response, RequestCallback } from "request/index"; import { MqttClient, PacketCallback } from "mqtt"; @@ -6,10 +9,7 @@ import { MqttClient, PacketCallback } from "mqtt"; // Definitions by: Jim Bouquet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -// TypeScript Version: 2.1 - -/// -/// +// TypeScript Version: 2.4 declare enum MessagingQOS { MESSAGING_QOS_AT_MOST_ONCE = 0, @@ -116,12 +116,12 @@ export interface Collection { remove(query: Query, callback: CbCallback): void; } -export declare const enum QuerySortDirections { +export declare enum QuerySortDirections { QUERY_SORT_ASCENDING = 'ASC', QUERY_SORT_DESCENDING = 'DESC' } -export declare const enum QueryConditions { +export declare enum QueryConditions { QUERY_EQUAL = 'EQ', QUERY_NOTEQUAL = 'NEQ', QUERY_GREATERTHAN = 'GT', diff --git a/types/clearbladejs-node/tsconfig.json b/types/clearbladejs-node/tsconfig.json index da91170d85..490278df1e 100644 --- a/types/clearbladejs-node/tsconfig.json +++ b/types/clearbladejs-node/tsconfig.json @@ -2,23 +2,17 @@ "compileOnSave": true, "compilerOptions": { "target": "ES5", - "module": "es6", - "moduleResolution": "Node", + "module": "commonjs", "lib": [ "es6" ], "noImplicitAny": true, - "noImplicitThis": false, - "noStrictGenericChecks": false, - "strictNullChecks": false, - "strictFunctionTypes": false, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - ".", - "../", - "../../node_modules/" - ], - "types": ["node"], + "typeRoots": ["../"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, diff --git a/types/clearbladejs-server/index.d.ts b/types/clearbladejs-server/index.d.ts index 7333b04cb9..178198ce05 100644 --- a/types/clearbladejs-server/index.d.ts +++ b/types/clearbladejs-server/index.d.ts @@ -1,11 +1,11 @@ +/// + // Type definitions for clearbladejs Server SDK v1.0.0 // Project: https://docs.clearblade.com/v/3/4-developer_reference/platformsdk/ClearBlade.js/ // Definitions by: Jim Bouquet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // -// TypeScript Version: 2.1 - -/// +// TypeScript Version: 2.4 interface BasicReq { readonly isLogging: boolean; @@ -140,12 +140,12 @@ interface Collection { count(query: Query, callback: CbCallback): void; } -declare const enum QuerySortDirections { +declare enum QuerySortDirections { QUERY_SORT_ASCENDING = 'ASC', QUERY_SORT_DESCENDING = 'DESC' } -declare const enum QueryConditions { +declare enum QueryConditions { QUERY_EQUAL = 'EQ', QUERY_NOTEQUAL = 'NEQ', QUERY_GREATERTHAN = 'GT', @@ -281,7 +281,7 @@ interface Device { create(newDevice: Object, callback: CbCallback): void; } -declare const enum TriggerModule { +declare enum TriggerModule { DEVICE = "Device", Data = "Data", MESSAGING = "Messaging", diff --git a/types/clearbladejs-server/tsconfig.json b/types/clearbladejs-server/tsconfig.json index a49f8d53d9..b549e1c685 100644 --- a/types/clearbladejs-server/tsconfig.json +++ b/types/clearbladejs-server/tsconfig.json @@ -1,8 +1,7 @@ { "compilerOptions": { "target": "ES5", - "moduleResolution": "node", - "module": "none", + "module": "commonjs", "lib": [ "es6" ], @@ -11,12 +10,8 @@ "strictNullChecks": true, "strictFunctionTypes": true, "baseUrl": "../", - "typeRoots": [ - ".", - "../", - "../../node_modules/" - ], - "types": ["node"], + "typeRoots": ["../"], + "types": [], "noEmit": true, "forceConsistentCasingInFileNames": true }, From f4788e7c6a9c875db621831030c2c5524dcee4f0 Mon Sep 17 00:00:00 2001 From: Jim Bouquet Date: Thu, 5 Apr 2018 18:34:12 -0500 Subject: [PATCH 3/5] Made changes to fix build issues --- types/clearbladejs-client/index.d.ts | 1 - types/clearbladejs-node/clearbladejs-node-tests.ts | 3 --- types/clearbladejs-node/index.d.ts | 13 ++++++------- types/clearbladejs-node/tsconfig.json | 3 +-- types/clearbladejs-server/index.d.ts | 5 ++--- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/types/clearbladejs-client/index.d.ts b/types/clearbladejs-client/index.d.ts index dcc7048cb8..44dd355213 100644 --- a/types/clearbladejs-client/index.d.ts +++ b/types/clearbladejs-client/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/ClearBlade/JavaScript-API // Definitions by: Jim Bouquet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// // TypeScript Version: 2.4 /// diff --git a/types/clearbladejs-node/clearbladejs-node-tests.ts b/types/clearbladejs-node/clearbladejs-node-tests.ts index b600332ca2..18cd509cc7 100644 --- a/types/clearbladejs-node/clearbladejs-node-tests.ts +++ b/types/clearbladejs-node/clearbladejs-node-tests.ts @@ -1,9 +1,6 @@ import { ClearBlade, Resp, QuerySortDirections, QueryConditions } from "."; // Sample code for clearbladejs Node SDK v1.0.0 used to test typescript definitions -// Project: https://github.com/ClearBlade/Node-SDK -// Definitions by: Jim Bouquet -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped const constants = require("./constants.json"); diff --git a/types/clearbladejs-node/index.d.ts b/types/clearbladejs-node/index.d.ts index 63b12af7e6..9efea47430 100644 --- a/types/clearbladejs-node/index.d.ts +++ b/types/clearbladejs-node/index.d.ts @@ -1,16 +1,15 @@ +// Type definitions for clearbladejs Node SDK v1.0.0 +// Project: https://github.com/ClearBlade/Node-SDK +// Definitions by: Jim Bouquet +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.4 + /// /// import { Response, RequestCallback } from "request/index"; import { MqttClient, PacketCallback } from "mqtt"; -// Type definitions for clearbladejs Node SDK v1.0.0 -// Project: https://github.com/ClearBlade/Node-SDK -// Definitions by: Jim Bouquet -// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// -// TypeScript Version: 2.4 - declare enum MessagingQOS { MESSAGING_QOS_AT_MOST_ONCE = 0, MESSAGING_QOS_AT_LEAST_ONCE = 1, diff --git a/types/clearbladejs-node/tsconfig.json b/types/clearbladejs-node/tsconfig.json index 490278df1e..67aea82d3f 100644 --- a/types/clearbladejs-node/tsconfig.json +++ b/types/clearbladejs-node/tsconfig.json @@ -18,8 +18,7 @@ }, "files": [ "index.d.ts", - "clearbladejs-node-tests.ts", - "../../node_modules/mqtt/types/index.d.ts" + "clearbladejs-node-tests.ts" ], "exclude": [ "**/clearbladejs-client/*", diff --git a/types/clearbladejs-server/index.d.ts b/types/clearbladejs-server/index.d.ts index 178198ce05..2c3a0845b4 100644 --- a/types/clearbladejs-server/index.d.ts +++ b/types/clearbladejs-server/index.d.ts @@ -1,12 +1,11 @@ -/// - // Type definitions for clearbladejs Server SDK v1.0.0 // Project: https://docs.clearblade.com/v/3/4-developer_reference/platformsdk/ClearBlade.js/ // Definitions by: Jim Bouquet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// // TypeScript Version: 2.4 +/// + interface BasicReq { readonly isLogging: boolean; readonly params: { From c5648fb940138f33a03f8c1ef67e877bb999280b Mon Sep 17 00:00:00 2001 From: Jim Bouquet Date: Fri, 6 Apr 2018 06:51:33 -0500 Subject: [PATCH 4/5] Removed references to mqtt library --- types/clearbladejs-node/index.d.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/types/clearbladejs-node/index.d.ts b/types/clearbladejs-node/index.d.ts index 9efea47430..bef502bb00 100644 --- a/types/clearbladejs-node/index.d.ts +++ b/types/clearbladejs-node/index.d.ts @@ -5,10 +5,9 @@ // TypeScript Version: 2.4 /// -/// import { Response, RequestCallback } from "request/index"; -import { MqttClient, PacketCallback } from "mqtt"; +//import {//PacketCallback } from "mqtt"; declare enum MessagingQOS { MESSAGING_QOS_AT_MOST_ONCE = 0, @@ -224,12 +223,12 @@ export interface Messaging { URI: string; systemKey: string; systemSecret: string; - client: MqttClient; + client: Object; getMessageHistory(topic: string, startTime: number, count: number, callback: CbCallback): void; publish(topic: string, payload: Object): void; subscribe(topic: string, options: MessagingSubscribeOptions, messageCallback: MessageCallback): void; - unsubscribe(topic: string, callback?: PacketCallback): void; + unsubscribe(topic: string, callback?: (error?: Error, packet?: Object) => any): void; } export interface CommonMessagingProperties { From bfaaf9272a60229befd27456d6ddde37ed8e80b5 Mon Sep 17 00:00:00 2001 From: Jim Bouquet Date: Fri, 6 Apr 2018 16:15:11 -0500 Subject: [PATCH 5/5] Modified tslint.json files to enable most rules. Cleaned up code to remove lint errors. --- .../clearbladejs-client-tests.ts | 72 +++++++-------- types/clearbladejs-client/global.d.ts | 2 +- types/clearbladejs-client/index.d.ts | 48 +++++----- types/clearbladejs-client/tslint.json | 74 +--------------- .../clearbladejs-node-tests.ts | 69 ++++++++------- types/clearbladejs-node/index.d.ts | 87 +++++++++---------- types/clearbladejs-node/tslint.json | 74 +--------------- .../clearbladejs-server-tests.ts | 72 +++++++-------- types/clearbladejs-server/global.d.ts | 2 +- types/clearbladejs-server/index.d.ts | 74 ++++++++-------- types/clearbladejs-server/tslint.json | 75 +--------------- 11 files changed, 211 insertions(+), 438 deletions(-) diff --git a/types/clearbladejs-client/clearbladejs-client-tests.ts b/types/clearbladejs-client/clearbladejs-client-tests.ts index 9aece4b19a..bce39bee2a 100644 --- a/types/clearbladejs-client/clearbladejs-client-tests.ts +++ b/types/clearbladejs-client/clearbladejs-client-tests.ts @@ -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 +// Definitions by: Jim Bouquet // 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); diff --git a/types/clearbladejs-client/global.d.ts b/types/clearbladejs-client/global.d.ts index 7f70ed08f7..d6e2e88a70 100644 --- a/types/clearbladejs-client/global.d.ts +++ b/types/clearbladejs-client/global.d.ts @@ -2,4 +2,4 @@ declare global { var ClearBlade: ClearBladeGlobal; } -export {}; \ No newline at end of file +export {}; diff --git a/types/clearbladejs-client/index.d.ts b/types/clearbladejs-client/index.d.ts index 44dd355213..4cb8c4744b 100644 --- a/types/clearbladejs-client/index.d.ts +++ b/types/clearbladejs-client/index.d.ts @@ -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 +// Definitions by: Jim Bouquet // 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; } diff --git a/types/clearbladejs-client/tslint.json b/types/clearbladejs-client/tslint.json index a4c53997aa..d538486d5e 100644 --- a/types/clearbladejs-client/tslint.json +++ b/types/clearbladejs-client/tslint.json @@ -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 } } \ No newline at end of file diff --git a/types/clearbladejs-node/clearbladejs-node-tests.ts b/types/clearbladejs-node/clearbladejs-node-tests.ts index 18cd509cc7..e9cb585d50 100644 --- a/types/clearbladejs-node/clearbladejs-node-tests.ts +++ b/types/clearbladejs-node/clearbladejs-node-tests.ts @@ -1,23 +1,26 @@ +// Testing type definitions for clearbladejs-node 1.0 +// Project: https://github.com/ClearBlade/Node-SDK +// Definitions by: Jim Bouquet +// 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"); } - - - diff --git a/types/clearbladejs-node/index.d.ts b/types/clearbladejs-node/index.d.ts index bef502bb00..192b1a97ee 100644 --- a/types/clearbladejs-node/index.d.ts +++ b/types/clearbladejs-node/index.d.ts @@ -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 +// Definitions by: Jim Bouquet // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 /// 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; diff --git a/types/clearbladejs-node/tslint.json b/types/clearbladejs-node/tslint.json index a4c53997aa..2e3f95d861 100644 --- a/types/clearbladejs-node/tslint.json +++ b/types/clearbladejs-node/tslint.json @@ -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 } } \ No newline at end of file diff --git a/types/clearbladejs-server/clearbladejs-server-tests.ts b/types/clearbladejs-server/clearbladejs-server-tests.ts index ea7c179df2..d240f181ea 100644 --- a/types/clearbladejs-server/clearbladejs-server-tests.ts +++ b/types/clearbladejs-server/clearbladejs-server-tests.ts @@ -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 +// Definitions by: Jim Bouquet // 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); diff --git a/types/clearbladejs-server/global.d.ts b/types/clearbladejs-server/global.d.ts index 7f70ed08f7..d6e2e88a70 100644 --- a/types/clearbladejs-server/global.d.ts +++ b/types/clearbladejs-server/global.d.ts @@ -2,4 +2,4 @@ declare global { var ClearBlade: ClearBladeGlobal; } -export {}; \ No newline at end of file +export {}; diff --git a/types/clearbladejs-server/index.d.ts b/types/clearbladejs-server/index.d.ts index 2c3a0845b4..fb3ef065ce 100644 --- a/types/clearbladejs-server/index.d.ts +++ b/types/clearbladejs-server/index.d.ts @@ -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 +// Definitions by: Jim Bouquet // 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; \ No newline at end of file +declare var ClearBlade: ClearBladeGlobal; diff --git a/types/clearbladejs-server/tslint.json b/types/clearbladejs-server/tslint.json index a4c53997aa..6a6f758e67 100644 --- a/types/clearbladejs-server/tslint.json +++ b/types/clearbladejs-server/tslint.json @@ -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 } } \ No newline at end of file