ApiLogicServer 15.0.14__py3-none-any.whl → 15.0.19__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- api_logic_server_cli/api_logic_server.py +2 -2
- api_logic_server_cli/api_logic_server_info.yaml +2 -2
- api_logic_server_cli/cli.py +44 -1
- api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/api_logic_server_utils.py +14 -0
- api_logic_server_cli/genai/genai_admin_app copy.py +150 -0
- api_logic_server_cli/genai/genai_admin_app.py +155 -0
- api_logic_server_cli/genai/genai_svcs.py +49 -10
- api_logic_server_cli/logging.yml +5 -0
- api_logic_server_cli/prototypes/base/config/config.py +4 -3
- api_logic_server_cli/prototypes/base/docs/training/admin_app_1_context.prompt.md +3 -0
- api_logic_server_cli/prototypes/base/docs/training/admin_app_2_functionality.prompt.md +69 -0
- api_logic_server_cli/prototypes/base/docs/training/admin_app_3_architecture.prompt.md +29 -0
- api_logic_server_cli/prototypes/base/docs/training/admin_app_unused.md +156 -0
- api_logic_server_cli/prototypes/base/integration/mcp/mcp_client_executor.py +15 -12
- api_logic_server_cli/prototypes/basic_demo/customizations/docs/mcp_learning/mcp_discovery.json +108 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/app_learning/Admin-App-Learning-Prompt.md +154 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/app_learning/notes.md +7 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/.DS_Store +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/README.md +17 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/README_create_react_app.md +70 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/package-lock.json +18469 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/package.json +44 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/public/favicon.ico +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/public/index.html +43 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/public/logo192.png +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/public/logo512.png +0 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/public/manifest.json +25 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/public/robots.txt +3 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/App.css +38 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/App.js +25 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/App.test.js +8 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/dataProvider.js +110 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/index.css +13 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/index.js +17 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/logo.svg +1 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/reportWebVitals.js +13 -0
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/src/setupTests.js +5 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/.DS_Store +0 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/README.md +19 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/README_create_react_app.md +70 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/package-lock.json +18469 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/package.json +44 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/public/favicon.ico +0 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/public/index.html +43 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/public/logo192.png +0 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/public/logo512.png +0 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/public/manifest.json +25 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/public/robots.txt +3 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/App.css +38 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/App.js +59 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/App.test.js +8 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Category.js +82 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Customer.js +116 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/CustomerDemographic.js +74 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Department.js +99 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Employee.js +149 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/EmployeeAudit.js +94 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/EmployeeTerritory.js +98 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Location.js +91 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Order.js +116 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/OrderDetail.js +121 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Product.js +105 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Region.js +70 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Shipper.js +64 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Supplier.js +103 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Territory.js +84 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/Union.js +77 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/dataProvider.js +110 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/index.css +13 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/index.js +17 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/logo.svg +1 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/reportWebVitals.js +13 -0
- api_logic_server_cli/prototypes/nw/ui/react_admin/src/setupTests.js +5 -0
- {apilogicserver-15.0.14.dist-info → apilogicserver-15.0.19.dist-info}/METADATA +1 -1
- {apilogicserver-15.0.14.dist-info → apilogicserver-15.0.19.dist-info}/RECORD +80 -15
- {apilogicserver-15.0.14.dist-info → apilogicserver-15.0.19.dist-info}/WHEEL +0 -0
- {apilogicserver-15.0.14.dist-info → apilogicserver-15.0.19.dist-info}/entry_points.txt +0 -0
- {apilogicserver-15.0.14.dist-info → apilogicserver-15.0.19.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-15.0.14.dist-info → apilogicserver-15.0.19.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
|
|
2
|
+
Generate a full React Admin application using the following instructions.
|
|
3
|
+
The result must be a runnable React app (`npm start`) that connects to the supplied JSON:API, with fully implemented components (no placeholders or empty files).
|
|
4
|
+
|
|
5
|
+
## Backend Description
|
|
6
|
+
|
|
7
|
+
The JSON:API backend is described by:
|
|
8
|
+
|
|
9
|
+
### 1. Schema (`docs/db.dbml`):
|
|
10
|
+
|
|
11
|
+
```dbml
|
|
12
|
+
Table Customer {
|
|
13
|
+
id INTEGER [primary key]
|
|
14
|
+
name VARCHAR
|
|
15
|
+
balance DECIMAL
|
|
16
|
+
credit_limit DECIMAL
|
|
17
|
+
email VARCHAR
|
|
18
|
+
email_opt_out BOOLEAN
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Table Item {
|
|
22
|
+
id INTEGER [primary key]
|
|
23
|
+
order_id INTEGER
|
|
24
|
+
product_id INTEGER
|
|
25
|
+
quantity INTEGER
|
|
26
|
+
amount DECIMAL
|
|
27
|
+
unit_price DECIMAL
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
Table Order {
|
|
31
|
+
id INTEGER [primary key]
|
|
32
|
+
notes VARCHAR
|
|
33
|
+
customer_id INTEGER
|
|
34
|
+
CreatedOn DATE
|
|
35
|
+
date_shipped DATE
|
|
36
|
+
amount_total DECIMAL
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
Table Product {
|
|
40
|
+
id INTEGER [primary key]
|
|
41
|
+
name VARCHAR
|
|
42
|
+
unit_price DECIMAL
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Relationships
|
|
46
|
+
Ref: Item.(order_id) < Order.(id)
|
|
47
|
+
Ref: Item.(product_id) < Product.(id)
|
|
48
|
+
Ref: Order.(customer_id) < Customer.(id)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. JSON:API Discovery (`docs/mcp_learning/mcp_discovery.json`):
|
|
52
|
+
|
|
53
|
+
- Base URL: `http://localhost:5656/api`
|
|
54
|
+
- Auth: `http://localhost:5656/api/auth/login`
|
|
55
|
+
- Tool type: `json-api`
|
|
56
|
+
- Describes four resources: Customer, Order, Item, Product
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## App Features
|
|
61
|
+
|
|
62
|
+
### Multi-Page
|
|
63
|
+
|
|
64
|
+
For each resource:
|
|
65
|
+
- Create a **List page** showing 7 user-friendly columns
|
|
66
|
+
- Add **pagination**, **sorting**, and **filtering**
|
|
67
|
+
- Link each row to a **Display (Show) page**
|
|
68
|
+
|
|
69
|
+
### Multi-Resource
|
|
70
|
+
|
|
71
|
+
Each **Display Page** should:
|
|
72
|
+
- Show all fields in a **multi-column layout**
|
|
73
|
+
- Include a **tab sheet** (`<TabbedShowLayout>`) for each related resource using `<ReferenceManyField>`
|
|
74
|
+
- Link child rows to their own display page
|
|
75
|
+
|
|
76
|
+
Example:
|
|
77
|
+
- Customer Display has tab for OrderList
|
|
78
|
+
- Each Order in the tab links to Order Display
|
|
79
|
+
|
|
80
|
+
### Automatic Joins
|
|
81
|
+
|
|
82
|
+
For foreign keys:
|
|
83
|
+
- Display joined value (e.g., `product.name` instead of `product_id`)
|
|
84
|
+
- Use first string field from parent table containing `name`, `title`, or `description`
|
|
85
|
+
|
|
86
|
+
Primary key fields:
|
|
87
|
+
- Display at the end of forms/lists
|
|
88
|
+
|
|
89
|
+
### Lookups (Foreign Keys)
|
|
90
|
+
|
|
91
|
+
For foreign key fields:
|
|
92
|
+
- Provide auto-complete dropdown (`<ReferenceInput>`)
|
|
93
|
+
- For numeric foreign keys, use the joined string field as lookup text
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Per-Resource Files (Required)
|
|
98
|
+
|
|
99
|
+
For each resource (`Customer`, `Order`, `Product`, `Item`):
|
|
100
|
+
- Create a source file under `src/`, e.g., `Customer.js`
|
|
101
|
+
- **Each file must fully implement**:
|
|
102
|
+
- `CustomerList`
|
|
103
|
+
- `CustomerShow`
|
|
104
|
+
- `CustomerCreate`
|
|
105
|
+
- `CustomerEdit`
|
|
106
|
+
|
|
107
|
+
Use:
|
|
108
|
+
- `<ReferenceField>` for foreign key displays
|
|
109
|
+
- `<ReferenceInput>` for foreign key input
|
|
110
|
+
- `<ReferenceManyField>` for tabbed child lists
|
|
111
|
+
- `<TabbedShowLayout>` for display pages
|
|
112
|
+
|
|
113
|
+
Do **not leave any file empty**.
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## App Wiring
|
|
118
|
+
|
|
119
|
+
In `App.js`:
|
|
120
|
+
- Import each resource file
|
|
121
|
+
- Register them in `<Admin>` using:
|
|
122
|
+
|
|
123
|
+
```jsx
|
|
124
|
+
<Resource name="Customer" list={CustomerList} show={CustomerShow} edit={CustomerEdit} create={CustomerCreate} />
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Architecture
|
|
130
|
+
|
|
131
|
+
- **Framework**: React 18 + react-admin 4.x
|
|
132
|
+
- **Data Provider**: Custom `dataProvider.js` using `fetchUtils` (no external `ra-jsonapi-client`)
|
|
133
|
+
- Must support: `getList`, `getOne`, `getMany`, `getManyReference`, `create`, `update`, `delete`
|
|
134
|
+
- Must support: filters, joins, sorting, pagination
|
|
135
|
+
- **Backend**: JSON:API per `mcp_discovery.json`
|
|
136
|
+
- **CORS**: Ensure API allows `http://localhost:3000`
|
|
137
|
+
```py
|
|
138
|
+
from flask_cors import CORS
|
|
139
|
+
CORS(app, origins='*') # or restrict to localhost:3000
|
|
140
|
+
```
|
|
141
|
+
- **Project Setup**:
|
|
142
|
+
- Use `create-react-app`
|
|
143
|
+
- Include: `react-admin`, `@mui/material`, `@emotion/react`, `@emotion/styled`, `react-router-dom`
|
|
144
|
+
- Do not use any deprecated or unmaintained libraries
|
|
145
|
+
- Include complete and correct `App.js`, `index.js`, `dataProvider.js`, and `index.html`
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Run Instructions
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npm install
|
|
153
|
+
npm start
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Then open in browser: `http://localhost:3000`
|
|
@@ -20,7 +20,7 @@ See: https://apilogicserver.github.io/Docs/Integration-MCP/
|
|
|
20
20
|
# debug settings
|
|
21
21
|
################
|
|
22
22
|
|
|
23
|
-
create_tool_context_from_llm =
|
|
23
|
+
create_tool_context_from_llm = False
|
|
24
24
|
''' set to False to bypass LLM call and save 2-3 secs in testing, no API Key required. '''
|
|
25
25
|
|
|
26
26
|
import os, logging, logging.config, sys
|
|
@@ -351,17 +351,18 @@ def process_tool_context(tool_context):
|
|
|
351
351
|
body = step.get("body", [])
|
|
352
352
|
# iterate the body fields / values
|
|
353
353
|
# This loop checks each field in the body for a fan-out pattern
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
354
|
+
if body is not None:
|
|
355
|
+
for attr_name, attr_value in body.items():
|
|
356
|
+
if isinstance(attr_value, str) and "[*]" in attr_value:
|
|
357
|
+
match = re.match(r"\$(\d+)\[\*\]\.(\w+)", attr_value)
|
|
358
|
+
if match:
|
|
359
|
+
return int(match.group(1)), match.group(2)
|
|
360
|
+
# If the body is a list, iterate through each field
|
|
361
|
+
for field in body:
|
|
362
|
+
if isinstance(field["value"], str) and "[*]" in field["value"]: # string indices must be integers, not 'str'
|
|
363
|
+
match = re.match(r"\$(\d+)\[\*\]\.(\w+)", field["value"])
|
|
364
|
+
if match:
|
|
365
|
+
return int(match.group(1)), match.group(2)
|
|
365
366
|
return None
|
|
366
367
|
|
|
367
368
|
|
|
@@ -468,7 +469,9 @@ def mcp_client_executor(query: str):
|
|
|
468
469
|
#als: create an MCP request. See https://apilogicserver.github.io/Docs/Integration-MCP/
|
|
469
470
|
|
|
470
471
|
Test:
|
|
472
|
+
* als add-auth --provider-type=None
|
|
471
473
|
* curl -X 'POST' 'http://localhost:5656/api/SysMcp/' -H 'accept: application/vnd.api+json' -H 'Content-Type: application/json' -d '{ "data": { "attributes": {"request": "List the orders date_shipped is null and CreatedOn before 2023-07-14, and send a discount email (subject: '\''Discount Offer'\'') to the customer for each one."}, "type": "SysMcp"}}'
|
|
474
|
+
|
|
472
475
|
* Or, use the Admin App and insert a row into SysMCP (see default `query`, below)
|
|
473
476
|
|
|
474
477
|
Args:
|
api_logic_server_cli/prototypes/basic_demo/customizations/docs/mcp_learning/mcp_discovery.json
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"base_url": "http://localhost:5656/api",
|
|
3
|
+
"authorization_url": "http://localhost:5656/api/auth/login",
|
|
4
|
+
"description": "API Logic Project: basic_demo",
|
|
5
|
+
"learning": "To issue one request per row from a prior step (fan-out), use the syntax:\n\n\"$<stepIndex>[*].<fieldName>\"\n\nFor example, if step 0 returns orders, and you want to send a POST per customer:\n\nBefore (incorrect):\n \"customer_id\": \"{customer_id}\"\n\nAfter (correct):\n \"customer_id\": \"$0[*].customer_id\"\n \nOnly if 'email' is in the Natural language query, send email by issing a POST request to the SysEmail endpoint, setting the subject, message and customer_id in the body. DO NOT include a POST unless the word \u2018email\u2019 appears in the user query.\n\nFormat response as mcp_responseFormat.\n\n<mcp_responseFormat>\nclass QueryParam(BaseModel):\n name: str # attribute name\n op: str # eq, lt, gt\n val: str\n\nclass JsonValues(BaseMopdel):\n name: str # name of attribute\n value: str # value of attribute\n\nclass Resource(BaseModel):\n tool_type: str\n base_url: str\n path: str # specified use case or requirement name (use 'General' if missing)\n method: str # GET, PATCH, POST or DELETE\n body: json # data for PATCH or POST\n query_params: List(QueryParam) # filter for GET\n\nclass MCPResult(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt\n schema_version: str\n resources : List[Resource] # list resources\n\n<mcp_responseFormat/>\n",
|
|
6
|
+
"resources": [
|
|
7
|
+
{
|
|
8
|
+
"fields": [
|
|
9
|
+
"id",
|
|
10
|
+
"name",
|
|
11
|
+
"balance",
|
|
12
|
+
"credit_limit",
|
|
13
|
+
"email",
|
|
14
|
+
"email_opt_out"
|
|
15
|
+
],
|
|
16
|
+
"filterable": [
|
|
17
|
+
"id",
|
|
18
|
+
"name",
|
|
19
|
+
"balance",
|
|
20
|
+
"credit_limit",
|
|
21
|
+
"email",
|
|
22
|
+
"email_opt_out"
|
|
23
|
+
],
|
|
24
|
+
"methods": [
|
|
25
|
+
"GET",
|
|
26
|
+
"PATCH",
|
|
27
|
+
"POST",
|
|
28
|
+
"DELETE"
|
|
29
|
+
],
|
|
30
|
+
"name": "Customer",
|
|
31
|
+
"path": "/Customer"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"fields": [
|
|
35
|
+
"id",
|
|
36
|
+
"order_id",
|
|
37
|
+
"product_id",
|
|
38
|
+
"quantity",
|
|
39
|
+
"amount",
|
|
40
|
+
"unit_price"
|
|
41
|
+
],
|
|
42
|
+
"filterable": [
|
|
43
|
+
"id",
|
|
44
|
+
"order_id",
|
|
45
|
+
"product_id",
|
|
46
|
+
"quantity",
|
|
47
|
+
"amount",
|
|
48
|
+
"unit_price"
|
|
49
|
+
],
|
|
50
|
+
"methods": [
|
|
51
|
+
"GET",
|
|
52
|
+
"PATCH",
|
|
53
|
+
"POST",
|
|
54
|
+
"DELETE"
|
|
55
|
+
],
|
|
56
|
+
"name": "Item",
|
|
57
|
+
"path": "/Item"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"fields": [
|
|
61
|
+
"id",
|
|
62
|
+
"notes",
|
|
63
|
+
"customer_id",
|
|
64
|
+
"CreatedOn",
|
|
65
|
+
"date_shipped",
|
|
66
|
+
"amount_total"
|
|
67
|
+
],
|
|
68
|
+
"filterable": [
|
|
69
|
+
"id",
|
|
70
|
+
"notes",
|
|
71
|
+
"customer_id",
|
|
72
|
+
"CreatedOn",
|
|
73
|
+
"date_shipped",
|
|
74
|
+
"amount_total"
|
|
75
|
+
],
|
|
76
|
+
"methods": [
|
|
77
|
+
"GET",
|
|
78
|
+
"PATCH",
|
|
79
|
+
"POST",
|
|
80
|
+
"DELETE"
|
|
81
|
+
],
|
|
82
|
+
"name": "Order",
|
|
83
|
+
"path": "/Order"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"fields": [
|
|
87
|
+
"id",
|
|
88
|
+
"name",
|
|
89
|
+
"unit_price"
|
|
90
|
+
],
|
|
91
|
+
"filterable": [
|
|
92
|
+
"id",
|
|
93
|
+
"name",
|
|
94
|
+
"unit_price"
|
|
95
|
+
],
|
|
96
|
+
"methods": [
|
|
97
|
+
"GET",
|
|
98
|
+
"PATCH",
|
|
99
|
+
"POST",
|
|
100
|
+
"DELETE"
|
|
101
|
+
],
|
|
102
|
+
"name": "Product",
|
|
103
|
+
"path": "/Product"
|
|
104
|
+
}
|
|
105
|
+
],
|
|
106
|
+
"schema_version": "1.0",
|
|
107
|
+
"tool_type": "json-api"
|
|
108
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
## Context
|
|
2
|
+
|
|
3
|
+
Generate a full React Admin application using the following instructions.
|
|
4
|
+
The result must be a runnable React app (`npm start`) that connects to the supplied JSON:API, with fully implemented components (no placeholders or empty files).
|
|
5
|
+
|
|
6
|
+
## App Features
|
|
7
|
+
|
|
8
|
+
### Multi-Page
|
|
9
|
+
|
|
10
|
+
For each resource:
|
|
11
|
+
- Create a **List page** showing 7 user-friendly columns
|
|
12
|
+
- Add **pagination**, **sorting**, and **filtering**
|
|
13
|
+
- Link each row to a **Display (Show) page**
|
|
14
|
+
|
|
15
|
+
### Multi-Resource
|
|
16
|
+
|
|
17
|
+
Each **Display Page** should:
|
|
18
|
+
- Show all fields in a **multi-column layout**
|
|
19
|
+
- Include a **tab sheet** (`<TabbedShowLayout>`) for each related resource using `<ReferenceManyField>`
|
|
20
|
+
- Link child rows to their own display page
|
|
21
|
+
|
|
22
|
+
Example:
|
|
23
|
+
- Customer Display has tab for OrderList
|
|
24
|
+
- The tab (with OrderList) is shown *below* all the Customer fields.
|
|
25
|
+
- Each Order in the tab links to Order Display
|
|
26
|
+
|
|
27
|
+
### Automatic Joins
|
|
28
|
+
|
|
29
|
+
For foreign keys:
|
|
30
|
+
- Display joined value (e.g., `product.name` instead of `product_id`)
|
|
31
|
+
- Use first string field from parent table containing `name`, `title`, or `description`
|
|
32
|
+
|
|
33
|
+
Numeric Primary key fields:
|
|
34
|
+
- Display at the end of forms/lists
|
|
35
|
+
|
|
36
|
+
### Lookups (Foreign Keys)
|
|
37
|
+
|
|
38
|
+
For foreign key fields:
|
|
39
|
+
- Provide auto-complete dropdown (`<ReferenceInput>`)
|
|
40
|
+
- For numeric foreign keys, use the joined string field as lookup text
|
|
41
|
+
|
|
42
|
+
### Cascade Add
|
|
43
|
+
|
|
44
|
+
When adding a child row as a detail in a Master / Detail,
|
|
45
|
+
default the Foreign Key to the Parent (Master) Primary Key.
|
|
46
|
+
|
|
47
|
+
## Implementation
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
### Architecture
|
|
51
|
+
|
|
52
|
+
- **Framework**: React 18 + react-admin 4.x
|
|
53
|
+
- **Data Provider**: Custom `dataProvider.js` using `fetchUtils` (no external `ra-jsonapi-client`)
|
|
54
|
+
- Must support: `getList`, `getOne`, `getMany`, `getManyReference`, `create`, `update`, `delete`
|
|
55
|
+
- Must support: filters, joins, sorting, pagination
|
|
56
|
+
- **Backend**: JSON:API per `mcp_discovery.json`
|
|
57
|
+
- **CORS**: Ensure API allows `http://localhost:3000`
|
|
58
|
+
```py
|
|
59
|
+
from flask_cors import CORS
|
|
60
|
+
CORS(app, origins='*') # or restrict to localhost:3000
|
|
61
|
+
```
|
|
62
|
+
- **Project Setup**:
|
|
63
|
+
- Use `create-react-app`
|
|
64
|
+
- Include: `react-admin`, `@mui/material`, `@emotion/react`, `@emotion/styled`, `react-router-dom`
|
|
65
|
+
- Do not use any deprecated or unmaintained libraries
|
|
66
|
+
- Include complete and correct `App.js`, `index.js`, `dataProvider.js`, and `index.html`
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
### Per-Resource Files (Required)
|
|
71
|
+
|
|
72
|
+
For each resource (`Customer`, `Order` etc):
|
|
73
|
+
- Create a source file under `src/`, e.g., `Customer.js`
|
|
74
|
+
- **Each file must fully implement**:
|
|
75
|
+
- `CustomerList`
|
|
76
|
+
- `CustomerShow`
|
|
77
|
+
- `CustomerCreate`
|
|
78
|
+
- `CustomerEdit`
|
|
79
|
+
|
|
80
|
+
Use:
|
|
81
|
+
- `<ReferenceField>` for foreign key displays
|
|
82
|
+
- `<ReferenceInput>` for foreign key input
|
|
83
|
+
- `<ReferenceManyField>` for tabbed child lists
|
|
84
|
+
- For show pages
|
|
85
|
+
- Always start with <SimpleShowLayout>, followed by a <TabbedShowLayout> for related data
|
|
86
|
+
- DO NOT start with <TabbedShowLayout>
|
|
87
|
+
|
|
88
|
+
Be sure to include all required imports. ALWAYS use the following AS IS, plus whatever else is required:
|
|
89
|
+
|
|
90
|
+
```jsx
|
|
91
|
+
import { List, FunctionField, Datagrid, TextField, DateField, NumberField, ReferenceField, ReferenceManyField, Show, TabbedShowLayout, Tab, SimpleShowLayout, TextInput, NumberInput, DateTimeInput, ReferenceInput, SelectInput, Create, SimpleForm, Edit, Filter, Pagination, BooleanField, BooleanInput } from 'react-admin';
|
|
92
|
+
```
|
|
93
|
+
You may add other imports, but be sure all those are included.
|
|
94
|
+
|
|
95
|
+
DO NOT use <EmailInput> - use <TextInput>.
|
|
96
|
+
|
|
97
|
+
DO NOT put <ReferenceField> in <Datagrid>.
|
|
98
|
+
|
|
99
|
+
Do **not leave any file empty**.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
### App Wiring
|
|
104
|
+
|
|
105
|
+
Sample code for `App.js`:
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
```jsx
|
|
109
|
+
import React from 'react';
|
|
110
|
+
import { Admin, Resource } from 'react-admin';
|
|
111
|
+
import { createTheme } from '@mui/material/styles';
|
|
112
|
+
|
|
113
|
+
// import each resource
|
|
114
|
+
import { CustomerList, CustomerShow, CustomerCreate, CustomerEdit } from './Customer';
|
|
115
|
+
...
|
|
116
|
+
// import the data provider
|
|
117
|
+
import { dataProvider } from './dataProvider';
|
|
118
|
+
|
|
119
|
+
const theme = createTheme({
|
|
120
|
+
palette: {
|
|
121
|
+
primary: { main: '#1976d2' }, // Material-UI default blue
|
|
122
|
+
secondary: { main: '#1565c0' }, // A darker blue, or choose another color
|
|
123
|
+
},
|
|
124
|
+
typography: { fontSize: 14 },
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
const App = () => {
|
|
128
|
+
return (
|
|
129
|
+
<Admin dataProvider={dataProvider}> // register each resource...
|
|
130
|
+
<Resource name="Customer" list={CustomerList} show={CustomerShow} edit={CustomerEdit} create={CustomerCreate} />
|
|
131
|
+
...
|
|
132
|
+
</Admin>
|
|
133
|
+
);
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
export default App;
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
For dataProvider:
|
|
140
|
+
1 - be sure it includes the braces: import { dataProvider }
|
|
141
|
+
2 - Do Not generate either:
|
|
142
|
+
```jsx
|
|
143
|
+
import jsonServerProvider from 'ra-data-json-server'
|
|
144
|
+
const dataProvider = jsonServerProvider('http://api.example.com');
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## Response Format
|
|
150
|
+
|
|
151
|
+
Format the response as a JSResponseFormat:
|
|
152
|
+
|
|
153
|
+
class JSResponseFormat(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
154
|
+
code : str # generated javascript code (only)
|
api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/.DS_Store
ADDED
|
Binary file
|
api_logic_server_cli/prototypes/manager/system/genai/app_templates/react-admin-template/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Getting Started with Genai-Logic react-admin
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). For more information, see [README_create_react_app](README_create_react_app.md).
|
|
4
|
+
|
|
5
|
+
GenAI-Logic (`als genai-app`) then [created this project](https://apilogicserver.github.io/Docs/Admin-Vibe/).
|
|
6
|
+
|
|
7
|
+
<br>
|
|
8
|
+
|
|
9
|
+
# To run the app:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
cd ui/react-admin
|
|
13
|
+
npm install
|
|
14
|
+
npm start
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Open your browser at [http://localhost:3000](http://localhost:3000).
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Getting Started with Create React App
|
|
2
|
+
|
|
3
|
+
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
|
|
4
|
+
|
|
5
|
+
## Available Scripts
|
|
6
|
+
|
|
7
|
+
In the project directory, you can run:
|
|
8
|
+
|
|
9
|
+
### `npm start`
|
|
10
|
+
|
|
11
|
+
Runs the app in the development mode.\
|
|
12
|
+
Open [http://localhost:3000](http://localhost:3000) to view it in your browser.
|
|
13
|
+
|
|
14
|
+
The page will reload when you make changes.\
|
|
15
|
+
You may also see any lint errors in the console.
|
|
16
|
+
|
|
17
|
+
### `npm test`
|
|
18
|
+
|
|
19
|
+
Launches the test runner in the interactive watch mode.\
|
|
20
|
+
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
|
|
21
|
+
|
|
22
|
+
### `npm run build`
|
|
23
|
+
|
|
24
|
+
Builds the app for production to the `build` folder.\
|
|
25
|
+
It correctly bundles React in production mode and optimizes the build for the best performance.
|
|
26
|
+
|
|
27
|
+
The build is minified and the filenames include the hashes.\
|
|
28
|
+
Your app is ready to be deployed!
|
|
29
|
+
|
|
30
|
+
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
|
|
31
|
+
|
|
32
|
+
### `npm run eject`
|
|
33
|
+
|
|
34
|
+
**Note: this is a one-way operation. Once you `eject`, you can't go back!**
|
|
35
|
+
|
|
36
|
+
If you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
|
|
37
|
+
|
|
38
|
+
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
|
|
39
|
+
|
|
40
|
+
You don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
|
|
41
|
+
|
|
42
|
+
## Learn More
|
|
43
|
+
|
|
44
|
+
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
|
|
45
|
+
|
|
46
|
+
To learn React, check out the [React documentation](https://reactjs.org/).
|
|
47
|
+
|
|
48
|
+
### Code Splitting
|
|
49
|
+
|
|
50
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)
|
|
51
|
+
|
|
52
|
+
### Analyzing the Bundle Size
|
|
53
|
+
|
|
54
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)
|
|
55
|
+
|
|
56
|
+
### Making a Progressive Web App
|
|
57
|
+
|
|
58
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)
|
|
59
|
+
|
|
60
|
+
### Advanced Configuration
|
|
61
|
+
|
|
62
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)
|
|
63
|
+
|
|
64
|
+
### Deployment
|
|
65
|
+
|
|
66
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)
|
|
67
|
+
|
|
68
|
+
### `npm run build` fails to minify
|
|
69
|
+
|
|
70
|
+
This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
|