Skip to content
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .cursor/commands/commit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Commit PR

## Overview
Add all files to the the commit. come up with a succinct, accurate commit message based on the commit. Then push that commit up as a branch.


## Steps
1. **Add all changes to the commit **
- Add all changes to the commit
- Ensure all changes are committed

2. **Add a succinct commit message based on the changes made**
- Summarize changes clearly
- commit that message
- be succinct

3. **Push up branch**
- push commit to latest branch in origin

## RULES YOU MUST FOLLOW
- never do this if you are in main. If so, alert the user that they are in main.
2 changes: 2 additions & 0 deletions .cursor/commands/format.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Your job is to create is to format the code base, given the changes that were made in the current pr, so that it confirms to all formatting, linting, prettier rules, etc that exist in this code base.
<!-- IMPROVE THIS ONE -->
27 changes: 27 additions & 0 deletions .cursor/commands/new-branch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

# Create a new branch

## Overview
Given a description for a task, create a new branch

## Steps
1. **Ingest the message put in and clean up the message**
- You must take in the message and clean it to be succinct and clear.

2. **Summarize the message into a branch**
- The branch should be relatively short, less than 63 characters
- if i provide a ticket number number like "ENT-1234" in the beginning, reference that at the beginning of the new summarize message. (ex: ENT-1234-my-branch)
- each word should be followed by - until the last word
- Validate that the branch name doesn't already exist
- Validate that the ticket number format is valid (e.g., numeric)
- Handle cases where the message is too long after summarization by truncating appropriately

3. **Create the branch**
- using the message in step 2, create the branch
- If branch creation fails (e.g., branch already exists), inform the user and do not proceed

## RULES YOU MUST FOLLOW
- never do this if there is no message given by the user
- never do this if the user does not provide a ticket number
- Validate all inputs before attempting branch creation
- Handle errors gracefully and provide clear feedback to the user
27 changes: 27 additions & 0 deletions .cursor/commands/review-pr.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# PR Code Review Checklist

## Overview
You will perform a comprehensive checklist for conducting thorough code reviews to ensure quality, security, and maintainability. It should be scoped to the pr and how it changes the codebase and functionality of the app.

Ensure all rules, in ./cursor/rules/, are followed.

## Review Categories

### Functionality
- [ ] Code does what it's supposed to do
- [ ] Edge cases are handled
- [ ] Error handling is appropriate
- [ ] No obvious bugs or logic errors

### Code Quality
- [ ] Code is readable and well-structured
- [ ] Functions are small and focused
- [ ] Variable names are descriptive
- [ ] No code duplication
- [ ] Follows project conventions

### Security
- [ ] No obvious security vulnerabilities
- [ ] Input validation is present
- [ ] Sensitive data is handled properly
- [ ] No hardcoded secrets
4 changes: 4 additions & 0 deletions .cursor/rules/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*

!.gitignore
!create-data-migration.mdc
16 changes: 16 additions & 0 deletions .cursor/rules/create-data-migration.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: This rule creates a data migration Typescript class. It does not need to understand the underlying database.
globs:
alwaysApply: false
---


# Required inputs
- Name, which must be specified by the user

# Steps
- Generate an id by running ` pnpm exec node -e "const { ulid } = require('ulid'); console.log(ulid())"` in the `common/temp` directory and capturing the output. Do not use other ULID utilities. Trim any whitespace or newlines and convert the ulid to lowercase. I will refer to this as ULID.
- Process the input name by converting it into kebab case. I will refer to this as NAME.
- Create a new file called "<ULID>-<NAME>".ts in the 'packages/api/src/data-migrations/migrations'. This file should follow the class definition pattern of other files in that directory. Make sure to include a constructor that calls 'super()' with the ULID as the only argument.
- Import the new class in 'packages/api/src/data-migrations/data-migration.jobs.module.ts' and add it to the `DATA_MIGRATION_MODULES` constant in alphabetical order.

22 changes: 22 additions & 0 deletions tests/test_audit_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,28 @@ def test_sends_idempotency_key(
assert request_kwargs["headers"]["idempotency-key"] == idempotency_key
assert response is None

def test_auto_generates_idempotency_key(
self, mock_audit_log_event, capture_and_mock_http_client_request
):
"""Test that idempotency key is auto-generated when not provided."""
organization_id = "org_123456789"

request_kwargs = capture_and_mock_http_client_request(
self.http_client, {"success": True}, 200
)

response = self.audit_logs.create_event(
organization_id=organization_id,
event=mock_audit_log_event,
# No idempotency_key provided
)

# Assert header exists and has a non-empty value
assert "idempotency-key" in request_kwargs["headers"]
idempotency_key = request_kwargs["headers"]["idempotency-key"]
assert idempotency_key and idempotency_key.strip()
assert response is None

def test_throws_unauthorized_exception(
self, mock_audit_log_event, mock_http_client_with_response
):
Expand Down
Loading