{"id":13580425,"url":"https://github.com/google/schema-dts","last_synced_at":"2025-04-06T02:31:31.603Z","repository":{"id":33677403,"uuid":"159731526","full_name":"google/schema-dts","owner":"google","description":"JSON-LD TypeScript types for Schema.org vocabulary","archived":false,"fork":false,"pushed_at":"2025-03-01T21:05:35.000Z","size":2342,"stargazers_count":973,"open_issues_count":13,"forks_count":33,"subscribers_count":13,"default_branch":"main","last_synced_at":"2025-03-22T00:42:35.985Z","etag":null,"topics":["json-ld","knowledge-graph","linked-data","ontology","schema-org","schemaorg","semantic-web","typescript","typescript-definitions"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/google.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-11-29T21:45:45.000Z","updated_at":"2025-03-21T14:40:47.000Z","dependencies_parsed_at":"2024-06-18T12:27:20.476Z","dependency_job_id":"47d66fd8-a666-4de9-9dbb-fa2681aac221","html_url":"https://github.com/google/schema-dts","commit_stats":{"total_commits":372,"total_committers":6,"mean_commits":62.0,"dds":"0.32258064516129037","last_synced_commit":"dea38fffd22c47b4b3461c12a16de4929220b3cd"},"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fschema-dts","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fschema-dts/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fschema-dts/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/google%2Fschema-dts/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/google","download_url":"https://codeload.github.com/google/schema-dts/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247425986,"owners_count":20937047,"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":["json-ld","knowledge-graph","linked-data","ontology","schema-org","schemaorg","semantic-web","typescript","typescript-definitions"],"created_at":"2024-08-01T15:01:51.151Z","updated_at":"2025-04-06T02:31:30.962Z","avatar_url":"https://github.com/google.png","language":"TypeScript","readme":"[![Build Status](https://github.com/google/schema-dts/actions/workflows/ci.yml/badge.svg)](https://github.com/google/schema-dts/actions/workflows/ci.yml)\n[![Coverage Status](https://coveralls.io/repos/github/google/schema-dts/badge.svg?branch=main)](https://coveralls.io/github/google/schema-dts?branch=main)\n[![schema-dts npm version](https://badge.fury.io/js/schema-dts.svg)](https://www.npmjs.com/package/schema-dts)\n[![schema-dts-gen version](https://badge.fury.io/js/schema-dts-gen.svg)](https://www.npmjs.com/package/schema-dts-gen)\n\n# schema-dts\n\nJSON-LD TypeScript types for Schema.org vocabulary.\n\n**schema-dts** provides TypeScript definitions for\n[Schema.org](https://schema.org/) vocabulary in JSON-LD format. The typings are\nexposed as complete sets of discriminated type unions, allowing for easy\ncompletions and stricter validation.\n\n![Example of Code Completion using schema-dts](./example-1.gif)\n\nThis repository contains two NPM packages:\n\n- **[schema-dts-gen](https://www.npmjs.com/package/schema-dts-gen)** Providing a\n  command-line tool to generate TypeScript files based on a specific Schema\n  version and layer.\n- **[schema-dts](https://www.npmjs.com/package/schema-dts)** Pre-packaged\n  TypeScript typings of latest Schema.org schema, without\n  [pending](https://pending.schema.org/) and other non-core layers.\n\nNote: This is not an officially supported Google product.\n\n## Usage\n\nTo use the typings for your project, simply add the\n[`schema-dts`](https://www.npmjs.com/package/schema-dts) NPM package to your\nproject:\n\n```command\nnpm install schema-dts\n```\n\nThen you can use it by importing `\"schema-dts\"`.\n\n### Root context\n\nYou will usually want your top-level item to include a `@context`, like\n`https://schema.org`. In order for your object type to accept this property, you\ncan augment it with `WithContext`, e.g.:\n\n```ts\nimport type {Person, WithContext} from 'schema-dts';\n\nconst p: WithContext\u003cPerson\u003e = {\n  '@context': 'https://schema.org',\n  '@type': 'Person',\n  name: 'Eve',\n  affiliation: {\n    '@type': 'School',\n    name: 'Nice School',\n  },\n};\n```\n\n### Graphs and IDs\n\nJSON-LD supports `'@graph'` objects that have richer interconnected links\nbetween the nodes. You can do that easily in `schema-dts` by using the `Graph`\ntype.\n\nNotice that any node can have an `@id` when defining it. And you can reference\nthe same node from different places by simply using an ID stub, for example\n`{ '@id': 'https://my.site/about/#page }` below is an ID stub.\n\nThe example below shows potential JSON-LD for an About page. It includes\ndefinitions of Alyssa P. Hacker (the author \u0026 subject of the page), the specific\npage in this URL, and the website it belongs to. Some objects are still defined\nas inline nested objects (e.g. Occupation), since they are only referenced by\ntheir parent. Other objects are defined at the top-level with an `@id`, because\nmultiple nodes refer to them.\n\n```ts\nimport type {Graph} from 'schema-dts';\n\nconst graph: Graph = {\n  '@context': 'https://schema.org',\n  '@graph': [\n    {\n      '@type': 'Person',\n      '@id': 'https://my.site/#alyssa',\n      name: 'Alyssa P. Hacker',\n      hasOccupation: {\n        '@type': 'Occupation',\n        name: 'LISP Hacker',\n        qualifications: 'Knows LISP',\n      },\n      mainEntityOfPage: {'@id': 'https://my.site/about/#page'},\n      subjectOf: {'@id': 'https://my.site/about/#page'},\n    },\n    {\n      '@type': 'AboutPage',\n      '@id': 'https://my.site/#site',\n      url: 'https://my.site',\n      name: \"Alyssa P. Hacker's Website\",\n      inLanguage: 'en-US',\n      description: 'The personal website of LISP legend Alyssa P. Hacker',\n      mainEntity: {'@id': 'https://my.site/#alyssa'},\n    },\n    {\n      '@type': 'WebPage',\n      '@id': 'https://my.site/about/#page',\n      url: 'https://my.site/about/',\n      name: \"About | Alyssa P. Hacker's Website\",\n      inLanguage: 'en-US',\n      isPartOf: {\n        '@id': 'https://my.site/#site',\n      },\n      about: {'@id': 'https://my.site/#alyssa'},\n      mainEntity: {'@id': 'https://my.site/#alyssa'},\n    },\n  ],\n};\n```\n\n# Schema Typings Generator\n\nThe Schema Typings Generator is available in the\n[**`schema-dts-gen`**](https://www.npmjs.com/package/schema-dts-gen) package.\n\n    npm install schema-dts-gen\n    npx schema-dts-gen --ontology=https://schema.org/version/latest/schemaorg-all-https.nt\n\nCommand line usage:\n\n- **Specify your ontology**\n\n  - Specify **`--ontology`**: An HTTPs URL to an .nt NTriple file declaring your\n    ontology.\n\n    Must be compatible with Schema.org, including the Schema.org `DataType`s and\n    specifying a top-level `Thing` type.\n\n- **`--context`**: Defaults to `https://schema.org`, the value or values to be\n  used with the `\"@context\"` property.\n\n  Can be either a single URL, or a comma separated list of two or more name:URL\n  pairs.\n\n  The context affects names of string properties in types, as well as the values\n  of an object's `\"@type\"`.\n\n- **`--deprecated`**/**`--nodeprecated`**: Whether or not to include deprecated\n  Schema.org types and properties. When included, these types will still be\n  marked with `@deprecated` JSDOC tags.\n\n- **`--verbose`**: Outputs additional logs and debugging notes to stderr.\n\n## Developers\n\nUse NPM to install dependencies:\n\n```command\nnpm install\n```\n\nWe have wrappers around `tsc` and `tsc --build` to build our generator other\n.d.ts files.\n\nTo generate TypeScript from the latest Schema.org Schema:\n\n```command\nnpm run build-gen \u0026\u0026 npm run build-schema\n```\n\nor simply build the schema-dts generator:\n\n```command\nnpm run build-gen\n```\n\nTo contribute changes, see [the CONTRIBUTING.md file](./CONTRIBUTING.md).\n","funding_links":[],"categories":["TypeScript","typescript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fschema-dts","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgoogle%2Fschema-dts","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgoogle%2Fschema-dts/lists"}