@neuralinnovations/dataisland-sdk 0.6.30 → 0.6.32
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/commands/startCommandHandler.js +6 -6
- package/dist/src/commands/startCommandHandler.js.map +1 -1
- package/dist/src/dto/chatbotAccountResponse.d.ts +23 -0
- package/dist/src/dto/chatbotAccountResponse.d.ts.map +1 -0
- package/dist/src/dto/chatbotAccountResponse.js +11 -0
- package/dist/src/dto/chatbotAccountResponse.js.map +1 -0
- package/dist/src/dto/instaResponse.d.ts +6 -0
- package/dist/src/dto/instaResponse.d.ts.map +1 -1
- package/dist/src/dto/instaResponse.js.map +1 -1
- package/dist/src/storages/chatbot/chatbotAccount.d.ts +8 -0
- package/dist/src/storages/chatbot/chatbotAccount.d.ts.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccount.impl.d.ts +12 -0
- package/dist/src/storages/chatbot/chatbotAccount.impl.d.ts.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccount.impl.js +38 -0
- package/dist/src/storages/chatbot/chatbotAccount.impl.js.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccount.js +7 -0
- package/dist/src/storages/chatbot/chatbotAccount.js.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccounts.d.ts +9 -0
- package/dist/src/storages/chatbot/chatbotAccounts.d.ts.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccounts.impl.d.ts +16 -0
- package/dist/src/storages/chatbot/chatbotAccounts.impl.d.ts.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccounts.impl.js +92 -0
- package/dist/src/storages/chatbot/chatbotAccounts.impl.js.map +1 -0
- package/dist/src/storages/chatbot/chatbotAccounts.js +7 -0
- package/dist/src/storages/chatbot/chatbotAccounts.js.map +1 -0
- package/dist/src/storages/chats/chats.d.ts +4 -0
- package/dist/src/storages/chats/chats.d.ts.map +1 -1
- package/dist/src/storages/chats/chats.impl.d.ts +1 -1
- package/dist/src/storages/chats/chats.impl.d.ts.map +1 -1
- package/dist/src/storages/chats/chats.impl.js +2 -2
- package/dist/src/storages/chats/chats.impl.js.map +1 -1
- package/dist/src/storages/chats/chats.js.map +1 -1
- package/dist/src/storages/groups/groups.impl.d.ts +0 -1
- package/dist/src/storages/groups/groups.impl.d.ts.map +1 -1
- package/dist/src/storages/groups/groups.impl.js +0 -3
- package/dist/src/storages/groups/groups.impl.js.map +1 -1
- package/dist/src/storages/insta/instaAccounts.d.ts +2 -0
- package/dist/src/storages/insta/instaAccounts.d.ts.map +1 -1
- package/dist/src/storages/insta/instaAccounts.impl.d.ts +2 -0
- package/dist/src/storages/insta/instaAccounts.impl.d.ts.map +1 -1
- package/dist/src/storages/insta/instaAccounts.impl.js +11 -0
- package/dist/src/storages/insta/instaAccounts.impl.js.map +1 -1
- package/dist/src/storages/insta/instaAccounts.js.map +1 -1
- package/dist/src/storages/organizations/organization.d.ts +5 -0
- package/dist/src/storages/organizations/organization.d.ts.map +1 -1
- package/dist/src/storages/organizations/organization.impl.d.ts +3 -0
- package/dist/src/storages/organizations/organization.impl.d.ts.map +1 -1
- package/dist/src/storages/organizations/organization.impl.js +11 -6
- package/dist/src/storages/organizations/organization.impl.js.map +1 -1
- package/dist/src/storages/organizations/organization.js.map +1 -1
- package/dist/src/storages/queryFlows/queryFlows.d.ts +1 -1
- package/dist/src/storages/queryFlows/queryFlows.d.ts.map +1 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.d.ts +1 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.d.ts.map +1 -1
- package/dist/src/storages/queryFlows/queryFlows.impl.js +2 -6
- package/dist/src/storages/queryFlows/queryFlows.impl.js.map +1 -1
- package/dist/src/storages/workspaces/workspaces.d.ts +4 -0
- package/dist/src/storages/workspaces/workspaces.d.ts.map +1 -1
- package/dist/src/storages/workspaces/workspaces.impl.d.ts +1 -2
- package/dist/src/storages/workspaces/workspaces.impl.d.ts.map +1 -1
- package/dist/src/storages/workspaces/workspaces.impl.js +3 -3
- package/dist/src/storages/workspaces/workspaces.impl.js.map +1 -1
- package/dist/src/storages/workspaces/workspaces.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/startCommandHandler.ts +6 -6
- package/src/dto/chatbotAccountResponse.ts +29 -0
- package/src/dto/instaResponse.ts +9 -0
- package/src/storages/chatbot/chatbotAccount.impl.ts +47 -0
- package/src/storages/chatbot/chatbotAccount.ts +15 -0
- package/src/storages/chatbot/chatbotAccounts.impl.ts +124 -0
- package/src/storages/chatbot/chatbotAccounts.ts +14 -0
- package/src/storages/chats/chats.impl.ts +2 -2
- package/src/storages/chats/chats.ts +5 -0
- package/src/storages/groups/groups.impl.ts +0 -4
- package/src/storages/insta/instaAccounts.impl.ts +21 -0
- package/src/storages/insta/instaAccounts.ts +3 -0
- package/src/storages/organizations/organization.impl.ts +14 -6
- package/src/storages/organizations/organization.ts +6 -0
- package/src/storages/queryFlows/queryFlows.impl.ts +2 -6
- package/src/storages/queryFlows/queryFlows.ts +1 -1
- package/src/storages/workspaces/workspaces.impl.ts +3 -4
- package/src/storages/workspaces/workspaces.ts +5 -0
@@ -0,0 +1,124 @@
|
|
1
|
+
|
2
|
+
import {OrganizationImpl} from "../organizations/organization.impl"
|
3
|
+
import {Context} from "../../context"
|
4
|
+
import {RpcService} from "../../services/rpcService"
|
5
|
+
import {ResponseUtils} from "../../services/responseUtils"
|
6
|
+
import { ChatbotAccounts } from "./chatbotAccounts"
|
7
|
+
import { ChatbotAccount } from "./chatbotAccount"
|
8
|
+
import { ChatbotAccountImpl } from "./chatbotAccount.impl"
|
9
|
+
import { ChatbotAccountDto, ChatbotAccountType, KeyValueItem } from "../../dto/chatbotAccountResponse"
|
10
|
+
|
11
|
+
|
12
|
+
export class ChatbotAccountsImpl extends ChatbotAccounts {
|
13
|
+
private _collection?: ChatbotAccountImpl[]
|
14
|
+
|
15
|
+
constructor(
|
16
|
+
public readonly organization: OrganizationImpl,
|
17
|
+
public readonly context: Context) {
|
18
|
+
super()
|
19
|
+
}
|
20
|
+
|
21
|
+
get collection(): ChatbotAccount[] {
|
22
|
+
if (this._collection !== undefined) {
|
23
|
+
return this._collection
|
24
|
+
}else {
|
25
|
+
throw new Error("Chatbot accounts collection is not loaded, please update it first")
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
async update(): Promise<void> {
|
31
|
+
const response = await this.context
|
32
|
+
.resolve(RpcService)
|
33
|
+
?.requestBuilder("api/v1/ChatbotAccount/list")
|
34
|
+
.searchParam("organizationId", this.organization.id)
|
35
|
+
.sendGet()
|
36
|
+
|
37
|
+
// check response status
|
38
|
+
if (ResponseUtils.isFail(response)) {
|
39
|
+
await ResponseUtils.throwError(
|
40
|
+
`Chatbot accounts list for organization ${this.organization.id} failed`,
|
41
|
+
response
|
42
|
+
)
|
43
|
+
}
|
44
|
+
|
45
|
+
this._collection = []
|
46
|
+
const accounts = (await response!.json() as {accounts: ChatbotAccountDto[]}).accounts
|
47
|
+
this._collection = accounts.map(acc => new ChatbotAccountImpl(this.context, acc))
|
48
|
+
}
|
49
|
+
|
50
|
+
async add(type: ChatbotAccountType, name: string, accountId: string, token: string, accountContext: string, notificationDelays: number[], data: KeyValueItem[]): Promise<void> {
|
51
|
+
|
52
|
+
if (type === undefined || type === null) {
|
53
|
+
throw new Error("Add chatbot account, type can not be null")
|
54
|
+
}
|
55
|
+
if (name === undefined || name === null || name.trim() === "") {
|
56
|
+
throw new Error("Add chatbot account, name can not be null or empty")
|
57
|
+
}
|
58
|
+
if (accountId === undefined || accountId === null || accountId.trim() === "") {
|
59
|
+
throw new Error("Add chatbot account, accountId can not be null or empty")
|
60
|
+
}
|
61
|
+
if (token === undefined || token === null || token.trim() === "") {
|
62
|
+
throw new Error("Add chatbot account, token can not be null or empty")
|
63
|
+
}
|
64
|
+
if (accountContext === undefined || accountContext === null) {
|
65
|
+
throw new Error("Add chatbot account, accountContext can not be null or empty")
|
66
|
+
}
|
67
|
+
if (notificationDelays === undefined || notificationDelays === null) {
|
68
|
+
throw new Error("Add chatbot account, notificationDelays can not be null")
|
69
|
+
}
|
70
|
+
if (data === undefined || data === null) {
|
71
|
+
throw new Error("Add chatbot account, data can not be null")
|
72
|
+
}
|
73
|
+
|
74
|
+
// send create request to the server
|
75
|
+
const response = await this.context
|
76
|
+
.resolve(RpcService)
|
77
|
+
?.requestBuilder("api/v1/ChatbotAccount")
|
78
|
+
.sendPostJson({
|
79
|
+
organizationId: this.organization.id,
|
80
|
+
accountType: type,
|
81
|
+
name: name,
|
82
|
+
token: token,
|
83
|
+
accountId: accountId,
|
84
|
+
context: accountContext,
|
85
|
+
data: data
|
86
|
+
})
|
87
|
+
|
88
|
+
// check response status
|
89
|
+
if (ResponseUtils.isFail(response)) {
|
90
|
+
await ResponseUtils.throwError(`Failed to add chatbot account in organization ${this.organization.id}`, response)
|
91
|
+
}
|
92
|
+
|
93
|
+
await this.update()
|
94
|
+
}
|
95
|
+
|
96
|
+
|
97
|
+
async delete(id: string): Promise<void> {
|
98
|
+
const account = this._collection?.find(acc => acc.id === id)
|
99
|
+
|
100
|
+
// check if account is found
|
101
|
+
if (!account) {
|
102
|
+
throw new Error(`Chatbot account ${id} is not found, organization: ${this.organization.id}`)
|
103
|
+
}
|
104
|
+
|
105
|
+
// send delete request to the server
|
106
|
+
const response = await this.context
|
107
|
+
.resolve(RpcService)
|
108
|
+
?.requestBuilder("api/v1/ChatbotAccount")
|
109
|
+
.searchParam("id", id)
|
110
|
+
.sendDelete()
|
111
|
+
|
112
|
+
// check response status
|
113
|
+
if (ResponseUtils.isFail(response)) {
|
114
|
+
await ResponseUtils.throwError(
|
115
|
+
`Failed to delete chatbot account: ${id}, organization: ${this.organization.id}`,
|
116
|
+
response
|
117
|
+
)
|
118
|
+
}
|
119
|
+
|
120
|
+
await this.update()
|
121
|
+
}
|
122
|
+
|
123
|
+
|
124
|
+
}
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import { ChatbotAccountType, KeyValueItem } from "../../dto/chatbotAccountResponse"
|
2
|
+
import { ChatbotAccount } from "./chatbotAccount"
|
3
|
+
|
4
|
+
|
5
|
+
export abstract class ChatbotAccounts {
|
6
|
+
|
7
|
+
abstract get collection(): ChatbotAccount[]
|
8
|
+
|
9
|
+
abstract update(): Promise<void>
|
10
|
+
|
11
|
+
abstract add(type: ChatbotAccountType, name: string, accountId: string, token: string, accountContext: string, notificationDelays: number[], data: KeyValueItem[]): Promise<void>
|
12
|
+
|
13
|
+
abstract delete(id: string): Promise<void>
|
14
|
+
}
|
@@ -20,8 +20,8 @@ export class ChatsImpl extends Chats {
|
|
20
20
|
super()
|
21
21
|
}
|
22
22
|
|
23
|
-
async
|
24
|
-
await this.loadOrganizationChats(
|
23
|
+
async load(): Promise<void> {
|
24
|
+
await this.loadOrganizationChats(this.organization.id)
|
25
25
|
const libraries = (this.context.resolve(LibrariesService) as LibrariesService).libraries.collection
|
26
26
|
for (const library of libraries){
|
27
27
|
await this.loadLibraryChats(library.id)
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import {InstaAccounts} from "./instaAccounts"
|
2
2
|
import {
|
3
3
|
InstaCutAccountDto,
|
4
|
+
InstaErrorDto,
|
4
5
|
InstaPostDto,
|
5
6
|
PostStatus,
|
6
7
|
} from "../../dto/instaResponse"
|
@@ -242,5 +243,25 @@ export class InstaAccountsImpl extends InstaAccounts {
|
|
242
243
|
await this.update()
|
243
244
|
}
|
244
245
|
|
246
|
+
async errors(): Promise<InstaErrorDto[]> {
|
247
|
+
const response = await this.context
|
248
|
+
.resolve(RpcService)
|
249
|
+
?.requestBuilder("api/v1/Insta/statistics")
|
250
|
+
.searchParam("organizationId", this.organization.id)
|
251
|
+
.sendGet()
|
252
|
+
|
253
|
+
// check response status
|
254
|
+
if (ResponseUtils.isFail(response)) {
|
255
|
+
await ResponseUtils.throwError(
|
256
|
+
`Insta errors list for organization ${this.organization.id} failed`,
|
257
|
+
response
|
258
|
+
)
|
259
|
+
}
|
260
|
+
|
261
|
+
const errors = (await response!.json() as {errors: InstaErrorDto[]}).errors
|
262
|
+
|
263
|
+
return errors
|
264
|
+
}
|
265
|
+
|
245
266
|
|
246
267
|
}
|
@@ -1,4 +1,5 @@
|
|
1
1
|
|
2
|
+
import { InstaErrorDto } from "../../dto/instaResponse"
|
2
3
|
import {InstaAccount} from "./instaAccount"
|
3
4
|
import {InstaPost} from "./instaPost"
|
4
5
|
|
@@ -28,4 +29,6 @@ export abstract class InstaAccounts {
|
|
28
29
|
|
29
30
|
abstract post(): Promise<void>
|
30
31
|
|
32
|
+
abstract errors(): Promise<InstaErrorDto[]>
|
33
|
+
|
31
34
|
}
|
@@ -44,6 +44,8 @@ import {InstaAccountsImpl} from "../insta/instaAccounts.impl"
|
|
44
44
|
import {InstaAccounts} from "../insta/instaAccounts"
|
45
45
|
import {MessengerAccountsImpl} from "../messenger/messengerAccounts.impl"
|
46
46
|
import {MessengerAccounts} from "../messenger/messengerAccounts"
|
47
|
+
import { ChatbotAccountsImpl } from "../chatbot/chatbotAccounts.impl"
|
48
|
+
import { ChatbotAccounts } from "../chatbot/chatbotAccounts"
|
47
49
|
|
48
50
|
export class OrganizationImpl extends Organization implements Disposable {
|
49
51
|
private _isDisposed: boolean = false
|
@@ -54,6 +56,7 @@ export class OrganizationImpl extends Organization implements Disposable {
|
|
54
56
|
private readonly _queryFlows: QueryFlowsImpl
|
55
57
|
private readonly _instaAccounts: InstaAccountsImpl
|
56
58
|
private readonly _messengerAccounts: MessengerAccountsImpl
|
59
|
+
private readonly _chatbotAccounts: ChatbotAccountsImpl
|
57
60
|
private readonly _chats: ChatsImpl
|
58
61
|
private readonly _prompts: OrganizationPromptsImpl
|
59
62
|
|
@@ -65,6 +68,7 @@ export class OrganizationImpl extends Organization implements Disposable {
|
|
65
68
|
this._queryFlows = new QueryFlowsImpl(this, this.context)
|
66
69
|
this._instaAccounts = new InstaAccountsImpl(this, this.context)
|
67
70
|
this._messengerAccounts = new MessengerAccountsImpl(this, this.context)
|
71
|
+
this._chatbotAccounts = new ChatbotAccountsImpl(this, this.context)
|
68
72
|
this._prompts = new OrganizationPromptsImpl(this, this.context)
|
69
73
|
}
|
70
74
|
|
@@ -76,13 +80,13 @@ export class OrganizationImpl extends Organization implements Disposable {
|
|
76
80
|
this._isAdmin = isAdmin
|
77
81
|
|
78
82
|
// init workspaces by organization id
|
79
|
-
const promises = [
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
]
|
83
|
+
// const promises = [
|
84
|
+
// this._workspaces.initFrom(content.id),
|
85
|
+
// this._chats.initFrom(content.id),
|
86
|
+
// this._accessGroups.initialize()
|
87
|
+
// ]
|
84
88
|
|
85
|
-
await Promise.all(promises)
|
89
|
+
// await Promise.all(promises)
|
86
90
|
|
87
91
|
return this
|
88
92
|
}
|
@@ -143,6 +147,10 @@ export class OrganizationImpl extends Organization implements Disposable {
|
|
143
147
|
return this._messengerAccounts
|
144
148
|
}
|
145
149
|
|
150
|
+
get chatbotAccounts(): ChatbotAccounts {
|
151
|
+
return this._chatbotAccounts
|
152
|
+
}
|
153
|
+
|
146
154
|
get chats(): Chats {
|
147
155
|
return this._chats
|
148
156
|
}
|
@@ -20,6 +20,7 @@ import { QueryFlows } from "../queryFlows/queryFlows"
|
|
20
20
|
import { OrganizationPrompts } from "./organizationPrompts"
|
21
21
|
import {InstaAccounts} from "../insta/instaAccounts"
|
22
22
|
import {MessengerAccounts} from "../messenger/messengerAccounts"
|
23
|
+
import { ChatbotAccounts } from "../chatbot/chatbotAccounts"
|
23
24
|
|
24
25
|
/**
|
25
26
|
* Organization event.
|
@@ -95,6 +96,11 @@ export abstract class Organization extends EventDispatcher<
|
|
95
96
|
*/
|
96
97
|
abstract get messengerAccounts(): MessengerAccounts
|
97
98
|
|
99
|
+
/**
|
100
|
+
* Chatbot accounts
|
101
|
+
*/
|
102
|
+
abstract get chatbotAccounts(): ChatbotAccounts
|
103
|
+
|
98
104
|
/**
|
99
105
|
* Get organization prompts
|
100
106
|
*/
|
@@ -85,16 +85,13 @@ export class QueryFlowsImpl extends QueryFlows {
|
|
85
85
|
}
|
86
86
|
}
|
87
87
|
|
88
|
-
async create(name: string, workspaceIds: WorkspaceId[],
|
88
|
+
async create(name: string, workspaceIds: WorkspaceId[], table: UploadFile): Promise<FlowId> {
|
89
89
|
if (name === undefined || name === null || name.trim() === "") {
|
90
90
|
throw new Error("Name is required, must be not empty")
|
91
91
|
}
|
92
92
|
if (workspaceIds === undefined || workspaceIds === null) {
|
93
93
|
throw new Error("WorkspaceIds is required, must be not empty")
|
94
94
|
}
|
95
|
-
if (file === undefined || file === null) {
|
96
|
-
throw new Error("Create query flow, file is undefined or null")
|
97
|
-
}
|
98
95
|
if (table === undefined || table === null) {
|
99
96
|
throw new Error("Create query flow, table is undefined or null")
|
100
97
|
}
|
@@ -103,7 +100,6 @@ export class QueryFlowsImpl extends QueryFlows {
|
|
103
100
|
const form = new FormData()
|
104
101
|
form.append("organizationId", this.organization.id)
|
105
102
|
form.append("name", name)
|
106
|
-
form.append("file", file, file.name)
|
107
103
|
form.append("tableFile", table, table.name)
|
108
104
|
workspaceIds.forEach(item => {
|
109
105
|
form.append("workspaceIds", item)
|
@@ -118,7 +114,7 @@ export class QueryFlowsImpl extends QueryFlows {
|
|
118
114
|
// check response status
|
119
115
|
if (ResponseUtils.isFail(response)) {
|
120
116
|
|
121
|
-
await ResponseUtils.throwError(`Query flow creation for ${
|
117
|
+
await ResponseUtils.throwError(`Query flow creation for ${table.name}`, response)
|
122
118
|
}
|
123
119
|
|
124
120
|
const content = (await response!.json()) as QueryFlowResponse
|
@@ -24,7 +24,7 @@ export abstract class QueryFlows extends EventDispatcher<
|
|
24
24
|
|
25
25
|
abstract getQueryFlows(): Promise<QueryFlow[]>
|
26
26
|
|
27
|
-
abstract create(name: string, workspaceIds: WorkspaceId[],
|
27
|
+
abstract create(name: string, workspaceIds: WorkspaceId[], table: UploadFile ): Promise<FlowId>
|
28
28
|
|
29
29
|
abstract delete(id: FlowId): Promise<void>
|
30
30
|
|
@@ -3,7 +3,6 @@ import { OrganizationImpl } from "../organizations/organization.impl"
|
|
3
3
|
import { Context } from "../../context"
|
4
4
|
import { Workspace } from "./workspace"
|
5
5
|
import { WorkspaceImpl } from "./workspace.impl"
|
6
|
-
import { OrganizationId } from "../organizations/organizations"
|
7
6
|
import { RpcService } from "../../services/rpcService"
|
8
7
|
import { OrganizationWorkspaces } from "../../dto/userInfoResponse"
|
9
8
|
import { WorkspaceDto } from "../../dto/workspacesResponse"
|
@@ -170,18 +169,18 @@ export class WorkspacesImpl extends Workspaces {
|
|
170
169
|
})
|
171
170
|
}
|
172
171
|
|
173
|
-
async
|
172
|
+
async load(): Promise<void> {
|
174
173
|
// init workspaces from the server's response
|
175
174
|
const response = await this.context
|
176
175
|
.resolve(RpcService)
|
177
176
|
?.requestBuilder("api/v1/Organizations")
|
178
|
-
.searchParam("id",
|
177
|
+
.searchParam("id", this.organization.id)
|
179
178
|
.sendGet()
|
180
179
|
|
181
180
|
// check response status
|
182
181
|
if (ResponseUtils.isFail(response)) {
|
183
182
|
const userProfile = this.context.resolve(UserProfileService)?.userProfile as UserProfile
|
184
|
-
await ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${
|
183
|
+
await ResponseUtils.throwError(`Failed to fetch workspaces in organization: ${this.organization.id}, userId: ${userProfile.id}, email: ${userProfile.email}`, response)
|
185
184
|
}
|
186
185
|
|
187
186
|
// parse workspaces from the server's response
|