@coasys/ad4m 0.12.0-rc1-dev.1 → 0.12.0-rc1-dev.2

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.
Files changed (128) hide show
  1. package/jest.config.js +4 -4
  2. package/lib/index.cjs +5999 -6046
  3. package/lib/index.js +5977 -6040
  4. package/lib/src/Ad4mClient.d.ts +16 -9
  5. package/lib/src/Ad4mClient.js +25 -46
  6. package/lib/src/Ad4mClient.test.d.ts +1 -0
  7. package/lib/src/Ad4mClient.test.js +1204 -0
  8. package/lib/src/Literal.d.ts +2 -1
  9. package/lib/src/Literal.js +35 -38
  10. package/lib/src/Literal.test.d.ts +1 -0
  11. package/lib/src/Literal.test.js +41 -0
  12. package/lib/src/SmartLiteral.d.ts +2 -1
  13. package/lib/src/SmartLiteral.js +15 -30
  14. package/lib/src/agent/AgentClient.d.ts +4 -1
  15. package/lib/src/agent/AgentClient.js +99 -79
  16. package/lib/src/ai/AIClient.d.ts +2 -1
  17. package/lib/src/ai/AIClient.js +220 -224
  18. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  19. package/lib/src/expression/ExpressionClient.js +86 -73
  20. package/lib/src/index.d.ts +1 -1
  21. package/lib/src/index.js +1 -1
  22. package/lib/src/language/LanguageClient.d.ts +1 -1
  23. package/lib/src/language/LanguageClient.js +52 -52
  24. package/lib/src/model/Ad4mModel.d.ts +157 -937
  25. package/lib/src/model/Ad4mModel.js +212 -2799
  26. package/lib/src/model/Ad4mModel.test.js +1002 -561
  27. package/lib/src/model/decorators.d.ts +94 -426
  28. package/lib/src/model/decorators.js +333 -741
  29. package/lib/src/model/mutation.d.ts +81 -0
  30. package/lib/src/model/mutation.js +317 -0
  31. package/lib/src/model/parentUtils.d.ts +32 -0
  32. package/lib/src/model/parentUtils.js +64 -0
  33. package/lib/src/model/prolog/generatePrologFacts.d.ts +36 -0
  34. package/lib/src/model/prolog/generatePrologFacts.js +139 -0
  35. package/lib/src/model/prolog/index.d.ts +1 -0
  36. package/lib/src/model/prolog/index.js +1 -0
  37. package/lib/src/model/query/ModelQueryBuilder.d.ts +82 -0
  38. package/lib/src/model/query/ModelQueryBuilder.js +115 -0
  39. package/lib/src/model/query/QueryBuilder.d.ts +101 -0
  40. package/lib/src/model/query/QueryBuilder.js +193 -0
  41. package/lib/src/model/query/SurrealQueryBuilder.d.ts +48 -0
  42. package/lib/src/model/query/SurrealQueryBuilder.js +371 -0
  43. package/lib/src/model/query/fetchInstance.d.ts +24 -0
  44. package/lib/src/model/query/fetchInstance.js +144 -0
  45. package/lib/src/model/query/hydration.d.ts +54 -0
  46. package/lib/src/model/query/hydration.js +214 -0
  47. package/lib/src/model/query/operations.d.ts +59 -0
  48. package/lib/src/model/query/operations.js +384 -0
  49. package/lib/src/model/query/snapshot.d.ts +59 -0
  50. package/lib/src/model/query/snapshot.js +106 -0
  51. package/lib/src/model/query/surrealCompiler.d.ts +42 -0
  52. package/lib/src/model/query/surrealCompiler.js +304 -0
  53. package/lib/src/model/schema/fromJSONSchema.d.ts +67 -0
  54. package/lib/src/model/schema/fromJSONSchema.js +264 -0
  55. package/lib/src/model/schema/metadata.d.ts +15 -0
  56. package/lib/src/model/schema/metadata.js +112 -0
  57. package/lib/src/model/subscription.d.ts +47 -0
  58. package/lib/src/model/subscription.js +231 -0
  59. package/lib/src/model/transaction.d.ts +27 -0
  60. package/lib/src/model/transaction.js +32 -0
  61. package/lib/src/model/types.d.ts +195 -0
  62. package/lib/src/model/types.js +8 -0
  63. package/lib/src/model/util.js +7 -7
  64. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +5 -1
  65. package/lib/src/neighbourhood/NeighbourhoodClient.js +263 -181
  66. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +2 -1
  67. package/lib/src/neighbourhood/NeighbourhoodProxy.js +13 -28
  68. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +1 -5
  69. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  70. package/lib/src/perspectives/PerspectiveClient.js +316 -240
  71. package/lib/src/perspectives/PerspectiveProxy.d.ts +54 -92
  72. package/lib/src/perspectives/PerspectiveProxy.js +803 -444
  73. package/lib/src/runtime/RuntimeClient.d.ts +5 -1
  74. package/lib/src/runtime/RuntimeClient.js +412 -238
  75. package/lib/src/shacl/SHACLFlow.test.js +164 -105
  76. package/lib/src/shacl/SHACLShape.d.ts +17 -3
  77. package/lib/src/shacl/SHACLShape.js +127 -90
  78. package/lib/src/shacl/SHACLShape.test.js +244 -176
  79. package/lib/src/utils.d.ts +8 -0
  80. package/lib/src/utils.js +21 -7
  81. package/package.json +8 -13
  82. package/src/Ad4mClient.test.ts +1564 -1315
  83. package/src/Ad4mClient.ts +55 -54
  84. package/src/Literal.test.ts +45 -26
  85. package/src/Literal.ts +82 -66
  86. package/src/SmartLiteral.ts +74 -58
  87. package/src/agent/AgentClient.ts +144 -99
  88. package/src/ai/AIClient.ts +409 -359
  89. package/src/expression/ExpressionClient.ts +142 -96
  90. package/src/index.ts +1 -1
  91. package/src/language/LanguageClient.ts +137 -113
  92. package/src/model/Ad4mModel.test.ts +1128 -647
  93. package/src/model/Ad4mModel.ts +485 -3249
  94. package/src/model/IMPROVEMENTS.md +482 -0
  95. package/src/model/PREDICATE_COLLISION_FIX.md +651 -0
  96. package/src/model/README.md +317 -0
  97. package/src/model/SHACL_MUTATION_DECOUPLING.md +356 -0
  98. package/src/model/SUBSCRIPTION_STRATEGY.md +317 -0
  99. package/src/model/TC39_STAGE_3_DECORATORS.md +609 -0
  100. package/src/model/decorators.ts +689 -1046
  101. package/src/model/mutation.ts +461 -0
  102. package/src/model/parentUtils.ts +91 -0
  103. package/src/model/prolog/generatePrologFacts.ts +176 -0
  104. package/src/model/prolog/index.ts +1 -0
  105. package/src/model/query/ModelQueryBuilder.ts +173 -0
  106. package/src/model/query/fetchInstance.ts +181 -0
  107. package/src/model/query/hydration.ts +273 -0
  108. package/src/model/query/operations.ts +510 -0
  109. package/src/model/query/snapshot.ts +126 -0
  110. package/src/model/query/surrealCompiler.ts +376 -0
  111. package/src/model/schema/fromJSONSchema.ts +411 -0
  112. package/src/model/schema/metadata.ts +148 -0
  113. package/src/model/subscription.ts +307 -0
  114. package/src/model/transaction.ts +60 -0
  115. package/src/model/types.ts +207 -0
  116. package/src/model/util.ts +47 -48
  117. package/src/neighbourhood/NeighbourhoodClient.ts +393 -251
  118. package/src/neighbourhood/NeighbourhoodProxy.test.ts +3 -7
  119. package/src/neighbourhood/NeighbourhoodProxy.ts +58 -40
  120. package/src/perspectives/PerspectiveClient.ts +779 -540
  121. package/src/perspectives/PerspectiveProxy.ts +2860 -2053
  122. package/src/runtime/RuntimeClient.ts +775 -476
  123. package/src/shacl/SHACLFlow.test.ts +196 -129
  124. package/src/shacl/SHACLShape.test.ts +284 -190
  125. package/src/shacl/SHACLShape.ts +225 -172
  126. package/src/utils.ts +31 -17
  127. package/tsconfig.json +9 -10
  128. package/src/model/Subject.ts +0 -159
@@ -1,342 +1,338 @@
1
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
2
- if (kind === "m") throw new TypeError("Private method is not writable");
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
5
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
6
- };
7
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
8
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
9
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
- };
12
- var _AIClient_apolloClient, _AIClient_transcriptionSubscriptions;
13
1
  import { gql } from "@apollo/client";
14
2
  import unwrapApolloResult from "../unwrapApolloResult";
15
- import base64js from 'base64-js';
16
- import pako from 'pako';
3
+ import { isSocketCloseError } from "../utils";
4
+ import base64js from "base64-js";
5
+ import pako from "pako";
17
6
  import { AITaskInput } from "./Tasks";
18
7
  export class AIClient {
19
8
  constructor(apolloClient, subscribe = true) {
20
- _AIClient_apolloClient.set(this, void 0);
21
- _AIClient_transcriptionSubscriptions.set(this, new Map());
22
- __classPrivateFieldSet(this, _AIClient_apolloClient, apolloClient, "f");
9
+ this._transcriptionSubscriptions = new Map();
10
+ this._apolloClient = apolloClient;
23
11
  }
24
12
  async getModels() {
25
- const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
13
+ const result = await this._apolloClient.query({
26
14
  query: gql `
27
- query {
28
- aiGetModels {
29
- id
30
- name
31
- api {
32
- baseUrl
33
- apiKey
34
- model
35
- apiType
36
- }
37
- local {
38
- fileName
39
- tokenizerSource {
40
- repo
41
- revision
42
- fileName
43
- }
44
- huggingfaceRepo
45
- revision
46
- }
47
- modelType
48
- }
49
- }
50
- `
15
+ query {
16
+ aiGetModels {
17
+ id
18
+ name
19
+ api {
20
+ baseUrl
21
+ apiKey
22
+ model
23
+ apiType
24
+ }
25
+ local {
26
+ fileName
27
+ tokenizerSource {
28
+ repo
29
+ revision
30
+ fileName
31
+ }
32
+ huggingfaceRepo
33
+ revision
34
+ }
35
+ modelType
36
+ }
37
+ }
38
+ `,
51
39
  });
52
40
  return unwrapApolloResult(result).aiGetModels;
53
41
  }
54
42
  async addModel(model) {
55
- const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
43
+ const result = await this._apolloClient.mutate({
56
44
  mutation: gql `
57
- mutation($model: ModelInput!) {
58
- aiAddModel(model: $model)
59
- }
60
- `,
61
- variables: { model }
45
+ mutation ($model: ModelInput!) {
46
+ aiAddModel(model: $model)
47
+ }
48
+ `,
49
+ variables: { model },
62
50
  });
63
51
  return unwrapApolloResult(result).aiAddModel;
64
52
  }
65
53
  async updateModel(modelId, model) {
66
- const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
54
+ const result = await this._apolloClient.mutate({
67
55
  mutation: gql `
68
- mutation($modelId: String!, $model: ModelInput!) {
69
- aiUpdateModel(modelId: $modelId, model: $model)
70
- }
71
- `,
72
- variables: { modelId, model }
56
+ mutation ($modelId: String!, $model: ModelInput!) {
57
+ aiUpdateModel(modelId: $modelId, model: $model)
58
+ }
59
+ `,
60
+ variables: { modelId, model },
73
61
  });
74
62
  return unwrapApolloResult(result).aiUpdateModel;
75
63
  }
76
64
  async removeModel(modelId) {
77
- const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
65
+ const result = await this._apolloClient.mutate({
78
66
  mutation: gql `
79
- mutation($modelId: String!) {
80
- aiRemoveModel(modelId: $modelId)
81
- }
82
- `,
83
- variables: { modelId }
67
+ mutation ($modelId: String!) {
68
+ aiRemoveModel(modelId: $modelId)
69
+ }
70
+ `,
71
+ variables: { modelId },
84
72
  });
85
73
  return unwrapApolloResult(result).aiRemoveModel;
86
74
  }
87
75
  async setDefaultModel(modelType, modelId) {
88
- const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
76
+ const result = await this._apolloClient.mutate({
89
77
  mutation: gql `
90
- mutation($modelType: ModelType!, $modelId: String!) {
91
- aiSetDefaultModel(modelType: $modelType modelId: $modelId)
92
- }
93
- `,
94
- variables: { modelId, modelType }
78
+ mutation ($modelType: ModelType!, $modelId: String!) {
79
+ aiSetDefaultModel(modelType: $modelType, modelId: $modelId)
80
+ }
81
+ `,
82
+ variables: { modelId, modelType },
95
83
  });
96
84
  return unwrapApolloResult(result).aiSetDefaultModel;
97
85
  }
98
86
  async getDefaultModel(modelType) {
99
- const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
87
+ const result = await this._apolloClient.query({
100
88
  query: gql `
101
- query($modelType: ModelType!) {
102
- aiGetDefaultModel(modelType: $modelType) {
103
- id
104
- name
105
- api {
106
- baseUrl
107
- apiKey
108
- model
109
- apiType
110
- }
111
- local {
112
- fileName
113
- tokenizerSource {
114
- repo
115
- revision
116
- fileName
117
- }
118
- huggingfaceRepo
119
- revision
120
- }
121
- modelType
122
- }
123
- }
124
- `,
125
- variables: { modelType }
89
+ query ($modelType: ModelType!) {
90
+ aiGetDefaultModel(modelType: $modelType) {
91
+ id
92
+ name
93
+ api {
94
+ baseUrl
95
+ apiKey
96
+ model
97
+ apiType
98
+ }
99
+ local {
100
+ fileName
101
+ tokenizerSource {
102
+ repo
103
+ revision
104
+ fileName
105
+ }
106
+ huggingfaceRepo
107
+ revision
108
+ }
109
+ modelType
110
+ }
111
+ }
112
+ `,
113
+ variables: { modelType },
126
114
  });
127
115
  return unwrapApolloResult(result).aiGetDefaultModel;
128
116
  }
129
117
  async tasks() {
130
- const { aiTasks } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
118
+ const { aiTasks } = unwrapApolloResult(await this._apolloClient.query({
131
119
  query: gql `
132
- query {
133
- aiTasks {
134
- name
135
- modelId
136
- taskId
137
- systemPrompt
138
- promptExamples {
139
- input
140
- output
141
- }
142
- metaData
143
- createdAt
144
- updatedAt
145
- }
146
- }
147
- `
120
+ query {
121
+ aiTasks {
122
+ name
123
+ modelId
124
+ taskId
125
+ systemPrompt
126
+ promptExamples {
127
+ input
128
+ output
129
+ }
130
+ metaData
131
+ createdAt
132
+ updatedAt
133
+ }
134
+ }
135
+ `,
148
136
  }));
149
137
  return aiTasks;
150
138
  }
151
139
  async addTask(name, modelId, systemPrompt, promptExamples, metaData) {
152
140
  const task = new AITaskInput(name, modelId, systemPrompt, promptExamples, metaData);
153
- const { aiAddTask } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
141
+ const { aiAddTask } = unwrapApolloResult(await this._apolloClient.mutate({
154
142
  mutation: gql `
155
- mutation AiAddTask($task: AITaskInput!) {
156
- aiAddTask(task: $task) {
157
- name
158
- modelId
159
- taskId
160
- systemPrompt
161
- promptExamples {
162
- input
163
- output
164
- }
165
- metaData
166
- createdAt
167
- updatedAt
168
- }
169
- }
170
- `,
171
- variables: {
172
- task
143
+ mutation AiAddTask($task: AITaskInput!) {
144
+ aiAddTask(task: $task) {
145
+ name
146
+ modelId
147
+ taskId
148
+ systemPrompt
149
+ promptExamples {
150
+ input
151
+ output
152
+ }
153
+ metaData
154
+ createdAt
155
+ updatedAt
173
156
  }
157
+ }
158
+ `,
159
+ variables: {
160
+ task,
161
+ },
174
162
  }));
175
163
  return aiAddTask;
176
164
  }
177
165
  async removeTask(taskId) {
178
- const { aiRemoveTask } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
166
+ const { aiRemoveTask } = unwrapApolloResult(await this._apolloClient.mutate({
179
167
  mutation: gql `
180
- mutation AiRemoveTask($taskId: String!) {
181
- aiRemoveTask(taskId: $taskId) {
182
- name
183
- modelId
184
- taskId
185
- systemPrompt
186
- promptExamples {
187
- input
188
- output
189
- }
190
- metaData
191
- createdAt
192
- updatedAt
193
- }
194
- }
195
- `,
196
- variables: {
197
- taskId
168
+ mutation AiRemoveTask($taskId: String!) {
169
+ aiRemoveTask(taskId: $taskId) {
170
+ name
171
+ modelId
172
+ taskId
173
+ systemPrompt
174
+ promptExamples {
175
+ input
176
+ output
177
+ }
178
+ metaData
179
+ createdAt
180
+ updatedAt
198
181
  }
182
+ }
183
+ `,
184
+ variables: {
185
+ taskId,
186
+ },
199
187
  }));
200
188
  return aiRemoveTask;
201
189
  }
202
190
  async updateTask(taskId, task) {
203
- const { aiUpdateTask } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
191
+ const { aiUpdateTask } = unwrapApolloResult(await this._apolloClient.mutate({
204
192
  mutation: gql `
205
- mutation AiUpdateTask($taskId: String!, $task: AITaskInput!) {
206
- aiUpdateTask(taskId: $taskId, task: $task) {
207
- name
208
- modelId
209
- taskId
210
- systemPrompt
211
- promptExamples {
212
- input
213
- output
214
- }
215
- metaData
216
- createdAt
217
- updatedAt
218
- }
219
- }
220
- `,
193
+ mutation AiUpdateTask($taskId: String!, $task: AITaskInput!) {
194
+ aiUpdateTask(taskId: $taskId, task: $task) {
195
+ name
196
+ modelId
197
+ taskId
198
+ systemPrompt
199
+ promptExamples {
200
+ input
201
+ output
202
+ }
203
+ metaData
204
+ createdAt
205
+ updatedAt
206
+ }
207
+ }
208
+ `,
221
209
  variables: {
222
210
  taskId,
223
211
  task: {
224
212
  name: task.name,
225
213
  modelId: task.modelId,
226
214
  systemPrompt: task.systemPrompt,
227
- promptExamples: task.promptExamples
228
- }
229
- }
215
+ promptExamples: task.promptExamples,
216
+ },
217
+ },
230
218
  }));
231
219
  return aiUpdateTask;
232
220
  }
233
221
  async modelLoadingStatus(model) {
234
- const { aiModelLoadingStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
222
+ const { aiModelLoadingStatus } = unwrapApolloResult(await this._apolloClient.query({
235
223
  query: gql `
236
- query AiModelLoadingStatus($model: String!) {
237
- aiModelLoadingStatus(model: $model) {
238
- model
239
- status
240
- progress
241
- loaded
242
- downloaded
243
- }
244
- }
245
- `,
246
- variables: {
247
- model
224
+ query AiModelLoadingStatus($model: String!) {
225
+ aiModelLoadingStatus(model: $model) {
226
+ model
227
+ status
228
+ progress
229
+ loaded
230
+ downloaded
248
231
  }
232
+ }
233
+ `,
234
+ variables: {
235
+ model,
236
+ },
249
237
  }));
250
238
  return aiModelLoadingStatus;
251
239
  }
252
240
  async prompt(taskId, prompt) {
253
- const { aiPrompt } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
241
+ const { aiPrompt } = unwrapApolloResult(await this._apolloClient.mutate({
254
242
  mutation: gql `
255
- mutation AiPrompt($taskId: String!, $prompt: String!) {
256
- aiPrompt(taskId: $taskId, prompt: $prompt)
257
- }
258
- `,
243
+ mutation AiPrompt($taskId: String!, $prompt: String!) {
244
+ aiPrompt(taskId: $taskId, prompt: $prompt)
245
+ }
246
+ `,
259
247
  variables: {
260
248
  taskId,
261
- prompt
262
- }
249
+ prompt,
250
+ },
263
251
  }));
264
252
  return aiPrompt;
265
253
  }
266
254
  async embed(modelId, text) {
267
- const { aiEmbed } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
255
+ const { aiEmbed } = unwrapApolloResult(await this._apolloClient.mutate({
268
256
  mutation: gql `
269
- mutation aiEmbed($modelId: String!, $text: String!) {
270
- aiEmbed(modelId: $modelId, text: $text)
271
- }
272
- `,
257
+ mutation aiEmbed($modelId: String!, $text: String!) {
258
+ aiEmbed(modelId: $modelId, text: $text)
259
+ }
260
+ `,
273
261
  variables: {
274
262
  modelId,
275
- text
276
- }
263
+ text,
264
+ },
277
265
  }));
278
266
  const compressed = base64js.toByteArray(aiEmbed);
279
- const decompressed = JSON.parse(pako.inflate(compressed, { to: 'string' }));
267
+ const decompressed = JSON.parse(pako.inflate(compressed, { to: "string" }));
280
268
  return decompressed;
281
269
  }
282
270
  async openTranscriptionStream(modelId, streamCallback, params) {
283
- const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
271
+ const { aiOpenTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
284
272
  mutation: gql `
285
- mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
286
- aiOpenTranscriptionStream(modelId: $modelId, params: $params)
287
- }
288
- `,
273
+ mutation AiOpenTranscriptionStream(
274
+ $modelId: String!
275
+ $params: VoiceActivityParamsInput
276
+ ) {
277
+ aiOpenTranscriptionStream(modelId: $modelId, params: $params)
278
+ }
279
+ `,
289
280
  variables: {
290
281
  modelId,
291
- params
292
- }
282
+ params,
283
+ },
293
284
  }));
294
- const subscription = __classPrivateFieldGet(this, _AIClient_apolloClient, "f").subscribe({
285
+ const subscription = this._apolloClient
286
+ .subscribe({
295
287
  query: gql ` subscription {
296
288
  aiTranscriptionText(streamId: "${aiOpenTranscriptionStream}")
297
- }`
298
- }).subscribe({
289
+ }`,
290
+ })
291
+ .subscribe({
299
292
  next(data) {
300
293
  streamCallback(data.data.aiTranscriptionText);
301
294
  return data.data.aiTranscriptionText;
302
295
  },
303
296
  error(err) {
304
- console.error(err);
305
- }
297
+ if (!isSocketCloseError(err))
298
+ console.error(err);
299
+ },
306
300
  });
307
- __classPrivateFieldGet(this, _AIClient_transcriptionSubscriptions, "f").set(aiOpenTranscriptionStream, subscription);
301
+ this._transcriptionSubscriptions.set(aiOpenTranscriptionStream, subscription);
308
302
  return aiOpenTranscriptionStream;
309
303
  }
310
304
  async closeTranscriptionStream(streamId) {
311
- const { aiCloseTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
305
+ const { aiCloseTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
312
306
  mutation: gql `
313
- mutation aiCloseTranscriptionStream($streamId: String!) {
314
- aiCloseTranscriptionStream(streamId: $streamId)
315
- }
316
- `,
307
+ mutation aiCloseTranscriptionStream($streamId: String!) {
308
+ aiCloseTranscriptionStream(streamId: $streamId)
309
+ }
310
+ `,
317
311
  variables: {
318
- streamId
319
- }
312
+ streamId,
313
+ },
320
314
  }));
321
- const subscription = __classPrivateFieldGet(this, _AIClient_transcriptionSubscriptions, "f").get(streamId);
315
+ const subscription = this._transcriptionSubscriptions.get(streamId);
322
316
  if (!subscription.closed) {
323
317
  subscription.unsubscribe();
324
318
  }
325
319
  return aiCloseTranscriptionStream;
326
320
  }
327
321
  async feedTranscriptionStream(streamIds, audio) {
328
- const { aiFeedTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
322
+ const { aiFeedTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
329
323
  mutation: gql `
330
- mutation AiFeedTranscriptionStream($streamIds: [String!]!, $audio: [Float!]!) {
331
- aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
332
- }
333
- `,
324
+ mutation AiFeedTranscriptionStream(
325
+ $streamIds: [String!]!
326
+ $audio: [Float!]!
327
+ ) {
328
+ aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
329
+ }
330
+ `,
334
331
  variables: {
335
332
  streamIds: Array.isArray(streamIds) ? streamIds : [streamIds],
336
- audio: audio
337
- }
333
+ audio: audio,
334
+ },
338
335
  }));
339
336
  return aiFeedTranscriptionStream;
340
337
  }
341
338
  }
342
- _AIClient_apolloClient = new WeakMap(), _AIClient_transcriptionSubscriptions = new WeakMap();
@@ -2,7 +2,7 @@ import { ApolloClient } from "@apollo/client/core";
2
2
  import { InteractionCall, InteractionMeta } from "../language/Language";
3
3
  import { ExpressionRendered } from "./Expression";
4
4
  export declare class ExpressionClient {
5
- #private;
5
+ private _apolloClient;
6
6
  constructor(client: ApolloClient<any>);
7
7
  get(url: string, alwaysGet?: boolean): Promise<ExpressionRendered>;
8
8
  getMany(urls: string[]): Promise<ExpressionRendered[]>;