@almatar/branding 1.0.0-beta.2 → 1.0.0-beta.3

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.
@@ -1,105 +1,43 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
4
  };
52
5
  Object.defineProperty(exports, "__esModule", { value: true });
53
- var Storage_1 = __importDefault(require("../Storage"));
54
- var TenantRequest = /** @class */ (function () {
55
- function TenantRequest() {
56
- }
57
- TenantRequest.request = function (options) {
6
+ const Storage_1 = __importDefault(require("../Storage"));
7
+ class TenantRequest {
8
+ static async request(options) {
58
9
  var _a, _b, _c;
59
- return __awaiter(this, void 0, void 0, function () {
60
- var brand, employeeBrands, headers, fetchOptions, response, data, e_1;
61
- return __generator(this, function (_d) {
62
- switch (_d.label) {
63
- case 0:
64
- _d.trys.push([0, 3, , 4]);
65
- brand = Storage_1.default.getBrand();
66
- employeeBrands = Storage_1.default.getEmployeeBrands();
67
- headers = __assign({ 'Content-Type': 'application/json' }, (((_a = options.reqObject) === null || _a === void 0 ? void 0 : _a.headers) || {}));
68
- if (brand) {
69
- headers['x-brand'] = brand;
70
- }
71
- if (employeeBrands && employeeBrands.length > 0) {
72
- headers['x-employee-brands'] = employeeBrands.join(',');
73
- }
74
- fetchOptions = {
75
- method: ((_b = options.reqObject) === null || _b === void 0 ? void 0 : _b.method) || 'GET',
76
- headers: headers,
77
- };
78
- if ((_c = options.reqObject) === null || _c === void 0 ? void 0 : _c.body) {
79
- fetchOptions.body = typeof options.reqObject.body === 'string'
80
- ? options.reqObject.body
81
- : JSON.stringify(options.reqObject.body);
82
- }
83
- return [4 /*yield*/, fetch(options.url, fetchOptions)];
84
- case 1:
85
- response = _d.sent();
86
- return [4 /*yield*/, response.json()];
87
- case 2:
88
- data = _d.sent();
89
- return [2 /*return*/, {
90
- status: response.status,
91
- data: data,
92
- }];
93
- case 3:
94
- e_1 = _d.sent();
95
- // tslint:disable-next-line no-console
96
- console.log('[TenantRequest] Request error:', e_1);
97
- return [2 /*return*/, null];
98
- case 4: return [2 /*return*/];
99
- }
100
- });
101
- });
102
- };
103
- return TenantRequest;
104
- }());
10
+ try {
11
+ const brand = Storage_1.default.getBrand();
12
+ const employeeBrands = Storage_1.default.getEmployeeBrands();
13
+ const headers = Object.assign({ 'Content-Type': 'application/json' }, (((_a = options.reqObject) === null || _a === void 0 ? void 0 : _a.headers) || {}));
14
+ if (brand) {
15
+ headers['x-brand'] = brand;
16
+ }
17
+ if (employeeBrands && employeeBrands.length > 0) {
18
+ headers['x-employee-brands'] = employeeBrands.join(',');
19
+ }
20
+ const fetchOptions = {
21
+ method: ((_b = options.reqObject) === null || _b === void 0 ? void 0 : _b.method) || 'GET',
22
+ headers,
23
+ };
24
+ if ((_c = options.reqObject) === null || _c === void 0 ? void 0 : _c.body) {
25
+ fetchOptions.body = typeof options.reqObject.body === 'string'
26
+ ? options.reqObject.body
27
+ : JSON.stringify(options.reqObject.body);
28
+ }
29
+ const response = await fetch(options.url, fetchOptions);
30
+ const data = await response.json();
31
+ return {
32
+ status: response.status,
33
+ data,
34
+ };
35
+ }
36
+ catch (e) {
37
+ // tslint:disable-next-line no-console
38
+ console.log('[TenantRequest] Request error:', e);
39
+ return null;
40
+ }
41
+ }
42
+ }
105
43
  exports.default = TenantRequest;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@almatar/branding",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -37,6 +37,10 @@
37
37
  "request": "^2.88.0",
38
38
  "rxjs": "^6.5.3"
39
39
  },
40
+ "peerDependencies": {
41
+ "typeorm": "^0.3.0",
42
+ "@nestjs/axios": "^4.0.0"
43
+ },
40
44
  "author": "",
41
45
  "license": "ISC",
42
46
  "devDependencies": {