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

jsonref

Package Overview
Dependencies
Maintainers
3
Versions
48
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsonref - npm Package Compare versions

Comparing version 7.0.0 to 8.0.0

12

dist/errors.js

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RebaserError = exports.ParserError = exports.RetrieverError = void 0;
class RetrieverError extends Error {
export class RetrieverError extends Error {
constructor(uri, originalError) {

@@ -12,4 +9,3 @@ super(uri);

}
exports.RetrieverError = RetrieverError;
class ParserError extends Error {
export class ParserError extends Error {
constructor(scope, type, errors) {

@@ -22,4 +18,3 @@ super(type);

}
exports.ParserError = ParserError;
class RebaserError extends Error {
export class RebaserError extends Error {
constructor(scope, type, errors) {

@@ -32,3 +27,2 @@ super(type);

}
exports.RebaserError = RebaserError;
//# sourceMappingURL=errors.js.map

@@ -1,7 +0,7 @@

import * as meta from './meta';
export * from './errors';
export { getMeta, isAnnotated, isRef, Meta, normalize, normalizeUri, Registry } from './meta';
export * from './patch';
export { resolve as pointer } from './pointer';
export * from './rebase';
import * as meta from './meta.js';
export * from './errors.js';
export { getMeta, isAnnotated, isRef, Meta, normalize, normalizeUri, Registry } from './meta.js';
export * from './patch.js';
export { resolve as pointer } from './pointer.js';
export * from './rebase.js';
export declare type Retriever = (url: string) => Promise<any>;

@@ -8,0 +8,0 @@ export interface ParseOptions extends meta.Options {

@@ -1,45 +0,10 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.parse = exports.scope = exports.pointer = exports.normalizeUri = exports.normalize = exports.isRef = exports.isAnnotated = exports.getMeta = void 0;
const errors_1 = require("./errors");
const meta = __importStar(require("./meta"));
const ref_1 = require("./ref");
__exportStar(require("./errors"), exports);
var meta_1 = require("./meta");
Object.defineProperty(exports, "getMeta", { enumerable: true, get: function () { return meta_1.getMeta; } });
Object.defineProperty(exports, "isAnnotated", { enumerable: true, get: function () { return meta_1.isAnnotated; } });
Object.defineProperty(exports, "isRef", { enumerable: true, get: function () { return meta_1.isRef; } });
Object.defineProperty(exports, "normalize", { enumerable: true, get: function () { return meta_1.normalize; } });
Object.defineProperty(exports, "normalizeUri", { enumerable: true, get: function () { return meta_1.normalizeUri; } });
__exportStar(require("./patch"), exports);
var pointer_1 = require("./pointer");
Object.defineProperty(exports, "pointer", { enumerable: true, get: function () { return pointer_1.resolve; } });
__exportStar(require("./rebase"), exports);
function scope(data) {
import { ParserError, RetrieverError } from './errors.js';
import * as meta from './meta.js';
import { resolve as refResolver } from './ref.js';
export * from './errors.js';
export { getMeta, isAnnotated, isRef, normalize, normalizeUri } from './meta.js';
export * from './patch.js';
export { resolve as pointer } from './pointer.js';
export * from './rebase.js';
export function scope(data) {
if (meta.isAnnotated(data)) {

@@ -49,4 +14,3 @@ return meta.getMeta(data).scope;

}
exports.scope = scope;
async function parse(dataOrUri, opts) {
export async function parse(dataOrUri, opts) {
let obj;

@@ -93,10 +57,10 @@ if (!opts || !opts.scope) {

catch (e) {
errors.push(new errors_1.RetrieverError(r, e));
errors.push(new RetrieverError(r, e));
}
}
if (errors.length) {
throw new errors_1.ParserError(meta.getMeta(obj).scope, 'retriever', errors);
throw new ParserError(meta.getMeta(obj).scope, 'retriever', errors);
}
}
return (0, ref_1.resolve)(obj, opts);
return refResolver(obj, opts);
}

@@ -108,3 +72,2 @@ else {

}
exports.parse = parse;
//# sourceMappingURL=index.js.map

@@ -1,8 +0,5 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.normalize = exports.missingRefs = exports.annotate = exports.getById = exports.getKey = exports.getMeta = exports.isDerefd = exports.isAnnotated = exports.isRef = exports.normalizeUri = exports.LII_RE = void 0;
const utils_1 = require("./utils");
import { escape } from './utils.js';
const __meta = Symbol();
exports.LII_RE = /^[a-zA-Z][a-zA-Z0-9\.\-_:]*$/; // Location-independent identifier, JSON Schema draft 7, par. 8.2.3
function normalizeUri(input, scope) {
export const LII_RE = /^[a-zA-Z][a-zA-Z0-9\.\-_:]*$/; // Location-independent identifier, JSON Schema draft 7, par. 8.2.3
export function normalizeUri(input, scope) {
const uri = new URL(input, scope);

@@ -12,16 +9,12 @@ const out = uri.toString();

}
exports.normalizeUri = normalizeUri;
function isRef(obj) {
export function isRef(obj) {
return obj !== null && typeof obj === 'object' && typeof obj.$ref === 'string';
}
exports.isRef = isRef;
function isAnnotated(obj) {
export function isAnnotated(obj) {
return obj !== null && typeof obj === 'object' && typeof obj[__meta] === 'object';
}
exports.isAnnotated = isAnnotated;
function isDerefd(obj) {
export function isDerefd(obj) {
return isAnnotated(obj) && obj[__meta].derefd === true;
}
exports.isDerefd = isDerefd;
function getMeta(obj) {
export function getMeta(obj) {
if (!isAnnotated(obj)) {

@@ -32,4 +25,3 @@ throw new Error('Not annotated');

}
exports.getMeta = getMeta;
function getKey(obj) {
export function getKey(obj) {
const parent = getMeta(obj).parent;

@@ -48,7 +40,6 @@ if (typeof parent === 'undefined') {

else {
return Object.keys(parent).find(k => parent[k] === obj);
return Object.keys(parent).find((k) => parent[k] === obj);
}
}
exports.getKey = getKey;
function getById(obj, id) {
export function getById(obj, id) {
if (obj === null || typeof obj !== 'object') {

@@ -60,4 +51,3 @@ throw new TypeError('Invalid object');

}
exports.getById = getById;
function annotate(obj, options) {
export function annotate(obj, options) {
if (obj === null || typeof obj !== 'object') {

@@ -72,3 +62,3 @@ throw new TypeError('Invalid object');

refs: options.refs || new Set(),
root: obj
root: obj,
};

@@ -89,3 +79,3 @@ obj[__meta].registry[normalizeUri(options.scope)] = obj;

const id = new URL(obj.$id, scope);
if (id.hash && !id.hash.substr(1).match(exports.LII_RE)) {
if (id.hash && !id.hash.substr(1).match(LII_RE)) {
throw new SyntaxError(`Invalid identifier ${obj.$id}`);

@@ -109,5 +99,5 @@ }

parent: obj,
root: meta.root
root: meta.root,
};
_annotate(next, `${meta.scope}/${(0, utils_1.escape)(key)}`);
_annotate(next, `${meta.scope}/${escape(key)}`);
}

@@ -119,10 +109,8 @@ }

}
exports.annotate = annotate;
function missingRefs(obj) {
export function missingRefs(obj) {
const meta = getMeta(obj);
const known = new Set(Object.keys(meta.registry));
return [...meta.refs].filter(r => !known.has(r));
return [...meta.refs].filter((r) => !known.has(r));
}
exports.missingRefs = missingRefs;
function normalize(obj) {
export function normalize(obj) {
if (!isAnnotated(obj)) {

@@ -149,3 +137,2 @@ throw new Error('Not annotated');

}
exports.normalize = normalize;
//# sourceMappingURL=meta.js.map

@@ -1,29 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.patch = exports.diff = void 0;
const meta = __importStar(require("./meta"));
const pointer = __importStar(require("./pointer"));
import * as meta from './meta.js';
import * as pointer from './pointer.js';
/*

@@ -34,3 +8,3 @@ export function toDottedPath(path: string): string {

*/
function diff(src, dst, path = '/') {
export function diff(src, dst, path = '/') {
let out = [];

@@ -74,4 +48,3 @@ if (src !== dst) {

}
exports.diff = diff;
function patch(obj, patch) {
export function patch(obj, patch) {
const out = meta.annotate(JSON.parse(JSON.stringify(obj)), { scope: 'jsonref:patch' });

@@ -194,3 +167,2 @@ for (let p of patch) {

}
exports.patch = patch;
//# sourceMappingURL=patch.js.map

@@ -1,35 +0,9 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolve = exports.getPointer = void 0;
const meta = __importStar(require("./meta"));
const utils_1 = require("./utils");
import * as meta from './meta.js';
import { unescape } from './utils.js';
const PREFIX_RE = /^(0|[1-9][0-9]*?)([#]?)$/;
const INDEX_RE = /-|0|[1-9][0-9]*/;
function getPointer(obj) {
export function getPointer(obj) {
const p = [];
let parent, current = obj;
while (parent = meta.getMeta(current).parent) {
while ((parent = meta.getMeta(current).parent)) {
const frag = meta.getKey(current);

@@ -46,4 +20,3 @@ if (!frag) {

}
exports.getPointer = getPointer;
function resolve(obj, path) {
export function resolve(obj, path) {
if (typeof obj === 'undefined') {

@@ -88,3 +61,3 @@ throw new TypeError('Bad object');

}
const part = (0, utils_1.unescape)(parts.shift());
const part = unescape(parts.shift());
if (Array.isArray(current)) {

@@ -116,3 +89,2 @@ if (!part.match(INDEX_RE)) {

}
exports.resolve = resolve;
//# sourceMappingURL=pointer.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.rebase = void 0;
const errors_1 = require("./errors");
import { RebaserError } from './errors.js';
/**

@@ -15,3 +12,3 @@ * Rebase JSON $refs properties (only) as specified by the rebase function.

*/
function rebase(id, obj, rebaser) {
export function rebase(id, obj, rebaser) {
// visited objects properties registry

@@ -30,3 +27,3 @@ const parsedProps = [];

if (!Array.isArray(prop)) {
if (!parsedProps.find(p => p === prop)) {
if (!parsedProps.find((p) => p === prop)) {
parsedProps.push(prop);

@@ -47,7 +44,6 @@ findAndRebase(prop);

catch (error) {
throw new errors_1.RebaserError('rebase', 'error', [error]);
throw new RebaserError('rebase', 'error', [error]);
}
return obj;
}
exports.rebase = rebase;
//# sourceMappingURL=rebase.js.map

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

import * as meta from './meta';
import * as meta from './meta.js';
export declare function resolve(obj: any, options: meta.Options): any;

@@ -1,29 +0,3 @@

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.resolve = void 0;
const meta = __importStar(require("./meta"));
const pointer = __importStar(require("./pointer"));
import * as meta from './meta.js';
import * as pointer from './pointer.js';
const RELATIVE_RE = /^#(?:0|[1-9][0-9]*?)(?:$|\/)/;

@@ -50,3 +24,3 @@ function deref(obj) {

}
function resolve(obj, options) {
export function resolve(obj, options) {
if (obj === null || typeof obj !== 'object') {

@@ -104,3 +78,2 @@ return obj;

}
exports.resolve = resolve;
//# sourceMappingURL=ref.js.map

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

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.unescape = exports.escape = void 0;
const TILDE_RE = /~/g;

@@ -8,10 +5,8 @@ const SLASH_RE = /\//g;

const TILDE_1_RE = /~1/g;
function escape(frag) {
export function escape(frag) {
return frag.replace(TILDE_RE, '~0').replace(SLASH_RE, '~1');
}
exports.escape = escape;
function unescape(frag) {
export function unescape(frag) {
return frag.replace(TILDE_1_RE, '/').replace(TILDE_0_RE, '~');
}
exports.unescape = unescape;
//# sourceMappingURL=utils.js.map
{
"name": "jsonref",
"version": "7.0.0",
"version": "8.0.0",
"description": "Javascript References ($ref) and Pointers library",
"type": "module",
"main": "dist/index.js",

@@ -52,7 +53,7 @@ "typings": "dist/index.d.ts",

"devDependencies": {
"@commitlint/config-conventional": "^16.2.1",
"@types/chai": "^4.3.0",
"@commitlint/config-conventional": "^17.0.2",
"@types/chai": "^4.3.1",
"@types/chai-as-promised": "^7.1.5",
"@types/chai-spies": "^1.0.3",
"@types/mocha": "^9.1.0",
"@types/mocha": "^9.1.1",
"@types/node": "^16.11.26",

@@ -63,12 +64,12 @@ "chai": "^4.3.6",

"commitizen": "^4.2.4",
"commitlint": "^16.2.1",
"commitlint": "^17.0.2",
"coveralls": "^3.1.1",
"cz-conventional-changelog": "^3.3.0",
"husky": "^7.0.4",
"mocha": "^9.2.1",
"mochawesome": "^7.1.0",
"husky": "^8.0.1",
"mocha": "^10.0.0",
"mochawesome": "^7.1.3",
"nyc": "^15.1.0",
"rimraf": "^3.0.2",
"semantic-release": "^19.0.2",
"typescript": "^4.6.2"
"typescript": "^4.7.3"
},

@@ -75,0 +76,0 @@ "engines": {

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