Skip to content

Conversation

@MarceloRGonc
Copy link
Contributor

@MarceloRGonc MarceloRGonc commented Jan 5, 2026

Fixes OPS-3312.

@linear
Copy link

linear bot commented Jan 5, 2026

Comment on lines +27 to 31
export const getAdminTablesContext = async (): Promise<TablesServerContext> => {
const { tablesDatabaseId, tablesDatabaseToken } = await getAdminUserProject();

return { tablesDatabaseToken, tablesDatabaseId };
};
Copy link
Contributor Author

Choose a reason for hiding this comment

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

In a future PR I will change this so that I don't use the admin account.

@MarceloRGonc MarceloRGonc changed the title Mg/ops 3312 3 Update the template tables creation to use database tokens Jan 5, 2026
userId,
}: CreateTemplateTablesSystemJobData): Promise<void> {
export async function addTemplateTablesCreationJob(
tablesContext: TablesServerContext,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I know this will cause an issue in the other repository, but I'll prepare a PR to fix it.

Base automatically changed from mg/remove-unused-seed to main January 6, 2026 10:09
@MarceloRGonc MarceloRGonc marked this pull request as ready for review January 6, 2026 10:10
Copilot AI review requested due to automatic review settings January 6, 2026 10:10
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jan 6, 2026

Copy link
Contributor

Copilot AI left a comment

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 refactors the template tables creation system to use database tokens from the TablesServerContext instead of authenticating users directly. The change removes the need to pass user credentials and authenticate them when creating template tables, instead relying on pre-encrypted database tokens stored in the context.

Key changes:

  • Replaced authentication flow with token-based context throughout template table creation
  • Updated function signatures to accept TablesServerContext instead of separate token and database ID parameters
  • Modified tests to mock encrypted token decryption and updated test assertions

Reviewed changes

Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/server/api/src/app/openops-tables/create-table.ts Updated to accept TablesServerContext and resolve tokens from context
packages/server/api/src/app/openops-tables/template-tables/*.ts Refactored all template table creation functions to use TablesServerContext
packages/server/api/src/app/openops-tables/template-tables/template-tables-job.ts Removed user authentication, now uses tokens from context
packages/server/api/src/app/openops-tables/template-tables/types.ts Removed TablesContext type definition
packages/server/api/src/app/helper/system-jobs/common.ts Updated system job data type to use TablesServerContext
packages/server/api/src/app/database/seeds/*.ts Updated seed functions to use TablesServerContext from admin context
packages/server/api/test/unit/openops-tables/*.test.ts Updated tests to mock token decryption and use new context structure

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

@MarceloRGonc MarceloRGonc merged commit c47296a into main Jan 6, 2026
23 checks passed
@MarceloRGonc MarceloRGonc deleted the mg/OPS-3312-3 branch January 6, 2026 11:18
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.

3 participants