🛒 Order Blocks
Order blocks provide comprehensive functionality for order management operations in Nodeblocks applications. These blocks handle order lifecycle operations including creation, retrieval, updates, and organization-scoped queries.
🎯 Overview
Order blocks are designed to:
- Manage order lifecycle with full CRUD operations
- Handle order queries with flexible filtering and pagination
- Support organization scoping for multi-tenant order management
- Provide type safety with comprehensive error handling
- Enable composition for building complex order features
📦 Block Types
🔍 Schemas
JSON Schema definitions for order data validation:
- orderSchema: Base order entity structure
- createOrderSchema: Order creation validation
- updateOrderSchema: Order modifications with optional field validation
- getOrderSchema: Order retrieval validation
- deleteOrderSchema: Order deletion validation
- findOrdersSchema: Order search with filtering and pagination
🔧 Blocks
Pure business logic functions for order operations:
- findOrders: Retrieve orders with filtering and pagination
- OrderBlockError: Base error class for order-related block operations
- OrderDbBlockError: Database-specific error class for order block operations
⚙️ Handlers
Core business logic for order operations:
- createOrder: Order creation with validation
- updateOrder: Order updates with validation and conflict detection
- getOrderById: Order data retrieval with existence validation
- findOrders: Order search and filtering
- deleteOrder: Order deletion with safe deletion and existence validation
- createOrderTerminator: Formats successful order creation response
- normalizeOrderTerminator: Normalizes order data by removing database-specific fields
- normalizeOrdersListTerminator: Normalizes orders list by removing database-specific fields
- deleteOrderTerminator: Formats successful deletion response
🛣️ Routes
HTTP endpoint definitions for order operations:
- createOrderRoute: POST
/orderswith creation handler - getOrderRoute: GET
/orders/:orderIdwith access control - findOrdersRoute: GET
/orderswith search and pagination - updateOrderRoute: PATCH
/orders/:orderIdwith access control - deleteOrderRoute: DELETE
/orders/:orderIdwith access control - findOrdersByOrganizationIdRoute: GET
/orders/organizations/:organizationIdwith organization role validation
🚀 Features
Complete order management features combining schemas, routes, and handlers:
- createOrderFeature: Order creation with validation and routing
- updateOrderFeature: Order updates with validation and routing
- getOrderFeature: Order retrieval with proper validation
- findOrdersFeature: Order search with filtering and pagination
- deleteOrderFeature: Order deletion with access control and cleanup
- findOrdersByOrganizationIdFeature: Organization-scoped order retrieval with role-based access control
✅ Validators
Validation functions for order operations:
- ownsOrder: Validates order ownership by the authenticated identity
- validateOrderAccess: Validates order access based on allowed subjects and token information (deprecated)
🔗 Related Documentation
- Order Schemas - Order data validation and contracts
- Order Blocks - Order business logic functions
- Order Handlers - Order business logic handlers
- Order Routes - HTTP endpoint definitions
- Order Features - Complete order management features
- Order Validators - Order validation functions