@ikatec/digisac-api-sdk 4.5.1 → 4.6.0

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 (117) hide show
  1. package/README.md +5 -3
  2. package/dist/apis/answers/AnswersApi.cjs +38 -0
  3. package/dist/apis/answers/AnswersApi.cjs.map +1 -1
  4. package/dist/apis/answers/AnswersApi.d.ts +33 -2
  5. package/dist/apis/answers/AnswersApi.d.ts.map +1 -1
  6. package/dist/apis/answers/AnswersApi.mjs +38 -0
  7. package/dist/apis/answers/AnswersApi.mjs.map +1 -1
  8. package/dist/apis/answers/types.d.ts +64 -1
  9. package/dist/apis/answers/types.d.ts.map +1 -1
  10. package/dist/apis/botSimulators/BotSimulatorsApi.cjs +42 -0
  11. package/dist/apis/botSimulators/BotSimulatorsApi.cjs.map +1 -0
  12. package/dist/apis/botSimulators/BotSimulatorsApi.d.ts +31 -0
  13. package/dist/apis/botSimulators/BotSimulatorsApi.d.ts.map +1 -0
  14. package/dist/apis/botSimulators/BotSimulatorsApi.mjs +41 -0
  15. package/dist/apis/botSimulators/BotSimulatorsApi.mjs.map +1 -0
  16. package/dist/apis/botSimulators/index.cjs +4 -0
  17. package/dist/apis/botSimulators/index.d.ts +3 -0
  18. package/dist/apis/botSimulators/index.d.ts.map +1 -0
  19. package/dist/apis/botSimulators/index.mjs +3 -0
  20. package/dist/apis/botSimulators/types.cjs +0 -0
  21. package/dist/apis/botSimulators/types.d.ts +73 -0
  22. package/dist/apis/botSimulators/types.d.ts.map +1 -0
  23. package/dist/apis/botSimulators/types.mjs +0 -0
  24. package/dist/apis/botVersions/BotVersionsApi.cjs +25 -0
  25. package/dist/apis/botVersions/BotVersionsApi.cjs.map +1 -1
  26. package/dist/apis/botVersions/BotVersionsApi.d.ts +18 -0
  27. package/dist/apis/botVersions/BotVersionsApi.d.ts.map +1 -1
  28. package/dist/apis/botVersions/BotVersionsApi.mjs +25 -0
  29. package/dist/apis/botVersions/BotVersionsApi.mjs.map +1 -1
  30. package/dist/apis/botVersions/types.d.ts +4 -0
  31. package/dist/apis/botVersions/types.d.ts.map +1 -1
  32. package/dist/apis/bots/BotsApi.cjs +99 -4
  33. package/dist/apis/bots/BotsApi.cjs.map +1 -1
  34. package/dist/apis/bots/BotsApi.d.ts +78 -5
  35. package/dist/apis/bots/BotsApi.d.ts.map +1 -1
  36. package/dist/apis/bots/BotsApi.mjs +99 -4
  37. package/dist/apis/bots/BotsApi.mjs.map +1 -1
  38. package/dist/apis/bots/types.d.ts +266 -16
  39. package/dist/apis/bots/types.d.ts.map +1 -1
  40. package/dist/apis/index.cjs +3 -0
  41. package/dist/apis/index.d.ts +1 -0
  42. package/dist/apis/index.d.ts.map +1 -1
  43. package/dist/apis/index.mjs +3 -1
  44. package/dist/apis/questions/QuestionsApi.cjs +15 -0
  45. package/dist/apis/questions/QuestionsApi.cjs.map +1 -1
  46. package/dist/apis/questions/QuestionsApi.d.ts +15 -1
  47. package/dist/apis/questions/QuestionsApi.d.ts.map +1 -1
  48. package/dist/apis/questions/QuestionsApi.mjs +15 -0
  49. package/dist/apis/questions/QuestionsApi.mjs.map +1 -1
  50. package/dist/apis/questions/types.d.ts +25 -5
  51. package/dist/apis/questions/types.d.ts.map +1 -1
  52. package/dist/apis/quickReplies/QuickRepliesApi.cjs +16 -0
  53. package/dist/apis/quickReplies/QuickRepliesApi.cjs.map +1 -1
  54. package/dist/apis/quickReplies/QuickRepliesApi.d.ts +15 -2
  55. package/dist/apis/quickReplies/QuickRepliesApi.d.ts.map +1 -1
  56. package/dist/apis/quickReplies/QuickRepliesApi.mjs +16 -0
  57. package/dist/apis/quickReplies/QuickRepliesApi.mjs.map +1 -1
  58. package/dist/apis/quickReplies/types.d.ts +30 -2
  59. package/dist/apis/quickReplies/types.d.ts.map +1 -1
  60. package/dist/apis/schedule/ScheduleApi.cjs +37 -2
  61. package/dist/apis/schedule/ScheduleApi.cjs.map +1 -1
  62. package/dist/apis/schedule/ScheduleApi.d.ts +30 -3
  63. package/dist/apis/schedule/ScheduleApi.d.ts.map +1 -1
  64. package/dist/apis/schedule/ScheduleApi.mjs +37 -2
  65. package/dist/apis/schedule/ScheduleApi.mjs.map +1 -1
  66. package/dist/apis/schedule/types.d.ts +58 -11
  67. package/dist/apis/schedule/types.d.ts.map +1 -1
  68. package/dist/apis/ticketTopics/TicketTopicsApi.cjs +25 -2
  69. package/dist/apis/ticketTopics/TicketTopicsApi.cjs.map +1 -1
  70. package/dist/apis/ticketTopics/TicketTopicsApi.d.ts +18 -4
  71. package/dist/apis/ticketTopics/TicketTopicsApi.d.ts.map +1 -1
  72. package/dist/apis/ticketTopics/TicketTopicsApi.mjs +25 -2
  73. package/dist/apis/ticketTopics/TicketTopicsApi.mjs.map +1 -1
  74. package/dist/apis/ticketTopics/types.d.ts +22 -1
  75. package/dist/apis/ticketTopics/types.d.ts.map +1 -1
  76. package/dist/core/BaseCrudApi.cjs +5 -2
  77. package/dist/core/BaseCrudApi.cjs.map +1 -1
  78. package/dist/core/BaseCrudApi.d.ts +7 -4
  79. package/dist/core/BaseCrudApi.d.ts.map +1 -1
  80. package/dist/core/BaseCrudApi.mjs +5 -2
  81. package/dist/core/BaseCrudApi.mjs.map +1 -1
  82. package/dist/core/types.d.ts +1 -1
  83. package/dist/core/types.d.ts.map +1 -1
  84. package/dist/incommingWebhooks/index.d.ts +7 -7
  85. package/dist/incommingWebhooks/index.d.ts.map +1 -1
  86. package/package.json +1 -1
  87. package/src/apis/answers/AnswersApi.test.ts +67 -0
  88. package/src/apis/answers/AnswersApi.ts +66 -2
  89. package/src/apis/answers/types.ts +64 -2
  90. package/src/apis/botSimulators/BotSimulatorsApi.test.ts +58 -0
  91. package/src/apis/botSimulators/BotSimulatorsApi.ts +57 -0
  92. package/src/apis/botSimulators/index.ts +2 -0
  93. package/src/apis/botSimulators/types.ts +72 -0
  94. package/src/apis/botVersions/BotVersionsApi.test.ts +51 -0
  95. package/src/apis/botVersions/BotVersionsApi.ts +41 -0
  96. package/src/apis/botVersions/types.ts +4 -0
  97. package/src/apis/bots/BotsApi.test.ts +177 -0
  98. package/src/apis/bots/BotsApi.ts +162 -6
  99. package/src/apis/bots/types.ts +267 -15
  100. package/src/apis/index.ts +1 -0
  101. package/src/apis/payloads.test-d.ts +148 -0
  102. package/src/apis/questions/QuestionsApi.test.ts +49 -0
  103. package/src/apis/questions/QuestionsApi.ts +20 -1
  104. package/src/apis/questions/types.ts +25 -6
  105. package/src/apis/quickReplies/QuickRepliesApi.test.ts +69 -0
  106. package/src/apis/quickReplies/QuickRepliesApi.ts +35 -2
  107. package/src/apis/quickReplies/types.ts +34 -2
  108. package/src/apis/schedule/ScheduleApi.test.ts +80 -0
  109. package/src/apis/schedule/ScheduleApi.ts +59 -6
  110. package/src/apis/schedule/types.ts +66 -11
  111. package/src/apis/ticketTopics/TicketTopicsApi.test.ts +40 -0
  112. package/src/apis/ticketTopics/TicketTopicsApi.ts +35 -4
  113. package/src/apis/ticketTopics/types.ts +26 -1
  114. package/src/core/BaseCrudApi.ts +9 -5
  115. package/src/core/types.ts +2 -1
  116. package/src/incommingWebhooks/index.test-d.ts +9 -0
  117. package/src/incommingWebhooks/index.ts +7 -7
@@ -1,10 +1,35 @@
1
1
  import { BaseCrudApi } from "../../core/BaseCrudApi.mjs";
2
2
 
3
3
  //#region src/apis/botVersions/BotVersionsApi.ts
4
+ /**
5
+ * Versions of the bots, with the contexts in the stored map form. The backend only serves the
6
+ * list (`getMany`/`getOne`, filter by `where.botId`; `paginate: false` is honored), under the
7
+ * `bots.view` permission: the versions are created and published by `BotsApi.create`/`updateById`.
8
+ * `include` is dropped (empty whitelist), so the relationships never come.
9
+ */
4
10
  var BotVersionsApi = class extends BaseCrudApi {
5
11
  constructor(client) {
6
12
  super(client, "/bot-versions");
7
13
  }
14
+ /**
15
+ * @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers
16
+ * 404. Use `getOne({ where: { id } })`.
17
+ */
18
+ getById(id, query, headers) {
19
+ return super.getById(id, query, headers);
20
+ }
21
+ /** @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers 404. Save the bot through `BotsApi`. */
22
+ create(body, headers) {
23
+ return super.create(body, headers);
24
+ }
25
+ /** @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers 404. Save the bot through `BotsApi`. */
26
+ updateById(id, body, headers) {
27
+ return super.updateById(id, body, headers);
28
+ }
29
+ /** @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers 404. */
30
+ deleteById(id, headers) {
31
+ return super.deleteById(id, headers);
32
+ }
8
33
  };
9
34
 
10
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"BotVersionsApi.mjs","names":[],"sources":["../../../src/apis/botVersions/BotVersionsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { BotVersion, CreateBotVersionPayload, UpdateBotVersionPayload } from './types'\n\nexport class BotVersionsApi extends BaseCrudApi<\n BotVersion,\n CreateBotVersionPayload,\n UpdateBotVersionPayload\n> {\n constructor(client: ApiClient) {\n super(client, '/bot-versions')\n }\n}\n"],"mappings":";;;AAIA,IAAa,iBAAb,cAAoC,YAIlC;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,gBAAgB"}
1
+ {"version":3,"file":"BotVersionsApi.mjs","names":[],"sources":["../../../src/apis/botVersions/BotVersionsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { GetByIdQuery } from '../../core/types'\nimport type { BotVersion, CreateBotVersionPayload, UpdateBotVersionPayload } from './types'\n\n/**\n * Versions of the bots, with the contexts in the stored map form. The backend only serves the\n * list (`getMany`/`getOne`, filter by `where.botId`; `paginate: false` is honored), under the\n * `bots.view` permission: the versions are created and published by `BotsApi.create`/`updateById`.\n * `include` is dropped (empty whitelist), so the relationships never come.\n */\nexport class BotVersionsApi extends BaseCrudApi<\n BotVersion,\n CreateBotVersionPayload,\n UpdateBotVersionPayload\n> {\n constructor(client: ApiClient) {\n super(client, '/bot-versions')\n }\n\n /**\n * @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers\n * 404. Use `getOne({ where: { id } })`.\n */\n override getById(\n id: string,\n query?: GetByIdQuery<BotVersion>,\n headers?: Record<string, string>,\n ): Promise<BotVersion> {\n return super.getById(id, query, headers)\n }\n\n /** @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers 404. Save the bot through `BotsApi`. */\n override create(\n body: CreateBotVersionPayload,\n headers?: Record<string, string>,\n ): Promise<BotVersion> {\n return super.create(body, headers)\n }\n\n /** @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers 404. Save the bot through `BotsApi`. */\n override updateById(\n id: string,\n body: UpdateBotVersionPayload,\n headers?: Record<string, string>,\n ): Promise<BotVersion> {\n return super.updateById(id, body, headers)\n }\n\n /** @deprecated Not served: the backend only serves GET /bot-versions (list): this route answers 404. */\n override deleteById(id: string, headers?: Record<string, string>): Promise<BotVersion> {\n return super.deleteById(id, headers)\n }\n}\n"],"mappings":";;;;;;;;;AAWA,IAAa,iBAAb,cAAoC,YAIlC;CACA,YAAY,QAAmB;AAC7B,QAAM,QAAQ,gBAAgB;;;;;;CAOhC,AAAS,QACP,IACA,OACA,SACqB;AACrB,SAAO,MAAM,QAAQ,IAAI,OAAO,QAAQ;;;CAI1C,AAAS,OACP,MACA,SACqB;AACrB,SAAO,MAAM,OAAO,MAAM,QAAQ;;;CAIpC,AAAS,WACP,IACA,MACA,SACqB;AACrB,SAAO,MAAM,WAAW,IAAI,MAAM,QAAQ;;;CAI5C,AAAS,WAAW,IAAY,SAAuD;AACrF,SAAO,MAAM,WAAW,IAAI,QAAQ"}
@@ -16,10 +16,14 @@ export type BotVersion = {
16
16
  createdAt: string;
17
17
  updatedAt: string;
18
18
  deletedAt: string | null;
19
+ /** @deprecated Never comes: the route drops every `include` (empty whitelist). */
19
20
  bot?: Bot;
21
+ /** @deprecated Never comes: the route drops every `include` (empty whitelist). */
20
22
  createdBy?: User | null;
23
+ /** @deprecated Never comes: the route drops every `include` (empty whitelist). */
21
24
  publishedBy?: User | null;
22
25
  };
26
+ /** @deprecated The route drops every `include` (empty whitelist). */
23
27
  export type BotVersionRelationships = 'bot' | 'createdBy' | 'publishedBy';
24
28
  export type CreateBotVersionPayload = {
25
29
  botId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/apis/botVersions/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC/E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAE1C,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,WAAW,CAAA;AAEpD,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,gBAAgB,CAAA;IACxB,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,WAAW,CAAA;IACrB,QAAQ,EAAE,WAAW,CAAA;IACrB,KAAK,EAAE,MAAM,CAAA;IACb,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IAExB,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAC1B,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,KAAK,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IAClF,GAAG,CAAC,EAAE,GAAG,CAAA;IACT,kFAAkF;IAClF,SAAS,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;IACvB,kFAAkF;IAClF,WAAW,CAAC,EAAE,IAAI,GAAG,IAAI,CAAA;CAC1B,CAAA;AAED,qEAAqE;AACrE,MAAM,MAAM,uBAAuB,GAAG,KAAK,GAAG,WAAW,GAAG,aAAa,CAAA;AAEzE,MAAM,MAAM,uBAAuB,GAAG;IACpC,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,QAAQ,CAAC,EAAE,WAAW,CAAA;CACvB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,QAAQ,CAAC,EAAE,WAAW,CAAA;IACtB,MAAM,CAAC,EAAE,gBAAgB,CAAA;CAC1B,CAAA"}
@@ -1,10 +1,105 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_core_BaseCrudApi = require('../../core/BaseCrudApi.cjs');
2
+ const require_core_BaseApi = require('../../core/BaseApi.cjs');
3
3
 
4
4
  //#region src/apis/bots/BotsApi.ts
5
- var BotsApi = class extends require_core_BaseCrudApi.BaseCrudApi {
6
- constructor(client) {
7
- super(client, "/bots");
5
+ /**
6
+ * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not
7
+ * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),
8
+ * not as the stored map that `BotVersionsApi` serves.
9
+ *
10
+ * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only
11
+ * handles JSON/text bodies.
12
+ */
13
+ var BotsApi = class extends require_core_BaseApi.BaseApi {
14
+ basePath = "/bots";
15
+ /**
16
+ * Lists the bots of the account. Always paginated, even with `paginate: false`.
17
+ * @permissions bots.view
18
+ */
19
+ getMany(query, headers) {
20
+ return this.client.get(`${this.basePath}${this.toQueryString(query)}`, headers);
21
+ }
22
+ /**
23
+ * Returns the first bot matching the query, or `null` when none match.
24
+ * @permissions bots.view
25
+ */
26
+ async getOne(query, headers) {
27
+ return (await this.getMany({
28
+ ...query,
29
+ perPage: 1,
30
+ page: 1
31
+ }, headers))?.data?.[0] ?? null;
32
+ }
33
+ /**
34
+ * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id
35
+ * answers 500, not an empty body.
36
+ * @permissions bots.view
37
+ */
38
+ getById(id, query, headers) {
39
+ return this.client.get(`${this.basePath}/${id}${this.toQueryString(query)}`, headers);
40
+ }
41
+ /**
42
+ * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name
43
+ * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the
44
+ * bot never sends a message (SD-2323).
45
+ * @permissions bots.create
46
+ */
47
+ create(body, headers) {
48
+ return this.client.post(this.basePath, body, headers);
49
+ }
50
+ /**
51
+ * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the
52
+ * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.
53
+ * @permissions bots.view OR bots.update
54
+ */
55
+ updateById(id, body, headers) {
56
+ return this.client.put(`${this.basePath}/${id}`, body, headers);
57
+ }
58
+ /**
59
+ * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was
60
+ * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the
61
+ * bot, as in the other routes. Do not read the result as success or failure. An unknown id
62
+ * answers 500.
63
+ * @permissions bots.view OR bots.destroy
64
+ */
65
+ deleteById(id, headers) {
66
+ return this.client.delete(`${this.basePath}/${id}`, headers);
67
+ }
68
+ /**
69
+ * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an
70
+ * empty page.
71
+ * @permissions bots.view
72
+ */
73
+ getErrors(id, query, headers) {
74
+ return this.client.get(`${this.basePath}/${id}/errors${this.toQueryString(query)}`, headers);
75
+ }
76
+ /**
77
+ * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by
78
+ * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the
79
+ * worker only runs it when the contact has an open ticket.
80
+ * @permissions bots.view
81
+ */
82
+ triggerSignal(botId, contactId, flag, headers) {
83
+ return this.client.post(`${this.basePath}/${botId}/trigger-signal/${contactId}`, flag === void 0 ? void 0 : { flag }, headers);
84
+ }
85
+ /**
86
+ * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot
87
+ * reads. Resolves with no content. An unknown history answers 404; a history that is not
88
+ * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML
89
+ * and CSV), up to 250 KB.
90
+ * @permissions bots.view
91
+ */
92
+ requestCallback(id, pendingRequestId, body, headers) {
93
+ return this.client.post(`${this.basePath}/${id}/request-callback/${pendingRequestId}`, body, headers);
94
+ }
95
+ /**
96
+ * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and
97
+ * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an
98
+ * option outside the lists, or the AI agent limit of the account reached
99
+ * (`Agent limit reached`), answers 500.
100
+ */
101
+ suggestAgentPrompt(body, headers) {
102
+ return this.client.post(`${this.basePath}/suggest-agent-prompt`, body, headers);
8
103
  }
9
104
  };
10
105
 
@@ -1 +1 @@
1
- {"version":3,"file":"BotsApi.cjs","names":["BaseCrudApi"],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { Bot, CreateBotPayload, UpdateBotPayload } from './types'\n\nexport class BotsApi extends BaseCrudApi<Bot, CreateBotPayload, UpdateBotPayload> {\n constructor(client: ApiClient) {\n super(client, '/bots')\n }\n}\n"],"mappings":";;;;AAIA,IAAa,UAAb,cAA6BA,qCAAqD;CAChF,YAAY,QAAmB;AAC7B,QAAM,QAAQ,QAAQ"}
1
+ {"version":3,"file":"BotsApi.cjs","names":["BaseApi"],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type {\n GetByIdQuery,\n HasCreate,\n HasDeleteById,\n HasGetById,\n HasUpdateById,\n ListQuery,\n Paginated,\n} from '../../core/types'\nimport type {\n Bot,\n BotErrorsQuery,\n BotHistory,\n CreateBotPayload,\n SuggestAgentPromptPayload,\n UpdateBotPayload,\n} from './types'\n\n/**\n * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not\n * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),\n * not as the stored map that `BotVersionsApi` serves.\n *\n * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only\n * handles JSON/text bodies.\n */\nexport class BotsApi\n extends BaseApi\n implements\n HasGetById<Bot>,\n HasCreate<Bot, CreateBotPayload>,\n HasUpdateById<Bot, UpdateBotPayload>,\n HasDeleteById<'OK' | false>\n{\n public readonly basePath = '/bots'\n\n /**\n * Lists the bots of the account. Always paginated, even with `paginate: false`.\n * @permissions bots.view\n */\n getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>> {\n return this.client.get<Paginated<Bot>>(`${this.basePath}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Returns the first bot matching the query, or `null` when none match.\n * @permissions bots.view\n */\n async getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null> {\n const page = await this.getMany({ ...query, perPage: 1, page: 1 }, headers)\n return page?.data?.[0] ?? null\n }\n\n /**\n * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id\n * answers 500, not an empty body.\n * @permissions bots.view\n */\n getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot> {\n return this.client.get<Bot>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name\n * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the\n * bot never sends a message (SD-2323).\n * @permissions bots.create\n */\n create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.post<Bot, CreateBotPayload>(this.basePath, body, headers)\n }\n\n /**\n * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the\n * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.\n * @permissions bots.view OR bots.update\n */\n updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.put<Bot, UpdateBotPayload>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was\n * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the\n * bot, as in the other routes. Do not read the result as success or failure. An unknown id\n * answers 500.\n * @permissions bots.view OR bots.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false> {\n return this.client.delete<'OK' | false>(`${this.basePath}/${id}`, headers)\n }\n\n /**\n * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an\n * empty page.\n * @permissions bots.view\n */\n getErrors(\n id: string,\n query?: BotErrorsQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<BotHistory>> {\n return this.client.get<Paginated<BotHistory>>(\n `${this.basePath}/${id}/errors${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by\n * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the\n * worker only runs it when the contact has an open ticket.\n * @permissions bots.view\n */\n triggerSignal(\n botId: string,\n contactId: string,\n flag?: string,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, { flag: string } | undefined>(\n `${this.basePath}/${botId}/trigger-signal/${contactId}`,\n flag === undefined ? undefined : { flag },\n headers,\n )\n }\n\n /**\n * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot\n * reads. Resolves with no content. An unknown history answers 404; a history that is not\n * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML\n * and CSV), up to 250 KB.\n * @permissions bots.view\n */\n requestCallback(\n id: string,\n pendingRequestId: string,\n body: unknown,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, unknown>(\n `${this.basePath}/${id}/request-callback/${pendingRequestId}`,\n body,\n headers,\n )\n }\n\n /**\n * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and\n * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an\n * option outside the lists, or the AI agent limit of the account reached\n * (`Agent limit reached`), answers 500.\n */\n suggestAgentPrompt(\n body: SuggestAgentPromptPayload,\n headers?: Record<string, string>,\n ): Promise<string> {\n return this.client.post<string, SuggestAgentPromptPayload>(\n `${this.basePath}/suggest-agent-prompt`,\n body,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;;AA2BA,IAAa,UAAb,cACUA,6BAMV;CACE,AAAgB,WAAW;;;;;CAM3B,QAAQ,OAAwB,SAA2D;AACzF,SAAO,KAAK,OAAO,IAAoB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;CAOjG,MAAM,OAAO,OAAwB,SAAuD;AAE1F,UADa,MAAM,KAAK,QAAQ;GAAE,GAAG;GAAO,SAAS;GAAG,MAAM;GAAG,EAAE,QAAQ,GAC9D,OAAO,MAAM;;;;;;;CAQ5B,QAAQ,IAAY,OAA2B,SAAgD;AAC7F,SAAO,KAAK,OAAO,IAAS,GAAG,KAAK,SAAS,GAAG,KAAK,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;;;CAS5F,OAAO,MAAwB,SAAgD;AAC7E,SAAO,KAAK,OAAO,KAA4B,KAAK,UAAU,MAAM,QAAQ;;;;;;;CAQ9E,WAAW,IAAY,MAAwB,SAAgD;AAC7F,SAAO,KAAK,OAAO,IAA2B,GAAG,KAAK,SAAS,GAAG,MAAM,MAAM,QAAQ;;;;;;;;;CAUxF,WAAW,IAAY,SAAyD;AAC9E,SAAO,KAAK,OAAO,OAAqB,GAAG,KAAK,SAAS,GAAG,MAAM,QAAQ;;;;;;;CAQ5E,UACE,IACA,OACA,SACgC;AAChC,SAAO,KAAK,OAAO,IACjB,GAAG,KAAK,SAAS,GAAG,GAAG,SAAS,KAAK,cAAc,MAAM,IACzD,QACD;;;;;;;;CASH,cACE,OACA,WACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,MAAM,kBAAkB,aAC5C,SAAS,SAAY,SAAY,EAAE,MAAM,EACzC,QACD;;;;;;;;;CAUH,gBACE,IACA,kBACA,MACA,SACe;AACf,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,GAAG,GAAG,oBAAoB,oBAC3C,MACA,QACD;;;;;;;;CASH,mBACE,MACA,SACiB;AACjB,SAAO,KAAK,OAAO,KACjB,GAAG,KAAK,SAAS,wBACjB,MACA,QACD"}
@@ -1,7 +1,80 @@
1
- import type { ApiClient } from '../../core/ApiClient';
2
- import { BaseCrudApi } from '../../core/BaseCrudApi';
3
- import type { Bot, CreateBotPayload, UpdateBotPayload } from './types';
4
- export declare class BotsApi extends BaseCrudApi<Bot, CreateBotPayload, UpdateBotPayload> {
5
- constructor(client: ApiClient);
1
+ import { BaseApi } from '../../core/BaseApi';
2
+ import type { GetByIdQuery, HasCreate, HasDeleteById, HasGetById, HasUpdateById, ListQuery, Paginated } from '../../core/types';
3
+ import type { Bot, BotErrorsQuery, BotHistory, CreateBotPayload, SuggestAgentPromptPayload, UpdateBotPayload } from './types';
4
+ /**
5
+ * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not
6
+ * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),
7
+ * not as the stored map that `BotVersionsApi` serves.
8
+ *
9
+ * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only
10
+ * handles JSON/text bodies.
11
+ */
12
+ export declare class BotsApi extends BaseApi implements HasGetById<Bot>, HasCreate<Bot, CreateBotPayload>, HasUpdateById<Bot, UpdateBotPayload>, HasDeleteById<'OK' | false> {
13
+ readonly basePath = "/bots";
14
+ /**
15
+ * Lists the bots of the account. Always paginated, even with `paginate: false`.
16
+ * @permissions bots.view
17
+ */
18
+ getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>>;
19
+ /**
20
+ * Returns the first bot matching the query, or `null` when none match.
21
+ * @permissions bots.view
22
+ */
23
+ getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null>;
24
+ /**
25
+ * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id
26
+ * answers 500, not an empty body.
27
+ * @permissions bots.view
28
+ */
29
+ getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot>;
30
+ /**
31
+ * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name
32
+ * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the
33
+ * bot never sends a message (SD-2323).
34
+ * @permissions bots.create
35
+ */
36
+ create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot>;
37
+ /**
38
+ * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the
39
+ * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.
40
+ * @permissions bots.view OR bots.update
41
+ */
42
+ updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot>;
43
+ /**
44
+ * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was
45
+ * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the
46
+ * bot, as in the other routes. Do not read the result as success or failure. An unknown id
47
+ * answers 500.
48
+ * @permissions bots.view OR bots.destroy
49
+ */
50
+ deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false>;
51
+ /**
52
+ * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an
53
+ * empty page.
54
+ * @permissions bots.view
55
+ */
56
+ getErrors(id: string, query?: BotErrorsQuery, headers?: Record<string, string>): Promise<Paginated<BotHistory>>;
57
+ /**
58
+ * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by
59
+ * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the
60
+ * worker only runs it when the contact has an open ticket.
61
+ * @permissions bots.view
62
+ */
63
+ triggerSignal(botId: string, contactId: string, flag?: string, headers?: Record<string, string>): Promise<void>;
64
+ /**
65
+ * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot
66
+ * reads. Resolves with no content. An unknown history answers 404; a history that is not
67
+ * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML
68
+ * and CSV), up to 250 KB.
69
+ * @permissions bots.view
70
+ */
71
+ requestCallback(id: string, pendingRequestId: string, body: unknown, headers?: Record<string, string>): Promise<void>;
72
+ /**
73
+ * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and
74
+ * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an
75
+ * option outside the lists, or the AI agent limit of the account reached
76
+ * (`Agent limit reached`), answers 500.
77
+ */
78
+ suggestAgentPrompt(body: SuggestAgentPromptPayload, headers?: Record<string, string>): Promise<string>;
6
79
  }
7
80
  //# sourceMappingURL=BotsApi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BotsApi.d.ts","sourceRoot":"","sources":["../../../src/apis/bots/BotsApi.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACpD,OAAO,KAAK,EAAE,GAAG,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAEtE,qBAAa,OAAQ,SAAQ,WAAW,CAAC,GAAG,EAAE,gBAAgB,EAAE,gBAAgB,CAAC;gBACnE,MAAM,EAA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BaseApi.mjs";
2
2
 
3
3
  //#region src/apis/bots/BotsApi.ts
4
- var BotsApi = class extends BaseCrudApi {
5
- constructor(client) {
6
- super(client, "/bots");
4
+ /**
5
+ * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not
6
+ * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),
7
+ * not as the stored map that `BotVersionsApi` serves.
8
+ *
9
+ * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only
10
+ * handles JSON/text bodies.
11
+ */
12
+ var BotsApi = class extends BaseApi {
13
+ basePath = "/bots";
14
+ /**
15
+ * Lists the bots of the account. Always paginated, even with `paginate: false`.
16
+ * @permissions bots.view
17
+ */
18
+ getMany(query, headers) {
19
+ return this.client.get(`${this.basePath}${this.toQueryString(query)}`, headers);
20
+ }
21
+ /**
22
+ * Returns the first bot matching the query, or `null` when none match.
23
+ * @permissions bots.view
24
+ */
25
+ async getOne(query, headers) {
26
+ return (await this.getMany({
27
+ ...query,
28
+ perPage: 1,
29
+ page: 1
30
+ }, headers))?.data?.[0] ?? null;
31
+ }
32
+ /**
33
+ * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id
34
+ * answers 500, not an empty body.
35
+ * @permissions bots.view
36
+ */
37
+ getById(id, query, headers) {
38
+ return this.client.get(`${this.basePath}/${id}${this.toQueryString(query)}`, headers);
39
+ }
40
+ /**
41
+ * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name
42
+ * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the
43
+ * bot never sends a message (SD-2323).
44
+ * @permissions bots.create
45
+ */
46
+ create(body, headers) {
47
+ return this.client.post(this.basePath, body, headers);
48
+ }
49
+ /**
50
+ * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the
51
+ * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.
52
+ * @permissions bots.view OR bots.update
53
+ */
54
+ updateById(id, body, headers) {
55
+ return this.client.put(`${this.basePath}/${id}`, body, headers);
56
+ }
57
+ /**
58
+ * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was
59
+ * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the
60
+ * bot, as in the other routes. Do not read the result as success or failure. An unknown id
61
+ * answers 500.
62
+ * @permissions bots.view OR bots.destroy
63
+ */
64
+ deleteById(id, headers) {
65
+ return this.client.delete(`${this.basePath}/${id}`, headers);
66
+ }
67
+ /**
68
+ * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an
69
+ * empty page.
70
+ * @permissions bots.view
71
+ */
72
+ getErrors(id, query, headers) {
73
+ return this.client.get(`${this.basePath}/${id}/errors${this.toQueryString(query)}`, headers);
74
+ }
75
+ /**
76
+ * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by
77
+ * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the
78
+ * worker only runs it when the contact has an open ticket.
79
+ * @permissions bots.view
80
+ */
81
+ triggerSignal(botId, contactId, flag, headers) {
82
+ return this.client.post(`${this.basePath}/${botId}/trigger-signal/${contactId}`, flag === void 0 ? void 0 : { flag }, headers);
83
+ }
84
+ /**
85
+ * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot
86
+ * reads. Resolves with no content. An unknown history answers 404; a history that is not
87
+ * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML
88
+ * and CSV), up to 250 KB.
89
+ * @permissions bots.view
90
+ */
91
+ requestCallback(id, pendingRequestId, body, headers) {
92
+ return this.client.post(`${this.basePath}/${id}/request-callback/${pendingRequestId}`, body, headers);
93
+ }
94
+ /**
95
+ * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and
96
+ * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an
97
+ * option outside the lists, or the AI agent limit of the account reached
98
+ * (`Agent limit reached`), answers 500.
99
+ */
100
+ suggestAgentPrompt(body, headers) {
101
+ return this.client.post(`${this.basePath}/suggest-agent-prompt`, body, headers);
7
102
  }
8
103
  };
9
104
 
@@ -1 +1 @@
1
- {"version":3,"file":"BotsApi.mjs","names":[],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import type { ApiClient } from '../../core/ApiClient'\nimport { BaseCrudApi } from '../../core/BaseCrudApi'\nimport type { Bot, CreateBotPayload, UpdateBotPayload } from './types'\n\nexport class BotsApi extends BaseCrudApi<Bot, CreateBotPayload, UpdateBotPayload> {\n constructor(client: ApiClient) {\n super(client, '/bots')\n }\n}\n"],"mappings":";;;AAIA,IAAa,UAAb,cAA6B,YAAqD;CAChF,YAAY,QAAmB;AAC7B,QAAM,QAAQ,QAAQ"}
1
+ {"version":3,"file":"BotsApi.mjs","names":[],"sources":["../../../src/apis/bots/BotsApi.ts"],"sourcesContent":["import { BaseApi } from '../../core/BaseApi'\nimport type {\n GetByIdQuery,\n HasCreate,\n HasDeleteById,\n HasGetById,\n HasUpdateById,\n ListQuery,\n Paginated,\n} from '../../core/types'\nimport type {\n Bot,\n BotErrorsQuery,\n BotHistory,\n CreateBotPayload,\n SuggestAgentPromptPayload,\n UpdateBotPayload,\n} from './types'\n\n/**\n * Bots. The list route always paginates (`paginate: false` is ignored), so this class does not\n * extend `BaseCrudApi`. The contexts travel as a list (`BotContextInput` / `BotParsedContext`),\n * not as the stored map that `BotVersionsApi` serves.\n *\n * `GET /bots/:id/errors/export` is not exposed: it answers a binary xlsx, and `ApiClient` only\n * handles JSON/text bodies.\n */\nexport class BotsApi\n extends BaseApi\n implements\n HasGetById<Bot>,\n HasCreate<Bot, CreateBotPayload>,\n HasUpdateById<Bot, UpdateBotPayload>,\n HasDeleteById<'OK' | false>\n{\n public readonly basePath = '/bots'\n\n /**\n * Lists the bots of the account. Always paginated, even with `paginate: false`.\n * @permissions bots.view\n */\n getMany(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Paginated<Bot>> {\n return this.client.get<Paginated<Bot>>(`${this.basePath}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Returns the first bot matching the query, or `null` when none match.\n * @permissions bots.view\n */\n async getOne(query?: ListQuery<Bot>, headers?: Record<string, string>): Promise<Bot | null> {\n const page = await this.getMany({ ...query, perPage: 1, page: 1 }, headers)\n return page?.data?.[0] ?? null\n }\n\n /**\n * Returns a bot by ID, with `defaultContexts` (the stored map, as a JSON string). An unknown id\n * answers 500, not an empty body.\n * @permissions bots.view\n */\n getById(id: string, query?: GetByIdQuery<Bot>, headers?: Record<string, string>): Promise<Bot> {\n return this.client.get<Bot>(`${this.basePath}/${id}${this.toQueryString(query)}`, headers)\n }\n\n /**\n * Creates a bot and its first version (published, or a draft with `isDraft`). A duplicate name\n * answers 409, unless the account allows duplicate names. Send `flowJson` with `edges`, or the\n * bot never sends a message (SD-2323).\n * @permissions bots.create\n */\n create(body: CreateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.post<Bot, CreateBotPayload>(this.basePath, body, headers)\n }\n\n /**\n * Saves the flow (publishing a version, or into the draft with `isDraft`), or only renames the\n * bot with `onlyUpdateBotName`. Resolves to the bot with `defaultContexts` as an object.\n * @permissions bots.view OR bots.update\n */\n updateById(id: string, body: UpdateBotPayload, headers?: Record<string, string>): Promise<Bot> {\n return this.client.put<Bot, UpdateBotPayload>(`${this.basePath}/${id}`, body, headers)\n }\n\n /**\n * Deletes a bot and its versions (hard delete). Today resolves to `false` even when the bot was\n * deleted (the backend destroy returns nothing); it becomes `'OK'` once the destroy returns the\n * bot, as in the other routes. Do not read the result as success or failure. An unknown id\n * answers 500.\n * @permissions bots.view OR bots.destroy\n */\n deleteById(id: string, headers?: Record<string, string>): Promise<'OK' | false> {\n return this.client.delete<'OK' | false>(`${this.basePath}/${id}`, headers)\n }\n\n /**\n * Lists the failed steps of the bot runs, newest first by default. An unknown bot answers an\n * empty page.\n * @permissions bots.view\n */\n getErrors(\n id: string,\n query?: BotErrorsQuery,\n headers?: Record<string, string>,\n ): Promise<Paginated<BotHistory>> {\n return this.client.get<Paginated<BotHistory>>(\n `${this.basePath}/${id}/errors${this.toQueryString(query)}`,\n headers,\n )\n }\n\n /**\n * Fires the `API_SIGNAL` trigger of the bot for the contact, with an optional `flag` (read by\n * the `api_signal_flag` condition). Asynchronous: always resolves with no content, and the\n * worker only runs it when the contact has an open ticket.\n * @permissions bots.view\n */\n triggerSignal(\n botId: string,\n contactId: string,\n flag?: string,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, { flag: string } | undefined>(\n `${this.basePath}/${botId}/trigger-signal/${contactId}`,\n flag === undefined ? undefined : { flag },\n headers,\n )\n }\n\n /**\n * Answers a pending asynchronous `HTTP_REQUEST` action: `body` becomes the response the bot\n * reads. Resolves with no content. An unknown history answers 404; a history that is not\n * `PENDING`, or of another bot, answers 400. JSON bodies only (the route also takes text, XML\n * and CSV), up to 250 KB.\n * @permissions bots.view\n */\n requestCallback(\n id: string,\n pendingRequestId: string,\n body: unknown,\n headers?: Record<string, string>,\n ): Promise<void> {\n return this.client.post<void, unknown>(\n `${this.basePath}/${id}/request-callback/${pendingRequestId}`,\n body,\n headers,\n )\n }\n\n /**\n * Generates a prompt for an AI agent of the bot. COSTS one AI agent credit of the account and\n * calls OpenAI. No permission check: any authenticated user. A missing field answers 400; an\n * option outside the lists, or the AI agent limit of the account reached\n * (`Agent limit reached`), answers 500.\n */\n suggestAgentPrompt(\n body: SuggestAgentPromptPayload,\n headers?: Record<string, string>,\n ): Promise<string> {\n return this.client.post<string, SuggestAgentPromptPayload>(\n `${this.basePath}/suggest-agent-prompt`,\n body,\n headers,\n )\n }\n}\n"],"mappings":";;;;;;;;;;;AA2BA,IAAa,UAAb,cACU,QAMV;CACE,AAAgB,WAAW;;;;;CAM3B,QAAQ,OAAwB,SAA2D;AACzF,SAAO,KAAK,OAAO,IAAoB,GAAG,KAAK,WAAW,KAAK,cAAc,MAAM,IAAI,QAAQ;;;;;;CAOjG,MAAM,OAAO,OAAwB,SAAuD;AAE1F,UADa,MAAM,KAAK,QAAQ;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