Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

object-unpacker

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

object-unpacker - npm Package Compare versions

Comparing version 0.0.22 to 1.0.0-rc.1

dist/instructions.d.ts

2

dist/bundle.js

@@ -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 i,s=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"}(i=r.Level||(r.Level={}));var o=function(e,r){this.consoleOnly=e,this.level=r};r.Options=o;var a=(0,s.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<=i.trace&&(this.options.consoleOnly?console.log(e):a.trace(e))},e.prototype.debug=function(e){this.options.level<=i.debug&&(this.options.consoleOnly?console.log(e):a.debug(e))},e.prototype.info=function(e){this.options.level<=i.info&&(this.options.consoleOnly?console.info(e):a.info(e))},e.prototype.warn=function(e){this.options.level<=i.warn&&(this.options.consoleOnly?console.warn(e):a.warn(e))},e.prototype.error=function(e){this.options.level<=i.error&&(this.options.consoleOnly?console.error(e):a.error(e))},e.prototype.fatal=function(e){this.options.level<=i.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 i.silent:a.level="silent";break;case i.trace:a.level="trace";break;case i.debug:a.level="debug";break;case i.info:a.level="info";break;case i.warn:a.level="warn";break;case i.error:a.level="error";break;case i.fatal:a.level="fatal";break;default:a.level="info"}},e}();r.logger=new l(new o(!1,i.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=o;const i=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||{},s={mapHttpRequest:v,mapHttpResponse:v,wrapRequestSerializer:b,wrapResponseSerializer:b,wrapErrorSerializer:b,req:v,res:v,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 o(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||i;e.browser.write&&(e.browser.asObject=!0);const n=e.serializers||{},s=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",v=Object.create(t);v.log||(v.log=h),Object.defineProperty(v,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(v,"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(b,v,"error","log"),a(b,v,"fatal","error"),a(b,v,"warn","error"),a(b,v,"info","log"),a(b,v,"debug","log"),a(b,v,"trace","log")}});const b={transmit:r,serialize:s,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:y(e)};return v.levels=o.levels,v.level=f,v.setMaxListeners=v.getMaxListeners=v.emit=v.addListener=v.on=v.prependListener=v.once=v.prependOnceListener=v.removeListener=v.removeAllListeners=v.listeners=v.listenerCount=v.eventNames=v.write=v.flush=h,v.serializers=n,v._serialize=s,v._stdErrSerialize=l,v.child=function(t,i){if(!t)throw new Error("missing bindings for child Pino");i=i||{},s&&t.serializers&&(i.serializers=t.serializers);const o=i.serializers;if(s&&o){var a=Object.assign({},n,o),l=!0===e.browser.serialize?Object.keys(a):s;delete t.serializers,u([t],l,a,this._stdErrSerialize)}function f(e){this._childLevel=1+(0|e._childLevel),this.error=c(e,t,"error"),this.fatal=c(e,t,"fatal"),this.warn=c(e,t,"warn"),this.info=c(e,t,"info"),this.debug=c(e,t,"debug"),this.trace=c(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&&(v._logEvent=p()),v}function a(e,r,t,n){const s=Object.getPrototypeOf(r);r[t]=r.levelVal>r.levels.values[t]?h:s[t]?s[t]:i[t]||i[n]||h,function(e,r,t){var n;(e.transmit||r[t]!==h)&&(r[t]=(n=r[t],function(){const s=e.timestamp(),a=new Array(arguments.length),c=Object.getPrototypeOf&&Object.getPrototypeOf(this)===i?i:this;for(var p=0;p<a.length;p++)a[p]=arguments[p];if(e.serialize&&!e.asObject&&u(a,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?n.call(c,l(this,t,a,s)):n.apply(c,a),e.transmit){const n=e.transmit.level||r.level,i=o.levels.values[n],l=o.levels.values[t];if(l<i)return;f(this,{ts:s,methodLevel:t,methodValue:l,transmitLevel:n,transmitValue:o.levels.values[e.transmit.level||r.level],send:e.transmit.send,val:r.levelVal},a)}}))}(e,r,t)}function l(e,r,t,i){e._serialize&&u(t,e._serialize,e.serializers,e._stdErrSerialize);const s=t.slice();let a=s[0];const l={};i&&(l.time=i),l.level=o.levels.values[r];let c=1+(0|e._childLevel);if(c<1&&(c=1),null!==a&&"object"==typeof a){for(;c--&&"object"==typeof s[0];)Object.assign(l,s.shift());a=s.length?n(s.shift(),s):void 0}else"string"==typeof a&&(a=n(s.shift(),s));return void 0!==a&&(l.msg=a),l}function u(e,r,t,n){for(const i in e)if(n&&e[i]instanceof Error)e[i]=o.stdSerializers.err(e[i]);else if("object"==typeof e[i]&&!Array.isArray(e[i]))for(const n in e[i])r&&r.indexOf(n)>-1&&n in t&&(e[i][n]=t[n](e[i][n]))}function c(e,r,t){return function(){const n=new Array(1+arguments.length);n[0]=r;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return e[t].apply(this,n)}}function f(e,r,t){const n=r.send,i=r.ts,s=r.methodLevel,o=r.methodValue,a=r.val,l=e._logEvent.bindings;u(t,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=i,e._logEvent.messages=t.filter((function(e){return-1===l.indexOf(e)})),e._logEvent.level.label=s,e._logEvent.level.value=o,n(s,e._logEvent,a),e._logEvent=p(l)}function p(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function y(e){return"function"==typeof e.timestamp?e.timestamp:!1===e.timestamp?d:g}function v(){return{}}function b(e){return e}function h(){}function d(){return!1}function g(){return Date.now()}o.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"}},o.stdSerializers=s,o.stdTimeFunctions=Object.assign({},{nullTime:d,epochTime:g,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 i=n&&n.stringify||r;if("object"==typeof e&&null!==e){var s=t.length+1;if(1===s)return e;var o=new Array(s);o[0]=i(e);for(var a=1;a<s;a++)o[a]=i(t[a]);return o.join(" ")}if("string"!=typeof e)return e;var l=t.length;if(0===l)return e;for(var u="",c=0,f=-1,p=e&&e.length||0,y=0;y<p;){if(37===e.charCodeAt(y)&&y+1<p){switch(f=f>-1?f:0,e.charCodeAt(y+1)){case 100:case 102:if(c>=l)break;if(null==t[c])break;f<y&&(u+=e.slice(f,y)),u+=Number(t[c]),f=y+2,y++;break;case 105:if(c>=l)break;if(null==t[c])break;f<y&&(u+=e.slice(f,y)),u+=Math.floor(Number(t[c])),f=y+2,y++;break;case 79:case 111:case 106:if(c>=l)break;if(void 0===t[c])break;f<y&&(u+=e.slice(f,y));var v=typeof t[c];if("string"===v){u+="'"+t[c]+"'",f=y+2,y++;break}if("function"===v){u+=t[c].name||"<anonymous>",f=y+2,y++;break}u+=i(t[c]),f=y+2,y++;break;case 115:if(c>=l)break;f<y&&(u+=e.slice(f,y)),u+=String(t[c]),f=y+2,y++;break;case 37:f<y&&(u+=e.slice(f,y)),u+="%",f=y+2,y++,c--}++c}++y}return-1===f?e:(f<p&&(u+=e.slice(f)),u)}},616:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.createObjectUnpacker=void 0;var n=t(503);r.createObjectUnpacker=function(e){switch(e){case"0.0.18":case"0.0.19":case"0.0.20":case"0.0.21":default:return new n.ObjectUnpacker001}}},503:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.ObjectUnpacker001=void 0;var n=t(980),i=t(27),s=t(102),o=t(571),a=function(){function e(){}return e.prototype.convert=function(e,r,t){try{var i=p(t),a=s.transform(r,s.prefixReferences),v=new Map;s.indexObject(l,u,c,n.INDEX_NAMESPACE,v,a["?"]),s.indexObject(l,u,c,n.COMPACT_NAMESPACE,v,a),s.indexObject(l,u,c,n.SUBS_NAMESPACE,v,e);var b=y(a,i,v);return delete b["?"],f.resolve(v,b)}catch(e){return o.log.error(e.message),{error:e.message}}},e}();r.ObjectUnpacker001=a;var l="%",u="%",c=!0,f=n.createReferencesResolver(),p=function(e){var r=new Map;return Object.keys(e).forEach((function(t){r.set(t,new i.TransformationInstruction(t,e[t]))})),r},y=function(e,r,t){if(null===e)return null;if(Array.isArray(e))return e.map((function(e){return y(e,r,t)}));if("object"==typeof e){var n={};return Object.keys(e).forEach((function(i){var o=r.get(i);if(o&&o.additionalKeys&&o.additionalKeys.has(i)&&(o=o.additionalKeys.get(i)),o){if(o.isRemovePair())return;var a="object"!=typeof e[i]&&o.assignKeys?[e[i]]:e[i],f=v(a,o,r,t);"string"==typeof f&&f.includes("%self")&&(f=_(a,f));var p=o.transformKey(i);if(o.replacePair)z(f)&&P(f,n);else if(o.rewriteValue)if(o.resultValue)if("object"==typeof o.resultValue)n[p]=v(a,o,r,t);else if("string"==typeof o.resultValue&&o.resultValue.startsWith("%")){var b=new Map;t.forEach((function(e,r){return b.set(r,e)})),s.indexObject(l,u,c,"",b,a),n[p]=v(a,o,r,b)}else n[p]=f;else n[p]=null;else n[p]=f}else t.has(i)?n[i]=t.get(i):n[i]=y(e[i],r,t)})),n}return e},v=function(e,r,t,n){if(null===e)return e;var i=z(e)?k(e,r,n):e,o=Array.isArray(i)&&r.assignKeys?h(r.assignKeys,i):new Map,a=new Map;if(n.forEach((function(e,r){return a.set(r,e)})),s.indexObject(l,u,c,"",a,b(o)),r.isArrayMapping()){if(Array.isArray(i)){var f=r.arrayItemsName,p=f?d(f,i):i;return r.assignKeys?h(r.assignKeys,p):y(p,t,a)}throw new Error('"arrayItems" can only be applied to arrays.')}if(!r.resultValue)return o.size>0?y(b(o),t,a):y(i,t,a);switch(typeof r.resultValue){case"object":return Array.isArray(r.resultValue)?w(r,t,a):g(r,i,t,a,o);case"string":return"%self"===r.resultValue?y(i,t,a):r.resultValue.match("^%[a-zA-Z]+(.[a-zA-Z]+)*$")?a.get(r.resultValue):y(r.resultValue,t,a);default:return r.resultValue}},b=function(e){var r={};return e.forEach((function(e,t){return r[t]=e})),r},h=function(e,r){var t=new Map;return Array.isArray(r)?e.forEach((function(e,n){n<r.length?t.set(e,r[n]):t.set(e,null)})):"object"==typeof r?e.forEach((function(e){t.set(e,r[e])})):e.forEach((function(e,n){0===n?t.set(e,r):t.set(e,null)})),t},d=function(e,r){return r.map((function(r){var t={};return t[e]=r,t}))},g=function(e,r,t,n,i){var o={},a=e.resultValue?e.resultValue:r;return Object.keys(a).forEach((function(e){var p=y(a[e],t,n);if("string"==typeof p){var b=p;if(m(r,b))"object"==typeof(h=r[b.substr(1)])?O(h,t,b)?o[e]=v(h,t.get(b.substr(1)),t,n):o[e]=y(h,t,n):o[e]=h;else if(j(b,i)){var h;(h=i.get(b.substr(1)))&&"object"==typeof h?O(h,t,b)?o[e]=v(h,t.get(b.substr(1)),t,n):o[e]=y(h,t,n):o[e]=h}else if(E(b)){var d=new Map;n.forEach((function(e,r){return d.set(r,e)})),s.indexObject(l,u,c,"",d,r),o[e]=f.resolve(d,p)}else b.includes("%self")?o[e]=_(r,b):n.has(b)?o[e]=n.get(b):o[e]=null}else A(p)?o[e]=f.resolve(n,p):o[e]=p})),o},w=function(e,r,t){return e.resultValue&&Array.isArray(e.resultValue)?e.resultValue.map((function(n){return v(n,e,r,t)})).filter((function(e){return null!==e})):[]},m=function(e,r){return"object"==typeof e&&"%"===r.charAt(0)&&e.hasOwnProperty(r.substr(1))},j=function(e,r){return"%"===e.charAt(0)&&r.has(e.substr(1))},O=function(e,r,t){return Array.isArray(e)&&r.has(t.substr(1))},E=function(e){return e.startsWith("%/")||!e.startsWith("%")&&!e.includes("%self")},A=function(e){return null!==e&&"object"==typeof e},_=function(e,r){var t=new Map;return t.set("%self",e),t.set("%self%",e),f.resolve(t,r)},z=function(e){return null!==e&&!Array.isArray(e)&&"object"==typeof e},P=function(e,r){Object.keys(e).forEach((function(t){r[t]=e[t]}))},k=function(e,r,t){var n=e,i={};for(var s in n)if(r.additionalKeys.has(s)){var o=r.additionalKeys.get(s);i[o.transformKey(s)]=y(n[s],o.additionalKeys,t)}else i[s]=n[s];return i}},980:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.FIND_REFS=r.SUBS_NAMESPACE=r.COMPACT_NAMESPACE=r.INDEX_NAMESPACE=r.createReferencesResolver=void 0,r.createReferencesResolver=function(){return new t},r.INDEX_NAMESPACE="/index",r.COMPACT_NAMESPACE="/compact",r.SUBS_NAMESPACE="/subs",r.FIND_REFS=new RegExp(/%?%[\w-./@]+%?/gm);var t=function(){function e(){}return e.prototype.resolve=function(e,r){if(null==r)throw new Error("Cannot dereference an undefined dataObject.");if("string"==typeof r)return s(e,r);var t=Array.isArray(r["?"])?r["?"]:[r["?"]];return t&&t.forEach((function(r,t){e.set("%"+t,r),e.set("%"+t+"%",r)})),Array.isArray(r)?n("",e,r):i("",e,r)},e}(),n=function(e,r,t){var o=[];return t.forEach((function(t,a){var l=e+"."+a;Array.isArray(t)?o.push(n(l,r,t)):"object"==typeof t?o.push(i(l,r,t)):"string"==typeof t?o.push(s(r,t)):o.push(t)})),o},i=function(e,r,t){if(null===t)return null;var o={};return Object.keys(t).forEach((function(a){var l=t[a];if(null!==l){var u=e+"."+a;Array.isArray(l)?o[a]=n(u,r,l):o[a]="object"==typeof l?i(u,r,l):"string"==typeof l?s(r,l):l}else o[a]=null})),o},s=function(e,t){for(var n=t,i=[],s=r.FIND_REFS.exec(n);null!==s;){var a=s[0];i.push(a),s=r.FIND_REFS.exec(n)}return i.forEach((function(r){if(!r.startsWith("%%")){var t=e.get(r);if(null!=t&&"string"==typeof n)if(n===r)n="string"==typeof t?o(t):t;else if("object"==typeof t){var i=o(r);console.error(i+" refers to an object or array and cannot be embedded in a string"),n=n.replace(r,""+i)}else n=n.replace(r,""+t);else n=n===r?null:n.replace(r,"")}})),"string"==typeof n?n.replace("%%","%"):n},o=function(e){return e.replace("/index.","").replace("/subs.","")}},27:(e,r)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.TransformationInstruction=void 0;var t=["rewriteValue","assignKeys","rewriteKey","replacePair","arrayItems"],n=function(){function e(r,n){var i=this;this.key=r,this.rewriteValue=!!n.hasOwnProperty("rewriteValue"),this.replacePair=!!n.hasOwnProperty("replacePair"),this.assignKeys=n.assignKeys?n.assignKeys:null,this.resultValue=n.rewriteValue?n.rewriteValue:n.replacePair,this.rewriteKey=n.rewriteKey?n.rewriteKey:null,this.arrayItemsName=n.arrayItems?n.arrayItems:null,this.additionalKeys=new Map,"object"!=typeof n||Array.isArray(n)||Object.keys(n).filter((function(e){return!t.includes(e)})).forEach((function(r){i.additionalKeys.set(r,new e(r,n[r]))}))}return e.prototype.transformKey=function(e){return this.rewriteKey?this.rewriteKey:e},e.prototype.shouldRewriteValue=function(){return this.rewriteValue},e.prototype.isArrayMapping=function(){return null!==this.arrayItemsName},e.prototype.isRemovePair=function(){return!this.replacePair&&!this.rewriteValue&&null===this.arrayItemsName&&null===this.assignKeys&&null===this.rewriteKey&&void 0===this.resultValue&&0===this.additionalKeys.size},e}();r.TransformationInstruction=n},102:(e,r,t)=>{Object.defineProperty(r,"__esModule",{value:!0}),r.identity=r.prefixReferences=r.transform=r.indexObject=void 0;var n=t(980);r.indexObject=function(e,t,n,i,s,o){o&&Object.entries(o).forEach((function(o){var a=i.length>0?i+"."+o[0]:""+o[0];n&&s.set(e+a,o[1]),s.set(e+a+t,o[1]),"object"==typeof o[1]&&r.indexObject(e,t,n,a,s,o[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 i={};return Object.entries(e).forEach((function(e){"object"==typeof e[1]?i[e[0]]=r.transform(e[1],t):i[e[0]]=t(e[1])})),t(i)}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.substr(1):"%"+n.SUBS_NAMESPACE+"."+e.substr(1)}))},r.identity=function(e){return e}}},r={};function t(n){if(r[n])return r[n].exports;var i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.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 i,o=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"}(i=r.Level||(r.Level={}));var s=function(e,r){this.consoleOnly=e,this.level=r};r.Options=s;var a=(0,o.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<=i.trace&&(this.options.consoleOnly?console.log(e):a.trace(e))},e.prototype.debug=function(e){this.options.level<=i.debug&&(this.options.consoleOnly?console.log(e):a.debug(e))},e.prototype.info=function(e){this.options.level<=i.info&&(this.options.consoleOnly?console.info(e):a.info(e))},e.prototype.warn=function(e){this.options.level<=i.warn&&(this.options.consoleOnly?console.warn(e):a.warn(e))},e.prototype.error=function(e){this.options.level<=i.error&&(this.options.consoleOnly?console.error(e):a.error(e))},e.prototype.fatal=function(e){this.options.level<=i.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 i.silent:a.level="silent";break;case i.trace:a.level="trace";break;case i.debug:a.level="debug";break;case i.info:a.level="info";break;case i.warn:a.level="warn";break;case i.error:a.level="error";break;case i.fatal:a.level="fatal";break;default:a.level="info"}},e}();r.logger=new l(new s(!1,i.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 i=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||{},o={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||i;e.browser.write&&(e.browser.asObject=!0);const n=e.serializers||{},o=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:o,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:p(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=o,g._stdErrSerialize=l,g.child=function(t,i){if(!t)throw new Error("missing bindings for child Pino");i=i||{},o&&t.serializers&&(i.serializers=t.serializers);const s=i.serializers;if(o&&s){var a=Object.assign({},n,s),l=!0===e.browser.serialize?Object.keys(a):o;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=v([].concat(e._logEvent.bindings,t)))}return f.prototype=this,new f(this)},r&&(g._logEvent=v()),g}function a(e,r,t,n){const o=Object.getPrototypeOf(r);r[t]=r.levelVal>r.levels.values[t]?y:o[t]?o[t]:i[t]||i[n]||y,function(e,r,t){var n;(e.transmit||r[t]!==y)&&(r[t]=(n=r[t],function(){const o=e.timestamp(),a=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===i?i:this;for(var v=0;v<a.length;v++)a[v]=arguments[v];if(e.serialize&&!e.asObject&&c(a,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?n.call(u,l(this,t,a,o)):n.apply(u,a),e.transmit){const n=e.transmit.level||r.level,i=s.levels.values[n],l=s.levels.values[t];if(l<i)return;f(this,{ts:o,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,i){e._serialize&&c(t,e._serialize,e.serializers,e._stdErrSerialize);const o=t.slice();let a=o[0];const l={};i&&(l.time=i),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 o[0];)Object.assign(l,o.shift());a=o.length?n(o.shift(),o):void 0}else"string"==typeof a&&(a=n(o.shift(),o));return void 0!==a&&(l.msg=a),l}function c(e,r,t,n){for(const i in e)if(n&&e[i]instanceof Error)e[i]=s.stdSerializers.err(e[i]);else if("object"==typeof e[i]&&!Array.isArray(e[i]))for(const n in e[i])r&&r.indexOf(n)>-1&&n in t&&(e[i][n]=t[n](e[i][n]))}function u(e,r,t){return function(){const n=new Array(1+arguments.length);n[0]=r;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return e[t].apply(this,n)}}function f(e,r,t){const n=r.send,i=r.ts,o=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=i,e._logEvent.messages=t.filter((function(e){return-1===l.indexOf(e)})),e._logEvent.level.label=o,e._logEvent.level.value=s,n(o,e._logEvent,a),e._logEvent=v(l)}function v(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function p(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=o,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 i=n&&n.stringify||r;if("object"==typeof e&&null!==e){var o=t.length+1;if(1===o)return e;var s=new Array(o);s[0]=i(e);for(var a=1;a<o;a++)s[a]=i(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,v=e&&e.length||0,p=0;p<v;){if(37===e.charCodeAt(p)&&p+1<v){switch(f=f>-1?f:0,e.charCodeAt(p+1)){case 100:case 102:if(u>=l)break;if(null==t[u])break;f<p&&(c+=e.slice(f,p)),c+=Number(t[u]),f=p+2,p++;break;case 105:if(u>=l)break;if(null==t[u])break;f<p&&(c+=e.slice(f,p)),c+=Math.floor(Number(t[u])),f=p+2,p++;break;case 79:case 111:case 106:if(u>=l)break;if(void 0===t[u])break;f<p&&(c+=e.slice(f,p));var g=typeof t[u];if("string"===g){c+="'"+t[u]+"'",f=p+2,p++;break}if("function"===g){c+=t[u].name||"<anonymous>",f=p+2,p++;break}c+=i(t[u]),f=p+2,p++;break;case 115:if(u>=l)break;f<p&&(c+=e.slice(f,p)),c+=String(t[u]),f=p+2,p++;break;case 37:f<p&&(c+=e.slice(f,p)),c+="%",f=p+2,p++,u--}++u}++p}return-1===f?e:(f<v&&(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),i=t(102),o=t(571),s=t(397),a=function(){function e(){}return e.prototype.convert=function(e,r,t){try{var a=s.toInstructionSchema(t),c=i.transform(r,i.prefixReferences),u=new Map;i.indexObject(n.INDEX_NAMESPACE,u,c["?"]),i.indexObject(n.COMPACT_NAMESPACE,u,c),i.indexObject(n.SUBS_NAMESPACE,u,e);var f=void 0;if(0===a.length)delete(f=c)["?"];else{var v={stack:[{locals:{"/compact":c},result:null}]};s.createInstructions(a)(v),f=v.stack[0].locals["/expanded"]}return l.resolve(u,f)}catch(v){return o.log.error(v.message),{error:v.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 i(!!e)},r.INDEX_NAMESPACE="/index",r.COMPACT_NAMESPACE="/compact",r.SUBS_NAMESPACE="/subs",r.FIND_REFS=new RegExp(/%?%[\w-./@]+%?/gm);var i=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,i=[];return t.forEach((function(t,o){var s=e+"."+o;Array.isArray(t)?i.push(n.processArray(s,r,t)):"object"==typeof t?i.push(n.processObject(s,r,t)):"string"==typeof t?i.push(n.processString(r,t)):i.push(t)})),i},e.prototype.processObject=function(e,r,t){var n=this;if(null===t)return null;var i={};return Object.keys(t).forEach((function(o){var s=t[o];if(null!==s){var a=e+"."+o;Array.isArray(s)?i[o]=n.processArray(a,r,s):i[o]="object"==typeof s?n.processObject(a,r,s):"string"==typeof s?n.processString(r,s):s}else i[o]=null})),i},e.prototype.processString=function(e,t){for(var i=this,o=t,s=[],a=r.FIND_REFS.exec(o);null!==a;){var l=a[0];s.push(l),a=r.FIND_REFS.exec(o)}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 o)if(o===r)o="string"!=typeof s||i.localsOnly?s:i.unref(s);else if("object"==typeof s){var a=i.unref(r);console.error(a+" refers to an object or array and cannot be embedded in a string"),o=o.replace(r,""+a)}else o=o.replace(r,""+s);else o=o===r?null:o.replace(r,"")}})),"string"==typeof o?o.replace("%%","%"):null===o&&this.localsOnly?t:o},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 i=e.length>0?e+"."+n[0]:""+n[0];t.set(i,n[1]),"object"==typeof n[1]&&r.indexObject(i,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 i={};return Object.entries(e).forEach((function(e){"object"==typeof e[1]?i[e[0]]=r.transform(e[1],t):i[e[0]]=t(e[1])})),t(i)}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.createInstructions=r.createToObjectInstruction=r.createToArrayInstruction=r.createForeachInstruction=r.createProcedureInstruction=r.createGetValueInstruction=r.toInstructionSchema=void 0;var n=t(571),i=t(980),o=t(102),s=i.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),i=v([e.key],t).get(e.key);return l(r.stack,e.target,i),e.return?r.stack[r.stack.length-1].locals[e.return]:(r.stack[r.stack.length-1].result=i,i)}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.createInstructions(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.createInstructions(e.instruction);return function(r){if("foreach"===e.action){n.log.debug('Calling "foreach" :'+e.comment);var i=c(r.stack,e.source);if(Array.isArray(i)){var o=new Array;i.forEach((function(n){r.stack.push({locals:{},result:null}),r.stack[r.stack.length-1].locals[e.loopVar]=n,t(r),o.push(r.stack[r.stack.length-1].result),r.stack.pop()})),l(r.stack,e.target,o)}}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),i=v(e.keys,t);if(i.size>0){var a=new Array;for(var u in e.values)e.values.hasOwnProperty(u)&&a.push(e.values[u]);o.indexObject("",i,t);var f=s.resolve(i,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),i=v(e.keys,t);if(i.size>0){var a=new Object;for(var u in e.values)e.values.hasOwnProperty(u)&&(a[u]=e.values[u]);o.indexObject("",i,t);var f=s.resolve(i,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 i=e.length-1;if(i>=0)return f(e[i].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,i=r;n<i.length;n++)if(!(t=t[i[n]]))return null;return t},f=function(e,r,t){for(var n=e,i=0;i<r.length-1;i++)n[r[i]]||(n[r[i]]=new Object),n=n[r[i]];n[r[r.length-1]]=t},v=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 i=0,o=e;i<o.length;i++){var s=o[i];r[s]&&t.set(s,r[s])}return t};r.createInstructions=function(e){return y(e)?r.createToObjectInstruction(e):h(e)?r.createForeachInstruction(e):d(e)?r.createProcedureInstruction(e):g(e)?r.createGetValueInstruction(e):p(e)?r.createToArrayInstruction(e):function(r){n.log.debug("Unknown Instruction: "+JSON.stringify(e)+"\n"+JSON.stringify(r))}};var p=function(e){return"toArray"===e.action},g=function(e){return"getValue"===e.action},h=function(e){return"foreach"===e.action},y=function(e){return"toObject"===e.action},d=function(e){return Array.isArray(e)},b=function(e){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.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(d(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(!p(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 i=r[n]={exports:{}};return e[n].call(i.exports,i,i.exports,t),i.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})()}));
export interface ObjectUnpacker {
convert(referencesObject: any, data: any, mapping: object): object;
}
export declare const createObjectUnpacker: (version?: string | undefined) => ObjectUnpacker;
export declare const createObjectUnpacker: () => ObjectUnpacker;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createObjectUnpacker = void 0;
var ObjectUnpacker001_1 = require("./ObjectUnpacker001");
var createObjectUnpacker = function (version) {
switch (version) {
case '0.0.18':
case '0.0.19':
case '0.0.20':
case '0.0.21':
default:
return new ObjectUnpacker001_1.ObjectUnpacker001();
}
var ObjectUnpackerImpl_1 = require("./ObjectUnpackerImpl");
var createObjectUnpacker = function () {
return new ObjectUnpackerImpl_1.ObjectUnpackerImpl();
};
exports.createObjectUnpacker = createObjectUnpacker;
//# sourceMappingURL=ObjectUnpacker.js.map
export interface ReferencesResolver {
resolve(referenceObject: Map<string, unknown>, dataObject: any): Record<string, unknown>;
}
export declare const createReferencesResolver: () => ReferencesResolver;
export declare const createReferencesResolver: (localsOnly?: boolean | undefined) => ReferencesResolver;
export declare const INDEX_NAMESPACE = "/index";

@@ -6,0 +6,0 @@ export declare const COMPACT_NAMESPACE = "/compact";

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FIND_REFS = exports.SUBS_NAMESPACE = exports.COMPACT_NAMESPACE = exports.INDEX_NAMESPACE = exports.createReferencesResolver = void 0;
var createReferencesResolver = function () { return new ReferencesResolverImpl(); };
var Util_1 = require("./Util");
var createReferencesResolver = function (localsOnly) { return new ReferencesResolverImpl(localsOnly ? true : false); };
exports.createReferencesResolver = createReferencesResolver;

@@ -11,3 +12,4 @@ exports.INDEX_NAMESPACE = '/index';

var ReferencesResolverImpl = (function () {
function ReferencesResolverImpl() {
function ReferencesResolverImpl(localsOnly) {
this.localsOnly = localsOnly;
}

@@ -19,3 +21,3 @@ ReferencesResolverImpl.prototype.resolve = function (referenceObject, dataObject) {

if (typeof dataObject === 'string') {
return processString(referenceObject, dataObject);
return this.processString(referenceObject, dataObject);
}

@@ -25,105 +27,114 @@ var index = Array.isArray(dataObject['?']) ? dataObject['?'] : [dataObject['?']];

index.forEach(function (v, i) {
referenceObject.set("%" + i, v);
referenceObject.set("%" + i + "%", v);
referenceObject.set("" + i, v);
});
}
return Array.isArray(dataObject) ? processArray('', referenceObject, dataObject) : processObject('', referenceObject, dataObject);
return Array.isArray(dataObject) ? this.processArray('', referenceObject, dataObject) : this.processObject('', referenceObject, dataObject);
};
return ReferencesResolverImpl;
}());
var processArray = function (parent, referenceValues, arr) {
var result = [];
arr.forEach(function (value, index) {
var newParent = parent + "." + index;
if (Array.isArray(value)) {
result.push(processArray(newParent, referenceValues, value));
ReferencesResolverImpl.prototype.processArray = function (parent, referenceValues, arr) {
var _this = this;
var result = [];
arr.forEach(function (value, index) {
var newParent = parent + "." + index;
if (Array.isArray(value)) {
result.push(_this.processArray(newParent, referenceValues, value));
}
else if (typeof value === 'object') {
result.push(_this.processObject(newParent, referenceValues, value));
}
else if (typeof value === 'string') {
result.push(_this.processString(referenceValues, value));
}
else {
result.push(value);
}
});
return result;
};
ReferencesResolverImpl.prototype.processObject = function (parent, referenceValues, obj) {
var _this = this;
if (obj === null) {
return null;
}
else if (typeof value === 'object') {
result.push(processObject(newParent, referenceValues, value));
var result = {};
Object.keys(obj).forEach(function (k) {
var value = obj[k];
if (value === null) {
result[k] = null;
return;
}
var newParent = parent + "." + k;
if (Array.isArray(value)) {
result[k] = _this.processArray(newParent, referenceValues, value);
}
else if (typeof value === 'object') {
result[k] = _this.processObject(newParent, referenceValues, value);
}
else if (typeof value === 'string') {
result[k] = _this.processString(referenceValues, value);
}
else {
result[k] = value;
}
});
return result;
};
ReferencesResolverImpl.prototype.processString = function (referenceValues, str) {
var _this = this;
var result = str;
var refsInString = [];
var matches = exports.FIND_REFS.exec(result);
while (matches !== null) {
var ref = matches[0];
refsInString.push(ref);
matches = exports.FIND_REFS.exec(result);
}
else if (typeof value === 'string') {
result.push(processString(referenceValues, value));
}
else {
result.push(value);
}
});
return result;
};
var processObject = function (parent, referenceValues, obj) {
if (obj === null) {
return null;
}
var result = {};
Object.keys(obj).forEach(function (k) {
var value = obj[k];
if (value === null) {
result[k] = null;
return;
}
var newParent = parent + "." + k;
if (Array.isArray(value)) {
result[k] = processArray(newParent, referenceValues, value);
}
else if (typeof value === 'object') {
result[k] = processObject(newParent, referenceValues, value);
}
else if (typeof value === 'string') {
result[k] = processString(referenceValues, value);
}
else {
result[k] = value;
}
});
return result;
};
var processString = function (referenceValues, str) {
var result = str;
var refsInString = [];
var matches = exports.FIND_REFS.exec(result);
while (matches !== null) {
var ref = matches[0];
refsInString.push(ref);
matches = exports.FIND_REFS.exec(result);
}
refsInString.forEach(function (ref) {
if (ref.startsWith('%%')) {
return;
}
var replacement = referenceValues.get(ref);
if (replacement !== null && replacement !== undefined && typeof result === 'string') {
if (result === ref) {
if (typeof replacement === 'string') {
result = unref(replacement);
refsInString.forEach(function (ref) {
if (ref.startsWith('%%')) {
return;
}
var bareRef = ref.startsWith('%') && ref.endsWith('%') ? ref.substring(1, ref.length - 1) : ref.substring(1);
if (Util_1.isNumeric.test(bareRef)) {
bareRef = "/index." + bareRef;
}
var replacement = referenceValues.get(bareRef);
if (replacement !== null && replacement !== undefined && typeof result === 'string') {
if (result === ref) {
if (typeof replacement === 'string' && !_this.localsOnly) {
result = _this.unref(replacement);
}
else {
result = replacement;
}
}
else {
result = replacement;
if (typeof replacement === 'object') {
var rawRef = _this.unref(ref);
console.error(rawRef + " refers to an object or array and cannot be embedded in a string");
result = result.replace(ref, "" + rawRef);
}
else {
result = result.replace(ref, "" + replacement);
}
}
}
else if (result === ref) {
result = null;
}
else {
if (typeof replacement === 'object') {
var rawRef = unref(ref);
console.error(rawRef + " refers to an object or array and cannot be embedded in a string");
result = result.replace(ref, "" + rawRef);
}
else {
result = result.replace(ref, "" + replacement);
}
result = result.replace(ref, '');
}
});
if (typeof result === 'string') {
return result.replace('%%', '%');
}
else if (result === ref) {
result = null;
if (result === null && this.localsOnly) {
return str;
}
else {
result = result.replace(ref, '');
}
});
if (typeof result === 'string') {
return result.replace('%%', '%');
}
return result;
};
var unref = function (ref) {
return ref.replace('/index.', '').replace('/subs.', '');
};
return result;
};
ReferencesResolverImpl.prototype.unref = function (ref) {
return ref.replace('/index.', '').replace('/subs.', '');
};
return ReferencesResolverImpl;
}());
//# sourceMappingURL=ReferencesResolver.js.map

@@ -1,4 +0,5 @@

export declare const indexObject: (prefix: string, postfix: string, optionalPostfix: boolean, parent: string, refs: Map<string, unknown>, data: any) => void;
export declare const isNumeric: RegExp;
export declare const indexObject: (parent: string, refs: Map<string, unknown>, data: any) => void;
export declare const transform: (data: any, f: (x: any) => any) => any;
export declare function prefixReferences(s: any): any;
export declare const identity: (x: any) => any;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.identity = exports.prefixReferences = exports.transform = exports.indexObject = void 0;
exports.identity = exports.prefixReferences = exports.transform = exports.indexObject = exports.isNumeric = void 0;
var ReferencesResolver_1 = require("./ReferencesResolver");
var indexObject = function (prefix, postfix, optionalPostfix, parent, refs, data) {
exports.isNumeric = /^[-]?\d*\.?\d+(?:[Ee][+-]?\d+)?$/;
var indexObject = function (parent, refs, data) {
if (!data) {

@@ -11,8 +12,5 @@ return;

var key = parent.length > 0 ? parent + "." + kvPair[0] : "" + kvPair[0];
if (optionalPostfix) {
refs.set(prefix + key, kvPair[1]);
}
refs.set(prefix + key + postfix, kvPair[1]);
refs.set(key, kvPair[1]);
if (typeof kvPair[1] === 'object') {
exports.indexObject(prefix, postfix, optionalPostfix, key, refs, kvPair[1]);
exports.indexObject(key, refs, kvPair[1]);
}

@@ -69,6 +67,6 @@ });

if (firstRefCharCode > 47 && firstRefCharCode < 58) {
return "%" + ReferencesResolver_1.INDEX_NAMESPACE + "." + ref.substr(1);
return "%" + ReferencesResolver_1.INDEX_NAMESPACE + "." + ref.substring(1);
}
else {
return "%" + ReferencesResolver_1.SUBS_NAMESPACE + "." + ref.substr(1);
return "%" + ReferencesResolver_1.SUBS_NAMESPACE + "." + ref.substring(1);
}

@@ -75,0 +73,0 @@ });

{
"name": "object-unpacker",
"version": "0.0.22",
"version": "1.0.0-rc.1",
"description": "A JSON to JSON mapper in TypeScript",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -8,5 +8,5 @@ # TypeScript Object Unpacker

```TypeScript
// Import the Schema Mapper type
import { createObjectUnpacker } from './ObjectUnpacker';
import { createObjectUnpacker } from '../src/ObjectUnpacker';
import { ProcedureInstruction } from '../src/instructions';

@@ -30,24 +30,38 @@ // Create the schema mapper

// This is the transformation specification
const mapperData = {
"x": {
"rewriteKey": "expanded"
},
"a": {
"rewriteKey": "another",
"assignKeys": [
"s",
"t",
"u"
],
"rewriteValue": {
"first": "%s",
"second": "%t",
"third": "%u",
"fourth": "%/subs.system.metadata.name"
const mapperData: ProcedureInstruction = [
{
comment: 'Create the top level result object',
action: 'toObject',
source: '/compact',
target: '/expanded',
keys: ['x'],
values: {
formatted: '%x'
}
},
"au": {
"rewriteKey": "author"
{
comment: 'process the `formatted` array',
action: 'foreach',
source: '/expanded.formatted',
target: '/expanded.formatted',
loopVar: 'i',
instruction: [
{
comment: 'process the array entry',
action: 'toObject',
source: 'i',
target: 'tmp',
keys: ['a', 'au'],
values: {
another:{
first:'%a.0',
second:'%a.1',
fourth:'%/subs.system.metadata.name'
},
author:'%au'
}
}
]
}
};
];

@@ -90,25 +104,38 @@ // Entries in this object can be referenced by the `data` or the `mapperData`.

// This is the transformation specification
const mapperData = {
"x": {
"rewriteKey": "expanded"
},
"a": {
"rewriteKey": "another",
"assignKeys": [
"s",
"t",
"u"
],
"rewriteValue": {
"first": "%s",
"second": "%t",
"third": "%u",
"fourth": "%/subs.system.metadata.name"
ProcedureInstruction = [
{
comment: 'Create the top level result object',
action: 'toObject',
source: '/compact',
target: '/expanded',
keys: ['x'],
values: {
formatted: '%x'
}
},
"au": {
"rewriteKey": "author"
{
comment: 'process the `formatted` array',
action: 'foreach',
source: '/expanded.formatted',
target: '/expanded.formatted',
loopVar: 'i',
instruction: [
{
comment: 'process the array entry',
action: 'toObject',
source: 'i',
target: 'tmp',
keys: ['a', 'au'],
values: {
another:{
first:'%a.0',
second:'%a.1',
fourth:'%/subs.system.metadata.name'
},
author:'%au'
}
}
]
}
};
];
// Entries in this object can be referenced by the `data` or the `mapperData`.

@@ -142,4 +169,4 @@ // E.g. `%system.metadata.name` and '%system.metadata.author'

```json
{
"expanded": [
{{
"formatted": [
{

@@ -146,0 +173,0 @@ "another": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc