ApiLogicServer 14.4.0__py3-none-any.whl → 14.5.0__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 +283 -0
- api_logic_server_cli/api_logic_server.py +15 -237
- api_logic_server_cli/api_logic_server_info.yaml +3 -3
- api_logic_server_cli/cli.py +38 -28
- api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc +0 -0
- api_logic_server_cli/create_from_model/__pycache__/ont_build.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/api_logic_server_utils.py +47 -0
- api_logic_server_cli/create_from_model/dbml.py +113 -58
- api_logic_server_cli/create_from_model/ont_build.py +83 -60
- api_logic_server_cli/create_from_model/ont_create.py +2 -1
- api_logic_server_cli/database/basic_demo.sqlite +0 -0
- api_logic_server_cli/database/basic_demo.txt +1 -0
- api_logic_server_cli/database/basic_demo_wg.sqlite +0 -0
- api_logic_server_cli/manager.py +3 -2
- api_logic_server_cli/prototypes/base/.vscode/launch.json +3 -2
- api_logic_server_cli/prototypes/base/config/config.py +66 -11
- api_logic_server_cli/prototypes/base/config/default.env +7 -1
- api_logic_server_cli/prototypes/base/database/test_data/readme.md +2 -1
- api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +5 -2
- api_logic_server_cli/prototypes/base/integration/n8n/n8n_producer.py +68 -21
- api_logic_server_cli/prototypes/base/integration/n8n/n8n_readme.md +19 -0
- api_logic_server_cli/prototypes/base/test/basic/server_test.py +1 -1
- api_logic_server_cli/prototypes/basic_demo/README.md +29 -52
- api_logic_server_cli/prototypes/basic_demo/customizations/api/.DS_Store +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/mcp_server_executor.py +138 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/openapi.py +92 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/proper_update_def.json +71 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/config/default.env +13 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/database/db.sqlite +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/database/models.py +131 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/.DS_Store +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/.DS_Store +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/1_langchain_loader.py +71 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/README_mcp.md +13 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_client_executor.py +295 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_schema.txt +47 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_server_discovery.json +9 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/multi_mcp_flow/multi_mcp_flow.png +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/multi_mcp_flow/multi_mcp_orchestration.yaml +49 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/multi_mcp_flow/wny mcp flows.png +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/natlang_to_api.py +73 -0
- api_logic_server_cli/prototypes/{nw_no_cust → basic_demo/customizations}/integration/mcp/resources/curl.txt +2 -1
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/images/MCP Overview.png +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/images/MCP_Arch.png +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/images/MCP_Overview_Executor.png +0 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/invoke_llm/1 - prompt_messages_array.json +10 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/invoke_llm/2 - completion_tool_context.json +12 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/llm_schema.txt +38 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/nw_swagger_2.yaml +17393 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/nw_swagger_3_relaxed.yaml +109 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/proxy_server.py +51 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/proxy_serverZ.py +72 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/validate_jsonapi.py +64 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/swagger_converter.py +65 -0
- api_logic_server_cli/prototypes/{nw_no_cust/integration/mcp → basic_demo/customizations/integration/mcp/z_old}/3_executor_test_agent.py +20 -6
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/3_executor_test_agent.py +52 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/README_functon.md +201 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/ai_plugin.json +17 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/nw-swagger_3.json +1731 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/snippets.txt +5 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3 genai_demo_with_get.json +1731 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3.json +1782 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo.json +264 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo_with_update.json +1782 -0
- api_logic_server_cli/prototypes/basic_demo/customizations/logic/declare_logic.py +62 -44
- api_logic_server_cli/prototypes/basic_demo/customizations/security/declare_security.py +11 -12
- api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +166 -0
- api_logic_server_cli/prototypes/basic_demo/iteration/api/{customize_api.py → api_discovery/order_b2b.py} +17 -23
- api_logic_server_cli/prototypes/basic_demo/iteration/database/db.sqlite +0 -0
- api_logic_server_cli/prototypes/basic_demo/iteration/integration/row_dict_maps/OrderB2B.py +6 -5
- api_logic_server_cli/prototypes/basic_demo/iteration/integration/row_dict_maps/OrderShipping.py +4 -4
- api_logic_server_cli/prototypes/basic_demo/iteration/logic/declare_logic.py +69 -43
- api_logic_server_cli/prototypes/basic_demo/iteration/ui/admin/admin.yaml +125 -50
- api_logic_server_cli/prototypes/manager/README.md +4 -0
- api_logic_server_cli/prototypes/manager/README_X.md +663 -0
- api_logic_server_cli/prototypes/nw_no_cust/Tutorial.md +45 -26
- api_logic_server_cli/prototypes/nw_no_cust/api/api_discovery/openapi.py +130 -0
- api_logic_server_cli/prototypes/nw_no_cust/api/api_discovery/proper_update_def.json +71 -0
- api_logic_server_cli/prototypes/nw_no_cust/config/default.env +13 -0
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/package-lock.json +9725 -1180
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/package.json +3 -6
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/app/shared/app.services.config.ts +1 -1
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/css/app.scss +4 -0
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/i18n/en.json +1 -1
- api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/i18n/es.json +14 -12
- api_logic_server_cli/prototypes/ont_app/templates/app_config.jinja +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/date_template.html +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/textarea_template.html +1 -1
- api_logic_server_cli/prototypes/ont_app/templates/timestamp_template.html +1 -1
- api_logic_server_cli/prototypes/sample_ai/logic/declare_logic.py +30 -13
- {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.0.dist-info}/METADATA +2 -2
- {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.0.dist-info}/RECORD +101 -60
- {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.0.dist-info}/WHEEL +1 -1
- api_logic_server_cli/prototypes/basic_demo/apply_customizations.ps1 +0 -17
- api_logic_server_cli/prototypes/basic_demo/apply_customizations.sh +0 -14
- api_logic_server_cli/prototypes/basic_demo/apply_iteration.ps1 +0 -20
- api_logic_server_cli/prototypes/basic_demo/apply_iteration.sh +0 -15
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/1_langchain_loader.py +0 -19
- api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/README.md +0 -17
- /api_logic_server_cli/prototypes/{nw_no_cust → basic_demo/customizations}/integration/mcp/2_gpt_mcp_prompt.txt +0 -0
- /api_logic_server_cli/prototypes/{nw_no_cust → basic_demo/customizations}/integration/mcp/resources/nw_swagger_3.yaml +0 -0
- /api_logic_server_cli/prototypes/{nw_no_cust → basic_demo/customizations}/integration/mcp/run_executor.py +0 -0
- {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.0.dist-info}/entry_points.txt +0 -0
- {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.0.dist-info}/licenses/LICENSE +0 -0
- {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
from api_logic_server_cli.cli_args_project import Project
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
import sqlalchemy
|
|
4
|
+
from sqlalchemy.orm import Session
|
|
5
|
+
from sqlalchemy.ext.declarative import declarative_base
|
|
6
|
+
import logging
|
|
7
|
+
import importlib.util
|
|
8
|
+
from api_logic_server_cli.create_from_model import api_logic_server_utils as api_logic_server_utils
|
|
9
|
+
from shutil import copyfile
|
|
10
|
+
import shutil, os
|
|
11
|
+
import create_from_model.api_logic_server_utils as create_utils
|
|
12
|
+
|
|
13
|
+
log = logging.getLogger('create_from_model.model_creation_services')
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
'''
|
|
17
|
+
samples and demos - simulate customizations - https://apilogicserver.github.io/Docs/Doc-Home/#start-install-samples-training
|
|
18
|
+
1. nw - sample code
|
|
19
|
+
2. genai_demo - GenAI (ChatGPT to create model, add rules VSC)
|
|
20
|
+
3. basic_demo - small db, no GenAI (w/ iteration)
|
|
21
|
+
4. sample_ai - CoPilot, no GenAI (w/ iteration)
|
|
22
|
+
5. Tech AI - just an article, no automated customizations...
|
|
23
|
+
|
|
24
|
+
Note: many require: rebuild-from-database --project_name=./ --db_url=sqlite:///database/db.sqlite
|
|
25
|
+
'''
|
|
26
|
+
|
|
27
|
+
def add_genai_customizations(project: Project, do_show_messages: bool = True, do_security: bool = True):
|
|
28
|
+
""" Add customizations to genai (default creation)
|
|
29
|
+
|
|
30
|
+
0. Initial: create_project_and_overlay_prototypes() -- minor: just creates the readme
|
|
31
|
+
* When done with genai logic prompt, logic is pre-created (in logic/declare_logic.py)
|
|
32
|
+
1. Deep copy prototypes/genai_demo (adds logic and security, and custom end point)
|
|
33
|
+
|
|
34
|
+
WebGenAI DX:
|
|
35
|
+
|
|
36
|
+
0. Convention: click the Blue Button
|
|
37
|
+
* Home/Create Project
|
|
38
|
+
* Home/Open App
|
|
39
|
+
* Landing
|
|
40
|
+
* Overview[Manager]/Open
|
|
41
|
+
* Overview/GitHub
|
|
42
|
+
* App Home / Develop --> GitHub
|
|
43
|
+
0. demo --> codespaces. Where are instructions (what is CS, how do I load/run)?
|
|
44
|
+
1. Name can be any, iff created with APILOGICPROJECT_IS_GENAI_DEMO
|
|
45
|
+
2. Bypass duplicate discovery logic iff created with APILOGICPROJECT_IS_GENAI_DEMO
|
|
46
|
+
3. TODO:
|
|
47
|
+
* cd project
|
|
48
|
+
* als add-cust # add customizations
|
|
49
|
+
* run, and use place b2b order service - end point is not activated.
|
|
50
|
+
|
|
51
|
+
Args:
|
|
52
|
+
"""
|
|
53
|
+
|
|
54
|
+
log.debug("\n\n==================================================================")
|
|
55
|
+
nw_messages = ""
|
|
56
|
+
do_security = True # other demos can explain security, here just make it work
|
|
57
|
+
if do_security:
|
|
58
|
+
if do_show_messages:
|
|
59
|
+
nw_messages = "Add sample_ai / genai_demo customizations - enabling security"
|
|
60
|
+
project.add_auth(is_nw=True, msg=nw_messages)
|
|
61
|
+
|
|
62
|
+
# overlay genai_demo := sample_ai + sample_ai_iteration
|
|
63
|
+
nw_path = (project.api_logic_server_dir_path).\
|
|
64
|
+
joinpath('prototypes/genai_demo') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
65
|
+
create_utils.recursive_overwrite(nw_path, project.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
66
|
+
|
|
67
|
+
if do_show_messages:
|
|
68
|
+
log.info("\nExplore key customization files:")
|
|
69
|
+
log.info(f'..api/customize_api.py')
|
|
70
|
+
log.info(f'..logic/declare_logic.py')
|
|
71
|
+
log.info(f'..security/declare_security.py\n')
|
|
72
|
+
if project.is_tutorial == False:
|
|
73
|
+
log.info(".. all customizations complete\n")
|
|
74
|
+
|
|
75
|
+
def fix_nw_datamodel(project_directory: str):
|
|
76
|
+
"""update sqlite data model for cascade delete, aliases -- fixme moving to add_cust
|
|
77
|
+
|
|
78
|
+
Args:
|
|
79
|
+
project_directory (str): project creation dir
|
|
80
|
+
"""
|
|
81
|
+
models_file_name = Path(project_directory).joinpath('database/models.py')
|
|
82
|
+
do_add_manual = True if models_file_name.is_file() and not create_utils.does_file_contain(search_for="manual fix", in_file=models_file_name) else False
|
|
83
|
+
if not do_add_manual:
|
|
84
|
+
log.debug(f'.. .. ..ALREADY SET cascade delete and column alias for sample database database/models.py')
|
|
85
|
+
pass # should not occur, just being careful
|
|
86
|
+
else:
|
|
87
|
+
log.debug(f'.. .. ..Setting cascade delete and column alias for sample database database/models.py')
|
|
88
|
+
create_utils.replace_string_in_file(in_file=models_file_name,
|
|
89
|
+
search_for='OrderDetailList : Mapped[List["OrderDetail"]] = relationship(back_populates="Order")',
|
|
90
|
+
replace_with='OrderDetailList : Mapped[List["OrderDetail"]] = relationship(cascade="all, delete", back_populates="Order") # manual fix')
|
|
91
|
+
create_utils.replace_string_in_file(in_file=models_file_name,
|
|
92
|
+
search_for="ShipPostalCode = Column(String(8000))",
|
|
93
|
+
replace_with="ShipZip = Column('ShipPostalCode', String(8000)) # manual fix - alias")
|
|
94
|
+
create_utils.replace_string_in_file(in_file=models_file_name,
|
|
95
|
+
search_for="CategoryName_ColumnName = Column(String(8000))",
|
|
96
|
+
replace_with="CategoryName = Column('CategoryName_ColumnName', String(8000)) # manual fix - alias")
|
|
97
|
+
|
|
98
|
+
def add_nw_customizations(project: Project, do_show_messages: bool = True, do_security: bool = True):
|
|
99
|
+
""" Add customizations to nw (default creation)
|
|
100
|
+
|
|
101
|
+
1. Add-sqlite-security (optionally - not used for initial creation)
|
|
102
|
+
|
|
103
|
+
2. Deep copy project_prototype_nw (adds logic)
|
|
104
|
+
|
|
105
|
+
3. Create readme files: Tutorial (copy_md), api/integration_defs/readme.md
|
|
106
|
+
|
|
107
|
+
4. Add database customizations
|
|
108
|
+
|
|
109
|
+
Args:
|
|
110
|
+
"""
|
|
111
|
+
|
|
112
|
+
log.debug("\n\n==================================================================")
|
|
113
|
+
nw_messages = ""
|
|
114
|
+
if do_security:
|
|
115
|
+
if do_show_messages:
|
|
116
|
+
nw_messages = "Add northwind customizations - enabling security"
|
|
117
|
+
project.add_auth(is_nw=True, msg=nw_messages)
|
|
118
|
+
|
|
119
|
+
nw_path = (project.api_logic_server_dir_path).\
|
|
120
|
+
joinpath('prototypes/nw') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
121
|
+
if os.path.isfile(project.project_directory_path.joinpath('ui/admin/admin.yaml')):
|
|
122
|
+
copyfile(src = project.project_directory_path.joinpath('ui/admin/admin.yaml'),
|
|
123
|
+
dst = project.project_directory_path.joinpath('ui/admin/admin_no_customizations.yaml'))
|
|
124
|
+
create_utils.recursive_overwrite(nw_path, project.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
125
|
+
|
|
126
|
+
project.create_nw_tutorial_and_readme()
|
|
127
|
+
|
|
128
|
+
# z_copy_md(project = project, from_doc_file="Sample-Integration.md", to_project_file='integration/Sample-Integration.md')
|
|
129
|
+
create_utils.copy_md(project = project, from_doc_file = "Sample-Integration.md", to_project_file='integration/Sample-Integration.md')
|
|
130
|
+
|
|
131
|
+
fix_nw_datamodel(project_directory=project.project_directory)
|
|
132
|
+
|
|
133
|
+
if do_show_messages:
|
|
134
|
+
log.info("\nExplore key customization files:")
|
|
135
|
+
log.info(f'..api/customize_api.py')
|
|
136
|
+
log.info(f'..database/customize_models.py')
|
|
137
|
+
log.info(f'..logic/declare_logic.py')
|
|
138
|
+
log.info(f'..security/declare_security.py\n')
|
|
139
|
+
if project.is_tutorial == False:
|
|
140
|
+
log.info(".. all customizations complete\n")
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def add_basic_demo_customizations(project: Project, do_show_messages: bool = True):
|
|
144
|
+
""" Add customizations to basic_demo (default creation)
|
|
145
|
+
|
|
146
|
+
1. Deep copy prototypes/basic_demo (adds logic and security)
|
|
147
|
+
|
|
148
|
+
2. Create readme files: Sample-AI (copy_md), api/integration_defs/readme.md TODO not done, fix cmts
|
|
149
|
+
|
|
150
|
+
Args:
|
|
151
|
+
"""
|
|
152
|
+
|
|
153
|
+
log.debug("\n\n==================================================================")
|
|
154
|
+
nw_messages = ""
|
|
155
|
+
do_security = False # disabled - keep clear what "activate security" means for reader
|
|
156
|
+
if do_security:
|
|
157
|
+
if do_show_messages:
|
|
158
|
+
nw_messages = "Add basic_demo customizations - enabling security"
|
|
159
|
+
project.add_auth(is_nw=True, msg=nw_messages)
|
|
160
|
+
|
|
161
|
+
nw_path = (project.api_logic_server_dir_path).\
|
|
162
|
+
joinpath('prototypes/basic_demo/customizations') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/basic_demo/customizations')
|
|
163
|
+
create_utils.recursive_overwrite(nw_path, project.project_directory)
|
|
164
|
+
|
|
165
|
+
if do_show_messages:
|
|
166
|
+
log.info("\nExplore key customization files:")
|
|
167
|
+
log.info(f'..logic/declare_logic.py')
|
|
168
|
+
log.info(f'..security/declare_security.py\n')
|
|
169
|
+
log.info(f'Explore MCP (Model Context Protocol): https://apilogicserver.github.io/Docs/Integration-MCP/\n')
|
|
170
|
+
log.info(f'Next Steps: activate security')
|
|
171
|
+
log.info(f'..ApiLogicServer add-auth --db_url=auth')
|
|
172
|
+
if project.is_tutorial == False:
|
|
173
|
+
log.info(".. complete\n")
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
def add_basic_demo_iteration(project: Project, do_show_messages: bool = True, do_security: bool = True):
|
|
177
|
+
""" Iterate data model for basic_demo (default creation)
|
|
178
|
+
|
|
179
|
+
1. Deep copy prototypes/basic_demo/iteration (adds db, logic)
|
|
180
|
+
|
|
181
|
+
Args:
|
|
182
|
+
"""
|
|
183
|
+
|
|
184
|
+
log.debug("\n\n==================================================================")
|
|
185
|
+
|
|
186
|
+
nw_path = (project.api_logic_server_dir_path).\
|
|
187
|
+
joinpath('prototypes/basic_demo/iteration')
|
|
188
|
+
create_utils.recursive_overwrite(nw_path, project.project_directory) # ~/dev/ApiLogicServer/ApiLogicServer-dev/servers/basic_demo
|
|
189
|
+
if do_show_messages:
|
|
190
|
+
log.info("\nNext Step:")
|
|
191
|
+
log.info(f'..ApiLogicServer rebuild-from-database --db_url=sqlite:///database/db.sqlite')
|
|
192
|
+
log.info(".. complete\n")
|
|
193
|
+
|
|
194
|
+
|
|
195
|
+
def add_sample_ai_customizations(project: Project, do_show_messages: bool = True):
|
|
196
|
+
""" Add customizations to sample_ai (default creation)
|
|
197
|
+
|
|
198
|
+
1. Deep copy prototypes/sample_ai (adds logic and security)
|
|
199
|
+
|
|
200
|
+
2. Create readme files: Sample-AI (copy_md), api/integration_defs/readme.md TODO not done, fix cmts
|
|
201
|
+
|
|
202
|
+
Args:
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
log.debug("\n\n==================================================================")
|
|
206
|
+
nw_messages = ""
|
|
207
|
+
do_security = False # disabled - keep clear what "activate security" means for reader
|
|
208
|
+
if do_security:
|
|
209
|
+
if do_show_messages:
|
|
210
|
+
nw_messages = "Add sample_ai customizations - enabling security"
|
|
211
|
+
project.add_auth(is_nw=True, msg=nw_messages)
|
|
212
|
+
|
|
213
|
+
nw_path = (project.api_logic_server_dir_path).\
|
|
214
|
+
joinpath('prototypes/sample_ai') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
215
|
+
create_utils.recursive_overwrite(nw_path, project.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
216
|
+
|
|
217
|
+
if do_show_messages:
|
|
218
|
+
log.info("\nExplore key customization files:")
|
|
219
|
+
log.info(f'..api/customize_api.py')
|
|
220
|
+
log.info(f'..logic/declare_logic.py')
|
|
221
|
+
log.info(f'..security/declare_security.py\n')
|
|
222
|
+
log.info(f'Next Steps: activate security')
|
|
223
|
+
log.info(f'..ApiLogicServer add-auth --db_url=auth')
|
|
224
|
+
if project.is_tutorial == False:
|
|
225
|
+
log.info(".. complete\n")
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def add_sample_ai_iteration(project: Project, do_show_messages: bool = True, do_security: bool = True):
|
|
229
|
+
""" Iterate data model for sample_ai (default creation)
|
|
230
|
+
|
|
231
|
+
1. Deep copy prototypes/sample_ai_iteration (adds db, logic)
|
|
232
|
+
|
|
233
|
+
Args:
|
|
234
|
+
"""
|
|
235
|
+
|
|
236
|
+
log.debug("\n\n==================================================================")
|
|
237
|
+
|
|
238
|
+
nw_path = (project.api_logic_server_dir_path).\
|
|
239
|
+
joinpath('prototypes/sample_ai_iteration') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
240
|
+
create_utils.recursive_overwrite(nw_path, project.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
241
|
+
if do_show_messages:
|
|
242
|
+
log.info("\nNext Step:")
|
|
243
|
+
log.info(f'..ApiLogicServer rebuild-from-database --project_name=./ --db_url=sqlite:///database/db.sqlite')
|
|
244
|
+
log.info(".. complete\n")
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
def add_cust(project: Project, models_py_path: Path, project_name: str):
|
|
248
|
+
''' determine which project, then call a customizer above '''
|
|
249
|
+
|
|
250
|
+
log.debug(f"\ncli[add-cust] models_py_path={models_py_path}")
|
|
251
|
+
if not models_py_path.exists():
|
|
252
|
+
raise Exception("Customizations are northwind/genai-specific - models.py does not exist")
|
|
253
|
+
|
|
254
|
+
project_is_genai_demo = False # can't use project.is_genai_demo because this is not the create command...
|
|
255
|
+
if project.project_directory_path.joinpath('docs/project_is_genai_demo.txt').exists():
|
|
256
|
+
project_is_genai_demo = True
|
|
257
|
+
|
|
258
|
+
project.abs_db_url, project.nw_db_status, project.model_file_name = create_utils.get_abs_db_url("0. Using Sample DB", project)
|
|
259
|
+
if create_utils.does_file_contain(search_for="CategoryTableNameTest", in_file=models_py_path):
|
|
260
|
+
add_nw_customizations(project=project, do_security=False)
|
|
261
|
+
log.info("\nNext step - add authentication:\n $ ApiLogicServer add-auth --db_url=auth\n\n")
|
|
262
|
+
|
|
263
|
+
elif project_is_genai_demo and create_utils.does_file_contain(search_for="Customer", in_file=models_py_path):
|
|
264
|
+
add_genai_customizations(project=project, do_security=False)
|
|
265
|
+
|
|
266
|
+
elif project_name == 'sample_ai' and create_utils.does_file_contain(search_for="CustomerName = Column(Text", in_file=models_py_path):
|
|
267
|
+
cocktail_napkin_path = project.project_directory_path.joinpath('logic/cocktail-napkin.jpg')
|
|
268
|
+
is_customized = cocktail_napkin_path.exists()
|
|
269
|
+
if not is_customized:
|
|
270
|
+
add_sample_ai_customizations(project=project)
|
|
271
|
+
else:
|
|
272
|
+
add_sample_ai_iteration(project=project)
|
|
273
|
+
|
|
274
|
+
elif project_name == 'basic_demo' and create_utils.does_file_contain(search_for="Customer", in_file=models_py_path):
|
|
275
|
+
cocktail_napkin_path = project.project_directory_path.joinpath('logic/cocktail-napkin.jpg')
|
|
276
|
+
is_customized = cocktail_napkin_path.exists()
|
|
277
|
+
if not is_customized:
|
|
278
|
+
add_basic_demo_customizations(project=project)
|
|
279
|
+
else:
|
|
280
|
+
add_basic_demo_iteration(project=project)
|
|
281
|
+
|
|
282
|
+
else:
|
|
283
|
+
raise Exception("Customizations are northwind/genai-specific - models.py has neither CategoryTableNameTest nor Customer")
|
|
@@ -12,9 +12,10 @@ ApiLogicServer CLI: given a database url, create [and run] customizable ApiLogic
|
|
|
12
12
|
Called from api_logic_server_cli.py, by instantiating the ProjectRun object.
|
|
13
13
|
'''
|
|
14
14
|
|
|
15
|
-
__version__ = "14.
|
|
15
|
+
__version__ = "14.05.00" # last public release: 14.04.00
|
|
16
16
|
recent_changes = \
|
|
17
17
|
f'\n\nRecent Changes:\n' +\
|
|
18
|
+
"\t05/16/2024 - 14.05.00: safrs 3.1.7, running mcp preview \n"\
|
|
18
19
|
"\t04/27/2024 - 14.04.00: Graphics preview, Vibe install fix, Improved IDE Chat Logic, MCP Exploration \n"\
|
|
19
20
|
"\t03/30/2024 - 14.03.25: WebGenAI fixes for Kafka and Keycloak \n"\
|
|
20
21
|
"\t03/19/2024 - 14.03.20: licensed webgenai docker, [87] sra fix for home.js \n"\
|
|
@@ -60,7 +61,7 @@ import importlib
|
|
|
60
61
|
import fnmatch
|
|
61
62
|
from dotmap import DotMap
|
|
62
63
|
import api_logic_server_cli.create_from_model.create_db_from_model as create_db_from_model
|
|
63
|
-
|
|
64
|
+
import add_cust.add_cust as add_cust
|
|
64
65
|
|
|
65
66
|
def is_docker() -> bool:
|
|
66
67
|
""" running docker? dir exists: /home/api_logic_server """
|
|
@@ -179,7 +180,7 @@ def delete_dir(dir_path, msg):
|
|
|
179
180
|
|
|
180
181
|
|
|
181
182
|
def recursive_overwrite(src, dest, ignore=None):
|
|
182
|
-
"""
|
|
183
|
+
""" moving to api_logic_server_utils
|
|
183
184
|
copyTree, with overwrite
|
|
184
185
|
thanks: https://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all
|
|
185
186
|
"""
|
|
@@ -334,7 +335,8 @@ def create_project_and_overlay_prototypes(project: 'ProjectRun', msg: str) -> st
|
|
|
334
335
|
log.debug(".. ..Copying nw customizations: logic, custom api, readme, tests, admin app")
|
|
335
336
|
if project.nw_db_status == 'nw':
|
|
336
337
|
log.error("\n==> System Error: Unexpected customization for nw. Please contact support.\n")
|
|
337
|
-
|
|
338
|
+
|
|
339
|
+
add_cust.add_nw_customizations(project=project, do_security=False, do_show_messages=False)
|
|
338
340
|
|
|
339
341
|
if project.nw_db_status in ["nw+"]:
|
|
340
342
|
log.debug(".. ..Copy in nw+ customizations: readme, perform_customizations")
|
|
@@ -525,7 +527,7 @@ def resolve_home(name: str) -> str:
|
|
|
525
527
|
return result
|
|
526
528
|
|
|
527
529
|
def fix_nw_datamodel(project_directory: str):
|
|
528
|
-
"""update sqlite data model for cascade delete, aliases
|
|
530
|
+
"""update sqlite data model for cascade delete, aliases -- fixme moving to add_cust
|
|
529
531
|
|
|
530
532
|
Args:
|
|
531
533
|
project_directory (str): project creation dir
|
|
@@ -1219,8 +1221,9 @@ from database import <project.bind_key>_models
|
|
|
1219
1221
|
# log.info(".. docs: https://apilogicserver.github.io/Docs/Security-Activation")
|
|
1220
1222
|
|
|
1221
1223
|
config_file = f'{self.project_directory}/config/config.py'
|
|
1224
|
+
env_file = f'{self.project_directory}/config/default.env'
|
|
1222
1225
|
is_enabled = create_utils.does_file_contain(search_for="SECURITY_ENABLED = True",
|
|
1223
|
-
in_file=
|
|
1226
|
+
in_file=env_file)
|
|
1224
1227
|
is_sql = create_utils.does_file_contain(search_for="authentication_provider.sql.auth_provider import",
|
|
1225
1228
|
in_file=config_file)
|
|
1226
1229
|
was_provider_type = "sql" if is_sql else "keycloak"
|
|
@@ -1240,8 +1243,8 @@ from database import <project.bind_key>_models
|
|
|
1240
1243
|
if is_enabled:
|
|
1241
1244
|
log.info(f'\n\n.. ..Disabling security for current provider type: {was_provider_type}\n')
|
|
1242
1245
|
create_utils.assign_value_to_key_in_file(value=False,
|
|
1243
|
-
key="
|
|
1244
|
-
in_file=
|
|
1246
|
+
key="SECURITY_ENABLED",
|
|
1247
|
+
in_file=env_file)
|
|
1245
1248
|
else:
|
|
1246
1249
|
log.info(f'\n.. .. ..No action taken - already disabled for current provider type: {was_provider_type}\n')
|
|
1247
1250
|
return
|
|
@@ -1260,8 +1263,8 @@ from database import <project.bind_key>_models
|
|
|
1260
1263
|
log.info("\n.. Authorization is declared in security/declare_security.py")
|
|
1261
1264
|
|
|
1262
1265
|
log.info(f'\n..{provider_note}') # set enabled, provider in config
|
|
1263
|
-
create_utils.assign_value_to_key_in_file(in_file=
|
|
1264
|
-
key="
|
|
1266
|
+
create_utils.assign_value_to_key_in_file(in_file=env_file, \
|
|
1267
|
+
key="SECURITY_ENABLED", value=True)
|
|
1265
1268
|
self.set_provider(from_value=was_provider_type, to_value=self.auth_provider_type, config_file=config_file)
|
|
1266
1269
|
if self.auth_provider_type == "keycloak":
|
|
1267
1270
|
use_keycloak =True
|
|
@@ -1539,231 +1542,6 @@ from database import <project.bind_key>_models
|
|
|
1539
1542
|
create_utils.copy_md(project = self, from_doc_file = "Tutorial-3.md", to_project_file='Tutorial.md')
|
|
1540
1543
|
# z_copy_md(project = self, from_doc_file="Tutorial-3.md", to_project_file='Tutorial.md')
|
|
1541
1544
|
|
|
1542
|
-
'''
|
|
1543
|
-
samples and demos - simulate customizations - https://apilogicserver.github.io/Docs/Doc-Home/#start-install-samples-training
|
|
1544
|
-
1. nw - sample code
|
|
1545
|
-
2. genai_demo - GenAI (ChatGPT to create model, add rules VSC)
|
|
1546
|
-
3. basic_demo - small db, no GenAI (w/ iteration)
|
|
1547
|
-
4. sample_ai - CoPilot, no GenAI (w/ iteration)
|
|
1548
|
-
5. Tech AI - just an article, no automated customizations...
|
|
1549
|
-
'''
|
|
1550
|
-
|
|
1551
|
-
def add_genai_customizations(self, do_show_messages: bool = True, do_security: bool = True):
|
|
1552
|
-
""" Add customizations to genai (default creation)
|
|
1553
|
-
|
|
1554
|
-
0. Initial: create_project_and_overlay_prototypes() -- minor: just creates the readme
|
|
1555
|
-
* When done with genai logic prompt, logic is pre-created (in logic/declare_logic.py)
|
|
1556
|
-
1. Deep copy prototypes/genai_demo (adds logic and security, and custom end point)
|
|
1557
|
-
|
|
1558
|
-
WebGenAI DX:
|
|
1559
|
-
|
|
1560
|
-
0. Convention: click the Blue Button
|
|
1561
|
-
* Home/Create Project
|
|
1562
|
-
* Home/Open App
|
|
1563
|
-
* Landing
|
|
1564
|
-
* Overview[Manager]/Open
|
|
1565
|
-
* Overview/GitHub
|
|
1566
|
-
* App Home / Develop --> GitHub
|
|
1567
|
-
0. demo --> codespaces. Where are instructions (what is CS, how do I load/run)?
|
|
1568
|
-
1. Name can be any, iff created with APILOGICPROJECT_IS_GENAI_DEMO
|
|
1569
|
-
2. Bypass duplicate discovery logic iff created with APILOGICPROJECT_IS_GENAI_DEMO
|
|
1570
|
-
3. TODO:
|
|
1571
|
-
* cd project
|
|
1572
|
-
* als add-cust # add customizations
|
|
1573
|
-
* run, and use place b2b order service - end point is not activated.
|
|
1574
|
-
|
|
1575
|
-
Args:
|
|
1576
|
-
"""
|
|
1577
|
-
|
|
1578
|
-
log.debug("\n\n==================================================================")
|
|
1579
|
-
nw_messages = ""
|
|
1580
|
-
do_security = True # other demos can explain security, here just make it work
|
|
1581
|
-
if do_security:
|
|
1582
|
-
if do_show_messages:
|
|
1583
|
-
nw_messages = "Add sample_ai / genai_demo customizations - enabling security"
|
|
1584
|
-
self.add_auth(is_nw=True, msg=nw_messages)
|
|
1585
|
-
|
|
1586
|
-
# overlay genai_demo := sample_ai + sample_ai_iteration
|
|
1587
|
-
nw_path = (self.api_logic_server_dir_path).\
|
|
1588
|
-
joinpath('prototypes/genai_demo') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
1589
|
-
recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
1590
|
-
|
|
1591
|
-
if do_show_messages:
|
|
1592
|
-
log.info("\nExplore key customization files:")
|
|
1593
|
-
log.info(f'..api/customize_api.py')
|
|
1594
|
-
log.info(f'..logic/declare_logic.py')
|
|
1595
|
-
log.info(f'..security/declare_security.py\n')
|
|
1596
|
-
if self.is_tutorial == False:
|
|
1597
|
-
log.info(".. all customizations complete\n")
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
def add_nw_customizations(self, do_show_messages: bool = True, do_security: bool = True):
|
|
1601
|
-
""" Add customizations to nw (default creation)
|
|
1602
|
-
|
|
1603
|
-
1. Add-sqlite-security (optionally - not used for initial creation)
|
|
1604
|
-
|
|
1605
|
-
2. Deep copy project_prototype_nw (adds logic)
|
|
1606
|
-
|
|
1607
|
-
3. Create readme files: Tutorial (copy_md), api/integration_defs/readme.md
|
|
1608
|
-
|
|
1609
|
-
4. Add database customizations
|
|
1610
|
-
|
|
1611
|
-
Args:
|
|
1612
|
-
"""
|
|
1613
|
-
|
|
1614
|
-
log.debug("\n\n==================================================================")
|
|
1615
|
-
nw_messages = ""
|
|
1616
|
-
if do_security:
|
|
1617
|
-
if do_show_messages:
|
|
1618
|
-
nw_messages = "Add northwind customizations - enabling security"
|
|
1619
|
-
self.add_auth(is_nw=True, msg=nw_messages)
|
|
1620
|
-
|
|
1621
|
-
nw_path = (self.api_logic_server_dir_path).\
|
|
1622
|
-
joinpath('prototypes/nw') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
1623
|
-
if os.path.isfile(self.project_directory_path.joinpath('ui/admin/admin.yaml')):
|
|
1624
|
-
copyfile(src = self.project_directory_path.joinpath('ui/admin/admin.yaml'),
|
|
1625
|
-
dst = self.project_directory_path.joinpath('ui/admin/admin_no_customizations.yaml'))
|
|
1626
|
-
recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
1627
|
-
|
|
1628
|
-
self.create_nw_tutorial_and_readme()
|
|
1629
|
-
|
|
1630
|
-
# z_copy_md(project = self, from_doc_file="Sample-Integration.md", to_project_file='integration/Sample-Integration.md')
|
|
1631
|
-
create_utils.copy_md(project = self, from_doc_file = "Sample-Integration.md", to_project_file='integration/Sample-Integration.md')
|
|
1632
|
-
|
|
1633
|
-
fix_nw_datamodel(project_directory=self.project_directory)
|
|
1634
|
-
|
|
1635
|
-
if do_show_messages:
|
|
1636
|
-
log.info("\nExplore key customization files:")
|
|
1637
|
-
log.info(f'..api/customize_api.py')
|
|
1638
|
-
log.info(f'..database/customize_models.py')
|
|
1639
|
-
log.info(f'..logic/declare_logic.py')
|
|
1640
|
-
log.info(f'..security/declare_security.py\n')
|
|
1641
|
-
if self.is_tutorial == False:
|
|
1642
|
-
log.info(".. all customizations complete\n")
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
def add_basic_demo_customizations(self, do_show_messages: bool = True):
|
|
1646
|
-
""" Add customizations to basic_demo (default creation)
|
|
1647
|
-
|
|
1648
|
-
1. Deep copy prototypes/basic_demo (adds logic and security)
|
|
1649
|
-
|
|
1650
|
-
2. Create readme files: Sample-AI (copy_md), api/integration_defs/readme.md TODO not done, fix cmts
|
|
1651
|
-
|
|
1652
|
-
Args:
|
|
1653
|
-
"""
|
|
1654
|
-
|
|
1655
|
-
log.debug("\n\n==================================================================")
|
|
1656
|
-
nw_messages = ""
|
|
1657
|
-
do_security = False # disabled - keep clear what "activate security" means for reader
|
|
1658
|
-
if do_security:
|
|
1659
|
-
if do_show_messages:
|
|
1660
|
-
nw_messages = "Add basic_demo customizations - enabling security"
|
|
1661
|
-
self.add_auth(is_nw=True, msg=nw_messages)
|
|
1662
|
-
|
|
1663
|
-
nw_path = (self.api_logic_server_dir_path).\
|
|
1664
|
-
joinpath('prototypes/basic_demo/customizations') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/basic_demo/customizations')
|
|
1665
|
-
recursive_overwrite(nw_path, self.project_directory)
|
|
1666
|
-
|
|
1667
|
-
if do_show_messages:
|
|
1668
|
-
log.info("\nExplore key customization files:")
|
|
1669
|
-
log.info(f'..logic/declare_logic.py')
|
|
1670
|
-
log.info(f'..security/declare_security.py\n')
|
|
1671
|
-
log.info(f'Next Steps: activate security')
|
|
1672
|
-
log.info(f'..ApiLogicServer add-auth --db_url=auth')
|
|
1673
|
-
if self.is_tutorial == False:
|
|
1674
|
-
log.info(".. complete\n")
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
def add_basic_demo_iteration(self, do_show_messages: bool = True, do_security: bool = True):
|
|
1678
|
-
""" Iterate data model for basic_demo (default creation)
|
|
1679
|
-
|
|
1680
|
-
1. Deep copy prototypes/basic_demo/iteration (adds db, logic)
|
|
1681
|
-
|
|
1682
|
-
Args:
|
|
1683
|
-
"""
|
|
1684
|
-
|
|
1685
|
-
log.debug("\n\n==================================================================")
|
|
1686
|
-
|
|
1687
|
-
nw_path = (self.api_logic_server_dir_path).\
|
|
1688
|
-
joinpath('prototypes/basic_demo/iteration')
|
|
1689
|
-
recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
1690
|
-
if do_show_messages:
|
|
1691
|
-
log.info("\nNext Step:")
|
|
1692
|
-
log.info(f'..ApiLogicServer rebuild-from-database --db_url=sqlite:///database/db.sqlite')
|
|
1693
|
-
log.info(".. complete\n")
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
def add_sample_ai_customizations(self, do_show_messages: bool = True):
|
|
1697
|
-
""" Add customizations to sample_ai (default creation)
|
|
1698
|
-
|
|
1699
|
-
1. Deep copy prototypes/sample_ai (adds logic and security)
|
|
1700
|
-
|
|
1701
|
-
2. Create readme files: Sample-AI (copy_md), api/integration_defs/readme.md TODO not done, fix cmts
|
|
1702
|
-
|
|
1703
|
-
Args:
|
|
1704
|
-
"""
|
|
1705
|
-
|
|
1706
|
-
log.debug("\n\n==================================================================")
|
|
1707
|
-
nw_messages = ""
|
|
1708
|
-
do_security = False # disabled - keep clear what "activate security" means for reader
|
|
1709
|
-
if do_security:
|
|
1710
|
-
if do_show_messages:
|
|
1711
|
-
nw_messages = "Add sample_ai customizations - enabling security"
|
|
1712
|
-
self.add_auth(is_nw=True, msg=nw_messages)
|
|
1713
|
-
|
|
1714
|
-
nw_path = (self.api_logic_server_dir_path).\
|
|
1715
|
-
joinpath('prototypes/sample_ai') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
1716
|
-
recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
1717
|
-
|
|
1718
|
-
if do_show_messages:
|
|
1719
|
-
log.info("\nExplore key customization files:")
|
|
1720
|
-
log.info(f'..api/customize_api.py')
|
|
1721
|
-
log.info(f'..logic/declare_logic.py')
|
|
1722
|
-
log.info(f'..security/declare_security.py\n')
|
|
1723
|
-
log.info(f'Next Steps: activate security')
|
|
1724
|
-
log.info(f'..ApiLogicServer add-auth --db_url=auth')
|
|
1725
|
-
if self.is_tutorial == False:
|
|
1726
|
-
log.info(".. complete\n")
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
def add_sample_ai_iteration(self, do_show_messages: bool = True, do_security: bool = True):
|
|
1730
|
-
""" Iterate data model for sample_ai (default creation)
|
|
1731
|
-
|
|
1732
|
-
1. Deep copy prototypes/sample_ai_iteration (adds db, logic)
|
|
1733
|
-
|
|
1734
|
-
Args:
|
|
1735
|
-
"""
|
|
1736
|
-
|
|
1737
|
-
log.debug("\n\n==================================================================")
|
|
1738
|
-
|
|
1739
|
-
nw_path = (self.api_logic_server_dir_path).\
|
|
1740
|
-
joinpath('prototypes/sample_ai_iteration') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
|
|
1741
|
-
recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
|
|
1742
|
-
if do_show_messages:
|
|
1743
|
-
log.info("\nNext Step:")
|
|
1744
|
-
log.info(f'..ApiLogicServer rebuild-from-database --project_name=./ --db_url=sqlite:///database/db.sqlite')
|
|
1745
|
-
log.info(".. complete\n")
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
def genai_get_logic(self, prompt: str) -> list[str]: # TODO drop old code
|
|
1749
|
-
""" Get logic from ChatGPT prompt
|
|
1750
|
-
Args:
|
|
1751
|
-
"""
|
|
1752
|
-
|
|
1753
|
-
prompt_array = prompt.split('\n')
|
|
1754
|
-
logic_text = list()
|
|
1755
|
-
line_num = 0
|
|
1756
|
-
logic_lines = 0
|
|
1757
|
-
writing = False
|
|
1758
|
-
for each_line in prompt_array:
|
|
1759
|
-
line_num += 1
|
|
1760
|
-
if "Enforce" in each_line:
|
|
1761
|
-
writing = True
|
|
1762
|
-
elif writing:
|
|
1763
|
-
logic_lines += 1
|
|
1764
|
-
logic_text.append(each_line)
|
|
1765
|
-
return logic_text
|
|
1766
|
-
|
|
1767
1545
|
|
|
1768
1546
|
def tutorial(self, msg: str="", create: str='tutorial'):
|
|
1769
1547
|
"""
|
|
@@ -1816,7 +1594,7 @@ from database import <project.bind_key>_models
|
|
|
1816
1594
|
|
|
1817
1595
|
self.project_name = with_cust
|
|
1818
1596
|
self.command = "add-cust"
|
|
1819
|
-
|
|
1597
|
+
add_cust.add_nw_customizations(project = self, do_show_messages=False, do_security=False)
|
|
1820
1598
|
self.run = save_run # remove logic below
|
|
1821
1599
|
|
|
1822
1600
|
|
|
@@ -1829,7 +1607,7 @@ from database import <project.bind_key>_models
|
|
|
1829
1607
|
|
|
1830
1608
|
self.project_name = with_cust
|
|
1831
1609
|
self.command = "add-cust"
|
|
1832
|
-
|
|
1610
|
+
add_cust.add_nw_customizations(project = self, do_show_messages=False)
|
|
1833
1611
|
self.run = save_run
|
|
1834
1612
|
|
|
1835
1613
|
if create != "tutorial":
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
last_created_date:
|
|
2
|
-
last_created_project_name:
|
|
3
|
-
last_created_version: 14.
|
|
1
|
+
last_created_date: May 15, 2025 12:52:13
|
|
2
|
+
last_created_project_name: ../../../servers/basic_demo
|
|
3
|
+
last_created_version: 14.04.08
|