feat: Implement initial structure for Directus Mayo API extension

- Added main router in src/index.js to register endpoints.
- Implemented GET /mayo-api/products to fetch product list with pagination and filters.
- Implemented GET /mayo-api/dictionaries to fetch various dictionaries for frontend use.
- Created separate files for routes, repositories, serializers, and utilities to maintain clean architecture.
- Added utility functions for async handling, pagination, and order search parsing.
- Introduced serializers for products and dictionaries to format data for frontend consumption.
- Established repository functions for database queries related to products and dictionaries.
- Updated package.json to include license information.
- Created documentation for the API extension detailing current state and future implementation plans.
This commit is contained in:
2026-05-20 22:38:51 +02:00
parent 2005e327f1
commit fb08705883
18 changed files with 1258 additions and 340 deletions

View File

@@ -1,76 +1,52 @@
// Directus Database Schema for Mayo
// Generated from snapshot(6).json
Enum mayo_models_neck_construction {
NTB
BOLT_ON
SET_IN
}
Enum mayo_parts_part_type {
BODY
NECK
}
Enum mayo_parts_finish {
GLOSS
SATIN
MAT
NITRO
}
// Revised schema proposal
// Updated: 2026-05-20
Table mayo_clients {
id integer [primary key]
name "character varying" [unique, not null]
country "character varying" [not null]
country "character varying"
}
Table mayo_color {
Table mayo_colors {
id integer [primary key]
name "character varying" [unique, not null]
}
Table mayo_lisst_products {
Table mayo_finishes {
id integer [primary key]
code "character varying" [unique, not null]
name "character varying" [not null]
}
Table mayo_neck_constructions {
id integer [primary key]
code "character varying" [unique, not null]
name "character varying" [not null]
}
Table mayo_part_types {
id integer [primary key]
code "character varying" [unique, not null]
name "character varying" [not null]
}
Table mayo_product_models {
id integer [primary key]
name "character varying" [unique, not null]
neck_construction_id integer [not null]
}
Table mayo_products {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
product_id integer [not null]
list_id integer [unique, not null]
}
Table mayo_lists {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
name "character varying" [unique, not null]
description "character varying"
}
Table mayo_models {
id integer [primary key]
name "character varying" [unique, not null]
neck_construction mayo_models_neck_construction [not null]
}
Table mayo_operations {
id integer [primary key]
name "character varying" [unique, not null]
description text
}
Table mayo_order_porducts {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
product_id integer [unique, not null]
order_id integer [not null]
order_index integer [not null]
source_url "character varying"
specification json
specification_last_fetched_at timestamp
product_model_id integer [not null]
}
Table mayo_orders {
@@ -84,49 +60,97 @@ Table mayo_orders {
client_id integer [not null]
}
Table mayo_part_events {
Table mayo_order_items {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
part_id integer [not null]
product_id integer [unique, not null]
order_id integer [not null]
order_index integer [not null]
}
Table mayo_production_lists {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
name "character varying" [unique, not null]
description text
}
Table mayo_product_production_lists {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
order_item_id integer [not null]
production_list_id integer [not null]
}
Table mayo_product_parts {
id integer [primary key]
product_id integer [not null]
part_type_id integer [not null]
top_color_id integer
back_color_id integer
top_finish_id integer
back_finish_id integer
}
Table mayo_production_operations {
id integer [primary key]
code "character varying" [unique, not null]
name "character varying" [unique, not null]
description text
}
Table mayo_production_events {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
product_part_id integer [not null]
ordinal integer [not null]
date date [not null]
event_date date [not null]
operation_id integer
note text
}
Table mayo_parts {
id integer [primary key]
part_type mayo_parts_part_type [not null]
top_color_id integer [not null]
back_color_id integer [not null]
top_finish mayo_parts_finish [not null]
back_finish mayo_parts_finish [not null]
product_id integer [not null]
}
Table mayo_products {
id integer [primary key]
user_created uuid
date_created timestamp
user_updated uuid
date_updated timestamp
source_url "character varying"
specification json
model_id integer [not null]
}
// Relationships
Ref: mayo_lisst_products.product_id > mayo_products.id
Ref: mayo_lisst_products.list_id > mayo_lists.id
Ref: mayo_order_porducts.product_id - mayo_products.id
Ref: mayo_order_porducts.order_id > mayo_orders.id
Ref: mayo_product_models.neck_construction_id > mayo_neck_constructions.id
Ref: mayo_products.product_model_id > mayo_product_models.id
Ref: mayo_orders.client_id > mayo_clients.id
Ref: mayo_part_events.part_id > mayo_parts.id
Ref: mayo_part_events.operation_id > mayo_operations.id
Ref: mayo_parts.top_color_id > mayo_color.id
Ref: mayo_parts.back_color_id > mayo_color.id
Ref: mayo_parts.product_id > mayo_products.id
Ref: mayo_products.model_id > mayo_models.id
Ref: mayo_order_items.product_id - mayo_products.id
Ref: mayo_order_items.order_id > mayo_orders.id
Ref: mayo_product_production_lists.order_item_id > mayo_order_items.id
Ref: mayo_product_production_lists.production_list_id > mayo_production_lists.id
Ref: mayo_product_parts.product_id > mayo_products.id
Ref: mayo_product_parts.part_type_id > mayo_part_types.id
Ref: mayo_product_parts.top_color_id > mayo_colors.id
Ref: mayo_product_parts.back_color_id > mayo_colors.id
Ref: mayo_product_parts.top_finish_id > mayo_finishes.id
Ref: mayo_product_parts.back_finish_id > mayo_finishes.id
Ref: mayo_production_events.product_part_id > mayo_product_parts.id
Ref: mayo_production_events.operation_id > mayo_production_operations.id
// Suggested seed values
//
// mayo_neck_constructions:
// - NTB: Neck-through-body
// - BOLT_ON: Bolt-on
// - SET_IN: Set-in
//
// mayo_part_types:
// - BODY: Body
// - NECK: Neck
//
// mayo_finishes:
// - GLOSS: Gloss
// - SATIN: Satin
// - MAT: Mat
// - NITRO: Nitro