@syrtis-ai/syrtis-javascript-client 0.0.48 → 0.0.65
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 +1 -10
- package/package.json +15 -8
- package/src/Common/MessageCollection.ts +355 -0
- package/src/Common/SyrtisClient.ts +24 -0
- package/src/Common/entitySchemas.ts +5 -0
- package/src/Common/generatedEntitySchemas.ts +17 -0
- package/src/Common/generatedRepositories.ts +15 -0
- package/src/Entity/Message.ts +10 -0
- package/src/Entity/MessageStamp.ts +10 -0
- package/src/Entity/Request.ts +10 -0
- package/src/Entity/Session.ts +10 -0
- package/src/Entity/User.ts +10 -0
- package/src/Repository/MessageRepository.ts +14 -0
- package/src/Repository/MessageStampRepository.ts +8 -0
- package/src/Repository/RequestRepository.ts +8 -0
- package/src/Repository/SessionRepository.ts +136 -0
- package/{dist/Repository/UserRepository.d.ts → src/Repository/UserRepository.ts} +4 -2
- package/src/Vue/Mixin/Entity/message.vue +10 -0
- package/src/Vue/Mixin/Entity/message_stamp.vue +10 -0
- package/src/Vue/Mixin/Entity/request.vue +10 -0
- package/src/Vue/Mixin/Entity/session.vue +10 -0
- package/src/Vue/Mixin/Entity/user.vue +10 -0
- package/src/Vue/Mixin/EntityManipulator/MessageEntityManipulatorVueMixin.ts +9 -0
- package/src/Vue/Mixin/EntityManipulator/MessageStampEntityManipulatorVueMixin.ts +9 -0
- package/src/Vue/Mixin/EntityManipulator/RequestEntityManipulatorVueMixin.ts +9 -0
- package/src/Vue/Mixin/EntityManipulator/SessionEntityManipulatorVueMixin.ts +9 -0
- package/src/Vue/Mixin/EntityManipulator/UserEntityManipulatorVueMixin.ts +9 -0
- package/src/data/entity/message.json +672 -0
- package/src/data/entity/message_stamp.json +140 -0
- package/src/data/entity/request.json +495 -0
- package/src/data/entity/session.json +364 -0
- package/src/data/entity/user.json +268 -0
- package/src/index.ts +21 -0
- package/dist/Common/SyrtisClient.d.ts +0 -9
- package/dist/Common/SyrtisClient.d.ts.map +0 -1
- package/dist/Common/SyrtisClient.js +0 -18
- package/dist/Common/SyrtisClient.js.map +0 -1
- package/dist/Entity/Scenario.d.ts +0 -7
- package/dist/Entity/Scenario.d.ts.map +0 -1
- package/dist/Entity/Scenario.js +0 -10
- package/dist/Entity/Scenario.js.map +0 -1
- package/dist/Entity/Session.d.ts +0 -7
- package/dist/Entity/Session.d.ts.map +0 -1
- package/dist/Entity/Session.js +0 -10
- package/dist/Entity/Session.js.map +0 -1
- package/dist/Entity/User.d.ts +0 -13
- package/dist/Entity/User.d.ts.map +0 -1
- package/dist/Entity/User.js +0 -22
- package/dist/Entity/User.js.map +0 -1
- package/dist/Repository/ScenarioRepository.d.ts +0 -6
- package/dist/Repository/ScenarioRepository.d.ts.map +0 -1
- package/dist/Repository/ScenarioRepository.js +0 -8
- package/dist/Repository/ScenarioRepository.js.map +0 -1
- package/dist/Repository/SessionRepository.d.ts +0 -6
- package/dist/Repository/SessionRepository.d.ts.map +0 -1
- package/dist/Repository/SessionRepository.js +0 -8
- package/dist/Repository/SessionRepository.js.map +0 -1
- package/dist/Repository/UserRepository.d.ts.map +0 -1
- package/dist/Repository/UserRepository.js +0 -8
- package/dist/Repository/UserRepository.js.map +0 -1
- package/dist/Vue/Mixin/EntityManipulator/ScenarioEntityManipulatorVueMixin.d.ts +0 -8
- package/dist/Vue/Mixin/EntityManipulator/ScenarioEntityManipulatorVueMixin.d.ts.map +0 -1
- package/dist/Vue/Mixin/EntityManipulator/ScenarioEntityManipulatorVueMixin.js +0 -9
- package/dist/Vue/Mixin/EntityManipulator/ScenarioEntityManipulatorVueMixin.js.map +0 -1
- package/dist/Vue/Mixin/EntityManipulator/SessionEntityManipulatorVueMixin.d.ts +0 -8
- package/dist/Vue/Mixin/EntityManipulator/SessionEntityManipulatorVueMixin.d.ts.map +0 -1
- package/dist/Vue/Mixin/EntityManipulator/SessionEntityManipulatorVueMixin.js +0 -9
- package/dist/Vue/Mixin/EntityManipulator/SessionEntityManipulatorVueMixin.js.map +0 -1
- package/dist/Vue/Mixin/EntityManipulator/UserEntityManipulatorVueMixin.d.ts +0 -8
- package/dist/Vue/Mixin/EntityManipulator/UserEntityManipulatorVueMixin.d.ts.map +0 -1
- package/dist/Vue/Mixin/EntityManipulator/UserEntityManipulatorVueMixin.js +0 -9
- package/dist/Vue/Mixin/EntityManipulator/UserEntityManipulatorVueMixin.js.map +0 -1
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -17
- package/dist/index.js.map +0 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import AbstractApiRepository from '@wexample/js-api/Common/AbstractApiRepository';
|
|
2
|
+
import Message from '../Entity/Message.js';
|
|
3
|
+
import Session from '../Entity/Session.js';
|
|
4
|
+
import type MessageRepository from './MessageRepository.js';
|
|
5
|
+
|
|
6
|
+
export type SessionSendMessageOptions = {
|
|
7
|
+
sessionSecureId: string;
|
|
8
|
+
content?: string | null;
|
|
9
|
+
files?: File[];
|
|
10
|
+
contentType?: string;
|
|
11
|
+
format?: string;
|
|
12
|
+
templateId?: string | number | null;
|
|
13
|
+
stamps?: string[];
|
|
14
|
+
name?: string | null;
|
|
15
|
+
metadata?: Record<string, unknown> | unknown[] | null;
|
|
16
|
+
fileStamps?: Record<string, string[]>;
|
|
17
|
+
parentRequestSecureId?: string | null;
|
|
18
|
+
timeZone?: string | null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type SessionFetchHistoryOptions = {
|
|
22
|
+
sessionSecureId: string;
|
|
23
|
+
page?: number;
|
|
24
|
+
length?: number | null;
|
|
25
|
+
lastRequestSecureId?: string | null;
|
|
26
|
+
orderBy?: string | null;
|
|
27
|
+
orderDirection?: 'ASC' | 'DESC' | null;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default class SessionRepository extends AbstractApiRepository<Session> {
|
|
31
|
+
static getEntityType() {
|
|
32
|
+
return Session;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async sendMessage(options: SessionSendMessageOptions): Promise<unknown> {
|
|
36
|
+
const {
|
|
37
|
+
sessionSecureId,
|
|
38
|
+
content = null,
|
|
39
|
+
files = [],
|
|
40
|
+
contentType = 'conversation',
|
|
41
|
+
format = 'text',
|
|
42
|
+
templateId = null,
|
|
43
|
+
stamps = [],
|
|
44
|
+
name = null,
|
|
45
|
+
metadata = null,
|
|
46
|
+
fileStamps = {},
|
|
47
|
+
parentRequestSecureId = null,
|
|
48
|
+
timeZone = null,
|
|
49
|
+
} = options;
|
|
50
|
+
|
|
51
|
+
const trimmedSecureId = String(sessionSecureId || '').trim();
|
|
52
|
+
if (!trimmedSecureId) {
|
|
53
|
+
throw new Error('Session secureId is required.');
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const trimmedContent = typeof content === 'string' ? content.trim() : '';
|
|
57
|
+
if (!trimmedContent && files.length === 0) {
|
|
58
|
+
throw new Error('Message content or at least one file is required.');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const messages = [];
|
|
62
|
+
if (trimmedContent) {
|
|
63
|
+
messages.push({
|
|
64
|
+
contentType,
|
|
65
|
+
format,
|
|
66
|
+
templateId,
|
|
67
|
+
stamps,
|
|
68
|
+
content: trimmedContent,
|
|
69
|
+
metadata,
|
|
70
|
+
name,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return this.client
|
|
75
|
+
.requestFormDataFromJson({
|
|
76
|
+
path: this.buildPath(`continue/${encodeURIComponent(trimmedSecureId)}`),
|
|
77
|
+
data: {
|
|
78
|
+
messages,
|
|
79
|
+
fileStamps,
|
|
80
|
+
parentRequestSecureId,
|
|
81
|
+
timeZone: timeZone || Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
82
|
+
},
|
|
83
|
+
files,
|
|
84
|
+
})
|
|
85
|
+
.json<unknown>();
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async fetchHistory(options: SessionFetchHistoryOptions): Promise<Message[]> {
|
|
89
|
+
const {
|
|
90
|
+
sessionSecureId,
|
|
91
|
+
page = 0,
|
|
92
|
+
length = 50,
|
|
93
|
+
lastRequestSecureId = null,
|
|
94
|
+
orderBy = null,
|
|
95
|
+
orderDirection = null,
|
|
96
|
+
} = options;
|
|
97
|
+
|
|
98
|
+
const trimmedSecureId = String(sessionSecureId || '').trim();
|
|
99
|
+
if (!trimmedSecureId) {
|
|
100
|
+
throw new Error('Session secureId is required.');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const searchParams: Record<string, string | number> = {
|
|
104
|
+
page,
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
if (length !== null) {
|
|
108
|
+
searchParams.length = length;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (lastRequestSecureId) {
|
|
112
|
+
searchParams.lastRequestSecureId = lastRequestSecureId;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
if (orderBy) {
|
|
116
|
+
searchParams.orderBy = orderBy;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
if (orderDirection) {
|
|
120
|
+
searchParams.orderDirection = orderDirection;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const data = await this.client
|
|
124
|
+
.get({
|
|
125
|
+
path: this.buildPath(`history/${encodeURIComponent(trimmedSecureId)}`),
|
|
126
|
+
options: { searchParams },
|
|
127
|
+
})
|
|
128
|
+
.json<unknown>();
|
|
129
|
+
|
|
130
|
+
const payload = this.extractPayload(data);
|
|
131
|
+
const items = this.extractItems(payload);
|
|
132
|
+
|
|
133
|
+
const messageRepository = this.client.getRepository(Message) as MessageRepository;
|
|
134
|
+
return messageRepository.hydrateFromApiCollection(items);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import AbstractApiRepository from '@wexample/js-api/Common/AbstractApiRepository';
|
|
2
2
|
import User from '../Entity/User.js';
|
|
3
|
+
|
|
3
4
|
export default class UserRepository extends AbstractApiRepository<User> {
|
|
4
|
-
|
|
5
|
+
static getEntityType() {
|
|
6
|
+
return User;
|
|
7
|
+
}
|
|
5
8
|
}
|
|
6
|
-
//# sourceMappingURL=UserRepository.d.ts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import AbstractEntitySingleMixin from "@wexample/js-api/Vue/AbstractEntitySingleMixin";
|
|
3
|
+
import MessageEntityManipulatorVueMixin from '../EntityManipulator/MessageEntityManipulatorVueMixin';
|
|
4
|
+
import Entity from '@wexample/symfony-design-system/vue/bases/entity';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
extends: Entity,
|
|
8
|
+
mixins: [AbstractEntitySingleMixin, MessageEntityManipulatorVueMixin],
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import AbstractEntitySingleMixin from "@wexample/js-api/Vue/AbstractEntitySingleMixin";
|
|
3
|
+
import MessageStampEntityManipulatorVueMixin from '../EntityManipulator/MessageStampEntityManipulatorVueMixin';
|
|
4
|
+
import Entity from '@wexample/symfony-design-system/vue/bases/entity';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
extends: Entity,
|
|
8
|
+
mixins: [AbstractEntitySingleMixin, MessageStampEntityManipulatorVueMixin],
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import AbstractEntitySingleMixin from "@wexample/js-api/Vue/AbstractEntitySingleMixin";
|
|
3
|
+
import RequestEntityManipulatorVueMixin from '../EntityManipulator/RequestEntityManipulatorVueMixin';
|
|
4
|
+
import Entity from '@wexample/symfony-design-system/vue/bases/entity';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
extends: Entity,
|
|
8
|
+
mixins: [AbstractEntitySingleMixin, RequestEntityManipulatorVueMixin],
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import AbstractEntitySingleMixin from "@wexample/js-api/Vue/AbstractEntitySingleMixin";
|
|
3
|
+
import SessionEntityManipulatorVueMixin from '../EntityManipulator/SessionEntityManipulatorVueMixin';
|
|
4
|
+
import Entity from '@wexample/symfony-design-system/vue/bases/entity';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
extends: Entity,
|
|
8
|
+
mixins: [AbstractEntitySingleMixin, SessionEntityManipulatorVueMixin],
|
|
9
|
+
};
|
|
10
|
+
</script>
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
import AbstractEntitySingleMixin from "@wexample/js-api/Vue/AbstractEntitySingleMixin";
|
|
3
|
+
import UserEntityManipulatorVueMixin from '../EntityManipulator/UserEntityManipulatorVueMixin';
|
|
4
|
+
import Entity from '@wexample/symfony-design-system/vue/bases/entity';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
extends: Entity,
|
|
8
|
+
mixins: [AbstractEntitySingleMixin, UserEntityManipulatorVueMixin],
|
|
9
|
+
};
|
|
10
|
+
</script>
|