@botonic/plugin-flow-builder 0.58.0-alpha.0 → 0.58.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/lib/cjs/action/push-flow-resolver.d.ts +3 -6
  2. package/lib/cjs/action/push-flow-resolver.js +20 -34
  3. package/lib/cjs/action/push-flow-resolver.js.map +1 -1
  4. package/lib/cjs/content-fields/flow-update-variables.d.ts +15 -0
  5. package/lib/cjs/content-fields/flow-update-variables.js +133 -0
  6. package/lib/cjs/content-fields/flow-update-variables.js.map +1 -0
  7. package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
  8. package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -0
  9. package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
  10. package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
  11. package/lib/cjs/content-fields/hubtype-fields/update-variables.d.ts +9 -0
  12. package/lib/cjs/content-fields/hubtype-fields/update-variables.js +3 -0
  13. package/lib/cjs/content-fields/hubtype-fields/update-variables.js.map +1 -0
  14. package/lib/cjs/content-fields/index.d.ts +3 -2
  15. package/lib/cjs/content-fields/index.js +3 -1
  16. package/lib/cjs/content-fields/index.js.map +1 -1
  17. package/lib/cjs/flow-factory.js +2 -0
  18. package/lib/cjs/flow-factory.js.map +1 -1
  19. package/lib/cjs/services/contact-info-fields-api.d.ts +7 -0
  20. package/lib/cjs/services/contact-info-fields-api.js +28 -0
  21. package/lib/cjs/services/contact-info-fields-api.js.map +1 -0
  22. package/lib/esm/action/push-flow-resolver.d.ts +3 -6
  23. package/lib/esm/action/push-flow-resolver.js +20 -34
  24. package/lib/esm/action/push-flow-resolver.js.map +1 -1
  25. package/lib/esm/content-fields/flow-update-variables.d.ts +15 -0
  26. package/lib/esm/content-fields/flow-update-variables.js +133 -0
  27. package/lib/esm/content-fields/flow-update-variables.js.map +1 -0
  28. package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
  29. package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -0
  30. package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
  31. package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
  32. package/lib/esm/content-fields/hubtype-fields/update-variables.d.ts +9 -0
  33. package/lib/esm/content-fields/hubtype-fields/update-variables.js +3 -0
  34. package/lib/esm/content-fields/hubtype-fields/update-variables.js.map +1 -0
  35. package/lib/esm/content-fields/index.d.ts +3 -2
  36. package/lib/esm/content-fields/index.js +3 -1
  37. package/lib/esm/content-fields/index.js.map +1 -1
  38. package/lib/esm/flow-factory.js +2 -0
  39. package/lib/esm/flow-factory.js.map +1 -1
  40. package/lib/esm/services/contact-info-fields-api.d.ts +7 -0
  41. package/lib/esm/services/contact-info-fields-api.js +28 -0
  42. package/lib/esm/services/contact-info-fields-api.js.map +1 -0
  43. package/package.json +2 -2
  44. package/src/action/push-flow-resolver.ts +38 -48
  45. package/src/content-fields/flow-update-variables.tsx +184 -0
  46. package/src/content-fields/hubtype-fields/node-types.ts +1 -0
  47. package/src/content-fields/hubtype-fields/nodes.ts +2 -0
  48. package/src/content-fields/hubtype-fields/update-variables.ts +10 -0
  49. package/src/content-fields/index.ts +3 -0
  50. package/src/flow-factory.ts +7 -0
  51. package/src/services/contact-info-fields-api.ts +36 -0
@@ -22,6 +22,7 @@ export enum HtNodeWithContentType {
22
22
  CUSTOM_CONDITION = 'custom-condition',
23
23
  DO_NOTHING = 'do-nothing',
24
24
  CONTACT_REASONS_CONDITION = 'contact-reasons-condition',
25
+ UPDATE_VARIABLES = 'update-variables',
25
26
  }
26
27
 
27
28
  export enum HtNodeWithoutContentType {
@@ -20,6 +20,7 @@ import type { HtPayloadNode } from './payload'
20
20
  import type { HtRatingNode } from './rating'
21
21
  import type { HtSmartIntentNode } from './smart-intent'
22
22
  import type { HtTextNode } from './text'
23
+ import type { HtUpdateVariablesNode } from './update-variables'
23
24
  import type { HtUrlNode } from './url'
24
25
  import type { HtVideoNode } from './video'
25
26
  import type { HtWebviewNode } from './webview'
@@ -52,6 +53,7 @@ export type HtNodeWithContent =
52
53
  | HtCustomConditionalV2Node
53
54
  | HtDoNothingNode
54
55
  | HtContactReasonsNode
56
+ | HtUpdateVariablesNode
55
57
  // | HtChannelConditionalNode
56
58
  // | HtCountryConditionalNode
57
59
  // | HtCustomConditionalNode
@@ -0,0 +1,10 @@
1
+ import type { HtBaseNode } from './common'
2
+ import type { HtNodeWithContentType } from './node-types'
3
+
4
+ export interface HtUpdateVariablesNode extends HtBaseNode {
5
+ type: HtNodeWithContentType.UPDATE_VARIABLES
6
+ content: {
7
+ set_variables: Record<string, string | number | boolean>
8
+ unset_variables: string[]
9
+ }
10
+ }
@@ -15,6 +15,7 @@ import { FlowImage } from './flow-image'
15
15
  import { FlowQueueStatusConditional } from './flow-queue-status-conditional'
16
16
  import { FlowRating } from './flow-rating'
17
17
  import { FlowText } from './flow-text'
18
+ import { FlowUpdateVariables } from './flow-update-variables'
18
19
  import { FlowVideo } from './flow-video'
19
20
  import { FlowWhatsappCtaUrlButtonNode } from './flow-whatsapp-cta-url-button'
20
21
  import { FlowWhatsappRequestContactInfoNode } from './flow-whatsapp-request-contact-info'
@@ -46,6 +47,7 @@ export {
46
47
  FlowQueueStatusConditional,
47
48
  FlowRating,
48
49
  FlowText,
50
+ FlowUpdateVariables,
49
51
  FlowVideo,
50
52
  FlowWhatsappButtonList,
51
53
  FlowWhatsappButtonListRow,
@@ -77,4 +79,5 @@ export type FlowContent =
77
79
  | FlowAiAgentRouter
78
80
  | FlowCustomConditionalV2
79
81
  | FlowDoNothing
82
+ | FlowUpdateVariables
80
83
  | FlowContactReasonsConditional
@@ -19,6 +19,7 @@ import {
19
19
  FlowQueueStatusConditional,
20
20
  FlowRating,
21
21
  FlowText,
22
+ FlowUpdateVariables,
22
23
  FlowVideo,
23
24
  FlowWhatsappButtonList,
24
25
  FlowWhatsappCtaUrlButtonNode,
@@ -123,6 +124,12 @@ export class FlowFactory {
123
124
  case HtNodeWithContentType.DO_NOTHING:
124
125
  return FlowDoNothing.fromHubtypeCMS(hubtypeContent)
125
126
 
127
+ case HtNodeWithContentType.UPDATE_VARIABLES:
128
+ return FlowUpdateVariables.fromHubtypeCMS(
129
+ hubtypeContent,
130
+ this.botContext
131
+ )
132
+
126
133
  case HtNodeWithContentType.CONTACT_REASONS_CONDITION:
127
134
  return FlowContactReasonsConditional.fromHubtypeCMS(
128
135
  hubtypeContent,
@@ -0,0 +1,36 @@
1
+ import axios from 'axios'
2
+
3
+ export class ContactInfoFieldsClient {
4
+ constructor(
5
+ private readonly hubtypeApiUrl: string,
6
+ private readonly accessToken: string
7
+ ) {}
8
+
9
+ async update(
10
+ chatId: string,
11
+ fieldName: string,
12
+ value: string | number | boolean
13
+ ): Promise<void> {
14
+ await axios.put(
15
+ `${this.hubtypeApiUrl}/external/v1/chats/${chatId}/contact_info_fields/${encodeURIComponent(fieldName)}/`,
16
+ { value },
17
+ {
18
+ headers: {
19
+ 'Content-Type': 'application/json',
20
+ Authorization: `Bearer ${this.accessToken}`,
21
+ },
22
+ }
23
+ )
24
+ }
25
+
26
+ async delete(chatId: string, fieldName: string): Promise<void> {
27
+ await axios.delete(
28
+ `${this.hubtypeApiUrl}/external/v1/chats/${chatId}/contact_info_fields/${encodeURIComponent(fieldName)}/`,
29
+ {
30
+ headers: {
31
+ Authorization: `Bearer ${this.accessToken}`,
32
+ },
33
+ }
34
+ )
35
+ }
36
+ }