@resconet/jsbridge 17.1.5 → 17.2.0-beta.1

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": "17.1.5",
3
+ "version": "17.2.0-beta.1",
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
@@ -70,6 +70,16 @@ declare namespace MobileCRM {
70
70
  public static requestObject(callback: (config: Configuration) => void, erroCallback?: (error: string) => void, scope?: any);
71
71
  }
72
72
 
73
+ class GlobalConstants {
74
+ /**Gets the JSON object representing the GlobalConstants variables. */
75
+ public static getAllAsync(): Promise<Object>;
76
+ /**
77
+ *Gets the constant associated with specified key in the GlobalConstants variables.
78
+ * @param key The key of the constant to get.
79
+ */
80
+ public static getAsync(key: String): Promise<Object>;
81
+ }
82
+
73
83
  class Settings {
74
84
  /**Gets the absolute URL (including the CrmOrganization).*/
75
85
  absoluteUrl: string;
@@ -1042,7 +1052,7 @@ declare namespace MobileCRM {
1042
1052
  * @param failed A callback which is called in case of error.
1043
1053
  * @param scope The scope for callbacks.
1044
1054
  */
1045
- static showForm(report: MobileCRM.Reference, source: Array<MobileCRM.Reference>, fetchXml: string, failed?: (err: string) => void, scope?: any);
1055
+ static showForm(report: MobileCRM.Reference, source: MobileCRM.Reference[], fetchXml: string, failed?: (err: string) => void, scope?: any);
1046
1056
  /**
1047
1057
  * @since 16.0
1048
1058
  * Shows new MobileReport form. Source for the report can be defined either as list of MobileCRM.Reference objects or as FetchXML query.
@@ -1055,7 +1065,7 @@ declare namespace MobileCRM {
1055
1065
  */
1056
1066
  static showFormWithConfiguration(
1057
1067
  report: MobileCRM.Reference,
1058
- source: Array<MobileCRM.Reference>,
1068
+ source: MobileCRM.Reference[],
1059
1069
  fetchXml: string,
1060
1070
  paramString: string,
1061
1071
  failed?: (err: string) => void,
@@ -1075,13 +1085,20 @@ declare module MobileCRM.FetchXml {
1075
1085
  /**
1076
1086
  * @class Represents a FetchXml
1077
1087
  * @property entity {MobileCRM.FetchXml.Entity} An entity object.
1078
- * @property count {number} The maximum number of records to retrieve.
1079
- * @property page {number} 1-based index of the data page to retrieve.
1080
- * @property aggregate {boolean} Indicates whether the fetch is aggregated.
1081
- * @property distinct {boolean} Indicates whether to return only distinct (different) values.
1088
+ * @property count {number} The maximum number of records to retrieve.
1089
+ * @property page {number} 1-based index of the data page to retrieve.
1090
+ * @property aggregate {boolean} Indicates whether the fetch is aggregated.
1091
+ * @property distinct {boolean} Indicates whether to return only distinct (different) values.
1082
1092
  */
1083
1093
  class Fetch {
1084
- constructor(entity?: MobileCRM.FetchXml.Entity, count?: number, page?: number, distinct?: boolean);
1094
+ /** Constructs Fetch object
1095
+ * @param entity {MobileCRM.FetchXml.Entity} An entity object.
1096
+ * @param count {number} The maximum number of records to retrieve.
1097
+ * @param page {number} 1-based index of the data page to retrieve.
1098
+ * @param distinct {boolean} Indicates whether to return only distinct (different) values.
1099
+ * @param aggregate {boolean} Indicates whether the fetch is aggregated.
1100
+ */
1101
+ constructor(entity?: MobileCRM.FetchXml.Entity, count?: number, page?: number, distinct?: boolean, aggregate?: boolean);
1085
1102
 
1086
1103
  public entity: MobileCRM.FetchXml.Entity;
1087
1104
  count: number;
@@ -1096,7 +1113,7 @@ declare module MobileCRM.FetchXml {
1096
1113
  * @param failed A callback function for command failure. The error argument will carry the error message.
1097
1114
  * @param scope A scope for calling the callbacks. Set to call the callbacks in global scope.
1098
1115
  */
1099
- public static executeFromXML(fetchXmlData: string, success: (res: Array<any>) => void, failed?: (error: string) => void, scope?: any);
1116
+ public static executeFromXML(fetchXmlData: string, success: (res: any[]) => void, failed?: (error: string) => void, scope?: any);
1100
1117
  /**
1101
1118
  * @since 10.0
1102
1119
  * Deserializes XML to the Fetch object.
@@ -1134,7 +1151,7 @@ declare module MobileCRM.FetchXml {
1134
1151
  * @param failed A callback function for command failure. The error argument will carry the error message.
1135
1152
  * @param scope A scope for calling the callbacks. Set to call the callbacks in global scope.
1136
1153
  */
1137
- public execute(output: string, success: (res: Array<any>) => void, failed?: (err: string) => void, scope?: any);
1154
+ public execute(output: string, success: (res: any[]) => void, failed?: (err: string) => void, scope?: any);
1138
1155
  /**
1139
1156
  * @since 8.0
1140
1157
  * Performs the online CRM Fetch request regardless of the app online/offline mode.
@@ -1143,7 +1160,7 @@ declare module MobileCRM.FetchXml {
1143
1160
  * @param failed A callback function for command failure. The error argument will carry the error message.
1144
1161
  * @param scope A scope for calling the callbacks. Set to call the callbacks in global scope.
1145
1162
  */
1146
- public executeOnline(output: string, success: (res: Array<any>) => void, failed?: (error: string) => void, scope?: any);
1163
+ public executeOnline(output: string, success: (res: any[]) => void, failed?: (error: string) => void, scope?: any);
1147
1164
  /**
1148
1165
  * @since 8.0
1149
1166
  * Performs the offline CRM Fetch request regardless of the app online/offline mode.
@@ -1152,7 +1169,7 @@ declare module MobileCRM.FetchXml {
1152
1169
  * @param failed A callback function for command failure. The error argument will carry the error message.
1153
1170
  * @param scope A scope for calling the callbacks. Set to call the callbacks in global scope.
1154
1171
  */
1155
- public executeOffline(output: string, success: (res: Array<any>) => void, failed?: (error: string) => void, scope?: any);
1172
+ public executeOffline(output: string, success: (res: any[]) => void, failed?: (error: string) => void, scope?: any);
1156
1173
  /**
1157
1174
  * Performs the asynchronous CRM Fetch request.
1158
1175
  * @param output A string defining the output format: Array, JSON, XML or DynamicEntities.
@@ -1164,19 +1181,32 @@ declare module MobileCRM.FetchXml {
1164
1181
  /**
1165
1182
  * @class Represents a FetchXml query root entity.
1166
1183
  * @param name {string} An entity logical name.
1167
- * @property attributes {Array<Attribute>} An array of <see cref="MobileCRM.FetchXml.Attribute">MobileCRM.FetchXml.Attribute</see> objects.
1168
- * @property order {Array<Order>} An array of {MobileCRM.FetchXml.Order} objects
1184
+ * @property attributes {Attribute[]} An array of <see cref="MobileCRM.FetchXml.Attribute">MobileCRM.FetchXml.Attribute</see> objects.
1185
+ * @property order {Order[]} An array of {MobileCRM.FetchXml.Order} objects
1169
1186
  * @property filter {Filter} A query filter.
1170
- * @property linkentities {Array<LinkEntity>} An array of {MobileCRM.FetchXml.LinkEntity} objects.
1187
+ * @property linkentities {LinkEntity[]} An array of {MobileCRM.FetchXml.LinkEntity} objects.
1171
1188
  */
1172
1189
  class Entity {
1173
- constructor(name: string);
1190
+ /**
1191
+ * Constructs Entity object
1192
+ * @param name An entity logical name.
1193
+ * @param attributes An array of Attribute objects or "*" for all attributes.
1194
+ * @param order An array of Order objects.
1195
+ * @param filter A query filter.
1196
+ * @param linkentities An array of LinkEntity objects.
1197
+ */
1198
+ constructor(name: string, attributes?: Attribute[] | "*", order?: Order[], filter?: Filter, linkentities?: LinkEntity[]);
1174
1199
 
1200
+ /** An entity logical name. */
1175
1201
  name: string;
1176
- attributes: Array<Attribute>;
1177
- order: Array<Order>;
1202
+ /** An array of Attribute objects. */
1203
+ attributes: Attribute[];
1204
+ /** An array of Order objects. */
1205
+ order: Order[];
1206
+ /** A query filter. */
1178
1207
  filter: Filter;
1179
- linkentities: Array<LinkEntity>;
1208
+ /** An array of LinkEntity objects. */
1209
+ linkentities: LinkEntity[];
1180
1210
 
1181
1211
  /**
1182
1212
  * Adds an order by statement to the fetch query.
@@ -1240,7 +1270,28 @@ declare module MobileCRM.FetchXml {
1240
1270
  * @property alias {string} Defines an order alias.
1241
1271
  */
1242
1272
  class LinkEntity extends Entity {
1243
- constructor(name: string);
1273
+ /** Constructs LinkEntity object.
1274
+ * @param name An entity logical name.
1275
+ * @param attributes An array of Attribute objects or "*" for all attributes.
1276
+ * @param order An array of Order objects.
1277
+ * @param filter A query filter.
1278
+ * @param linkentities An array of LinkEntity objects.
1279
+ * @param from {number} The "from" field (if parent then target entity primary key).
1280
+ * @param to {number}
1281
+ * @param alias {string} Defines an order alias.
1282
+ * @param linktype {boolean} The link (join) type ("inner" or "outer").
1283
+ */
1284
+ constructor(
1285
+ name: string,
1286
+ attributes?: Attribute[] | "*",
1287
+ order?: Order[],
1288
+ filter?: Filter,
1289
+ linkentities?: LinkEntity[],
1290
+ from?: string,
1291
+ to?: string,
1292
+ alias?: string,
1293
+ linkType?: string
1294
+ );
1244
1295
 
1245
1296
  from: string;
1246
1297
  to: string;
@@ -1257,7 +1308,16 @@ declare module MobileCRM.FetchXml {
1257
1308
  * @property dategrouping {string} A date group by modifier (year, quarter, month, week, day).
1258
1309
  */
1259
1310
  class Attribute {
1260
- constructor(name: string);
1311
+ /**
1312
+ * Constructs Attribute object.
1313
+ * @param name A lower-case entity attribute name (CRM logical field name).
1314
+ * @param alias Defines an order alias.
1315
+ * @param aggregate An aggregation function.
1316
+ * @param groupBy Indicates whether to group by this attribute.
1317
+ * @param dateGrouping A date group by modifier (year, quarter, month, week, day).
1318
+ */
1319
+ constructor(name: string, alias?: string, aggregate?: boolean, groupBy?: boolean, dateGrouping?: string);
1320
+
1261
1321
  name: string;
1262
1322
  aggregate: string;
1263
1323
  groupby: boolean;
@@ -1271,7 +1331,13 @@ declare module MobileCRM.FetchXml {
1271
1331
  * @property descending {boolean} true, for descending order; false, for ascending order
1272
1332
  */
1273
1333
  class Order {
1274
- constructor(attribute?: string, descending?: boolean);
1334
+ /**
1335
+ * Constructs Order object
1336
+ * @param attribute An attribute name (CRM logical field name).
1337
+ * @param descending true, for descending order; false, for ascending order
1338
+ * @param alias Defines an order alias.
1339
+ */
1340
+ constructor(attribute?: string, descending?: boolean, alias?: string);
1275
1341
  attribute: string;
1276
1342
  alias: string;
1277
1343
  descending: boolean;
@@ -1279,13 +1345,21 @@ declare module MobileCRM.FetchXml {
1279
1345
  /**
1280
1346
  * @class Represents a FetchXml filter statement. A logical combination of {Condition} and child-filters.
1281
1347
  * @property type {string} Defines the filter operator ("or" / "and").
1282
- * @property conditions {Array<Condition>} An array of {Condition} objects.
1283
- * @property filters { Array<Filter>} An array of <see cref="MobileCRM.FetchXml.Filter"/> objects representing child-filters.
1348
+ * @property conditions {Condition[]} An array of {Condition} objects.
1349
+ * @property filters {Filter[]} An array of {Filter} objects representing child-filters.
1284
1350
  */
1285
1351
  class Filter {
1352
+ /**
1353
+ * Constructs {Filter} object.
1354
+ * @param type Defines the filter operator ("or" / "and").
1355
+ * @param conditions An array of {Condition} objects.
1356
+ * @param filters An array of {Filter} objects representing child-filters.
1357
+ */
1358
+ constructor(type?: string, conditions?: Condition[], filters?: Filter[]);
1359
+
1286
1360
  type: string;
1287
- conditions: Array<Condition>;
1288
- filters: Array<Filter>;
1361
+ conditions: Condition[];
1362
+ filters: Filter[];
1289
1363
  /**
1290
1364
  * Adds a attribute condition to the filter.
1291
1365
  * @param attribute The attribute name (CRM logical field name).
@@ -1338,16 +1412,27 @@ declare module MobileCRM.FetchXml {
1338
1412
  * @property uitype {string} The lookup target entity display name.
1339
1413
  * @property uiname {string} The lookup target entity logical name.
1340
1414
  * @property value {any} The value to compare to.
1341
- * @property values {Array<any>} The list of values to compare to.
1415
+ * @property values {any[]} The list of values to compare to.
1342
1416
  */
1343
1417
  class Condition {
1418
+ /**
1419
+ * Constructs {Condition} object.
1420
+ * @param attribute The attribute name (CRM logical field name).
1421
+ * @param operator The condition operator. "eq", "ne", "in", "not-in", "between", "not-between", "lt", "le", "gt", "ge", "like", "not-like", "null", "not-null", "eq-userid", "eq-userteams", "today", "yesterday", "tomorrow", "this-year", "last-week", "last-x-hours", "next-x-years", "olderthan-x-months", ...
1422
+ * @param value The value (or values) to compare to.
1423
+ * @param entityName The link name or alias to which this condition is relative to.
1424
+ * @param refTarget The lookup target entity logical name.
1425
+ * @param refLabel The lookup target entity display name.
1426
+ */
1427
+ constructor(attribute?: string, operator?: string, value?: any | any[], entityName?: string, refTarget?: string, refLabel?: string);
1428
+
1344
1429
  attribute: string;
1345
1430
  entityname: string;
1346
1431
  operator: string;
1347
1432
  uitype: string;
1348
1433
  uiname: string;
1349
1434
  value: any;
1350
- values: Array<any>;
1435
+ values: any[];
1351
1436
  }
1352
1437
  }
1353
1438
  declare module MobileCRM.Services {
package/src/JSBridge.js CHANGED
@@ -219,6 +219,9 @@
219
219
  /// <field name="settings" type="MobileCRM._Settings">Gets the application settings.</field>
220
220
  /// <field name="storageDirectory" type="String">Gets the root folder of the application storage.</field>
221
221
  },
222
+ GlobalConstants: function () {
223
+ /// <summary>Provides access to the global constants.</summary>
224
+ },
222
225
  CultureInfo: function () {
223
226
  /// <summary>[v10.2] Provides information about current device culture. The information includes the names for the culture, the writing system, the calendar used, and formatting for dates.</summary>
224
227
  /// <field name="name" type="String">Gets the culture name in the format languageCode/region (e.g. &quot;en-US&quot;). languageCode is a lowercase two-letter code derived from ISO 639-1. regioncode is derived from ISO 3166 and usually consists of two uppercase letters.</field>
@@ -402,12 +405,13 @@
402
405
  /// <field name="isSingularParty" type="Boolean">Gets whether the property represents a singular activity party property. These properties exists as both a Lookup property on the entity and an ActivytParty record.</field>
403
406
  },
404
407
  FetchXml: {
405
- Fetch: function (entity, count, page, distinct) {
408
+ Fetch: function (entity, count, page, distinct, aggregate) {
406
409
  /// <summary>Represents a FetchXml query object.</summary>
407
410
  /// <param name="entity" type="MobileCRM.FetchXml.Entity">An entity object.</param>
408
411
  /// <param name="count" type="int">the maximum number of records to retrieve.</param>
409
412
  /// <param name="page" type="int">1-based index of the data page to retrieve.</param>
410
413
  /// <param name="distinct" type="bool">Whether to return only distinct (different) values.</param>
414
+ /// <param name="aggregate" type="bool">Indicates whether the fetch is aggregated.</param>
411
415
  /// <field name="aggregate" type="Boolean">Indicates whether the fetch is aggregated.</field>
412
416
  /// <field name="count" type="int">the maximum number of records to retrieve.</field>
413
417
  /// <field name="entity" type="MobileCRM.FetchXml.Entity">An entity object.</field>
@@ -422,12 +426,12 @@
422
426
  if (typeof page !== "undefined") {
423
427
  this.page = page;
424
428
  }
425
- this.aggregate = false;
429
+ this.aggregate = !!aggregate;
426
430
  if (typeof distinct !== "undefined") {
427
431
  this.distinct = distinct;
428
432
  }
429
433
  },
430
- Entity: function (name) {
434
+ Entity: function (name, attributes, order, filter, linkentities) {
431
435
  /// <summary>Represents a FetchXml query root entity.</summary>
432
436
  /// <param name="name" type="String">An entity logical name.</param>
433
437
  /// <field name="allattributes" type="Boolean">Indicates whether to fetch all attributes instead of explicitly chosen set.</field>
@@ -439,22 +443,42 @@
439
443
  if (name) {
440
444
  this.name = name;
441
445
  }
442
- this.attributes = [];
443
- this.order = [];
444
- this.filter = null;
445
- this.linkentities = [];
446
+ if (attributes) {
447
+ if (attributes == "*") {
448
+ this.allattributes = true;
449
+ } else {
450
+ this.attributes = attributes;
451
+ }
452
+ } else {
453
+ this.attributes = [];
454
+ }
455
+ this.order = order instanceof Array ? order : [];
456
+ this.filter = filter ? filter : null;
457
+ this.linkentities = linkentities ? linkentities : [];
446
458
  },
447
- LinkEntity: function () {
459
+ LinkEntity: function (name, attributes, order, filter, linkentities, from, to, alias, linkType) {
448
460
  /// <summary>Represents a FetchXml query linked entity.</summary>
449
461
  /// <remarks>This object is derived from <see cref="MobileCRM.FetchXml.Entity">MobileCRM.FetchXml.Entity</see></remarks>
450
462
  /// <param name="name" type="String">An entity name</param>
451
463
  /// <field name="alias" type="String">A link alias.</field>
452
464
  /// <field name="from" type="String">The "from" field (if parent then target entity primary key).</field>
453
- /// <field name="linkType" type="String">The link (join) type ("inner" or "outer").</field>
465
+ /// <field name="linktype" type="String">The link (join) type ("inner" or "outer").</field>
454
466
  /// <field name="to" type="String">The "to" field.</field>
455
467
  MobileCRM.FetchXml.LinkEntity.superproto.constructor.apply(this, arguments);
468
+ if (from) {
469
+ this.from = from;
470
+ }
471
+ if (to) {
472
+ this.to = to;
473
+ }
474
+ if (alias) {
475
+ this.alias = alias;
476
+ }
477
+ if (linkType) {
478
+ this.linktype = linkType;
479
+ }
456
480
  },
457
- Attribute: function (name) {
481
+ Attribute: function (name, alias, aggregate, groupBy, dateGrouping) {
458
482
  /// <summary>Represents a FetchXml select statement (CRM field).</summary>
459
483
  /// <param name="name" type="String">A lower-case entity attribute name (CRM logical field name).</param>
460
484
  /// <field name="aggregate" type="String">An aggregation function.</field>
@@ -465,9 +489,18 @@
465
489
  if (name) {
466
490
  this.name = name;
467
491
  }
468
- this.groupby = false;
492
+ if (alias) {
493
+ this.alias = alias;
494
+ }
495
+ this.groupby = !!groupBy;
496
+ if (aggregate) {
497
+ this.aggregate = aggregate;
498
+ }
499
+ if (dateGrouping) {
500
+ this.dategrouping = dateGrouping;
501
+ }
469
502
  },
470
- Order: function (attribute, descending) {
503
+ Order: function (attribute, descending, alias) {
471
504
  /// <summary>Represents a FetchXml order statement.</summary>
472
505
  /// <param name="attribute" type="String">An attribute name (CRM logical field name).</param>
473
506
  /// <param name="descending" type="Boolean">true, for descending order; false, for ascending order</param>
@@ -478,16 +511,22 @@
478
511
  this.attribute = attribute;
479
512
  }
480
513
  this.descending = descending ? true : false;
514
+ if (alias) {
515
+ this.alias = alias;
516
+ }
481
517
  },
482
- Filter: function () {
518
+ Filter: function (type, conditions, filters) {
483
519
  /// <summary>Represents a FetchXml filter statement. A logical combination of <see cref="MobileCRM.FetchXml.Condition">Conditions</see> and child-filters.</summary>
484
520
  /// <field name="conditions" type="Array">An array of <see cref="MobileCRM.FetchXml.Condition">Condition</see> objects.</field>
485
521
  /// <field name="filters" type="Array">An array of <see cref="MobileCRM.FetchXml.Filter">Filter</see> objects representing child-filters.</field>
486
522
  /// <field name="type" type="String">Defines the filter operator ("or" / "and").</field>
487
- this.conditions = [];
488
- this.filters = [];
523
+ if (type) {
524
+ this.type = type;
525
+ }
526
+ this.conditions = conditions instanceof Array ? conditions : [];
527
+ this.filters = filters instanceof Array ? filters : [];
489
528
  },
490
- Condition: function () {
529
+ Condition: function (attribute, operator, value, entityName, refTarget, refLabel) {
491
530
  /// <summary>Represents a FetchXml attribute condition statement.</summary>
492
531
  /// <field name="attribute" type="String">The attribute name (CRM logical field name).</field>
493
532
  /// <field name="operator" type="String">The condition operator. "eq", "ne", "in", "not-in", "between", "not-between", "lt", "le", "gt", "ge", "like", "not-like", "null", "not-null", "eq-userid", "eq-userteams", "today", "yesterday", "tomorrow", "this-year", "last-week", "last-x-hours", "next-x-years", "olderthan-x-months", ...</field>
@@ -496,7 +535,29 @@
496
535
  /// <field name="uitype" type="String">The lookup target entity logical name.</field>
497
536
  /// <field name="value" type="">The value to compare to.</field>
498
537
  /// <field name="values" type="Array">The list of values to compare to.</field>
538
+ if (attribute) {
539
+ this.attribute = attribute;
540
+ }
541
+ if (operator) {
542
+ this.operator = operator;
543
+ }
499
544
  this.values = [];
545
+ if (value) {
546
+ if (value instanceof Array) {
547
+ this.values = value;
548
+ } else {
549
+ this.value = value;
550
+ }
551
+ }
552
+ if (entityName) {
553
+ this.entityname = entityName;
554
+ }
555
+ if (refTarget) {
556
+ this.uitype = refTarget;
557
+ }
558
+ if (refLabel) {
559
+ this.uiname = refLabel;
560
+ }
500
561
  },
501
562
  },
502
563
  Platform: function () {
@@ -1622,6 +1683,18 @@
1622
1683
  scope
1623
1684
  );
1624
1685
  };
1686
+ //MobileCRM.GlobalConstants
1687
+ MobileCRM.GlobalConstants.getAllAsync = function () {
1688
+ /// <summary>Asynchronously returns the JSON object representing the GlobalConstants variables.</summary>
1689
+ /// <returns type="Promise&lt;Object&gt;">A Promise object that will be resolved with the properties representing the constant variables.</returns>
1690
+ return MobileCRM.bridge.invokeCommandPromise("getGlobalConstants");
1691
+ };
1692
+ MobileCRM.GlobalConstants.getAsync = function (key) {
1693
+ /// <summary>Asynchronously returns the constant associated with the specified key in the GlobalConstants variables.</summary>
1694
+ /// <param name="key" type="String">The key of the constant to get.</param>
1695
+ /// <returns type="Promise&lt;Object&gt;">A Promise object that will be resolved with an object representing the constant variable.</returns>
1696
+ return MobileCRM.bridge.invokeCommandPromise("getGlobalConstants", key);
1697
+ };
1625
1698
  // MobileCRM._Settings
1626
1699
  MobileCRM._Settings = {
1627
1700
  /// <summary>MobileCRM configuration settings class.</summary>