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

ts-japi

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ts-japi - npm Package Compare versions

Comparing version 1.2.7 to 1.3.0

lib/utils/is-error-document.d.ts

11

CHANGELOG.md

@@ -8,2 +8,13 @@ # Changelog

## [1.3.0] - 2020-06-23
### Added
* Added an `isErrorDocument` function to detect JSON:API Error documents. This function allows you to treat the argument *as if it were an error document* (there is obviously no way to know if it really is a JSON:API error document at runtime).
* Added an `isLikeJapiError` function to detect JSON:API Error. This function allows you to treat the argument *as if it were an JSON:API error* (there is obviously no way to know if it really is a JSON:API error at runtime).
### Changed
* Exported a `isPlainObject` and `isObjectObject` functions from internal.
## [1.2.7] - 2020-06-22

@@ -10,0 +21,0 @@

30

lib/index.d.ts

@@ -1,19 +0,21 @@

import Metaizer from "./classes/metaizer";
import Linker from "./classes/linker";
import Paginator from "./classes/paginator";
import Relator from "./classes/relator";
import Serializer from "./classes/serializer";
import JapiError from "./models/error.model";
import ErrorSerializer from "./classes/error-serializer";
import Cache from "./classes/cache";
export { default as Cache } from "./classes/cache";
export { default as Linker } from "./classes/linker";
export { default as Metaizer } from "./classes/metaizer";
export { default as Paginator } from "./classes/paginator";
export { default as Relator } from "./classes/relator";
export { default as JapiError } from "./models/error.model";
export { default as ErrorSerializer } from "./classes/error-serializer";
export { default as Serializer } from "./classes/serializer";
export * from "./interfaces/cache.interface";
export * from "./interfaces/error-serializer.interface";
export * from "./interfaces/error.interface";
export * from "./interfaces/json-api.interface";
export * from "./interfaces/linker.interface";
export * from "./interfaces/paginator.interface";
export * from "./interfaces/relator.interface";
export * from "./interfaces/serializer.interface";
export * from "./interfaces/error-serializer.interface";
export * from "./interfaces/linker.interface";
export * from "./interfaces/paginator.interface";
export * from "./interfaces/cache.interface";
export * from "./interfaces/json-api.interface";
export * from "./types/global.types";
export { Metaizer, Linker, Paginator, Relator, Serializer, JapiError, ErrorSerializer, Cache };
export * from "./utils/is-error-document";
export * from "./utils/is-plain-object";
export * from "./utils/is-object";
//# sourceMappingURL=index.d.ts.map

@@ -12,32 +12,31 @@ "use strict";

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
exports.__esModule = true;
exports.Cache = exports.ErrorSerializer = exports.JapiError = exports.Serializer = exports.Relator = exports.Paginator = exports.Linker = exports.Metaizer = void 0;
var metaizer_1 = __importDefault(require("./classes/metaizer"));
exports.Metaizer = metaizer_1["default"];
var linker_1 = __importDefault(require("./classes/linker"));
exports.Linker = linker_1["default"];
var paginator_1 = __importDefault(require("./classes/paginator"));
exports.Paginator = paginator_1["default"];
var relator_1 = __importDefault(require("./classes/relator"));
exports.Relator = relator_1["default"];
var serializer_1 = __importDefault(require("./classes/serializer"));
exports.Serializer = serializer_1["default"];
var error_model_1 = __importDefault(require("./models/error.model"));
exports.JapiError = error_model_1["default"];
var error_serializer_1 = __importDefault(require("./classes/error-serializer"));
exports.ErrorSerializer = error_serializer_1["default"];
var cache_1 = __importDefault(require("./classes/cache"));
exports.Cache = cache_1["default"];
var cache_1 = require("./classes/cache");
__createBinding(exports, cache_1, "default", "Cache");
var linker_1 = require("./classes/linker");
__createBinding(exports, linker_1, "default", "Linker");
var metaizer_1 = require("./classes/metaizer");
__createBinding(exports, metaizer_1, "default", "Metaizer");
var paginator_1 = require("./classes/paginator");
__createBinding(exports, paginator_1, "default", "Paginator");
var relator_1 = require("./classes/relator");
__createBinding(exports, relator_1, "default", "Relator");
var error_model_1 = require("./models/error.model");
__createBinding(exports, error_model_1, "default", "JapiError");
var error_serializer_1 = require("./classes/error-serializer");
__createBinding(exports, error_serializer_1, "default", "ErrorSerializer");
var serializer_1 = require("./classes/serializer");
__createBinding(exports, serializer_1, "default", "Serializer");
__exportStar(require("./interfaces/cache.interface"), exports);
__exportStar(require("./interfaces/error-serializer.interface"), exports);
__exportStar(require("./interfaces/error.interface"), exports);
__exportStar(require("./interfaces/json-api.interface"), exports);
__exportStar(require("./interfaces/linker.interface"), exports);
__exportStar(require("./interfaces/paginator.interface"), exports);
__exportStar(require("./interfaces/relator.interface"), exports);
__exportStar(require("./interfaces/serializer.interface"), exports);
__exportStar(require("./interfaces/error-serializer.interface"), exports);
__exportStar(require("./interfaces/linker.interface"), exports);
__exportStar(require("./interfaces/paginator.interface"), exports);
__exportStar(require("./interfaces/cache.interface"), exports);
__exportStar(require("./interfaces/json-api.interface"), exports);
__exportStar(require("./types/global.types"), exports);
__exportStar(require("./utils/is-error-document"), exports);
__exportStar(require("./utils/is-plain-object"), exports);
__exportStar(require("./utils/is-object"), exports);
//# sourceMappingURL=index.js.map

@@ -6,2 +6,8 @@ import { Dictionary, nullish } from "..";

export default class JapiError {
/**
* Tests whether `error` has similar attributes to a JapiError
*
* @param error An unknown object
*/
static isLikeJapiError(error: unknown): error is Partial<JapiError>;
/** @internal */

@@ -8,0 +14,0 @@ stack: string;

"use strict";
exports.__esModule = true;
var is_object_1 = require("../utils/is-object");
var JapiError = /** @class */ (function () {

@@ -20,2 +21,16 @@ function JapiError(options) {

}
/**
* Tests whether `error` has similar attributes to a JapiError
*
* @param error An unknown object
*/
JapiError.isLikeJapiError = function (error) {
if (!is_object_1.isObject(error))
return false;
return (["id", "status", "code", "title", "detail", "source", "links", "meta"].some(function (attrName) { return attrName in error; }) &&
[
["id", "status", "code", "title", "detail"].every(function (attrName) { return !(attrName in error) || typeof error[attrName] === "string"; }),
["source", "links", "meta"].every(function (attrName) { return !(attrName in error) || is_object_1.isObject(error[attrName]); }),
].every(function (v) { return v; }));
};
return JapiError;

@@ -22,0 +37,0 @@ }());

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

export declare function isPlainObject(o: any): o is object;
export declare function isPlainObject(o: unknown): o is Record<string, unknown>;
//# sourceMappingURL=is-plain-object.d.ts.map
"use strict";
exports.__esModule = true;
exports.isPlainObject = void 0;
var is_object_object_1 = require("./is-object-object");
var is_object_1 = require("./is-object");
function isPlainObject(o) {
if (!is_object_object_1.isObject(o))
if (!is_object_1.isObject(o))
return false;
// If has modified constructor
var ctor = o.constructor;
if (typeof ctor !== "function")
// If constructor was modified
if (typeof o.constructor !== "function")
return false;
// If has modified prototype
var prot = ctor.prototype;
if (!is_object_object_1.isObject(prot))
// If prototype was modified
if (!is_object_1.isObject(o.constructor.prototype))
return false;
// If constructor does not have an Object-specific method
// eslint-disable-next-line no-prototype-builtins
if (!prot.hasOwnProperty("isPrototypeOf"))
if (!o.constructor.prototype.hasOwnProperty("isPrototypeOf"))
return false;
// Most likely a plain Object
return true;

@@ -22,0 +18,0 @@ }

{
"name": "ts-japi",
"version": "1.2.7",
"version": "1.3.0",
"description": "A highly-modular (typescript-friendly)-framework agnostic library for serializing data to the JSON:API specification",

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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