backendless 6.7.0 → 6.7.1-dev.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.
Files changed (159) hide show
  1. package/backendless.d.ts +5 -0
  2. package/dist/backendless.js +20966 -23929
  3. package/dist/backendless.js.map +1 -1
  4. package/dist/backendless.min.js +2 -2
  5. package/es/bl/constants.js +0 -2
  6. package/es/bl/custom-services.js +40 -65
  7. package/es/bl/events.js +30 -52
  8. package/es/bl/index.js +3 -9
  9. package/es/cache/index.js +125 -189
  10. package/es/commerce/index.js +78 -119
  11. package/es/counters/counter.js +0 -8
  12. package/es/counters/index.js +171 -258
  13. package/es/data/data-query-builder.js +2 -39
  14. package/es/data/geo/geo-constructor.js +5 -26
  15. package/es/data/geo/geo-json-parser.js +0 -7
  16. package/es/data/geo/geometry.js +4 -13
  17. package/es/data/geo/linestring.js +4 -21
  18. package/es/data/geo/point.js +4 -22
  19. package/es/data/geo/polygon.js +4 -30
  20. package/es/data/geo/spatial-reference-system.js +1 -7
  21. package/es/data/geo/wkt-parser.js +0 -10
  22. package/es/data/geo/wkt-to-geojson.js +4 -44
  23. package/es/data/group-query-builder.js +0 -23
  24. package/es/data/index.js +17 -54
  25. package/es/data/json-update-builder.js +0 -18
  26. package/es/data/load-relations-query-builder.js +0 -16
  27. package/es/data/persmission.js +0 -16
  28. package/es/data/rt-handlers.js +1 -46
  29. package/es/data/store.js +316 -518
  30. package/es/decorators/deprecated.js +2 -5
  31. package/es/decorators/index.js +0 -2
  32. package/es/device/index.js +3 -8
  33. package/es/expression.js +29 -0
  34. package/es/files/index.js +354 -493
  35. package/es/files/persmission.js +0 -15
  36. package/es/files/utils.js +32 -55
  37. package/es/hive/index.js +1 -13
  38. package/es/hive/stores/base-store.js +14 -50
  39. package/es/hive/stores/index.js +0 -10
  40. package/es/hive/stores/key-value.js +4 -37
  41. package/es/hive/stores/list.js +0 -32
  42. package/es/hive/stores/map.js +0 -34
  43. package/es/hive/stores/set.js +0 -29
  44. package/es/hive/stores/sorted-set.js +19 -94
  45. package/es/hive/utils.js +0 -2
  46. package/es/index.js +51 -71
  47. package/es/local-cache/index.js +0 -10
  48. package/es/local-cache/local-storage.js +1 -9
  49. package/es/local-cache/virtual-storage.js +0 -6
  50. package/es/logging/index.js +21 -46
  51. package/es/logging/logger.js +0 -6
  52. package/es/management/data.js +0 -8
  53. package/es/management/index.js +3 -7
  54. package/es/messaging/channel/index.js +0 -27
  55. package/es/messaging/helpers/body-parts.js +3 -6
  56. package/es/messaging/helpers/delivery-options.js +3 -6
  57. package/es/messaging/helpers/email-envelope.js +13 -25
  58. package/es/messaging/helpers/index.js +10 -16
  59. package/es/messaging/helpers/publish-options.js +3 -6
  60. package/es/messaging/index.js +213 -317
  61. package/es/persmission.js +7 -16
  62. package/es/request/index.js +2 -16
  63. package/es/rso/connection.js +3 -34
  64. package/es/rso/index.js +0 -7
  65. package/es/rt.js +21 -52
  66. package/es/unit-of-work/constants.js +1 -1
  67. package/es/unit-of-work/index.js +27 -145
  68. package/es/unit-of-work/json-adapter.js +14 -35
  69. package/es/unit-of-work/op-result-value-reference.js +1 -11
  70. package/es/unit-of-work/op-result.js +2 -13
  71. package/es/urls.js +18 -15
  72. package/es/user-agent.js +0 -7
  73. package/es/users/index.js +345 -552
  74. package/es/users/roles.js +79 -128
  75. package/es/users/social/container.js +0 -16
  76. package/es/users/social/index.js +166 -250
  77. package/es/users/user.js +2 -9
  78. package/es/users/utils.js +0 -3
  79. package/es/utils.js +0 -17
  80. package/lib/bl/constants.js +0 -2
  81. package/lib/bl/custom-services.js +40 -65
  82. package/lib/bl/events.js +30 -52
  83. package/lib/bl/index.js +3 -9
  84. package/lib/cache/index.js +125 -189
  85. package/lib/commerce/index.js +78 -119
  86. package/lib/counters/counter.js +0 -8
  87. package/lib/counters/index.js +171 -258
  88. package/lib/data/data-query-builder.js +2 -39
  89. package/lib/data/geo/geo-constructor.js +5 -26
  90. package/lib/data/geo/geo-json-parser.js +0 -7
  91. package/lib/data/geo/geometry.js +4 -13
  92. package/lib/data/geo/linestring.js +4 -21
  93. package/lib/data/geo/point.js +4 -22
  94. package/lib/data/geo/polygon.js +4 -30
  95. package/lib/data/geo/spatial-reference-system.js +1 -7
  96. package/lib/data/geo/wkt-parser.js +0 -10
  97. package/lib/data/geo/wkt-to-geojson.js +4 -44
  98. package/lib/data/group-query-builder.js +0 -23
  99. package/lib/data/index.js +17 -54
  100. package/lib/data/json-update-builder.js +0 -18
  101. package/lib/data/load-relations-query-builder.js +0 -16
  102. package/lib/data/persmission.js +0 -16
  103. package/lib/data/rt-handlers.js +1 -46
  104. package/lib/data/store.js +316 -518
  105. package/lib/decorators/deprecated.js +2 -5
  106. package/lib/decorators/index.js +0 -2
  107. package/lib/device/index.js +3 -8
  108. package/lib/expression.js +29 -0
  109. package/lib/files/index.js +354 -493
  110. package/lib/files/persmission.js +0 -15
  111. package/lib/files/utils.js +32 -55
  112. package/lib/hive/index.js +1 -13
  113. package/lib/hive/stores/base-store.js +14 -50
  114. package/lib/hive/stores/index.js +0 -10
  115. package/lib/hive/stores/key-value.js +4 -37
  116. package/lib/hive/stores/list.js +0 -32
  117. package/lib/hive/stores/map.js +0 -34
  118. package/lib/hive/stores/set.js +0 -29
  119. package/lib/hive/stores/sorted-set.js +19 -94
  120. package/lib/hive/utils.js +0 -2
  121. package/lib/index.js +51 -71
  122. package/lib/local-cache/index.js +0 -10
  123. package/lib/local-cache/local-storage.js +1 -9
  124. package/lib/local-cache/virtual-storage.js +0 -6
  125. package/lib/logging/index.js +21 -46
  126. package/lib/logging/logger.js +0 -6
  127. package/lib/management/data.js +0 -8
  128. package/lib/management/index.js +3 -7
  129. package/lib/messaging/channel/index.js +0 -27
  130. package/lib/messaging/helpers/body-parts.js +3 -6
  131. package/lib/messaging/helpers/delivery-options.js +3 -6
  132. package/lib/messaging/helpers/email-envelope.js +13 -25
  133. package/lib/messaging/helpers/index.js +10 -16
  134. package/lib/messaging/helpers/publish-options.js +3 -6
  135. package/lib/messaging/index.js +213 -317
  136. package/lib/persmission.js +7 -16
  137. package/lib/request/index.js +2 -16
  138. package/lib/rso/connection.js +3 -34
  139. package/lib/rso/index.js +0 -7
  140. package/lib/rt.js +21 -52
  141. package/lib/unit-of-work/constants.js +1 -1
  142. package/lib/unit-of-work/index.js +27 -145
  143. package/lib/unit-of-work/json-adapter.js +14 -35
  144. package/lib/unit-of-work/op-result-value-reference.js +1 -11
  145. package/lib/unit-of-work/op-result.js +2 -13
  146. package/lib/urls.js +18 -15
  147. package/lib/user-agent.js +0 -7
  148. package/lib/users/index.js +345 -552
  149. package/lib/users/roles.js +79 -128
  150. package/lib/users/social/container.js +0 -16
  151. package/lib/users/social/index.js +166 -250
  152. package/lib/users/user.js +2 -9
  153. package/lib/users/utils.js +0 -3
  154. package/lib/utils.js +0 -17
  155. package/package.json +16 -16
  156. package/src/data/store.js +3 -1
  157. package/src/expression.js +16 -0
  158. package/src/files/utils.js +1 -1
  159. package/src/index.js +5 -0
@@ -1,76 +1,62 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.OperationJSONAdapter = void 0;
9
-
10
8
  var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
11
-
12
9
  var _constants = require("./constants");
13
-
14
10
  var _opResult = require("./op-result");
15
-
16
11
  function resolveOpResultValueReference(uow, value) {
17
12
  if (Array.isArray(value)) {
18
13
  return value.map(function (item) {
19
14
  return resolveOpResultValueReference(uow, item);
20
15
  });
21
16
  }
22
-
23
17
  if (value && (0, _typeof2["default"])(value) === 'object') {
24
18
  if (value.___ref) {
25
19
  var opResult = uow.getOpResultById(value.opResultId);
26
-
27
20
  if (value.resultIndex !== undefined) {
28
21
  return opResult.resolveTo(value.resultIndex, value.propName);
29
22
  }
30
-
31
23
  if (value.propName !== undefined) {
32
24
  return opResult.resolveTo(value.propName);
33
25
  }
34
-
35
26
  return opResult;
36
27
  }
37
-
38
28
  var result = {};
39
-
40
29
  for (var prop in value) {
41
30
  result[prop] = resolveOpResultValueReference(uow, value[prop]);
42
31
  }
43
-
44
32
  return result;
45
33
  }
46
-
47
34
  return value;
48
35
  }
49
-
50
36
  var OperationJSONAdapter = {
51
37
  CREATE: function CREATE(uow, _ref) {
52
38
  var table = _ref.table,
53
- payload = _ref.payload;
39
+ payload = _ref.payload;
54
40
  return uow.create.call(uow, table, resolveOpResultValueReference(uow, payload));
55
41
  },
56
42
  DELETE: function DELETE(uow, _ref2) {
57
43
  var table = _ref2.table,
58
- payload = _ref2.payload;
44
+ payload = _ref2.payload;
59
45
  return uow["delete"].call(uow, table, resolveOpResultValueReference(uow, payload));
60
46
  },
61
47
  UPDATE: function UPDATE(uow, _ref3) {
62
48
  var table = _ref3.table,
63
- payload = _ref3.payload;
49
+ payload = _ref3.payload;
64
50
  return uow.update.call(uow, table, resolveOpResultValueReference(uow, payload));
65
51
  },
66
52
  UPSERT: function UPSERT(uow, _ref4) {
67
53
  var table = _ref4.table,
68
- payload = _ref4.payload;
54
+ payload = _ref4.payload;
69
55
  return uow.upsert.call(uow, table, resolveOpResultValueReference(uow, payload));
70
56
  },
71
57
  UPDATE_BULK: function UPDATE_BULK(uow, _ref5) {
72
58
  var table = _ref5.table,
73
- payload = _ref5.payload;
59
+ payload = _ref5.payload;
74
60
  var args = baseBulkArgs(uow, {
75
61
  table: table,
76
62
  payload: payload
@@ -80,7 +66,7 @@ var OperationJSONAdapter = {
80
66
  },
81
67
  DELETE_BULK: function DELETE_BULK(uow, _ref6) {
82
68
  var table = _ref6.table,
83
- payload = _ref6.payload;
69
+ payload = _ref6.payload;
84
70
  var args = baseBulkArgs(uow, {
85
71
  table: table,
86
72
  payload: payload
@@ -89,17 +75,17 @@ var OperationJSONAdapter = {
89
75
  },
90
76
  CREATE_BULK: function CREATE_BULK(uow, _ref7) {
91
77
  var table = _ref7.table,
92
- payload = _ref7.payload;
78
+ payload = _ref7.payload;
93
79
  return uow.bulkCreate.call(uow, table, resolveOpResultValueReference(uow, payload));
94
80
  },
95
81
  UPSERT_BULK: function UPSERT_BULK(uow, _ref8) {
96
82
  var table = _ref8.table,
97
- payload = _ref8.payload;
83
+ payload = _ref8.payload;
98
84
  return uow.bulkUpsert.call(uow, table, resolveOpResultValueReference(uow, payload));
99
85
  },
100
86
  SET_RELATION: function SET_RELATION(uow, _ref9) {
101
87
  var table = _ref9.table,
102
- payload = _ref9.payload;
88
+ payload = _ref9.payload;
103
89
  return updateRelations(uow, 'setRelation', {
104
90
  table: table,
105
91
  payload: payload
@@ -107,7 +93,7 @@ var OperationJSONAdapter = {
107
93
  },
108
94
  DELETE_RELATION: function DELETE_RELATION(uow, _ref10) {
109
95
  var table = _ref10.table,
110
- payload = _ref10.payload;
96
+ payload = _ref10.payload;
111
97
  return updateRelations(uow, 'deleteRelation', {
112
98
  table: table,
113
99
  payload: payload
@@ -115,7 +101,7 @@ var OperationJSONAdapter = {
115
101
  },
116
102
  ADD_RELATION: function ADD_RELATION(uow, _ref11) {
117
103
  var table = _ref11.table,
118
- payload = _ref11.payload;
104
+ payload = _ref11.payload;
119
105
  return updateRelations(uow, 'addToRelation', {
120
106
  table: table,
121
107
  payload: payload
@@ -123,23 +109,20 @@ var OperationJSONAdapter = {
123
109
  },
124
110
  FIND: function FIND(uow, _ref12) {
125
111
  var table = _ref12.table,
126
- payload = _ref12.payload;
112
+ payload = _ref12.payload;
127
113
  return uow.addOperations(_constants.OperationType.FIND, table, payload);
128
114
  }
129
115
  };
130
116
  exports.OperationJSONAdapter = OperationJSONAdapter;
131
-
132
117
  function baseBulkArgs(uow, _ref13) {
133
118
  var table = _ref13.table,
134
- payload = _ref13.payload;
119
+ payload = _ref13.payload;
135
120
  var args = [];
136
-
137
121
  if (payload.conditional) {
138
122
  args.push(table);
139
123
  args.push(payload.conditional);
140
124
  } else {
141
125
  var opRef = resolveOpResultValueReference(uow, payload.unconditional);
142
-
143
126
  if (opRef instanceof _opResult.OpResult) {
144
127
  args.push(opRef);
145
128
  } else {
@@ -147,15 +130,12 @@ function baseBulkArgs(uow, _ref13) {
147
130
  args.push(opRef);
148
131
  }
149
132
  }
150
-
151
133
  return args;
152
134
  }
153
-
154
135
  function updateRelations(uow, method, _ref14) {
155
136
  var table = _ref14.table,
156
- payload = _ref14.payload;
137
+ payload = _ref14.payload;
157
138
  var args = [table];
158
-
159
139
  if (typeof payload.parentObject === 'string') {
160
140
  args.push({
161
141
  objectId: payload.parentObject
@@ -163,7 +143,6 @@ function updateRelations(uow, method, _ref14) {
163
143
  } else {
164
144
  args.push(resolveOpResultValueReference(uow, payload.parentObject));
165
145
  }
166
-
167
146
  args.push(payload.relationColumn);
168
147
  args.push(payload.conditional || resolveOpResultValueReference(uow, payload.unconditional));
169
148
  return uow[method].apply(uow, args);
@@ -1,26 +1,21 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.OpResultValueReference = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
10
  var OpResultValueReference = /*#__PURE__*/function () {
15
11
  function OpResultValueReference(opResult, _ref) {
16
12
  var resultIndex = _ref.resultIndex,
17
- propName = _ref.propName;
13
+ propName = _ref.propName;
18
14
  (0, _classCallCheck2["default"])(this, OpResultValueReference);
19
15
  this.opResult = opResult;
20
16
  this.resultIndex = resultIndex;
21
17
  this.propName = propName;
22
18
  }
23
-
24
19
  (0, _createClass2["default"])(OpResultValueReference, [{
25
20
  key: "getTableName",
26
21
  value: function getTableName() {
@@ -30,23 +25,18 @@ var OpResultValueReference = /*#__PURE__*/function () {
30
25
  key: "toJSON",
31
26
  value: function toJSON() {
32
27
  var result = this.opResult.toJSON();
33
-
34
28
  if (this.resultIndex !== undefined) {
35
29
  result.resultIndex = this.resultIndex;
36
30
  }
37
-
38
31
  if (this.propName !== undefined) {
39
32
  result.propName = this.propName;
40
33
  }
41
-
42
34
  if (!result.propName && this.opResult.isFindRef()) {
43
35
  result.propName = 'objectId';
44
36
  }
45
-
46
37
  return result;
47
38
  }
48
39
  }]);
49
40
  return OpResultValueReference;
50
41
  }();
51
-
52
42
  exports.OpResultValueReference = OpResultValueReference;
@@ -1,25 +1,19 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.OpResult = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
10
  var _constants = require("./constants");
15
-
16
11
  var _opResultValueReference = require("./op-result-value-reference");
17
-
18
12
  var OpResult = /*#__PURE__*/function () {
19
13
  function OpResult(uow, _ref) {
20
14
  var operationType = _ref.operationType,
21
- table = _ref.table,
22
- payload = _ref.payload;
15
+ table = _ref.table,
16
+ payload = _ref.payload;
23
17
  (0, _classCallCheck2["default"])(this, OpResult);
24
18
  this.uow = uow;
25
19
  this.operationType = operationType;
@@ -30,7 +24,6 @@ var OpResult = /*#__PURE__*/function () {
30
24
  this.opResultId = "".concat(stackName).concat(resultIndex);
31
25
  this.result = null;
32
26
  }
33
-
34
27
  (0, _createClass2["default"])(OpResult, [{
35
28
  key: "setResult",
36
29
  value: function setResult(result) {
@@ -94,7 +87,6 @@ var OpResult = /*#__PURE__*/function () {
94
87
  propName = resultIndex;
95
88
  resultIndex = undefined;
96
89
  }
97
-
98
90
  return new _opResultValueReference.OpResultValueReference(this, {
99
91
  resultIndex: resultIndex,
100
92
  propName: propName
@@ -107,15 +99,12 @@ var OpResult = /*#__PURE__*/function () {
107
99
  ___ref: true,
108
100
  opResultId: this.opResultId
109
101
  };
110
-
111
102
  if (this.isObjectRef()) {
112
103
  result.propName = 'objectId';
113
104
  }
114
-
115
105
  return result;
116
106
  }
117
107
  }]);
118
108
  return OpResult;
119
109
  }();
120
-
121
110
  exports.OpResult = OpResult;
package/lib/urls.js CHANGED
@@ -1,28 +1,24 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports["default"] = void 0;
9
-
10
8
  var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
11
-
12
9
  var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
13
-
14
10
  var Urls = /*#__PURE__*/function () {
15
11
  function Urls(app) {
16
12
  (0, _classCallCheck2["default"])(this, Urls);
17
13
  this.app = app;
18
14
  }
19
-
20
15
  (0, _createClass2["default"])(Urls, [{
21
16
  key: "root",
22
17
  value: function root() {
23
18
  return this.app.appPath;
24
- } //bl
19
+ }
25
20
 
21
+ //bl
26
22
  }, {
27
23
  key: "blServices",
28
24
  value: function blServices() {
@@ -37,14 +33,16 @@ var Urls = /*#__PURE__*/function () {
37
33
  key: "blEvent",
38
34
  value: function blEvent(eventName) {
39
35
  return "".concat(this.root(), "/servercode/events/").concat(eventName);
40
- } //logging
36
+ }
41
37
 
38
+ //logging
42
39
  }, {
43
40
  key: "logging",
44
41
  value: function logging() {
45
42
  return "".concat(this.root(), "/log");
46
- } //cache
43
+ }
47
44
 
45
+ //cache
48
46
  }, {
49
47
  key: "cache",
50
48
  value: function cache() {
@@ -69,8 +67,9 @@ var Urls = /*#__PURE__*/function () {
69
67
  key: "cacheItemCheck",
70
68
  value: function cacheItemCheck(key) {
71
69
  return "".concat(this.cacheItem(key), "/check");
72
- } //counters
70
+ }
73
71
 
72
+ //counters
74
73
  }, {
75
74
  key: "counters",
76
75
  value: function counters() {
@@ -125,8 +124,9 @@ var Urls = /*#__PURE__*/function () {
125
124
  key: "counterReset",
126
125
  value: function counterReset(name) {
127
126
  return "".concat(this.counter(name), "/reset");
128
- } //data
127
+ }
129
128
 
129
+ //data
130
130
  }, {
131
131
  key: "data",
132
132
  value: function data() {
@@ -281,8 +281,9 @@ var Urls = /*#__PURE__*/function () {
281
281
  key: "emailTemplateSend",
282
282
  value: function emailTemplateSend() {
283
283
  return "".concat(this.emailTemplate(), "/send");
284
- } //commerce
284
+ }
285
285
 
286
+ //commerce
286
287
  }, {
287
288
  key: "commerce",
288
289
  value: function commerce() {
@@ -302,8 +303,9 @@ var Urls = /*#__PURE__*/function () {
302
303
  key: "commerceSubStatus",
303
304
  value: function commerceSubStatus(name, subId, token) {
304
305
  return "".concat(this.commerce(), "/").concat(name, "/subscription/").concat(subId, "/purchases/").concat(token);
305
- } //files
306
+ }
306
307
 
308
+ //files
307
309
  }, {
308
310
  key: "files",
309
311
  value: function files() {
@@ -358,8 +360,9 @@ var Urls = /*#__PURE__*/function () {
358
360
  key: "fileAppendBinaryPath",
359
361
  value: function fileAppendBinaryPath(path) {
360
362
  return "".concat(this.files(), "/append/binary/").concat(path);
361
- } //users
363
+ }
362
364
 
365
+ //users
363
366
  }, {
364
367
  key: "users",
365
368
  value: function users() {
@@ -464,8 +467,9 @@ var Urls = /*#__PURE__*/function () {
464
467
  key: "userStatus",
465
468
  value: function userStatus(userId) {
466
469
  return "".concat(this.userObject(userId), "/status");
467
- } //management
470
+ }
468
471
 
472
+ //management
469
473
  }, {
470
474
  key: "management",
471
475
  value: function management() {
@@ -484,5 +488,4 @@ var Urls = /*#__PURE__*/function () {
484
488
  }]);
485
489
  return Urls;
486
490
  }();
487
-
488
491
  exports["default"] = Urls;
package/lib/user-agent.js CHANGED
@@ -1,32 +1,25 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
4
  Object.defineProperty(exports, "__esModule", {
6
5
  value: true
7
6
  });
8
7
  exports.getUserAgent = getUserAgent;
9
-
10
8
  var _utils = _interopRequireDefault(require("./utils"));
11
-
12
9
  function getUserAgent() {
13
10
  var ua = 'NodeJS';
14
-
15
11
  if (_utils["default"].isBrowser) {
16
12
  ua = navigator.userAgent ? navigator.userAgent.toLowerCase() : 'hybrid-app';
17
13
  }
18
-
19
14
  var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || /(webkit)[ \/]([\w.]+)/.exec(ua) || /(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || /(msie) ([\w.]+)/.exec(ua) || ua.indexOf('compatible') < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || [];
20
15
  var matched = {
21
16
  browser: match[1] || '',
22
17
  version: match[2] || '0'
23
18
  };
24
19
  var browser = {};
25
-
26
20
  if (matched.browser) {
27
21
  browser[matched.browser] = true;
28
22
  browser.version = matched.version;
29
23
  }
30
-
31
24
  return browser;
32
25
  }