{"id":27399640,"url":"https://github.com/decoverto/decoverto","last_synced_at":"2025-04-14T03:20:13.735Z","repository":{"id":57675487,"uuid":"345939333","full_name":"decoverto/decoverto","owner":"decoverto","description":"Convert data to classes using @decorators","archived":false,"fork":false,"pushed_at":"2024-11-11T11:14:31.000Z","size":2451,"stargazers_count":6,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-23T23:37:01.073Z","etag":null,"topics":["decorators","deserialization","json","parse","serialization","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/decoverto.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-03-09T08:44:14.000Z","updated_at":"2024-11-11T11:14:35.000Z","dependencies_parsed_at":"2024-11-11T12:31:27.283Z","dependency_job_id":null,"html_url":"https://github.com/decoverto/decoverto","commit_stats":{"total_commits":627,"total_committers":19,"mean_commits":33.0,"dds":0.4976076555023924,"last_synced_commit":"b863d90bd61069cb82239dd35816aa72139b1eb4"},"previous_names":["matthiaskunnen/decorated-json"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decoverto%2Fdecoverto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decoverto%2Fdecoverto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decoverto%2Fdecoverto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/decoverto%2Fdecoverto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/decoverto","download_url":"https://codeload.github.com/decoverto/decoverto/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248813989,"owners_count":21165656,"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":["decorators","deserialization","json","parse","serialization","typescript"],"created_at":"2025-04-14T03:20:13.075Z","updated_at":"2025-04-14T03:20:13.728Z","avatar_url":"https://github.com/decoverto.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![npm version](https://img.shields.io/npm/v/decoverto.svg?logo=npm\u0026style=for-the-badge)](https://www.npmjs.com/package/decoverto)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/decoverto/decoverto/nodejs.yml?branch=master\u0026label=CI\u0026logo=github\u0026style=for-the-badge)\n](https://github.com/decoverto/decoverto/actions)\n[![Code coverage](https://img.shields.io/codecov/c/github/decoverto/decoverto/master?style=for-the-badge)\n](https://app.codecov.io/gh/decoverto/decoverto)\n[![License](https://img.shields.io/npm/l/decoverto?\u0026style=for-the-badge\u0026color=green)\n](https://github.com/decoverto/decoverto/blob/master/LICENSE)\n\n# Decoverto\nConvert data into instances of first and third party classes and back using decorators. Enjoy not having to write data-to-class setup code.\n\n**[Test and tinker on the Decoverto playground](https://codesandbox.io/s/github/decoverto/playground?file=/index.ts)**\n\n## Features\n\n- [Convert object literals to and from instances](docs/conversion.md)\n- [Multilevel inheritance](docs/inheritance.md)\n    - [Using discriminators](docs/inheritance.md#discriminator-strategy)\n    - [Using a predicate](docs/inheritance.md#predicate-strategy)\n- [Reflect property types and stay DRY](docs/defining-properties.md#reflect-metadata)\n- [Make your own converters](docs/defining-properties.md#mapping-types) \u003csmall\u003eHandy for third-party types\u003c/small\u003e\n- Builtin support for:\n  - `number`, `string`, `Date`, `ArrayBuffer`, `DataView`, `TypedArray`\n  - [Collections such as `Array`, `Set`, `Map`](docs/defining-properties.md#collections)\n- [Deferred types](docs/defining-properties.md#passing-the-type-to-the-decorator) \n- Convert any raw data:\n    - [Use your own parser](docs/parser.md#custom-parser)\n    - [Configure the default JSON parser](docs/parser.md#customize-json-parser)\n- Works in browser and Node\n- Use TypeScript ([playground](https://codesandbox.io/s/github/decoverto/playground?file=/index.ts)) or JavaScript with Babel ([playground](https://codesandbox.io/s/github/decoverto/example-javascript?file=/index.js))\n\n\nA model looks like this:\n\n```TypeScript\nimport {model, map, MapShape, property} from 'decoverto';\n\n@model()\nclass User {\n\n    @property()\n    createdAt: Date;\n\n    @property()\n    givenName: string;\n\n    @property(() =\u003e String)\n    referralToken: string | null;\n\n    @property(map(() =\u003e String, () =\u003e Boolean, {shape: MapShape.Object}))\n    permissions: Map\u003cstring, boolean\u003e;\n}\n```\n\n### Quickstart\n\n1. Install decoverto\n\n   ```shell\n   yarn add decoverto\n   ```\n   or\n    ```shell\n    npm install decoverto\n    ```\n\n1. When using TypeScript, enable `experimentalDecorators` in `tsconfig.json`\n1. Define a model\n\n    ```TypeScript\n    import {model, map, MapShape, property} from 'decoverto';\n\n    @model()\n    class User {\n\n        @property(() =\u003e Date)\n        createdAt: Date;\n\n        @property(() =\u003e String)\n        givenName: string;\n\n        @property(() =\u003e String)\n        referralToken: string | null;\n\n        @property(map(() =\u003e String, () =\u003e Boolean, {shape: MapShape.Object}))\n        permissions: Map\u003cstring, boolean\u003e;\n    }\n    ```\n\n1. Create a Decoverto instance `const decoverto = new Decoverto()`\n1. Convert some data\n\n   ```TypeScript\n   // Convert raw data using the default JSON parser\n   user = decoverto.type(User).rawToInstance(`{\n       \"createdAt\": \"2021-03-31T14:08:42.009Z\",\n       \"givenName\": \"Mark\",\n       \"referralToken\": null,\n       \"permissions\": {\n           \"canManageUsers\": true,\n           \"canCreateProducts\": true\n       }\n   }`);\n\n   // Convert an object literal\n   user = decoverto.type(User).plainToInstance({\n       createdAt: new Date(),\n       givenName: 'Mark',\n       referralToken: null,\n       permissions: {\n           canManageUsers: true,\n           canCreateProducts: true,\n       }\n   });\n   ```\n\nFor more information, see links in the [features list](#features) or the [docs directory](docs).\n\n## Examples/Playground\n\nDecoverto has playgrounds where you can view examples and tinker with them. It allows you to see what is possible and experiment.\n- [TypeScript playground](https://codesandbox.io/s/github/decoverto/playground?file=/index.ts) This is the main playground.\n- [JavaScript + Babel playground](https://codesandbox.io/s/github/decoverto/example-javascript?file=/index.js)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecoverto%2Fdecoverto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecoverto%2Fdecoverto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecoverto%2Fdecoverto/lists"}