@neuralinnovations/dataisland-sdk 0.0.1-dev25 → 0.0.1-dev26
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 +8 -26
- package/dist/package.json +10 -10
- package/dist/src/commands/deleteUserFullCommandHandler.d.ts +7 -0
- package/dist/src/commands/deleteUserFullCommandHandler.d.ts.map +1 -0
- package/dist/src/commands/deleteUserFullCommandHandler.js +21 -0
- package/dist/src/commands/deleteUserFullCommandHandler.js.map +1 -0
- package/dist/src/dto/chatResponse.d.ts +9 -6
- package/dist/src/dto/chatResponse.d.ts.map +1 -1
- package/dist/src/dto/chatResponse.js.map +1 -1
- package/dist/src/internal/app.impl.d.ts.map +1 -1
- package/dist/src/internal/app.impl.js +4 -0
- package/dist/src/internal/app.impl.js.map +1 -1
- package/dist/src/storages/chats/answer.d.ts +8 -11
- package/dist/src/storages/chats/answer.d.ts.map +1 -1
- package/dist/src/storages/chats/answer.impl.d.ts +11 -8
- package/dist/src/storages/chats/answer.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/answer.impl.js +28 -57
- package/dist/src/storages/chats/answer.impl.js.map +1 -1
- package/dist/src/storages/chats/answer.js +1 -0
- package/dist/src/storages/chats/answer.js.map +1 -1
- package/dist/src/storages/chats/chat.d.ts +0 -4
- package/dist/src/storages/chats/chat.d.ts.map +1 -1
- package/dist/src/storages/chats/chat.impl.d.ts +2 -3
- package/dist/src/storages/chats/chat.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/chat.impl.js +2 -26
- package/dist/src/storages/chats/chat.impl.js.map +1 -1
- package/dist/src/storages/chats/chat.js.map +1 -1
- package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -1
- package/dist/src/storages/workspaces/workspaces.impl.js +4 -2
- package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -1
- package/dist/src/unitTest.d.ts +1 -1
- package/dist/src/unitTest.d.ts.map +1 -1
- package/dist/src/unitTest.js +3 -3
- package/dist/src/unitTest.js.map +1 -1
- package/package.json +11 -11
- package/src/commands/deleteUserFullCommandHandler.ts +19 -0
- package/src/dto/chatResponse.ts +10 -6
- package/src/internal/app.impl.ts +7 -0
- package/src/storages/chats/answer.impl.ts +36 -81
- package/src/storages/chats/answer.ts +9 -16
- package/src/storages/chats/chat.impl.ts +5 -36
- package/src/storages/chats/chat.ts +0 -4
- package/src/storages/workspaces/workspaces.impl.ts +4 -1
- package/src/unitTest.ts +3 -3
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"chat.impl.js","sourceRoot":"","sources":["../../../../src/storages/chats/chat.impl.ts"],"names":[],"mappings":";;;AAAA,iCAA6C;AAK7C,+CAA0C;AAC1C,0DAAsD;AACtD,gEAA4D;AAG5D,MAAa,QAAS,SAAQ,WAAI;IAMhC,YACmB,OAAgB,EACjB,YAA0B;QAE1C,KAAK,EAAE,CAAA;QAHU,YAAO,GAAP,OAAO,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAc;QAPpC,gBAAW,GAAY,KAAK,CAAA;QACnB,aAAQ,GAAiB,EAAE,CAAA;IAS5C,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,IAAa;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;QAEpB,eAAe;QACf,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YAC/B,+BAA+B;YAC/B,MAAM,MAAM,GAAG,
|
1
|
+
{"version":3,"file":"chat.impl.js","sourceRoot":"","sources":["../../../../src/storages/chats/chat.impl.ts"],"names":[],"mappings":";;;AAAA,iCAA6C;AAK7C,+CAA0C;AAC1C,0DAAsD;AACtD,gEAA4D;AAG5D,MAAa,QAAS,SAAQ,WAAI;IAMhC,YACmB,OAAgB,EACjB,YAA0B;QAE1C,KAAK,EAAE,CAAA;QAHU,YAAO,GAAP,OAAO,CAAS;QACjB,iBAAY,GAAZ,YAAY,CAAc;QAPpC,gBAAW,GAAY,KAAK,CAAA;QACnB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EACvC,WAAW,CAAC;YACX,MAAM,EAAE,IAAI,CAAC,EAAE;YACf,eAAe,EAAE,OAAO;YACxB,YAAY,EAAE,CAAC,UAAU,KAAK,qBAAc,CAAC,IAAI,CAAC;SACnD,CAAC,CAAA,CAAA;QAEJ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,6BAAa,CAAC,UAAU,CAAC,2CAA2C,IAAI,CAAC,YAAY,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,CAAA;QAC7G,CAAC;QAED,6CAA6C;QAC7C,MAAM,EAAE,GAAG,CAAC,MAAM,QAAS,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE,CAAA;QAEtC,+BAA+B;QAC/B,MAAM,MAAM,GAAG,MAAM,IAAI,wBAAU,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,CAAA;QAE5E,+BAA+B;QAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;QAE1B,OAAO,MAAM,CAAA;IACf,CAAC;IAED,OAAO;QACL,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA;IACzB,CAAC;CAEF;AApFD,4BAoFC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../src/storages/chats/chat.ts"],"names":[],"mappings":";;;AAKA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,MAAsB,IAAI;
|
1
|
+
{"version":3,"file":"chat.js","sourceRoot":"","sources":["../../../../src/storages/chats/chat.ts"],"names":[],"mappings":";;;AAKA,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAED,MAAsB,IAAI;CAiCzB;AAjCD,oBAiCC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workspaces.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/workspaces/workspaces.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;
|
1
|
+
{"version":3,"file":"workspaces.impl.d.ts","sourceRoot":"","sources":["../../../../src/storages/workspaces/workspaces.impl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAA;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAA;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEvC,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAQ/D,qBAAa,cAAe,SAAQ,UAAU;IAI1C,OAAO,CAAC,QAAQ,CAAC,YAAY;IAC7B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAJ1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAsB;gBAG/B,YAAY,EAAE,gBAAgB,EAC9B,OAAO,EAAE,OAAO;IAKnC,IAAI,UAAU,IAAI,SAAS,SAAS,EAAE,CAErC;IAED,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS;IAI1B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,SAAS;IAIzC,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI7B;;;;;OAKG;IACG,MAAM,CACV,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,MAAM,EACnB,UAAU,CAAC,EAAE;QACX,gBAAgB,EAAE,OAAO,CAAA;QACzB,YAAY,EAAE,MAAM,CAAA;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAA;KACnB,GACA,OAAO,CAAC,SAAS,CAAC;IA2ErB;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA8CtC,QAAQ,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;CAoC9D"}
|
@@ -5,6 +5,7 @@ const workspaces_1 = require("./workspaces");
|
|
5
5
|
const workspace_impl_1 = require("./workspace.impl");
|
6
6
|
const rpcService_1 = require("../../services/rpcService");
|
7
7
|
const responseUtils_1 = require("../../services/responseUtils");
|
8
|
+
const userProfileService_1 = require("../../services/userProfileService");
|
8
9
|
class WorkspacesImpl extends workspaces_1.Workspaces {
|
9
10
|
constructor(organization, context) {
|
10
11
|
super();
|
@@ -126,13 +127,14 @@ class WorkspacesImpl extends workspaces_1.Workspaces {
|
|
126
127
|
});
|
127
128
|
}
|
128
129
|
async initFrom(organizationId) {
|
129
|
-
var _a;
|
130
|
+
var _a, _b;
|
130
131
|
// init workspaces from the server's response
|
131
132
|
const response = await ((_a = this.context
|
132
133
|
.resolve(rpcService_1.RpcService)) === null || _a === void 0 ? void 0 : _a.requestBuilder("api/v1/Organizations").searchParam("id", organizationId).sendGet());
|
133
134
|
// check response status
|
134
135
|
if (responseUtils_1.ResponseUtils.isFail(response)) {
|
135
|
-
|
136
|
+
const userProfile = (_b = this.context.resolve(userProfileService_1.UserProfileService)) === null || _b === void 0 ? void 0 : _b.userProfile;
|
137
|
+
await responseUtils_1.ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${organizationId}, userId: ${userProfile.id}, email: ${userProfile.email}`, response);
|
136
138
|
}
|
137
139
|
// parse workspaces from the server's response
|
138
140
|
const workspaces = (await response.json())
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"workspaces.impl.js","sourceRoot":"","sources":["../../../../src/storages/workspaces/workspaces.impl.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AAIvE,qDAAgD;AAEhD,0DAAsD;AAGtD,gEAA4D;
|
1
|
+
{"version":3,"file":"workspaces.impl.js","sourceRoot":"","sources":["../../../../src/storages/workspaces/workspaces.impl.ts"],"names":[],"mappings":";;;AAAA,6CAAuE;AAIvE,qDAAgD;AAEhD,0DAAsD;AAGtD,gEAA4D;AAC5D,0EAAsE;AAGtE,MAAa,cAAe,SAAQ,uBAAU;IAG5C,YACmB,YAA8B,EAC9B,OAAgB;QAEjC,KAAK,EAAE,CAAA;QAHU,iBAAY,GAAZ,YAAY,CAAkB;QAC9B,YAAO,GAAP,OAAO,CAAS;QAJlB,gBAAW,GAAoB,EAAE,CAAA;IAOlD,CAAC;IAED,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,WAAW,CAAA;IACzB,CAAC;IAED,GAAG,CAAC,EAAU;QACZ,OAAkB,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACnC,CAAC;IAED,MAAM,CAAC,EAAU;QACf,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,CAAA;IAChE,CAAC;IAED,QAAQ,CAAC,EAAU;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,SAAS,CAAA;IAC9E,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CACV,IAAY,EACZ,WAAmB,EACnB,UAIC;;QAED,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;YAC9D,MA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AE,CAAA,CAAA;QAEZ,wBAAwB;QACxB,IAAI,6BAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;YACnC,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,uCAAkB,CAAC,0CAAE,WAA0B,CAAA;YACxF,MAAM,6BAAa,CAAC,UAAU,CAAC,+CAA+C,cAAc,aAAa,WAAW,CAAC,EAAE,YAAY,WAAW,CAAC,KAAK,EAAE,EAAE,QAAQ,CAAC,CAAA;QACnK,CAAC;QAED,8CAA8C;QAC9C,MAAM,UAAU,GAAI,CAAC,MAAM,QAAS,CAAC,IAAI,EAAE,CAA4B;aACpE,UAAU,CAAA;QAEb,6CAA6C;QAC7C,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;YACnC,kCAAkC;YAClC,MAAM,aAAa,GAAG,IAAI,8BAAa,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;YAExE,4CAA4C;YAC5C,MAAM,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAA;YAEvC,kCAAkC;YAClC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;YAEpC,iBAAiB;YACjB,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,4BAAe,CAAC,KAAK;gBAC3B,IAAI,EAAE,aAAa;aACpB,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;CACF;AAzMD,wCAyMC"}
|
package/dist/src/unitTest.d.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unitTest.d.ts","sourceRoot":"","sources":["../../src/unitTest.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,UAAU,IAAI;IACd,YAAY,IAAS;IACrB,4BAA4B,IAAS;IAErC,
|
1
|
+
{"version":3,"file":"unitTest.d.ts","sourceRoot":"","sources":["../../src/unitTest.ts"],"names":[],"mappings":"AAAA,oBAAY,QAAQ;IAClB,UAAU,IAAI;IACd,YAAY,IAAS;IACrB,4BAA4B,IAAS;IAErC,gBAAgB,IAA8C;CAC/D;AAED,MAAM,MAAM,yBAAyB,GAAG,MAAM,IAAI,CAAA;AAClD,MAAM,MAAM,0BAA0B,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;AA8B5D,eAAO,MAAM,OAAO,yCAEZ,yBAAyB,GAAG,0BAA0B,KAC3D,QAAQ,IAAI,CAEd,CAAA;AAED,eAAO,MAAM,cAAc,QAAO,QAEjC,CAAA;AAED,eAAO,MAAM,UAAU,SAAU,QAAQ,KAAG,OAE3C,CAAA"}
|
package/dist/src/unitTest.js
CHANGED
@@ -6,13 +6,13 @@ var UnitTest;
|
|
6
6
|
UnitTest[UnitTest["DO_NOTHING"] = 0] = "DO_NOTHING";
|
7
7
|
UnitTest[UnitTest["DO_NOT_START"] = 1] = "DO_NOT_START";
|
8
8
|
UnitTest[UnitTest["DO_NOT_PRINT_INITIALIZED_LOG"] = 2] = "DO_NOT_PRINT_INITIALIZED_LOG";
|
9
|
-
UnitTest[UnitTest["
|
9
|
+
UnitTest[UnitTest["DO_NOT_START_SDK"] = 3] = "DO_NOT_START_SDK";
|
10
10
|
})(UnitTest || (exports.UnitTest = UnitTest = {}));
|
11
11
|
class AppSdkUnitTest {
|
12
12
|
static get current() {
|
13
13
|
return this._stack[this._stack.length - 1];
|
14
14
|
}
|
15
|
-
static async test(unitTest = UnitTest.
|
15
|
+
static async test(unitTest = UnitTest.DO_NOT_START_SDK, func) {
|
16
16
|
this._stack.push(unitTest);
|
17
17
|
if (func) {
|
18
18
|
const result = func();
|
@@ -29,7 +29,7 @@ class AppSdkUnitTest {
|
|
29
29
|
}
|
30
30
|
}
|
31
31
|
AppSdkUnitTest._stack = [UnitTest.DO_NOTHING];
|
32
|
-
const appTest = async (unitTest = UnitTest.
|
32
|
+
const appTest = async (unitTest = UnitTest.DO_NOT_START_SDK, func) => {
|
33
33
|
await AppSdkUnitTest.test(unitTest, func);
|
34
34
|
};
|
35
35
|
exports.appTest = appTest;
|
package/dist/src/unitTest.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unitTest.js","sourceRoot":"","sources":["../../src/unitTest.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,mDAAc,CAAA;IACd,uDAAqB,CAAA;IACrB,uFAAqC,CAAA;IAErC,
|
1
|
+
{"version":3,"file":"unitTest.js","sourceRoot":"","sources":["../../src/unitTest.ts"],"names":[],"mappings":";;;AAAA,IAAY,QAMX;AAND,WAAY,QAAQ;IAClB,mDAAc,CAAA;IACd,uDAAqB,CAAA;IACrB,uFAAqC,CAAA;IAErC,+DAA8D,CAAA;AAChE,CAAC,EANW,QAAQ,wBAAR,QAAQ,QAMnB;AAKD,MAAM,cAAc;IAGX,MAAM,KAAK,OAAO;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAA;IAC5C,CAAC;IAEM,MAAM,CAAC,KAAK,CAAC,IAAI,CACtB,WAAqB,QAAQ,CAAC,gBAAgB,EAC9C,IAA4D;QAE5D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC1B,IAAI,IAAI,EAAE,CAAC;YACT,MAAM,MAAM,GAAG,IAAI,EAAE,CAAA;YACrB,IAAI,MAAM,EAAE,CAAC;gBACX,MAAM,MAAM,CAAA;YACd,CAAC;YACD,cAAc,CAAC,GAAG,EAAE,CAAA;QACtB,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,GAAG;QAChB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAA;QACnB,CAAC;IACH,CAAC;;AAxBc,qBAAM,GAAe,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAA;AA2BpD,MAAM,OAAO,GAAG,KAAK,EAC1B,WAAqB,QAAQ,CAAC,gBAAgB,EAC9C,IAA4D,EAC7C,EAAE;IACjB,MAAM,cAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;AAC3C,CAAC,CAAA;AALY,QAAA,OAAO,WAKnB;AAEM,MAAM,cAAc,GAAG,GAAa,EAAE;IAC3C,OAAO,cAAc,CAAC,OAAO,CAAA;AAC/B,CAAC,CAAA;AAFY,QAAA,cAAc,kBAE1B;AAEM,MAAM,UAAU,GAAG,CAAC,IAAc,EAAW,EAAE;IACpD,OAAO,CAAC,cAAc,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,IAAI,CAAA;AAChD,CAAC,CAAA;AAFY,QAAA,UAAU,cAEtB"}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@neuralinnovations/dataisland-sdk",
|
3
|
-
"version": "0.0.1-
|
3
|
+
"version": "0.0.1-dev26",
|
4
4
|
"description": "SDK for DataIsland project",
|
5
5
|
"licenses": [
|
6
6
|
{
|
@@ -12,6 +12,15 @@
|
|
12
12
|
"type": "git",
|
13
13
|
"url": "https://github.com/NeuralInnovations/dataisland-client-js-sdk.git"
|
14
14
|
},
|
15
|
+
"scripts": {
|
16
|
+
"build": "tsc",
|
17
|
+
"test": "jest",
|
18
|
+
"lint": "eslint --ext .ts,.tsx src test",
|
19
|
+
"lint:fix": "eslint --fix --ext .ts,.tsx src test",
|
20
|
+
"docs": "typedoc --disableSources --includeVersion --plugin typedoc-plugin-markdown --out docs src/index.ts && node scripts/docs/index.js",
|
21
|
+
"version-up-dev": "node scripts/version/up-dev.js && rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs",
|
22
|
+
"release": "rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs"
|
23
|
+
},
|
15
24
|
"publishConfig": {
|
16
25
|
"access": "public"
|
17
26
|
},
|
@@ -33,15 +42,6 @@
|
|
33
42
|
"engines": {
|
34
43
|
"node": ">=16"
|
35
44
|
},
|
36
|
-
"scripts": {
|
37
|
-
"build": "tsc",
|
38
|
-
"test": "jest --runInBand",
|
39
|
-
"lint": "eslint --ext .ts,.tsx src test",
|
40
|
-
"lint:fix": "eslint --fix --ext .ts,.tsx src test",
|
41
|
-
"docs": "typedoc --disableSources --includeVersion --plugin typedoc-plugin-markdown --out docs src/index.ts && node scripts/docs/index.js",
|
42
|
-
"version-up-dev": "node scripts/version/up-dev.js && rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs",
|
43
|
-
"release": "rm package-lock.json && npm install && npm run build && npm run lint:fix && npm run docs"
|
44
|
-
},
|
45
45
|
"keywords": [
|
46
46
|
"dataisland",
|
47
47
|
"sdk",
|
@@ -97,4 +97,4 @@
|
|
97
97
|
"dotenv": "^16.3.2",
|
98
98
|
"jsdom": "^23.2.0"
|
99
99
|
}
|
100
|
-
}
|
100
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { Command, CommandHandler } from "../services/commandService"
|
2
|
+
import { RpcService } from "../services/rpcService"
|
3
|
+
import { ResponseUtils } from "../services/responseUtils"
|
4
|
+
|
5
|
+
export class DeleteUserFullCommand extends Command {
|
6
|
+
|
7
|
+
}
|
8
|
+
|
9
|
+
export class DeleteUserFullCommandHandler extends CommandHandler<DeleteUserFullCommand> {
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
11
|
+
async execute(message: DeleteUserFullCommand): Promise<void> {
|
12
|
+
const response = await this.resolve(RpcService)?.requestBuilder("/api/v1/Users/self/full")
|
13
|
+
.sendDelete()
|
14
|
+
|
15
|
+
if (ResponseUtils.isFail(response)) {
|
16
|
+
await ResponseUtils.throwError("Failed to delete user", response)
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
package/src/dto/chatResponse.ts
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
import { AnswerId, StepId } from "../storages/chats/answer"
|
2
|
+
import { ChatId } from "../storages/chats/chat"
|
3
|
+
import { UserId } from "../storages/user/userProfile"
|
4
|
+
|
1
5
|
export interface SourceDto {
|
2
6
|
id: string;
|
3
7
|
name: string;
|
@@ -7,8 +11,8 @@ export interface SourceDto {
|
|
7
11
|
}
|
8
12
|
|
9
13
|
export interface AnswerDto {
|
10
|
-
id:
|
11
|
-
chatId:
|
14
|
+
id: AnswerId;
|
15
|
+
chatId: ChatId;
|
12
16
|
question: string;
|
13
17
|
context: string;
|
14
18
|
sources: SourceDto[];
|
@@ -16,11 +20,11 @@ export interface AnswerDto {
|
|
16
20
|
}
|
17
21
|
|
18
22
|
export interface ChatDto {
|
19
|
-
id:
|
23
|
+
id: ChatId;
|
20
24
|
name: string;
|
21
25
|
createdAt: number;
|
22
26
|
modifiedAt: number;
|
23
|
-
userId:
|
27
|
+
userId: UserId;
|
24
28
|
organizationId: string;
|
25
29
|
workspaceId: string;
|
26
30
|
answers: AnswerDto[];
|
@@ -38,7 +42,7 @@ export enum AnswerStatus {
|
|
38
42
|
}
|
39
43
|
|
40
44
|
export interface AnswerStepDto {
|
41
|
-
id:
|
45
|
+
id: StepId;
|
42
46
|
type: StepType;
|
43
47
|
status: StepStatus;
|
44
48
|
start_at: string;
|
@@ -48,7 +52,7 @@ export interface AnswerStepDto {
|
|
48
52
|
}
|
49
53
|
|
50
54
|
export interface FetchAnswerResponse {
|
51
|
-
id:
|
55
|
+
id: AnswerId;
|
52
56
|
status: AnswerStatus;
|
53
57
|
steps: AnswerStepDto[];
|
54
58
|
}
|
package/src/internal/app.impl.ts
CHANGED
@@ -20,6 +20,10 @@ import { OrganizationService } from "../services/organizationService"
|
|
20
20
|
import { Organizations } from "../storages/organizations/organizations"
|
21
21
|
import { UserProfile } from "../storages/user/userProfile"
|
22
22
|
import { isUnitTest, UnitTest } from "../unitTest"
|
23
|
+
import {
|
24
|
+
DeleteUserFullCommand,
|
25
|
+
DeleteUserFullCommandHandler
|
26
|
+
} from "../commands/deleteUserFullCommandHandler"
|
23
27
|
|
24
28
|
export class DataIslandAppImpl extends DataIslandApp {
|
25
29
|
readonly name: string
|
@@ -83,6 +87,9 @@ export class DataIslandAppImpl extends DataIslandApp {
|
|
83
87
|
builder.registerCommand(StartCommand, (context: Context) => {
|
84
88
|
return new StartCommandHandler(context)
|
85
89
|
})
|
90
|
+
builder.registerCommand(DeleteUserFullCommand, (context: Context) => {
|
91
|
+
return new DeleteUserFullCommandHandler(context)
|
92
|
+
})
|
86
93
|
|
87
94
|
// register services
|
88
95
|
builder.registerService(CredentialService, (context: ServiceContext) => {
|
@@ -4,7 +4,6 @@ import {
|
|
4
4
|
AnswerStatus,
|
5
5
|
AnswerStepDto,
|
6
6
|
FetchAnswerResponse,
|
7
|
-
FetchTokensResponse,
|
8
7
|
SourceDto,
|
9
8
|
StepType
|
10
9
|
} from "../../dto/chatResponse"
|
@@ -14,11 +13,13 @@ import { Answer, AnswerEvent, AnswerId } from "./answer"
|
|
14
13
|
import { Chat } from "./chat"
|
15
14
|
|
16
15
|
export class AnswerImpl extends Answer {
|
17
|
-
private _content?: AnswerDto
|
18
16
|
|
19
17
|
private _steps?: AnswerStepDto[]
|
20
18
|
private _status?: AnswerStatus
|
21
19
|
private _id?: AnswerId
|
20
|
+
private _question?: string
|
21
|
+
private _sources?: SourceDto[]
|
22
|
+
private _answer?: string
|
22
23
|
|
23
24
|
constructor(
|
24
25
|
private readonly chat: Chat,
|
@@ -26,75 +27,53 @@ export class AnswerImpl extends Answer {
|
|
26
27
|
super()
|
27
28
|
}
|
28
29
|
|
29
|
-
|
30
|
-
this._content = answer
|
30
|
+
initFromHistory(answer: AnswerDto): AnswerImpl {
|
31
31
|
this._id = answer.id
|
32
|
+
this._question = answer.question
|
33
|
+
this._answer = answer.context
|
34
|
+
this._sources = answer.sources
|
32
35
|
|
33
36
|
return this
|
34
37
|
}
|
35
38
|
|
36
|
-
async
|
39
|
+
async initNew(id: AnswerId, question: string): Promise<AnswerImpl> {
|
37
40
|
this._id = id
|
41
|
+
this._question = question
|
42
|
+
this._answer = ""
|
38
43
|
|
39
|
-
// fetch answer
|
40
44
|
await this.fetch()
|
41
45
|
|
42
|
-
this.dispatch({
|
43
|
-
type: AnswerEvent.ADDED,
|
44
|
-
data: this
|
45
|
-
})
|
46
|
-
|
47
46
|
return this
|
48
47
|
}
|
49
48
|
|
50
|
-
get id():
|
51
|
-
return <
|
49
|
+
get id(): AnswerId {
|
50
|
+
return <AnswerId>this._id
|
52
51
|
}
|
53
52
|
|
54
53
|
get status(): AnswerStatus {
|
55
54
|
return <AnswerStatus>this._status
|
56
55
|
}
|
57
56
|
|
58
|
-
get
|
59
|
-
|
60
|
-
return <AnswerDto>this._content
|
61
|
-
}
|
62
|
-
throw new Error("Answer status is running, please use fetch() or fetch_tokens()")
|
57
|
+
get question(): string {
|
58
|
+
return <string>this._question
|
63
59
|
}
|
64
60
|
|
65
|
-
|
66
|
-
return this.
|
61
|
+
get sources(): SourceDto[] {
|
62
|
+
return <SourceDto[]>this._sources
|
67
63
|
}
|
68
64
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
// get step
|
73
|
-
const step = this.getStep(type)
|
74
|
-
|
75
|
-
// check step
|
76
|
-
if (!step) {
|
77
|
-
throw new Error(`Step with type ${type.toString()} is not found, answer: ${this.id}, organization: ${this.chat.organization.id}`)
|
78
|
-
}
|
79
|
-
|
80
|
-
// get sources
|
81
|
-
const response = await this.context
|
82
|
-
.resolve(RpcService)
|
83
|
-
?.requestBuilder("api/v1/Chats/answer/sources")
|
84
|
-
.searchParam("chat_uid", this.chat.id)
|
85
|
-
.searchParam("uid", this.id)
|
86
|
-
.searchParam("step_id", step.id)
|
87
|
-
.sendGet()
|
65
|
+
get tokens(): string {
|
66
|
+
return <string>this._answer
|
67
|
+
}
|
88
68
|
|
89
|
-
|
90
|
-
if (
|
91
|
-
|
69
|
+
public fetchAfter() {
|
70
|
+
if (this._status === undefined || this._status === AnswerStatus.RUNNING) {
|
71
|
+
setTimeout(async () => await this.fetch(), 300)
|
92
72
|
}
|
73
|
+
}
|
93
74
|
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
return sources
|
75
|
+
private getStep(type: StepType): AnswerStepDto | undefined {
|
76
|
+
return this._steps?.find(step => step.type === type)
|
98
77
|
}
|
99
78
|
|
100
79
|
async fetch(): Promise<void> {
|
@@ -121,46 +100,22 @@ export class AnswerImpl extends Answer {
|
|
121
100
|
this._status = <AnswerStatus>answer.status
|
122
101
|
this._steps = <AnswerStepDto[]>answer.steps
|
123
102
|
|
124
|
-
this.
|
125
|
-
|
126
|
-
|
127
|
-
})
|
128
|
-
|
129
|
-
if (this._status != AnswerStatus.RUNNING){
|
130
|
-
await this.chat.update()
|
131
|
-
}
|
132
|
-
}
|
133
|
-
|
134
|
-
async fetchTokens(type: StepType, token_start_at: number): Promise<FetchTokensResponse> {
|
135
|
-
// fetch answer
|
136
|
-
await this.fetch()
|
137
|
-
// get step
|
138
|
-
const step = this.getStep(type)
|
139
|
-
|
140
|
-
// check step
|
141
|
-
if (!step) {
|
142
|
-
throw new Error(`Step with type ${type.toString()} is not found`)
|
103
|
+
if (this.getStep(StepType.GENERATE_ANSWER) !== undefined) {
|
104
|
+
const step = this.getStep(StepType.GENERATE_ANSWER)
|
105
|
+
this._answer = step?.tokens.join("")
|
143
106
|
}
|
144
107
|
|
145
|
-
|
146
|
-
|
147
|
-
.
|
148
|
-
?.requestBuilder("api/v1/Chats/answer/fetch/tokens")
|
149
|
-
.searchParam("chat_uid", this.chat.id)
|
150
|
-
.searchParam("uid", this.id)
|
151
|
-
.searchParam("step_id", step.id)
|
152
|
-
.searchParam("token_start_at", token_start_at.toString())
|
153
|
-
.sendGet()
|
154
|
-
|
155
|
-
// check response status
|
156
|
-
if (ResponseUtils.isFail(response)) {
|
157
|
-
await ResponseUtils.throwError(`Failed to get sources for ${type.toString()}`, response)
|
108
|
+
if (this.getStep(StepType.SOURCES) !== undefined) {
|
109
|
+
const sources_step = this.getStep(StepType.SOURCES)
|
110
|
+
this._sources = sources_step?.sources
|
158
111
|
}
|
159
112
|
|
160
|
-
|
161
|
-
|
113
|
+
this.dispatch({
|
114
|
+
type: AnswerEvent.UPDATED,
|
115
|
+
data: this
|
116
|
+
})
|
162
117
|
|
163
|
-
|
118
|
+
this.fetchAfter()
|
164
119
|
}
|
165
120
|
|
166
121
|
async cancel(): Promise<void> {
|
@@ -1,9 +1,6 @@
|
|
1
1
|
import {
|
2
|
-
AnswerDto,
|
3
2
|
AnswerStatus,
|
4
|
-
|
5
|
-
SourceDto,
|
6
|
-
StepType
|
3
|
+
SourceDto
|
7
4
|
} from "../../dto/chatResponse"
|
8
5
|
import { EventDispatcher } from "../../events"
|
9
6
|
|
@@ -13,6 +10,7 @@ export type StepId = string
|
|
13
10
|
export enum AnswerEvent {
|
14
11
|
ADDED = "added",
|
15
12
|
CANCALLED = "cancelled",
|
13
|
+
FAILED = "failed",
|
16
14
|
UPDATED = "updated"
|
17
15
|
}
|
18
16
|
|
@@ -26,27 +24,22 @@ export abstract class Answer extends EventDispatcher<AnswerEvent, Answer> {
|
|
26
24
|
/**
|
27
25
|
* Answer data object
|
28
26
|
*/
|
29
|
-
abstract get
|
27
|
+
abstract get question(): string
|
30
28
|
|
31
29
|
/**
|
32
|
-
* Answer
|
30
|
+
* Answer tokens
|
33
31
|
*/
|
34
|
-
abstract get
|
32
|
+
abstract get tokens(): string
|
35
33
|
|
36
34
|
/**
|
37
|
-
* Answer
|
38
|
-
*/
|
39
|
-
abstract sources(type: StepType): Promise<SourceDto[]>
|
40
|
-
|
41
|
-
/**
|
42
|
-
* Fetch answer.
|
35
|
+
* Answer status.
|
43
36
|
*/
|
44
|
-
abstract
|
37
|
+
abstract get status(): AnswerStatus
|
45
38
|
|
46
39
|
/**
|
47
|
-
*
|
40
|
+
* Answer sources.
|
48
41
|
*/
|
49
|
-
abstract
|
42
|
+
abstract get sources(): SourceDto[]
|
50
43
|
|
51
44
|
/**
|
52
45
|
* Cancel answer
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Chat, ChatAnswerType } from "./chat"
|
2
2
|
import { Disposable } from "../../disposable"
|
3
|
-
import { Answer } from "./answer"
|
3
|
+
import { Answer, AnswerId } from "./answer"
|
4
4
|
import { ChatDto } from "../../dto/chatResponse"
|
5
5
|
import { Context } from "../../context"
|
6
6
|
import { AnswerImpl } from "./answer.impl"
|
@@ -27,7 +27,7 @@ export class ChatImpl extends Chat implements Disposable {
|
|
27
27
|
// init answers
|
28
28
|
for (const ans of chat.answers) {
|
29
29
|
// create answer implementation
|
30
|
-
const answer =
|
30
|
+
const answer = new AnswerImpl(this, this.context).initFromHistory(ans)
|
31
31
|
|
32
32
|
// add answer to the collection
|
33
33
|
this._answers.push(answer)
|
@@ -52,9 +52,9 @@ export class ChatImpl extends Chat implements Disposable {
|
|
52
52
|
return this._isDisposed
|
53
53
|
}
|
54
54
|
|
55
|
-
public getAnswer(id:
|
55
|
+
public getAnswer(id: AnswerId): Answer {
|
56
56
|
const answer = this._answers.find(answer => answer.id === id)
|
57
|
-
if (answer){
|
57
|
+
if (answer) {
|
58
58
|
return answer
|
59
59
|
}
|
60
60
|
throw new Error(`Answer with id ${id} is not found`)
|
@@ -80,7 +80,7 @@ export class ChatImpl extends Chat implements Disposable {
|
|
80
80
|
const id = (await response!.json()).id
|
81
81
|
|
82
82
|
// create answer implementation
|
83
|
-
const answer = await new AnswerImpl(this, this.context).
|
83
|
+
const answer = await new AnswerImpl(this, this.context).initNew(id, message)
|
84
84
|
|
85
85
|
// add answer to the collection
|
86
86
|
this._answers.push(answer)
|
@@ -88,37 +88,6 @@ export class ChatImpl extends Chat implements Disposable {
|
|
88
88
|
return answer
|
89
89
|
}
|
90
90
|
|
91
|
-
async update(): Promise<void>{
|
92
|
-
const response = await this.context
|
93
|
-
.resolve(RpcService)
|
94
|
-
?.requestBuilder("api/v1/Chats")
|
95
|
-
.searchParam("id", this.id)
|
96
|
-
.sendGet()
|
97
|
-
|
98
|
-
// check response status
|
99
|
-
if (ResponseUtils.isFail(response)) {
|
100
|
-
await ResponseUtils.throwError(`Failed to update chat ${this.id}`, response)
|
101
|
-
}
|
102
|
-
|
103
|
-
const chat = (await response!.json()).chat as ChatDto
|
104
|
-
|
105
|
-
this._content = chat
|
106
|
-
|
107
|
-
for (const ans of chat.answers) {
|
108
|
-
let answer = this._answers.find(answer => answer.id === ans.id)
|
109
|
-
if (!answer){
|
110
|
-
// create answer implementation
|
111
|
-
answer = new AnswerImpl(this, this.context).initFromData(ans)
|
112
|
-
}else{
|
113
|
-
this._answers.splice(this._answers.indexOf(answer), 1)
|
114
|
-
|
115
|
-
answer.initFromData(ans)
|
116
|
-
}
|
117
|
-
// add answer to the collection
|
118
|
-
this._answers.push(answer)
|
119
|
-
}
|
120
|
-
}
|
121
|
-
|
122
91
|
dispose(): void {
|
123
92
|
this._isDisposed = true
|
124
93
|
}
|
@@ -8,6 +8,8 @@ import { RpcService } from "../../services/rpcService"
|
|
8
8
|
import { OrganizationWorkspaces } from "../../dto/userInfoResponse"
|
9
9
|
import { WorkspaceDto } from "../../dto/workspacesResponse"
|
10
10
|
import { ResponseUtils } from "../../services/responseUtils"
|
11
|
+
import { UserProfileService } from "../../services/userProfileService"
|
12
|
+
import { UserProfile } from "../user/userProfile"
|
11
13
|
|
12
14
|
export class WorkspacesImpl extends Workspaces {
|
13
15
|
private readonly _workspaces: WorkspaceImpl[] = []
|
@@ -184,7 +186,8 @@ export class WorkspacesImpl extends Workspaces {
|
|
184
186
|
|
185
187
|
// check response status
|
186
188
|
if (ResponseUtils.isFail(response)) {
|
187
|
-
|
189
|
+
const userProfile = this.context.resolve(UserProfileService)?.userProfile as UserProfile
|
190
|
+
await ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${organizationId}, userId: ${userProfile.id}, email: ${userProfile.email}`, response)
|
188
191
|
}
|
189
192
|
|
190
193
|
// parse workspaces from the server's response
|
package/src/unitTest.ts
CHANGED
@@ -3,7 +3,7 @@ export enum UnitTest {
|
|
3
3
|
DO_NOT_START = 1 << 0,
|
4
4
|
DO_NOT_PRINT_INITIALIZED_LOG = 1 << 1,
|
5
5
|
|
6
|
-
|
6
|
+
DO_NOT_START_SDK = DO_NOT_START | DO_NOT_PRINT_INITIALIZED_LOG
|
7
7
|
}
|
8
8
|
|
9
9
|
export type UnitTestProfileSyncAction = () => void
|
@@ -17,7 +17,7 @@ class AppSdkUnitTest {
|
|
17
17
|
}
|
18
18
|
|
19
19
|
public static async test(
|
20
|
-
unitTest: UnitTest = UnitTest.
|
20
|
+
unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
|
21
21
|
func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
|
22
22
|
): Promise<void> {
|
23
23
|
this._stack.push(unitTest)
|
@@ -38,7 +38,7 @@ class AppSdkUnitTest {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
export const appTest = async (
|
41
|
-
unitTest: UnitTest = UnitTest.
|
41
|
+
unitTest: UnitTest = UnitTest.DO_NOT_START_SDK,
|
42
42
|
func: UnitTestProfileSyncAction | UnitTestProfileAsyncAction
|
43
43
|
): Promise<void> => {
|
44
44
|
await AppSdkUnitTest.test(unitTest, func)
|