backendless 7.1.0 → 7.2.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/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  # Welcome to Backendless!
2
2
 
3
+ [![Check](https://github.com/Backendless/JS-SDK/actions/workflows/main.yml/badge.svg)](https://github.com/Backendless/JS-SDK/actions/workflows/main.yml)
3
4
  [![Build Status](https://travis-ci.com/Backendless/JS-SDK.svg?branch=master)](https://travis-ci.com/Backendless/JS-SDK)
4
5
  [![npm version](https://img.shields.io/npm/v/backendless.svg?style=flat)](https://www.npmjs.com/package/backendless)
5
6
  [![dependencies Status](https://david-dm.org/backendless/JS-SDK/status.svg)](https://david-dm.org/backendless/JS-SDK)
package/backendless.d.ts CHANGED
@@ -599,6 +599,20 @@ declare module Backendless {
599
599
  }
600
600
  }
601
601
 
602
+ /**
603
+ * @public
604
+ * @namespace Backendless.Automations
605
+ */
606
+ namespace Automations {
607
+ /**
608
+ * @public
609
+ * @type: Function
610
+ */
611
+
612
+ function activateFlow(flowName: string, initialData?: object): Promise<void>
613
+ function activateFlowTrigger(flowName: string, triggerName: string, data?: object): Promise<void>
614
+ }
615
+
602
616
  /**
603
617
  * @public
604
618
  * @namespace Backendless.UserService
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  * ********************************************************************************************************************
3
- * Backendless SDK for JavaScript. Version: 7.1.0
3
+ * Backendless SDK for JavaScript. Version: 7.2.1
4
4
  *
5
5
  * Copyright 2012-2023 BACKENDLESS.COM. All Rights Reserved.
6
6
  *
@@ -24,6 +24,118 @@
24
24
  return /******/ (() => { // webpackBootstrap
25
25
  /******/ var __webpack_modules__ = ({
26
26
 
27
+ /***/ "./src/automations/index.js":
28
+ /*!**********************************!*\
29
+ !*** ./src/automations/index.js ***!
30
+ \**********************************/
31
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
32
+
33
+ "use strict";
34
+
35
+
36
+ var _interopRequireDefault = __webpack_require__(/*! @babel/runtime/helpers/interopRequireDefault */ "./node_modules/@babel/runtime/helpers/interopRequireDefault.js");
37
+ Object.defineProperty(exports, "__esModule", ({
38
+ value: true
39
+ }));
40
+ exports["default"] = void 0;
41
+ var _regenerator = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/regenerator */ "./node_modules/@babel/runtime/regenerator/index.js"));
42
+ var _asyncToGenerator2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/asyncToGenerator */ "./node_modules/@babel/runtime/helpers/asyncToGenerator.js"));
43
+ var _classCallCheck2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/classCallCheck */ "./node_modules/@babel/runtime/helpers/classCallCheck.js"));
44
+ var _createClass2 = _interopRequireDefault(__webpack_require__(/*! @babel/runtime/helpers/createClass */ "./node_modules/@babel/runtime/helpers/createClass.js"));
45
+ var _utils = _interopRequireDefault(__webpack_require__(/*! ../utils */ "./src/utils.js"));
46
+ var Automations = /*#__PURE__*/function () {
47
+ function Automations(app) {
48
+ (0, _classCallCheck2["default"])(this, Automations);
49
+ this.app = app;
50
+ }
51
+ (0, _createClass2["default"])(Automations, [{
52
+ key: "activateFlow",
53
+ value: function () {
54
+ var _activateFlow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(flowName, initialData) {
55
+ return _regenerator["default"].wrap(function _callee$(_context) {
56
+ while (1) switch (_context.prev = _context.next) {
57
+ case 0:
58
+ if (!(!flowName || typeof flowName !== 'string')) {
59
+ _context.next = 2;
60
+ break;
61
+ }
62
+ throw new Error('The "flowName" argument must be provided and must be a string.');
63
+ case 2:
64
+ if (!(initialData !== undefined && !_utils["default"].isObject(initialData))) {
65
+ _context.next = 4;
66
+ break;
67
+ }
68
+ throw new Error('The "initialData" argument must be an object with an arbitrary structure.');
69
+ case 4:
70
+ return _context.abrupt("return", this.app.request.post({
71
+ url: "".concat(this.app.urls.automationFlow(), "/activate-by-name"),
72
+ data: {
73
+ name: flowName,
74
+ initialData: initialData
75
+ }
76
+ }));
77
+ case 5:
78
+ case "end":
79
+ return _context.stop();
80
+ }
81
+ }, _callee, this);
82
+ }));
83
+ function activateFlow(_x, _x2) {
84
+ return _activateFlow.apply(this, arguments);
85
+ }
86
+ return activateFlow;
87
+ }()
88
+ }, {
89
+ key: "activateFlowTrigger",
90
+ value: function () {
91
+ var _activateFlowTrigger = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(flowName, triggerName, data) {
92
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
93
+ while (1) switch (_context2.prev = _context2.next) {
94
+ case 0:
95
+ if (!(!flowName || typeof flowName !== 'string')) {
96
+ _context2.next = 2;
97
+ break;
98
+ }
99
+ throw new Error('The "flowName" argument must be provided and must be a string.');
100
+ case 2:
101
+ if (!(!triggerName || typeof triggerName !== 'string')) {
102
+ _context2.next = 4;
103
+ break;
104
+ }
105
+ throw new Error('The "triggerName" argument must be provided and must be a string.');
106
+ case 4:
107
+ if (!(data !== undefined && !_utils["default"].isObject(data))) {
108
+ _context2.next = 6;
109
+ break;
110
+ }
111
+ throw new Error('The "data" argument must be an object with an arbitrary structure.');
112
+ case 6:
113
+ return _context2.abrupt("return", this.app.request.post({
114
+ url: "".concat(this.app.urls.automationFlowTrigger(), "/activate-by-name"),
115
+ query: {
116
+ flowName: flowName,
117
+ triggerName: triggerName
118
+ },
119
+ data: data
120
+ }));
121
+ case 7:
122
+ case "end":
123
+ return _context2.stop();
124
+ }
125
+ }, _callee2, this);
126
+ }));
127
+ function activateFlowTrigger(_x3, _x4, _x5) {
128
+ return _activateFlowTrigger.apply(this, arguments);
129
+ }
130
+ return activateFlowTrigger;
131
+ }()
132
+ }]);
133
+ return Automations;
134
+ }();
135
+ exports["default"] = Automations;
136
+
137
+ /***/ }),
138
+
27
139
  /***/ "./src/bl/constants.js":
28
140
  /*!*****************************!*\
29
141
  !*** ./src/bl/constants.js ***!
@@ -6387,6 +6499,9 @@ var SERVICES = {
6387
6499
  },
6388
6500
  'Management': function Management() {
6389
6501
  return (__webpack_require__(/*! ./management */ "./src/management/index.js")["default"]);
6502
+ },
6503
+ 'Automations': function Automations() {
6504
+ return (__webpack_require__(/*! ./automations */ "./src/automations/index.js")["default"]);
6390
6505
  }
6391
6506
  };
6392
6507
  var Backendless = /*#__PURE__*/function () {
@@ -6437,7 +6552,7 @@ var Backendless = /*#__PURE__*/function () {
6437
6552
  app.__removeService('LocalCache');
6438
6553
  var loggingConfig = (0, _extends2["default"])({
6439
6554
  loadLevels: true,
6440
- defaultLevel: 'all',
6555
+ globalLevel: 'all',
6441
6556
  levels: {}
6442
6557
  }, config.logging);
6443
6558
  if (app.__hasService('Logging')) {
@@ -6728,6 +6843,11 @@ var Backendless = /*#__PURE__*/function () {
6728
6843
  get: function get() {
6729
6844
  return this.__getService('Management');
6730
6845
  }
6846
+ }, {
6847
+ key: "Automations",
6848
+ get: function get() {
6849
+ return this.__getService('Automations');
6850
+ }
6731
6851
 
6732
6852
  ///-------------- SERVICES -------------///
6733
6853
  ///-------------------------------------///
@@ -7056,8 +7176,8 @@ var Logging = /*#__PURE__*/function () {
7056
7176
  if (config.levels) {
7057
7177
  this.levels = config.levels;
7058
7178
  }
7059
- if (config.defaultLevel) {
7060
- this.defaultLevel = config.defaultLevel;
7179
+ if (config.globalLevel) {
7180
+ this.globalLevel = config.globalLevel;
7061
7181
  }
7062
7182
  if (config.loadLevels) {
7063
7183
  this.loadLoggingLevels();
@@ -7067,7 +7187,7 @@ var Logging = /*#__PURE__*/function () {
7067
7187
  key: "reset",
7068
7188
  value: function reset() {
7069
7189
  this.levels = {};
7070
- this.defaultLevel = 'all';
7190
+ this.globalLevel = 'all';
7071
7191
  this.loggers = {};
7072
7192
  this.messages = [];
7073
7193
  this.numOfMessages = 10;
@@ -7080,11 +7200,16 @@ var Logging = /*#__PURE__*/function () {
7080
7200
  var _this = this;
7081
7201
  this.app.request.get({
7082
7202
  url: this.app.urls.loggingLevels()
7083
- }).then(function (loggers) {
7084
- loggers.forEach(function (logger) {
7085
- _this.levels[logger.name] = logger.level;
7203
+ }).then(function (loggersList) {
7204
+ var loggers = {};
7205
+ loggersList.forEach(function (logger) {
7206
+ loggers[logger.name] = logger.level;
7207
+ });
7208
+ var globalLevel = loggers[GLOBAL_LOGGER_NAME];
7209
+ _this.setConfig({
7210
+ loggers: loggers,
7211
+ globalLevel: globalLevel
7086
7212
  });
7087
- _this.defaultLevel = _this.levels[GLOBAL_LOGGER_NAME] || _this.defaultLevel;
7088
7213
  })["catch"](function (error) {
7089
7214
  // eslint-disable-next-line no-console
7090
7215
  console.error('Could not load logging levels: ', error);
@@ -7290,8 +7415,16 @@ var Logger = /*#__PURE__*/function () {
7290
7415
  }, {
7291
7416
  key: "min",
7292
7417
  value: function min(level) {
7293
- var configuredLevel = this.logging.levels[this.name] || this.logging.defaultLevel;
7294
- return LogLevelPriorities[configuredLevel.toLowerCase()] >= LogLevelPriorities[level.toLowerCase()];
7418
+ level = level.toLowerCase();
7419
+ var globalLevel = this.logging.globalLevel;
7420
+ var loggerLevel = this.logging.levels[this.name];
7421
+ if (globalLevel && LogLevelPriorities[globalLevel.toLowerCase()] < LogLevelPriorities[level]) {
7422
+ return false;
7423
+ }
7424
+ if (!loggerLevel) {
7425
+ return true;
7426
+ }
7427
+ return LogLevelPriorities[loggerLevel.toLowerCase()] >= LogLevelPriorities[level];
7295
7428
  }
7296
7429
  }]);
7297
7430
  return Logger;
@@ -10061,6 +10194,23 @@ var Urls = /*#__PURE__*/function () {
10061
10194
  return this.app.appPath;
10062
10195
  }
10063
10196
 
10197
+ //automations
10198
+ }, {
10199
+ key: "automation",
10200
+ value: function automation() {
10201
+ return "".concat(this.root(), "/automation");
10202
+ }
10203
+ }, {
10204
+ key: "automationFlow",
10205
+ value: function automationFlow() {
10206
+ return "".concat(this.automation(), "/flow");
10207
+ }
10208
+ }, {
10209
+ key: "automationFlowTrigger",
10210
+ value: function automationFlowTrigger() {
10211
+ return "".concat(this.automationFlow(), "/trigger");
10212
+ }
10213
+
10064
10214
  //bl
10065
10215
  }, {
10066
10216
  key: "blServices",