UNPKG

idea-toolbox

Version:
62 lines (61 loc) 1.93 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MembershipSummary = exports.Membership = void 0; const resource_model_1 = require("./resource.model"); /** * This class serve two purposes: * 1. To represent the resource IDEA Membership, which is stored in the table below. * 2. To give a generic representation to the concept of Membership in IDEA's project. * * Table: `idea_teams_users`. * * Indexes: * - `userId-index`. */ class Membership extends resource_model_1.Resource { load(x) { super.load(x); this.teamId = this.clean(x.teamId, String); this.userId = this.clean(x.userId, String); this.name = this.clean(x.name, String); if (x.initials) this.initials = this.clean(x.initials, String); if (x.pendingInvitation) this.pendingInvitation = true; } safeLoad(newData, safeData) { super.safeLoad(newData, safeData); this.teamId = safeData.teamId; this.userId = safeData.userId; if (safeData.pendingInvitation) this.pendingInvitation = safeData.pendingInvitation; } validate() { const e = super.validate(); if (this.iE(this.name)) e.push('name'); return e; } } exports.Membership = Membership; /** * Minimal info on the membership, to attach to other entities. */ class MembershipSummary extends resource_model_1.Resource { load(x) { super.load(x); this.userId = this.clean(x.userId, String); this.name = this.clean(x.name, String); if (x.initials) this.initials = this.clean(x.initials, String); } validate() { const e = super.validate(); if (this.iE(this.userId)) e.push('userId'); if (this.iE(this.name)) e.push('name'); return e; } } exports.MembershipSummary = MembershipSummary;