Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new “document” record slice to the examples/omnikernel-module package, extending the existing OmniKernel foundations (named/record/relation/external-ref) with a concrete document entity plus resolver/DTO wiring.
Changes:
- Introduces
OmniDocumentEntity+ DTOs + resolver factory and registers them inOmniKernelModuleand package exports. - Adds typed enums for record/relation statuses and relation kinds, and applies them to entities/DTO validations.
- Adds a TypeORM metadata-based unit test for the new document entity and updates module README.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/omnikernel-module/src/omnikernel.module.ts | Registers OmniDocumentEntity and its CRUD-gen providers in the dynamic module. |
| examples/omnikernel-module/src/omni-relation.dto.ts | Switches relation kind/status DTO fields to typed enums + IsEnum. |
| examples/omnikernel-module/src/omni-relation-status.enum.ts | Adds OmniRelationStatus enum. |
| examples/omnikernel-module/src/omni-relation-kind.enum.ts | Adds OmniRelationKind enum. |
| examples/omnikernel-module/src/omni-record.dto.ts | Switches record status DTO field to typed enum + IsEnum. |
| examples/omnikernel-module/src/omni-record-status.enum.ts | Adds OmniRecordStatus enum. |
| examples/omnikernel-module/src/omni-document.resolver.ts | Adds CRUD-gen providers factory for Omni documents. |
| examples/omnikernel-module/src/omni-document.entity.ts | Adds TypeORM entity for document records (subtype fields + hooks). |
| examples/omnikernel-module/src/omni-document.dto.ts | Adds GraphQL DTOs + inputs/conditions for documents. |
| examples/omnikernel-module/src/omni-document-kind.enum.ts | Adds OmniDocumentKind enum for document subtypes. |
| examples/omnikernel-module/src/index.ts | Exports new enums + document slice modules. |
| examples/omnikernel-module/src/base/omni-relation.entity.ts | Types relation kind/status columns using enums (and default). |
| examples/omnikernel-module/src/base/omni-record.entity.ts | Types record status column using enum (and default). |
| examples/omnikernel-module/src/tests/omni-document.entity.spec.ts | Adds metadata-level test coverage for OmniDocumentEntity. |
| examples/omnikernel-module/README.md | Documents the new document entity and enum additions. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @ModelField({}) | ||
| @Field() | ||
| @IsString() | ||
| @IsIn(['draft', 'active', 'archived']) | ||
| status!: string; | ||
| @IsEnum(OmniRecordStatus) | ||
| status!: OmniRecordStatus; |
There was a problem hiding this comment.
status is now typed as a TypeScript enum, but the GraphQL decorator is still @Field() with no explicit type. With emitDecoratorMetadata enabled, enums typically reflect as Object, and Nest GraphQL can fail schema generation with “Cannot determine GraphQL output type…”. Consider registering the enum with registerEnumType and using @Field(() => OmniRecordStatus), or keep the field typed as string if the API should expose a string.
| @ModelField({}) | ||
| @Field() | ||
| @IsString() | ||
| @MaxLength(64) | ||
| kind!: string; | ||
| @IsEnum(OmniRelationKind) | ||
| kind!: OmniRelationKind; | ||
|
|
||
| @ModelField({}) | ||
| @Field() | ||
| @IsString() | ||
| @IsIn(['active', 'inactive', 'archived']) | ||
| status!: string; | ||
| @IsEnum(OmniRelationStatus) | ||
| status!: OmniRelationStatus; |
There was a problem hiding this comment.
kind/status are now TypeScript enums but still use @Field() without an explicit type. With decorator metadata enabled this can prevent Nest GraphQL from inferring a valid GraphQL type at runtime. Suggest registering these enums via registerEnumType and switching to @Field(() => OmniRelationKind) / @Field(() => OmniRelationStatus) (or keep them as string if you intentionally want GraphQL strings).
| @ModelField({}) | ||
| @Field() | ||
| @IsEnum(OmniRecordStatus) | ||
| status!: OmniRecordStatus; |
There was a problem hiding this comment.
status is typed as OmniRecordStatus but the GraphQL decorator is @Field() without an explicit type. If enum reflection resolves to Object, schema generation can fail. Consider registering OmniRecordStatus as a GraphQL enum and using @Field(() => OmniRecordStatus) (or switch the property back to string if you want a string field).
| @ModelField({}) | ||
| @Field() | ||
| @IsEnum(OmniDocumentKind) | ||
| documentKind!: OmniDocumentKind; |
There was a problem hiding this comment.
documentKind is a TypeScript enum but uses @Field() without an explicit type. This can break Nest GraphQL type inference when emitDecoratorMetadata is on. Recommend registerEnumType(OmniDocumentKind, ...) and @Field(() => OmniDocumentKind) (or expose it as string explicitly).
| if (!this.kind) { | ||
| this.kind = OmniDocumentKind.Document; | ||
| } |
There was a problem hiding this comment.
ensureDocumentRecordKind() only sets kind when it’s falsy, so it won’t prevent persisting an OmniDocumentEntity with a non-document kind (which would also contradict the DTO validation that only allows kind === 'document'). Consider enforcing the invariant (always set kind to OmniDocumentKind.Document, or throw if a different value is provided).
| if (!this.kind) { | |
| this.kind = OmniDocumentKind.Document; | |
| } | |
| this.kind = OmniDocumentKind.Document; |
| It follows the same `CrudGenDependencyFactory` pattern used by | ||
| `examples/task-system-module`, so each entity exposes the usual auto-wired | ||
| service, dataloader, and GraphQL resolver providers. |
There was a problem hiding this comment.
README references examples/task-system-module, but that directory/module doesn’t exist in this repo. This makes the documentation misleading; update the reference to an existing example (or remove it).
| ## PR 2 additions | ||
|
|
||
| - typed record and relation enums for status and relation semantics | ||
| - `OmniDocumentEntity` as the first concrete record family built on | ||
| `OmniRecordEntity` | ||
|
|
There was a problem hiding this comment.
Section title “PR 2 additions” is tied to a specific PR and will become stale once merged. Consider renaming this to something repo-agnostic (e.g. “Recent additions” / “Document slice additions”) or folding the bullets into the main module description.
|
Superseded by PR #123 after consolidating the document slice and review fixes into a single OmniKernel PR. |
Summary
OmniDocumentEntityas the first concrete record family on top of the foundations layerValidation
npx eslint -c .eslintrc.cjs "examples/omnikernel-module/src/**/*.ts" --max-warnings=0NODE_OPTIONS="--experimental-vm-modules --experimental-import-meta-resolve" npx jest --config examples/omnikernel-module/jest.config.cjs --runInBand