@bwi-mentorspaces/application-utils-npm 0.0.58 → 0.0.60
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.
|
@@ -1,7 +1,22 @@
|
|
|
1
|
-
import { ICronofyAccessToken, ICronofyConfig } from "./models";
|
|
1
|
+
import { ICronofyAccessToken, ICronofyApplicationCalendar, ICronofyConfig, ICronofyElementTokenParams, ICronofyElementTokenResponse } from "./models";
|
|
2
|
+
import { ICronofyAvailabilityRulesPostParams } from "./models/_/cronofy.data";
|
|
2
3
|
export declare class CronofyAPI {
|
|
3
4
|
private _cronofy;
|
|
4
5
|
constructor(config: ICronofyConfig);
|
|
6
|
+
/**
|
|
7
|
+
* Create a Cronofy application calendar.
|
|
8
|
+
*
|
|
9
|
+
* @param {string} calendarId Id for the new Cronofy application calendar
|
|
10
|
+
* @returns {Promise<ICronofyApplicationCalendar>} Returns Cronofy application calendar data
|
|
11
|
+
*/
|
|
12
|
+
createApplicationCalendar(calendarId: string): Promise<ICronofyApplicationCalendar>;
|
|
13
|
+
/**
|
|
14
|
+
* Refresh a Cronofy account access token using a refresh token.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} refreshToken Cronofy refresh token
|
|
17
|
+
* @returns {Promise<ICronofyAccessToken>} Returns Cronofy access token data
|
|
18
|
+
*/
|
|
19
|
+
refreshAccessToken(refreshToken: string): Promise<ICronofyAccessToken>;
|
|
5
20
|
/**
|
|
6
21
|
* Request an access token from Cronofy with an authorization code.
|
|
7
22
|
*
|
|
@@ -10,10 +25,24 @@ export declare class CronofyAPI {
|
|
|
10
25
|
* @returns {Promise<ICronofyAccessToken>} Returns Cronofy access token data
|
|
11
26
|
*/
|
|
12
27
|
requestAccessToken(authCode: string, redirectUri: string): Promise<ICronofyAccessToken>;
|
|
28
|
+
/**
|
|
29
|
+
* Request an element token from Cronofy.
|
|
30
|
+
*
|
|
31
|
+
* @param {ICronofyElementTokenParams} params Parameters for the Cronofy request element token API
|
|
32
|
+
* @returns {Promise<ICronofyElementTokenResponse>} Returns Cronofy element token data
|
|
33
|
+
*/
|
|
34
|
+
requestElementToken(params: ICronofyElementTokenParams): Promise<ICronofyElementTokenResponse | null>;
|
|
13
35
|
/**
|
|
14
36
|
* Revokes authorization for a Cronofy linked calendar.
|
|
15
37
|
*
|
|
16
38
|
* @param {string} token Access or refresh token associated with the account to revoke
|
|
17
39
|
*/
|
|
18
40
|
revokeAuthorization(token: string): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* Create or update a Cronofy availability rule.
|
|
43
|
+
*
|
|
44
|
+
* @param {ICronofyAvailabilityRulesPostParams} params Parameters for the Cronofy availability rules POST API
|
|
45
|
+
* @returns {Promise<boolean>} Returns true if the request was successful
|
|
46
|
+
*/
|
|
47
|
+
upsertAvailabilityRule(accessToken: string, params: ICronofyAvailabilityRulesPostParams): Promise<boolean>;
|
|
19
48
|
}
|
|
@@ -32,6 +32,32 @@ let CronofyAPI = class CronofyAPI {
|
|
|
32
32
|
data_center: config.dataCenter,
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a Cronofy application calendar.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} calendarId Id for the new Cronofy application calendar
|
|
39
|
+
* @returns {Promise<ICronofyApplicationCalendar>} Returns Cronofy application calendar data
|
|
40
|
+
*/
|
|
41
|
+
createApplicationCalendar(calendarId) {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
const options = { application_calendar_id: calendarId };
|
|
44
|
+
const appCalendar = yield this._cronofy.applicationCalendar(options);
|
|
45
|
+
return appCalendar;
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Refresh a Cronofy account access token using a refresh token.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} refreshToken Cronofy refresh token
|
|
52
|
+
* @returns {Promise<ICronofyAccessToken>} Returns Cronofy access token data
|
|
53
|
+
*/
|
|
54
|
+
refreshAccessToken(refreshToken) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const options = { refresh_token: refreshToken };
|
|
57
|
+
const accessToken = yield this._cronofy.refreshAccessToken(options);
|
|
58
|
+
return accessToken;
|
|
59
|
+
});
|
|
60
|
+
}
|
|
35
61
|
/**
|
|
36
62
|
* Request an access token from Cronofy with an authorization code.
|
|
37
63
|
*
|
|
@@ -49,6 +75,18 @@ let CronofyAPI = class CronofyAPI {
|
|
|
49
75
|
return accessToken;
|
|
50
76
|
});
|
|
51
77
|
}
|
|
78
|
+
/**
|
|
79
|
+
* Request an element token from Cronofy.
|
|
80
|
+
*
|
|
81
|
+
* @param {ICronofyElementTokenParams} params Parameters for the Cronofy request element token API
|
|
82
|
+
* @returns {Promise<ICronofyElementTokenResponse>} Returns Cronofy element token data
|
|
83
|
+
*/
|
|
84
|
+
requestElementToken(params) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
86
|
+
const elementToken = yield this._cronofy.requestElementToken(params);
|
|
87
|
+
return elementToken.element_token ? elementToken.element_token : null;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
52
90
|
/**
|
|
53
91
|
* Revokes authorization for a Cronofy linked calendar.
|
|
54
92
|
*
|
|
@@ -60,6 +98,18 @@ let CronofyAPI = class CronofyAPI {
|
|
|
60
98
|
yield this._cronofy.revokeAuthorization(options);
|
|
61
99
|
});
|
|
62
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Create or update a Cronofy availability rule.
|
|
103
|
+
*
|
|
104
|
+
* @param {ICronofyAvailabilityRulesPostParams} params Parameters for the Cronofy availability rules POST API
|
|
105
|
+
* @returns {Promise<boolean>} Returns true if the request was successful
|
|
106
|
+
*/
|
|
107
|
+
upsertAvailabilityRule(accessToken, params) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
const res = yield this._cronofy.upsertAvailabilityRule(Object.assign({ access_token: accessToken }, params));
|
|
110
|
+
return res && res.availability_rule && res && res.availability_rule.availability_rule_id;
|
|
111
|
+
});
|
|
112
|
+
}
|
|
63
113
|
};
|
|
64
114
|
CronofyAPI = __decorate([
|
|
65
115
|
(0, tsyringe_1.injectable)(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cronofy.api.js","sourceRoot":"","sources":["../../../calendar/cronofy/cronofy.api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,uCAAsC;
|
|
1
|
+
{"version":3,"file":"cronofy.api.js","sourceRoot":"","sources":["../../../calendar/cronofy/cronofy.api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,uCAAsC;AAM/B,IAAM,UAAU,GAAhB,MAAM,UAAU;IAGnB,YAAY,MAAsB;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,iBAAO,CAAC;YACxB,SAAS,EAAE,MAAM,CAAC,QAAQ;YAC1B,aAAa,EAAE,MAAM,CAAC,YAAY;YAClC,WAAW,EAAE,MAAM,CAAC,UAAU;SACjC,CAAC,CAAC;IACP,CAAC;IAED;;;;;OAKG;IACU,yBAAyB,CAAC,UAAkB;;YACrD,MAAM,OAAO,GAAG,EAAE,uBAAuB,EAAE,UAAU,EAAE,CAAC;YACxD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;YACrE,OAAO,WAAW,CAAC;QACvB,CAAC;KAAA;IAED;;;;;OAKG;IACU,kBAAkB,CAAC,YAAoB;;YAChD,MAAM,OAAO,GAAG,EAAE,aAAa,EAAE,YAAY,EAAE,CAAC;YAChD,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACpE,OAAO,WAAW,CAAC;QACvB,CAAC;KAAA;IAED;;;;;;OAMG;IACU,kBAAkB,CAAC,QAAgB,EAAE,WA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export interface ICronofyAccessToken {
|
|
|
14
16
|
provider_service: string;
|
|
15
17
|
};
|
|
16
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Cronofy Application Calendar data interface
|
|
21
|
+
*/
|
|
22
|
+
export interface ICronofyApplicationCalendar {
|
|
23
|
+
access_token: string;
|
|
24
|
+
token_type: 'bearer';
|
|
25
|
+
expires_in: number;
|
|
26
|
+
refresh_token: string;
|
|
27
|
+
scope: string;
|
|
28
|
+
sub: string;
|
|
29
|
+
application_calendar_id: string;
|
|
30
|
+
linking_profile: {
|
|
31
|
+
provider_name: string;
|
|
32
|
+
profile_id: string;
|
|
33
|
+
profile_name: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Cronofy Element Token Request Parameters data interface
|
|
38
|
+
*/
|
|
39
|
+
export interface ICronofyElementTokenParams {
|
|
40
|
+
version?: string;
|
|
41
|
+
permissions: string[];
|
|
42
|
+
subs: string[];
|
|
43
|
+
origin: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Cronofy Element Token Response data interface
|
|
47
|
+
*/
|
|
48
|
+
export interface ICronofyElementTokenResponse {
|
|
49
|
+
permissions: string[];
|
|
50
|
+
origin: string;
|
|
51
|
+
token: string;
|
|
52
|
+
expires_in: number;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Cronofy availability rules post request parameters interface
|
|
56
|
+
*/
|
|
57
|
+
export interface ICronofyAvailabilityRulesPostParams {
|
|
58
|
+
availability_rule_id: string;
|
|
59
|
+
tzid: string;
|
|
60
|
+
calendar_ids?: string[];
|
|
61
|
+
weekly_periods: ICronofyAvailabilityRulesWeeklyPeriod[];
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Cronofy availability rules weekly period interface
|
|
65
|
+
*/
|
|
66
|
+
export interface ICronofyAvailabilityRulesWeeklyPeriod {
|
|
67
|
+
day: string;
|
|
68
|
+
start_time: string;
|
|
69
|
+
end_time: string;
|
|
70
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ICronofyConfig } from "./_/cronofy.config";
|
|
2
|
-
import { ICronofyAccessToken } from "./_/cronofy.data";
|
|
3
|
-
export { ICronofyAccessToken, ICronofyConfig };
|
|
2
|
+
import { ICronofyAccessToken, ICronofyElementTokenParams, ICronofyElementTokenResponse, ICronofyApplicationCalendar, ICronofyAvailabilityRulesPostParams, ICronofyAvailabilityRulesWeeklyPeriod } from "./_/cronofy.data";
|
|
3
|
+
export { ICronofyAccessToken, ICronofyConfig, ICronofyElementTokenParams, ICronofyElementTokenResponse, ICronofyApplicationCalendar, ICronofyAvailabilityRulesPostParams, ICronofyAvailabilityRulesWeeklyPeriod };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bwi-mentorspaces/application-utils-npm",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.60",
|
|
4
4
|
"description": "Mentor Spaces npm packages for reusable models, utils, and abstracted, commonly used processes for DB Repo, Logging, etc.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Mentor Spaces",
|