fix(core): update

This commit is contained in:
Philipp Kunz 2020-06-21 16:06:11 +00:00
parent 94b313b835
commit c08c708704
10 changed files with 219 additions and 28 deletions

36
package-lock.json generated
View File

@ -1134,6 +1134,16 @@
"symbol-tree": "^3.2.4"
}
},
"@pushrocks/qenv": {
"version": "4.0.10",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fqenv/-/qenv-4.0.10.tgz",
"integrity": "sha512-bQknJrGa9zXDTmohi2W0fi/gZ5H36J1138WsRgdR2u/9D/0gwjBasL0kqBokH9sddcLSYe/H9itGFxbT7i7MCg==",
"dev": true,
"requires": {
"@pushrocks/smartfile": "^7.0.12",
"@pushrocks/smartlog": "^2.0.26"
}
},
"@pushrocks/smartbrowser": {
"version": "1.0.17",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartbrowser/-/smartbrowser-1.0.17.tgz",
@ -1371,8 +1381,7 @@
"@pushrocks/smartpromise": {
"version": "3.0.6",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartpromise/-/smartpromise-3.0.6.tgz",
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg==",
"dev": true
"integrity": "sha512-vlQlBGNVIjfClgnsfgQBU6GIKcskYSFzEcKLt18ngPzPEcjKklXcxaqzLXpnoxR+KBh30QPE8255ncYHXuPPOg=="
},
"@pushrocks/smartpuppeteer": {
"version": "1.0.15",
@ -1390,7 +1399,6 @@
"version": "1.1.47",
"resolved": "https://verdaccio.lossless.one/@pushrocks%2fsmartrequest/-/smartrequest-1.1.47.tgz",
"integrity": "sha512-0AuqtAI14VeWeXl2WpJbgCybVlG03rOjdGchAqy5k5lg9ACLhN3Z4kmoLgpBysWO/L2SjlAKB489SRyV3acykg==",
"dev": true,
"requires": {
"@pushrocks/smartpromise": "^3.0.5",
"@types/form-data": "^2.5.0",
@ -1672,7 +1680,6 @@
"version": "2.5.0",
"resolved": "https://verdaccio.lossless.one/@types%2fform-data/-/form-data-2.5.0.tgz",
"integrity": "sha512-23/wYiuckYYtFpL+4RPWiWmRQH2BjFuqCUi2+N3amB1a1Drv+i/byTrGvlLwRVLFNAZbwpbQ7JvTK+VCAPMbcg==",
"dev": true,
"requires": {
"form-data": "*"
}
@ -1855,7 +1862,6 @@
"version": "4.1.3",
"resolved": "https://verdaccio.lossless.one/agentkeepalive/-/agentkeepalive-4.1.3.tgz",
"integrity": "sha512-wn8fw19xKZwdGPO47jivonaHRTd+nGOMP1z11sgGeQzDy2xd5FG0R67dIMcKHDE2cJ5y+YXV30XVGUBPRSY7Hg==",
"dev": true,
"requires": {
"debug": "^4.1.0",
"depd": "^1.1.2",
@ -1928,8 +1934,7 @@
"asynckit": {
"version": "0.4.0",
"resolved": "https://verdaccio.lossless.one/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=",
"dev": true
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"atob": {
"version": "2.1.2",
@ -2209,7 +2214,6 @@
"version": "1.0.8",
"resolved": "https://verdaccio.lossless.one/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"requires": {
"delayed-stream": "~1.0.0"
}
@ -2366,7 +2370,6 @@
"version": "4.1.1",
"resolved": "https://verdaccio.lossless.one/debug/-/debug-4.1.1.tgz",
"integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==",
"dev": true,
"requires": {
"ms": "^2.1.1"
}
@ -2449,14 +2452,12 @@
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://verdaccio.lossless.one/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=",
"dev": true
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"depd": {
"version": "1.1.2",
"resolved": "https://verdaccio.lossless.one/depd/-/depd-1.1.2.tgz",
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=",
"dev": true
"integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak="
},
"destroy": {
"version": "1.0.4",
@ -2763,7 +2764,6 @@
"version": "2.5.1",
"resolved": "https://verdaccio.lossless.one/form-data/-/form-data-2.5.1.tgz",
"integrity": "sha512-m21N3WOmEEURgk6B9GLOE4RuWOFf28Lhh9qGYeNlGq4VDXUlJy2th2slBNU8Gp8EzloYZOibZJ7t5ecIrFSjVA==",
"dev": true,
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
@ -3013,7 +3013,6 @@
"version": "1.2.1",
"resolved": "https://verdaccio.lossless.one/humanize-ms/-/humanize-ms-1.2.1.tgz",
"integrity": "sha1-xG4xWaKT9riW2ikxbYtv6Lt5u+0=",
"dev": true,
"requires": {
"ms": "^2.0.0"
}
@ -3401,14 +3400,12 @@
"mime-db": {
"version": "1.44.0",
"resolved": "https://verdaccio.lossless.one/mime-db/-/mime-db-1.44.0.tgz",
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg==",
"dev": true
"integrity": "sha512-/NOTfLrsPBVeH7YtFPgsVWveuL+4SjjYxaQ1xtM1KMFj7HdxlBlxeyNLzhyJVx7r4rZGJAZ/6lkKCitSc/Nmpg=="
},
"mime-types": {
"version": "2.1.27",
"resolved": "https://verdaccio.lossless.one/mime-types/-/mime-types-2.1.27.tgz",
"integrity": "sha512-JIhqnCasI9yD+SsmkquHBxTSEuZdQX5BuQnS2Vc7puQQQ+8yiP5AY5uWhpdv4YL4VM5c6iliiYWPgJ/nJQLp7w==",
"dev": true,
"requires": {
"mime-db": "1.44.0"
}
@ -3458,8 +3455,7 @@
"ms": {
"version": "2.1.2",
"resolved": "https://verdaccio.lossless.one/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
},
"mute-stream": {
"version": "0.0.8",

View File

@ -15,12 +15,15 @@
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/qenv": "^4.0.10",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.7",
"tslint": "^5.11.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {},
"dependencies": {
"@pushrocks/smartrequest": "^1.1.47"
},
"files": [
"ts/**/*",
"ts_web/**/*",

2
qenv.yml Normal file
View File

@ -0,0 +1,2 @@
required:
- ORA_APITOKEN

View File

@ -1,8 +1,27 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as qenv from '@pushrocks/qenv';
const testQenv = new qenv.Qenv('./', './.nogit');
import * as ora from '../ts/index';
tap.test('first test', async () => {
console.log(ora.standardExport);
let oraInstance: ora.Ora;
tap.test('should create a valid instance for Ora', async () => {
oraInstance = new ora.Ora(testQenv.getEnvVarOnDemand('ORA_APITOKEN'));
});
tap.test('should get all organizations', async () => {
const organizations = await oraInstance.getOrganizations();
expect(organizations.length).to.equal(2);
});
tap.test('should get all projects of an organization', async () => {
const organizations = await oraInstance.getOrganizations();
const losslessOrganization = organizations.find(orgArg => {
return orgArg.name.startsWith('Lossless');
});
const projectsInLosslessOrg = await losslessOrganization.getAllProjects();
console.log(projectsInLosslessOrg);
});
tap.start();

View File

@ -1,3 +1,2 @@
import * as plugins from './ora.plugins';
export let standardExport = 'Hi there! :) This is an exported string';
export * from './ora.classes.ora';
export * from './ora.classes.organization';

5
ts/ora.classes.list.ts Normal file
View File

@ -0,0 +1,5 @@
import * as plugins from './ora.plugins';
export class OraList {
}

33
ts/ora.classes.ora.ts Normal file
View File

@ -0,0 +1,33 @@
import * as plugins from './ora.plugins';
import { OraOrganization } from './ora.classes.organization';
export class Ora {
public apiBase: string = 'https://api.ora.pm';
private apiToken: string;
constructor(apiTokenArg: string) {
this.apiToken = apiTokenArg;
}
public async getOrganizations () {
return await OraOrganization.getAllOrganizations(this);
}
/**
* make a request
* @param routeArg
* @param methodArg
* @param payloadArg
*/
public async request (routeArg: string, methodArg: string, payloadArg?: string) {
const response = await plugins.smartrequest.request(this.apiBase + routeArg, {
method: methodArg,
requestBody: payloadArg,
headers: {
accept: "application/json",
authorization: `Bearer ${this.apiToken}`
}
});
return response.body;
}
}

View File

@ -0,0 +1,56 @@
import * as plugins from './ora.plugins';
import { Ora } from './ora.classes.ora';
import { OraProject } from './ora.classes.project';
export interface IOraOrganization {
created_at: string;
description: string;
id: number;
member_type: number;
name: string;
org_picture: string;
org_type: number;
owner_id: number;
premium_plan: null;
quantity: number;
updated_at: string;
web: string;
}
export class OraOrganization implements IOraOrganization {
public created_at: string;
public description: string;
public id: number;
public member_type: number;
public name: string;
public org_picture: string;
public org_type: number;
public owner_id: number;
public premium_plan: null;
public quantity: number;
public updated_at: string;
public web: string;
public static async getAllOrganizations(oraRef: Ora): Promise<OraOrganization[]> {
const response = await oraRef.request('/organizations', 'GET');
const organizations: OraOrganization[] = [];
for (const orgData of response.data) {
organizations.push(new OraOrganization(oraRef, orgData));
}
return organizations;
}
// ========
// INSTANCE
// ========
public oraRef: Ora;
constructor(oraRefArg: Ora, creationObjectArg: IOraOrganization) {
this.oraRef = oraRefArg;
Object.assign(this, creationObjectArg);
}
public async getAllProjects(): Promise<OraProject[]> {
return OraProject.getAllProjectsForOrganization(this);
}
}

74
ts/ora.classes.project.ts Normal file
View File

@ -0,0 +1,74 @@
import * as plugins from './ora.plugins';
import { Ora } from './ora.classes.ora';
import { OraOrganization } from './ora.classes.organization';
export interface IOraProject {
archived: boolean;
comment_all: number;
commits_visibility: number;
created_at: string;
default_view: boolean;
description: string;
id: number;
invite_all: boolean;
item_name: 'task';
items_name: 'tasks';
organization_id: number;
owner: number;
picture: string;
prefix: string;
project_color: string;
project_type: number;
seen: boolean;
starred: number;
tasks: number;
title: string;
updated_at: string;
view_title: 'Backlog';
web: string;
}
export class OraProject implements IOraProject {
public archived: boolean;
public comment_all: number;
public commits_visibility: number;
public created_at: string;
public default_view: boolean;
public description: string;
public id: number;
public invite_all: boolean;
public item_name: 'task';
public items_name: 'tasks';
public organization_id: number;
public owner: number;
public picture: string;
public prefix: string;
public project_color: string;
public project_type: number;
public seen: boolean;
public starred: number;
public tasks: number;
public title: string;
public updated_at: string;
public view_title: 'Backlog';
public web: string;
public oraOrganizationRef: OraOrganization;
constructor(oraOrganiazionRefArg: OraOrganization, creationObjectArg: IOraProject) {
this.oraOrganizationRef = oraOrganiazionRefArg;
Object.assign(this, creationObjectArg);
}
public static async getAllProjectsForOrganization(oraOrganizationRef: OraOrganization) {
const response = await oraOrganizationRef.oraRef.request('/projects', 'GET');
const projects: OraProject[] = [];
for (const projectData of response.data) {
const oraProject = new OraProject(oraOrganizationRef, projectData);
if (oraProject.organization_id === oraOrganizationRef.id) {
projects.push(oraProject);
}
}
return projects;
}
}

View File

@ -1,2 +1,6 @@
const removeme = {};
export { removeme };
// pushrocks scope
import * as smartrequest from '@pushrocks/smartrequest';
export {
smartrequest
};