Skip to content

Commit

Permalink
Merge pull request #106 from line/dev
Browse files Browse the repository at this point in the history
beta release: 3.2350.24-beta
  • Loading branch information
h4l-yup authored Dec 14, 2023
2 parents bf918e3 + a0604a6 commit b979999
Show file tree
Hide file tree
Showing 24 changed files with 149 additions and 79 deletions.
1 change: 0 additions & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"bcrypt": "^5.1.1",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"dayjs": "^1.11.10",
"exceljs": "^4.4.0",
"fast-csv": "^4.3.6",
"joi": "^17.11.0",
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/common/entities/common.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* License for the specific language governing permissions and limitations
* under the License.
*/
import dayjs from 'dayjs';
import { DateTime } from 'luxon';
import {
BeforeInsert,
BeforeUpdate,
Expand All @@ -38,12 +38,12 @@ export abstract class CommonEntity {

@BeforeInsert()
beforeInsertHook() {
this.createdAt = dayjs().toDate();
this.updatedAt = dayjs().toDate();
this.createdAt = DateTime.utc().toJSDate();
this.updatedAt = DateTime.utc().toJSDate();
}

@BeforeUpdate()
beforeUpdateHook() {
this.updatedAt = dayjs().toDate();
this.updatedAt = DateTime.utc().toJSDate();
}
}
4 changes: 2 additions & 2 deletions apps/api/src/domains/auth/auth.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { faker } from '@faker-js/faker';
import { Test } from '@nestjs/testing';
import dayjs from 'dayjs';
import { DateTime } from 'luxon';

import { getMockProvider } from '@/test-utils/util-functions';
import { TenantService } from '../tenant/tenant.service';
Expand Down Expand Up @@ -59,7 +59,7 @@ describe('AuthController', () => {
it('sendCode', async () => {
jest
.spyOn(MockAuthService, 'sendEmailCode')
.mockResolvedValue(dayjs().format());
.mockResolvedValue(DateTime.utc().toISO());

const dto = new EmailVerificationMailingRequestDto();
dto.email = faker.internet.email();
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/domains/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { ConfigService } from '@nestjs/config';
import { JwtService } from '@nestjs/jwt';
import { AxiosError } from 'axios';
import * as bcrypt from 'bcrypt';
import dayjs from 'dayjs';
import { DateTime } from 'luxon';
import { catchError, lastValueFrom, map } from 'rxjs';
import { Transactional } from 'typeorm-transactional';

Expand Down Expand Up @@ -90,9 +90,9 @@ export class AuthService {
});
await this.emailVerificationMailingService.send({ code, email });

return dayjs()
.add(5 * 60, 'seconds')
.format();
return DateTime.utc()
.plus({ seconds: 5 * 60 })
.toISO();
}

async verifyEmailCode({ code, email }: VerifyEmailCodeDto) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
IsObject,
IsOptional,
IsString,
MaxLength,
MinLength,
ValidateNested,
} from 'class-validator';
Expand Down Expand Up @@ -90,11 +91,13 @@ export class CreateChannelRequestDto {
@ApiProperty()
@IsString()
@MinLength(1)
@MaxLength(20)
name: string;

@ApiProperty({ nullable: true })
@IsNullable()
@IsString()
@MaxLength(50)
description: string | null;

@ApiProperty({ required: false, nullable: true, type: ImageConfigRequestDto })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*/
import { ApiProperty } from '@nestjs/swagger';
import { IsObject, IsString, MinLength } from 'class-validator';
import { IsObject, IsString, MaxLength, MinLength } from 'class-validator';

import { IsNullable } from '@/domains/user/decorators';
import { ImageConfigRequestDto } from './image-config-request.dto';
Expand All @@ -23,11 +23,13 @@ export class UpdateChannelRequestDto {
@ApiProperty()
@IsString()
@MinLength(1)
@MaxLength(20)
name: string;

@ApiProperty({ nullable: true })
@IsNullable()
@IsString()
@MaxLength(50)
description: string | null;

@ApiProperty({ nullable: true, type: ImageConfigRequestDto })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@
* under the License.
*/
import { ApiProperty } from '@nestjs/swagger';
import { IsString } from 'class-validator';
import { IsString, MaxLength, MinLength } from 'class-validator';

export class CreateOptionRequestDto {
@ApiProperty()
@IsString()
@MinLength(1)
@MaxLength(20)
name: string;

@ApiProperty()
@IsString()
@MinLength(1)
@MaxLength(20)
key: string;
}
6 changes: 3 additions & 3 deletions apps/api/src/domains/feedback/feedback.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import {
UseGuards,
} from '@nestjs/common';
import { ApiOkResponse, ApiParam } from '@nestjs/swagger';
import dayjs from 'dayjs';
import { FastifyReply } from 'fastify';
import { DateTime } from 'luxon';

import { ApiKeyAuthGuard } from '@/domains/auth/guards';
import { ChannelService } from '../channel/channel/channel.service';
Expand Down Expand Up @@ -144,8 +144,8 @@ export class FeedbackController {
});
const stream = streamableFile.getStream();

const filename = `UFB_${projectName}_${channelName}_Feedback_${dayjs().format(
'YYYY-MM-DD',
const filename = `UFB_${projectName}_${channelName}_Feedback_${DateTime.utc().toFormat(
'yyyy-MM-dd',
)}.${type}`;
res.header('Content-Disposition', `attachment; filename="${filename}"`);

Expand Down
12 changes: 6 additions & 6 deletions apps/api/src/domains/feedback/feedback.mysql.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import dayjs from 'dayjs';
import { DateTime } from 'luxon';
import { ClsService } from 'nestjs-cls';
import type { IPaginationMeta, Pagination } from 'nestjs-typeorm-paginate';
import { Brackets, QueryFailedError, Repository } from 'typeorm';
Expand Down Expand Up @@ -291,7 +291,7 @@ export class FeedbackMySQLService {

return query;
},
updatedAt: () => `'${dayjs().format('YYYY-MM-DD HH:mm:ss')}'`,
updatedAt: () => `'${DateTime.utc().toFormat('yyyy-MM-dd HH:mm:ss')}'`,
})
.where('id = :feedbackId', { feedbackId })
.execute();
Expand All @@ -316,12 +316,12 @@ export class FeedbackMySQLService {

await this.feedbackRepository.save({
...feedback,
updatedAt: dayjs().format('YYYY-MM-DD HH:mm:ss'),
updatedAt: DateTime.utc().toFormat('yyyy-MM-dd HH:mm:ss'),
});

await this.issueRepository.update(dto.issueId, {
feedbackCount: () => 'feedback_count + 1',
updatedAt: () => `'${dayjs().format('YYYY-MM-DD HH:mm:ss')}'`,
updatedAt: () => `'${DateTime.utc().toFormat('yyyy-MM-dd HH:mm:ss')}'`,
});
} catch (e) {
if (e instanceof QueryFailedError) {
Expand Down Expand Up @@ -353,12 +353,12 @@ export class FeedbackMySQLService {

await this.feedbackRepository.save({
...feedback,
updatedAt: dayjs().format('YYYY-MM-DD HH:mm:ss'),
updatedAt: DateTime.utc().toFormat('yyyy-MM-dd HH:mm:ss'),
});

await this.issueRepository.update(dto.issueId, {
feedbackCount: () => 'feedback_count - 1',
updatedAt: () => `'${dayjs().format('YYYY-MM-DD HH:mm:ss')}'`,
updatedAt: () => `'${DateTime.utc().toFormat('yyyy-MM-dd HH:mm:ss')}'`,
});
} catch (e) {
if (e instanceof QueryFailedError) {
Expand Down
8 changes: 4 additions & 4 deletions apps/api/src/domains/feedback/feedback.os.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
import { BadRequestException, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import dayjs from 'dayjs';
import { DateTime } from 'luxon';
import type { IPaginationMeta, Pagination } from 'nestjs-typeorm-paginate';
import { In, Repository } from 'typeorm';

Expand Down Expand Up @@ -216,8 +216,8 @@ export class FeedbackOSService {
const osFeedbackData = {
...feedback.rawData,
id: feedback.id,
createdAt: dayjs().toISOString(),
updatedAt: dayjs().toISOString(),
createdAt: DateTime.utc().toISO(),
updatedAt: DateTime.utc().toISO(),
};

return await this.osRepository.createData({
Expand Down Expand Up @@ -304,7 +304,7 @@ export class FeedbackOSService {

async upsertFeedbackItem(dto: UpdateFeedbackESDto) {
const { feedbackId, data, channelId } = dto;
data.updatedAt = dayjs().toISOString();
data.updatedAt = DateTime.utc().toISO();
await this.osRepository.updateData({
id: feedbackId.toString(),
index: channelId.toString(),
Expand Down
5 changes: 2 additions & 3 deletions apps/api/src/domains/feedback/feedback.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import {
StreamableFile,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import dayjs from 'dayjs';
import * as ExcelJS from 'exceljs';
import * as fastcsv from 'fast-csv';
import { DateTime } from 'luxon';
Expand Down Expand Up @@ -521,7 +520,7 @@ export class FeedbackService {
await this.feedbackOSService.upsertFeedbackItem({
channelId: dto.channelId,
feedbackId: dto.feedbackId,
data: { updatedAt: dayjs().toISOString() },
data: { updatedAt: DateTime.utc().toISO() },
});
}
}
Expand All @@ -534,7 +533,7 @@ export class FeedbackService {
await this.feedbackOSService.upsertFeedbackItem({
channelId: dto.channelId,
feedbackId: dto.feedbackId,
data: { updatedAt: dayjs().toISOString() },
data: { updatedAt: DateTime.utc().toISO() },
});
}
}
Expand Down
10 changes: 7 additions & 3 deletions apps/api/src/domains/migration/migration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { Inject, Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Client } from '@opensearch-project/opensearch';
import dayjs from 'dayjs';
import { DateTime } from 'luxon';
import { Repository } from 'typeorm';

import { OpensearchRepository } from '@/common/repositories';
Expand Down Expand Up @@ -62,8 +62,12 @@ export class MigrationService {
id: feedback.id,
...feedback.rawData,
...feedback.additionalData,
createdAt: dayjs(feedback.createdAt).format('YYYY-MM-DD HH:mm:ssZ'),
updatedAt: dayjs(feedback.updatedAt).format('YYYY-MM-DD HH:mm:ssZ'),
createdAt: DateTime.fromJSDate(feedback.createdAt).toFormat(
'yyyy-MM-dd HH:mm:ssZZ',
),
updatedAt: DateTime.fromJSDate(feedback.updatedAt).toFormat(
'yyyy-MM-dd HH:mm:ssZZ',
),
};
});
this.logger.log('documents.length: ' + documents.length);
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/domains/project/api-key/api-key.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import { randomBytes } from 'crypto';
import { BadRequestException, Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import dayjs from 'dayjs';
import { DateTime } from 'luxon';
import { Repository } from 'typeorm';
import { Transactional } from 'typeorm-transactional';

Expand Down Expand Up @@ -105,7 +105,7 @@ export class ApiKeyService {
});

await this.repository.save(
Object.assign(apiKey, { deletedAt: dayjs().toDate() }),
Object.assign(apiKey, { deletedAt: DateTime.utc().toJSDate() }),
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* under the License.
*/
import { ApiProperty } from '@nestjs/swagger';
import { IsString, MinLength } from 'class-validator';
import { IsString, MaxLength, MinLength } from 'class-validator';

export class CreateIssueRequestDto {
@ApiProperty()
@IsString()
@MinLength(1)
@MaxLength(20)
name: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* under the License.
*/
import { ApiProperty } from '@nestjs/swagger';
import { IsEnum, IsOptional, IsString } from 'class-validator';
import { IsEnum, IsOptional, IsString, MaxLength } from 'class-validator';

import { IssueStatusEnum } from '@/common/enums';
import { IsNullable } from '@/domains/user/decorators';
Expand All @@ -24,6 +24,7 @@ export class UpdateIssueRequestDto extends CreateIssueRequestDto {
@ApiProperty({ nullable: true })
@IsString()
@IsNullable()
@MaxLength(50)
description: string | null;

@ApiProperty({ required: false })
Expand Down
10 changes: 9 additions & 1 deletion apps/api/src/domains/project/issue/issue.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,16 @@ export class IssueService {
andWhere.id = query.id as number;
}

if (query.statuses) {
andWhere.status = In(query.statuses as string[]);
}

for (const column of Object.keys(query)) {
if (['id', 'createdAt', 'updatedAt', 'searchText'].includes(column)) {
if (
['id', 'createdAt', 'updatedAt', 'searchText', 'statuses'].includes(
column,
)
) {
continue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
IsOptional,
IsString,
Length,
MaxLength,
MinLength,
} from 'class-validator';

import { TimezoneOffset } from '@ufb/shared';
Expand Down Expand Up @@ -48,11 +50,14 @@ class CreateApiKeyByValueDto {
export class CreateProjectRequestDto {
@ApiProperty()
@IsString()
@MinLength(1)
@MaxLength(20)
name: string;

@ApiProperty({ nullable: true })
@IsString()
@IsNullable()
@MaxLength(50)
description: string | null;

@ApiProperty()
Expand Down
Loading

0 comments on commit b979999

Please sign in to comment.