@resconet/jsbridge 18.0.0-beta.1 → 18.0.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resconet/jsbridge",
3
- "version": "18.0.0-beta.1",
3
+ "version": "18.0.0-beta.2",
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
@@ -1114,6 +1114,13 @@ declare module MobileCRM.FetchXml {
1114
1114
  * @param scope A scope for calling the callbacks. Set to call the callbacks in global scope.
1115
1115
  */
1116
1116
  public static executeFromXML(fetchXmlData: string, success: (res: any[]) => void, failed?: (error: string) => void, scope?: any);
1117
+ /**
1118
+ * Executes fetch XML asynchronously.
1119
+ * The format of result output is controlled by internal XML attribute "resultformat" on root fetch XML element.
1120
+ * @param fetchXmlData CRM fetch in XML representation.
1121
+ * @returns A promise object fulfilled with the array of objects having type specified by resultformat XML attribute (Array, JSON, XML or DynamicEntities).
1122
+ */
1123
+ public static executeFromXmlAsync(fetchXmlData: string): Promise<any[]>;
1117
1124
  /**
1118
1125
  * @since 10.0
1119
1126
  * Deserializes XML to the Fetch object.
@@ -1233,10 +1240,10 @@ declare module MobileCRM.FetchXml {
1233
1240
  * @param target The target entity.
1234
1241
  * @param from The "from" field (if parent then target entity primary key).
1235
1242
  * @param to The "to" field.
1236
- * @param linkType The link (join) type ("inner" or "outer").
1243
+ * @param linktype The link (join) type ("inner" or "outer").
1237
1244
  * @returns MobileCRM.FetchXml.LinkEntity
1238
1245
  */
1239
- addLink(target: string, from: string, to: string, linkType: string): MobileCRM.FetchXml.LinkEntity;
1246
+ addLink(target: string, from: string, to: string, linktype: string): MobileCRM.FetchXml.LinkEntity;
1240
1247
  removeLink(link: MobileCRM.FetchXml.LinkEntity): void;
1241
1248
  /**
1242
1249
  * Adds a filter for this fetch entity.
@@ -1290,7 +1297,7 @@ declare module MobileCRM.FetchXml {
1290
1297
  from?: string,
1291
1298
  to?: string,
1292
1299
  alias?: string,
1293
- linkType?: string
1300
+ linktype?: string
1294
1301
  );
1295
1302
 
1296
1303
  from: string;
@@ -1452,6 +1459,10 @@ declare module MobileCRM.Services {
1452
1459
  mimeType: string;
1453
1460
  nextInfo: FileInfo;
1454
1461
  }
1462
+ class ZebraScanner {
1463
+ 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;
1465
+ }
1455
1466
  class DocumentService {
1456
1467
  /**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].*/
1457
1468
  maxImageSize: string;
package/src/JSBridge.js CHANGED
@@ -420,14 +420,14 @@
420
420
  if (entity) {
421
421
  this.entity = entity;
422
422
  }
423
- if (typeof count !== "undefined") {
423
+ if (count !== undefined && count !== null) {
424
424
  this.count = count;
425
425
  }
426
- if (typeof page !== "undefined") {
426
+ if (page) {
427
427
  this.page = page;
428
428
  }
429
429
  this.aggregate = !!aggregate;
430
- if (typeof distinct !== "undefined") {
430
+ if (distinct !== undefined && distinct !== null) {
431
431
  this.distinct = distinct;
432
432
  }
433
433
  },
@@ -456,7 +456,7 @@
456
456
  this.filter = filter ? filter : null;
457
457
  this.linkentities = linkentities ? linkentities : [];
458
458
  },
459
- LinkEntity: function (name, attributes, order, filter, linkentities, from, to, alias, linkType) {
459
+ LinkEntity: function (name, attributes, order, filter, linkentities, from, to, alias, linktype) {
460
460
  /// <summary>Represents a FetchXml query linked entity.</summary>
461
461
  /// <remarks>This object is derived from <see cref="MobileCRM.FetchXml.Entity">MobileCRM.FetchXml.Entity</see></remarks>
462
462
  /// <param name="name" type="String">An entity name</param>
@@ -474,8 +474,8 @@
474
474
  if (alias) {
475
475
  this.alias = alias;
476
476
  }
477
- if (linkType) {
478
- this.linktype = linkType;
477
+ if (linktype) {
478
+ this.linktype = linktype;
479
479
  }
480
480
  },
481
481
  Attribute: function (name, alias, aggregate, groupBy, dateGrouping) {
@@ -990,6 +990,9 @@
990
990
  },
991
991
  },
992
992
  Services: {
993
+ ZebraScanner: function () {
994
+ /// <summary>Represents a service for scanning barcodes using Zebra scanner.</summary>
995
+ },
993
996
  FileInfo: function (filePath, url, mimeType, nextInfo) {
994
997
  /// <summary>Carries the result of a DocumentService operation.</summary>
995
998
  /// <remarks>In case of canceled document service operation, all properties in this object will be set to &quot;null&quot;.</remarks>
@@ -1178,6 +1181,46 @@
1178
1181
  return typeof result == "string" ? result : JSON.stringify(result);
1179
1182
  }
1180
1183
  };
1184
+
1185
+ MobileCRM.Services.ZebraScanner.onScan = function (handler, bind, scope) {
1186
+ /// <summary>Registers the handler for the scan event.</summary>
1187
+ /// <param name="handler" type="function(data)">The handler function that is called when the scan event is raised.</param>
1188
+ /// <param name="bind" type="Boolean">Indicates whether to bind the handler to the event.</param>
1189
+ /// <param name="scope" type="Object">The scope in which the handler function is called.</param>
1190
+ let handlerName = "onScan";
1191
+ let handlers = MobileCRM.Services.ZebraScanner._handlers[handlerName];
1192
+
1193
+ if (!handlers) {
1194
+ MobileCRM.Services.ZebraScanner._handlers[handlerName] = handlers = [];
1195
+ }
1196
+
1197
+ const register = handlers.length == 0;
1198
+ _bindHandler(handler, handlers, bind, scope);
1199
+
1200
+ if (register) {
1201
+ MobileCRM.bridge.command("registerEvents", handlerName);
1202
+ }
1203
+ };
1204
+
1205
+ MobileCRM.Services.ZebraScanner.connect = function (successCallback, errorCallback, scope) {
1206
+ /// <summary>Connects to the Zebra scanner.</summary>
1207
+ /// <param name="successCallback" type="function">The callback function that is called when the connection is established.</param>
1208
+ /// <param name="errorCallback" type="function(errorMsg)">The errorCallback which is called in case of error.</param>
1209
+ /// <param name="scope" type="Object">The scope in which the callback function is called.</param>
1210
+ MobileCRM.bridge.command("initZebra", null, successCallback, errorCallback, scope);
1211
+ };
1212
+
1213
+ MobileCRM.Services.ZebraScanner._callHandlers = function (event, data) {
1214
+ /// <summary>Invokes the registered handlers for the specified event.</summary>
1215
+ const handlers = MobileCRM.Services.ZebraScanner._handlers[event];
1216
+
1217
+ if (handlers && handlers.length > 0) {
1218
+ return _callHandlers(handlers, data);
1219
+ }
1220
+
1221
+ return null;
1222
+ };
1223
+
1181
1224
  // MobileCRM.UI._MediaTab
1182
1225
  MobileCRM.UI.MediaTab.prototype._onCommand = function (commandIndex, errorCallback) {
1183
1226
  /// <summary>Executes the MediaTab command by index.</summary>
@@ -2617,6 +2660,13 @@
2617
2660
  /// <param name="scope" type="">A scope for calling the callbacks; set &quot;null&quot; to call the callbacks in global scope.</param>
2618
2661
  _global.MobileCRM.bridge.command("fetchXML", fetchXmlData, success, failed, scope);
2619
2662
  };
2663
+ MobileCRM.FetchXml.Fetch.executeFromXmlAsync = function (fetchXmlData) {
2664
+ /// <summary>Executes fetch XML asynchronously.</summary>
2665
+ /// <remarks>The format of result output is controlled by internal XML attribute &quot;resultformat&quot; on root fetch XML element.</remarks>
2666
+ /// <param name="fetchXmlData" type="String">CRM fetch in XML representation.</param>
2667
+ /// <returns type="Promise">A promise object fulfilled with the array of objects having type specified by resultformat XML attribute (Array, JSON, XML or DynamicEntities).</returns>
2668
+ return MobileCRM.bridge.invokeCommandPromise("fetchXML", fetchXmlData);
2669
+ };
2620
2670
  MobileCRM.FetchXml.Condition._constructConditionParams = function (condition) {
2621
2671
  if (condition) {
2622
2672
  var conditionParams = {};
@@ -2728,21 +2778,21 @@
2728
2778
  if (linkEntity.to) {
2729
2779
  linkParams.to = linkEntity.to;
2730
2780
  }
2731
- if (linkEntity.linkType) {
2732
- linkParams.linkType = linkEntity.linkType;
2781
+ if (linkEntity.linktype) {
2782
+ linkParams.linktype = linkEntity.linktype;
2733
2783
  }
2734
2784
  }
2735
2785
  return linkParams;
2736
2786
  };
2737
2787
  MobileCRM.FetchXml.Fetch.prototype._constructFetchParams = function () {
2738
2788
  var reqParams = { entity: MobileCRM.FetchXml.Entity._constructEntityParams(this.entity) };
2739
- if (typeof this.page !== "undefined") {
2789
+ if (this.page) {
2740
2790
  reqParams.page = this.page;
2741
2791
  }
2742
- if (typeof this.count !== "undefined") {
2792
+ if (this.count !== undefined && this.count !== null) {
2743
2793
  reqParams.count = this.count;
2744
2794
  }
2745
- if (typeof this.aggregate !== "undefined") {
2795
+ if (this.aggregate !== undefined && this.aggregate !== null) {
2746
2796
  reqParams.aggregate = this.aggregate;
2747
2797
  }
2748
2798
  if (this.distinct) {
@@ -2870,7 +2920,7 @@
2870
2920
  /// <param name="target" type="String">The target entity.</param>
2871
2921
  /// <param name="from" type="String">The "from" field (if parent then target entity primary key).</param>
2872
2922
  /// <param name="to" type="String">The "to" field.</param>
2873
- /// <param name="linkType" type="String">The link (join) type ("inner" or "outer").</param>
2923
+ /// <param name="linktype" type="String">The link (join) type ("inner" or "outer").</param>
2874
2924
  /// <returns type="MobileCRM.FetchXml.LinkEntity">The newly created MobileCRM.FetchXml.LinkEntity object.</returns>
2875
2925
  var link = new MobileCRM.FetchXml.LinkEntity(target);
2876
2926
  link.from = from;
@@ -4941,6 +4991,7 @@
4941
4991
  /// <param name="entities" type="Array[MobileCRM.DynamicEntity]">A chunk (array) of <see cref="MobileCRM.DynamicEntity">DynamicEntities</see> that has to be passed back to the native code to fill in to the list view.</param>
4942
4992
  MobileCRM.bridge.command(this._chunkReadyCmdId, JSON.stringify(entities));
4943
4993
  };
4994
+ MobileCRM.Services.ZebraScanner._handlers = { onScan: [] };
4944
4995
  // MobileCRM.UI.QuestionnaireForm
4945
4996
  _inherit(MobileCRM.UI.QuestionnaireForm, MobileCRM.ObservableObject);
4946
4997
  MobileCRM.UI.QuestionnaireForm._handlers = { onChange: [], onSave: [], onPostSave: [], onRepeatGroup: [], onDeleteGroup: [] };