UNPKG

type-arango

Version:

ArangoDB Foxx decorators and utilities for TypeScript

66 lines 2.51 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Type = void 0; var __1 = require(".."); var Joi = require("joi"); var Type; (function (Type) { var I18n = /** @class */ (function () { function I18n() { } I18n.forClient = function (val, _a) { var req = _a.req, session = _a.session; var sess = session(); var param = req.param('locale'); if (param === '*') return val; var locale = param || (sess.data ? sess.data.locale || __1.config.defaultLocale : __1.config.defaultLocale); return !val ? null : val[locale] || val[locale.split('-')[0]] || val[__1.config.defaultLocale] || null; }; I18n._typeArango = '0.4'; I18n.schema = Joi.object().unknown().example({ en: 'Translation' }); return I18n; }()); Type.I18n = I18n; var Currencies = /** @class */ (function () { function Currencies() { } Currencies.forClient = function (val, _a) { var req = _a.req, session = _a.session; var sess = session(); var param = req.param('currency'); if (param === '*') return val; var currency = param || (sess.data ? sess.data.currency : __1.config.defaultCurrency); return val[currency] || val[__1.config.defaultCurrency] || val['USD'] || null; }; Currencies._typeArango = '1.0'; return Currencies; }()); Type.Currencies = Currencies; /** * Sets current Date to attribute when a new document is inserted */ var DateInsert = /** @class */ (function () { function DateInsert() { } DateInsert.beforeInsert = function () { return new Date(); }; DateInsert._typeArango = '0.7'; DateInsert.schema = Joi.date(); return DateInsert; }()); Type.DateInsert = DateInsert; /** * Sets current Date to attribute whenever the document is updated */ var DateUpdate = /** @class */ (function () { function DateUpdate() { } DateUpdate.beforeUpdate = function () { return new Date(); }; DateUpdate._typeArango = '0.7'; DateUpdate.schema = Joi.date(); return DateUpdate; }()); Type.DateUpdate = DateUpdate; })(Type = exports.Type || (exports.Type = {})); //# sourceMappingURL=Type.models.js.map