@or-sdk/identifiers 0.25.0-beta.848.0 → 0.25.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 +129 -0
- package/dist/cjs/__tests__/identifiers.spec.js +44 -0
- package/dist/cjs/__tests__/identifiers.spec.js.map +1 -0
- package/dist/cjs/constants.js +1 -2
- package/dist/cjs/constants.js.map +1 -1
- package/dist/cjs/identifiers.errors.js +46 -0
- package/dist/cjs/identifiers.errors.js.map +1 -0
- package/dist/cjs/{Identifiers.js → identifiers.js} +52 -82
- package/dist/cjs/identifiers.js.map +1 -0
- package/dist/cjs/index.js +2 -2
- package/dist/esm/__tests__/identifiers.spec.js +43 -0
- package/dist/esm/__tests__/identifiers.spec.js.map +1 -0
- package/dist/esm/constants.js +0 -1
- package/dist/esm/constants.js.map +1 -1
- package/dist/esm/identifiers.errors.js +19 -0
- package/dist/esm/identifiers.errors.js.map +1 -0
- package/dist/esm/{Identifiers.js → identifiers.js} +46 -58
- package/dist/esm/identifiers.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/types/__tests__/identifiers.spec.d.ts +2 -0
- package/dist/types/__tests__/identifiers.spec.d.ts.map +1 -0
- package/dist/types/constants.d.ts +0 -1
- package/dist/types/constants.d.ts.map +1 -1
- package/dist/types/{Identifiers.d.ts → identifiers.d.ts} +8 -10
- package/dist/types/identifiers.d.ts.map +1 -0
- package/dist/types/identifiers.errors.d.ts +13 -0
- package/dist/types/identifiers.errors.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/types.d.ts +9 -24
- package/dist/types/types.d.ts.map +1 -1
- package/package.json +12 -6
- package/src/__tests__/identifiers.spec.ts +59 -0
- package/src/constants.ts +0 -1
- package/src/identifiers.errors.ts +20 -0
- package/src/identifiers.ts +338 -0
- package/src/index.ts +1 -1
- package/src/types.ts +20 -42
- package/vitest.config.js +24 -0
- package/dist/cjs/Identifiers.js.map +0 -1
- package/dist/esm/Identifiers.js.map +0 -1
- package/dist/types/Identifiers.d.ts.map +0 -1
- package/src/Identifiers.ts +0 -270
|
@@ -7,21 +7,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import {
|
|
10
|
+
import { makeList } from '@or-sdk/base';
|
|
11
11
|
import { SdkApi } from '@or-sdk/sdk-api';
|
|
12
|
-
import { SERVICE_KEY } from './constants';
|
|
13
12
|
import { extractIdentifierProvidersResponse, getGroupIdentifiers, getSingleIdentifiers, makeIdentifierGroups, } from './utils';
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
import { SdkUrlOrDiscoveryUrlIsMissedError, TokenIsMissedError } from './identifiers.errors';
|
|
15
|
+
export class Identifiers {
|
|
16
|
+
constructor(config) {
|
|
17
|
+
const { token, sdkUrl, discoveryUrl, accountId, } = config;
|
|
18
|
+
if (_.isEmpty(sdkUrl) && _.isEmpty(discoveryUrl)) {
|
|
19
|
+
throw new SdkUrlOrDiscoveryUrlIsMissedError();
|
|
20
|
+
}
|
|
21
|
+
if (_.isEmpty(token)) {
|
|
22
|
+
throw new TokenIsMissedError();
|
|
23
|
+
}
|
|
24
|
+
this._sdkApi = new SdkApi({
|
|
25
25
|
token,
|
|
26
26
|
discoveryUrl,
|
|
27
27
|
accountId,
|
|
@@ -30,34 +30,24 @@ export class Identifiers extends Base {
|
|
|
30
30
|
}
|
|
31
31
|
init() {
|
|
32
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
yield this.
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
fetchIdentifiers(id, groupDetails = true) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
const params = Object.assign({ fullInfo: true, groupDetails, identifier: id ? id : undefined }, this.sdkApi.isCrossAccount ? { accountId: this.sdkApi.currentAccountId } : {});
|
|
39
|
-
return this.sdkApi.makeRequest({
|
|
40
|
-
method: 'GET',
|
|
41
|
-
route: '/http/provider/identifiers',
|
|
42
|
-
params,
|
|
43
|
-
});
|
|
33
|
+
yield this._sdkApi.init();
|
|
44
34
|
});
|
|
45
35
|
}
|
|
46
36
|
listIdentifiers() {
|
|
47
37
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
const result = yield this.
|
|
38
|
+
const result = yield this._fetchIdentifiers();
|
|
49
39
|
return makeList(getSingleIdentifiers(result));
|
|
50
40
|
});
|
|
51
41
|
}
|
|
52
42
|
listIdentifierGroups() {
|
|
53
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
54
|
-
const result = yield this.
|
|
44
|
+
const result = yield this._fetchIdentifiers();
|
|
55
45
|
return makeList(makeIdentifierGroups(result));
|
|
56
46
|
});
|
|
57
47
|
}
|
|
58
48
|
getIdentifier(id) {
|
|
59
49
|
return __awaiter(this, void 0, void 0, function* () {
|
|
60
|
-
const result = yield this.
|
|
50
|
+
const result = yield this._fetchIdentifiers(id, false);
|
|
61
51
|
const singleIdentifiers = getSingleIdentifiers(result);
|
|
62
52
|
if (singleIdentifiers.length === 0) {
|
|
63
53
|
throw `Id ${id} doesn't belong to an identifier`;
|
|
@@ -67,7 +57,7 @@ export class Identifiers extends Base {
|
|
|
67
57
|
}
|
|
68
58
|
getIdentifierGroup(id) {
|
|
69
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const result = yield this.
|
|
60
|
+
const result = yield this._fetchIdentifiers(id);
|
|
71
61
|
const groupIdentifiers = getGroupIdentifiers(result);
|
|
72
62
|
if (groupIdentifiers.length === 0) {
|
|
73
63
|
throw `Id ${id} doesn't belong to an identifier group`;
|
|
@@ -77,18 +67,18 @@ export class Identifiers extends Base {
|
|
|
77
67
|
}
|
|
78
68
|
listObtainableIdentifiers(params = {}) {
|
|
79
69
|
return __awaiter(this, void 0, void 0, function* () {
|
|
80
|
-
const result = yield this.
|
|
70
|
+
const result = yield this._sdkApi.makeRequest({
|
|
81
71
|
method: 'GET',
|
|
82
72
|
route: '/http/provider/obtainable-identifiers',
|
|
83
|
-
params: Object.assign(Object.assign({}, params), this.
|
|
73
|
+
params: Object.assign(Object.assign({}, params), this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {}),
|
|
84
74
|
});
|
|
85
75
|
return makeList(result);
|
|
86
76
|
});
|
|
87
77
|
}
|
|
88
78
|
releaseIdentifier(id) {
|
|
89
79
|
return __awaiter(this, void 0, void 0, function* () {
|
|
90
|
-
const params = Object.assign({ identifier: id }, this.
|
|
91
|
-
yield this.
|
|
80
|
+
const params = Object.assign({ identifier: id }, this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {});
|
|
81
|
+
yield this._sdkApi.makeRequest({
|
|
92
82
|
method: 'DELETE',
|
|
93
83
|
route: '/http/provider/identifiers',
|
|
94
84
|
params,
|
|
@@ -97,8 +87,8 @@ export class Identifiers extends Base {
|
|
|
97
87
|
}
|
|
98
88
|
buyIdentifier(identifiers) {
|
|
99
89
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
|
-
const data = Object.assign({ identifiers: Array.isArray(identifiers) ? identifiers : [identifiers] }, this.
|
|
101
|
-
return this.
|
|
90
|
+
const data = Object.assign({ identifiers: Array.isArray(identifiers) ? identifiers : [identifiers] }, this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {});
|
|
91
|
+
return this._sdkApi.makeRequest({
|
|
102
92
|
method: 'POST',
|
|
103
93
|
route: '/http/provider/identifiers',
|
|
104
94
|
data,
|
|
@@ -108,8 +98,8 @@ export class Identifiers extends Base {
|
|
|
108
98
|
createProvider(provider, settings = {}) {
|
|
109
99
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
100
|
const data = Object.assign({ provider,
|
|
111
|
-
settings }, this.
|
|
112
|
-
yield this.
|
|
101
|
+
settings }, this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {});
|
|
102
|
+
yield this._sdkApi.makeRequest({
|
|
113
103
|
method: 'POST',
|
|
114
104
|
route: '/http/provider/identifier-providers',
|
|
115
105
|
data,
|
|
@@ -118,8 +108,8 @@ export class Identifiers extends Base {
|
|
|
118
108
|
}
|
|
119
109
|
listProviders() {
|
|
120
110
|
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
-
const params = this.
|
|
122
|
-
const data = yield this.
|
|
111
|
+
const params = this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {};
|
|
112
|
+
const data = yield this._sdkApi.makeRequest({
|
|
123
113
|
method: 'GET',
|
|
124
114
|
route: '/http/provider/identifier-providers',
|
|
125
115
|
params,
|
|
@@ -129,40 +119,38 @@ export class Identifiers extends Base {
|
|
|
129
119
|
}
|
|
130
120
|
deleteProvider(provider) {
|
|
131
121
|
return __awaiter(this, void 0, void 0, function* () {
|
|
132
|
-
const params = Object.assign({ provider }, this.
|
|
133
|
-
yield this.
|
|
122
|
+
const params = Object.assign({ provider }, this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {});
|
|
123
|
+
yield this._sdkApi.makeRequest({
|
|
134
124
|
method: 'DELETE',
|
|
135
125
|
route: '/http/provider/identifier-providers',
|
|
136
126
|
params,
|
|
137
127
|
});
|
|
138
128
|
});
|
|
139
129
|
}
|
|
140
|
-
|
|
130
|
+
listIdentifiersTriggers(identifiers) {
|
|
141
131
|
return __awaiter(this, void 0, void 0, function* () {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return this.callApiV2({
|
|
152
|
-
route: `/identifiers/${encodeURIComponent(data.name)}`,
|
|
153
|
-
method: 'delete',
|
|
132
|
+
const ids = _.chain(identifiers.items)
|
|
133
|
+
.reject('group')
|
|
134
|
+
.map('id')
|
|
135
|
+
.value();
|
|
136
|
+
const data = Object.assign({ identifiers: ids }, this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {});
|
|
137
|
+
console.warn('data', data);
|
|
138
|
+
return this._sdkApi.makeRequest({
|
|
139
|
+
method: 'POST',
|
|
140
|
+
route: '/http/provider/get-identifiers-triggers',
|
|
154
141
|
data,
|
|
155
142
|
});
|
|
156
143
|
});
|
|
157
144
|
}
|
|
158
|
-
|
|
145
|
+
_fetchIdentifiers(id, groupDetails = true) {
|
|
159
146
|
return __awaiter(this, void 0, void 0, function* () {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
method: '
|
|
147
|
+
const params = Object.assign({ fullInfo: true, groupDetails, identifier: id ? id : undefined }, this._sdkApi.isCrossAccount ? { accountId: this._sdkApi.currentAccountId } : {});
|
|
148
|
+
return this._sdkApi.makeRequest({
|
|
149
|
+
method: 'GET',
|
|
150
|
+
route: '/http/provider/identifiers',
|
|
163
151
|
params,
|
|
164
152
|
});
|
|
165
153
|
});
|
|
166
154
|
}
|
|
167
155
|
}
|
|
168
|
-
//# sourceMappingURL=
|
|
156
|
+
//# sourceMappingURL=identifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.js","sourceRoot":"","sources":["../../src/identifiers.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAQ,QAAQ,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAezC,OAAO,EACL,kCAAkC,EAClC,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AACjB,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,iCAAiC,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAA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4B;gBACnC,MAAM;aACP,CAAC,CAAC;QACL,CAAC;KAAA;CACF"}
|
package/dist/esm/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/identifiers.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BuyIdentifierResponse,
|
|
3
|
-
export declare class Identifiers
|
|
4
|
-
private readonly
|
|
5
|
-
constructor(
|
|
1
|
+
import { List } from '@or-sdk/base';
|
|
2
|
+
import { BuyIdentifierResponse, Identifier, IdentifierGroup, IdentifierProvider, IdentifiersConfig, IdentifierTrigger, ObtainableIdentifier, ObtainableIdentifierRequestParams, SingleIdentifier } from './types';
|
|
3
|
+
export declare class Identifiers {
|
|
4
|
+
private readonly _sdkApi;
|
|
5
|
+
constructor(config: IdentifiersConfig);
|
|
6
6
|
init(): Promise<void>;
|
|
7
|
-
private fetchIdentifiers;
|
|
8
7
|
listIdentifiers(): Promise<List<SingleIdentifier>>;
|
|
9
8
|
listIdentifierGroups(): Promise<List<IdentifierGroup>>;
|
|
10
9
|
getIdentifier(id: Identifier['id']): Promise<SingleIdentifier>;
|
|
@@ -15,8 +14,7 @@ export declare class Identifiers extends Base {
|
|
|
15
14
|
createProvider(provider: IdentifierProvider['name'], settings?: IdentifierProvider['settings']): Promise<void>;
|
|
16
15
|
listProviders(): Promise<IdentifierProvider[]>;
|
|
17
16
|
deleteProvider(provider: IdentifierProvider['name']): Promise<void>;
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
listIdentifiersV2(params: ListIdentifiersV2): Promise<IdentifierV2[]>;
|
|
17
|
+
listIdentifiersTriggers(identifiers: List<SingleIdentifier>): Promise<List<IdentifierTrigger>>;
|
|
18
|
+
private _fetchIdentifiers;
|
|
21
19
|
}
|
|
22
|
-
//# sourceMappingURL=
|
|
20
|
+
//# sourceMappingURL=identifiers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.d.ts","sourceRoot":"","sources":["../../src/identifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAY,MAAM,cAAc,CAAC;AAE9C,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,eAAe,EACf,kBAAkB,EAClB,iBAAiB,EACjB,iBAAiB,EAEjB,oBAAoB,EACpB,iCAAiC,EACjC,gBAAgB,EAGjB,MAAM,SAAS,CAAC;AAgBjB,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;gBAUrB,MAAM,EAAE,iBAAiB;IA0B/B,IAAI;IAcG,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;IAiBlD,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;IAiBtD,aAAa,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAsB9D,kBAAkB,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC;IA6BlE,yBAAyB,CACpC,MAAM,GAAE,iCAAsC,GAC7C,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IAsBzB,iBAAiB,CAAC,EAAE,EAAE,UAAU,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBtD,aAAa,CACxB,WAAW,EAAE,oBAAoB,GAAG,oBAAoB,EAAE,GACzD,OAAO,CAAC,qBAAqB,CAAC;IAwBpB,cAAc,CACzB,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,EACpC,QAAQ,GAAE,kBAAkB,CAAC,UAAU,CAAM,GAC5C,OAAO,CAAC,IAAI,CAAC;IAuBH,aAAa,IAAI,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAoB9C,cAAc,CAAC,QAAQ,EAAE,kBAAkB,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAwBnE,uBAAuB,CAAC,WAAW,EAAE,IAAI,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;YAiB7F,iBAAiB;CAchC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class IdentifiersConfigurationWrongError extends Error {
|
|
2
|
+
static BAD_CONFIGURATION_PARAMETERS: string;
|
|
3
|
+
constructor(details: string);
|
|
4
|
+
}
|
|
5
|
+
export declare class SdkUrlOrDiscoveryUrlIsMissedError extends IdentifiersConfigurationWrongError {
|
|
6
|
+
static DETAILS: string;
|
|
7
|
+
constructor();
|
|
8
|
+
}
|
|
9
|
+
export declare class TokenIsMissedError extends IdentifiersConfigurationWrongError {
|
|
10
|
+
static DETAILS: string;
|
|
11
|
+
constructor();
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=identifiers.errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identifiers.errors.d.ts","sourceRoot":"","sources":["../../src/identifiers.errors.ts"],"names":[],"mappings":"AAAA,qBAAa,kCAAmC,SAAQ,KAAK;IAC3D,MAAM,CAAC,4BAA4B,SAAkC;gBACzD,OAAO,EAAE,MAAM;CAG5B;AAED,qBAAa,iCAAkC,SAAQ,kCAAkC;IACvF,MAAM,CAAC,OAAO,SAAsE;;CAIrF;AAED,qBAAa,kBAAmB,SAAQ,kCAAkC;IACxE,MAAM,CAAC,OAAO,SAA6C;;CAI5D"}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/types.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Token } from '@or-sdk/base';
|
|
2
2
|
export declare type IdentifiersConfig = {
|
|
3
3
|
token: Token;
|
|
4
|
+
sdkUrl?: string;
|
|
4
5
|
discoveryUrl?: string;
|
|
5
6
|
accountId?: string;
|
|
6
|
-
sdkUrl?: string;
|
|
7
|
-
dataHubUrl?: string;
|
|
8
7
|
};
|
|
9
8
|
export declare type Type = 'local' | 'tollfree' | 'mobile';
|
|
10
9
|
export declare type PatternType = 'starts' | 'ends' | 'contains';
|
|
@@ -39,6 +38,14 @@ export declare type SingleIdentifierCrossAccount = {
|
|
|
39
38
|
phoneNumber: string;
|
|
40
39
|
};
|
|
41
40
|
export declare type SingleIdentifier = SingleIdentifierNormal & SingleIdentifierCrossAccount;
|
|
41
|
+
export declare type IdentifierTrigger = {
|
|
42
|
+
keywords: [];
|
|
43
|
+
value: string;
|
|
44
|
+
type: string;
|
|
45
|
+
used: {
|
|
46
|
+
flowId: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
42
49
|
export declare type GroupIdentifierNormal = {
|
|
43
50
|
id: string;
|
|
44
51
|
name: string;
|
|
@@ -96,26 +103,4 @@ export declare type IdentifierProvider = {
|
|
|
96
103
|
name: string;
|
|
97
104
|
settings: IdentifierProviderSettings;
|
|
98
105
|
};
|
|
99
|
-
export declare type CreateIdentifierParams = {
|
|
100
|
-
type: string;
|
|
101
|
-
data: object;
|
|
102
|
-
name: string;
|
|
103
|
-
};
|
|
104
|
-
export declare type IdentifierV2 = CreateIdentifierParams & {
|
|
105
|
-
dateCreated: Date;
|
|
106
|
-
dateModified: Date;
|
|
107
|
-
schemaVersion: string;
|
|
108
|
-
accountId: string;
|
|
109
|
-
};
|
|
110
|
-
export declare type ListIdentifiersV2 = {
|
|
111
|
-
query?: object;
|
|
112
|
-
projection?: string[];
|
|
113
|
-
group?: string;
|
|
114
|
-
limit?: number;
|
|
115
|
-
offset?: number;
|
|
116
|
-
order?: string;
|
|
117
|
-
};
|
|
118
|
-
export declare type DeleteIdentifierV2 = {
|
|
119
|
-
name: string;
|
|
120
|
-
};
|
|
121
106
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -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,iBAAiB,GAAG;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,oBAAY,iBAAiB,GAAG;IAK9B,KAAK,EAAE,KAAK,CAAC;IAMb,MAAM,CAAC,EAAE,MAAM,CAAC;IAKhB,YAAY,CAAC,EAAE,MAAM,CAAC;IAKtB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,oBAAY,IAAI,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEnD,oBAAY,WAAW,GAAG,QAAQ,GAAG,MAAM,GAAG,UAAU,CAAC;AAEzD,oBAAY,UAAU,GAAG,OAAO,GAAG,KAAK,GAAG,KAAK,CAAC;AAEjD,oBAAY,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,oBAAY,4BAA4B,GAAG;I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,EAAE,0BAA0B,CAAC;CACtC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/identifiers",
|
|
3
|
-
"version": "0.25.0
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"main": "dist/cjs/index.js",
|
|
5
5
|
"module": "dist/esm/index.js",
|
|
6
6
|
"types": "dist/types/index.d.ts",
|
|
@@ -14,19 +14,25 @@
|
|
|
14
14
|
"build:watch:esm": "tsc --project tsconfig.esm.json -w",
|
|
15
15
|
"build:watch:types": "tsc --project tsconfig.types.json -w",
|
|
16
16
|
"clean": "rm -rf ./dist",
|
|
17
|
-
"dev": "pnpm build:watch:esm"
|
|
17
|
+
"dev": "pnpm build:watch:esm",
|
|
18
|
+
"test": "vitest",
|
|
19
|
+
"test:watch": "vitest --watch",
|
|
20
|
+
"coverage": "vitest run --coverage"
|
|
18
21
|
},
|
|
19
22
|
"dependencies": {
|
|
20
|
-
"@or-sdk/base": "^0.
|
|
21
|
-
"@or-sdk/sdk-api": "^0.
|
|
23
|
+
"@or-sdk/base": "^0.35.0",
|
|
24
|
+
"@or-sdk/sdk-api": "^0.26.5",
|
|
22
25
|
"lodash": "^4.17.21"
|
|
23
26
|
},
|
|
24
27
|
"devDependencies": {
|
|
25
28
|
"@types/lodash": "^4.14.176",
|
|
29
|
+
"@vitest/coverage-c8": "^0.31.1",
|
|
26
30
|
"concurrently": "^6.4.0",
|
|
27
|
-
"typescript": "^4.4.4"
|
|
31
|
+
"typescript": "^4.4.4",
|
|
32
|
+
"vitest": "^0.31.1"
|
|
28
33
|
},
|
|
29
34
|
"publishConfig": {
|
|
30
35
|
"access": "public"
|
|
31
|
-
}
|
|
36
|
+
},
|
|
37
|
+
"gitHead": "a369b69b93bc8d8a6a35de2e2d2dcf6fe14e4086"
|
|
32
38
|
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { assert, describe, expect, it } from 'vitest';
|
|
2
|
+
import { Identifiers } from '../identifiers';
|
|
3
|
+
import { IdentifiersConfig } from '../types';
|
|
4
|
+
|
|
5
|
+
import { SdkUrlOrDiscoveryUrlIsMissedError, TokenIsMissedError } from '../identifiers.errors';
|
|
6
|
+
|
|
7
|
+
describe('identifiers.Identifiers', () => {
|
|
8
|
+
|
|
9
|
+
describe('Instantiation', () => {
|
|
10
|
+
|
|
11
|
+
it('successfully instantiated', () => {
|
|
12
|
+
const parameters = {
|
|
13
|
+
token: 'token',
|
|
14
|
+
sdkUrl: 'sdkUrl',
|
|
15
|
+
} as IdentifiersConfig;
|
|
16
|
+
|
|
17
|
+
const identifiers: Identifiers = new Identifiers(parameters);
|
|
18
|
+
assert.isNotNull(identifiers, 'identifiers is not null');
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it(`should throw ${SdkUrlOrDiscoveryUrlIsMissedError.name} if token is missed`, () => {
|
|
22
|
+
const parameters = {
|
|
23
|
+
sdkUrl: 'sdkUrl',
|
|
24
|
+
} as IdentifiersConfig;
|
|
25
|
+
|
|
26
|
+
let identifiers: Identifiers;
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
identifiers = new Identifiers(parameters);
|
|
30
|
+
expect(identifiers).toBeNull();
|
|
31
|
+
} catch (error) {
|
|
32
|
+
const e = error as TokenIsMissedError;
|
|
33
|
+
expect(e.message).toBe(
|
|
34
|
+
new TokenIsMissedError().message
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it(
|
|
40
|
+
`should throw ${SdkUrlOrDiscoveryUrlIsMissedError.name}
|
|
41
|
+
if some of required parameters of configuration is missed`,
|
|
42
|
+
() => {
|
|
43
|
+
const parameters = {} as IdentifiersConfig;
|
|
44
|
+
|
|
45
|
+
let identifiers: Identifiers;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
identifiers = new Identifiers(parameters);
|
|
49
|
+
expect(identifiers).toBeNull();
|
|
50
|
+
} catch (error) {
|
|
51
|
+
const e = error as SdkUrlOrDiscoveryUrlIsMissedError;
|
|
52
|
+
expect(e.message).toBe(
|
|
53
|
+
new SdkUrlOrDiscoveryUrlIsMissedError().message
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
});
|
|
59
|
+
});
|
package/src/constants.ts
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class IdentifiersConfigurationWrongError extends Error {
|
|
2
|
+
static BAD_CONFIGURATION_PARAMETERS = 'Bad configuration parameters';
|
|
3
|
+
constructor(details: string) {
|
|
4
|
+
super(`${IdentifiersConfigurationWrongError.BAD_CONFIGURATION_PARAMETERS} : ${details}`);
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export class SdkUrlOrDiscoveryUrlIsMissedError extends IdentifiersConfigurationWrongError {
|
|
9
|
+
static DETAILS = 'One of configuration parameters sdkUrl or discoveryUrl is missed';
|
|
10
|
+
constructor() {
|
|
11
|
+
super(SdkUrlOrDiscoveryUrlIsMissedError.DETAILS);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export class TokenIsMissedError extends IdentifiersConfigurationWrongError {
|
|
16
|
+
static DETAILS = 'Configuration parameter Token is missed';
|
|
17
|
+
constructor() {
|
|
18
|
+
super(TokenIsMissedError.DETAILS);
|
|
19
|
+
}
|
|
20
|
+
}
|