-
Notifications
You must be signed in to change notification settings - Fork 166
Update the template tables creation to use database tokens #1801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| export const getAdminTablesContext = async (): Promise<TablesServerContext> => { | ||
| const { tablesDatabaseId, tablesDatabaseToken } = await getAdminUserProject(); | ||
|
|
||
| return { tablesDatabaseToken, tablesDatabaseId }; | ||
| }; |
There was a problem hiding this comment.
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.
| userId, | ||
| }: CreateTemplateTablesSystemJobData): Promise<void> { | ||
| export async function addTemplateTablesCreationJob( | ||
| tablesContext: TablesServerContext, |
There was a problem hiding this comment.
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.
|
There was a problem hiding this 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
TablesServerContextinstead 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.



Fixes OPS-3312.