New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

sanity-diff-patch

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sanity-diff-patch - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

1

dist/index.d.ts
export { diffPatch } from './diffPatch';
export { validateDocument } from './validate';
export { DiffError } from './diffError';

@@ -565,4 +565,5 @@ 'use strict';

exports.DiffError = DiffError;
exports.diffPatch = diffPatch;
exports.validateDocument = validateDocument;
//# sourceMappingURL=sanity-diff-patch.cjs.development.js.map

2

dist/sanity-diff-patch.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("diff-match-patch");function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function o(t,e,r){return(o=i()?Reflect.construct:function(t,e,r){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return r&&n(o,r.prototype),o}).apply(null,arguments)}function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return o(t,arguments,r(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n(i,t)})(t)}function u(t){return t.reduce((function(t,e,r){if(Array.isArray(e))return t+"["+e.join(":")+"]";if("object"==typeof(n=e)&&"string"==typeof n._key)return t+'[_key=="'+e._key+'"]';var n;if("number"==typeof e)return t+"["+e+"]";if(/^\d+$/.test(e))return t+'["'+e+'"]';if("string"==typeof e)return t+(0===r?"":".")+e;throw new Error('Unsupported path segment "'+e+'"')}),"")}var c=function(t){var e,r;function n(e,r,n){var i,o=u(r);return(i=t.call(this,e+" (at '"+o+"')")||this).path=r,i.serializedPath=o,i.value=n,i}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(a(Error)),f=/^[a-z0-9][a-z0-9_.-]+$/i,s=/^[a-zA-Z_][a-zA-Z0-9_]+$/,p=/^[a-z_]/i;function h(t,e,r){if(!p.test(t))throw new c("Keys must start with a letter (a-z)",r.concat(t),e);if(!s.test(t))throw new c("Keys can only contain letters, numbers and underscores",r.concat(t),e);if("_key"===t||"_ref"===t||"_type"===t){if("string"!=typeof e)throw new c("Keys must be strings",r.concat(t),e);if(!f.test(e))throw new c("Invalid key - use less exotic characters",r.concat(t),e)}return t}var l=["_id","_type","_createdAt","_updatedAt","_rev"],y=new t.diff_match_patch,d={hideWarnings:!1,diffMatchPatch:{enabled:!0,lengthThresholdAbsolute:30,lengthThresholdRelative:1.2}};function v(t,e,r,n,i){if(t===e)return n;var o=Array.isArray(t)?"array":typeof t,a=Array.isArray(e)?"array":typeof e,u="undefined"===o,f="undefined"===a;if(u&&!f)return n.push({op:"set",path:r,value:e}),n;if(!u&&f)return n.push({op:"unset",path:r}),n;var s=u?a:o;return"object"===s||"array"===s?o!==a?(n.push({op:"set",path:r,value:e}),n):"array"===s?function(t,e,r,n,i){e.length>t.length&&n.push({op:"insert",after:r.concat([-1]),items:e.slice(t.length).map((function(t,e){return w(t,r,e,i)}))}),e.length<t.length&&n.push({op:"unset",path:r.concat([t.length-e.length==1?e.length:[e.length,""]])});for(var o=0;o<e.length;o++)if(Array.isArray(e[o]))throw new c("Multi-dimensional arrays not supported",r.concat(o),e[o]);var a=Math.min(t.length,e.length),u=t.slice(0,a),f=e.slice(0,a);return b(u)&&b(f)?function(t,e,r,n,i){var o=m(t),a=m(e);if(!function(t,e){return t.length===e.length&&t.every((function(t,r){return e[r]===t}))}(o.keys,a.keys))return g(t,e,r,n,i);for(var u=0;u<a.keys.length;u++){var c=a.keys[u];v(o.index[c],w(a.index[c],r,u,i),r.concat({_key:c}),n,i)}return n}(u,f,r,n,i):g(u,f,r,n,i)}(t,e,r,n,i):function(t,e,r,n,i){for(var o=0===r.length,a=Object.keys(t).filter(o?_:A).map((function(e){return h(e,t[e],r)})),u=a.length,c=Object.keys(e).filter(o?_:A).map((function(t){return h(t,e[t],r)})),f=c.length,s=0;s<u;s++){var p=a[s];p in e||n.push({op:"unset",path:r.concat(p)})}for(var l=0;l<f;l++){var y=c[l];v(t[y],e[y],r.concat([y]),n,i)}return n}(t,e,r,n,i):function(t,e,r,n,i){var o=function(t,e,r,n){var i=n.diffMatchPatch,o=i.lengthThresholdRelative,a=r[r.length-1];if(!(!i.enabled||"string"!=typeof t||"string"!=typeof e||"string"==typeof a&&"_"===a[0]||e.length<i.lengthThresholdAbsolute)){var u="";try{var c=y.diff_main(t,e);y.diff_cleanupEfficiency(c),u=y.patch_toText(y.patch_make(c))}catch(t){return}return u.length>e.length*o?void 0:{op:"diffMatchPatch",path:r,value:u}}}(t,e,r,i);return n.push(o||{op:"set",path:r,value:e}),n}(t,e,r,n,i)}function g(t,e,r,n,i){for(var o=0;o<t.length;o++)v(t[o],w(e[o],r,o,i),r.concat(o),n,i);return n}function _(t){return-1===l.indexOf(t)}function b(t){for(var e=[],r=0;r<t.length;r++){var n=t[r]&&t[r]._key;if(!n||-1!==e.indexOf(n))return!1;e.push(n)}return!0}function m(t){return t.reduce((function(t,e){return t.keys.push(e._key),t.index[e._key]=e,t}),{keys:[],index:{}})}function w(t,e,r,n){if(void 0!==t)return t;if(!n.hideWarnings){var i=u(e.concat(r));console.warn("undefined value in array converted to null (at '"+i+"')")}return null}function A(t){return!0}exports.diffPatch=function(t,r,n){void 0===n&&(n={});var i=e({},d,{},n,{diffMatchPatch:e({},d.diffMatchPatch,{},n.diffMatchPatch||{})}),o=i.id||t._id===r._id&&t._id,a=i.ifRevisionID||i.ifRevisionId,c="boolean"==typeof a?t._rev:a,f=i.basePath||[];if(!o)throw new Error("_id on itemA and itemB not present or differs, specify document id the mutations should be applied to");if(!0===a&&!c)throw new Error("`ifRevisionID` is set to `true`, but no `_rev` was passed in item A. Either explicitly set `ifRevisionID` to a revision, or pass `_rev` as part of item A.");if(0===f.length&&t._type!==r._type)throw new Error("_type is immutable and cannot be changed ("+t._type+" => "+r._type+")");return function(t,r){if(0===t.length)return[];var n=r.id,i=r.ifRevisionID,o=t.filter((function(t){return"set"===t.op})),a=t.filter((function(t){return"unset"===t.op})),c=t.filter((function(t){return"insert"===t.op})),f=t.filter((function(t){return"diffMatchPatch"===t.op})),s=o.length>0&&o.reduce((function(t,e){var r=u(e.path);return t.set[r]=e.value,t}),{id:n,set:{}}),p=a.length>0&&a.reduce((function(t,e){var r=u(e.path);return t.unset.push(r),t}),{id:n,unset:[]}),h=c.reduce((function(t,e){var r=u(e.after);return t.concat({id:n,insert:{after:r,items:e.items}})}),[]);return[s,p,f.length>0&&f.reduce((function(t,e){var r=u(e.path);return t.diffMatchPatch[r]=e.value,t}),{id:n,diffMatchPatch:{}})].concat(h).filter((function(t){return!1!==t})).map((function(t,r){return{patch:i&&0===r?e({},t,{ifRevisionID:i}):t}}))}(v(t,r,f,[],i),{id:o,ifRevisionID:a?c:void 0})},exports.validateDocument=function t(e,r){if(void 0===r&&(r=[]),Array.isArray(e))return e.every((function(e,n){if(Array.isArray(e))throw new c("Multi-dimensional arrays not supported",r.concat(n));return t(e,r.concat(n))}));if("object"==typeof e&&null!==e){var n=e;return Object.keys(n).every((function(e){return h(e,n[e],r)&&t(n[e],r.concat(e))}))}return!0};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("diff-match-patch");function e(){return(e=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function n(t,e){return(n=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function i(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function o(t,e,r){return(o=i()?Reflect.construct:function(t,e,r){var i=[null];i.push.apply(i,e);var o=new(Function.bind.apply(t,i));return r&&n(o,r.prototype),o}).apply(null,arguments)}function a(t){var e="function"==typeof Map?new Map:void 0;return(a=function(t){if(null===t||-1===Function.toString.call(t).indexOf("[native code]"))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,i)}function i(){return o(t,arguments,r(this).constructor)}return i.prototype=Object.create(t.prototype,{constructor:{value:i,enumerable:!1,writable:!0,configurable:!0}}),n(i,t)})(t)}function u(t){return t.reduce((function(t,e,r){if(Array.isArray(e))return t+"["+e.join(":")+"]";if("object"==typeof(n=e)&&"string"==typeof n._key)return t+'[_key=="'+e._key+'"]';var n;if("number"==typeof e)return t+"["+e+"]";if(/^\d+$/.test(e))return t+'["'+e+'"]';if("string"==typeof e)return t+(0===r?"":".")+e;throw new Error('Unsupported path segment "'+e+'"')}),"")}var c=function(t){var e,r;function n(e,r,n){var i,o=u(r);return(i=t.call(this,e+" (at '"+o+"')")||this).path=r,i.serializedPath=o,i.value=n,i}return r=t,(e=n).prototype=Object.create(r.prototype),e.prototype.constructor=e,e.__proto__=r,n}(a(Error)),f=/^[a-z0-9][a-z0-9_.-]+$/i,s=/^[a-zA-Z_][a-zA-Z0-9_]+$/,p=/^[a-z_]/i;function h(t,e,r){if(!p.test(t))throw new c("Keys must start with a letter (a-z)",r.concat(t),e);if(!s.test(t))throw new c("Keys can only contain letters, numbers and underscores",r.concat(t),e);if("_key"===t||"_ref"===t||"_type"===t){if("string"!=typeof e)throw new c("Keys must be strings",r.concat(t),e);if(!f.test(e))throw new c("Invalid key - use less exotic characters",r.concat(t),e)}return t}var l=["_id","_type","_createdAt","_updatedAt","_rev"],y=new t.diff_match_patch,d={hideWarnings:!1,diffMatchPatch:{enabled:!0,lengthThresholdAbsolute:30,lengthThresholdRelative:1.2}};function v(t,e,r,n,i){if(t===e)return n;var o=Array.isArray(t)?"array":typeof t,a=Array.isArray(e)?"array":typeof e,u="undefined"===o,f="undefined"===a;if(u&&!f)return n.push({op:"set",path:r,value:e}),n;if(!u&&f)return n.push({op:"unset",path:r}),n;var s=u?a:o;return"object"===s||"array"===s?o!==a?(n.push({op:"set",path:r,value:e}),n):"array"===s?function(t,e,r,n,i){e.length>t.length&&n.push({op:"insert",after:r.concat([-1]),items:e.slice(t.length).map((function(t,e){return w(t,r,e,i)}))}),e.length<t.length&&n.push({op:"unset",path:r.concat([t.length-e.length==1?e.length:[e.length,""]])});for(var o=0;o<e.length;o++)if(Array.isArray(e[o]))throw new c("Multi-dimensional arrays not supported",r.concat(o),e[o]);var a=Math.min(t.length,e.length),u=t.slice(0,a),f=e.slice(0,a);return b(u)&&b(f)?function(t,e,r,n,i){var o=m(t),a=m(e);if(!function(t,e){return t.length===e.length&&t.every((function(t,r){return e[r]===t}))}(o.keys,a.keys))return g(t,e,r,n,i);for(var u=0;u<a.keys.length;u++){var c=a.keys[u];v(o.index[c],w(a.index[c],r,u,i),r.concat({_key:c}),n,i)}return n}(u,f,r,n,i):g(u,f,r,n,i)}(t,e,r,n,i):function(t,e,r,n,i){for(var o=0===r.length,a=Object.keys(t).filter(o?_:A).map((function(e){return h(e,t[e],r)})),u=a.length,c=Object.keys(e).filter(o?_:A).map((function(t){return h(t,e[t],r)})),f=c.length,s=0;s<u;s++){var p=a[s];p in e||n.push({op:"unset",path:r.concat(p)})}for(var l=0;l<f;l++){var y=c[l];v(t[y],e[y],r.concat([y]),n,i)}return n}(t,e,r,n,i):function(t,e,r,n,i){var o=function(t,e,r,n){var i=n.diffMatchPatch,o=i.lengthThresholdRelative,a=r[r.length-1];if(!(!i.enabled||"string"!=typeof t||"string"!=typeof e||"string"==typeof a&&"_"===a[0]||e.length<i.lengthThresholdAbsolute)){var u="";try{var c=y.diff_main(t,e);y.diff_cleanupEfficiency(c),u=y.patch_toText(y.patch_make(c))}catch(t){return}return u.length>e.length*o?void 0:{op:"diffMatchPatch",path:r,value:u}}}(t,e,r,i);return n.push(o||{op:"set",path:r,value:e}),n}(t,e,r,n,i)}function g(t,e,r,n,i){for(var o=0;o<t.length;o++)v(t[o],w(e[o],r,o,i),r.concat(o),n,i);return n}function _(t){return-1===l.indexOf(t)}function b(t){for(var e=[],r=0;r<t.length;r++){var n=t[r]&&t[r]._key;if(!n||-1!==e.indexOf(n))return!1;e.push(n)}return!0}function m(t){return t.reduce((function(t,e){return t.keys.push(e._key),t.index[e._key]=e,t}),{keys:[],index:{}})}function w(t,e,r,n){if(void 0!==t)return t;if(!n.hideWarnings){var i=u(e.concat(r));console.warn("undefined value in array converted to null (at '"+i+"')")}return null}function A(t){return!0}exports.DiffError=c,exports.diffPatch=function(t,r,n){void 0===n&&(n={});var i=e({},d,{},n,{diffMatchPatch:e({},d.diffMatchPatch,{},n.diffMatchPatch||{})}),o=i.id||t._id===r._id&&t._id,a=i.ifRevisionID||i.ifRevisionId,c="boolean"==typeof a?t._rev:a,f=i.basePath||[];if(!o)throw new Error("_id on itemA and itemB not present or differs, specify document id the mutations should be applied to");if(!0===a&&!c)throw new Error("`ifRevisionID` is set to `true`, but no `_rev` was passed in item A. Either explicitly set `ifRevisionID` to a revision, or pass `_rev` as part of item A.");if(0===f.length&&t._type!==r._type)throw new Error("_type is immutable and cannot be changed ("+t._type+" => "+r._type+")");return function(t,r){if(0===t.length)return[];var n=r.id,i=r.ifRevisionID,o=t.filter((function(t){return"set"===t.op})),a=t.filter((function(t){return"unset"===t.op})),c=t.filter((function(t){return"insert"===t.op})),f=t.filter((function(t){return"diffMatchPatch"===t.op})),s=o.length>0&&o.reduce((function(t,e){var r=u(e.path);return t.set[r]=e.value,t}),{id:n,set:{}}),p=a.length>0&&a.reduce((function(t,e){var r=u(e.path);return t.unset.push(r),t}),{id:n,unset:[]}),h=c.reduce((function(t,e){var r=u(e.after);return t.concat({id:n,insert:{after:r,items:e.items}})}),[]);return[s,p,f.length>0&&f.reduce((function(t,e){var r=u(e.path);return t.diffMatchPatch[r]=e.value,t}),{id:n,diffMatchPatch:{}})].concat(h).filter((function(t){return!1!==t})).map((function(t,r){return{patch:i&&0===r?e({},t,{ifRevisionID:i}):t}}))}(v(t,r,f,[],i),{id:o,ifRevisionID:a?c:void 0})},exports.validateDocument=function t(e,r){if(void 0===r&&(r=[]),Array.isArray(e))return e.every((function(e,n){if(Array.isArray(e))throw new c("Multi-dimensional arrays not supported",r.concat(n));return t(e,r.concat(n))}));if("object"==typeof e&&null!==e){var n=e;return Object.keys(n).every((function(e){return h(e,n[e],r)&&t(n[e],r.concat(e))}))}return!0};
//# sourceMappingURL=sanity-diff-patch.cjs.production.min.js.map

@@ -561,3 +561,3 @@ import { diff_match_patch } from 'diff-match-patch';

export { diffPatch, validateDocument };
export { DiffError, diffPatch, validateDocument };
//# sourceMappingURL=sanity-diff-patch.esm.js.map
{
"name": "sanity-diff-patch",
"version": "1.0.3",
"version": "1.0.4",
"description": "Generates a set of Sanity patches needed to change an item (usually a document) from one shape to another",

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

export {diffPatch} from './diffPatch'
export {validateDocument} from './validate'
export {DiffError} from './diffError'

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