@moxt-ai/mobius-sdk 0.0.9 → 0.0.11

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 (48) hide show
  1. package/README.md +21 -17
  2. package/dist/channel.d.ts +1 -1
  3. package/dist/channel.d.ts.map +1 -1
  4. package/dist/channel.js.map +1 -1
  5. package/dist/client.d.ts +7 -0
  6. package/dist/client.d.ts.map +1 -1
  7. package/dist/client.js +127 -1
  8. package/dist/client.js.map +1 -1
  9. package/dist/index.d.ts +1 -4
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +0 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/platform.d.ts +0 -28
  14. package/dist/platform.d.ts.map +1 -1
  15. package/dist/platform.js +0 -56
  16. package/dist/platform.js.map +1 -1
  17. package/dist/project-authentication.d.ts.map +1 -1
  18. package/dist/project-authentication.js +0 -9
  19. package/dist/project-authentication.js.map +1 -1
  20. package/dist/resources.d.ts +1 -2
  21. package/dist/resources.d.ts.map +1 -1
  22. package/dist/resources.js +3 -9
  23. package/dist/resources.js.map +1 -1
  24. package/dist/server.d.ts +0 -3
  25. package/dist/server.d.ts.map +1 -1
  26. package/dist/server.js +0 -3
  27. package/dist/server.js.map +1 -1
  28. package/dist/service-client.d.ts +16 -13
  29. package/dist/service-client.d.ts.map +1 -1
  30. package/dist/service-client.js +71 -67
  31. package/dist/service-client.js.map +1 -1
  32. package/package.json +2 -6
  33. package/dist/bot-owner-resources.d.ts +0 -272
  34. package/dist/bot-owner-resources.d.ts.map +0 -1
  35. package/dist/bot-owner-resources.js +0 -749
  36. package/dist/bot-owner-resources.js.map +0 -1
  37. package/dist/bot-resources.d.ts +0 -151
  38. package/dist/bot-resources.d.ts.map +0 -1
  39. package/dist/bot-resources.js +0 -466
  40. package/dist/bot-resources.js.map +0 -1
  41. package/dist/bot-service-client.d.ts +0 -232
  42. package/dist/bot-service-client.d.ts.map +0 -1
  43. package/dist/bot-service-client.js +0 -670
  44. package/dist/bot-service-client.js.map +0 -1
  45. package/dist/browser.d.ts +0 -173
  46. package/dist/browser.d.ts.map +0 -1
  47. package/dist/browser.js +0 -396
  48. package/dist/browser.js.map +0 -1
@@ -1,749 +0,0 @@
1
- import { decodeAgentExecutionConfiguration, decodeSessionReadyEvent, } from "@moxt-ai/mobius-protocol";
2
- import { MobiusProtocolError } from "./errors.js";
3
- const IDENTIFIER_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,127}$/;
4
- function invalid(name) {
5
- return new MobiusProtocolError(`The service returned an invalid ${name}`);
6
- }
7
- function record(value, name) {
8
- if (typeof value !== "object" || value === null || Array.isArray(value)) {
9
- throw invalid(name);
10
- }
11
- return Object.freeze(Object.fromEntries(Object.entries(value)));
12
- }
13
- function exact(value, fields, name) {
14
- const keys = Object.keys(value);
15
- if (keys.length !== fields.length || keys.some((key) => !fields.includes(key))) {
16
- throw invalid(name);
17
- }
18
- }
19
- function text(value, key, name, allowEmpty = false) {
20
- const field = value[key];
21
- if (typeof field !== "string" || (!allowEmpty && field.length === 0)) {
22
- throw invalid(name);
23
- }
24
- return field;
25
- }
26
- function identifier(value, key, name) {
27
- const field = text(value, key, name);
28
- if (!IDENTIFIER_PATTERN.test(field)) {
29
- throw invalid(name);
30
- }
31
- return field;
32
- }
33
- function integer(value, key, name) {
34
- const field = value[key];
35
- if (typeof field !== "number" || !Number.isSafeInteger(field) || field < 0) {
36
- throw invalid(name);
37
- }
38
- return field;
39
- }
40
- function boolean(value, key, name) {
41
- const field = value[key];
42
- if (typeof field !== "boolean") {
43
- throw invalid(name);
44
- }
45
- return field;
46
- }
47
- function timestamp(value, key, name) {
48
- const field = text(value, key, name);
49
- if (Number.isNaN(Date.parse(field))) {
50
- throw invalid(name);
51
- }
52
- return field;
53
- }
54
- function texts(value, key, name) {
55
- const field = value[key];
56
- if (!Array.isArray(field) || field.some((candidate) => typeof candidate !== "string")) {
57
- throw invalid(name);
58
- }
59
- return Object.freeze(field.filter((candidate) => typeof candidate === "string"));
60
- }
61
- function records(value, key, name) {
62
- const field = value[key];
63
- if (!Array.isArray(field)) {
64
- throw invalid(name);
65
- }
66
- return Object.freeze([...field]);
67
- }
68
- export class MobiusBotState {
69
- }
70
- export class MobiusDraftBotState extends MobiusBotState {
71
- kind = "draft";
72
- }
73
- export class MobiusActiveBotState extends MobiusBotState {
74
- activeBehaviorRevisionId;
75
- activeBindingId;
76
- kind = "active";
77
- constructor(activeBehaviorRevisionId, activeBindingId) {
78
- super();
79
- this.activeBehaviorRevisionId = activeBehaviorRevisionId;
80
- this.activeBindingId = activeBindingId;
81
- }
82
- }
83
- export class MobiusSuspendedBotState extends MobiusBotState {
84
- activeBehaviorRevisionId;
85
- activeBindingId;
86
- kind = "suspended";
87
- suspendedAt;
88
- constructor(activeBehaviorRevisionId, activeBindingId, suspendedAt) {
89
- super();
90
- this.activeBehaviorRevisionId = activeBehaviorRevisionId;
91
- this.activeBindingId = activeBindingId;
92
- this.suspendedAt = suspendedAt;
93
- }
94
- }
95
- export class MobiusArchivedBotState extends MobiusBotState {
96
- archivedAt;
97
- kind = "archived";
98
- constructor(archivedAt) {
99
- super();
100
- this.archivedAt = archivedAt;
101
- }
102
- }
103
- export class MobiusBot {
104
- avatarRef;
105
- botId;
106
- createdAt;
107
- currentProfileRevisionId;
108
- description;
109
- displayName;
110
- lifecycleRevision;
111
- profileRevision;
112
- projectId;
113
- state;
114
- updatedAt;
115
- constructor(resource, state, name = "Bot") {
116
- this.avatarRef = text(resource, "avatarRef", name, true);
117
- this.botId = identifier(resource, "botId", name);
118
- this.createdAt = timestamp(resource, "createdAt", name);
119
- this.currentProfileRevisionId = identifier(resource, "currentProfileRevisionId", name);
120
- this.description = text(resource, "description", name, true);
121
- this.displayName = text(resource, "displayName", name);
122
- this.lifecycleRevision = integer(resource, "lifecycleRevision", name);
123
- this.profileRevision = integer(resource, "profileRevision", name);
124
- this.projectId = identifier(resource, "projectId", name);
125
- this.state = state;
126
- this.updatedAt = timestamp(resource, "updatedAt", name);
127
- }
128
- }
129
- const BOT_FIELDS = [
130
- "avatarRef",
131
- "botId",
132
- "createdAt",
133
- "currentProfileRevisionId",
134
- "description",
135
- "displayName",
136
- "lifecycle",
137
- "lifecycleRevision",
138
- "profileRevision",
139
- "projectId",
140
- "updatedAt",
141
- ];
142
- export function decodeMobiusBot(value) {
143
- const name = "Bot";
144
- const resource = record(value, name);
145
- const lifecycle = resource["lifecycle"];
146
- if (lifecycle === "draft") {
147
- exact(resource, BOT_FIELDS, name);
148
- return new MobiusBot(resource, new MobiusDraftBotState());
149
- }
150
- if (lifecycle === "active") {
151
- exact(resource, [...BOT_FIELDS, "activeBehaviorRevisionId", "activeBindingId"], name);
152
- return new MobiusBot(resource, new MobiusActiveBotState(identifier(resource, "activeBehaviorRevisionId", name), identifier(resource, "activeBindingId", name)));
153
- }
154
- if (lifecycle === "suspended") {
155
- exact(resource, [...BOT_FIELDS, "activeBehaviorRevisionId", "activeBindingId", "suspendedAt"], name);
156
- return new MobiusBot(resource, new MobiusSuspendedBotState(identifier(resource, "activeBehaviorRevisionId", name), identifier(resource, "activeBindingId", name), timestamp(resource, "suspendedAt", name)));
157
- }
158
- if (lifecycle === "archived") {
159
- exact(resource, [...BOT_FIELDS, "archivedAt"], name);
160
- return new MobiusBot(resource, new MobiusArchivedBotState(timestamp(resource, "archivedAt", name)));
161
- }
162
- throw invalid(name);
163
- }
164
- export class MobiusBotDirectory {
165
- bots;
166
- constructor(value) {
167
- const resource = record(value, "Bot directory");
168
- exact(resource, ["bots"], "Bot directory");
169
- this.bots = Object.freeze(records(resource, "bots", "Bot directory").map(decodeMobiusBot));
170
- }
171
- }
172
- export class MobiusBotBehaviorState {
173
- }
174
- export class MobiusProposedBotBehaviorState extends MobiusBotBehaviorState {
175
- kind = "proposed";
176
- }
177
- export class MobiusActiveBotBehaviorState extends MobiusBotBehaviorState {
178
- activatedAt;
179
- kind = "active";
180
- constructor(activatedAt) {
181
- super();
182
- this.activatedAt = activatedAt;
183
- }
184
- }
185
- export class MobiusRetiredBotBehaviorState extends MobiusBotBehaviorState {
186
- kind = "retired";
187
- retiredAt;
188
- constructor(retiredAt) {
189
- super();
190
- this.retiredAt = retiredAt;
191
- }
192
- }
193
- export class MobiusBotBehaviorRevision {
194
- agentConfiguration;
195
- behaviorRevisionId;
196
- botId;
197
- contentDigest;
198
- createdAt;
199
- instructions;
200
- requiredCapabilities;
201
- revisionNumber;
202
- state;
203
- constructor(resource, state) {
204
- this.agentConfiguration = record(resource["agentConfiguration"], "Bot behavior configuration");
205
- this.behaviorRevisionId = identifier(resource, "behaviorRevisionId", "Bot behavior");
206
- this.botId = identifier(resource, "botId", "Bot behavior");
207
- this.contentDigest = text(resource, "contentDigest", "Bot behavior");
208
- this.createdAt = timestamp(resource, "createdAt", "Bot behavior");
209
- this.instructions = text(resource, "instructions", "Bot behavior", true);
210
- this.requiredCapabilities = texts(resource, "requiredCapabilities", "Bot behavior");
211
- this.revisionNumber = integer(resource, "revisionNumber", "Bot behavior");
212
- this.state = state;
213
- }
214
- }
215
- const BEHAVIOR_FIELDS = [
216
- "agentConfiguration",
217
- "behaviorRevisionId",
218
- "botId",
219
- "contentDigest",
220
- "createdAt",
221
- "instructions",
222
- "lifecycle",
223
- "requiredCapabilities",
224
- "revisionNumber",
225
- ];
226
- export function decodeMobiusBotBehavior(value) {
227
- const name = "Bot behavior";
228
- const resource = record(value, name);
229
- const lifecycle = resource["lifecycle"];
230
- if (lifecycle === "proposed") {
231
- exact(resource, BEHAVIOR_FIELDS, name);
232
- return new MobiusBotBehaviorRevision(resource, new MobiusProposedBotBehaviorState());
233
- }
234
- if (lifecycle === "active") {
235
- exact(resource, [...BEHAVIOR_FIELDS, "activatedAt"], name);
236
- return new MobiusBotBehaviorRevision(resource, new MobiusActiveBotBehaviorState(timestamp(resource, "activatedAt", name)));
237
- }
238
- if (lifecycle === "retired") {
239
- exact(resource, [...BEHAVIOR_FIELDS, "retiredAt"], name);
240
- return new MobiusBotBehaviorRevision(resource, new MobiusRetiredBotBehaviorState(timestamp(resource, "retiredAt", name)));
241
- }
242
- throw invalid(name);
243
- }
244
- export class MobiusBotBehaviorDirectory {
245
- behaviorRevisions;
246
- constructor(value) {
247
- const resource = record(value, "Bot behavior directory");
248
- exact(resource, ["behaviorRevisions"], "Bot behavior directory");
249
- this.behaviorRevisions = Object.freeze(records(resource, "behaviorRevisions", "Bot behavior directory").map(decodeMobiusBotBehavior));
250
- }
251
- }
252
- export class MobiusBotCompletionPolicy {
253
- }
254
- export class MobiusNoBotCompletionPolicy extends MobiusBotCompletionPolicy {
255
- kind = "none";
256
- }
257
- export class MobiusRequiredBotCompletionPolicy extends MobiusBotCompletionPolicy {
258
- deliveryTargetId;
259
- kind = "required";
260
- messageTemplate;
261
- constructor(deliveryTargetId, messageTemplate) {
262
- super();
263
- this.deliveryTargetId = deliveryTargetId;
264
- this.messageTemplate = messageTemplate;
265
- }
266
- }
267
- function decodeCompletionPolicy(value) {
268
- const resource = record(value, "Bot completion policy");
269
- if (resource["kind"] === "none") {
270
- exact(resource, ["kind"], "Bot completion policy");
271
- return new MobiusNoBotCompletionPolicy();
272
- }
273
- if (resource["kind"] === "required") {
274
- exact(resource, ["deliveryTargetId", "kind", "messageTemplate"], "Bot completion policy");
275
- return new MobiusRequiredBotCompletionPolicy(identifier(resource, "deliveryTargetId", "Bot completion policy"), text(resource, "messageTemplate", "Bot completion policy"));
276
- }
277
- throw invalid("Bot completion policy");
278
- }
279
- export class MobiusBotBindingState {
280
- }
281
- export class MobiusActiveBotBindingState extends MobiusBotBindingState {
282
- activatedAt;
283
- kind = "active";
284
- constructor(activatedAt) {
285
- super();
286
- this.activatedAt = activatedAt;
287
- }
288
- }
289
- export class MobiusUnavailableBotBindingState extends MobiusBotBindingState {
290
- code;
291
- kind = "unavailable";
292
- message;
293
- unavailableAt;
294
- constructor(code, message, unavailableAt) {
295
- super();
296
- this.code = code;
297
- this.message = message;
298
- this.unavailableAt = unavailableAt;
299
- }
300
- }
301
- export class MobiusRevokedBotBindingState extends MobiusBotBindingState {
302
- kind = "revoked";
303
- revokedAt;
304
- constructor(revokedAt) {
305
- super();
306
- this.revokedAt = revokedAt;
307
- }
308
- }
309
- export class MobiusBotExecutionBinding {
310
- agentConfigRevision;
311
- agentRef;
312
- allowedDeliveryTargetIds;
313
- behaviorRevisionId;
314
- bindingId;
315
- bindingRevision;
316
- botId;
317
- completionPolicy;
318
- createdAt;
319
- executionConfiguration;
320
- runtimeId;
321
- state;
322
- workspaceRef;
323
- constructor(resource, state) {
324
- this.agentConfigRevision = integer(resource, "agentConfigRevision", "Bot execution binding");
325
- this.agentRef = identifier(resource, "agentRef", "Bot execution binding");
326
- this.allowedDeliveryTargetIds = texts(resource, "allowedDeliveryTargetIds", "Bot execution binding");
327
- this.behaviorRevisionId = identifier(resource, "behaviorRevisionId", "Bot execution binding");
328
- this.bindingId = identifier(resource, "bindingId", "Bot execution binding");
329
- this.bindingRevision = integer(resource, "bindingRevision", "Bot execution binding");
330
- this.botId = identifier(resource, "botId", "Bot execution binding");
331
- this.completionPolicy = decodeCompletionPolicy(resource["completionPolicy"]);
332
- this.createdAt = timestamp(resource, "createdAt", "Bot execution binding");
333
- try {
334
- this.executionConfiguration = decodeAgentExecutionConfiguration(resource["executionConfiguration"]);
335
- }
336
- catch (cause) {
337
- throw new MobiusProtocolError("The service returned an invalid Bot execution binding", { cause });
338
- }
339
- this.runtimeId = identifier(resource, "runtimeId", "Bot execution binding");
340
- this.state = state;
341
- this.workspaceRef = text(resource, "workspaceRef", "Bot execution binding");
342
- }
343
- }
344
- const BINDING_FIELDS = [
345
- "agentConfigRevision",
346
- "agentRef",
347
- "allowedDeliveryTargetIds",
348
- "behaviorRevisionId",
349
- "bindingId",
350
- "bindingRevision",
351
- "botId",
352
- "completionPolicy",
353
- "createdAt",
354
- "executionConfiguration",
355
- "lifecycle",
356
- "runtimeId",
357
- "workspaceRef",
358
- ];
359
- function decodeMobiusBotExecutionBinding(value) {
360
- const name = "Bot execution binding";
361
- const resource = record(value, name);
362
- const lifecycle = resource["lifecycle"];
363
- if (lifecycle === "active") {
364
- exact(resource, [...BINDING_FIELDS, "activatedAt"], name);
365
- return new MobiusBotExecutionBinding(resource, new MobiusActiveBotBindingState(timestamp(resource, "activatedAt", name)));
366
- }
367
- if (lifecycle === "unavailable") {
368
- exact(resource, [...BINDING_FIELDS, "code", "message", "unavailableAt"], name);
369
- return new MobiusBotExecutionBinding(resource, new MobiusUnavailableBotBindingState(identifier(resource, "code", name), text(resource, "message", name), timestamp(resource, "unavailableAt", name)));
370
- }
371
- if (lifecycle === "revoked") {
372
- exact(resource, [...BINDING_FIELDS, "revokedAt"], name);
373
- return new MobiusBotExecutionBinding(resource, new MobiusRevokedBotBindingState(timestamp(resource, "revokedAt", name)));
374
- }
375
- throw invalid(name);
376
- }
377
- export class MobiusBotBindingDirectory {
378
- executionBindings;
379
- constructor(value) {
380
- const resource = record(value, "Bot binding directory");
381
- exact(resource, ["executionBindings"], "Bot binding directory");
382
- this.executionBindings = Object.freeze(records(resource, "executionBindings", "Bot binding directory").map(decodeMobiusBotExecutionBinding));
383
- }
384
- }
385
- export class MobiusBotProfileRevision {
386
- avatarRef;
387
- botId;
388
- createdAt;
389
- description;
390
- displayName;
391
- lifecycleRevision;
392
- profileRevisionId;
393
- revisionNumber;
394
- constructor(value) {
395
- const name = "Bot profile revision";
396
- const resource = record(value, name);
397
- exact(resource, [
398
- "avatarRef",
399
- "botId",
400
- "createdAt",
401
- "description",
402
- "displayName",
403
- "lifecycleRevision",
404
- "profileRevisionId",
405
- "revisionNumber",
406
- ], name);
407
- this.avatarRef = text(resource, "avatarRef", name, true);
408
- this.botId = identifier(resource, "botId", name);
409
- this.createdAt = timestamp(resource, "createdAt", name);
410
- this.description = text(resource, "description", name, true);
411
- this.displayName = text(resource, "displayName", name);
412
- this.lifecycleRevision = integer(resource, "lifecycleRevision", name);
413
- this.profileRevisionId = identifier(resource, "profileRevisionId", name);
414
- this.revisionNumber = integer(resource, "revisionNumber", name);
415
- }
416
- }
417
- export class MobiusBotBindingRequestAcceptance {
418
- activatedAt;
419
- bindingId;
420
- bindingRevision;
421
- lifecycle = "active";
422
- constructor(value) {
423
- const name = "Bot binding activation";
424
- const resource = record(value, name);
425
- exact(resource, ["activatedAt", "bindingId", "bindingRevision", "lifecycle"], name);
426
- if (resource["lifecycle"] !== "active") {
427
- throw invalid(name);
428
- }
429
- this.activatedAt = timestamp(resource, "activatedAt", name);
430
- this.bindingId = identifier(resource, "bindingId", name);
431
- this.bindingRevision = integer(resource, "bindingRevision", name);
432
- }
433
- }
434
- export class MobiusBotConversationState {
435
- }
436
- export class MobiusProvisioningBotConversationState extends MobiusBotConversationState {
437
- kind = "provisioning";
438
- }
439
- export class MobiusActiveBotConversationState extends MobiusBotConversationState {
440
- kind = "active";
441
- }
442
- export class MobiusClosedBotConversationState extends MobiusBotConversationState {
443
- kind = "closed";
444
- }
445
- export class MobiusBotConversationOrigin {
446
- }
447
- export class MobiusOwnerBotConversationOrigin extends MobiusBotConversationOrigin {
448
- kind = "owner";
449
- }
450
- export class MobiusConnectedBotConversationOrigin extends MobiusBotConversationOrigin {
451
- connectionId;
452
- kind = "connection";
453
- replyDeliveryTargetId;
454
- constructor(connectionId, replyDeliveryTargetId) {
455
- super();
456
- this.connectionId = connectionId;
457
- this.replyDeliveryTargetId = replyDeliveryTargetId;
458
- }
459
- }
460
- export class MobiusBotConversation {
461
- behaviorRevisionId;
462
- bindingId;
463
- bindingRevision;
464
- botId;
465
- clientConversationKey;
466
- conversationId;
467
- createdAt;
468
- creatorPrincipalId;
469
- origin;
470
- sessionId;
471
- state;
472
- title;
473
- constructor(resource, origin, state) {
474
- const name = "Bot conversation";
475
- this.behaviorRevisionId = identifier(resource, "behaviorRevisionId", name);
476
- this.bindingId = identifier(resource, "bindingId", name);
477
- this.bindingRevision = integer(resource, "bindingRevision", name);
478
- this.botId = identifier(resource, "botId", name);
479
- this.clientConversationKey = identifier(resource, "clientConversationKey", name);
480
- this.conversationId = identifier(resource, "conversationId", name);
481
- this.createdAt = timestamp(resource, "createdAt", name);
482
- this.creatorPrincipalId = text(resource, "creatorPrincipalId", name);
483
- this.origin = origin;
484
- this.sessionId = identifier(resource, "sessionId", name);
485
- this.state = state;
486
- this.title = text(resource, "title", name, true);
487
- }
488
- }
489
- const CONVERSATION_FIELDS = [
490
- "behaviorRevisionId",
491
- "bindingId",
492
- "bindingRevision",
493
- "botId",
494
- "clientConversationKey",
495
- "conversationId",
496
- "createdAt",
497
- "creatorKind",
498
- "creatorPrincipalId",
499
- "lifecycle",
500
- "sessionId",
501
- "title",
502
- ];
503
- function conversationState(resource) {
504
- if (resource["lifecycle"] === "provisioning") {
505
- return new MobiusProvisioningBotConversationState();
506
- }
507
- if (resource["lifecycle"] === "active") {
508
- return new MobiusActiveBotConversationState();
509
- }
510
- if (resource["lifecycle"] === "closed") {
511
- return new MobiusClosedBotConversationState();
512
- }
513
- throw invalid("Bot conversation");
514
- }
515
- export function decodeMobiusOwnerBotConversation(value) {
516
- const resource = record(value, "owner Bot conversation");
517
- exact(resource, CONVERSATION_FIELDS, "owner Bot conversation");
518
- if (resource["creatorKind"] !== "owner") {
519
- throw invalid("owner Bot conversation");
520
- }
521
- return new MobiusBotConversation(resource, new MobiusOwnerBotConversationOrigin(), conversationState(resource));
522
- }
523
- function decodeMobiusBotConversation(value) {
524
- const resource = record(value, "Bot conversation");
525
- if (resource["creatorKind"] === "owner") {
526
- return decodeMobiusOwnerBotConversation(resource);
527
- }
528
- if (resource["creatorKind"] === "connection") {
529
- exact(resource, [...CONVERSATION_FIELDS, "connectionId", "replyDeliveryTargetId"], "Bot conversation");
530
- return new MobiusBotConversation(resource, new MobiusConnectedBotConversationOrigin(identifier(resource, "connectionId", "Bot conversation"), identifier(resource, "replyDeliveryTargetId", "Bot conversation")), conversationState(resource));
531
- }
532
- throw invalid("Bot conversation");
533
- }
534
- export class MobiusBotConversationDirectory {
535
- conversations;
536
- constructor(value) {
537
- const resource = record(value, "Bot conversation directory");
538
- exact(resource, ["conversations"], "Bot conversation directory");
539
- this.conversations = Object.freeze(records(resource, "conversations", "Bot conversation directory").map(decodeMobiusBotConversation));
540
- }
541
- }
542
- export class MobiusProjectConversation {
543
- behaviorRevisionId;
544
- bindingId;
545
- bindingRevision;
546
- botId;
547
- clientReference;
548
- conversationId;
549
- createdAt;
550
- idempotencyKey;
551
- lifecycle;
552
- projectId;
553
- ready;
554
- sessionId;
555
- title;
556
- constructor(value) {
557
- const name = "Project conversation";
558
- const resource = record(value, name);
559
- const fields = [
560
- "behaviorRevisionId",
561
- "bindingId",
562
- "bindingRevision",
563
- "botId",
564
- "clientReference",
565
- "conversationId",
566
- "createdAt",
567
- "idempotencyKey",
568
- "lifecycle",
569
- "projectId",
570
- "sessionId",
571
- "title",
572
- ];
573
- exact(resource, resource["ready"] === undefined ? fields : [...fields, "ready"], name);
574
- this.behaviorRevisionId = identifier(resource, "behaviorRevisionId", name);
575
- this.bindingId = identifier(resource, "bindingId", name);
576
- this.bindingRevision = integer(resource, "bindingRevision", name);
577
- this.botId = identifier(resource, "botId", name);
578
- this.clientReference = identifier(resource, "clientReference", name);
579
- this.conversationId = identifier(resource, "conversationId", name);
580
- this.createdAt = timestamp(resource, "createdAt", name);
581
- this.idempotencyKey = identifier(resource, "idempotencyKey", name);
582
- this.lifecycle = text(resource, "lifecycle", name);
583
- this.projectId = identifier(resource, "projectId", name);
584
- this.ready =
585
- resource["ready"] === undefined ? null : decodeSessionReadyEvent(JSON.stringify(resource["ready"]));
586
- this.sessionId = identifier(resource, "sessionId", name);
587
- this.title = text(resource, "title", name, true);
588
- }
589
- }
590
- export class MobiusBotConnectionState {
591
- }
592
- export class MobiusActiveBotConnectionState extends MobiusBotConnectionState {
593
- kind = "active";
594
- lastUsedAt;
595
- constructor(lastUsedAt) {
596
- super();
597
- this.lastUsedAt = lastUsedAt;
598
- }
599
- }
600
- export class MobiusRevokedBotConnectionState extends MobiusBotConnectionState {
601
- kind = "revoked";
602
- revokedAt;
603
- constructor(revokedAt) {
604
- super();
605
- this.revokedAt = revokedAt;
606
- }
607
- }
608
- export class MobiusOwnerBotConnection {
609
- audience;
610
- botId;
611
- connectionId;
612
- connectorPrincipalId;
613
- createdAt;
614
- label;
615
- lifecycleRevision;
616
- scopes;
617
- state;
618
- constructor(resource, state) {
619
- const name = "Bot connection";
620
- this.audience = identifier(resource, "audience", name);
621
- this.botId = identifier(resource, "botId", name);
622
- this.connectionId = identifier(resource, "connectionId", name);
623
- this.connectorPrincipalId = text(resource, "connectorPrincipalId", name);
624
- this.createdAt = timestamp(resource, "createdAt", name);
625
- this.label = text(resource, "label", name);
626
- this.lifecycleRevision = integer(resource, "lifecycleRevision", name);
627
- this.scopes = texts(resource, "scopes", name);
628
- this.state = state;
629
- }
630
- }
631
- const CONNECTION_FIELDS = [
632
- "audience",
633
- "botId",
634
- "connectionId",
635
- "connectorPrincipalId",
636
- "createdAt",
637
- "label",
638
- "lifecycle",
639
- "lifecycleRevision",
640
- "scopes",
641
- ];
642
- function decodeMobiusOwnerBotConnection(value) {
643
- const name = "Bot connection";
644
- const resource = record(value, name);
645
- if (resource["lifecycle"] === "active") {
646
- exact(resource, [...CONNECTION_FIELDS, "lastUsedAt"], name);
647
- return new MobiusOwnerBotConnection(resource, new MobiusActiveBotConnectionState(timestamp(resource, "lastUsedAt", name)));
648
- }
649
- if (resource["lifecycle"] === "revoked") {
650
- exact(resource, [...CONNECTION_FIELDS, "revokedAt"], name);
651
- return new MobiusOwnerBotConnection(resource, new MobiusRevokedBotConnectionState(timestamp(resource, "revokedAt", name)));
652
- }
653
- throw invalid(name);
654
- }
655
- export class MobiusBotDeliveryTargetState {
656
- }
657
- export class MobiusActiveBotDeliveryTargetState extends MobiusBotDeliveryTargetState {
658
- kind = "active";
659
- }
660
- export class MobiusDisabledBotDeliveryTargetState extends MobiusBotDeliveryTargetState {
661
- disabledAt;
662
- kind = "disabled";
663
- constructor(disabledAt) {
664
- super();
665
- this.disabledAt = disabledAt;
666
- }
667
- }
668
- export class MobiusOwnerBotDeliveryTarget {
669
- alias;
670
- botId;
671
- connectionId;
672
- createdAt;
673
- deliveryTargetId;
674
- lifecycleRevision;
675
- outboundPolicyRevision;
676
- ownerApproved;
677
- state;
678
- updatedAt;
679
- constructor(resource, state) {
680
- const name = "Bot delivery target";
681
- this.alias = text(resource, "alias", name);
682
- this.botId = identifier(resource, "botId", name);
683
- this.connectionId = identifier(resource, "connectionId", name);
684
- this.createdAt = timestamp(resource, "createdAt", name);
685
- this.deliveryTargetId = identifier(resource, "deliveryTargetId", name);
686
- this.lifecycleRevision = integer(resource, "lifecycleRevision", name);
687
- this.outboundPolicyRevision = integer(resource, "outboundPolicyRevision", name);
688
- this.ownerApproved = boolean(resource, "ownerApproved", name);
689
- this.state = state;
690
- this.updatedAt = timestamp(resource, "updatedAt", name);
691
- }
692
- }
693
- const TARGET_FIELDS = [
694
- "alias",
695
- "botId",
696
- "connectionId",
697
- "createdAt",
698
- "deliveryTargetId",
699
- "lifecycle",
700
- "lifecycleRevision",
701
- "outboundPolicyRevision",
702
- "ownerApproved",
703
- "updatedAt",
704
- ];
705
- function decodeMobiusOwnerBotDeliveryTarget(value) {
706
- const name = "Bot delivery target";
707
- const resource = record(value, name);
708
- if (resource["lifecycle"] === "active") {
709
- exact(resource, TARGET_FIELDS, name);
710
- return new MobiusOwnerBotDeliveryTarget(resource, new MobiusActiveBotDeliveryTargetState());
711
- }
712
- if (resource["lifecycle"] === "disabled") {
713
- exact(resource, [...TARGET_FIELDS, "disabledAt"], name);
714
- return new MobiusOwnerBotDeliveryTarget(resource, new MobiusDisabledBotDeliveryTargetState(timestamp(resource, "disabledAt", name)));
715
- }
716
- throw invalid(name);
717
- }
718
- export class MobiusBotConnectionDirectory {
719
- connections;
720
- deliveryTargets;
721
- constructor(value) {
722
- const resource = record(value, "Bot connection directory");
723
- exact(resource, ["connections", "deliveryTargets"], "Bot connection directory");
724
- this.connections = Object.freeze(records(resource, "connections", "Bot connection directory").map(decodeMobiusOwnerBotConnection));
725
- this.deliveryTargets = Object.freeze(records(resource, "deliveryTargets", "Bot connection directory").map(decodeMobiusOwnerBotDeliveryTarget));
726
- }
727
- }
728
- export class MobiusBotConnectionGrant {
729
- audience;
730
- botId;
731
- expiresAt;
732
- grantId;
733
- grantSecret;
734
- label;
735
- scopes;
736
- constructor(value) {
737
- const name = "Bot connection grant";
738
- const resource = record(value, name);
739
- exact(resource, ["audience", "botId", "expiresAt", "grantId", "grantSecret", "label", "scopes"], name);
740
- this.audience = identifier(resource, "audience", name);
741
- this.botId = identifier(resource, "botId", name);
742
- this.expiresAt = timestamp(resource, "expiresAt", name);
743
- this.grantId = identifier(resource, "grantId", name);
744
- this.grantSecret = text(resource, "grantSecret", name);
745
- this.label = text(resource, "label", name);
746
- this.scopes = texts(resource, "scopes", name);
747
- }
748
- }
749
- //# sourceMappingURL=bot-owner-resources.js.map