{"id":15105354,"url":"https://github.com/raido/ember-json-serializer-meta","last_synced_at":"2025-09-27T03:30:44.379Z","repository":{"id":57223934,"uuid":"49321989","full_name":"raido/ember-json-serializer-meta","owner":"raido","description":"Extensive metadata support for Ember Data JSONSerializer","archived":true,"fork":false,"pushed_at":"2017-09-10T11:25:23.000Z","size":132,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-01-03T17:49:39.104Z","etag":null,"topics":["addon","ember","ember-data","json-api","serializer"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/raido.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-09T11:38:36.000Z","updated_at":"2023-01-28T21:10:07.000Z","dependencies_parsed_at":"2022-08-30T02:10:23.235Z","dependency_job_id":null,"html_url":"https://github.com/raido/ember-json-serializer-meta","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raido%2Fember-json-serializer-meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raido%2Fember-json-serializer-meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raido%2Fember-json-serializer-meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/raido%2Fember-json-serializer-meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/raido","download_url":"https://codeload.github.com/raido/ember-json-serializer-meta/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234376917,"owners_count":18822416,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["addon","ember","ember-data","json-api","serializer"],"created_at":"2024-09-25T20:23:39.287Z","updated_at":"2025-09-27T03:30:39.076Z","avatar_url":"https://github.com/raido.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ember-json-serializer-meta\n\n[![Build Status](https://travis-ci.org/raido/ember-json-serializer-meta.svg)](https://travis-ci.org/raido/ember-json-serializer-meta)\n[![npm version](https://badge.fury.io/js/ember-json-serializer-meta.svg)](https://badge.fury.io/js/ember-json-serializer-meta)\n\nSo I heard you are working with custom APIs that are not either JSONAPI or REST but rather something in between, a hybrid. Then this addon is for you! It enables extracting metadata for all the Ember Data normalize*Response hooks.\n\n```ember install ember-json-serializer-meta```\n\n**Works with Ember 1.13+**\n\n## How it works\n\n### Flow chart\n\n```\n                                               ┌─ extractMetaFindAllResponse() ─────┐\n                                               ├─ extractMetaFindHasManyResponse() ─┼─ extractMetaArrayResponse() ─────────────────────────────────┐\n                                               ├─ extractMetaFindManyResponse() ────┤                                                              │\n                                               ├─ extractMetaQueryResponse() ───────┘                                                              │\n                                               │                                                                                                   │\n                                               ├─ extractMetaFindRecordResponse() ─────────────────────────────────┐                               │\nnormalizeResponse() - normalizeMetaResponse() ─┼─ extractMetaFindBelongsToResponse() ──────────────────────────────┤                               │\n                                               ├─ extractMetaQueryRecordResponse() ────────────────────────────────┤                               │\n                                               │                                                                   │                               │\n                                               ├─ extractMetaCreateRecordResponse() ─┐                             │                               │\n                                               ├─ extractMetaDeleteRecordResponse() ─┼─ extractMetaSaveResponse() ─┴─ extractMetaSingleResponse() ─┴─ extractMetaResponse()\n                                               └─ extractMetaUpdateRecordResponse() ─┘\n\n```\n\n### API response\n\n```\n  {\n    status: {\n      errorCode: 0\n    },\n    records: [{\n      id: 1,\n      name: 'Tomster'\n    }],\n    pagination: {\n\n    }\n  }\n```\n\n By default such payload is not supported by the JSONSerializer, it is impossible to extract metadata with default `extractMeta` hook.\n\nHere comes in the addon which adds another serializer hook for extracting meta for your custom API responses with JSONSerializer.\n\n```app/serializers/user.js\nimport extractMetaResponseMixin from 'ember-json-serializer-meta';\n\nexport default DS.JSONSerializer.extend(extractMetaResponseMixin, {\n  extractMetaResponse(store, typeClass, payload/*, id, requestType*/) {\n    if (payload \u0026\u0026 payload.pagination) {\n      return payload.pagination;\n    }\n  }\n});\n```\n\nDefault implementation of extractMetaResponse will lookup `meta` property.\n\n```\n  {\n    ...\n    meta: {\n      my: 'meta'\n    }\n    ...\n  }\n```\n\n# Contribution\n\n**This project follows [Gitflow Workflow](https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow).**\n\n## Installation\n\n* `git clone` this repository\n* `yarn install`\n\n## Running\n\n* `ember serve`\n* Visit your app at [http://localhost:4200](http://localhost:4200).\n\n## Running Tests\n\n* `yarn test` (Runs `ember try:each` to test your addon against multiple Ember versions)\n* `ember test`\n* `ember test --server`\n\n## Building\n\n* `ember build`\n\nFor more information on using ember-cli, visit [https://ember-cli.com/](https://ember-cli.com/).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraido%2Fember-json-serializer-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraido%2Fember-json-serializer-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraido%2Fember-json-serializer-meta/lists"}