@or-sdk/adapters 0.1.1-beta.736.0 → 0.1.1-beta.745.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 +22 -0
- package/dist/cjs/Adapters.js +85 -2
- package/dist/cjs/Adapters.js.map +1 -1
- package/dist/esm/Adapters.js +33 -2
- package/dist/esm/Adapters.js.map +1 -1
- package/dist/types/Adapters.d.ts +5 -1
- package/dist/types/Adapters.d.ts.map +1 -1
- package/dist/types/types.d.ts +2 -2
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +4 -3
- package/src/Adapters.ts +25 -3
- package/src/types.ts +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
## Installation:
|
|
2
|
+
```
|
|
3
|
+
$ npm i @or-sdk/accounts
|
|
4
|
+
```
|
|
5
|
+
|
|
6
|
+
## Usage:
|
|
7
|
+
```typescript
|
|
8
|
+
import { Adapters } from '@or-sdk/adapters'
|
|
9
|
+
|
|
10
|
+
// with direct api url
|
|
11
|
+
const adapters = new Adapters({
|
|
12
|
+
token: 'my-account-token-string',
|
|
13
|
+
eventManagerUrl: 'http://example.accounts/endpoint',
|
|
14
|
+
accountId: 'account-id-string'
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
// with service discovery(slower)
|
|
18
|
+
const adapters = new Adapters({
|
|
19
|
+
token: 'my-account-token-string',
|
|
20
|
+
discoveryUrl: 'http://example.accounts/endpoint'
|
|
21
|
+
});
|
|
22
|
+
```
|
package/dist/cjs/Adapters.js
CHANGED
|
@@ -10,21 +10,104 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
50
|
exports.Adapters = void 0;
|
|
15
51
|
var event_manager_1 = require("@or-sdk/event-manager");
|
|
52
|
+
var discovery_1 = require("@or-sdk/discovery");
|
|
16
53
|
var Adapters = (function () {
|
|
17
54
|
function Adapters(params) {
|
|
55
|
+
this._accountId = undefined;
|
|
18
56
|
var token = params.token, discoveryUrl = params.discoveryUrl, eventManagerUrl = params.eventManagerUrl, accountId = params.accountId;
|
|
19
57
|
this.eventManager = new event_manager_1.EventManager({
|
|
20
58
|
token: token,
|
|
21
59
|
discoveryUrl: discoveryUrl,
|
|
22
60
|
eventManagerUrl: eventManagerUrl,
|
|
23
61
|
});
|
|
24
|
-
this.
|
|
62
|
+
this.discovery = new discovery_1.Discovery({
|
|
63
|
+
token: token,
|
|
64
|
+
discoveryUrl: discoveryUrl,
|
|
65
|
+
});
|
|
66
|
+
this._accountId = accountId;
|
|
25
67
|
}
|
|
68
|
+
Object.defineProperty(Adapters.prototype, "accountId", {
|
|
69
|
+
get: function () {
|
|
70
|
+
return this._accountId;
|
|
71
|
+
},
|
|
72
|
+
enumerable: false,
|
|
73
|
+
configurable: true
|
|
74
|
+
});
|
|
75
|
+
Object.defineProperty(Adapters.prototype, "adaptersUrl", {
|
|
76
|
+
get: function () {
|
|
77
|
+
return this.accountId ? "/http/".concat(this.accountId) : '';
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
26
82
|
Adapters.prototype.makeRequest = function (params) {
|
|
27
|
-
return this
|
|
83
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
84
|
+
return __generator(this, function (_a) {
|
|
85
|
+
switch (_a.label) {
|
|
86
|
+
case 0:
|
|
87
|
+
if (!!this.accountId) return [3, 2];
|
|
88
|
+
return [4, this.getAccountId()];
|
|
89
|
+
case 1:
|
|
90
|
+
_a.sent();
|
|
91
|
+
_a.label = 2;
|
|
92
|
+
case 2: return [2, this.eventManager.makeRequest(__assign(__assign({}, params), { route: "".concat(this.adaptersUrl, "/").concat(params.route) }))];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
Adapters.prototype.getAccountId = function () {
|
|
98
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
99
|
+
var _a;
|
|
100
|
+
return __generator(this, function (_b) {
|
|
101
|
+
switch (_b.label) {
|
|
102
|
+
case 0:
|
|
103
|
+
_a = this;
|
|
104
|
+
return [4, this.discovery.getCurrentAccountId()];
|
|
105
|
+
case 1:
|
|
106
|
+
_a._accountId = _b.sent();
|
|
107
|
+
return [2];
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
});
|
|
28
111
|
};
|
|
29
112
|
return Adapters;
|
|
30
113
|
}());
|
package/dist/cjs/Adapters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../src/Adapters.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../src/Adapters.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,uDAAqD;AACrD,+CAA8C;AAW9C;IAYE,kBAAY,MAAsB;QAF1B,eAAU,GAAuB,SAAS,CAAC;QAGzC,IAAA,KAAK,GAA+C,MAAM,MAArD,EAAE,YAAY,GAAiC,MAAM,aAAvC,EAAE,eAAe,GAAgB,MAAM,gBAAtB,EAAE,SAAS,GAAK,MAAM,UAAX,CAAY;QAEnE,IAAI,CAAC,YAAY,GAAG,IAAI,4BAAY,CAAC;YACnC,KAAK,OAAA;YACL,YAAY,cAAA;YACZ,eAAe,iBAAA;SAChB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,qBAAS,CAAC;YAC7B,KAAK,OAAA;YACL,YAAY,cAAA;SACb,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,sBAAI,+BAAS;aAAb;YACE,OAAO,IAAI,CAAC,UAAU,CAAC;QACzB,CAAC;;;OAAA;IAED,sBAAI,iCAAW;aAAf;YACE,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAS,IAAI,CAAC,SAAS,CAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzD,CAAC;;;OAAA;IAEY,8BAAW,GAAxB,UAA4B,MAAoB;;;;;6BAC1C,CAAC,IAAI,CAAC,SAAS,EAAf,cAAe;wBACjB,WAAM,IAAI,CAAC,YAAY,EAAE,EAAA;;wBAAzB,SAAyB,CAAC;;4BAE5B,WAAO,IAAI,CAAC,YAAY,CAAC,WAAW,uBAC/B,MAAM,KACT,KAAK,EAAE,UAAG,IAAI,CAAC,WAAW,cAAI,MAAM,CAAC,KAAK,CAAE,IAC5C,EAAC;;;;KACJ;IAEa,+BAAY,GAA1B;;;;;;wBACE,KAAA,IAAI,CAAA;wBAAc,WAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,EAAA;;wBAA5D,GAAK,UAAU,GAAG,SAA0C,CAAC;;;;;KAC9D;IACH,eAAC;AAAD,CAAC,AAjDD,IAiDC;AAjDY,4BAAQ"}
|
package/dist/esm/Adapters.js
CHANGED
|
@@ -1,16 +1,47 @@
|
|
|
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
|
+
};
|
|
1
10
|
import { EventManager } from '@or-sdk/event-manager';
|
|
11
|
+
import { Discovery } from '@or-sdk/discovery';
|
|
2
12
|
export class Adapters {
|
|
3
13
|
constructor(params) {
|
|
14
|
+
this._accountId = undefined;
|
|
4
15
|
const { token, discoveryUrl, eventManagerUrl, accountId } = params;
|
|
5
16
|
this.eventManager = new EventManager({
|
|
6
17
|
token,
|
|
7
18
|
discoveryUrl,
|
|
8
19
|
eventManagerUrl,
|
|
9
20
|
});
|
|
10
|
-
this.
|
|
21
|
+
this.discovery = new Discovery({
|
|
22
|
+
token,
|
|
23
|
+
discoveryUrl,
|
|
24
|
+
});
|
|
25
|
+
this._accountId = accountId;
|
|
26
|
+
}
|
|
27
|
+
get accountId() {
|
|
28
|
+
return this._accountId;
|
|
29
|
+
}
|
|
30
|
+
get adaptersUrl() {
|
|
31
|
+
return this.accountId ? `/http/${this.accountId}` : '';
|
|
11
32
|
}
|
|
12
33
|
makeRequest(params) {
|
|
13
|
-
return this
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
if (!this.accountId) {
|
|
36
|
+
yield this.getAccountId();
|
|
37
|
+
}
|
|
38
|
+
return this.eventManager.makeRequest(Object.assign(Object.assign({}, params), { route: `${this.adaptersUrl}/${params.route}` }));
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
getAccountId() {
|
|
42
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
+
this._accountId = yield this.discovery.getCurrentAccountId();
|
|
44
|
+
});
|
|
14
45
|
}
|
|
15
46
|
}
|
|
16
47
|
//# sourceMappingURL=Adapters.js.map
|
package/dist/esm/Adapters.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../src/Adapters.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"Adapters.js","sourceRoot":"","sources":["../../src/Adapters.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAW9C,MAAM,OAAO,QAAQ;IAYnB,YAAY,MAAsB;QAF1B,eAAU,GAAuB,SAAS,CAAC;QAGjD,MAAM,EAAE,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QAEnE,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC;YACnC,KAAK;YACL,YAAY;YACZ,eAAe;SAChB,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC;YAC7B,KAAK;YACL,YAAY;SACb,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,IAAI,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,CAAC;IAEY,WAAW,CAAI,MAAoB;;YAC9C,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE;gBACnB,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;aAC3B;YACD,OAAO,IAAI,CAAC,YAAY,CAAC,WAAW,iCAC/B,MAAM,KACT,KAAK,EAAE,GAAG,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,KAAK,EAAE,IAC5C,CAAC;QACL,CAAC;KAAA;IAEa,YAAY;;YACxB,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,mBAAmB,EAAE,CAAC;QAC/D,CAAC;KAAA;CACF"}
|
package/dist/types/Adapters.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { CalApiParams } from '@or-sdk/base';
|
|
2
2
|
import { AdaptersConfig } from './types';
|
|
3
3
|
export declare class Adapters {
|
|
4
|
-
private readonly adaptersUrl;
|
|
5
4
|
private readonly eventManager;
|
|
5
|
+
private readonly discovery;
|
|
6
|
+
private _accountId;
|
|
6
7
|
constructor(params: AdaptersConfig);
|
|
8
|
+
get accountId(): string | undefined;
|
|
9
|
+
get adaptersUrl(): string;
|
|
7
10
|
makeRequest<T>(params: CalApiParams): Promise<T>;
|
|
11
|
+
private getAccountId;
|
|
8
12
|
}
|
|
9
13
|
//# sourceMappingURL=Adapters.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Adapters.d.ts","sourceRoot":"","sources":["../../src/Adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Adapters.d.ts","sourceRoot":"","sources":["../../src/Adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AASzC,qBAAa,QAAQ;IAQnB,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAe;IAC5C,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IACtC,OAAO,CAAC,UAAU,CAAiC;gBAEvC,MAAM,EAAE,cAAc;IAgBlC,IAAI,SAAS,uBAEZ;IAED,IAAI,WAAW,WAEd;IAEY,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC;YAU/C,YAAY;CAG3B"}
|
package/dist/types/types.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,cAAc,GAAG;IAI3B,KAAK,EAAE,KAAK,CAAC;IAIb,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,eAAe,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,cAAc,GAAG;IAI3B,KAAK,EAAE,KAAK,CAAC;IAIb,YAAY,CAAC,EAAE,MAAM,CAAC;IAItB,eAAe,CAAC,EAAE,MAAM,CAAC;IAEzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "0.1.1-beta.
|
|
2
|
+
"version": "0.1.1-beta.745.0",
|
|
3
3
|
"name": "@or-sdk/adapters",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@or-sdk/base": "
|
|
28
|
-
"@or-sdk/
|
|
27
|
+
"@or-sdk/base": "0.27.0",
|
|
28
|
+
"@or-sdk/discovery": "^1.5.1-beta.745.0",
|
|
29
|
+
"@or-sdk/event-manager": "^0.24.7"
|
|
29
30
|
}
|
|
30
31
|
}
|
package/src/Adapters.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { CalApiParams } from '@or-sdk/base';
|
|
2
2
|
import { EventManager } from '@or-sdk/event-manager';
|
|
3
|
+
import { Discovery } from '@or-sdk/discovery';
|
|
4
|
+
|
|
3
5
|
import { AdaptersConfig } from './types';
|
|
4
6
|
|
|
5
7
|
/**
|
|
@@ -17,8 +19,9 @@ export class Adapters {
|
|
|
17
19
|
* ```
|
|
18
20
|
*/
|
|
19
21
|
|
|
20
|
-
private readonly adaptersUrl: string;
|
|
21
22
|
private readonly eventManager: EventManager;
|
|
23
|
+
private readonly discovery: Discovery;
|
|
24
|
+
private _accountId: string | undefined = undefined;
|
|
22
25
|
|
|
23
26
|
constructor(params: AdaptersConfig) {
|
|
24
27
|
const { token, discoveryUrl, eventManagerUrl, accountId } = params;
|
|
@@ -28,14 +31,33 @@ export class Adapters {
|
|
|
28
31
|
discoveryUrl,
|
|
29
32
|
eventManagerUrl,
|
|
30
33
|
});
|
|
34
|
+
this.discovery = new Discovery({
|
|
35
|
+
token,
|
|
36
|
+
discoveryUrl,
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
this._accountId = accountId;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
get accountId() {
|
|
43
|
+
return this._accountId;
|
|
44
|
+
}
|
|
31
45
|
|
|
32
|
-
|
|
46
|
+
get adaptersUrl() {
|
|
47
|
+
return this.accountId ? `/http/${this.accountId}` : '';
|
|
33
48
|
}
|
|
34
49
|
|
|
35
|
-
public makeRequest<T>(params: CalApiParams): Promise<T> {
|
|
50
|
+
public async makeRequest<T>(params: CalApiParams): Promise<T> {
|
|
51
|
+
if (!this.accountId) {
|
|
52
|
+
await this.getAccountId();
|
|
53
|
+
}
|
|
36
54
|
return this.eventManager.makeRequest({
|
|
37
55
|
...params,
|
|
38
56
|
route: `${this.adaptersUrl}/${params.route}`,
|
|
39
57
|
});
|
|
40
58
|
}
|
|
59
|
+
|
|
60
|
+
private async getAccountId(): Promise<void> {
|
|
61
|
+
this._accountId = await this.discovery.getCurrentAccountId();
|
|
62
|
+
}
|
|
41
63
|
}
|