Compare commits
6 Commits
dev
...
feature/op
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
60f4069aea | ||
|
|
d7ba323355 | ||
|
|
49715531d9 | ||
|
|
fba7c240b1 | ||
|
|
1539183662 | ||
|
|
6f2778794d |
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
@ -13,9 +13,9 @@
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": true,
|
||||
"source.fixAll.eslint": true,
|
||||
"source.removeUnusedImports": true
|
||||
"source.fixAll": "explicit",
|
||||
"source.fixAll.eslint": "explicit",
|
||||
"source.removeUnusedImports": "explicit"
|
||||
},
|
||||
"workbench.editor.labelFormat": "short",
|
||||
"eslint.workingDirectories": [{ "directory": "apps/web", "changeProcessCWD": true }],
|
||||
|
||||
6
apps/api/.dockerignore
Normal file
6
apps/api/.dockerignore
Normal file
@ -0,0 +1,6 @@
|
||||
Dockerfile
|
||||
.dockerignore
|
||||
node_modules
|
||||
npm-debug.log
|
||||
dist
|
||||
README.md
|
||||
13
apps/api/.eslintrc.js
Normal file
13
apps/api/.eslintrc.js
Normal file
@ -0,0 +1,13 @@
|
||||
const { createConfig } = require('@vchikalkin/eslint-config-awesome');
|
||||
|
||||
module.exports = createConfig('typescript', {
|
||||
parserOptions: {
|
||||
project: './tsconfig.json',
|
||||
tsconfigRootDir: __dirname,
|
||||
},
|
||||
ignorePatterns: ['*.config.js', '.eslintrc.js'],
|
||||
rules: {
|
||||
'import/no-duplicates': 'off',
|
||||
'import/consistent-type-specifier-style': 'off',
|
||||
},
|
||||
});
|
||||
56
apps/api/.gitignore
vendored
Normal file
56
apps/api/.gitignore
vendored
Normal file
@ -0,0 +1,56 @@
|
||||
# compiled output
|
||||
/dist
|
||||
/node_modules
|
||||
/build
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
pnpm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
|
||||
# Tests
|
||||
/coverage
|
||||
/.nyc_output
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
|
||||
# dotenv environment variable files
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
|
||||
# temp directory
|
||||
.temp
|
||||
.tmp
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
4
apps/api/.prettierrc
Normal file
4
apps/api/.prettierrc
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
||||
41
apps/api/Dockerfile
Normal file
41
apps/api/Dockerfile
Normal file
@ -0,0 +1,41 @@
|
||||
# This Dockerfile is copy-pasted into our main docs at /docs/handbook/deploying-with-docker.
|
||||
# Make sure you update both files!
|
||||
|
||||
FROM node:alpine AS builder
|
||||
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
|
||||
RUN apk add --no-cache libc6-compat
|
||||
RUN apk update
|
||||
# Set working directory
|
||||
WORKDIR /app
|
||||
RUN yarn global add turbo
|
||||
COPY . .
|
||||
RUN turbo prune --scope=api --docker
|
||||
|
||||
# Add lockfile and package.json's of isolated subworkspace
|
||||
FROM node:alpine AS installer
|
||||
RUN apk add --no-cache libc6-compat
|
||||
RUN apk update
|
||||
WORKDIR /app
|
||||
|
||||
# First install dependencies (as they change less often)
|
||||
COPY .gitignore .gitignore
|
||||
COPY --from=builder /app/out/json/ .
|
||||
COPY --from=builder /app/out/yarn.lock ./yarn.lock
|
||||
RUN yarn install
|
||||
|
||||
# Build the project and its dependencies
|
||||
COPY --from=builder /app/out/full/ .
|
||||
COPY turbo.json turbo.json
|
||||
# COPY .env .env
|
||||
RUN yarn turbo run build --filter=api...
|
||||
|
||||
FROM node:alpine AS runner
|
||||
WORKDIR /app
|
||||
|
||||
# Don't run production as root
|
||||
RUN addgroup --system --gid 1001 nestjs
|
||||
RUN adduser --system --uid 1001 nestjs
|
||||
USER nestjs
|
||||
COPY --from=installer /app .
|
||||
|
||||
CMD node apps/api/dist/main.js
|
||||
73
apps/api/README.md
Normal file
73
apps/api/README.md
Normal file
@ -0,0 +1,73 @@
|
||||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[](https://opencollective.com/nest#backer)
|
||||
[](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ yarn install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ yarn run start
|
||||
|
||||
# watch mode
|
||||
$ yarn run start:dev
|
||||
|
||||
# production mode
|
||||
$ yarn run start:prod
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ yarn run test
|
||||
|
||||
# e2e tests
|
||||
$ yarn run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ yarn run test:cov
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
||||
8
apps/api/nest-cli.json
Normal file
8
apps/api/nest-cli.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src",
|
||||
"compilerOptions": {
|
||||
"deleteOutDir": true
|
||||
}
|
||||
}
|
||||
73
apps/api/package.json
Normal file
73
apps/api/package.json
Normal file
@ -0,0 +1,73 @@
|
||||
{
|
||||
"name": "api",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/cache-manager": "^2.2.1",
|
||||
"@nestjs/common": "^10.0.0",
|
||||
"@nestjs/config": "^3.2.0",
|
||||
"@nestjs/core": "^10.0.0",
|
||||
"@nestjs/platform-express": "^10.0.0",
|
||||
"@nestjs/platform-fastify": "^10.3.3",
|
||||
"cache-manager": "^5.4.0",
|
||||
"cache-manager-ioredis": "^2.1.0",
|
||||
"ioredis": "^5.3.2",
|
||||
"reflect-metadata": "^0.2.0",
|
||||
"rxjs": "^7.8.1",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^10.0.0",
|
||||
"@nestjs/schematics": "^10.0.0",
|
||||
"@nestjs/testing": "^10.0.0",
|
||||
"@types/jest": "^29.5.2",
|
||||
"@types/node": "^20.3.1",
|
||||
"@types/supertest": "^6.0.0",
|
||||
"@vchikalkin/eslint-config-awesome": "^1.1.5",
|
||||
"eslint": "^8.51.0",
|
||||
"fastify": "^4.26.1",
|
||||
"jest": "^29.5.0",
|
||||
"prettier": "^3.0.0",
|
||||
"source-map-support": "^0.5.21",
|
||||
"supertest": "^6.3.3",
|
||||
"ts-jest": "^29.1.0",
|
||||
"ts-loader": "^9.4.3",
|
||||
"ts-node": "^10.9.1",
|
||||
"tsconfig-paths": "^4.2.0",
|
||||
"typescript": "^5.1.3"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
||||
16
apps/api/src/app.module.ts
Normal file
16
apps/api/src/app.module.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { ProxyModule } from './proxy/proxy.module';
|
||||
import { Global, Module } from '@nestjs/common';
|
||||
import { ConfigModule } from '@nestjs/config';
|
||||
|
||||
@Global()
|
||||
@Module({
|
||||
imports: [
|
||||
ConfigModule.forRoot({
|
||||
isGlobal: true,
|
||||
}),
|
||||
ProxyModule,
|
||||
],
|
||||
providers: [],
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
||||
export class AppModule {}
|
||||
3
apps/api/src/config/env.ts
Normal file
3
apps/api/src/config/env.ts
Normal file
@ -0,0 +1,3 @@
|
||||
import envSchema from './schema/env';
|
||||
|
||||
export const env = envSchema.parse(process.env);
|
||||
16
apps/api/src/config/schema/env.ts
Normal file
16
apps/api/src/config/schema/env.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
const envSchema = z.object({
|
||||
CACHE_TTL: z
|
||||
.string()
|
||||
.transform((val) => Number.parseInt(val, 10))
|
||||
.default('900'),
|
||||
REDIS_HOST: z.string(),
|
||||
REDIS_PORT: z
|
||||
.string()
|
||||
.transform((val) => Number.parseInt(val, 10))
|
||||
.default('6379'),
|
||||
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||
});
|
||||
|
||||
export default envSchema;
|
||||
13
apps/api/src/main.ts
Normal file
13
apps/api/src/main.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import { AppModule } from './app.module';
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import type { NestFastifyApplication } from '@nestjs/platform-fastify';
|
||||
import { FastifyAdapter } from '@nestjs/platform-fastify';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestFastifyApplication>(
|
||||
AppModule,
|
||||
new FastifyAdapter(),
|
||||
);
|
||||
await app.listen(3001);
|
||||
}
|
||||
bootstrap();
|
||||
37
apps/api/src/proxy/proxy.controller.ts
Normal file
37
apps/api/src/proxy/proxy.controller.ts
Normal file
@ -0,0 +1,37 @@
|
||||
import type { GQLRequest } from './types';
|
||||
import { CACHE_MANAGER } from '@nestjs/cache-manager';
|
||||
import { All, Controller, Inject, Req, Res } from '@nestjs/common';
|
||||
import { Cache } from 'cache-manager';
|
||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { env } from 'src/config/env';
|
||||
|
||||
@Controller('proxy')
|
||||
export class ProxyController {
|
||||
constructor(@Inject(CACHE_MANAGER) private readonly cacheManager: Cache) {}
|
||||
@All('/graphql')
|
||||
public async graphql(@Req() req: FastifyRequest, @Res() reply: FastifyReply) {
|
||||
const { operationName, query, variables } = req.body as GQLRequest;
|
||||
|
||||
const key = `${operationName} ${JSON.stringify(variables)}`;
|
||||
const cached = await this.cacheManager.get(key);
|
||||
|
||||
if (cached) {
|
||||
return reply.send(cached);
|
||||
}
|
||||
|
||||
const response = await fetch(env.URL_CRM_GRAPHQL_DIRECT, {
|
||||
body: JSON.stringify({ operationName, query, variables }),
|
||||
headers: {
|
||||
Authorization: req.headers.authorization,
|
||||
'Content-Type': 'application/json',
|
||||
Cookie: req.headers.cookie,
|
||||
},
|
||||
method: req.method,
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (data) await this.cacheManager.set(key, data);
|
||||
|
||||
return reply.send(data);
|
||||
}
|
||||
}
|
||||
20
apps/api/src/proxy/proxy.module.ts
Normal file
20
apps/api/src/proxy/proxy.module.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import { ProxyController } from './proxy.controller';
|
||||
import { CacheModule } from '@nestjs/cache-manager';
|
||||
import { Module } from '@nestjs/common';
|
||||
import * as redisStore from 'cache-manager-ioredis';
|
||||
import type { RedisOptions } from 'ioredis';
|
||||
import { env } from 'src/config/env';
|
||||
|
||||
@Module({
|
||||
controllers: [ProxyController],
|
||||
imports: [
|
||||
CacheModule.register<RedisOptions>({
|
||||
host: env.REDIS_HOST,
|
||||
port: env.REDIS_PORT,
|
||||
store: redisStore,
|
||||
ttl: env.CACHE_TTL,
|
||||
}),
|
||||
],
|
||||
})
|
||||
// eslint-disable-next-line @typescript-eslint/no-extraneous-class
|
||||
export class ProxyModule {}
|
||||
5
apps/api/src/proxy/types.ts
Normal file
5
apps/api/src/proxy/types.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export type GQLRequest = {
|
||||
operationName: string;
|
||||
query: string;
|
||||
variables: string;
|
||||
};
|
||||
4
apps/api/tsconfig.build.json
Normal file
4
apps/api/tsconfig.build.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
||||
22
apps/api/tsconfig.json
Normal file
22
apps/api/tsconfig.json
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "ES2021",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
},
|
||||
"exclude": ["node_modules"]
|
||||
}
|
||||
@ -32,6 +32,7 @@ ARG SENTRY_DSN
|
||||
ARG SENTRYCLI_CDNURL
|
||||
ARG URL_GET_USER_DIRECT
|
||||
ARG URL_CRM_GRAPHQL_DIRECT
|
||||
ARG URL_CRM_GRAPHQL_PROXY
|
||||
ARG URL_CRM_CREATEKP_DIRECT
|
||||
ARG URL_CRM_DOWNLOADKP_BASE
|
||||
ARG URL_CORE_FINGAP_DIRECT
|
||||
|
||||
@ -10,6 +10,7 @@ const envSchema = z.object({
|
||||
URL_CRM_CREATEKP_DIRECT: z.string(),
|
||||
URL_CRM_DOWNLOADKP_BASE: z.string(),
|
||||
URL_CRM_GRAPHQL_DIRECT: z.string(),
|
||||
URL_CRM_GRAPHQL_PROXY: z.string(),
|
||||
URL_ELT_KASKO_DIRECT: z.string(),
|
||||
URL_ELT_OSAGO_DIRECT: z.string(),
|
||||
URL_GET_USER_DIRECT: z.string(),
|
||||
|
||||
@ -15,6 +15,7 @@ const serverRuntimeConfigSchema = envSchema.pick({
|
||||
URL_CORE_FINGAP_DIRECT: true,
|
||||
URL_CRM_CREATEKP_DIRECT: true,
|
||||
URL_CRM_GRAPHQL_DIRECT: true,
|
||||
URL_CRM_GRAPHQL_PROXY: true,
|
||||
URL_ELT_KASKO_DIRECT: true,
|
||||
URL_ELT_OSAGO_DIRECT: true,
|
||||
URL_GET_USER_DIRECT: true,
|
||||
|
||||
@ -13,7 +13,6 @@ export function withBasePath(path: string) {
|
||||
function getUrls() {
|
||||
if (isServer()) {
|
||||
const {
|
||||
URL_CRM_GRAPHQL_DIRECT,
|
||||
URL_GET_USER_DIRECT,
|
||||
URL_CORE_FINGAP_DIRECT,
|
||||
URL_1C_TRANSTAX_DIRECT,
|
||||
@ -22,6 +21,7 @@ function getUrls() {
|
||||
PORT,
|
||||
URL_ELT_KASKO_DIRECT,
|
||||
URL_ELT_OSAGO_DIRECT,
|
||||
URL_CRM_GRAPHQL_PROXY,
|
||||
} = serverRuntimeConfigSchema.parse(serverRuntimeConfig);
|
||||
|
||||
return {
|
||||
@ -33,7 +33,7 @@ function getUrls() {
|
||||
URL_CORE_FINGAP: URL_CORE_FINGAP_DIRECT,
|
||||
URL_CRM_CREATEKP: URL_CRM_CREATEKP_DIRECT,
|
||||
URL_CRM_DOWNLOADKP: withBasePath(urls.URL_CRM_DOWNLOADKP_PROXY),
|
||||
URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_DIRECT,
|
||||
URL_CRM_GRAPHQL: URL_CRM_GRAPHQL_PROXY,
|
||||
URL_ELT_KASKO: URL_ELT_KASKO_DIRECT,
|
||||
URL_ELT_OSAGO: URL_ELT_OSAGO_DIRECT,
|
||||
URL_GET_USER: URL_GET_USER_DIRECT,
|
||||
|
||||
@ -38,8 +38,8 @@ module.exports = withSentryConfig({
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
destination: env.URL_CRM_GRAPHQL_DIRECT,
|
||||
source: urls.URL_CRM_GRAPHQL_PROXY,
|
||||
destination: env.URL_CRM_GRAPHQL_PROXY + '/:path*',
|
||||
source: urls.URL_CRM_GRAPHQL_PROXY + '/:path*',
|
||||
},
|
||||
{
|
||||
destination: env.URL_CRM_DOWNLOADKP_BASE + '/:path*',
|
||||
|
||||
@ -4,14 +4,11 @@ import type { ProcessContext } from '../types';
|
||||
import { createValidationSchema } from './validation';
|
||||
import { selectRequirementTelematic } from '@/config/default-options';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { debouncedReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction, toJS } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $tables } = store;
|
||||
|
||||
@ -23,7 +20,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
|
||||
return;
|
||||
}
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
@ -80,7 +77,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
reaction(
|
||||
() => $calculation.$values.getValues(['leasingPeriod', 'leaseObjectType']),
|
||||
async ({ leasingPeriod, leaseObjectType }) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
@ -164,7 +161,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
leasingPeriod,
|
||||
plPriceRub,
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
@ -277,7 +274,7 @@ export default function reactions({ store, apolloClient }: ProcessContext) {
|
||||
leaseObjectType: leaseObjectTypeId,
|
||||
engineType,
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
const {
|
||||
data: { evo_addproduct_types: trackerTypes },
|
||||
} = await apolloClient.query({
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import type { ValidationContext } from '../../types';
|
||||
import type { ElementsTypes } from '@/Components/Calculation/config/map/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import dayjs from 'dayjs';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
|
||||
export type ProductId = ElementsTypes['selectProduct'];
|
||||
|
||||
@ -25,7 +25,7 @@ export default function helper({ apolloClient, user }: ValidationContext) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_coefficients },
|
||||
|
||||
@ -2,13 +2,9 @@ import type { ProcessContext } from '../../types';
|
||||
import helper from '../lib/helper';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { round } from 'tools';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions(context: ProcessContext) {
|
||||
const { store, apolloClient } = context;
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -3,6 +3,7 @@ import defaultValues from '@/config/default-values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import dayjs from 'dayjs';
|
||||
import { first, sort } from 'radash';
|
||||
|
||||
@ -79,7 +80,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
||||
},
|
||||
|
||||
async getRates({ tarif: tarifId }: GetRatesInputValues) {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_rates },
|
||||
@ -134,7 +135,7 @@ export default function helper({ apolloClient }: Pick<ProcessContext, 'apolloCli
|
||||
floatingRate,
|
||||
partialVAT,
|
||||
}: GetTarifInputValues) {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_tarifs = [] },
|
||||
|
||||
@ -4,15 +4,12 @@ import { crmTools } from '@/graphql/crm.tools';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { SEASON_TYPES } from '@/process/payments/lib/seasons-constants';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { diff, sift } from 'radash';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions({ store, apolloClient, user }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -358,7 +355,7 @@ export default function reactions({ store, apolloClient, user }: ProcessContext)
|
||||
reaction(
|
||||
() => $calculation.element('selectQuote').getValue(),
|
||||
async (quoteId) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
let {
|
||||
data: { evo_baseproducts },
|
||||
|
||||
@ -4,12 +4,8 @@ import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableDebouncedReaction, disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { comparer, reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function valuesReactions({ store, apolloClient, trpcClient }: ProcessContext) {
|
||||
let abortController = new AbortController();
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -6,8 +6,8 @@ import { STALE_TIME } from '@/constants/request';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import type { QueryFunctionContext } from '@tanstack/react-query';
|
||||
import dayjs from 'dayjs';
|
||||
import { flatten } from 'tools/object';
|
||||
|
||||
type GetFingapRisksInputValues = Pick<
|
||||
@ -38,7 +38,7 @@ export default function helper({
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetAddproductTypesDocument,
|
||||
variables: {
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -1,12 +1,8 @@
|
||||
import helper from '../lib/helper';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { comparer, reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export default function reactions({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
const { getFingapRisks } = helper({ apolloClient, queryClient });
|
||||
|
||||
|
||||
@ -6,14 +6,12 @@ import { getTransTax } from '@/api/1c/query';
|
||||
import { selectObjectCategoryTax } from '@/config/default-options';
|
||||
import { STALE_TIME } from '@/constants/request';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
@ -239,8 +237,6 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
leaseObjectType,
|
||||
// eslint-disable-next-line sonarjs/cognitive-complexity
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
|
||||
let evo_region: CRMTypes.GetRegionQuery['evo_region'];
|
||||
if (objectRegionRegistrationId) {
|
||||
const { data } = await apolloClient.query({
|
||||
@ -254,7 +250,7 @@ export function common({ store, apolloClient, queryClient }: ProcessContext) {
|
||||
data: { evo_addproduct_types },
|
||||
} = await apolloClient.query({
|
||||
query: CRMTypes.GetRegistrationTypesDocument,
|
||||
variables: { currentDate },
|
||||
variables: { currentDate: getCurrentISODate() },
|
||||
});
|
||||
|
||||
const options = evo_addproduct_types?.filter((x) => {
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
import type { User } from '@/api/user/types';
|
||||
import { crmTools } from '@/graphql/crm.tools';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
export async function getInitialData({ query }: ApolloClient<object>, user: User) {
|
||||
const leadsQuery = query({
|
||||
@ -17,7 +17,7 @@ export async function getInitialData({ query }: ApolloClient<object>, user: User
|
||||
const productsQuery = query({
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetProductsDocument,
|
||||
variables: { currentDate: dayjs().utc(false).toISOString() },
|
||||
variables: { currentDate: getCurrentISODate() },
|
||||
});
|
||||
const systemUserQuery = query({
|
||||
fetchPolicy: 'network-only',
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
/* eslint-disable canonical/sort-keys */
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { useStore } from '@/stores/hooks';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { useApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { useEffect } from 'react';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@ -3,14 +3,11 @@
|
||||
import { notification } from '@/Components/Common/Notification';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { uid } from 'radash';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
const NOTIFICATION_KEY = uid(7);
|
||||
|
||||
export function common({ store, apolloClient }: ProcessContext) {
|
||||
@ -67,7 +64,7 @@ export function common({ store, apolloClient }: ProcessContext) {
|
||||
firstPaymentPerc,
|
||||
model: modelId,
|
||||
}) => {
|
||||
const currentDate = dayjs().utc(false).toISOString();
|
||||
const currentDate = getCurrentISODate();
|
||||
|
||||
const {
|
||||
data: { evo_addproduct_types },
|
||||
|
||||
@ -1,15 +1,12 @@
|
||||
import type { AgentsFields, AgentsRewardConditionsFields, AgentsSumFields } from './types';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type RootStore from '@/stores/root';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { comparer, reaction } from 'mobx';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function fillAgentRewardReaction(
|
||||
store: RootStore,
|
||||
apolloClient: ApolloClient<object>,
|
||||
@ -44,7 +41,7 @@ export function fillAgentRewardReaction(
|
||||
query: CRMTypes.GetRewardConditionsDocument,
|
||||
variables: {
|
||||
agentid,
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -4,15 +4,11 @@ import * as fillAgentsFromLead from '../lib/fill-agents-from-lead';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { disposableReaction } from '@/utils/mobx';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
|
||||
const { fillIndAgent, fillCalcBroker, fillCalcDoubleAgent, fillFinDepartment } = fillAgentsFromLead;
|
||||
const { fillAgentRewardReaction, fillAgentRewardSummReaction } = createReactions;
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
class Helper {
|
||||
public enabled: boolean;
|
||||
/**
|
||||
|
||||
@ -2,13 +2,9 @@ import * as createReactions from '../lib/create-reactions';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ProcessContext } from '@/process/types';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { reaction } from 'mobx';
|
||||
import { sift } from 'radash';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
export function common({ store, apolloClient }: ProcessContext) {
|
||||
const { $calculation, $process } = store;
|
||||
|
||||
|
||||
@ -4,14 +4,11 @@ import type { ValidationContext } from '../types';
|
||||
import type { Elements } from '@/Components/Calculation/config/map/values';
|
||||
import ValuesSchema from '@/config/schema/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import { normalizeOptions } from '@/utils/entity';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import type { RefinementCtx } from 'zod';
|
||||
import { z } from 'zod';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx }) {
|
||||
return {
|
||||
async validateRewardSum({
|
||||
@ -32,7 +29,7 @@ function helper({ apolloClient, ctx }: ValidationContext & { ctx: RefinementCtx
|
||||
query: CRMTypes.GetRewardConditionsDocument,
|
||||
variables: {
|
||||
agentid,
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@ -5,6 +5,7 @@ import { ESN, NSIB_MAX, VAT } from '@/constants/values';
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import helper from '@/process/calculate/lib/helper';
|
||||
import { createCurrencyUtility } from '@/utils/currency';
|
||||
import { getCurrentISODate } from '@/utils/date';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
import { min, sum } from 'radash';
|
||||
@ -126,7 +127,7 @@ export async function createRequestData({
|
||||
await apolloClient.query({
|
||||
query: CRMTypes.GetCoefficientsDocument,
|
||||
variables: {
|
||||
currentDate: currentDate.toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
})
|
||||
).data.evo_coefficients
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
import * as CRMTypes from '@/graphql/crm.types';
|
||||
import type { ApolloClient } from '@apollo/client';
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
|
||||
dayjs.extend(utc);
|
||||
import { getCurrentISODate } from './date';
|
||||
|
||||
type Context = {
|
||||
apolloClient: ApolloClient<object>;
|
||||
@ -36,7 +33,7 @@ export function createCurrencyUtility({ apolloClient }: Context) {
|
||||
fetchPolicy: 'network-only',
|
||||
query: CRMTypes.GetCurrencyChangesDocument,
|
||||
variables: {
|
||||
currentDate: dayjs().utc(false).toISOString(),
|
||||
currentDate: getCurrentISODate(),
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
16
apps/web/utils/date.ts
Normal file
16
apps/web/utils/date.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import dayjs from 'dayjs';
|
||||
import utc from 'dayjs/plugin/utc';
|
||||
|
||||
dayjs.extend(utc);
|
||||
|
||||
function _currentDate() {
|
||||
return dayjs().utc(false).hour(5).minute(0).second(0).millisecond(0);
|
||||
}
|
||||
|
||||
export function getCurrentISODate() {
|
||||
return _currentDate().toISOString();
|
||||
}
|
||||
|
||||
export function getCurrentDate() {
|
||||
return _currentDate().toDate();
|
||||
}
|
||||
@ -8,6 +8,7 @@ services:
|
||||
- SENTRYCLI_CDNURL=${SENTRYCLI_CDNURL}
|
||||
- URL_GET_USER_DIRECT=${URL_GET_USER_DIRECT}
|
||||
- URL_CRM_GRAPHQL_DIRECT=${URL_CRM_GRAPHQL_DIRECT}
|
||||
- URL_CRM_GRAPHQL_PROXY=${URL_CRM_GRAPHQL_PROXY}
|
||||
- URL_CRM_CREATEKP_DIRECT=${URL_CRM_CREATEKP_DIRECT}
|
||||
- URL_CRM_DOWNLOADKP_BASE=${URL_CRM_DOWNLOADKP_BASE}
|
||||
- URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT}
|
||||
@ -23,6 +24,7 @@ services:
|
||||
- SENTRYCLI_CDNURL=${SENTRYCLI_CDNURL}
|
||||
- URL_GET_USER_DIRECT=${URL_GET_USER_DIRECT}
|
||||
- URL_CRM_GRAPHQL_DIRECT=${URL_CRM_GRAPHQL_DIRECT}
|
||||
- URL_CRM_GRAPHQL_PROXY=${URL_CRM_GRAPHQL_PROXY}
|
||||
- URL_CRM_CREATEKP_DIRECT=${URL_CRM_CREATEKP_DIRECT}
|
||||
- URL_CRM_DOWNLOADKP_BASE=${URL_CRM_DOWNLOADKP_BASE}
|
||||
- URL_CORE_FINGAP_DIRECT=${URL_CORE_FINGAP_DIRECT}
|
||||
@ -36,6 +38,30 @@ services:
|
||||
- calc_network
|
||||
- auth_network
|
||||
restart: always
|
||||
depends_on:
|
||||
- api
|
||||
|
||||
api:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: ./apps/api/Dockerfile
|
||||
environment:
|
||||
- REDIS_HOST=redis
|
||||
- CACHE_TTL=${CACHE_TTL}
|
||||
- URL_CRM_GRAPHQL_DIRECT=${URL_CRM_GRAPHQL_DIRECT}
|
||||
restart: always
|
||||
networks:
|
||||
- calc_network
|
||||
depends_on:
|
||||
- redis
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
environment:
|
||||
ALLOW_EMPTY_PASSWORD: 'yes'
|
||||
restart: always
|
||||
networks:
|
||||
- calc_network
|
||||
|
||||
networks:
|
||||
calc_network:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user