logologo
เริ่มต้น
คู่มือ
การพัฒนา
ปลั๊กอิน
API
English
简体中文
日本語
한국어
Deutsch
Français
Español
Português
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
เริ่มต้น
คู่มือ
การพัฒนา
ปลั๊กอิน
API
logologo
API Overview

@nocobase/auth

AuthManager
Auth
BaseAuth

@nocobase/cache

CacheManager
แคช

@nocobase/cli

NocoBase CLI
ตัวแปรสภาพแวดล้อมส่วนกลาง

@nocobase/client

แอปพลิเคชัน
ปลั๊กอิน

@nocobase/database

คอลเลกชัน
ฟิลด์

interfaces

BaseInterface
ตัวดำเนินการ Filter

RelationRepository

BelongsToManyRepository
belongs-to-repository
HasManyRepository
HasOneRepository
รีโพสิทอรี

shared

create-options
destroy-options
find-one
find-options
transaction
update-options

@nocobase/data-source-manager

DataSourceManager
แหล่งข้อมูล (abstract)
ICollectionManager
ICollection
IField
IModel
IRepository

@nocobase/flow-engine

ตัวจัดการแหล่งข้อมูล
โฟลว์บริบท
FlowEngine
FlowModel
ทรัพยากรเวิร์กโฟลว์

@nocobase/logger

Logger

@nocobase/server

AppCommand
แอปพลิเคชัน
AuditManager
บริบท
การไมเกรต
ปลั๊กอิน

@nocobase/sdk

Auth
สตอเรจ
Previous Pageแอปพลิเคชัน
Next Pageบริบท
TIP

เอกสารนี้แปลโดย AI หากมีข้อมูลที่ไม่ถูกต้อง โปรดดูเวอร์ชันภาษาอังกฤษ

#AuditManager

#ภาพรวม

AuditManager เป็นโมดูลจัดการการตรวจสอบทรัพยากรใน NocoBase ครับ/ค่ะ ใช้สำหรับลงทะเบียนอินเทอร์เฟซทรัพยากรที่ต้องการให้มีการตรวจสอบ

#การใช้งานเบื้องต้น

import { Plugin } from '@nocobase/server';

class PluginCustomAuditResourceServer extends Plugin {
  async load() {
    this.app.auditManager.registerAction('resource:action');
  }
}

#เมธอดของคลาส

#setLogger()

กำหนดวิธีการส่งออก (output) สำหรับบันทึกการตรวจสอบ (audit logs) ครับ/ค่ะ

const auditManager = new AuditManager();
auditManager.setLogger({
  log: async (auditLog: AuditLog) => console.log(auditLog);
})

#รูปแบบการใช้งาน

  • setLogger(logger: AuditLogger)

#ประเภท

export interface AuditLog {
  uuid: string;
  dataSource: string;
  resource: string;
  action: string;
  sourceCollection?: string;
  sourceRecordUK?: string;
  targetCollection?: string;
  targetRecordUK?: string;
  userId: string;
  roleName: string;
  ip: string;
  ua: string;
  status: number;
  metadata?: Record<string, any>;
}

export interface AuditLogger {
  log(auditLog: AuditLog): Promise<void>;
}

#registerAction()

ลงทะเบียนการดำเนินการของทรัพยากรที่ต้องการให้มีการตรวจสอบครับ/ค่ะ

#รูปแบบการใช้งาน

  • registerAction(action: Action)

#ประเภท

export interface UserInfo {
  userId?: string;
  roleName?: string;
}

export interface SourceAndTarget {
  sourceCollection?: string;
  sourceRecordUK?: string;
  targetCollection?: string;
  targetRecordUK?: string;
}

type Action =
  | string
  | {
      name: string;
      getMetaData?: (ctx: Context) => Promise<Record<string, any>>;
      getUserInfo?: (ctx: Context) => Promise<UserInfo>;
      getSourceAndTarget?: (ctx: Context) => Promise<SourceAndTarget>;
    };

#รายละเอียด

รองรับรูปแบบการเขียนหลายแบบ ดังนี้ครับ/ค่ะ

  1. ใช้ได้กับทรัพยากรทั้งหมด

    registerActions(['create']);
  2. ใช้ได้กับการดำเนินการทั้งหมดของทรัพยากรที่ระบุ resource:*

    registerActions(['app:*']);
  3. ใช้ได้กับการดำเนินการที่เฉพาะเจาะจงของทรัพยากรที่ระบุ resource:action

    registerAction(['pm:update']);
  4. รองรับการส่งเมธอด getMetaData, getUserInfo และ getSourceAndTarget ที่กำหนดเองสำหรับการดำเนินการนั้นๆ ครับ/ค่ะ

    registerActions([
      'create',
      { name: 'auth:signIn', getMetaData, getUserInfo, getSourceAndTarget },
    ]);

ในกรณีที่อินเทอร์เฟซที่ลงทะเบียนมีการทับซ้อนกัน วิธีการลงทะเบียนที่มีความละเอียดเฉพาะเจาะจงมากกว่าจะมีลำดับความสำคัญสูงกว่าครับ/ค่ะ ตัวอย่างเช่น:

  1. registerActions('create')

  2. registerAction({ name: 'user:*', getMetaData })

  3. registerAction({ name: 'user:create', getMetaData })

สำหรับอินเทอร์เฟซ user:create การลงทะเบียนในข้อ 3 จะมีผลครับ/ค่ะ

#registerActions()

ลงทะเบียนการดำเนินการของทรัพยากรหลายรายการที่ต้องการให้มีการตรวจสอบครับ/ค่ะ

#รูปแบบการใช้งาน

  • registerActions(actions: Action[])