-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: new apps logger deno-runtime (#31136)
* refactor: convert to typescript * feat: change storeEntries to receive logEntries instead appconsole instance * refactor: remove `logs-storage.js` * refactor: remove type `any` * fix: type errors * fix: implement correct method * chore: use apps engine with deno vm * Fix import --------- Co-authored-by: Douglas Gubert <[email protected]>
- Loading branch information
1 parent
c77bad5
commit 41b7359
Showing
5 changed files
with
42 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type { ILoggerStorageEntry } from '@rocket.chat/apps-engine/server/logging'; | ||
import type { IAppLogStorageFindOptions } from '@rocket.chat/apps-engine/server/storage'; | ||
import { AppLogStorage } from '@rocket.chat/apps-engine/server/storage'; | ||
import { InstanceStatus } from '@rocket.chat/instance-status'; | ||
import type { AppLogs } from '@rocket.chat/models'; | ||
|
||
export class AppRealLogStorage extends AppLogStorage { | ||
constructor(private db: typeof AppLogs) { | ||
super('mongodb'); | ||
} | ||
|
||
async find( | ||
query: { | ||
[field: string]: any; | ||
}, | ||
options?: IAppLogStorageFindOptions, | ||
): Promise<ILoggerStorageEntry[]> { | ||
return this.db.find({ ...options, ...query }).toArray(); | ||
} | ||
|
||
async storeEntries(logEntry: ILoggerStorageEntry): Promise<ILoggerStorageEntry> { | ||
logEntry.instanceId = InstanceStatus.id(); | ||
|
||
const id = (await this.db.insertOne(logEntry)).insertedId; | ||
|
||
return this.db.findOneById(id); | ||
} | ||
|
||
async getEntriesFor(appId: string): Promise<ILoggerStorageEntry[]> { | ||
return this.db.find({ appId }).toArray(); | ||
} | ||
|
||
async removeEntriesFor(appId: string): Promise<void> { | ||
await this.db.deleteOne({ appId }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import './AppFileSystemSourceStorage'; | ||
import './AppGridFSSourceStorage'; | ||
|
||
export { AppRealLogsStorage } from './logs-storage'; | ||
export { AppRealLogStorage } from './AppRealLogStorage'; | ||
export { AppRealStorage } from './AppRealStorage'; | ||
export { ConfigurableAppSourceStorage } from './ConfigurableAppSourceStorage'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,9 @@ | ||
import type { DeleteResult, Filter } from 'mongodb'; | ||
|
||
import type { IBaseModel } from './IBaseModel'; | ||
|
||
// TODO: type for AppLogs | ||
export interface IAppLogsModel extends IBaseModel<any> { | ||
resetTTLIndex(expireAfterSeconds: number): Promise<void>; | ||
remove(query: Filter<any>): Promise<DeleteResult>; | ||
} |