schema-dts
Advanced tools
+1
-1
| { | ||
| "name": "schema-dts", | ||
| "version": "0.8.3", | ||
| "version": "0.9.0", | ||
| "displayName": "schema-dts: Strongly-typed Schema.org vocabulary declarations", | ||
@@ -5,0 +5,0 @@ "description": "A TypeScript package with latest Schema.org Schema Typings", |
+63
-1
@@ -23,3 +23,5 @@ [](https://travis-ci.org/google/schema-dts) | ||
| npm install schema-dts | ||
| ```command | ||
| npm install schema-dts | ||
| ``` | ||
@@ -70,1 +72,61 @@ Then you can use it by importing `"schema-dts"`. | ||
| ``` | ||
| ### Graphs and IDs | ||
| JSON-LD supports `'@graph'` objects that have richer interconnected links | ||
| between the nodes. You can do that easily in `schema-dts` by using the `Graph` | ||
| type. | ||
| Notice that any node can have an `@id` when defining it. And you can reference | ||
| the same node from different places by simply using an ID stub, for example | ||
| `{ '@id': 'https://my.site/about/#page }` below is an ID stub. | ||
| The example below shows potential JSON-LD for an About page. It includes | ||
| definitions of Alyssa P. Hacker (the author & subject of the page), the specific | ||
| page in this URL, and the website it belongs to. Some objects are still defined | ||
| as inline nested objects (e.g. Occupation), since they are only referenced by | ||
| their parent. Other objects are defined at the top-level with an `@id`, because | ||
| multiple nodes refer to them. | ||
| ```ts | ||
| import {Graph} from 'schema-dts'; | ||
| const graph: Graph = { | ||
| '@context': 'https://schema.org', | ||
| '@graph': [ | ||
| { | ||
| '@type': 'Person', | ||
| '@id': 'https://my.site/#alyssa', | ||
| name: 'Alyssa P. Hacker', | ||
| hasOccupation: { | ||
| '@type': 'Occupation', | ||
| name: 'LISP Hacker', | ||
| qualifications: 'Knows LISP', | ||
| }, | ||
| mainEntityOfPage: {'@id': 'https://my.site/about/#page'}, | ||
| subjectOf: {'@id': 'https://my.site/about/#page'}, | ||
| }, | ||
| { | ||
| '@type': 'AboutPage', | ||
| '@id': 'https://my.site/#site', | ||
| url: 'https://my.site', | ||
| name: "Alyssa P. Hacker's Website", | ||
| inLanguage: 'en-US', | ||
| description: 'The personal website of LISP legend Alyssa P. Hacker', | ||
| mainEntity: {'@id': 'https://my.site/#alyssa'}, | ||
| }, | ||
| { | ||
| '@type': 'WebPage', | ||
| '@id': 'https://my.site/about/#page', | ||
| url: 'https://my.site/about/', | ||
| name: "About | Alyssa P. Hacker's Website", | ||
| inLanguage: 'en-US', | ||
| isPartOf: { | ||
| '@id': 'https://my.site/#site', | ||
| }, | ||
| about: {'@id': 'https://my.site/#alyssa'}, | ||
| mainEntity: {'@id': 'https://my.site/#alyssa'}, | ||
| }, | ||
| ], | ||
| }; | ||
| ``` |
Sorry, the diff of this file is too big to display
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
819635
4.31%11453
2.92%131
89.86%84
-3.45%