Skip to content

feat: implement pure CRUD operations for table entities#1831

Merged
Artuomka merged 1 commit into
mainfrom
backend_new_table_crud_endpoints
Jun 5, 2026
Merged

feat: implement pure CRUD operations for table entities#1831
Artuomka merged 1 commit into
mainfrom
backend_new_table_crud_endpoints

Conversation

@Artuomka

@Artuomka Artuomka commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator
  • Add PureCreateRowInTableUseCase for creating rows in tables.
  • Add PureDeleteRowFromTableUseCase for deleting rows from tables.
  • Add PureGetRowsFromTableUseCase for retrieving rows from tables.
  • Add PureReadRowFromTableUseCase for reading a single row by primary key.
  • Add PureUpdateRowInTableUseCase for updating rows in tables.
  • Define interfaces for CRUD use cases in table-pure-crud-use-cases.interface.ts.
  • Implement end-to-end tests for CRUD operations in non-saas-table-pure-crud-operations-e2e.test.ts.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added pure CRUD operations for direct table row management through dedicated API endpoints
    • Supports creating, reading, updating, and deleting individual rows
    • Includes bulk row retrieval with pagination and filtering capabilities
    • All operations include built-in authentication and validation

- Add PureCreateRowInTableUseCase for creating rows in tables.
- Add PureDeleteRowFromTableUseCase for deleting rows from tables.
- Add PureGetRowsFromTableUseCase for retrieving rows from tables.
- Add PureReadRowFromTableUseCase for reading a single row by primary key.
- Add PureUpdateRowInTableUseCase for updating rows in tables.
- Define interfaces for CRUD use cases in table-pure-crud-use-cases.interface.ts.
- Implement end-to-end tests for CRUD operations in non-saas-table-pure-crud-operations-e2e.test.ts.
Copilot AI review requested due to automatic review settings June 5, 2026 14:18
@Artuomka Artuomka enabled auto-merge June 5, 2026 14:19
@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

Pull request was closed or merged during review

📝 Walkthrough

Walkthrough

This pull request introduces a Pure CRUD operations module enabling direct HTTP row-level create, read, update, delete, and list operations against database tables. The implementation includes DTOs, five use cases, a NestJS controller, module wiring, and comprehensive E2E tests covering all endpoints and error conditions.

Changes

Pure CRUD Operations Feature

Layer / File(s) Summary
Module integration and DI configuration
backend/src/app.module.ts, backend/src/common/data-injection.tokens.ts, backend/src/entities/table/table-pure-crud-operations/table-pure-crud-operations.module.ts
Application module imports TablePureCrudOperationsModule; UseCaseType enum gains six new PURE_* identifiers; module registers TypeORM entities, wires use-case providers via DI tokens, and configures AuthWithApiMiddleware for /table/crud/... routes.
Request and response data structures
backend/src/entities/table/table-pure-crud-operations/application/data-structures/*
Five input DTOs (PureCreateRowDs, PureReadRowDs, PureUpdateRowDs, PureDeleteRowDs, PureGetRowsDs) and two output DTOs (PureCrudRowResponseDs, PureFoundRowsResponseDs) define HTTP payload contracts with Swagger/OpenAPI decorators.
Use case interface contracts
backend/src/entities/table/table-pure-crud-operations/use-cases/table-pure-crud-use-cases.interface.ts
Five exported interfaces standardize the execute(inputData, inTransaction) signature for CRUD operations, each returning single-row or multi-row response shapes.
Create and read use cases
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-create-row-in-table.use.case.ts, backend/src/entities/table/table-pure-crud-operations/use-cases/pure-read-row-from-table.use.case.ts
PureCreateRowInTableUseCase validates connection/table/permissions, transforms row data (hashing, UUID/hex conversion), inserts via DAO, and returns created row; PureReadRowFromTableUseCase normalizes primary key, retrieves row, and strips password fields.
Update and delete use cases
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-update-row-in-table.use.case.ts, backend/src/entities/table/table-pure-crud-operations/use-cases/pure-delete-row-from-table.use.case.ts
PureUpdateRowInTableUseCase merges row data, computes prospective primary key, applies transformations, performs update, and returns updated row; PureDeleteRowFromTableUseCase loads row, enforces can_delete permission, performs deletion, and returns deleted row.
Get rows use case
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-get-rows-from-table.use.case.ts
PureGetRowsFromTableUseCase builds query settings from pagination/search/filter inputs, handles hex-to-binary search conversion, queries DAO with error mapping, post-processes rows with widgets, and returns paginated response.
HTTP controller and routing
backend/src/entities/table/table-pure-crud-operations/table-pure-crud-operations.controller.ts
TablePureCrudOperationsController exposes POST (create), GET (read), PUT (update), DELETE, and POST /rows (paginated list) endpoints; centralizes primary-key extraction via extractPrimaryKeyFromQuery helper that loads connection, verifies table existence, and assembles key from query fields.
End-to-end test suite
backend/test/ava-tests/non-saas-tests/non-saas-table-pure-crud-operations-e2e.test.ts
Comprehensive AVA test suite verifies CRUD endpoint status codes and response shapes (only row/rows+pagination, no metadata), validates error handling for missing parameters and non-existent rows, and confirms pagination, search, and filtering behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~75 minutes

Possibly related PRs

  • rocket-admin/rocketadmin#1746: Modifies the UseCaseType enum in backend/src/common/data-injection.tokens.ts to add/remove table-related use case identifiers.

Suggested reviewers

  • lyubov-voloshko
  • gugu

Poem

🐰 A rabbit's ode to CRUD so pure,
Five endpoints now, direct and sure,
Create, read, update, delete with care,
And rows galore—they float through air!
From DTO to DAO's embrace,
Pure operations light the pace!

🚥 Pre-merge checks | ✅ 4 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Security Check ⚠️ Warning Password leak when addRowInTable returns empty key; incorrect primary key normalization removes 0 and false values; direct database error disclosure in responses. Fix password leak by always sanitizing before return; Replace falsy checks with explicit null/undefined checks; Wrap DB errors in generic messages.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: implementing pure CRUD operations for table entities, which aligns with the PR's primary objective of adding create, read, update, delete, and get-rows use cases along with their controller and supporting infrastructure.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_new_table_crud_endpoints

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot requested review from gugu and lyubov-voloshko June 5, 2026 14:19
@Artuomka Artuomka merged commit 869e97a into main Jun 5, 2026
16 of 18 checks passed
@Artuomka Artuomka deleted the backend_new_table_crud_endpoints branch June 5, 2026 14:27

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a new “pure” CRUD surface for table rows (create/read/update/delete + list) intended to return minimal payloads (only row or rows + pagination) and to be usable via API key access. It adds a dedicated Nest module/controller, corresponding use cases + data structures, and an end-to-end test suite for non‑SaaS flows.

Changes:

  • Added TablePureCrudOperationsModule + TablePureCrudOperationsController with endpoints under /table/crud/*.
  • Implemented “pure” CRUD use cases and request/response data-structures for row operations.
  • Added non‑SaaS AVA e2e coverage for create/read/update/delete + list rows (pagination/search/body filters).

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
backend/test/ava-tests/non-saas-tests/non-saas-table-pure-crud-operations-e2e.test.ts New e2e tests validating pure CRUD endpoints return minimal payload shapes and expected behaviors.
backend/src/entities/table/table-pure-crud-operations/use-cases/table-pure-crud-use-cases.interface.ts New interfaces defining the pure CRUD use case contracts.
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-create-row-in-table.use.case.ts Implements create-row use case returning only the created row.
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-read-row-from-table.use.case.ts Implements read-row-by-PK use case returning only the row.
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-update-row-in-table.use.case.ts Implements update-row-by-PK use case returning only the updated row.
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-delete-row-from-table.use.case.ts Implements delete-row-by-PK use case returning the deleted row.
backend/src/entities/table/table-pure-crud-operations/use-cases/pure-get-rows-from-table.use.case.ts Implements rows listing with pagination/search/query/body-filters returning only rows + pagination.
backend/src/entities/table/table-pure-crud-operations/table-pure-crud-operations.module.ts Wires up providers, controller, and middleware protection for the new routes.
backend/src/entities/table/table-pure-crud-operations/table-pure-crud-operations.controller.ts Defines the new HTTP endpoints and request parsing (PK extraction, pagination parsing).
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-create-row.ds.ts New input DS for create row.
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-read-row.ds.ts New input DS for read row.
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-update-row.ds.ts New input DS for update row.
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-delete-row.ds.ts New input DS for delete row.
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-get-rows.ds.ts New input DS for list rows.
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-crud-row-response.ds.ts New minimal response DS for single-row responses.
backend/src/entities/table/table-pure-crud-operations/application/data-structures/pure-found-rows-response.ds.ts New minimal response DS for list responses.
backend/src/common/data-injection.tokens.ts Adds DI tokens for the new pure CRUD use cases.
backend/src/app.module.ts Registers the new pure CRUD module in the main application module.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +135 to +143
let parsedPage = 0;
let parsedPerPage = 0;
if (page && perPage) {
parsedPage = parseInt(page, 10);
parsedPerPage = parseInt(perPage, 10);
if ((parsedPage && parsedPage <= 0) || (parsedPerPage && parsedPerPage <= 0)) {
throw new HttpException({ message: Messages.PAGE_AND_PERPAGE_INVALID }, HttpStatus.BAD_REQUEST);
}
}
Comment on lines +274 to +281
const primaryColumns = await dao.getTablePrimaryColumns(tableName, userEmail);
const primaryKey: Record<string, unknown> = {};
for (const primaryColumn of primaryColumns) {
if (isObjectPropertyExists(primaryColumn, 'column_name')) {
primaryKey[primaryColumn.column_name] = query[primaryColumn.column_name];
}
}
return primaryKey;
Comment on lines +76 to +79
const addedRowPrimaryKey = (await dao.addRowInTable(tableName, row, userEmail)) as Record<string, unknown>;
if (!addedRowPrimaryKey || isObjectEmpty(addedRowPrimaryKey)) {
return { row };
}
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