ApiLogicServer 14.3.25__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.
Files changed (167) hide show
  1. api_logic_server_cli/add_cust/add_cust.py +283 -0
  2. api_logic_server_cli/api_logic_server.py +18 -250
  3. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  4. api_logic_server_cli/cli.py +54 -35
  5. api_logic_server_cli/create_from_model/__pycache__/api_logic_server_utils.cpython-312.pyc +0 -0
  6. api_logic_server_cli/create_from_model/__pycache__/create_db_from_model.cpython-312.pyc +0 -0
  7. api_logic_server_cli/create_from_model/__pycache__/dbml.cpython-312.pyc +0 -0
  8. api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc +0 -0
  9. api_logic_server_cli/create_from_model/__pycache__/ont_create.cpython-312.pyc +0 -0
  10. api_logic_server_cli/create_from_model/api_logic_server_utils.py +47 -0
  11. api_logic_server_cli/create_from_model/create_db_from_model.py +2 -0
  12. api_logic_server_cli/create_from_model/dbml.py +113 -58
  13. api_logic_server_cli/create_from_model/ont_build.py +102 -74
  14. api_logic_server_cli/create_from_model/ont_create.py +7 -6
  15. api_logic_server_cli/create_from_model/safrs-react-admin-npm-build/static/.DS_Store +0 -0
  16. api_logic_server_cli/database/basic_demo.sqlite +0 -0
  17. api_logic_server_cli/database/basic_demo.txt +1 -0
  18. api_logic_server_cli/database/basic_demo_wg.sqlite +0 -0
  19. api_logic_server_cli/database/nw-gold-fix.sql +62 -0
  20. api_logic_server_cli/database/nw-gold.sqlite +0 -0
  21. api_logic_server_cli/{prototypes/manager/webgenai → fragments}/docker-compose.yml +1 -1
  22. api_logic_server_cli/genai/genai.py +42 -11
  23. api_logic_server_cli/genai/genai_graphics.py +252 -38
  24. api_logic_server_cli/genai/genai_svcs.py +20 -12
  25. api_logic_server_cli/manager.py +22 -12
  26. api_logic_server_cli/prototypes/.DS_Store +0 -0
  27. api_logic_server_cli/prototypes/base/.DS_Store +0 -0
  28. api_logic_server_cli/prototypes/base/.vscode/launch.json +22 -2
  29. api_logic_server_cli/prototypes/base/api/expose_api_models.py +3 -1
  30. api_logic_server_cli/prototypes/base/api_logic_server_run.py +5 -2
  31. api_logic_server_cli/prototypes/base/config/activate_logicbank.py +1 -0
  32. api_logic_server_cli/prototypes/base/config/config.py +123 -25
  33. api_logic_server_cli/prototypes/base/config/default.env +7 -1
  34. api_logic_server_cli/prototypes/base/config/logging.yml +1 -0
  35. api_logic_server_cli/prototypes/base/config/server_setup.py +33 -1
  36. api_logic_server_cli/prototypes/base/database/test_data/readme.md +5 -2
  37. api_logic_server_cli/prototypes/base/devops/docker-standard-image/docker-compose-standard-image.yml +7 -2
  38. api_logic_server_cli/prototypes/base/docs/training/logic_bank_api.prompt +314 -0
  39. api_logic_server_cli/prototypes/base/docs/training/logic_example.py +41 -0
  40. api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +12 -5
  41. api_logic_server_cli/prototypes/base/integration/n8n/n8n_producer.py +68 -21
  42. api_logic_server_cli/prototypes/base/integration/n8n/n8n_readme.md +19 -0
  43. api_logic_server_cli/prototypes/base/integration/system/FlaskKafka.py +5 -1
  44. api_logic_server_cli/prototypes/base/test/basic/server_test.py +1 -1
  45. api_logic_server_cli/prototypes/base/ui/templates/bar_chart.jinja +64 -0
  46. api_logic_server_cli/prototypes/basic_demo/README.md +29 -52
  47. api_logic_server_cli/prototypes/basic_demo/customizations/api/.DS_Store +0 -0
  48. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/mcp_server_executor.py +138 -0
  49. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/openapi.py +92 -0
  50. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/proper_update_def.json +71 -0
  51. api_logic_server_cli/prototypes/basic_demo/customizations/config/default.env +13 -0
  52. api_logic_server_cli/prototypes/basic_demo/customizations/database/db.sqlite +0 -0
  53. api_logic_server_cli/prototypes/basic_demo/customizations/database/models.py +131 -0
  54. api_logic_server_cli/prototypes/basic_demo/customizations/integration/.DS_Store +0 -0
  55. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/.DS_Store +0 -0
  56. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/1_langchain_loader.py +71 -0
  57. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/2_gpt_mcp_prompt.txt +19 -0
  58. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/README_mcp.md +13 -0
  59. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_client_executor.py +295 -0
  60. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_schema.txt +47 -0
  61. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_server_discovery.json +9 -0
  62. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/multi_mcp_flow/multi_mcp_flow.png +0 -0
  63. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/multi_mcp_flow/multi_mcp_orchestration.yaml +49 -0
  64. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/multi_mcp_flow/wny mcp flows.png +0 -0
  65. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/natlang_to_api.py +73 -0
  66. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/curl.txt +5 -0
  67. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/images/MCP Overview.png +0 -0
  68. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/images/MCP_Arch.png +0 -0
  69. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/images/MCP_Overview_Executor.png +0 -0
  70. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/invoke_llm/1 - prompt_messages_array.json +10 -0
  71. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/invoke_llm/2 - completion_tool_context.json +12 -0
  72. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/llm_schema.txt +38 -0
  73. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/nw_swagger_2.yaml +17393 -0
  74. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/nw_swagger_3.yaml +16660 -0
  75. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/nw_swagger_3_relaxed.yaml +109 -0
  76. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/proxy_server.py +51 -0
  77. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/proxy_serverZ.py +72 -0
  78. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/resources/validate_jsonapi.py +64 -0
  79. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/run_executor.py +23 -0
  80. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/swagger_converter.py +65 -0
  81. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/z_old/3_executor_test_agent.py +52 -0
  82. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/3_executor_test_agent.py +52 -0
  83. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/README_functon.md +201 -0
  84. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/ai_plugin.json +17 -0
  85. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/nw-swagger_3.json +1731 -0
  86. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/snippets.txt +5 -0
  87. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3 genai_demo_with_get.json +1731 -0
  88. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3.json +1782 -0
  89. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo.json +264 -0
  90. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo_with_update.json +1782 -0
  91. api_logic_server_cli/prototypes/basic_demo/customizations/logic/declare_logic.py +62 -44
  92. api_logic_server_cli/prototypes/basic_demo/customizations/security/declare_security.py +11 -12
  93. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +166 -0
  94. api_logic_server_cli/prototypes/basic_demo/iteration/api/{customize_api.py → api_discovery/order_b2b.py} +17 -23
  95. api_logic_server_cli/prototypes/basic_demo/iteration/database/db.sqlite +0 -0
  96. api_logic_server_cli/prototypes/basic_demo/iteration/integration/row_dict_maps/OrderB2B.py +6 -5
  97. api_logic_server_cli/prototypes/basic_demo/iteration/integration/row_dict_maps/OrderShipping.py +4 -4
  98. api_logic_server_cli/prototypes/basic_demo/iteration/logic/declare_logic.py +69 -43
  99. api_logic_server_cli/prototypes/basic_demo/iteration/ui/admin/admin.yaml +125 -50
  100. api_logic_server_cli/prototypes/genai_demo/ui/admin/admin.yaml +1 -1
  101. api_logic_server_cli/prototypes/manager/README.md +30 -4
  102. api_logic_server_cli/prototypes/manager/README_X.md +663 -0
  103. api_logic_server_cli/prototypes/manager/system/genai/.DS_Store +0 -0
  104. api_logic_server_cli/prototypes/manager/system/genai/examples/.DS_Store +0 -0
  105. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/.DS_Store +0 -0
  106. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.prompt +0 -10
  107. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo.response_example +32 -10
  108. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_docs_logic/docs/002_create_db_models.prompt +4 -4
  109. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_docs_logic/docs/003_create_db_models.response +77 -47
  110. api_logic_server_cli/prototypes/manager/system/genai/examples/genai_demo/genai_demo_informal.prompt +1 -1
  111. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/dashboard_services.jinja +83 -0
  112. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/graphics_dashboard_WIP.py +34 -0
  113. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/{graphics_services.py → graphics_services_api_xxx.py} +0 -9
  114. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/graphics_services_db.jinja +46 -0
  115. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/graphics_services_db_each_method.jinja +36 -0
  116. api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/graphics.prompt +7 -3
  117. api_logic_server_cli/prototypes/manager/system/genai/prompt_inserts/response_format.prompt +8 -1
  118. api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/install-ApiLogicServer-dev.ps1 +100 -0
  119. api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/install-ApiLogicServer-dev.sh +116 -0
  120. api_logic_server_cli/prototypes/manager/system/install-ApiLogicServer-dev/readme.md +7 -0
  121. api_logic_server_cli/prototypes/manager/system/style-guide.yaml +2 -2
  122. api_logic_server_cli/prototypes/manager/webgenai/README.md +6 -0
  123. api_logic_server_cli/prototypes/nw/docs/graphics/count_orders_by_category.prompt +1 -0
  124. api_logic_server_cli/prototypes/nw/docs/graphics/order_count_by_month.prompt +1 -0
  125. api_logic_server_cli/prototypes/nw/docs/graphics/request copy.json +892 -0
  126. api_logic_server_cli/prototypes/nw/docs/graphics/request.json +6 -0
  127. api_logic_server_cli/prototypes/nw/docs/graphics/response.json +17 -0
  128. api_logic_server_cli/prototypes/nw/docs/graphics/response.yaml +59 -0
  129. api_logic_server_cli/prototypes/nw/docs/graphics/sales_by_category.prompt +1 -0
  130. api_logic_server_cli/prototypes/nw/ui/admin/home.js +5 -4
  131. api_logic_server_cli/prototypes/nw/ui/app_model_custom.yaml +851 -1082
  132. api_logic_server_cli/prototypes/nw_no_cust/Tutorial.md +45 -26
  133. api_logic_server_cli/prototypes/nw_no_cust/api/api_discovery/openapi.py +130 -0
  134. api_logic_server_cli/prototypes/nw_no_cust/api/api_discovery/proper_update_def.json +71 -0
  135. api_logic_server_cli/prototypes/nw_no_cust/config/default.env +13 -0
  136. api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/count_orders_by_category.prompt +1 -0
  137. api_logic_server_cli/prototypes/nw_no_cust/docs/graphics/sales_by_employee.prompt +1 -0
  138. api_logic_server_cli/prototypes/ont_app/ontimize_seed/nginx/nginx.conf +2 -2
  139. api_logic_server_cli/prototypes/ont_app/ontimize_seed/package-lock.json +9725 -1180
  140. api_logic_server_cli/prototypes/ont_app/ontimize_seed/package.json +6 -9
  141. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/app/app.config.ts +2 -1
  142. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/app/shared/app.services.config.ts +1 -1
  143. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/css/app.scss +4 -0
  144. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/i18n/en.json +1 -1
  145. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/i18n/es.json +14 -12
  146. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/environments/environment.prod.ts +5 -5
  147. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/environments/environment.ts +5 -5
  148. api_logic_server_cli/prototypes/ont_app/templates/app_config.jinja +1 -1
  149. api_logic_server_cli/prototypes/ont_app/templates/date_template.html +1 -1
  150. api_logic_server_cli/prototypes/ont_app/templates/detail_template.html +1 -1
  151. api_logic_server_cli/prototypes/ont_app/templates/new_template.html +16 -16
  152. api_logic_server_cli/prototypes/ont_app/templates/textarea_template.html +1 -1
  153. api_logic_server_cli/prototypes/ont_app/templates/timestamp_template.html +1 -1
  154. api_logic_server_cli/prototypes/sample_ai/logic/declare_logic.py +30 -13
  155. apilogicserver-14.5.0.dist-info/METADATA +76 -0
  156. {apilogicserver-14.3.25.dist-info → apilogicserver-14.5.0.dist-info}/RECORD +160 -88
  157. {apilogicserver-14.3.25.dist-info → apilogicserver-14.5.0.dist-info}/WHEEL +1 -1
  158. api_logic_server_cli/prototypes/basic_demo/apply_customizations.ps1 +0 -17
  159. api_logic_server_cli/prototypes/basic_demo/apply_customizations.sh +0 -14
  160. api_logic_server_cli/prototypes/basic_demo/apply_iteration.ps1 +0 -20
  161. api_logic_server_cli/prototypes/basic_demo/apply_iteration.sh +0 -15
  162. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/service_template_jsonapi_rpc.jinja +0 -37
  163. api_logic_server_cli/prototypes/manager/system/genai/graphics_templates/service_template_unused.jinja +0 -38
  164. apilogicserver-14.3.25.dist-info/METADATA +0 -167
  165. {apilogicserver-14.3.25.dist-info → apilogicserver-14.5.0.dist-info}/entry_points.txt +0 -0
  166. {apilogicserver-14.3.25.dist-info → apilogicserver-14.5.0.dist-info}/licenses/LICENSE +0 -0
  167. {apilogicserver-14.3.25.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")
@@ -3,7 +3,7 @@
3
3
  '''
4
4
  ApiLogicServer CLI: given a database url, create [and run] customizable ApiLogicProject.
5
5
  * Basically clones prototype project (api_logic_server_cli/prototypes/base), and creates:
6
- * database/models.py for SQLAlchemy,` using modified sqlacodegen & safrs metadata
6
+ * database/models.py for SQLAlchemy, using modified sqlacodegen & safrs metadata
7
7
  * ui/admin/admin.yaml for the Admin App - using introspected models.py
8
8
  * api/expose_api_models.py for a safrs api - using introspected models.py
9
9
  * Special provisions for NW Sample, to show customizations.
@@ -12,26 +12,19 @@ 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.03.25"
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"\
19
+ "\t04/27/2024 - 14.04.00: Graphics preview, Vibe install fix, Improved IDE Chat Logic, MCP Exploration \n"\
18
20
  "\t03/30/2024 - 14.03.25: WebGenAI fixes for Kafka and Keycloak \n"\
19
21
  "\t03/19/2024 - 14.03.20: licensed webgenai docker, [87] sra fix for home.js \n"\
20
22
  "\t02/26/2024 - 14.03.14: [85: reserved words], genai_demo fixes \n"\
21
- "\t02/16/2024 - 14.03.12: Docker w/ std container, mgr assistant for local WebG \n"\
22
- "\t02/13/2024 - 14.03.11: fixes [78: Keycloak, 79: boolean defaulting, 80: Send If missing attribute] \n"\
23
- "\t01/31/2024 - 14.03.00: Issue 76: exp ending in right paren, Issue 74: Multi-db fix, extended default options, if-based Nat Lang formulas \n"\
24
- "\t01/29/2024 - 14.02.34: save docs/response.json to fix bad rules for IS_GENAI_DEMO, LogicBank 1.20.23 (all defaults) \n"\
25
- "\t01/26/2024 - 14.02.31: genai_logic fail-safe, Issue 74: Multi-db fix, support models named Rule, wg logic discovery, if formula \n"\
26
23
  "\t01/17/2024 - 14.02.20: WebGenAI support, genai_demo \n"\
27
24
  "\t01/06/2024 - 14.01.00: N8N, Rebuild test data, Fixup, Project Import, Improved reporting of missing attributes, Simplified RowDictMaper \n"\
28
25
  "\t11/18/2024 - 12.02.00: genai: 'qualified any' now supported in logic training \n"\
29
26
  "\t10/31/2024 - 12.01.00: genai: informal rules (eg, Sum of employee salaries cannot exceed department budget) \n"\
30
- "\t10/21/2024 - 12.00.04: sra 10-22, Prelim support genai --using=dir/project \n"\
31
27
  "\t10/12/2024 - 12.00.02: Natural Language Logic \n"\
32
- "\t10/17/2024 - 11.02.19: singular classes, expanded doc/prompts, logic work-arounds, docs/logic, logic learning, readme \n"\
33
- "\t10/11/2024 - 11.02.14: NL/Logic with test data calcs, sra 10-07-2024, genai-logic, cs, iteration rebuild \n"\
34
- "\t08/02/2024 - 11.00.07: App Model Editor UI rework, docs and fix for kc and export \n"\
35
28
  "\t07/25/2024 - 11.00.00: Keycloak, App Model Editor \n"\
36
29
  "\t03/28/2024 - 10.03.46: Python 3.12, View support, CLI option-names, Keycloak preview \n"\
37
30
  "\t12/19/2023 - 10.00.00: Kafka pub/sub, Fix MySQL CHAR/String, list/hash/set types \n"\
@@ -39,8 +32,6 @@ recent_changes = \
39
32
  "\t09/14/2023 - 09.03.00: Oracle support \n"\
40
33
  "\t06/22/2023 - 09.00.00: Optimistic Locking, safrs 310, SQLAlchemy 2.0.15 \n"\
41
34
  "\t05/01/2023 - 08.03.06: allocation sample \n"\
42
- "\t04/26/2023 - 08.03.00: virt attrs (Issue 56), safrs 3.0.2, readme updates, LogicBank 1.8.4 \n"\
43
- "\t04/13/2023 - 08.02.00: integratedConsole, logic logging (66), table relns fix (65) \n"\
44
35
  "\t02/15/2023 - 08.00.01: Declarative Authorization and Authentication, Werkzeug==2.2.3 \n"\
45
36
  "\t01/06/2023 - 07.00.00: Multi-db, sqlite test dbs, tests run, security prototype, env config \n"\
46
37
 
@@ -70,7 +61,7 @@ import importlib
70
61
  import fnmatch
71
62
  from dotmap import DotMap
72
63
  import api_logic_server_cli.create_from_model.create_db_from_model as create_db_from_model
73
-
64
+ import add_cust.add_cust as add_cust
74
65
 
75
66
  def is_docker() -> bool:
76
67
  """ running docker? dir exists: /home/api_logic_server """
@@ -189,7 +180,7 @@ def delete_dir(dir_path, msg):
189
180
 
190
181
 
191
182
  def recursive_overwrite(src, dest, ignore=None):
192
- """
183
+ """ moving to api_logic_server_utils
193
184
  copyTree, with overwrite
194
185
  thanks: https://stackoverflow.com/questions/12683834/how-to-copy-directory-recursively-in-python-and-overwrite-all
195
186
  """
@@ -344,7 +335,8 @@ def create_project_and_overlay_prototypes(project: 'ProjectRun', msg: str) -> st
344
335
  log.debug(".. ..Copying nw customizations: logic, custom api, readme, tests, admin app")
345
336
  if project.nw_db_status == 'nw':
346
337
  log.error("\n==> System Error: Unexpected customization for nw. Please contact support.\n")
347
- project.add_nw_customizations(do_security=False, do_show_messages=False)
338
+
339
+ add_cust.add_nw_customizations(project=project, do_security=False, do_show_messages=False)
348
340
 
349
341
  if project.nw_db_status in ["nw+"]:
350
342
  log.debug(".. ..Copy in nw+ customizations: readme, perform_customizations")
@@ -535,7 +527,7 @@ def resolve_home(name: str) -> str:
535
527
  return result
536
528
 
537
529
  def fix_nw_datamodel(project_directory: str):
538
- """update sqlite data model for cascade delete, aliases
530
+ """update sqlite data model for cascade delete, aliases -- fixme moving to add_cust
539
531
 
540
532
  Args:
541
533
  project_directory (str): project creation dir
@@ -1229,8 +1221,9 @@ from database import <project.bind_key>_models
1229
1221
  # log.info(".. docs: https://apilogicserver.github.io/Docs/Security-Activation")
1230
1222
 
1231
1223
  config_file = f'{self.project_directory}/config/config.py'
1224
+ env_file = f'{self.project_directory}/config/default.env'
1232
1225
  is_enabled = create_utils.does_file_contain(search_for="SECURITY_ENABLED = True",
1233
- in_file=config_file)
1226
+ in_file=env_file)
1234
1227
  is_sql = create_utils.does_file_contain(search_for="authentication_provider.sql.auth_provider import",
1235
1228
  in_file=config_file)
1236
1229
  was_provider_type = "sql" if is_sql else "keycloak"
@@ -1250,8 +1243,8 @@ from database import <project.bind_key>_models
1250
1243
  if is_enabled:
1251
1244
  log.info(f'\n\n.. ..Disabling security for current provider type: {was_provider_type}\n')
1252
1245
  create_utils.assign_value_to_key_in_file(value=False,
1253
- key=" SECURITY_ENABLED",
1254
- in_file=config_file)
1246
+ key="SECURITY_ENABLED",
1247
+ in_file=env_file)
1255
1248
  else:
1256
1249
  log.info(f'\n.. .. ..No action taken - already disabled for current provider type: {was_provider_type}\n')
1257
1250
  return
@@ -1270,8 +1263,8 @@ from database import <project.bind_key>_models
1270
1263
  log.info("\n.. Authorization is declared in security/declare_security.py")
1271
1264
 
1272
1265
  log.info(f'\n..{provider_note}') # set enabled, provider in config
1273
- create_utils.assign_value_to_key_in_file(in_file=config_file, \
1274
- key=" SECURITY_ENABLED", value=True)
1266
+ create_utils.assign_value_to_key_in_file(in_file=env_file, \
1267
+ key="SECURITY_ENABLED", value=True)
1275
1268
  self.set_provider(from_value=was_provider_type, to_value=self.auth_provider_type, config_file=config_file)
1276
1269
  if self.auth_provider_type == "keycloak":
1277
1270
  use_keycloak =True
@@ -1549,231 +1542,6 @@ from database import <project.bind_key>_models
1549
1542
  create_utils.copy_md(project = self, from_doc_file = "Tutorial-3.md", to_project_file='Tutorial.md')
1550
1543
  # z_copy_md(project = self, from_doc_file="Tutorial-3.md", to_project_file='Tutorial.md')
1551
1544
 
1552
- '''
1553
- samples and demos - simulate customizations - https://apilogicserver.github.io/Docs/Doc-Home/#start-install-samples-training
1554
- 1. nw - sample code
1555
- 2. genai_demo - GenAI (ChatGPT to create model, add rules VSC)
1556
- 3. basic_demo - small db, no GenAI (w/ iteration)
1557
- 4. sample_ai - CoPilot, no GenAI (w/ iteration)
1558
- 5. Tech AI - just an article, no automated customizations...
1559
- '''
1560
-
1561
- def add_genai_customizations(self, do_show_messages: bool = True, do_security: bool = True):
1562
- """ Add customizations to genai (default creation)
1563
-
1564
- 0. Initial: create_project_and_overlay_prototypes() -- minor: just creates the readme
1565
- * When done with genai logic prompt, logic is pre-created (in logic/declare_logic.py)
1566
- 1. Deep copy prototypes/genai_demo (adds logic and security, and custom end point)
1567
-
1568
- WebGenAI DX:
1569
-
1570
- 0. Convention: click the Blue Button
1571
- * Home/Create Project
1572
- * Home/Open App
1573
- * Landing
1574
- * Overview[Manager]/Open
1575
- * Overview/GitHub
1576
- * App Home / Develop --> GitHub
1577
- 0. demo --> codespaces. Where are instructions (what is CS, how do I load/run)?
1578
- 1. Name can be any, iff created with APILOGICPROJECT_IS_GENAI_DEMO
1579
- 2. Bypass duplicate discovery logic iff created with APILOGICPROJECT_IS_GENAI_DEMO
1580
- 3. TODO:
1581
- * cd project
1582
- * als add-cust # add customizations
1583
- * run, and use place b2b order service - end point is not activated.
1584
-
1585
- Args:
1586
- """
1587
-
1588
- log.debug("\n\n==================================================================")
1589
- nw_messages = ""
1590
- do_security = True # other demos can explain security, here just make it work
1591
- if do_security:
1592
- if do_show_messages:
1593
- nw_messages = "Add sample_ai / genai_demo customizations - enabling security"
1594
- self.add_auth(is_nw=True, msg=nw_messages)
1595
-
1596
- # overlay genai_demo := sample_ai + sample_ai_iteration
1597
- nw_path = (self.api_logic_server_dir_path).\
1598
- joinpath('prototypes/genai_demo') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
1599
- recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
1600
-
1601
- if do_show_messages:
1602
- log.info("\nExplore key customization files:")
1603
- log.info(f'..api/customize_api.py')
1604
- log.info(f'..logic/declare_logic.py')
1605
- log.info(f'..security/declare_security.py\n')
1606
- if self.is_tutorial == False:
1607
- log.info(".. all customizations complete\n")
1608
-
1609
-
1610
- def add_nw_customizations(self, do_show_messages: bool = True, do_security: bool = True):
1611
- """ Add customizations to nw (default creation)
1612
-
1613
- 1. Add-sqlite-security (optionally - not used for initial creation)
1614
-
1615
- 2. Deep copy project_prototype_nw (adds logic)
1616
-
1617
- 3. Create readme files: Tutorial (copy_md), api/integration_defs/readme.md
1618
-
1619
- 4. Add database customizations
1620
-
1621
- Args:
1622
- """
1623
-
1624
- log.debug("\n\n==================================================================")
1625
- nw_messages = ""
1626
- if do_security:
1627
- if do_show_messages:
1628
- nw_messages = "Add northwind customizations - enabling security"
1629
- self.add_auth(is_nw=True, msg=nw_messages)
1630
-
1631
- nw_path = (self.api_logic_server_dir_path).\
1632
- joinpath('prototypes/nw') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
1633
- if os.path.isfile(self.project_directory_path.joinpath('ui/admin/admin.yaml')):
1634
- copyfile(src = self.project_directory_path.joinpath('ui/admin/admin.yaml'),
1635
- dst = self.project_directory_path.joinpath('ui/admin/admin_no_customizations.yaml'))
1636
- recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
1637
-
1638
- self.create_nw_tutorial_and_readme()
1639
-
1640
- # z_copy_md(project = self, from_doc_file="Sample-Integration.md", to_project_file='integration/Sample-Integration.md')
1641
- create_utils.copy_md(project = self, from_doc_file = "Sample-Integration.md", to_project_file='integration/Sample-Integration.md')
1642
-
1643
- fix_nw_datamodel(project_directory=self.project_directory)
1644
-
1645
- if do_show_messages:
1646
- log.info("\nExplore key customization files:")
1647
- log.info(f'..api/customize_api.py')
1648
- log.info(f'..database/customize_models.py')
1649
- log.info(f'..logic/declare_logic.py')
1650
- log.info(f'..security/declare_security.py\n')
1651
- if self.is_tutorial == False:
1652
- log.info(".. all customizations complete\n")
1653
-
1654
-
1655
- def add_basic_demo_customizations(self, do_show_messages: bool = True):
1656
- """ Add customizations to basic_demo (default creation)
1657
-
1658
- 1. Deep copy prototypes/basic_demo (adds logic and security)
1659
-
1660
- 2. Create readme files: Sample-AI (copy_md), api/integration_defs/readme.md TODO not done, fix cmts
1661
-
1662
- Args:
1663
- """
1664
-
1665
- log.debug("\n\n==================================================================")
1666
- nw_messages = ""
1667
- do_security = False # disabled - keep clear what "activate security" means for reader
1668
- if do_security:
1669
- if do_show_messages:
1670
- nw_messages = "Add basic_demo customizations - enabling security"
1671
- self.add_auth(is_nw=True, msg=nw_messages)
1672
-
1673
- nw_path = (self.api_logic_server_dir_path).\
1674
- joinpath('prototypes/basic_demo/customizations') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/basic_demo/customizations')
1675
- recursive_overwrite(nw_path, self.project_directory)
1676
-
1677
- if do_show_messages:
1678
- log.info("\nExplore key customization files:")
1679
- log.info(f'..logic/declare_logic.py')
1680
- log.info(f'..security/declare_security.py\n')
1681
- log.info(f'Next Steps: activate security')
1682
- log.info(f'..ApiLogicServer add-auth --db_url=auth')
1683
- if self.is_tutorial == False:
1684
- log.info(".. complete\n")
1685
-
1686
-
1687
- def add_basic_demo_iteration(self, do_show_messages: bool = True, do_security: bool = True):
1688
- """ Iterate data model for basic_demo (default creation)
1689
-
1690
- 1. Deep copy prototypes/basic_demo/iteration (adds db, logic)
1691
-
1692
- Args:
1693
- """
1694
-
1695
- log.debug("\n\n==================================================================")
1696
-
1697
- nw_path = (self.api_logic_server_dir_path).\
1698
- joinpath('prototypes/basic_demo/iteration')
1699
- recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
1700
- if do_show_messages:
1701
- log.info("\nNext Step:")
1702
- log.info(f'..ApiLogicServer rebuild-from-database --db_url=sqlite:///database/db.sqlite')
1703
- log.info(".. complete\n")
1704
-
1705
-
1706
- def add_sample_ai_customizations(self, do_show_messages: bool = True):
1707
- """ Add customizations to sample_ai (default creation)
1708
-
1709
- 1. Deep copy prototypes/sample_ai (adds logic and security)
1710
-
1711
- 2. Create readme files: Sample-AI (copy_md), api/integration_defs/readme.md TODO not done, fix cmts
1712
-
1713
- Args:
1714
- """
1715
-
1716
- log.debug("\n\n==================================================================")
1717
- nw_messages = ""
1718
- do_security = False # disabled - keep clear what "activate security" means for reader
1719
- if do_security:
1720
- if do_show_messages:
1721
- nw_messages = "Add sample_ai customizations - enabling security"
1722
- self.add_auth(is_nw=True, msg=nw_messages)
1723
-
1724
- nw_path = (self.api_logic_server_dir_path).\
1725
- joinpath('prototypes/sample_ai') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
1726
- recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
1727
-
1728
- if do_show_messages:
1729
- log.info("\nExplore key customization files:")
1730
- log.info(f'..api/customize_api.py')
1731
- log.info(f'..logic/declare_logic.py')
1732
- log.info(f'..security/declare_security.py\n')
1733
- log.info(f'Next Steps: activate security')
1734
- log.info(f'..ApiLogicServer add-auth --db_url=auth')
1735
- if self.is_tutorial == False:
1736
- log.info(".. complete\n")
1737
-
1738
-
1739
- def add_sample_ai_iteration(self, do_show_messages: bool = True, do_security: bool = True):
1740
- """ Iterate data model for sample_ai (default creation)
1741
-
1742
- 1. Deep copy prototypes/sample_ai_iteration (adds db, logic)
1743
-
1744
- Args:
1745
- """
1746
-
1747
- log.debug("\n\n==================================================================")
1748
-
1749
- nw_path = (self.api_logic_server_dir_path).\
1750
- joinpath('prototypes/sample_ai_iteration') # PosixPath('/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/ApiLogicServer-src/api_logic_server_cli/prototypes/nw')
1751
- recursive_overwrite(nw_path, self.project_directory) # '/Users/val/dev/ApiLogicServer/ApiLogicServer-dev/org_git/tutorial/1. Instant_Creation'
1752
- if do_show_messages:
1753
- log.info("\nNext Step:")
1754
- log.info(f'..ApiLogicServer rebuild-from-database --project_name=./ --db_url=sqlite:///database/db.sqlite')
1755
- log.info(".. complete\n")
1756
-
1757
-
1758
- def genai_get_logic(self, prompt: str) -> list[str]: # TODO drop old code
1759
- """ Get logic from ChatGPT prompt
1760
- Args:
1761
- """
1762
-
1763
- prompt_array = prompt.split('\n')
1764
- logic_text = list()
1765
- line_num = 0
1766
- logic_lines = 0
1767
- writing = False
1768
- for each_line in prompt_array:
1769
- line_num += 1
1770
- if "Enforce" in each_line:
1771
- writing = True
1772
- elif writing:
1773
- logic_lines += 1
1774
- logic_text.append(each_line)
1775
- return logic_text
1776
-
1777
1545
 
1778
1546
  def tutorial(self, msg: str="", create: str='tutorial'):
1779
1547
  """
@@ -1826,7 +1594,7 @@ from database import <project.bind_key>_models
1826
1594
 
1827
1595
  self.project_name = with_cust
1828
1596
  self.command = "add-cust"
1829
- self.add_nw_customizations(do_show_messages=False, do_security=False)
1597
+ add_cust.add_nw_customizations(project = self, do_show_messages=False, do_security=False)
1830
1598
  self.run = save_run # remove logic below
1831
1599
 
1832
1600
 
@@ -1839,7 +1607,7 @@ from database import <project.bind_key>_models
1839
1607
 
1840
1608
  self.project_name = with_cust
1841
1609
  self.command = "add-cust"
1842
- self.add_nw_customizations(do_show_messages=False)
1610
+ add_cust.add_nw_customizations(project = self, do_show_messages=False)
1843
1611
  self.run = save_run
1844
1612
 
1845
1613
  if create != "tutorial":
@@ -1960,7 +1728,7 @@ from database import <project.bind_key>_models
1960
1728
  ont_creator = OntCreator(project = build.project)
1961
1729
  ont_creator.create_application(show_messages=False)
1962
1730
 
1963
- if False and self.project_directory_path.joinpath('ui/app_model_custom.yaml').exists():
1731
+ if self.project_directory_path.joinpath('ui/app_model_custom.yaml').exists():
1964
1732
  # eg, nw project contains this for demo purposes
1965
1733
  copyfile (src=self.project_directory_path.joinpath('ui/app_model_custom.yaml'),
1966
1734
  dst=self.project_directory_path.joinpath('ui/app/app_model.yaml'))
@@ -1,3 +1,3 @@
1
- last_created_date: March 26, 2025 13:40:07
2
- last_created_project_name: genai_demo
3
- last_created_version: 14.03.22
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