@or-sdk/invitations 1.1.0-beta.2601.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/CHANGELOG.md +4 -0
- package/README.md +14 -0
- package/dist/cjs/Invitations.js +140 -0
- package/dist/cjs/Invitations.js.map +1 -0
- package/dist/cjs/constants.js +5 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/types.js +3 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/esm/Invitations.js +67 -0
- package/dist/esm/Invitations.js.map +1 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/index.js +3 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/types.js +2 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/types/Invitations.d.ts +10 -0
- package/dist/types/Invitations.d.ts.map +1 -0
- package/dist/types/constants.d.ts +2 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/types.d.ts +32 -0
- package/dist/types/types.d.ts.map +1 -0
- package/package.json +29 -0
- package/src/Invitations.ts +77 -0
- package/src/constants.ts +1 -0
- package/src/index.ts +2 -0
- package/src/types.ts +42 -0
- package/tsconfig.dev.json +8 -0
- package/tsconfig.esm.json +12 -0
- package/tsconfig.json +7 -0
- package/tsconfig.types.json +10 -0
package/CHANGELOG.md
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Installation:
|
|
2
|
+
```
|
|
3
|
+
$ npm i @or-sdk/invitations
|
|
4
|
+
```
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
## Usage:
|
|
8
|
+
```typescript
|
|
9
|
+
import { Invitations } from '@or-sdk/invitations'
|
|
10
|
+
|
|
11
|
+
const invitationsApi = new Invitations({
|
|
12
|
+
token: 'my-account-token-string',
|
|
13
|
+
usersUrl: 'http://example.usersApi]/endpoint'
|
|
14
|
+
});
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
+
function step(op) {
|
|
31
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
33
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
+
switch (op[0]) {
|
|
36
|
+
case 0: case 1: t = op; break;
|
|
37
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
+
default:
|
|
41
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
+
if (t[2]) _.ops.pop();
|
|
46
|
+
_.trys.pop(); continue;
|
|
47
|
+
}
|
|
48
|
+
op = body.call(thisArg, _);
|
|
49
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.Invitations = void 0;
|
|
55
|
+
var base_1 = require("@or-sdk/base");
|
|
56
|
+
var constants_1 = require("./constants");
|
|
57
|
+
var Invitations = (function (_super) {
|
|
58
|
+
__extends(Invitations, _super);
|
|
59
|
+
function Invitations(params) {
|
|
60
|
+
var token = params.token, usersUrl = params.usersUrl, discoveryUrl = params.discoveryUrl;
|
|
61
|
+
return _super.call(this, {
|
|
62
|
+
token: token,
|
|
63
|
+
serviceUrl: usersUrl,
|
|
64
|
+
serviceKey: constants_1.SERVICE_KEY,
|
|
65
|
+
discoveryUrl: discoveryUrl,
|
|
66
|
+
}) || this;
|
|
67
|
+
}
|
|
68
|
+
Invitations.prototype.createInvitation = function (payload) {
|
|
69
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
70
|
+
var data;
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
switch (_a.label) {
|
|
73
|
+
case 0: return [4, this.callApiV2({
|
|
74
|
+
method: 'POST',
|
|
75
|
+
route: '/invitation',
|
|
76
|
+
data: payload,
|
|
77
|
+
})];
|
|
78
|
+
case 1:
|
|
79
|
+
data = _a.sent();
|
|
80
|
+
return [2, data];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
85
|
+
Invitations.prototype.listInvitations = function (params) {
|
|
86
|
+
if (params === void 0) { params = {}; }
|
|
87
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
88
|
+
var _a, from, size, orderDirection, orderProperty, query, data;
|
|
89
|
+
return __generator(this, function (_b) {
|
|
90
|
+
switch (_b.label) {
|
|
91
|
+
case 0:
|
|
92
|
+
_a = params.from, from = _a === void 0 ? 0 : _a, size = params.size, orderDirection = params.orderDirection, orderProperty = params.orderProperty, query = params.query;
|
|
93
|
+
return [4, this.callApiV2({
|
|
94
|
+
method: 'GET',
|
|
95
|
+
route: '/invitations',
|
|
96
|
+
params: {
|
|
97
|
+
from: from,
|
|
98
|
+
size: size,
|
|
99
|
+
orderDirection: orderDirection,
|
|
100
|
+
orderProperty: orderProperty,
|
|
101
|
+
query: query,
|
|
102
|
+
},
|
|
103
|
+
})];
|
|
104
|
+
case 1:
|
|
105
|
+
data = _b.sent();
|
|
106
|
+
return [2, data];
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
};
|
|
111
|
+
Invitations.prototype.approveInvitation = function (invitationId, payload) {
|
|
112
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
113
|
+
return __generator(this, function (_a) {
|
|
114
|
+
return [2, this.callApiV2({
|
|
115
|
+
method: 'PUT',
|
|
116
|
+
route: "/invitation/approve/".concat(invitationId),
|
|
117
|
+
data: payload,
|
|
118
|
+
})];
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
Invitations.prototype.deleteInvitation = function (invitationId) {
|
|
123
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
switch (_a.label) {
|
|
126
|
+
case 0: return [4, this.callApiV2({
|
|
127
|
+
method: 'DELETE',
|
|
128
|
+
route: "/invitation/".concat(invitationId),
|
|
129
|
+
})];
|
|
130
|
+
case 1:
|
|
131
|
+
_a.sent();
|
|
132
|
+
return [2];
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
return Invitations;
|
|
138
|
+
}(base_1.Base));
|
|
139
|
+
exports.Invitations = Invitations;
|
|
140
|
+
//# sourceMappingURL=Invitations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invitations.js","sourceRoot":"","sources":["../../src/Invitations.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAoC;AAQpC,yCAA0C;AAS1C;IAAiC,+BAAI;IAOnC,qBAAY,MAAyB;QAC3B,IAAA,KAAK,GAA6B,MAAM,MAAnC,EAAE,QAAQ,GAAmB,MAAM,SAAzB,EAAE,YAAY,GAAK,MAAM,aAAX,CAAY;eACjD,kBAAM;YACJ,KAAK,OAAA;YACL,UAAU,EAAE,QAAQ;YACpB,UAAU,EAAE,uBAAW;YACvB,YAAY,cAAA;SACb,CAAC;IACJ,CAAC;IAEY,sCAAgB,GAA7B,UAA8B,OAAgC;;;;;4BAC/C,WAAM,IAAI,CAAC,SAAS,CAAqB;4BACpD,MAAM,EAAE,MAAM;4BACd,KAAK,EAAE,aAAa;4BACpB,IAAI,EAAE,OAAO;yBACd,CAAC,EAAA;;wBAJI,IAAI,GAAG,SAIX;wBACF,WAAO,IAAI,EAAC;;;;KACb;IAEY,qCAAe,GAA5B,UAA6B,MAAoC;QAApC,uBAAA,EAAA,SAAS,EAA2B;;;;;;wBACvD,KAAyD,MAAM,KAAvD,EAAR,IAAI,mBAAG,CAAC,KAAA,EAAE,IAAI,GAA2C,MAAM,KAAjD,EAAE,cAAc,GAA2B,MAAM,eAAjC,EAAE,aAAa,GAAY,MAAM,cAAlB,EAAE,KAAK,GAAK,MAAM,MAAX,CAAY;wBAC3D,WAAM,IAAI,CAAC,SAAS,CAAuB;gCACtD,MAAM,EAAE,KAAK;gCACb,KAAK,EAAE,cAAc;gCACrB,MAAM,EAAE;oCACN,IAAI,MAAA;oCACJ,IAAI,MAAA;oCACJ,cAAc,gBAAA;oCACd,aAAa,eAAA;oCACb,KAAK,OAAA;iCACN;6BACF,CAAC,EAAA;;wBAVI,IAAI,GAAG,SAUX;wBACF,WAAO,IAAI,EAAC;;;;KACb;IAEY,uCAAiB,GAA9B,UACE,YAAoB,EACpB,OAAiC;;;gBAEjC,WAAO,IAAI,CAAC,SAAS,CAAC;wBACpB,MAAM,EAAE,KAAK;wBACb,KAAK,EAAE,8BAAuB,YAAY,CAAE;wBAC5C,IAAI,EAAE,OAAO;qBACd,CAAC,EAAC;;;KACJ;IAEY,sCAAgB,GAA7B,UAA8B,YAAoB;;;;4BAChD,WAAM,IAAI,CAAC,SAAS,CAAC;4BACnB,MAAM,EAAE,QAAQ;4BAChB,KAAK,EAAE,sBAAe,YAAY,CAAE;yBACrC,CAAC,EAAA;;wBAHF,SAGE,CAAC;;;;;KACJ;IACH,kBAAC;AAAD,CAAC,AA3DD,CAAiC,WAAI,GA2DpC;AA3DY,kCAAW"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,WAAW,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Invitations = void 0;
|
|
18
|
+
var Invitations_1 = require("./Invitations");
|
|
19
|
+
Object.defineProperty(exports, "Invitations", { enumerable: true, get: function () { return Invitations_1.Invitations; } });
|
|
20
|
+
__exportStar(require("./types"), exports);
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,0CAAwB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Base } from '@or-sdk/base';
|
|
11
|
+
import { SERVICE_KEY } from './constants';
|
|
12
|
+
export class Invitations extends Base {
|
|
13
|
+
constructor(params) {
|
|
14
|
+
const { token, usersUrl, discoveryUrl } = params;
|
|
15
|
+
super({
|
|
16
|
+
token,
|
|
17
|
+
serviceUrl: usersUrl,
|
|
18
|
+
serviceKey: SERVICE_KEY,
|
|
19
|
+
discoveryUrl,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
createInvitation(payload) {
|
|
23
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const data = yield this.callApiV2({
|
|
25
|
+
method: 'POST',
|
|
26
|
+
route: '/invitation',
|
|
27
|
+
data: payload,
|
|
28
|
+
});
|
|
29
|
+
return data;
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
listInvitations(params = {}) {
|
|
33
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
+
const { from = 0, size, orderDirection, orderProperty, query } = params;
|
|
35
|
+
const data = yield this.callApiV2({
|
|
36
|
+
method: 'GET',
|
|
37
|
+
route: '/invitations',
|
|
38
|
+
params: {
|
|
39
|
+
from,
|
|
40
|
+
size,
|
|
41
|
+
orderDirection,
|
|
42
|
+
orderProperty,
|
|
43
|
+
query,
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
return data;
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
approveInvitation(invitationId, payload) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return this.callApiV2({
|
|
52
|
+
method: 'PUT',
|
|
53
|
+
route: `/invitation/approve/${invitationId}`,
|
|
54
|
+
data: payload,
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
deleteInvitation(invitationId) {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
+
yield this.callApiV2({
|
|
61
|
+
method: 'DELETE',
|
|
62
|
+
route: `/invitation/${invitationId}`,
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=Invitations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invitations.js","sourceRoot":"","sources":["../../src/Invitations.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAQpC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAS1C,MAAM,OAAO,WAAY,SAAQ,IAAI;IAOnC,YAAY,MAAyB;QACnC,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;QACjD,KAAK,CAAC;YACJ,KAAK;YACL,UAAU,EAAE,QAAQ;YACpB,UAAU,EAAE,WAAW;YACvB,YAAY;SACb,CAAC,CAAC;IACL,CAAC;IAEY,gBAAgB,CAAC,OAAgC;;YAC5D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAqB;gBACpD,MAAM,EAAE,MAAM;gBACd,KAAK,EAAE,aAAa;gBACpB,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEY,eAAe,CAAC,SAAS,EAA2B;;YAC/D,MAAM,EAAE,IAAI,GAAG,CAAC,EAAE,IAAI,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,GAAG,MAAM,CAAC;YACxE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,SAAS,CAAuB;gBACtD,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,cAAc;gBACrB,MAAM,EAAE;oBACN,IAAI;oBACJ,IAAI;oBACJ,cAAc;oBACd,aAAa;oBACb,KAAK;iBACN;aACF,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;KAAA;IAEY,iBAAiB,CAC5B,YAAoB,EACpB,OAAiC;;YAEjC,OAAO,IAAI,CAAC,SAAS,CAAC;gBACpB,MAAM,EAAE,KAAK;gBACb,KAAK,EAAE,uBAAuB,YAAY,EAAE;gBAC5C,IAAI,EAAE,OAAO;aACd,CAAC,CAAC;QACL,CAAC;KAAA;IAEY,gBAAgB,CAAC,YAAoB;;YAChD,MAAM,IAAI,CAAC,SAAS,CAAC;gBACnB,MAAM,EAAE,QAAQ;gBAChB,KAAK,EAAE,eAAe,YAAY,EAAE;aACrC,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,iBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Base } from '@or-sdk/base';
|
|
2
|
+
import { InvitationsConfig, InvitationCreatePayload, InvitationResponse, ApproveInvitationPayload, ListInvitationsParams } from './types';
|
|
3
|
+
export declare class Invitations extends Base {
|
|
4
|
+
constructor(params: InvitationsConfig);
|
|
5
|
+
createInvitation(payload: InvitationCreatePayload): Promise<InvitationResponse>;
|
|
6
|
+
listInvitations(params?: ListInvitationsParams): Promise<InvitationResponse[]>;
|
|
7
|
+
approveInvitation(invitationId: string, payload: ApproveInvitationPayload): Promise<InvitationResponse>;
|
|
8
|
+
deleteInvitation(invitationId: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=Invitations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Invitations.d.ts","sourceRoot":"","sources":["../../src/Invitations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EACL,iBAAiB,EACjB,uBAAuB,EACvB,kBAAkB,EAClB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,SAAS,CAAC;AAUjB,qBAAa,WAAY,SAAQ,IAAI;gBAOvB,MAAM,EAAE,iBAAiB;IAUxB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAS/E,eAAe,CAAC,MAAM,wBAA8B,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAgBpF,iBAAiB,CAC5B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,kBAAkB,CAAC;IAQjB,gBAAgB,CAAC,YAAY,EAAE,MAAM;CAMnD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
export type InvitationsConfig = {
|
|
3
|
+
token: Token;
|
|
4
|
+
usersUrl: string;
|
|
5
|
+
discoveryUrl?: string;
|
|
6
|
+
};
|
|
7
|
+
export type InvitationCreatePayload = {
|
|
8
|
+
accountId: string;
|
|
9
|
+
email: string;
|
|
10
|
+
};
|
|
11
|
+
export type InvitationResponse = {
|
|
12
|
+
id: string;
|
|
13
|
+
accountId: string;
|
|
14
|
+
email: string;
|
|
15
|
+
createdBy: string;
|
|
16
|
+
dateCreated: Date;
|
|
17
|
+
dateModified: Date;
|
|
18
|
+
};
|
|
19
|
+
export type ApproveInvitationPayload = {
|
|
20
|
+
role: string;
|
|
21
|
+
permissions?: {
|
|
22
|
+
scope: string[];
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type ListInvitationsParams = {
|
|
26
|
+
from?: number;
|
|
27
|
+
size?: number;
|
|
28
|
+
orderDirection?: 'asc' | 'desc';
|
|
29
|
+
orderProperty?: string;
|
|
30
|
+
query?: string;
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,MAAM,MAAM,iBAAiB,GAAG;IAI9B,KAAK,EAAE,KAAK,CAAC;IAIb,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,IAAI,CAAC;IAClB,YAAY,EAAE,IAAI,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,CAAC,EAAE;QACZ,KAAK,EAAE,MAAM,EAAE,CAAC;KACjB,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1.1.0-beta.2601.0",
|
|
3
|
+
"name": "@or-sdk/invitations",
|
|
4
|
+
"main": "dist/cjs/index.js",
|
|
5
|
+
"module": "dist/esm/index.js",
|
|
6
|
+
"types": "dist/types/index.d.ts",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "pnpm clean && pnpm build:esm && pnpm build:cjs",
|
|
9
|
+
"build:cjs": "tsc --project tsconfig.json",
|
|
10
|
+
"build:esm": "tsc --project tsconfig.esm.json",
|
|
11
|
+
"build:types": "tsc --project tsconfig.types.json",
|
|
12
|
+
"build:watch": "concurrently -r --hide 1,2 \"pnpm build:watch:cjs\" \"pnpm build:watch:esm\" \"pnpm build:watch:types\"",
|
|
13
|
+
"build:watch:cjs": "tsc --project tsconfig.json -w",
|
|
14
|
+
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
15
|
+
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
|
+
"clean": "rm -rf ./dist",
|
|
17
|
+
"dev": "pnpm build:watch:esm"
|
|
18
|
+
},
|
|
19
|
+
"devDependencies": {
|
|
20
|
+
"concurrently": "^6.4.0",
|
|
21
|
+
"typescript": "^4.4.4"
|
|
22
|
+
},
|
|
23
|
+
"publishConfig": {
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@or-sdk/base": "^0.32.0"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Base } from '@or-sdk/base';
|
|
2
|
+
import {
|
|
3
|
+
InvitationsConfig,
|
|
4
|
+
InvitationCreatePayload,
|
|
5
|
+
InvitationResponse,
|
|
6
|
+
ApproveInvitationPayload,
|
|
7
|
+
ListInvitationsParams,
|
|
8
|
+
} from './types';
|
|
9
|
+
import { SERVICE_KEY } from './constants';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* OneReach Invitations service client
|
|
13
|
+
* ## Installation:
|
|
14
|
+
* ```
|
|
15
|
+
* $ npm i @or-sdk/invitations
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export class Invitations extends Base {
|
|
19
|
+
/**
|
|
20
|
+
* ```typescript
|
|
21
|
+
* import { Invitations } from '@or-sdk/invitations'
|
|
22
|
+
* const invitations = new Invitations({token: 'my-account-token-string', discoveryUrl: 'http://example.tables/endpoint'});
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
constructor(params: InvitationsConfig) {
|
|
26
|
+
const { token, usersUrl, discoveryUrl } = params;
|
|
27
|
+
super({
|
|
28
|
+
token,
|
|
29
|
+
serviceUrl: usersUrl,
|
|
30
|
+
serviceKey: SERVICE_KEY,
|
|
31
|
+
discoveryUrl,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
public async createInvitation(payload: InvitationCreatePayload): Promise<InvitationResponse> {
|
|
36
|
+
const data = await this.callApiV2<InvitationResponse>({
|
|
37
|
+
method: 'POST',
|
|
38
|
+
route: '/invitation',
|
|
39
|
+
data: payload,
|
|
40
|
+
});
|
|
41
|
+
return data;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public async listInvitations(params = {} as ListInvitationsParams): Promise<InvitationResponse[]> {
|
|
45
|
+
const { from = 0, size, orderDirection, orderProperty, query } = params;
|
|
46
|
+
const data = await this.callApiV2<InvitationResponse[]>({
|
|
47
|
+
method: 'GET',
|
|
48
|
+
route: '/invitations',
|
|
49
|
+
params: {
|
|
50
|
+
from,
|
|
51
|
+
size,
|
|
52
|
+
orderDirection,
|
|
53
|
+
orderProperty,
|
|
54
|
+
query,
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public async approveInvitation(
|
|
61
|
+
invitationId: string,
|
|
62
|
+
payload: ApproveInvitationPayload
|
|
63
|
+
): Promise<InvitationResponse> {
|
|
64
|
+
return this.callApiV2({
|
|
65
|
+
method: 'PUT',
|
|
66
|
+
route: `/invitation/approve/${invitationId}`,
|
|
67
|
+
data: payload,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public async deleteInvitation(invitationId: string) {
|
|
72
|
+
await this.callApiV2({
|
|
73
|
+
method: 'DELETE',
|
|
74
|
+
route: `/invitation/${invitationId}`,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
}
|
package/src/constants.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const SERVICE_KEY = 'invitations-api';
|
package/src/index.ts
ADDED
package/src/types.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Token } from '@or-sdk/base';
|
|
2
|
+
|
|
3
|
+
export type InvitationsConfig = {
|
|
4
|
+
/**
|
|
5
|
+
* token
|
|
6
|
+
*/
|
|
7
|
+
token: Token;
|
|
8
|
+
/**
|
|
9
|
+
* function which return token
|
|
10
|
+
*/
|
|
11
|
+
usersUrl: string;
|
|
12
|
+
discoveryUrl?: string;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export type InvitationCreatePayload = {
|
|
16
|
+
accountId: string;
|
|
17
|
+
email: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export type InvitationResponse = {
|
|
21
|
+
id: string;
|
|
22
|
+
accountId: string;
|
|
23
|
+
email: string;
|
|
24
|
+
createdBy: string;
|
|
25
|
+
dateCreated: Date;
|
|
26
|
+
dateModified: Date;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ApproveInvitationPayload = {
|
|
30
|
+
role: string;
|
|
31
|
+
permissions?: {
|
|
32
|
+
scope: string[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type ListInvitationsParams = {
|
|
37
|
+
from?: number;
|
|
38
|
+
size?: number;
|
|
39
|
+
orderDirection?: 'asc' | 'desc';
|
|
40
|
+
orderProperty?: string;
|
|
41
|
+
query?: string;
|
|
42
|
+
};
|
package/tsconfig.json
ADDED