@bwi-mentorspaces/application-utils-npm 0.0.57 → 0.0.58
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/calendar/cronofy/cronofy.api.d.ts +19 -0
- package/calendar/cronofy/cronofy.api.js +69 -0
- package/calendar/cronofy/cronofy.api.js.map +1 -0
- package/calendar/cronofy/index.d.ts +2 -0
- package/calendar/cronofy/index.js +6 -0
- package/calendar/cronofy/index.js.map +1 -0
- package/calendar/cronofy/models/_/cronofy.config.d.ts +8 -0
- package/calendar/cronofy/models/_/cronofy.config.js +3 -0
- package/calendar/cronofy/models/_/cronofy.config.js.map +1 -0
- package/calendar/cronofy/models/_/cronofy.data.d.ts +16 -0
- package/calendar/cronofy/models/_/cronofy.data.js +3 -0
- package/calendar/cronofy/models/_/cronofy.data.js.map +1 -0
- package/calendar/cronofy/models/index.d.ts +3 -0
- package/calendar/cronofy/models/index.js +3 -0
- package/calendar/cronofy/models/index.js.map +1 -0
- package/calendar/enum/index.d.ts +6 -0
- package/calendar/enum/index.js +11 -0
- package/calendar/enum/index.js.map +1 -0
- package/calendar/index.d.ts +33 -0
- package/calendar/index.js +55 -0
- package/calendar/index.js.map +1 -0
- package/package.json +2 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ICronofyAccessToken, ICronofyConfig } from "./models";
|
|
2
|
+
export declare class CronofyAPI {
|
|
3
|
+
private _cronofy;
|
|
4
|
+
constructor(config: ICronofyConfig);
|
|
5
|
+
/**
|
|
6
|
+
* Request an access token from Cronofy with an authorization code.
|
|
7
|
+
*
|
|
8
|
+
* @param {string} authCode Authorization code obtained from Cronofy
|
|
9
|
+
* @param {string} redirectUri Redirect URI used when obtaining the auth code
|
|
10
|
+
* @returns {Promise<ICronofyAccessToken>} Returns Cronofy access token data
|
|
11
|
+
*/
|
|
12
|
+
requestAccessToken(authCode: string, redirectUri: string): Promise<ICronofyAccessToken>;
|
|
13
|
+
/**
|
|
14
|
+
* Revokes authorization for a Cronofy linked calendar.
|
|
15
|
+
*
|
|
16
|
+
* @param {string} token Access or refresh token associated with the account to revoke
|
|
17
|
+
*/
|
|
18
|
+
revokeAuthorization(token: string): Promise<void>;
|
|
19
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
21
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
exports.CronofyAPI = void 0;
|
|
25
|
+
const cronofy_1 = __importDefault(require("cronofy"));
|
|
26
|
+
const tsyringe_1 = require("tsyringe");
|
|
27
|
+
let CronofyAPI = class CronofyAPI {
|
|
28
|
+
constructor(config) {
|
|
29
|
+
this._cronofy = new cronofy_1.default({
|
|
30
|
+
client_id: config.clientId,
|
|
31
|
+
client_secret: config.clientSecret,
|
|
32
|
+
data_center: config.dataCenter,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Request an access token from Cronofy with an authorization code.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} authCode Authorization code obtained from Cronofy
|
|
39
|
+
* @param {string} redirectUri Redirect URI used when obtaining the auth code
|
|
40
|
+
* @returns {Promise<ICronofyAccessToken>} Returns Cronofy access token data
|
|
41
|
+
*/
|
|
42
|
+
requestAccessToken(authCode, redirectUri) {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const options = {
|
|
45
|
+
code: authCode,
|
|
46
|
+
redirect_uri: redirectUri,
|
|
47
|
+
};
|
|
48
|
+
const accessToken = yield this._cronofy.requestAccessToken(options);
|
|
49
|
+
return accessToken;
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Revokes authorization for a Cronofy linked calendar.
|
|
54
|
+
*
|
|
55
|
+
* @param {string} token Access or refresh token associated with the account to revoke
|
|
56
|
+
*/
|
|
57
|
+
revokeAuthorization(token) {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
const options = { token };
|
|
60
|
+
yield this._cronofy.revokeAuthorization(options);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
CronofyAPI = __decorate([
|
|
65
|
+
(0, tsyringe_1.injectable)(),
|
|
66
|
+
__metadata("design:paramtypes", [Object])
|
|
67
|
+
], CronofyAPI);
|
|
68
|
+
exports.CronofyAPI = CronofyAPI;
|
|
69
|
+
//# sourceMappingURL=cronofy.api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronofy.api.js","sourceRoot":"","sources":["../../../calendar/cronofy/cronofy.api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA8B;AAC9B,uCAAsC;AAK/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;;;;;;OAMG;IACU,kBAAkB,CAAC,QAAgB,EAAE,WAAmB;;YACjE,MAAM,OAAO,GAAG;gBACZ,IAAI,EAAE,QAAQ;gBACd,YAAY,EAAE,WAAW;aAC5B,CAAC;YACF,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;YACpE,OAAO,WAAW,CAAC;QACvB,CAAC;KAAA;IAED;;;;OAIG;IACU,mBAAmB,CAAC,KAAa;;YAC1C,MAAM,OAAO,GAAG,EAAE,KAAK,EAAE,CAAC;YAC1B,MAAM,IAAI,CAAC,QAAQ,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAAC;QACrD,CAAC;KAAA;CACJ,CAAA;AApCY,UAAU;IADtB,IAAA,qBAAU,GAAE;;GACA,UAAU,CAoCtB;AApCY,gCAAU"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CronofyAPI = void 0;
|
|
4
|
+
const cronofy_api_1 = require("./cronofy.api");
|
|
5
|
+
Object.defineProperty(exports, "CronofyAPI", { enumerable: true, get: function () { return cronofy_api_1.CronofyAPI; } });
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../calendar/cronofy/index.ts"],"names":[],"mappings":";;;AAAA,+CAA2C;AAClC,2FADA,wBAAU,OACA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronofy.config.js","sourceRoot":"","sources":["../../../../../calendar/cronofy/models/_/cronofy.config.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Cronofy Access Token data*/
|
|
2
|
+
export interface ICronofyAccessToken {
|
|
3
|
+
access_token: string;
|
|
4
|
+
token_type: 'bearer';
|
|
5
|
+
expires_in: number;
|
|
6
|
+
refresh_token: string;
|
|
7
|
+
scope: string;
|
|
8
|
+
sub: string;
|
|
9
|
+
account_id: string;
|
|
10
|
+
linking_profile: {
|
|
11
|
+
provider_name: string;
|
|
12
|
+
profile_id: string;
|
|
13
|
+
profile_name: string;
|
|
14
|
+
provider_service: string;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cronofy.data.js","sourceRoot":"","sources":["../../../../../calendar/cronofy/models/_/cronofy.data.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../calendar/cronofy/models/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientType = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Client Type enum
|
|
6
|
+
*/
|
|
7
|
+
var ClientType;
|
|
8
|
+
(function (ClientType) {
|
|
9
|
+
ClientType["Cronofy"] = "cronofy";
|
|
10
|
+
})(ClientType = exports.ClientType || (exports.ClientType = {}));
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../calendar/enum/index.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,UAEX;AAFD,WAAY,UAAU;IAClB,iCAAmB,CAAA;AACvB,CAAC,EAFW,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAErB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ClientType } from "./enum";
|
|
2
|
+
import { ICronofyConfig } from "./cronofy/models";
|
|
3
|
+
/**
|
|
4
|
+
* Calendar declarations
|
|
5
|
+
*/
|
|
6
|
+
interface ICalendar<T> {
|
|
7
|
+
client: T;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Calendar implementation
|
|
11
|
+
*/
|
|
12
|
+
export declare class Calendar<T> implements ICalendar<T> {
|
|
13
|
+
private _client;
|
|
14
|
+
private _config;
|
|
15
|
+
private _clientType;
|
|
16
|
+
/**
|
|
17
|
+
* Session constructor
|
|
18
|
+
* @param {ClientType} clientType client type
|
|
19
|
+
* @param {ICronofyConfig} config session configuration
|
|
20
|
+
*/
|
|
21
|
+
constructor(clientType: ClientType, config: ICronofyConfig);
|
|
22
|
+
/**
|
|
23
|
+
* getter for client
|
|
24
|
+
* @returns {T} client of type T
|
|
25
|
+
*/
|
|
26
|
+
get client(): T;
|
|
27
|
+
/**
|
|
28
|
+
* initialize method
|
|
29
|
+
* @returns {void} promise of type void
|
|
30
|
+
*/
|
|
31
|
+
private init;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Calendar = void 0;
|
|
13
|
+
const tsyringe_1 = require("tsyringe");
|
|
14
|
+
const enum_1 = require("./enum");
|
|
15
|
+
const cronofy_api_1 = require("./cronofy/cronofy.api");
|
|
16
|
+
/**
|
|
17
|
+
* Calendar implementation
|
|
18
|
+
*/
|
|
19
|
+
let Calendar = class Calendar {
|
|
20
|
+
/**
|
|
21
|
+
* Session constructor
|
|
22
|
+
* @param {ClientType} clientType client type
|
|
23
|
+
* @param {ICronofyConfig} config session configuration
|
|
24
|
+
*/
|
|
25
|
+
constructor(clientType, config) {
|
|
26
|
+
this._clientType = clientType;
|
|
27
|
+
this._config = config;
|
|
28
|
+
this.init();
|
|
29
|
+
}
|
|
30
|
+
// getter / setter
|
|
31
|
+
/**
|
|
32
|
+
* getter for client
|
|
33
|
+
* @returns {T} client of type T
|
|
34
|
+
*/
|
|
35
|
+
get client() {
|
|
36
|
+
return this._client;
|
|
37
|
+
}
|
|
38
|
+
// methods
|
|
39
|
+
/**
|
|
40
|
+
* initialize method
|
|
41
|
+
* @returns {void} promise of type void
|
|
42
|
+
*/
|
|
43
|
+
init() {
|
|
44
|
+
// change to switch when adding new client types
|
|
45
|
+
if (this._clientType == enum_1.ClientType.Cronofy) {
|
|
46
|
+
this._client = new cronofy_api_1.CronofyAPI(this._config);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
Calendar = __decorate([
|
|
51
|
+
(0, tsyringe_1.injectable)(),
|
|
52
|
+
__metadata("design:paramtypes", [String, Object])
|
|
53
|
+
], Calendar);
|
|
54
|
+
exports.Calendar = Calendar;
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../calendar/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uCAAsC;AACtC,iCAAoC;AAEpC,uDAAmD;AAUnD;;GAEG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAQ;IAMjB;;;;OAIG;IACH,YAAY,UAAsB,EAAE,MAAsB;QACtD,IAAI,CAAC,WAAW,GAAG,UAAU,CAAC;QAC9B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;QACtB,IAAI,CAAC,IAAI,EAAE,CAAC;IAChB,CAAC;IAED,kBAAkB;IAClB;;;OAGG;IACH,IAAW,MAAM;QACb,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,UAAU;IACV;;;OAGG;IACK,IAAI;QACR,gDAAgD;QAChD,IAAI,IAAI,CAAC,WAAW,IAAI,iBAAU,CAAC,OAAO,EAAE;YACxC,IAAI,CAAC,OAAO,GAAG,IAAI,wBAAU,CAAC,IAAI,CAAC,OAAO,CAAiB,CAAC;SAC/D;IACL,CAAC;CACJ,CAAA;AArCY,QAAQ;IADpB,IAAA,qBAAU,GAAE;;GACA,QAAQ,CAqCpB;AArCY,4BAAQ"}
|
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.58",
|
|
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",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"dependencies": {
|
|
42
42
|
"aws-lambda": "^1.0.7",
|
|
43
43
|
"axios": "^0.24.0",
|
|
44
|
+
"cronofy": "^3.8.0",
|
|
44
45
|
"crypto-js": "^4.1.1",
|
|
45
46
|
"express": "^4.17.2",
|
|
46
47
|
"guid-typescript": "^1.0.9",
|