Comparing version 1.2.4 to 1.2.5
@@ -8,2 +8,11 @@ # Changelog | ||
## [1.2.5] - 2020-06-19 | ||
### Changed | ||
* Exported interfaces related to JSON:API. | ||
* The Error and Data document interfaces now require the "errors" and "data" properties respectively. | ||
* The Base document interface has been abstracted further by removing the "meta" property. | ||
* A *new* Meta document interface is now available for type-checking. | ||
## [1.2.4] - 2020-06-19 | ||
@@ -10,0 +19,0 @@ |
@@ -27,6 +27,6 @@ import { SerializerOptions } from "../interfaces/serializer.interface"; | ||
/** @internal Gets a document in the cache */ | ||
get(data: SingleOrArray<PrimaryType> | nullish, options?: Partial<SerializerOptions<PrimaryType>>): false | DataDocument<PrimaryType>; | ||
get(data: SingleOrArray<PrimaryType> | nullish, options?: Partial<SerializerOptions<PrimaryType>>): false | Partial<DataDocument<PrimaryType>>; | ||
/** @internal Sets a document in the cache */ | ||
set(data: SingleOrArray<PrimaryType> | nullish, document: DataDocument<PrimaryType>, options?: Partial<SerializerOptions<PrimaryType>>): DataDocument<PrimaryType>; | ||
set(data: SingleOrArray<PrimaryType> | nullish, document: Partial<DataDocument<PrimaryType>>, options?: Partial<SerializerOptions<PrimaryType>>): Partial<DataDocument<PrimaryType>>; | ||
} | ||
//# sourceMappingURL=cache.d.ts.map |
@@ -82,3 +82,3 @@ "use strict"; | ||
var version = o.version; | ||
var document = {}; | ||
var document = { errors: [] }; | ||
// Normalize error input | ||
@@ -88,34 +88,34 @@ if (!Array.isArray(errors)) { | ||
} | ||
document.errors = errors.map(function (error) { | ||
if (error instanceof error_model_1["default"]) | ||
return error; | ||
var errorOptions = {}; | ||
if (attributes.id && error[attributes.id]) { | ||
errorOptions.id = String(error[attributes.id]); | ||
document.errors = errors.map(function (e) { | ||
if (e instanceof error_model_1["default"]) | ||
return e; | ||
var eo = {}; | ||
if (attributes.id && e[attributes.id]) { | ||
eo.id = String(e[attributes.id]); | ||
} | ||
if (attributes.status && error[attributes.status]) { | ||
errorOptions.status = String(error[attributes.status]); | ||
if (attributes.status && e[attributes.status]) { | ||
eo.status = String(e[attributes.status]); | ||
} | ||
if (attributes.code && error[attributes.code]) { | ||
errorOptions.code = String(error[attributes.code]); | ||
if (attributes.code && e[attributes.code]) { | ||
eo.code = String(e[attributes.code]); | ||
} | ||
if (attributes.title && error[attributes.title]) { | ||
errorOptions.title = String(error[attributes.title]); | ||
if (attributes.title && e[attributes.title]) { | ||
eo.title = String(e[attributes.title]); | ||
} | ||
if (attributes.detail && error[attributes.detail]) { | ||
errorOptions.detail = String(error[attributes.detail]); | ||
if (attributes.detail && e[attributes.detail]) { | ||
eo.detail = String(e[attributes.detail]); | ||
} | ||
if (attributes.source) { | ||
errorOptions.source = {}; | ||
if (attributes.source.pointer && error[attributes.source.pointer]) { | ||
errorOptions.source.pointer = String(error[attributes.source.pointer]); | ||
eo.source = {}; | ||
if (attributes.source.pointer && e[attributes.source.pointer]) { | ||
eo.source.pointer = String(e[attributes.source.pointer]); | ||
} | ||
if (attributes.source.parameter && error[attributes.source.parameter]) { | ||
errorOptions.source.parameter = String(error[attributes.source.parameter]); | ||
if (attributes.source.parameter && e[attributes.source.parameter]) { | ||
eo.source.parameter = String(e[attributes.source.parameter]); | ||
} | ||
if (Object.keys(errorOptions.source).length === 0) { | ||
delete errorOptions.source; | ||
if (Object.keys(eo.source).length === 0) { | ||
delete eo.source; | ||
} | ||
} | ||
return new error_model_1["default"](errorOptions); | ||
return new error_model_1["default"](eo); | ||
}); | ||
@@ -122,0 +122,0 @@ // Constructing base document. |
@@ -75,4 +75,4 @@ import { DataDocument } from "../interfaces/json:api.interface"; | ||
*/ | ||
serialize(data: SingleOrArray<PrimaryType> | nullish, options?: Partial<SerializerOptions<PrimaryType>>): Promise<DataDocument<PrimaryType>>; | ||
serialize(data: SingleOrArray<PrimaryType> | nullish, options?: Partial<SerializerOptions<PrimaryType>>): Promise<Partial<DataDocument<PrimaryType>>>; | ||
} | ||
//# sourceMappingURL=serializer.d.ts.map |
@@ -16,4 +16,5 @@ import Metaizer from "./classes/metaizer"; | ||
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 }; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -40,3 +40,4 @@ "use strict"; | ||
__exportStar(require("./interfaces/cache.interface"), exports); | ||
__exportStar(require("./interfaces/json:api.interface"), exports); | ||
__exportStar(require("./types/global.types"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -8,9 +8,9 @@ import JapiError from "../models/error.model"; | ||
import { PaginationOf } from "./paginator.interface"; | ||
export interface DataDocument<PrimaryType extends Dictionary<any>> extends BaseDocument { | ||
export interface DataDocument<PrimaryType extends Dictionary<any>> extends Partial<MetaDocument> { | ||
links?: Dictionary<Link | nullish> | PaginationOf<Link>; | ||
included?: Resource[]; | ||
data?: PrimaryData<PrimaryType>; | ||
data: PrimaryData<PrimaryType>; | ||
} | ||
export interface ErrorDocument extends BaseDocument { | ||
errors?: JapiError[]; | ||
export interface ErrorDocument extends Partial<MetaDocument> { | ||
errors: JapiError[]; | ||
} | ||
@@ -21,5 +21,7 @@ export interface JSONAPIObject { | ||
} | ||
export interface MetaDocument extends BaseDocument { | ||
meta: Meta; | ||
} | ||
export interface BaseDocument { | ||
jsonapi?: JSONAPIObject; | ||
meta?: Meta; | ||
} | ||
@@ -26,0 +28,0 @@ export declare type PrimaryData<T> = SingleOrArray<ResourceIdentifier> | SingleOrArray<Resource<T>> | null; |
{ | ||
"name": "ts-japi", | ||
"version": "1.2.4", | ||
"version": "1.2.5", | ||
"description": "A highly-modular (typescript-friendly)-framework agnostic library for serializing data to the JSON:API specification", | ||
@@ -45,31 +45,31 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@babel/cli": "^7.10.1", | ||
"@babel/core": "^7.10.2", | ||
"@babel/plugin-proposal-class-properties": "^7.10.1", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.10.1", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.10.1", | ||
"@babel/preset-env": "^7.10.2", | ||
"@babel/preset-typescript": "^7.10.1", | ||
"@babel/cli": "^7.10.4", | ||
"@babel/core": "^7.10.4", | ||
"@babel/plugin-proposal-class-properties": "^7.10.4", | ||
"@babel/plugin-proposal-export-namespace-from": "^7.10.4", | ||
"@babel/plugin-proposal-object-rest-spread": "^7.10.4", | ||
"@babel/preset-env": "^7.10.4", | ||
"@babel/preset-typescript": "^7.10.4", | ||
"@types/benchmark": "^1.0.33", | ||
"@types/jest": "^25.2.3", | ||
"@types/lodash": "^4.14.155", | ||
"@types/uuid": "^7.0.4", | ||
"@typescript-eslint/eslint-plugin": "^2.34.0", | ||
"@typescript-eslint/parser": "^2.34.0", | ||
"babel-jest": "^26.0.1", | ||
"@types/jest": "^26.0.3", | ||
"@types/lodash": "^4.14.157", | ||
"@types/uuid": "^8.0.0", | ||
"@typescript-eslint/eslint-plugin": "^3.5.0", | ||
"@typescript-eslint/parser": "^3.5.0", | ||
"babel-jest": "^26.1.0", | ||
"benchmark": "^2.1.4", | ||
"core-js": "^3.6.5", | ||
"eslint": "^7.1.0", | ||
"eslint": "^7.4.0", | ||
"eslint-config-prettier": "^6.11.0", | ||
"eslint-plugin-prettier": "^3.1.3", | ||
"jest": "^26.0.1", | ||
"eslint-plugin-prettier": "^3.1.4", | ||
"jest": "^26.1.0", | ||
"lodash": "^4.17.15", | ||
"prettier": "^2.0.5", | ||
"regenerator-runtime": "^0.13.5", | ||
"snyk": "^1.336.0", | ||
"snyk": "^1.360.0", | ||
"ts-node": "^8.10.2", | ||
"typedoc": "^0.17.0-3", | ||
"typedoc-plugin-markdown": "^2.3.1", | ||
"typescript": "^3.9.5", | ||
"uuid": "^8.1.0" | ||
"typescript": "^3.9.6", | ||
"uuid": "^8.2.0" | ||
}, | ||
@@ -76,0 +76,0 @@ "snyk": true, |
@@ -321,3 +321,3 @@ <br /> | ||
Feel free to submit an issue, but please do not submit pull requests unless it is to fix some issue. | ||
For more information, read the [contribution guide](https://github.com/jun-sheaf/ts-japi/blob/master/CONTRIBUTING.md). | ||
For more information, read the [contribution guide](https://github.com/jun-sheaf/ts-japi/blob/master/CONTRIBUTING.html). | ||
@@ -324,0 +324,0 @@ ## License |
@@ -8,3 +8,4 @@ { | ||
"lib": [ | ||
"es2020" | ||
"es2020", | ||
"dom" | ||
], /* Specify library files to be included in the compilation. */ | ||
@@ -11,0 +12,0 @@ // "allowJs": true, /* Allow javascript files to be compiled. */ |
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
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
189527
2387