@neuralinnovations/dataisland-sdk 0.0.1-dev34 → 0.0.1-dev35
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/dist/package.json +1 -1
- package/dist/src/dto/userInfoResponse.d.ts +1 -0
- package/dist/src/dto/userInfoResponse.d.ts.map +1 -1
- package/dist/src/services/userProfileService.d.ts.map +1 -1
- package/dist/src/services/userProfileService.js +1 -1
- package/dist/src/services/userProfileService.js.map +1 -1
- package/dist/src/storages/user/userProfile.d.ts +14 -0
- package/dist/src/storages/user/userProfile.d.ts.map +1 -1
- package/dist/src/storages/user/userProfile.impl.d.ts +6 -0
- package/dist/src/storages/user/userProfile.impl.d.ts.map +1 -1
- package/dist/src/storages/user/userProfile.impl.js +49 -0
- package/dist/src/storages/user/userProfile.impl.js.map +1 -1
- package/dist/src/storages/user/userProfile.js.map +1 -1
- package/package.json +1 -1
- package/src/dto/userInfoResponse.ts +1 -0
- package/src/services/userProfileService.ts +1 -1
- package/src/storages/user/userProfile.impl.ts +62 -0
- package/src/storages/user/userProfile.ts +17 -0
package/dist/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userInfoResponse.d.ts","sourceRoot":"","sources":["../../../src/dto/userInfoResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAA;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,yCAAyC,CAAA;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE/D,MAAM,WAAW,gBAAgB;IAC/B,mBAAmB,EAAE,MAAM,EAAE,CAAA;IAC7B,aAAa,EAAE,eAAe,EAAE,CAAA;IAChC,IAAI,EAAE,OAAO,CAAA;CACd;AAED,MAAM,WA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AgB,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAA;IACvB,OAAO,EAAE,sBAAsB,EAAE,CAAA;CAClC;AAED,MAAM,WAAW,sBAAsB;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,EAAE,MAAM,CAAA;IACX,UAAU,EAAE,MAAM,CAAA;CACnB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userProfileService.d.ts","sourceRoot":"","sources":["../../../src/services/userProfileService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAM1D,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,
|
1
|
+
{"version":3,"file":"userProfileService.d.ts","sourceRoot":"","sources":["../../../src/services/userProfileService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AAEnC,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAA;AAM1D,qBAAa,kBAAmB,SAAQ,OAAO;IAC7C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAqD;IAE1E,IAAI,WAAW,IAAI,WAAW,CAE7B;IAEK,KAAK,CAAC,eAAe,EAAE,MAAM;IAc7B,KAAK;CAsBZ"}
|
@@ -9,7 +9,7 @@ const responseUtils_1 = require("./responseUtils");
|
|
9
9
|
class UserProfileService extends service_1.Service {
|
10
10
|
constructor() {
|
11
11
|
super(...arguments);
|
12
|
-
this.impl = new userProfile_impl_1.UserProfileImpl();
|
12
|
+
this.impl = new userProfile_impl_1.UserProfileImpl(this.context);
|
13
13
|
}
|
14
14
|
get userProfile() {
|
15
15
|
return this.impl;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userProfileService.js","sourceRoot":"","sources":["../../../src/services/userProfileService.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,6CAAyC;AAGzC,+DAA2D;AAC3D,wEAAmE;AACnE,mDAA+C;AAE/C,MAAa,kBAAmB,SAAQ,iBAAO;IAA/C;;QACmB,SAAI,GAAoB,IAAI,kCAAe,
|
1
|
+
{"version":3,"file":"userProfileService.js","sourceRoot":"","sources":["../../../src/services/userProfileService.ts"],"names":[],"mappings":";;;AAAA,uCAAmC;AACnC,6CAAyC;AAGzC,+DAA2D;AAC3D,wEAAmE;AACnE,mDAA+C;AAE/C,MAAa,kBAAmB,SAAQ,iBAAO;IAA/C;;QACmB,SAAI,GAAoB,IAAI,kCAAe,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IA0C5E,CAAC;IAxCC,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,eAAuB;QACjC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAU,CAAe,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,8BAA8B,CAAC;aACtE,YAAY,CAAC;YACZ,cAAc,EAAE,eAAe;SAChC,CAAC,CAAA;QAEJ,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,gCAAgC,EAAE,QAAQ,CAAC,CAAA;QAC5E,CAAC;QAED,MAAM,IAAI,CAAC,KAAK,EAAE,CAAA;IACpB,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,uBAAU,CAAe,CAAA;QAClD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,cAAc,CAAC,oBAAoB,CAAC,CAAC,OAAO,EAAE,CAAA;QACzE,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,8BAA8B,EAAE,QAAQ,CAAC,CAAA;QAC1E,CAAC;QACD,MAAM,OAAO,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAqB,CAAA;QAE3D,+CAA+C;QAC/C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAA;QAE3B,MAAM,mBAAmB,GAAG,IAAI,CAAC,OAAO,CACtC,yCAAmB,CACG,CAAA;QAExB,8CAA8C;QAC9C,MAAM,mBAAmB,CAAC,QAAQ,CAChC,OAAO,CAAC,mBAAmB,EAC3B,OAAO,CAAC,aAAa,EACrB,OAAO,CAAC,IAAI,CAAC,QAAQ,CACtB,CAAA;IACH,CAAC;CACF;AA3CD,gDA2CC"}
|
@@ -16,6 +16,10 @@ export declare abstract class UserProfile extends EventDispatcher<UserEvent, Use
|
|
16
16
|
* User email.
|
17
17
|
*/
|
18
18
|
abstract get email(): string;
|
19
|
+
/**
|
20
|
+
* Additional binance ID
|
21
|
+
*/
|
22
|
+
abstract get binanceId(): string;
|
19
23
|
/**
|
20
24
|
* Is user deleted.
|
21
25
|
*/
|
@@ -32,5 +36,15 @@ export declare abstract class UserProfile extends EventDispatcher<UserEvent, Use
|
|
32
36
|
* Modified at.
|
33
37
|
*/
|
34
38
|
abstract get modifiedAt(): Date;
|
39
|
+
/**
|
40
|
+
* Update user profile
|
41
|
+
* @param newName
|
42
|
+
* @param newId
|
43
|
+
*/
|
44
|
+
abstract updateUser(newName: string, newId: string): Promise<void>;
|
45
|
+
/**
|
46
|
+
* Delete User
|
47
|
+
*/
|
48
|
+
abstract deleteUser(): Promise<boolean>;
|
35
49
|
}
|
36
50
|
//# sourceMappingURL=userProfile.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userProfile.d.ts","sourceRoot":"","sources":["../../../../src/storages/user/userProfile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,C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;;OAEG;IACH,QAAQ,KAAK,UAAU,IAAI,IAAI,CAAA;IAE/B;;;;OAIG;IACH,QAAQ,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAElE;;OAEG;IACH,QAAQ,CAAC,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CACxC"}
|
@@ -1,14 +1,20 @@
|
|
1
1
|
import { UserProfile } from "./userProfile";
|
2
2
|
import { UserInfoResponse } from "../../dto/userInfoResponse";
|
3
|
+
import { Context } from "../../context";
|
3
4
|
export declare class UserProfileImpl extends UserProfile {
|
5
|
+
private readonly context;
|
4
6
|
private content?;
|
7
|
+
constructor(context: Context);
|
5
8
|
get id(): string;
|
6
9
|
get name(): string;
|
7
10
|
get email(): string;
|
11
|
+
get binanceId(): string;
|
8
12
|
get isDeleted(): boolean;
|
9
13
|
get isAnonymous(): boolean;
|
10
14
|
get createdAt(): Date;
|
11
15
|
get modifiedAt(): Date;
|
12
16
|
initFrom(content: UserInfoResponse): void;
|
17
|
+
updateUser(newName: string, newId: string): Promise<void>;
|
18
|
+
deleteUser(): Promise<boolean>;
|
13
19
|
}
|
14
20
|
//# sourceMappingURL=userProfile.impl.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userProfile.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/user/userProfile.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;
|
1
|
+
{"version":3,"file":"userProfile.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/user/userProfile.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,WAAW,EAAE,MAAM,eAAe,CAAA;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAC7D,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAIvC,qBAAa,eAAgB,SAAQ,WAAW;IAIlC,OAAO,CAAC,QAAQ,CAAC,OAAO;IAHpC,OAAO,CAAC,OAAO,CAAC,CAAkB;gBAGL,OAAO,EAAE,OAAO;IAI7C,IAAI,EAAE,IAAI,MAAM,CAKf;IAED,IAAI,IAAI,IAAI,MAAM,CAKjB;IAED,IAAI,KAAK,IAAI,MAAM,CAKlB;IAED,IAAI,SAAS,IAAI,MAAM,CAKtB;IAED,IAAI,SAAS,IAAI,OAAO,CAKvB;IAED,IAAI,WAAW,IAAI,OAAO,CAKzB;IAED,IAAI,SAAS,IAAI,IAAI,CAKpB;IAED,IAAI,UAAU,IAAI,IAAI,CAKrB;IAED,QAAQ,CAAC,OAAO,EAAE,gBAAgB;IAQ5B,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmCzD,UAAU,IAAI,OAAO,CAAC,OAAO,CAAC;CAarC"}
|
@@ -2,7 +2,13 @@
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.UserProfileImpl = void 0;
|
4
4
|
const userProfile_1 = require("./userProfile");
|
5
|
+
const rpcService_1 = require("../../services/rpcService");
|
6
|
+
const responseUtils_1 = require("../../services/responseUtils");
|
5
7
|
class UserProfileImpl extends userProfile_1.UserProfile {
|
8
|
+
constructor(context) {
|
9
|
+
super();
|
10
|
+
this.context = context;
|
11
|
+
}
|
6
12
|
get id() {
|
7
13
|
if (this.content) {
|
8
14
|
return this.content.user.id;
|
@@ -21,6 +27,12 @@ class UserProfileImpl extends userProfile_1.UserProfile {
|
|
21
27
|
}
|
22
28
|
throw new Error("The profile is not loaded.");
|
23
29
|
}
|
30
|
+
get binanceId() {
|
31
|
+
if (this.content) {
|
32
|
+
return this.content.user.profile.binanceId;
|
33
|
+
}
|
34
|
+
throw new Error("The profile is not loaded.");
|
35
|
+
}
|
24
36
|
get isDeleted() {
|
25
37
|
if (this.content) {
|
26
38
|
return this.content.user.isDeleted;
|
@@ -52,6 +64,43 @@ class UserProfileImpl extends userProfile_1.UserProfile {
|
|
52
64
|
data: this
|
53
65
|
});
|
54
66
|
}
|
67
|
+
async updateUser(newName, newId) {
|
68
|
+
var _a;
|
69
|
+
if (!this.content) {
|
70
|
+
throw new Error("User is not loaded.");
|
71
|
+
}
|
72
|
+
if (newName === this.name && newId === this.binanceId) {
|
73
|
+
return Promise.resolve();
|
74
|
+
}
|
75
|
+
const response = await ((_a = this.context
|
76
|
+
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Users").sendPutJson({
|
77
|
+
profile: {
|
78
|
+
newName,
|
79
|
+
undefined,
|
80
|
+
newId,
|
81
|
+
}
|
82
|
+
}));
|
83
|
+
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
84
|
+
await responseUtils_1.ResponseUtils.throwError("Failed to change organization", response);
|
85
|
+
}
|
86
|
+
if (this.content) {
|
87
|
+
this.content.user.profile.name = newName;
|
88
|
+
this.content.user.profile.binanceId = newId;
|
89
|
+
}
|
90
|
+
this.dispatch({
|
91
|
+
type: userProfile_1.UserEvent.CHANGED,
|
92
|
+
data: this
|
93
|
+
});
|
94
|
+
}
|
95
|
+
async deleteUser() {
|
96
|
+
var _a;
|
97
|
+
const response = await ((_a = this.context
|
98
|
+
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("/api/v1/Users/self").sendDelete());
|
99
|
+
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
100
|
+
await responseUtils_1.ResponseUtils.throwError("Failed to delete user", response);
|
101
|
+
}
|
102
|
+
return true;
|
103
|
+
}
|
55
104
|
}
|
56
105
|
exports.UserProfileImpl = UserProfileImpl;
|
57
106
|
//# sourceMappingURL=userProfile.impl.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userProfile.impl.js","sourceRoot":"","sources":["../../../../src/storages/user/userProf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EAClC,UAAU,EAAE,CAAA,CAAA;QAEf,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,uBAAuB,EAAE,QAAQ,CAAC,CAAA;QACnE,CAAC;QAED,OAAO,IAAI,CAAA;IACb,CAAC;CAEF;AAxHD,0CAwHC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"userProfile.js","sourceRoot":"","sources":["../../../../src/storages/user/userProfile.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAI9C,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,gCAAmB,CAAA;AACrB,CAAC,EAFW,SAAS,yBAAT,SAAS,QAEpB;AAED,MAAsB,WAAY,SAAQ,wBAGzC;
|
1
|
+
{"version":3,"file":"userProfile.js","sourceRoot":"","sources":["../../../../src/storages/user/userProfile.ts"],"names":[],"mappings":";;;AAAA,yCAA8C;AAI9C,IAAY,SAEX;AAFD,WAAY,SAAS;IACnB,gCAAmB,CAAA;AACrB,CAAC,EAFW,SAAS,yBAAT,SAAS,QAEpB;AAED,MAAsB,WAAY,SAAQ,wBAGzC;CAoDA;AAvDD,kCAuDC"}
|
package/package.json
CHANGED
@@ -7,7 +7,7 @@ import { UserProfileImpl } from "../storages/user/userProfile.impl"
|
|
7
7
|
import { ResponseUtils } from "./responseUtils"
|
8
8
|
|
9
9
|
export class UserProfileService extends Service {
|
10
|
-
private readonly impl: UserProfileImpl = new UserProfileImpl()
|
10
|
+
private readonly impl: UserProfileImpl = new UserProfileImpl(this.context)
|
11
11
|
|
12
12
|
get userProfile(): UserProfile {
|
13
13
|
return this.impl
|
@@ -1,10 +1,17 @@
|
|
1
1
|
import { UserEvent, UserProfile } from "./userProfile"
|
2
2
|
import { UserInfoResponse } from "../../dto/userInfoResponse"
|
3
|
+
import { Context } from "../../context"
|
4
|
+
import { RpcService } from "../../services/rpcService"
|
5
|
+
import { ResponseUtils } from "../../services/responseUtils"
|
3
6
|
|
4
7
|
export class UserProfileImpl extends UserProfile {
|
5
8
|
private content?: UserInfoResponse
|
6
9
|
|
7
10
|
|
11
|
+
constructor(private readonly context: Context) {
|
12
|
+
super()
|
13
|
+
}
|
14
|
+
|
8
15
|
get id(): string {
|
9
16
|
if (this.content) {
|
10
17
|
return this.content.user.id
|
@@ -26,6 +33,13 @@ export class UserProfileImpl extends UserProfile {
|
|
26
33
|
throw new Error("The profile is not loaded.")
|
27
34
|
}
|
28
35
|
|
36
|
+
get binanceId(): string {
|
37
|
+
if (this.content) {
|
38
|
+
return this.content.user.profile.binanceId
|
39
|
+
}
|
40
|
+
throw new Error("The profile is not loaded.")
|
41
|
+
}
|
42
|
+
|
29
43
|
get isDeleted(): boolean {
|
30
44
|
if (this.content) {
|
31
45
|
return this.content.user.isDeleted
|
@@ -62,4 +76,52 @@ export class UserProfileImpl extends UserProfile {
|
|
62
76
|
})
|
63
77
|
}
|
64
78
|
|
79
|
+
async updateUser(newName: string, newId: string): Promise<void>{
|
80
|
+
if (!this.content) {
|
81
|
+
throw new Error("User is not loaded.")
|
82
|
+
}
|
83
|
+
|
84
|
+
if (newName === this.name && newId === this.binanceId) {
|
85
|
+
return Promise.resolve()
|
86
|
+
}
|
87
|
+
|
88
|
+
const response = await this.context
|
89
|
+
.resolve(RpcService)
|
90
|
+
?.requestBuilder("api/v1/Users")
|
91
|
+
.sendPutJson({
|
92
|
+
profile: {
|
93
|
+
newName,
|
94
|
+
undefined,
|
95
|
+
newId,
|
96
|
+
}
|
97
|
+
})
|
98
|
+
|
99
|
+
if (ResponseUtils.isFail(response)) {
|
100
|
+
await ResponseUtils.throwError("Failed to change organization", response)
|
101
|
+
}
|
102
|
+
|
103
|
+
if (this.content) {
|
104
|
+
this.content!.user.profile.name = newName
|
105
|
+
this.content!.user.profile.binanceId = newId
|
106
|
+
}
|
107
|
+
|
108
|
+
this.dispatch({
|
109
|
+
type: UserEvent.CHANGED,
|
110
|
+
data: this
|
111
|
+
})
|
112
|
+
}
|
113
|
+
|
114
|
+
async deleteUser(): Promise<boolean>{
|
115
|
+
const response = await this.context
|
116
|
+
.resolve(RpcService)?.
|
117
|
+
requestBuilder("/api/v1/Users/self")
|
118
|
+
.sendDelete()
|
119
|
+
|
120
|
+
if (ResponseUtils.isFail(response)) {
|
121
|
+
await ResponseUtils.throwError("Failed to delete user", response)
|
122
|
+
}
|
123
|
+
|
124
|
+
return true
|
125
|
+
}
|
126
|
+
|
65
127
|
}
|
@@ -25,6 +25,11 @@ export abstract class UserProfile extends EventDispatcher<
|
|
25
25
|
*/
|
26
26
|
abstract get email(): string
|
27
27
|
|
28
|
+
/**
|
29
|
+
* Additional binance ID
|
30
|
+
*/
|
31
|
+
abstract get binanceId(): string
|
32
|
+
|
28
33
|
/**
|
29
34
|
* Is user deleted.
|
30
35
|
*/
|
@@ -44,4 +49,16 @@ export abstract class UserProfile extends EventDispatcher<
|
|
44
49
|
* Modified at.
|
45
50
|
*/
|
46
51
|
abstract get modifiedAt(): Date
|
52
|
+
|
53
|
+
/**
|
54
|
+
* Update user profile
|
55
|
+
* @param newName
|
56
|
+
* @param newId
|
57
|
+
*/
|
58
|
+
abstract updateUser(newName: string, newId: string): Promise<void>
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Delete User
|
62
|
+
*/
|
63
|
+
abstract deleteUser(): Promise<boolean>
|
47
64
|
}
|