@botonic/plugin-flow-builder 0.21.0-alpha.5 → 0.21.0-alpha.7

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 (138) hide show
  1. package/lib/cjs/action.d.ts +3 -4
  2. package/lib/cjs/action.js +15 -10
  3. package/lib/cjs/action.js.map +1 -1
  4. package/lib/cjs/content-fields/content-fields-base.d.ts +7 -0
  5. package/lib/cjs/content-fields/{content-base.js → content-fields-base.js} +7 -2
  6. package/lib/cjs/content-fields/content-fields-base.js.map +1 -0
  7. package/lib/cjs/content-fields/{button.d.ts → flow-button.d.ts} +3 -3
  8. package/lib/cjs/content-fields/{button.js → flow-button.js} +12 -6
  9. package/lib/cjs/content-fields/flow-button.js.map +1 -0
  10. package/lib/cjs/content-fields/flow-carousel.d.ts +10 -0
  11. package/lib/cjs/content-fields/{carousel.js → flow-carousel.js} +10 -10
  12. package/lib/cjs/content-fields/flow-carousel.js.map +1 -0
  13. package/lib/cjs/content-fields/flow-element.d.ts +11 -0
  14. package/lib/cjs/content-fields/{element.js → flow-element.js} +6 -7
  15. package/lib/cjs/content-fields/flow-element.js.map +1 -0
  16. package/lib/cjs/content-fields/flow-image.d.ts +9 -0
  17. package/lib/cjs/content-fields/{image.js → flow-image.js} +4 -5
  18. package/lib/cjs/content-fields/flow-image.js.map +1 -0
  19. package/lib/cjs/content-fields/flow-text.d.ts +12 -0
  20. package/lib/cjs/content-fields/{text.js → flow-text.js} +8 -8
  21. package/lib/cjs/content-fields/flow-text.js.map +1 -0
  22. package/lib/cjs/content-fields/index.d.ts +7 -0
  23. package/lib/cjs/content-fields/index.js +16 -0
  24. package/lib/cjs/content-fields/index.js.map +1 -0
  25. package/lib/cjs/content-fields/types.d.ts +4 -0
  26. package/lib/cjs/content-fields/types.js +3 -0
  27. package/lib/cjs/content-fields/types.js.map +1 -0
  28. package/lib/cjs/flow-builder-models.d.ts +174 -0
  29. package/lib/cjs/flow-builder-models.js +22 -0
  30. package/lib/cjs/flow-builder-models.js.map +1 -0
  31. package/lib/cjs/functions/conditional-queue-status.d.ts +2 -2
  32. package/lib/cjs/functions/conditional-queue-status.js +15 -2
  33. package/lib/cjs/functions/conditional-queue-status.js.map +1 -1
  34. package/lib/cjs/functions/index.d.ts +1 -1
  35. package/lib/cjs/functions/index.js +3 -1
  36. package/lib/cjs/functions/index.js.map +1 -1
  37. package/lib/cjs/handoff.d.ts +1 -1
  38. package/lib/cjs/handoff.js +11 -15
  39. package/lib/cjs/handoff.js.map +1 -1
  40. package/lib/cjs/index.d.ts +15 -13
  41. package/lib/cjs/index.js +44 -27
  42. package/lib/cjs/index.js.map +1 -1
  43. package/lib/cjs/utils.d.ts +1 -2
  44. package/lib/cjs/utils.js +6 -6
  45. package/lib/cjs/utils.js.map +1 -1
  46. package/lib/esm/action.d.ts +3 -4
  47. package/lib/esm/action.js +14 -10
  48. package/lib/esm/action.js.map +1 -1
  49. package/lib/esm/content-fields/content-fields-base.d.ts +7 -0
  50. package/lib/esm/content-fields/content-fields-base.js +16 -0
  51. package/lib/esm/content-fields/content-fields-base.js.map +1 -0
  52. package/lib/esm/content-fields/{button.d.ts → flow-button.d.ts} +3 -3
  53. package/lib/esm/content-fields/{button.js → flow-button.js} +11 -5
  54. package/lib/esm/content-fields/flow-button.js.map +1 -0
  55. package/lib/esm/content-fields/flow-carousel.d.ts +10 -0
  56. package/lib/esm/content-fields/{carousel.js → flow-carousel.js} +9 -9
  57. package/lib/esm/content-fields/flow-carousel.js.map +1 -0
  58. package/lib/esm/content-fields/flow-element.d.ts +11 -0
  59. package/lib/esm/content-fields/{element.js → flow-element.js} +4 -5
  60. package/lib/esm/content-fields/flow-element.js.map +1 -0
  61. package/lib/esm/content-fields/flow-image.d.ts +9 -0
  62. package/lib/esm/content-fields/{image.js → flow-image.js} +3 -4
  63. package/lib/esm/content-fields/flow-image.js.map +1 -0
  64. package/lib/esm/content-fields/flow-text.d.ts +12 -0
  65. package/lib/esm/content-fields/{text.js → flow-text.js} +4 -4
  66. package/lib/esm/content-fields/flow-text.js.map +1 -0
  67. package/lib/esm/content-fields/index.d.ts +7 -0
  68. package/lib/esm/content-fields/index.js +7 -0
  69. package/lib/esm/content-fields/index.js.map +1 -0
  70. package/lib/esm/content-fields/types.d.ts +4 -0
  71. package/lib/esm/content-fields/types.js +2 -0
  72. package/lib/esm/content-fields/types.js.map +1 -0
  73. package/lib/esm/flow-builder-models.d.ts +174 -0
  74. package/lib/esm/flow-builder-models.js +19 -0
  75. package/lib/esm/flow-builder-models.js.map +1 -0
  76. package/lib/esm/functions/conditional-queue-status.d.ts +2 -2
  77. package/lib/esm/functions/conditional-queue-status.js +15 -2
  78. package/lib/esm/functions/conditional-queue-status.js.map +1 -1
  79. package/lib/esm/functions/index.d.ts +1 -1
  80. package/lib/esm/functions/index.js +3 -1
  81. package/lib/esm/functions/index.js.map +1 -1
  82. package/lib/esm/handoff.d.ts +1 -1
  83. package/lib/esm/handoff.js +12 -16
  84. package/lib/esm/handoff.js.map +1 -1
  85. package/lib/esm/index.d.ts +15 -13
  86. package/lib/esm/index.js +39 -24
  87. package/lib/esm/index.js.map +1 -1
  88. package/lib/esm/utils.d.ts +1 -2
  89. package/lib/esm/utils.js +4 -4
  90. package/lib/esm/utils.js.map +1 -1
  91. package/package.json +1 -1
  92. package/src/action.tsx +17 -16
  93. package/src/content-fields/content-fields-base.ts +15 -0
  94. package/src/content-fields/{button.tsx → flow-button.tsx} +13 -6
  95. package/src/content-fields/flow-carousel.tsx +39 -0
  96. package/src/content-fields/{element.tsx → flow-element.tsx} +8 -6
  97. package/src/content-fields/{image.tsx → flow-image.tsx} +5 -6
  98. package/src/content-fields/{text.tsx → flow-text.tsx} +5 -5
  99. package/src/content-fields/index.ts +7 -0
  100. package/src/content-fields/types.ts +5 -0
  101. package/src/flow-builder-models.ts +220 -0
  102. package/src/functions/conditional-queue-status.ts +24 -2
  103. package/src/functions/index.ts +3 -1
  104. package/src/handoff.ts +18 -17
  105. package/src/index.ts +79 -61
  106. package/src/utils.ts +10 -5
  107. package/lib/cjs/content-fields/button.js.map +0 -1
  108. package/lib/cjs/content-fields/carousel.d.ts +0 -10
  109. package/lib/cjs/content-fields/carousel.js.map +0 -1
  110. package/lib/cjs/content-fields/content-base.d.ts +0 -10
  111. package/lib/cjs/content-fields/content-base.js.map +0 -1
  112. package/lib/cjs/content-fields/element.d.ts +0 -11
  113. package/lib/cjs/content-fields/element.js.map +0 -1
  114. package/lib/cjs/content-fields/image.d.ts +0 -9
  115. package/lib/cjs/content-fields/image.js.map +0 -1
  116. package/lib/cjs/content-fields/text.d.ts +0 -12
  117. package/lib/cjs/content-fields/text.js.map +0 -1
  118. package/lib/cjs/hubtype-models.d.ts +0 -160
  119. package/lib/cjs/hubtype-models.js +0 -50
  120. package/lib/cjs/hubtype-models.js.map +0 -1
  121. package/lib/esm/content-fields/button.js.map +0 -1
  122. package/lib/esm/content-fields/carousel.d.ts +0 -10
  123. package/lib/esm/content-fields/carousel.js.map +0 -1
  124. package/lib/esm/content-fields/content-base.d.ts +0 -10
  125. package/lib/esm/content-fields/content-base.js +0 -11
  126. package/lib/esm/content-fields/content-base.js.map +0 -1
  127. package/lib/esm/content-fields/element.d.ts +0 -11
  128. package/lib/esm/content-fields/element.js.map +0 -1
  129. package/lib/esm/content-fields/image.d.ts +0 -9
  130. package/lib/esm/content-fields/image.js.map +0 -1
  131. package/lib/esm/content-fields/text.d.ts +0 -12
  132. package/lib/esm/content-fields/text.js.map +0 -1
  133. package/lib/esm/hubtype-models.d.ts +0 -160
  134. package/lib/esm/hubtype-models.js +0 -47
  135. package/lib/esm/hubtype-models.js.map +0 -1
  136. package/src/content-fields/carousel.tsx +0 -39
  137. package/src/content-fields/content-base.ts +0 -15
  138. package/src/hubtype-models.ts +0 -200
@@ -2,9 +2,22 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.conditionalQueueStatus = void 0;
4
4
  const tslib_1 = require("tslib");
5
+ /* eslint-disable @typescript-eslint/naming-convention */
5
6
  const axios_1 = tslib_1.__importDefault(require("axios"));
6
- async function conditionalQueueStatus({ queue_id }) {
7
- const response = await axios_1.default.get(`https://api.hubtype.com/v1/queues/${queue_id}/availability/`);
7
+ const utils_1 = require("../utils");
8
+ const _HUBTYPE_API_URL_ = utils_1.getWebpackEnvVar(
9
+ // @ts-ignore
10
+ typeof HUBTYPE_API_URL !== 'undefined' && HUBTYPE_API_URL, 'HUBTYPE_API_URL', 'https://api.hubtype.com');
11
+ async function conditionalQueueStatus({ queue_id, }) {
12
+ const response = await axios_1.default.get(`${_HUBTYPE_API_URL_}/v1/queues/${queue_id}/availability/`,
13
+ // TODO: Make it configurable in the future
14
+ {
15
+ params: {
16
+ check_queue_schedule: true,
17
+ check_waiting_cases: false,
18
+ check_available_agents: false,
19
+ },
20
+ });
8
21
  const isAvailable = response.data.available;
9
22
  return isAvailable ? 'open' : 'closed';
10
23
  }
@@ -1 +1 @@
1
- {"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AAAA,0DAAyB;AAElB,KAAK,UAAU,sBAAsB,CAAC,EAAE,QAAQ,EAAE;IACvD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,qCAAqC,QAAQ,gBAAgB,CAC9D,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AAND,wDAMC"}
1
+ {"version":3,"file":"conditional-queue-status.js","sourceRoot":"","sources":["../../../src/functions/conditional-queue-status.ts"],"names":[],"mappings":";;;;AAAA,yDAAyD;AACzD,0DAAyB;AAEzB,oCAA2C;AAE3C,MAAM,iBAAiB,GAAG,wBAAgB;AACxC,aAAa;AACb,OAAO,eAAe,KAAK,WAAW,IAAI,eAAe,EACzD,iBAAiB,EACjB,yBAAyB,CAC1B,CAAA;AAEM,KAAK,UAAU,sBAAsB,CAAC,EAC3C,QAAQ,GAGT;IACC,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAC9B,GAAG,iBAAiB,cAAc,QAAQ,gBAAgB;IAC1D,2CAA2C;IAC3C;QACE,MAAM,EAAE;YACN,oBAAoB,EAAE,IAAI;YAC1B,mBAAmB,EAAE,KAAK;YAC1B,sBAAsB,EAAE,KAAK;SAC9B;KACF,CACF,CAAA;IACD,MAAM,WAAW,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAA;IAC3C,OAAO,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAA;AACxC,CAAC;AAlBD,wDAkBC"}
@@ -1,6 +1,6 @@
1
1
  import { conditionalProvider } from './conditional-provider';
2
2
  import { conditionalQueueStatus } from './conditional-queue-status';
3
3
  export declare const DEFAULT_FUNCTIONS: {
4
- 'conditional-queue-status': typeof conditionalQueueStatus;
4
+ 'check-queue-status': typeof conditionalQueueStatus;
5
5
  'conditional-provider': typeof conditionalProvider;
6
6
  };
@@ -4,7 +4,9 @@ exports.DEFAULT_FUNCTIONS = void 0;
4
4
  const conditional_provider_1 = require("./conditional-provider");
5
5
  const conditional_queue_status_1 = require("./conditional-queue-status");
6
6
  exports.DEFAULT_FUNCTIONS = {
7
- 'conditional-queue-status': conditional_queue_status_1.conditionalQueueStatus,
7
+ // TODO: Rename api action name
8
+ // 'conditional-queue-status': conditionalQueueStatus,
9
+ 'check-queue-status': conditional_queue_status_1.conditionalQueueStatus,
8
10
  'conditional-provider': conditional_provider_1.conditionalProvider,
9
11
  };
10
12
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,yEAAmE;AAEtD,QAAA,iBAAiB,GAAG;IAC/B,0BAA0B,EAAE,iDAAsB;IAClD,sBAAsB,EAAE,0CAAmB;CAC5C,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/functions/index.ts"],"names":[],"mappings":";;;AAAA,iEAA4D;AAC5D,yEAAmE;AAEtD,QAAA,iBAAiB,GAAG;IAC/B,+BAA+B;IAC/B,sDAAsD;IACtD,oBAAoB,EAAE,iDAAsB;IAC5C,sBAAsB,EAAE,0CAAmB;CAC5C,CAAA"}
@@ -1,2 +1,2 @@
1
1
  import { ActionRequest } from '@botonic/react';
2
- export declare function doHandoff(request: ActionRequest): Promise<any>;
2
+ export declare function doHandoff(request: ActionRequest, queue: string, note?: string, agentEmail?: string): Promise<void>;
@@ -2,27 +2,23 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.doHandoff = void 0;
4
4
  const core_1 = require("@botonic/core");
5
- // TODO: Remove all "getOpenQueues" logic and open/closed messages.
6
- // This function should just do a basic handoff
7
- // TODO: add missing options: withNote, withAgent
8
- async function doHandoff(request) {
5
+ async function doHandoff(request, queue, note, agentEmail) {
9
6
  var _a;
10
7
  // @ts-ignore
11
8
  const flowBuilderPlugin = request.plugins.hubtypeFlowBuilder;
12
9
  const handoffContent = await flowBuilderPlugin.getHandoffContent();
13
- console.log(handoffContent);
14
10
  // @ts-ignore
15
- let openQueues = await core_1.getOpenQueues(request.session);
16
- const queueName = 'Test';
17
- if (openQueues.queues.indexOf(queueName) !== -1) {
18
- // @ts-ignore
19
- const handOffBuilder = new core_1.HandOffBuilder(request.session);
20
- handOffBuilder.withQueue('Test');
21
- handOffBuilder.withOnFinishPayload((_a = handoffContent.target) === null || _a === void 0 ? void 0 : _a.id);
22
- await handOffBuilder.handOff();
23
- return handoffContent.content.message[0].message;
11
+ const handOffBuilder = new core_1.HandOffBuilder(request.session);
12
+ handOffBuilder.withQueue(queue);
13
+ if (note) {
14
+ handOffBuilder.withNote(note);
24
15
  }
25
- return handoffContent.content.failMessage[0].message;
16
+ if (agentEmail) {
17
+ handOffBuilder.withAgentEmail(agentEmail);
18
+ }
19
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
20
+ handOffBuilder.withOnFinishPayload((_a = handoffContent.target) === null || _a === void 0 ? void 0 : _a.id);
21
+ await handOffBuilder.handOff();
26
22
  }
27
23
  exports.doHandoff = doHandoff;
28
24
  //# sourceMappingURL=handoff.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA6D;AAG7D,mEAAmE;AACnE,+CAA+C;AAC/C,iDAAiD;AAE1C,KAAK,UAAU,SAAS,CAAC,OAAsB;;IACpD,aAAa;IACb,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAyB,CAAA;IACnE,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,EAAE,CAAA;IAClE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;IAC3B,aAAa;IACb,IAAI,UAAU,GAAG,MAAM,oBAAa,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IACrD,MAAM,SAAS,GAAG,MAAM,CAAA;IACxB,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,EAAE;QAC/C,aAAa;QACb,MAAM,cAAc,GAAG,IAAI,qBAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC1D,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAChC,cAAc,CAAC,mBAAmB,CAAC,MAAA,cAAc,CAAC,MAAM,0CAAE,EAAG,CAAC,CAAA;QAC9D,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;QAE9B,OAAO,cAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;KACjD;IAED,OAAO,cAAc,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,OAAO,CAAA;AACtD,CAAC;AAnBD,8BAmBC"}
1
+ {"version":3,"file":"handoff.js","sourceRoot":"","sources":["../../src/handoff.ts"],"names":[],"mappings":";;;AAAA,wCAA8C;AAGvC,KAAK,UAAU,SAAS,CAC7B,OAAsB,EACtB,KAAa,EACb,IAAa,EACb,UAAmB;;IAEnB,aAAa;IACb,MAAM,iBAAiB,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAyB,CAAA;IACnE,MAAM,cAAc,GAAG,MAAM,iBAAiB,CAAC,iBAAiB,EAAE,CAAA;IAElE,aAAa;IACb,MAAM,cAAc,GAAG,IAAI,qBAAc,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;IAC1D,cAAc,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAE/B,IAAI,IAAI,EAAE;QACR,cAAc,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;KAC9B;IAED,IAAI,UAAU,EAAE;QACd,cAAc,CAAC,cAAc,CAAC,UAAU,CAAC,CAAA;KAC1C;IACD,oEAAoE;IACpE,cAAc,CAAC,mBAAmB,CAAC,MAAA,cAAc,CAAC,MAAM,0CAAE,EAAG,CAAC,CAAA;IAC9D,MAAM,cAAc,CAAC,OAAO,EAAE,CAAA;AAChC,CAAC;AAxBD,8BAwBC"}
@@ -1,11 +1,12 @@
1
1
  import { Input, Plugin, PluginPostRequest, PluginPreRequest, Session } from '@botonic/core';
2
- import { FlowContent } from './content-fields/content-base';
3
- import { HtFlowBuilderData, HtFunctionNode, HtHandoffNode, HtIntentNode, HtKeywordNode, HtNodeComponent } from './hubtype-models';
4
- declare type BotonicPluginFlowBuilderOptions = {
2
+ import { FlowContent } from './content-fields';
3
+ import { FlowBuilderData, FunctionNode, HandoffNode, IntentNode, KeywordNode, NodeComponent } from './flow-builder-models';
4
+ export declare type BotonicPluginFlowBuilderOptions = {
5
5
  flowUrl: string;
6
- flow: any;
7
- customFunctions: Record<any, any>;
6
+ flow?: FlowBuilderData;
7
+ customFunctions?: Record<any, any>;
8
8
  getLocale: (session: Session) => string;
9
+ getAccessToken: () => string;
9
10
  };
10
11
  export default class BotonicPluginFlowBuilder implements Plugin {
11
12
  readonly options: BotonicPluginFlowBuilderOptions;
@@ -13,21 +14,22 @@ export default class BotonicPluginFlowBuilder implements Plugin {
13
14
  private flow;
14
15
  private functions;
15
16
  private currentRequest;
17
+ private getAccessToken;
16
18
  getLocale: (session: Session) => string;
17
19
  constructor(options: BotonicPluginFlowBuilderOptions);
18
- readFlowContent(): Promise<HtFlowBuilderData>;
20
+ readFlowContent(): Promise<FlowBuilderData>;
19
21
  pre(request: PluginPreRequest): Promise<void>;
20
22
  post(_request: PluginPostRequest): Promise<void>;
21
- getContent(id: string): Promise<HtNodeComponent>;
22
- getHandoffContent(): Promise<HtHandoffNode>;
23
- getFlowContent(hubtypeContent: HtNodeComponent, locale: string): FlowContent | undefined;
23
+ getContent(id: string): Promise<NodeComponent>;
24
+ getHandoffContent(): Promise<HandoffNode>;
25
+ getFlowContent(hubtypeContent: NodeComponent, locale: string): FlowContent | undefined;
24
26
  getStartId(): Promise<string>;
25
27
  getContents(id: string, locale: string, prevContents?: FlowContent[]): Promise<FlowContent[]>;
26
28
  getPayloadByInput(input: Input, locale: string): Promise<string | undefined>;
27
- hasIntent(node: HtIntentNode, intent: string, locale: string): boolean;
29
+ hasIntent(node: IntentNode, intent: string, locale: string): boolean;
28
30
  getPayloadByKeyword(input: Input, locale: string): Promise<string | undefined>;
29
- matchKeywords(node: HtKeywordNode, input: string, locale: string): boolean;
31
+ matchKeywords(node: KeywordNode, input: string, locale: string): boolean;
30
32
  containsAnyKeywords(input: string, keywords: string[]): boolean;
31
- callFunction(functionNode: HtFunctionNode, locale: string): Promise<string>;
33
+ callFunction(functionNode: FunctionNode, locale: string): Promise<string>;
32
34
  }
33
- export {};
35
+ export { FlowBuilderAction } from './action';
package/lib/cjs/index.js CHANGED
@@ -1,26 +1,26 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FlowBuilderAction = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const axios_1 = tslib_1.__importDefault(require("axios"));
5
- const carousel_1 = require("./content-fields/carousel");
6
- const image_1 = require("./content-fields/image");
7
- const text_1 = require("./content-fields/text");
6
+ const content_fields_1 = require("./content-fields");
7
+ const flow_builder_models_1 = require("./flow-builder-models");
8
8
  const functions_1 = require("./functions");
9
- const hubtype_models_1 = require("./hubtype-models");
10
9
  class BotonicPluginFlowBuilder {
11
10
  constructor(options) {
12
11
  this.options = options;
12
+ this.getLocale = options.getLocale;
13
+ this.getAccessToken = options.getAccessToken;
13
14
  this.flowUrl = options.flowUrl;
14
15
  this.flow = options.flow || this.readFlowContent();
15
16
  const customFunctions = options.customFunctions || {};
16
17
  this.functions = Object.assign(Object.assign({}, functions_1.DEFAULT_FUNCTIONS), customFunctions);
17
- this.getLocale = options.getLocale;
18
18
  }
19
19
  async readFlowContent() {
20
- const response = await axios_1.default.get(this.flowUrl);
21
- const data = await response.data;
22
- //@ts-ignore
23
- return Promise.resolve(data);
20
+ const response = await axios_1.default.get(this.flowUrl, {
21
+ headers: { Authorization: `Bearer ${this.getAccessToken()}` },
22
+ });
23
+ return response.data;
24
24
  }
25
25
  async pre(request) {
26
26
  this.currentRequest = request;
@@ -29,33 +29,33 @@ class BotonicPluginFlowBuilder {
29
29
  async post(_request) { }
30
30
  async getContent(id) {
31
31
  const flow = await this.flow;
32
- const content = flow.nodes.find((c) => c.id === id);
32
+ const content = flow.nodes.find(node => node.id === id);
33
33
  if (!content)
34
- throw Error(`text with id: '${id}' not found`);
34
+ throw Error(`Node with id: '${id}' not found`);
35
35
  return content;
36
36
  }
37
37
  async getHandoffContent() {
38
38
  const flow = await this.flow;
39
- const content = flow.nodes.find((c) => c.type === 'handoff');
39
+ const content = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.HANDOFF);
40
40
  if (!content)
41
41
  throw Error(`Handoff node not found`);
42
42
  return content;
43
43
  }
44
44
  getFlowContent(hubtypeContent, locale) {
45
45
  switch (hubtypeContent.type) {
46
- case hubtype_models_1.MessageContentType.TEXT:
47
- return text_1.FlowText.fromHubtypeCMS(hubtypeContent, locale);
48
- case hubtype_models_1.MessageContentType.IMAGE:
49
- return image_1.FlowImage.fromHubtypeCMS(hubtypeContent, locale);
50
- case hubtype_models_1.MessageContentType.CAROUSEL:
51
- return carousel_1.FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
46
+ case flow_builder_models_1.NodeType.TEXT:
47
+ return content_fields_1.FlowText.fromHubtypeCMS(hubtypeContent, locale);
48
+ case flow_builder_models_1.NodeType.IMAGE:
49
+ return content_fields_1.FlowImage.fromHubtypeCMS(hubtypeContent, locale);
50
+ case flow_builder_models_1.NodeType.CAROUSEL:
51
+ return content_fields_1.FlowCarousel.fromHubtypeCMS(hubtypeContent, locale);
52
52
  default:
53
53
  return undefined;
54
54
  }
55
55
  }
56
56
  async getStartId() {
57
57
  const flow = await this.flow;
58
- const startNode = flow.nodes.find((node) => (node === null || node === void 0 ? void 0 : node.type) === hubtype_models_1.StartFieldsType.START_UP);
58
+ const startNode = flow.nodes.find(node => node.type === flow_builder_models_1.NodeType.START_UP);
59
59
  if (!startNode) {
60
60
  throw new Error('start-up id must be defined');
61
61
  }
@@ -64,8 +64,18 @@ class BotonicPluginFlowBuilder {
64
64
  async getContents(id, locale, prevContents) {
65
65
  const contents = prevContents || [];
66
66
  const hubtypeContent = await this.getContent(id);
67
+ if (hubtypeContent.content.buttons) {
68
+ for (const i in hubtypeContent.content.buttons) {
69
+ const button = hubtypeContent.content.buttons[i];
70
+ if (button.url) {
71
+ for (const j in button.url) {
72
+ button.url[j] = Object.assign(Object.assign({}, button.url[j]), (await this.getContent(button.url[j].id)));
73
+ }
74
+ }
75
+ }
76
+ }
67
77
  const content = await this.getFlowContent(hubtypeContent, locale);
68
- if (hubtypeContent.type === hubtype_models_1.MessageContentType.FUNCTION) {
78
+ if (hubtypeContent.type === flow_builder_models_1.NodeType.FUNCTION) {
69
79
  const targetId = await this.callFunction(hubtypeContent, locale);
70
80
  return this.getContents(targetId, locale, contents);
71
81
  }
@@ -84,7 +94,7 @@ class BotonicPluginFlowBuilder {
84
94
  var _a;
85
95
  try {
86
96
  const flow = await this.flow;
87
- const intents = flow.nodes.filter(node => node.type == hubtype_models_1.MessageContentType.INTENT);
97
+ const intents = flow.nodes.filter(node => node.type === flow_builder_models_1.NodeType.INTENT);
88
98
  if (input.intent) {
89
99
  const matchedIntents = intents.filter(node =>
90
100
  //@ts-ignore
@@ -107,7 +117,7 @@ class BotonicPluginFlowBuilder {
107
117
  var _a;
108
118
  try {
109
119
  const flow = await this.flow;
110
- const keywordNodes = flow.nodes.filter(node => node.type == hubtype_models_1.MessageContentType.KEYWORD);
120
+ const keywordNodes = flow.nodes.filter(node => node.type == flow_builder_models_1.NodeType.KEYWORD);
111
121
  const matchedKeywordNodes = keywordNodes.filter(node =>
112
122
  //@ts-ignore
113
123
  this.matchKeywords(node, input.data, locale));
@@ -133,11 +143,13 @@ class BotonicPluginFlowBuilder {
133
143
  return false;
134
144
  }
135
145
  async callFunction(functionNode, locale) {
136
- // Check if target is missing or missing arguments
137
- // TODO: get arguments by locale
138
- const nameValues = functionNode.content.arguments
139
- .find(arg => arg.locale === locale)
140
- .values.map(value => ({ [value.name]: value.value }));
146
+ var _a;
147
+ const functionNodeId = functionNode.id;
148
+ const nameValues = (_a = functionNode.content.arguments
149
+ .find(arg => arg.locale === locale)) === null || _a === void 0 ? void 0 : _a.values.map(value => ({ [value.name]: value.value }));
150
+ if (!nameValues) {
151
+ throw new Error(`No arguments found for node with id ${functionNodeId}`);
152
+ }
141
153
  const args = Object.assign({
142
154
  session: this.currentRequest.session,
143
155
  results: [functionNode.content.result_mapping.map(r => r.result)],
@@ -145,8 +157,13 @@ class BotonicPluginFlowBuilder {
145
157
  const functionResult = await this.functions[functionNode.content.action](args);
146
158
  // TODO define result_mapping per locale??
147
159
  const result = functionNode.content.result_mapping.find(r => r.result === functionResult);
160
+ if (!result) {
161
+ throw new Error(`No result found for result_mapping for node with id: ${functionNodeId}`);
162
+ }
148
163
  return result.target.id;
149
164
  }
150
165
  }
151
166
  exports.default = BotonicPluginFlowBuilder;
167
+ var action_1 = require("./action");
168
+ Object.defineProperty(exports, "FlowBuilderAction", { enumerable: true, get: function () { return action_1.FlowBuilderAction; } });
152
169
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAOA,0DAAyB;AAEzB,wDAAwD;AAExD,kDAAkD;AAClD,gDAAgD;AAChD,2CAA+C;AAC/C,qDAYyB;AASzB,MAAqB,wBAAwB;IAO3C,YAAqB,OAAwC;QAAxC,YAAO,GAAP,OAAO,CAAiC;QAC3D,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAA;QAC9B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,IAAI,CAAC,eAAe,EAAE,CAAA;QAClD,MAAM,eAAe,GAAG,OAAO,CAAC,eAAe,IAAI,EAAE,CAAA;QACrD,IAAI,CAAC,SAAS,mCAAQ,6BAAiB,GAAK,eAAe,CAAE,CAAA;QAC7D,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;IACpC,CAAC;IAED,KAAK,CAAC,eAAe;QACnB,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9C,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAA;QAChC,YAAY;QACZ,OAAO,OAAO,CAAC,OAAO,CAAC,IAAyB,CAAC,CAAA;IACnD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,OAAyB;QACjC,IAAI,CAAC,cAAc,GAAG,OAAO,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,eAAe,EAAE,CAAA;IACpC,CAAC;IAED,KAAK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ACpC,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;SAClE,EACD,GAAG,UAAU,CACd,CAAA;QACD,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,OAAO,CAAC,MAAM,CAAC,CACtE,IAAI,CACL,CAAA;QACD,0CAA0C;QAC1C,MAAM,MAAM,GAAG,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,IAAI,CACrD,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,cAAc,CACjC,CAAA;QACD,IAAI,CAAC,MAAM,EAAE;YACX,MAAM,IAAI,KAAK,CACb,wDAAwD,cAAc,EAAE,CACzE,CAAA;SACF;QACD,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,CAAA;IACzB,CAAC;CACF;AAnND,2CAmNC;AAED,mCAA4C;AAAnC,2GAAA,iBAAiB,OAAA"}
@@ -1,2 +1 @@
1
- import { HtMediaFileLocale } from './hubtype-models';
2
- export declare function getImageByLocale(locale: string, image: HtMediaFileLocale[]): string;
1
+ export declare function getWebpackEnvVar(webpackEnvVar: string | false, name: string, defaultValue: string): string;
package/lib/cjs/utils.js CHANGED
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImageByLocale = void 0;
4
- function getImageByLocale(locale, image) {
5
- var _a;
6
- const result = image.find(t => t.locale == locale);
7
- return (_a = result === null || result === void 0 ? void 0 : result.file) !== null && _a !== void 0 ? _a : '';
3
+ exports.getWebpackEnvVar = void 0;
4
+ function getWebpackEnvVar(webpackEnvVar, name, defaultValue) {
5
+ return (webpackEnvVar ||
6
+ (typeof process !== 'undefined' && process.env[name]) ||
7
+ defaultValue);
8
8
  }
9
- exports.getImageByLocale = getImageByLocale;
9
+ exports.getWebpackEnvVar = getWebpackEnvVar;
10
10
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,MAAc,EAAE,KAA0B;;IACzE,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,IAAI,MAAM,CAAC,CAAA;IAClD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,EAAE,CAAA;AAC3B,CAAC;AAHD,4CAGC"}
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,gBAAgB,CAC9B,aAA6B,EAC7B,IAAY,EACZ,YAAoB;IAEpB,OAAO,CACL,aAAa;QACb,CAAC,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACrD,YAAY,CACb,CAAA;AACH,CAAC;AAVD,4CAUC"}
@@ -1,12 +1,11 @@
1
1
  import { ActionRequest } from '@botonic/react';
2
2
  import React from 'react';
3
- import { FlowContent } from './content-fields/content-base';
4
- import { HtHandoffNode } from './hubtype-models';
3
+ import { FlowContent } from './content-fields';
5
4
  declare type FlowBuilderActionProps = {
6
5
  content?: FlowContent[];
7
- handoffMsg?: HtHandoffNode;
6
+ isHandoff?: boolean;
8
7
  };
9
- export default class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
8
+ export declare class FlowBuilderAction extends React.Component<FlowBuilderActionProps> {
10
9
  static contextType: React.Context<import("@botonic/react").RequestContextInterface>;
11
10
  static botonicInit(request: ActionRequest): Promise<any>;
12
11
  render(): JSX.Element | JSX.Element[];
package/lib/esm/action.js CHANGED
@@ -1,11 +1,10 @@
1
1
  import { RequestContext, Text } from '@botonic/react';
2
2
  import React from 'react';
3
3
  import { doHandoff } from './handoff';
4
- export default class FlowBuilderAction extends React.Component {
4
+ export class FlowBuilderAction extends React.Component {
5
5
  static async botonicInit(request) {
6
- console.log(request);
7
6
  const flowBuilderPlugin = request.plugins
8
- .flowBuilder;
7
+ .hubtypeFlowBuilder;
9
8
  const locale = flowBuilderPlugin.getLocale(request.session);
10
9
  let payload = request.input.payload
11
10
  ? request.input.payload
@@ -22,18 +21,23 @@ export default class FlowBuilderAction extends React.Component {
22
21
  }
23
22
  // We use only Spanish because they are the backend examples
24
23
  const content = await flowBuilderPlugin.getContents(payload, locale);
25
- if (content.length == 0) {
26
- const handoffMsg = await doHandoff(request);
27
- return { handoffMsg };
24
+ if (content.length === 0) {
25
+ const handoffParams = {
26
+ queue: 'Test',
27
+ agentEmail: 'test@gmail.com',
28
+ note: 'This is a note that will be attached to the case as a reminder',
29
+ };
30
+ await doHandoff(request, handoffParams.queue, handoffParams.note);
31
+ const isHandoff = true;
32
+ return { isHandoff };
28
33
  }
29
34
  return { content };
30
35
  }
31
36
  render() {
32
37
  // @ts-ignore
33
- const { content: contents, handoffMsg } = this.props;
34
- if (handoffMsg) {
35
- // @ts-ignore
36
- return React.createElement(Text, null, handoffMsg);
38
+ const { content: contents, isHandoff } = this.props;
39
+ if (isHandoff) {
40
+ return React.createElement(Text, null, "You are being transferred to an agent!");
37
41
  }
38
42
  else {
39
43
  return contents.map((content, index) => content.toBotonic(index));
@@ -1 +1 @@
1
- {"version":3,"file":"action.js","sourceRoot":"","sources":["../../src/action.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAiB,cAAc,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AACpE,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AASrC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK,CAAC,SAAiC;IAGpF,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC,OAAsB;QAC7C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QACp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;QAEpE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE;YACxB,MAAM,aAAa,GAAG;gBACpB,KAAK,EAAE,MAAM;gBACb,UAAU,EAAE,gBAAgB;gBAC5B,IAAI,EAAE,gEAAgE;aACvE,CAAA;YACD,MAAM,SAAS,CAAC,OAAO,EAAE,aAAa,CAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAA;YACjE,MAAM,SAAS,GAAG,IAAI,CAAA;YACtB,OAAO,EAAE,SAAS,EAAE,CAAA;SACrB;QACD,OAAO,EAAE,OAAO,EAAE,CAAA;IACpB,CAAC;IAED,MAAM;QACJ,aAAa;QACb,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QACnD,IAAI,SAAS,EAAE;YACb,OAAO,oBAAC,IAAI,iDAA8C,CAAA;SAC3D;aAAM;YACL,OAAO,QAAS,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;SACnE;IACH,CAAC;;AAlDM,6BAAW,GAAG,cAAc,CAAA"}
@@ -0,0 +1,7 @@
1
+ import { MediaFileLocale, TextLocale } from '../flow-builder-models';
2
+ export declare abstract class ContentFieldsBase {
3
+ private readonly id;
4
+ constructor(id: string);
5
+ static getTextByLocale(locale: string, text: TextLocale[]): string;
6
+ static getImageByLocale(locale: string, image: MediaFileLocale[]): string;
7
+ }
@@ -0,0 +1,16 @@
1
+ export class ContentFieldsBase {
2
+ constructor(id) {
3
+ this.id = id;
4
+ }
5
+ static getTextByLocale(locale, text) {
6
+ var _a;
7
+ const result = text.find(t => t.locale === locale);
8
+ return (_a = result === null || result === void 0 ? void 0 : result.message) !== null && _a !== void 0 ? _a : '';
9
+ }
10
+ static getImageByLocale(locale, image) {
11
+ var _a;
12
+ const result = image.find(t => t.locale === locale);
13
+ return (_a = result === null || result === void 0 ? void 0 : result.file) !== null && _a !== void 0 ? _a : '';
14
+ }
15
+ }
16
+ //# sourceMappingURL=content-fields-base.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-fields-base.js","sourceRoot":"","sources":["../../../src/content-fields/content-fields-base.ts"],"names":[],"mappings":"AAEA,MAAM,OAAgB,iBAAiB;IACrC,YAA6B,EAAU;QAAV,OAAE,GAAF,EAAE,CAAQ;IAAG,CAAC;IAE3C,MAAM,CAAC,eAAe,CAAC,MAAc,EAAE,IAAkB;;QACvD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QAClD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,mCAAI,EAAE,CAAA;IAC9B,CAAC;IAED,MAAM,CAAC,gBAAgB,CAAC,MAAc,EAAE,KAAwB;;QAC9D,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,MAAM,CAAC,CAAA;QACnD,OAAO,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,EAAE,CAAA;IAC3B,CAAC;CACF"}
@@ -1,10 +1,10 @@
1
1
  /// <reference types="react" />
2
- import { ButtonStyle, HtButton } from '../hubtype-models';
3
- import { ContentFieldsBase } from './content-base';
2
+ import { Button as FbButton, ButtonStyle } from '../flow-builder-models';
3
+ import { ContentFieldsBase } from './content-fields-base';
4
4
  export declare class FlowButton extends ContentFieldsBase {
5
5
  text: string;
6
6
  url?: string;
7
7
  payload?: string;
8
- static fromHubtypeCMS(component: HtButton, locale: string): FlowButton;
8
+ static fromHubtypeCMS(component: FbButton, locale: string): FlowButton;
9
9
  renderButton(index: number, buttonStyle: ButtonStyle): JSX.Element;
10
10
  }
@@ -1,7 +1,7 @@
1
1
  import { Button, Reply } from '@botonic/react';
2
2
  import React from 'react';
3
- import { ButtonStyle } from '../hubtype-models';
4
- import { ContentFieldsBase } from './content-base';
3
+ import { ButtonStyle } from '../flow-builder-models';
4
+ import { ContentFieldsBase } from './content-fields-base';
5
5
  export class FlowButton extends ContentFieldsBase {
6
6
  constructor() {
7
7
  super(...arguments);
@@ -12,15 +12,21 @@ export class FlowButton extends ContentFieldsBase {
12
12
  const newButton = new FlowButton(component.id);
13
13
  newButton.text = FlowButton.getTextByLocale(locale, component.text);
14
14
  newButton.payload = (_a = component.target) === null || _a === void 0 ? void 0 : _a.id;
15
+ if (component.url) {
16
+ newButton.url = component.url.find(url => url.locale === locale).content.url;
17
+ }
15
18
  return newButton;
16
19
  }
17
20
  renderButton(index, buttonStyle) {
18
- if (buttonStyle == ButtonStyle.QUICK_REPLY) {
21
+ if (buttonStyle === ButtonStyle.QUICK_REPLY) {
19
22
  return (React.createElement(Reply, { payload: this.payload, key: index }, this.text));
20
23
  }
24
+ let props = {};
25
+ if (this.url)
26
+ props = { url: this.url };
21
27
  return (
22
28
  // @ts-ignore
23
- React.createElement(Button, { payload: this.payload, key: index }, this.text));
29
+ React.createElement(Button, Object.assign({ payload: this.payload, key: index }, props), this.text));
24
30
  }
25
31
  }
26
- //# sourceMappingURL=button.js.map
32
+ //# sourceMappingURL=flow-button.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"flow-button.js","sourceRoot":"","sources":["../../../src/content-fields/flow-button.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAsB,WAAW,EAAE,MAAM,wBAAwB,CAAA;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AAEzD,MAAM,OAAO,UAAW,SAAQ,iBAAiB;IAAjD;;QACS,SAAI,GAAG,EAAE,CAAA;IAiClB,CAAC;IA7BC,MAAM,CAAC,cAAc,CAAC,SAAmB,EAAE,MAAc;;QACvD,MAAM,SAAS,GAAG,IAAI,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC,CAAA;QAC9C,SAAS,CAAC,IAAI,GAAG,UAAU,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,IAAI,CAAC,CAAA;QACnE,SAAS,CAAC,OAAO,GAAG,MAAA,SAAS,CAAC,MAAM,0CAAE,EAAE,CAAA;QACxC,IAAI,SAAS,CAAC,GAAG,EAAE;YACjB,SAAS,CAAC,GAAG,GAAI,SAAS,CAAC,GAAW,CAAC,IAAI,CACzC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,MAAM,KAAK,MAAM,CAC7B,CAAC,OAAO,CAAC,GAAG,CAAA;SACd;QACD,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,YAAY,CAAC,KAAa,EAAE,WAAwB;QAClD,IAAI,WAAW,KAAK,WAAW,CAAC,WAAW,EAAE;YAC3C,OAAO,CACL,oBAAC,KAAK,IAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,IACrC,IAAI,CAAC,IAAI,CACJ,CACT,CAAA;SACF;QACD,IAAI,KAAK,GAAG,EAAE,CAAA;QACd,IAAI,IAAI,CAAC,GAAG;YAAE,KAAK,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAAA;QACvC,OAAO;QACL,aAAa;QACb,oBAAC,MAAM,kBAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,KAAK,IAAM,KAAK,GACjD,IAAI,CAAC,IAAI,CACH,CACV,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { CarouselNode } from '../flow-builder-models';
3
+ import { ContentFieldsBase } from './content-fields-base';
4
+ import { FlowElement } from './flow-element';
5
+ export declare class FlowCarousel extends ContentFieldsBase {
6
+ code: string;
7
+ elements: FlowElement[];
8
+ static fromHubtypeCMS(component: CarouselNode, locale: string): FlowCarousel;
9
+ toBotonic(index: number): JSX.Element;
10
+ }
@@ -1,7 +1,7 @@
1
1
  import { Button, Carousel, Element, Pic, Subtitle, Title } from '@botonic/react';
2
2
  import React from 'react';
3
- import { ContentFieldsBase } from './content-base';
4
- import { FlowElement } from './element';
3
+ import { ContentFieldsBase } from './content-fields-base';
4
+ import { FlowElement } from './flow-element';
5
5
  export class FlowCarousel extends ContentFieldsBase {
6
6
  constructor() {
7
7
  super(...arguments);
@@ -11,19 +11,19 @@ export class FlowCarousel extends ContentFieldsBase {
11
11
  static fromHubtypeCMS(component, locale) {
12
12
  const newCarousel = new FlowCarousel(component.id);
13
13
  newCarousel.code = component.code;
14
- newCarousel.elements = component.content.elements.map(ele => FlowElement.fromHubtypeCMS(ele, locale));
14
+ newCarousel.elements = component.content.elements.map(element => FlowElement.fromHubtypeCMS(element, locale));
15
15
  return newCarousel;
16
16
  }
17
17
  toBotonic(index) {
18
- return (React.createElement(Carousel, { key: index }, this.elements.map((e, eIndex) => {
18
+ return (React.createElement(Carousel, { key: index }, this.elements.map((element, eIndex) => {
19
19
  var _a, _b;
20
20
  return (React.createElement(Element, { key: eIndex },
21
- React.createElement(Pic, { src: e.image }),
22
- React.createElement(Title, { style: '' }, e.title),
23
- React.createElement(Subtitle, { style: '' }, e.subtitle),
24
- React.createElement(Button, { payload: (_a = e.buttons) === null || _a === void 0 ? void 0 : _a.payload }, (_b = e.buttons) === null || _b === void 0 ? void 0 : _b.text),
21
+ React.createElement(Pic, { src: element.image }),
22
+ React.createElement(Title, { style: '' }, element.title),
23
+ React.createElement(Subtitle, { style: '' }, element.subtitle),
24
+ React.createElement(Button, { payload: (_a = element.buttons) === null || _a === void 0 ? void 0 : _a.payload }, (_b = element.buttons) === null || _b === void 0 ? void 0 : _b.text),
25
25
  ","));
26
26
  })));
27
27
  }
28
28
  }
29
- //# sourceMappingURL=carousel.js.map
29
+ //# sourceMappingURL=flow-carousel.js.map
@@ -0,0 +1 @@
1
+ {"version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AAE,OAAO,CAAC,QAAQ,CAAY;gBAEhD,oBAAC,MAAM,IAAC,OAAO,EAAE,MAAA,OAAO,CAAC,OAAO,0CAAE,OAAO,IACtC,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,CACf;oBAED,CACX,CAAA;SAAA,CAAC,CACO,CACZ,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { CarouselElementNode } from '../flow-builder-models';
2
+ import { ContentFieldsBase } from './content-fields-base';
3
+ import { FlowButton } from './flow-button';
4
+ export declare class FlowElement extends ContentFieldsBase {
5
+ title: string;
6
+ subtitle: string;
7
+ buttons: FlowButton | undefined;
8
+ image: string;
9
+ hidden: boolean;
10
+ static fromHubtypeCMS(component: CarouselElementNode, locale: string): FlowElement;
11
+ }