@sourceloop/ctrl-plane-tenant-management-service
Version:
Tenant Management microservice for SaaS control plane
111 lines • 3.98 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tenant = void 0;
const tslib_1 = require("tslib");
const repository_1 = require("@loopback/repository");
const core_1 = require("@sourceloop/core");
const enums_1 = require("../enums");
const utils_1 = require("../utils");
const contact_model_1 = require("./contact.model");
const lead_model_1 = require("./lead.model");
const resource_model_1 = require("./resource.model");
const address_model_1 = require("./address.model");
let Tenant = class Tenant extends core_1.UserModifiableEntity {
constructor(data) {
super(data);
}
};
exports.Tenant = Tenant;
tslib_1.__decorate([
(0, repository_1.property)({
type: 'string',
id: true,
generated: true,
}),
tslib_1.__metadata("design:type", String)
], Tenant.prototype, "id", void 0);
tslib_1.__decorate([
(0, repository_1.property)({
type: 'string',
description: 'name of the tenant',
required: true,
}),
tslib_1.__metadata("design:type", String)
], Tenant.prototype, "name", void 0);
tslib_1.__decorate([
(0, repository_1.property)({
type: 'number',
description: 'status of a tenant, it can be - 0(active), 1(provisioning),2(deprovisioning),3(inactive)',
required: true,
jsonSchema: {
enum: (0, utils_1.numericEnumValues)(enums_1.TenantStatus),
},
}),
tslib_1.__metadata("design:type", Number)
], Tenant.prototype, "status", void 0);
tslib_1.__decorate([
(0, repository_1.property)({
type: 'string',
description: 'a short string used to identify a tenant. This is also used as the namespace and subdomain for this particular tenant',
required: true,
jsonSchema: {
pattern: '^[a-z0-9]+$',
maxLength: 10,
},
}),
tslib_1.__metadata("design:type", String)
], Tenant.prototype, "key", void 0);
tslib_1.__decorate([
(0, repository_1.property)({
name: 'spoc_user_id',
description: 'user id of the admin user who acts as a spoc for this tenant.',
type: 'string',
}),
tslib_1.__metadata("design:type", String)
], Tenant.prototype, "spocUserId", void 0);
tslib_1.__decorate([
(0, repository_1.property)({
type: 'array',
itemType: 'string',
description: 'array of domains that are allowed for this tenant',
postgresql: {
dataType: 'varchar[]',
},
required: true,
}),
tslib_1.__metadata("design:type", Array)
], Tenant.prototype, "domains", void 0);
tslib_1.__decorate([
(0, repository_1.hasMany)(() => contact_model_1.Contact, {
keyTo: 'tenantId',
}),
tslib_1.__metadata("design:type", Array)
], Tenant.prototype, "contacts", void 0);
tslib_1.__decorate([
(0, repository_1.hasMany)(() => resource_model_1.Resource, {
keyTo: 'tenantId',
}),
tslib_1.__metadata("design:type", Array)
], Tenant.prototype, "resources", void 0);
tslib_1.__decorate([
(0, repository_1.belongsTo)(() => lead_model_1.Lead, undefined, {
description: 'id of the lead from which this tenant was generated. this is optional as a tenant can be created without this lead.',
name: 'lead_id',
}),
tslib_1.__metadata("design:type", String)
], Tenant.prototype, "leadId", void 0);
tslib_1.__decorate([
(0, repository_1.belongsTo)(() => address_model_1.Address, undefined, {
name: 'address_id',
description: 'id of the address of the tenant',
}),
tslib_1.__metadata("design:type", String)
], Tenant.prototype, "addressId", void 0);
exports.Tenant = Tenant = tslib_1.__decorate([
(0, repository_1.model)({
name: 'tenants',
description: 'main model of the service that represents a tenant in the system, either pooled or siloed',
}),
tslib_1.__metadata("design:paramtypes", [Object])
], Tenant);
//# sourceMappingURL=tenant.model.js.map