@pliancy/timelyapp-sdk 6.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +53 -0
- package/index.d.ts +2 -0
- package/index.js +8 -0
- package/index.js.map +1 -0
- package/lib/accounts/accounts.d.ts +8 -0
- package/lib/accounts/accounts.js +18 -0
- package/lib/accounts/accounts.js.map +1 -0
- package/lib/clients/clients.d.ts +13 -0
- package/lib/clients/clients.js +37 -0
- package/lib/clients/clients.js.map +1 -0
- package/lib/events/events.d.ts +14 -0
- package/lib/events/events.js +62 -0
- package/lib/events/events.js.map +1 -0
- package/lib/http/http.d.ts +2 -0
- package/lib/http/http.js +8 -0
- package/lib/http/http.js.map +1 -0
- package/lib/http/paginated-request.d.ts +4 -0
- package/lib/http/paginated-request.js +22 -0
- package/lib/http/paginated-request.js.map +1 -0
- package/lib/labels/labels.d.ts +11 -0
- package/lib/labels/labels.js +31 -0
- package/lib/labels/labels.js.map +1 -0
- package/lib/projects/projects.d.ts +14 -0
- package/lib/projects/projects.js +43 -0
- package/lib/projects/projects.js.map +1 -0
- package/lib/reports/reports.d.ts +13 -0
- package/lib/reports/reports.js +16 -0
- package/lib/reports/reports.js.map +1 -0
- package/lib/teams/teams.d.ts +10 -0
- package/lib/teams/teams.js +23 -0
- package/lib/teams/teams.js.map +1 -0
- package/lib/timely-app.d.ts +24 -0
- package/lib/timely-app.js +41 -0
- package/lib/timely-app.js.map +1 -0
- package/lib/timely-app.spec.d.ts +1 -0
- package/lib/timely-app.spec.js +32 -0
- package/lib/timely-app.spec.js.map +1 -0
- package/lib/types.d.ts +387 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/users/users.d.ts +19 -0
- package/lib/users/users.js +61 -0
- package/lib/users/users.js.map +1 -0
- package/package.json +62 -0
package/README.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# TimelyApp Node SDK
|
|
2
|
+
|
|
3
|
+
[](https://dev.timelyapp.com/)
|
|
4
|
+
[](https://github.com/pliancy/timelyapp-sdk)
|
|
5
|
+
[](https://www.npmjs.com/package/timelyapp)
|
|
6
|
+
[](https://npmjs.com/timelyapp)
|
|
7
|
+
[](https://david-dm.org/pliancy/timelyapp-sdk)
|
|
8
|
+
[](https://npmjs.com/timelyapp)
|
|
9
|
+
|
|
10
|
+
A typed node module which provides a wrapper and several convienence functions for the TimelyApp.com API
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```shell
|
|
15
|
+
npm install timelyapp
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Examples
|
|
19
|
+
```typescript
|
|
20
|
+
import { TimelyApp } from 'timelyapp'
|
|
21
|
+
import dotenv from 'dotenv'
|
|
22
|
+
dotenv.config()
|
|
23
|
+
|
|
24
|
+
const timely = new TimelyApp({
|
|
25
|
+
accountId: process.env.TIMELY_ACCOUNT as string,
|
|
26
|
+
token: process.env.TIMELY_TOKEN as string,
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
;(async () => {
|
|
30
|
+
const output = await timely.getClients()
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.dir(output, { depth: null })
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
})().catch(console.log)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Create the client
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { TimelyApp } from 'timelyapp'
|
|
41
|
+
|
|
42
|
+
const timely = new TimelyApp({
|
|
43
|
+
clientId: 'xxxxxxxxxxxxx',
|
|
44
|
+
clientSecret: 'xxxxxxxxxxxxx',
|
|
45
|
+
accountId: '123456',
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Get all users
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
const users = await timely.users.getAll()
|
|
53
|
+
```
|
package/index.d.ts
ADDED
package/index.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimelyApp = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("./lib/types"), exports);
|
|
6
|
+
var timely_app_1 = require("./lib/timely-app");
|
|
7
|
+
Object.defineProperty(exports, "TimelyApp", { enumerable: true, get: function () { return timely_app_1.TimelyApp; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,sDAA2B;AAC3B,+CAA4C;AAAnC,uGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TimelyAccount } from '../types';
|
|
3
|
+
export declare class Accounts {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: AxiosInstance);
|
|
6
|
+
getAll(): Promise<TimelyAccount[]>;
|
|
7
|
+
getById(accountId: number): Promise<TimelyAccount>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Accounts = void 0;
|
|
4
|
+
class Accounts {
|
|
5
|
+
constructor(http) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
}
|
|
8
|
+
async getAll() {
|
|
9
|
+
const { data } = await this.http.get('/accounts');
|
|
10
|
+
return data;
|
|
11
|
+
}
|
|
12
|
+
async getById(accountId) {
|
|
13
|
+
const { data } = await this.http.get(`/accounts/${accountId}`);
|
|
14
|
+
return data;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.Accounts = Accounts;
|
|
18
|
+
//# sourceMappingURL=accounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/lib/accounts/accounts.ts"],"names":[],"mappings":";;;AAGA,MAAa,QAAQ;IACjB,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD,KAAK,CAAC,MAAM;QACR,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,WAAW,CAAC,CAAA;QACjD,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,SAAiB;QAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,aAAa,SAAS,EAAE,CAAC,CAAA;QAC9D,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAZD,4BAYC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AddTimelyClient, TimelyAppConfig, TimelyClient } from '../types';
|
|
3
|
+
export declare class Clients {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getAll(): Promise<TimelyClient[]>;
|
|
8
|
+
getById(clientId: number): Promise<TimelyClient>;
|
|
9
|
+
getByName(clientName: string): Promise<TimelyClient | undefined>;
|
|
10
|
+
getByExternalId(customerId: string): Promise<TimelyClient | undefined>;
|
|
11
|
+
add(client: AddTimelyClient): Promise<TimelyClient>;
|
|
12
|
+
update(clientId: number, client: Partial<TimelyClient>): Promise<TimelyClient>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Clients = void 0;
|
|
4
|
+
class Clients {
|
|
5
|
+
constructor(http, config) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async getAll() {
|
|
10
|
+
const { data } = await this.http.get(`/${this.config.accountId}/clients?show=all`);
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
async getById(clientId) {
|
|
14
|
+
const { data } = await this.http.get(`/${this.config.accountId}/clients/${clientId}`);
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
async getByName(clientName) {
|
|
18
|
+
const clients = await this.getAll();
|
|
19
|
+
return clients.find((c) => c.name === clientName);
|
|
20
|
+
}
|
|
21
|
+
async getByExternalId(customerId) {
|
|
22
|
+
const clients = await this.getAll();
|
|
23
|
+
return clients.find((e) => e.external_id === customerId);
|
|
24
|
+
}
|
|
25
|
+
async add(client) {
|
|
26
|
+
const { data } = await this.http.post(`/${this.config.accountId}/clients`, { client });
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
async update(clientId, client) {
|
|
30
|
+
const { data } = await this.http.put(`/${this.config.accountId}/clients/${clientId}`, {
|
|
31
|
+
client,
|
|
32
|
+
});
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.Clients = Clients;
|
|
37
|
+
//# sourceMappingURL=clients.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clients.js","sourceRoot":"","sources":["../../../src/lib/clients/clients.ts"],"names":[],"mappings":";;;AAGA,MAAa,OAAO;IAChB,YACqB,IAAmB,EACnB,MAAuB;QADvB,SAAI,GAAJ,IAAI,CAAe;QACnB,WAAM,GAAN,MAAM,CAAiB;IACzC,CAAC;IAEJ,KAAK,CAAC,MAAM;QACR,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,mBAAmB,CAAC,CAAA;QAClF,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAgB;QAC1B,MAAM,EAAE,IAAI,EAAE,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';
|
|
3
|
+
export declare class Events {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getAll(start?: DateString, end?: DateString): Promise<TimelyEvent[]>;
|
|
8
|
+
getByProjectId(projectId: number, start: DateString, end: DateString): Promise<TimelyEvent[]>;
|
|
9
|
+
bulkUpdate(updateArray: TimelyEventBulkUpdate[]): Promise<TimelyBulkUpdateEventsReturn[]>;
|
|
10
|
+
bulkDelete(eventIds: number[]): Promise<TimelyBulkUpdateEventsReturn[]>;
|
|
11
|
+
update(eventId: number, event: Partial<TimelyEvent>): Promise<TimelyEvent>;
|
|
12
|
+
getById(eventId: number): Promise<TimelyEvent>;
|
|
13
|
+
ensureISOFormat(date: DateString): string;
|
|
14
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Events = void 0;
|
|
4
|
+
const paginated_request_1 = require("../http/paginated-request");
|
|
5
|
+
class Events {
|
|
6
|
+
constructor(http, config) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
async getAll(start, end) {
|
|
11
|
+
const [startDate, endDate] = [start, end].map((s) => (s ? this.ensureISOFormat(s) : null));
|
|
12
|
+
const params = {};
|
|
13
|
+
if (startDate && endDate) {
|
|
14
|
+
params.since = startDate;
|
|
15
|
+
params.upto = endDate;
|
|
16
|
+
}
|
|
17
|
+
const data = await (0, paginated_request_1.paginatedRequest)(this.http, `/${this.config.accountId}/events`, params);
|
|
18
|
+
return data;
|
|
19
|
+
}
|
|
20
|
+
async getByProjectId(projectId, start, end) {
|
|
21
|
+
const [startDate, endDate] = [start, end].map((s) => this.ensureISOFormat(s));
|
|
22
|
+
const params = {};
|
|
23
|
+
if (startDate) {
|
|
24
|
+
params.since = startDate;
|
|
25
|
+
}
|
|
26
|
+
if (endDate) {
|
|
27
|
+
params.upto = endDate;
|
|
28
|
+
}
|
|
29
|
+
const data = await (0, paginated_request_1.paginatedRequest)(this.http, `/${this.config.accountId}/projects/${projectId}/events`, params);
|
|
30
|
+
return data;
|
|
31
|
+
}
|
|
32
|
+
async bulkUpdate(updateArray) {
|
|
33
|
+
const { data } = await this.http.post(`/${this.config.accountId}/bulk/events`, {
|
|
34
|
+
update: updateArray,
|
|
35
|
+
});
|
|
36
|
+
return data;
|
|
37
|
+
}
|
|
38
|
+
async bulkDelete(eventIds) {
|
|
39
|
+
const { data } = await this.http.post(`/${this.config.accountId}/bulk/events`, {
|
|
40
|
+
delete: eventIds,
|
|
41
|
+
});
|
|
42
|
+
return data;
|
|
43
|
+
}
|
|
44
|
+
async update(eventId, event) {
|
|
45
|
+
const { data } = await this.http.put(`/${this.config.accountId}/events/${eventId}`, event);
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
async getById(eventId) {
|
|
49
|
+
const { data } = await this.http.get(`/${this.config.accountId}/events/${eventId}`);
|
|
50
|
+
return data;
|
|
51
|
+
}
|
|
52
|
+
ensureISOFormat(date) {
|
|
53
|
+
try {
|
|
54
|
+
return new Date(date).toISOString().slice(0, 10);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
throw new Error(`Unable to parse "${date}" as YYYY-MM-DD`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
exports.Events = Events;
|
|
62
|
+
//# sourceMappingURL=events.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/lib/events/events.ts"],"names":[],"mappings":";;;AACA,iEAA4D;AAS5D,MAAa,MAAM;IACf,YACqB,IAAmB,EACnB,MAAuB;QADvB,SAAI,GAAJ,IAAI,CAAe;QACnB,WAAM,GAAN,MAAM,CAAiB;IACzC,CAAC;IAEJ,KAAK,CAAC,MAAM,CAAC,KAAkB,EAAE,GAAg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/lib/http/http.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createHttpClient = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
6
|
+
const createHttpClient = (config) => axios_1.default.create(config);
|
|
7
|
+
exports.createHttpClient = createHttpClient;
|
|
8
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../../src/lib/http/http.ts"],"names":[],"mappings":";;;;AAAA,0DAAiD;AAE1C,MAAM,gBAAgB,GAAG,CAAC,MAA0B,EAAE,EAAE,CAAC,eAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;AAAvE,QAAA,gBAAgB,oBAAuD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.paginatedRequest = void 0;
|
|
4
|
+
const paginatedRequest = async (httpAgent, route, filter, per_page = 1000) => {
|
|
5
|
+
const params = {
|
|
6
|
+
per_page,
|
|
7
|
+
page: 1,
|
|
8
|
+
};
|
|
9
|
+
if (filter)
|
|
10
|
+
Object.assign(params, { ...filter });
|
|
11
|
+
const finalData = [];
|
|
12
|
+
let res = [];
|
|
13
|
+
do {
|
|
14
|
+
const { data } = await httpAgent.get(route, { params });
|
|
15
|
+
finalData.push(...data);
|
|
16
|
+
res = data;
|
|
17
|
+
params.page++;
|
|
18
|
+
} while (res.length === per_page);
|
|
19
|
+
return finalData;
|
|
20
|
+
};
|
|
21
|
+
exports.paginatedRequest = paginatedRequest;
|
|
22
|
+
//# sourceMappingURL=paginated-request.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paginated-request.js","sourceRoot":"","sources":["../../../src/lib/http/paginated-request.ts"],"names":[],"mappings":";;;AAEO,MAAM,gBAAgB,GAAG,KAAK,EACjC,SAAwB,EACxB,KAAa,EACb,MAAiC,EACjC,QAAQ,GAAG,IAAI,EACD,EAAE;IAChB,MAAM,MAAM,GAAG;QACX,QAAQ;QACR,IAAI,EAAE,CAAC;KACV,CAAA;IAED,IAAI,MAAM;QAAE,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,GAAG,MAAM,EAAE,CAAC,CAAA;IAEhD,MAAM,SAAS,GAAG,EAAE,CAAA;IACpB,IAAI,GAAG,GAAU,EAAE,CAAA;IAEnB,GAAG,CAAC;QACA,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;QACvD,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;QACvB,GAAG,GAAG,IAAI,CAAA;QACV,MAAM,CAAC,IAAI,EAAE,CAAA;IAEjB,CAAC,QAAQ,GAAG,CAAC,MAAM,KAAK,QAAQ,EAAC;IAEjC,OAAO,SAAS,CAAA;AACpB,CAAC,CAAA;AAzBY,QAAA,gBAAgB,oBAyB5B"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AddTimelyLabel, TimelyAppConfig, TimelyLabel } from '../types';
|
|
3
|
+
export declare class Labels {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getAll(): Promise<TimelyLabel[]>;
|
|
8
|
+
getById(labelId: number): Promise<TimelyLabel>;
|
|
9
|
+
update(labelId: number, label: Partial<TimelyLabel>): Promise<TimelyLabel>;
|
|
10
|
+
add(label: AddTimelyLabel): Promise<TimelyLabel>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Labels = void 0;
|
|
4
|
+
class Labels {
|
|
5
|
+
constructor(http, config) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async getAll() {
|
|
10
|
+
const { data } = await this.http.get(`/${this.config.accountId}/labels`);
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
async getById(labelId) {
|
|
14
|
+
const { data } = await this.http.get(`/${this.config.accountId}/labels/${labelId}`);
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
async update(labelId, label) {
|
|
18
|
+
const { data } = await this.http.put(`/${this.config.accountId}/labels/${labelId}`, {
|
|
19
|
+
label,
|
|
20
|
+
});
|
|
21
|
+
return data;
|
|
22
|
+
}
|
|
23
|
+
async add(label) {
|
|
24
|
+
const { data } = await this.http.post(`/${this.config.accountId}/labels`, {
|
|
25
|
+
label,
|
|
26
|
+
});
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
exports.Labels = Labels;
|
|
31
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../../src/lib/labels/labels.ts"],"names":[],"mappings":";;;AAGA,MAAa,MAAM;IACf,YACqB,IAAmB,EACnB,MAAuB;QADvB,SAAI,GAAJ,IAAI,CAAe;QACnB,WAAM,GAAN,MAAM,CAAiB;IACzC,CAAC;IAEJ,KAAK,CAAC,MAAM;QACR,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,SAAS,CAAC,CAAA;QACxE,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAe;QACzB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,WAAW,OAAO,EAAE,CAAC,CAAA;QACnF,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,KAA2B;QACrD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,WAAW,OAAO,EAAE,EAAE;YAChF,KAAK;SACR,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,KAAqB;QAC3B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,SAAS,EAAE;YACtE,KAAK;SACR,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AA7BD,wBA6BC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AddTimelyProject, TimelyAppConfig, TimelyProject } from '../types';
|
|
3
|
+
export declare class Projects {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getAll(filter?: 'active' | 'all' | 'mine' | 'archived'): Promise<TimelyProject[]>;
|
|
8
|
+
getArchived(): Promise<TimelyProject[]>;
|
|
9
|
+
getById(projectId: number): Promise<TimelyProject>;
|
|
10
|
+
getByExternalId(externalId: string): Promise<TimelyProject[]>;
|
|
11
|
+
add(project: AddTimelyProject): Promise<TimelyProject>;
|
|
12
|
+
remove(projectId: number): Promise<{}>;
|
|
13
|
+
update(projectId: number, project: Partial<TimelyProject>): Promise<TimelyProject>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Projects = void 0;
|
|
4
|
+
class Projects {
|
|
5
|
+
constructor(http, config) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async getAll(filter) {
|
|
10
|
+
const { data } = await this.http.get(`/${this.config.accountId}/projects?filter=${filter !== null && filter !== void 0 ? filter : 'active'} `);
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
async getArchived() {
|
|
14
|
+
const { data } = await this.http.get(`/${this.config.accountId}/projects?filter=archived`);
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
async getById(projectId) {
|
|
18
|
+
const { data } = await this.http.get(`/${this.config.accountId}/projects/${projectId}`);
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
async getByExternalId(externalId) {
|
|
22
|
+
const projects = await this.getAll();
|
|
23
|
+
if (!(projects && projects.length))
|
|
24
|
+
return [];
|
|
25
|
+
return projects.filter((e) => (e === null || e === void 0 ? void 0 : e.external_id) === externalId);
|
|
26
|
+
}
|
|
27
|
+
async add(project) {
|
|
28
|
+
const { data } = await this.http.post(`/${this.config.accountId}/projects`, { project });
|
|
29
|
+
return data;
|
|
30
|
+
}
|
|
31
|
+
async remove(projectId) {
|
|
32
|
+
const { data } = await this.http.delete(`/${this.config.accountId}/projects/${projectId}`);
|
|
33
|
+
return data;
|
|
34
|
+
}
|
|
35
|
+
async update(projectId, project) {
|
|
36
|
+
const { data } = await this.http.put(`/${this.config.accountId}/projects/${projectId}`, {
|
|
37
|
+
project,
|
|
38
|
+
});
|
|
39
|
+
return data;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.Projects = Projects;
|
|
43
|
+
//# sourceMappingURL=projects.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../../../src/lib/projects/projects.ts"],"names":[],"mappings":";;;AAGA,MAAa,QAAQ;IACjB,YACqB,I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AAM,CAAC,SAAS,WAAW,EAAE,EAAE,OAAO,EAAE,CAAC,CAAA;QACxF,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB;QAC1B,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,aAAa,SAAS,EAAE,CAAC,CAAA;QAC1F,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,SAAiB,EAAE,OAA+B;QAC3D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,aAAa,SAAS,EAAE,EAAE;YACpF,OAAO;SACV,CAAC,CAAA;QACF,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AA7CD,4BA6CC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TimelyAppConfig } from '../types';
|
|
3
|
+
export declare class Reports {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getByExternalId(externalId: string, filter: {
|
|
8
|
+
group_by?: string[];
|
|
9
|
+
project_ids?: number[];
|
|
10
|
+
since?: string;
|
|
11
|
+
until?: string;
|
|
12
|
+
}): Promise<any[]>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Reports = void 0;
|
|
4
|
+
const paginated_request_1 = require("../http/paginated-request");
|
|
5
|
+
class Reports {
|
|
6
|
+
constructor(http, config) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
this.config = config;
|
|
9
|
+
}
|
|
10
|
+
async getByExternalId(externalId, filter) {
|
|
11
|
+
const data = await (0, paginated_request_1.paginatedRequest)(this.http, `/${this.config.accountId}/reports/filter`, filter);
|
|
12
|
+
return data;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.Reports = Reports;
|
|
16
|
+
//# sourceMappingURL=reports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reports.js","sourceRoot":"","sources":["../../../src/lib/reports/reports.ts"],"names":[],"mappings":";;;AACA,iEAA4D;AAG5D,MAAa,OAAO;IAChB,YACqB,IAAmB,EACnB,MAAuB;QADvB,SAAI,GAAJ,IAAI,CAAe;QACnB,WAAM,GAAN,MAAM,CAAiB;IACzC,CAAC;IAEJ,KAAK,CAAC,eAAe,CACjB,UAAkB,EAClB,MAKC;QAED,MAAM,IAAI,GAAG,MAAM,IAAA,oCAAgB,EAC/B,IAAI,CAAC,IAAI,EACT,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,iBAAiB,EAC1C,MAAM,CACT,CAAA;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAtBD,0BAsBC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TimelyAppConfig, TimelyTeam, TimelyUser } from '../types';
|
|
3
|
+
export declare class Teams {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getAll(): Promise<TimelyUser[]>;
|
|
8
|
+
getByName(name: string): Promise<TimelyTeam>;
|
|
9
|
+
update(teamId: number, team: Partial<TimelyTeam>): Promise<TimelyTeam>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Teams = void 0;
|
|
4
|
+
class Teams {
|
|
5
|
+
constructor(http, config) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async getAll() {
|
|
10
|
+
const { data } = await this.http.get(`/${this.config.accountId}/teams`);
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
async getByName(name) {
|
|
14
|
+
const { data: response } = await this.http.get(`/${this.config.accountId}/teams`);
|
|
15
|
+
return response.find((u) => u.name === name);
|
|
16
|
+
}
|
|
17
|
+
async update(teamId, team) {
|
|
18
|
+
const { data } = await this.http.put(`/${this.config.accountId}/teams/${teamId}`, { team });
|
|
19
|
+
return data;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.Teams = Teams;
|
|
23
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../../../src/lib/teams/teams.ts"],"names":[],"mappings":";;;AAGA,MAAa,KAAK;IACd,YACqB,IAAmB,EACnB,MAAuB;QADvB,SAAI,GAAJ,IAAI,CAAe;QACnB,WAAM,GAAN,MAAM,CAAiB;IACzC,CAAC;IAEJ,KAAK,CAAC,MAAM;QACR,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,QAAQ,CAAC,CAAA;QACvE,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAY;QACxB,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAA2B,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAClE,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,QAAQ,CACpC,CAAA;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAe,CAAA;IAC9D,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAc,EAAE,IAAyB;QAClD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,UAAU,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;QAC3F,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAtBD,sBAsBC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { TimelyAppConfig } from './types';
|
|
3
|
+
import { Accounts } from './accounts/accounts';
|
|
4
|
+
import { Clients } from './clients/clients';
|
|
5
|
+
import { Events } from './events/events';
|
|
6
|
+
import { Labels } from './labels/labels';
|
|
7
|
+
import { Projects } from './projects/projects';
|
|
8
|
+
import { Users } from './users/users';
|
|
9
|
+
import { Teams } from './teams/teams';
|
|
10
|
+
import { Reports } from './reports/reports';
|
|
11
|
+
export declare class TimelyApp {
|
|
12
|
+
private readonly config;
|
|
13
|
+
readonly accounts: Accounts;
|
|
14
|
+
readonly clients: Clients;
|
|
15
|
+
readonly events: Events;
|
|
16
|
+
readonly http: AxiosInstance;
|
|
17
|
+
readonly labels: Labels;
|
|
18
|
+
readonly projects: Projects;
|
|
19
|
+
readonly teams: Teams;
|
|
20
|
+
readonly users: Users;
|
|
21
|
+
readonly reports: Reports;
|
|
22
|
+
constructor(config: TimelyAppConfig);
|
|
23
|
+
private validateConfig;
|
|
24
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TimelyApp = void 0;
|
|
4
|
+
const accounts_1 = require("./accounts/accounts");
|
|
5
|
+
const clients_1 = require("./clients/clients");
|
|
6
|
+
const events_1 = require("./events/events");
|
|
7
|
+
const labels_1 = require("./labels/labels");
|
|
8
|
+
const projects_1 = require("./projects/projects");
|
|
9
|
+
const users_1 = require("./users/users");
|
|
10
|
+
const http_1 = require("./http/http");
|
|
11
|
+
const teams_1 = require("./teams/teams");
|
|
12
|
+
const reports_1 = require("./reports/reports");
|
|
13
|
+
class TimelyApp {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
var _a;
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.validateConfig();
|
|
18
|
+
const httpConfig = {
|
|
19
|
+
baseURL: 'https://api.timelyapp.com/1.1',
|
|
20
|
+
timeout: (_a = this.config.timeout) !== null && _a !== void 0 ? _a : 20000,
|
|
21
|
+
headers: {
|
|
22
|
+
authorization: `Bearer ${this.config.token}`,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
this.http = (0, http_1.createHttpClient)(httpConfig);
|
|
26
|
+
this.accounts = new accounts_1.Accounts(this.http);
|
|
27
|
+
this.clients = new clients_1.Clients(this.http, this.config);
|
|
28
|
+
this.events = new events_1.Events(this.http, this.config);
|
|
29
|
+
this.labels = new labels_1.Labels(this.http, this.config);
|
|
30
|
+
this.projects = new projects_1.Projects(this.http, this.config);
|
|
31
|
+
this.teams = new teams_1.Teams(this.http, this.config);
|
|
32
|
+
this.users = new users_1.Users(this.http, this.config);
|
|
33
|
+
this.reports = new reports_1.Reports(this.http, this.config);
|
|
34
|
+
}
|
|
35
|
+
validateConfig() {
|
|
36
|
+
if (!this.config.accountId || !this.config.token)
|
|
37
|
+
throw new Error('Missing required inputs for TimelyApp constructor');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.TimelyApp = TimelyApp;
|
|
41
|
+
//# sourceMappingURL=timely-app.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timely-app.js","sourceRoot":"","sources":["../../src/lib/timely-app.ts"],"names":[],"mappings":";;;AAEA,kDAA8C;AAC9C,+CAA2C;AAC3C,4CAAwC;AACxC,4CAAwC;AACxC,kDAA8C;AAC9C,yCAAqC;AACrC,sCAA8C;AAC9C,yCAAqC;AACrC,+CAA2C;AAE3C,MAAa,SAAS;IAmBlB,YAA6B,MAAuB;;QAAvB,WAAM,GAAN,MAAM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M,CAAC,KAAK;YAC5C,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;IAC5E,CAAC;CACJ;AA5CD,8BA4CC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const timely_app_1 = require("./timely-app");
|
|
4
|
+
const labels_1 = require("./labels/labels");
|
|
5
|
+
const events_1 = require("./events/events");
|
|
6
|
+
const clients_1 = require("./clients/clients");
|
|
7
|
+
const accounts_1 = require("./accounts/accounts");
|
|
8
|
+
const projects_1 = require("./projects/projects");
|
|
9
|
+
describe('TimelyApp', () => {
|
|
10
|
+
it('fails to create given a bad config', () => {
|
|
11
|
+
try {
|
|
12
|
+
new timely_app_1.TimelyApp({});
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
expect(e.message).toBe('Missing required inputs for TimelyApp constructor');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
it('creates component instances', () => {
|
|
19
|
+
const t = new timely_app_1.TimelyApp({
|
|
20
|
+
accountId: 'accountId',
|
|
21
|
+
timeout: 20000,
|
|
22
|
+
token: 'token',
|
|
23
|
+
});
|
|
24
|
+
expect(t.http).toBeDefined();
|
|
25
|
+
expect(t.labels).toBeInstanceOf(labels_1.Labels);
|
|
26
|
+
expect(t.events).toBeInstanceOf(events_1.Events);
|
|
27
|
+
expect(t.clients).toBeInstanceOf(clients_1.Clients);
|
|
28
|
+
expect(t.accounts).toBeInstanceOf(accounts_1.Accounts);
|
|
29
|
+
expect(t.projects).toBeInstanceOf(projects_1.Projects);
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=timely-app.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timely-app.spec.js","sourceRoot":"","sources":["../../src/lib/timely-app.spec.ts"],"names":[],"mappings":";;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ig {
|
|
3
|
+
token: string;
|
|
4
|
+
accountId: string;
|
|
5
|
+
timeout?: number;
|
|
6
|
+
}
|
|
7
|
+
export interface TimelyAccount {
|
|
8
|
+
id: number;
|
|
9
|
+
name: string;
|
|
10
|
+
color: string;
|
|
11
|
+
currency: {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
iso_code: string;
|
|
15
|
+
symbol: string;
|
|
16
|
+
symbol_first: boolean;
|
|
17
|
+
};
|
|
18
|
+
logo: {
|
|
19
|
+
large_retina: string;
|
|
20
|
+
medium_retina: string;
|
|
21
|
+
small_retina: string;
|
|
22
|
+
brand_logo: boolean;
|
|
23
|
+
};
|
|
24
|
+
from: string;
|
|
25
|
+
max_users: number;
|
|
26
|
+
seats: number;
|
|
27
|
+
max_projects: number;
|
|
28
|
+
plan_id: number;
|
|
29
|
+
plan_name: string;
|
|
30
|
+
next_charge: string;
|
|
31
|
+
start_of_week: number;
|
|
32
|
+
created_at: number;
|
|
33
|
+
payment_mode: string;
|
|
34
|
+
paid: boolean;
|
|
35
|
+
company_size: string;
|
|
36
|
+
plan_code: string;
|
|
37
|
+
plan_custom: boolean;
|
|
38
|
+
appstore_transaction_id: number;
|
|
39
|
+
owner_id: number;
|
|
40
|
+
weekly_user_capacity: number;
|
|
41
|
+
default_hour_rate: number;
|
|
42
|
+
support_email: string;
|
|
43
|
+
estimated_company_size: string;
|
|
44
|
+
industry: string;
|
|
45
|
+
num_users: number;
|
|
46
|
+
num_projects: number;
|
|
47
|
+
active_projects_count: number;
|
|
48
|
+
total_projects_count: number;
|
|
49
|
+
capacity: {
|
|
50
|
+
hours: number;
|
|
51
|
+
minutes: number;
|
|
52
|
+
seconds: number;
|
|
53
|
+
formatted: string;
|
|
54
|
+
total_hours: number;
|
|
55
|
+
total_seconds: number;
|
|
56
|
+
total_minutes: number;
|
|
57
|
+
};
|
|
58
|
+
status: string;
|
|
59
|
+
beta: boolean;
|
|
60
|
+
expired: boolean;
|
|
61
|
+
trial: boolean;
|
|
62
|
+
days_to_end_trial: number;
|
|
63
|
+
features: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
days: number;
|
|
66
|
+
}>;
|
|
67
|
+
}
|
|
68
|
+
export interface TimelyClient {
|
|
69
|
+
id: number;
|
|
70
|
+
name: string;
|
|
71
|
+
active: boolean;
|
|
72
|
+
external_id: string;
|
|
73
|
+
updated_at: string;
|
|
74
|
+
}
|
|
75
|
+
export interface TimelyTeam {
|
|
76
|
+
id: number;
|
|
77
|
+
name: string;
|
|
78
|
+
users: {
|
|
79
|
+
user_id: number;
|
|
80
|
+
lead?: boolean;
|
|
81
|
+
}[];
|
|
82
|
+
}
|
|
83
|
+
export interface TimelyUser {
|
|
84
|
+
id: number;
|
|
85
|
+
email: string;
|
|
86
|
+
name: string;
|
|
87
|
+
active: boolean;
|
|
88
|
+
day_view_onboarded: boolean;
|
|
89
|
+
memory_onboarded: boolean;
|
|
90
|
+
created_at: number;
|
|
91
|
+
updated_at: number;
|
|
92
|
+
last_received_memories_date: boolean;
|
|
93
|
+
sign_in_count: boolean;
|
|
94
|
+
external_id: string;
|
|
95
|
+
time_zone: string;
|
|
96
|
+
avatar: {
|
|
97
|
+
large_retina: string;
|
|
98
|
+
large: string;
|
|
99
|
+
medium_retina: string;
|
|
100
|
+
medium: string;
|
|
101
|
+
small_retina: string;
|
|
102
|
+
small: string;
|
|
103
|
+
};
|
|
104
|
+
type: string;
|
|
105
|
+
weekly_capacity: number;
|
|
106
|
+
user_level: string;
|
|
107
|
+
admin: boolean;
|
|
108
|
+
hide_hourly_rate: boolean;
|
|
109
|
+
deleted: boolean;
|
|
110
|
+
default_hour_rate: number;
|
|
111
|
+
internal_hour_rate?: number;
|
|
112
|
+
role_id: number;
|
|
113
|
+
role: {
|
|
114
|
+
id: number;
|
|
115
|
+
name: string;
|
|
116
|
+
};
|
|
117
|
+
projects?: {
|
|
118
|
+
project_id: number;
|
|
119
|
+
hour_rate?: number;
|
|
120
|
+
}[];
|
|
121
|
+
}
|
|
122
|
+
export interface TimelyLabel {
|
|
123
|
+
id: number;
|
|
124
|
+
name: string;
|
|
125
|
+
sequence: number;
|
|
126
|
+
parent_id: number;
|
|
127
|
+
emoji: string;
|
|
128
|
+
active: boolean;
|
|
129
|
+
children: TimelyLabel[];
|
|
130
|
+
}
|
|
131
|
+
export interface TimelyProject {
|
|
132
|
+
id: number;
|
|
133
|
+
active: boolean;
|
|
134
|
+
account_id: number;
|
|
135
|
+
name: string;
|
|
136
|
+
color: string;
|
|
137
|
+
rate_type: string;
|
|
138
|
+
billable: boolean;
|
|
139
|
+
updated_at?: number;
|
|
140
|
+
external_id: string;
|
|
141
|
+
budget_scope: any;
|
|
142
|
+
client: TimelyClient;
|
|
143
|
+
required_notes: boolean;
|
|
144
|
+
required_labels: boolean;
|
|
145
|
+
budget_expired_on?: any;
|
|
146
|
+
has_recurrence: boolean;
|
|
147
|
+
enable_labels: 'all' | 'none' | 'custom';
|
|
148
|
+
budget: number;
|
|
149
|
+
budget_type: string;
|
|
150
|
+
hour_rate: number;
|
|
151
|
+
hour_rate_in_cents: number;
|
|
152
|
+
budget_progress: number;
|
|
153
|
+
budget_percent: number;
|
|
154
|
+
users: TimelyProjectUser[];
|
|
155
|
+
labels: TimelyProjectLabel[];
|
|
156
|
+
label_ids: number[];
|
|
157
|
+
required_label_ids: number[];
|
|
158
|
+
cost: TimelyProjectCost;
|
|
159
|
+
estimated_cost: TimelyProjectCost;
|
|
160
|
+
duration: TimelyProjectDuration;
|
|
161
|
+
estimated_duration: TimelyProjectDuration;
|
|
162
|
+
billed_cost: TimelyProjectCost;
|
|
163
|
+
billed_duration: TimelyProjectDuration;
|
|
164
|
+
unbilled_cost: TimelyProjectCost;
|
|
165
|
+
unbilled_duration: TimelyProjectDuration;
|
|
166
|
+
}
|
|
167
|
+
export interface TimelyProjectDuration {
|
|
168
|
+
hours: number;
|
|
169
|
+
minutes: number;
|
|
170
|
+
seconds: number;
|
|
171
|
+
formatted: string;
|
|
172
|
+
total_hours: number;
|
|
173
|
+
total_seconds: number;
|
|
174
|
+
total_minutes: number;
|
|
175
|
+
}
|
|
176
|
+
export interface TimelyProjectCost {
|
|
177
|
+
fractional: number;
|
|
178
|
+
formatted: string;
|
|
179
|
+
amount: number;
|
|
180
|
+
}
|
|
181
|
+
export interface TimelyProjectUser {
|
|
182
|
+
user_id: number;
|
|
183
|
+
hour_rate: number;
|
|
184
|
+
hour_rate_in_cents: number;
|
|
185
|
+
updated_at?: string;
|
|
186
|
+
created_at?: string;
|
|
187
|
+
deleted: boolean;
|
|
188
|
+
}
|
|
189
|
+
export interface TimelyProjectClient {
|
|
190
|
+
id: number;
|
|
191
|
+
name: string;
|
|
192
|
+
active: boolean;
|
|
193
|
+
external_id: string;
|
|
194
|
+
updated_at?: string;
|
|
195
|
+
}
|
|
196
|
+
export interface TimelyProjectLabel {
|
|
197
|
+
project_id: number;
|
|
198
|
+
label_id: number;
|
|
199
|
+
budget: number;
|
|
200
|
+
required: Boolean;
|
|
201
|
+
updated_at?: Date | string;
|
|
202
|
+
}
|
|
203
|
+
export interface AddTimelyProject {
|
|
204
|
+
name: string;
|
|
205
|
+
color: string;
|
|
206
|
+
client_id: number;
|
|
207
|
+
rate_type: 'user' | 'project';
|
|
208
|
+
active?: boolean;
|
|
209
|
+
currency_code?: string;
|
|
210
|
+
budget_type?: string;
|
|
211
|
+
users?: Array<{
|
|
212
|
+
user_id: number;
|
|
213
|
+
hour_rate?: number;
|
|
214
|
+
}>;
|
|
215
|
+
hour_rate?: number;
|
|
216
|
+
budget?: number;
|
|
217
|
+
billable?: boolean;
|
|
218
|
+
external_id?: string;
|
|
219
|
+
send_invite?: boolean;
|
|
220
|
+
required_notes?: boolean;
|
|
221
|
+
budget_recurrence?: {
|
|
222
|
+
recur: string;
|
|
223
|
+
start_date: Date | string;
|
|
224
|
+
end_date: Date | string;
|
|
225
|
+
recur_until: Date | string;
|
|
226
|
+
};
|
|
227
|
+
labels?: [Array<{
|
|
228
|
+
label_id: number;
|
|
229
|
+
required: boolean;
|
|
230
|
+
}>];
|
|
231
|
+
enable_labels?: 'all' | 'none' | 'custom';
|
|
232
|
+
}
|
|
233
|
+
export interface TimelyRole {
|
|
234
|
+
id: number;
|
|
235
|
+
name: string;
|
|
236
|
+
display_name: string;
|
|
237
|
+
description: string;
|
|
238
|
+
scopes: [
|
|
239
|
+
{
|
|
240
|
+
name: string;
|
|
241
|
+
display_name: string;
|
|
242
|
+
description: string;
|
|
243
|
+
default: string;
|
|
244
|
+
options: any[];
|
|
245
|
+
}
|
|
246
|
+
];
|
|
247
|
+
default: boolean;
|
|
248
|
+
}
|
|
249
|
+
export interface TimelyUserCapacity {
|
|
250
|
+
user_id: number;
|
|
251
|
+
capacities: TimelyCapacity[];
|
|
252
|
+
}
|
|
253
|
+
export interface TimelyCapacity {
|
|
254
|
+
id?: number;
|
|
255
|
+
weekly_capacity: number;
|
|
256
|
+
daily_capacity: number;
|
|
257
|
+
weekdays: string;
|
|
258
|
+
total_working_days?: number;
|
|
259
|
+
weekly_working_days?: number;
|
|
260
|
+
current: boolean;
|
|
261
|
+
start_date?: string;
|
|
262
|
+
end_date?: string;
|
|
263
|
+
}
|
|
264
|
+
export interface TimelyPermission {
|
|
265
|
+
resource: string;
|
|
266
|
+
permissions: Array<'create' | 'read' | 'update' | 'delete'>;
|
|
267
|
+
}
|
|
268
|
+
export interface TimelyEvent {
|
|
269
|
+
id: number;
|
|
270
|
+
uid: string;
|
|
271
|
+
user: {
|
|
272
|
+
id: number;
|
|
273
|
+
email: string;
|
|
274
|
+
name: string;
|
|
275
|
+
avatar: object;
|
|
276
|
+
updated_at: string;
|
|
277
|
+
};
|
|
278
|
+
project: {
|
|
279
|
+
id: number;
|
|
280
|
+
active: boolean;
|
|
281
|
+
account_id: number;
|
|
282
|
+
name: string;
|
|
283
|
+
color: string;
|
|
284
|
+
rate_type: string;
|
|
285
|
+
billable: boolean;
|
|
286
|
+
updated_at: number;
|
|
287
|
+
external_id: string;
|
|
288
|
+
budget_scope: any;
|
|
289
|
+
client: {
|
|
290
|
+
id: number;
|
|
291
|
+
name: string;
|
|
292
|
+
active: boolean;
|
|
293
|
+
external_id: any;
|
|
294
|
+
updated_at: string;
|
|
295
|
+
};
|
|
296
|
+
required_notes: boolean;
|
|
297
|
+
required_labels: boolean;
|
|
298
|
+
budget_expired_on: string;
|
|
299
|
+
has_recurrence: boolean;
|
|
300
|
+
enable_labels: string;
|
|
301
|
+
budget: number;
|
|
302
|
+
budget_type: string;
|
|
303
|
+
hour_rate: number;
|
|
304
|
+
hour_rate_in_cents: number;
|
|
305
|
+
budget_progress: number;
|
|
306
|
+
budget_percent: number;
|
|
307
|
+
invoice_by_budget: boolean;
|
|
308
|
+
labels: TimelyLabel[];
|
|
309
|
+
label_ids: [];
|
|
310
|
+
required_label_ids: [];
|
|
311
|
+
};
|
|
312
|
+
duration: {
|
|
313
|
+
hours: number;
|
|
314
|
+
minutes: number;
|
|
315
|
+
seconds: number;
|
|
316
|
+
formatted: string;
|
|
317
|
+
total_hours: number;
|
|
318
|
+
total_seconds: number;
|
|
319
|
+
total_minutes: number;
|
|
320
|
+
};
|
|
321
|
+
estimated_duration: {
|
|
322
|
+
hours: number;
|
|
323
|
+
minutes: number;
|
|
324
|
+
seconds: number;
|
|
325
|
+
formatted: string;
|
|
326
|
+
total_hours: number;
|
|
327
|
+
total_seconds: number;
|
|
328
|
+
total_minutes: number;
|
|
329
|
+
};
|
|
330
|
+
cost: {
|
|
331
|
+
fractional: number;
|
|
332
|
+
formatted: string;
|
|
333
|
+
amount: number;
|
|
334
|
+
};
|
|
335
|
+
estimated_cost: {
|
|
336
|
+
fractional: number;
|
|
337
|
+
formatted: string;
|
|
338
|
+
amount: number;
|
|
339
|
+
};
|
|
340
|
+
day: string;
|
|
341
|
+
note: string;
|
|
342
|
+
sequence: number;
|
|
343
|
+
estimated: boolean;
|
|
344
|
+
timer_state: string;
|
|
345
|
+
timer_started_on: 0;
|
|
346
|
+
timer_stopped_on: 0;
|
|
347
|
+
label_ids: number[];
|
|
348
|
+
user_ids: number[];
|
|
349
|
+
updated_at: number;
|
|
350
|
+
created_at: number;
|
|
351
|
+
created_from: string;
|
|
352
|
+
updated_from: string;
|
|
353
|
+
billed: boolean;
|
|
354
|
+
billable: boolean;
|
|
355
|
+
to: any;
|
|
356
|
+
from: any;
|
|
357
|
+
deleted: boolean;
|
|
358
|
+
hour_rate: number;
|
|
359
|
+
hour_rate_in_cents: number;
|
|
360
|
+
creator_id: number;
|
|
361
|
+
updater_id: number;
|
|
362
|
+
external_id: any;
|
|
363
|
+
entry_ids: [any];
|
|
364
|
+
suggestion_id: any;
|
|
365
|
+
draft: boolean;
|
|
366
|
+
manage: boolean;
|
|
367
|
+
forecast_id: any;
|
|
368
|
+
readonly locked_reason: string;
|
|
369
|
+
readonly locked: boolean;
|
|
370
|
+
invoice_id: any;
|
|
371
|
+
timestamps: any[];
|
|
372
|
+
}
|
|
373
|
+
export interface TimelyBulkUpdateEventsReturn {
|
|
374
|
+
deleted_ids: number[];
|
|
375
|
+
created_ids: number[];
|
|
376
|
+
updated_ids: number[];
|
|
377
|
+
}
|
|
378
|
+
export type TimelyEventBulkUpdate = OptionalExceptFor<TimelyEvent, 'id'>;
|
|
379
|
+
export type AddTimelyClient = OptionalExceptFor<TimelyClient, 'name'>;
|
|
380
|
+
export type AddTimelyUser = AddToAllProjects & OptionalExceptFor<TimelyUser, 'name' | 'email' | 'role_id'>;
|
|
381
|
+
export type UpdateTimelyUser = Partial<TimelyUser & AddToAllProjects>;
|
|
382
|
+
export interface AddToAllProjects {
|
|
383
|
+
add_to_all_projects?: boolean;
|
|
384
|
+
}
|
|
385
|
+
export type AddTimelyLabel = OptionalExceptFor<TimelyLabel, 'name'>;
|
|
386
|
+
export type DateString = string | Date;
|
|
387
|
+
export {};
|
package/lib/types.js
ADDED
package/lib/types.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/lib/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AxiosInstance } from 'axios';
|
|
2
|
+
import { AddTimelyUser, TimelyAppConfig, TimelyCapacity, TimelyPermission, TimelyRole, TimelyUser, TimelyUserCapacity, UpdateTimelyUser } from '../types';
|
|
3
|
+
export declare class Users {
|
|
4
|
+
private readonly http;
|
|
5
|
+
private readonly config;
|
|
6
|
+
constructor(http: AxiosInstance, config: TimelyAppConfig);
|
|
7
|
+
getAll(): Promise<TimelyUser[]>;
|
|
8
|
+
getById(userId: number): Promise<TimelyUser>;
|
|
9
|
+
getByEmail(userEmail: string): Promise<TimelyUser>;
|
|
10
|
+
add(user: AddTimelyUser): Promise<TimelyUser>;
|
|
11
|
+
update(userId: number, user: UpdateTimelyUser): Promise<TimelyUser>;
|
|
12
|
+
removeUserById(userId: number): Promise<{}>;
|
|
13
|
+
removeUserByEmail(userEmail: string): Promise<{}>;
|
|
14
|
+
getRoles(): Promise<TimelyRole[]>;
|
|
15
|
+
getUserCapacities(): Promise<TimelyUserCapacity[]>;
|
|
16
|
+
getUserCapacityById(userId: number): Promise<TimelyCapacity>;
|
|
17
|
+
getUsersPermissions(): Promise<TimelyPermission[]>;
|
|
18
|
+
getUsersPermissionsById(userId: number): Promise<TimelyPermission[]>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Users = void 0;
|
|
4
|
+
class Users {
|
|
5
|
+
constructor(http, config) {
|
|
6
|
+
this.http = http;
|
|
7
|
+
this.config = config;
|
|
8
|
+
}
|
|
9
|
+
async getAll() {
|
|
10
|
+
const { data } = await this.http.get(`/${this.config.accountId}/users?limit=1000`);
|
|
11
|
+
return data;
|
|
12
|
+
}
|
|
13
|
+
async getById(userId) {
|
|
14
|
+
const { data } = await this.http.get(`/${this.config.accountId}/users/${userId}`);
|
|
15
|
+
return data;
|
|
16
|
+
}
|
|
17
|
+
async getByEmail(userEmail) {
|
|
18
|
+
const { data: response } = await this.http.get(`/${this.config.accountId}/users?limit=999`);
|
|
19
|
+
return response.find((u) => u.email === userEmail);
|
|
20
|
+
}
|
|
21
|
+
async add(user) {
|
|
22
|
+
const { data } = await this.http.post(`/${this.config.accountId}/users`, { user });
|
|
23
|
+
return data;
|
|
24
|
+
}
|
|
25
|
+
async update(userId, user) {
|
|
26
|
+
const { data } = await this.http.put(`/${this.config.accountId}/users/${userId}`, { user });
|
|
27
|
+
return data;
|
|
28
|
+
}
|
|
29
|
+
async removeUserById(userId) {
|
|
30
|
+
const { data } = await this.http.delete(`/${this.config.accountId}/users/${userId}`);
|
|
31
|
+
return data;
|
|
32
|
+
}
|
|
33
|
+
async removeUserByEmail(userEmail) {
|
|
34
|
+
const user = await this.getByEmail(userEmail);
|
|
35
|
+
if (!user)
|
|
36
|
+
throw new Error(`failed to find user with email: ${userEmail}`);
|
|
37
|
+
return await this.removeUserById(user.id);
|
|
38
|
+
}
|
|
39
|
+
async getRoles() {
|
|
40
|
+
const { data } = await this.http.get(`/${this.config.accountId}/roles`);
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
async getUserCapacities() {
|
|
44
|
+
const { data } = await this.http.get(`/${this.config.accountId}/users/capacities`);
|
|
45
|
+
return data;
|
|
46
|
+
}
|
|
47
|
+
async getUserCapacityById(userId) {
|
|
48
|
+
const { data } = await this.http.get(`/${this.config.accountId}/users/${userId}/capacities`);
|
|
49
|
+
return data;
|
|
50
|
+
}
|
|
51
|
+
async getUsersPermissions() {
|
|
52
|
+
const { data } = await this.http.get(`/${this.config.accountId}/users/current/permissions`);
|
|
53
|
+
return data;
|
|
54
|
+
}
|
|
55
|
+
async getUsersPermissionsById(userId) {
|
|
56
|
+
const { data } = await this.http.get(`/${this.config.accountId}/users/${userId}/permissions`);
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Users =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IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,UAAU,MAAM,aAAa,CAAC,CAAA;QAC5F,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,mBAAmB;QACrB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,4BAA4B,CAAC,CAAA;QAC3F,OAAO,IAAI,CAAA;IACf,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,MAAc;QACxC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAChC,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,UAAU,MAAM,cAAc,CAC1D,CAAA;QACD,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAtED,sBAsEC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"author": {
|
|
3
|
+
"name": "Josh Stout",
|
|
4
|
+
"email": "joshstout@gmail.com"
|
|
5
|
+
},
|
|
6
|
+
"config": {
|
|
7
|
+
"commitizen": {
|
|
8
|
+
"path": "./node_modules/@digitalroute/cz-conventional-changelog-for-jira",
|
|
9
|
+
"skipScope": false
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"axios": "1.17.0"
|
|
14
|
+
},
|
|
15
|
+
"description": "SDK for timelyapp.com API",
|
|
16
|
+
"devDependencies": {
|
|
17
|
+
"@digitalroute/cz-conventional-changelog-for-jira": "6.8.0",
|
|
18
|
+
"@pliancy/eslint-config-ts": "1.1.0",
|
|
19
|
+
"@pliancy/semantic-release-config-npm": "2.5.0",
|
|
20
|
+
"@types/jest": "29.5.12",
|
|
21
|
+
"commitizen": "4.3.0",
|
|
22
|
+
"cpy-cli": "5.0.0",
|
|
23
|
+
"husky": "9.0.11",
|
|
24
|
+
"jest": "29.7.0",
|
|
25
|
+
"npm-run-all2": "5.0.0",
|
|
26
|
+
"pinst": "3.0.0",
|
|
27
|
+
"rimraf": "5.0.5",
|
|
28
|
+
"semantic-release": "23.0.2",
|
|
29
|
+
"ts-jest": "29.1.2",
|
|
30
|
+
"ts-node": "10.9.2",
|
|
31
|
+
"typescript": "5.4.2"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=12"
|
|
35
|
+
},
|
|
36
|
+
"keywords": [],
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"main": "index.js",
|
|
39
|
+
"name": "@pliancy/timelyapp-sdk",
|
|
40
|
+
"repository": {
|
|
41
|
+
"type": "git",
|
|
42
|
+
"url": "https://github.com/pliancy/timelyapp-sdk"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "run-s -l clean test tsc copy",
|
|
46
|
+
"build:check": "tsc --noEmit",
|
|
47
|
+
"clean": "rimraf coverage dist tmp",
|
|
48
|
+
"copy": "pinst --disable && cpy package.json dist && cpy README.md dist && pinst --enable",
|
|
49
|
+
"lint": "eslint \"src/**/*.ts\" --fix",
|
|
50
|
+
"_postinstall": "husky install",
|
|
51
|
+
"qa": "run-s -l lint test clean build:check",
|
|
52
|
+
"semantic-release": "semantic-release",
|
|
53
|
+
"test": "jest",
|
|
54
|
+
"tsc": "tsc -p tsconfig.build.json"
|
|
55
|
+
},
|
|
56
|
+
"types": "index.d.ts",
|
|
57
|
+
"version": "6.1.0",
|
|
58
|
+
"volta": {
|
|
59
|
+
"node": "24.16.0",
|
|
60
|
+
"yarn": "1.22.21"
|
|
61
|
+
}
|
|
62
|
+
}
|