shinkansen-transmission 2.2.1 → 2.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/babel.config.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const debug = require('debug')
2
2
 
3
- const log = debug('shinkansen:transmission')
3
+ const log = debug('shinkansen-transmission')
4
4
 
5
5
  const {
6
6
  env: {
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const debug = require('debug')
2
2
 
3
- const log = debug('shinkansen:transmission')
3
+ const log = debug('shinkansen-transmission')
4
4
 
5
5
  log('`transmission` is awake')
6
6
 
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/es.array.is-array.js");require("core-js/modules/es.symbol.js");require("core-js/modules/es.symbol.description.js");require("core-js/modules/es.object.to-string.js");require("core-js/modules/es.symbol.iterator.js");require("core-js/modules/es.array.iterator.js");require("core-js/modules/es.string.iterator.js");require("core-js/modules/web.dom-collections.iterator.js");require("core-js/modules/es.array.slice.js");require("core-js/modules/es.function.name.js");require("core-js/modules/es.array.from.js");require("core-js/modules/es.object.define-property.js");Object.defineProperty(exports,"__esModule",{value:true});exports.getObject=getObject;exports.getArray=getArray;exports.getSchema=getSchema;exports.transformValueIndexFor=transformValueIndexFor;exports.transformEqualIndexFor=transformEqualIndexFor;exports.transformArrayFor=transformArrayFor;exports.transformObjectFor=transformObjectFor;exports.transformArray=transformArray;exports.transformObject=transformObject;exports["default"]=transform;exports.transformValue=void 0;require("core-js/modules/es.array.find.js");require("core-js/modules/es.reflect.get.js");require("core-js/modules/es.object.keys.js");require("core-js/modules/es.array.some.js");require("core-js/modules/es.array.find-index.js");require("core-js/modules/es.array.reduce.js");require("core-js/modules/es.object.entries.js");require("core-js/modules/es.array.map.js");var _debug=_interopRequireDefault(require("debug"));var _fastDeepEqual=_interopRequireDefault(require("fast-deep-equal"));var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}var log=(0,_debug["default"])('shinkansen-transmission:from-document-to-hash');function findByKey(parentUri,uri){return function find(key){return uri===(0,_common.getUri)(parentUri,key);};}function findByIndex(parentUri,uri){return function find(schema,index){if((0,_common.hasEnum)(schema)){}else{if((0,_common.hasAnyOf)(schema)){var array=(0,_common.getAnyOf)(schema);return array.find(findByIndex(parentUri,uri));}else{if((0,_common.hasOneOf)(schema)){var _array=(0,_common.getOneOf)(schema);return _array.find(findByIndex(parentUri,uri));}}}return(0,_common.getUri)(parentUri,index)===uri;};}function findByValue(value){return function find(schema){return value===transformValue(schema);};}function findByEqual(value){return function find(schema){return(0,_fastDeepEqual["default"])(value,transformValue(schema));};}function toString(value){return value!==undefined?String(value):'';}function getObject(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$properties=_ref.properties,properties=_ref$properties===void 0?{}:_ref$properties;var parentUri=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';return Reflect.get(properties,Object.keys(properties).find(findByKey(parentUri,uri)));}function getArray(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref2$items=_ref2.items,items=_ref2$items===void 0?{}:_ref2$items;var parentUri=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';return(0,_common.isArray)(items)?items.find(findByIndex(parentUri,uri)):items;}function getSchema(){var schema=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var parentUri=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';var type=schema.type;switch(type){case'object':return getObject(schema,parentUri,uri);case'array':return getArray(schema,parentUri,uri);default:return schema;}}var transformValue=function transformValue(schema){return(0,_common.isObject)(schema)?(0,_common.isConstValue)(schema)?(0,_common.toConstValue)(schema):(0,_common.isDefaultValue)(schema)?(0,_common.toDefaultValue)(schema):schema:schema;};exports.transformValue=transformValue;function transformValueIndexFor(array,value){var find=findByValue(value);if(array.some(find)){var index=array.findIndex(find);return String(index);}return toString(value);}function transformEqualIndexFor(array,value){var find=findByEqual(value);if(array.some(find)){var index=array.findIndex(find);return String(index);}return toString(value);}function transformArrayFor(document,schema,values,params,parentUri,uri){return document.reduce(function(values,value,index){var schemaUri=(0,_common.getUri)(parentUri,index);return transform(value,getSchema(schema,parentUri,schemaUri),values,params,schemaUri,schemaUri);},values);}function transformObjectFor(document,schema,values,params,parentUri,uri){return Object.entries(document).reduce(function(values,_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],value=_ref4[1];var schemaUri=(0,_common.getUri)(parentUri,key);return transform(value,getSchema(schema,parentUri,schemaUri),values,params,schemaUri,schemaUri);},values);}function transformArray(document,schema,values,params,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);values[uri]=document.map(function(value){return transformValueIndexFor(array,value);});return values;}else{if((0,_common.hasAnyOf)(schema)){var _array2=(0,_common.getAnyOf)(schema);values[uri]=document.map(function(value){return transformValueIndexFor(_array2,value);});return values;}else{if((0,_common.hasOneOf)(schema)){var _array3=(0,_common.getOneOf)(schema);values[uri]=document.map(function(value){return transformValueIndexFor(_array3,value);});return values;}else{var _schema$items=schema.items,items=_schema$items===void 0?{}:_schema$items;if((0,_common.isArray)(items)){return transformArrayFor(document,schema,values,params,parentUri,uri);}else{if((0,_common.isObject)(items)){if((0,_common.hasEnum)(items)){var _array4=(0,_common.getEnum)(items);values[uri]=document.map(function(value){return transformValueIndexFor(_array4,value);});return values;}else{if((0,_common.hasAnyOf)(items)){var _array5=(0,_common.getAnyOf)(items);values[uri]=document.map(function(value){return transformValueIndexFor(_array5,value);});return values;}else{if((0,_common.hasOneOf)(items)){var _array6=(0,_common.getOneOf)(items);values[uri]=document.map(function(value){return transformValueIndexFor(_array6,value);});return values;}}}}}}}}return transformArrayFor(document,schema,values,params,parentUri,uri);}function transformObject(document,schema,values,params,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);values[uri]=transformEqualIndexFor(array,document);return values;}else{if((0,_common.hasAnyOf)(schema)){var _array7=(0,_common.getAnyOf)(schema);values[uri]=transformEqualIndexFor(_array7,document);return values;}else{if((0,_common.hasOneOf)(schema)){var _array8=(0,_common.getOneOf)(schema);values[uri]=transformEqualIndexFor(_array8,document);return values;}}}return transformObjectFor(document,schema,values,params,parentUri,uri);}function transform(document){var schema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var values=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var params=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var parentUri=arguments.length>4&&arguments[4]!==undefined?arguments[4]:'#';var uri=arguments.length>5&&arguments[5]!==undefined?arguments[5]:(0,_common.getUri)(parentUri);log('fromDocumentToHash');if((0,_common.isArray)(document)){return transformArray(document,schema,values,params,parentUri,uri);}else{if((0,_common.isObject)(document)){return transformObject(document,schema,values,params,parentUri,uri);}else{if((0,_common.hasEnum)(schema)){var items=(0,_common.getEnum)(schema);values[uri]=transformValueIndexFor(items,document);return values;}else{if((0,_common.hasAnyOf)(schema)){var _items=(0,_common.getAnyOf)(schema);values[uri]=transformValueIndexFor(_items,document);return values;}else{if((0,_common.hasOneOf)(schema)){var _items2=(0,_common.getOneOf)(schema);values[uri]=transformValueIndexFor(_items2,document);return values;}}}}}values[uri]=toString(document);return values;}
1
+ "use strict";require("core-js/modules/es.array.is-array.js");require("core-js/modules/es.symbol.js");require("core-js/modules/es.symbol.description.js");require("core-js/modules/es.object.to-string.js");require("core-js/modules/es.symbol.iterator.js");require("core-js/modules/es.array.iterator.js");require("core-js/modules/es.string.iterator.js");require("core-js/modules/web.dom-collections.iterator.js");require("core-js/modules/es.array.slice.js");require("core-js/modules/es.function.name.js");require("core-js/modules/es.array.from.js");require("core-js/modules/es.object.define-property.js");Object.defineProperty(exports,"__esModule",{value:true});exports.getObject=getObject;exports.getArray=getArray;exports.getSchema=getSchema;exports.transformValueIndexFor=transformValueIndexFor;exports.transformEqualIndexFor=transformEqualIndexFor;exports.transformArrayFor=transformArrayFor;exports.transformObjectFor=transformObjectFor;exports.transformArray=transformArray;exports.transformObject=transformObject;exports["default"]=transform;exports.transformValue=void 0;require("core-js/modules/es.array.find.js");require("core-js/modules/es.reflect.get.js");require("core-js/modules/es.object.keys.js");require("core-js/modules/es.array.some.js");require("core-js/modules/es.array.find-index.js");require("core-js/modules/es.array.reduce.js");require("core-js/modules/es.object.entries.js");require("core-js/modules/es.array.map.js");var _debug=_interopRequireDefault(require("debug"));var _fastDeepEqual=_interopRequireDefault(require("fast-deep-equal"));var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}var log=(0,_debug["default"])('shinkansen-transmission:from-document-to-hash');log('`shinkansen-transmission` is awake');function findByKey(parentUri,uri){return function find(key){return(0,_common.getUri)(parentUri,key)===uri;};}function findByIndex(parentUri,uri){return function find(schema,index){if((0,_common.hasEnum)(schema)){return(0,_common.getUri)(parentUri,index)===uri;}else{if((0,_common.hasAnyOf)(schema)){var array=(0,_common.getAnyOf)(schema);return array.find(findByIndex(parentUri,uri));}else{if((0,_common.hasOneOf)(schema)){var _array=(0,_common.getOneOf)(schema);return _array.find(findByIndex(parentUri,uri));}}}return(0,_common.getUri)(parentUri,index)===uri;};}function findByValue(value){return function find(schema){return value===transformValue(schema);};}function findByEqual(value){return function find(schema){return(0,_fastDeepEqual["default"])(value,transformValue(schema));};}function toString(value){return value!==undefined?String(value):'';}function getObject(){var _ref=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref$properties=_ref.properties,properties=_ref$properties===void 0?{}:_ref$properties;var parentUri=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';return Reflect.get(properties,Object.keys(properties).find(findByKey(parentUri,uri)));}function getArray(){var _ref2=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{},_ref2$items=_ref2.items,items=_ref2$items===void 0?{}:_ref2$items;var parentUri=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';return(0,_common.isArray)(items)?items.find(findByIndex(parentUri,uri)):items;}function getSchema(){var schema=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var parentUri=arguments.length>1&&arguments[1]!==undefined?arguments[1]:'';var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'';var type=schema.type;switch(type){case'object':return getObject(schema,parentUri,uri);case'array':return getArray(schema,parentUri,uri);default:return schema;}}var transformValue=function transformValue(schema){return(0,_common.isObject)(schema)?(0,_common.isConstValue)(schema)?(0,_common.toConstValue)(schema):(0,_common.isDefaultValue)(schema)?(0,_common.toDefaultValue)(schema):schema:schema;};exports.transformValue=transformValue;function transformValueIndexFor(array,value){var find=findByValue(value);if(array.some(find)){var index=array.findIndex(find);return String(index);}return toString(value);}function transformEqualIndexFor(array,value){var find=findByEqual(value);if(array.some(find)){var index=array.findIndex(find);return String(index);}return toString(value);}function transformArrayFor(document,schema,values,params,parentUri,uri){return document.reduce(function(values,value,index){var schemaUri=(0,_common.getUri)(parentUri,index);return transform(value,getSchema(schema,parentUri,schemaUri),values,params,schemaUri,schemaUri);},values);}function transformObjectFor(document,schema,values,params,parentUri,uri){return Object.entries(document).reduce(function(values,_ref3){var _ref4=_slicedToArray(_ref3,2),key=_ref4[0],value=_ref4[1];var schemaUri=(0,_common.getUri)(parentUri,key);return transform(value,getSchema(schema,parentUri,schemaUri),values,params,schemaUri,schemaUri);},values);}function transformArray(document,schema,values,params,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);values[uri]=document.map(function(value){return transformValueIndexFor(array,value);});return values;}else{if((0,_common.hasAnyOf)(schema)){var _array2=(0,_common.getAnyOf)(schema);values[uri]=document.map(function(value){return transformValueIndexFor(_array2,value);});return values;}else{if((0,_common.hasOneOf)(schema)){var _array3=(0,_common.getOneOf)(schema);values[uri]=document.map(function(value){return transformValueIndexFor(_array3,value);});return values;}else{var _schema$items=schema.items,items=_schema$items===void 0?{}:_schema$items;if((0,_common.isArray)(items)){return transformArrayFor(document,schema,values,params,parentUri,uri);}else{if((0,_common.isObject)(items)){if((0,_common.hasEnum)(items)){var _array4=(0,_common.getEnum)(items);values[uri]=document.map(function(value){return transformValueIndexFor(_array4,value);});return values;}else{if((0,_common.hasAnyOf)(items)){var _array5=(0,_common.getAnyOf)(items);values[uri]=document.map(function(value){return transformValueIndexFor(_array5,value);});return values;}else{if((0,_common.hasOneOf)(items)){var _array6=(0,_common.getOneOf)(items);values[uri]=document.map(function(value){return transformValueIndexFor(_array6,value);});return values;}}}}}}}}return transformArrayFor(document,schema,values,params,parentUri,uri);}function transformObject(document,schema,values,params,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);values[uri]=transformEqualIndexFor(array,document);return values;}else{if((0,_common.hasAnyOf)(schema)){var _array7=(0,_common.getAnyOf)(schema);values[uri]=transformEqualIndexFor(_array7,document);return values;}else{if((0,_common.hasOneOf)(schema)){var _array8=(0,_common.getOneOf)(schema);values[uri]=transformEqualIndexFor(_array8,document);return values;}}}return transformObjectFor(document,schema,values,params,parentUri,uri);}function transform(document){var schema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var values=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var params=arguments.length>3&&arguments[3]!==undefined?arguments[3]:{};var parentUri=arguments.length>4&&arguments[4]!==undefined?arguments[4]:'#';var uri=arguments.length>5&&arguments[5]!==undefined?arguments[5]:(0,_common.getUri)(parentUri);log('fromDocumentToHash');if((0,_common.isArray)(document)){return transformArray(document,schema,values,params,parentUri,uri);}else{if((0,_common.isObject)(document)){return transformObject(document,schema,values,params,parentUri,uri);}else{if((0,_common.hasEnum)(schema)){var items=(0,_common.getEnum)(schema);values[uri]=transformValueIndexFor(items,document);return values;}else{if((0,_common.hasAnyOf)(schema)){var _items=(0,_common.getAnyOf)(schema);values[uri]=transformValueIndexFor(_items,document);return values;}else{if((0,_common.hasOneOf)(schema)){var _items2=(0,_common.getOneOf)(schema);values[uri]=transformValueIndexFor(_items2,document);return values;}}}}}values[uri]=toString(document);return values;}
@@ -1 +1 @@
1
- "use strict";require("core-js/modules/es.array.is-array.js");require("core-js/modules/es.symbol.js");require("core-js/modules/es.symbol.description.js");require("core-js/modules/es.object.to-string.js");require("core-js/modules/es.symbol.iterator.js");require("core-js/modules/es.array.iterator.js");require("core-js/modules/es.string.iterator.js");require("core-js/modules/web.dom-collections.iterator.js");require("core-js/modules/es.function.name.js");require("core-js/modules/es.array.from.js");require("core-js/modules/es.object.define-property.js");require("core-js/modules/es.date.to-string.js");require("core-js/modules/es.regexp.to-string.js");Object.defineProperty(exports,"__esModule",{value:true});exports.toNull=toNull;exports.toBoolean=toBoolean;exports.toString=toString;exports.toNumber=toNumber;exports.transformValueFor=transformValueFor;exports.getArrayFor=getArrayFor;exports.transformArrayFor=transformArrayFor;exports.transformObjectFor=transformObjectFor;exports.transformItemsArrayFor=transformItemsArrayFor;exports.transformItemsObjectFor=transformItemsObjectFor;exports.transformObjectSchemaNull=transformObjectSchemaNull;exports.transformObjectSchemaBoolean=transformObjectSchemaBoolean;exports.transformObjectSchemaObject=transformObjectSchemaObject;exports.transformObjectSchemaArray=transformObjectSchemaArray;exports.transformObjectSchemaNumber=transformObjectSchemaNumber;exports.transformObjectSchemaString=transformObjectSchemaString;exports.transformObjectSchema=transformObjectSchema;exports.transformArraySchemaNull=transformArraySchemaNull;exports.transformArraySchemaBoolean=transformArraySchemaBoolean;exports.transformArraySchemaObject=transformArraySchemaObject;exports.transformArraySchemaArray=transformArraySchemaArray;exports.transformArraySchemaNumber=transformArraySchemaNumber;exports.transformArraySchemaString=transformArraySchemaString;exports.transformArraySchema=transformArraySchema;exports.transformNull=transformNull;exports.transformBoolean=transformBoolean;exports.transformObject=transformObject;exports.transformArray=transformArray;exports.transformNumber=transformNumber;exports.transformString=transformString;exports["default"]=transform;exports.transformValue=void 0;require("core-js/modules/es.number.constructor.js");require("core-js/modules/es.reflect.has.js");require("core-js/modules/es.reflect.get.js");require("core-js/modules/es.array.reduce.js");require("core-js/modules/es.object.entries.js");require("core-js/modules/es.array.filter.js");require("core-js/modules/es.object.keys.js");require("core-js/modules/es.string.starts-with.js");require("core-js/modules/es.string.ends-with.js");require("core-js/modules/es.array.slice.js");require("core-js/modules/es.array.includes.js");require("core-js/modules/es.string.includes.js");require("core-js/modules/es.array.index-of.js");require("core-js/modules/es.array.map.js");var _debug=_interopRequireDefault(require("debug"));var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}var log=(0,_debug["default"])('shinkansen-transmission:from-hash-to-document:log');var error=(0,_debug["default"])('shinkansen-transmission:from-hash-to-document:error');function toNull(v){if(v===null||v==='null')return null;throw new Error('Invalid `null`');}function toBoolean(v){if(typeof v==='boolean')return v;if(v==='true')return true;if(v==='false')return false;throw new Error('Invalid `boolean`');}function toString(v){if(typeof v==='string')return v;if(typeof v==='number')return String(v);return JSON.stringify(v);}function toNumber(v){if(typeof v==='number')return v;if(v){var n=Number(v);if(!isNaN(n))return n;}throw new Error('Invalid `number`');}var transformValue=function transformValue(schema){return(0,_common.isObject)(schema)?(0,_common.isConstValue)(schema)?(0,_common.toConstValue)(schema):(0,_common.isDefaultValue)(schema)?(0,_common.toDefaultValue)(schema):schema:schema;};exports.transformValue=transformValue;function transformValueFor(value,array){try{var i=toNumber(value);if(Reflect.has(array,i)){var v=Reflect.get(array,i);return transformValue(v);}}catch(_ref){var _ref$message=_ref.message;var message=_ref$message===void 0?'No error message defined':_ref$message;error(message);}return value;}function getArrayFor(values){var array=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';if(Reflect.has(values,uri)){var v=Reflect.get(values,uri);var i=Number(v);if(!isNaN(i))return array[i];}return[];}function transformArrayFor(values){var _ref2=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref2$items=_ref2.items,items=_ref2$items===void 0?null:_ref2$items;var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if((0,_common.isArray)(items)){return transformItemsArrayFor(values,items,parentUri,uri);}else{if((0,_common.isObject)(items)){return transformItemsObjectFor(values,items,parentUri,uri);}}return[];}function transformObjectFor(values){var _ref3=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref3$properties=_ref3.properties,properties=_ref3$properties===void 0?null:_ref3$properties;var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if((0,_common.isObject)(properties)){return Object.entries(properties).reduce(function(accumulator,_ref4){var _ref5=_slicedToArray(_ref4,2),key=_ref5[0],schema=_ref5[1];var schemaUri=(0,_common.getUri)(parentUri,key);accumulator[key]=transform(values,schema,schemaUri,schemaUri);return accumulator;},{});}return{};}function transformItemsArrayFor(values){var items=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.isArray)(value)){return transform(values,items,uri,uri);}}return Object.keys(values).filter(function(key){return key.startsWith(uri);}).reduce(function(accumulator,key){var v=uri.endsWith('/')?key.slice(uri.length):key.slice(uri.length+1);var i=v?Number(v.includes('/')?v.slice(0,v.indexOf('/')):v):NaN;if(!isNaN(i)){var schemaUri=(0,_common.getUri)(parentUri,i);accumulator[i]=transform(values,items[i],schemaUri,schemaUri);}return accumulator;},[]);}function transformItemsObjectFor(values){var items=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.isArray)(value)){return transform(values,items,uri,uri);}}return Object.keys(values).filter(function(key){return key.startsWith(uri);}).reduce(function(accumulator,key){var v=uri.endsWith('/')?key.slice(uri.length):key.slice(uri.length+1);var i=v?Number(v.includes('/')?v.slice(0,v.indexOf('/')):v):NaN;if(!isNaN(i)){var schemaUri=(0,_common.getUri)(parentUri,i);accumulator[i]=transform(values,items,schemaUri,schemaUri);}return accumulator;},[]);}var handleError=function handleError(_ref6){var _ref6$message=_ref6.message,message=_ref6$message===void 0?'No error message defined':_ref6$message;return error(message);};function transformObjectSchemaNull(values,schema,_ref7){var parentUri=_ref7.uri,fieldKey=_ref7.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformNull(values,schema,parentUri,uri);}function transformObjectSchemaBoolean(values,schema,_ref8){var parentUri=_ref8.uri,fieldKey=_ref8.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformBoolean(values,schema,parentUri,uri);}function transformObjectSchemaObject(values,schema,_ref9){var parentUri=_ref9.uri,fieldKey=_ref9.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformObject(values,schema,uri,uri);}function transformObjectSchemaArray(values,schema,_ref10){var parentUri=_ref10.uri,fieldKey=_ref10.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformArray(values,schema,uri,uri);}function transformObjectSchemaNumber(values,schema,_ref11){var parentUri=_ref11.uri,fieldKey=_ref11.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformNumber(values,schema,parentUri,uri);}function transformObjectSchemaString(values,schema,_ref12){var parentUri=_ref12.uri,fieldKey=_ref12.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformString(values,schema,parentUri,uri);}function transformObjectSchema(){var values=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var schema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var type=schema.type;switch(type){case'null':return transformObjectSchemaNull(values,schema,params);case'boolean':return transformObjectSchemaBoolean(values,schema,params);case'object':return transformObjectSchemaObject(values,schema,params);case'array':return transformObjectSchemaArray(values,schema,params);case'number':return transformObjectSchemaNumber(values,schema,params);case'string':return transformObjectSchemaString(values,schema,params);default:throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1');}}function transformArraySchemaNull(values,schema,_ref13){var parentUri=_ref13.uri,arrayIndex=_ref13.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformNull(values,schema,parentUri,uri);}function transformArraySchemaBoolean(values,schema,_ref14){var parentUri=_ref14.uri,arrayIndex=_ref14.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformBoolean(values,schema,parentUri,uri);}function transformArraySchemaObject(values,schema,_ref15){var parentUri=_ref15.uri,arrayIndex=_ref15.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformObject(values,schema,uri,uri);}function transformArraySchemaArray(values,schema,_ref16){var parentUri=_ref16.uri,arrayIndex=_ref16.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformArray(values,schema,uri,uri);}function transformArraySchemaNumber(values,schema,_ref17){var parentUri=_ref17.uri,arrayIndex=_ref17.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformNumber(values,schema,parentUri,uri);}function transformArraySchemaString(values,schema,_ref18){var parentUri=_ref18.uri,arrayIndex=_ref18.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformString(values,schema,parentUri,uri);}function transformArraySchema(){var values=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var schema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var type=schema.type;switch(type){case'null':return transformArraySchemaNull(values,schema,params);case'boolean':return transformArraySchemaBoolean(values,schema,params);case'object':return transformArraySchemaObject(values,schema,params);case'array':return transformArraySchemaArray(values,schema,params);case'number':return transformArraySchemaNumber(values,schema,params);case'string':return transformArraySchemaString(values,schema,params);default:throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1');}}function transformNull(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array);});return transformValueFor(value,_array);}else{if((0,_common.hasOneOf)(schema)){var _array2=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array2);});return transformValueFor(value,_array2);}}}try{if((0,_common.isArray)(value))return value.map(toNull);return toNull(value);}catch(e){handleError(e);}return value;}}function transformBoolean(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array3=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array3);});return transformValueFor(value,_array3);}else{if((0,_common.hasOneOf)(schema)){var _array4=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array4);});return transformValueFor(value,_array4);}}}try{if((0,_common.isArray)(value))return value.map(toBoolean);return toBoolean(value);}catch(e){handleError(e);}return value;}}function transformObject(values,schema,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);return getArrayFor(values,array,uri);}else{if((0,_common.hasAnyOf)(schema)){var _array5=(0,_common.getAnyOf)(schema);return getArrayFor(values,_array5,uri);}else{if((0,_common.hasOneOf)(schema)){var _array6=(0,_common.getOneOf)(schema);return getArrayFor(values,_array6,uri);}}}return transformObjectFor(values,schema,parentUri,uri);}function transformArray(values,schema,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);return getArrayFor(values,array,uri);}else{if((0,_common.hasAnyOf)(schema)){var _array7=(0,_common.getAnyOf)(schema);return getArrayFor(values,_array7,uri);}else{if((0,_common.hasOneOf)(schema)){var _array8=(0,_common.getOneOf)(schema);return getArrayFor(values,_array8,uri);}}}return transformArrayFor(values,schema,parentUri,uri);}function transformNumber(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array9=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array9);});return transformValueFor(value,_array9);}else{if((0,_common.hasOneOf)(schema)){var _array10=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array10);});return transformValueFor(value,_array10);}}}try{if((0,_common.isArray)(value))return value.map(toNumber);return toNumber(value);}catch(e){handleError(e);}return value;}}function transformString(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array11=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array11);});return transformValueFor(value,_array11);}else{if((0,_common.hasOneOf)(schema)){var _array12=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array12);});return transformValueFor(value,_array12);}}}try{if((0,_common.isArray)(value))return value.map(toString);return toString(value);}catch(e){handleError(e);}return value;}}function transform(){var values=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var rootSchema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);log('fromHashToDocument');var type=rootSchema.type;switch(type){case'null':return transformNull(values,rootSchema,parentUri,uri);case'boolean':return transformBoolean(values,rootSchema,parentUri,uri);case'object':return transformObject(values,rootSchema,parentUri,uri);case'array':return transformArray(values,rootSchema,parentUri,uri);case'number':return transformNumber(values,rootSchema,parentUri,uri);case'string':return transformString(values,rootSchema,parentUri,uri);default:throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1');}}
1
+ "use strict";require("core-js/modules/es.array.is-array.js");require("core-js/modules/es.symbol.js");require("core-js/modules/es.symbol.description.js");require("core-js/modules/es.object.to-string.js");require("core-js/modules/es.symbol.iterator.js");require("core-js/modules/es.array.iterator.js");require("core-js/modules/es.string.iterator.js");require("core-js/modules/web.dom-collections.iterator.js");require("core-js/modules/es.function.name.js");require("core-js/modules/es.array.from.js");require("core-js/modules/es.object.define-property.js");require("core-js/modules/es.date.to-string.js");require("core-js/modules/es.regexp.to-string.js");Object.defineProperty(exports,"__esModule",{value:true});exports.toNull=toNull;exports.toBoolean=toBoolean;exports.toString=toString;exports.toNumber=toNumber;exports.transformValueFor=transformValueFor;exports.getArrayFor=getArrayFor;exports.transformArrayFor=transformArrayFor;exports.transformObjectFor=transformObjectFor;exports.transformItemsArrayFor=transformItemsArrayFor;exports.transformItemsObjectFor=transformItemsObjectFor;exports.transformObjectSchemaNull=transformObjectSchemaNull;exports.transformObjectSchemaBoolean=transformObjectSchemaBoolean;exports.transformObjectSchemaObject=transformObjectSchemaObject;exports.transformObjectSchemaArray=transformObjectSchemaArray;exports.transformObjectSchemaNumber=transformObjectSchemaNumber;exports.transformObjectSchemaString=transformObjectSchemaString;exports.transformObjectSchema=transformObjectSchema;exports.transformArraySchemaNull=transformArraySchemaNull;exports.transformArraySchemaBoolean=transformArraySchemaBoolean;exports.transformArraySchemaObject=transformArraySchemaObject;exports.transformArraySchemaArray=transformArraySchemaArray;exports.transformArraySchemaNumber=transformArraySchemaNumber;exports.transformArraySchemaString=transformArraySchemaString;exports.transformArraySchema=transformArraySchema;exports.transformNull=transformNull;exports.transformBoolean=transformBoolean;exports.transformObject=transformObject;exports.transformArray=transformArray;exports.transformNumber=transformNumber;exports.transformString=transformString;exports["default"]=transform;exports.transformValue=void 0;require("core-js/modules/es.number.constructor.js");require("core-js/modules/es.reflect.has.js");require("core-js/modules/es.reflect.get.js");require("core-js/modules/es.array.reduce.js");require("core-js/modules/es.object.entries.js");require("core-js/modules/es.array.filter.js");require("core-js/modules/es.object.keys.js");require("core-js/modules/es.string.starts-with.js");require("core-js/modules/es.string.ends-with.js");require("core-js/modules/es.array.slice.js");require("core-js/modules/es.array.includes.js");require("core-js/modules/es.string.includes.js");require("core-js/modules/es.array.index-of.js");require("core-js/modules/es.array.map.js");var _debug=_interopRequireDefault(require("debug"));var _common=require("../common");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{"default":obj};}function _slicedToArray(arr,i){return _arrayWithHoles(arr)||_iterableToArrayLimit(arr,i)||_unsupportedIterableToArray(arr,i)||_nonIterableRest();}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");}function _unsupportedIterableToArray(o,minLen){if(!o)return;if(typeof o==="string")return _arrayLikeToArray(o,minLen);var n=Object.prototype.toString.call(o).slice(8,-1);if(n==="Object"&&o.constructor)n=o.constructor.name;if(n==="Map"||n==="Set")return Array.from(o);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return _arrayLikeToArray(o,minLen);}function _arrayLikeToArray(arr,len){if(len==null||len>arr.length)len=arr.length;for(var i=0,arr2=new Array(len);i<len;i++){arr2[i]=arr[i];}return arr2;}function _iterableToArrayLimit(arr,i){var _i=arr==null?null:typeof Symbol!=="undefined"&&arr[Symbol.iterator]||arr["@@iterator"];if(_i==null)return;var _arr=[];var _n=true;var _d=false;var _s,_e;try{for(_i=_i.call(arr);!(_n=(_s=_i.next()).done);_n=true){_arr.push(_s.value);if(i&&_arr.length===i)break;}}catch(err){_d=true;_e=err;}finally{try{if(!_n&&_i["return"]!=null)_i["return"]();}finally{if(_d)throw _e;}}return _arr;}function _arrayWithHoles(arr){if(Array.isArray(arr))return arr;}var log=(0,_debug["default"])('shinkansen-transmission:from-hash-to-document');log('`shinkansen-transmission` is awake');function toNull(v){if(v===null||v==='null')return null;throw new Error('Invalid `null`');}function toBoolean(v){if(typeof v==='boolean')return v;if(v==='true')return true;if(v==='false')return false;throw new Error('Invalid `boolean`');}function toString(v){if(typeof v==='string')return v;if(typeof v==='number')return String(v);return JSON.stringify(v);}function toNumber(v){if(typeof v==='number')return v;if(v){var n=Number(v);if(!isNaN(n))return n;}throw new Error('Invalid `number`');}var transformValue=function transformValue(schema){return(0,_common.isObject)(schema)?(0,_common.isConstValue)(schema)?(0,_common.toConstValue)(schema):(0,_common.isDefaultValue)(schema)?(0,_common.toDefaultValue)(schema):schema:schema;};exports.transformValue=transformValue;function transformValueFor(value,array){try{var i=toNumber(value);if(Reflect.has(array,i)){var v=Reflect.get(array,i);return transformValue(v);}}catch(_ref){var _ref$message=_ref.message;var message=_ref$message===void 0?'No error message defined':_ref$message;log(message);}return value;}function getArrayFor(values){var array=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var uri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';if(Reflect.has(values,uri)){var v=Reflect.get(values,uri);var i=Number(v);if(!isNaN(i))return array[i];}return[];}function transformArrayFor(values){var _ref2=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref2$items=_ref2.items,items=_ref2$items===void 0?null:_ref2$items;var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if((0,_common.isArray)(items)){return transformItemsArrayFor(values,items,parentUri,uri);}else{if((0,_common.isObject)(items)){return transformItemsObjectFor(values,items,parentUri,uri);}}return[];}function transformObjectFor(values){var _ref3=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},_ref3$properties=_ref3.properties,properties=_ref3$properties===void 0?null:_ref3$properties;var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if((0,_common.isObject)(properties)){return Object.entries(properties).reduce(function(accumulator,_ref4){var _ref5=_slicedToArray(_ref4,2),key=_ref5[0],schema=_ref5[1];var schemaUri=(0,_common.getUri)(parentUri,key);accumulator[key]=transform(values,schema,schemaUri,schemaUri);return accumulator;},{});}return{};}function transformItemsArrayFor(values){var items=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.isArray)(value)){return transform(values,items,uri,uri);}}return Object.keys(values).filter(function(key){return key.startsWith(uri);}).reduce(function(accumulator,key){var v=uri.endsWith('/')?key.slice(uri.length):key.slice(uri.length+1);var i=v?Number(v.includes('/')?v.slice(0,v.indexOf('/')):v):NaN;if(!isNaN(i)){var schemaUri=(0,_common.getUri)(parentUri,i);accumulator[i]=transform(values,items[i],schemaUri,schemaUri);}return accumulator;},[]);}function transformItemsObjectFor(values){var items=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.isArray)(value)){return transform(values,items,uri,uri);}}return Object.keys(values).filter(function(key){return key.startsWith(uri);}).reduce(function(accumulator,key){var v=uri.endsWith('/')?key.slice(uri.length):key.slice(uri.length+1);var i=v?Number(v.includes('/')?v.slice(0,v.indexOf('/')):v):NaN;if(!isNaN(i)){var schemaUri=(0,_common.getUri)(parentUri,i);accumulator[i]=transform(values,items,schemaUri,schemaUri);}return accumulator;},[]);}var handleError=function handleError(_ref6){var _ref6$message=_ref6.message,message=_ref6$message===void 0?'No error message defined':_ref6$message;return log(message);};function transformObjectSchemaNull(values,schema,_ref7){var parentUri=_ref7.uri,fieldKey=_ref7.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformNull(values,schema,parentUri,uri);}function transformObjectSchemaBoolean(values,schema,_ref8){var parentUri=_ref8.uri,fieldKey=_ref8.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformBoolean(values,schema,parentUri,uri);}function transformObjectSchemaObject(values,schema,_ref9){var parentUri=_ref9.uri,fieldKey=_ref9.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformObject(values,schema,uri,uri);}function transformObjectSchemaArray(values,schema,_ref10){var parentUri=_ref10.uri,fieldKey=_ref10.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformArray(values,schema,uri,uri);}function transformObjectSchemaNumber(values,schema,_ref11){var parentUri=_ref11.uri,fieldKey=_ref11.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformNumber(values,schema,parentUri,uri);}function transformObjectSchemaString(values,schema,_ref12){var parentUri=_ref12.uri,fieldKey=_ref12.key;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,fieldKey);return transformString(values,schema,parentUri,uri);}function transformObjectSchema(){var values=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var schema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var type=schema.type;switch(type){case'null':return transformObjectSchemaNull(values,schema,params);case'boolean':return transformObjectSchemaBoolean(values,schema,params);case'object':return transformObjectSchemaObject(values,schema,params);case'array':return transformObjectSchemaArray(values,schema,params);case'number':return transformObjectSchemaNumber(values,schema,params);case'string':return transformObjectSchemaString(values,schema,params);default:throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1');}}function transformArraySchemaNull(values,schema,_ref13){var parentUri=_ref13.uri,arrayIndex=_ref13.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformNull(values,schema,parentUri,uri);}function transformArraySchemaBoolean(values,schema,_ref14){var parentUri=_ref14.uri,arrayIndex=_ref14.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformBoolean(values,schema,parentUri,uri);}function transformArraySchemaObject(values,schema,_ref15){var parentUri=_ref15.uri,arrayIndex=_ref15.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformObject(values,schema,uri,uri);}function transformArraySchemaArray(values,schema,_ref16){var parentUri=_ref16.uri,arrayIndex=_ref16.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformArray(values,schema,uri,uri);}function transformArraySchemaNumber(values,schema,_ref17){var parentUri=_ref17.uri,arrayIndex=_ref17.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformNumber(values,schema,parentUri,uri);}function transformArraySchemaString(values,schema,_ref18){var parentUri=_ref18.uri,arrayIndex=_ref18.index;var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri,arrayIndex);return transformString(values,schema,parentUri,uri);}function transformArraySchema(){var values=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var schema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var params=arguments.length>2&&arguments[2]!==undefined?arguments[2]:{};var type=schema.type;switch(type){case'null':return transformArraySchemaNull(values,schema,params);case'boolean':return transformArraySchemaBoolean(values,schema,params);case'object':return transformArraySchemaObject(values,schema,params);case'array':return transformArraySchemaArray(values,schema,params);case'number':return transformArraySchemaNumber(values,schema,params);case'string':return transformArraySchemaString(values,schema,params);default:throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1');}}function transformNull(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array);});return transformValueFor(value,_array);}else{if((0,_common.hasOneOf)(schema)){var _array2=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array2);});return transformValueFor(value,_array2);}}}try{if((0,_common.isArray)(value))return value.map(toNull);return toNull(value);}catch(e){handleError(e);}return value;}}function transformBoolean(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array3=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array3);});return transformValueFor(value,_array3);}else{if((0,_common.hasOneOf)(schema)){var _array4=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array4);});return transformValueFor(value,_array4);}}}try{if((0,_common.isArray)(value))return value.map(toBoolean);return toBoolean(value);}catch(e){handleError(e);}return value;}}function transformObject(values,schema,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);return getArrayFor(values,array,uri);}else{if((0,_common.hasAnyOf)(schema)){var _array5=(0,_common.getAnyOf)(schema);return getArrayFor(values,_array5,uri);}else{if((0,_common.hasOneOf)(schema)){var _array6=(0,_common.getOneOf)(schema);return getArrayFor(values,_array6,uri);}}}return transformObjectFor(values,schema,parentUri,uri);}function transformArray(values,schema,parentUri,uri){if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);return getArrayFor(values,array,uri);}else{if((0,_common.hasAnyOf)(schema)){var _array7=(0,_common.getAnyOf)(schema);return getArrayFor(values,_array7,uri);}else{if((0,_common.hasOneOf)(schema)){var _array8=(0,_common.getOneOf)(schema);return getArrayFor(values,_array8,uri);}}}return transformArrayFor(values,schema,parentUri,uri);}function transformNumber(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array9=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array9);});return transformValueFor(value,_array9);}else{if((0,_common.hasOneOf)(schema)){var _array10=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array10);});return transformValueFor(value,_array10);}}}try{if((0,_common.isArray)(value))return value.map(toNumber);return toNumber(value);}catch(e){handleError(e);}return value;}}function transformString(values,schema,parentUri,uri){if(Reflect.has(values,uri)){var value=Reflect.get(values,uri);if((0,_common.hasEnum)(schema)){var array=(0,_common.getEnum)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,array);});return transformValueFor(value,array);}else{if((0,_common.hasAnyOf)(schema)){var _array11=(0,_common.getAnyOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array11);});return transformValueFor(value,_array11);}else{if((0,_common.hasOneOf)(schema)){var _array12=(0,_common.getOneOf)(schema);if((0,_common.isArray)(value))return value.map(function(v){return transformValueFor(v,_array12);});return transformValueFor(value,_array12);}}}try{if((0,_common.isArray)(value))return value.map(toString);return toString(value);}catch(e){handleError(e);}return value;}}function transform(){var values=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};var rootSchema=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var parentUri=arguments.length>2&&arguments[2]!==undefined?arguments[2]:'#';var uri=arguments.length>3&&arguments[3]!==undefined?arguments[3]:(0,_common.getUri)(parentUri);log('fromHashToDocument');var type=rootSchema.type;switch(type){case'null':return transformNull(values,rootSchema,parentUri,uri);case'boolean':return transformBoolean(values,rootSchema,parentUri,uri);case'object':return transformObject(values,rootSchema,parentUri,uri);case'array':return transformArray(values,rootSchema,parentUri,uri);case'number':return transformNumber(values,rootSchema,parentUri,uri);case'string':return transformString(values,rootSchema,parentUri,uri);default:throw new Error('Schema does not conform to Instance Data Model, https://json-schema.org/draft/2019-09/json-schema-core.html#rfc.section.4.2.1');}}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shinkansen-transmission",
3
- "version": "2.2.1",
3
+ "version": "2.2.2",
4
4
  "description": "Shinkansen Transmission",
5
5
  "keywords": [
6
6
  "Shinkansen",
@@ -22,7 +22,7 @@
22
22
  "scripts": {
23
23
  "prepublishOnly": "cross-env NODE_ENV=production npm run build",
24
24
  "prebuild": "npm run clean",
25
- "build": "npm run babel",
25
+ "build": "cross-env DEBUG=shinkansen-transmission npm run babel",
26
26
  "build:watch": "npm run babel:watch",
27
27
  "clean": "rimraf lib",
28
28
  "babel": "babel src -d lib",
@@ -51,11 +51,14 @@
51
51
  "core-js": "^3.17.3",
52
52
  "cross-env": "^7.0.3",
53
53
  "eslint": "^7.32.0",
54
+ "eslint-config-standard": "^16.0.3",
54
55
  "eslint-import-resolver-babel-module": "^5.3.1",
56
+ "eslint-plugin-import": "^2.24.2",
57
+ "eslint-plugin-node": "^11.1.0",
58
+ "eslint-plugin-promise": "^5.1.0",
55
59
  "husky": "^7.0.2",
56
60
  "mocha": "^9.1.1",
57
61
  "nyc": "^15.1.0",
58
- "rimraf": "^3.0.2",
59
- "standard": "^16.0.3"
62
+ "rimraf": "^3.0.2"
60
63
  }
61
64
  }
@@ -20,22 +20,30 @@ import {
20
20
 
21
21
  const log = debug('shinkansen-transmission:from-document-to-hash')
22
22
 
23
+ log('`shinkansen-transmission` is awake')
24
+
23
25
  function findByKey (parentUri, uri) {
26
+ /*
27
+ * log('findByKey')
28
+ */
24
29
  return function find (key) {
25
- return uri === getUri(parentUri, key)
30
+ /*
31
+ * log('find')
32
+ */
33
+ return getUri(parentUri, key) === uri
26
34
  }
27
35
  }
28
36
 
29
37
  function findByIndex (parentUri, uri) {
38
+ /*
39
+ * log('findByIndex')
40
+ */
30
41
  return function find (schema, index) {
31
42
  /*
32
- * log('findByIndex')
43
+ * log('find')
33
44
  */
34
-
35
45
  if (hasEnum(schema)) {
36
- // const array = getEnum(schema)
37
-
38
- // return array.find(findByIndex(parentUri, uri))
46
+ return getUri(parentUri, index) === uri
39
47
  } else {
40
48
  if (hasAnyOf(schema)) {
41
49
  const array = getAnyOf(schema)
@@ -55,22 +63,33 @@ function findByIndex (parentUri, uri) {
55
63
  }
56
64
 
57
65
  function findByValue (value) {
66
+ /*
67
+ * log('findByValue')
68
+ */
58
69
  return function find (schema) {
59
70
  /*
60
- * log('findByValue')
71
+ * log('find')
61
72
  */
62
-
63
73
  return value === transformValue(schema)
64
74
  }
65
75
  }
66
76
 
67
77
  function findByEqual (value) {
78
+ /*
79
+ * log('findByEqual')
80
+ */
68
81
  return function find (schema) {
82
+ /*
83
+ * log('find')
84
+ */
69
85
  return equal(value, transformValue(schema))
70
86
  }
71
87
  }
72
88
 
73
89
  function toString (value) {
90
+ /*
91
+ * log('toString')
92
+ */
74
93
  return (value !== undefined) ? String(value) : ''
75
94
  }
76
95
 
@@ -78,7 +97,6 @@ export function getObject ({ properties = {} /* object */ } = {}, parentUri = ''
78
97
  /*
79
98
  * log('getObject')
80
99
  */
81
-
82
100
  return (
83
101
  Reflect.get(properties, (
84
102
  Object.keys(properties)
@@ -91,7 +109,6 @@ export function getArray ({ items = {} /* array or object */ } = {}, parentUri =
91
109
  /*
92
110
  * log('getArray')
93
111
  */
94
-
95
112
  return (isArray(items))
96
113
  ? items.find(findByIndex(parentUri, uri))
97
114
  : items
@@ -101,7 +118,6 @@ export function getSchema (schema = {}, parentUri = '', uri = '') {
101
118
  /*
102
119
  * log('getSchema')
103
120
  */
104
-
105
121
  const { type } = schema
106
122
 
107
123
  switch (type) {
@@ -127,6 +143,9 @@ export const transformValue = (schema) => (
127
143
  )
128
144
 
129
145
  export function transformValueIndexFor (array, value) {
146
+ /*
147
+ * log('transformValueIndexFor')
148
+ */
130
149
  const find = findByValue(value)
131
150
 
132
151
  if (array.some(find)) {
@@ -145,6 +164,9 @@ export function transformValueIndexFor (array, value) {
145
164
  }
146
165
 
147
166
  export function transformEqualIndexFor (array, value) {
167
+ /*
168
+ * log('transformEqualIndexFor')
169
+ */
148
170
  const find = findByEqual(value)
149
171
 
150
172
  if (array.some(find)) {
@@ -166,7 +188,6 @@ export function transformArrayFor (document, schema, values, params, parentUri,
166
188
  /*
167
189
  * log('transformArrayFor')
168
190
  */
169
-
170
191
  return (
171
192
  document
172
193
  .reduce((values, value, index) => {
@@ -181,7 +202,6 @@ export function transformObjectFor (document, schema, values, params, parentUri,
181
202
  /*
182
203
  * log('transformObjectFor')
183
204
  */
184
-
185
205
  return (
186
206
  Object.entries(document)
187
207
  .reduce((values, [key, value]) => {
@@ -16,8 +16,9 @@ import {
16
16
  getUri
17
17
  } from 'shinkansen-transmission/transmission/common'
18
18
 
19
- const log = debug('shinkansen-transmission:from-hash-to-document:log')
20
- const error = debug('shinkansen-transmission:from-hash-to-document:error')
19
+ const log = debug('shinkansen-transmission:from-hash-to-document')
20
+
21
+ log('`shinkansen-transmission` is awake')
21
22
 
22
23
  export function toNull (v) {
23
24
  if (v === null || v === 'null') return null
@@ -78,7 +79,7 @@ export function transformValueFor (value, array) {
78
79
  return transformValue(v)
79
80
  }
80
81
  } catch ({ message = 'No error message defined' }) {
81
- error(message)
82
+ log(message)
82
83
  }
83
84
 
84
85
  /*
@@ -204,7 +205,7 @@ export function transformItemsObjectFor (values, items = {}, parentUri = '#', ur
204
205
  )
205
206
  }
206
207
 
207
- const handleError = ({ message = 'No error message defined' }) => error(message)
208
+ const handleError = ({ message = 'No error message defined' }) => log(message)
208
209
 
209
210
  // https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.6
210
211
  export function transformObjectSchemaNull (values, schema, { uri: parentUri, key: fieldKey }, uri = getUri(parentUri, fieldKey)) {