@lighthouse/common
Advanced tools
Comparing version 0.1.10 to 0.1.11
@@ -1,1 +0,1 @@ | ||
exports["lighthouse-common"]=function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=7)}([function(t,e){t.exports=require("lodash")},function(t,e){t.exports=require("bluebird")},function(t,e){t.exports=require("moment")},function(t,e){t.exports=require("moment-timezone")},function(t,e,n){"use strict";(function(t){n.d(e,"a",function(){return c});var r=n(6),o=n.n(r),i=n(1),a=n.n(i),u=o()({Promise:a.a}).fetch;function c(e){return u(e).then(function(t){return t.ok?t.blob():a.a.reject(new Error("Failed to fetch image: "+e))}).then(function(e){return new a.a(function(n,r){var o=new t;o.onloadend=function(){return n(o.result)},o.onerror=r,o.readAsDataURL(e)})})}}).call(this,n(10))},function(t,e){t.exports=require("react-html-parser")},function(t,e){t.exports=require("fetch-ponyfill")},function(t,e,n){"use strict";n.r(e);var r=3,o=[60,110,60,80],i="portrait",a="A4",u="Lighthouse.io",c="https://s3.amazonaws.com/assets-lighthouse-io/img/logo-medium.png",l=n(0),s=n(1),d=n.n(s);function f(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}var b=d.a.method(function(t){var e=[],n=[];return Object(l.reduce)(t,function(t,e){var n=e.groupActualScore,r=e.groupMaximumScore,o=e.items,i=e.title,a=[[{text:"Group Score",bold:!0},n+"/"+r]],u=nt(i,{style:"header3"}),c={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},s=$({body:a,margin:[0,0,0,0]}),b=[[{text:"Question",bold:!0},{text:"Score",bold:!0},{text:"Attachments",bold:!0},{text:"Comments",bold:!0}]];Object(l.each)(o,function(e){var n=e.assetCount,r=e.assets,o=e.comments,a=void 0===o?"":o,u=e.label,c=void 0===u?"":u,s=e.scoreLabel,m=void 0===s?"":s;if(b.push([c,m,n,a]),!Object(l.isEmpty)(r)){var h=Object(l.map)(r,function(t){return Object(x.a)(t.assetUrl)}),v=d.a.all(h).then(function(t){var e=nt(i,{style:"header3"}),n={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},o=Z(Object(l.map)(t,function(t,e){var n=r[e];return{alignment:"center",fit:[150,150],image:t,link:n&&n.assetUrl}}));return[e].concat(f(o),[n])});t.imageContentPromises.push(v)}});var m=tt({body:b,margin:[0,0,0,0],widths:[130,"*","*","*"]});return t.details.push([u,c,m,c,s,c]),t},{details:e,imageContentPromises:n}),d.a.all(n).then(function(t){if(Object(l.isEmpty)(t))return{details:e};var n=[nt("Photos",{pageBreak:"before",style:"header2"}),{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}].concat(f(t));return{details:e,photos:n}})});function m(t,e){var n=e.awsS3BaseUrl,r=e.cloudinaryBaseUrl,o=e.height,i=e.width,a=[],u="";return i&&a.push("w_"+i.toString()),o&&a.push("h_"+o.toString()),a.length>0&&(u=a.join(",")+"/"),r+"/"+u+n+"/"+t}function h(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}var v=d.a.method(function(t,e){var n=e.settings,r=(n=void 0===n?{}:n).awsS3BaseUrl,o=n.cloudinaryBaseUrl,i=[],a=[];Object(l.reduce)(t,function(t,e){var n=nt(e.label,{style:"header3"}),i={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},a=Object(l.chain)(e.fieldGroups).map(function(e){var n=Object(l.filter)(e.fields,function(t){return"list"===t.fieldtype&&"media"===t.options.type&&t.value.length>0});Object(l.each)(n,function(e){Object(l.each)(e.value,function(e){var n=m(e,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:800});t.images.push(n)})});var i=Object(l.filter)(e.fields,function(t){return"list"!==t.fieldtype});return Object(l.isEmpty)(i)?[]:[$({body:Object(l.map)(i,function(t){var e=t.label,n=t.options,r=void 0===n?{}:n,o=t.value;if("html"===r.type)return[e,Q(o.replace(/<p><\/p>/g,""))];var i=K(o);return[e,Object(l.isArray)(i)?Object(l.join)(i,", "):function(t){return Object(l.startsWith)(t,"data:image/png;")}(i)?{alignment:"left",image:i,width:140}:i]})})]}).flattenDeep().compact().value();if(!Object(l.isEmpty)(a))return t.details.push([n,i].concat(h(a))),t},{details:i,images:a});var u=Object(l.map)(a,function(t){return Object(x.a)(t)});return d.a.all(u).then(function(t){if(Object(l.isEmpty)(i)||i.unshift(nt("Details",{style:"header2"})),Object(l.isEmpty)(t))return{details:i};var e=nt("Photos",{pageBreak:"before",style:"header2"}),n={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},r=Z(Object(l.map)(t,function(t,e){return{alignment:"center",fit:[150,150],image:t,link:a[e]}})),o=[e,n].concat(h(r));return{details:i,photos:o}})});var y=n(2),g=n.n(y);function p(t,e){var n=g()().format("D/M/YY");return Object(x.a)(t).then(function(t){return function(r){return{columns:[{fit:[80,30],image:t,margin:[60,20,0,0]},{alignment:"right",text:e+" | "+n+" | Page "+r,style:"small",margin:[0,25,60,0]}]}}})}function O(t){return Object(x.a)(t).then(function(t){return{fit:[130,50],image:t,margin:[60,60,60,0]}})}var j={h1:{fontSize:12,margin:[0,0,0,10],color:"#222"},h2:{fontSize:10,margin:[0,5,0,5],color:"#222"},header1:{fontSize:16,margin:[0,20,0,20],color:"#222"},header2:{fontSize:14,margin:[0,10,0,10],color:"#222"},header3:{fontSize:12,margin:[0,10,0,0],color:"#444"},horizontalLine:{margin:[0,0,0,0],fontSize:1},ol:{bold:!1,color:"#666",fontSize:8,margin:[10,10,10,10]},p:{fontSize:8,bold:!1,color:"#666"},small:{fontSize:8,bold:!1,color:"#666"},table:{fontSize:8,lineHeight:1.1,color:"#444"},ul:{bold:!1,color:"#666",fontSize:8,margin:[10,10,10,10]}},x=n(4),S=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(r=(a=u.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){o=!0,i=t}finally{try{!r&&u.return&&u.return()}finally{if(o)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();function A(t){var e=t.content,n=t.fileTitle,r=t.footer,s=void 0===r?p:r,f=t.header,b=void 0===f?O:f,m=t.logoUrl,h=void 0===m?c:m,v=t.pageMargins,y=void 0===v?o:v,g=t.pageOrientation,x=void 0===g?i:g,A=t.pageSize,L=void 0===A?a:A,w=t.styles,T=void 0===w?{}:w,D=t.title,z=void 0===D?u:D,E=Object(l.defaults)({},T,j),U={title:n},k=[function(t){if(Object(l.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(b(h)),function(t){if(Object(l.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(e),function(t){if(Object(l.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(s(c,z))];return d.a.all(k).then(function(t){var e=S(t,3);return{header:e[0],content:e[1],footer:e[2],info:U,pageMargins:y,pageOrientation:x,pageSize:L,styles:E}})}function L(t,e){return Object(l.isEmpty)(e)?"No users assigned":Object(l.chain)(e).map(function(e){return R(t,e)}).compact().join(", ").value()}function w(t){var e=t.entity,n=t.timezone,r=e.createdAt,o=e.gps,i=e.items,a=e.score,u=k(t),c=Object(l.get)(o,"reverseGeocoded.label","Unknown Location"),s=T(i,t),d=N(t),f=B(a.result),b=M(r,n);return{gpsText:c,groupedData:s,locationText:u,referenceLabel:d.label,referenceValue:d.value,scoreText:f,timezoneDatetime:b}}function T(t,e){var n=e.settings,r=(n=void 0===n?{}:n).awsS3BaseUrl,o=n.cloudinaryBaseUrl,i=Object(l.groupBy)(t,"group.id"),a={overallActualScore:0,overallMaximumScore:0};return a.items=Object(l.map)(i,function(t,e){var n={key:e,groupMaximumScore:0,groupActualScore:0,title:t[0].group.label};return n.items=t.map(function(t,i){var u=t.assets,c=t.comments,s=t.label,d=t.score,f=t.scores,b=t.scoreWeight,h=t.weight,v=Object(l.maxBy)(f,"value").value*h,y=Object(l.find)(f,{value:d});return n.groupMaximumScore+=v,n.groupActualScore+=b,a.overallMaximumScore+=v,a.overallActualScore+=b,{assetCount:u.length,assets:u.map(function(t,n){return{assetUrl:m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:800}),key:e+"-item-asset-"+n,thumbnailUrl:m(t,{awsS3BaseUrl:r,cloudinaryBaseUrl:o,width:100})}}),comments:c,key:e+"-item-"+i,label:s,scoreLabel:y?y.label:"Unknown Score"}}),n}),a}var D=["label","postalcode"];function z(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:D;return t?Object(l.chain)(t).pick(e).values().compact().join(", ").value():"Unknown Location"}function E(t){var e=t.entity,n=t.timezone,r=t.users,o=e.assignees,i=e.createdAt,a=e.duration,u=e.gps,c=e.status,s=e.user,d=L(r,o),f=C(g.a.duration(a,"minutes")),b=R(r,s),m=Object(l.get)(u,"reverseGeocoded.label","Unknown Location"),h="closed"===c,v=k(t),y=P(c),p=y.style;return{assigneeNames:d,durationText:f,gpsText:m,fullName:b,isClosedStatus:h,locationText:v,statusStyle:p,statusColor:p.color,statusText:Object(l.upperCase)(y.text),timezoneDatetime:M(i,n)}}n(3);function U(t){var e=t.entity,n=void 0===e?{}:e,r=t.timezone,o=t.users,i=n.assignees,a=n.author,u=n.createdAt,c=n.description,s=void 0===c?"-":c,d=n.due,f=n.geometryReverseGeocoded,b=n.reference,m=void 0===b?"-":b,h=n.status,v=L(o,i),y=R(o,a),p=z(f),O=P(h),j=O.style,x=j.color,S=Object(l.upperCase)(O.text);return{assigneeNames:v,authorFullName:y,createdTimezoneDateTime:M(u,r),description:s,dueDateTimezoneDateTime:M(d,r),locationText:p,statusStyle:j,statusColor:x,statusText:S,reference:m,timezoneAbbrText:g()().tz(r).format("z")}}function k(t){var e=t.entity,n=t.locations,r=void 0===n?{}:n,o=t.zones,i=void 0===o?{}:o,a=e.area,u=e.location,c=e.zone,s=void 0,d=void 0,f=Object(l.get)(a,"label");return u&&(s=Object(l.isString)(u)?Object(l.get)(r,u+".name"):u.name),c&&(d=Object(l.isString)(c)?Object(l.get)(i,c+".name"):c.name),s||d?Object(l.compact)([s,d]).join(", "):f||"Unknown Location"}function C(t){var e=Math.floor(t.asDays()),n=Math.floor(t.asHours()),r=t.hours(),o=t.minutes(),i=t.seconds();return e>0?e+"d "+r+"h":n>0?n+"h "+o+"m":o>0?o+"m":i+"s"}function N(t){var e=t.entity,n=t.users,r=e.user,o="Reference",i="Unknown Reference";r&&(o="User",i=R(n,r));return{label:o,value:i}}var P=Object(l.memoize)(function(t){switch(t){case"closed":return{style:{color:"#D0021B"},text:"Closed"};case"in-progress":return{style:{color:"#00AAE4"},text:"In Progress"};case"open":return{style:{color:"#FF8C2F"},text:"Open"};default:return{style:{color:"#666666"},text:"Unknown"}}});function G(t){var e=t.entity,n=void 0===e?{}:e,r=t.timezone,o=n.createdAt,i=n.gps,a=Object(l.get)(i,"reverseGeocoded.label","Unknown Location"),u=k(t),c=N(t),s=M(o,r);return{locationText:u,gpsText:a,referenceLabel:c.label,referenceValue:c.value,timezoneDatetime:s}}function M(t,e){var n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],r=g()(t).tz(e),o=r.format("MMM D h:mma"),i=r.format("z");return n?o+" ("+i+")":""+o}function R(t,e){var n=(Object(l.find)(t,["user._id",e])||{}).user;return n?n.firstName+" "+n.lastName:"Unknown User"}function B(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Math.floor(100*t)+"%"}function I(){return{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}}var _=n(5),F=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};var W=["ol","ul"],q=/.*\n.*/,H=/\s+/g;function J(t){if(!Object(l.isPlainObject)(t))throw new Error("InvalidDataError");var e=t.children,n=void 0===e?[]:e,r=t.data,o=void 0===r?"":r,i=t.name,a=void 0===i?"":i;if("text"===t.type&&o){var u=o.replace(H," ").trim();return u&&u+" "}var c=Object(l.reject)(n,["data",q]),s=Object(l.compact)(Object(l.map)(c,J)),d=Object(l.includes)(W,a)?a:"text",f=Object(l.isArray)(s)&&1===s.length&&Object(l.isString)(s[0])?s[0]:s;return F({},V(t),function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}({},d,f))}function V(t){var e=t.name,n=void 0===e?"":e,r={};return"em"===n&&(r.italics=!0),"ins"===n&&(r.decoration="underline"),"strong"===n&&(r.bold=!0),r.bold||r.decoration||r.italics||(r.style=n),r}function Y(t){if(!t||!Object(l.isString)(t))throw new Error("InvalidDataError");return _.htmlparser2.parseDOM(t)}function Q(t){if(!t)throw new Error("InvalidDataError");var e=Y(t);return Object(l.compact)(Object(l.map)(e,J))}function Z(t){var e=Object(l.chunk)(t,r);return Object(l.map)(e,function(t){var e=Object(l.fill)(Array(r),{text:""}),n=Object(l.concat)(t,Object(l.slice)(e,t.length));return{table:{body:[[].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(n))],widths:[160,160,160]},layout:"noBorders",margin:[0,5,0,5]}})}function K(t){return Object(l.isBoolean)(t)?t?"Yes":"No":Object(l.isObjectLike)(t)&&Object(l.isEmpty)(t)?" - ":t||" - "}function X(t){var e=t.body,n=t.layout,r=void 0===n?"noBorders":n,o=t.margin,i=void 0===o?[0,10,0,20]:o,a=t.widths,u=t.style,c=void 0===u?"table":u;return Object(l.isObject)(c)&&(c=Object(l.defaults)({},c,j.table)),{layout:r,margin:i,style:c,table:{body:e,widths:a,headerRows:1}}}function $(t){return X(Object(l.defaults)({},t,{widths:[130,"*"]}))}function tt(t){return X(Object(l.defaults)({},t,{widths:[130,"*","*","*"]}))}var et=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function nt(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return et({text:t=t||"Unknown"},e)}var rt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function ot(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function it(t,e){var n="Audit Report - "+Object(l.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=e.footerFields,r=void 0===n?{}:n,o=e.headerFields,i=void 0===o?{}:o,a=e.title,u=void 0===a?"Unknown":a,c=w(t),s=[[{text:"Title",bold:!0},u],[{text:"Location",bold:!0},c.locationText],[{text:"GPS Location",bold:!0},c.gpsText],[{text:c.referenceLabel,bold:!0},c.referenceValue],[{text:"Created",bold:!0},c.timezoneDatetime],[{text:"Score",bold:!0},c.scoreText]],f=[[{text:"Total Score",bold:!0},c.groupedData.overallActualScore+" / "+c.groupedData.overallMaximumScore]],m=nt("Audit Report",{style:"header1"}),h=$({body:s}),y=nt("Details",{style:"header2"}),g=$({body:f,style:{fontSize:12},margin:[0,20,0,10]}),p={entry:b(c.groupedData.items),footer:v(r.formGroups,t),header:v(i.formGroups,t)};return d.a.props(p).then(function(t){var e=t.entry,n=t.footer,r=t.header,o=e.details,i=void 0===o?[]:o,a=e.photos,u=void 0===a?[]:a,c=n.details,s=void 0===c?[]:c,d=n.photos,f=void 0===d?[]:d,b=r.details,v=void 0===b?[]:b,p=r.photos,O=void 0===p?[]:p;return[m,h,y].concat(ot(Object(l.reject)(v,["text","Details"])),ot(i),[g],ot(Object(l.reject)(s,["text","Details"])),ot(O),ot(u),ot(f))})}(e).then(function(e){return A(rt({content:e,fileTitle:n},t))})}var at=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function ut(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function ct(t,e){var n="Issue Report - "+Object(l.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=t.timezone,r=e.entry,o=e.title,i=e.timeline,a=void 0===i?[]:i,u=E(t),c=Object(l.map)(a,lt),s=[[{text:"Title",bold:!0},o],[{text:"Status",bold:!0},{text:u.statusText,color:u.statusColor}],[{text:"Assignees",bold:!0},u.assigneeNames],[{text:"Location",bold:!0},u.locationText],[{text:"GPS Location",bold:!0},u.gpsText],[{text:"Raised by",bold:!0},u.fullName],[{text:"Created",bold:!0},u.timezoneDatetime]];u.isClosedStatus&&s.push([{text:"Duration",bold:!0},u.durationText]);var d=Object(l.isEmpty)(c)?[["No Timeline data"]]:Object(l.map)(c,function(t){return function(e){var n=e.text,r=e.timestamp,o=M(r,t);return[{text:o,bold:!0},n]}}(n)),f=nt("Issue Report",{style:"header1"}),b=$({body:s}),m=nt("Timeline",{style:"header2"}),h={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},y=$({body:d});return v(r.formGroups,t).then(function(t){var e=t.details,n=void 0===e?[]:e,r=t.photos,o=void 0===r?[]:r;return[f,b,m,h,y].concat(ut(n),ut(o))})}(e).then(function(e){return A(at({content:e,fileTitle:n},t))})}function lt(t){var e=t._id,n=t.meta,r=void 0===n?{}:n,o=t.timestamp;return{_id:e,text:"status"===r.field?function(t){var e=t.meta,n=t.source,r=t.type,o=Object(l.get)(e,"next"),i=Object(l.get)(n,"meta.firstName"),a=Object(l.get)(n,"meta.lastName"),u=i&&a?i+" "+a:"Unknown User",c="issue-new"===r,s="issue-update"===r,d="open"===o,f=P(o).text;return c&&d?"Issue opened by "+u:c&&!d?"Issue opened with status "+f+" by "+u:s?"Issue updated to "+f+" by "+u:"Unknown status timeline change"}(t):null,timestamp:o}}var st=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};var dt=[{text:"Type",bold:!0},{text:"User",bold:!0},{text:"Start Time",bold:!0},{text:"Start Location",bold:!0},{text:"End Time",bold:!0},{text:"End Location",bold:!0},{text:"Duration",bold:!0}];function ft(t,e){var n="Job Report - "+Object(l.get)(e,"entity.title","Unknown"),r=function(t){var e=t.entity.title,n=U(t),r=[[{text:"Location",bold:!0},n.locationText],[{text:"Author",bold:!0},n.authorFullName],[{text:"Reference",bold:!0},n.reference],[{text:"Description",bold:!0},n.description],[{text:"Due Date",bold:!0},n.dueDateTimezoneDateTime],[{text:"Assignees",bold:!0},n.assigneeNames],[{text:"Status",bold:!0},{text:n.statusText,color:n.statusColor}],[{text:"Created",bold:!0},n.createdTimezoneDateTime],[{text:"Timezone",bold:!0},n.timezoneAbbrText]],o=nt("Job Report: "+e,{style:"header1"}),i=$({body:r}),a=nt("Job Activities",{style:"header2"}),u=X(function(t){var e=t.jobActivities,n=t.timezone,r=t.users;if(Object(l.isEmpty)(e))return{body:[["No Job Activities Data"]],widths:"*"};var o=Object(l.map)(e,function(t){var e=t.entity,o=e.type,i=e.duration,a=e.user,u=e.start,c=void 0===u?{}:u,s=e.end,d=void 0===s?{}:s,f=R(r,a),b=g.a.duration(i,"minutes"),m=i?C(b):"-",h=c.time,v=Object(l.get)(c,"geometryReverseGeocoded.label","-"),y=d.time,p=Object(l.get)(d,"geometryReverseGeocoded.label","-"),O=h?M(h,n,!1):"-",j=y?M(y,n,!1):"-";return[o,f,O,v,j,p,m]});return{body:[dt].concat(function(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}(o)),widths:[70,80,60,"*",60,"*",50]}}(t));return[o,i,a,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},u,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}]}(e);return A(st({content:r,fileTitle:n,pageOrientation:"landscape"},t))}var bt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t};function mt(t){if(Array.isArray(t)){for(var e=0,n=Array(t.length);e<t.length;e++)n[e]=t[e];return n}return Array.from(t)}function ht(t,e){var n="Task Report - "+Object(l.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,n=e.entry,r=e.title,o=G(t),i=[[{text:"Title",bold:!0},r],[{text:"Location",bold:!0},o.locationText],[{text:"GPS Location",bold:!0},o.gpsText],[{text:o.referenceLabel,bold:!0},o.referenceValue],[{text:"Created",bold:!0},o.timezoneDatetime]],a=nt("Task Report",{style:"header1"}),u=$({body:i});return v(n.formGroups,t).then(function(t){var e=t.details,n=void 0===e?[]:e,r=t.photos,o=void 0===r?[]:r;return[a,u].concat(mt(n),mt(o))})}(e).then(function(e){return A(bt({content:e,fileTitle:n},t))})}n.d(e,"DEFAULT_IMAGE_ROW_LENGTH",function(){return r}),n.d(e,"DEFAULT_PAGE_MARGINS",function(){return o}),n.d(e,"DEFAULT_PAGE_ORIENTATION",function(){return i}),n.d(e,"DEFAULT_PAGE_SIZE",function(){return a}),n.d(e,"DEFAULT_TITLE",function(){return u}),n.d(e,"LIGHTHOUSE_LOGO_URL",function(){return c}),n.d(e,"buildAuditContent",function(){return b}),n.d(e,"buildFetchUrl",function(){return m}),n.d(e,"buildTemplateContent",function(){return v}),n.d(e,"defaultFooter",function(){return p}),n.d(e,"defaultHeader",function(){return O}),n.d(e,"defaultStyles",function(){return j}),n.d(e,"fetchImage",function(){return x.a}),n.d(e,"generateDefinition",function(){return A}),n.d(e,"getAssigneesFullNames",function(){return L}),n.d(e,"getAuditEntryDetails",function(){return w}),n.d(e,"getAuditItemsData",function(){return T}),n.d(e,"getGeometryGeocodedString",function(){return z}),n.d(e,"getIssueDetails",function(){return E}),n.d(e,"getJobDetails",function(){return U}),n.d(e,"getLocationText",function(){return k}),n.d(e,"getPrettyDuration",function(){return C}),n.d(e,"getReferenceDetails",function(){return N}),n.d(e,"getStatusDetails",function(){return P}),n.d(e,"getTaskEntryDetails",function(){return G}),n.d(e,"getTimezoneDatetime",function(){return M}),n.d(e,"getUserFullName",function(){return R}),n.d(e,"getValueAsPercentage",function(){return B}),n.d(e,"horizontalLine",function(){return I}),n.d(e,"convertToPdfMake",function(){return J}),n.d(e,"getStyleAttributes",function(){return V}),n.d(e,"parseHtml",function(){return Y}),n.d(e,"toPdf",function(){return Q}),n.d(e,"imagesTable",function(){return Z}),n.d(e,"parseValue",function(){return K}),n.d(e,"table",function(){return X}),n.d(e,"twoColumnTable",function(){return $}),n.d(e,"fourColumnTable",function(){return tt}),n.d(e,"text",function(){return nt}),n.d(e,"buildAuditPdf",function(){return it}),n.d(e,"buildIssuePdf",function(){return ct}),n.d(e,"buildJobPdf",function(){return ft}),n.d(e,"buildTaskPdf",function(){return ht})},function(t,e){t.exports=require("events")},function(t,e){t.exports=require("fs")},function(t,e,n){!function(){"use strict";var e=n(9),r=n(8).EventEmitter;function o(t,e,n){"function"==typeof t&&t.apply(n,e)}t.exports=function(){var t,n=this,i=new r;function a(a,u,c){if(!(t=a)||!t.name||!(t.path||t.stream||t.buffer))throw new Error("cannot read as File: "+JSON.stringify(t));0===n.readyState?process.nextTick(function(){n.readyState=n.LOADING,i.emit("loadstart"),function(){var o=new r,i=n.nodeChunkedEncoding;if(!t.size&&i&&t.path&&e.stat(t.path,function(e,n){t.size=n.size,t.lastModifiedDate=n.mtime}),!t.stream){if(t.buffer)return process.nextTick(function(){o.emit("data",t.buffer),o.emit("end")}),void(t.stream=o);if(t.path){if(!i)return e.readFile(t.path,function(t,e){t&&o.emit("error",t),e&&(o.emit("data",e),o.emit("end"))}),void(t.stream=o);t.stream=e.createReadStream(t.path)}}}(),function(e,r){var o=t.stream,a=[];n.nodeChunkedEncoding,a.dataLength=0,o.on("error",function(t){n.DONE!==n.readyState&&(n.readyState=n.DONE,n.error=t,i.emit("error",t))}),o.on("data",function(e){n.DONE!==n.readyState&&(a.dataLength+=e.length,a.push(e),i.emit("progress",{lengthComputable:!isNaN(t.size),loaded:a.dataLength,total:t.size}),i.emit("data",e))}),o.on("end",function(){var o;n.DONE!==n.readyState&&(o=a.length>1?Buffer.concat(a):a[0],n.readyState=n.DONE,n.result=function(t,e,n,r){switch(n){case"buffer":return e;case"binary":return e.toString("binary");case"dataUrl":return function(t,e){var n="data:";return e&&(n+=e+";"),/text/i.test(e)?(n+="charset=utf-8,",n+=t.toString("utf8")):(n+="base64,",n+=t.toString("base64")),n}(e,t.type);case"text":return e.toString(r||"utf8")}}(t,o,e,r),i.emit("load",{target:{nodeBufferResult:o,result:n.result}}),i.emit("loadend"))})}(u,c),i.on("start",function(){o(n.onloadstart,arguments)}),i.on("progress",function(){o(n.onprogress,arguments)}),i.on("error",function(t){if(n.onerror)n.onerror(t);else if(!i.listeners.error||!i.listeners.error.length)throw t}),i.on("load",function(){o(n.onload,arguments)}),i.on("end",function(){o(n.onloadend,arguments)}),i.on("abort",function(){o(n.onabort,arguments)})}):console.log("already loading, request to change format ignored")}n.addEventListener=function(t,e){i.on(t,e)},n.removeEventListener=function(t){i.removeListener(t)},n.dispatchEvent=function(t){i.emit(t)},n.EMPTY=0,n.LOADING=1,n.DONE=2,n.error=void 0,n.readyState=n.EMPTY,n.result=void 0,n.on=function(){i.on.apply(i,arguments)},n.nodeChunkedEncoding=!1,n.setNodeChunkedEncoding=function(t){n.nodeChunkedEncoding=t},i.on("abort",function(){n.readyState=n.DONE}),n.abort=function(){n.readState!=n.DONE&&(n.readyState=n.DONE,i.emit("abort"))},n.readAsArrayBuffer=function(t){a(t,"buffer")},n.readAsBinaryString=function(t){a(t,"binary")},n.readAsDataURL=function(t){a(t,"dataUrl")},n.readAsText=function(t,e){a(t,"text",e)}}}()}]); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("lodash"),require("bluebird"),require("moment"),require("moment-timezone"),require("react-html-parser"),require("fetch-ponyfill")):"function"==typeof define&&define.amd?define("lighthouse-common",["lodash","bluebird","moment","moment-timezone","react-html-parser","fetch-ponyfill"],e):"object"==typeof exports?exports["lighthouse-common"]=e(require("lodash"),require("bluebird"),require("moment"),require("moment-timezone"),require("react-html-parser"),require("fetch-ponyfill")):t["lighthouse-common"]=e(t._,t.bluebird,t.moment,t["moment-timezone"],t["react-html-parser"],t["fetch-ponyfill"])}("undefined"!=typeof self?self:this,function(t,e,r,n,o,i){return function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,r){t.exports=e},function(t,e){t.exports=r},function(t,e){t.exports=n},function(t,e){t.exports=o},function(t,e){t.exports=i},function(t,e,r){"use strict";const n=r(9),o=r(8);t.exports={atob:n,btoa:o}},function(t,e,r){"use strict";r.r(e);var n=3,o=[60,110,60,80],i="portrait",a="A4",u="Lighthouse.io",l="https://s3.amazonaws.com/assets-lighthouse-io/img/logo-medium.png",c=r(0),s=r(1),d=r.n(s);function f(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}var b=d.a.method(function(t){var e=[],r=[];return Object(c.reduce)(t,function(t,e){var r=e.groupActualScore,n=e.groupMaximumScore,o=e.items,i=e.title,a=[[{text:"Group Score",bold:!0},r+"/"+n]],u=it(i,{style:"header3"}),l={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},s=rt({body:a,margin:[0,0,0,0]}),b=[[{text:"Question",bold:!0},{text:"Score",bold:!0},{text:"Attachments",bold:!0},{text:"Comments",bold:!0}]];Object(c.each)(o,function(e){var r=e.assetCount,n=e.assets,o=e.comments,a=void 0===o?"":o,u=e.label,l=void 0===u?"":u,s=e.scoreLabel,h=void 0===s?"":s;if(b.push([l,h,r,a]),!Object(c.isEmpty)(n)){var m=Object(c.map)(n,function(t){return w(t.assetUrl)}),v=d.a.all(m).then(function(t){var e=it(i,{style:"header3"}),r={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},o=X(Object(c.map)(t,function(t,e){var r=n[e];return{alignment:"center",fit:[150,150],image:t,link:r&&r.assetUrl}}));return[e].concat(f(o),[r])});t.imageContentPromises.push(v)}});var h=nt({body:b,margin:[0,0,0,0],widths:[130,"*","*","*"]});return t.details.push([u,l,h,l,s,l]),t},{details:e,imageContentPromises:r}),d.a.all(r).then(function(t){if(Object(c.isEmpty)(t))return{details:e};var r=[it("Photos",{pageBreak:"before",style:"header2"}),{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}].concat(f(t));return{details:e,photos:r}})});function h(t,e){var r=e.awsS3BaseUrl,n=e.cloudinaryBaseUrl,o=e.height,i=e.width,a=[],u="";return i&&a.push("w_"+i.toString()),o&&a.push("h_"+o.toString()),a.length>0&&(u=a.join(",")+"/"),n+"/"+u+r+"/"+t}function m(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}var v=d.a.method(function(t,e){var r=e.settings,n=(r=void 0===r?{}:r).awsS3BaseUrl,o=r.cloudinaryBaseUrl,i=[],a=[];Object(c.reduce)(t,function(t,e){var r=it(e.label,{style:"header3"}),i={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},a=Object(c.chain)(e.fieldGroups).map(function(e){var r=Object(c.filter)(e.fields,function(t){return"list"===t.fieldtype&&"media"===t.options.type&&t.value.length>0});Object(c.each)(r,function(e){Object(c.each)(e.value,function(e){var r=h(e,{awsS3BaseUrl:n,cloudinaryBaseUrl:o,width:800});t.images.push(r)})});var i=Object(c.filter)(e.fields,function(t){return"list"!==t.fieldtype});return Object(c.isEmpty)(i)?[]:[rt({body:Object(c.map)(i,function(t){var e=t.label,r=t.options,n=void 0===r?{}:r,o=t.value;if("html"===n.type)return[e,K(o.replace(/<p><\/p>/g,""))];var i=tt(o);return[e,Object(c.isArray)(i)?Object(c.join)(i,", "):function(t){return Object(c.startsWith)(t,"data:image/png;")}(i)?{alignment:"left",image:i,width:140}:i]})})]}).flattenDeep().compact().value();if(!Object(c.isEmpty)(a))return t.details.push([r,i].concat(m(a))),t},{details:i,images:a});var u=Object(c.map)(a,function(t){return w(t)});return d.a.all(u).then(function(t){if(Object(c.isEmpty)(i)||i.unshift(it("Details",{style:"header2"})),Object(c.isEmpty)(t))return{details:i};var e=it("Photos",{pageBreak:"before",style:"header2"}),r={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},n=X(Object(c.map)(t,function(t,e){return{alignment:"center",fit:[150,150],image:t,link:a[e]}})),o=[e,r].concat(m(n));return{details:i,photos:o}})});var y=r(2),g=r.n(y);function p(t,e){var r=g()().format("D/M/YY");return w(t).then(function(t){return function(n){return{columns:[{fit:[80,30],image:t,margin:[60,20,0,0]},{alignment:"right",text:e+" | "+r+" | Page "+n,style:"small",margin:[0,25,60,0]}]}}})}function O(t){return w(t).then(function(t){return{fit:[130,50],image:t,margin:[60,60,60,0]}})}var j={h1:{fontSize:12,margin:[0,0,0,10],color:"#222"},h2:{fontSize:10,margin:[0,5,0,5],color:"#222"},header1:{fontSize:16,margin:[0,20,0,20],color:"#222"},header2:{fontSize:14,margin:[0,10,0,10],color:"#222"},header3:{fontSize:12,margin:[0,10,0,0],color:"#444"},horizontalLine:{margin:[0,0,0,0],fontSize:1},ol:{bold:!1,color:"#666",fontSize:8,margin:[10,10,10,10]},p:{fontSize:8,bold:!1,color:"#666"},small:{fontSize:8,bold:!1,color:"#666"},table:{fontSize:8,lineHeight:1.1,color:"#444"},ul:{bold:!1,color:"#666",fontSize:8,margin:[10,10,10,10]}},x=r(6),A=r(5),S=r.n(A)()({Promise:d.a}).fetch;function w(t){return S(t).then(function(e){return e.ok?e.arrayBuffer():d.a.reject(new Error("Failed to fetch image: "+t))}).then(function(t){return"data:image/jpeg;base64,"+function(t){var e="";return[].slice.call(new Uint8Array(t)).forEach(function(t){return e+=String.fromCharCode(t)}),Object(x.btoa)(e)}(t)})}var T=function(){return function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var r=[],n=!0,o=!1,i=void 0;try{for(var a,u=t[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{!n&&u.return&&u.return()}finally{if(o)throw i}}return r}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}();function L(t){var e=t.content,r=t.fileTitle,n=t.footer,s=void 0===n?p:n,f=t.header,b=void 0===f?O:f,h=t.logoUrl,m=void 0===h?l:h,v=t.pageMargins,y=void 0===v?o:v,g=t.pageOrientation,x=void 0===g?i:g,A=t.pageSize,S=void 0===A?a:A,w=t.styles,L=void 0===w?{}:w,C=t.title,z=void 0===C?u:C,D=Object(c.defaults)({},L,j),U={title:r},E=[function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(b(m)),function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(e),function(t){if(Object(c.isFunction)(t))return d.a.resolve(t());return d.a.resolve(t)}(s(l,z))];return d.a.all(E).then(function(t){var e=T(t,3);return{header:e[0],content:e[1],footer:e[2],info:U,pageMargins:y,pageOrientation:x,pageSize:S,styles:D}})}function C(t,e){return Object(c.isEmpty)(e)?"No users assigned":Object(c.chain)(e).map(function(e){return R(t,e)}).compact().join(", ").value()}function z(t){var e=t.entity,r=t.timezone,n=e.createdAt,o=e.gps,i=e.items,a=e.score,u=G(t),l=Object(c.get)(o,"reverseGeocoded.label","Unknown Location"),s=D(i,t),d=M(t),f=W(a.result),b=I(n,r);return{gpsText:l,groupedData:s,locationText:u,referenceLabel:d.label,referenceValue:d.value,scoreText:f,timezoneDatetime:b}}function D(t,e){var r=e.settings,n=(r=void 0===r?{}:r).awsS3BaseUrl,o=r.cloudinaryBaseUrl,i=Object(c.groupBy)(t,"group.id"),a={overallActualScore:0,overallMaximumScore:0};return a.items=Object(c.map)(i,function(t,e){var r={key:e,groupMaximumScore:0,groupActualScore:0,title:t[0].group.label};return r.items=t.map(function(t,i){var u=t.assets,l=t.comments,s=t.label,d=t.score,f=t.scores,b=t.scoreWeight,m=t.weight,v=Object(c.maxBy)(f,"value").value*m,y=Object(c.find)(f,{value:d});return r.groupMaximumScore+=v,r.groupActualScore+=b,a.overallMaximumScore+=v,a.overallActualScore+=b,{assetCount:u.length,assets:u.map(function(t,r){return{assetUrl:h(t,{awsS3BaseUrl:n,cloudinaryBaseUrl:o,width:800}),key:e+"-item-asset-"+r,thumbnailUrl:h(t,{awsS3BaseUrl:n,cloudinaryBaseUrl:o,width:100})}}),comments:l,key:e+"-item-"+i,label:s,scoreLabel:y?y.label:"Unknown Score"}}),r}),a}var U=["label","postalcode"];function E(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:U;return t?Object(c.chain)(t).pick(e).values().compact().join(", ").value():"Unknown Location"}function P(t){var e=t.entity,r=t.timezone,n=t.users,o=e.assignees,i=e.createdAt,a=e.duration,u=e.gps,l=e.status,s=e.user,d=C(n,o),f=_(g.a.duration(a,"minutes")),b=R(n,s),h=Object(c.get)(u,"reverseGeocoded.label","Unknown Location"),m="closed"===l,v=G(t),y=N(l),p=y.style;return{assigneeNames:d,durationText:f,gpsText:h,fullName:b,isClosedStatus:m,locationText:v,statusStyle:p,statusColor:p.color,statusText:Object(c.upperCase)(y.text),timezoneDatetime:I(i,r)}}r(3);function k(t){var e=t.entity,r=void 0===e?{}:e,n=t.timezone,o=t.users,i=r.assignees,a=r.author,u=r.createdAt,l=r.description,s=void 0===l?"-":l,d=r.due,f=r.geometryReverseGeocoded,b=r.reference,h=void 0===b?"-":b,m=r.status,v=C(o,i),y=R(o,a),p=E(f),O=N(m),j=O.style,x=j.color,A=Object(c.upperCase)(O.text);return{assigneeNames:v,authorFullName:y,createdTimezoneDateTime:I(u,n),description:s,dueDateTimezoneDateTime:I(d,n),locationText:p,statusStyle:j,statusColor:x,statusText:A,reference:h,timezoneAbbrText:g()().tz(n).format("z")}}function G(t){var e=t.entity,r=t.locations,n=void 0===r?{}:r,o=t.zones,i=void 0===o?{}:o,a=e.area,u=e.location,l=e.zone,s=void 0,d=void 0,f=Object(c.get)(a,"label");return u&&(s=Object(c.isString)(u)?Object(c.get)(n,u+".name"):u.name),l&&(d=Object(c.isString)(l)?Object(c.get)(i,l+".name"):l.name),s||d?Object(c.compact)([s,d]).join(", "):f||"Unknown Location"}function _(t){var e=Math.floor(t.asDays()),r=Math.floor(t.asHours()),n=t.hours(),o=t.minutes(),i=t.seconds();return e>0?e+"d "+n+"h":r>0?r+"h "+o+"m":o>0?o+"m":i+"s"}function M(t){var e=t.entity,r=t.users,n=e.user,o="Reference",i="Unknown Reference";n&&(o="User",i=R(r,n));return{label:o,value:i}}var N=Object(c.memoize)(function(t){switch(t){case"closed":return{style:{color:"#D0021B"},text:"Closed"};case"in-progress":return{style:{color:"#00AAE4"},text:"In Progress"};case"open":return{style:{color:"#FF8C2F"},text:"Open"};default:return{style:{color:"#666666"},text:"Unknown"}}});function B(t){var e=t.entity,r=void 0===e?{}:e,n=t.timezone,o=r.createdAt,i=r.gps,a=Object(c.get)(i,"reverseGeocoded.label","Unknown Location"),u=G(t),l=M(t),s=I(o,n);return{locationText:u,gpsText:a,referenceLabel:l.label,referenceValue:l.value,timezoneDatetime:s}}function I(t,e){var r=!(arguments.length>2&&void 0!==arguments[2])||arguments[2],n=g()(t).tz(e),o=n.format("MMM D h:mma"),i=n.format("z");return r?o+" ("+i+")":""+o}function R(t,e){var r=(Object(c.find)(t,["user._id",e])||{}).user;return r?r.firstName+" "+r.lastName:"Unknown User"}function W(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return Math.floor(100*t)+"%"}function F(){return{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}}var q=r(4),H=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};var J=["ol","ul"],V=/.*\n.*/,Y=/\s+/g;function Z(t){if(!Object(c.isPlainObject)(t))throw new Error("InvalidDataError");var e=t.children,r=void 0===e?[]:e,n=t.data,o=void 0===n?"":n,i=t.name,a=void 0===i?"":i;if("text"===t.type&&o){var u=o.replace(Y," ").trim();return u&&u+" "}var l=Object(c.reject)(r,["data",V]),s=Object(c.compact)(Object(c.map)(l,Z)),d=Object(c.includes)(J,a)?a:"text",f=Object(c.isArray)(s)&&1===s.length&&Object(c.isString)(s[0])?s[0]:s;return H({},$(t),function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},d,f))}function $(t){var e=t.name,r=void 0===e?"":e,n={};return"em"===r&&(n.italics=!0),"ins"===r&&(n.decoration="underline"),"strong"===r&&(n.bold=!0),n.bold||n.decoration||n.italics||(n.style=r),n}function Q(t){if(!t||!Object(c.isString)(t))throw new Error("InvalidDataError");return q.htmlparser2.parseDOM(t)}function K(t){if(!t)throw new Error("InvalidDataError");var e=Q(t);return Object(c.compact)(Object(c.map)(e,Z))}function X(t){var e=Object(c.chunk)(t,n);return Object(c.map)(e,function(t){var e=Object(c.fill)(Array(n),{text:""}),r=Object(c.concat)(t,Object(c.slice)(e,t.length));return{table:{body:[[].concat(function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}(r))],widths:[160,160,160]},layout:"noBorders",margin:[0,5,0,5]}})}function tt(t){return Object(c.isBoolean)(t)?t?"Yes":"No":Object(c.isObjectLike)(t)&&Object(c.isEmpty)(t)?" - ":t||" - "}function et(t){var e=t.body,r=t.layout,n=void 0===r?"noBorders":r,o=t.margin,i=void 0===o?[0,10,0,20]:o,a=t.widths,u=t.style,l=void 0===u?"table":u;return Object(c.isObject)(l)&&(l=Object(c.defaults)({},l,j.table)),{layout:n,margin:i,style:l,table:{body:e,widths:a,headerRows:1}}}function rt(t){return et(Object(c.defaults)({},t,{widths:[130,"*"]}))}function nt(t){return et(Object(c.defaults)({},t,{widths:[130,"*","*","*"]}))}var ot=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};function it(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return ot({text:t=t||"Unknown"},e)}var at=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};function ut(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function lt(t,e){var r="Audit Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,r=e.footerFields,n=void 0===r?{}:r,o=e.headerFields,i=void 0===o?{}:o,a=e.title,u=void 0===a?"Unknown":a,l=z(t),s=[[{text:"Title",bold:!0},u],[{text:"Location",bold:!0},l.locationText],[{text:"GPS Location",bold:!0},l.gpsText],[{text:l.referenceLabel,bold:!0},l.referenceValue],[{text:"Created",bold:!0},l.timezoneDatetime],[{text:"Score",bold:!0},l.scoreText]],f=[[{text:"Total Score",bold:!0},l.groupedData.overallActualScore+" / "+l.groupedData.overallMaximumScore]],h=it("Audit Report",{style:"header1"}),m=rt({body:s}),y=it("Details",{style:"header2"}),g=rt({body:f,style:{fontSize:12},margin:[0,20,0,10]}),p={entry:b(l.groupedData.items),footer:v(n.formGroups,t),header:v(i.formGroups,t)};return d.a.props(p).then(function(t){var e=t.entry,r=t.footer,n=t.header,o=e.details,i=void 0===o?[]:o,a=e.photos,u=void 0===a?[]:a,l=r.details,s=void 0===l?[]:l,d=r.photos,f=void 0===d?[]:d,b=n.details,v=void 0===b?[]:b,p=n.photos,O=void 0===p?[]:p;return[h,m,y].concat(ut(Object(c.reject)(v,["text","Details"])),ut(i),[g],ut(Object(c.reject)(s,["text","Details"])),ut(O),ut(u),ut(f))})}(e).then(function(e){return L(at({content:e,fileTitle:r},t))})}var ct=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};function st(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function dt(t,e){var r="Issue Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,r=t.timezone,n=e.entry,o=e.title,i=e.timeline,a=void 0===i?[]:i,u=P(t),l=Object(c.map)(a,ft),s=[[{text:"Title",bold:!0},o],[{text:"Status",bold:!0},{text:u.statusText,color:u.statusColor}],[{text:"Assignees",bold:!0},u.assigneeNames],[{text:"Location",bold:!0},u.locationText],[{text:"GPS Location",bold:!0},u.gpsText],[{text:"Raised by",bold:!0},u.fullName],[{text:"Created",bold:!0},u.timezoneDatetime]];u.isClosedStatus&&s.push([{text:"Duration",bold:!0},u.durationText]);var d=Object(c.isEmpty)(l)?[["No Timeline data"]]:Object(c.map)(l,function(t){return function(e){var r=e.text,n=e.timestamp,o=I(n,t);return[{text:o,bold:!0},r]}}(r)),f=it("Issue Report",{style:"header1"}),b=rt({body:s}),h=it("Timeline",{style:"header2"}),m={style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},y=rt({body:d});return v(n.formGroups,t).then(function(t){var e=t.details,r=void 0===e?[]:e,n=t.photos,o=void 0===n?[]:n;return[f,b,h,m,y].concat(st(r),st(o))})}(e).then(function(e){return L(ct({content:e,fileTitle:r},t))})}function ft(t){var e=t._id,r=t.meta,n=void 0===r?{}:r,o=t.timestamp;return{_id:e,text:"status"===n.field?function(t){var e=t.meta,r=t.source,n=t.type,o=Object(c.get)(e,"next"),i=Object(c.get)(r,"meta.firstName"),a=Object(c.get)(r,"meta.lastName"),u=i&&a?i+" "+a:"Unknown User",l="issue-new"===n,s="issue-update"===n,d="open"===o,f=N(o).text;return l&&d?"Issue opened by "+u:l&&!d?"Issue opened with status "+f+" by "+u:s?"Issue updated to "+f+" by "+u:"Unknown status timeline change"}(t):null,timestamp:o}}var bt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};var ht=[{text:"Type",bold:!0},{text:"User",bold:!0},{text:"Start Time",bold:!0},{text:"Start Location",bold:!0},{text:"End Time",bold:!0},{text:"End Location",bold:!0},{text:"Duration",bold:!0}];function mt(t,e){var r="Job Report - "+Object(c.get)(e,"entity.title","Unknown"),n=function(t){var e=t.entity.title,r=k(t),n=[[{text:"Location",bold:!0},r.locationText],[{text:"Author",bold:!0},r.authorFullName],[{text:"Reference",bold:!0},r.reference],[{text:"Description",bold:!0},r.description],[{text:"Due Date",bold:!0},r.dueDateTimezoneDateTime],[{text:"Assignees",bold:!0},r.assigneeNames],[{text:"Status",bold:!0},{text:r.statusText,color:r.statusColor}],[{text:"Created",bold:!0},r.createdTimezoneDateTime],[{text:"Timezone",bold:!0},r.timezoneAbbrText]],o=it("Job Report: "+e,{style:"header1"}),i=rt({body:n}),a=it("Job Activities",{style:"header2"}),u=et(function(t){var e=t.jobActivities,r=t.timezone,n=t.users;if(Object(c.isEmpty)(e))return{body:[["No Job Activities Data"]],widths:"*"};var o=Object(c.map)(e,function(t){var e=t.entity,o=e.type,i=e.duration,a=e.user,u=e.start,l=void 0===u?{}:u,s=e.end,d=void 0===s?{}:s,f=R(n,a),b=g.a.duration(i,"minutes"),h=i?_(b):"-",m=l.time,v=Object(c.get)(l,"geometryReverseGeocoded.label","-"),y=d.time,p=Object(c.get)(d,"geometryReverseGeocoded.label","-"),O=m?I(m,r,!1):"-",j=y?I(y,r,!1):"-";return[o,f,O,v,j,p,h]});return{body:[ht].concat(function(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}(o)),widths:[70,80,60,"*",60,"*",50]}}(t));return[o,i,a,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}},u,{style:"horizontalLine",table:{widths:["*"],body:[[" "],[" "]]},layout:{hLineWidth:function(t,e){return 0===t||t===e.table.body.length?0:.5},vLineWidth:function(){return 0},hLineColor:function(){return"#ddd"}}}]}(e);return L(bt({content:n,fileTitle:r,pageOrientation:"landscape"},t))}var vt=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t};function yt(t){if(Array.isArray(t)){for(var e=0,r=Array(t.length);e<t.length;e++)r[e]=t[e];return r}return Array.from(t)}function gt(t,e){var r="Task Report - "+Object(c.get)(e,"entity.title","Unknown");return function(t){var e=t.entity,r=e.entry,n=e.title,o=B(t),i=[[{text:"Title",bold:!0},n],[{text:"Location",bold:!0},o.locationText],[{text:"GPS Location",bold:!0},o.gpsText],[{text:o.referenceLabel,bold:!0},o.referenceValue],[{text:"Created",bold:!0},o.timezoneDatetime]],a=it("Task Report",{style:"header1"}),u=rt({body:i});return v(r.formGroups,t).then(function(t){var e=t.details,r=void 0===e?[]:e,n=t.photos,o=void 0===n?[]:n;return[a,u].concat(yt(r),yt(o))})}(e).then(function(e){return L(vt({content:e,fileTitle:r},t))})}r.d(e,"DEFAULT_IMAGE_ROW_LENGTH",function(){return n}),r.d(e,"DEFAULT_PAGE_MARGINS",function(){return o}),r.d(e,"DEFAULT_PAGE_ORIENTATION",function(){return i}),r.d(e,"DEFAULT_PAGE_SIZE",function(){return a}),r.d(e,"DEFAULT_TITLE",function(){return u}),r.d(e,"LIGHTHOUSE_LOGO_URL",function(){return l}),r.d(e,"buildAuditContent",function(){return b}),r.d(e,"buildFetchUrl",function(){return h}),r.d(e,"buildTemplateContent",function(){return v}),r.d(e,"defaultFooter",function(){return p}),r.d(e,"defaultHeader",function(){return O}),r.d(e,"defaultStyles",function(){return j}),r.d(e,"fetchImage",function(){return w}),r.d(e,"generateDefinition",function(){return L}),r.d(e,"getAssigneesFullNames",function(){return C}),r.d(e,"getAuditEntryDetails",function(){return z}),r.d(e,"getAuditItemsData",function(){return D}),r.d(e,"getGeometryGeocodedString",function(){return E}),r.d(e,"getIssueDetails",function(){return P}),r.d(e,"getJobDetails",function(){return k}),r.d(e,"getLocationText",function(){return G}),r.d(e,"getPrettyDuration",function(){return _}),r.d(e,"getReferenceDetails",function(){return M}),r.d(e,"getStatusDetails",function(){return N}),r.d(e,"getTaskEntryDetails",function(){return B}),r.d(e,"getTimezoneDatetime",function(){return I}),r.d(e,"getUserFullName",function(){return R}),r.d(e,"getValueAsPercentage",function(){return W}),r.d(e,"horizontalLine",function(){return F}),r.d(e,"convertToPdfMake",function(){return Z}),r.d(e,"getStyleAttributes",function(){return $}),r.d(e,"parseHtml",function(){return Q}),r.d(e,"toPdf",function(){return K}),r.d(e,"imagesTable",function(){return X}),r.d(e,"parseValue",function(){return tt}),r.d(e,"table",function(){return et}),r.d(e,"twoColumnTable",function(){return rt}),r.d(e,"fourColumnTable",function(){return nt}),r.d(e,"text",function(){return it}),r.d(e,"buildAuditPdf",function(){return lt}),r.d(e,"buildIssuePdf",function(){return dt}),r.d(e,"buildJobPdf",function(){return mt}),r.d(e,"buildTaskPdf",function(){return gt})},function(t,e,r){"use strict";function n(t){return t<26?String.fromCharCode(t+"A".charCodeAt(0)):t<52?String.fromCharCode(t-26+"a".charCodeAt(0)):t<62?String.fromCharCode(t-52+"0".charCodeAt(0)):62===t?"+":63===t?"/":void 0}t.exports=function(t){let e;for(t=`${t}`,e=0;e<t.length;e++)if(t.charCodeAt(e)>255)return null;let r="";for(e=0;e<t.length;e+=3){const o=[void 0,void 0,void 0,void 0];o[0]=t.charCodeAt(e)>>2,o[1]=(3&t.charCodeAt(e))<<4,t.length>e+1&&(o[1]|=t.charCodeAt(e+1)>>4,o[2]=(15&t.charCodeAt(e+1))<<2),t.length>e+2&&(o[2]|=t.charCodeAt(e+2)>>6,o[3]=63&t.charCodeAt(e+2));for(let t=0;t<o.length;t++)void 0===o[t]?r+="=":r+=n(o[t])}return r}},function(t,e,r){"use strict";function n(t){return/[A-Z]/.test(t)?t.charCodeAt(0)-"A".charCodeAt(0):/[a-z]/.test(t)?t.charCodeAt(0)-"a".charCodeAt(0)+26:/[0-9]/.test(t)?t.charCodeAt(0)-"0".charCodeAt(0)+52:"+"===t?62:"/"===t?63:void 0}t.exports=function(t){if((t=(t=`${t}`).replace(/[ \t\n\f\r]/g,"")).length%4==0&&(t=t.replace(/==?$/,"")),t.length%4==1||/[^+/0-9A-Za-z]/.test(t))return null;let e="",r=0,o=0;for(let i=0;i<t.length;i++)r<<=6,r|=n(t[i]),24===(o+=6)&&(e+=String.fromCharCode((16711680&r)>>16),e+=String.fromCharCode((65280&r)>>8),e+=String.fromCharCode(255&r),r=o=0);return 12===o?(r>>=4,e+=String.fromCharCode(r)):18===o&&(r>>=2,e+=String.fromCharCode((65280&r)>>8),e+=String.fromCharCode(255&r)),e}}])}); |
{ | ||
"name": "@lighthouse/common", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "", | ||
@@ -33,3 +33,5 @@ "main": "dist/lighthouse-common.js", | ||
"homepage": "https://github.com/Lighthouse-io/common#readme", | ||
"dependencies": {}, | ||
"dependencies": { | ||
"abab": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
@@ -69,6 +71,3 @@ "babel-cli": "^6.26.0", | ||
"react-html-parser": "2.x.x" | ||
}, | ||
"optionalDependencies": { | ||
"filereader": "^0.10.3" | ||
} | ||
} |
@@ -0,1 +1,2 @@ | ||
import { btoa } from 'abab' | ||
import fetchPonyfill from 'fetch-ponyfill' | ||
@@ -9,16 +10,20 @@ import Promise from 'bluebird' | ||
.then(response => { | ||
if (response.ok) return response.blob() | ||
if (response.ok) return response.arrayBuffer() | ||
return Promise.reject(new Error(`Failed to fetch image: ${url}`)) | ||
}) | ||
.then( | ||
blob => | ||
new Promise((resolve, reject) => { | ||
// NOTE: Web FileReader API is switched for | ||
// 'filereader' package when webpack commonjs build | ||
const reader = new FileReader() | ||
reader.onloadend = () => resolve(reader.result) | ||
reader.onerror = reject | ||
reader.readAsDataURL(blob) | ||
}) | ||
) | ||
.then(buffer => { | ||
const base64Flag = 'data:image/jpeg;base64,' | ||
const imageStr = arrayBufferToBase64(buffer) | ||
return `${base64Flag}${imageStr}` | ||
}) | ||
} | ||
function arrayBufferToBase64(buffer) { | ||
let binary = '' | ||
const bytes = [].slice.call(new Uint8Array(buffer)) | ||
bytes.forEach(b => (binary += String.fromCharCode(b))) | ||
return btoa(binary) | ||
} |
262
test.js
const lib = require('./dist/lighthouse-common') | ||
console.log(lib) | ||
const entity = { | ||
_id: '5b3c26a4b396456c4821a3a8', | ||
updatedAt: '2018-07-04T01:45:08.418Z', | ||
createdAt: '2018-07-04T01:45:08.418Z', | ||
application: '56b2dc56d4c6f552c5cc0c94', | ||
title: 'Signature Test', | ||
date: '2018-07-04T01:45:06.247Z', | ||
location: '56b2de0d2eec92db6a46c5a7', | ||
user: '59e41dccaffc27533f14bf3d', | ||
zone: '57c6377421c407ee44f2228f', | ||
audit: '5b30c13d86fe133585a7a4a0', | ||
__v: 0, | ||
footerFields: { | ||
relations: [], | ||
formGroups: [ | ||
{ | ||
updatedAt: '2018-06-25T10:15:58.550Z', | ||
createdAt: '2018-06-25T10:15:58.550Z', | ||
label: 'Signature', | ||
_id: '5b30c0dea8bdb23ad69eaaa0', | ||
fieldGroups: [ | ||
{ | ||
_id: '5b30c0dea8bdb23ad69eaaa1', | ||
fields: [ | ||
{ | ||
label: 'Please Sign', | ||
fieldtype: 'text', | ||
options: { | ||
type: 'signature', | ||
}, | ||
_id: '5b30c0dea8bdb23ad69eaaa2', | ||
value: 'data:image/png;base64,ENCODED_DATA_FIXTURE', | ||
validation: { | ||
enum: [], | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
repeatable: 1, | ||
}, | ||
], | ||
}, | ||
headerFields: { | ||
relations: [], | ||
formGroups: [ | ||
{ | ||
updatedAt: '2018-06-25T10:15:25.007Z', | ||
createdAt: '2018-06-25T10:15:25.007Z', | ||
label: 'Details', | ||
_id: '5b30c0bd86fe133585a7a479', | ||
fieldGroups: [ | ||
{ | ||
_id: '5b30c0bd86fe133585a7a47a', | ||
fields: [ | ||
{ | ||
label: 'Priority', | ||
fieldtype: 'select', | ||
options: { | ||
type: 'select-single', | ||
}, | ||
_id: '5b30c0bd86fe133585a7a47b', | ||
value: 'High', | ||
validation: { | ||
enum: ['High', 'Medium', 'Low'], | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
repeatable: 1, | ||
}, | ||
], | ||
}, | ||
area: { | ||
floorsRef: [], | ||
}, | ||
score: { | ||
result: 0.75, | ||
actual: 3, | ||
max: 4, | ||
}, | ||
gps: { | ||
floorsRef: [], | ||
}, | ||
participants: [], | ||
items: [ | ||
{ | ||
scoreWeight: 0.5, | ||
label: 'Are the floors clean?', | ||
weight: 1, | ||
_id: '5b30c13d86fe133585a7a4ad', | ||
comments: 'Yes they are clean', | ||
score: 0.5, | ||
assets: [ | ||
'56b2dc56d4c6f552c5cc0c94/BB220A8E-1395-4AB0-AF41-E33886DF7BF5-0A7E4D5B-4B57-4AC3-8BD9-6546A2809F82.jpg', | ||
'56b2dc56d4c6f552c5cc0c94/BB220A8E-1395-4AB0-AF41-E33886DF7BF5-BD3B47B1-BB84-4209-9720-1C2D4D488999.jpg', | ||
], | ||
scores: [ | ||
{ | ||
label: 'Pass', | ||
value: 1, | ||
_id: '5b30c13d86fe133585a7a4b0', | ||
}, | ||
{ | ||
label: 'IR', | ||
value: 0.5, | ||
_id: '5b30c13d86fe133585a7a4af', | ||
}, | ||
{ | ||
label: 'Fail', | ||
value: 0, | ||
_id: '5b30c13d86fe133585a7a4ae', | ||
}, | ||
], | ||
group: { | ||
id: '0', | ||
label: 'Indoors', | ||
}, | ||
}, | ||
{ | ||
scoreWeight: 0.5, | ||
label: 'Are the windows clean?', | ||
weight: 1, | ||
_id: '5b30c13d86fe133585a7a4a9', | ||
comments: | ||
'Windows dirty\n\ud83d\udc80\u2620\ufe0f\ud83d\udc7e\ud83d\ude3f', | ||
score: 0.5, | ||
assets: [ | ||
'56b2dc56d4c6f552c5cc0c94/BB220A8E-1395-4AB0-AF41-E33886DF7BF5-382B9975-03C3-4C22-AFF5-DE82C75EA435.jpg', | ||
], | ||
scores: [ | ||
{ | ||
label: 'Pass', | ||
value: 1, | ||
_id: '5b30c13d86fe133585a7a4ac', | ||
}, | ||
{ | ||
label: 'IR', | ||
value: 0.5, | ||
_id: '5b30c13d86fe133585a7a4ab', | ||
}, | ||
{ | ||
label: 'Fail', | ||
value: 0, | ||
_id: '5b30c13d86fe133585a7a4aa', | ||
}, | ||
], | ||
group: { | ||
id: '0', | ||
label: 'Indoors', | ||
}, | ||
}, | ||
{ | ||
scoreWeight: 1, | ||
label: 'Is the exterior in good condition', | ||
weight: 1, | ||
_id: '5b30c13d86fe133585a7a4a5', | ||
comments: 'Brvxsvcc', | ||
score: 1, | ||
assets: [ | ||
'56b2dc56d4c6f552c5cc0c94/BB220A8E-1395-4AB0-AF41-E33886DF7BF5-ACA705A2-EC3C-4E4D-BBED-D7F8DF2D678D.jpg', | ||
], | ||
scores: [ | ||
{ | ||
label: 'Pass', | ||
value: 1, | ||
_id: '5b30c13d86fe133585a7a4a8', | ||
}, | ||
{ | ||
label: 'IR', | ||
value: 0.5, | ||
_id: '5b30c13d86fe133585a7a4a7', | ||
}, | ||
{ | ||
label: 'Fail', | ||
value: 0, | ||
_id: '5b30c13d86fe133585a7a4a6', | ||
}, | ||
], | ||
group: { | ||
id: '01', | ||
label: 'Outdoors', | ||
}, | ||
}, | ||
{ | ||
scoreWeight: 1, | ||
label: 'Are the bins accessible', | ||
weight: 1, | ||
_id: '5b30c13d86fe133585a7a4a1', | ||
comments: 'Aaaaaa', | ||
score: 1, | ||
assets: [ | ||
'56b2dc56d4c6f552c5cc0c94/BB220A8E-1395-4AB0-AF41-E33886DF7BF5-09859ADB-7201-43AC-8B34-86F69DCDEF78.jpg', | ||
], | ||
scores: [ | ||
{ | ||
label: 'Pass', | ||
value: 1, | ||
_id: '5b30c13d86fe133585a7a4a4', | ||
}, | ||
{ | ||
label: 'IR', | ||
value: 0.5, | ||
_id: '5b30c13d86fe133585a7a4a3', | ||
}, | ||
{ | ||
label: 'Fail', | ||
value: 0, | ||
_id: '5b30c13d86fe133585a7a4a2', | ||
}, | ||
], | ||
group: { | ||
id: '01', | ||
label: 'Outdoors', | ||
}, | ||
}, | ||
], | ||
zones: [], | ||
} | ||
const locations = { | ||
'56b2de0d2eec92db6a46c5a7': { | ||
_id: '56b2de0d2eec92db6a46c5a7', | ||
name: 'Test Location', | ||
}, | ||
} | ||
const timezone = 'Australia/Melbourne' | ||
const users = { | ||
'59e41dccaffc27533f14bf3d': { | ||
user: { | ||
_id: '59e41dccaffc27533f14bf3d', | ||
firstName: 'Testing', | ||
lastName: 'Tester', | ||
}, | ||
}, | ||
} | ||
const zones = { | ||
'57c6377421c407ee44f2228f': { | ||
_id: '57c6377421c407ee44f2228f', | ||
name: 'Test Zone', | ||
}, | ||
} | ||
const data = { | ||
entity, | ||
locations, | ||
settings: { | ||
awsS3BaseUrl: 'https://uploads-lighthouse-io.s3.amazonaws.com', | ||
cloudinaryBaseUrl: | ||
'https://res.cloudinary.com/lighthouseio/image/fetch', | ||
}, | ||
timezone, | ||
zones, | ||
users, | ||
} | ||
lib.buildAuditPdf({}, data).then((def) => console.log(def)) |
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin | ||
const path = require('path') | ||
const webpack = require('webpack') | ||
@@ -17,3 +16,8 @@ const reports = path.join(__dirname, 'reports') | ||
'fetch-ponyfill': 'fetch-ponyfill', | ||
lodash: 'lodash', | ||
lodash: { | ||
amd: 'lodash', | ||
commonjs: 'lodash', | ||
commonjs2: 'lodash', | ||
root: '_', | ||
}, | ||
moment: 'moment', | ||
@@ -35,3 +39,6 @@ 'moment-timezone': 'moment-timezone', | ||
library: 'lighthouse-common', | ||
libraryTarget: 'commonjs', | ||
libraryTarget: 'umd', | ||
umdNamedDefine: true, | ||
// TODO: Remove this when bug is fixed: https://github.com/webpack/webpack/issues/6784 | ||
globalObject: `typeof self !== 'undefined' ? self : this`, | ||
}, | ||
@@ -45,7 +52,3 @@ plugins: [ | ||
}), | ||
new webpack.ProvidePlugin({ | ||
'FileReader': 'filereader', | ||
}), | ||
], | ||
target: 'node', | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
407797
2999
1
+ Addedabab@^2.0.0
+ Addedabab@2.0.6(transitive)
- Removedfilereader@0.10.3(transitive)