ts-japi
Advanced tools
Comparing version 1.11.1 to 1.11.2
{ | ||
".": "1.11.1" | ||
".": "1.11.2" | ||
} |
# Changelog | ||
## [1.11.2](https://github.com/mathematic-inc/ts-japi/compare/v1.11.1...v1.11.2) (2024-04-18) | ||
### Bug Fixes | ||
* better support for polymorphic inputs ([#87](https://github.com/mathematic-inc/ts-japi/issues/87)) ([f29f835](https://github.com/mathematic-inc/ts-japi/commit/f29f835e39a397cd9357fd55ccb8fe982bca06ec)) | ||
## [1.11.1](https://github.com/mathematic-inc/ts-japi/compare/v1.11.0...v1.11.1) (2024-04-17) | ||
@@ -4,0 +11,0 @@ |
@@ -28,10 +28,35 @@ "use strict"; | ||
})); | ||
return documents.reduce((result, document) => { | ||
if (!result) { | ||
return document; | ||
} | ||
// Construct initial document and included data | ||
let document = { | ||
data: [], | ||
}; | ||
// Document versioning | ||
if (options?.version) { | ||
document.jsonapi = { ...document.jsonapi, version: options.version }; | ||
} | ||
if (options?.metaizers?.jsonapi) { | ||
document.jsonapi = { ...document.jsonapi, meta: options.metaizers.jsonapi.metaize() }; | ||
} | ||
document = documents.reduce((result, document) => { | ||
result.data = [result.data ?? [], document.data ?? []].flat(); | ||
result.included = [result.included ?? [], document.included ?? []].flat(); | ||
return result; | ||
}); | ||
}, document); | ||
// Handle meta | ||
if (options?.metaizers?.document) { | ||
document.meta = options.metaizers.document.metaize(data); | ||
} | ||
// Handle links | ||
if (options?.linkers?.document) { | ||
if (options.linkers.document) { | ||
document.links = { ...document.links, self: options.linkers.document.link(data) }; | ||
} | ||
if (options.linkers.paginator) { | ||
const pagination = options.linkers.paginator.paginate(data); | ||
if (pagination) { | ||
document.links = { ...document.links, ...pagination }; | ||
} | ||
} | ||
} | ||
return document; | ||
} | ||
@@ -38,0 +63,0 @@ else if (data) { |
{ | ||
"name": "ts-japi", | ||
"version": "1.11.1", | ||
"version": "1.11.2", | ||
"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
237213
3500