@dawntech/blip-tools 0.7.1 → 0.7.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.
package/dist/index.cjs CHANGED
@@ -93,6 +93,9 @@ class BlipBucket {
93
93
  throw handleError(error);
94
94
  }
95
95
  }
96
+ /**
97
+ * Returns all document ids stored in the Blip bucket.
98
+ */
96
99
  async getAllContentIdsFromBucket() {
97
100
  try {
98
101
  const body = {
@@ -185,6 +188,9 @@ class BlipAttendance {
185
188
  constructor(context) {
186
189
  this.api = context.api;
187
190
  }
191
+ /**
192
+ * Returns the attendance hour container for the given id.
193
+ */
188
194
  async getAttendanceHourContainer({ attendanceContainerId }) {
189
195
  try {
190
196
  const body = {
@@ -216,6 +222,9 @@ class BlipContact {
216
222
  constructor(context) {
217
223
  this.api = context.api;
218
224
  }
225
+ /**
226
+ * Merges the provided fields into the contact identified by `identity`.
227
+ */
219
228
  async update({ identity, contactData }) {
220
229
  try {
221
230
  const response = await this.api.post('/commands', {
@@ -235,6 +244,9 @@ class BlipContact {
235
244
  handleError(error);
236
245
  }
237
246
  }
247
+ /**
248
+ * Returns the contact for the given identity.
249
+ */
238
250
  async get({ identity }) {
239
251
  try {
240
252
  const response = await this.api.post('/commands', {
@@ -250,6 +262,9 @@ class BlipContact {
250
262
  throw handleError(error);
251
263
  }
252
264
  }
265
+ /**
266
+ * Searches contacts. Supports OData-style `$filter`, `$skip` and `$take` parameters.
267
+ */
253
268
  async search({ filter, skip, take } = {}) {
254
269
  const params = {
255
270
  $filter: filter,
@@ -277,6 +292,9 @@ class BlipContext {
277
292
  constructor(context) {
278
293
  this.api = context.api;
279
294
  }
295
+ /**
296
+ * Returns the value of a context variable for the given identity.
297
+ */
280
298
  async getContextVariable({ identity, variableName }) {
281
299
  try {
282
300
  const response = await this.api.post('/commands', {
@@ -292,6 +310,9 @@ class BlipContext {
292
310
  throw handleError(error);
293
311
  }
294
312
  }
313
+ /**
314
+ * Returns all available context variables for the given identity.
315
+ */
295
316
  async getAvailableContextVariables({ identity }) {
296
317
  try {
297
318
  const response = await this.api.post('/commands', {
@@ -307,6 +328,9 @@ class BlipContext {
307
328
  throw handleError(error);
308
329
  }
309
330
  }
331
+ /**
332
+ * Sets a context variable for the given identity. Object values are stored as JSON, primitive values as plain text.
333
+ */
310
334
  async setContextVariable({ value, variableName, identity, }) {
311
335
  try {
312
336
  const resourceType = typeof value === 'object' ? 'application/vnd.lime.contact+json' : 'text/plain';
@@ -379,6 +403,9 @@ class BlipDispatch {
379
403
  throw handleError(error);
380
404
  }
381
405
  }
406
+ /**
407
+ * Returns the delivery status entries of a campaign notification by id.
408
+ */
382
409
  async getCampaignNotificationStatus({ campaignNotificationId }) {
383
410
  try {
384
411
  const response = await this.api.post('/commands', {
@@ -459,6 +486,9 @@ class BlipDispatch {
459
486
  handleError(error);
460
487
  }
461
488
  }
489
+ /**
490
+ * Sends a message with selectable buttons to an active user. Up to 3 buttons are shown immediately; more are presented as a list.
491
+ */
462
492
  async sendMessageWithButtons({ identity, message, buttons, metadata, }) {
463
493
  try {
464
494
  const response = await this.api.post('/messages', {
@@ -485,6 +515,9 @@ class BlipEvent {
485
515
  constructor(context) {
486
516
  this.api = context.api;
487
517
  }
518
+ /**
519
+ * Tracks an analytics event under the given category and action. Optionally associates it with a contact identity.
520
+ */
488
521
  async createTrackEvent({ category, action, identity }) {
489
522
  try {
490
523
  const body = {
@@ -513,6 +546,9 @@ class BlipInteraction {
513
546
  constructor(context) {
514
547
  this.blipContext = context.blipContext;
515
548
  }
549
+ /**
550
+ * Moves a user to the specified subbot and state by setting the corresponding context variables.
551
+ */
516
552
  async moveUser({ identity, botIdentity, botFlowId, botStateId, }) {
517
553
  await Promise.all([
518
554
  this.blipContext.setContextVariable({ identity, variableName: 'master-state', value: botIdentity }),
@@ -526,6 +562,9 @@ class BlipTicket {
526
562
  constructor(context) {
527
563
  this.api = context.api;
528
564
  }
565
+ /**
566
+ * Searches tickets. Supports OData-style `$filter`, `$skip` and `$take` parameters.
567
+ */
529
568
  async search({ filter, skip, take } = {}) {
530
569
  try {
531
570
  const params = {
@@ -547,6 +586,9 @@ class BlipTicket {
547
586
  throw handleError(error);
548
587
  }
549
588
  }
589
+ /**
590
+ * Returns a ticket by id.
591
+ */
550
592
  async getTicket(ticketId) {
551
593
  try {
552
594
  const body = {
@@ -570,6 +612,9 @@ class BlipWhatsapp {
570
612
  constructor(context) {
571
613
  this.api = context.api;
572
614
  }
615
+ /**
616
+ * Returns all approved WhatsApp message templates for the channel.
617
+ */
573
618
  async getTemplates() {
574
619
  try {
575
620
  const response = await this.api.post('/commands', {
@@ -585,6 +630,9 @@ class BlipWhatsapp {
585
630
  throw handleError(error);
586
631
  }
587
632
  }
633
+ /**
634
+ * Returns the WhatsApp Blip identity associated with the given phone number.
635
+ */
588
636
  async getIdentity(phone) {
589
637
  try {
590
638
  const response = await this.api.post('/commands', {
@@ -607,6 +655,9 @@ class BlipCampaign {
607
655
  constructor(context) {
608
656
  this.api = context.api;
609
657
  }
658
+ /**
659
+ * Searches campaigns. Supports OData-style `$filter`, `$skip` and `$take` parameters.
660
+ */
610
661
  async search({ filter, skip, take } = {}) {
611
662
  try {
612
663
  const params = {
@@ -628,6 +679,9 @@ class BlipCampaign {
628
679
  throw handleError(error);
629
680
  }
630
681
  }
682
+ /**
683
+ * Returns a campaign by id.
684
+ */
631
685
  async get(campaignId) {
632
686
  try {
633
687
  const body = {
@@ -644,6 +698,9 @@ class BlipCampaign {
644
698
  throw handleError(error);
645
699
  }
646
700
  }
701
+ /**
702
+ * Deletes a campaign by id.
703
+ */
647
704
  async deleteCampaign(campaignId) {
648
705
  try {
649
706
  const body = {
@@ -661,8 +718,81 @@ class BlipCampaign {
661
718
  }
662
719
  }
663
720
 
721
+ class BlipApplication {
722
+ api;
723
+ constructor(context) {
724
+ this.api = context.api;
725
+ }
726
+ /**
727
+ * Returns the application.
728
+ */
729
+ async getApplication() {
730
+ try {
731
+ const body = {
732
+ id: crypto.randomUUID(),
733
+ to: 'postmaster@configurations.msging.net',
734
+ method: 'get',
735
+ uri: 'lime://enterprise.master.hosting@msging.net/configuration',
736
+ };
737
+ const response = await this.api.post('/commands', body);
738
+ validateResponse(response);
739
+ return JSON.parse(response.data.resource.Application);
740
+ }
741
+ catch (error) {
742
+ throw handleError(error);
743
+ }
744
+ }
745
+ }
746
+
747
+ const BUILDER_RECIPIENT = 'postmaster@builder.msging.net';
748
+ class BlipFlow {
749
+ api;
750
+ constructor(context) {
751
+ this.api = context.api;
752
+ }
753
+ /**
754
+ * Returns the flow id. When `shortName` is provided, returns the flow id of the matching subbot.
755
+ */
756
+ async getFlowId(shortName) {
757
+ try {
758
+ const body = {
759
+ id: crypto.randomUUID(),
760
+ to: BUILDER_RECIPIENT,
761
+ method: 'get',
762
+ uri: createUri('/flow-id', { shortName }),
763
+ };
764
+ const response = await this.api.post('/commands', body);
765
+ validateResponse(response);
766
+ return response.data.resource;
767
+ }
768
+ catch (error) {
769
+ throw handleError(error);
770
+ }
771
+ }
772
+ /**
773
+ * Returns the states of a flow using the flow name.
774
+ */
775
+ async getFlowStates(flowShortName) {
776
+ try {
777
+ const body = {
778
+ id: crypto.randomUUID(),
779
+ to: BUILDER_RECIPIENT,
780
+ method: 'get',
781
+ uri: createUri('/flow/states', { shortName: flowShortName }),
782
+ };
783
+ const response = await this.api.post('/commands', body);
784
+ validateResponse(response);
785
+ return response.data.resource.items;
786
+ }
787
+ catch (error) {
788
+ throw handleError(error);
789
+ }
790
+ }
791
+ }
792
+
664
793
  var index$1 = /*#__PURE__*/Object.freeze({
665
794
  __proto__: null,
795
+ BlipApplication: BlipApplication,
666
796
  BlipAttendance: BlipAttendance,
667
797
  BlipBucket: BlipBucket,
668
798
  BlipCampaign: BlipCampaign,
@@ -670,6 +800,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
670
800
  BlipContext: BlipContext,
671
801
  BlipDispatch: BlipDispatch,
672
802
  BlipEvent: BlipEvent,
803
+ BlipFlow: BlipFlow,
673
804
  BlipInteraction: BlipInteraction,
674
805
  BlipMedia: BlipMedia,
675
806
  BlipTicket: BlipTicket,
@@ -690,6 +821,9 @@ class BlipMonitoring {
690
821
  constructor(context) {
691
822
  this.api = context.api;
692
823
  }
824
+ /**
825
+ * Returns currently monitored tickets.
826
+ */
693
827
  async getTickets() {
694
828
  try {
695
829
  const response = await this.api.post('/commands', {
@@ -705,6 +839,9 @@ class BlipMonitoring {
705
839
  throw handleError(error);
706
840
  }
707
841
  }
842
+ /**
843
+ * Returns aggregated ticket metrics for the desk.
844
+ */
708
845
  async getTicketMetrics() {
709
846
  try {
710
847
  const response = await this.api.post('/commands', {
@@ -720,6 +857,9 @@ class BlipMonitoring {
720
857
  throw handleError(error);
721
858
  }
722
859
  }
860
+ /**
861
+ * Returns aggregated metrics about attendant status.
862
+ */
723
863
  async getAttendantStatusMetrics() {
724
864
  try {
725
865
  const response = await this.api.post('/commands', {
@@ -735,6 +875,9 @@ class BlipMonitoring {
735
875
  throw handleError(error);
736
876
  }
737
877
  }
878
+ /**
879
+ * Returns metrics for tickets currently waiting to be served.
880
+ */
738
881
  async getWaitingTicketsMetrics() {
739
882
  try {
740
883
  const response = await this.api.post('/commands', {
@@ -833,6 +976,9 @@ class BlipThreads {
833
976
  constructor(context) {
834
977
  this.api = context.api;
835
978
  }
979
+ /**
980
+ * Returns the message thread for the given identity. Supports pagination, filtering by message id or storage date, and refreshing expired media URIs.
981
+ */
836
982
  async getThread({ identity, refreshExpiredMedia, skip, take, messageId, storageDate, direction, getFromOriginator, }) {
837
983
  const params = {
838
984
  refreshExpiredMedia: refreshExpiredMedia ? 'true' : 'false',
@@ -874,6 +1020,8 @@ class Blip {
874
1020
  analytics;
875
1021
  campaign;
876
1022
  threads;
1023
+ application;
1024
+ flow;
877
1025
  constructor(params) {
878
1026
  validateInstance(params);
879
1027
  this.api = axios.create({
@@ -897,6 +1045,8 @@ class Blip {
897
1045
  this.analytics = new BlipAnalytics({ api: this.api });
898
1046
  this.campaign = new BlipCampaign({ api: this.api });
899
1047
  this.threads = new BlipThreads({ api: this.api });
1048
+ this.application = new BlipApplication({ api: this.api });
1049
+ this.flow = new BlipFlow({ api: this.api });
900
1050
  }
901
1051
  }
902
1052
 
package/dist/index.mjs CHANGED
@@ -91,6 +91,9 @@ class BlipBucket {
91
91
  throw handleError(error);
92
92
  }
93
93
  }
94
+ /**
95
+ * Returns all document ids stored in the Blip bucket.
96
+ */
94
97
  async getAllContentIdsFromBucket() {
95
98
  try {
96
99
  const body = {
@@ -183,6 +186,9 @@ class BlipAttendance {
183
186
  constructor(context) {
184
187
  this.api = context.api;
185
188
  }
189
+ /**
190
+ * Returns the attendance hour container for the given id.
191
+ */
186
192
  async getAttendanceHourContainer({ attendanceContainerId }) {
187
193
  try {
188
194
  const body = {
@@ -214,6 +220,9 @@ class BlipContact {
214
220
  constructor(context) {
215
221
  this.api = context.api;
216
222
  }
223
+ /**
224
+ * Merges the provided fields into the contact identified by `identity`.
225
+ */
217
226
  async update({ identity, contactData }) {
218
227
  try {
219
228
  const response = await this.api.post('/commands', {
@@ -233,6 +242,9 @@ class BlipContact {
233
242
  handleError(error);
234
243
  }
235
244
  }
245
+ /**
246
+ * Returns the contact for the given identity.
247
+ */
236
248
  async get({ identity }) {
237
249
  try {
238
250
  const response = await this.api.post('/commands', {
@@ -248,6 +260,9 @@ class BlipContact {
248
260
  throw handleError(error);
249
261
  }
250
262
  }
263
+ /**
264
+ * Searches contacts. Supports OData-style `$filter`, `$skip` and `$take` parameters.
265
+ */
251
266
  async search({ filter, skip, take } = {}) {
252
267
  const params = {
253
268
  $filter: filter,
@@ -275,6 +290,9 @@ class BlipContext {
275
290
  constructor(context) {
276
291
  this.api = context.api;
277
292
  }
293
+ /**
294
+ * Returns the value of a context variable for the given identity.
295
+ */
278
296
  async getContextVariable({ identity, variableName }) {
279
297
  try {
280
298
  const response = await this.api.post('/commands', {
@@ -290,6 +308,9 @@ class BlipContext {
290
308
  throw handleError(error);
291
309
  }
292
310
  }
311
+ /**
312
+ * Returns all available context variables for the given identity.
313
+ */
293
314
  async getAvailableContextVariables({ identity }) {
294
315
  try {
295
316
  const response = await this.api.post('/commands', {
@@ -305,6 +326,9 @@ class BlipContext {
305
326
  throw handleError(error);
306
327
  }
307
328
  }
329
+ /**
330
+ * Sets a context variable for the given identity. Object values are stored as JSON, primitive values as plain text.
331
+ */
308
332
  async setContextVariable({ value, variableName, identity, }) {
309
333
  try {
310
334
  const resourceType = typeof value === 'object' ? 'application/vnd.lime.contact+json' : 'text/plain';
@@ -377,6 +401,9 @@ class BlipDispatch {
377
401
  throw handleError(error);
378
402
  }
379
403
  }
404
+ /**
405
+ * Returns the delivery status entries of a campaign notification by id.
406
+ */
380
407
  async getCampaignNotificationStatus({ campaignNotificationId }) {
381
408
  try {
382
409
  const response = await this.api.post('/commands', {
@@ -457,6 +484,9 @@ class BlipDispatch {
457
484
  handleError(error);
458
485
  }
459
486
  }
487
+ /**
488
+ * Sends a message with selectable buttons to an active user. Up to 3 buttons are shown immediately; more are presented as a list.
489
+ */
460
490
  async sendMessageWithButtons({ identity, message, buttons, metadata, }) {
461
491
  try {
462
492
  const response = await this.api.post('/messages', {
@@ -483,6 +513,9 @@ class BlipEvent {
483
513
  constructor(context) {
484
514
  this.api = context.api;
485
515
  }
516
+ /**
517
+ * Tracks an analytics event under the given category and action. Optionally associates it with a contact identity.
518
+ */
486
519
  async createTrackEvent({ category, action, identity }) {
487
520
  try {
488
521
  const body = {
@@ -511,6 +544,9 @@ class BlipInteraction {
511
544
  constructor(context) {
512
545
  this.blipContext = context.blipContext;
513
546
  }
547
+ /**
548
+ * Moves a user to the specified subbot and state by setting the corresponding context variables.
549
+ */
514
550
  async moveUser({ identity, botIdentity, botFlowId, botStateId, }) {
515
551
  await Promise.all([
516
552
  this.blipContext.setContextVariable({ identity, variableName: 'master-state', value: botIdentity }),
@@ -524,6 +560,9 @@ class BlipTicket {
524
560
  constructor(context) {
525
561
  this.api = context.api;
526
562
  }
563
+ /**
564
+ * Searches tickets. Supports OData-style `$filter`, `$skip` and `$take` parameters.
565
+ */
527
566
  async search({ filter, skip, take } = {}) {
528
567
  try {
529
568
  const params = {
@@ -545,6 +584,9 @@ class BlipTicket {
545
584
  throw handleError(error);
546
585
  }
547
586
  }
587
+ /**
588
+ * Returns a ticket by id.
589
+ */
548
590
  async getTicket(ticketId) {
549
591
  try {
550
592
  const body = {
@@ -568,6 +610,9 @@ class BlipWhatsapp {
568
610
  constructor(context) {
569
611
  this.api = context.api;
570
612
  }
613
+ /**
614
+ * Returns all approved WhatsApp message templates for the channel.
615
+ */
571
616
  async getTemplates() {
572
617
  try {
573
618
  const response = await this.api.post('/commands', {
@@ -583,6 +628,9 @@ class BlipWhatsapp {
583
628
  throw handleError(error);
584
629
  }
585
630
  }
631
+ /**
632
+ * Returns the WhatsApp Blip identity associated with the given phone number.
633
+ */
586
634
  async getIdentity(phone) {
587
635
  try {
588
636
  const response = await this.api.post('/commands', {
@@ -605,6 +653,9 @@ class BlipCampaign {
605
653
  constructor(context) {
606
654
  this.api = context.api;
607
655
  }
656
+ /**
657
+ * Searches campaigns. Supports OData-style `$filter`, `$skip` and `$take` parameters.
658
+ */
608
659
  async search({ filter, skip, take } = {}) {
609
660
  try {
610
661
  const params = {
@@ -626,6 +677,9 @@ class BlipCampaign {
626
677
  throw handleError(error);
627
678
  }
628
679
  }
680
+ /**
681
+ * Returns a campaign by id.
682
+ */
629
683
  async get(campaignId) {
630
684
  try {
631
685
  const body = {
@@ -642,6 +696,9 @@ class BlipCampaign {
642
696
  throw handleError(error);
643
697
  }
644
698
  }
699
+ /**
700
+ * Deletes a campaign by id.
701
+ */
645
702
  async deleteCampaign(campaignId) {
646
703
  try {
647
704
  const body = {
@@ -659,8 +716,81 @@ class BlipCampaign {
659
716
  }
660
717
  }
661
718
 
719
+ class BlipApplication {
720
+ api;
721
+ constructor(context) {
722
+ this.api = context.api;
723
+ }
724
+ /**
725
+ * Returns the application.
726
+ */
727
+ async getApplication() {
728
+ try {
729
+ const body = {
730
+ id: randomUUID(),
731
+ to: 'postmaster@configurations.msging.net',
732
+ method: 'get',
733
+ uri: 'lime://enterprise.master.hosting@msging.net/configuration',
734
+ };
735
+ const response = await this.api.post('/commands', body);
736
+ validateResponse(response);
737
+ return JSON.parse(response.data.resource.Application);
738
+ }
739
+ catch (error) {
740
+ throw handleError(error);
741
+ }
742
+ }
743
+ }
744
+
745
+ const BUILDER_RECIPIENT = 'postmaster@builder.msging.net';
746
+ class BlipFlow {
747
+ api;
748
+ constructor(context) {
749
+ this.api = context.api;
750
+ }
751
+ /**
752
+ * Returns the flow id. When `shortName` is provided, returns the flow id of the matching subbot.
753
+ */
754
+ async getFlowId(shortName) {
755
+ try {
756
+ const body = {
757
+ id: randomUUID(),
758
+ to: BUILDER_RECIPIENT,
759
+ method: 'get',
760
+ uri: createUri('/flow-id', { shortName }),
761
+ };
762
+ const response = await this.api.post('/commands', body);
763
+ validateResponse(response);
764
+ return response.data.resource;
765
+ }
766
+ catch (error) {
767
+ throw handleError(error);
768
+ }
769
+ }
770
+ /**
771
+ * Returns the states of a flow using the flow name.
772
+ */
773
+ async getFlowStates(flowShortName) {
774
+ try {
775
+ const body = {
776
+ id: randomUUID(),
777
+ to: BUILDER_RECIPIENT,
778
+ method: 'get',
779
+ uri: createUri('/flow/states', { shortName: flowShortName }),
780
+ };
781
+ const response = await this.api.post('/commands', body);
782
+ validateResponse(response);
783
+ return response.data.resource.items;
784
+ }
785
+ catch (error) {
786
+ throw handleError(error);
787
+ }
788
+ }
789
+ }
790
+
662
791
  var index$1 = /*#__PURE__*/Object.freeze({
663
792
  __proto__: null,
793
+ BlipApplication: BlipApplication,
664
794
  BlipAttendance: BlipAttendance,
665
795
  BlipBucket: BlipBucket,
666
796
  BlipCampaign: BlipCampaign,
@@ -668,6 +798,7 @@ var index$1 = /*#__PURE__*/Object.freeze({
668
798
  BlipContext: BlipContext,
669
799
  BlipDispatch: BlipDispatch,
670
800
  BlipEvent: BlipEvent,
801
+ BlipFlow: BlipFlow,
671
802
  BlipInteraction: BlipInteraction,
672
803
  BlipMedia: BlipMedia,
673
804
  BlipTicket: BlipTicket,
@@ -688,6 +819,9 @@ class BlipMonitoring {
688
819
  constructor(context) {
689
820
  this.api = context.api;
690
821
  }
822
+ /**
823
+ * Returns currently monitored tickets.
824
+ */
691
825
  async getTickets() {
692
826
  try {
693
827
  const response = await this.api.post('/commands', {
@@ -703,6 +837,9 @@ class BlipMonitoring {
703
837
  throw handleError(error);
704
838
  }
705
839
  }
840
+ /**
841
+ * Returns aggregated ticket metrics for the desk.
842
+ */
706
843
  async getTicketMetrics() {
707
844
  try {
708
845
  const response = await this.api.post('/commands', {
@@ -718,6 +855,9 @@ class BlipMonitoring {
718
855
  throw handleError(error);
719
856
  }
720
857
  }
858
+ /**
859
+ * Returns aggregated metrics about attendant status.
860
+ */
721
861
  async getAttendantStatusMetrics() {
722
862
  try {
723
863
  const response = await this.api.post('/commands', {
@@ -733,6 +873,9 @@ class BlipMonitoring {
733
873
  throw handleError(error);
734
874
  }
735
875
  }
876
+ /**
877
+ * Returns metrics for tickets currently waiting to be served.
878
+ */
736
879
  async getWaitingTicketsMetrics() {
737
880
  try {
738
881
  const response = await this.api.post('/commands', {
@@ -831,6 +974,9 @@ class BlipThreads {
831
974
  constructor(context) {
832
975
  this.api = context.api;
833
976
  }
977
+ /**
978
+ * Returns the message thread for the given identity. Supports pagination, filtering by message id or storage date, and refreshing expired media URIs.
979
+ */
834
980
  async getThread({ identity, refreshExpiredMedia, skip, take, messageId, storageDate, direction, getFromOriginator, }) {
835
981
  const params = {
836
982
  refreshExpiredMedia: refreshExpiredMedia ? 'true' : 'false',
@@ -872,6 +1018,8 @@ class Blip {
872
1018
  analytics;
873
1019
  campaign;
874
1020
  threads;
1021
+ application;
1022
+ flow;
875
1023
  constructor(params) {
876
1024
  validateInstance(params);
877
1025
  this.api = axios.create({
@@ -895,6 +1043,8 @@ class Blip {
895
1043
  this.analytics = new BlipAnalytics({ api: this.api });
896
1044
  this.campaign = new BlipCampaign({ api: this.api });
897
1045
  this.threads = new BlipThreads({ api: this.api });
1046
+ this.application = new BlipApplication({ api: this.api });
1047
+ this.flow = new BlipFlow({ api: this.api });
898
1048
  }
899
1049
  }
900
1050
 
@@ -0,0 +1,12 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { BlipRouterConfig } from '../types/application';
3
+ export default class BlipApplication {
4
+ private api;
5
+ constructor(context: {
6
+ api: AxiosInstance;
7
+ });
8
+ /**
9
+ * Returns the application.
10
+ */
11
+ getApplication(): Promise<BlipRouterConfig>;
12
+ }
@@ -5,6 +5,9 @@ export default class BlipAttendance {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Returns the attendance hour container for the given id.
10
+ */
8
11
  getAttendanceHourContainer({ attendanceContainerId }: {
9
12
  attendanceContainerId: string;
10
13
  }): Promise<AttendanceHourContainer>;
@@ -15,6 +15,9 @@ export default class BlipBucket {
15
15
  Retrieves a document from the Blip bucket.
16
16
  */
17
17
  getContentFromBucket<T>(id: string): Promise<T>;
18
+ /**
19
+ * Returns all document ids stored in the Blip bucket.
20
+ */
18
21
  getAllContentIdsFromBucket(): Promise<string[]>;
19
22
  /**
20
23
  Deletes a JSON document from the Blip bucket.
@@ -5,11 +5,20 @@ export default class BlipCampaign {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Searches campaigns. Supports OData-style `$filter`, `$skip` and `$take` parameters.
10
+ */
8
11
  search({ filter, skip, take }?: {
9
12
  filter?: string;
10
13
  skip?: number;
11
14
  take?: number;
12
15
  }): Promise<Campaign[]>;
16
+ /**
17
+ * Returns a campaign by id.
18
+ */
13
19
  get(campaignId: string): Promise<Campaign>;
20
+ /**
21
+ * Deletes a campaign by id.
22
+ */
14
23
  deleteCampaign(campaignId: string): Promise<void>;
15
24
  }
@@ -5,13 +5,22 @@ export default class BlipContact {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Merges the provided fields into the contact identified by `identity`.
10
+ */
8
11
  update({ identity, contactData }: {
9
12
  identity: string;
10
13
  contactData: Record<string, unknown>;
11
14
  }): Promise<void>;
15
+ /**
16
+ * Returns the contact for the given identity.
17
+ */
12
18
  get({ identity }: {
13
19
  identity: string;
14
20
  }): Promise<Contact>;
21
+ /**
22
+ * Searches contacts. Supports OData-style `$filter`, `$skip` and `$take` parameters.
23
+ */
15
24
  search({ filter, skip, take }?: {
16
25
  filter?: string;
17
26
  skip?: number;
@@ -4,13 +4,22 @@ export default class BlipContext {
4
4
  constructor(context: {
5
5
  api: AxiosInstance;
6
6
  });
7
+ /**
8
+ * Returns the value of a context variable for the given identity.
9
+ */
7
10
  getContextVariable({ identity, variableName }: {
8
11
  identity: string;
9
12
  variableName: string;
10
13
  }): Promise<unknown>;
14
+ /**
15
+ * Returns all available context variables for the given identity.
16
+ */
11
17
  getAvailableContextVariables({ identity }: {
12
18
  identity: string;
13
19
  }): Promise<Record<string, unknown>>;
20
+ /**
21
+ * Sets a context variable for the given identity. Object values are stored as JSON, primitive values as plain text.
22
+ */
14
23
  setContextVariable({ value, variableName, identity, }: {
15
24
  variableName: string;
16
25
  value: unknown;
@@ -21,6 +21,9 @@ export default class BlipDispatch {
21
21
  params?: string[];
22
22
  scheduled?: Date;
23
23
  }): Promise<CampaignNotification>;
24
+ /**
25
+ * Returns the delivery status entries of a campaign notification by id.
26
+ */
24
27
  getCampaignNotificationStatus({ campaignNotificationId }: {
25
28
  campaignNotificationId: string;
26
29
  }): Promise<CampaignNotificationStatus[]>;
@@ -55,6 +58,9 @@ export default class BlipDispatch {
55
58
  previewUri?: string;
56
59
  previewType?: string;
57
60
  }): Promise<void>;
61
+ /**
62
+ * Sends a message with selectable buttons to an active user. Up to 3 buttons are shown immediately; more are presented as a list.
63
+ */
58
64
  sendMessageWithButtons({ identity, message, buttons, metadata, }: {
59
65
  identity: string;
60
66
  message: string;
@@ -4,6 +4,9 @@ export default class BlipEvent {
4
4
  constructor(context: {
5
5
  api: AxiosInstance;
6
6
  });
7
+ /**
8
+ * Tracks an analytics event under the given category and action. Optionally associates it with a contact identity.
9
+ */
7
10
  createTrackEvent({ category, action, identity }: {
8
11
  category: string;
9
12
  action: string;
@@ -0,0 +1,16 @@
1
+ import { AxiosInstance } from 'axios';
2
+ import { FlowState } from '../types/flow';
3
+ export default class BlipFlow {
4
+ private api;
5
+ constructor(context: {
6
+ api: AxiosInstance;
7
+ });
8
+ /**
9
+ * Returns the flow id. When `shortName` is provided, returns the flow id of the matching subbot.
10
+ */
11
+ getFlowId(shortName?: string): Promise<string>;
12
+ /**
13
+ * Returns the states of a flow using the flow name.
14
+ */
15
+ getFlowStates(flowShortName: string): Promise<FlowState[]>;
16
+ }
@@ -4,6 +4,9 @@ export default class BlipInteraction {
4
4
  constructor(context: {
5
5
  blipContext: BlipContext;
6
6
  });
7
+ /**
8
+ * Moves a user to the specified subbot and state by setting the corresponding context variables.
9
+ */
7
10
  moveUser({ identity, botIdentity, botFlowId, botStateId, }: {
8
11
  identity: string;
9
12
  botIdentity: string;
@@ -13,6 +13,8 @@ import BlipMonitoring from './blip-monitoring';
13
13
  import BlipAnalytics from './blip-analytics';
14
14
  import BlipCampaign from './blip-campaign';
15
15
  import BlipThreads from './blip-threads';
16
+ import BlipApplication from './blip-application';
17
+ import BlipFlow from './blip-flow';
16
18
  export declare class Blip {
17
19
  private api;
18
20
  bucket: BlipBucket;
@@ -29,5 +31,7 @@ export declare class Blip {
29
31
  analytics: BlipAnalytics;
30
32
  campaign: BlipCampaign;
31
33
  threads: BlipThreads;
34
+ application: BlipApplication;
35
+ flow: BlipFlow;
32
36
  constructor(params: BlipConstructor);
33
37
  }
@@ -5,8 +5,20 @@ export default class BlipMonitoring {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Returns currently monitored tickets.
10
+ */
8
11
  getTickets(): Promise<MonitoredTickets>;
12
+ /**
13
+ * Returns aggregated ticket metrics for the desk.
14
+ */
9
15
  getTicketMetrics(): Promise<MonitoredTicketMetrics>;
16
+ /**
17
+ * Returns aggregated metrics about attendant status.
18
+ */
10
19
  getAttendantStatusMetrics(): Promise<MonitoredAttendantStatusMetrics>;
20
+ /**
21
+ * Returns metrics for tickets currently waiting to be served.
22
+ */
11
23
  getWaitingTicketsMetrics(): Promise<MonitoredWaitingTicketsMetrics[]>;
12
24
  }
@@ -5,6 +5,9 @@ export default class BlipThreads {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Returns the message thread for the given identity. Supports pagination, filtering by message id or storage date, and refreshing expired media URIs.
10
+ */
8
11
  getThread({ identity, refreshExpiredMedia, skip, take, messageId, storageDate, direction, getFromOriginator, }: {
9
12
  identity: string;
10
13
  refreshExpiredMedia?: boolean;
@@ -5,10 +5,16 @@ export default class BlipTicket {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Searches tickets. Supports OData-style `$filter`, `$skip` and `$take` parameters.
10
+ */
8
11
  search({ filter, skip, take }?: {
9
12
  filter?: string;
10
13
  skip?: number;
11
14
  take?: number;
12
15
  }): Promise<Ticket[]>;
16
+ /**
17
+ * Returns a ticket by id.
18
+ */
13
19
  getTicket(ticketId: string): Promise<Ticket>;
14
20
  }
@@ -5,6 +5,12 @@ export default class BlipWhatsapp {
5
5
  constructor(context: {
6
6
  api: AxiosInstance;
7
7
  });
8
+ /**
9
+ * Returns all approved WhatsApp message templates for the channel.
10
+ */
8
11
  getTemplates(): Promise<Template[]>;
12
+ /**
13
+ * Returns the WhatsApp Blip identity associated with the given phone number.
14
+ */
9
15
  getIdentity(phone: string): Promise<string>;
10
16
  }
@@ -9,4 +9,6 @@ import BlipInteraction from './blip-interaction';
9
9
  import BlipTicket from './blip-ticket';
10
10
  import BlipWhatsapp from './blip-whatsapp';
11
11
  import BlipCampaign from './blip-campaign';
12
- export { BlipMedia, BlipBucket, BlipAttendance, BlipContact, BlipContext, BlipDispatch, BlipEvent, BlipInteraction, BlipTicket, BlipWhatsapp, BlipCampaign, };
12
+ import BlipApplication from './blip-application';
13
+ import BlipFlow from './blip-flow';
14
+ export { BlipMedia, BlipBucket, BlipAttendance, BlipContact, BlipContext, BlipDispatch, BlipEvent, BlipInteraction, BlipTicket, BlipWhatsapp, BlipCampaign, BlipApplication, BlipFlow, };
@@ -0,0 +1,37 @@
1
+ export interface BlipRouterConfig {
2
+ identifier: string;
3
+ messageReceivers: MessageReceiver[];
4
+ notificationReceivers: NotificationReceiver[];
5
+ startupType: string;
6
+ serviceProviderType: string;
7
+ disableNotify: boolean;
8
+ receiptEvents: string[];
9
+ settings: Settings;
10
+ settingsType: string;
11
+ }
12
+ export interface MessageReceiver {
13
+ type: string;
14
+ mediaType?: string;
15
+ sender?: string;
16
+ priority?: number;
17
+ }
18
+ export interface NotificationReceiver {
19
+ type: string;
20
+ sender?: string;
21
+ priority?: number;
22
+ }
23
+ export interface Settings {
24
+ children: ChildService[];
25
+ }
26
+ export interface ChildService {
27
+ isDefault: boolean;
28
+ identity: string;
29
+ longName: string;
30
+ shortName: string;
31
+ service: string;
32
+ $id: number;
33
+ isOnline: boolean;
34
+ isPersistent?: boolean;
35
+ tenantNotFound?: boolean;
36
+ redirectTimeoutInSeconds?: string;
37
+ }
@@ -0,0 +1,6 @@
1
+ export interface FlowState {
2
+ id: string;
3
+ name?: string;
4
+ root?: boolean;
5
+ [key: string]: unknown;
6
+ }
@@ -7,4 +7,5 @@ import { MonitoredTickets, MonitoredTicketMetrics, MonitoredAttendantStatusMetri
7
7
  import { TicketAnalyticsReport, TicketAnalyticsTimings } from './analytics';
8
8
  import { Campaign } from './campaign';
9
9
  import { Contact } from './contact';
10
- export { AttendanceHourContainer, BlipConstructor, BlipRequestBody, BlipResponse, BlipArrayBody, Parameter, Component, Template, TicketAnalyticsReport, MonitoredTickets, MonitoredTicketMetrics, MonitoredAttendantStatusMetrics, TicketAnalyticsTimings, Ticket, Campaign, Contact, };
10
+ import { FlowState } from './flow';
11
+ export { AttendanceHourContainer, BlipConstructor, BlipRequestBody, BlipResponse, BlipArrayBody, Parameter, Component, Template, TicketAnalyticsReport, MonitoredTickets, MonitoredTicketMetrics, MonitoredAttendantStatusMetrics, TicketAnalyticsTimings, Ticket, Campaign, Contact, FlowState, };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dawntech/blip-tools",
3
- "version": "0.7.1",
3
+ "version": "0.7.2",
4
4
  "description": "Node package for Blip API",
5
5
  "exports": {
6
6
  ".": {