@coasys/ad4m 0.12.0-rc1-dev.2 → 0.12.0-rc1-dev.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.
Files changed (153) hide show
  1. package/jest.config.js +10 -3
  2. package/lib/index.cjs +6893 -5884
  3. package/lib/index.js +6889 -5872
  4. package/lib/src/Ad4mClient.d.ts +9 -16
  5. package/lib/src/Ad4mClient.js +46 -25
  6. package/lib/src/Literal.d.ts +1 -2
  7. package/lib/src/Literal.js +38 -35
  8. package/lib/src/SmartLiteral.d.ts +1 -2
  9. package/lib/src/SmartLiteral.js +30 -15
  10. package/lib/src/agent/AgentClient.d.ts +1 -4
  11. package/lib/src/agent/AgentClient.js +79 -99
  12. package/lib/src/ai/AIClient.d.ts +1 -2
  13. package/lib/src/ai/AIClient.js +224 -220
  14. package/lib/src/expression/ExpressionClient.d.ts +1 -1
  15. package/lib/src/expression/ExpressionClient.js +73 -86
  16. package/lib/src/index.d.ts +1 -1
  17. package/lib/src/index.js +1 -1
  18. package/lib/src/language/LanguageClient.d.ts +1 -1
  19. package/lib/src/language/LanguageClient.js +52 -52
  20. package/lib/src/model/Ad4mModel.d.ts +1351 -144
  21. package/lib/src/model/Ad4mModel.js +3760 -228
  22. package/lib/src/model/Ad4mModel.test.js +522 -979
  23. package/lib/src/model/Subject.d.ts +3 -3
  24. package/lib/src/model/Subject.js +25 -25
  25. package/lib/src/model/decorators.d.ts +444 -100
  26. package/lib/src/model/decorators.js +686 -321
  27. package/lib/src/model/util.d.ts +6 -6
  28. package/lib/src/model/util.js +24 -24
  29. package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +1 -5
  30. package/lib/src/neighbourhood/NeighbourhoodClient.js +179 -242
  31. package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +1 -2
  32. package/lib/src/neighbourhood/NeighbourhoodProxy.js +28 -13
  33. package/lib/src/neighbourhood/NeighbourhoodProxy.test.js +5 -1
  34. package/lib/src/perspectives/PerspectiveClient.d.ts +9 -9
  35. package/lib/src/perspectives/PerspectiveClient.js +240 -316
  36. package/lib/src/perspectives/PerspectiveProxy.d.ts +99 -61
  37. package/lib/src/perspectives/PerspectiveProxy.js +485 -832
  38. package/lib/src/runtime/RuntimeClient.d.ts +1 -5
  39. package/lib/src/runtime/RuntimeClient.js +238 -412
  40. package/lib/src/shacl/SHACLFlow.test.js +105 -164
  41. package/lib/src/shacl/SHACLShape.d.ts +12 -17
  42. package/lib/src/shacl/SHACLShape.js +115 -128
  43. package/lib/src/shacl/SHACLShape.test.js +176 -244
  44. package/lib/src/shims/reflect-metadata.d.ts +0 -0
  45. package/lib/src/shims/type-graphql.d.ts +32 -0
  46. package/lib/src/src/Ad4mClient.d.ts +28 -0
  47. package/lib/src/src/Address.d.ts +1 -0
  48. package/lib/src/src/DID.d.ts +1 -0
  49. package/lib/src/src/Exception.d.ts +7 -0
  50. package/lib/src/src/Literal.d.ts +7 -0
  51. package/lib/src/src/PubSub.d.ts +17 -0
  52. package/lib/src/src/SmartLiteral.d.ts +12 -0
  53. package/lib/src/src/agent/Agent.d.ts +110 -0
  54. package/lib/src/src/agent/AgentClient.d.ts +62 -0
  55. package/lib/src/src/agent/AgentResolver.d.ts +30 -0
  56. package/lib/src/src/agent/AgentStatus.d.ts +8 -0
  57. package/lib/src/src/ai/AIClient.d.ts +32 -0
  58. package/lib/src/src/ai/AIResolver.d.ts +75 -0
  59. package/lib/src/src/ai/Tasks.d.ts +37 -0
  60. package/lib/src/src/buildSchema.d.ts +1 -0
  61. package/lib/src/src/expression/Expression.d.ts +28 -0
  62. package/lib/src/src/expression/ExpressionClient.d.ts +13 -0
  63. package/lib/src/src/expression/ExpressionRef.d.ts +9 -0
  64. package/lib/src/src/expression/ExpressionResolver.d.ts +10 -0
  65. package/lib/src/src/index.d.ts +35 -0
  66. package/lib/src/src/jestSetup.d.ts +1 -0
  67. package/lib/src/src/language/Icon.d.ts +4 -0
  68. package/lib/src/src/language/Language.d.ts +206 -0
  69. package/lib/src/src/language/LanguageClient.d.ts +17 -0
  70. package/lib/src/src/language/LanguageContext.d.ts +37 -0
  71. package/lib/src/src/language/LanguageHandle.d.ts +9 -0
  72. package/lib/src/src/language/LanguageMeta.d.ts +35 -0
  73. package/lib/src/src/language/LanguageRef.d.ts +6 -0
  74. package/lib/src/src/language/LanguageResolver.d.ts +19 -0
  75. package/lib/src/src/links/Links.d.ts +39 -0
  76. package/lib/src/src/links/Links.test.d.ts +1 -0
  77. package/lib/src/src/model/Ad4mModel.d.ts +1438 -0
  78. package/lib/src/src/model/Ad4mModel.test.d.ts +1 -0
  79. package/lib/src/src/model/Subject.d.ts +25 -0
  80. package/lib/src/src/model/decorators.d.ts +545 -0
  81. package/lib/src/src/model/util.d.ts +12 -0
  82. package/lib/src/src/neighbourhood/Neighbourhood.d.ts +10 -0
  83. package/lib/src/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
  84. package/lib/src/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
  85. package/lib/src/src/neighbourhood/NeighbourhoodProxy.test.d.ts +1 -0
  86. package/lib/src/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
  87. package/lib/src/src/perspectives/LinkQuery.d.ts +11 -0
  88. package/lib/src/src/perspectives/Perspective.d.ts +38 -0
  89. package/lib/src/src/perspectives/Perspective.test.d.ts +1 -0
  90. package/lib/src/src/perspectives/PerspectiveClient.d.ts +97 -0
  91. package/lib/src/src/perspectives/PerspectiveDiff.d.ts +9 -0
  92. package/lib/src/src/perspectives/PerspectiveHandle.d.ts +18 -0
  93. package/lib/src/src/perspectives/PerspectiveProxy.d.ts +865 -0
  94. package/lib/src/src/perspectives/PerspectiveResolver.d.ts +57 -0
  95. package/lib/src/src/runtime/RuntimeClient.d.ts +56 -0
  96. package/lib/src/src/runtime/RuntimeResolver.d.ts +132 -0
  97. package/lib/src/src/shacl/SHACLFlow.d.ts +171 -0
  98. package/lib/src/src/shacl/SHACLFlow.test.d.ts +1 -0
  99. package/lib/src/src/shacl/SHACLShape.d.ts +117 -0
  100. package/lib/src/src/shacl/SHACLShape.test.d.ts +1 -0
  101. package/lib/src/src/typeDefs.d.ts +1 -0
  102. package/lib/src/src/unwrapApolloResult.d.ts +2 -0
  103. package/lib/src/src/utils.d.ts +25 -0
  104. package/lib/src/utils.d.ts +0 -8
  105. package/lib/src/utils.js +7 -21
  106. package/package.json +15 -14
  107. package/src/Ad4mClient.test.ts +1315 -1564
  108. package/src/Ad4mClient.ts +54 -55
  109. package/src/Literal.test.ts +26 -45
  110. package/src/Literal.ts +66 -82
  111. package/src/SmartLiteral.ts +58 -74
  112. package/src/agent/AgentClient.ts +99 -144
  113. package/src/ai/AIClient.ts +359 -409
  114. package/src/expression/ExpressionClient.ts +96 -142
  115. package/src/index.ts +1 -1
  116. package/src/language/LanguageClient.ts +113 -137
  117. package/src/model/Ad4mModel.test.ts +616 -1114
  118. package/src/model/Ad4mModel.ts +4386 -451
  119. package/src/model/Subject.ts +159 -0
  120. package/src/model/decorators.ts +1168 -667
  121. package/src/model/util.ts +54 -53
  122. package/src/neighbourhood/NeighbourhoodClient.ts +266 -392
  123. package/src/neighbourhood/NeighbourhoodProxy.test.ts +7 -3
  124. package/src/neighbourhood/NeighbourhoodProxy.ts +40 -58
  125. package/src/perspectives/PerspectiveClient.ts +540 -779
  126. package/src/perspectives/PerspectiveProxy.ts +2067 -2860
  127. package/src/runtime/RuntimeClient.ts +476 -775
  128. package/src/shacl/SHACLFlow.test.ts +129 -196
  129. package/src/shacl/SHACLShape.test.ts +190 -284
  130. package/src/shacl/SHACLShape.ts +200 -224
  131. package/src/utils.ts +17 -31
  132. package/tsconfig.json +10 -9
  133. package/src/model/IMPROVEMENTS.md +0 -482
  134. package/src/model/PREDICATE_COLLISION_FIX.md +0 -651
  135. package/src/model/README.md +0 -317
  136. package/src/model/SHACL_MUTATION_DECOUPLING.md +0 -356
  137. package/src/model/SUBSCRIPTION_STRATEGY.md +0 -317
  138. package/src/model/TC39_STAGE_3_DECORATORS.md +0 -609
  139. package/src/model/mutation.ts +0 -461
  140. package/src/model/parentUtils.ts +0 -91
  141. package/src/model/prolog/generatePrologFacts.ts +0 -176
  142. package/src/model/prolog/index.ts +0 -1
  143. package/src/model/query/ModelQueryBuilder.ts +0 -173
  144. package/src/model/query/fetchInstance.ts +0 -181
  145. package/src/model/query/hydration.ts +0 -273
  146. package/src/model/query/operations.ts +0 -510
  147. package/src/model/query/snapshot.ts +0 -126
  148. package/src/model/query/surrealCompiler.ts +0 -376
  149. package/src/model/schema/fromJSONSchema.ts +0 -411
  150. package/src/model/schema/metadata.ts +0 -148
  151. package/src/model/subscription.ts +0 -307
  152. package/src/model/transaction.ts +0 -60
  153. package/src/model/types.ts +0 -207
@@ -1,338 +1,342 @@
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;
1
13
  import { gql } from "@apollo/client";
2
14
  import unwrapApolloResult from "../unwrapApolloResult";
3
- import { isSocketCloseError } from "../utils";
4
- import base64js from "base64-js";
5
- import pako from "pako";
15
+ import base64js from 'base64-js';
16
+ import pako from 'pako';
6
17
  import { AITaskInput } from "./Tasks";
7
18
  export class AIClient {
8
19
  constructor(apolloClient, subscribe = true) {
9
- this._transcriptionSubscriptions = new Map();
10
- this._apolloClient = apolloClient;
20
+ _AIClient_apolloClient.set(this, void 0);
21
+ _AIClient_transcriptionSubscriptions.set(this, new Map());
22
+ __classPrivateFieldSet(this, _AIClient_apolloClient, apolloClient, "f");
11
23
  }
12
24
  async getModels() {
13
- const result = await this._apolloClient.query({
25
+ const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
14
26
  query: gql `
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
- `,
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
+ `
39
51
  });
40
52
  return unwrapApolloResult(result).aiGetModels;
41
53
  }
42
54
  async addModel(model) {
43
- const result = await this._apolloClient.mutate({
55
+ const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
44
56
  mutation: gql `
45
- mutation ($model: ModelInput!) {
46
- aiAddModel(model: $model)
47
- }
48
- `,
49
- variables: { model },
57
+ mutation($model: ModelInput!) {
58
+ aiAddModel(model: $model)
59
+ }
60
+ `,
61
+ variables: { model }
50
62
  });
51
63
  return unwrapApolloResult(result).aiAddModel;
52
64
  }
53
65
  async updateModel(modelId, model) {
54
- const result = await this._apolloClient.mutate({
66
+ const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
55
67
  mutation: gql `
56
- mutation ($modelId: String!, $model: ModelInput!) {
57
- aiUpdateModel(modelId: $modelId, model: $model)
58
- }
59
- `,
60
- variables: { modelId, model },
68
+ mutation($modelId: String!, $model: ModelInput!) {
69
+ aiUpdateModel(modelId: $modelId, model: $model)
70
+ }
71
+ `,
72
+ variables: { modelId, model }
61
73
  });
62
74
  return unwrapApolloResult(result).aiUpdateModel;
63
75
  }
64
76
  async removeModel(modelId) {
65
- const result = await this._apolloClient.mutate({
77
+ const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
66
78
  mutation: gql `
67
- mutation ($modelId: String!) {
68
- aiRemoveModel(modelId: $modelId)
69
- }
70
- `,
71
- variables: { modelId },
79
+ mutation($modelId: String!) {
80
+ aiRemoveModel(modelId: $modelId)
81
+ }
82
+ `,
83
+ variables: { modelId }
72
84
  });
73
85
  return unwrapApolloResult(result).aiRemoveModel;
74
86
  }
75
87
  async setDefaultModel(modelType, modelId) {
76
- const result = await this._apolloClient.mutate({
88
+ const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
77
89
  mutation: gql `
78
- mutation ($modelType: ModelType!, $modelId: String!) {
79
- aiSetDefaultModel(modelType: $modelType, modelId: $modelId)
80
- }
81
- `,
82
- variables: { modelId, modelType },
90
+ mutation($modelType: ModelType!, $modelId: String!) {
91
+ aiSetDefaultModel(modelType: $modelType modelId: $modelId)
92
+ }
93
+ `,
94
+ variables: { modelId, modelType }
83
95
  });
84
96
  return unwrapApolloResult(result).aiSetDefaultModel;
85
97
  }
86
98
  async getDefaultModel(modelType) {
87
- const result = await this._apolloClient.query({
99
+ const result = await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
88
100
  query: gql `
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 },
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 }
114
126
  });
115
127
  return unwrapApolloResult(result).aiGetDefaultModel;
116
128
  }
117
129
  async tasks() {
118
- const { aiTasks } = unwrapApolloResult(await this._apolloClient.query({
130
+ const { aiTasks } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
119
131
  query: gql `
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
- `,
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
+ `
136
148
  }));
137
149
  return aiTasks;
138
150
  }
139
151
  async addTask(name, modelId, systemPrompt, promptExamples, metaData) {
140
152
  const task = new AITaskInput(name, modelId, systemPrompt, promptExamples, metaData);
141
- const { aiAddTask } = unwrapApolloResult(await this._apolloClient.mutate({
153
+ const { aiAddTask } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
142
154
  mutation: gql `
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
156
- }
157
- }
158
- `,
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
+ `,
159
171
  variables: {
160
- task,
161
- },
172
+ task
173
+ }
162
174
  }));
163
175
  return aiAddTask;
164
176
  }
165
177
  async removeTask(taskId) {
166
- const { aiRemoveTask } = unwrapApolloResult(await this._apolloClient.mutate({
178
+ const { aiRemoveTask } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
167
179
  mutation: gql `
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
181
- }
182
- }
183
- `,
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
+ `,
184
196
  variables: {
185
- taskId,
186
- },
197
+ taskId
198
+ }
187
199
  }));
188
200
  return aiRemoveTask;
189
201
  }
190
202
  async updateTask(taskId, task) {
191
- const { aiUpdateTask } = unwrapApolloResult(await this._apolloClient.mutate({
203
+ const { aiUpdateTask } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
192
204
  mutation: gql `
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
- `,
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
+ `,
209
221
  variables: {
210
222
  taskId,
211
223
  task: {
212
224
  name: task.name,
213
225
  modelId: task.modelId,
214
226
  systemPrompt: task.systemPrompt,
215
- promptExamples: task.promptExamples,
216
- },
217
- },
227
+ promptExamples: task.promptExamples
228
+ }
229
+ }
218
230
  }));
219
231
  return aiUpdateTask;
220
232
  }
221
233
  async modelLoadingStatus(model) {
222
- const { aiModelLoadingStatus } = unwrapApolloResult(await this._apolloClient.query({
234
+ const { aiModelLoadingStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").query({
223
235
  query: gql `
224
- query AiModelLoadingStatus($model: String!) {
225
- aiModelLoadingStatus(model: $model) {
226
- model
227
- status
228
- progress
229
- loaded
230
- downloaded
231
- }
232
- }
233
- `,
236
+ query AiModelLoadingStatus($model: String!) {
237
+ aiModelLoadingStatus(model: $model) {
238
+ model
239
+ status
240
+ progress
241
+ loaded
242
+ downloaded
243
+ }
244
+ }
245
+ `,
234
246
  variables: {
235
- model,
236
- },
247
+ model
248
+ }
237
249
  }));
238
250
  return aiModelLoadingStatus;
239
251
  }
240
252
  async prompt(taskId, prompt) {
241
- const { aiPrompt } = unwrapApolloResult(await this._apolloClient.mutate({
253
+ const { aiPrompt } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
242
254
  mutation: gql `
243
- mutation AiPrompt($taskId: String!, $prompt: String!) {
244
- aiPrompt(taskId: $taskId, prompt: $prompt)
245
- }
246
- `,
255
+ mutation AiPrompt($taskId: String!, $prompt: String!) {
256
+ aiPrompt(taskId: $taskId, prompt: $prompt)
257
+ }
258
+ `,
247
259
  variables: {
248
260
  taskId,
249
- prompt,
250
- },
261
+ prompt
262
+ }
251
263
  }));
252
264
  return aiPrompt;
253
265
  }
254
266
  async embed(modelId, text) {
255
- const { aiEmbed } = unwrapApolloResult(await this._apolloClient.mutate({
267
+ const { aiEmbed } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
256
268
  mutation: gql `
257
- mutation aiEmbed($modelId: String!, $text: String!) {
258
- aiEmbed(modelId: $modelId, text: $text)
259
- }
260
- `,
269
+ mutation aiEmbed($modelId: String!, $text: String!) {
270
+ aiEmbed(modelId: $modelId, text: $text)
271
+ }
272
+ `,
261
273
  variables: {
262
274
  modelId,
263
- text,
264
- },
275
+ text
276
+ }
265
277
  }));
266
278
  const compressed = base64js.toByteArray(aiEmbed);
267
- const decompressed = JSON.parse(pako.inflate(compressed, { to: "string" }));
279
+ const decompressed = JSON.parse(pako.inflate(compressed, { to: 'string' }));
268
280
  return decompressed;
269
281
  }
270
282
  async openTranscriptionStream(modelId, streamCallback, params) {
271
- const { aiOpenTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
283
+ const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
272
284
  mutation: gql `
273
- mutation AiOpenTranscriptionStream(
274
- $modelId: String!
275
- $params: VoiceActivityParamsInput
276
- ) {
277
- aiOpenTranscriptionStream(modelId: $modelId, params: $params)
278
- }
279
- `,
285
+ mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
286
+ aiOpenTranscriptionStream(modelId: $modelId, params: $params)
287
+ }
288
+ `,
280
289
  variables: {
281
290
  modelId,
282
- params,
283
- },
291
+ params
292
+ }
284
293
  }));
285
- const subscription = this._apolloClient
286
- .subscribe({
294
+ const subscription = __classPrivateFieldGet(this, _AIClient_apolloClient, "f").subscribe({
287
295
  query: gql ` subscription {
288
296
  aiTranscriptionText(streamId: "${aiOpenTranscriptionStream}")
289
- }`,
290
- })
291
- .subscribe({
297
+ }`
298
+ }).subscribe({
292
299
  next(data) {
293
300
  streamCallback(data.data.aiTranscriptionText);
294
301
  return data.data.aiTranscriptionText;
295
302
  },
296
303
  error(err) {
297
- if (!isSocketCloseError(err))
298
- console.error(err);
299
- },
304
+ console.error(err);
305
+ }
300
306
  });
301
- this._transcriptionSubscriptions.set(aiOpenTranscriptionStream, subscription);
307
+ __classPrivateFieldGet(this, _AIClient_transcriptionSubscriptions, "f").set(aiOpenTranscriptionStream, subscription);
302
308
  return aiOpenTranscriptionStream;
303
309
  }
304
310
  async closeTranscriptionStream(streamId) {
305
- const { aiCloseTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
311
+ const { aiCloseTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
306
312
  mutation: gql `
307
- mutation aiCloseTranscriptionStream($streamId: String!) {
308
- aiCloseTranscriptionStream(streamId: $streamId)
309
- }
310
- `,
313
+ mutation aiCloseTranscriptionStream($streamId: String!) {
314
+ aiCloseTranscriptionStream(streamId: $streamId)
315
+ }
316
+ `,
311
317
  variables: {
312
- streamId,
313
- },
318
+ streamId
319
+ }
314
320
  }));
315
- const subscription = this._transcriptionSubscriptions.get(streamId);
321
+ const subscription = __classPrivateFieldGet(this, _AIClient_transcriptionSubscriptions, "f").get(streamId);
316
322
  if (!subscription.closed) {
317
323
  subscription.unsubscribe();
318
324
  }
319
325
  return aiCloseTranscriptionStream;
320
326
  }
321
327
  async feedTranscriptionStream(streamIds, audio) {
322
- const { aiFeedTranscriptionStream } = unwrapApolloResult(await this._apolloClient.mutate({
328
+ const { aiFeedTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
323
329
  mutation: gql `
324
- mutation AiFeedTranscriptionStream(
325
- $streamIds: [String!]!
326
- $audio: [Float!]!
327
- ) {
328
- aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
329
- }
330
- `,
330
+ mutation AiFeedTranscriptionStream($streamIds: [String!]!, $audio: [Float!]!) {
331
+ aiFeedTranscriptionStream(streamIds: $streamIds, audio: $audio)
332
+ }
333
+ `,
331
334
  variables: {
332
335
  streamIds: Array.isArray(streamIds) ? streamIds : [streamIds],
333
- audio: audio,
334
- },
336
+ audio: audio
337
+ }
335
338
  }));
336
339
  return aiFeedTranscriptionStream;
337
340
  }
338
341
  }
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 _apolloClient;
5
+ #private;
6
6
  constructor(client: ApolloClient<any>);
7
7
  get(url: string, alwaysGet?: boolean): Promise<ExpressionRendered>;
8
8
  getMany(urls: string[]): Promise<ExpressionRendered[]>;