{"_id":"@comake/shacl-to-json-schema","_rev":"7-531112c2410b26af88d2da0c45e77cc4","name":"@comake/shacl-to-json-schema","dist-tags":{"latest":"1.0.3"},"versions":{"1.0.0":{"name":"@comake/shacl-to-json-schema","version":"1.0.0","keywords":["shacl","json-schema","converter","rdf","json"],"author":{"name":"Adler Faulkner","email":"adler@comake.io"},"license":"MIT","_id":"@comake/shacl-to-json-schema@1.0.0","maintainers":[{"name":"adlerfaulkner","email":"adler@comake.io"}],"homepage":"https://github.com/comake/shacl-to-json-schema#readme","bugs":{"url":"https://github.com/comake/shacl-to-json-schema/issues"},"dist":{"shasum":"8bb3d1a24b4c3c481f08047b856b0b214a2e9e6b","tarball":"https://registry.npmjs.org/@comake/shacl-to-json-schema/-/shacl-to-json-schema-1.0.0.tgz","fileCount":15,"integrity":"sha512-ZOX3GLgJ3OtOf9ngk63G5H9YmzjCDAR2tPHrKXW6wmHbGwRdz/Z7d51+FMvI6RSPIW/kDoewdP+b5ePMjg/uxw==","signatures":[{"sig":"MEQCIHhGnRxapXhiGw7nAI2MBCVfLvoNwiZ9AEcbwx3q74KZAiBvn/O8p1mZ3TyM7S3fDEADngUSd136N8Mc+cQSsD8gIg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":69105},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"04d016c8ceb4929d41de8cdbc116026550fe26a5","scripts":{"jest":"jest --coverage","test":"npm run test:ts && npm run jest","build":"tsc","prepare":"npm run build","test:ts":"tsc -p test --noEmit","test:integration":"jest --coverageReporters text-summary -- test/integration"},"_npmUser":{"name":"adlerfaulkner","email":"adler@comake.io"},"repository":{"url":"git+https://github.com/comake/shacl-to-json-schema.git","type":"git"},"_npmVersion":"8.15.0","description":"This is a simple library to translate SHACL NodeShapes into JSON Schemas. It does not support the full SHACL vocabulary, only those fields which can be applied to JSON Schema.","directories":{},"_nodeVersion":"16.17.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.6.1","eslint":"^8.31.0","ts-jest":"^29.1.1","typescript":"^4.9.4","@types/jest":"^29.5.2","@types/node":"^18.11.18","@types/jsonld":"^1.5.9","@tsconfig/node16":"^1.0.3","eslint-config-es":"4.1.0","eslint-plugin-jest":"^27.2.2","eslint-plugin-tsdoc":"^0.2.17","eslint-plugin-import":"^2.25.2","@typescript-eslint/parser":"^5.4.0","eslint-plugin-unused-imports":"^2.0.0","eslint-plugin-eslint-comments":"^3.2.0","@typescript-eslint/eslint-plugin":"^5.3.0","eslint-import-resolver-typescript":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/shacl-to-json-schema_1.0.0_1689278665813_0.30045696391558363","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@comake/shacl-to-json-schema","version":"1.0.1","keywords":["shacl","json-schema","converter","rdf","json"],"author":{"name":"Adler Faulkner","email":"adler@comake.io"},"license":"MIT","_id":"@comake/shacl-to-json-schema@1.0.1","maintainers":[{"name":"adlerfaulkner","email":"adler@comake.io"}],"homepage":"https://github.com/comake/shacl-to-json-schema#readme","bugs":{"url":"https://github.com/comake/shacl-to-json-schema/issues"},"dist":{"shasum":"80d8a8ed47107cf1a78a260e0667d48658b3cc0a","tarball":"https://registry.npmjs.org/@comake/shacl-to-json-schema/-/shacl-to-json-schema-1.0.1.tgz","fileCount":15,"integrity":"sha512-Ik28lTnIltd9g/iAEM2eKx3OJQzbtl8bEFagN82meu/1l4prBegDPG5WFEiWHOfhaD6v14a7FKJCoibB6qQGNw==","signatures":[{"sig":"MEUCIB8nAdoVfwerc7PF5avQRTlz6/5ZHZyGJGTaKyNOzKONAiEA5V7yCHUCs/qjkoT/GckNKyWgITul8DWaUr0SZomgFf4=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":69107},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"4437102ae2fa6f0dcf5fed6affeb1239de333671","scripts":{"jest":"jest --coverage","test":"npm run test:ts && npm run jest","build":"tsc","prepare":"npm run build","test:ts":"tsc -p test --noEmit","test:integration":"jest --coverageReporters text-summary -- test/integration"},"_npmUser":{"name":"adlerfaulkner","email":"adler@comake.io"},"repository":{"url":"git+https://github.com/comake/shacl-to-json-schema.git","type":"git"},"_npmVersion":"8.15.0","description":"This is a simple library to translate SHACL NodeShapes into JSON Schemas. It does not support the full SHACL vocabulary, only those fields which can be applied to JSON Schema.","directories":{},"_nodeVersion":"16.17.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.6.1","eslint":"^8.31.0","ts-jest":"^29.1.1","typescript":"^4.9.4","@types/jest":"^29.5.2","@types/node":"^18.11.18","@types/jsonld":"^1.5.9","@tsconfig/node16":"^1.0.3","eslint-config-es":"4.1.0","eslint-plugin-jest":"^27.2.2","eslint-plugin-tsdoc":"^0.2.17","eslint-plugin-import":"^2.25.2","@typescript-eslint/parser":"^5.4.0","eslint-plugin-unused-imports":"^2.0.0","eslint-plugin-eslint-comments":"^3.2.0","@typescript-eslint/eslint-plugin":"^5.3.0","eslint-import-resolver-typescript":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/shacl-to-json-schema_1.0.1_1689279137981_0.9614168435516317","host":"s3://npm-registry-packages"}},"1.0.2":{"name":"@comake/shacl-to-json-schema","version":"1.0.2","keywords":["shacl","json-schema","converter","rdf","json"],"author":{"name":"Adler Faulkner","email":"adler@comake.io"},"license":"MIT","_id":"@comake/shacl-to-json-schema@1.0.2","maintainers":[{"name":"adlerfaulkner","email":"adler@comake.io"}],"homepage":"https://github.com/comake/shacl-to-json-schema#readme","bugs":{"url":"https://github.com/comake/shacl-to-json-schema/issues"},"dist":{"shasum":"b7a55ecc7833b8a9597bdf41cd80c1ca0dbe5766","tarball":"https://registry.npmjs.org/@comake/shacl-to-json-schema/-/shacl-to-json-schema-1.0.2.tgz","fileCount":20,"integrity":"sha512-JFz4PDCrBVA2fc1SfyLhkMXeF5r02vyLHgj0LkECOnwJvFmeWj5vWsHWu3iVE1vD9sgiffDFq+Mx803NboMZcw==","signatures":[{"sig":"MEUCIFuS8wbFL7YsbA7Md3J9xEPVhDOjhPh748nNpv50/+unAiEAlen9JQ+R77MbhIHKO+ePbEZ82IyVQpao6vnbTTwbVPA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38120},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"1ebe7235395ffc0d70df16bc98cd752378a9fba8","scripts":{"jest":"jest --coverage","test":"npm run test:ts && npm run jest","build":"tsc","prepare":"npm run build","test:ts":"tsc -p test --noEmit","test:integration":"jest --coverageReporters text-summary -- test/integration"},"_npmUser":{"name":"adlerfaulkner","email":"adler@comake.io"},"repository":{"url":"git+https://github.com/comake/shacl-to-json-schema.git","type":"git"},"_npmVersion":"8.15.0","description":"This is a simple library to translate SHACL NodeShapes into JSON Schemas. It does not support the full SHACL vocabulary, only those fields which can be applied to JSON Schema.","directories":{},"_nodeVersion":"16.17.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.6.1","eslint":"^8.31.0","ts-jest":"^29.1.1","typescript":"^4.9.4","@types/jest":"^29.5.2","@types/node":"^18.11.18","@types/jsonld":"^1.5.9","@tsconfig/node16":"^1.0.3","eslint-config-es":"4.1.0","eslint-plugin-jest":"^27.2.2","eslint-plugin-tsdoc":"^0.2.17","eslint-plugin-import":"^2.25.2","@typescript-eslint/parser":"^5.4.0","eslint-plugin-unused-imports":"^2.0.0","eslint-plugin-eslint-comments":"^3.2.0","@typescript-eslint/eslint-plugin":"^5.3.0","eslint-import-resolver-typescript":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/shacl-to-json-schema_1.0.2_1689283904220_0.8381812631548322","host":"s3://npm-registry-packages"}},"1.0.3":{"name":"@comake/shacl-to-json-schema","version":"1.0.3","keywords":["shacl","json-schema","converter","rdf","json"],"author":{"name":"Adler Faulkner","email":"adler@comake.io"},"license":"MIT","_id":"@comake/shacl-to-json-schema@1.0.3","maintainers":[{"name":"adlerfaulkner","email":"adler@comake.io"}],"homepage":"https://github.com/comake/shacl-to-json-schema#readme","bugs":{"url":"https://github.com/comake/shacl-to-json-schema/issues"},"dist":{"shasum":"231ab6ae01699ffba54c9397dd06bdb5f94f63a7","tarball":"https://registry.npmjs.org/@comake/shacl-to-json-schema/-/shacl-to-json-schema-1.0.3.tgz","fileCount":20,"integrity":"sha512-AWnOuWIXKEpsXDKKKgzvkJpgRQ4thNorjt8JGBhw9bzstTp6H5dUz4aCORe9fIXYkWK9FLC8YZPlxR2oT6+4GA==","signatures":[{"sig":"MEYCIQCjIjTX0SNLIJYcSp8y78woggrGpkF+m/rMipD7KBW2PAIhAKSu5euj0oO468MVnHyyqHRUiQFhiMripfXJlpaA2ase","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":38355},"main":"./dist/index.js","types":"./dist/index.d.ts","gitHead":"054e9dda8d7222b0da3b9fbc3e1dfd0ad8cef32d","scripts":{"jest":"jest --coverage","test":"npm run test:ts && npm run jest","build":"tsc","prepare":"npm run build","test:ts":"tsc -p test --noEmit","test:integration":"jest --coverageReporters text-summary -- test/integration"},"_npmUser":{"name":"adlerfaulkner","email":"adler@comake.io"},"repository":{"url":"git+https://github.com/comake/shacl-to-json-schema.git","type":"git"},"_npmVersion":"8.15.0","description":"This is a simple library to translate SHACL NodeShapes into JSON Schemas. It does not support the full SHACL vocabulary, only those fields which can be applied to JSON Schema.","directories":{},"_nodeVersion":"16.17.0","_hasShrinkwrap":false,"devDependencies":{"jest":"^29.6.1","eslint":"^8.31.0","ts-jest":"^29.1.1","typescript":"^4.9.4","@types/jest":"^29.5.2","@types/node":"^18.11.18","@types/jsonld":"^1.5.9","@tsconfig/node16":"^1.0.3","eslint-config-es":"4.1.0","eslint-plugin-jest":"^27.2.2","eslint-plugin-tsdoc":"^0.2.17","eslint-plugin-import":"^2.25.2","@typescript-eslint/parser":"^5.4.0","eslint-plugin-unused-imports":"^2.0.0","eslint-plugin-eslint-comments":"^3.2.0","@typescript-eslint/eslint-plugin":"^5.3.0","eslint-import-resolver-typescript":"^3.2.5"},"_npmOperationalInternal":{"tmp":"tmp/shacl-to-json-schema_1.0.3_1696556645360_0.6813307194375458","host":"s3://npm-registry-packages"}}},"time":{"created":"2023-07-13T20:04:25.704Z","modified":"2025-05-13T17:23:21.326Z","1.0.0":"2023-07-13T20:04:26.031Z","1.0.1":"2023-07-13T20:12:18.210Z","1.0.2":"2023-07-13T21:31:44.413Z","1.0.3":"2023-10-06T01:44:05.545Z"},"bugs":{"url":"https://github.com/comake/shacl-to-json-schema/issues"},"author":{"name":"Adler Faulkner","email":"adler@comake.io"},"license":"MIT","homepage":"https://github.com/comake/shacl-to-json-schema#readme","keywords":["shacl","json-schema","converter","rdf","json"],"repository":{"url":"git+https://github.com/comake/shacl-to-json-schema.git","type":"git"},"description":"This is a simple library to translate SHACL NodeShapes into JSON Schemas. It does not support the full SHACL vocabulary, only those fields which can be applied to JSON Schema.","maintainers":[{"email":"avneesh@comake.io","name":"comkeavneesh"},{"email":"andres@comake.io","name":"aeg72"},{"email":"mahesh@comake.io","name":"maheshcomake"}],"readme":"# SHACL To JSON Schema\n\nThis is a simple library to translate SHACL NodeShapes into JSON Schemas. It does not support the full SHACL vocabulary, only those fields which can be applied to JSON Schema.\n\n## Install\n\n```shell\nnpm install @comake/shacl-to-json-schema\n```\n\n## Usage\n\nThe `nodeShapeToJSONSchema` function exported by this library supports converting SHACL NodeShapes encoded as JSON-LD into JSON Schema.\n\nFor example, using Typescript:\n```ts\nimport { nodeShapeToJSONSchema } from '@comake/shacl-to-json-schema';\n\nconst nodeShape = {\n  '@type': 'shacl:NodeShape',\n  'http://www.w3.org/ns/shacl#targetClass': 'https://example.com/Class',\n  'http://www.w3.org/ns/shacl#property': [\n    {\n      'http://www.w3.org/ns/shacl#datatype': {\n        '@id': 'http://www.w3.org/2001/XMLSchema#string'\n      },\n      'http://www.w3.org/ns/shacl#maxCount': {\n        '@value': 1,\n        '@type': 'http://www.w3.org/2001/XMLSchema#integer'\n      },\n      'http://www.w3.org/ns/shacl#name': {\n        '@value': 'field',\n        '@type': 'http://www.w3.org/2001/XMLSchema#string'\n      }\n      'http://www.w3.org/ns/shacl#path': {\n        '@id': 'https://example.com/field'\n      }\n    }\n  ]\n};\n\nconst schema = nodeShapeToJSONSchema(nodeShape);\nconsole.log(schema);\n\n// Output:\n// {\n//   type: 'object',\n//   properties: {\n//     'https://example.com/field': { \n//       type: 'string'\n//     }\n//   }\n// }\n```\n\nBy default the `shacl:path` of each property will be used as the property key in the resulting JSON Schema. If instead you need the generated JSON Schema to use the `shacl:name` field as property keys, set the `useNames` option to `true`:\n\n```ts\nconst schema = nodeShapeToJSONSchema(nodeShape, { useNames: true });\nconsole.log(schema);\n\n// Output:\n// {\n//   type: 'object',\n//   properties: {\n//     field: {   <---- Uses \"field\" instead of \"https://example.com/field\"\n//       type: 'string'\n//     }\n//   }\n// }\n```\n\n\n\n## Support\n\nCurrently this library only supports properties that include a `shacl:datatype`, `shacl:node`, or `shacl:nodeKind`.\n\nSupported `shacl:datatype` values:\n- `xsd:string` generates a JSON Schema with type `string`\n- `xsd:integer` generates a JSON Schema with type `integer`\n- `xsd:negativeInteger` generates a JSON Schema with type `integer`\n- `xsd:positiveInteger` generates a JSON Schema with type `integer`\n- `xsd:int` generates a JSON Schema with type `integer`\n- `xsd:decimal` generates a JSON Schema with type `number`\n- `xsd:float` generates a JSON Schema with type `number`\n- `xsd:double` generates a JSON Schema with type `number`\n- `xsd:boolean` generates a JSON Schema with type `boolean`\n- `xsd:dateTime` generates a JSON Schema with type `string` and format `data-time`\n- `xsd:date` generates a JSON Schema with type `string` and format `date`\n- `xsd:time` generates a JSON Schema with type `string` and format `time`\n- `rdf:JSON` generates a JSON Schema with type `string`, `number`, `boolean`, `object`, or `array`\n\nSupported `shacl:nodeKind` values:\n- `sh:BlankNode` generates a JSON Schema with type `object`\n- `sh:IRI` generates a JSON Schema with type `string`\n- `sh:Literal` generates a JSON Schema with type `string`, `number`, `boolean`, `object`, or `array`\n- `sh:BlankNodeOrIRI` generates a JSON Schema with type `string` or `object`\n- `sh:BlankNodeOrLiteral` generates a JSON Schema with type `string`, `number`, `boolean`, `object`, or `array`\n- `sh:IRIOrLiteral` generates a JSON Schema with type `string`, `number`, `boolean`, `object`, or `array`\n\nSupport for `shacl:maxLength`, which adds `maxLength` to the resulting JSON Schema property when the `shacl:datatype` is one of:\n- `xsd:string`\n- `xsd:dateTime`\n- `xsd:date`\n- `xsd:time`\n\nSupport for `shacl:in` for all datatypes, which produces a JSON Schema `enum`\n\nSupport for `shacl:minExclusive`, `shacl:minInclusive`, `shacl:maxExclusive`, `shacl:maxInclusive` for all numeric datatypes\n\nOptional support for `shacl:name` and `shacl:description` when the options `addTitles` or `addDescriptions` are set to `true`, respectively. Doing so will add JSON Schema `title` and `description` to the resulting properties.\n\nSupport for `shacl:minCount` and `shacl:maxCount`:\n- If `shacl:maxCount` is unset or greater than 1, the property will be treated as an array. If so, `shacl:maxCount` and `shacl:minCount` values are used to set `maxItems` and `minItems` in the resulting JSON Schema.\n- If `shacl:minCount` is greater than 0, the property will be required in the resulting JSON Schema\n\nSupport for `shacl:closed`. When true, the resulting JSON Schema will have `additionalProperties` set to false.\n\n## Not Supported\n\nNo support for SHACL predicates `shacl:lessThanOrEquals`, `shacl:lessThan`, `shacl:flag`, `shacl:equal`, `shacl:class`, and `shacl:languageIn`.\n\nThere is also currently no support for complex SHACL Property Paths including Sequence Paths, Alternative Paths, Inverse Paths, Zero-Or-More Paths, One-Or-More Paths, and Zero-Or-One Paths.\n\n## API\n\n### nodeShapeToJSONSchema\n\nConverts SHACL NodeShapes encoded as JSON-LD into JSON Schema.\n\n#### Parameters\n\n| Parameter | Type | Required | Description |\n| :--- | :--- | :--- | :--- |\n| `shape` | `JSON` | Required | The SHACL NodeShape to convert encoded as JSON-LD. |\n| `options` | `object` |  | A `ConversionOptions` object (see below).  |\n\n#### ConversionOptions\n\nThese are the available options to configure the behavior of the conversion (in Typescript):\n\n```ts\ninterface ConversionOptions {\n  /**\n   * When true, the names of fields in the generated JSON Schema \n   * will use the shacl:name of each property instead of the shacl:path uri\n   */\n  useNames?: boolean;\n  /**\n   * When true, each field will include a title equal \n   * to it's corresponding property's shacl:name\n   */\n  addTitles?: boolean;\n  /**\n   * When true, each field will include a description equal \n   * to it's corresponding property's shacl:description\n   */\n  addDescriptions?: boolean;\n}\n```\n\n#### Return Value\n\nA JSON Schema object","readmeFilename":"README.md"}