@resconet/jsbridge 18.0.0-beta.2 → 18.0.0-beta.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resconet/jsbridge",
3
- "version": "18.0.0-beta.2",
3
+ "version": "18.0.0-beta.4",
4
4
  "main": "./src/JSBridge.js",
5
5
  "types": "./src/JSBridge.d.ts",
6
6
  "description": "Install npm JSBridge module",
package/src/JSBridge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // JSBridge.js TypeScript definition file
2
- // (c) 2023 Resco
2
+ // (c) 2024 Resco
3
3
 
4
4
  /* eslint-disable @typescript-eslint/ban-types */
5
5
  /* eslint-disable @typescript-eslint/prefer-namespace-keyword */
@@ -1001,6 +1001,7 @@ declare namespace MobileCRM {
1001
1001
  */
1002
1002
  class MobileReport {
1003
1003
  /**
1004
+ * @deprecated Please use {@link generateReportAsync} instead.
1004
1005
  * @since 9.1
1005
1006
  * Executes the mobile reporting request which produces the mobile report document of given format.
1006
1007
  * @param fetch The fetch XML defining the entity (entities) query used as report input.
@@ -1025,6 +1026,7 @@ declare namespace MobileCRM {
1025
1026
  scope?: any
1026
1027
  );
1027
1028
  /**
1029
+ * @deprecated Please use {@link generateReportAsync} instead.
1028
1030
  * @since 9.1
1029
1031
  * Executes the mobile reporting request which produces the mobile report document of given format.
1030
1032
  * @param fetch The fetch XML defining the entity (entities) query used as report input.
@@ -1043,6 +1045,50 @@ declare namespace MobileCRM {
1043
1045
  isOnline: boolean,
1044
1046
  outputFile: string
1045
1047
  ): Promise<string>;
1048
+
1049
+ /**
1050
+ * The request class specifying behavior of {@link generateReportAsync} function.
1051
+ */
1052
+ static GenerateReportRequest = class {
1053
+ /** The identifier of report source record(s) as {@link MobileCRM.Reference} or fetch in its xml representation. */
1054
+ source: string | Reference;
1055
+ /** The identifier of report template as its string record ID, exact logical name, {@link MobileCRM.Reference} or actual xml definition of report.*/
1056
+ template: string | Reference;
1057
+ /** Optional code of report format. Supported values are: Pdf (default), Html, Excel, Text. */
1058
+ format = "Pdf";
1059
+ /** Optional custom name of report file or its full path. If not provided, default report name and path are used.
1060
+ * When using full path, it is recommended to place it in {@link MobileCRM.Configuration.storageDirectory}. */
1061
+ customNameOrPath: string;
1062
+ /** Optional iso code (e.g. 'en-US') of report language. Currently it only works for reports on localized Questionnaires. */
1063
+ languageCode: string | undefined;
1064
+ /** Optional custom message displayed to user while report is being generated.
1065
+ * When null or empty string is provided, default message is shown. When undefined, shows no wait message. */
1066
+ waitMessage: string | undefined;
1067
+ /** Optionally specifies if report should be created in Online, or Offline mode. If undefined, the mode in which app is currently running is used. */
1068
+ isOnline: boolean | undefined;
1069
+ /** A {@link MobileCRM.Reference} to parent record. If provided, method will generate new attachment record and link it to the parent record. */
1070
+ attachTo: Reference | undefined;
1071
+ /**
1072
+ * When {@link attachmentRecord} is provided, optionally specifies the type of attachment entity.
1073
+ * If not specified, the default attachment entity is created. */
1074
+ attachmentEntity: string | undefined;
1075
+ };
1076
+ /**
1077
+ * The result class for {@link generateReportAsync} function.
1078
+ */
1079
+ static GenerateReportResult = class {
1080
+ /** The full file path to generated report. Not present if {@link GenerateReportRequest.attachTo} is provided. */
1081
+ outputReportPath: string | undefined;
1082
+ /** The reference to attachment record containing the generated report. Only present if {@link GenerateReportRequest.attachTo} is provided.*/
1083
+ attachmentRecord: Reference | undefined;
1084
+ };
1085
+ /**
1086
+ * @since 18.0
1087
+ * Generates the mobile report based on provided request parameters. The generated report will be saved to file system or attached to a record.
1088
+ * @param request The request specifying the details of how the report will be created.
1089
+ * @returns The promise with the result object.
1090
+ */
1091
+ static generateReportAsync(request: MobileCRM.MobileReport.GenerateReportRequest): Promise<MobileCRM.MobileReport.GenerateReportResult>;
1046
1092
  /**
1047
1093
  * @since 10.1
1048
1094
  * Shows new MobileReport form. Source for the report can be defined either as list of MobileCRM.Reference objects or as FetchXML query.
@@ -1461,7 +1507,9 @@ declare module MobileCRM.Services {
1461
1507
  }
1462
1508
  class ZebraScanner {
1463
1509
  static connect: (success: (result: string) => void, failed?: (err: string) => void, scope?: any) => void;
1464
- static onScan: (handler: (questionnaireForm: QuestionnaireForm) => void, bind: boolean, scope?: any) => void;
1510
+ static setPower: (power: number, success: (result: string) => void, failed?: (err: string) => void, scope?: any) => void;
1511
+ static setVolume: (volume: number, success: (result: string) => void, failed?: (err: string) => void, scope?: any) => void;
1512
+ static onScan: (handler: (tags: string[]) => void, bind: boolean, scope?: any) => void;
1465
1513
  }
1466
1514
  class DocumentService {
1467
1515
  /**Gets or sets the maximum captured image size. If captured image size is greater, the image is resized to specified maximum size. [640x480,1024x768,1600x1200,2048x1536,2592x1936].*/
@@ -2253,6 +2301,7 @@ declare module MobileCRM.UI {
2253
2301
  */
2254
2302
  public static requestObject(callback: (entityList: EntityList) => void, errorCallback?: (err: string) => void, scope?: any);
2255
2303
  /**
2304
+ * @deprecated Use {@link setDataSourceFactory} instead.
2256
2305
  * Sets the entity list data source replacement.
2257
2306
  * @see Data source must be set during the document load stage and must not be delayed. It is used only if the entity view iFrame is marked as data source provider in Woodford.
2258
2307
  * @param dataSource A data source object implementing the DynamicEntity list loading routine.
@@ -2487,6 +2536,11 @@ declare module MobileCRM.UI {
2487
2536
  questionnaire: DynamicEntity;
2488
2537
  /** Custom event context */
2489
2538
  context: any;
2539
+ /**
2540
+ * @since 18.0
2541
+ * Language of the questionnaire
2542
+ */
2543
+ language: string;
2490
2544
 
2491
2545
  /**
2492
2546
  * Stops the onSave validation and optionally causes an error message to be displayed.
package/src/JSBridge.js CHANGED
@@ -1210,12 +1210,30 @@
1210
1210
  MobileCRM.bridge.command("initZebra", null, successCallback, errorCallback, scope);
1211
1211
  };
1212
1212
 
1213
+ MobileCRM.Services.ZebraScanner.setPower = function (power, successCallback, errorCallback, scope) {
1214
+ /// <summary>Set power of antenna the Zebra scanner.</summary>
1215
+ /// <param name="power" type="Number">The power of the scanner.</param>
1216
+ /// <param name="successCallback" type="function">The callback function that is called when the connection is established.</param>
1217
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
1218
+ /// <param name="scope" type="Object">The scope in which the callback function is called.</param>
1219
+ MobileCRM.bridge.command("setPower", JSON.stringify({ power: power }), successCallback, errorCallback, scope);
1220
+ };
1221
+
1222
+ MobileCRM.Services.ZebraScanner.setVolume = function (volume, successCallback, errorCallback, scope) {
1223
+ /// <summary>Set volume of the Zebra scanner.</summary>
1224
+ /// <param name="volume" type="Number">The volume of the scanner.</param>
1225
+ /// <param name="successCallback" type="function">The callback function that is called when the connection is established.</param>
1226
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
1227
+ /// <param name="scope" type="Object">The scope in which the callback function is called.</param>
1228
+ MobileCRM.bridge.command("setVolume", JSON.stringify({ volume: volume }), successCallback, errorCallback, scope);
1229
+ };
1230
+
1213
1231
  MobileCRM.Services.ZebraScanner._callHandlers = function (event, data) {
1214
1232
  /// <summary>Invokes the registered handlers for the specified event.</summary>
1215
1233
  const handlers = MobileCRM.Services.ZebraScanner._handlers[event];
1216
1234
 
1217
1235
  if (handlers && handlers.length > 0) {
1218
- return _callHandlers(handlers, data);
1236
+ return _callHandlers(handlers, JSON.parse(data));
1219
1237
  }
1220
1238
 
1221
1239
  return null;
@@ -2874,13 +2892,13 @@
2874
2892
  /// <param name="success" type="function(String)">A callback function for successful asynchronous result. The <b>result</b> argument will carry the XML representation of the Fetch object.</param>
2875
2893
  /// <param name="failed" type="function(error)">A callback function for command failure. The <b>error</b> argument will carry the error message.</param>
2876
2894
  /// <param name="scope" type="">A scope for calling the callbacks; set &quot;null&quot; to call the callbacks in global scope.</param>
2877
- var reqParams = this._constructFetchParams();
2895
+ var reqParams = JSON.stringify(this._constructFetchParams());
2878
2896
  MobileCRM.bridge.command("fetchToXml", reqParams, success, failed, scope);
2879
2897
  };
2880
2898
  MobileCRM.FetchXml.Fetch.prototype.serializeToXmlAsync = function () {
2881
2899
  /// <summary>[v10.0] Serializes the Fetch object to XML.</summary>
2882
2900
  /// <returns type="Promise&lt;string&gt;">A Promise object which will be resolved with the XML representation of this Fetch object.</returns>
2883
- var reqParams = this._constructFetchParams();
2901
+ var reqParams = JSON.stringify(this._constructFetchParams());
2884
2902
  return MobileCRM.bridge.invokeCommandPromise("fetchToXml", reqParams);
2885
2903
  };
2886
2904
  // MobileCRM.FetchXml.Entity
@@ -4452,7 +4470,7 @@
4452
4470
  MobileCRM.bridge.command("showReport", JSON.stringify(params), success, failed, scope);
4453
4471
  };
4454
4472
  MobileCRM.MobileReport.runReport = function (fetch, reportXML, reportFormat, isExportOnly, isOnline, outputFile, success, failed, scope) {
4455
- /// <summary>[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.</summary>
4473
+ /// <summary>[v9.1] Deprecated: please use MobileCRM.MobileReport.generateReportAsync instead. Executes the mobile reporting request which produces the mobile report document of given format.</summary>
4456
4474
  /// <param name="fetch" type="String">The fetch XML defining the entity (entities) query used as report input.</param>
4457
4475
  /// <param name="reportXML" type="String">The mobile report XML definition which can be loaded from the resco_report entity or constructed dynamically. Ignored if IsExportOnly parameter is true.</param>
4458
4476
  /// <param name="reportFormat" type="String">Report format: Pdf (default), Html, Excel, Text.</param>
@@ -4472,7 +4490,7 @@
4472
4490
  MobileCRM.bridge.command("runMobileReportAsync", JSON.stringify(params), success, failed, scope);
4473
4491
  };
4474
4492
  MobileCRM.MobileReport.runReportAsync = function (fetch, reportXML, reportFormat, isExportOnly, isOnline, outputFile) {
4475
- /// <summary>[v9.1] Executes the mobile reporting request which produces the mobile report document of given format.</summary>
4493
+ /// <summary>[v9.1] Deprecated: please use MobileCRM.MobileReport.generateReportAsync instead. Executes the mobile reporting request which produces the mobile report document of given format.</summary>
4476
4494
  /// <param name="fetch" type="String">The fetch XML defining the entity (entities) query used as report input.</param>
4477
4495
  /// <param name="reportXML" type="String">The mobile report XML definition which can be loaded from the resco_mobilereport entity or constructed dynamically. Ignored if IsExportOnly parameter is true.</param>
4478
4496
  /// <param name="reportFormat" type="String">Report format: Pdf (default), Html, Excel, Text.</param>
@@ -4486,6 +4504,42 @@
4486
4504
  });
4487
4505
  });
4488
4506
  };
4507
+
4508
+ MobileCRM.MobileReport.GenerateReportRequest = function () {
4509
+ /// <summary>[v18.0] The request class specifying behavior of MobileCRM.MobileReport.generateReportAsync function.</summary>
4510
+ /// <param name="source" type="String | MobileCRM.Reference">The identifier of report source record(s) as MobileCRM.Reference or fetch in its xml representation.</param>
4511
+ /// <param name="template" type="String | MobileCRM.Reference">The identifier of report template as its string record ID, exact logical name, MobileCRM.Reference or actual xml definition of report.</param>
4512
+ /// <param name="format" type="String">Optional code of report format. Supported values are: Pdf (default), Html, Excel, Text.</param>
4513
+ /// <param name="customNameOrPath" type="String">Optional custom name of report file or its full path. If not provided, default report name and path are used. When using full path, it is recommended to place it in MobileCRM.Configuration.storageDirectory.</param>
4514
+ /// <param name="languageCode" type="String">Optional iso code (e.g. "en-US") of report language. Currently it only works for reports on localized Questionnaires.</param>
4515
+ /// <param name="waitMessage" type="String">Optional custom message displayed to user while report is being generated. When null or empty string is provided, default message is shown. When undefined, shows no wait message.</param>
4516
+ /// <param name="isOnline" type="Boolean">Optionally specifies if report should be created in Online, or Offline mode. If undefined, the mode in which app is currently running is used.</param>
4517
+ /// <param name="attachTo" type="MobileCRM.Reference">A MobileCRM.Reference to parent record. If provided, method will generate new attachment record and link it to the parent record.</param>
4518
+ /// <param name="attachmentEntity" type="String">When attachmentRecord is provided, optionally specifies the type of attachment entity. If not specified, the default attachment entity is created.</param>
4519
+ this.source = undefined;
4520
+ this.template = undefined;
4521
+ this.format = "Pdf";
4522
+ this.customNameOrPath = undefined;
4523
+ this.languageCode = undefined;
4524
+ this.waitMessage = undefined;
4525
+ this.isOnline = undefined;
4526
+ this.attachTo = undefined;
4527
+ this.attachmentEntity = undefined;
4528
+ };
4529
+ MobileCRM.MobileReport.GenerateReportResult = function () {
4530
+ /// <summary>[v18.0] The result class for MobileCRM.MobileReport.generateReportAsync function.</summary>
4531
+ /// <param name="outputReportPath" type="String">The full file path to generated report. Not present if MobileCRM.MobileReport.GenerateReportRequest.attachTo is provided.</param>
4532
+ /// <param name="attachmentRecord" type="MobileCRM.Reference">The reference to attachment record containing the generated report. Only present if MobileCRM.MobileReport.GenerateReportRequest.attachTo is provided.</param>
4533
+ this.outputReportPath = undefined;
4534
+ this.attachmentRecord = undefined;
4535
+ };
4536
+ MobileCRM.MobileReport.generateReportAsync = async function (request) {
4537
+ /// <summary>[v18.0] Generates the mobile report based on provided request parameters. The generated report will be saved to file system or attached to a record.</summary>
4538
+ /// <param name="request" type="MobileCRM.MobileReport.GenerateReportRequest">The request specifying the details of how the report will be created.</param>
4539
+ /// <returns type="MobileCRM.MobileReport.GenerateReportResult">The promise with <see cref="MobileCRM.MobileReport.GenerateReportResult">GenerateReportResult</see> object.</returns>
4540
+ return MobileCRM.bridge.invokeCommandPromise("generateMobileReportAsync", JSON.stringify(request));
4541
+ };
4542
+
4489
4543
  MobileCRM.MobileReport.showForm = function (report, source, fetchXml, failed, scope) {
4490
4544
  /// <summary>[v10.1] Shows new MobileReport form. Source for the report can be defined either as list of <see cref="MobileCRM.Reference">MobileCRM.Reference</see> objects or as FetchXML query.</summary>
4491
4545
  /// <remarks>If both types of source are passed, user can select which one to use.</remarks>
@@ -4822,7 +4876,7 @@
4822
4876
  );
4823
4877
  };
4824
4878
  MobileCRM.UI.EntityList.setDataSource = function (dataSource) {
4825
- /// <summary>Sets the entity list data source replacement.</summary>
4879
+ /// <summary>Deprecated: Please use setDataSourceFactory instead. Sets the entity list data source replacement.</summary>
4826
4880
  /// <remarks><p>Data source must be set during the document load stage and must not be delayed.</p><p>It is used only if the entity view iFrame is marked as data source provider in Woodford.</p></remarks>
4827
4881
  /// <param name="dataSource" type="MobileCRM.UI.ListDataSource">A data source object implementing the DynamicEntity list loading routine.</param>
4828
4882
  MobileCRM.UI.EntityList._dataSource = dataSource;
@@ -4976,7 +5030,7 @@
4976
5030
  // MobileCRM.UI.ListDataSource
4977
5031
  MobileCRM.UI.ListDataSource = function () {
4978
5032
  /// <summary>The data source loading routine implementation.</summary>
4979
- /// <remarks><p>An instance of this object can be used to supply the data source for <see cref="MobileCRM.UI.EntityList.setDataSource">MobileCRM.UI.EntityList.setDataSource</see> function.</p><p>The instance of this object is valid only if the method loadNextChunk is implemented. See example <see cref="MobileCRM.UI.EntityList.setDataSource">here</see>.</p></remarks>
5033
+ /// <remarks><p>An instance of this object can be used to supply the data source for <see cref="MobileCRM.UI.EntityList.setDataSourceFactory">MobileCRM.UI.EntityList.setDataSourceFactory</see> function.</p><p>The instance of this object is valid only if the method loadNextChunk is implemented. See example <see cref="MobileCRM.UI.EntityList.setDataSourceFactory">here</see>.</p></remarks>
4980
5034
  /// <field name="chunkSize" type="Number">Controls the number of entities loaded in once.</field>
4981
5035
  /// <field name="fetch" type="MobileCRM.FetchXml.Fetch">Gets the original fetch request for this list view.</field>
4982
5036
  /// <field name="loadNextChunk" type="function(page, count)">Controls the number of entities loaded in once. It is called from native code to get chunk (array) of <see cref="MobileCRM.DynamicEntity">DynamicEntities</see>. The chunk is defined by 1-based page number and the desired count which corresponds to the value of chunkSize property.</field>