{"_id":"@antinna/schema-ld-types","_rev":"2-e1df31ba86bb70b146943c169cf4cf11","name":"@antinna/schema-ld-types","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@antinna/schema-ld-types","version":"1.0.0","keywords":["jsonld","schema.org","typescript","validation"],"author":{"name":"Antinna"},"license":"MIT","_id":"@antinna/schema-ld-types@1.0.0","maintainers":[{"name":"manish3994","email":"manishgautammg7@gmail.com"}],"homepage":"https://github.com/Antinna/schema-ld-types#readme","bugs":{"url":"https://github.com/Antinna/schema-ld-types/issues"},"dist":{"shasum":"1906ca5e94ae760bbfe9d19155aeee304360124c","tarball":"https://registry.npmjs.org/@antinna/schema-ld-types/-/schema-ld-types-1.0.0.tgz","fileCount":36,"integrity":"sha512-cU6swC57fX7+YFNJN1p+Gt9r+/X7H/Z80CI60Yd53pb0/uaM+SyUQeX7Mjm+J99i21CY93EfFmVgPkPI8i/cBQ==","signatures":[{"sig":"MEUCIEKfE2G3tHevou8EwDPWtChThKGQRIsG6rmxsdL/6tT7AiEAzEg+x1ZqLihTOLzblLU/aZ8dHakoSOHq82XGLw8BOaA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10081872},"main":"./dist/index.umd.js","type":"module","types":"./dist/index.d.ts","module":"./dist/index.mjs","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.umd.js"}},"funding":{"url":"https://github.com/sponsors/manishmg3994","type":"github"},"gitHead":"bfa65cad670eda45a1320370628879081c637289","scripts":{"dev":"vite","lint":"tsc --noEmit","test":"vitest run","build":"vite build && tsc -p tsconfig.build.json","generate":"tsx scripts/generate.ts"},"_npmUser":{"name":"manish3994","email":"manishgautammg7@gmail.com"},"repository":{"url":"git+https://github.com/Antinna/schema-ld-types.git","type":"git"},"_npmVersion":"10.8.2","description":"TypeSafe library for Schema.org JSON-LD with validation and serialization.","directories":{},"_nodeVersion":"20.20.2","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.22.4","vite":"^6.0.7","axios":"^1.18.0","vitest":"^2.1.8","typescript":"^5.7.2","@types/node":"^22.19.21","@types/jsonld":"^1.5.15","vite-plugin-dts":"^4.5.4"},"_npmOperationalInternal":{"tmp":"tmp/schema-ld-types_1.0.0_1781798456326_0.47671494113769564","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2026-06-18T16:00:56.053Z","modified":"2026-06-18T20:03:24.651Z","1.0.0":"2026-06-18T16:00:56.489Z"},"bugs":{"url":"https://github.com/Antinna/schema-ld-types/issues"},"author":{"name":"Antinna"},"license":"MIT","homepage":"https://github.com/Antinna/schema-ld-types#readme","keywords":["jsonld","schema.org","typescript","validation"],"repository":{"url":"git+https://github.com/Antinna/schema-ld-types.git","type":"git"},"description":"TypeSafe library for Schema.org JSON-LD with validation and serialization.","maintainers":[{"email":"manishgautammg7@gmail.com","name":"manish3994"},{"email":"manishgautammg3994@gmail.com","name":"manishmg3994"}],"readme":"# @antinna/schema-ld-types\n\n[![npm version](https://img.shields.io/npm/v/@antinna/schema-ld-types.svg?style=flat-square)](https://www.npmjs.com/package/@antinna/schema-ld-types)\n[![license](https://img.shields.io/npm/l/@antinna/schema-ld-types.svg?style=flat-square)](https://github.com/Antinna/schema-ld-types/blob/main/LICENSE)\n[![npm downloads](https://img.shields.io/npm/dm/@antinna/schema-ld-types.svg?style=flat-square)](https://www.npmjs.com/package/@antinna/schema-ld-types)\n[![Sponsor](https://img.shields.io/badge/Sponsor-GitHub-ea4aaa?style=flat-square&logo=github-sponsors)](https://github.com/sponsors/manishmg3994)\n\nA comprehensive, typesafe library for [Schema.org](https://schema.org) JSON-LD objects. Ensure runtime and compile-time accuracy for your structured search data, metadata serialization, and dynamic JSON-LD injection.\n\n---\n\n## Features\n\n- **Full Type-Safety**: Autogenerated TypeScript definitions directly compiled from the Schema.org vocabulary.\n- **Validation & Typeguards**: Helper utilities to validate and assert schema structures.\n- **Hydration**: Automatically insert missing `@type` properties onto nested objects.\n- **Serialization/Deserialization**: Seamless translation to and from JSON-LD strings with automatically resolved `@context`.\n\n## Installation\n\n```bash\nnpm install @antinna/schema-ld-types\n```\n\n## Usage Examples\n\nHere are some standard ways to validate, serialize, deserialize, and check types for Schema.org JSON-LD elements.\n\n### 1. Import Types & Utilities\n\n```typescript\nimport { \n  Person, \n  validate, \n  assertType, \n  serialize, \n  deserialize, \n  hydrate \n} from '@antinna/schema-ld-types';\n```\n\n### 2. Validate Data (Type Guarding)\n\nEnsure at runtime that an object conforms to the expected Schema.org hierarchy.\n\n```typescript\nconst data: any = {\n  '@type': 'Person',\n  name: 'Jane Doe',\n  jobTitle: 'Software Engineer',\n  worksFor: {\n    '@type': 'Organization',\n    name: 'Antinna'\n  }\n};\n\nif (validate<Person>(data, 'Person')) {\n  // TypeScript now knows 'data' is Person\n  console.log(`Successfully verified Person: ${data.name}`);\n} else {\n  console.error(\"Invalid Person structure!\");\n}\n```\n\n### 3. Assertion Testing\n\nThrows an error if the object does not conform to the expected type.\n\n```typescript\ntry {\n  const verifiedPerson = assertType<Person>(data, 'Person');\n  console.log(verifiedPerson.name);\n} catch (error) {\n  console.error(error.message);\n}\n```\n\n### 4. Serialize to JSON-LD String\n\nAutomatically prepends the correct `@context` to your structured data.\n\n```typescript\nconst author: Person = {\n  '@type': 'Person',\n  name: 'Manish',\n  url: 'https://github.com/manishmg3994'\n};\n\nconst jsonLdString = serialize(author);\nconsole.log(jsonLdString);\n/* \nOutput:\n{\n  \"@context\": \"https://schema.org\",\n  \"@type\": \"Person\",\n  \"name\": \"Manish\",\n  \"url\": \"https://github.com/manishmg3994\"\n}\n*/\n```\n\n### 5. Deserialize & Hydrate\n\nParses a JSON-LD string and automatically hydrates missing nested `@type` properties recursively based on Schema.org rules.\n\n```typescript\nconst rawJson = `\n{\n  \"name\": \"John Doe\",\n  \"worksFor\": {\n    \"name\": \"Antinna\"\n  }\n}\n`;\n\n// Deserializes and automatically infers worksFor's @type as Organization\nconst loadedPerson = deserialize<Person>(rawJson, 'Person');\n\nconsole.log(loadedPerson['@type']); // \"Person\"\nconsole.log(loadedPerson.worksFor['@type']); // \"Organization\"\n```\n\n---\n\n## Funding and Sponsorship\n\nIf you find this library useful, please consider supporting the project and its development! \n\n💖 **[Sponsor on GitHub Sponsors](https://github.com/sponsors/manishmg3994)**\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](https://github.com/Antinna/schema-ld-types/blob/main/LICENSE).\n","readmeFilename":"README.md"}