{"_id":"@inixiative/prisma-map","_rev":"7-78cbdf7bc9bb9202909f8cf3a15e9dbc","name":"@inixiative/prisma-map","dist-tags":{"latest":"0.2.0"},"versions":{"0.0.1":{"name":"@inixiative/prisma-map","version":"0.0.1","keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"author":{"name":"Aron Greenspan"},"license":"MIT","_id":"@inixiative/prisma-map@0.0.1","maintainers":[{"name":"inixiative","email":"aron.greenspan@inixiative.com"}],"homepage":"https://github.com/inixiative/prisma-map#readme","bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"dist":{"shasum":"0bd4f530e7e7a438673eec55a7e4c96b6771949f","tarball":"https://registry.npmjs.org/@inixiative/prisma-map/-/prisma-map-0.0.1.tgz","fileCount":33,"integrity":"sha512-/X9HUzWid1XoxjnE1mNI46lkMNzMP65sTkYZndMsS32T+/6kT6RFs27soIU6LJOn5orqLE1103K2DSfo6Wup8w==","signatures":[{"sig":"MEYCIQDAGU8GzkyjSwUTiGpiM7ookJm37ri3Raa7NhK6tbm+GgIhAJr/1UVlDuFEadstpaJgCko2zYQ+vbyuLMgG49gfv3u1","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122134},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./v6":{"types":"./dist/v6/index.d.ts","import":"./dist/v6/index.js","require":"./dist/v6/index.cjs"},"./v7":{"types":"./dist/v7/index.d.ts","import":"./dist/v7/index.js","require":"./dist/v7/index.cjs"}},"gitHead":"11f1963b8af23fe1150be2c932c36ae16f9cba66","scripts":{"lint":"biome check .","test":"bun test","build":"tsup","check":"bun run typecheck && bun run lint","format":"biome format --write .","prepare":"lefthook install","typecheck":"tsc --noEmit","prepublishOnly":"bun run check && bun run build"},"_npmUser":{"name":"inixiative","email":"aron.greenspan@inixiative.com"},"repository":{"url":"git+https://github.com/inixiative/prisma-map.git","type":"git"},"_npmVersion":"11.11.0","description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","directories":{},"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","lefthook":"^2.1.2","typescript":"^5.0.0","@types/node":"^25.3.5","@biomejs/biome":"^2.4.6"},"_npmOperationalInternal":{"tmp":"tmp/prisma-map_0.0.1_1772916329139_0.7076503145129713","host":"s3://npm-registry-packages-npm-production"}},"0.0.2":{"name":"@inixiative/prisma-map","version":"0.0.2","keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"author":{"name":"Aron Greenspan"},"license":"MIT","_id":"@inixiative/prisma-map@0.0.2","maintainers":[{"name":"inixiative","email":"aron.greenspan@inixiative.com"}],"homepage":"https://github.com/inixiative/prisma-map#readme","bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"dist":{"shasum":"165388709e5b726edf1554f7f4b7f1d5e52e4840","tarball":"https://registry.npmjs.org/@inixiative/prisma-map/-/prisma-map-0.0.2.tgz","fileCount":33,"integrity":"sha512-QVEuPHKDEYccSd/EFlJY7Q3jjyPkcHEoDHWTwUlw+fPAd8oqemciAR/1vy1FvU2jSge80winVv08DMPaYg2qgQ==","signatures":[{"sig":"MEQCIF0hcJvPl7MUfBCxMgZaz7OHZSJg8m+tsZCN80jHNN/IAiBnPUikIwHf8BnOmf5RqHEf/bhD/6XpENjIx01s8i4F+w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122242},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./v6":{"types":"./dist/v6/index.d.ts","import":"./dist/v6/index.js","require":"./dist/v6/index.cjs"},"./v7":{"types":"./dist/v7/index.d.ts","import":"./dist/v7/index.js","require":"./dist/v7/index.cjs"}},"gitHead":"62d12041258e162c4e61b9004706fab647629ebc","scripts":{"lint":"biome check .","test":"bun test","build":"tsup","check":"bun run typecheck && bun run lint","format":"biome format --write .","prepare":"lefthook install","typecheck":"tsc --noEmit","prepublishOnly":"bun run check && bun run build"},"_npmUser":{"name":"inixiative","email":"aron.greenspan@inixiative.com"},"repository":{"url":"git+https://github.com/inixiative/prisma-map.git","type":"git"},"_npmVersion":"11.11.0","description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","directories":{},"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","lefthook":"^2.1.2","typescript":"^5.0.0","@types/node":"^25.3.5","@biomejs/biome":"^2.4.6"},"_npmOperationalInternal":{"tmp":"tmp/prisma-map_0.0.2_1772916618617_0.22112040667583166","host":"s3://npm-registry-packages-npm-production"}},"0.0.3":{"name":"@inixiative/prisma-map","version":"0.0.3","keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"author":{"name":"Aron Greenspan"},"license":"MIT","_id":"@inixiative/prisma-map@0.0.3","maintainers":[{"name":"inixiative","email":"aron.greenspan@inixiative.com"}],"homepage":"https://github.com/inixiative/prisma-map#readme","bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"dist":{"shasum":"b2c842f748d7aad84b93936b80cde5962804842b","tarball":"https://registry.npmjs.org/@inixiative/prisma-map/-/prisma-map-0.0.3.tgz","fileCount":33,"integrity":"sha512-mQttgC5cX4nr5I+kibOwS2FpzYsbv0hdgSqAPj9nsJBIbwoJTxgGncJVUiKSGXl1h+OnSuP/mdbQb3fVdFP41Q==","signatures":[{"sig":"MEQCIHVsq0JwQN8/dq5q4pj5XSjOYuLhavs1zae8i2wPyefxAiBcJyb6+4RXB0fTd7J91Y4Sqmu/XpZ7vAUg0ywppQ4JHQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":122242},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./v6":{"types":"./dist/v6/index.d.ts","import":"./dist/v6/index.js","require":"./dist/v6/index.cjs"},"./v7":{"types":"./dist/v7/index.d.ts","import":"./dist/v7/index.js","require":"./dist/v7/index.cjs"}},"gitHead":"3cd249e3933e271985298f0c9b0cbda748a4349b","scripts":{"lint":"biome check .","test":"bun test","build":"tsup","check":"bun run typecheck && bun run lint","format":"biome format --write .","prepare":"lefthook install","typecheck":"tsc --noEmit","prepublishOnly":"bun run check && bun run build"},"_npmUser":{"name":"inixiative","email":"aron.greenspan@inixiative.com"},"repository":{"url":"git+https://github.com/inixiative/prisma-map.git","type":"git"},"_npmVersion":"11.11.0","description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","directories":{},"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","lefthook":"^2.1.2","typescript":"^5.0.0","@types/node":"^25.3.5","@biomejs/biome":"^2.4.6"},"_npmOperationalInternal":{"tmp":"tmp/prisma-map_0.0.3_1780750981892_0.4373716608022722","host":"s3://npm-registry-packages-npm-production"}},"0.0.4":{"name":"@inixiative/prisma-map","version":"0.0.4","keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"author":{"name":"Aron Greenspan"},"license":"MIT","_id":"@inixiative/prisma-map@0.0.4","maintainers":[{"name":"inixiative","email":"aron.greenspan@inixiative.com"}],"homepage":"https://github.com/inixiative/prisma-map#readme","bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"dist":{"shasum":"ba3bd0aa1b29829bdd1a70066b7f0c6a01123a62","tarball":"https://registry.npmjs.org/@inixiative/prisma-map/-/prisma-map-0.0.4.tgz","fileCount":33,"integrity":"sha512-Wdvr/ST3sCX+ZTfZwFNLiq1o3gW/sLcetOFngaKhblF+1kABkm14TQeNv9qqBJqdXbRVB//uRcKiDuQoaOIDSg==","signatures":[{"sig":"MEYCIQDX8Lqcg3nnl/uiVg81UJL2zUmMx1BVxipCb6mA3rnOuQIhAOSZiobh7ApPVqJ51yUiKDAFo6ufYFeziDXBkx5vx7Gi","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":136832},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./v6":{"types":"./dist/v6/index.d.ts","import":"./dist/v6/index.js","require":"./dist/v6/index.cjs"},"./v7":{"types":"./dist/v7/index.d.ts","import":"./dist/v7/index.js","require":"./dist/v7/index.cjs"}},"gitHead":"3cd249e3933e271985298f0c9b0cbda748a4349b","scripts":{"lint":"biome check .","test":"bun test","build":"tsup","check":"bun run typecheck && bun run lint","format":"biome format --write .","prepare":"lefthook install","typecheck":"tsc --noEmit","prepublishOnly":"bun run check && bun run build"},"_npmUser":{"name":"inixiative","email":"aron.greenspan@inixiative.com"},"repository":{"url":"git+https://github.com/inixiative/prisma-map.git","type":"git"},"_npmVersion":"11.11.0","description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","directories":{},"_nodeVersion":"22.12.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","lefthook":"^2.1.2","typescript":"^5.0.0","@types/node":"^25.3.5","@biomejs/biome":"^2.4.6"},"_npmOperationalInternal":{"tmp":"tmp/prisma-map_0.0.4_1780751401663_0.3861584425390312","host":"s3://npm-registry-packages-npm-production"}},"0.1.0":{"name":"@inixiative/prisma-map","version":"0.1.0","keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"author":{"name":"Aron Greenspan"},"license":"MIT","_id":"@inixiative/prisma-map@0.1.0","maintainers":[{"name":"inixiative","email":"aron.greenspan@inixiative.com"}],"homepage":"https://github.com/inixiative/prisma-map#readme","bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"dist":{"shasum":"3ac4ec157cd4e7dad6b795761987f4b837e82062","tarball":"https://registry.npmjs.org/@inixiative/prisma-map/-/prisma-map-0.1.0.tgz","fileCount":33,"integrity":"sha512-wb/Pc5q6SQvb3LrKR2Hz/SuYFnd9biyojnpd962bndq/Zjf1kUH8PdKxjQ0b532fm9Fw8SiDwRmsg/rY3KLjuw==","signatures":[{"sig":"MEYCIQDdWK+0YZaPqYQenOPxJDWY/zbUiOiOUWYmFBwB3V7B4AIhAKg9KxSqhVvhi9HFvlGIkAF5nsSHSwn3gwJgIYKim531","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":189618},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./v6":{"types":"./dist/v6/index.d.ts","import":"./dist/v6/index.js","require":"./dist/v6/index.cjs"},"./v7":{"types":"./dist/v7/index.d.ts","import":"./dist/v7/index.js","require":"./dist/v7/index.cjs"}},"gitHead":"747dc2599bab17ae04917b6671e487bc8240ee7a","scripts":{"lint":"biome check .","test":"bun test","build":"tsup","check":"bun run typecheck && bun run lint","format":"biome format --write .","prepare":"lefthook install","typecheck":"tsc --noEmit","prepublishOnly":"bun run check && bun run build"},"_npmUser":{"name":"inixiative","email":"aron.greenspan@inixiative.com"},"repository":{"url":"git+https://github.com/inixiative/prisma-map.git","type":"git"},"_npmVersion":"10.9.3","description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","directories":{},"_nodeVersion":"22.19.0","publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","lefthook":"^2.1.2","typescript":"^5.0.0","@types/node":"^25.3.5","@biomejs/biome":"^2.4.6"},"_npmOperationalInternal":{"tmp":"tmp/prisma-map_0.1.0_1781274118481_0.44826360222907113","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@inixiative/prisma-map","version":"0.2.0","description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","type":"module","main":"./dist/index.cjs","module":"./dist/index.js","types":"./dist/index.d.ts","scripts":{"build":"tsup","test":"bun test","typecheck":"tsc --noEmit -p tsconfig.check.json","lint":"biome check .","format":"biome format --write .","check":"bun run typecheck && bun run lint && bun run test","prepare":"lefthook install","prepublishOnly":"bun run check && bun run build"},"keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"author":{"name":"Aron Greenspan"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/inixiative/prisma-map.git"},"publishConfig":{"access":"public"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"},"./v7":{"types":"./dist/v7/index.d.ts","import":"./dist/v7/index.js","require":"./dist/v7/index.cjs"},"./v6":{"types":"./dist/v6/index.d.ts","import":"./dist/v6/index.js","require":"./dist/v6/index.cjs"}},"devDependencies":{"@biomejs/biome":"2.5.2","@inixiative/config":"^0.5.23","@types/bun":"1.3.14","@types/node":"^25.3.5","lefthook":"2.1.9","tsup":"8.5.1","typescript":"6.0.3"},"packageManager":"bun@1.3.14","_id":"@inixiative/prisma-map@0.2.0","gitHead":"124e8d83196c385301117912501c952b33dd7796","bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"homepage":"https://github.com/inixiative/prisma-map#readme","_nodeVersion":"22.19.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-8zXkKog5zQ4Chu/oJLzbDjY66FvPaf7f0ttuo4WBjtnXblnKdDkXvoqx0XDYlXvWllTCLxE0g9G/39N450PzYA==","shasum":"609c16a2b2f5e07128e9252caaa2bc5317f3317f","tarball":"https://registry.npmjs.org/@inixiative/prisma-map/-/prisma-map-0.2.0.tgz","fileCount":27,"unpackedSize":308070,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIAIvdEwCLkKgZQvt7RDbyxuY5zDcnQLnjNFQ4lxlxRrsAiB7wZhFGdx09l7ZAWHswPLFSPFBksY8ITqC2NZD0j40Kg=="}]},"_npmUser":{"name":"aron.inixiative","email":"aron.greenspan@inixiative.com"},"directories":{},"maintainers":[{"name":"aron.inixiative","email":"aron.greenspan@inixiative.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/prisma-map_0.2.0_1788275558758_0.4834104863897406"},"_hasShrinkwrap":false}},"time":{"created":"2026-03-07T20:45:29.060Z","modified":"2026-09-01T15:12:39.110Z","0.0.1":"2026-03-07T20:45:29.325Z","0.0.2":"2026-03-07T20:50:18.773Z","0.0.3":"2026-06-06T13:03:02.048Z","0.0.4":"2026-06-06T13:10:01.885Z","0.1.0":"2026-06-12T14:21:58.636Z","0.2.0":"2026-09-01T15:12:38.911Z"},"bugs":{"url":"https://github.com/inixiative/prisma-map/issues"},"author":{"name":"Aron Greenspan"},"license":"MIT","homepage":"https://github.com/inixiative/prisma-map#readme","keywords":["prisma","orm","schema","map","typescript","prisma-map","field-map"],"repository":{"type":"git","url":"git+https://github.com/inixiative/prisma-map.git"},"description":"Extracts a complete model map (fields, relations, FK info) from a Prisma generated client — supports v6 (schema.prisma) and v7 (runtimeDataModel)","maintainers":[{"name":"aron.inixiative","email":"aron.greenspan@inixiative.com"}],"readme":"# @inixiative/prisma-map\n\nExtract a structured, runtime-friendly model map from a Prisma generated client.\n\n`@inixiative/prisma-map` builds a `PrismaMap` object that includes:\n- Models and fields\n- Field kinds (`scalar`, `enum`, `object`)\n- Relation FK direction (`fromFields`, `toFields`)\n- Model DB table name (`@@map`) as `dbName`\n- Field DB column name (`@map`) as `dbName`\n- Enum values (ordered), with stored DB values (`@map` on members) as `valueDbNames`\n\nIt supports both Prisma client layouts:\n- Prisma v7: parse generated `internal/class.ts`\n- Prisma v6: parse generated `schema.prisma`\n\n## Installation\n\n```bash\nbun add @inixiative/prisma-map\n```\n\nor\n\n```bash\nnpm i @inixiative/prisma-map\n```\n\n## Quick Start\n\n### Prisma v7\n\n```ts\nimport { buildPrismaMapV7 } from '@inixiative/prisma-map';\n\nconst map = buildPrismaMapV7();\n// or: buildPrismaMapV7('/absolute/path/to/generated/client')\n\nconsole.log(map.User.fields.posts);\n```\n\n### Prisma v6\n\n```ts\nimport { buildPrismaMapV6 } from '@inixiative/prisma-map';\n\nconst map = buildPrismaMapV6();\n// or: buildPrismaMapV6('/absolute/path/to/generated/client')\n\nconsole.log(map.Post.fields.author);\n```\n\n## Output Shape\n\nThe library returns:\n\n```ts\ntype PrismaMap = Record<string, {\n  dbName: string | null;\n  fields: Record<string, ScalarField | EnumField | RelationField>;\n}>;\n```\n\n### Scalar field\n\n```json\n{\n  \"kind\": \"scalar\",\n  \"type\": \"String\",\n  \"isRequired\": true,\n  \"isList\": false,\n  \"isId\": false\n}\n```\n\n### Enum field\n\n```json\n{\n  \"kind\": \"enum\",\n  \"type\": \"UserRole\",\n  \"isRequired\": true,\n  \"isList\": false,\n  \"values\": [\"ADMIN\", \"USER\", \"GUEST\"]\n}\n```\n\n### Relation field\n\n```json\n{\n  \"kind\": \"object\",\n  \"type\": \"User\",\n  \"isList\": false,\n  \"isRequired\": true,\n  \"relationName\": \"AuthoredPosts\",\n  \"fromFields\": [\"authorId\"],\n  \"toFields\": [\"id\"]\n}\n```\n\n`fromFields`/`toFields` are empty arrays on back-relations.\n\n## Example End-to-End\n\nGiven:\n\n```prisma\nenum Role {\n  ADMIN\n  USER\n}\n\nmodel User {\n  id    String @id\n  role  Role\n  posts Post[]\n\n  @@map(\"users\")\n}\n\nmodel Post {\n  id       String @id\n  authorId String\n  author   User   @relation(\"AuthoredPosts\", fields: [authorId], references: [id])\n}\n```\n\nA representative map:\n\n```json\n{\n  \"User\": {\n    \"dbName\": \"users\",\n    \"fields\": {\n      \"id\": {\n        \"kind\": \"scalar\",\n        \"type\": \"String\",\n        \"isRequired\": true,\n        \"isList\": false,\n        \"isId\": true\n      },\n      \"role\": {\n        \"kind\": \"enum\",\n        \"type\": \"Role\",\n        \"isRequired\": true,\n        \"isList\": false,\n        \"values\": [\"ADMIN\", \"USER\"]\n      },\n      \"posts\": {\n        \"kind\": \"object\",\n        \"type\": \"Post\",\n        \"isList\": true,\n        \"isRequired\": true,\n        \"fromFields\": [],\n        \"toFields\": []\n      }\n    }\n  },\n  \"Post\": {\n    \"dbName\": null,\n    \"fields\": {\n      \"author\": {\n        \"kind\": \"object\",\n        \"type\": \"User\",\n        \"isList\": false,\n        \"isRequired\": true,\n        \"relationName\": \"AuthoredPosts\",\n        \"fromFields\": [\"authorId\"],\n        \"toFields\": [\"id\"]\n      }\n    }\n  }\n}\n```\n\n## API\n\nRoot exports:\n\n```ts\nimport {\n  buildPrismaMapV6,\n  buildPrismaMapV7,\n  getRelations,\n  relationForeignKey,\n  parseTagClasses,\n  type PrismaMap,\n  type ModelEntry,\n  type ModelField,\n  type ScalarField,\n  type EnumField,\n  type RelationField,\n  type IndexEntry,\n  type RelationInfo,\n  type Identifier,\n  type Annotations,\n} from '@inixiative/prisma-map';\n```\n\nVersion-specific exports:\n\n```ts\nimport { buildPrismaMapV7, parseRuntimeDataModel, parseInlineSchema, parseRelationFks, parseEnumValues, parseSchemaStructure } from '@inixiative/prisma-map/v7';\nimport { buildPrismaMapV6, parseSchemaText, buildFromSchemaFile } from '@inixiative/prisma-map/v6';\n```\n\n## Relation Traversal\n\n`getRelations(map, modelName)` lists a model's relation fields with their foreign\nkeys collapsed for lookup; `relationForeignKey(field)` does the collapse alone.\n\n```ts\nimport { getRelations } from '@inixiative/prisma-map';\n\ngetRelations(map, 'Inquiry');\n// [\n//   { relationName: 'organization', targetModel: 'Organization', isList: false,\n//     foreignKey: { id: 'organizationId' } },\n//   { relationName: 'parent', targetModel: 'Inquiry', isList: false,\n//     foreignKey: { id: 'parentId' }, annotations: { tree: { parent: true } } },\n//   { relationName: 'children', targetModel: 'Inquiry', isList: true, foreignKey: null },\n// ]\n```\n\n`foreignKey` is a bare field name for a single same-named pair, a\n`{ referencedField: localField }` map otherwise, and `null` for back-relations.\nFunctions are string-keyed — wrap them with your generated `ModelName` types if\nyou want typed accessors.\n\n## Annotation DSL (`/// @tagClass(key: value)`)\n\nPrisma rejects custom attributes, but preserves `///` doc comments into the\ngenerated client's `inlineSchema`. prisma-map parses a small, forward-looking DSL\nout of those comments and records it — domain-agnostically — under `annotations`.\n\n```prisma\nmodel Category {\n  id       String     @id\n  parentId String?\n  /// @tree(parent: true)\n  parent   Category?  @relation(\"tree\", fields: [parentId], references: [id])\n  children Category[] @relation(\"tree\")\n\n  /// @search(fuzzy: true)\n  @@index([name])\n}\n```\n\n```ts\nmap.Category.fields.parent.annotations; // { tree: { parent: true } }\nmap.Category.indexes;\n// [{ kind: 'index', fields: ['name'], annotations: { search: { fuzzy: true } } }]\n```\n\n- **Grammar:** `@<tagClass>(<key>: <value>, …)`; multiple tag classes per line allowed.\n- **Values:** `true`/`false` → boolean, numerics → number, `\"quoted\"`/bare words → string, `[a, b]` → array.\n- **Placement:** a `///` run binds to the declaration directly below it — a model, a field, or an index (`@@index` / `@@unique` / `@@id` / `@@fulltext`). A blank line or a plain `//` breaks the binding.\n- prisma-map only records the bag; what a tag class *means* (e.g. `tree.parent` → \"don't auto-recurse up this self-relation\") is the consumer's to decide.\n\n## Auto-Detection Behavior\n\nIf you omit the path, the library walks upward from `process.cwd()` and checks common generated client locations:\n\n- `node_modules/.prisma/client`\n- `node_modules/@prisma/client`\n- `prisma/generated/client`\n- `src/generated/client`\n- `src/generated/prisma`\n- `generated/client`\n\nv7 detection requires `internal/class.ts`.\nv6 detection requires `schema.prisma` and excludes directories that also have `internal/class.ts`.\n\n## Practical Use Cases\n\n- Build rule-engine metadata for JSON rules\n- Resolve template/package dependency graphs via relation edges\n- Generate guardrails (for example, \"entity X must include relation Y\")\n- Build field-level introspection UIs\n\n## Resolving DB identifiers\n\n`map.X.fields.y` is a `ModelField` union, so narrow it first — relation fields have\nno column and the resolvers reject them at compile time:\n\n```ts\nimport {\n  columnName,\n  hasColumn,\n  isEnumField,\n  storedValue,\n  tableName,\n  type DbIdentifier,\n  type DbValue,\n} from '@inixiative/prisma-map';\n\nconst model = map.BrandMissions;\n\ntableName(model, 'BrandMissions'); // '@@map' if set, else 'BrandMissions'\n\nconst createdAt = model.fields.createdAt;\nif (hasColumn(createdAt)) {\n  columnName(createdAt, 'createdAt'); // 'created_at' via '@map'\n}\n\nconst typeName = model.fields.typeName;\nif (isEnumField(typeName)) {\n  storedValue(typeName, 'SOCIAL_POST'); // 'Social Post' via '@map' on the member\n  storedValue(typeName, 'UNMAPPED'); // 'UNMAPPED' — no '@map', the name is the value\n}\n```\n\nThe resolvers return branded `DbIdentifier` / `DbValue` rather than bare `string`. Both\nsurfaces are strings, so a mix-up otherwise produces valid SQL that silently matches no\nrows. Type a SQL builder's parameters as the brands and a raw Prisma name becomes a\ncompile error:\n\n```ts\nconst eq = (column: DbIdentifier, value: DbValue) => `${column} = '${value}'`;\n\neq('missionTypeName', 'SOCIAL_POST'); // compile error — raw Prisma names rejected\n```\n\n## Notes and Limits\n\n- Every key in the map is the **Prisma** name — `map.User`, `map.User.fields.createdAt`,\n  and the entries of `values`. `dbName` / `valueDbNames` are the only crossings to the\n  physical DB surface, and both are sparse: absent means the Prisma name IS the DB\n  identifier. Resolve them with `tableName` / `columnName` / `storedValue` rather than\n  open-coding `?? name` — a missed fallback fails silently (comparing against an unmapped\n  enum member selects zero rows instead of erroring).\n- `@@map` on a model is emitted as `ModelEntry.dbName`; `@map` on a scalar/enum field as\n  the field's `dbName`; `@map` on enum members as the field's `valueDbNames`.\n- Relation fields never carry `dbName` — they have no column.\n- Native DB type annotations (for example `@db.Text`) are not emitted.\n- `relationName` is included when available in Prisma runtime metadata.\n\n## Development\n\n```bash\nbun run test\nbun run typecheck\nbun run check\nbun run build\n```\n\n## License\n\nMIT\n","readmeFilename":"README.md"}