@frontegg/rest-api 3.1.75 → 3.1.76-alpha.9502349697
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/BaseApiClient.d.ts +16 -0
- package/BaseApiClient.js +39 -0
- package/ContextHolder/index.d.ts +108 -27
- package/ContextHolder/index.js +155 -50
- package/FetchClient.d.ts +42 -0
- package/FetchClient.js +308 -0
- package/account-settings/index.d.ts +19 -7
- package/account-settings/index.js +23 -13
- package/applications/index.d.ts +49 -44
- package/applications/index.js +51 -37
- package/audits/index.d.ts +27 -15
- package/audits/index.js +27 -17
- package/auth/index.d.ts +817 -768
- package/auth/index.js +902 -721
- package/auth/secutiry-poilicy/index.d.ts +58 -102
- package/auth/secutiry-poilicy/index.js +122 -90
- package/auth/utils.d.ts +2 -2
- package/auth/utils.js +9 -8
- package/connectivity/index.d.ts +126 -27
- package/connectivity/index.js +147 -114
- package/directory/index.d.ts +31 -22
- package/directory/index.js +27 -15
- package/entitlements/index.d.ts +14 -8
- package/entitlements/index.js +12 -4
- package/feature-flags/index.d.ts +8 -2
- package/feature-flags/index.js +16 -8
- package/groups/index.d.ts +73 -49
- package/groups/index.js +64 -45
- package/impersonate/index.d.ts +15 -6
- package/impersonate/index.js +13 -5
- package/index.d.ts +154 -108
- package/index.js +109 -78
- package/interfaces.d.ts +10 -0
- package/metadata/index.d.ts +67 -7
- package/metadata/index.js +52 -32
- package/node/BaseApiClient.js +49 -0
- package/node/ContextHolder/index.js +155 -50
- package/node/FetchClient.js +326 -0
- package/node/account-settings/index.js +27 -16
- package/node/applications/index.js +51 -44
- package/node/audits/index.js +31 -20
- package/node/auth/index.js +768 -1035
- package/node/auth/secutiry-poilicy/index.js +125 -136
- package/node/auth/utils.js +9 -7
- package/node/connectivity/index.js +148 -187
- package/node/directory/index.js +29 -20
- package/node/entitlements/index.js +18 -5
- package/node/feature-flags/index.js +21 -9
- package/node/groups/index.js +65 -63
- package/node/impersonate/index.js +18 -5
- package/node/index.js +116 -71
- package/node/metadata/index.js +61 -52
- package/node/notifications/index.js +37 -27
- package/node/reports/index.js +78 -70
- package/node/roles/index.js +56 -51
- package/node/security-center/index.js +21 -9
- package/node/sub-tenants/index.js +90 -89
- package/node/subscriptions/index.js +69 -107
- package/node/subscriptions/invoices.js +25 -17
- package/node/subscriptions/managedSubscriptions.js +32 -27
- package/node/subscriptions/paymentMethods.js +27 -20
- package/node/subscriptions/paymentProviders.js +15 -6
- package/node/subscriptions/plans.js +17 -9
- package/node/subscriptions/providers/stripe/index.js +26 -21
- package/node/subscriptions/subscriptions.js +32 -27
- package/node/subscriptions/summaries.js +15 -6
- package/node/subscriptions/tenantConfiguration.js +17 -9
- package/node/subscriptions/vendorPublicConfigurations.js +15 -6
- package/node/teams/index.js +130 -138
- package/node/tenants/index.js +65 -60
- package/node/user-phone-numbers/index.js +32 -24
- package/node/users/index.js +58 -53
- package/node/vendor/index.js +17 -6
- package/notifications/index.d.ts +22 -16
- package/notifications/index.js +33 -22
- package/package.json +1 -1
- package/reports/index.d.ts +50 -44
- package/reports/index.js +75 -62
- package/roles/index.d.ts +44 -38
- package/roles/index.js +57 -41
- package/security-center/index.d.ts +14 -2
- package/security-center/index.js +15 -6
- package/sub-tenants/index.d.ts +57 -15
- package/sub-tenants/index.js +88 -68
- package/subscriptions/index.d.ts +56 -11
- package/subscriptions/index.js +58 -11
- package/subscriptions/invoices.d.ts +16 -13
- package/subscriptions/invoices.js +24 -14
- package/subscriptions/managedSubscriptions.d.ts +18 -15
- package/subscriptions/managedSubscriptions.js +33 -22
- package/subscriptions/paymentMethods.d.ts +16 -13
- package/subscriptions/paymentMethods.js +26 -17
- package/subscriptions/paymentProviders.d.ts +8 -5
- package/subscriptions/paymentProviders.js +11 -4
- package/subscriptions/plans.d.ts +11 -8
- package/subscriptions/plans.js +14 -6
- package/subscriptions/providers/stripe/index.d.ts +24 -21
- package/subscriptions/providers/stripe/index.js +27 -16
- package/subscriptions/subscriptions.d.ts +24 -21
- package/subscriptions/subscriptions.js +33 -22
- package/subscriptions/summaries.d.ts +7 -4
- package/subscriptions/summaries.js +10 -3
- package/subscriptions/tenantConfiguration.d.ts +6 -3
- package/subscriptions/tenantConfiguration.js +15 -7
- package/subscriptions/vendorPublicConfigurations.d.ts +5 -2
- package/subscriptions/vendorPublicConfigurations.js +11 -4
- package/teams/index.d.ts +35 -131
- package/teams/index.js +122 -93
- package/tenants/index.d.ts +25 -37
- package/tenants/index.js +62 -46
- package/user-phone-numbers/index.d.ts +32 -26
- package/user-phone-numbers/index.js +32 -19
- package/users/index.d.ts +21 -15
- package/users/index.js +60 -44
- package/vendor/index.d.ts +12 -6
- package/vendor/index.js +11 -4
- package/fetch.d.ts +0 -24
- package/fetch.js +0 -265
- package/node/fetch.js +0 -306
- package/node/subscriptions/providers/index.js +0 -18
- package/subscriptions/providers/index.d.ts +0 -1
- package/subscriptions/providers/index.js +0 -1
|
@@ -3,37 +3,45 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.deletePhoneNumber = deletePhoneNumber;
|
|
8
|
-
exports.getUserPhoneNumbers = getUserPhoneNumbers;
|
|
9
|
-
exports.preVerifyPhoneNumber = preVerifyPhoneNumber;
|
|
10
|
-
exports.verifyDeletePhoneNumber = verifyDeletePhoneNumber;
|
|
11
|
-
exports.verifyPhoneNumber = verifyPhoneNumber;
|
|
6
|
+
exports.default = exports.PhoneNumbersApi = void 0;
|
|
12
7
|
|
|
13
8
|
var _constants = require("../constants");
|
|
14
9
|
|
|
15
|
-
var
|
|
10
|
+
var _BaseApiClient = require("../BaseApiClient");
|
|
16
11
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
12
|
+
class PhoneNumbersApi extends _BaseApiClient.BaseApiClient {
|
|
13
|
+
constructor(appName) {
|
|
14
|
+
super(appName);
|
|
20
15
|
|
|
21
|
-
async
|
|
22
|
-
|
|
23
|
-
}
|
|
16
|
+
this.getUserPhoneNumbers = async queryParams => {
|
|
17
|
+
return this.get(`${_constants.urls.identity.phoneNumbers.v1}`, queryParams);
|
|
18
|
+
};
|
|
24
19
|
|
|
25
|
-
async
|
|
26
|
-
|
|
27
|
-
}
|
|
20
|
+
this.createPhoneNumber = async body => {
|
|
21
|
+
return this.post(`${_constants.urls.identity.phoneNumbers.v1}`, body);
|
|
22
|
+
};
|
|
28
23
|
|
|
29
|
-
async
|
|
30
|
-
|
|
31
|
-
}
|
|
24
|
+
this.deletePhoneNumber = async phoneId => {
|
|
25
|
+
return this.delete(`${_constants.urls.identity.phoneNumbers.v1}/${phoneId}`);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
this.preVerifyPhoneNumber = async body => {
|
|
29
|
+
return this.post(`${_constants.urls.identity.phoneNumbers.v1}/preverify`, body);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
this.verifyPhoneNumber = async body => {
|
|
33
|
+
return this.post(`${_constants.urls.identity.phoneNumbers.v1}/verify`, body);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
this.verifyDeletePhoneNumber = async (phoneId, body) => {
|
|
37
|
+
return this.post(`${_constants.urls.identity.phoneNumbers.v1}/${phoneId}/delete/verify`, body);
|
|
38
|
+
};
|
|
39
|
+
}
|
|
32
40
|
|
|
33
|
-
async function verifyPhoneNumber(body) {
|
|
34
|
-
return (0, _fetch.Post)(`${_constants.urls.identity.phoneNumbers.v1}/verify`, body);
|
|
35
41
|
}
|
|
36
42
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
exports.PhoneNumbersApi = PhoneNumbersApi;
|
|
44
|
+
|
|
45
|
+
var _default = new PhoneNumbersApi('default');
|
|
46
|
+
|
|
47
|
+
exports.default = _default;
|
package/node/users/index.js
CHANGED
|
@@ -5,70 +5,75 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.
|
|
9
|
-
exports.getCurrentUserTenantsV1 = getCurrentUserTenantsV1;
|
|
10
|
-
exports.getCurrentUserTenantsV3 = getCurrentUserTenantsV3;
|
|
11
|
-
exports.getUsersGroups = getUsersGroups;
|
|
12
|
-
exports.getUsersRoles = getUsersRoles;
|
|
13
|
-
exports.getUsersV2 = getUsersV2;
|
|
14
|
-
exports.getUsersV3 = getUsersV3;
|
|
15
|
-
exports.sendResetBreachedPasswordEmails = sendResetBreachedPasswordEmails;
|
|
16
|
-
exports.updateUserProfileV2 = updateUserProfileV2;
|
|
8
|
+
exports.default = exports.UsersApi = void 0;
|
|
17
9
|
|
|
18
10
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
19
11
|
|
|
20
|
-
var _fetch = require("../fetch");
|
|
21
|
-
|
|
22
12
|
var _constants = require("../constants");
|
|
23
13
|
|
|
24
|
-
|
|
25
|
-
return (0, _fetch.Post)(`${_constants.urls.identity.users.v3}/me/token`, body);
|
|
26
|
-
}
|
|
14
|
+
var _BaseApiClient = require("../BaseApiClient");
|
|
27
15
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
});
|
|
32
|
-
}
|
|
16
|
+
class UsersApi extends _BaseApiClient.BaseApiClient {
|
|
17
|
+
constructor(appName) {
|
|
18
|
+
super(appName);
|
|
33
19
|
|
|
34
|
-
async
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
});
|
|
38
|
-
}
|
|
20
|
+
this.GetUserJwt = async body => {
|
|
21
|
+
return this.post(`${_constants.urls.identity.users.v3}/me/token`, body);
|
|
22
|
+
};
|
|
39
23
|
|
|
40
|
-
async
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
}
|
|
24
|
+
this.getUsersV2 = async (queryParams, options) => {
|
|
25
|
+
return this.get(_constants.urls.identity.users.v2, queryParams, {
|
|
26
|
+
headers: this.extractHeadersFromOptions(options)
|
|
27
|
+
});
|
|
28
|
+
};
|
|
47
29
|
|
|
48
|
-
async
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
}
|
|
30
|
+
this.getUsersV3 = async (queryParams, options) => {
|
|
31
|
+
return this.get(_constants.urls.identity.users.v3, queryParams, {
|
|
32
|
+
headers: this.extractHeadersFromOptions(options)
|
|
33
|
+
});
|
|
34
|
+
};
|
|
55
35
|
|
|
56
|
-
async
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
36
|
+
this.getUsersRoles = async (queryParams, options) => {
|
|
37
|
+
return this.get(_constants.urls.identity.users.roles.v3, (0, _extends2.default)({}, queryParams, {
|
|
38
|
+
ids: queryParams.ids.join(',')
|
|
39
|
+
}), {
|
|
40
|
+
headers: this.extractHeadersFromOptions(options)
|
|
41
|
+
});
|
|
42
|
+
};
|
|
61
43
|
|
|
62
|
-
async
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
44
|
+
this.getUsersGroups = async (queryParams, options) => {
|
|
45
|
+
return this.get(_constants.urls.identity.users.groups.v3, (0, _extends2.default)({}, queryParams, {
|
|
46
|
+
ids: queryParams.ids.join(',')
|
|
47
|
+
}), {
|
|
48
|
+
headers: this.extractHeadersFromOptions(options)
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
this.getCurrentUserTenantsV3 = async options => {
|
|
53
|
+
return this.get(_constants.urls.identity.users.tenants.me.v3, undefined, {
|
|
54
|
+
headers: this.extractHeadersFromOptions(options)
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
this.getCurrentUserTenantsV1 = async options => {
|
|
59
|
+
return this.get(_constants.urls.identity.users.tenants.me.v1, undefined, {
|
|
60
|
+
headers: this.extractHeadersFromOptions(options)
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
this.sendResetBreachedPasswordEmails = async () => {
|
|
65
|
+
return this.post(_constants.urls.identity.users.passwords.resetBreachedPasswords.v1);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
this.updateUserProfileV2 = async body => {
|
|
69
|
+
return this.put(`${_constants.urls.identity.users.v2}/me`, body);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
67
72
|
|
|
68
|
-
async function sendResetBreachedPasswordEmails() {
|
|
69
|
-
return (0, _fetch.Post)(_constants.urls.identity.users.passwords.resetBreachedPasswords.v1);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
exports.UsersApi = UsersApi;
|
|
76
|
+
|
|
77
|
+
var _default = new UsersApi('default');
|
|
78
|
+
|
|
79
|
+
exports.default = _default;
|
package/node/vendor/index.js
CHANGED
|
@@ -3,14 +3,25 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
var _fetch = require("../fetch");
|
|
6
|
+
exports.default = exports.VendorApi = void 0;
|
|
9
7
|
|
|
10
8
|
var _constants = require("../constants");
|
|
11
9
|
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var _BaseApiClient = require("../BaseApiClient");
|
|
11
|
+
|
|
12
|
+
class VendorApi extends _BaseApiClient.BaseApiClient {
|
|
13
|
+
constructor(appName) {
|
|
14
|
+
super(appName);
|
|
15
|
+
|
|
16
|
+
this.getVendorPublicInfo = async () => {
|
|
17
|
+
return this.get(`${_constants.urls.vendor}/public`);
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
14
21
|
}
|
|
15
22
|
|
|
16
|
-
;
|
|
23
|
+
exports.VendorApi = VendorApi;
|
|
24
|
+
|
|
25
|
+
var _default = new VendorApi('default');
|
|
26
|
+
|
|
27
|
+
exports.default = _default;
|
package/notifications/index.d.ts
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { ILoadMessages, IMessage, IUpdateNotificationStatus, IUpdateNotificationIsPinned } from './interfaces';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export declare class NotificationsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName: string);
|
|
5
|
+
/**
|
|
6
|
+
* Get notifications
|
|
7
|
+
*/
|
|
8
|
+
getNotifications: (params: ILoadMessages) => Promise<Array<IMessage>>;
|
|
9
|
+
/**
|
|
10
|
+
* Update notification status
|
|
11
|
+
*/
|
|
12
|
+
updateNotificationStatus: (params: IUpdateNotificationStatus) => Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Update notification pin status
|
|
15
|
+
*/
|
|
16
|
+
updateNotificationIsPinned: (params: IUpdateNotificationIsPinned) => Promise<any>;
|
|
17
|
+
/**
|
|
18
|
+
* Mark all notifications as read
|
|
19
|
+
*/
|
|
20
|
+
markAllAsRead: () => Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
declare const _default: NotificationsApi;
|
|
23
|
+
export default _default;
|
package/notifications/index.js
CHANGED
|
@@ -1,24 +1,35 @@
|
|
|
1
|
-
import { Get, Post, Put } from '../fetch';
|
|
2
1
|
import { urls } from '../constants';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export class NotificationsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName) {
|
|
5
|
+
super(appName);
|
|
6
|
+
|
|
7
|
+
this.getNotifications = async params => {
|
|
8
|
+
return this.get(urls.notifications.v1, {
|
|
9
|
+
params
|
|
10
|
+
});
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
this.updateNotificationStatus = async params => {
|
|
14
|
+
return this.put(`${urls.notifications.v1}/status`, {
|
|
15
|
+
params
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
this.updateNotificationIsPinned = async params => {
|
|
20
|
+
const {
|
|
21
|
+
notificationId,
|
|
22
|
+
pinStatus
|
|
23
|
+
} = params;
|
|
24
|
+
return this.put(`${urls.notifications.v1}/${pinStatus}`, {
|
|
25
|
+
notificationId
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
this.markAllAsRead = async () => {
|
|
30
|
+
return this.post(`${urls.notifications.v1}/status/mark-all-read`);
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
7
34
|
}
|
|
8
|
-
export
|
|
9
|
-
return Put(`${urls.notifications.v1}/status`, {
|
|
10
|
-
params
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
export async function updateNotificationIsPinned(params) {
|
|
14
|
-
const {
|
|
15
|
-
notificationId,
|
|
16
|
-
pinStatus
|
|
17
|
-
} = params;
|
|
18
|
-
return Put(`${urls.notifications.v1}/${pinStatus}`, {
|
|
19
|
-
notificationId
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
export async function markAllAsRead() {
|
|
23
|
-
return Post(`${urls.notifications.v1}/status/mark-all-read`);
|
|
24
|
-
}
|
|
35
|
+
export default new NotificationsApi('default');
|
package/package.json
CHANGED
package/reports/index.d.ts
CHANGED
|
@@ -1,45 +1,51 @@
|
|
|
1
1
|
import { IDownloadReport, IGetReport, IGetReports, IRenderReport, IRenderReportResponse, IReportRecord, IScheduleReport, ISendReport } from './interfaces';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
3
|
+
export declare class ReportsApi extends BaseApiClient {
|
|
4
|
+
constructor(appName: string);
|
|
5
|
+
/**
|
|
6
|
+
* Get all active tenant reports from reports service by active vendor.
|
|
7
|
+
* Optional: pass filters and sort options to reports.
|
|
8
|
+
*
|
|
9
|
+
* @returns list of reports objects
|
|
10
|
+
*/
|
|
11
|
+
getReports: (body: IGetReports) => Promise<IReportRecord[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Get report record by id.
|
|
14
|
+
*
|
|
15
|
+
* @returns list of report object
|
|
16
|
+
* @throws exception if report not found.
|
|
17
|
+
*/
|
|
18
|
+
getReport: (body: IGetReport) => Promise<IReportRecord>;
|
|
19
|
+
/**
|
|
20
|
+
* Render report by id.
|
|
21
|
+
* Optional: pass data filters if exists to render report by specific data.
|
|
22
|
+
*
|
|
23
|
+
* @returns html content of the rendered reports
|
|
24
|
+
* @throws exception if report not found or the data api unreached.
|
|
25
|
+
*/
|
|
26
|
+
renderReport: ({ dataFilters, ...body }: IRenderReport) => Promise<IRenderReportResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* Schedule report by providing cron expression and data filters.
|
|
29
|
+
*
|
|
30
|
+
* @returns the updated report object
|
|
31
|
+
* @throws exception if report not found or the data api unreached.
|
|
32
|
+
*/
|
|
33
|
+
scheduleReport: ({ templateId, dataFilters, ...body }: IScheduleReport) => Promise<IReportRecord>;
|
|
34
|
+
/**
|
|
35
|
+
* Download report as file in specific format.
|
|
36
|
+
* This function will add a href element with url to trigger file download.
|
|
37
|
+
* Optional: pass data filters if exists to generate report by specific data.
|
|
38
|
+
*
|
|
39
|
+
* @throws exception if report not found or the data api unreached.
|
|
40
|
+
*/
|
|
41
|
+
downloadReport: ({ dataFilters, ...body }: IDownloadReport) => Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Send report to specific email address.
|
|
44
|
+
* Optional: pass data filters if exists to send report by specific data.
|
|
45
|
+
*
|
|
46
|
+
* @throws exception if report not found or the data api unreached.
|
|
47
|
+
*/
|
|
48
|
+
sendReport: (body: ISendReport) => Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
declare const _default: ReportsApi;
|
|
51
|
+
export default _default;
|
package/reports/index.js
CHANGED
|
@@ -3,73 +3,86 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["dataFilters"],
|
|
4
4
|
_excluded2 = ["templateId", "dataFilters"],
|
|
5
5
|
_excluded3 = ["dataFilters"];
|
|
6
|
-
import { Get, Post } from '../fetch';
|
|
7
6
|
import { urls } from '../constants';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return Get(`${urls.reports.service.v2}/${body.id}/tenant-reports`);
|
|
13
|
-
}
|
|
14
|
-
export async function renderReport(_ref) {
|
|
15
|
-
let {
|
|
16
|
-
dataFilters
|
|
17
|
-
} = _ref,
|
|
18
|
-
body = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
7
|
+
import { BaseApiClient } from '../BaseApiClient';
|
|
8
|
+
export class ReportsApi extends BaseApiClient {
|
|
9
|
+
constructor(appName) {
|
|
10
|
+
super(appName);
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}), {
|
|
24
|
-
responseType: 'plain'
|
|
25
|
-
});
|
|
26
|
-
return {
|
|
27
|
-
html
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
export async function scheduleReport(_ref2) {
|
|
31
|
-
let {
|
|
32
|
-
templateId,
|
|
33
|
-
dataFilters
|
|
34
|
-
} = _ref2,
|
|
35
|
-
body = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
12
|
+
this.getReports = async body => {
|
|
13
|
+
return this.get(`${urls.reports.service.v2}/tenant-reports`, body);
|
|
14
|
+
};
|
|
36
15
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
16
|
+
this.getReport = async body => {
|
|
17
|
+
return this.get(`${urls.reports.service.v2}/${body.id}/tenant-reports`);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
this.renderReport = async _ref => {
|
|
21
|
+
let {
|
|
22
|
+
dataFilters
|
|
23
|
+
} = _ref,
|
|
24
|
+
body = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
25
|
+
|
|
26
|
+
const html = await this.get(`${urls.reports.trigger.v1}/preview-report`, _extends({}, body, {
|
|
27
|
+
dataFilters: btoa(JSON.stringify(dataFilters || {})),
|
|
28
|
+
responseType: 'html'
|
|
29
|
+
}), {
|
|
30
|
+
responseType: 'plain'
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
html
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
this.scheduleReport = async _ref2 => {
|
|
38
|
+
let {
|
|
39
|
+
templateId,
|
|
40
|
+
dataFilters
|
|
41
|
+
} = _ref2,
|
|
42
|
+
body = _objectWithoutPropertiesLoose(_ref2, _excluded2);
|
|
43
|
+
|
|
44
|
+
return this.post(`${urls.reports.service.v2}/${templateId}/tenant-reports`, _extends({}, body, {
|
|
45
|
+
dataFilters: btoa(JSON.stringify(dataFilters || {}))
|
|
46
|
+
}));
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
this.downloadReport = async _ref3 => {
|
|
50
|
+
let {
|
|
51
|
+
dataFilters
|
|
52
|
+
} = _ref3,
|
|
53
|
+
body = _objectWithoutPropertiesLoose(_ref3, _excluded3);
|
|
54
|
+
|
|
55
|
+
const blob = await this.get(`${urls.reports.trigger.v1}/preview-report`, _extends({}, body, {
|
|
56
|
+
dataFilters: btoa(JSON.stringify(dataFilters || {}))
|
|
57
|
+
}), {
|
|
58
|
+
responseType: 'blob'
|
|
59
|
+
});
|
|
60
|
+
let contentType = 'text/html';
|
|
61
|
+
let contentExt = 'html';
|
|
62
|
+
|
|
63
|
+
if (body.responseType === 'pdf') {
|
|
64
|
+
contentType = 'application/pdf';
|
|
65
|
+
contentExt = 'pdf';
|
|
66
|
+
} else if (body.responseType === 'image') {
|
|
67
|
+
contentType = 'image/jpeg';
|
|
68
|
+
contentExt = 'jpg';
|
|
69
|
+
}
|
|
46
70
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
71
|
+
const newBlob = new Blob([blob], {
|
|
72
|
+
type: contentType
|
|
73
|
+
});
|
|
74
|
+
const fileURL = URL.createObjectURL(newBlob);
|
|
75
|
+
const tempLink = document.createElement('a');
|
|
76
|
+
tempLink.href = fileURL;
|
|
77
|
+
tempLink.setAttribute('download', `report_${body.name || ''}.${contentExt}`);
|
|
78
|
+
tempLink.click();
|
|
79
|
+
setTimeout(tempLink.remove.bind(tempLink));
|
|
80
|
+
};
|
|
54
81
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
} else if (body.responseType === 'image') {
|
|
59
|
-
contentType = 'image/jpeg';
|
|
60
|
-
contentExt = 'jpg';
|
|
82
|
+
this.sendReport = async body => {
|
|
83
|
+
return this.post(`${urls.reports.trigger.v1}/tenant-reports`, body);
|
|
84
|
+
};
|
|
61
85
|
}
|
|
62
86
|
|
|
63
|
-
const newBlob = new Blob([blob], {
|
|
64
|
-
type: contentType
|
|
65
|
-
});
|
|
66
|
-
const fileURL = URL.createObjectURL(newBlob);
|
|
67
|
-
const tempLink = document.createElement('a');
|
|
68
|
-
tempLink.href = fileURL;
|
|
69
|
-
tempLink.setAttribute('download', `report_${body.name || ''}.${contentExt}`);
|
|
70
|
-
tempLink.click();
|
|
71
|
-
setTimeout(tempLink.remove.bind(tempLink));
|
|
72
87
|
}
|
|
73
|
-
export
|
|
74
|
-
return Post(`${urls.reports.trigger.v1}/tenant-reports`, body);
|
|
75
|
-
}
|
|
88
|
+
export default new ReportsApi('default');
|