@almatar/branding 0.2.0 → 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.
- package/lib/index.d.ts +6 -0
- package/lib/index.js +14 -5
- package/lib/lib/AlmatarBranding.js +6 -9
- package/lib/lib/BrandIdentifier.d.ts +2 -2
- package/lib/lib/BrandIdentifier.js +72 -88
- package/lib/lib/BrandManager.d.ts +5 -0
- package/lib/lib/BrandManager.js +178 -127
- package/lib/lib/Models/BrandModel.js +3 -4
- package/lib/lib/Models/EmployeeBrandModel.js +3 -4
- package/lib/lib/Storage.js +78 -151
- package/lib/lib/TenantModel/Mongoose/MultiTenant.js +13 -17
- package/lib/lib/TenantModel/MongooseModel.js +56 -39
- package/lib/lib/TenantModel/NestMongoose/TenantMongooseModule.js +12 -33
- package/lib/lib/TenantModel/NestMongoose/mongoose.providers.d.ts +0 -24
- package/lib/lib/TenantModel/NestMongoose/mongoose.providers.js +8 -9
- package/lib/lib/TenantModel/TypeORM/TenantEntitySubscriber.d.ts +27 -0
- package/lib/lib/TenantModel/TypeORM/TenantEntitySubscriber.js +68 -0
- package/lib/lib/TenantModel/TypeORM/TenantHttpInterceptor.d.ts +26 -0
- package/lib/lib/TenantModel/TypeORM/TenantHttpInterceptor.js +92 -0
- package/lib/lib/TenantModel/TypeORM/TenantRepository.d.ts +58 -0
- package/lib/lib/TenantModel/TypeORM/TenantRepository.js +281 -0
- package/lib/lib/request/PromiseRequest.js +37 -56
- package/lib/lib/request/TenantRequest.d.ts +4 -1
- package/lib/lib/request/TenantRequest.js +38 -68
- package/package.json +31 -25
|
@@ -1,73 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
4
|
};
|
|
38
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
6
|
+
const Storage_1 = __importDefault(require("../Storage"));
|
|
7
|
+
class TenantRequest {
|
|
8
|
+
static async request(options) {
|
|
9
|
+
var _a, _b, _c;
|
|
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
|
+
}
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
46
|
-
var brand, employeeBrands;
|
|
47
|
-
return __generator(this, function (_a) {
|
|
48
|
-
switch (_a.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
brand = Storage_1.default.getBrand();
|
|
51
|
-
employeeBrands = Storage_1.default.getEmployeeBrands();
|
|
52
|
-
if (!options.reqObject.headers) {
|
|
53
|
-
options.reqObject.headers = {};
|
|
54
|
-
}
|
|
55
|
-
options.reqObject.headers['Content-Type'] = 'application/json';
|
|
56
|
-
options.reqObject.headers['x-brand'] = brand;
|
|
57
|
-
// tslint:disable-next-line:no-unused-expression
|
|
58
|
-
employeeBrands ? (options.reqObject.headers['x-employee-brands'] = employeeBrands.join(',')) : null;
|
|
59
|
-
return [4 /*yield*/, (0, node_fetch_1.default)(options.url, options.reqObject)
|
|
60
|
-
.then(function (res) {
|
|
61
|
-
return res.json();
|
|
62
|
-
})
|
|
63
|
-
.catch(function (e) {
|
|
64
|
-
return null;
|
|
65
|
-
})];
|
|
66
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
return TenantRequest;
|
|
72
|
-
}());
|
|
42
|
+
}
|
|
73
43
|
exports.default = TenantRequest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@almatar/branding",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -8,12 +8,14 @@
|
|
|
8
8
|
"lib/**/*"
|
|
9
9
|
],
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "
|
|
11
|
+
"build": "node scripts/build.js",
|
|
12
12
|
"format": "prettier --write \"src/**/*.ts\" \"src/**/*.js\"",
|
|
13
13
|
"lint": "tslint -p tsconfig.json",
|
|
14
14
|
"test": "jest --config jestconfig.json",
|
|
15
15
|
"prepare": "npm run build",
|
|
16
16
|
"prepublishOnly": "npm test && npm run lint",
|
|
17
|
+
"publish:beta": "npm publish --tag beta",
|
|
18
|
+
"publish:latest": "npm publish --tag latest",
|
|
17
19
|
"preversion": "npm run lint",
|
|
18
20
|
"version": "npm run format && git add -A && git commit -m \"Setup Package\"",
|
|
19
21
|
"postversion": "git push && git push --tags"
|
|
@@ -22,35 +24,39 @@
|
|
|
22
24
|
"lint"
|
|
23
25
|
],
|
|
24
26
|
"dependencies": {
|
|
25
|
-
"@hapi/boom": "^
|
|
26
|
-
"@nestjs/common": "^
|
|
27
|
-
"@nestjs/core": "^
|
|
28
|
-
"@nestjs/mongoose": "^
|
|
29
|
-
"@types/mongoose": "^5.
|
|
30
|
-
"@types/request": "^2.48.
|
|
27
|
+
"@hapi/boom": "^8.0.1",
|
|
28
|
+
"@nestjs/common": "^6.8.2",
|
|
29
|
+
"@nestjs/core": "^6.8.2",
|
|
30
|
+
"@nestjs/mongoose": "^6.1.2",
|
|
31
|
+
"@types/mongoose": "^5.5.19",
|
|
32
|
+
"@types/request": "^2.48.3",
|
|
31
33
|
"cls-hooked": "^4.2.2",
|
|
32
|
-
"mongoose": "^
|
|
33
|
-
"node-fetch": "^
|
|
34
|
-
"reflect-metadata": "^0.
|
|
34
|
+
"mongoose": "^5.7.3",
|
|
35
|
+
"node-fetch": "^2.6.1",
|
|
36
|
+
"reflect-metadata": "^0.1.13",
|
|
35
37
|
"request": "^2.88.0",
|
|
36
|
-
"rxjs": "^
|
|
38
|
+
"rxjs": "^6.5.3"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"typeorm": "^0.3.0",
|
|
42
|
+
"@nestjs/axios": "^4.0.0"
|
|
37
43
|
},
|
|
38
44
|
"author": "",
|
|
39
45
|
"license": "ISC",
|
|
40
46
|
"devDependencies": {
|
|
41
|
-
"@babel/core": "^7.
|
|
42
|
-
"@babel/preset-env": "^7.
|
|
43
|
-
"@babel/register": "^7.
|
|
44
|
-
"@types/jest": "^
|
|
45
|
-
"@types/node": "^
|
|
46
|
-
"@types/node-fetch": "^2.
|
|
47
|
-
"jest": "^
|
|
48
|
-
"npm-watch": "^0.
|
|
47
|
+
"@babel/core": "^7.5.5",
|
|
48
|
+
"@babel/preset-env": "^7.5.5",
|
|
49
|
+
"@babel/register": "^7.5.5",
|
|
50
|
+
"@types/jest": "^24.0.18",
|
|
51
|
+
"@types/node": "^12.7.5",
|
|
52
|
+
"@types/node-fetch": "^2.5.10",
|
|
53
|
+
"jest": "^24.9.0",
|
|
54
|
+
"npm-watch": "^0.6.0",
|
|
49
55
|
"pre-commit": "^1.2.2",
|
|
50
|
-
"prettier": "^
|
|
51
|
-
"ts-jest": "^
|
|
52
|
-
"tslint": "^5.20.
|
|
56
|
+
"prettier": "^1.18.2",
|
|
57
|
+
"ts-jest": "^24.1.0",
|
|
58
|
+
"tslint": "^5.20.0",
|
|
53
59
|
"tslint-config-prettier": "^1.18.0",
|
|
54
|
-
"typescript": "^
|
|
60
|
+
"typescript": "^3.6.3"
|
|
55
61
|
}
|
|
56
|
-
}
|
|
62
|
+
}
|