@awhere/api
Version:
The awesome aWhere API for JavaScript.
241 lines • 8.52 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
var uuid_1 = __importDefault(require("../utils/uuid"));
var IdentityMixin_1 = __importDefault(require("./IdentityMixin"));
var PrototypeBase = /** @class */ (function (_super) {
__extends(PrototypeBase, _super);
function PrototypeBase(props) {
if (props === void 0) { props = {}; }
var _this = _super.call(this) || this;
_this._createdAt = new Date();
_this._updatedAt = new Date();
_this._deleted = false;
if (props._id !== undefined) {
_this._id = props._id;
}
if (props.props !== undefined) {
_this._props = props.props;
}
if (props.extendedProps !== undefined) {
_this._extendedProps = props.extendedProps;
}
if (props.organization !== undefined) {
_this._organization = props.organization;
}
if (props.createdAt !== undefined) {
if (typeof props.createdAt === 'string') {
_this._createdAt = new Date(props.createdAt);
}
else if (typeof props.createdAt === 'number') {
_this._createdAt = new Date(props.createdAt);
}
else if (props.createdAt instanceof Date) {
_this._createdAt = props.createdAt;
}
}
if (props.createdBy !== undefined) {
_this._createdBy = props.createdBy;
}
if (props.updatedAt !== undefined) {
if (typeof props.updatedAt === 'string') {
_this._updatedAt = new Date(props.updatedAt);
}
else if (typeof props.updatedAt === 'number') {
_this._updatedAt = new Date(props.updatedAt);
}
else if (props.updatedAt instanceof Date) {
_this._updatedAt = props.updatedAt;
}
}
if (props.deleted !== undefined) {
_this._deleted = props.deleted;
}
if (props.deletedBy !== undefined) {
_this._deletedBy = props.deletedBy;
}
if (props.deletedAt !== undefined) {
if (typeof props.deletedAt === 'string') {
_this._deletedAt = new Date(props.deletedAt);
}
else if (typeof props.deletedAt === 'number') {
_this._deletedAt = new Date(props.deletedAt);
}
else if (props.deletedAt instanceof Date) {
_this._deletedAt = props.deletedAt;
}
}
return _this;
}
PrototypeBase.generateId = function (namespace) {
if (namespace === void 0) { namespace = 'awhere.core.uuid'; }
return (0, uuid_1.default)(namespace);
};
Object.defineProperty(PrototypeBase.prototype, "_id", {
get: function () {
return this.__id;
},
set: function (v) {
this.__id = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "createdAt", {
get: function () {
return this._createdAt;
},
set: function (v) {
this._createdAt = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "createdBy", {
get: function () {
return this._createdBy;
},
set: function (v) {
this._createdBy = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "updatedAt", {
get: function () {
return this._updatedAt;
},
set: function (v) {
this._updatedAt = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "updatedBy", {
get: function () {
return this._updatedBy;
},
set: function (v) {
this._updatedBy = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "deleted", {
get: function () {
return this._deleted;
},
set: function (value) {
this._deleted = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "deletedBy", {
get: function () {
return this._deletedBy;
},
set: function (value) {
this._deletedBy = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "deletedAt", {
get: function () {
return this._deletedAt;
},
set: function (value) {
this._deletedAt = value;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "props", {
get: function () {
return this._props;
},
set: function (v) {
this._props = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "extendedProps", {
get: function () {
return this._extendedProps;
},
set: function (v) {
this._extendedProps = v;
},
enumerable: false,
configurable: true
});
Object.defineProperty(PrototypeBase.prototype, "organization", {
get: function () {
return this._organization;
},
set: function (v) {
this._organization = v;
},
enumerable: false,
configurable: true
});
PrototypeBase.prototype.toJSON = function () {
var _this = this;
var proto = Object.getPrototypeOf(this);
var jsonObj = {};
Object.entries(Object.getOwnPropertyDescriptors(proto))
.filter(function (_a) {
var key = _a[0], descriptor = _a[1];
return typeof descriptor.get === 'function';
})
.map(function (_a) {
var key = _a[0], descriptor = _a[1];
try {
var val = _this[key];
if (val && typeof val.toJSON === 'function') {
jsonObj[key] = val.toJSON();
}
else {
jsonObj[key] = val;
}
}
catch (error) {
console.error("Error calling getter ".concat(key), error);
}
});
return __assign(__assign({ _id: this._id }, jsonObj), { createdAt: this.createdAt ? this.createdAt.toISOString() : undefined, createdBy: this.createdBy, updatedAt: this.updatedAt ? this.updatedAt.toISOString() : undefined, updatedBy: this.updatedBy, deleted: this.deleted, deletedAt: this.deletedAt ? this.deletedAt.toISOString() : undefined, deletedBy: this.deletedBy, props: this.props, extendedProps: this.extendedProps });
};
return PrototypeBase;
}(IdentityMixin_1.default));
exports.default = PrototypeBase;
//# sourceMappingURL=PrototypeBase.js.map
;