export default function ApiDocs() {
  return <div>Check the source code for the full API Markdown</div>;
}

/*
# KROW Workforce Platform - API Documentation

**Version:** 3.0 (Auto-Updated)
**Last Updated:** 2025-11-20
**Project:** KROW Workforce Control Tower

## Table of Contents
1. [Overview](#overview)
2. [Authentication](#authentication)
3. [Entity Schemas](#entity-schemas)
4. [SDK Operations](#sdk-operations)
5. [Core Integrations](#core-integrations)
6. [Data Models Reference](#data-models-reference)
7. [Code Examples](#code-examples)
8. [Best Practices](#best-practices)
9. [Security Considerations](#security-considerations)
10. [Rate Limits & Quotas](#rate-limits--quotas)
11. [Changelog](#changelog)
12. [Support & Resources](#support--resources)

---

## Overview
KROW Workforce is a comprehensive workforce management platform built on Base44. This documentation provides complete API specifications for all entities, SDK methods, and integration endpoints.

### Base44 Client Import
```javascript
import { base44 } from "@/api/base44Client";
```

---

## Authentication

### User Authentication Methods
```javascript
// Get current authenticated user
const user = await base44.auth.me();

// Update current user
await base44.auth.updateMe({
  full_name: "John Doe",
  custom_field: "value"
});

// Logout
base44.auth.logout(redirectUrl?: string);

// Redirect to login
base44.auth.redirectToLogin(nextUrl?: string);

// Check authentication status
const isAuthenticated = await base44.auth.isAuthenticated();
```

### User Object Structure
```json
{
  "id": "string",
  "email": "string",
  "full_name": "string",
  "role": "admin" | "user",
  "user_role": "string",
  "created_date": "timestamp",
  "updated_date": "timestamp"
}
```

---

## Entity Schemas

### 1. User Entity (Built-in)
Description: Core user entity with authentication and role management.

| Field Name | Type      | Description             | Validation                               |
| :--------- | :-------- | :---------------------- | :--------------------------------------- |
| `id`       | `string`  | Unique user identifier  | Auto-generated, unique                   |
| `email`    | `string`  | User email address      | Required, unique, email format           |
| `full_name`| `string`  | User's full name        | Required                                 |
| `role`     | `string`  | Base role               | Enum: "admin", "user"                    |
| `user_role`| `string`  | Custom application role | Optional, custom values                  |
| `created_date`| `timestamp`| Account creation date   | Auto-generated                           |
| `updated_date`| `timestamp`| Last update timestamp   | Auto-updated                             |

JSON Schema:
```json
{
  "type": "object",
  "properties": {
    "email": {"type": "string", "format": "email"},
    "full_name": {"type": "string"},
    "role": {"type": "string", "enum": ["admin", "user"]},
    "user_role": {"type": "string"}
  }
}
```

Security Rules:
- Only admin users can list, update, or delete other users
- Regular users can only view and update their own user record
- These rules are automatically enforced

### 2. Event Entity
Description: Core event/order management entity for workforce scheduling.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique event identifier | Auto-generated                                                          |
| `event_name`| `string`  | Name of the event       | Required                                                                |
| `is_rapid` | `boolean` | RAPID/urgent order flag | Default: false                                                          |
| `is_recurring`| `boolean`| Whether event recurs    | Default: false                                                          |
| `is_multi_day`| `boolean`| Multi-day event flag    | Default: false                                                          |
| `recurrence_type`| `string`| Type of recurrence      | Enum: "single", "date_range", "scatter"                                 |
| `recurrence_start_date`| `date`| Start date for recurring events| Optional                                                                |
| `recurrence_end_date`| `date`| End date for recurring events  | Optional                                                                |
| `scatter_dates`| `array` | Specific dates for scatter recurring| Array of date strings                                                   |
| `multi_day_start_date`| `date`| Multi-day start date    | Optional                                                                |
| `multi_day_end_date`| `date`| Multi-day end date      | Optional                                                                |
| `buffer_time_before`| `number`| Buffer time before (minutes)| Default: 0                                                              |
| `buffer_time_after`| `number`| Buffer time after (minutes) | Default: 0                                                              |
| `conflict_detection_enabled`| `boolean`| Enable conflict detection| Default: true                                                           |
| `detected_conflicts`| `array`| Array of detected conflicts | Array of conflict objects with type, severity, description              |
| `business_id`| `string`  | Associated business ID  | Optional                                                                |
| `business_name`| `string`  | Business name           | Optional                                                                |
| `vendor_id`| `string`  | Vendor ID if created by vendor| Optional                                                                |
| `vendor_name`| `string`  | Vendor name             | Optional                                                                |
| `hub`      | `string`  | Hub location            | Optional                                                                |
| `event_location`| `string`| Event location address  | Optional                                                                |
| `contract_type`| `string`| Contract type           | Enum: "W2", "1099", "Temp", "Contract"                                  |
| `po_reference`| `string`| Purchase order reference| Optional                                                                |
| `status`   | `string`  | Event status            | Enum: "Draft", "Active", "Pending", "Assigned", "Confirmed", "Completed", "Canceled" |
| `date`     | `date`    | Event date              | Optional                                                                |
| `shifts`   | `array`   | Array of shift objects  | Optional                                                                |
| `addons`   | `object`  | Additional services/features| Optional                                                                |
| `total`    | `number`  | Total cost              | Optional                                                                |
| `client_name`| `string`  | Client contact name     | Optional                                                                |
| `client_email`| `string`| Client email            | Optional                                                                |
| `client_phone`| `string`| Client phone            | Optional                                                                |
| `invoice_id`| `string`  | Associated invoice ID   | Optional                                                                |
| `notes`    | `string`  | Additional notes        | Optional                                                                |
| `requested`| `number`  | Total staff requested   | Optional                                                                |
| `assigned_staff`| `array`| Array of assigned staff | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

Shifts Structure:
```json
{
  "shift_name": "string",
  "shift_contact": "string",
  "location": "string",
  "location_address": "string",
  "roles": [
    {
      "role": "string",
      "department": "string",
      "count": "number",
      "start_time": "string",
      "end_time": "string",
      "hours": "number",
      "uniform": "string",
      "break_minutes": "number",
      "cost_per_hour": "number",
      "total_value": "number",
      "vendor_name": "string",
      "vendor_id": "string"
    }
  ]
}
```

Detected Conflicts Structure:
```json
{
  "conflict_type": "staff_overlap" | "venue_overlap" | "time_buffer",
  "severity": "low" | "medium" | "high" | "critical",
  "description": "string",
  "conflicting_event_id": "string",
  "staff_id": "string",
  "detected_at": "timestamp"
}
```

### 3. Staff Entity
Description: Employee/workforce member management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique staff identifier | Auto-generated                                                          |
| `employee_name`| `string`| Full name               | Required                                                                |
| `vendor_id`| `string`  | Associated vendor ID    | Optional                                                                |
| `vendor_name`| `string`| Vendor company name     | Optional                                                                |
| `manager`  | `string`  | Manager's name          | Optional                                                                |
| `contact_number`| `string`| Primary contact number  | Optional                                                                |
| `phone`    | `string`  | Additional phone        | Optional                                                                |
| `email`    | `string`  | Email address           | Email format                                                            |
| `department`| `string` | Department              | Enum: "Operations", "Sales", "HR", "Finance", "IT", "Marketing", "Customer Service", "Logistics" |
| `hub_location`| `string`| Hub/office location     | Optional                                                                |
| `event_location`| `string`| Event location          | Optional                                                                |
| `track`    | `string`  | Track information       | Optional                                                                |
| `address`  | `string`  | Employee address        | Optional                                                                |
| `city`     | `string`  | City                    | Optional                                                                |
| `position` | `string`  | Primary job position/skill| Optional                                                                |
| `position_2`| `string` | Secondary job position/skill| Optional                                                                |
| `initial`  | `string`  | Employee initials       | Optional                                                                |
| `profile_type`| `string`| Skill profile level     | Enum: "Skilled", "Beginner", "Cross-Trained"                            |
| `employment_type`| `string`| Employment type         | Enum: "Full Time", "Part Time", "On call", "Weekends", "Specific Days", "Seasonal", "Medical Leave" |
| `english`  | `string`  | English proficiency     | Enum: "Fluent", "Intermediate", "Basic", "None"                         |
| `english_required`| `boolean`| English required        | Optional                                                                |
| `check_in` | `date`    | Last check-in date      | Optional                                                                |
| `replaced_by`| `string` | Name of replacement employee| Optional                                                                |
| `ro`       | `string`  | R.O field               | Optional                                                                |
| `mon`      | `string`  | MON field               | Optional                                                                |
| `schedule_days`| `string`| Working schedule days   | Optional                                                                |
| `invoiced` | `boolean` | Invoice status          | Optional                                                                |
| `action`   | `string`  | Current action or status| Optional                                                                |
| `notes`    | `string`  | General notes about the employee| Optional                                                                |
| `accounting_comments`| `string`| Comments from accounting| Optional                                                                |
| `rating`   | `number`  | Staff performance rating| Min: 0, Max: 5                                                          |
| `shift_coverage_percentage`| `number`| Percentage of shifts covered| Min: 0, Max: 100                                                        |
| `cancellation_count`| `number`| Number of shift cancellations| Min: 0                                                                  |
| `no_show_count`| `number`| Number of no-shows      | Min: 0                                                                  |
| `total_shifts`| `number`| Total number of shifts assigned| Min: 0                                                                  |
| `reliability_score`| `number`| Overall reliability score| Min: 0, Max: 100                                                        |
| `background_check_status`| `string`| Background check status | Enum: "pending", "cleared", "failed", "expired", "not_required"         |
| `background_check_date`| `date`| Date of last background check| Optional                                                                |
| `certifications`| `array`| List of certifications  | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 4. Vendor Entity
Description: Vendor/supplier management and onboarding.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique vendor identifier| Auto-generated                                                          |
| `vendor_number`| `string`| Vendor Number (VN-####) | Required, Pattern: `^VN-[0-9]{4}$`                                      |
| `legal_name`| `string` | Legal business name     | Required                                                                |
| `doing_business_as`| `string`| DBA/Trade name          | Optional                                                                |
| `region`   | `string`  | Geographic region       | Enum: "National", "Bay Area", "Southern California", "Northern California", "West", "East", "Midwest", "South" |
| `state`    | `string`  | Primary state           | Optional                                                                |
| `city`     | `string`  | Primary city            | Optional                                                                |
| `service_specialty`| `string`| Service specialty       | Optional                                                                |
| `workforce_count`| `number`| Total workforce count   | Optional                                                                |
| `platform_type`| `string`| Technology integration level| Enum: "Full Platform", "Building platform (KROW)", "Partial Tech", "Traditional" |
| `tax_id`   | `string`  | Federal Tax ID/EIN      | Optional                                                                |
| `business_type`| `string`| Business entity type    | Enum: "Corporation", "LLC", "Partnership", "Sole Proprietorship"        |
| `primary_contact_name`| `string`| Primary contact         | Optional                                                                |
| `primary_contact_email`| `string`| Primary email           | Required, Email format                                                  |
| `primary_contact_phone`| `string`| Primary phone           | Optional                                                                |
| `billing_address`| `string`| Billing address         | Optional                                                                |
| `service_address`| `string`| Service/office address  | Optional                                                                |
| `coverage_regions`| `array`| Geographic regions vendor can service| Array of strings                                                        |
| `eligible_roles`| `array`| Roles/positions vendor can provide| Array of strings                                                        |
| `insurance_certificate`| `string`| URL to insurance certificate| Optional                                                                |
| `insurance_expiry`| `date`| Insurance expiration date| Optional                                                                |
| `w9_document`| `string` | URL to W9 form          | Optional                                                                |
| `coi_document`| `string` | URL to Certificate of Insurance| Optional                                                                |
| `compliance_package_id`| `string`| Reference to compliance package| Optional                                                                |
| `performance_scorecard_id`| `string`| Reference to performance scorecard| Optional                                                                |
| `approval_status`| `string`| Vendor approval status  | Enum: "pending", "approved", "suspended", "terminated"                  |
| `approved_date`| `date` | Date vendor was approved| Optional                                                                |
| `approved_by`| `string` | User who approved vendor| Optional                                                                |
| `is_active`| `boolean` | Is vendor currently active| Default: true                                                           |
| `notes`    | `string`  | Internal notes about vendor| Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 5. VendorRate Entity
Description: Vendor pricing and rate management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique rate identifier  | Auto-generated                                                          |
| `vendor_id`| `string`  | Vendor ID               | Optional                                                                |
| `vendor_name`| `string`| Vendor name             | Required                                                                |
| `category` | `string`  | Service category        | Enum: "Kitchen and Culinary", "Concessions", "Facilities", "Bartending", "Security", "Event Staff", "Management", "Technical", "Other" |
| `role_name`| `string`  | Role/position name      | Required                                                                |
| `employee_wage`| `number`| Employee base wage/hour | Required, Min: 0                                                        |
| `markup_percentage`| `number`| Markup percentage       | Min: 0, Max: 100                                                        |
| `vendor_fee_percentage`| `number`| Vendor fee percentage   | Min: 0, Max: 100                                                        |
| `client_rate`| `number` | Final rate to client    | Required, Min: 0                                                        |
| `is_active`| `boolean` | Active status           | Default: true                                                           |
| `minimum_wage_compliance`| `boolean`| Meets minimum wage      | Optional                                                                |
| `pricing_status`| `string`| Pricing analysis        | Enum: "optimal", "underpriced", "overpriced", "competitive"             |
| `market_average`| `number`| Market average rate     | Optional                                                                |
| `notes`    | `string`  | Additional notes        | Optional                                                                |
| `available_to_clients`| `array`| Client IDs with access  | Array of strings                                                        |
| `client_visibility`| `string`| Visibility setting      | Enum: "all", "specific", "none"                                         |
| `competitive_status`| `boolean`| Competitive pricing     | Default: false                                                          |
| `csta_compliant`| `boolean`| CA Staffing Agency compliant| Default: false                                                          |
| `compliance_verified`| `boolean`| Compliance verified     | Default: false                                                          |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 6. VendorDefaultSettings Entity
Description: Default markup and fee settings for vendors.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique settings identifier| Auto-generated                                                          |
| `vendor_name`| `string`| Name of the vendor      | Required                                                                |
| `default_markup_percentage`| `number`| Default markup percentage for this vendor| Required, Min: 0, Max: 100                                              |
| `default_vendor_fee_percentage`| `number`| Default vendor fee percentage for this vendor| Required, Min: 0, Max: 100                                              |
| `notes`    | `string`  | Additional notes about vendor defaults| Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 7. Invoice Entity
Description: Invoice and billing management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique invoice identifier| Auto-generated                                                          |
| `invoice_number`| `string`| Unique invoice number   | Required                                                                |
| `event_name`| `string` | Name of the event       | Optional                                                                |
| `event_id` | `string`  | Related event ID        | Optional                                                                |
| `po_reference`| `string`| Purchase order reference| Optional                                                                |
| `event_date`| `date`   | Event date              | Optional                                                                |
| `from_company`| `object`| Vendor company information| Optional                                                                |
| `to_company`| `object` | Client company information| Optional                                                                |
| `business_name`| `string`| Client/Business name    | Required                                                                |
| `manager_name`| `string`| Manager/client name     | Optional                                                                |
| `vendor_name`| `string`| Vendor providing services| Optional                                                                |
| `vendor_id`| `string`  | Vendor ID               | Optional                                                                |
| `hub`      | `string`  | Hub location            | Optional                                                                |
| `cost_center`| `string` | Cost center or department| Optional                                                                |
| `roles`    | `array`   | Grouped by role with staff details| Optional                                                                |
| `subtotal` | `number`  | Subtotal amount         | Optional                                                                |
| `other_charges`| `number`| Additional charges      | Optional                                                                |
| `amount`   | `number`  | Grand total invoice amount| Required, Min: 0                                                        |
| `tax_amount`| `number` | Tax amount              | Optional                                                                |
| `tax_rate` | `number`  | Tax rate percentage     | Optional                                                                |
| `status`   | `string`  | Current invoice status  | Enum: "Draft", "Pending Review", "Approved", "Disputed", "Under Review", "Resolved", "Overdue", "Paid", "Reconciled", "Cancelled" |
| `issue_date`| `date`   | Invoice issue date      | Required                                                                |
| `due_date` | `date`    | Payment due date        | Required                                                                |
| `paid_date`| `date`    | Date payment was received| Optional                                                                |
| `payment_method`| `string`| Payment method used     | Enum: "Credit Card", "ACH", "Wire Transfer", "Check", "Cash"            |
| `payment_reference`| `string`| Payment reference/transaction ID| Optional                                                                |
| `dispute_reason`| `string`| Reason for dispute      | Optional                                                                |
| `dispute_details`| `string`| Detailed dispute information| Optional                                                                |
| `disputed_items`| `array`| List of disputed staff entry indices| Optional                                                                |
| `disputed_by`| `string`| User who disputed the invoice| Optional                                                                |
| `disputed_date`| `timestamp`| When dispute was raised | Optional                                                                |
| `resolution_notes`| `string`| Notes about dispute resolution| Optional                                                                |
| `approved_by`| `string`| User who approved the invoice| Optional                                                                |
| `approved_date`| `timestamp`| When invoice was approved| Optional                                                                |
| `is_auto_generated`| `boolean`| Whether invoice was auto-generated from event| Default: false                                                          |
| `pdf_url`  | `string`  | URL to PDF version of invoice| Optional                                                                |
| `notes`    | `string`  | Additional notes about the invoice| Optional                                                                |
| `internal_notes`| `string`| Internal notes not visible to client| Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 8. Business Entity
Description: Client business/company management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique business identifier| Auto-generated                                                          |
| `business_name`| `string`| Business/client company name| Required                                                                |
| `company_logo`| `string`| URL to company logo     | Optional                                                                |
| `contact_name`| `string`| Primary contact person  | Required                                                                |
| `email`    | `string`  | Business email          | Email format                                                            |
| `phone`    | `string`  | Business phone          | Optional                                                                |
| `hub_building`| `string`| Hub/building name       | Optional                                                                |
| `address`  | `string`  | Street address          | Optional                                                                |
| `city`     | `string`  | City                    | Optional                                                                |
| `area`     | `string`  | Geographic area         | Enum: "Bay Area", "Southern California", "Northern California", "Central Valley", "Other" |
| `sector`   | `string`  | Sector/industry         | Enum: "Bon Appétit", "Eurest", "Aramark", "Epicurean Group", "Chartwells", "Other" |
| `rate_group`| `string` | Pricing tier            | Required, Enum: "Standard", "Premium", "Enterprise", "Custom"           |
| `status`   | `string`  | Business status         | Enum: "Active", "Inactive", "Pending"                                   |
| `notes`    | `string`  | Additional notes        | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 9. Certification Entity
Description: Employee certification and compliance tracking.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique certification ID | Auto-generated                                                          |
| `employee_id`| `string`| Staff member ID         | Optional                                                                |
| `employee_name`| `string`| Staff member name       | Required                                                                |
| `vendor_id`| `string`  | Vendor ID               | Optional                                                                |
| `vendor_name`| `string`| Vendor name             | Optional                                                                |
| `certification_name`| `string`| Certification name      | Required                                                                |
| `certification_type`| `string`| Type of certification   | Enum: "Legal", "Operational", "Safety", "Training", "License", "Other"  |
| `status`   | `string`  | Current status          | Enum: "current", "expiring_soon", "expired", "pending_validation"       |
| `issue_date`| `date`   | Issue date              | Optional                                                                |
| `expiry_date`| `date`  | Expiration date         | Required                                                                |
| `issuer`   | `string`  | Issuing authority       | Optional                                                                |
| `certificate_number`| `string`| Certificate ID          | Optional                                                                |
| `document_url`| `string`| Uploaded certificate URL| Optional                                                                |
| `validation_status`| `string`| Validation status       | Enum: "approved", "pending_expert_review", "rejected", "ai_verified", "ai_flagged", "manual_review_needed" |
| `ai_validation_result`| `object`| AI validation results   | Optional                                                                |
| `validated_by`| `string`| Validator               | Optional                                                                |
| `validated_date`| `date`| Validation date         | Optional                                                                |
| `is_required_for_role`| `boolean`| Required for role       | Default: false                                                          |
| `days_until_expiry`| `number`| Auto-calculated days    | Optional                                                                |
| `alert_sent`| `boolean` | Expiry alert sent       | Default: false                                                          |
| `notes`    | `string`  | Additional notes        | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 10. Team Entity
Description: Team and organization management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique team identifier  | Auto-generated                                                          |
| `team_name`| `string`  | Name of the team        | Required                                                                |
| `owner_id` | `string`  | Team owner user ID      | Required                                                                |
| `owner_name`| `string` | Team owner name         | Required                                                                |
| `owner_role`| `string` | Role of team owner      | Required, Enum: "admin", "procurement", "operator", "sector", "client", "vendor", "workforce" |
| `company_logo`| `string`| URL to company logo     | Optional                                                                |
| `full_name`| `string`  | Primary contact name    | Optional                                                                |
| `email`    | `string`  | Contact email           | Email format                                                            |
| `phone`    | `string`  | Contact phone           | Optional                                                                |
| `address`  | `string`  | Company address         | Optional                                                                |
| `city`     | `string`  | City                    | Optional                                                                |
| `zip_code` | `string`  | ZIP code                | Optional                                                                |
| `vendor_id`| `string`  | Vendor ID if applicable | Optional                                                                |
| `departments`| `array` | Available departments   | Array of strings                                                        |
| `total_members`| `number`| Total team members      | Default: 0                                                              |
| `active_members`| `number`| Active members          | Default: 0                                                              |
| `total_hubs`| `number` | Total hubs              | Default: 0                                                              |
| `favorite_staff`| `array`| Array of favorite staff | Array of objects with staff_id, staff_name, position, added_date        |
| `blocked_staff`| `array`| Array of blocked staff  | Array of objects with staff_id, staff_name, reason, blocked_date        |
| `favorite_staff_count`| `number`| Favorite staff count    | Default: 0                                                              |
| `blocked_staff_count`| `number`| Blocked staff count     | Default: 0                                                              |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 11. TeamMember Entity
Description: Team member management within teams.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique member identifier| Auto-generated                                                          |
| `team_id`  | `string`  | Team ID                 | Required                                                                |
| `member_name`| `string`| Member name             | Required                                                                |
| `email`    | `string`  | Member email            | Required, Email format                                                  |
| `phone`    | `string`  | Member phone            | Optional                                                                |
| `title`    | `string`  | Job title               | Optional                                                                |
| `role`     | `string`  | Team role               | Enum: "admin", "manager", "member", "viewer"                            |
| `department`| `string` | Department              | Optional                                                                |
| `hub`      | `string`  | Assigned hub            | Optional                                                                |
| `is_active`| `boolean` | Active status           | Default: true                                                           |
| `permissions`| `array` | Permissions             | Array of strings                                                        |
| `avatar_url`| `string` | URL to member avatar    | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 12. TeamHub Entity
Description: Team hub/location management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique hub identifier   | Auto-generated                                                          |
| `team_id`  | `string`  | Team ID                 | Required                                                                |
| `hub_name` | `string`  | Name of the hub/location| Required                                                                |
| `address`  | `string`  | Hub address             | Optional                                                                |
| `city`     | `string`  | City                    | Optional                                                                |
| `state`    | `string`  | State                   | Optional                                                                |
| `zip_code` | `string`  | ZIP code                | Optional                                                                |
| `manager_name`| `string`| Hub manager name        | Optional                                                                |
| `manager_email`| `string`| Hub manager email       | Email format                                                            |
| `departments`| `array` | Departments within this hub| Array of objects with department_name, cost_center                      |
| `is_active`| `boolean` | Whether the hub is active| Default: true                                                           |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

Departments Structure:
```json
{
  "department_name": "string",
  "cost_center": "string"
}
```

### 13. TeamMemberInvite Entity
Description: Team member invitation management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique invite identifier| Auto-generated                                                          |
| `team_id`  | `string`  | Team ID                 | Required                                                                |
| `team_name`| `string`  | Team name               | Optional                                                                |
| `invite_code`| `string`| Unique invite code      | Required                                                                |
| `email`    | `string`  | Invitee email           | Required, Email format                                                  |
| `full_name`| `string`  | Invitee full name       | Optional                                                                |
| `phone`    | `string`  | Invitee phone           | Optional                                                                |
| `role`     | `string`  | Assigned role           | Optional                                                                |
| `title`    | `string`  | Job title               | Optional                                                                |
| `hub`      | `string`  | Assigned hub            | Optional                                                                |
| `department`| `string` | Assigned department     | Optional                                                                |
| `invited_by`| `string` | Inviter email/name      | Optional                                                                |
| `invite_status`| `string`| Invite status           | Enum: "pending", "accepted", "expired", "cancelled"                     |
| `invited_date`| `timestamp`| Invitation date         | Optional                                                                |
| `accepted_date`| `timestamp`| Acceptance date         | Optional                                                                |
| `expires_at`| `timestamp`| Expiration date         | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 14. Conversation Entity
Description: Messaging and communication management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique conversation ID  | Auto-generated                                                          |
| `participants`| `array` | Array of participant objects| Required                                                                |
| `conversation_type`| `string`| Type of conversation    | Required, Enum: "client-vendor", "staff-client", "staff-admin", "vendor-admin", "client-admin", "group-staff", "group-event-staff" |
| `is_group` | `boolean` | Is group conversation   | Default: false                                                          |
| `group_name`| `string` | Group name              | Optional                                                                |
| `related_to`| `string` | Related entity ID       | Optional                                                                |
| `related_type`| `string`| Related entity type     | Enum: "event", "staff", "business", "general"                           |
| `subject`  | `string`  | Conversation subject    | Optional                                                                |
| `last_message`| `string`| Preview of last message | Optional                                                                |
| `last_message_at`| `timestamp`| Last message timestamp  | Optional                                                                |
| `unread_count`| `number`| Unread message count    | Default: 0                                                              |
| `status`   | `string`  | Conversation status     | Enum: "active", "archived", "closed"                                    |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 15. Message Entity
Description: Individual messages within conversations.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique message identifier| Auto-generated                                                          |
| `conversation_id`| `string`| Conversation ID         | Required                                                                |
| `sender_id`| `string`  | Sender ID               | Optional                                                                |
| `sender_name`| `string`| Sender name             | Required                                                                |
| `sender_role`| `string`| Sender role             | Enum: "client", "vendor", "staff", "admin"                              |
| `content`  | `string`  | Message content         | Required                                                                |
| `read_by`  | `array`   | User IDs who read       | Array of strings                                                        |
| `attachments`| `array` | Attached files          | Array of objects                                                        |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 16. ActivityLog Entity
Description: Activity and notification tracking.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique activity identifier| Auto-generated                                                          |
| `title`    | `string`  | Notification title      | Required                                                                |
| `description`| `string`| Detailed description    | Required                                                                |
| `activity_type`| `string`| Type of activity        | Required, Enum: "event_created", "event_updated", "event_rescheduled", "event_canceled", "staff_assigned", "staff_removed", "invoice_paid", "invoice_created", "message_received", "order_created", "order_updated" |
| `related_entity_type`| `string`| Related entity type     | Enum: "event", "staff", "invoice", "message", "order", "user"           |
| `related_entity_id`| `string`| Related entity ID       | Optional                                                                |
| `action_link`| `string`| Link to related item    | Optional                                                                |
| `action_label`| `string`| Action button label     | Optional                                                                |
| `user_id`  | `string`  | User this is for        | Required                                                                |
| `is_read`  | `boolean` | Read status             | Default: false                                                          |
| `icon_type`| `string`  | Icon to display         | Enum: "calendar", "user", "invoice", "message", "alert", "check"        |
| `icon_color`| `string` | Icon color theme        | Enum: "blue", "red", "green", "yellow", "purple"                        |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 17. Enterprise Entity
Description: Enterprise organization management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique enterprise ID    | Auto-generated                                                          |
| `enterprise_number`| `string`| Enterprise Number (EN-####)| Required, Pattern: `^EN-[0-9]{4}$`                                      |
| `enterprise_name`| `string`| Enterprise name         | Required                                                                |
| `enterprise_code`| `string`| Short code identifier   | Required                                                                |
| `brand_family`| `array` | Brands under enterprise | Array of strings                                                        |
| `headquarters_address`| `string`| HQ address              | Optional                                                                |
| `global_policies`| `object`| Global policies         | Optional                                                                |
| `sector_registry`| `array`| Sector IDs              | Array of strings                                                        |
| `rate_guardrails`| `object`| Rate limits             | Optional                                                                |
| `primary_contact_name`| `string`| Contact name            | Optional                                                                |
| `primary_contact_email`| `string`| Contact email           | Email format                                                            |
| `is_active`| `boolean` | Active status           | Default: true                                                           |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 18. Sector Entity
Description: Sector/branch management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique sector identifier| Auto-generated                                                          |
| `sector_number`| `string`| Sector Number (SN-####) | Required, Pattern: `^SN-[0-9]{4}$`                                      |
| `sector_name`| `string` | Sector/brand name       | Required                                                                |
| `sector_code`| `string` | Short code identifier   | Required                                                                |
| `parent_enterprise_id`| `string`| Parent enterprise ID    | Optional                                                                |
| `parent_enterprise_name`| `string`| Parent enterprise name  | Optional                                                                |
| `sector_type`| `string` | Sector business type    | Enum: "Food Service", "Facilities", "Healthcare", "Education", "Corporate", "Sports & Entertainment" |
| `client_portfolio`| `array`| Partner/client IDs      | Array of strings                                                        |
| `sector_policies`| `object`| Sector-specific policies| Optional                                                                |
| `approved_vendors`| `array`| Approved vendor IDs     | Array of strings                                                        |
| `is_active`| `boolean` | Active status           | Default: true                                                           |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 19. Partner Entity
Description: Partner/client organization management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique partner identifier| Auto-generated                                                          |
| `partner_name`| `string`| Partner/client name     | Required                                                                |
| `partner_number`| `string`| Partner Number (PN-####)| Required, Pattern: `^PN-[0-9]{4}$`                                      |
| `partner_type`| `string`| Partner type            | Enum: "Corporate", "Education", "Healthcare", "Sports & Entertainment", "Government" |
| `sector_id`| `string`  | Sector ID               | Optional                                                                |
| `sector_name`| `string`| Sector name             | Optional                                                                |
| `primary_contact_name`| `string`| Primary contact         | Optional                                                                |
| `primary_contact_email`| `string`| Primary email           | Email format                                                            |
| `primary_contact_phone`| `string`| Primary phone           | Optional                                                                |
| `billing_address`| `string`| Billing address         | Optional                                                                |
| `sites`    | `array`   | Partner sites/locations | Array of objects                                                        |
| `allowed_vendors`| `array`| Allowed vendor IDs      | Array of strings                                                        |
| `rate_exceptions`| `array`| Rate exceptions         | Array of objects                                                        |
| `cost_centers`| `array` | Cost centers/PO numbers | Array of strings                                                        |
| `payment_terms`| `string`| Payment terms           | Default: "Net 30"                                                       |
| `is_active`| `boolean` | Active status           | Default: true                                                           |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 20. Order Entity
Description: Order management system.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique order identifier | Auto-generated                                                          |
| `order_number`| `string`| Order Number (ORD-####) | Required, Pattern: `^ORD-[0-9]{4,6}$`                                   |
| `partner_id`| `string` | Partner/Client ID       | Required                                                                |
| `partner_name`| `string`| Partner/Client name     | Optional                                                                |
| `site_id`  | `string`  | Site/location ID        | Optional                                                                |
| `site_name`| `string`  | Site/location name      | Optional                                                                |
| `site_address`| `string`| Event/site address      | Optional                                                                |
| `sector_id`| `string`  | Sector ID               | Optional                                                                |
| `enterprise_id`| `string`| Enterprise ID           | Optional                                                                |
| `order_type`| `string` | Type of order           | Enum: "Standard", "Last Minute", "Emergency", "Recurring"               |
| `cost_center`| `string`| Cost center             | Optional                                                                |
| `po_number`| `string`  | Purchase order number   | Optional                                                                |
| `roles_requested`| `array`| Roles and headcount     | Array of objects                                                        |
| `tags`     | `array`   | Order tags/labels       | Array of strings                                                        |
| `point_of_contact`| `object`| On-site contact         | Optional                                                                |
| `sla_targets`| `object`| SLA targets             | Optional                                                                |
| `order_status`| `string`| Order status            | Enum: "Draft", "Submitted", "Confirmed", "In Progress", "Completed", "Cancelled" |
| `submitted_date`| `timestamp`| Submission date         | Optional                                                                |
| `confirmed_date`| `timestamp`| Confirmation date       | Optional                                                                |
| `special_instructions`| `string`| Special instructions    | Optional                                                                |
| `total_estimated_cost`| `number`| Estimated total cost    | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 21. Shift Entity
Description: Shift scheduling and management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique shift identifier | Auto-generated                                                          |
| `event_id` | `string`  | Associated event ID     | Optional                                                                |
| `shift_name`| `string` | Name of the shift       | Required                                                                |
| `manager_id`| `string` | Manager staff ID        | Optional                                                                |
| `manager_name`| `string`| Manager name            | Optional                                                                |
| `location` | `string`  | Shift location          | Optional                                                                |
| `start_date`| `timestamp`| Shift start date/time   | Required                                                                |
| `end_date` | `timestamp`| Shift end date/time     | Optional                                                                |
| `unpaid_break`| `number`| Unpaid break in minutes | Optional                                                                |
| `count`    | `number`  | Number of staff needed  | Optional                                                                |
| `assigned` | `number`  | Number of staff assigned| Optional                                                                |
| `uniform_type`| `string`| Required uniform type   | Optional                                                                |
| `price`    | `number`  | Price per staff member  | Optional                                                                |
| `amount`   | `number`  | Total amount for shift  | Optional                                                                |
| `assigned_staff`| `array`| List of assigned staff  | Array of objects                                                        |
| `role`     | `string`  | Role for this shift     | Optional                                                                |
| `department`| `string` | Department              | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

### 22. Assignment Entity
Description: Worker assignment and tracking.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique assignment identifier| Auto-generated                                                          |
| `assignment_number`| `string`| Assignment Number (ASN-####)| Pattern: `^ASN-[0-9]{4,6}$`                                             |
| `order_id` | `string`  | Associated order ID     | Required                                                                |
| `order_number`| `string`| Order number            | Optional                                                                |
| `workforce_id`| `string`| Assigned worker ID      | Required                                                                |
| `workforce_name`| `string`| Assigned worker name    | Optional                                                                |
| `vendor_id`| `string`  | Vendor providing the worker| Required                                                                |
| `vendor_name`| `string`| Vendor name             | Optional                                                                |
| `partner_id`| `string` | Client/partner ID       | Optional                                                                |
| `role`     | `string`  | Role assigned           | Required                                                                |
| `department`| `string` | Department              | Optional                                                                |
| `assignment_status`| `string`| Assignment status       | Enum: "Pending", "Confirmed", "Checked In", "In Progress", "Completed", "Cancelled", "No Show" |
| `scheduled_start`| `timestamp`| Scheduled start time    | Required                                                                |
| `scheduled_end`| `timestamp`| Scheduled end time      | Optional                                                                |
| `actual_start`| `timestamp`| Actual start time       | Optional                                                                |
| `actual_end`| `timestamp`| Actual end time         | Optional                                                                |
| `timesheet`| `object` | Timesheet data          | Optional                                                                |
| `ratings`  | `object`  | Performance ratings     | Optional                                                                |
| `pay_rate` | `number`  | Worker pay rate         | Optional                                                                |
| `bill_rate`| `number`  | Client bill rate        | Optional                                                                |
| `total_pay`| `number`  | Total worker pay        | Optional                                                                |
| `total_bill`| `number` | Total client bill       | Optional                                                                |
| `notes`    | `string`  | Assignment notes        | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

Timesheet Structure:
```json
{
  "clock_in": "timestamp",
  "clock_out": "timestamp",
  "break_minutes": "number",
  "total_hours": "number",
  "regular_hours": "number",
  "overtime_hours": "number",
  "approved_by": "string",
  "approved_date": "timestamp"
}
```

Ratings Structure:
```json
{
  "punctuality": "number (1-5)",
  "quality_of_work": "number (1-5)",
  "professionalism": "number (1-5)",
  "would_hire_again": "boolean",
  "comments": "string",
  "rated_by": "string",
  "rated_date": "timestamp"
}
```

### 23. Workforce Entity
Description: Worker/contractor management.

| Field Name | Type      | Description             | Validation                                                              |
| :--------- | :-------- | :---------------------- | :---------------------------------------------------------------------- |
| `id`       | `string`  | Unique workforce identifier| Auto-generated                                                          |
| `workforce_number`| `string`| Worker Number (WF-####) | Required, Pattern: `^WF-[0-9]{4,6}$`                                    |
| `vendor_id`| `string`  | Vendor who manages this worker| Required                                                                |
| `vendor_name`| `string`| Vendor name             | Optional                                                                |
| `first_name`| `string` | Worker first name       | Required                                                                |
| `last_name`| `string` | Worker last name        | Required                                                                |
| `email`    | `string`  | Worker email            | Email format                                                            |
| `phone`    | `string`  | Worker phone            | Optional                                                                |
| `address`  | `string`  | Worker address          | Optional                                                                |
| `city`     | `string`  | City                    | Optional                                                                |
| `state`    | `string`  | State                   | Optional                                                                |
| `zip_code` | `string`  | ZIP code                | Optional                                                                |
| `date_of_birth`| `date` | Date of birth           | Optional                                                                |
| `ssn_last_four`| `string`| Last 4 digits of SSN    | Pattern: `^[0-9]{4}$`                                                   |
| `employment_type`| `string`| Employment classification| Enum: "W2", "1099", "Temporary", "Contract"                             |
| `skills`   | `array`   | Worker skills           | Array of strings                                                        |
| `roles_qualified`| `array`| Roles worker is qualified for| Array of strings                                                        |
| `certifications`| `array`| Certifications          | Array of cert objects                                                   |
| `background_check_status`| `string`| Background check status | Enum: "Pending", "Cleared", "Failed", "Expired"                         |
| `background_check_date`| `date`| Background check date   | Optional                                                                |
| `drug_test_status`| `string`| Drug test status        | Enum: "Pending", "Passed", "Failed", "Expired"                          |
| `drug_test_date`| `date`| Drug test date          | Optional                                                                |
| `reliability_index`| `number`| Reliability score       | Min: 0, Max: 100                                                        |
| `total_assignments`| `number`| Total assignments completed| Default: 0                                                              |
| `cancelled_assignments`| `number`| Cancelled assignments   | Default: 0                                                              |
| `no_shows` | `number`  | No-show count           | Default: 0                                                              |
| `average_rating`| `number`| Average performance rating| Min: 0, Max: 5                                                          |
| `languages`| `array`  | Languages spoken        | Array of strings                                                        |
| `availability`| `object`| Worker availability     | Optional                                                                |
| `is_active`| `boolean`| Is worker active        | Default: true                                                           |
| `hire_date`| `date`   | Date worker was hired   | Optional                                                                |
| `termination_date`| `date`| Termination date if applicable| Optional                                                                |
| `notes`    | `string`  | Internal notes          | Optional                                                                |
| `created_date`| `timestamp`| Creation date           | Auto-generated                                                          |
| `updated_date`| `timestamp`| Last update             | Auto-updated                                                            |
| `created_by`| `string`  | Creator email           | Auto-populated                                                          |

Availability Structure:
```json
{
  "monday": "boolean",
  "tuesday": "boolean",
  "wednesday": "boolean",
  "thursday": "boolean",
  "friday": "boolean",
  "saturday": "boolean",
  "sunday": "boolean",
  "shift_preferences": ["Morning", "Day", "Evening", "Night", "Overnight"]
}
```

---

## SDK Operations

### Standard Entity Operations
All entities support the following base operations:

#### List All Records
```javascript
// List all records (default limit: 50)
const records = await base44.entities.EntityName.list();

// List with sorting (descending by created_date)
const records = await base44.entities.EntityName.list('-created_date');

// List with sorting and limit
const records = await base44.entities.EntityName.list('-created_date', 20);
```

#### Filter Records
```javascript
// Filter by single field
const records = await base44.entities.EntityName.filter({
  status: 'Active'
});

// Filter with multiple conditions
const records = await base44.entities.EntityName.filter({
  status: 'Active',
  created_by: user.email
});

// Filter with sorting and limit
const records = await base44.entities.EntityName.filter(
  { status: 'Active' },
  '-created_date',
  10
);

// Filter with operators
const records = await base44.entities.EntityName.filter({
  rating: { $gte: 4.5 },
  total: { $lte: 1000 }
});
```

#### Create Record
```javascript
// Create single record
const newRecord = await base44.entities.EntityName.create({
  field1: 'value1',
  field2: 'value2'
});

// Returns created record with id
```

#### Bulk Create Records
```javascript
// Create multiple records
const newRecords = await base44.entities.EntityName.bulkCreate([
  { field1: 'value1' },
  { field1: 'value2' },
  { field1: 'value3' }
]);

// Returns array of created records
```

#### Update Record
```javascript
// Update by ID
const updatedRecord = await base44.entities.EntityName.update(recordId, {
  field1: 'new value'
});

// Returns updated record
```

#### Delete Record
```javascript
// Delete by ID
await base44.entities.EntityName.delete(recordId);
```

#### Get Entity Schema
```javascript
// Get JSON schema (without built-in fields)
const schema = await base44.entities.EntityName.schema();

// Useful for dynamic form generation
```

### Entity-Specific Examples

#### Event Operations
```javascript
// List recent events
const events = await base44.entities.Event.list('-date', 50);

// Filter vendor's events
const myEvents = await base44.entities.Event.filter({
  vendor_id: user.id,
  status: 'Active'
}, '-date', 20);

// Create new event
const newEvent = await base44.entities.Event.create({
  event_name: 'Corporate Luncheon',
  business_name: 'Acme Corp',
  date: '2025-12-01',
  status: 'Draft',
  requested: 15,
  is_rapid: false,
  conflict_detection_enabled: true
});

// Update event status
await base44.entities.Event.update(eventId, {
  status: 'Confirmed'
});
```

#### Staff Operations
```javascript
// List all active staff
const staff = await base44.entities.Staff.list('-created_date');

// Filter by vendor
const vendorStaff = await base44.entities.Staff.filter({
  vendor_id: vendorId
});

// Filter by rating
const topStaff = await base44.entities.Staff.filter({
  rating: { $gte: 4.5 }
}, '-rating', 10);

// Create staff member
const newStaff = await base44.entities.Staff.create({
  employee_name: 'John Doe',
  vendor_name: 'ABC Staffing',
  position: 'Server',
  employment_type: 'Part Time'
});

// Update staff rating
await base44.entities.Staff.update(staffId, {
  rating: 4.8,
  reliability_score: 95
});
```

#### Invoice Operations
```javascript
// List unpaid invoices
const unpaid = await base44.entities.Invoice.filter({
  status: 'Open'
}, '-due_date');

// Get client's invoices
const clientInvoices = await base44.entities.Invoice.filter({
  business_name: clientName
});

// Create invoice
const invoice = await base44.entities.Invoice.create({
  invoice_number: 'INV-2025-001',
  business_name: 'Client Corp',
  amount: 5000,
  status: 'Draft',
  issue_date: '2025-01-01',
  due_date: '2025-01-31'
});

// Mark as paid
await base44.entities.Invoice.update(invoiceId, {
  status: 'Paid',
  paid_date: new Date().toISOString()
});
```

#### Team Operations
```javascript
// Get user's team
const myTeam = await base44.entities.Team.filter({
  owner_id: user.id
});

// Create team
const team = await base44.entities.Team.create({
  team_name: 'Operations Team',
  owner_id: user.id,
  owner_name: user.full_name,
  owner_role: user.user_role,
  departments: ['Operations', 'HR', 'Finance']
});

// Add favorite staff
await base44.entities.Team.update(teamId, {
  favorite_staff: [
    ...existingFavorites,
    {
      staff_id: staffId,
      staff_name: 'John Doe',
      position: 'Server',
      added_date: new Date().toISOString()
    }
  ],
  favorite_staff_count: existingFavorites.length + 1
});
```

#### TeamMember Operations
```javascript
// List team members
const members = await base44.entities.TeamMember.filter({
  team_id: teamId,
  is_active: true
});

// Create team member
const member = await base44.entities.TeamMember.create({
  team_id: teamId,
  member_name: 'Jane Smith',
  email: 'jane@example.com',
  role: 'member',
  department: 'Operations',
  hub: 'BVG 300'
});

// Deactivate member
await base44.entities.TeamMember.update(memberId, {
  is_active: false
});
```

#### Conversation & Message Operations
```javascript
// List active conversations
const conversations = await base44.entities.Conversation.filter({
  status: 'active',
  participants: { $contains: userId }
}, '-last_message_at');

// Create conversation
const conversation = await base44.entities.Conversation.create({
  participants: [
    { id: user1Id, name: user1Name, role: 'client' },
    { id: user2Id, name: user2Name, role: 'vendor' }
  ],
  conversation_type: 'client-vendor',
  subject: 'Event #123 Discussion',
  status: 'active'
});

// Send message
const message = await base44.entities.Message.create({
  conversation_id: conversationId,
  sender_id: userId,
  sender_name: userName,
  sender_role: 'client',
  content: 'Hello, can we discuss the event details?'
});

// Mark as read
await base44.entities.Message.update(messageId, {
  read_by: [...existingReadBy, userId]
});
```

---

## Core Integrations

### Integration: InvokeLLM
Description: Generate responses from an LLM with optional web context or file attachments.

| Parameter                 | Type      | Required | Description                                            |
| :------------------------ | :-------- | :------- | :----------------------------------------------------- |
| `prompt`                  | `string`  | Yes      | The prompt to send to the LLM                          |
| `add_context_from_internet`| `boolean` | No       | Fetch context from Google Search, Maps, News (default: false) |
| `response_json_schema`    | `object`  | No       | JSON schema for structured output (root must be "object") |
| `file_urls`               | `string[]`| No       | Array of file URLs for additional context              |

Returns:
- If `response_json_schema` specified: `object` (parsed JSON)
- Otherwise: `string`

Examples:
```javascript
// Simple text response
const response = await base44.integrations.Core.InvokeLLM({
  prompt: "Summarize the top 3 benefits of workforce automation"
});

// Structured JSON response
const data = await base44.integrations.Core.InvokeLLM({
  prompt: "Extract key information about Apple (the company)",
  add_context_from_internet: true,
  response_json_schema: {
    type: "object",
    properties: {
      stock_price: { type: "number" },
      ceo: { type: "string" },
      headquarters: { type: "string" },
      recent_news: {
        type: "array",
        items: { type: "string" }
      }
    }
  }
});

// With file context
const analysis = await base44.integrations.Core.InvokeLLM({
  prompt: "Analyze this invoice and extract line items",
  file_urls: [invoiceFileUrl],
  response_json_schema: {
    type: "object",
    properties: {
      line_items: {
        type: "array",
        items: {
          type: "object",
          properties: {
            description: { type: "string" },
            quantity: { type: "number" },
            rate: { type: "number" },
            amount: { type: "number" }
          }
        }
      },
      total: { type: "number" }
    }
  }
});
```

### Integration: SendEmail
Description: Send an email to a user.

| Parameter | Type      | Required | Description                                            |
| :-------- | :-------- | :------- | :----------------------------------------------------- |
| `to`      | `string`  | Yes      | Recipient email address                                |
| `subject` | `string`  | Yes      | Email subject line                                     |
| `body`    | `string`  | Yes      | Email body (supports HTML)                             |
| `from_name`| `string` | No       | Sender name (defaults to app name)                     |

Returns: `void`

Example:
```javascript
await base44.integrations.Core.SendEmail({
  to: 'client@example.com',
  subject: 'Your Event Has Been Confirmed',
  body: `
    <h2>Event Confirmation</h2>
    <p>Hello ${clientName},</p>
    <p>Your event "${eventName}" has been confirmed for ${eventDate}.</p>
    <p>Staff assigned: ${staffCount}</p>
    <p>Thank you for using KROW Workforce!</p>
  `,
  from_name: 'KROW Workforce Team'
});
```

### Integration: UploadFile
Description: Upload a file to public storage.

| Parameter | Type   | Required | Description             |
| :-------- | :----- | :------- | :---------------------- |
| `file`    | `File` | Yes      | File object to upload   |

Returns:
```json
{
  "file_url": "string"
}
```

Example:
```javascript
// From file input
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];

const { file_url } = await base44.integrations.Core.UploadFile({
  file: file
});

// Use the URL
await base44.entities.Staff.update(staffId, {
  profile_picture: file_url
});
```

### Integration: UploadPrivateFile
Description: Upload a file to private storage (requires signed URL for access).

| Parameter | Type   | Required | Description             |
| :-------- | :----- | :------- | :---------------------- |
| `file`    | `File` | Yes      | File object to upload   |

Returns:
```json
{
  "file_uri": "string"
}
```

Example:
```javascript
// Upload private document
const { file_uri } = await base44.integrations.Core.UploadPrivateFile({
  file: sensitiveDocument
});

// Store the URI
await base44.entities.Vendor.update(vendorId, {
  w9_document: file_uri
});

// Later, create signed URL for access
const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
  file_uri: file_uri,
  expires_in: 3600  // 1 hour
});
```

### Integration: CreateFileSignedUrl
Description: Create a temporary signed URL for accessing a private file.

| Parameter  | Type      | Required | Description                                            |
| :--------- | :-------- | :------- | :----------------------------------------------------- |
| `file_uri` | `string`  | Yes      | Private file URI                                       |
| `expires_in`| `number` | No       | Expiration time in seconds (default: 300)              |

Returns:
```json
{
  "signed_url": "string"
}
```

Example:
```javascript
// Create 1-hour signed URL
const { signed_url } = await base44.integrations.Core.CreateFileSignedUrl({
  file_uri: vendor.w9_document,
  expires_in: 3600
});

// Use signed URL
window.open(signed_url, '_blank');
```

### Integration: ExtractDataFromUploadedFile
Description: Extract structured data from uploaded files (CSV, PDF, images).

| Parameter   | Type      | Required | Description                                            |
| :---------- | :-------- | :------- | :----------------------------------------------------- |
| `file_url`  | `string`  | Yes      | URL to uploaded file                                   |
| `json_schema`| `object` | Yes      | JSON schema defining expected data structure           |

Returns:
```json
{
  "status": "success" | "error",
  "details": "string | null",
  "output": "object[] | object | null"
}
```

Example:
```javascript
// Upload CSV of staff members
const { file_url } = await base44.integrations.Core.UploadFile({
  file: csvFile
});

// Extract data
const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
  file_url: file_url,
  json_schema: {
    type: "array",
    items: {
      type: "object",
      properties: {
        employee_name: { type: "string" },
        email: { type: "string" },
        position: { type: "string" },
        department: { type: "string" },
        phone: { type: "string" }
      }
    }
  }
});

if (result.status === "success") {
  // Bulk create staff from extracted data
  await base44.entities.Staff.bulkCreate(result.output);
}
```

### Integration: GenerateImage
Description: Generate an AI image from a text prompt.

| Parameter | Type      | Required | Description                                            |
| :-------- | :-------- | :------- | :----------------------------------------------------- |
| `prompt`  | `string`  | Yes      | Detailed image description                             |

Returns:
```json
{
  "url": "string"
}
```

Example:
```javascript
// Generate event banner
const { url } = await base44.integrations.Core.GenerateImage({
  prompt: "Professional corporate event banner with elegant food service theme, blue and white color scheme, modern minimalist design"
});

// Use the generated image
await base44.entities.Event.update(eventId, {
  banner_image: url
});
```

---

## Data Models Reference

### Complete Event Object Example
```json
{
  "id": "evt_1234567890",
  "event_name": "Google Campus Lunch Service",
  "is_recurring": true,
  "is_multi_day": false,
  "is_rapid": false,
  "recurrence_type": "date_range",
  "recurrence_start_date": "2025-01-01",
  "recurrence_end_date": "2025-12-31",
  "buffer_time_before": 15,
  "buffer_time_after": 15,
  "conflict_detection_enabled": true,
  "detected_conflicts": [],
  "business_id": "bus_0987654321",
  "business_name": "Google",
  "vendor_id": "vnd_1122334455",
  "vendor_name": "Elite Staffing Solutions",
  "hub": "Mountain View Campus",
  "contract_type": "W2",
  "po_reference": "PO-2025-001",
  "status": "Active",
  "date": "2025-01-15",
  "shifts": [
    {
      "shift_name": "Lunch Shift",
      "shift_contact": "John Manager",
      "location_address": "1600 Amphitheatre Parkway",
      "roles": [
        {
          "role": "Server",
          "department": "Food Service",
          "count": 10,
          "start_time": "11:00",
          "end_time": "15:00",
          "hours": 4,
          "uniform": "White shirt, black pants",
          "break_minutes": 30,
          "cost_per_hour": 25,
          "total_value": 1000,
          "vendor_name": "Elite Staffing Solutions",
          "vendor_id": "vnd_1122334455"
        }
      ]
    }
  ],
  "addons": {
    "goal": {
      "enabled": true,
      "text": "Maintain 95% customer satisfaction"
    },
    "portal_access": true,
    "meal_provided": true,
    "travel_time": false,
    "tips": {
      "enabled": true,
      "amount": "pooled"
    }
  },
  "total": 1900,
  "requested": 15,
  "assigned_staff": [
    {
      "staff_id": "stf_111",
      "staff_name": "Maria Garcia",
      "role": "Server",
      "confirmed": true
    }
  ],
  "client_name": "Sarah Johnson",
  "client_email": "sarah.johnson@google.com",
  "client_phone": "(650) 555-0123",
  "notes": "Ensure all staff arrive 15 minutes early",
  "created_date": "2025-01-01T10:00:00Z",
  "updated_date": "2025-01-10T14:30:00Z",
  "created_by": "admin@krow.com"
}
```

### Complete Staff Object Example
```json
{
  "id": "stf_9876543210",
  "employee_name": "Maria Garcia",
  "vendor_id": "vnd_1122334455",
  "vendor_name": "Elite Staffing Solutions",
  "manager": "Fernando Lopez",
  "contact_number": "(415) 555-0199",
  "phone": "(415) 555-0200",
  "email": "maria.garcia@email.com",
  "department": "Operations",
  "hub_location": "San Francisco Bay Area",
  "event_location": "Various",
  "address": "123 Main St, Apt 4B",
  "city": "San Francisco",
  "position": "Server",
  "position_2": "Bartender",
  "initial": "MG",
  "profile_type": "Skilled",
  "employment_type": "Part Time",
  "english": "Fluent",
  "english_required": true,
  "check_in": "2025-01-15",
  "rating": 4.8,
  "shift_coverage_percentage": 95,
  "cancellation_count": 2,
  "no_show_count": 0,
  "total_shifts": 47,
  "reliability_score": 96,
  "background_check_status": "cleared",
  "background_check_date": "2024-06-15",
  "certifications": [
    {
      "name": "Food Handler Certificate",
      "issued_date": "2024-06-01",
      "expiry_date": "2026-06-01",
      "issuer": "ServSafe"
    }
  ],
  "notes": "Excellent customer service skills",
  "created_date": "2024-01-10T09:00:00Z",
  "updated_date": "2025-01-15T16:45:00Z",
  "created_by": "vendor@elitestaffing.com"
}
```

### Complete Team Object Example
```json
{
  "id": "team_123456",
  "team_name": "Operations Team",
  "owner_id": "user_789",
  "owner_name": "John Manager",
  "owner_role": "vendor",
  "email": "john@example.com",
  "phone": "(555) 123-4567",
  "departments": ["Operations", "HR", "Finance"],
  "total_members": 15,
  "active_members": 12,
  "total_hubs": 3,
  "favorite_staff": [
    {
      "staff_id": "stf_111",
      "staff_name": "Maria Garcia",
      "position": "Server",
      "added_date": "2025-01-15T10:00:00Z"
    }
  ],
  "blocked_staff": [
    {
      "staff_id": "stf_222",
      "staff_name": "John Smith",
      "reason": "Performance issues",
      "blocked_date": "2025-01-10T14:30:00Z"
    }
  ],
  "favorite_staff_count": 1,
  "blocked_staff_count": 1,
  "created_date": "2025-01-01T08:00:00Z",
  "updated_date": "2025-01-15T16:00:00Z"
}
```

---

## Code Examples

### Example 1: Create Event with Staff Assignment
```javascript
import { base44 } from "@/api/base44Client";

async function createEventAndAssignStaff() {
  const user = await base44.auth.me();
  
  const event = await base44.entities.Event.create({
    event_name: "Corporate Holiday Party",
    business_name: "Acme Corporation",
    date: "2025-12-20",
    hub: "Downtown Office",
    status: "Draft",
    requested: 20,
    is_rapid: false,
    conflict_detection_enabled: true,
    shifts: [
      {
        shift_name: "Evening Service",
        location_address: "123 Corporate Plaza",
        roles: [
          {
            role: "Server",
            department: "Food Service",
            count: 15,
            start_time: "18:00",
            end_time: "23:00",
            hours: 5,
            cost_per_hour: 28,
            total_value: 2100
          }
        ]
      }
    ],
    total: 3060,
    client_name: user.full_name,
    client_email: user.email
  });
  
  const availableStaff = await base44.entities.Staff.filter({
    position: "Server",
    rating: { $gte: 4.5 },
    employment_type: { $in: ["Part Time", "Full Time"] }
  }, '-rating', 15);
  
  const assignedStaff = availableStaff.map(staff => ({
    staff_id: staff.id,
    staff_name: staff.employee_name,
    role: "Server",
    confirmed: false
  }));
  
  await base44.entities.Event.update(event.id, {
    assigned_staff: assignedStaff,
    status: "Pending"
  });
  
  await base44.entities.ActivityLog.create({
    title: "Event Created",
    description: `New event "${event.event_name}" created and staff assigned`,
    activity_type: "event_created",
    related_entity_type: "event",
    related_entity_id: event.id,
    user_id: user.id,
    is_read: false,
    icon_type: "calendar",
    icon_color: "blue"
  });
  
  return event;
}
```

### Example 2: Send Invoice Reminder Emails
```javascript
import { base44 } from "@/api/base44Client";

async function sendInvoiceReminders() {
  const today = new Date();
  const overdueInvoices = await base44.entities.Invoice.filter({
    status: { $in: ["Open", "Overdue"] },
    due_date: { $lt: today.toISOString().split('T')[0] }
  });
  
  for (const invoice of overdueInvoices) {
    await base44.entities.Invoice.update(invoice.id, {
      status: "Overdue"
    });
    
    const business = await base44.entities.Business.filter({
      business_name: invoice.business_name
    });
    
    if (business.length > 0) {
      const contact = business[0];
      
      await base44.integrations.Core.SendEmail({
        to: contact.email,
        subject: `Payment Reminder: Invoice ${invoice.invoice_number}`,
        body: `
          <h2>Payment Reminder</h2>
          <p>Dear ${contact.contact_name},</p>
          <p>Invoice <strong>${invoice.invoice_number}</strong> 
          for <strong>$${invoice.amount.toLocaleString()}</strong> is now overdue.</p>
          <p><strong>Due Date:</strong> ${invoice.due_date}</p>
          <p>Please process payment at your earliest convenience.</p>
          <p>Thank you,<br>KROW Workforce Team</p>
        `,
        from_name: "KROW Accounts Receivable"
      });
      
      await base44.entities.ActivityLog.create({
        title: "Invoice Reminder Sent",
        description: `Reminder sent for invoice ${invoice.invoice_number}`,
        activity_type: "invoice_created",
        related_entity_type: "invoice",
        related_entity_id: invoice.id,
        user_id: contact.id || "system",
        icon_type: "invoice",
        icon_color: "yellow"
      });
    }
  }
  
  return overdueInvoices.length;
}
```

### Example 3: AI-Powered Staff Recommendation
```javascript
import { base44 } from "@/api/base44Client";

async function getStaffRecommendations(eventId) {
  const events = await base44.entities.Event.filter({ id: eventId });
  const event = events[0];
  
  const allStaff = await base44.entities.Staff.list();
  
  const recommendations = await base44.integrations.Core.InvokeLLM({
    prompt: `
      Analyze this event and recommend the best staff members.
      
      Event Details:
      - Name: ${event.event_name}
      - Date: ${event.date}
      - Location: ${event.hub}
      - Roles Needed: ${JSON.stringify(event.shifts)}
      
      Available Staff:
      ${JSON.stringify(allStaff.map(s => ({
        id: s.id,
        name: s.employee_name,
        position: s.position,
        rating: s.rating,
        reliability: s.reliability_score,
        experience: s.total_shifts
      })))}
      
      Recommend the top staff for each role based on:
      1. Position match
      2. Rating and reliability
      3. Experience level
      
      Provide reasoning for each recommendation.
    `,
    response_json_schema: {
      type: "object",
      properties: {
        recommendations: {
          type: "array",
          items: {
            type: "object",
            properties: {
              staff_id: { type: "string" },
              staff_name: { type: "string" },
              role: { type: "string" },
              score: { type: "number" },
              reasoning: { type: "string" }
            }
          }
        },
        overall_analysis: { type: "string" }
      }
    }
  });
  
  return recommendations;
}
```

### Example 4: Bulk Import Staff from CSV
```javascript
import { base44 } from "@/api/base44Client";

async function importStaffFromCSV(file) {
  const { file_url } = await base44.integrations.Core.UploadFile({
    file: file
  });
  
  const result = await base44.integrations.Core.ExtractDataFromUploadedFile({
    file_url: file_url,
    json_schema: {
      type: "array",
      items: {
        type: "object",
        properties: {
          employee_name: { type: "string" },
          email: { type: "string" },
          phone: { type: "string" },
          position: { type: "string" },
          department: { type: "string" },
          employment_type: { type: "string" },
          vendor_name: { type: "string" }
        },
        required: ["employee_name"]
      }
    }
  });
  
  if (result.status === "error") {
    throw new Error(result.details);
  }
  
  const createdStaff = await base44.entities.Staff.bulkCreate(
    result.output.map(staff => ({
      ...staff,
      rating: 0,
      reliability_score: 0,
      total_shifts: 0,
      background_check_status: "pending"
    }))
  );
  
  await base44.entities.ActivityLog.create({
    title: "Bulk Staff Import",
    description: `${createdStaff.length} staff members imported from CSV`,
    activity_type: "staff_assigned",
    user_id: (await base44.auth.me()).id,
    icon_type: "user",
    icon_color: "green"
  });
  
  return createdStaff;
}
```

### Example 5: Team Management with Invitations
```javascript
import { base44 } from "@/api/base44Client";

async function createTeamAndInviteMembers() {
  const user = await base44.auth.me();
  
  // Create team
  const team = await base44.entities.Team.create({
    team_name: "Operations Team",
    owner_id: user.id,
    owner_name: user.full_name,
    owner_role: user.user_role,
    email: user.email,
    departments: ["Operations", "HR", "Finance"]
  });
  
  // Create hub
  const hub = await base44.entities.TeamHub.create({
    team_id: team.id,
    hub_name: "BVG 300",
    address: "300 Bayview Dr, Mountain View, CA",
    manager_name: "John Manager",
    manager_email: "john@example.com",
    departments: [
      {
        department_name: "Catering FOH",
        cost_center: "CC-001"
      }
    ]
  });
  
  // Create invitation
  const inviteCode = `TEAM-${Math.floor(10000 + Math.random() * 90000)}`;
  const invite = await base44.entities.TeamMemberInvite.create({
    team_id: team.id,
    team_name: team.team_name,
    invite_code: inviteCode,
    email: "newmember@example.com",
    full_name: "New Member",
    role: "member",
    hub: hub.hub_name,
    department: "Catering FOH",
    invited_by: user.email,
    invite_status: "pending",
    invited_date: new Date().toISOString(),
    expires_at: new Date(Date.now() + 7 * 24 * 60 * 60 * 1000).toISOString()
  });
  
  // Send invitation email
  await base44.integrations.Core.SendEmail({
    to: "newmember@example.com",
    subject: `You're invited to join ${team.team_name}`,
    body: `
      <h2>Join ${team.team_name}</h2>
      <p>You've been invited to join ${hub.hub_name}.</p>
      <p>Register here: ${window.location.origin}/Onboarding?invite=${inviteCode}</p>
    `,
    from_name: team.team_name
  });
  
  return { team, hub, invite };
}
```

---

## Best Practices

### 1. Error Handling
```javascript
try {
  const event = await base44.entities.Event.create(eventData);
} catch (error) {
  console.error("Failed to create event:", error);
  toast({
    title: "❌ Error",
    description: "Failed to create event. Please try again.",
    variant: "destructive"
  });
}
```

### 2. Query Optimization
```javascript
// ❌ Bad: Fetch all then filter in memory
const allEvents = await base44.entities.Event.list();
const vendorEvents = allEvents.filter(e => e.vendor_id === vendorId);

// ✅ Good: Filter at database level
const vendorEvents = await base44.entities.Event.filter({
  vendor_id: vendorId
});
```

### 3. Pagination
```javascript
// Fetch in batches
const pageSize = 50;
let page = 0;
let allRecords = [];

while (true) {
  const batch = await base44.entities.Event.list(
    '-created_date',
    pageSize,
    page * pageSize
  );
  
  if (batch.length === 0) break;
  
  allRecords = [...allRecords, ...batch];
  page++;
}
```

### 4. Caching with React Query
```javascript
import { useQuery } from "@tanstack/react-query";

function useEvents() {
  return useQuery({
    queryKey: ['events'],
    queryFn: () => base44.entities.Event.list('-date'),
    initialData: [],
    staleTime: 5 * 60 * 1000,
    cacheTime: 10 * 60 * 1000
  });
}
```

### 5. Batch Operations
```javascript
// ❌ Bad: Multiple sequential creates
for (const staff of staffList) {
  await base44.entities.Staff.create(staff);
}

// ✅ Good: Single bulk create
await base44.entities.Staff.bulkCreate(staffList);
```

### 6. Team Isolation
```javascript
// Teams are automatically isolated by owner_id
const myTeam = await base44.entities.Team.filter({
  owner_id: user.id
});

// Each role can only see their own team
// Vendors cannot see Procurement teams
// Procurement cannot see Vendor teams
```

---

## Security Considerations

### 1. User Entity Access Control
- Only admin users can access other users' data
- Regular users can only view/update their own records
- Built-in security rules are automatically enforced

### 2. Team Isolation
- Teams are isolated by `owner_id`
- Each user role (vendor, procurement, operator, sector, client, workforce) can only see and manage their own team
- Vendors CANNOT see Procurement teams
- Procurement CANNOT see Vendor teams
- NO cross-layer visibility is allowed

### 3. Private Files
- Use `UploadPrivateFile` for sensitive documents
- Always use signed URLs with appropriate expiration
- Never expose private file URIs directly

### 4. Email Validation
- Always validate email formats before sending
- Use proper HTML escaping in email bodies
- Consider rate limiting for bulk emails

### 5. Data Validation
- Validate all input data before entity operations
- Use enum constraints where applicable
- Implement client-side validation before API calls

---

## Rate Limits & Quotas

### Standard Limits
- Entity Operations: 1000 requests/minute
- LLM Invocations: 100 requests/minute
- File Uploads: 100 MB per file
- Email Sending: 1000 emails/day

### Best Practices for Limits
- Implement exponential backoff for retries
- Cache frequently accessed data
- Use bulk operations when possible
- Monitor usage via activity logs

---

## Changelog

### Version 3.0 (2025-11-20)
- Added Team, TeamMember, TeamHub, TeamMemberInvite entities
- Added Assignment and Workforce entities
- Added VendorDefaultSettings entity
- Updated Event entity with conflict detection, multi-day support, and RAPID flag
- Enhanced Invoice entity with comprehensive dispute tracking
- Updated Team entity with favorite_staff and blocked_staff arrays
- Added team isolation security documentation
- Updated all entity schemas with current validation rules
- Enhanced integration specifications
- Added complete code examples for team management

### Version 2.0 (2025-01-11)
- Complete entity schema documentation
- Added 17 entity schemas with full field specifications
- Comprehensive SDK operation examples
- Core integration specifications
- Advanced code examples
- Best practices and security guidelines

### Version 1.0 (2024-12-01)
- Initial API documentation
- Basic entity schemas
- Core integration endpoints

---

## Support & Resources

- **Documentation**
  - Platform Docs: `https://docs.base44.com`
  - API Reference: `https://api.base44.com/docs`
  - Community Forum: `https://community.base44.com`
  
- **Contact**
  - Technical Support: `support@krow.com`
  - Sales Inquiries: `sales@krow.com`
  - General Questions: `info@krow.com`

© 2025 KROW Workforce. All rights reserved.
*/