{"_id":"@axonsdev/hateoas-nestjs-typeorm","name":"@axonsdev/hateoas-nestjs-typeorm","dist-tags":{"latest":"0.1.0"},"versions":{"0.1.0":{"name":"@axonsdev/hateoas-nestjs-typeorm","version":"0.1.0","license":"MPL-2.0","author":{"email":"nprin@axons.fr"},"type":"module","main":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"}},"sideEffects":false,"publishConfig":{"access":"public"},"peerDependencies":{"typeorm":">=0.3.0"},"dependencies":{"@axonsdev/hateoas-nestjs":"^0.1.0"},"scripts":{"build":"tsc -b tsconfig.json"},"_id":"@axonsdev/hateoas-nestjs-typeorm@0.1.0","description":"Assisted TypeORM integration for `@axonsdev/hateoas-nestjs`.","_integrity":"sha512-ive07djGmUB195bpQvb1vZpZDVlupQ42zRCwpsScmF3hK4QHrbIKE3cuxZ/ou7P/zHXtF5N5+Lqflb3M7QKSSQ==","_resolved":"/tmp/0a62e3ab11dacf8617f02928336f4c54/axonsdev-hateoas-nestjs-typeorm-0.1.0.tgz","_from":"file:axonsdev-hateoas-nestjs-typeorm-0.1.0.tgz","_nodeVersion":"22.22.2","_npmVersion":"10.9.7","dist":{"integrity":"sha512-ive07djGmUB195bpQvb1vZpZDVlupQ42zRCwpsScmF3hK4QHrbIKE3cuxZ/ou7P/zHXtF5N5+Lqflb3M7QKSSQ==","shasum":"1845e940dae60c97fcc30bff0c4b6c7f2642aac0","tarball":"https://registry.npmjs.org/@axonsdev/hateoas-nestjs-typeorm/-/hateoas-nestjs-typeorm-0.1.0.tgz","fileCount":7,"unpackedSize":21816,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDAR95/10JpcuBz8Q0XcPpPmG6K+quqkNMMfLGwzlXfawIgSgKWySBRrTtOPBrSshEcqpe8Q0DjUqrKkTuvlNPTNi4="}]},"_npmUser":{"name":"axonsdev","email":"nprin@axons.fr"},"directories":{},"maintainers":[{"name":"axonsdev","email":"nprin@axons.fr"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/hateoas-nestjs-typeorm_0.1.0_1777393229816_0.1308198737721109"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-28T16:20:29.730Z","0.1.0":"2026-04-28T16:20:29.959Z","modified":"2026-04-28T16:20:30.140Z"},"maintainers":[{"name":"axonsdev","email":"nprin@axons.fr"}],"description":"Assisted TypeORM integration for `@axonsdev/hateoas-nestjs`.","author":{"email":"nprin@axons.fr"},"license":"MPL-2.0","readme":"# @axonsdev/hateoas-nestjs-typeorm\n\nAssisted TypeORM integration for `@axonsdev/hateoas-nestjs`.\n\nThis package helps build Siren resource definitions from TypeORM entities while keeping explicit control over exposed fields.\n\n## Responsibilities\n\n- Build a `HypermediaResourceDefinition` for a TypeORM entity.\n- Generate property mappings from an explicit `expose` list.\n- Optionally validate exposed columns against TypeORM metadata.\n- Preserve the same links, actions, profiles, and context model as `@axonsdev/hateoas-nestjs`.\n\n## Main Exports\n\n```ts\ndefineTypeOrmSirenResource(entity, options)\nTypeOrmSirenResourceOptions\n```\n\n## Basic Usage\n\n```ts\nexport const articleResource = defineTypeOrmSirenResource<Article, { user: User }>(Article, {\n  dataSource,\n  name: 'article',\n  classes: ['article'],\n  id: (entity) => entity.id,\n  expose: ['id', 'title', 'status'],\n  profiles: {\n    list: {\n      expose: ['id', 'title', 'status'],\n      links: ['self'],\n      actions: [],\n    },\n  },\n  links: {\n    self: ({ entity, url }) => sirenLink('self', url.route('articles.findOne', { id: entity.id })),\n  },\n});\n```\n\n## `expose` Is Mandatory\n\nThe package intentionally does not expose every TypeORM column automatically.\n\n```ts\nexpose: ['id', 'title', 'status']\n```\n\nThis prevents accidental leaks of sensitive fields such as passwords, tokens, internal flags, or audit data.\n\n## Custom Properties\n\nYou can add computed properties or override generated mappings:\n\n```ts\ndefineTypeOrmSirenResource(UserEntity, {\n  expose: ['id', 'email'],\n  properties: {\n    displayName: ({ entity }) => `${entity.firstName} ${entity.lastName}`,\n  },\n  // links, actions, profiles...\n});\n```\n\nGenerated mappings from `expose` are merged first. `properties` are merged afterward.\n\n## Metadata Validation\n\nWhen `dataSource` is provided, every exposed field is checked against TypeORM column metadata.\n\n```ts\ndefineTypeOrmSirenResource(UserEntity, {\n  dataSource,\n  expose: ['id', 'email'],\n  // ...\n});\n```\n\nIf an exposed field is not a known column, the function throws an error.\n\nThis is a guard against typos and stale resource definitions.\n\n## Relationship To @axonsdev/hateoas-nestjs\n\nThe result is a normal `HypermediaResourceDefinition`, so it can be registered in `HateoasModule.forRoot(...)`:\n\n```ts\nHateoasModule.forRoot({\n  resources: [articleResource],\n  routes,\n});\n```\n\n## Current Limitations\n\n- It does not automatically expose relations.\n- It does not automatically generate links from TypeORM relations.\n- It does not infer profiles.\n- It does not infer actions.\n- It validates columns only when a `DataSource` is supplied.\n\nThese constraints are intentional for the first version: representation exposure should stay explicit.\n","readmeFilename":"README.md","_rev":"1-84dc819249e5c8e4e762742f07a92858"}