Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade dependencies and fix Readme.md #183

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
460 changes: 460 additions & 0 deletions .eslintrc.js

Large diffs are not rendered by default.

6,690 changes: 5,262 additions & 1,428 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 28 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,48 @@
"build:protos": "yarn build:protos:msgs && yarn build:protos:srvs",
"build": "tsc -p tsconfig.release.json",
"build:watch": "tsc -w -p tsconfig.release.json",
"lint": "tslint -t stylish --project tsconfig.json",
"lint:fix": "tslint --fix -t stylish --project tsconfig.json",
"lint": "eslint -c .eslintrc.js --ext .ts .",
"lint:fix": "eslint . --ext .ts --fix",
"pretest": "yarn lint",
"test": "jest --coverage --runInBand",
"test:watch": "jest --watch",
"coveralls": "cat ./coverage/lcov.info | coveralls"
},
"devDependencies": {
"@types/google-protobuf": "^3.15.6",
"@types/jest": "^29.4.0",
"@types/node": "^18.11.18",
"@types/google-protobuf": "^3.15.12",
"@types/jest": "^29.5.12",
"@types/node": "^20.14.4",
"@typescript-eslint/eslint-plugin": "^7.13.1",
"@typescript-eslint/parser": "^7.13.1",
"coveralls": "^3.1.1",
"grpc-tools": "^1.12.4",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-jest": "^28.6.0",
"eslint-plugin-jsdoc": "^48.2.12",
"eslint-plugin-jsx-a11y": "^6.8.0",
"eslint-plugin-no-null": "^1.0.2",
"eslint-plugin-prefer-arrow": "^1.2.3",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-security": "^3.0.1",
"eslint-plugin-unicorn": "^54.0.0",
"grpc_tools_node_protoc_ts": "^5.3.3",
"grpc-tools": "^1.12.4",
"install-peers": "^1.0.4",
"jest": "^29.4.1",
"jest": "^29.7.0",
"jest-teamcity": "^1.11.0",
"rimraf": "^4.1.2",
"ts-jest": "^29.0.5",
"rimraf": "^5.0.7",
"ts-jest": "^29.1.5",
"ts-protoc-gen": "^0.15.0",
"tslint": "^6.1.3",
"tslint-microsoft-contrib": "^6.2.0",
"typescript": "^4.9.5"
"typescript": "^5.4.5"
},
"dependencies": {
"@grpc/grpc-js": "1.8.8",
"@types/url-parse": "^1.4.8",
"@grpc/grpc-js": "^1.10.9",
"@types/url-parse": "^1.4.11",
"@typescript-eslint/eslint-plugin-tslint": "^6.21.0",
"dgraph-js": "^21.3.1",
"eslint-plugin-lodash": "^7.4.0",
"google-protobuf": "^3.21.2",
"grpc": "^1.24.11",
"is-base64": "^1.1.0",
"url-parse": "^1.5.10"
}
Expand Down
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export class DgraphClient {
*/
public debug(msg: string): void {
if (this.debugMode) {
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.log(msg);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/clientStub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ export class DgraphClientStub {
options?: object,
) {
if (addr === undefined) {
// tslint:disable-next-line no-parameter-reassignment
// eslint-disable-next-line no-param-reassign
addr = "localhost:9080";
}
if (credentials === undefined) {
// tslint:disable-next-line no-parameter-reassignment
// eslint-disable-next-line no-param-reassign
credentials = grpc.credentials.createInsecure();
}

Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,6 @@ export class Mutation extends messages.Mutation {
super.setSetNquads(value);
return;
}
// tslint:disable-next-line no-unsafe-any
if (isBase64(value)) {
super.setSetNquads(value);
return;
Expand Down Expand Up @@ -289,7 +288,6 @@ export class Mutation extends messages.Mutation {
super.setDelNquads(value);
return;
}
// tslint:disable-next-line no-unsafe-any
if (isBase64(value)) {
super.setDelNquads(value);
return;
Expand Down
4 changes: 2 additions & 2 deletions src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export function errorCode(err: any): { valid: boolean; code: number } { // tslin
if (
err === undefined ||
typeof err !== "object" ||
!err.hasOwnProperty("code") || // tslint:disable-line no-unsafe-any
typeof err.code !== "number" // tslint:disable-line no-unsafe-any
!err.hasOwnProperty("code") || // eslint-disable-line @typescript-eslint/tslint/config
typeof err.code !== "number" // eslint-disable-line @typescript-eslint/tslint/config
) {
return {
valid: false,
Expand Down
4 changes: 2 additions & 2 deletions tests/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import * as dgraph from "../src";

import { createClient, createClientStub } from "./helper";

// tslint:disable no-console
/* eslint-disable no-console */
describe("client", () => {
describe("constructor", () => {
it("should throw no clients error if no client stubs are passed", () => {
expect.assertions(1);

try {
// tslint:disable-next-line no-unused-expression
// eslint-disable-next-line no-unused-expressions
new dgraph.DgraphClient();
} catch (e) {
expect(e).toBe(dgraph.ERR_NO_CLIENTS);
Expand Down
2 changes: 1 addition & 1 deletion tests/clientStub.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as dgraph from "../src";

import { SERVER_ADDR, SERVER_CREDENTIALS, setup } from "./helper";

function validateVersionObject(version: dgraph.Version) {
function validateVersionObject(version: dgraph.Version){
const tag = version.getTag();
expect(typeof tag).toEqual("string");
expect(tag).toBeDefined();
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/acctUpsert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function tryUpsert(account: Account): Promise<void> {
const res = await txn.query(q);
const resJson: {
find: { uid: string }[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config
expect(resJson.find.length).toBeLessThanOrEqual(1);

let mu: dgraph.Mutation;
Expand Down Expand Up @@ -83,7 +83,7 @@ let retryCount = 0;
function conditionalLog(): void {
const now = new Date().getTime();
if (now - lastStatus > 1000 && !cancelled) {
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.log(`Success: ${successCount}, Retries: ${retryCount}, Total Time: ${now - startStatus} ms`);
lastStatus = now;
}
Expand Down Expand Up @@ -141,7 +141,7 @@ async function checkIntegrity(): Promise<void> {

const data: {
all: Account[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config

const accountSet: { [key: string]: boolean } = {};
for (const account of data.all) {
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/acl.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { fail } from "assert";
import { exec } from "child_process";
import { promisify } from "util";

Expand Down Expand Up @@ -28,7 +29,7 @@ const MUTATE_PERMISSION_DENIED = new Error(`7 PERMISSION_DENIED:\
const ALTER_PERMISSION_DENIED = new Error(`7 PERMISSION_DENIED:\
unauthorized to alter following predicates: ${PRED} \n`);

async function cmd(command: string) {
async function cmd(command: string){
try {
await execute(command);
} catch (err) {
Expand Down
7 changes: 3 additions & 4 deletions tests/integration/bank.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,9 @@ async function runTotal(): Promise<void> {
bal: sum(val(b))
}
}`);
// tslint:disable-next-line no-unsafe-any
expect(res.getJson().total[0].bal).toBe(uids.length * initialBalance);

// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.log(`Runs: ${runs}, Aborts: ${aborts}, Total Time: ${new Date().getTime() - startStatus} ms`);
}

Expand All @@ -80,7 +79,7 @@ async function runTotalInLoop(): Promise<void> {
async function runTxn(): Promise<void> {
let fromUid: string;
let toUid: string;
// tslint:disable-next-line no-constant-condition
// eslint-disable-next-line no-constant-condition
while (true) {
fromUid = uids[Math.floor(Math.random() * uids.length)];
toUid = uids[Math.floor(Math.random() * uids.length)];
Expand All @@ -96,7 +95,7 @@ async function runTxn(): Promise<void> {
const accountsWithUid: {
uid: string;
bal: number;
}[] = res.getJson().both; // tslint:disable-line no-unsafe-any
}[] = res.getJson().both; // eslint-disable-line @typescript-eslint/tslint/config
expect(accountsWithUid).toHaveLength(2);

accountsWithUid[0].bal += 5;
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/conditionalUpsert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ async function checkUpsertIntegrity(expectedObject: Profile): Promise<void> {

const data: {
all: Profile[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config

const profileSet: { [key: string]: boolean } = {};
for (const profile of data.all) {
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/delete.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ describe("delete", () => {
await performNquadDeletion(nquads2, uid.toString());

const res = await client.newTxn().query(q);
// tslint:disable-next-line no-unsafe-any
expect(res.getJson().all).toHaveLength(0);
});

Expand Down Expand Up @@ -161,7 +160,6 @@ describe("delete", () => {
await client.newTxn().mutate(mu);

const res = await client.newTxn().query(query);
// tslint:disable-next-line no-unsafe-any
expect(res.getJson().all[0].friends).toBeFalsy();
});

Expand Down
13 changes: 6 additions & 7 deletions tests/integration/upsert.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ let retryCount = 0;
function conditionalLog(): void {
const now = new Date().getTime();
if (now - lastStatus > 1000 && !cancelled) {
// tslint:disable-next-line no-console
// eslint-disable-next-line no-console
console.log(`Success: ${successCount}, Retries: ${retryCount}, Total Time: ${now - startStatus} ms`);
lastStatus = now;
}
Expand Down Expand Up @@ -107,7 +107,7 @@ async function checkIntegrity(): Promise<void> {

const data: {
all: Account[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config

const accountSet: { [key: string]: boolean } = {};
for (const account of data.all) {
Expand Down Expand Up @@ -245,9 +245,8 @@ async function performJsonUpsert(profile: Profile): Promise<void> {
req.setMutationsList([mu]);
req.setCommitNow(true);

let uid: string;
const response = await client.newTxn().doRequest(req);
uid = response.getUidsMap().get(blankNodeLabel);
const uid = response.getUidsMap().get(blankNodeLabel);
expect(uid).not.toEqual("");
}

Expand All @@ -264,7 +263,7 @@ async function checkMutationIntegrity(ourProfiles: Profile[]): Promise<void> {

const data: {
all: Profile[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config

const profileSet: { [key: string]: boolean } = {};
for (const profile of data.all) {
Expand Down Expand Up @@ -292,7 +291,7 @@ async function checkUpsertIntegrity(): Promise<void> {

const data: {
all: Profile[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config

const profileSet: { [key: string]: boolean } = {};
for (const profile of data.all) {
Expand Down Expand Up @@ -368,7 +367,7 @@ async function doInsertUpsertWithVars(): Promise<void> {
const res = await client.newTxn().queryWithVars(query2, vars2);
const data: {
all: Profile[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config
const receivedObject: Profile = data.all[0];
expect(receivedObject).toEqual(updatedProfile);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/txn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ describe("txn", () => {
);
let resJson: {
me: { name: string }[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config
expect(resJson.me).toHaveLength(1);
expect(resJson.me[0].name).toEqual("Alice");

Expand All @@ -43,7 +43,7 @@ describe("txn", () => {
$b: true, // non-string properties are ignored
},
);
resJson = res.getJson(); // tslint:disable-line no-unsafe-any
resJson = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config
expect(resJson.me).toHaveLength(1);
expect(resJson.me[0].name).toEqual("Alice");
});
Expand Down Expand Up @@ -88,7 +88,7 @@ describe("txn", () => {
);
const resJson: {
me: { name: string }[];
} = res.getJson(); // tslint:disable-line no-unsafe-any
} = res.getJson(); // eslint-disable-line @typescript-eslint/tslint/config
expect(resJson.me).toHaveLength(0);
});

Expand Down
4 changes: 2 additions & 2 deletions tests/util.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function fnAddThisVal1(
a: number,
cb: (err?: Error, res?: number) => void,
): void {
// tslint:disable-next-line no-invalid-this
// eslint-disable-next-line no-invalid-this
cb(undefined, (<{ val: number }>this).val + a);
}

Expand All @@ -23,7 +23,7 @@ function fnAddThisVal3(
c: number,
cb: (err?: Error, res?: number) => void,
): void {
// tslint:disable-next-line no-invalid-this
// eslint-disable-next-line no-invalid-this
cb(undefined, (<{ val: number }>this).val + a + b + c);
}

Expand Down
Loading