{"_id":"@btakita/schema-dts","name":"@btakita/schema-dts","dist-tags":{"latest":"1.1.3-patch"},"versions":{"1.1.3-patch":{"name":"@btakita/schema-dts","version":"1.1.3-patch","displayName":"schema-dts: Strongly-typed Schema.org vocabulary declarations","description":"A TypeScript package with latest Schema.org Schema Typings","author":{"name":"Eyas Sharaiha","email":"eyas@google.com","url":"https://eyas.sh/"},"maintainers":[{"name":"btakita","email":"brian.takita@gmail.com"}],"contributors":[{"name":"Brian Takita","email":"brian@briantakita.me","url":"https://briantakita.me/"},{"name":"Eyas Sharaiha","email":"npm@eyas.sh","url":"https://eyas.sh/"}],"types":"./dist/schema.d.ts","main":"./dist/schema.js","devDependencies":{"mkdirp":"^1.0.4","schema-dts-gen":"*"},"keywords":["typescript","tsd","dts","schema.org","Semantic Web","semantic-web","Linked Data","linked-data","jsonld","JSON-LD","structured data","structured-data"],"homepage":"https://github.com/btakita/schema-dts","bugs":{"url":"https://github.com/btakita/schema-dts/issues"},"repository":{"type":"git","url":"git+https://github.com/btakita/schema-dts.git","directory":"packages/schema-dts"},"scripts":{"lint:eslint":"eslint test/**/*.ts","prepare":"mkdirp lib/","build:generate":"schema-dts-gen > lib/schema.ts","build:compile":"tsc -p .","build":"npm run build:generate && npm run build:compile","test":"npm run build && tsc -p test/"},"license":"Apache-2.0","_id":"@btakita/schema-dts@1.1.3-patch","gitHead":"4261f3c038b9afe851e85bc98f0f1986083abd97","_nodeVersion":"20.11.1","_npmVersion":"10.4.0","dist":{"integrity":"sha512-awDzrA6wDXqLNuiHhD1ttkf7aaVXO7/J9ktmOARrLGM2xm1ZvmASoJ9bmVweXEu82eWi+AeiNVxdjQKrLPStKw==","shasum":"93239fe1bc2b329fb4c1cd6c9b48b6017830a202","tarball":"https://registry.npmjs.org/@btakita/schema-dts/-/schema-dts-1.1.3-patch.tgz","fileCount":5,"unpackedSize":926066,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCiol3wnCnFuvgfOkPWDvGYomqe4MPB1bs7PY9QAdt2OQIgXANkictfBhGGw9+xe5rvs6ipS7fDqQYyiXN96vSdi3M="}]},"_npmUser":{"name":"btakita","email":"brian.takita@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/schema-dts_1.1.3-patch_1709846960433_0.8486650903149402"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-07T21:29:20.305Z","1.1.3-patch":"2024-03-07T21:29:20.581Z","modified":"2024-03-07T21:29:21.108Z"},"maintainers":[{"name":"btakita","email":"brian.takita@gmail.com"}],"description":"A TypeScript package with latest Schema.org Schema Typings","homepage":"https://github.com/btakita/schema-dts","keywords":["typescript","tsd","dts","schema.org","Semantic Web","semantic-web","Linked Data","linked-data","jsonld","JSON-LD","structured data","structured-data"],"repository":{"type":"git","url":"git+https://github.com/btakita/schema-dts.git","directory":"packages/schema-dts"},"contributors":[{"name":"Brian Takita","email":"brian@briantakita.me","url":"https://briantakita.me/"},{"name":"Eyas Sharaiha","email":"npm@eyas.sh","url":"https://eyas.sh/"}],"author":{"name":"Eyas Sharaiha","email":"eyas@google.com","url":"https://eyas.sh/"},"bugs":{"url":"https://github.com/btakita/schema-dts/issues"},"license":"Apache-2.0","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\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](https://raw.githubusercontent.com/google/schema-dts/HEAD/example-1.gif)\n\nNote: This is not an officially supported Google product.\n\n## Usage\n\nTo use the typings for your project, simply add the `schema-dts` NPM package to\nyour project:\n\n```command\nnpm install schema-dts\n```\n\nThen you can use it by importing `\"schema-dts\"`.\n\n## Examples\n\n### Defining Simple Properties\n\n```ts\nimport type {Person} from 'schema-dts';\n\nconst inventor: Person = {\n  '@type': 'Person',\n  name: 'Grace Hopper',\n  disambiguatingDescription: 'American computer scientist',\n  birthDate: '1906-12-09',\n  deathDate: '1992-01-01',\n  awards: [\n    'Presidential Medal of Freedom',\n    'National Medal of Technology and Innovation',\n    'IEEE Emanuel R. Piore Award',\n  ],\n};\n```\n\n### Using 'Context'\n\nJSON-LD requires a `\"@context\"` property to be set on the top-level JSON object,\nto describe the URIs represeting the types and properties being referenced.\nschema-dts provides the `WithContext<T>` type to facilitate this.\n\n```ts\nimport type {Organization, Thing, WithContext} from 'schema-dts';\n\nexport function JsonLd<T extends Thing>(json: WithContext<T>): string {\n  return `<script type=\"application/ld+json\">\n${JSON.stringify(json)}\n</script>`;\n}\n\nexport const MY_ORG = JsonLd<Organization>({\n  '@context': 'https://schema.org',\n  '@type': 'Corporation',\n  name: 'Google LLC',\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 & 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","readmeFilename":"README.md"}