From 0843b81ae4604aa51aabf34b65243a089556736b Mon Sep 17 00:00:00 2001 From: Christian Engleder Date: Tue, 8 Jan 2019 13:16:43 +0100 Subject: [PATCH 1/3] Add Meta inside the data object --- src/serializer-options.ts | 3 ++- src/serializer-utils.ts | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/serializer-options.ts b/src/serializer-options.ts index 5e65f0e..d380e59 100644 --- a/src/serializer-options.ts +++ b/src/serializer-options.ts @@ -1,4 +1,4 @@ -import { Links, AttributesObject, caseOptions, RelationshipMeta} from './types'; +import { AttributesObject, Links, RelationshipMeta, caseOptions } from './types'; export interface SerializerOptions { [index: string]: any, @@ -14,6 +14,7 @@ export interface SerializerOptions { relationshipLinks?: Links, relationshipMeta?: RelationshipMeta, dataLinks?: Links, + dataMeta?: any, included?: boolean, includedLinks?: Links, embed?: boolean, diff --git a/src/serializer-utils.ts b/src/serializer-utils.ts index b0585a4..fbf79df 100644 --- a/src/serializer-utils.ts +++ b/src/serializer-utils.ts @@ -1,6 +1,7 @@ import * as _ from 'lodash'; -import { Links } from './types'; + import { Inflector } from './inflector'; +import { Links } from './types'; import { SerializerOptions } from './serializer-options'; export class SerializerUtils { @@ -145,6 +146,11 @@ export class SerializerUtils { data.links = this.getLinks(this.record, this.opts.dataLinks); } + // Data meta. + if (this.opts.dataMeta) { + data.meta = this.getMeta(this.record, this.opts.dataMeta); + } + _.each(this.opts.attributes, (attribute) => { var splittedAttributes = attribute.split(':'); From d464b18666de12705abbfac856a0fe2cc0ab28e4 Mon Sep 17 00:00:00 2001 From: christianengledercadt <44844093+christianengledercadt@users.noreply.github.com> Date: Tue, 8 Jan 2019 13:19:57 +0100 Subject: [PATCH 2/3] Fix import order --- src/serializer-utils.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/serializer-utils.ts b/src/serializer-utils.ts index fbf79df..0a329d9 100644 --- a/src/serializer-utils.ts +++ b/src/serializer-utils.ts @@ -1,7 +1,6 @@ import * as _ from 'lodash'; - -import { Inflector } from './inflector'; import { Links } from './types'; +import { Inflector } from './inflector'; import { SerializerOptions } from './serializer-options'; export class SerializerUtils { From 7e7dc457925d1e9f54c4c1778e040f8937d1ace7 Mon Sep 17 00:00:00 2001 From: christianengledercadt <44844093+christianengledercadt@users.noreply.github.com> Date: Tue, 8 Jan 2019 13:21:59 +0100 Subject: [PATCH 3/3] Update serializer-options.ts Fix import orders --- src/serializer-options.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/serializer-options.ts b/src/serializer-options.ts index d380e59..ee7faa5 100644 --- a/src/serializer-options.ts +++ b/src/serializer-options.ts @@ -1,4 +1,4 @@ -import { AttributesObject, Links, RelationshipMeta, caseOptions } from './types'; +import { Links, AttributesObject, caseOptions, RelationshipMeta} from './types'; export interface SerializerOptions { [index: string]: any,