{"id":20597064,"url":"https://github.com/tradle/lens","last_synced_at":"2026-04-20T11:03:48.810Z","repository":{"id":66294720,"uuid":"114502039","full_name":"tradle/lens","owner":"tradle","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-03T20:57:10.000Z","size":9,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-01-17T00:53:11.755Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tradle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-12-17T01:40:06.000Z","updated_at":"2022-07-03T20:57:13.000Z","dependencies_parsed_at":"2023-02-22T13:00:56.883Z","dependency_job_id":null,"html_url":"https://github.com/tradle/lens","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Flens","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Flens/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Flens/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tradle%2Flens/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tradle","download_url":"https://codeload.github.com/tradle/lens/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242231441,"owners_count":20093636,"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":[],"created_at":"2024-11-16T08:20:06.909Z","updated_at":"2026-04-20T11:03:48.784Z","avatar_url":"https://github.com/tradle.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @tradle/lens\n\ntools for validating and merging Tradle models and lenses for them\n\n## Usage\n\n```js\n// example.js\nconst { models } = require('@tradle/models')\nconst { merge } = require('@tradle/lens')\nconst model = {\n  type: 'tradle.Model',\n  id: 'my.custom.AddressForm',\n  title: 'Your Address',\n  subClassOf: 'tradle.Form',\n  properties: {\n    buildingName: {\n      type: 'string'\n    },\n    what3words: {\n      type: 'string',\n      description: 'Your three-word address on https://map.what3words.com'\n    }\n  },\n  required: ['what3words']\n}\n\nconst lens = {\n  _t: 'tradle.Lens',\n  id: 'my.custom.AddressFormLens',\n  model: 'my.custom.AddressForm',\n  properties: {\n    what3words: {\n      // customize a field by adding / overriding model attributes\n      title: 'Address',\n      description:  'your address on https://map.what3words.com, e.g. parade.help.bleat'\n    }\n  },\n  required: ['buildingName', 'what3words'],\n  hidden: []\n}\n\nconst merged = merge({ models, model, lens })\nconsole.log(JSON.stringify(merged, null, 2))\n\n// {\n//   \"type\": \"tradle.Model\",\n//   \"id\": \"my.custom.AddressForm\",\n//   \"title\": \"Your Address\",\n//   \"subClassOf\": \"tradle.Form\",\n//   \"required\": [\n//     \"what3words\",\n//     \"buildingName\"\n//   ],\n//   \"properties\": {\n//     \"buildingName\": {\n//       \"type\": \"string\"\n//     },\n//     \"what3words\": {\n//       \"type\": \"string\",\n//       \"description\": \"your address on https://map.what3words.com, e.g. parade.help.bleat\",\n//       \"title\": \"Address\"\n//     }\n//   },\n//   \"hidden\": []\n// }\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradle%2Flens","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftradle%2Flens","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftradle%2Flens/lists"}