ApiLogicServer 14.4.0__py3-none-any.whl → 14.5.3__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 (95) hide show
  1. api_logic_server_cli/add_cust/add_cust.py +269 -0
  2. api_logic_server_cli/api_logic_server.py +18 -238
  3. api_logic_server_cli/api_logic_server_info.yaml +3 -3
  4. api_logic_server_cli/cli.py +38 -28
  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__/dbml.cpython-312.pyc +0 -0
  7. api_logic_server_cli/create_from_model/__pycache__/ont_build.cpython-312.pyc +0 -0
  8. api_logic_server_cli/create_from_model/__pycache__/ont_create.cpython-312.pyc +0 -0
  9. api_logic_server_cli/create_from_model/api_logic_server_utils.py +47 -0
  10. api_logic_server_cli/create_from_model/dbml.py +113 -58
  11. api_logic_server_cli/create_from_model/ont_build.py +83 -60
  12. api_logic_server_cli/create_from_model/ont_create.py +2 -1
  13. api_logic_server_cli/database/basic_demo.sqlite +0 -0
  14. api_logic_server_cli/database/basic_demo.txt +1 -0
  15. api_logic_server_cli/database/basic_demo_wg.sqlite +0 -0
  16. api_logic_server_cli/manager.py +3 -2
  17. api_logic_server_cli/prototypes/base/.vscode/launch.json +3 -2
  18. api_logic_server_cli/prototypes/base/config/config.py +66 -11
  19. api_logic_server_cli/prototypes/base/config/default.env +7 -1
  20. api_logic_server_cli/prototypes/base/database/test_data/readme.md +2 -1
  21. api_logic_server_cli/prototypes/base/integration/kafka/kafka_producer.py +5 -2
  22. api_logic_server_cli/prototypes/base/integration/n8n/n8n_producer.py +68 -21
  23. api_logic_server_cli/prototypes/base/integration/n8n/n8n_readme.md +19 -0
  24. api_logic_server_cli/prototypes/base/test/basic/server_test.py +1 -1
  25. api_logic_server_cli/prototypes/basic_demo/README.md +29 -52
  26. api_logic_server_cli/prototypes/basic_demo/customizations/api/.DS_Store +0 -0
  27. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/mcp_discovery.py +139 -0
  28. api_logic_server_cli/prototypes/basic_demo/customizations/api/api_discovery/openapi.py +92 -0
  29. api_logic_server_cli/prototypes/basic_demo/customizations/config/default.env +13 -0
  30. api_logic_server_cli/prototypes/basic_demo/customizations/config/server_setup.py +388 -0
  31. api_logic_server_cli/prototypes/basic_demo/customizations/database/db.sqlite +0 -0
  32. api_logic_server_cli/prototypes/basic_demo/customizations/database/models.py +131 -0
  33. api_logic_server_cli/prototypes/basic_demo/customizations/database/system/SAFRSBaseX.py +136 -0
  34. api_logic_server_cli/prototypes/basic_demo/customizations/integration/.DS_Store +0 -0
  35. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/.DS_Store +0 -0
  36. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/README_mcp.md +15 -0
  37. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_client_executor.py +350 -0
  38. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_schema.txt +47 -0
  39. api_logic_server_cli/prototypes/basic_demo/customizations/integration/mcp/mcp_server_discovery.json +9 -0
  40. api_logic_server_cli/prototypes/{nw_no_cust/integration/mcp → basic_demo/customizations/integration/openai_function}/3_executor_test_agent.py +20 -6
  41. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/README_functon.md +201 -0
  42. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/ai_plugin.json +17 -0
  43. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/nw-swagger_3.json +1731 -0
  44. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/snippets.txt +5 -0
  45. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3 genai_demo_with_get.json +1731 -0
  46. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3.json +1782 -0
  47. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo.json +264 -0
  48. api_logic_server_cli/prototypes/basic_demo/customizations/integration/openai_function/swagger_3_genai_demo_with_update.json +1782 -0
  49. api_logic_server_cli/prototypes/basic_demo/customizations/logic/declare_logic.py +79 -41
  50. api_logic_server_cli/prototypes/basic_demo/customizations/security/declare_security.py +11 -12
  51. api_logic_server_cli/prototypes/basic_demo/customizations/ui/admin/admin.yaml +166 -0
  52. api_logic_server_cli/prototypes/basic_demo/iteration/api/{customize_api.py → api_discovery/order_b2b.py} +17 -23
  53. api_logic_server_cli/prototypes/basic_demo/iteration/database/db.sqlite +0 -0
  54. api_logic_server_cli/prototypes/basic_demo/iteration/integration/row_dict_maps/OrderB2B.py +6 -5
  55. api_logic_server_cli/prototypes/basic_demo/iteration/integration/row_dict_maps/OrderShipping.py +4 -4
  56. api_logic_server_cli/prototypes/basic_demo/iteration/logic/declare_logic.py +69 -43
  57. api_logic_server_cli/prototypes/basic_demo/iteration/ui/admin/admin.yaml +125 -50
  58. api_logic_server_cli/prototypes/manager/README.md +4 -0
  59. api_logic_server_cli/prototypes/nw/logic/declare_logic.py +2 -2
  60. api_logic_server_cli/prototypes/nw_no_cust/.obsidian/app.json +1 -0
  61. api_logic_server_cli/prototypes/nw_no_cust/.obsidian/appearance.json +1 -0
  62. api_logic_server_cli/prototypes/nw_no_cust/.obsidian/core-plugins.json +31 -0
  63. api_logic_server_cli/prototypes/nw_no_cust/.obsidian/workspace.json +166 -0
  64. api_logic_server_cli/prototypes/nw_no_cust/Tutorial.md +45 -26
  65. api_logic_server_cli/prototypes/nw_no_cust/api/api_discovery/openapi.py +130 -0
  66. api_logic_server_cli/prototypes/nw_no_cust/api/api_discovery/proper_update_def.json +71 -0
  67. api_logic_server_cli/prototypes/nw_no_cust/config/default.env +13 -0
  68. api_logic_server_cli/prototypes/ont_app/ontimize_seed/package-lock.json +9725 -1180
  69. api_logic_server_cli/prototypes/ont_app/ontimize_seed/package.json +3 -6
  70. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/app/shared/app.services.config.ts +1 -1
  71. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/css/app.scss +4 -0
  72. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/i18n/en.json +1 -1
  73. api_logic_server_cli/prototypes/ont_app/ontimize_seed/src/assets/i18n/es.json +14 -12
  74. api_logic_server_cli/prototypes/ont_app/templates/app_config.jinja +1 -1
  75. api_logic_server_cli/prototypes/ont_app/templates/date_template.html +1 -1
  76. api_logic_server_cli/prototypes/ont_app/templates/textarea_template.html +1 -1
  77. api_logic_server_cli/prototypes/ont_app/templates/timestamp_template.html +1 -1
  78. api_logic_server_cli/prototypes/sample_ai/logic/declare_logic.py +30 -13
  79. apilogicserver-14.5.3.dist-info/METADATA +168 -0
  80. {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.3.dist-info}/RECORD +84 -61
  81. {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.3.dist-info}/WHEEL +1 -1
  82. api_logic_server_cli/prototypes/basic_demo/apply_customizations.ps1 +0 -17
  83. api_logic_server_cli/prototypes/basic_demo/apply_customizations.sh +0 -14
  84. api_logic_server_cli/prototypes/basic_demo/apply_iteration.ps1 +0 -20
  85. api_logic_server_cli/prototypes/basic_demo/apply_iteration.sh +0 -15
  86. api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/1_langchain_loader.py +0 -19
  87. api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/2_gpt_mcp_prompt.txt +0 -19
  88. api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/README.md +0 -17
  89. api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/resources/curl.txt +0 -4
  90. api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/resources/nw_swagger_3.yaml +0 -16660
  91. api_logic_server_cli/prototypes/nw_no_cust/integration/mcp/run_executor.py +0 -23
  92. apilogicserver-14.4.0.dist-info/METADATA +0 -76
  93. {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.3.dist-info}/entry_points.txt +0 -0
  94. {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.3.dist-info}/licenses/LICENSE +0 -0
  95. {apilogicserver-14.4.0.dist-info → apilogicserver-14.5.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,130 @@
1
+ from flask import request, jsonify
2
+ from flask import Flask, redirect, send_from_directory, send_file
3
+ import logging
4
+ import os
5
+ import json
6
+ import io
7
+ from config.config import Args # circular import error if at top
8
+
9
+ app_logger = logging.getLogger("api_logic_server_app")
10
+
11
+ def add_service(app, api, project_dir, swagger_host: str, PORT: str, method_decorators = []):
12
+ pass
13
+
14
+ def get_server_url():
15
+ """ return the server URL for the OpenAPI spec """
16
+ result = f'http://{Args.instance.swagger_host}:{Args.instance.swagger_port}'
17
+ # get env variable API_LOGIC_SERVER_TUNNEL (or None)
18
+ if tunnel_url := os.getenv("API_LOGIC_SERVER_TUNNEL", None):
19
+ app_logger.info(f".. tunnel URL: {tunnel_url}")
20
+ result = tunnel_url
21
+ return result # + '/api'
22
+
23
+
24
+
25
+ @app.before_request
26
+ def before_any_request():
27
+ # print(f"[DEBUG] Incoming request: {request.method} {request.url}")
28
+ if activate_openapi_logging := True:
29
+ if request.content_type == 'application/json' and request.method in ['POST', 'PUT', 'PATCH']:
30
+ # openapi: Incoming request: PATCH http://localhost:5656/api/Customer/1/ {'data': {'attributes': {'credit_limit': 5555}, 'type': 'Customer', 'id': '1'}}
31
+ # openapi: Incoming request: PATCH http://6f6f-2601-644-4900-d6f0-ecc9-6df3-8863-c5b2.ngrok-free.app/api/Customer/1 {'credit_limit': 5555}
32
+
33
+ app_logger.info(f"openapi: Incoming request: {request.method} {request.url} {str(request.json)}")
34
+ else:
35
+ app_logger.info(f"openapi: Incoming request: {request.method} {request.url}")
36
+ # app_logger.info(f"openapi: Incoming request headers: {request.headers}")
37
+
38
+ chatgpt_request_json = {
39
+ "credit_limit": 25000,
40
+ }
41
+ standard_request_json = {
42
+ "data": {
43
+ "type": "Customer",
44
+ "id": "ALFKI",
45
+ "attributes": {
46
+ "name": "Alice",
47
+ "credit_limit": 25000,
48
+ "balance": 12345
49
+ }
50
+ }
51
+ }
52
+ swagger_request_json = {
53
+ 'data': {
54
+ 'attributes': {
55
+ 'credit_limit': 5555
56
+ },
57
+ 'type': 'Customer',
58
+ 'id': '1'
59
+ }
60
+ }
61
+ pass
62
+
63
+ @app.route('/mcp.json')
64
+ def mcp(path=None):
65
+ '''
66
+ test: curl -X GET http://localhost:5656/mcp.json
67
+ '''
68
+
69
+ mcp_json = {
70
+ "name": "MCP genai_demo test",
71
+ "description": "You are an AI Planner + Executor for a live JSON:API server.",
72
+ "instructions": [
73
+ "When a user gives you a natural language goal (e.g., 'list customers from Germany'), you:",
74
+ "Identify the resource (Customer, Order, Product).",
75
+ "Map filters (e.g., Country=Germany).",
76
+ "Construct a JSON:API call to the live endpoint (through a function called fetch_resource).",
77
+ "Execute the live API call through the function.",
78
+ "Format and display the results neatly."
79
+ ],
80
+ "serverUrl": "http://localhost:5656/api",
81
+ "openapiUrl": "http://localhost:5656/api/openapi.json",
82
+ "apiStandard": "JSON:API (application/vnd.api+json)"
83
+ }
84
+ mcp_json["serverUrl"] = get_server_url() + '/api'
85
+ mcp_json["openapiUrl"] = get_server_url() + '/api/openapi.json'
86
+ # return jsonify(mcp), 200, {'Content-Type': 'text/plain; charset=utf-8'}
87
+ return jsonify(mcp_json), 200, {'Content-Type': 'application/json; charset=utf-8'}
88
+
89
+
90
+ @app.route('/api/openapi.json')
91
+ def openapi(path=None):
92
+ """ return integration/openai_plugin/swagger_3.json
93
+ * with updated tunnel URL if API_LOGIC_SERVER_TUNNEL is set
94
+
95
+ test: curl -X GET http://localhost:5656/api/openapi.json
96
+ like: curl -X GET http://localhost:5656/api/swagger.json
97
+ """
98
+
99
+ # read dict from json file integration/openai_plugin/swagger_3.json
100
+ with open("integration/openai_function/swagger_3.json", "r") as json_file:
101
+ swagger_dict = json.load(json_file)
102
+ app_logger.info(f"openapi: Swagger JSON loaded: {swagger_dict}")
103
+
104
+ server_url = get_server_url()
105
+ swagger_dict["servers"][0]["url"] = server_url + '/api'
106
+
107
+ # convert dict to buffered stream
108
+ swagger_dict_mem = io.BytesIO(json.dumps(swagger_dict).encode('utf-8'))
109
+ return send_file(swagger_dict_mem, mimetype='text/json')
110
+
111
+
112
+ @app.route('/api/ai_plugin')
113
+ def ai_plugin(path=None):
114
+ """ return integration/openai_plugin/ai_plugin.json (disparaged)
115
+ * with updated tunnel URL if API_LOGIC_SERVER_TUNNEL is set
116
+
117
+ test: curl -X GET http://localhost:5656/api/ai_plugin
118
+ """
119
+
120
+ # read dict from json file integration/openai_plugin/swagger_3.json
121
+ with open("integration/openai_plugin/ai_plugin.json", "r") as json_file:
122
+ swagger_dict = json.load(json_file)
123
+ app_logger.info(f"openapi: ai_plugin JSON loaded: {swagger_dict}")
124
+
125
+ server_url = get_server_url()
126
+ swagger_dict["servers"][0]["url"] = server_url
127
+
128
+ # convert dict to buffered stream
129
+ swagger_dict_mem = io.BytesIO(json.dumps(swagger_dict).encode('utf-8'))
130
+ return send_file(swagger_dict_mem, mimetype='text/json')
@@ -0,0 +1,71 @@
1
+ {
2
+ "/Customer/{id}": {
3
+ "patch": {
4
+ "summary": "Update Customer by ID",
5
+ "operationId": "updateCustomer",
6
+ "parameters": [
7
+ {
8
+ "name": "id",
9
+ "in": "path",
10
+ "required": true,
11
+ "schema": {
12
+ "type": "string"
13
+ }
14
+ }
15
+ ],
16
+ "requestBody": {
17
+ "required": true,
18
+ "content": {
19
+ "application/vnd.api+json": {
20
+ "schema": {
21
+ "type": "object",
22
+ "required": ["data"],
23
+ "properties": {
24
+ "data": {
25
+ "type": "object",
26
+ "required": ["type", "id", "attributes"],
27
+ "properties": {
28
+ "type": {
29
+ "type": "string",
30
+ "enum": ["Customer"]
31
+ },
32
+ "id": {
33
+ "type": "string"
34
+ },
35
+ "attributes": {
36
+ "type": "object",
37
+ "properties": {
38
+ "name": {
39
+ "type": "string"
40
+ },
41
+ "credit_limit": {
42
+ "type": "number"
43
+ },
44
+ "balance": {
45
+ "type": "number"
46
+ }
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
52
+ }
53
+ }
54
+ }
55
+ },
56
+ "responses": {
57
+ "200": {
58
+ "description": "Customer updated",
59
+ "content": {
60
+ "application/vnd.api+json": {
61
+ "schema": {
62
+ "type": "object"
63
+ }
64
+ }
65
+ }
66
+ }
67
+ }
68
+ }
69
+ }
70
+ }
71
+
@@ -0,0 +1,13 @@
1
+ SECRET_KEY = "whatnothow"
2
+ SQLALCHEMY_TRACK_MODIFICATIONS = False
3
+ SQLAlCHEMY_ECHO = False
4
+ # AGGREGATE_DEFAULTS = True
5
+ # ALL_DEFAULTS = True
6
+ # APILOGICPROJECT_KAFKA_PRODUCER = "{\"bootstrap.servers\": \"localhost:9092\"}"
7
+ # SQLALCHEMY_DATABASE_URI=db.sqlite
8
+
9
+ SECURITY_ENABLED = false
10
+
11
+ # if using tunnel for mcp, function, or ai_plugin
12
+ # eg, https://tunnel_url.ngrok-free.app
13
+ API_LOGIC_SERVER_TUNNEL = "TUNNEL_URL"