Browse Source

Merge remote-tracking branch 'origin/main' into feature/extend-holdings-endpoint-for-cash

pull/5650/head
KenTandrian 1 week ago
parent
commit
370bdaa2f6
  1. 2
      CHANGELOG.md
  2. 4
      apps/api/src/app/admin/admin.controller.ts
  3. 1
      apps/api/src/app/endpoints/public/public.controller.ts
  4. 4
      apps/api/src/services/cron/cron.service.ts
  5. 53
      apps/api/src/services/queues/data-gathering/data-gathering.service.ts
  6. 20
      apps/client-e2e/.eslintrc.json
  7. 12
      apps/client-e2e/cypress.json
  8. 22
      apps/client-e2e/project.json
  9. 4
      apps/client-e2e/src/fixtures/example.json
  10. 13
      apps/client-e2e/src/integration/app.spec.ts
  11. 22
      apps/client-e2e/src/plugins/index.js
  12. 1
      apps/client-e2e/src/support/app.po.ts
  13. 31
      apps/client-e2e/src/support/commands.ts
  14. 16
      apps/client-e2e/src/support/index.ts
  15. 10
      apps/client-e2e/tsconfig.e2e.json
  16. 10
      apps/client-e2e/tsconfig.json
  17. 13
      apps/ui-e2e/cypress.json
  18. 33
      apps/ui-e2e/eslint.config.cjs
  19. 28
      apps/ui-e2e/project.json
  20. 4
      apps/ui-e2e/src/fixtures/example.json
  21. 6
      apps/ui-e2e/src/integration/value/value.component.spec.ts
  22. 22
      apps/ui-e2e/src/plugins/index.js
  23. 33
      apps/ui-e2e/src/support/commands.ts
  24. 16
      apps/ui-e2e/src/support/index.ts
  25. 10
      apps/ui-e2e/tsconfig.json
  26. 402
      package-lock.json
  27. 5
      package.json

2
CHANGELOG.md

@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Restricted the asset profile data gathering on Sundays to only process outdated asset profiles
- Removed the _Cypress_ testing setup
- Eliminated `uuid` in favor of using `randomUUID` from `node:crypto`
- Upgraded `color` from version `5.0.0` to `5.0.3`

4
apps/api/src/app/admin/admin.controller.ts

@ -93,7 +93,7 @@ export class AdminController {
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
public async gatherMax(): Promise<void> {
const assetProfileIdentifiers =
await this.dataGatheringService.getAllActiveAssetProfileIdentifiers();
await this.dataGatheringService.getActiveAssetProfileIdentifiers();
await this.dataGatheringService.addJobsToQueue(
assetProfileIdentifiers.map(({ dataSource, symbol }) => {
@ -120,7 +120,7 @@ export class AdminController {
@UseGuards(AuthGuard('jwt'), HasPermissionGuard)
public async gatherProfileData(): Promise<void> {
const assetProfileIdentifiers =
await this.dataGatheringService.getAllActiveAssetProfileIdentifiers();
await this.dataGatheringService.getActiveAssetProfileIdentifiers();
await this.dataGatheringService.addJobsToQueue(
assetProfileIdentifiers.map(({ dataSource, symbol }) => {

1
apps/api/src/app/endpoints/public/public.controller.ts

@ -82,7 +82,6 @@ export class PublicController {
]);
const { activities } = await this.orderService.getOrders({
includeDrafts: false,
sortColumn: 'date',
sortDirection: 'desc',
take: 10,

4
apps/api/src/services/cron/cron.service.ts

@ -59,7 +59,9 @@ export class CronService {
public async runEverySundayAtTwelvePm() {
if (await this.isDataGatheringEnabled()) {
const assetProfileIdentifiers =
await this.dataGatheringService.getAllActiveAssetProfileIdentifiers();
await this.dataGatheringService.getActiveAssetProfileIdentifiers({
maxAge: '60 days'
});
await this.dataGatheringService.addJobsToQueue(
assetProfileIdentifiers.map(({ dataSource, symbol }) => {

53
apps/api/src/services/queues/data-gathering/data-gathering.service.ts

@ -28,8 +28,9 @@ import { InjectQueue } from '@nestjs/bull';
import { Inject, Injectable, Logger } from '@nestjs/common';
import { DataSource } from '@prisma/client';
import { JobOptions, Queue } from 'bull';
import { format, min, subDays, subYears } from 'date-fns';
import { format, min, subDays, subMilliseconds, subYears } from 'date-fns';
import { isEmpty } from 'lodash';
import ms, { StringValue } from 'ms';
@Injectable()
export class DataGatheringService {
@ -160,8 +161,7 @@ export class DataGatheringService {
);
if (!assetProfileIdentifiers) {
assetProfileIdentifiers =
await this.getAllActiveAssetProfileIdentifiers();
assetProfileIdentifiers = await this.getActiveAssetProfileIdentifiers();
}
if (assetProfileIdentifiers.length <= 0) {
@ -301,29 +301,36 @@ export class DataGatheringService {
);
}
public async getAllActiveAssetProfileIdentifiers(): Promise<
AssetProfileIdentifier[]
> {
const symbolProfiles = await this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }],
/**
* Returns active asset profile identifiers
*
* @param {StringValue} maxAge - Optional. Specifies the maximum allowed age
* of a profiles last update timestamp. Only asset profiles considered stale
* are returned.
*/
public async getActiveAssetProfileIdentifiers({
maxAge
}: {
maxAge?: StringValue;
} = {}): Promise<AssetProfileIdentifier[]> {
return this.prismaService.symbolProfile.findMany({
orderBy: [{ symbol: 'asc' }, { dataSource: 'asc' }],
select: {
dataSource: true,
symbol: true
},
where: {
isActive: true
dataSource: {
notIn: ['MANUAL', 'RAPID_API']
},
isActive: true,
...(maxAge && {
updatedAt: {
lt: subMilliseconds(new Date(), ms(maxAge))
}
})
}
});
return symbolProfiles
.filter(({ dataSource }) => {
return (
dataSource !== DataSource.MANUAL &&
dataSource !== DataSource.RAPID_API
);
})
.map(({ dataSource, symbol }) => {
return {
dataSource,
symbol
};
});
}
private async getAssetProfileIdentifiersWithCompleteMarketData(): Promise<

20
apps/client-e2e/.eslintrc.json

@ -1,20 +0,0 @@
{
"extends": ["plugin:cypress/recommended", "../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["apps/client-e2e/tsconfig.*?.json"]
},
"rules": {}
},
{
"files": ["src/plugins/index.js"],
"rules": {
"@typescript-eslint/no-var-requires": "off",
"no-undef": "off"
}
}
]
}

12
apps/client-e2e/cypress.json

@ -1,12 +0,0 @@
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"pluginsFile": "./src/plugins/index",
"supportFile": "./src/support/index.ts",
"video": true,
"videosFolder": "../../dist/cypress/apps/client-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/client-e2e/screenshots",
"chromeWebSecurity": false
}

22
apps/client-e2e/project.json

@ -1,22 +0,0 @@
{
"name": "client-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/client-e2e/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["client"],
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/client-e2e/cypress.json",
"devServerTarget": "client:serve"
},
"configurations": {
"production": {
"devServerTarget": "client:serve:production"
}
}
}
}
}

4
apps/client-e2e/src/fixtures/example.json

@ -1,4 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}

13
apps/client-e2e/src/integration/app.spec.ts

@ -1,13 +0,0 @@
import { getGreeting } from '../support/app.po';
describe('client', () => {
beforeEach(() => cy.visit('/'));
it('should display welcome message', () => {
// Custom command example, see `../support/commands.ts` file
cy.login('my-email@something.com', 'myPassword');
// Function helper example, see `../support/app.po.ts` file
getGreeting().contains('Welcome to client!');
});
});

22
apps/client-e2e/src/plugins/index.js

@ -1,22 +0,0 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const { preprocessTypescript } = require('@nx/cypress/plugins/preprocessor');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
// Preprocess Typescript file using Nx helper
on('file:preprocessor', preprocessTypescript(config));
};

1
apps/client-e2e/src/support/app.po.ts

@ -1 +0,0 @@
export const getGreeting = () => cy.get('h1');

31
apps/client-e2e/src/support/commands.ts

@ -1,31 +0,0 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
declare namespace Cypress {
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

16
apps/client-e2e/src/support/index.ts

@ -1,16 +0,0 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';

10
apps/client-e2e/tsconfig.e2e.json

@ -1,10 +0,0 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}

10
apps/client-e2e/tsconfig.json

@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"files": [],
"include": [],
"references": [
{
"path": "./tsconfig.e2e.json"
}
]
}

13
apps/ui-e2e/cypress.json

@ -1,13 +0,0 @@
{
"fileServerFolder": ".",
"fixturesFolder": "./src/fixtures",
"integrationFolder": "./src/integration",
"modifyObstructiveCode": false,
"supportFile": "./src/support/index.ts",
"pluginsFile": "./src/plugins/index",
"video": true,
"videosFolder": "../../dist/cypress/apps/ui-e2e/videos",
"screenshotsFolder": "../../dist/cypress/apps/ui-e2e/screenshots",
"chromeWebSecurity": false,
"baseUrl": "http://localhost:4400"
}

33
apps/ui-e2e/eslint.config.cjs

@ -1,33 +0,0 @@
const { FlatCompat } = require('@eslint/eslintrc');
const js = require('@eslint/js');
const baseConfig = require('../../eslint.config.cjs');
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended
});
module.exports = [
{
ignores: ['**/dist']
},
...baseConfig,
...compat.extends('plugin:cypress/recommended'),
{
files: ['**/*.ts', '**/*.tsx', '**/*.js', '**/*.jsx'],
// Override or add rules here
rules: {},
languageOptions: {
parserOptions: {
project: ['apps/ui-e2e/tsconfig.json']
}
}
},
{
files: ['src/plugins/index.js'],
rules: {
'@typescript-eslint/no-var-requires': 'off',
'no-undef': 'off'
}
}
];

28
apps/ui-e2e/project.json

@ -1,28 +0,0 @@
{
"name": "ui-e2e",
"$schema": "../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "apps/ui-e2e/src",
"projectType": "application",
"tags": [],
"implicitDependencies": ["ui"],
"targets": {
"e2e": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "apps/ui-e2e/cypress.json",
"devServerTarget": "ui:storybook"
},
"configurations": {
"ci": {
"devServerTarget": "ui:storybook:ci"
}
}
},
"lint": {
"executor": "@nx/eslint:lint",
"options": {
"lintFilePatterns": ["apps/ui-e2e/**/*.{js,ts}"]
}
}
}
}

4
apps/ui-e2e/src/fixtures/example.json

@ -1,4 +0,0 @@
{
"name": "Using fixtures to represent data",
"email": "hello@cypress.io"
}

6
apps/ui-e2e/src/integration/value/value.component.spec.ts

@ -1,6 +0,0 @@
describe('ui', () => {
beforeEach(() => cy.visit('/iframe.html?id=valuecomponent--loading'));
it('should render the component', () => {
cy.get('gf-value').should('exist');
});
});

22
apps/ui-e2e/src/plugins/index.js

@ -1,22 +0,0 @@
// ***********************************************************
// This example plugins/index.js can be used to load plugins
//
// You can change the location of this file or turn off loading
// the plugins file with the 'pluginsFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/plugins-guide
// ***********************************************************
// This function is called when a project is opened or re-opened (e.g. due to
// the project's config changing)
const { preprocessTypescript } = require('@nx/cypress/plugins/preprocessor');
module.exports = (on, config) => {
// `on` is used to hook into various events Cypress emits
// `config` is the resolved Cypress config
// Preprocess Typescript file using Nx helper
on('file:preprocessor', preprocessTypescript(config));
};

33
apps/ui-e2e/src/support/commands.ts

@ -1,33 +0,0 @@
// ***********************************************
// This example commands.js shows you how to
// create various custom commands and overwrite
// existing commands.
//
// For more comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace Cypress {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
interface Chainable<Subject> {
login(email: string, password: string): void;
}
}
//
// -- This is a parent command --
Cypress.Commands.add('login', (email, password) => {
console.log('Custom command example: Login', email, password);
});
//
// -- This is a child command --
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
//
//
// -- This is a dual command --
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
//
//
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })

16
apps/ui-e2e/src/support/index.ts

@ -1,16 +0,0 @@
// ***********************************************************
// This example support/index.js is processed and
// loaded automatically before your test files.
//
// This is a great place to put global configuration and
// behavior that modifies Cypress.
//
// You can change the location of this file or turn off
// automatically serving support files with the
// 'supportFile' configuration option.
//
// You can read more here:
// https://on.cypress.io/configuration
// ***********************************************************
// Import commands.js using ES2015 syntax:
import './commands';

10
apps/ui-e2e/tsconfig.json

@ -1,10 +0,0 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"sourceMap": false,
"outDir": "../../dist/out-tsc",
"allowJs": true,
"types": ["cypress", "node"]
},
"include": ["src/**/*.ts", "src/**/*.js"]
}

402
package-lock.json

File diff suppressed because it is too large

5
package.json

@ -9,7 +9,6 @@
"affected:apps": "nx affected:apps",
"affected:build": "nx affected:build",
"affected:dep-graph": "nx affected:dep-graph",
"affected:e2e": "nx affected:e2e",
"affected:libs": "nx affected:libs",
"affected:lint": "nx affected:lint",
"affected:test": "nx affected:test",
@ -27,7 +26,6 @@
"database:setup": "npm run database:push && npm run database:seed",
"database:validate-schema": "prisma validate",
"dep-graph": "nx dep-graph",
"e2e": "ng e2e",
"extract-locales": "nx run client:extract-i18n --output-path ./apps/client/src/locales",
"format": "nx format:write",
"format:check": "nx format:check",
@ -155,7 +153,6 @@
"@nestjs/schematics": "11.0.9",
"@nestjs/testing": "11.1.8",
"@nx/angular": "21.5.1",
"@nx/cypress": "21.5.1",
"@nx/eslint-plugin": "21.5.1",
"@nx/jest": "21.5.1",
"@nx/js": "21.5.1",
@ -178,10 +175,8 @@
"@types/passport-google-oauth20": "2.0.16",
"@typescript-eslint/eslint-plugin": "8.43.0",
"@typescript-eslint/parser": "8.43.0",
"cypress": "6.2.1",
"eslint": "9.35.0",
"eslint-config-prettier": "10.1.8",
"eslint-plugin-cypress": "4.2.0",
"eslint-plugin-import": "2.32.0",
"eslint-plugin-storybook": "9.1.5",
"husky": "9.1.7",

Loading…
Cancel
Save