Skip to content

feat(examples): add OmniKernel document slice - #124

Closed
Yehonal wants to merge 1 commit into
feat/omnikernel-foundationsfrom
feat/omnikernel-documents
Closed

Yehonal wants to merge 1 commit into
feat/omnikernel-foundationsfrom
feat/omnikernel-documents

Conversation

@Yehonal

@Yehonal Yehonal commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add typed OmniKernel record and relation enums for shared semantics
  • introduce OmniDocumentEntity as the first concrete record family on top of the foundations layer
  • wire document DTOs, resolver factory, module registration, exports, docs, and entity tests

Validation

  • npx eslint -c .eslintrc.cjs "examples/omnikernel-module/src/**/*.ts" --max-warnings=0
  • NODE_OPTIONS="--experimental-vm-modules --experimental-import-meta-resolve" npx jest --config examples/omnikernel-module/jest.config.cjs --runInBand

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in OmniKernelModule and 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.

Comment on lines 70 to +73
@ModelField({})
@Field()
@IsString()
@IsIn(['draft', 'active', 'archived'])
status!: string;
@IsEnum(OmniRecordStatus)
status!: OmniRecordStatus;

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 81 to +89
@ModelField({})
@Field()
@IsString()
@MaxLength(64)
kind!: string;
@IsEnum(OmniRelationKind)
kind!: OmniRelationKind;

@ModelField({})
@Field()
@IsString()
@IsIn(['active', 'inactive', 'archived'])
status!: string;
@IsEnum(OmniRelationStatus)
status!: OmniRelationStatus;

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +74 to +77
@ModelField({})
@Field()
@IsEnum(OmniRecordStatus)
status!: OmniRecordStatus;

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +114 to +117
@ModelField({})
@Field()
@IsEnum(OmniDocumentKind)
documentKind!: OmniDocumentKind;

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +31 to +33
if (!this.kind) {
this.kind = OmniDocumentKind.Document;
}

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Suggested change
if (!this.kind) {
this.kind = OmniDocumentKind.Document;
}
this.kind = OmniDocumentKind.Document;

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 13
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.

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +20
## PR 2 additions

- typed record and relation enums for status and relation semantics
- `OmniDocumentEntity` as the first concrete record family built on
`OmniRecordEntity`

Copilot AI Apr 8, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@Yehonal

Yehonal commented Apr 8, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by PR #123 after consolidating the document slice and review fixes into a single OmniKernel PR.

@Yehonal Yehonal closed this Apr 8, 2026
@Yehonal
Yehonal deleted the feat/omnikernel-documents branch April 8, 2026 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants