ApiLogicServer 15.0.28__py3-none-any.whl → 15.0.33__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/add_cust/add_cust.py +4 -4
- api_logic_server_cli/api_logic_server.py +20 -5
- api_logic_server_cli/api_logic_server_info.yaml +3 -3
- api_logic_server_cli/cli.py +61 -10
- api_logic_server_cli/cli_args_base.py +1 -1
- api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/ont_create.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/dbml.py +1 -1
- api_logic_server_cli/create_from_model/ont_create.py +6 -1
- api_logic_server_cli/database/mcp.sqlite +0 -0
- api_logic_server_cli/fragments/mcp_admin.yml +11 -0
- api_logic_server_cli/genai/genai_admin_app.py +67 -19
- api_logic_server_cli/genai/genai_mcp.py +43 -0
- api_logic_server_cli/genai/genai_svcs.py +13 -12
- api_logic_server_cli/manager.py +29 -2
- api_logic_server_cli/prototypes/base/config/default.env +3 -0
- api_logic_server_cli/prototypes/base/devops/docker-compose-dev-azure/azure-deploy.sh +3 -3
- api_logic_server_cli/prototypes/base/devops/docker-compose-dev-local/docker-compose.sh +1 -1
- api_logic_server_cli/prototypes/base/ui/admin/admin_loader.py +2 -0
- api_logic_server_cli/prototypes/basic_demo/README.md +1 -1
- api_logic_server_cli/prototypes/basic_demo/customizations/database/db.sqlite +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/database/models.py +0 -16
- api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +0 -11
- api_logic_server_cli/prototypes/basic_demo/iteration/database/db.sqlite +0 -0
- api_logic_server_cli/prototypes/basic_demo/iteration/ui/admin/admin.yaml +4 -4
- api_logic_server_cli/prototypes/manager/README.md +1 -1
- api_logic_server_cli/prototypes/manager/samples/dbs/readme_samples.md +5 -0
- api_logic_server_cli/prototypes/manager/samples/readme_samples.md +3 -0
- api_logic_server_cli/prototypes/manager/system/app_model_editor/devops/docker-compose-dev-azure/azure-deploy.sh +1 -1
- api_logic_server_cli/prototypes/manager/system/app_model_editor/devops/docker-compose-dev-local-nginx/docker-compose.sh +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_docs_logic/devops/docker-compose-dev-azure/azure-deploy.sh +1 -1
- api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_docs_logic/devops/docker-compose-dev-local/docker-compose.sh +1 -1
- api_logic_server_cli/prototypes/nw_no_cust/Tutorial.md +2 -2
- api_logic_server_cli/prototypes/sqlite/devops/docker-compose-dev-azure/azure-deploy.sh +1 -1
- api_logic_server_cli/{prototypes/basic_demo/customizations/logic/logic_discovery → templates}/mcp_client_executor_request.py +4 -2
- {apilogicserver-15.0.28.dist-info → apilogicserver-15.0.33.dist-info}/METADATA +1 -1
- {apilogicserver-15.0.28.dist-info → apilogicserver-15.0.33.dist-info}/RECORD +41 -40
- apilogicserver-15.0.33.dist-info/entry_points.txt +7 -0
- api_logic_server_cli/genai/genai_admin_app copy.py +0 -150
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/app_learning/Admin-App-Resource-Learning-Prompt copy.md +0 -203
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/app_learning/notes.md +0 -7
- api_logic_server_cli/prototypes/manager/system/genai/app_templates/app_learning/z-unused-Admin-App-Learning-Prompt.md +0 -179
- apilogicserver-15.0.28.dist-info/entry_points.txt +0 -3
- {apilogicserver-15.0.28.dist-info → apilogicserver-15.0.33.dist-info}/WHEEL +0 -0
- {apilogicserver-15.0.28.dist-info → apilogicserver-15.0.33.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-15.0.28.dist-info → apilogicserver-15.0.33.dist-info}/top_level.txt +0 -0
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import shutil
|
|
2
|
-
from typing import Dict, List
|
|
3
|
-
from api_logic_server_cli.cli_args_project import Project
|
|
4
|
-
import logging
|
|
5
|
-
from pathlib import Path
|
|
6
|
-
import importlib
|
|
7
|
-
from api_logic_server_cli.genai.genai_utils import call_chatgpt
|
|
8
|
-
import requests
|
|
9
|
-
import os, time
|
|
10
|
-
import datetime
|
|
11
|
-
import create_from_model.api_logic_server_utils as utils
|
|
12
|
-
import time
|
|
13
|
-
from openai import OpenAI
|
|
14
|
-
from api_logic_server_cli.genai.genai_svcs import WGResult
|
|
15
|
-
from api_logic_server_cli.genai.genai_svcs import Rule
|
|
16
|
-
import api_logic_server_cli.genai.genai_svcs as genai_svcs
|
|
17
|
-
import json
|
|
18
|
-
from typing import List, Dict
|
|
19
|
-
from pydantic import BaseModel
|
|
20
|
-
from dotmap import DotMap
|
|
21
|
-
from natsort import natsorted
|
|
22
|
-
import glob
|
|
23
|
-
import create_from_model.api_logic_server_utils as create_utils
|
|
24
|
-
from jinja2 import Environment, FileSystemLoader
|
|
25
|
-
import os
|
|
26
|
-
import json
|
|
27
|
-
from pathlib import Path
|
|
28
|
-
from openai import OpenAI
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
K_data_model_prompt = "Use SQLAlchemy to create"
|
|
32
|
-
|
|
33
|
-
log = logging.getLogger(__name__)
|
|
34
|
-
|
|
35
|
-
class GenAIAdminApp:
|
|
36
|
-
""" 6/13/2025
|
|
37
|
-
Creates ui/admin_app_react.zip, a source version of ui/admin/admin.yaml.
|
|
38
|
-
|
|
39
|
-
Users without JS/HTML background can use Nat Lang to customize ("Vibe for dummies").
|
|
40
|
-
|
|
41
|
-
Called by CLI for existing projects.
|
|
42
|
-
|
|
43
|
-
* The constructor project arg provides project.project_directory_path, to provide meta data to ChatGPT:
|
|
44
|
-
* docs/db.dbml describes the schema
|
|
45
|
-
* docs/mcp_learning/mcp_discovery.json describes the JSON:API
|
|
46
|
-
* docs/training/admin_app.md describes the app functionality and architecture
|
|
47
|
-
|
|
48
|
-
* Basic steps
|
|
49
|
-
* Step 1 – Parse Schema
|
|
50
|
-
* Step 2 – Generate <each_resource.js> (per schema)
|
|
51
|
-
* Step 3 – Generate `App.js`
|
|
52
|
-
* Step 4 – Custom dataProvider.js
|
|
53
|
-
* provide alternative for React Admin's default data provider for REST APIs,
|
|
54
|
-
* believe that is: 'ra-data-simple-rest'
|
|
55
|
-
|
|
56
|
-
Testing:
|
|
57
|
-
* BLT to create manager
|
|
58
|
-
* Use basic_demo
|
|
59
|
-
|
|
60
|
-
"""
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
def __init__(self, project: Project, genai_version: OpenAI):
|
|
64
|
-
self.project = project
|
|
65
|
-
self.schema_path = project.project_directory_path / "docs/db.dbml"
|
|
66
|
-
self.discovery_path = project.project_directory_path / "docs/mcp_learning/mcp_discovery.json"
|
|
67
|
-
self.genai_version = genai_version
|
|
68
|
-
|
|
69
|
-
self.manager_path = genai_svcs.get_manager_path()
|
|
70
|
-
|
|
71
|
-
self.start_time = time.time()
|
|
72
|
-
self.prompt = self.compose_prompt()
|
|
73
|
-
self.response = self.get_response(self.prompt)
|
|
74
|
-
self.content = self.response.choices[0].message.content
|
|
75
|
-
self.write_output(self.content)
|
|
76
|
-
return self.content
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def compose_prompt(self) -> str:
|
|
81
|
-
|
|
82
|
-
def load_prompt_parts(self):
|
|
83
|
-
"""
|
|
84
|
-
Step 2: load context, functionality, and architecture prompt sections
|
|
85
|
-
"""
|
|
86
|
-
context = (self.project_path / "docs/prompts/context.md").read_text()
|
|
87
|
-
functionality = (self.project_path / "docs/prompts/functionality.md").read_text()
|
|
88
|
-
architecture = (self.project_path / "docs/prompts/architecture.md").read_text()
|
|
89
|
-
return context, functionality, architecture
|
|
90
|
-
|
|
91
|
-
def load_schema(self) -> str:
|
|
92
|
-
return self.schema_path.read_text()
|
|
93
|
-
|
|
94
|
-
def load_discovery(self) -> str:
|
|
95
|
-
return json.dumps(json.loads(self.discovery_path.read_text()), indent=4)
|
|
96
|
-
|
|
97
|
-
"""
|
|
98
|
-
Step 3: compose the prompt by combining static prompt parts with schema and discovery
|
|
99
|
-
"""
|
|
100
|
-
context, functionality, architecture = self.load_prompt_parts()
|
|
101
|
-
schema = self.load_schema()
|
|
102
|
-
discovery = self.load_discovery()
|
|
103
|
-
|
|
104
|
-
prompt = f"""
|
|
105
|
-
{context}
|
|
106
|
-
|
|
107
|
-
The JSON:API backend is described by:
|
|
108
|
-
docs/db.dbml describes the schema:
|
|
109
|
-
|
|
110
|
-
```dbml
|
|
111
|
-
{schema}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
docs/mcp_learning/mcp_discovery.json describes the JSON:API:
|
|
115
|
-
|
|
116
|
-
```json
|
|
117
|
-
{discovery}
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
{functionality}
|
|
121
|
-
|
|
122
|
-
{architecture}
|
|
123
|
-
"""
|
|
124
|
-
return prompt
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
def get_response(self):
|
|
128
|
-
"""
|
|
129
|
-
Step 4: issue the prompt to the LLM to get generated source code
|
|
130
|
-
"""
|
|
131
|
-
response = self.client.chat.completions.create(
|
|
132
|
-
model="gpt-4o",
|
|
133
|
-
messages=[
|
|
134
|
-
{"role": "system", "content": "You are a senior React Admin developer."},
|
|
135
|
-
{"role": "user", "content": self.prompt}
|
|
136
|
-
],
|
|
137
|
-
temperature=0.3
|
|
138
|
-
)
|
|
139
|
-
return response
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def write_output(self, output: str, output_file: str = "admin_app_generated.txt"):
|
|
143
|
-
"""
|
|
144
|
-
Step 5: write generated source code to output file for inspection or extraction
|
|
145
|
-
"""
|
|
146
|
-
output_path = self.project_path / output_file
|
|
147
|
-
output_path.write_text(output)
|
|
148
|
-
print(f"Output written to {output_path}")
|
|
149
|
-
|
|
150
|
-
|
|
@@ -1,203 +0,0 @@
|
|
|
1
|
-
## Context
|
|
2
|
-
|
|
3
|
-
Generate a per-resource file for a 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
|
-
---
|
|
7
|
-
|
|
8
|
-
### Per-Resource Files (Required)
|
|
9
|
-
|
|
10
|
-
For each resource (`Customer`, `Order` etc):
|
|
11
|
-
|
|
12
|
-
* Create a source file under `src/`, e.g., `Customer.js`
|
|
13
|
-
* Each file must **fully** implement:
|
|
14
|
-
* `CustomerList`
|
|
15
|
-
* `CustomerShow`
|
|
16
|
-
* `CustomerCreate`
|
|
17
|
-
* `CustomerEdit`
|
|
18
|
-
|
|
19
|
-
Use:
|
|
20
|
-
|
|
21
|
-
- `<ReferenceField>` for foreign key displays
|
|
22
|
-
- `<ReferenceInput>` for foreign key input
|
|
23
|
-
- `<ReferenceManyField>` for tabbed child lists
|
|
24
|
-
- For show pages
|
|
25
|
-
|
|
26
|
-
* Always start with `<SimpleShowLayout>`, followed by a `<TabbedShowLayout>` for related data
|
|
27
|
-
* DO NOT start with `<TabbedShowLayout>`
|
|
28
|
-
|
|
29
|
-
Use the attribute order from the schema.
|
|
30
|
-
|
|
31
|
-
You may add other imports, but be sure imports below are included.
|
|
32
|
-
|
|
33
|
-
DO NOT use `<EmailInput>` - use `<TextInput>`.
|
|
34
|
-
|
|
35
|
-
DO NOT put `<ReferenceField>` in `<Datagrid>`.
|
|
36
|
-
|
|
37
|
-
Do **not leave any file empty**.
|
|
38
|
-
|
|
39
|
-
Sample code for each resource (follow these guidelines EXACTLY):
|
|
40
|
-
|
|
41
|
-
```jsx
|
|
42
|
-
import React from 'react';
|
|
43
|
-
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, Labeled } from 'react-admin'; // mandatory imports
|
|
44
|
-
|
|
45
|
-
import { Grid, Typography, Box, Divider } from '@mui/material';
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
// Filter for Customer List
|
|
49
|
-
const CustomerFilter = (props) => (
|
|
50
|
-
<Filter {...props}>
|
|
51
|
-
<TextInput label="Search" source="name" alwaysOn />
|
|
52
|
-
<BooleanInput label="Email Opt Out" source="email_opt_out" />
|
|
53
|
-
</Filter>
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
// Customer List
|
|
57
|
-
export const CustomerList = (props) => {
|
|
58
|
-
return (
|
|
59
|
-
<List filters={<CustomerFilter />} {...props} sort={{ field: 'name', order: 'ASC' }} pagination={<Pagination rowsPerPageOptions={[5, 10, 25]} showFirstLastButtons />}>
|
|
60
|
-
<Datagrid rowClick="show">
|
|
61
|
-
<TextField source="name" label="Name" />
|
|
62
|
-
<NumberField source="balance" label="Balance" />
|
|
63
|
-
...
|
|
64
|
-
</Datagrid>
|
|
65
|
-
</List>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
// Customer Show
|
|
71
|
-
export const CustomerShow = (props) => {
|
|
72
|
-
return (
|
|
73
|
-
<Show {...props}>
|
|
74
|
-
<SimpleShowLayout>
|
|
75
|
-
<Box sx={{ mb: 3 }}>
|
|
76
|
-
<Typography variant="h5" component="h2" sx={{ mb: 2, fontWeight: 'bold' }}>
|
|
77
|
-
Customer Information
|
|
78
|
-
</Typography>
|
|
79
|
-
<Grid container spacing={3} sx={{ mb: 2 }}>
|
|
80
|
-
<Grid item xs={12} sm={6} md={3}>
|
|
81
|
-
<Box sx={{ p: 1 }}>
|
|
82
|
-
<Labeled label="Name">
|
|
83
|
-
<TextField source="name" />
|
|
84
|
-
</Labeled>
|
|
85
|
-
</Box>
|
|
86
|
-
</Grid>
|
|
87
|
-
<Grid item xs={12} sm={6} md={3}>
|
|
88
|
-
<Box sx={{ p: 1 }}>
|
|
89
|
-
<Labeled label="Balance">
|
|
90
|
-
<NumberField source="balance" options={{ style: 'currency', currency: 'USD' }} />
|
|
91
|
-
</Labeled>
|
|
92
|
-
</Box>
|
|
93
|
-
</Grid>
|
|
94
|
-
</Grid>
|
|
95
|
-
...
|
|
96
|
-
<Divider sx={{ my: 2 }} />
|
|
97
|
-
</Box>
|
|
98
|
-
</SimpleShowLayout>
|
|
99
|
-
<TabbedShowLayout>
|
|
100
|
-
<Tab label="Orders">
|
|
101
|
-
<ReferenceManyField reference="Order" target="customer_id" addLabel={false} pagination={<Pagination />}>
|
|
102
|
-
<Datagrid rowClick="show">
|
|
103
|
-
<TextField source="id" label="Order ID" />
|
|
104
|
-
<TextField source="notes" label="Notes" />
|
|
105
|
-
<DateField source="CreatedOn" label="Created On" />
|
|
106
|
-
<NumberField source="amount_total" label="Amount Total" options={{ style: 'currency', currency: 'USD' }} />
|
|
107
|
-
<DateField source="date_shipped" label="Date Shipped" />
|
|
108
|
-
</Datagrid>
|
|
109
|
-
</ReferenceManyField>
|
|
110
|
-
</Tab>
|
|
111
|
-
...
|
|
112
|
-
</TabbedShowLayout>
|
|
113
|
-
</Show>
|
|
114
|
-
);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// generate similar multi-column blocks (e.g., box) for edit and create, using <Edit {...props} redirect={false}>
|
|
118
|
-
|
|
119
|
-
export default {
|
|
120
|
-
list: CustomerList,
|
|
121
|
-
show: CustomerShow,
|
|
122
|
-
create: CustomerCreate,
|
|
123
|
-
edit: CustomerEdit,
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
---
|
|
129
|
-
|
|
130
|
-
## App Features
|
|
131
|
-
|
|
132
|
-
### Multi-Page
|
|
133
|
-
|
|
134
|
-
For each resource:
|
|
135
|
-
|
|
136
|
-
- Create a **List page** showing 7 user-friendly columns
|
|
137
|
-
- Add **pagination**, **sorting**, and **filtering**
|
|
138
|
-
- Link each row to a **Display (Show) page**
|
|
139
|
-
|
|
140
|
-
### Multi-Resource
|
|
141
|
-
|
|
142
|
-
Each **Display Page** should:
|
|
143
|
-
|
|
144
|
-
- Show all fields in a **multi-column layout**
|
|
145
|
-
- Include a **tab sheet** (`<TabbedShowLayout>`) for each related resource using `<ReferenceManyField>`
|
|
146
|
-
- Link child rows to their own display page
|
|
147
|
-
|
|
148
|
-
Example:
|
|
149
|
-
|
|
150
|
-
- Customer Display has tab for OrderList
|
|
151
|
-
|
|
152
|
-
- The tab (with OrderList) is shown *below* all the Customer fields.
|
|
153
|
-
- Each Order in the tab links to Order Display
|
|
154
|
-
|
|
155
|
-
### Automatic Joins
|
|
156
|
-
|
|
157
|
-
For foreign keys:
|
|
158
|
-
|
|
159
|
-
- Display joined value (e.g., `product.name` instead of `product_id`)
|
|
160
|
-
- Use first string field from parent table containing `name`, `title`, or `description`
|
|
161
|
-
|
|
162
|
-
Numeric Primary key fields:
|
|
163
|
-
|
|
164
|
-
- Display at the end of forms/lists
|
|
165
|
-
|
|
166
|
-
### Lookups (Foreign Keys)
|
|
167
|
-
|
|
168
|
-
For foreign key fields:
|
|
169
|
-
|
|
170
|
-
- Provide auto-complete dropdown (`<ReferenceInput>`)
|
|
171
|
-
- For numeric foreign keys, use the joined string field as lookup text
|
|
172
|
-
|
|
173
|
-
### Cascade Add
|
|
174
|
-
|
|
175
|
-
When adding a child row as a detail in a Master / Detail,
|
|
176
|
-
default the Foreign Key to the Parent (Master) Primary Key.
|
|
177
|
-
|
|
178
|
-
## Implementation
|
|
179
|
-
|
|
180
|
-
### Architecture
|
|
181
|
-
|
|
182
|
-
- **Framework**: React 18 + react-admin 4.x
|
|
183
|
-
- **Data Provider**: Custom pre-built in src/rav4-jsonapi-client
|
|
184
|
-
- **CORS**: Ensure API allows `http://localhost:3000`
|
|
185
|
-
|
|
186
|
-
```py
|
|
187
|
-
from flask_cors import CORS
|
|
188
|
-
CORS(app, origins='*') # or restrict to localhost:3000
|
|
189
|
-
```
|
|
190
|
-
- **Project Setup**:
|
|
191
|
-
|
|
192
|
-
- Use `create-react-app`
|
|
193
|
-
- Include: `react-admin`, `@mui/material`, `@emotion/react`, `@emotion/styled`, `react-router-dom`
|
|
194
|
-
- Do not use any deprecated or unmaintained libraries
|
|
195
|
-
- Include complete and correct `App.js`, `index.js`, `dataProvider.js`, and `index.html`
|
|
196
|
-
---
|
|
197
|
-
|
|
198
|
-
## Response Format
|
|
199
|
-
|
|
200
|
-
Format the response as a JSResponseFormat:
|
|
201
|
-
|
|
202
|
-
class JSResponseFormat(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
203
|
-
code : str # generated javascript code (only)
|
|
@@ -1,179 +0,0 @@
|
|
|
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
|
-
|
|
12
|
-
- Create a **List page** showing 7 user-friendly columns
|
|
13
|
-
- Add **pagination**, **sorting**, and **filtering**
|
|
14
|
-
- Link each row to a **Display (Show) page**
|
|
15
|
-
|
|
16
|
-
### Multi-Resource
|
|
17
|
-
|
|
18
|
-
Each **Display Page** should:
|
|
19
|
-
|
|
20
|
-
- Show all fields in a **multi-column layout**
|
|
21
|
-
- Include a **tab sheet** (`<TabbedShowLayout>`) for each related resource using `<ReferenceManyField>`
|
|
22
|
-
- Link child rows to their own display page
|
|
23
|
-
|
|
24
|
-
Example:
|
|
25
|
-
|
|
26
|
-
- Customer Display has tab for OrderList
|
|
27
|
-
|
|
28
|
-
- The tab (with OrderList) is shown *below* all the Customer fields.
|
|
29
|
-
- Each Order in the tab links to Order Display
|
|
30
|
-
|
|
31
|
-
### Automatic Joins
|
|
32
|
-
|
|
33
|
-
For foreign keys:
|
|
34
|
-
|
|
35
|
-
- Display joined value (e.g., `product.name` instead of `product_id`)
|
|
36
|
-
- Use first string field from parent table containing `name`, `title`, or `description`
|
|
37
|
-
|
|
38
|
-
Numeric Primary key fields:
|
|
39
|
-
|
|
40
|
-
- Display at the end of forms/lists
|
|
41
|
-
|
|
42
|
-
### Lookups (Foreign Keys)
|
|
43
|
-
|
|
44
|
-
For foreign key fields:
|
|
45
|
-
|
|
46
|
-
- Provide auto-complete dropdown (`<ReferenceInput>`)
|
|
47
|
-
- For numeric foreign keys, use the joined string field as lookup text
|
|
48
|
-
|
|
49
|
-
### Cascade Add
|
|
50
|
-
|
|
51
|
-
When adding a child row as a detail in a Master / Detail,
|
|
52
|
-
default the Foreign Key to the Parent (Master) Primary Key.
|
|
53
|
-
|
|
54
|
-
## Implementation
|
|
55
|
-
|
|
56
|
-
### Architecture
|
|
57
|
-
|
|
58
|
-
- **Framework**: React 18 + react-admin 4.x
|
|
59
|
-
- **Data Provider**: Custom pre-built in src/rav4-jsonapi-client
|
|
60
|
-
- **CORS**: Ensure API allows `http://localhost:3000`
|
|
61
|
-
|
|
62
|
-
```py
|
|
63
|
-
from flask_cors import CORS
|
|
64
|
-
CORS(app, origins='*') # or restrict to localhost:3000
|
|
65
|
-
```
|
|
66
|
-
- **Project Setup**:
|
|
67
|
-
|
|
68
|
-
- Use `create-react-app`
|
|
69
|
-
- Include: `react-admin`, `@mui/material`, `@emotion/react`, `@emotion/styled`, `react-router-dom`
|
|
70
|
-
- Do not use any deprecated or unmaintained libraries
|
|
71
|
-
- Include complete and correct `App.js`, `index.js`, `dataProvider.js`, and `index.html`
|
|
72
|
-
|
|
73
|
-
---
|
|
74
|
-
|
|
75
|
-
### Per-Resource Files (Required)
|
|
76
|
-
|
|
77
|
-
For each resource (`Customer`, `Order` etc):
|
|
78
|
-
|
|
79
|
-
* Create a source file under `src/`, e.g., `Customer.js`
|
|
80
|
-
* Each file must **fully** implement:
|
|
81
|
-
* `CustomerList`
|
|
82
|
-
* `CustomerShow`
|
|
83
|
-
* `CustomerCreate`
|
|
84
|
-
* `CustomerEdit`
|
|
85
|
-
|
|
86
|
-
Use:
|
|
87
|
-
|
|
88
|
-
- `<ReferenceField>` for foreign key displays
|
|
89
|
-
- `<ReferenceInput>` for foreign key input
|
|
90
|
-
- `<ReferenceManyField>` for tabbed child lists
|
|
91
|
-
- For show pages
|
|
92
|
-
|
|
93
|
-
* Always start with `<SimpleShowLayout>`, followed by a `<TabbedShowLayout>` for related data
|
|
94
|
-
* DO NOT start with `<TabbedShowLayout>`
|
|
95
|
-
|
|
96
|
-
ALWAYS include these 2 imports at the top of the file, with this EXACT formatting, whether or not they are used:
|
|
97
|
-
|
|
98
|
-
```jsx
|
|
99
|
-
import React from 'react';
|
|
100
|
-
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'; // mandatory import
|
|
101
|
-
```
|
|
102
|
-
You may add other imports, but be sure all those are included.
|
|
103
|
-
|
|
104
|
-
DO NOT use `<EmailInput>` - use `<TextInput>`.
|
|
105
|
-
|
|
106
|
-
DO NOT put `<ReferenceField>` in `<Datagrid>`.
|
|
107
|
-
|
|
108
|
-
Do **not leave any file empty**.
|
|
109
|
-
|
|
110
|
-
---
|
|
111
|
-
|
|
112
|
-
### App Wiring
|
|
113
|
-
|
|
114
|
-
Sample code for `App.js` (follow these guidelines EXACTLY):
|
|
115
|
-
|
|
116
|
-
```jsx
|
|
117
|
-
// begin constant imports (always included) -- generate this code EXACTLY
|
|
118
|
-
import React from 'react';
|
|
119
|
-
import { Admin, Resource, Loading } from 'react-admin'; // val? loading
|
|
120
|
-
import { createTheme } from '@mui/material/styles';
|
|
121
|
-
import { useConf, loadHomeConf } from "./Config"; // val ??
|
|
122
|
-
// end constant imports
|
|
123
|
-
|
|
124
|
-
// import each resource, e.g.
|
|
125
|
-
import { CustomerList, CustomerShow, CustomerCreate, CustomerEdit } from './Customer';
|
|
126
|
-
...
|
|
127
|
-
|
|
128
|
-
const theme = createTheme({
|
|
129
|
-
palette: {
|
|
130
|
-
primary: { main: '#1976d2' }, // Material-UI default blue
|
|
131
|
-
secondary: { main: '#1565c0' }, // A darker blue, or choose another color
|
|
132
|
-
},
|
|
133
|
-
typography: { fontSize: 14 },
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
const App = () => {
|
|
137
|
-
const [conf, setConf] = React.useState({});
|
|
138
|
-
|
|
139
|
-
React.useEffect(() => {
|
|
140
|
-
const fetchData = async () => {
|
|
141
|
-
try {
|
|
142
|
-
console.log('loading HomeConf-1')
|
|
143
|
-
const conf = await loadHomeConf()
|
|
144
|
-
setConf(conf)
|
|
145
|
-
setLoading(false);
|
|
146
|
-
console.log('AppConf0: ', conf);
|
|
147
|
-
} catch (error) {
|
|
148
|
-
console.error('Error fetching data:', error);
|
|
149
|
-
sessionStorage.removeItem("raSpa");
|
|
150
|
-
}
|
|
151
|
-
};
|
|
152
|
-
fetchData();
|
|
153
|
-
}, []);
|
|
154
|
-
|
|
155
|
-
if (loading) {
|
|
156
|
-
return <Loading loadingPrimary="Loading..." loadingSecondary="Please wait" />;
|
|
157
|
-
}
|
|
158
|
-
const dataProvider = jsonapiClient(conf.api_root, { conf: {} }, null);
|
|
159
|
-
|
|
160
|
-
return (
|
|
161
|
-
// register each resource (do NOT generate {dataProvider(conf.api_root)}...
|
|
162
|
-
<Admin dataProvider={dataProvider} theme={theme}>
|
|
163
|
-
<Resource name="Customer" list={CustomerList} show={CustomerShow} edit={CustomerEdit} create={CustomerCreate} />
|
|
164
|
-
...
|
|
165
|
-
</Admin>
|
|
166
|
-
);
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
export default App;
|
|
170
|
-
```
|
|
171
|
-
|
|
172
|
-
---
|
|
173
|
-
|
|
174
|
-
## Response Format
|
|
175
|
-
|
|
176
|
-
Format the response as a JSResponseFormat:
|
|
177
|
-
|
|
178
|
-
class JSResponseFormat(BaseModel): # must match system/genai/prompt_inserts/response_format.prompt
|
|
179
|
-
code : str # generated javascript code (only)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|