Skip to content

Update packages and domo client #21

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ dist/
node_modules/
coverage/
*.log
/.idea/
6 changes: 6 additions & 0 deletions .mocharc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
spec: 'test/**/*.spec.ts'
require: 'ts-node/register'
reporter: 'list'
watch-extensions: 'ts'
recursive: true
color: true
7 changes: 0 additions & 7 deletions mocha.opts

This file was deleted.

3,780 changes: 984 additions & 2,796 deletions package-lock.json

Large diffs are not rendered by default.

42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"name": "domo-sdk",
"version": "2.0.1",
"version": "2.1.0",
"description": "Javascript Domo SDK",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"lint": "tslint src/**/*.ts --project ./tsconfig.json --type-check",
"test": "mocha --opts mocha.opts",
"tdd": "mocha --opts mocha.opts --watch",
"test": "mocha --config .mocharc.yaml",
"tdd": "mocha --config .mocharc.yaml --watch",
"build": "rm -rf ./dist && tsc",
"coverage": "NODE_ENV=test istanbul cover _mocha -- --opts .mocharc",
"upload": "npm run test && npm version && npm run build && npm publish",
Expand All @@ -24,30 +24,30 @@
],
"license": "MIT",
"dependencies": {
"debug": "^2.6.6",
"debug": "^4.3.1",
"growl": "^1.10.5",
"request": "^2.88.0",
"request-promise-native": "^1.0.7"
},
"devDependencies": {
"@types/chai": "^4.0.1",
"@types/debug": "0.0.29",
"@types/mocha": "^2.2.41",
"@types/nock": "^8.2.1",
"@types/node": "^8.0.8",
"@types/request": "0.0.45",
"@types/request-promise-native": "^1.0.5",
"@types/sinon": "^2.3.2",
"chai": "^3.5.0",
"@types/chai": "^4.2.15",
"@types/debug": "4.1.5",
"@types/mocha": "^8.2.1",
"@types/nock": "^10.0.3",
"@types/node": "^14.14.33",
"@types/request": "2.48.5",
"@types/request-promise-native": "^1.0.17",
"@types/sinon": "^9.0.11",
"chai": "^4.3.3",
"istanbul": "^0.4.5",
"mocha": "^3.3.0",
"nock": "^9.0.13",
"sinon": "^2.3.6",
"ts-node": "^3.2.0",
"tslint": "^5.5.0",
"tslint-config-airbnb": "^5.2.1",
"tsutils": "^2.5.1",
"typescript": "^2.4.1"
"mocha": "^8.3.1",
"nock": "^13.0.11",
"sinon": "^9.2.4",
"ts-node": "^9.1.1",
"tslint": "^5.20.1",
"tslint-config-airbnb": "^5.11.2",
"tsutils": "^3.21.0",
"typescript": "^4.2.3"
},
"engines": {
"node": ">=6.4.0"
Expand Down
4 changes: 2 additions & 2 deletions src/datasets/DatasetClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ export default class DatasetClient {
return this.transport.delete(req, this.type);
}

importData(id: string, csv: string): Promise<void> {
importData(id: string, csv: string, append: boolean = false): Promise<void> {
const req: Request = {
url: `${this.urlBase}/${id}/data`,
url: `${this.urlBase}/${id}/data?updateMethod=${append ? 'APPEND' : 'REPLACE'}`,
headers: { 'Content-Type': 'text/csv' },
body: csv,
};
Expand Down
16 changes: 14 additions & 2 deletions src/datasets/models.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
export interface Column {
name: string;
type: string;
type: 'STRING' | 'DECIMAL' | 'LONG' | 'DOUBLE' | 'DATE' | 'DATETIME';
}

export interface Schema {
columns: Column[];
}

export interface DataSet {
id?: string;
name?: string;
schema?: Schema;
description?: string;
owner?: {
id?: string;
name?: string;
};
columns?: number;
createdAt?: string;
updatedAt?: string;
dataCurrentAt?: string;
schema?: Schema;
pdpEnabled?: boolean;
policies?: Policy[];
rows?: number;
}

export interface Policy {
Expand Down
23 changes: 21 additions & 2 deletions test/DatasetClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ describe('(Client): Dataset', () => {
});
});

it('should import csv data', (done) => {
it('should import and replce csv data', (done) => {
const spy = sinon.stub(client.transport, 'put').returns(Promise.resolve());
expect(client.importData).to.exist;
expect(client.importData).to.an.instanceOf(Function);
Expand All @@ -130,7 +130,26 @@ describe('(Client): Dataset', () => {

promise.then(() => {
expect(spy.calledOnce).to.be.true;
expect(spy.firstCall.args[0]).to.have.property('url', `${client.urlBase}/1/data`);
expect(spy.firstCall.args[0]).to.have.property('url', `${client.urlBase}/1/data?updateMethod=REPLACE`);
expect(spy.firstCall.args[0]).to.have.property('body', csv);
expect(spy.firstCall.args[0].headers).to.have.property('Content-Type', 'text/csv');
expect(spy.firstCall.args[1]).to.equal(client.type);
done();
});
});

it('should import and append csv data', (done) => {
const spy = sinon.stub(client.transport, 'put').returns(Promise.resolve());
expect(client.importData).to.exist;
expect(client.importData).to.an.instanceOf(Function);

const csv = 'example,csv,here';
const promise = client.importData(1, csv, true);
expect(promise).to.be.an.instanceOf(Promise);

promise.then(() => {
expect(spy.calledOnce).to.be.true;
expect(spy.firstCall.args[0]).to.have.property('url', `${client.urlBase}/1/data?updateMethod=APPEND`);
expect(spy.firstCall.args[0]).to.have.property('body', csv);
expect(spy.firstCall.args[0].headers).to.have.property('Content-Type', 'text/csv');
expect(spy.firstCall.args[1]).to.equal(client.type);
Expand Down