@api-client/core 0.19.3 → 0.19.4
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/build/src/models/AiSession.d.ts +13 -0
- package/build/src/models/AiSession.d.ts.map +1 -1
- package/build/src/models/AiSession.js +8 -0
- package/build/src/models/AiSession.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/models/AiSession.ts +20 -0
- package/tests/unit/models/AiSession.spec.ts +5 -0
package/package.json
CHANGED
package/src/models/AiSession.ts
CHANGED
|
@@ -3,6 +3,13 @@ import { AiSessionKind } from './kinds.js'
|
|
|
3
3
|
import { nanoid } from '../nanoid.js'
|
|
4
4
|
import type { AiModelMessage } from './AiMessage.js'
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* The application the session is for.
|
|
8
|
+
*
|
|
9
|
+
* - `domain` - The session is for data domain modeling.
|
|
10
|
+
* - `api` - The session is for API modeling.
|
|
11
|
+
* - `general` - The session is for general AI chat.
|
|
12
|
+
*/
|
|
6
13
|
export type AiSessionApp = 'domain' | 'api' | 'general'
|
|
7
14
|
|
|
8
15
|
export interface AiSessionSchema {
|
|
@@ -51,6 +58,11 @@ export interface AiSessionSchema {
|
|
|
51
58
|
* Always set when the `delete` is true.
|
|
52
59
|
*/
|
|
53
60
|
deletedInfo?: IDeletion
|
|
61
|
+
/**
|
|
62
|
+
* If the session is related to a file (data domain, API model, etc.), this is the key of the file.
|
|
63
|
+
* It is useful to filter session by specific object.
|
|
64
|
+
*/
|
|
65
|
+
fileKey?: string
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
export class AiSession implements AiSessionSchema {
|
|
@@ -71,6 +83,7 @@ export class AiSession implements AiSessionSchema {
|
|
|
71
83
|
updatedAt: number
|
|
72
84
|
deleted: boolean
|
|
73
85
|
deletedInfo?: IDeletion
|
|
86
|
+
fileKey?: string
|
|
74
87
|
|
|
75
88
|
/**
|
|
76
89
|
* Checks if the given value is a valid AiSessionApp.
|
|
@@ -101,6 +114,9 @@ export class AiSession implements AiSessionSchema {
|
|
|
101
114
|
result.deleted = input.deleted
|
|
102
115
|
result.deletedInfo = input.deletedInfo
|
|
103
116
|
}
|
|
117
|
+
if (input.fileKey) {
|
|
118
|
+
result.fileKey = input.fileKey
|
|
119
|
+
}
|
|
104
120
|
return result
|
|
105
121
|
}
|
|
106
122
|
|
|
@@ -115,6 +131,7 @@ export class AiSession implements AiSessionSchema {
|
|
|
115
131
|
this.updatedAt = init.updatedAt
|
|
116
132
|
this.deleted = init.deleted || false
|
|
117
133
|
this.deletedInfo = init.deletedInfo
|
|
134
|
+
this.fileKey = init.fileKey
|
|
118
135
|
}
|
|
119
136
|
|
|
120
137
|
toJSON(): AiSessionSchema {
|
|
@@ -132,6 +149,9 @@ export class AiSession implements AiSessionSchema {
|
|
|
132
149
|
result.deleted = this.deleted
|
|
133
150
|
result.deletedInfo = { ...this.deletedInfo }
|
|
134
151
|
}
|
|
152
|
+
if (this.fileKey) {
|
|
153
|
+
result.fileKey = this.fileKey
|
|
154
|
+
}
|
|
135
155
|
return result
|
|
136
156
|
}
|
|
137
157
|
|
|
@@ -39,6 +39,7 @@ test.group('AiSession', () => {
|
|
|
39
39
|
assert.equal(schema.updatedAt, 0)
|
|
40
40
|
assert.isUndefined(schema.deleted)
|
|
41
41
|
assert.isUndefined(schema.deletedInfo)
|
|
42
|
+
assert.isUndefined(schema.fileKey)
|
|
42
43
|
})
|
|
43
44
|
|
|
44
45
|
test('constructor builds AiSession instance', ({ assert }) => {
|
|
@@ -50,6 +51,7 @@ test.group('AiSession', () => {
|
|
|
50
51
|
userRenamed: true,
|
|
51
52
|
createdAt: 100,
|
|
52
53
|
updatedAt: 200,
|
|
54
|
+
fileKey: 'file-123',
|
|
53
55
|
})
|
|
54
56
|
|
|
55
57
|
assert.equal(session.key, 'test-key')
|
|
@@ -61,6 +63,7 @@ test.group('AiSession', () => {
|
|
|
61
63
|
assert.equal(session.updatedAt, 200)
|
|
62
64
|
assert.isFalse(session.deleted)
|
|
63
65
|
assert.isUndefined(session.deletedInfo)
|
|
66
|
+
assert.equal(session.fileKey, 'file-123')
|
|
64
67
|
})
|
|
65
68
|
|
|
66
69
|
test('toJSON correctly serializes an AiSession', ({ assert }) => {
|
|
@@ -75,6 +78,7 @@ test.group('AiSession', () => {
|
|
|
75
78
|
byMe: true,
|
|
76
79
|
user: 'user1',
|
|
77
80
|
},
|
|
81
|
+
fileKey: 'file-123',
|
|
78
82
|
})
|
|
79
83
|
session.title = 'Test Title'
|
|
80
84
|
|
|
@@ -94,6 +98,7 @@ test.group('AiSession', () => {
|
|
|
94
98
|
byMe: true,
|
|
95
99
|
user: 'user1',
|
|
96
100
|
},
|
|
101
|
+
fileKey: 'file-123',
|
|
97
102
|
})
|
|
98
103
|
})
|
|
99
104
|
|