Исправлены ошибки сборки проекта
This commit is contained in:
parent
eb16e92a6c
commit
60b0bdbcd4
14 changed files with 148 additions and 29 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import configuration from '../configs/main-config';
|
||||
import nano = require('nano');
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import nano from 'nano';
|
||||
import { CouchDb } from './couchdb';
|
||||
|
|
|
|||
|
|
@ -12,8 +12,10 @@ import { RedmineIssuesCacheWriterService } from './issue-cache-writer/redmine-is
|
|||
import { CouchDb } from './couchdb-datasources/couchdb';
|
||||
import { Users } from './couchdb-datasources/users';
|
||||
import { Issues } from './couchdb-datasources/issues';
|
||||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineUserCacheWriterService } from './user-cache-writer/user-cache-writer.service';
|
||||
import { UsersController } from './users/users.controller';
|
||||
import { RedmineTypes } from './models/redmine-types';
|
||||
import { UsersService } from './users/users.service';
|
||||
|
||||
@Module({})
|
||||
export class EventEmitterModule implements OnModuleInit {
|
||||
|
|
@ -35,6 +37,7 @@ export class EventEmitterModule implements OnModuleInit {
|
|||
Users,
|
||||
Issues,
|
||||
RedmineUserCacheWriterService,
|
||||
UsersService,
|
||||
],
|
||||
exports: [
|
||||
EventEmitterService,
|
||||
|
|
@ -45,8 +48,9 @@ export class EventEmitterModule implements OnModuleInit {
|
|||
Users,
|
||||
Issues,
|
||||
RedmineUserCacheWriterService,
|
||||
UsersService,
|
||||
],
|
||||
controllers: [MainController],
|
||||
controllers: [MainController, UsersController],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Issues } from '../couchdb-datasources/issues';
|
||||
import { RedmineEventsGateway } from '../events/redmine-events.gateway';
|
||||
|
|
|
|||
99
libs/event-emitter/src/models/redmine-types/index.d.ts
vendored
Normal file
99
libs/event-emitter/src/models/redmine-types/index.d.ts
vendored
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/// <reference types="typescript" />
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-namespace-keyword
|
||||
export module RedmineTypes {
|
||||
export type IdAndName = {
|
||||
id: number;
|
||||
name: string;
|
||||
};
|
||||
|
||||
export type CustomField = {
|
||||
id: number;
|
||||
name: string;
|
||||
value: string;
|
||||
};
|
||||
|
||||
export type JournalDetail = {
|
||||
property: string;
|
||||
name: string;
|
||||
old_value?: string;
|
||||
new_value?: string;
|
||||
};
|
||||
|
||||
export type Journal = {
|
||||
id: number;
|
||||
user: IdAndName;
|
||||
notes?: string;
|
||||
created_on: string;
|
||||
details?: JournalDetail[];
|
||||
};
|
||||
|
||||
export type Issue = {
|
||||
id: number;
|
||||
project: IdAndName;
|
||||
tracker: IdAndName;
|
||||
status: IdAndName;
|
||||
priority: IdAndName;
|
||||
author: IdAndName;
|
||||
category: IdAndName;
|
||||
fixed_version: IdAndName;
|
||||
subject: string;
|
||||
description: string;
|
||||
start_date: string;
|
||||
done_ratio: number;
|
||||
spent_hours: number;
|
||||
total_spent_hours: number;
|
||||
custom_fields: CustomField[];
|
||||
created_on: string;
|
||||
updated_on?: string;
|
||||
closed_on?: string;
|
||||
relations?: Record<string, any>[];
|
||||
journals?: Journal[];
|
||||
};
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/prefer-namespace-keyword
|
||||
export module Unknown {
|
||||
export const num = -1;
|
||||
export const str = '';
|
||||
export const idAndName: IdAndName = {
|
||||
id: -1,
|
||||
name: str,
|
||||
};
|
||||
export const unknownName = 'Unknown';
|
||||
export const subject = 'Unknown';
|
||||
export const date = '1970-01-01T00:00:00Z';
|
||||
export const issue: Issue = {
|
||||
id: num,
|
||||
project: idAndName,
|
||||
tracker: idAndName,
|
||||
status: idAndName,
|
||||
priority: idAndName,
|
||||
author: idAndName,
|
||||
category: idAndName,
|
||||
fixed_version: idAndName,
|
||||
subject: subject,
|
||||
description: str,
|
||||
start_date: date,
|
||||
done_ratio: num,
|
||||
spent_hours: num,
|
||||
total_spent_hours: num,
|
||||
custom_fields: [],
|
||||
created_on: date,
|
||||
};
|
||||
|
||||
export const user: User = {
|
||||
id: num,
|
||||
firstname: unknownName,
|
||||
lastname: unknownName,
|
||||
mail: str,
|
||||
};
|
||||
}
|
||||
|
||||
export type User = {
|
||||
id: number;
|
||||
login: string;
|
||||
firstname: string;
|
||||
lastname: string;
|
||||
mail: string;
|
||||
};
|
||||
}
|
||||
0
libs/event-emitter/src/models/redmine-types/index.js
Normal file
0
libs/event-emitter/src/models/redmine-types/index.js
Normal file
12
libs/event-emitter/src/models/redmine-types/package.json
Normal file
12
libs/event-emitter/src/models/redmine-types/package.json
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "redmine-types",
|
||||
"version": "0.1.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"types": "index.d.ts",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Pavel Gnedov",
|
||||
"license": "MIT"
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import axios from 'axios';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { ConfigService } from '@nestjs/config';
|
||||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
|
||||
@Injectable()
|
||||
export class RedmineDataLoader {
|
||||
|
|
|
|||
|
|
@ -10,5 +10,5 @@ export type RssListenerParams = {
|
|||
|
||||
export const RssListenerDefaultParams: RssListenerParams = {
|
||||
subscriptions: [],
|
||||
updateInterval: 300000 // 5min
|
||||
}
|
||||
updateInterval: 300000, // 5min
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
import { Injectable } from "@nestjs/common";
|
||||
import { RssListenerDefaultParams, RssListenerParams, RssListenerSubscriptionParams } from "./rsslistener-params";
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { CreateSubjectsParserByRegExp } from "../subjects-parser/subjects-parser";
|
||||
import { EventsListener } from "../events/events-listener";
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import {
|
||||
RssListenerDefaultParams,
|
||||
RssListenerParams,
|
||||
RssListenerSubscriptionParams,
|
||||
} from './rsslistener-params';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import { CreateSubjectsParserByRegExp } from '../subjects-parser/subjects-parser';
|
||||
import { EventsListener } from '../events/events-listener';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const Parser = require('rss-parser');
|
||||
|
|
@ -10,14 +14,14 @@ const parser = new Parser();
|
|||
|
||||
@Injectable()
|
||||
export class RssListener implements EventsListener {
|
||||
|
||||
issues = new BehaviorSubject<number[]>([])
|
||||
issues = new BehaviorSubject<number[]>([]);
|
||||
|
||||
private updateTimeout;
|
||||
|
||||
private lastTimeUpdate: Date | null = null;
|
||||
|
||||
constructor(private config: RssListenerParams = RssListenerDefaultParams) {
|
||||
this.lastTimeUpdate = new Date();
|
||||
}
|
||||
|
||||
start(): void {
|
||||
|
|
@ -38,23 +42,27 @@ export class RssListener implements EventsListener {
|
|||
}
|
||||
|
||||
private async getIssues(): Promise<number[]> {
|
||||
const promises = this.config.subscriptions.map(sub => this.createSubscriptionPromise(sub));
|
||||
const promises = this.config.subscriptions.map((sub) =>
|
||||
this.createSubscriptionPromise(sub),
|
||||
);
|
||||
const issues = await Promise.all(promises);
|
||||
this.lastTimeUpdate = new Date();
|
||||
return this.getFlatIssueNumbers(issues);
|
||||
}
|
||||
|
||||
private async createSubscriptionPromise(subscription: RssListenerSubscriptionParams): Promise<number[]> {
|
||||
private async createSubscriptionPromise(
|
||||
subscription: RssListenerSubscriptionParams,
|
||||
): Promise<number[]> {
|
||||
const url = subscription.url;
|
||||
const regexp = new RegExp(subscription.issueNumberParser);
|
||||
const subjectParser = CreateSubjectsParserByRegExp(regexp);
|
||||
const feed = await parser.parseURL(url);
|
||||
const issueNumbers: number[] = feed.items
|
||||
.filter(item => {
|
||||
.filter((item) => {
|
||||
const itemDate = new Date(item.pubDate);
|
||||
return itemDate >= this.lastTimeUpdate;
|
||||
})
|
||||
.map(item => {
|
||||
.map((item) => {
|
||||
const issueNumber = subjectParser.getIssueNumber(item.title);
|
||||
return issueNumber;
|
||||
});
|
||||
|
|
@ -63,8 +71,8 @@ export class RssListener implements EventsListener {
|
|||
|
||||
private getFlatIssueNumbers(issues: number[][]): number[] {
|
||||
const res: number[] = [];
|
||||
issues.forEach(issueNumbers => {
|
||||
issueNumbers.forEach(num => {
|
||||
issues.forEach((issueNumbers) => {
|
||||
issueNumbers.forEach((num) => {
|
||||
if (res.indexOf(num) < 0) {
|
||||
res.push(num);
|
||||
}
|
||||
|
|
@ -72,5 +80,4 @@ export class RssListener implements EventsListener {
|
|||
});
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
import { Injectable, Logger } from '@nestjs/common';
|
||||
import { Users } from '../couchdb-datasources/users';
|
||||
import nano from 'nano';
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { UsersService } from './users.service';
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { RedmineTypes } from '@app/redmine-types/index';
|
||||
import { RedmineTypes } from '../models/redmine-types';
|
||||
import { Timestamped } from '../models/timestamped';
|
||||
import { Users } from '../couchdb-datasources/users';
|
||||
import { RedmineDataLoader } from '../redmine-data-loader/redmine-data-loader';
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@
|
|||
],
|
||||
"@app/event-emitter/*": [
|
||||
"libs/event-emitter/src/*"
|
||||
],
|
||||
"@app/redmine-types/*": [
|
||||
"libs/redmine-types/*"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue