add audit log generic types
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
"./localization-api": "./dist-cms/libs/localization-api/index.js",
|
||||
"./observable-api": "./dist-cms/libs/observable-api/index.js",
|
||||
"./action": "./dist-cms/packages/core/action/index.js",
|
||||
"./audit-log": "./dist-cms/packages/audit-log/index.js",
|
||||
"./audit-log": "./dist-cms/packages/core/audit-log/index.js",
|
||||
"./auth": "./dist-cms/packages/core/auth/index.js",
|
||||
"./block-grid": "./dist-cms/packages/block/block-grid/index.js",
|
||||
"./block-list": "./dist-cms/packages/block/block-list/index.js",
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { UmbAuditLogModel, UmbAuditLogRequestArgs } from './types.js';
|
||||
import type { UmbDataSourceResponse, UmbPagedModel } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
export interface UmbAuditLogDataSource<AuditLogType extends UmbAuditLogModel> {
|
||||
getAuditLog(args: UmbAuditLogRequestArgs): Promise<UmbDataSourceResponse<UmbPagedModel<AuditLogType>>>;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { UmbAuditLogModel, UmbAuditLogRequestArgs } from './types.js';
|
||||
import type { UmbRepositoryBase, UmbRepositoryResponse } from '@umbraco-cms/backoffice/repository';
|
||||
|
||||
export interface UmbAuditLogRepository<AuditLogType extends UmbAuditLogModel> extends UmbRepositoryBase {
|
||||
requestAuditLog(args: UmbAuditLogRequestArgs): Promise<UmbRepositoryResponse<AuditLogType>>;
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export type { UmbAuditLogRepository } from './audit-log-repository.interface.js';
|
||||
export type { UmbAuditLogDataSource } from './audit-log-data-source.interface.js';
|
||||
export type { UmbAuditLogModel, UmbAuditLogRequestArgs } from './types.js';
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { AuditTypeModel } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models';
|
||||
import type { UmbDirectionType } from '@umbraco-cms/backoffice/utils';
|
||||
|
||||
export interface UmbAuditLogModel {
|
||||
user: UmbReferenceByUnique | null;
|
||||
timestamp: string;
|
||||
logType: AuditTypeModel;
|
||||
comment?: string | null;
|
||||
parameters?: string | null;
|
||||
}
|
||||
|
||||
export interface UmbAuditLogRequestArgs {
|
||||
unique: string;
|
||||
orderDirection?: UmbDirectionType;
|
||||
sinceDate?: string;
|
||||
skip?: number;
|
||||
take?: number;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { UmbAuditLogRequestArgs } from '../types.js';
|
||||
import type { UmbAuditLogRepository, UmbAuditLogRequestArgs } from '@umbraco-cms/backoffice/audit-log';
|
||||
import type { UmbDocumentAuditLogModel } from '../types.js';
|
||||
import { UmbDocumentAuditLogServerDataSource } from './document-audit-log.server.data-source.js';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
|
||||
@@ -9,7 +10,10 @@ import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
|
||||
* @class UmbDocumentAuditLogRepository
|
||||
* @extends {UmbRepositoryBase}
|
||||
*/
|
||||
export class UmbDocumentAuditLogRepository extends UmbRepositoryBase {
|
||||
export class UmbDocumentAuditLogRepository
|
||||
extends UmbRepositoryBase
|
||||
implements UmbAuditLogRepository<UmbDocumentAuditLogModel>
|
||||
{
|
||||
#dataSource: UmbDocumentAuditLogServerDataSource;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import type { UmbAuditLogRequestArgs } from '../types.js';
|
||||
import type { UmbAuditLogDataSource, UmbAuditLogRequestArgs } from '@umbraco-cms/backoffice/audit-log';
|
||||
import type { UmbDocumentAuditLogModel } from '../types.js';
|
||||
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
|
||||
import type { DirectionModel } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
import { DocumentService } from '@umbraco-cms/backoffice/external/backend-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
|
||||
@@ -8,7 +10,7 @@ import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources';
|
||||
* @export
|
||||
* @class UmbAuditLogServerDataSource
|
||||
*/
|
||||
export class UmbDocumentAuditLogServerDataSource {
|
||||
export class UmbDocumentAuditLogServerDataSource implements UmbAuditLogDataSource<UmbDocumentAuditLogModel> {
|
||||
#host: UmbControllerHost;
|
||||
|
||||
/**
|
||||
@@ -31,7 +33,7 @@ export class UmbDocumentAuditLogServerDataSource {
|
||||
this.#host,
|
||||
DocumentService.getDocumentByIdAuditLog({
|
||||
id: args.unique,
|
||||
orderDirection: args.orderDirection,
|
||||
orderDirection: args.orderDirection as DirectionModel, // TODO: Fix type cast
|
||||
sinceDate: args.sinceDate,
|
||||
skip: args.skip,
|
||||
take: args.take,
|
||||
@@ -39,7 +41,7 @@ export class UmbDocumentAuditLogServerDataSource {
|
||||
);
|
||||
|
||||
if (data) {
|
||||
const mappedItems = data.items.map((item) => {
|
||||
const mappedItems: Array<UmbDocumentAuditLogModel> = data.items.map((item) => {
|
||||
return {
|
||||
user: item.user ? { unique: item.user.id } : null,
|
||||
timestamp: item.timestamp,
|
||||
|
||||
@@ -1,18 +1,3 @@
|
||||
import type { UmbReferenceByUnique } from '@umbraco-cms/backoffice/models';
|
||||
import type { UmbDirectionType } from '@umbraco-cms/backoffice/utils';
|
||||
import type { UmbAuditLogModel } from '@umbraco-cms/backoffice/audit-log';
|
||||
|
||||
export interface UmbAuditLogRequestArgs {
|
||||
unique: string;
|
||||
orderDirection?: UmbDirectionType;
|
||||
sinceDate?: string;
|
||||
skip?: number;
|
||||
take?: number;
|
||||
}
|
||||
|
||||
export interface UmbDocumentAuditLogModel {
|
||||
user: UmbReferenceByUnique;
|
||||
timestamp: string;
|
||||
logType: AuditTypeModel;
|
||||
comment?: string | null;
|
||||
parameters?: string | null;
|
||||
}
|
||||
export interface UmbDocumentAuditLogModel extends UmbAuditLogModel {}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"@umbraco-cms/backoffice/localization-api": ["./src/libs/localization-api/index.ts"],
|
||||
"@umbraco-cms/backoffice/observable-api": ["./src/libs/observable-api/index.ts"],
|
||||
"@umbraco-cms/backoffice/action": ["./src/packages/core/action/index.ts"],
|
||||
"@umbraco-cms/backoffice/audit-log": ["./src/packages/audit-log/index.ts"],
|
||||
"@umbraco-cms/backoffice/audit-log": ["./src/packages/core/audit-log/index.ts"],
|
||||
"@umbraco-cms/backoffice/auth": ["./src/packages/core/auth/index.ts"],
|
||||
"@umbraco-cms/backoffice/block-grid": ["./src/packages/block/block-grid/index.ts"],
|
||||
"@umbraco-cms/backoffice/block-list": ["./src/packages/block/block-list/index.ts"],
|
||||
|
||||
Reference in New Issue
Block a user