Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
static columnValuesForFeature(feature, options = {}) {
const values = {};
for (const formValue of feature.formValues.all) {
if (formValue.isEmpty) {
continue;
}
const element = formValue.element;
let columnValue = formValue.columnValue;
if (_lodash2.default.isNumber(columnValue) || _lodash2.default.isString(columnValue) || _lodash2.default.isArray(columnValue) || _lodash2.default.isDate(columnValue)) {
if (options.calculatedFieldDateFormat === 'date' && element.isCalculatedElement && element.display.isDate) {
columnValue = _fulcrumCore.DateUtils.parseDate(formValue.textValue);
}
// don't allow dates greater than 9999, yes - they exist in the wild
if (_lodash2.default.isDate(columnValue)) {
columnValue = columnValue.getFullYear() > 9999 ? null : formValue.textValue;
}
this.maybeAssignArray(values, 'f' + formValue.element.key.toLowerCase(), columnValue, options.disableArrays, options.disableComplexTypes);
} else if (columnValue) {
if (element && options.mediaURLFormatter) {
if (element.isPhotoElement || element.isVideoElement || element.isAudioElement) {
const prefix = 'f' + formValue.element.key.toLowerCase();
columnValue[prefix + '_urls'] = options.mediaURLFormatter(formValue);
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._metadata = attributes.metadata;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._hasTrack = !!attributes.track;
this._trackJSON = attributes.track;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
this._duration = null;
this._bitRate = null;
if (attributes.metadata && attributes.metadata.format) {
if (attributes.metadata.format.duration != null) {
this._duration = +attributes.metadata.format.duration;
}
if (attributes.metadata.format.bit_rate != null) {
this._bitRate = +attributes.metadata.format.bit_rate;
}
}
}
return _asyncToGenerator(function* () {
const data = {
DateUtils: _fulcrumCore.DateUtils,
record: _this.record,
renderValues: _this.renderValues
};
const options = {};
const html = _ejs2.default.render(_this.contentTemplate, data, options);
const topdf = new _htmlToPdf2.default(html);
const result = yield topdf.run();
let outputPath = null;
if (result) {
const reportName = (0, _sanitizeFilename2.default)(_this.record.displayValue || _this.record.id);
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._exif = attributes.exif;
this._fileSize = attributes.file_size;
this._latitude = attributes.latitude;
this._longitude = attributes.longitude;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
if (attributes.exif) {
const { exif } = attributes;
this._altitude = exif.gps_altitude;
this._direction = exif.gps_img_direction;
this._accuracy = exif.gps_dop;
this._width = this.integerValue(exif.pixel_x_dimension);
this._height = this.integerValue(exif.pixel_y_dimension);
this._make = exif.make;
this._model = exif.model;
this._software = exif.software;
this._dateTime = exif.date_time_original || exif.date_time;
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._metadata = attributes.metadata;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._hasTrack = !!attributes.track;
this._trackJSON = attributes.track;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
this._width = null;
this._height = null;
this._bitRate = null;
if (attributes.metadata) {
const video = attributes.metadata && attributes.metadata.streams && attributes.metadata.streams.find(s => s.codec_type === 'video');
if (video) {
this._width = video.width;
this._height = video.height;
}
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._metadata = attributes.metadata;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._hasTrack = !!attributes.track;
this._trackJSON = attributes.track;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
this._duration = null;
this._bitRate = null;
if (attributes.metadata && attributes.metadata.format) {
if (attributes.metadata.format.duration != null) {
this._duration = +attributes.metadata.format.duration;
}
if (attributes.metadata.format.bit_rate != null) {
this._bitRate = +attributes.metadata.format.bit_rate;
}
}
return _asyncToGenerator(function* () {
const isChanged = !object.isPersisted || _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at).getTime() !== object.updatedAt.getTime();
object.updateFromAPIAttributes(attributes);
if (object._deletedAt != null) {
object._deletedAt = null;
}
yield _this.loadObject(object, attributes);
yield object.save();
if (isChanged) {
yield _this.triggerEvent('save', { [_this.propertyName]: object });
}
})();
}
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._metadata = attributes.metadata;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._hasTrack = !!attributes.track;
this._trackJSON = attributes.track;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
this._width = null;
this._height = null;
this._bitRate = null;
if (attributes.metadata) {
const video = attributes.metadata && attributes.metadata.streams && attributes.metadata.streams.find(s => s.codec_type === 'video');
if (video) {
this._width = video.width;
this._height = video.height;
}
if (attributes.metadata && attributes.metadata.format) {
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._exif = attributes.exif;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
}
updateFromAPIAttributes(attributes) {
this._id = attributes.access_key;
this._fileSize = attributes.file_size;
this._isUploaded = attributes.uploaded;
this._isStored = attributes.stored;
this._isProcessed = attributes.processed;
this._contentType = attributes.content_type;
this._createdByID = attributes.created_by_id;
this._updatedByID = attributes.updated_by_id;
this._createdAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.created_at);
this._updatedAt = _fulcrumCore.DateUtils.parseISOTimestamp(attributes.updated_at);
this._formID = attributes.form_id;
this._recordID = attributes.record_id;
}