# Plugin API Reference {#plugin-api-reference}


Shared APIs, decorators, guards, and base classes available to all plugins.


## Base Classes {#base-classes}



### TenantOrganizationBaseEntity {#tenantorganizationbaseentity}


All plugin entities should extend this class for automatic tenant and organization scoping:

```typescript
export class TenantOrganizationBaseEntity extends TenantBaseEntity {
  organizationId: string;
  organization: Organization;
}
```


### TenantAwareCrudService {#tenantawarecrudservice}


Provides CRUD operations with automatic tenant filtering:

```typescript
export class TenantAwareCrudService<T> extends CrudService<T> {
  findAll(filter?: FindManyOptions<T>): Promise<IPagination<T>>;
  findOneByIdString(id: string, options?: FindOneOptions<T>): Promise<T>;
  create(entity: DeepPartial<T>): Promise<T>;
  update(id: string, entity: DeepPartial<T>): Promise<UpdateResult | T>;
  delete(id: string): Promise<DeleteResult>;
}
```


### CrudController {#crudcontroller}


Base controller with standard REST endpoints:

```typescript
export class CrudController<T> {
  constructor(protected readonly crudService: CrudService<T>) {}
}
```


## Guards {#guards}


| Guard                         | Description                      |
| ----------------------------- | -------------------------------- |
| `TenantPermissionGuard`       | Ensures request is tenant-scoped |
| `PermissionGuard`             | Checks user permissions          |
| `OrganizationPermissionGuard` | Checks org-level perms           |
| `RoleGuard`                   | Checks user role                 |


## Decorators {#decorators}


| Decorator           | Description                 |
| ------------------- | --------------------------- |
| `@Permissions(...)` | Define required permissions |
| `@Roles(...)`       | Define required roles       |
| `@Public()`         | Mark endpoint as public     |
| `@Feature(...)`     | Link to feature flag        |


## Multi-ORM Decorators {#multi-orm-decorators}


| Decorator                 | Description           |
| ------------------------- | --------------------- |
| `@MultiORMEntity(table)`  | Entity registration   |
| `@MultiORMColumn(opts)`   | Column definition     |
| `@MultiORMManyToOne(fn)`  | Many-to-One relation  |
| `@MultiORMOneToMany(fn)`  | One-to-Many relation  |
| `@MultiORMManyToMany(fn)` | Many-to-Many relation |
| `@MultiORMOneToOne(fn)`   | One-to-One relation   |


## Pipes {#pipes}


| Pipe                 | Description               |
| -------------------- | ------------------------- |
| `UUIDValidationPipe` | Validates UUID parameters |
| `UseValidationPipe`  | Applies class-validator   |
| `ParseJsonPipe`      | Parses JSON query params  |


## DTOs {#dtos}


```typescript
// Base query DTOs
BaseQueryDTO<T>; // Pagination + filter + relations
FindOptionsQueryDTO<T>; // Find options with relations
```


## Related Pages {#related-pages}


- [Plugin Development Guide](https://sourcey-gauzy.pages.dev/plugins-built-in/plugin-development-guide/index.md) — getting started
- [Multi-ORM Architecture](https://sourcey-gauzy.pages.dev/architecture/multi-orm-architecture/index.md) — ORM patterns
