@resconet/jsbridge 17.1.0-beta.3 → 17.1.0
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 +1 -1
- package/src/JSBridge.js +181 -39
package/package.json
CHANGED
package/src/JSBridge.js
CHANGED
|
@@ -25,6 +25,21 @@
|
|
|
25
25
|
}
|
|
26
26
|
return null;
|
|
27
27
|
};
|
|
28
|
+
var _normalizeArray = function (arr, convertCallback) {
|
|
29
|
+
var retVal = undefined;
|
|
30
|
+
if (arr instanceof Array && arr.length > 0) {
|
|
31
|
+
const normArr = [];
|
|
32
|
+
for (const o of arr) {
|
|
33
|
+
if (o) {
|
|
34
|
+
normArr.push(convertCallback(o));
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (normArr.length > 0) {
|
|
38
|
+
retVal = normArr;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return retVal;
|
|
42
|
+
};
|
|
28
43
|
var _addProperty = function (obj, name, writable, value) {
|
|
29
44
|
if (!obj._privVals) {
|
|
30
45
|
obj._privVals = {};
|
|
@@ -398,39 +413,46 @@
|
|
|
398
413
|
/// <field name="entity" type="MobileCRM.FetchXml.Entity">An entity object.</field>
|
|
399
414
|
/// <field name="page" type="int">1-based index of the data page to retrieve.</field>
|
|
400
415
|
/// <field name="distinct" type="Boolean">Whether to return only distinct (different) values.</field>
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
416
|
+
if (entity) {
|
|
417
|
+
this.entity = entity;
|
|
418
|
+
}
|
|
419
|
+
if (typeof count !== "undefined") {
|
|
420
|
+
this.count = count;
|
|
421
|
+
}
|
|
422
|
+
if (typeof page !== "undefined") {
|
|
423
|
+
this.page = page;
|
|
424
|
+
}
|
|
404
425
|
this.aggregate = false;
|
|
405
|
-
|
|
426
|
+
if (typeof distinct !== "undefined") {
|
|
427
|
+
this.distinct = distinct;
|
|
428
|
+
}
|
|
406
429
|
},
|
|
407
430
|
Entity: function (name) {
|
|
408
431
|
/// <summary>Represents a FetchXml query root entity.</summary>
|
|
409
432
|
/// <param name="name" type="String">An entity logical name.</param>
|
|
433
|
+
/// <field name="allattributes" type="Boolean">Indicates whether to fetch all attributes instead of explicitly chosen set.</field>
|
|
410
434
|
/// <field name="attributes" type="Array">An array of <see cref="MobileCRM.FetchXml.Attribute">MobileCRM.FetchXml.Attribute</see> objects.</field>
|
|
411
435
|
/// <field name="filter" type="MobileCRM.FetchXml.Filter">A query filter.</field>
|
|
412
436
|
/// <field name="linkentities" type="Array">An array of <see cref="MobileCRM.FetchXml.LinkEntity">MobileCRM.FetchXml.LinkEntity</see> objects.</field>
|
|
413
437
|
/// <field name="name" type="String">An entity logical name.</field>
|
|
414
438
|
/// <field name="order" type="Array">An array of <see cref="MobileCRM.FetchXml.Order">MobileCRM.FetchXml.Order</see> objects.</field>
|
|
415
|
-
|
|
439
|
+
if (name) {
|
|
440
|
+
this.name = name;
|
|
441
|
+
}
|
|
416
442
|
this.attributes = [];
|
|
417
443
|
this.order = [];
|
|
418
444
|
this.filter = null;
|
|
419
445
|
this.linkentities = [];
|
|
420
446
|
},
|
|
421
|
-
LinkEntity: function (
|
|
447
|
+
LinkEntity: function () {
|
|
422
448
|
/// <summary>Represents a FetchXml query linked entity.</summary>
|
|
423
449
|
/// <remarks>This object is derived from <see cref="MobileCRM.FetchXml.Entity">MobileCRM.FetchXml.Entity</see></remarks>
|
|
450
|
+
/// <param name="name" type="String">An entity name</param>
|
|
424
451
|
/// <field name="alias" type="String">A link alias.</field>
|
|
425
452
|
/// <field name="from" type="String">The "from" field (if parent then target entity primary key).</field>
|
|
426
453
|
/// <field name="linkType" type="String">The link (join) type ("inner" or "outer").</field>
|
|
427
|
-
/// <param name="name" type="String">An entity name</param>
|
|
428
454
|
/// <field name="to" type="String">The "to" field.</field>
|
|
429
455
|
MobileCRM.FetchXml.LinkEntity.superproto.constructor.apply(this, arguments);
|
|
430
|
-
this.from = null;
|
|
431
|
-
this.to = null;
|
|
432
|
-
this.linktype = null;
|
|
433
|
-
this.alias = null;
|
|
434
456
|
},
|
|
435
457
|
Attribute: function (name) {
|
|
436
458
|
/// <summary>Represents a FetchXml select statement (CRM field).</summary>
|
|
@@ -440,11 +462,10 @@
|
|
|
440
462
|
/// <field name="dategrouping" type="String">A date group by modifier (year, quarter, month, week, day).</field>
|
|
441
463
|
/// <field name="groupby" type="Boolean">Indicates whether to group by this attribute.</field>
|
|
442
464
|
/// <field name="name" type="String">A lower-case entity attribute name (CRM logical field name).</field>
|
|
443
|
-
|
|
444
|
-
|
|
465
|
+
if (name) {
|
|
466
|
+
this.name = name;
|
|
467
|
+
}
|
|
445
468
|
this.groupby = false;
|
|
446
|
-
this.alias = null;
|
|
447
|
-
this.dategrouping = null;
|
|
448
469
|
},
|
|
449
470
|
Order: function (attribute, descending) {
|
|
450
471
|
/// <summary>Represents a FetchXml order statement.</summary>
|
|
@@ -453,8 +474,9 @@
|
|
|
453
474
|
/// <field name="alias" type="String">Defines an order alias.</field>
|
|
454
475
|
/// <field name="attribute" type="String">An attribute name (CRM logical field name).</field>
|
|
455
476
|
/// <field name="descending" type="Boolean">true, for descending order; false, for ascending order.</field>
|
|
456
|
-
|
|
457
|
-
|
|
477
|
+
if (attribute) {
|
|
478
|
+
this.attribute = attribute;
|
|
479
|
+
}
|
|
458
480
|
this.descending = descending ? true : false;
|
|
459
481
|
},
|
|
460
482
|
Filter: function () {
|
|
@@ -462,7 +484,6 @@
|
|
|
462
484
|
/// <field name="conditions" type="Array">An array of <see cref="MobileCRM.FetchXml.Condition">Condition</see> objects.</field>
|
|
463
485
|
/// <field name="filters" type="Array">An array of <see cref="MobileCRM.FetchXml.Filter">Filter</see> objects representing child-filters.</field>
|
|
464
486
|
/// <field name="type" type="String">Defines the filter operator ("or" / "and").</field>
|
|
465
|
-
this.type = null;
|
|
466
487
|
this.conditions = [];
|
|
467
488
|
this.filters = [];
|
|
468
489
|
},
|
|
@@ -474,15 +495,10 @@
|
|
|
474
495
|
/// <field name="uitype" type="String">The lookup target entity logical name.</field>
|
|
475
496
|
/// <field name="value" type="">The value to compare to.</field>
|
|
476
497
|
/// <field name="values" type="Array">The list of values to compare to.</field>
|
|
477
|
-
this.attribute = null;
|
|
478
|
-
this.operator = null;
|
|
479
|
-
this.uitype = null;
|
|
480
|
-
this.uiname = null;
|
|
481
|
-
this.value = null;
|
|
482
498
|
this.values = [];
|
|
483
499
|
},
|
|
484
500
|
},
|
|
485
|
-
Platform: function (
|
|
501
|
+
Platform: function () {
|
|
486
502
|
/// <summary>Represents object for querying platform specific information and executing platform integrated actions.</summary>
|
|
487
503
|
/// <remarks>This object cannot be created directly. To obtain/modify this object, use <see cref="MobileCRM.Platform.requestObject">MobileCRM.Platform.requestObject</see> function.</remarks>
|
|
488
504
|
/// <field name="capabilities" type="Number">Gets the mask of capability flags supported by this device (MakePhoneCalls=1; HasMapView=2).</field>
|
|
@@ -544,7 +560,7 @@
|
|
|
544
560
|
},
|
|
545
561
|
UI: {
|
|
546
562
|
FormManager: {},
|
|
547
|
-
EntityForm: function (
|
|
563
|
+
EntityForm: function () {
|
|
548
564
|
/// <summary>Represents the Javascript equivalent of native entity form object.</summary>
|
|
549
565
|
/// <remarks>This object cannot be created directly. To obtain/modify this object, use <see cref="MobileCRM.UI.EntityForm.requestObject">MobileCRM.UI.EntityForm.requestObject</see> function.</remarks>
|
|
550
566
|
/// <field name="associatedViews" type="Array">Gets the associated views as an array of <see cref="MobileCRM.UI._EntityList">MobileCRM.UI._EntityList</see> objects.</field>
|
|
@@ -572,11 +588,11 @@
|
|
|
572
588
|
/// <field name="relationship" type="MobileCRM.Relationship">Gets the relation source and related entity. "null", if there is no relationship.</field>
|
|
573
589
|
MobileCRM.UI.QuestionnaireForm.superproto.constructor.apply(this, arguments);
|
|
574
590
|
},
|
|
575
|
-
EntityChart: function (
|
|
591
|
+
EntityChart: function () {
|
|
576
592
|
/// <summary>[13.0] Represents the Javascript equivalent of native entity chart object.</summary>
|
|
577
593
|
MobileCRM.UI.EntityChart.superproto.constructor.apply(this, arguments);
|
|
578
594
|
},
|
|
579
|
-
EntityList: function (
|
|
595
|
+
EntityList: function () {
|
|
580
596
|
/// <summary>[v9.2] Represents the Javascript equivalent of native entity list object.</summary>
|
|
581
597
|
/// <field name="allowAddExisting" type="Boolean">Gets or sets whether adding an existing entity is allowed.</field>
|
|
582
598
|
/// <field name="allowCreateNew" type="Boolean">Gets or sets whether create a new entity (or managing the N:N entities in the case of N:N list) is allowed.</field>
|
|
@@ -604,7 +620,7 @@
|
|
|
604
620
|
/// <field name="uniqueName" type="Number">Gets or sets the unique name of the list. Used to save/load list specific settings.</field>
|
|
605
621
|
MobileCRM.UI.EntityList.superproto.constructor.apply(this, arguments);
|
|
606
622
|
},
|
|
607
|
-
HomeForm: function (
|
|
623
|
+
HomeForm: function () {
|
|
608
624
|
/// <summary>[v8.0] Represents the Javascript equivalent of the home form object which contains the Home/UI replacement iFrame.</summary>
|
|
609
625
|
/// <remarks><p>This class works only from Home/UI replacement iFrame.</p><p>This object cannot be created directly. To obtain/modify this object, use <see cref="MobileCRM.UI.HomeForm.requestObject">MobileCRM.UI.HomeForm.requestObject</see> function.</p></remarks>
|
|
610
626
|
/// <field name="form" type="MobileCRM.UI.Form">Gets the top level form.</field>
|
|
@@ -2527,21 +2543,147 @@
|
|
|
2527
2543
|
/// <param name="scope" type="">A scope for calling the callbacks; set "null" to call the callbacks in global scope.</param>
|
|
2528
2544
|
_global.MobileCRM.bridge.command("fetchXML", fetchXmlData, success, failed, scope);
|
|
2529
2545
|
};
|
|
2546
|
+
MobileCRM.FetchXml.Condition._constructConditionParams = function (condition) {
|
|
2547
|
+
if (condition) {
|
|
2548
|
+
var conditionParams = {};
|
|
2549
|
+
if (condition.attribute) {
|
|
2550
|
+
conditionParams.attribute = condition.attribute;
|
|
2551
|
+
}
|
|
2552
|
+
if (condition.operator) {
|
|
2553
|
+
conditionParams.operator = condition.operator;
|
|
2554
|
+
}
|
|
2555
|
+
if (condition.uiname) {
|
|
2556
|
+
conditionParams.uiname = condition.uiname;
|
|
2557
|
+
}
|
|
2558
|
+
if (condition.uitype) {
|
|
2559
|
+
conditionParams.uitype = condition.uitype;
|
|
2560
|
+
}
|
|
2561
|
+
if (typeof condition.value !== "undefined") {
|
|
2562
|
+
conditionParams.value = condition.value;
|
|
2563
|
+
}
|
|
2564
|
+
if (condition.values instanceof Array && condition.values.length > 0) {
|
|
2565
|
+
conditionParams.values = condition.values;
|
|
2566
|
+
}
|
|
2567
|
+
return conditionParams;
|
|
2568
|
+
} else {
|
|
2569
|
+
return undefined;
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
MobileCRM.FetchXml.Filter._constructFilterParams = function (filter) {
|
|
2573
|
+
if (filter) {
|
|
2574
|
+
var filterParams = {};
|
|
2575
|
+
if (filter.type) {
|
|
2576
|
+
filterParams.type = filter.type;
|
|
2577
|
+
}
|
|
2578
|
+
filterParams.conditions = _normalizeArray(filter.conditions, MobileCRM.FetchXml.Condition._constructConditionParams);
|
|
2579
|
+
filterParams.filters = _normalizeArray(filter.filters, MobileCRM.FetchXml.Filter._constructFilterParams);
|
|
2580
|
+
return filterParams;
|
|
2581
|
+
} else {
|
|
2582
|
+
return undefined;
|
|
2583
|
+
}
|
|
2584
|
+
};
|
|
2585
|
+
MobileCRM.FetchXml.Order._constructOrderParams = function (order) {
|
|
2586
|
+
if (order) {
|
|
2587
|
+
var orderParams = { attribute: order.attribute };
|
|
2588
|
+
if (typeof order.descending != "undefined") {
|
|
2589
|
+
orderParams.descending = order.descending;
|
|
2590
|
+
}
|
|
2591
|
+
if (order.alias) {
|
|
2592
|
+
orderParams.alias = order.alias;
|
|
2593
|
+
}
|
|
2594
|
+
return orderParams;
|
|
2595
|
+
} else {
|
|
2596
|
+
return undefined;
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
MobileCRM.FetchXml.Attribute._constructAttributeParams = function (attribute) {
|
|
2600
|
+
if (attribute) {
|
|
2601
|
+
var attrParams = {};
|
|
2602
|
+
if (attribute.name) {
|
|
2603
|
+
attrParams.name = attribute.name;
|
|
2604
|
+
}
|
|
2605
|
+
if (attribute.aggregate) {
|
|
2606
|
+
attrParams.aggregate = attribute.aggregate;
|
|
2607
|
+
}
|
|
2608
|
+
if (typeof attribute.groupby != "undefined") {
|
|
2609
|
+
attrParams.groupby = attribute.groupby;
|
|
2610
|
+
}
|
|
2611
|
+
if (attribute.alias) {
|
|
2612
|
+
attrParams.alias = attribute.alias;
|
|
2613
|
+
}
|
|
2614
|
+
if (attribute.dategrouping) {
|
|
2615
|
+
attrParams.dategrouping = attribute.dategrouping;
|
|
2616
|
+
}
|
|
2617
|
+
return attrParams;
|
|
2618
|
+
} else {
|
|
2619
|
+
return undefined;
|
|
2620
|
+
}
|
|
2621
|
+
};
|
|
2622
|
+
MobileCRM.FetchXml.Entity._constructEntityParams = function (entity) {
|
|
2623
|
+
if (entity) {
|
|
2624
|
+
var entityParams = {};
|
|
2625
|
+
if (entity.name) {
|
|
2626
|
+
entityParams.name = entity.name;
|
|
2627
|
+
}
|
|
2628
|
+
entityParams.attributes = _normalizeArray(entity.attributes, MobileCRM.FetchXml.Attribute._constructAttributeParams);
|
|
2629
|
+
entityParams.order = _normalizeArray(entity.order, MobileCRM.FetchXml.Order._constructOrderParams);
|
|
2630
|
+
if (entity.filter) {
|
|
2631
|
+
entityParams.filter = MobileCRM.FetchXml.Filter._constructFilterParams(entity.filter);
|
|
2632
|
+
}
|
|
2633
|
+
entityParams.linkentities = _normalizeArray(entity.linkentities, MobileCRM.FetchXml.LinkEntity._constructLinkParams);
|
|
2634
|
+
if (entity.allattributes) {
|
|
2635
|
+
entityParams.allattributes = entity.allattributes;
|
|
2636
|
+
}
|
|
2637
|
+
return entityParams;
|
|
2638
|
+
} else {
|
|
2639
|
+
return undefined;
|
|
2640
|
+
}
|
|
2641
|
+
};
|
|
2642
|
+
MobileCRM.FetchXml.LinkEntity._constructLinkParams = function (linkEntity) {
|
|
2643
|
+
var linkParams = MobileCRM.FetchXml.Entity._constructEntityParams(linkEntity);
|
|
2644
|
+
if (linkParams) {
|
|
2645
|
+
if (linkEntity.alias) {
|
|
2646
|
+
linkParams.alias = linkEntity.alias;
|
|
2647
|
+
}
|
|
2648
|
+
if (linkEntity.from) {
|
|
2649
|
+
linkParams.from = linkEntity.from;
|
|
2650
|
+
}
|
|
2651
|
+
if (linkEntity.to) {
|
|
2652
|
+
linkParams.to = linkEntity.to;
|
|
2653
|
+
}
|
|
2654
|
+
if (linkEntity.linkType) {
|
|
2655
|
+
linkParams.linkType = linkEntity.linkType;
|
|
2656
|
+
}
|
|
2657
|
+
}
|
|
2658
|
+
return linkParams;
|
|
2659
|
+
};
|
|
2660
|
+
MobileCRM.FetchXml.Fetch.prototype._constructFetchParams = function () {
|
|
2661
|
+
var reqParams = { entity: MobileCRM.FetchXml.Entity._constructEntityParams(this.entity) };
|
|
2662
|
+
if (typeof this.page !== "undefined") {
|
|
2663
|
+
reqParams.page = this.page;
|
|
2664
|
+
}
|
|
2665
|
+
if (typeof this.count !== "undefined") {
|
|
2666
|
+
reqParams.count = this.count;
|
|
2667
|
+
}
|
|
2668
|
+
if (typeof this.aggregate !== "undefined") {
|
|
2669
|
+
reqParams.aggregate = this.aggregate;
|
|
2670
|
+
}
|
|
2671
|
+
if (this.distinct) {
|
|
2672
|
+
reqParams.distinct = this.distinct;
|
|
2673
|
+
}
|
|
2674
|
+
return reqParams;
|
|
2675
|
+
};
|
|
2530
2676
|
MobileCRM.FetchXml.Fetch.prototype.execute = function (output, success, failed, scope) {
|
|
2531
2677
|
/// <summary>Performs the asynchronous CRM Fetch request.</summary>
|
|
2532
2678
|
/// <param name="output" type="String">A string defining the output format: Array, JSON, XML or DynamicEntities.</param>
|
|
2533
2679
|
/// <param name="success" type="function(result)">A callback function for successful asynchronous result. The <b>result</b> argument will carry the objects array of type specified by <b>output</b> argument.</param>
|
|
2534
2680
|
/// <param name="failed" type="function(error)">A callback function for command failure. The <b>error</b> argument will carry the error message.</param>
|
|
2535
2681
|
/// <param name="scope" type="">A scope for calling the callbacks; set "null" to call the callbacks in global scope.</param>
|
|
2536
|
-
var reqParams =
|
|
2537
|
-
|
|
2538
|
-
resultformat
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
aggregate: this.aggregate,
|
|
2542
|
-
distinct: this.distinct,
|
|
2543
|
-
});
|
|
2544
|
-
MobileCRM.bridge.command("fetch", reqParams, success, failed, scope);
|
|
2682
|
+
var reqParams = this._constructFetchParams();
|
|
2683
|
+
if (output) {
|
|
2684
|
+
reqParams.resultformat = output;
|
|
2685
|
+
}
|
|
2686
|
+
MobileCRM.bridge.command("fetch", JSON.stringify(reqParams), success, failed, scope);
|
|
2545
2687
|
};
|
|
2546
2688
|
MobileCRM.FetchXml.Fetch.prototype.executeOnline = function (output, success, failed, scope) {
|
|
2547
2689
|
/// <summary>[v8.0] Performs the online CRM Fetch request regardless of the app online/offline mode.</summary>
|
|
@@ -2605,13 +2747,13 @@
|
|
|
2605
2747
|
/// <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>
|
|
2606
2748
|
/// <param name="failed" type="function(error)">A callback function for command failure. The <b>error</b> argument will carry the error message.</param>
|
|
2607
2749
|
/// <param name="scope" type="">A scope for calling the callbacks; set "null" to call the callbacks in global scope.</param>
|
|
2608
|
-
var reqParams =
|
|
2750
|
+
var reqParams = this._constructFetchParams();
|
|
2609
2751
|
MobileCRM.bridge.command("fetchToXml", reqParams, success, failed, scope);
|
|
2610
2752
|
};
|
|
2611
2753
|
MobileCRM.FetchXml.Fetch.prototype.serializeToXmlAsync = function () {
|
|
2612
2754
|
/// <summary>[v10.0] Serializes the Fetch object to XML.</summary>
|
|
2613
2755
|
/// <returns type="Promise<string>">A Promise object which will be resolved with the XML representation of this Fetch object.</returns>
|
|
2614
|
-
var reqParams =
|
|
2756
|
+
var reqParams = this._constructFetchParams();
|
|
2615
2757
|
return MobileCRM.bridge.invokeCommandPromise("fetchToXml", reqParams);
|
|
2616
2758
|
};
|
|
2617
2759
|
// MobileCRM.FetchXml.Entity
|