Merge branch 'staging' into dallin/bus-920-feature-finish-rest-of-permissions

This commit is contained in:
Nate Kelley 2025-01-20 14:14:11 -07:00
commit acafc5a025
No known key found for this signature in database
GPG Key ID: FD90372AB8D98B4F
7 changed files with 3802 additions and 64 deletions

View File

@ -162,23 +162,27 @@ pub async fn list_assets_handler(
let query = format!( let query = format!(
r#" r#"
SELECT DISTINCT ON (content, asset_type) WITH distinct_assets AS (
asset_search.asset_id, SELECT DISTINCT ON (content, asset_type)
asset_search.content, asset_search.asset_id,
asset_search.updated_at, asset_search.content,
asset_search.asset_type asset_search.updated_at,
FROM asset_search.asset_type
asset_search FROM
INNER JOIN asset_search
asset_permissions INNER JOIN
ON asset_permissions
asset_search.asset_id = asset_permissions.asset_id ON
WHERE asset_search.asset_id = asset_permissions.asset_id
asset_search.asset_type IN ({}) WHERE
AND (asset_permissions.identity_id = '{}') asset_search.asset_type IN ({})
AND asset_search.deleted_at IS NULL AND (asset_permissions.identity_id = '{}')
AND asset_permissions.deleted_at IS NULL AND asset_search.deleted_at IS NULL
ORDER BY asset_search.content, asset_search.asset_type, asset_search.updated_at DESC AND asset_permissions.deleted_at IS NULL
)
SELECT *
FROM distinct_assets
ORDER BY updated_at DESC
LIMIT {}; LIMIT {};
"#, "#,
asset_types asset_types

15
web/.cursorrules Normal file
View File

@ -0,0 +1,15 @@
# Project: React TypeScript Application
You are a TypeScript expert with deep knowledge of the language's features and best practices. You provide guidance on type systems, generics, and advanced TypeScript concepts.
## Coding Standards
- Use TypeScript for all new code
- Prefer functional components and hooks over class components
- Use proper TypeScript types for all variables and functions
## Best Practices
- Try to use Ant Design componets (Button, Input, etc) over native HTML elements.
- If we need to create custom elements like cards or containers with border colors, use createStyles from antd-style and use the token to get the exact color
- If newly defined element has a border, it should be 0.5px
- Use React.memo() for performance optimization when appropriate
- Prefer async/await over .then() for asynchronous operations

24
web/jest.config.mjs Normal file
View File

@ -0,0 +1,24 @@
import nextJest from 'next/jest.js';
const createJestConfig = nextJest({
// Provide the path to your Next.js app to load next.config.js and .env files in your test environment
dir: './'
});
// Add any custom config to be passed to Jest
/** @type {import('jest').Config} */
const config = {
// Add more setup options before each test is run
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
testEnvironment: 'jest-environment-jsdom',
preset: 'ts-jest',
moduleNameMapper: {
// Handle module aliases (if you're using them in your Next.js project)
'^@/(.*)$': '<rootDir>/src/$1'
},
// Test files can be next to components with .test.tsx or .spec.tsx extensions
testMatch: ['**/__tests__/**/*.[jt]s?(x)', '**/?(*.)+(spec|test).[jt]s?(x)']
};
// createJestConfig is exported this way to ensure that next/jest can load the Next.js config which is async
export default createJestConfig(config);

45
web/jest.setup.js Normal file
View File

@ -0,0 +1,45 @@
// Learn more: https://github.com/testing-library/jest-dom
import '@testing-library/jest-dom';
// Mock Next.js router
jest.mock('next/router', () => ({
useRouter() {
return {
route: '/',
pathname: '',
query: {},
asPath: '',
push: jest.fn(),
replace: jest.fn(),
reload: jest.fn(),
back: jest.fn(),
prefetch: jest.fn(),
beforePopState: jest.fn(),
events: {
on: jest.fn(),
off: jest.fn(),
emit: jest.fn()
},
isFallback: false
};
}
}));
// Mock next/navigation
jest.mock('next/navigation', () => ({
useRouter() {
return {
push: jest.fn(),
replace: jest.fn(),
refresh: jest.fn(),
back: jest.fn(),
forward: jest.fn()
};
},
usePathname() {
return '';
},
useSearchParams() {
return new URLSearchParams();
}
}));

3700
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,9 @@
"build": "next build", "build": "next build",
"start": "next start", "start": "next start",
"lint": "next lint", "lint": "next lint",
"cy:run": "npx cypress run --browser chrome" "cy:run": "npx cypress run --browser chrome",
"test": "jest",
"test:watch": "jest --watch"
}, },
"engines": { "engines": {
"node": ">=20.0.0" "node": ">=20.0.0"
@ -101,7 +103,11 @@
"virtua": "^0.39.3" "virtua": "^0.39.3"
}, },
"devDependencies": { "devDependencies": {
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^14.3.1",
"@testing-library/user-event": "^14.5.1",
"@types/canvas-confetti": "^1.9.0", "@types/canvas-confetti": "^1.9.0",
"@types/jest": "^29.5.14",
"@types/js-cookie": "^3.0.6", "@types/js-cookie": "^3.0.6",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/node": "^20", "@types/node": "^20",
@ -119,10 +125,13 @@
"eslint-config-next": "14.2.3", "eslint-config-next": "14.2.3",
"eslint-config-prettier": "^9.1.0", "eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.2", "eslint-plugin-prettier": "^5.2.2",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"monaco-editor-webpack-plugin": "^7.1.0", "monaco-editor-webpack-plugin": "^7.1.0",
"postcss": "~8", "postcss": "~8",
"sass": "^1.83.4", "sass": "^1.83.4",
"tailwindcss": "^3.4.17", "tailwindcss": "^3.4.17",
"ts-jest": "^29.2.5",
"typescript": "^5" "typescript": "^5"
}, },
"overrides": {} "overrides": {}

View File

@ -1,6 +1,15 @@
{ {
"compilerOptions": { "compilerOptions": {
"lib": ["dom", "dom.iterable", "esnext"], "lib": [
"dom",
"dom.iterable",
"esnext"
],
"types": [
"node",
"jest",
"@testing-library/jest-dom"
],
"allowJs": true, "allowJs": true,
"skipLibCheck": true, "skipLibCheck": true,
"strict": true, "strict": true,
@ -18,19 +27,23 @@
} }
], ],
"paths": { "paths": {
"@/*": ["./src/*"], "@/*": [
"@utils/*": ["./src/utils/*"], "./src/*"
"typeRoots": ["./node_modules/@types", "./src/components/chartjs"] ],
"@utils/*": [
"./src/utils/*"
]
}, },
"target": "ES2017" "target": "ES2017"
}, },
"include": [ "include": [
"next-env.d.ts", "next-env.d.ts",
"**/*.ts", "src/**/*.ts",
"**/*.tsx", "src/**/*.tsx",
".next/types/**/*.ts", ".next/types/**/*.ts"
"middleware.ts",
"**/*.d.ts"
], ],
"exclude": ["node_modules"] "exclude": [
"node_modules",
"dist"
]
} }