{"name":"@ts-graphviz/common","version":"3.0.2","keywords":["graphviz","dot"],"author":{"name":"Yuki Yamazaki","email":"yuki@kamiazya.tech"},"license":"MIT","_id":"@ts-graphviz/common@3.0.2","maintainers":[{"name":"kamiazya","email":"yuki@kamiazya.tech"}],"homepage":"https://github.com/ts-graphviz/ts-graphviz#readme","bugs":{"url":"https://github.com/ts-graphviz/ts-graphviz/issues"},"dist":{"shasum":"44e02a0718f45fe1e27502f6d3f02140466c57a5","tarball":"http://registry-npm.ywwl.com/@ts-graphviz/common/download/@ts-graphviz/common-3.0.2.tgz","fileCount":6,"integrity":"sha512-eizqQAfOePiZ2bt5NYYXDmTs/tlYVgVPvTKfXDeFNhGH5RfSCGQ0xX/UjKG+zNrwaCSXhWCDJlIon1zc4Gi/bw==","signatures":[{"sig":"MEYCIQCMKrqHo56OnJdroYCnkF4Fj573k1iM5bSFcKVGUWF0eQIhAIMNTY8GBIYH+x1rOKa/lm4PNB6h4Of86vbW8vOHqj5Z","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@ts-graphviz%2fcommon@3.0.2","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":253854,"size":48913,"noattachment":false,"key":"/@ts-graphviz/common/-/@ts-graphviz/common-3.0.2.tgz"},"type":"module","_from":"file:ts-graphviz-common-3.0.2.tgz","types":"lib/common.d.ts","module":"lib/common.js","engines":{"node":">=20"},"exports":{".":{"types":"./lib/common.d.ts","default":"./lib/common.js"},"./package.json":"./package.json"},"funding":[{"url":"https://github.com/sponsors/ts-graphviz","type":"github"},{"url":"https://opencollective.com/ts-graphviz","type":"opencollective"}],"scripts":{"build":"vite build"},"_npmUser":{"name":"kamiazya","email":"yuki@kamiazya.tech"},"_resolved":"/tmp/9652669351963d772798e2fae6074269/ts-graphviz-common-3.0.2.tgz","_integrity":"sha512-eizqQAfOePiZ2bt5NYYXDmTs/tlYVgVPvTKfXDeFNhGH5RfSCGQ0xX/UjKG+zNrwaCSXhWCDJlIon1zc4Gi/bw==","repository":{"url":"git+https://github.com/ts-graphviz/ts-graphviz.git","type":"git","directory":"packages/common"},"_npmVersion":"10.8.2","description":"Graphviz Types and Utilities","directories":{},"_nodeVersion":"20.19.5","publishConfig":{"access":"public","provenance":true},"_hasShrinkwrap":false,"devDependencies":{"vite":"^7.0.2","typescript":"^5.8.2","vite-plugin-dts":"^4.5.3"},"_npmOperationalInternal":{"tmp":"tmp/common_3.0.2_1759594767543_0.8359962379083155","host":"s3://npm-registry-packages-npm-production"},"readme":"<div align=\"center\">\n\n[![Main](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/main.yaml/badge.svg)](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/main.yaml)\n[![CodeQL](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ts-graphviz/ts-graphviz/actions/workflows/codeql-analysis.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE)\n[![All Contributors](https://img.shields.io/github/all-contributors/ts-graphviz/ts-graphviz?color=orange)](#contributors-)\n\n[![OpenSSF Best Practices](https://www.bestpractices.dev/projects/8396/badge)](https://www.bestpractices.dev/projects/8396)\n[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/ts-graphviz/ts-graphviz/badge)](https://scorecard.dev/viewer/?uri=github.com/ts-graphviz/ts-graphviz)\n[![Tidelift](https://tidelift.com/badges/package/npm/ts-graphviz?style=flat)](https://tidelift.com/subscription/pkg/npm-ts-graphviz?utm_source=npm-ts-graphviz&utm_medium=readme)\n\n[![npm version](https://badge.fury.io/js/ts-graphviz.svg)](https://badge.fury.io/js/ts-graphviz)\n![node version](https://img.shields.io/node/v/ts-graphviz)\n[![deno version](https://img.shields.io/badge/deno-lts-black?logo=deno)](https://github.com/denoland/deno)\n[![npm](https://img.shields.io/npm/dm/ts-graphviz)](https://npmtrends.com/ts-graphviz)\n\n# @ts-graphviz/common\n\nType information, constants, and utility functions related to the DOT language attributes, attribute values, and models for ts-graphviz.\n\n🔗\n\n[![GitHub](https://img.shields.io/badge/-GitHub-181717?logo=GitHub&style=flat)](https://github.com/ts-graphviz/ts-graphviz)\n[![npm](https://img.shields.io/badge/-npm-CB3837?logo=npm&style=flat)](https://www.npmjs.com/package/ts-graphviz)\n[![Reference](https://img.shields.io/badge/-API_Reference-3178C6?logo=TypeScript&style=flat&logoColor=fff)](https://ts-graphviz.github.io/ts-graphviz/)\n[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/ts-graphviz/ts-graphviz)\n\n[![Sponsor](https://img.shields.io/badge/-GitHub%20Sponsor-fff?logo=GitHub%20Sponsors&style=flat)](https://github.com/sponsors/ts-graphviz)\n[![OpenCollective](https://img.shields.io/badge/-OpenCollective-7FADF2?logo=opencollective&style=flat&logoColor=white)](https://opencollective.com/ts-graphviz)\n\n[![format: Biome](https://img.shields.io/badge/format%20with-Biome-F7B911?logo=biome&style=flat)](https://biomejs.dev/)\n[![test: Vitest](https://img.shields.io/badge/tested%20with-Vitest-6E9F18?logo=vitest&style=flat)](https://vitest.dev/)\n[![build: Vite](https://img.shields.io/badge/build%20with-Vite-646CFF?logo=vite&style=flat)](https://rollupjs.org/)\n\n</div>\n\n---\n\n> It is part of the ts-graphviz library, which is split into modular packages to improve maintainability, flexibility, and ease of use.\n\n## Features\n\n- **Type definitions** for DOT language elements, including attributes and attribute values\n- **Constants** representing common attribute names and values\n- **Comprehensive type guards** for runtime type checking and TypeScript type narrowing\n- **Node reference utilities** for parsing and converting complex node references\n- **Performance-optimized utilities** for working with large model collections\n- **Seamless integration** with @ts-graphviz/react for type-safe model filtering\n- **Dual-mode type handling** - runtime validation or trusted user assertions\n\n## Usage\n\n### Basic Type Definitions\n\nImport the necessary types, constants, or utility functions from the `@ts-graphviz/common` package:\n\n```ts\nimport {\n  NodeAttributesObject,\n  EdgeAttributesObject,\n  isNodeModel,\n  isEdgeModel,\n  toNodeRef\n} from '@ts-graphviz/common';\n```\n\n### Type-Safe Model Operations\n\nThe package excels at providing type safety for graph model operations:\n\n\n```ts\nconst nodeAttr: NodeAttributesObject = {\n  label: 'Node label',\n  shape: 'ellipse',\n};\n\nconst edgeAttr: EdgeAttributesObject = {\n  label: 'Edge label',\n  color: 'red',\n};\n```\n\n### Type Guards and Model Utilities\n\nThe package provides powerful type guards for working with graph models with full TypeScript integration:\n\n```ts\nimport {\n  isNodeModel,\n  isEdgeModel,\n  isRootGraphModel,\n  isSubgraphModel,\n  isAttributeListModel\n} from '@ts-graphviz/common';\n\n// Type-safe model checking\nif (isNodeModel(someModel)) {\n  // TypeScript knows someModel is NodeModel\n  console.log(someModel.id);\n}\n\nif (isEdgeModel(someModel)) {\n  // TypeScript knows someModel is EdgeModel\n  console.log(someModel.targets);\n}\n```\n\n### Node Reference Utilities\n\nUtilities for working with node references and compass directions:\n\n```ts\nimport {\n  isNodeRef,\n  isNodeRefLike,\n  isCompass,\n  toNodeRef,\n  toNodeRefGroup\n} from '@ts-graphviz/common';\n\n// Check if a value is a valid node reference\nif (isNodeRefLike('node1:port:n')) {\n  const nodeRef = toNodeRef('node1:port:n');\n  console.log(nodeRef); // { id: 'node1', port: 'port', compass: 'n' }\n}\n\n// Convert multiple node references\nconst targets = toNodeRefGroup(['node1', 'node2:port', 'node3::s']);\nconsole.log(targets);\n// [\n//   { id: 'node1' },\n//   { id: 'node2', port: 'port' },\n//   { id: 'node3', port: '', compass: 's' }\n// ]\n\n// Validate compass directions\nif (isCompass('ne')) {\n  console.log('Valid compass direction');\n}\n```\n\n### Advanced Type Checking\n\nThe package provides additional utilities for complex type checking scenarios:\n\n```ts\nimport {\n  isForwardRefNode,\n  isNodeRefGroupLike,\n  isNodeRef,\n  isNodeRefLike,\n  FilterableModel\n} from '@ts-graphviz/common';\n\n// Check for forward reference nodes\nconst forwardRef = { id: 'futureNode' };\nif (isForwardRefNode(forwardRef)) {\n  console.log('Valid forward reference');\n}\n\n// Validate arrays of node references\nconst targets = ['node1', 'node2:port'];\nif (isNodeRefGroupLike(targets)) {\n  const nodeRefs = toNodeRefGroup(targets);\n  // Process validated node references\n}\n```\n\nFor more examples and usage details, please refer to the ts-graphviz documentation.\n\n## Contributors 👥\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n  <tbody>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"http://blog.kamiazya.tech/\"><img src=\"https://avatars0.githubusercontent.com/u/35218186?v=4?s=100\" width=\"100px;\" alt=\"Yuki Yamazaki\"/><br /><sub><b>Yuki Yamazaki</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=kamiazya\" title=\"Code\">💻</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=kamiazya\" title=\"Tests\">⚠️</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=kamiazya\" title=\"Documentation\">📖</a> <a href=\"#ideas-kamiazya\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://laysent.com\"><img src=\"https://avatars2.githubusercontent.com/u/1191606?v=4?s=100\" width=\"100px;\" alt=\"LaySent\"/><br /><sub><b>LaySent</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Alaysent\" title=\"Bug reports\">🐛</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=laysent\" title=\"Tests\">⚠️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/elasticdotventures\"><img src=\"https://avatars0.githubusercontent.com/u/35611074?v=4?s=100\" width=\"100px;\" alt=\"elasticdotventures\"/><br /><sub><b>elasticdotventures</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=elasticdotventures\" title=\"Documentation\">📖</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/ChristianMurphy\"><img src=\"https://avatars.githubusercontent.com/u/3107513?v=4?s=100\" width=\"100px;\" alt=\"Christian Murphy\"/><br /><sub><b>Christian Murphy</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=ChristianMurphy\" title=\"Code\">💻</a> <a href=\"#ideas-ChristianMurphy\" title=\"Ideas, Planning, & Feedback\">🤔</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=ChristianMurphy\" title=\"Documentation\">📖</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/ArtemAdamenko\"><img src=\"https://avatars.githubusercontent.com/u/2178516?v=4?s=100\" width=\"100px;\" alt=\"Artem\"/><br /><sub><b>Artem</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3AArtemAdamenko\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/fredericohpandolfo\"><img src=\"https://avatars.githubusercontent.com/u/24229136?v=4?s=100\" width=\"100px;\" alt=\"fredericohpandolfo\"/><br /><sub><b>fredericohpandolfo</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Afredericohpandolfo\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/diegoquinteiro\"><img src=\"https://avatars.githubusercontent.com/u/1878108?v=4?s=100\" width=\"100px;\" alt=\"diegoquinteiro\"/><br /><sub><b>diegoquinteiro</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Adiegoquinteiro\" title=\"Bug reports\">🐛</a></td>\n    </tr>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/robross0606\"><img src=\"https://avatars.githubusercontent.com/u/2965467?v=4?s=100\" width=\"100px;\" alt=\"robross0606\"/><br /><sub><b>robross0606</b></sub></a><br /><a href=\"#ideas-robross0606\" title=\"Ideas, Planning, & Feedback\">🤔</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://blake-regalia.net\"><img src=\"https://avatars.githubusercontent.com/u/1456400?v=4?s=100\" width=\"100px;\" alt=\"Blake Regalia\"/><br /><sub><b>Blake Regalia</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Ablake-regalia\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/bigbug\"><img src=\"https://avatars.githubusercontent.com/u/27259?v=4?s=100\" width=\"100px;\" alt=\"bigbug\"/><br /><sub><b>bigbug</b></sub></a><br /><a href=\"#question-bigbug\" title=\"Answering Questions\">💬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/murawakimitsuhiro\"><img src=\"https://avatars.githubusercontent.com/u/13833242?v=4?s=100\" width=\"100px;\" alt=\"mrwk\"/><br /><sub><b>mrwk</b></sub></a><br /><a href=\"#question-murawakimitsuhiro\" title=\"Answering Questions\">💬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/svdvonde\"><img src=\"https://avatars.githubusercontent.com/u/2751783?v=4?s=100\" width=\"100px;\" alt=\"svdvonde\"/><br /><sub><b>svdvonde</b></sub></a><br /><a href=\"#question-svdvonde\" title=\"Answering Questions\">💬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/seethroughdev\"><img src=\"https://avatars.githubusercontent.com/u/203779?v=4?s=100\" width=\"100px;\" alt=\"Adam\"/><br /><sub><b>Adam</b></sub></a><br /><a href=\"#question-seethroughdev\" title=\"Answering Questions\">💬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/trevor-scheer\"><img src=\"https://avatars.githubusercontent.com/u/29644393?v=4?s=100\" width=\"100px;\" alt=\"Trevor Scheer\"/><br /><sub><b>Trevor Scheer</b></sub></a><br /><a href=\"#a11y-trevor-scheer\" title=\"Accessibility\">️️️️♿️</a></td>\n    </tr>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://pre.ms\"><img src=\"https://avatars.githubusercontent.com/u/238277?v=4?s=100\" width=\"100px;\" alt=\"Prem Pillai\"/><br /><sub><b>Prem Pillai</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Acloud-on-prem\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/nagasawaryoya\"><img src=\"https://avatars.githubusercontent.com/u/53528726?v=4?s=100\" width=\"100px;\" alt=\"nagasawaryoya\"/><br /><sub><b>nagasawaryoya</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=nagasawaryoya\" title=\"Code\">💻</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=nagasawaryoya\" title=\"Tests\">⚠️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/tokidrill\"><img src=\"https://avatars.githubusercontent.com/u/42460318?v=4?s=100\" width=\"100px;\" alt=\"YukiSasaki\"/><br /><sub><b>YukiSasaki</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=tokidrill\" title=\"Code\">💻</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/commits?author=tokidrill\" title=\"Tests\">⚠️</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/Madd0g\"><img src=\"https://avatars.githubusercontent.com/u/1171003?v=4?s=100\" width=\"100px;\" alt=\"Madd0g\"/><br /><sub><b>Madd0g</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3AMadd0g\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/j4k0xb\"><img src=\"https://avatars.githubusercontent.com/u/55899582?v=4?s=100\" width=\"100px;\" alt=\"j4k0xb\"/><br /><sub><b>j4k0xb</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Aj4k0xb\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/haved\"><img src=\"https://avatars.githubusercontent.com/u/3748845?v=4?s=100\" width=\"100px;\" alt=\"HKrogstie\"/><br /><sub><b>HKrogstie</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Ahaved\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/septatrix\"><img src=\"https://avatars.githubusercontent.com/u/24257556?v=4?s=100\" width=\"100px;\" alt=\"Nils K\"/><br /><sub><b>Nils K</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Aseptatrix\" title=\"Bug reports\">🐛</a></td>\n    </tr>\n    <tr>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/hao2013\"><img src=\"https://avatars.githubusercontent.com/u/67059492?v=4?s=100\" width=\"100px;\" alt=\"hao2013\"/><br /><sub><b>hao2013</b></sub></a><br /><a href=\"#maintenance-hao2013\" title=\"Maintenance\">🚧</a> <a href=\"https://github.com/ts-graphviz/ts-graphviz/pulls?q=is%3Apr+reviewed-by%3Ahao2013\" title=\"Reviewed Pull Requests\">👀</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"http://www.walterra.dev\"><img src=\"https://avatars.githubusercontent.com/u/230104?v=4?s=100\" width=\"100px;\" alt=\"Walter Rafelsberger\"/><br /><sub><b>Walter Rafelsberger</b></sub></a><br /><a href=\"#question-walterra\" title=\"Answering Questions\">💬</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/grsjst\"><img src=\"https://avatars.githubusercontent.com/u/4739018?v=4?s=100\" width=\"100px;\" alt=\"grsjst\"/><br /><sub><b>grsjst</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Agrsjst\" title=\"Bug reports\">🐛</a></td>\n      <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/stephenirven\"><img src=\"https://avatars.githubusercontent.com/u/4293560?v=4?s=100\" width=\"100px;\" alt=\"Steve\"/><br /><sub><b>Steve</b></sub></a><br /><a href=\"https://github.com/ts-graphviz/ts-graphviz/issues?q=author%3Astephenirven\" title=\"Bug reports\">🐛</a></td>\n    </tr>\n  </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors)\nspecification. Contributions of any kind welcome!\n\n## Changelog 📜\n\nSee [CHANGELOG.md](https://github.com/ts-graphviz/ts-graphviz/blob/main/packages/common/CHANGELOG.md) for more details.\n\n## License ⚖️\n\nThis software is released under the MIT License, see [LICENSE](https://github.com/ts-graphviz/ts-graphviz/blob/main/LICENSE).\n","publish_time":1759594767772,"_cnpm_publish_time":1759594767772,"dist-tags":{"develop":"0.0.0-pr956-20240225163634","latest":"3.0.7","next":"3.0.7-next-25c9dd3bd549e8cd4fd0d200c83e8a436ea579e5"}}