Skip to content

Commit 829fd8a

Browse files
authored
feat(server): support function history changelog (#1756)
* feat(server): support function history changelog
1 parent dfacca6 commit 829fd8a

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

server/src/function/dto/update-function.dto.ts

+4
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export class UpdateFunctionDto {
4040
@IsNotEmpty({ each: true })
4141
tags: string[]
4242

43+
@ApiPropertyOptional()
44+
@MaxLength(256)
45+
changelog?: string
46+
4347
validate() {
4448
return null
4549
}

server/src/function/entities/cloud-function-history.ts

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export class CloudFunctionHistory {
1919
@ApiProperty({ type: CloudFunctionHistorySource })
2020
source: CloudFunctionHistorySource
2121

22+
@ApiProperty({ type: String })
23+
changelog?: string
24+
2225
@ApiProperty()
2326
createdAt: Date
2427
}

server/src/function/function.service.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export class FunctionService {
5959

6060
const fn = await this.findOne(appid, dto.name)
6161

62-
await this.addOneHistoryRecord(fn)
62+
await this.addOneHistoryRecord(fn, 'created')
6363
await this.publish(fn)
6464
return fn
6565
}
@@ -175,7 +175,7 @@ export class FunctionService {
175175
)
176176

177177
const fn = await this.findOne(func.appid, func.name)
178-
await this.addOneHistoryRecord(fn)
178+
await this.addOneHistoryRecord(fn, dto.changelog)
179179
await this.publish(fn)
180180

181181
return fn
@@ -414,7 +414,7 @@ export class FunctionService {
414414
return history
415415
}
416416

417-
async addOneHistoryRecord(func: CloudFunction) {
417+
async addOneHistoryRecord(func: CloudFunction, changelog = '') {
418418
await this.db
419419
.collection<CloudFunctionHistory>('CloudFunctionHistory')
420420
.insertOne({
@@ -424,6 +424,7 @@ export class FunctionService {
424424
code: func.source.code,
425425
},
426426
createdAt: new Date(),
427+
changelog,
427428
})
428429
}
429430

0 commit comments

Comments
 (0)