object-unpacker
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,1 +0,1 @@ | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.ObjectUnpacker=r():e.ObjectUnpacker=r()}(self,(function(){return(()=>{"use strict";var e={65:function(e,r,t){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.logger=r.Options=r.Level=void 0;var o,i=n(t(501));!function(e){e[e.silent=0]="silent",e[e.trace=10]="trace",e[e.debug=20]="debug",e[e.info=30]="info",e[e.warn=40]="warn",e[e.error=50]="error",e[e.fatal=60]="fatal"}(o=r.Level||(r.Level={}));var s=function(e,r){this.consoleOnly=e,this.level=r};r.Options=s;var a=(0,i.default)(),l=function(){function e(e){this.options=e}return e.prototype.setConsoleOnly=function(e){this.options.consoleOnly=e},e.prototype.silent=function(e){},e.prototype.trace=function(e){this.options.level<=o.trace&&(this.options.consoleOnly?console.log(e):a.trace(e))},e.prototype.debug=function(e){this.options.level<=o.debug&&(this.options.consoleOnly?console.log(e):a.debug(e))},e.prototype.info=function(e){this.options.level<=o.info&&(this.options.consoleOnly?console.info(e):a.info(e))},e.prototype.warn=function(e){this.options.level<=o.warn&&(this.options.consoleOnly?console.warn(e):a.warn(e))},e.prototype.error=function(e){this.options.level<=o.error&&(this.options.consoleOnly?console.error(e):a.error(e))},e.prototype.fatal=function(e){this.options.level<=o.fatal&&(this.options.consoleOnly?console.error(e):a.fatal(e))},e.prototype.always=function(e){console.log(e)},e.prototype.setLevel=function(e){switch(this.options.level=e,e){case o.silent:a.level="silent";break;case o.trace:a.level="trace";break;case o.debug:a.level="debug";break;case o.info:a.level="info";break;case o.warn:a.level="warn";break;case o.error:a.level="error";break;case o.fatal:a.level="fatal";break;default:a.level="info"}},e}();r.logger=new l(new s(!1,o.info))},571:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Level=r.log=void 0;var n=t(65);Object.defineProperty(r,"log",{enumerable:!0,get:function(){return n.logger}}),Object.defineProperty(r,"Level",{enumerable:!0,get:function(){return n.Level}})},501:(e,r,t)=>{const n=t(346);e.exports=s;const o=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(r){return e(self)||e(window)||e(this)||{}}}().console||{},i={mapHttpRequest:g,mapHttpResponse:g,wrapRequestSerializer:h,wrapResponseSerializer:h,wrapErrorSerializer:h,req:g,res:g,err:function(e){const r={type:e.constructor.name,msg:e.message,stack:e.stack};for(const t in e)void 0===r[t]&&(r[t]=e[t]);return r}};function s(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const t=e.browser.write||o;e.browser.write&&(e.browser.asObject=!0);const n=e.serializers||{},i=function(e,r){return Array.isArray(e)?e.filter((function(e){return"!stdSerializers.err"!==e})):!0===e&&Object.keys(r)}(e.browser.serialize,n);let l=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(l=!1),"function"==typeof t&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),!1===e.enabled&&(e.level="silent");const f=e.level||"info",g=Object.create(t);g.log||(g.log=d),Object.defineProperty(g,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(g,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,a(h,g,"error","log"),a(h,g,"fatal","error"),a(h,g,"warn","error"),a(h,g,"info","log"),a(h,g,"debug","log"),a(h,g,"trace","log")}});const h={transmit:r,serialize:i,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:v(e)};return g.levels=s.levels,g.level=f,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=d,g.serializers=n,g._serialize=i,g._stdErrSerialize=l,g.child=function(t,o){if(!t)throw new Error("missing bindings for child Pino");o=o||{},i&&t.serializers&&(o.serializers=t.serializers);const s=o.serializers;if(i&&s){var a=Object.assign({},n,s),l=!0===e.browser.serialize?Object.keys(a):i;delete t.serializers,c([t],l,a,this._stdErrSerialize)}function f(e){this._childLevel=1+(0|e._childLevel),this.error=u(e,t,"error"),this.fatal=u(e,t,"fatal"),this.warn=u(e,t,"warn"),this.info=u(e,t,"info"),this.debug=u(e,t,"debug"),this.trace=u(e,t,"trace"),a&&(this.serializers=a,this._serialize=l),r&&(this._logEvent=p([].concat(e._logEvent.bindings,t)))}return f.prototype=this,new f(this)},r&&(g._logEvent=p()),g}function a(e,r,t,n){const i=Object.getPrototypeOf(r);r[t]=r.levelVal>r.levels.values[t]?d:i[t]?i[t]:o[t]||o[n]||d,function(e,r,t){var n;(e.transmit||r[t]!==d)&&(r[t]=(n=r[t],function(){const i=e.timestamp(),a=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===o?o:this;for(var p=0;p<a.length;p++)a[p]=arguments[p];if(e.serialize&&!e.asObject&&c(a,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?n.call(u,l(this,t,a,i)):n.apply(u,a),e.transmit){const n=e.transmit.level||r.level,o=s.levels.values[n],l=s.levels.values[t];if(l<o)return;f(this,{ts:i,methodLevel:t,methodValue:l,transmitLevel:n,transmitValue:s.levels.values[e.transmit.level||r.level],send:e.transmit.send,val:r.levelVal},a)}}))}(e,r,t)}function l(e,r,t,o){e._serialize&&c(t,e._serialize,e.serializers,e._stdErrSerialize);const i=t.slice();let a=i[0];const l={};o&&(l.time=o),l.level=s.levels.values[r];let u=1+(0|e._childLevel);if(u<1&&(u=1),null!==a&&"object"==typeof a){for(;u--&&"object"==typeof i[0];)Object.assign(l,i.shift());a=i.length?n(i.shift(),i):void 0}else"string"==typeof a&&(a=n(i.shift(),i));return void 0!==a&&(l.msg=a),l}function c(e,r,t,n){for(const o in e)if(n&&e[o]instanceof Error)e[o]=s.stdSerializers.err(e[o]);else if("object"==typeof e[o]&&!Array.isArray(e[o]))for(const n in e[o])r&&r.indexOf(n)>-1&&n in t&&(e[o][n]=t[n](e[o][n]))}function u(e,r,t){return function(){const n=new Array(1+arguments.length);n[0]=r;for(var o=1;o<n.length;o++)n[o]=arguments[o-1];return e[t].apply(this,n)}}function f(e,r,t){const n=r.send,o=r.ts,i=r.methodLevel,s=r.methodValue,a=r.val,l=e._logEvent.bindings;c(t,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=o,e._logEvent.messages=t.filter((function(e){return-1===l.indexOf(e)})),e._logEvent.level.label=i,e._logEvent.level.value=s,n(i,e._logEvent,a),e._logEvent=p(l)}function p(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function v(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?y:b}function g(){return{}}function h(e){return e}function d(){}function y(){return!1}function b(){return Date.now()}s.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},s.stdSerializers=i,s.stdTimeFunctions=Object.assign({},{nullTime:y,epochTime:b,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},346:e=>{function r(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}e.exports=function(e,t,n){var o=n&&n.stringify||r;if("object"==typeof e&&null!==e){var i=t.length+1;if(1===i)return e;var s=new Array(i);s[0]=o(e);for(var a=1;a<i;a++)s[a]=o(t[a]);return s.join(" ")}if("string"!=typeof e)return e;var l=t.length;if(0===l)return e;for(var c="",u=0,f=-1,p=e&&e.length||0,v=0;v<p;){if(37===e.charCodeAt(v)&&v+1<p){switch(f=f>-1?f:0,e.charCodeAt(v+1)){case 100:case 102:if(u>=l)break;if(null==t[u])break;f<v&&(c+=e.slice(f,v)),c+=Number(t[u]),f=v+2,v++;break;case 105:if(u>=l)break;if(null==t[u])break;f<v&&(c+=e.slice(f,v)),c+=Math.floor(Number(t[u])),f=v+2,v++;break;case 79:case 111:case 106:if(u>=l)break;if(void 0===t[u])break;f<v&&(c+=e.slice(f,v));var g=typeof t[u];if("string"===g){c+="'"+t[u]+"'",f=v+2,v++;break}if("function"===g){c+=t[u].name||"<anonymous>",f=v+2,v++;break}c+=o(t[u]),f=v+2,v++;break;case 115:if(u>=l)break;f<v&&(c+=e.slice(f,v)),c+=String(t[u]),f=v+2,v++;break;case 37:f<v&&(c+=e.slice(f,v)),c+="%",f=v+2,v++,u--}++u}++v}return-1===f?e:(f<p&&(c+=e.slice(f)),c)}},616:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createObjectUnpacker=void 0;var n=t(89);r.createObjectUnpacker=function(){return new n.ObjectUnpackerImpl}},89:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ObjectUnpackerImpl=void 0;var n=t(980),o=t(102),i=t(571),s=t(397),a=function(){function e(){}return e.prototype.convert=function(e,r,t){try{var a=s.toInstructionSchema(t),c=o.transform(r,o.prefixReferences),u=new Map;o.indexObject(n.INDEX_NAMESPACE,u,c["?"]),o.indexObject(n.COMPACT_NAMESPACE,u,c),o.indexObject(n.SUBS_NAMESPACE,u,e);var f=void 0;if(0===a.length)delete(f=c)["?"];else{var p={stack:[{locals:{"/compact":c},result:null}]};s.createUnpacker(a)(p),f=p.stack[0].locals["/expanded"]}return l.resolve(u,f)}catch(p){return i.log.error(p.message),{error:p.message}}},e}();r.ObjectUnpackerImpl=a;var l=n.createReferencesResolver()},980:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FIND_REFS=r.SUBS_NAMESPACE=r.COMPACT_NAMESPACE=r.INDEX_NAMESPACE=r.createReferencesResolver=void 0;var n=t(102);r.createReferencesResolver=function(e){return new o(!!e)},r.INDEX_NAMESPACE="/index",r.COMPACT_NAMESPACE="/compact",r.SUBS_NAMESPACE="/subs",r.FIND_REFS=new RegExp(/%?%[\w-./@]+%?/gm);var o=function(){function e(e){this.localsOnly=e}return e.prototype.resolve=function(e,r){if(null==r)throw new Error("Cannot dereference an undefined dataObject.");if("string"==typeof r)return this.processString(e,r);var t=Array.isArray(r["?"])?r["?"]:[r["?"]];return t&&t.forEach((function(r,t){e.set(""+t,r)})),Array.isArray(r)?this.processArray("",e,r):this.processObject("",e,r)},e.prototype.processArray=function(e,r,t){var n=this,o=[];return t.forEach((function(t,i){var s=e+"."+i;Array.isArray(t)?o.push(n.processArray(s,r,t)):"object"==typeof t?o.push(n.processObject(s,r,t)):"string"==typeof t?o.push(n.processString(r,t)):o.push(t)})),o},e.prototype.processObject=function(e,r,t){var n=this;if(null===t)return null;var o={};return Object.keys(t).forEach((function(i){var s=t[i];if(null!==s){var a=e+"."+i;Array.isArray(s)?o[i]=n.processArray(a,r,s):o[i]="object"==typeof s?n.processObject(a,r,s):"string"==typeof s?n.processString(r,s):s}else o[i]=null})),o},e.prototype.processString=function(e,t){for(var o=this,i=t,s=[],a=r.FIND_REFS.exec(i);null!==a;){var l=a[0];s.push(l),a=r.FIND_REFS.exec(i)}return s.forEach((function(r){if(!r.startsWith("%%")){var t=r.startsWith("%")&&r.endsWith("%")?r.substring(1,r.length-1):r.substring(1);n.isNumeric.test(t)&&(t="/index."+t);var s=e.get(t);if(null!=s&&"string"==typeof i)if(i===r)i="string"!=typeof s||o.localsOnly?s:o.unref(s);else if("object"==typeof s){var a=o.unref(r);console.error(a+" refers to an object or array and cannot be embedded in a string"),i=i.replace(r,""+a)}else i=i.replace(r,""+s);else i=i===r?null:i.replace(r,"")}})),"string"==typeof i?i.replace("%%","%"):null===i&&this.localsOnly?t:i},e.prototype.unref=function(e){return e.replace("/index.","").replace("/subs.","")},e}()},102:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.identity=r.prefixReferences=r.transform=r.indexObject=r.isNumeric=void 0;var n=t(980);r.isNumeric=/^[-]?\d*\.?\d+(?:[Ee][+-]?\d+)?$/,r.indexObject=function(e,t,n){n&&Object.entries(n).forEach((function(n){var o=e.length>0?e+"."+n[0]:""+n[0];t.set(o,n[1]),"object"==typeof n[1]&&r.indexObject(o,t,n[1])}))},r.transform=function(e,t){if(!e)return t(e);if(Array.isArray(e)){var n=[];return e.forEach((function(e){"object"==typeof e?n.push(r.transform(e,t)):n.push(t(e))})),t(n)}if("object"==typeof e){var o={};return Object.entries(e).forEach((function(e){"object"==typeof e[1]?o[e[0]]=r.transform(e[1],t):o[e[0]]=t(e[1])})),t(o)}return t(e)},r.prefixReferences=function(e){return"string"!=typeof e?e:e.replace(n.FIND_REFS,(function(e){if(e.startsWith("%%"))return e;var r=e.charCodeAt(1);return r>47&&r<58?"%"+n.INDEX_NAMESPACE+"."+e.substring(1):"%"+n.SUBS_NAMESPACE+"."+e.substring(1)}))},r.identity=function(e){return e}},397:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createUnpacker=r.createToObjectInstruction=r.createToArrayInstruction=r.createForeachInstruction=r.createProcedureInstruction=r.createGetValueInstruction=r.toInstructionSchema=void 0;var n=t(571),o=t(980),i=t(102),s=o.createReferencesResolver(!0);r.toInstructionSchema=function(e){if(Array.isArray(e)){for(var r=0,t=e;r<t.length;r++){var n=t[r];b(n)}return e}throw new Error("Invalid transformation object - should be an array of Instructions.")},r.createGetValueInstruction=function(e){return function(r){if("getValue"===e.action){n.log.debug('Calling "getValue" :'+e.comment);var t=c(r.stack,e.source);if(!t)return n.log.debug("Source not matched for : "+e.source),null;var o=p([e.key],t).get(e.key);return l(r.stack,e.target,o),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=o,o)}return n.log.debug('Skipping "getValue" :'+e.comment),null}},r.createProcedureInstruction=function(e){var t=function(e){return e};return e.forEach((function(e){var n=r.createUnpacker(e);t=a(t,n)})),t};var a=function(e,r){return function(t){e(t),r(t)}};r.createForeachInstruction=function(e){var t=r.createUnpacker(e.instruction);return function(r){if("foreach"===e.action){n.log.debug('Calling "foreach" :'+e.comment);var o=c(r.stack,e.source);if(o||n.log.debug("Source not matched for : "+e.source),Array.isArray(o)){var i=new Array;o.forEach((function(n){r.stack.push({locals:{},result:null}),r.stack[r.stack.length-1].locals[e.loopVar]=n,t(r),i.push(r.stack[r.stack.length-1].result),r.stack.pop()})),l(r.stack,e.target,i)}}else n.log.debug('Skipping "foreach" :'+e.comment)}},r.createToArrayInstruction=function(e){return function(r){if("toArray"===e.action){n.log.debug('Calling "toArray" :'+e.comment);var t=c(r.stack,e.source);if(!t)return n.log.debug("Source not matched for : "+e.source),null;var o=p(e.keys,t);if(o.size>0){var a=new Array;for(var u in e.values)e.values.hasOwnProperty(u)&&a.push(e.values[u]);i.indexObject("",o,t);var f=s.resolve(o,a);return l(r.stack,e.target,f),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=f,f)}}return n.log.debug('Skipping "toArray" :'+e.comment),null}},r.createToObjectInstruction=function(e){return function(r){if("toObject"===e.action){n.log.debug('Calling "toObject" :'+e.comment);var t=c(r.stack,e.source);if(!t)return n.log.debug("Source not matched for : "+e.source),null;var o=p(e.keys,t);if("object"!=typeof t&&e.keys.length>0&&("string"==typeof t&&t.startsWith("%")||o.set(e.keys[0],t)),o.size>0){var a=new Object;for(var u in e.values)e.values.hasOwnProperty(u)&&(a[u]=e.values[u]);i.indexObject("",o,t);var f=s.resolve(o,a);return l(r.stack,e.target,f),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=f,f)}}return n.log.debug('Skipping "toObject" :'+e.comment),null}};var l=function(e,r,t){if(r.startsWith("/")){var n=r.split(".");return f(e[0].locals,n,t)}n=r.split(".");var o=e.length-1;if(o>=0)return f(e[o].locals,n,t)},c=function(e,r){if(r.startsWith("/")){var t=r.split(".");return u(e[0].locals,t)}t=r.split(".");for(var n=e.length-1;n>=0;){if(e[n].locals[t[0]])return u(e[n].locals,t);n--}},u=function(e,r){for(var t=e,n=0,o=r;n<o.length;n++)if(!(t=t[o[n]]))return null;return t},f=function(e,r,t){for(var n=e,o=0;o<r.length-1;o++)n[r[o]]||(n[r[o]]=new Object),n=n[r[o]];n[r[r.length-1]]=t},p=function(e,r){var t=new Map;if(Array.isArray(r)&&r.length===e.length){for(var n=0;n<e.length;n++)t.set(e[n],r[n]);return t}if("object"==typeof r)for(var o=0,i=e;o<i.length;o++){var s=i[o];r[s]&&t.set(s,r[s])}return t};r.createUnpacker=function(e){return d(e)?r.createToObjectInstruction(e):h(e)?r.createForeachInstruction(e):y(e)?r.createProcedureInstruction(e):g(e)?r.createGetValueInstruction(e):v(e)?r.createToArrayInstruction(e):function(r){n.log.debug("Unknown Instruction: "+JSON.stringify(e)+"\n"+JSON.stringify(r))}};var v=function(e){return"toArray"===e.action},g=function(e){return"getValue"===e.action},h=function(e){return"foreach"===e.action},d=function(e){return"toObject"===e.action},y=function(e){return Array.isArray(e)},b=function(e){if(d(e))!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.return&&""===e.return)throw new Error("Invalid return in : "+JSON.stringify(e));if(!e.keys||0===e.keys.length)throw new Error("No keys specified in : "+JSON.stringify(e));if(!e.values||0===e.values.length)throw new Error("No values specified in : "+JSON.stringify(e))}(e);else if(h(e))!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.loopVar&&""===e.loopVar)throw new Error("Invalid loopVar in : "+JSON.stringify(e));if(!e.instruction)throw new Error("No instruction specified in : "+JSON.stringify(e))}(e);else if(y(e))!function(e){for(var r=0,t=e;r<t.length;r++){var n=t[r];b(n)}}(e);else if(g(e))!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.return&&""===e.return)throw new Error("Invalid return in : "+JSON.stringify(e));if(!e.key||""===e.key)throw new Error("No key specified in : "+JSON.stringify(e))}(e);else{if(!v(e))throw new Error("Invalid Instruction - "+JSON.stringify(e));!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.return&&""===e.return)throw new Error("Invalid return in : "+JSON.stringify(e));if(!e.keys||0===e.keys.length)throw new Error("No keys specified in : "+JSON.stringify(e));if(!e.values||0===e.values.length)throw new Error("No values specified in : "+JSON.stringify(e))}(e)}}}},r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{}};return e[n].call(o.exports,o,o.exports,t),o.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.mapper=void 0;var r=t(616);e.mapper=r.createObjectUnpacker()})(),n})()})); | ||
!function(e,r){"object"==typeof exports&&"object"==typeof module?module.exports=r():"function"==typeof define&&define.amd?define([],r):"object"==typeof exports?exports.ObjectUnpacker=r():e.ObjectUnpacker=r()}(self,(function(){return(()=>{"use strict";var e={65:function(e,r,t){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(r,"__esModule",{value:!0}),r.logger=r.Options=r.Level=void 0;var o,i=n(t(501));!function(e){e[e.silent=0]="silent",e[e.trace=10]="trace",e[e.debug=20]="debug",e[e.info=30]="info",e[e.warn=40]="warn",e[e.error=50]="error",e[e.fatal=60]="fatal"}(o=r.Level||(r.Level={}));var s=function(e,r){this.consoleOnly=e,this.level=r};r.Options=s;var a=(0,i.default)(),l=function(){function e(e){this.options=e}return e.prototype.setConsoleOnly=function(e){this.options.consoleOnly=e},e.prototype.silent=function(e){},e.prototype.trace=function(e){this.options.level<=o.trace&&(this.options.consoleOnly?console.log(e):a.trace(e))},e.prototype.debug=function(e){this.options.level<=o.debug&&(this.options.consoleOnly?console.log(e):a.debug(e))},e.prototype.info=function(e){this.options.level<=o.info&&(this.options.consoleOnly?console.info(e):a.info(e))},e.prototype.warn=function(e){this.options.level<=o.warn&&(this.options.consoleOnly?console.warn(e):a.warn(e))},e.prototype.error=function(e){this.options.level<=o.error&&(this.options.consoleOnly?console.error(e):a.error(e))},e.prototype.fatal=function(e){this.options.level<=o.fatal&&(this.options.consoleOnly?console.error(e):a.fatal(e))},e.prototype.always=function(e){console.log(e)},e.prototype.setLevel=function(e){switch(this.options.level=e,e){case o.silent:a.level="silent";break;case o.trace:a.level="trace";break;case o.debug:a.level="debug";break;case o.info:a.level="info";break;case o.warn:a.level="warn";break;case o.error:a.level="error";break;case o.fatal:a.level="fatal";break;default:a.level="info"}},e}();r.logger=new l(new s(!1,o.info))},571:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.Level=r.log=void 0;var n=t(65);Object.defineProperty(r,"log",{enumerable:!0,get:function(){return n.logger}}),Object.defineProperty(r,"Level",{enumerable:!0,get:function(){return n.Level}})},501:(e,r,t)=>{const n=t(346);e.exports=s;const o=function(){function e(e){return void 0!==e&&e}try{return"undefined"!=typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(r){return e(self)||e(window)||e(this)||{}}}().console||{},i={mapHttpRequest:g,mapHttpResponse:g,wrapRequestSerializer:h,wrapResponseSerializer:h,wrapErrorSerializer:h,req:g,res:g,err:function(e){const r={type:e.constructor.name,msg:e.message,stack:e.stack};for(const t in e)void 0===r[t]&&(r[t]=e[t]);return r}};function s(e){(e=e||{}).browser=e.browser||{};const r=e.browser.transmit;if(r&&"function"!=typeof r.send)throw Error("pino: transmit option must have a send function");const t=e.browser.write||o;e.browser.write&&(e.browser.asObject=!0);const n=e.serializers||{},i=function(e,r){return Array.isArray(e)?e.filter((function(e){return"!stdSerializers.err"!==e})):!0===e&&Object.keys(r)}(e.browser.serialize,n);let l=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(l=!1),"function"==typeof t&&(t.error=t.fatal=t.warn=t.info=t.debug=t.trace=t),!1===e.enabled&&(e.level="silent");const f=e.level||"info",g=Object.create(t);g.log||(g.log=y),Object.defineProperty(g,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(g,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,a(h,g,"error","log"),a(h,g,"fatal","error"),a(h,g,"warn","error"),a(h,g,"info","log"),a(h,g,"debug","log"),a(h,g,"trace","log")}});const h={transmit:r,serialize:i,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:v(e)};return g.levels=s.levels,g.level=f,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=y,g.serializers=n,g._serialize=i,g._stdErrSerialize=l,g.child=function(t,o){if(!t)throw new Error("missing bindings for child Pino");o=o||{},i&&t.serializers&&(o.serializers=t.serializers);const s=o.serializers;if(i&&s){var a=Object.assign({},n,s),l=!0===e.browser.serialize?Object.keys(a):i;delete t.serializers,c([t],l,a,this._stdErrSerialize)}function f(e){this._childLevel=1+(0|e._childLevel),this.error=u(e,t,"error"),this.fatal=u(e,t,"fatal"),this.warn=u(e,t,"warn"),this.info=u(e,t,"info"),this.debug=u(e,t,"debug"),this.trace=u(e,t,"trace"),a&&(this.serializers=a,this._serialize=l),r&&(this._logEvent=p([].concat(e._logEvent.bindings,t)))}return f.prototype=this,new f(this)},r&&(g._logEvent=p()),g}function a(e,r,t,n){const i=Object.getPrototypeOf(r);r[t]=r.levelVal>r.levels.values[t]?y:i[t]?i[t]:o[t]||o[n]||y,function(e,r,t){var n;(e.transmit||r[t]!==y)&&(r[t]=(n=r[t],function(){const i=e.timestamp(),a=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===o?o:this;for(var p=0;p<a.length;p++)a[p]=arguments[p];if(e.serialize&&!e.asObject&&c(a,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?n.call(u,l(this,t,a,i)):n.apply(u,a),e.transmit){const n=e.transmit.level||r.level,o=s.levels.values[n],l=s.levels.values[t];if(l<o)return;f(this,{ts:i,methodLevel:t,methodValue:l,transmitLevel:n,transmitValue:s.levels.values[e.transmit.level||r.level],send:e.transmit.send,val:r.levelVal},a)}}))}(e,r,t)}function l(e,r,t,o){e._serialize&&c(t,e._serialize,e.serializers,e._stdErrSerialize);const i=t.slice();let a=i[0];const l={};o&&(l.time=o),l.level=s.levels.values[r];let u=1+(0|e._childLevel);if(u<1&&(u=1),null!==a&&"object"==typeof a){for(;u--&&"object"==typeof i[0];)Object.assign(l,i.shift());a=i.length?n(i.shift(),i):void 0}else"string"==typeof a&&(a=n(i.shift(),i));return void 0!==a&&(l.msg=a),l}function c(e,r,t,n){for(const o in e)if(n&&e[o]instanceof Error)e[o]=s.stdSerializers.err(e[o]);else if("object"==typeof e[o]&&!Array.isArray(e[o]))for(const n in e[o])r&&r.indexOf(n)>-1&&n in t&&(e[o][n]=t[n](e[o][n]))}function u(e,r,t){return function(){const n=new Array(1+arguments.length);n[0]=r;for(var o=1;o<n.length;o++)n[o]=arguments[o-1];return e[t].apply(this,n)}}function f(e,r,t){const n=r.send,o=r.ts,i=r.methodLevel,s=r.methodValue,a=r.val,l=e._logEvent.bindings;c(t,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=o,e._logEvent.messages=t.filter((function(e){return-1===l.indexOf(e)})),e._logEvent.level.label=i,e._logEvent.level.value=s,n(i,e._logEvent,a),e._logEvent=p(l)}function p(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function v(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?d:b}function g(){return{}}function h(e){return e}function y(){}function d(){return!1}function b(){return Date.now()}s.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},s.stdSerializers=i,s.stdTimeFunctions=Object.assign({},{nullTime:d,epochTime:b,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},346:e=>{function r(e){try{return JSON.stringify(e)}catch(e){return'"[Circular]"'}}e.exports=function(e,t,n){var o=n&&n.stringify||r;if("object"==typeof e&&null!==e){var i=t.length+1;if(1===i)return e;var s=new Array(i);s[0]=o(e);for(var a=1;a<i;a++)s[a]=o(t[a]);return s.join(" ")}if("string"!=typeof e)return e;var l=t.length;if(0===l)return e;for(var c="",u=0,f=-1,p=e&&e.length||0,v=0;v<p;){if(37===e.charCodeAt(v)&&v+1<p){switch(f=f>-1?f:0,e.charCodeAt(v+1)){case 100:case 102:if(u>=l)break;if(null==t[u])break;f<v&&(c+=e.slice(f,v)),c+=Number(t[u]),f=v+2,v++;break;case 105:if(u>=l)break;if(null==t[u])break;f<v&&(c+=e.slice(f,v)),c+=Math.floor(Number(t[u])),f=v+2,v++;break;case 79:case 111:case 106:if(u>=l)break;if(void 0===t[u])break;f<v&&(c+=e.slice(f,v));var g=typeof t[u];if("string"===g){c+="'"+t[u]+"'",f=v+2,v++;break}if("function"===g){c+=t[u].name||"<anonymous>",f=v+2,v++;break}c+=o(t[u]),f=v+2,v++;break;case 115:if(u>=l)break;f<v&&(c+=e.slice(f,v)),c+=String(t[u]),f=v+2,v++;break;case 37:f<v&&(c+=e.slice(f,v)),c+="%",f=v+2,v++,u--}++u}++v}return-1===f?e:(f<p&&(c+=e.slice(f)),c)}},616:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createObjectUnpacker=void 0;var n=t(89);r.createObjectUnpacker=function(){return new n.ObjectUnpackerImpl}},89:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ObjectUnpackerImpl=void 0;var n=t(980),o=t(102),i=t(571),s=t(397),a=function(){function e(){}return e.prototype.convert=function(e,r,t){try{var a=s.toInstructionSchema(t),c=o.transform(r,o.prefixReferences),u=new Map;o.indexObject(n.INDEX_NAMESPACE,u,c["?"]),o.indexObject(n.COMPACT_NAMESPACE,u,c),o.indexObject(n.SUBS_NAMESPACE,u,e);var f=void 0;if(0===a.length)delete(f=c)["?"];else{var p={stack:[{locals:{"/compact":c},result:null}]};s.createUnpacker(a)(p),f=p.stack[0].locals["/expanded"]}return l.resolve(u,f)}catch(p){return i.log.error(p.message),{error:p.message}}},e}();r.ObjectUnpackerImpl=a;var l=n.createReferencesResolver()},980:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FIND_REFS=r.SUBS_NAMESPACE=r.COMPACT_NAMESPACE=r.INDEX_NAMESPACE=r.createReferencesResolver=void 0;var n=t(102);r.createReferencesResolver=function(e){return new o(!!e)},r.INDEX_NAMESPACE="/index",r.COMPACT_NAMESPACE="/compact",r.SUBS_NAMESPACE="/subs",r.FIND_REFS=new RegExp(/%?%[\w-./@]+%?/gm);var o=function(){function e(e){this.localsOnly=e}return e.prototype.resolve=function(e,r){if(null==r)throw new Error("Cannot dereference an undefined dataObject.");if("string"==typeof r)return this.processString(e,r);var t=Array.isArray(r["?"])?r["?"]:[r["?"]];return t&&t.forEach((function(r,t){e.set(""+t,r)})),Array.isArray(r)?this.processArray("",e,r):this.processObject("",e,r)},e.prototype.processArray=function(e,r,t){var n=this,o=[];return t.forEach((function(t,i){var s=e+"."+i;Array.isArray(t)?o.push(n.processArray(s,r,t)):"object"==typeof t?o.push(n.processObject(s,r,t)):"string"==typeof t?o.push(n.processString(r,t)):o.push(t)})),o},e.prototype.processObject=function(e,r,t){var n=this;if(null===t)return null;var o={};return Object.keys(t).forEach((function(i){var s=t[i];if(null!==s){var a=e+"."+i;Array.isArray(s)?o[i]=n.processArray(a,r,s):o[i]="object"==typeof s?n.processObject(a,r,s):"string"==typeof s?n.processString(r,s):s}else o[i]=null})),o},e.prototype.processString=function(e,t){for(var o=this,i=t,s=[],a=r.FIND_REFS.exec(i);null!==a;){var l=a[0];s.push(l),a=r.FIND_REFS.exec(i)}return s.forEach((function(r){if(!r.startsWith("%%")){var t=r.startsWith("%")&&r.endsWith("%")?r.substring(1,r.length-1):r.substring(1);n.isNumeric.test(t)&&(t="/index."+t);var s=e.get(t);if(null!=s&&"string"==typeof i)if(i===r)i="string"!=typeof s||o.localsOnly?s:o.unref(s);else if("object"==typeof s){var a=o.unref(r);console.error(a+" refers to an object or array and cannot be embedded in a string"),i=i.replace(r,""+a)}else i=i.replace(r,""+s);else i=i===r?null:i.replace(r,"")}})),"string"==typeof i?i.replace("%%","%"):null===i&&this.localsOnly?t:i},e.prototype.unref=function(e){return e.replace("/index.","").replace("/subs.","")},e}()},102:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.identity=r.prefixReferences=r.transform=r.indexObject=r.isNumeric=void 0;var n=t(980);r.isNumeric=/^[-]?\d*\.?\d+(?:[Ee][+-]?\d+)?$/,r.indexObject=function(e,t,n){n&&Object.entries(n).forEach((function(n){var o=e.length>0?e+"."+n[0]:""+n[0];t.set(o,n[1]),"object"==typeof n[1]&&r.indexObject(o,t,n[1])}))},r.transform=function(e,t){if(!e)return t(e);if(Array.isArray(e)){var n=[];return e.forEach((function(e){"object"==typeof e?n.push(r.transform(e,t)):n.push(t(e))})),t(n)}if("object"==typeof e){var o={};return Object.entries(e).forEach((function(e){"object"==typeof e[1]?o[e[0]]=r.transform(e[1],t):o[e[0]]=t(e[1])})),t(o)}return t(e)},r.prefixReferences=function(e){return"string"!=typeof e?e:e.replace(n.FIND_REFS,(function(e){if(e.startsWith("%%"))return e;var r=e.charCodeAt(1);return r>47&&r<58?"%"+n.INDEX_NAMESPACE+"."+e.substring(1):"%"+n.SUBS_NAMESPACE+"."+e.substring(1)}))},r.identity=function(e){return e}},397:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createUnpacker=r.createToObjectInstruction=r.createToArrayInstruction=r.createForeachInstruction=r.createProcedureInstruction=r.createGetValueInstruction=r.toInstructionSchema=void 0;var n=t(571),o=t(980),i=t(102),s=o.createReferencesResolver(!0);r.toInstructionSchema=function(e){if(Array.isArray(e)){for(var r=0,t=e;r<t.length;r++){var n=t[r];O(n)}return e}throw new Error("Invalid transformation object - should be an array of Instructions.")},r.createGetValueInstruction=function(e){return function(r){if("getValue"===e.action){n.log.debug('Calling "getValue" :'+e.comment);var t=c(r.stack,e.source);if(!t)return n.log.debug("Source not matched for : "+e.source),null;var o=v(e.key,t).get(e.key);return l(r.stack,e.target,o),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=o,o)}return n.log.debug('Skipping "getValue" :'+e.comment),null}},r.createProcedureInstruction=function(e){var t=function(e){return e};return e.forEach((function(e){var n=r.createUnpacker(e);t=a(t,n)})),t};var a=function(e,r){return function(t){e(t),r(t)}};r.createForeachInstruction=function(e){var t=r.createUnpacker(e.instruction);return function(r){if("foreach"===e.action){n.log.debug('Calling "foreach" :'+e.comment);var o=c(r.stack,e.source);if(o||n.log.debug("Source not matched for : "+e.source),Array.isArray(o)){var i=new Array;o.forEach((function(n){r.stack.push({locals:{},result:null}),r.stack[r.stack.length-1].locals[e.loopVar]=n,t(r),i.push(r.stack[r.stack.length-1].result),r.stack.pop()})),l(r.stack,e.target,i)}}else n.log.debug('Skipping "foreach" :'+e.comment)}},r.createToArrayInstruction=function(e){return function(r){if("toArray"===e.action){n.log.debug('Calling "toArray" :'+e.comment);var t=c(r.stack,e.source);if(!t)return n.log.debug("Source not matched for : "+e.source),null;var o=p(e.keys,t);if(o.size>0){var a=new Array;for(var u in e.values)e.values.hasOwnProperty(u)&&a.push(e.values[u]);i.indexObject("",o,t);var f=s.resolve(o,a);return l(r.stack,e.target,f),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=f,f)}}return n.log.debug('Skipping "toArray" :'+e.comment),null}},r.createToObjectInstruction=function(e){return function(r){if("toObject"===e.action){n.log.debug('Calling "toObject" :'+e.comment);var t=c(r.stack,e.source);if(!t)return n.log.debug("Source not matched for : "+e.source),null;var o=p(e.keys,t);if("object"!=typeof t&&e.keys.length>0&&("string"==typeof t&&t.startsWith("%")||o.set(e.keys[0],t)),o.size>0){var a=new Object;for(var u in e.values)e.values.hasOwnProperty(u)&&(a[u]=e.values[u]);i.indexObject("",o,t);var f=s.resolve(o,a);return l(r.stack,e.target,f),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=f,f)}}return n.log.debug('Skipping "toObject" :'+e.comment),null}};var l=function(e,r,t){if(r.startsWith("/")){var n=r.split(".");return f(e[0].locals,n,t)}n=r.split(".");var o=e.length-1;if(o>=0)return f(e[o].locals,n,t)},c=function(e,r){if(r.startsWith("/")){var t=r.split(".");return u(e[0].locals,t)}t=r.split(".");for(var n=e.length-1;n>=0;){if(e[n].locals[t[0]])return u(e[n].locals,t);n--}},u=function(e,r){for(var t=e,n=0,o=r;n<o.length;n++)if(!(t=t[o[n]]))return null;return t},f=function(e,r,t){for(var n=e,o=0;o<r.length-1;o++)n[r[o]]||(n[r[o]]=new Object),n=n[r[o]];n[r[r.length-1]]=t},p=function(e,r){var t=new Map;if(Array.isArray(r)){for(var n=0;n<e.length;n++)t.set(e[n],r[n]);return t}if("object"==typeof r)for(var o=0,i=e;o<i.length;o++){var s=i[o];r[s]&&t.set(s,r[s])}return t},v=function(e,r){var t=new Map;return"object"==typeof r&&r[e]&&t.set(e,r[e]),t};r.createUnpacker=function(e){return d(e)?r.createToObjectInstruction(e):y(e)?r.createForeachInstruction(e):b(e)?r.createProcedureInstruction(e):h(e)?r.createGetValueInstruction(e):g(e)?r.createToArrayInstruction(e):function(r){n.log.debug("Unknown Instruction: "+JSON.stringify(e)+"\n"+JSON.stringify(r))}};var g=function(e){return"toArray"===e.action},h=function(e){return"getValue"===e.action},y=function(e){return"foreach"===e.action},d=function(e){return"toObject"===e.action},b=function(e){return Array.isArray(e)},O=function(e){if(d(e))!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.return&&""===e.return)throw new Error("Invalid return in : "+JSON.stringify(e));if(!e.keys||0===e.keys.length)throw new Error("No keys specified in : "+JSON.stringify(e));if(!e.values||0===e.values.length)throw new Error("No values specified in : "+JSON.stringify(e))}(e);else if(y(e))!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.loopVar&&""===e.loopVar)throw new Error("Invalid loopVar in : "+JSON.stringify(e));if(!e.instruction)throw new Error("No instruction specified in : "+JSON.stringify(e))}(e);else if(b(e))!function(e){for(var r=0,t=e;r<t.length;r++){var n=t[r];O(n)}}(e);else if(h(e))!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.return&&""===e.return)throw new Error("Invalid return in : "+JSON.stringify(e));if(!e.key||""===e.key)throw new Error("No key specified in : "+JSON.stringify(e))}(e);else{if(!g(e))throw new Error("Invalid Instruction - "+JSON.stringify(e));!function(e){if(""===e.source)throw new Error("Invalid source in : "+JSON.stringify(e));if(""===e.target)throw new Error("Invalid target in : "+JSON.stringify(e));if(e.return&&""===e.return)throw new Error("Invalid return in : "+JSON.stringify(e));if(!e.keys||0===e.keys.length)throw new Error("No keys specified in : "+JSON.stringify(e));if(!e.values||0===e.values.length)throw new Error("No values specified in : "+JSON.stringify(e))}(e)}}}},r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{}};return e[n].call(o.exports,o,o.exports,t),o.exports}var n={};return(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.mapper=void 0;var r=t(616);e.mapper=r.createObjectUnpacker()})(),n})()})); |
@@ -96,3 +96,3 @@ "use strict"; | ||
} | ||
var sourceValues = getSourceValues([i.key], source); | ||
var sourceValues = getSourceValue(i.key, source); | ||
var target = sourceValues.get(i.key); | ||
@@ -283,3 +283,3 @@ setTarget(e.stack, i.target, target); | ||
var result = new Map(); | ||
if (Array.isArray(o) && o.length === keys.length) { | ||
if (Array.isArray(o)) { | ||
for (var i = 0; i < keys.length; i++) { | ||
@@ -300,2 +300,11 @@ result.set(keys[i], o[i]); | ||
}; | ||
var getSourceValue = function (key, o) { | ||
var result = new Map(); | ||
if (typeof o === 'object') { | ||
if (o[key]) { | ||
result.set(key, o[key]); | ||
} | ||
} | ||
return result; | ||
}; | ||
var createUnpacker = function (i) { | ||
@@ -302,0 +311,0 @@ if (isToObjectInstruction(i)) { |
{ | ||
"name": "object-unpacker", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "A JSON to JSON mapper in TypeScript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
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
77527
771