@ipcom/asterisk-ari 0.0.159 → 0.0.161

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 (37) hide show
  1. package/dist/cjs/index.cjs +210 -0
  2. package/dist/cjs/index.cjs.map +3 -3
  3. package/dist/cjs/package.json +3 -0
  4. package/dist/esm/index.js +210 -0
  5. package/dist/esm/index.js.map +3 -3
  6. package/dist/types/ari-client/ariClient.d.ts +14 -12
  7. package/dist/types/ari-client/ariClient.d.ts.map +1 -1
  8. package/dist/types/ari-client/baseClient.d.ts +1 -1
  9. package/dist/types/ari-client/interfaces/applications.types.d.ts +2 -2
  10. package/dist/types/ari-client/interfaces/bridges.types.d.ts +5 -5
  11. package/dist/types/ari-client/interfaces/channels.types.d.ts +4 -4
  12. package/dist/types/ari-client/interfaces/events.types.d.ts +41 -41
  13. package/dist/types/ari-client/interfaces/events.types.d.ts.map +1 -1
  14. package/dist/types/ari-client/interfaces/index.d.ts +10 -9
  15. package/dist/types/ari-client/interfaces/index.d.ts.map +1 -1
  16. package/dist/types/ari-client/interfaces/playbacks.types.d.ts +2 -2
  17. package/dist/types/ari-client/interfaces/recordings.types.d.ts +50 -0
  18. package/dist/types/ari-client/interfaces/recordings.types.d.ts.map +1 -0
  19. package/dist/types/ari-client/interfaces/websocket.types.d.ts +2 -2
  20. package/dist/types/ari-client/resources/applications.d.ts +2 -2
  21. package/dist/types/ari-client/resources/asterisk.d.ts +4 -4
  22. package/dist/types/ari-client/resources/baseResource.d.ts +1 -1
  23. package/dist/types/ari-client/resources/baseResource.d.ts.map +1 -1
  24. package/dist/types/ari-client/resources/bridges.d.ts +6 -6
  25. package/dist/types/ari-client/resources/channels.d.ts +39 -11
  26. package/dist/types/ari-client/resources/channels.d.ts.map +1 -1
  27. package/dist/types/ari-client/resources/endpoints.d.ts +2 -2
  28. package/dist/types/ari-client/resources/playbacks.d.ts +8 -8
  29. package/dist/types/ari-client/resources/playbacks.d.ts.map +1 -1
  30. package/dist/types/ari-client/resources/recordings.d.ts +77 -0
  31. package/dist/types/ari-client/resources/recordings.d.ts.map +1 -1
  32. package/dist/types/ari-client/resources/sounds.d.ts +2 -2
  33. package/dist/types/ari-client/utils.d.ts +1 -1
  34. package/dist/types/ari-client/websocketClient.d.ts +4 -4
  35. package/dist/types/index.d.ts +17 -17
  36. package/dist/types/index.d.ts.map +1 -1
  37. package/package.json +24 -10
@@ -1855,6 +1855,7 @@ var ChannelInstance = class {
1855
1855
  listeners.forEach((listener) => {
1856
1856
  this.eventEmitter.off(
1857
1857
  event,
1858
+ // biome-ignore lint/suspicious/noExplicitAny: <explanation>
1858
1859
  listener
1859
1860
  );
1860
1861
  });
@@ -1897,6 +1898,81 @@ var ChannelInstance = class {
1897
1898
  throw new Error(`Failed to originate channel: ${message}`);
1898
1899
  }
1899
1900
  }
1901
+ /**
1902
+ * Continues the execution of a dialplan for the current channel.
1903
+ *
1904
+ * @param {string} [context] - The dialplan context to continue execution in, if specified.
1905
+ * @param {string} [extension] - The dialplan extension to proceed with, if provided.
1906
+ * @param {number} [priority] - The priority within the dialplan extension to resume at, if specified.
1907
+ * @param {string} [label] - The label to start from within the dialplan, if given.
1908
+ * @return {Promise<void>} Resolves when the dialplan is successfully continued.
1909
+ */
1910
+ async continueDialplan(context, extension, priority, label) {
1911
+ try {
1912
+ if (!this.channelData) {
1913
+ this.channelData = await this.getDetails();
1914
+ }
1915
+ await this.baseClient.post(`/channels/${this.id}/continue`, {
1916
+ context,
1917
+ extension,
1918
+ priority,
1919
+ label
1920
+ });
1921
+ } catch (error) {
1922
+ const message = getErrorMessage2(error);
1923
+ console.error(
1924
+ `Error continuing dialplan for channel ${this.id}:`,
1925
+ message
1926
+ );
1927
+ throw new Error(`Failed to continue dialplan: ${message}`);
1928
+ }
1929
+ }
1930
+ /**
1931
+ * Initiates a snoop operation on this channel with the provided options.
1932
+ * Snooping allows you to listen in or interact with an existing call.
1933
+ *
1934
+ * @param {SnoopOptions} options - Configuration options for the snooping operation.
1935
+ * @return {Promise<Channel>} A promise that resolves to the snooped channel data.
1936
+ * @throws {Error} If the channel is not initialized or if snooping fails.
1937
+ */
1938
+ async snoop(options) {
1939
+ try {
1940
+ if (!this.channelData) {
1941
+ this.channelData = await this.getDetails();
1942
+ }
1943
+ const queryParams = toQueryParams2(options);
1944
+ return await this.baseClient.post(
1945
+ `/channels/${this.id}/snoop?${queryParams}`
1946
+ );
1947
+ } catch (error) {
1948
+ const message = getErrorMessage2(error);
1949
+ console.error(`Error snooping on channel ${this.id}:`, message);
1950
+ throw new Error(`Failed to snoop channel: ${message}`);
1951
+ }
1952
+ }
1953
+ /**
1954
+ * Initiates a snoop operation on this channel with a specific snoop ID.
1955
+ *
1956
+ * @param {string} snoopId - The unique identifier for the snoop operation.
1957
+ * @param {SnoopOptions} options - Configuration options for the snooping operation.
1958
+ * @return {Promise<Channel>} A promise that resolves to the snooped channel data.
1959
+ * @throws {Error} If the channel is not initialized or if snooping fails.
1960
+ */
1961
+ async snoopWithId(snoopId, options) {
1962
+ try {
1963
+ if (!this.channelData) {
1964
+ this.channelData = await this.getDetails();
1965
+ }
1966
+ const queryParams = toQueryParams2(options);
1967
+ return await this.baseClient.post(
1968
+ `/channels/${this.id}/snoop/${snoopId}?${queryParams}`
1969
+ );
1970
+ } catch (error) {
1971
+ const message = getErrorMessage2(error);
1972
+ console.error(`Error snooping with ID on channel ${this.id}:`, message);
1973
+ throw new Error(`Failed to snoop channel with ID: ${message}`);
1974
+ }
1975
+ }
1900
1976
  /**
1901
1977
  * Plays media on the channel
1902
1978
  */
@@ -3618,6 +3694,137 @@ var WebSocketClient = class extends import_events4.EventEmitter {
3618
3694
  }
3619
3695
  };
3620
3696
 
3697
+ // src/ari-client/resources/recordings.ts
3698
+ var Recordings = class {
3699
+ constructor(baseClient) {
3700
+ this.baseClient = baseClient;
3701
+ }
3702
+ /**
3703
+ * List recordings that are complete.
3704
+ * @returns Promise<StoredRecording[]>
3705
+ */
3706
+ async listStored() {
3707
+ return this.baseClient.get("/recordings/stored");
3708
+ }
3709
+ /**
3710
+ * Get a stored recording's details.
3711
+ * @param params - The parameters for getting a stored recording
3712
+ * @returns Promise<StoredRecording>
3713
+ */
3714
+ async getStored(params) {
3715
+ return this.baseClient.get(
3716
+ `/recordings/stored/${params.recordingName}`
3717
+ );
3718
+ }
3719
+ /**
3720
+ * Delete a stored recording.
3721
+ * @param params - The parameters for deleting a stored recording
3722
+ * @returns Promise<void>
3723
+ */
3724
+ async deleteStored(params) {
3725
+ return this.baseClient.delete(
3726
+ `/recordings/stored/${params.recordingName}`
3727
+ );
3728
+ }
3729
+ /**
3730
+ * Get the file associated with the stored recording.
3731
+ * @param params - The parameters for getting a stored recording file
3732
+ * @returns Promise<ArrayBuffer>
3733
+ */
3734
+ async getStoredFile(params) {
3735
+ return this.baseClient.get(
3736
+ `/recordings/stored/${params.recordingName}/file`,
3737
+ { responseType: "arraybuffer" }
3738
+ );
3739
+ }
3740
+ /**
3741
+ * Copy a stored recording.
3742
+ * @param params - The parameters for copying a stored recording
3743
+ * @returns Promise<StoredRecording>
3744
+ */
3745
+ async copyStored(params) {
3746
+ return this.baseClient.post(
3747
+ `/recordings/stored/${params.recordingName}/copy`,
3748
+ void 0,
3749
+ {
3750
+ params: {
3751
+ destinationRecordingName: params.destinationRecordingName
3752
+ }
3753
+ }
3754
+ );
3755
+ }
3756
+ /**
3757
+ * List live recordings.
3758
+ * @param params - The parameters for getting a live recording
3759
+ * @returns Promise<LiveRecording>
3760
+ */
3761
+ async getLive(params) {
3762
+ return this.baseClient.get(
3763
+ `/recordings/live/${params.recordingName}`
3764
+ );
3765
+ }
3766
+ /**
3767
+ * Stop a live recording and discard it.
3768
+ * @param params - The parameters for canceling a recording
3769
+ * @returns Promise<void>
3770
+ */
3771
+ async cancel(params) {
3772
+ return this.baseClient.delete(
3773
+ `/recordings/live/${params.recordingName}`
3774
+ );
3775
+ }
3776
+ /**
3777
+ * Stop a live recording and store it.
3778
+ * @param params - The parameters for stopping a recording
3779
+ * @returns Promise<void>
3780
+ */
3781
+ async stop(params) {
3782
+ return this.baseClient.post(
3783
+ `/recordings/live/${params.recordingName}/stop`
3784
+ );
3785
+ }
3786
+ /**
3787
+ * Pause a live recording.
3788
+ * @param params - The parameters for pausing a recording
3789
+ * @returns Promise<void>
3790
+ */
3791
+ async pause(params) {
3792
+ return this.baseClient.post(
3793
+ `/recordings/live/${params.recordingName}/pause`
3794
+ );
3795
+ }
3796
+ /**
3797
+ * Unpause a live recording.
3798
+ * @param params - The parameters for unpausing a recording
3799
+ * @returns Promise<void>
3800
+ */
3801
+ async unpause(params) {
3802
+ return this.baseClient.delete(
3803
+ `/recordings/live/${params.recordingName}/pause`
3804
+ );
3805
+ }
3806
+ /**
3807
+ * Mute a live recording.
3808
+ * @param params - The parameters for muting a recording
3809
+ * @returns Promise<void>
3810
+ */
3811
+ async mute(params) {
3812
+ return this.baseClient.post(
3813
+ `/recordings/live/${params.recordingName}/mute`
3814
+ );
3815
+ }
3816
+ /**
3817
+ * Unmute a live recording.
3818
+ * @param params - The parameters for unmuting a recording
3819
+ * @returns Promise<void>
3820
+ */
3821
+ async unmute(params) {
3822
+ return this.baseClient.delete(
3823
+ `/recordings/live/${params.recordingName}/mute`
3824
+ );
3825
+ }
3826
+ };
3827
+
3621
3828
  // src/ari-client/ariClient.ts
3622
3829
  var AriClient = class {
3623
3830
  /**
@@ -3642,6 +3849,7 @@ var AriClient = class {
3642
3849
  this.applications = new Applications(this.baseClient);
3643
3850
  this.sounds = new Sounds(this.baseClient);
3644
3851
  this.asterisk = new Asterisk(this.baseClient);
3852
+ this.recordings = new Recordings(this.baseClient);
3645
3853
  console.log(`ARI Client initialized with base URL: ${baseUrl}`);
3646
3854
  }
3647
3855
  baseClient;
@@ -3654,6 +3862,7 @@ var AriClient = class {
3654
3862
  sounds;
3655
3863
  asterisk;
3656
3864
  bridges;
3865
+ recordings;
3657
3866
  async cleanup() {
3658
3867
  try {
3659
3868
  console.log("Starting ARI Client cleanup...");
@@ -3765,6 +3974,7 @@ var AriClient = class {
3765
3974
  this.applications = null;
3766
3975
  this.sounds = null;
3767
3976
  this.asterisk = null;
3977
+ this.recordings = null;
3768
3978
  console.log("ARI Client destroyed successfully");
3769
3979
  } catch (error) {
3770
3980
  console.error("Error destroying ARI Client:", error);