arpakitlib 1.7.257__py3-none-any.whl → 1.8.1__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 (294) hide show
  1. arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/README.md +1 -1
  2. arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic/env.py +3 -3
  3. arpakitlib/_arpakit_project_template_v_1/api/asgi.py +3 -0
  4. arpakitlib/_arpakit_project_template_v_1/api/auth.py +235 -0
  5. arpakitlib/_arpakit_project_template_v_1/api/const.py +18 -0
  6. arpakitlib/_arpakit_project_template_v_1/api/create_api_app.py +71 -0
  7. arpakitlib/_arpakit_project_template_v_1/api/event.py +74 -0
  8. arpakitlib/_arpakit_project_template_v_1/api/exception.py +38 -0
  9. arpakitlib/_arpakit_project_template_v_1/api/exception_handler.py +308 -0
  10. arpakitlib/_arpakit_project_template_v_1/api/openapi_ui.py +28 -0
  11. arpakitlib/_arpakit_project_template_v_1/api/response.py +31 -0
  12. arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/api/router/main_router.py +4 -3
  13. arpakitlib/_arpakit_project_template_v_1/api/router/v1/arpakit_project_template.py +22 -0
  14. arpakitlib/_arpakit_project_template_v_1/api/router/v1/check_auth.py +30 -0
  15. arpakitlib/_arpakit_project_template_v_1/api/router/v1/clear_log_file.py +25 -0
  16. arpakitlib/_arpakit_project_template_v_1/api/router/v1/get_errors_info.py +24 -0
  17. arpakitlib/_arpakit_project_template_v_1/api/router/v1/get_log_file.py +23 -0
  18. arpakitlib/_arpakit_project_template_v_1/api/router/v1/healthcheck.py +21 -0
  19. arpakitlib/_arpakit_project_template_v_1/api/router/v1/main_router.py +67 -0
  20. arpakitlib/_arpakit_project_template_v_1/api/router/v1/now_utc_datetime.py +21 -0
  21. arpakitlib/_arpakit_project_template_v_1/api/router/v1/raise_fake_error.py +35 -0
  22. arpakitlib/_arpakit_project_template_v_1/api/schema/base_schema.py +26 -0
  23. arpakitlib/_arpakit_project_template_v_1/api/schema/common/in_.py +5 -0
  24. arpakitlib/_arpakit_project_template_v_1/api/schema/common/out.py +60 -0
  25. arpakitlib/_arpakit_project_template_v_1/api/schema/v1/in_.py +5 -0
  26. arpakitlib/_arpakit_project_template_v_1/api/schema/v1/out.py +47 -0
  27. arpakitlib/_arpakit_project_template_v_1/arpakitlib_project_template.json +3 -0
  28. arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/business_service/hello_world.py +1 -1
  29. arpakitlib/_arpakit_project_template_v_1/business_service/remove_operations.py +51 -0
  30. arpakitlib/_arpakit_project_template_v_1/command/alembic_history.sh +2 -0
  31. arpakitlib/_arpakit_project_template_v_1/command/alembic_revision_autogenerate.sh +2 -0
  32. arpakitlib/{_arpakit_project_template/manage/json_beautify.py → _arpakit_project_template_v_1/command/beautify_json.py} +2 -2
  33. arpakitlib/{_arpakit_project_template/src/core/_check_logging.py → _arpakit_project_template_v_1/command/check_logging.py} +3 -3
  34. arpakitlib/_arpakit_project_template_v_1/command/check_sqlalchemy_db.py +11 -0
  35. arpakitlib/_arpakit_project_template_v_1/command/drop_json_db.py +13 -0
  36. arpakitlib/_arpakit_project_template_v_1/command/drop_sqlalchemy_db.py +14 -0
  37. arpakitlib/{_arpakit_project_template/src/core/_generate_settings_env_example.py → _arpakit_project_template_v_1/command/generate_settings_env_example.py} +4 -4
  38. arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/hello_world.py +2 -2
  39. arpakitlib/_arpakit_project_template_v_1/command/init_json_db.py +11 -0
  40. arpakitlib/_arpakit_project_template_v_1/command/init_sqlalchemy_db.py +11 -0
  41. arpakitlib/_arpakit_project_template_v_1/command/reinit_json_db.py +13 -0
  42. arpakitlib/_arpakit_project_template_v_1/command/reinit_sqlalchemy_db.py +13 -0
  43. arpakitlib/_arpakit_project_template_v_1/command/remove_operations.py +13 -0
  44. arpakitlib/_arpakit_project_template_v_1/command/remove_story_logs.py +16 -0
  45. arpakitlib/_arpakit_project_template_v_1/command/rm_all_records_in_json_db.py +13 -0
  46. arpakitlib/{_arpakit_project_template/src/core/_show_settings.py → _arpakit_project_template_v_1/command/show_settings.py} +3 -3
  47. arpakitlib/{_arpakit_project_template/src/api/_start_api_with_reload.py → _arpakit_project_template_v_1/command/start_api_with_reload.py} +5 -5
  48. arpakitlib/{_arpakit_project_template/src/api/_start_api_without_reload.py → _arpakit_project_template_v_1/command/start_api_without_reload.py} +5 -5
  49. arpakitlib/_arpakit_project_template_v_1/command/start_async_operation_executor_worker.py +14 -0
  50. arpakitlib/_arpakit_project_template_v_1/command/start_async_scheduled_operation_creator_worker.py +14 -0
  51. arpakitlib/_arpakit_project_template_v_1/command/start_sync_operation_executor_worker.py +15 -0
  52. arpakitlib/_arpakit_project_template_v_1/command/start_sync_operation_executor_workers.py +22 -0
  53. arpakitlib/_arpakit_project_template_v_1/command/start_sync_scheduled_operation_creator_worker.py +12 -0
  54. arpakitlib/_arpakit_project_template_v_1/core/cache_file_storage_in_dir.py +23 -0
  55. arpakitlib/_arpakit_project_template_v_1/core/const.py +33 -0
  56. arpakitlib/_arpakit_project_template_v_1/core/dump_file_storage_in_dir.py +23 -0
  57. arpakitlib/_arpakit_project_template_v_1/core/jinja2_templates.py +14 -0
  58. arpakitlib/_arpakit_project_template_v_1/core/media_file_storage_in_dir.py +23 -0
  59. arpakitlib/_arpakit_project_template_v_1/core/settings.py +195 -0
  60. arpakitlib/_arpakit_project_template_v_1/core/util.py +29 -0
  61. arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/example.env +13 -7
  62. arpakitlib/_arpakit_project_template_v_1/json_db/json_db.py +28 -0
  63. arpakitlib/_arpakit_project_template_v_1/operation_execution/operation_executor_worker.py +256 -0
  64. arpakitlib/_arpakit_project_template_v_1/operation_execution/scheduled_operation_creator_worker.py +106 -0
  65. arpakitlib/_arpakit_project_template_v_1/operation_execution/scheduled_operations.py +49 -0
  66. arpakitlib/_arpakit_project_template_v_1/operation_execution/util.py +29 -0
  67. arpakitlib/_arpakit_project_template_v_1/resource/static/openapi-favicon.png +0 -0
  68. arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/index.html +19 -0
  69. arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-bundle.js +2 -0
  70. arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-es-bundle-core.js +1 -1
  71. arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-es-bundle-core.js.map +1 -0
  72. arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-es-bundle.js +2 -0
  73. arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui-standalone-preset.js +2 -0
  74. arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui.js +1 -1
  75. arpakitlib/_arpakit_project_template_v_1/resource/static/swagger-ui/swagger-ui.js.map +1 -0
  76. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_1.py +14 -0
  77. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_2.py +14 -0
  78. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_3.py +14 -0
  79. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_4.py +14 -0
  80. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_5.py +14 -0
  81. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_6.py +14 -0
  82. arpakitlib/_arpakit_project_template_v_1/sandbox/sandbox_7.py +14 -0
  83. arpakitlib/_arpakit_project_template_v_1/site/router/main_router.py +3 -0
  84. arpakitlib/_arpakit_project_template_v_1/sqladmin_/add_admin_in_app.py +24 -0
  85. arpakitlib/_arpakit_project_template_v_1/sqladmin_/admin_auth.py +54 -0
  86. arpakitlib/_arpakit_project_template_v_1/sqladmin_/model_view.py +95 -0
  87. arpakitlib/_arpakit_project_template_v_1/sqlalchemy_db/sqlalchemy_db.py +22 -0
  88. arpakitlib/_arpakit_project_template_v_1/sqlalchemy_db/sqlalchemy_model.py +129 -0
  89. arpakitlib/_arpakit_project_template_v_1/sqlalchemy_db/util.py +28 -0
  90. arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_3.py → _arpakit_project_template_v_1/test_data/make_test_data_1.py} +8 -3
  91. arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_4.py → _arpakit_project_template_v_1/test_data/make_test_data_2.py} +8 -3
  92. arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_1.py → _arpakit_project_template_v_1/test_data/make_test_data_3.py} +8 -3
  93. arpakitlib/{_arpakit_project_template/src/sandbox/sandbox_2.py → _arpakit_project_template_v_1/test_data/make_test_data_4.py} +8 -3
  94. arpakitlib/_arpakit_project_template_v_1/test_data/make_test_data_5.py +22 -0
  95. arpakitlib/_arpakit_project_template_v_1/tg_bot/blank/blank.py +5 -0
  96. arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/blank/util.py +1 -1
  97. arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/const.py +6 -3
  98. arpakitlib/_arpakit_project_template_v_1/tg_bot/event.py +51 -0
  99. arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/filter/not_prod_mode.py +1 -1
  100. arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/tg_bot/filter/prod_mode.py +1 -1
  101. arpakitlib/_arpakit_project_template_v_1/tg_bot/kb/static_/__init__.py +0 -0
  102. arpakitlib/_arpakit_project_template_v_1/tg_bot/kb/static_/common.py +0 -0
  103. arpakitlib/_arpakit_project_template_v_1/tg_bot/middleware/__init__.py +0 -0
  104. arpakitlib/_arpakit_project_template_v_1/tg_bot/middleware/init_user.py +24 -0
  105. arpakitlib/_arpakit_project_template_v_1/tg_bot/middleware/middleware.py +12 -0
  106. arpakitlib/_arpakit_project_template_v_1/tg_bot/router/__init__.py +0 -0
  107. arpakitlib/_arpakit_project_template_v_1/tg_bot/router/arpakitlib_.py +10 -0
  108. arpakitlib/_arpakit_project_template_v_1/tg_bot/router/error.py +15 -0
  109. arpakitlib/_arpakit_project_template_v_1/tg_bot/router/healthcheck.py +10 -0
  110. arpakitlib/_arpakit_project_template_v_1/tg_bot/router/main_router.py +14 -0
  111. arpakitlib/_arpakit_project_template_v_1/tg_bot/start_tg_bot.py +34 -0
  112. arpakitlib/_arpakit_project_template_v_1/tg_bot/tg_bot.py +24 -0
  113. arpakitlib/_arpakit_project_template_v_1/tg_bot/tg_bot_dispatcher.py +19 -0
  114. arpakitlib/_arpakit_project_template_v_1/tg_bot/transmitted_tg_data.py +58 -0
  115. arpakitlib/_arpakit_project_template_v_1/tg_bot/util.py +0 -0
  116. arpakitlib/_arpakit_project_template_v_1/util/__init__.py +0 -0
  117. arpakitlib/_arpakit_project_template_v_1/util/read_arpakitlib_project_template_file.py +17 -0
  118. arpakitlib/ar_aiogram_util.py +41 -52
  119. arpakitlib/ar_arpakit_project_template_util.py +5 -11
  120. arpakitlib/ar_arpakitlib_cli_util.py +8 -2
  121. arpakitlib/ar_base_worker_util.py +35 -17
  122. arpakitlib/ar_class_util.py +11 -0
  123. arpakitlib/ar_func_util.py +19 -29
  124. arpakitlib/ar_http_request_util.py +10 -2
  125. arpakitlib/ar_rat_func_util.py +1 -1
  126. arpakitlib/ar_retry_func_util.py +4 -4
  127. arpakitlib/ar_schedule_uust_api_client_util.py +1 -1
  128. arpakitlib/ar_settings_util.py +3 -204
  129. arpakitlib/ar_sqladmin_util.py +7 -102
  130. arpakitlib/ar_sqlalchemy_util.py +65 -13
  131. arpakitlib/ar_type_util.py +0 -2
  132. {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.dist-info}/METADATA +5 -3
  133. arpakitlib-1.8.1.dist-info/RECORD +261 -0
  134. {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.dist-info}/WHEEL +1 -1
  135. arpakitlib/_arpakit_project_template/ARPAKITLIB +0 -1
  136. arpakitlib/_arpakit_project_template/manage/docker_ps.sh +0 -2
  137. arpakitlib/_arpakit_project_template/manage/git_branch.sh +0 -2
  138. arpakitlib/_arpakit_project_template/manage/poetry_add_plugin_export.sh +0 -2
  139. arpakitlib/_arpakit_project_template/manage/poetry_config_virtualenvs_in_project_true.sh +0 -2
  140. arpakitlib/_arpakit_project_template/manage/poetry_self_add_plugin_export.sh +0 -2
  141. arpakitlib/_arpakit_project_template/src/admin1/add_admin_in_app.py +0 -32
  142. arpakitlib/_arpakit_project_template/src/admin1/admin_auth.py +0 -29
  143. arpakitlib/_arpakit_project_template/src/admin1/model_view.py +0 -1
  144. arpakitlib/_arpakit_project_template/src/api/asgi.py +0 -3
  145. arpakitlib/_arpakit_project_template/src/api/auth.py +0 -53
  146. arpakitlib/_arpakit_project_template/src/api/const.py +0 -13
  147. arpakitlib/_arpakit_project_template/src/api/create_api_app.py +0 -43
  148. arpakitlib/_arpakit_project_template/src/api/create_handle_exception_.py +0 -59
  149. arpakitlib/_arpakit_project_template/src/api/event.py +0 -83
  150. arpakitlib/_arpakit_project_template/src/api/router/v1/get_api_error_info.py +0 -27
  151. arpakitlib/_arpakit_project_template/src/api/router/v1/main_router.py +0 -15
  152. arpakitlib/_arpakit_project_template/src/api/schema/v1/in_.py +0 -1
  153. arpakitlib/_arpakit_project_template/src/api/schema/v1/out.py +0 -1
  154. arpakitlib/_arpakit_project_template/src/api/transmitted_api_data.py +0 -7
  155. arpakitlib/_arpakit_project_template/src/api/util.py +0 -44
  156. arpakitlib/_arpakit_project_template/src/core/const.py +0 -41
  157. arpakitlib/_arpakit_project_template/src/core/settings.py +0 -21
  158. arpakitlib/_arpakit_project_template/src/core/util.py +0 -61
  159. arpakitlib/_arpakit_project_template/src/json_db/_drop_json_db.py +0 -13
  160. arpakitlib/_arpakit_project_template/src/json_db/_init_json_db.py +0 -11
  161. arpakitlib/_arpakit_project_template/src/json_db/_reinit_json_db.py +0 -13
  162. arpakitlib/_arpakit_project_template/src/json_db/_rm_all_records_in_json_db.py +0 -13
  163. arpakitlib/_arpakit_project_template/src/json_db/json_db.py +0 -11
  164. arpakitlib/_arpakit_project_template/src/json_db/util.py +0 -17
  165. arpakitlib/_arpakit_project_template/src/just_script/example.py +0 -16
  166. arpakitlib/_arpakit_project_template/src/operation_execution/_start_operation_executor_worker.py +0 -17
  167. arpakitlib/_arpakit_project_template/src/operation_execution/_start_scheduled_operation_creator_worker.py +0 -17
  168. arpakitlib/_arpakit_project_template/src/operation_execution/const.py +0 -9
  169. arpakitlib/_arpakit_project_template/src/operation_execution/operation_executor.py +0 -16
  170. arpakitlib/_arpakit_project_template/src/operation_execution/scheduled_operations.py +0 -29
  171. arpakitlib/_arpakit_project_template/src/operation_execution/util.py +0 -1
  172. arpakitlib/_arpakit_project_template/src/sandbox/sandbox_5.py +0 -17
  173. arpakitlib/_arpakit_project_template/src/sandbox/sandbox_6.py +0 -17
  174. arpakitlib/_arpakit_project_template/src/sandbox/sandbox_7.py +0 -17
  175. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_check_conn_sqlalchemy_db.py +0 -11
  176. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_drop_sqlalchemy_db.py +0 -13
  177. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_init_sqlalchemy_db.py +0 -11
  178. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_reinit_sqlalchemy_db.py +0 -13
  179. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_remove_operations.py +0 -15
  180. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/_remove_story_logs.py +0 -16
  181. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/sqlalchemy_model.py +0 -13
  182. arpakitlib/_arpakit_project_template/src/sqlalchemy_db/util.py +0 -27
  183. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_1.py +0 -8
  184. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_2.py +0 -8
  185. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_3.py +0 -8
  186. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_4.py +0 -8
  187. arpakitlib/_arpakit_project_template/src/test_data/make_test_data_5.py +0 -8
  188. arpakitlib/_arpakit_project_template/src/tg_bot/blank/blank.py +0 -10
  189. arpakitlib/_arpakit_project_template/src/tg_bot/event.py +0 -39
  190. arpakitlib/_arpakit_project_template/src/tg_bot/router/error.py +0 -3
  191. arpakitlib/_arpakit_project_template/src/tg_bot/router/router.py +0 -7
  192. arpakitlib/_arpakit_project_template/src/tg_bot/start_tg_bot.py +0 -11
  193. arpakitlib/_arpakit_project_template/src/tg_bot/transmitted_tg_data.py +0 -6
  194. arpakitlib/_arpakit_project_template/src/tg_bot/util.py +0 -44
  195. arpakitlib/ar_api_key_util.py +0 -21
  196. arpakitlib/ar_fastapi_static/swagger-ui/index.html +0 -19
  197. arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-bundle.js +0 -2
  198. arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-es-bundle-core.js.map +0 -1
  199. arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-es-bundle.js +0 -2
  200. arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui-standalone-preset.js +0 -2
  201. arpakitlib/ar_fastapi_static/swagger-ui/swagger-ui.js.map +0 -1
  202. arpakitlib/ar_fastapi_util.py +0 -862
  203. arpakitlib/ar_operation_execution_util.py +0 -504
  204. arpakitlib/ar_sqlalchemy_model_util.py +0 -183
  205. arpakitlib-1.7.257.dist-info/RECORD +0 -236
  206. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/.gitignore +0 -0
  207. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/.python-version +0 -0
  208. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/LICENSE +0 -0
  209. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/additional_model}/__init__.py +0 -0
  210. /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/additional_model/additional_model.py +0 -0
  211. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic/README +0 -0
  212. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic/script.py.mako +0 -0
  213. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/alembic.ini +0 -0
  214. /arpakitlib/{_arpakit_project_template/manage/note → _arpakit_project_template_v_1/api}/__init__.py +0 -0
  215. /arpakitlib/{_arpakit_project_template/resource → _arpakit_project_template_v_1/api/router}/__init__.py +0 -0
  216. /arpakitlib/{_arpakit_project_template/resource/static → _arpakit_project_template_v_1/api/router/v1}/__init__.py +0 -0
  217. /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1/api/schema}/__init__.py +0 -0
  218. /arpakitlib/{_arpakit_project_template/src/additional_model → _arpakit_project_template_v_1/api/schema/common}/__init__.py +0 -0
  219. /arpakitlib/{_arpakit_project_template/src/admin1 → _arpakit_project_template_v_1/api/schema/v1}/__init__.py +0 -0
  220. /arpakitlib/{_arpakit_project_template/manage/note/note_1.txt → _arpakit_project_template_v_1/api/util.py} +0 -0
  221. /arpakitlib/{_arpakit_project_template/src/api → _arpakit_project_template_v_1/business_service}/__init__.py +0 -0
  222. /arpakitlib/{_arpakit_project_template/src/api/router → _arpakit_project_template_v_1/celery_}/__init__.py +0 -0
  223. /arpakitlib/{_arpakit_project_template/src/api/router/v1 → _arpakit_project_template_v_1/command}/__init__.py +0 -0
  224. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/alembic_upgrade_head .sh +0 -0
  225. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_ps_a.sh +0 -0
  226. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_rm_postgres.sh +0 -0
  227. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_run_postgres.sh +0 -0
  228. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_start_postgres.sh +0 -0
  229. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/docker_stop_postgres.sh +0 -0
  230. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_commit.sh +0 -0
  231. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_company_github_1.sh +0 -0
  232. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_company_gitlab_1.sh +0 -0
  233. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_github_1.sh +0 -0
  234. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_push_arpakit_gitlab_1.sh +0 -0
  235. /arpakitlib/{_arpakit_project_template/manage/git_remote_v.sh → _arpakit_project_template_v_1/command/git_remote.sh} +0 -0
  236. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_set_arpakit_company_origin.sh +0 -0
  237. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_set_arpakit_origin.sh +0 -0
  238. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/git_status.sh +0 -0
  239. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_check.sh +0 -0
  240. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_clear_cache.sh +0 -0
  241. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_config.sh +0 -0
  242. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_install.sh +0 -0
  243. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_lock.sh +0 -0
  244. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_remove_and_add_arpakitlib.sh +0 -0
  245. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_show.sh +0 -0
  246. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_show_arpakitlib.sh +0 -0
  247. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_update.sh +0 -0
  248. /arpakitlib/{_arpakit_project_template/manage → _arpakit_project_template_v_1/command}/poetry_update_arpakitlib.sh +0 -0
  249. /arpakitlib/{_arpakit_project_template/src/api/schema → _arpakit_project_template_v_1/core}/__init__.py +0 -0
  250. /arpakitlib/{_arpakit_project_template/src/api/schema/v1 → _arpakit_project_template_v_1/json_db}/__init__.py +0 -0
  251. /arpakitlib/{_arpakit_project_template/src/business_service → _arpakit_project_template_v_1/note}/__init__.py +0 -0
  252. /arpakitlib/{_arpakit_project_template/manage/note/note_2.txt → _arpakit_project_template_v_1/note/note_1.txt} +0 -0
  253. /arpakitlib/{_arpakit_project_template/manage/note/note_3.txt → _arpakit_project_template_v_1/note/note_2.txt} +0 -0
  254. /arpakitlib/{_arpakit_project_template/manage/note/note_4.txt → _arpakit_project_template_v_1/note/note_3.txt} +0 -0
  255. /arpakitlib/{_arpakit_project_template/manage/note/note_5.txt → _arpakit_project_template_v_1/note/note_4.txt} +0 -0
  256. /arpakitlib/{_arpakit_project_template/src/core/__init__.py → _arpakit_project_template_v_1/note/note_5.txt} +0 -0
  257. /arpakitlib/{_arpakit_project_template/src/json_db → _arpakit_project_template_v_1/operation_execution}/__init__.py +0 -0
  258. /arpakitlib/{_arpakit_project_template/src/just_script/__init__.py → _arpakit_project_template_v_1/operation_execution/const.py} +0 -0
  259. /arpakitlib/{_arpakit_project_template/src/operation_execution → _arpakit_project_template_v_1/resource}/__init__.py +0 -0
  260. /arpakitlib/{_arpakit_project_template/resource/static/healthcheck → _arpakit_project_template_v_1/resource/static/1} +0 -0
  261. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/healthcheck +0 -0
  262. /arpakitlib/{_arpakit_project_template → _arpakit_project_template_v_1}/resource/static/helloworld +0 -0
  263. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/redoc/redoc.standalone.js +0 -0
  264. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/favicon-16x16.png +0 -0
  265. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/favicon-32x32.png +0 -0
  266. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/index.css +0 -0
  267. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/oauth2-redirect.html +0 -0
  268. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-initializer.js +0 -0
  269. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-bundle.js.map +0 -0
  270. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-es-bundle.js.map +0 -0
  271. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui-standalone-preset.js.map +0 -0
  272. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui.css +0 -0
  273. /arpakitlib/{ar_fastapi_static → _arpakit_project_template_v_1/resource/static}/swagger-ui/swagger-ui.css.map +0 -0
  274. /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/sandbox/__init__.py +0 -0
  275. /arpakitlib/{_arpakit_project_template/src/sqlalchemy_db → _arpakit_project_template_v_1/site}/__init__.py +0 -0
  276. /arpakitlib/{_arpakit_project_template/src/test_data/__init__.py → _arpakit_project_template_v_1/site/asgi.py} +0 -0
  277. /arpakitlib/{_arpakit_project_template/src/tg_bot/__init__.py → _arpakit_project_template_v_1/site/consts.py} +0 -0
  278. /arpakitlib/{_arpakit_project_template/src/tg_bot/blank/__init__.py → _arpakit_project_template_v_1/site/create_site_app.py} +0 -0
  279. /arpakitlib/{_arpakit_project_template/src/tg_bot/filter/__init__.py → _arpakit_project_template_v_1/site/event.py} +0 -0
  280. /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/__init__.py → _arpakit_project_template_v_1/site/exception_handler.py} +0 -0
  281. /arpakitlib/{_arpakit_project_template/src/tg_bot/kb → _arpakit_project_template_v_1/site/router}/__init__.py +0 -0
  282. /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/inline_ → _arpakit_project_template_v_1/sqladmin_}/__init__.py +0 -0
  283. /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/static_ → _arpakit_project_template_v_1/sqlalchemy_db}/__init__.py +0 -0
  284. /arpakitlib/{_arpakit_project_template/src → _arpakit_project_template_v_1}/sqlalchemy_db/const.py +0 -0
  285. /arpakitlib/{_arpakit_project_template/src/tg_bot/middleware → _arpakit_project_template_v_1/test_data}/__init__.py +0 -0
  286. /arpakitlib/{_arpakit_project_template/src/tg_bot/router → _arpakit_project_template_v_1/tg_bot}/__init__.py +0 -0
  287. /arpakitlib/{_arpakit_project_template/src/util → _arpakit_project_template_v_1/tg_bot/blank}/__init__.py +0 -0
  288. /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/cmd_arpakitlib.py → _arpakit_project_template_v_1/tg_bot/filter/__init__.py} +0 -0
  289. /arpakitlib/{_arpakit_project_template/src/tg_bot/handler/cmd_healthcheck.py → _arpakit_project_template_v_1/tg_bot/kb/__init__.py} +0 -0
  290. /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/inline_/callback.py → _arpakit_project_template_v_1/tg_bot/kb/inline_/__init__.py} +0 -0
  291. /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/inline_/common.py → _arpakit_project_template_v_1/tg_bot/kb/inline_/callback.py} +0 -0
  292. /arpakitlib/{_arpakit_project_template/src/tg_bot/kb/static_ → _arpakit_project_template_v_1/tg_bot/kb/inline_}/common.py +0 -0
  293. {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.dist-info}/LICENSE +0 -0
  294. {arpakitlib-1.7.257.dist-info → arpakitlib-1.8.1.dist-info}/entry_points.txt +0 -0
@@ -0,0 +1,308 @@
1
+ import asyncio
2
+ import inspect
3
+ import logging
4
+ from contextlib import suppress
5
+ from typing import Any, Callable
6
+
7
+ import fastapi
8
+ import starlette.exceptions
9
+
10
+ from api.const import APIErrorCodes
11
+ from api.exception import APIException
12
+ from api.response import APIJSONResponse
13
+ from api.schema.common.out import ErrorCommonSO
14
+ from arpakitlib.ar_datetime_util import now_utc_dt
15
+ from arpakitlib.ar_dict_util import combine_dicts
16
+ from arpakitlib.ar_exception_util import exception_to_traceback_str
17
+ from arpakitlib.ar_func_util import raise_if_not_async_callable, is_async_callable, is_sync_function
18
+ from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str
19
+ from arpakitlib.ar_type_util import raise_for_type
20
+ from core.settings import get_cached_settings
21
+ from sqlalchemy_db.sqlalchemy_db import get_cached_sqlalchemy_db
22
+ from sqlalchemy_db.sqlalchemy_model import StoryLogDBM
23
+
24
+ _logger = logging.getLogger(__name__)
25
+
26
+
27
+ def create_exception_handler(
28
+ *,
29
+ funcs_before: list[Callable | None] | None = None,
30
+ async_funcs_after: list[Callable | None] | None = None
31
+ ) -> Callable:
32
+ if funcs_before is None:
33
+ funcs_before = []
34
+ funcs_before = [v for v in funcs_before if v is not None]
35
+
36
+ if async_funcs_after is None:
37
+ async_funcs_after = []
38
+ async_funcs_after = [v for v in async_funcs_after if v is not None]
39
+
40
+ async def func(
41
+ request: fastapi.requests.Request,
42
+ exception: Exception
43
+ ) -> APIJSONResponse:
44
+ status_code = fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
45
+
46
+ error_common_so = ErrorCommonSO(
47
+ has_error=True,
48
+ error_code=APIErrorCodes.unknown_error,
49
+ error_data={
50
+ "exception_type": str(type(exception)),
51
+ "exception_str": str(exception),
52
+ "request.method": str(request.method),
53
+ "request.url": str(request.url)
54
+ }
55
+ )
56
+
57
+ if isinstance(exception, APIException):
58
+ old_error_data = error_common_so.error_data
59
+ error_common_so = exception.error_common_so
60
+ error_common_so.error_data = combine_dicts(old_error_data, error_common_so.error_data)
61
+
62
+ elif (
63
+ isinstance(exception, fastapi.exceptions.HTTPException)
64
+ or isinstance(exception, starlette.exceptions.HTTPException)
65
+ ):
66
+ status_code = exception.status_code
67
+ if status_code in (fastapi.status.HTTP_403_FORBIDDEN, fastapi.status.HTTP_401_UNAUTHORIZED):
68
+ error_common_so.error_code = APIErrorCodes.cannot_authorize
69
+ elif status_code == fastapi.status.HTTP_404_NOT_FOUND:
70
+ error_common_so.error_code = APIErrorCodes.not_found
71
+ else:
72
+ status_code = fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
73
+ with suppress(Exception):
74
+ error_common_so.error_data["exception.detail"] = exception.detail
75
+
76
+ elif isinstance(exception, fastapi.exceptions.RequestValidationError):
77
+ status_code = fastapi.status.HTTP_422_UNPROCESSABLE_ENTITY
78
+ error_common_so.error_code = APIErrorCodes.error_in_request
79
+ with suppress(Exception):
80
+ error_common_so.error_data["exception.errors"] = str(exception.errors()) if exception.errors() else {}
81
+
82
+ else:
83
+ status_code = fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
84
+ error_common_so.error_code = APIErrorCodes.unknown_error
85
+
86
+ if error_common_so.error_code is not None:
87
+ error_common_so.error_code = error_common_so.error_code.upper().replace(" ", "_").strip()
88
+
89
+ if error_common_so.error_specification_code is not None:
90
+ error_common_so.error_specification_code = (
91
+ error_common_so.error_specification_code.upper().replace(" ", "_").strip()
92
+ )
93
+
94
+ if error_common_so.error_code == APIErrorCodes.not_found:
95
+ status_code = fastapi.status.HTTP_404_NOT_FOUND
96
+
97
+ if error_common_so.error_code == APIErrorCodes.cannot_authorize:
98
+ status_code = fastapi.status.HTTP_401_UNAUTHORIZED
99
+
100
+ error_common_so.error_data["status_code"] = status_code
101
+
102
+ # funcs_before
103
+
104
+ _transmitted_kwargs = {}
105
+ for func_before in funcs_before:
106
+ if is_async_callable(func_before):
107
+ try:
108
+ _func_before_res = await func_before(
109
+ request=request, status_code=status_code, error_common_so=error_common_so, exception=exception,
110
+ transmitted_kwargs=_transmitted_kwargs
111
+ )
112
+ except Exception as exception_:
113
+ _logger.exception(exception_)
114
+ raise exception_
115
+ elif is_sync_function(func_before):
116
+ try:
117
+ _func_before_res = func_before(
118
+ request=request, status_code=status_code, error_common_so=error_common_so, exception=exception,
119
+ transmitted_kwargs=_transmitted_kwargs
120
+ )
121
+ except Exception as exception_:
122
+ _logger.exception(exception_)
123
+ raise exception_
124
+ else:
125
+ raise TypeError("unknown func_before type")
126
+ if _func_before_res is not None:
127
+ error_common_so, _transmitted_kwargs = _func_before_res[0], _func_before_res[1]
128
+ raise_for_type(error_common_so, ErrorCommonSO)
129
+ raise_for_type(_transmitted_kwargs, dict)
130
+
131
+ # async_funcs_after
132
+
133
+ for async_func_after in async_funcs_after:
134
+ raise_if_not_async_callable(async_func_after)
135
+ _ = asyncio.create_task(async_func_after(
136
+ request=request, status_code=status_code, error_common_so=error_common_so, exception=exception
137
+ ))
138
+
139
+ return APIJSONResponse(
140
+ content=error_common_so,
141
+ status_code=status_code
142
+ )
143
+
144
+ return func
145
+
146
+
147
+ def logging__api_func_before_in_handle_exception(
148
+ *,
149
+ ignore_api_error_codes: list[str] | None = None,
150
+ ignore_status_codes: list[int] | None = None,
151
+ ignore_exception_types: list[type[Exception]] | None = None
152
+ ) -> Callable:
153
+ current_func_name = inspect.currentframe().f_code.co_name
154
+
155
+ def func(
156
+ *,
157
+ request: fastapi.requests.Request,
158
+ status_code: int,
159
+ error_common_so: ErrorCommonSO,
160
+ exception: Exception,
161
+ transmitted_kwargs: dict[str, Any],
162
+ **kwargs
163
+ ) -> (ErrorCommonSO, dict[str, Any]):
164
+ transmitted_kwargs[current_func_name] = now_utc_dt()
165
+
166
+ if ignore_api_error_codes is not None and error_common_so.error_code in ignore_api_error_codes:
167
+ return error_common_so, transmitted_kwargs
168
+
169
+ if ignore_status_codes is not None and status_code in ignore_status_codes:
170
+ return error_common_so, transmitted_kwargs
171
+
172
+ if ignore_exception_types is not None and (
173
+ exception in ignore_exception_types or type(exception) in ignore_exception_types
174
+ ):
175
+ return error_common_so, transmitted_kwargs
176
+
177
+ _logger.error(safely_transfer_obj_to_json_str(error_common_so.model_dump()), exc_info=False)
178
+
179
+ return func
180
+
181
+
182
+ def story_log__api_func_before_in_handle_exception(
183
+ *,
184
+ ignore_api_error_codes: list[str] | None = None,
185
+ ignore_status_codes: list[int] | None = None,
186
+ ignore_exception_types: list[type[Exception]] | None = None,
187
+ ) -> Callable:
188
+ current_func_name = inspect.currentframe().f_code.co_name
189
+
190
+ async def async_func(
191
+ *,
192
+ request: fastapi.requests.Request,
193
+ status_code: int,
194
+ error_common_so: ErrorCommonSO,
195
+ exception: Exception,
196
+ transmitted_kwargs: dict[str, Any],
197
+ **kwargs
198
+ ) -> (ErrorCommonSO, dict[str, Any]):
199
+ transmitted_kwargs[current_func_name] = now_utc_dt()
200
+
201
+ if ignore_api_error_codes is not None and error_common_so.error_code in ignore_api_error_codes:
202
+ return error_common_so, transmitted_kwargs
203
+
204
+ if ignore_status_codes is not None and status_code in ignore_status_codes:
205
+ return error_common_so, transmitted_kwargs
206
+
207
+ if ignore_exception_types is not None and (
208
+ exception in ignore_exception_types or type(exception) in ignore_exception_types
209
+ ):
210
+ return error_common_so, transmitted_kwargs
211
+
212
+ async with get_cached_sqlalchemy_db().new_async_session() as session:
213
+ story_log_dbm = StoryLogDBM(
214
+ level=StoryLogDBM.Levels.error,
215
+ type=StoryLogDBM.Types.error_in_api_route,
216
+ title=f"{status_code}, {type(exception)}",
217
+ data={
218
+ "error_common_so": error_common_so.model_dump(),
219
+ "traceback_str": exception_to_traceback_str(exception=exception)
220
+ }
221
+ )
222
+ session.add(story_log_dbm)
223
+ await session.commit()
224
+ await session.refresh(story_log_dbm)
225
+
226
+ error_common_so.error_data.update({"story_log_long_id": story_log_dbm.long_id})
227
+ transmitted_kwargs["story_log_id"] = story_log_dbm.id
228
+
229
+ return error_common_so, transmitted_kwargs
230
+
231
+ return async_func
232
+
233
+
234
+ def get_exception_handler() -> Callable:
235
+ funcs_before = []
236
+ async_funcs_after = []
237
+
238
+ if (
239
+ get_cached_settings().api_story_log__api_func_before_in_exception_handler
240
+ and get_cached_sqlalchemy_db() is not None
241
+ ):
242
+ funcs_before.append(
243
+ story_log__api_func_before_in_handle_exception(
244
+ ignore_api_error_codes=[
245
+ APIErrorCodes.cannot_authorize,
246
+ APIErrorCodes.error_in_request,
247
+ APIErrorCodes.not_found
248
+ ],
249
+ ignore_status_codes=[
250
+ fastapi.status.HTTP_401_UNAUTHORIZED,
251
+ fastapi.status.HTTP_422_UNPROCESSABLE_ENTITY,
252
+ fastapi.status.HTTP_404_NOT_FOUND
253
+ ],
254
+ ignore_exception_types=[
255
+ fastapi.exceptions.RequestValidationError
256
+ ],
257
+ )
258
+ )
259
+
260
+ funcs_before.append(
261
+ logging__api_func_before_in_handle_exception(
262
+ ignore_api_error_codes=[
263
+ APIErrorCodes.cannot_authorize,
264
+ APIErrorCodes.error_in_request,
265
+ APIErrorCodes.not_found
266
+ ],
267
+ ignore_status_codes=[
268
+ fastapi.status.HTTP_401_UNAUTHORIZED,
269
+ fastapi.status.HTTP_422_UNPROCESSABLE_ENTITY,
270
+ fastapi.status.HTTP_404_NOT_FOUND
271
+ ],
272
+ ignore_exception_types=[
273
+ fastapi.exceptions.RequestValidationError
274
+ ],
275
+ )
276
+ )
277
+
278
+ return create_exception_handler(
279
+ funcs_before=funcs_before,
280
+ async_funcs_after=async_funcs_after
281
+ )
282
+
283
+
284
+ def add_exception_handler_to_app(*, app: fastapi.FastAPI) -> fastapi.FastAPI:
285
+ exception_handler = get_exception_handler()
286
+
287
+ app.add_exception_handler(
288
+ exc_class_or_status_code=Exception,
289
+ handler=exception_handler
290
+ )
291
+ app.add_exception_handler(
292
+ exc_class_or_status_code=ValueError,
293
+ handler=exception_handler
294
+ )
295
+ app.add_exception_handler(
296
+ exc_class_or_status_code=fastapi.exceptions.RequestValidationError,
297
+ handler=exception_handler
298
+ )
299
+ app.add_exception_handler(
300
+ exc_class_or_status_code=fastapi.exceptions.HTTPException,
301
+ handler=exception_handler
302
+ )
303
+ app.add_exception_handler(
304
+ exc_class_or_status_code=starlette.exceptions.HTTPException,
305
+ handler=exception_handler
306
+ )
307
+
308
+ return app
@@ -0,0 +1,28 @@
1
+ from fastapi import FastAPI
2
+ from fastapi.openapi.docs import get_swagger_ui_html, get_redoc_html
3
+
4
+
5
+ def add_local_openapi_ui_to_app(
6
+ *,
7
+ app: FastAPI
8
+ ):
9
+ @app.get("/docs", include_in_schema=False)
10
+ async def custom_swagger_ui_html():
11
+ return get_swagger_ui_html(
12
+ openapi_url=app.openapi_url,
13
+ title=app.title,
14
+ swagger_js_url="/static/swagger-ui/swagger-ui-bundle.js",
15
+ swagger_css_url="/static/swagger-ui/swagger-ui.css",
16
+ swagger_favicon_url="/static/openapi-favicon.png"
17
+ )
18
+
19
+ @app.get("/redoc", include_in_schema=False)
20
+ async def custom_redoc_html():
21
+ return get_redoc_html(
22
+ openapi_url=app.openapi_url,
23
+ title=app.title,
24
+ redoc_js_url="/static/redoc/redoc.standalone.js",
25
+ redoc_favicon_url="/static/openapi-favicon.png"
26
+ )
27
+
28
+ return app
@@ -0,0 +1,31 @@
1
+ from typing import Any
2
+
3
+ import fastapi
4
+
5
+ from api.schema.v1.out import BaseSO
6
+ from arpakitlib.ar_json_util import safely_transfer_obj_to_json_str_to_json_obj
7
+
8
+
9
+ class APIJSONResponse(fastapi.responses.JSONResponse):
10
+ def __init__(
11
+ self, *,
12
+ content: dict[str, Any] | list[Any] | BaseSO | None, status_code: int = fastapi.status.HTTP_200_OK
13
+ ):
14
+ if isinstance(content, dict):
15
+ content = safely_transfer_obj_to_json_str_to_json_obj(content)
16
+ elif isinstance(content, list):
17
+ content = safely_transfer_obj_to_json_str_to_json_obj(content)
18
+ elif isinstance(content, BaseSO):
19
+ content = safely_transfer_obj_to_json_str_to_json_obj(content.model_dump())
20
+ elif content is None:
21
+ content = None
22
+ else:
23
+ raise ValueError(f"unknown content type, type(content)={type(content)}")
24
+
25
+ self.content_ = content
26
+ self.status_code_ = status_code
27
+
28
+ super().__init__(
29
+ content=content,
30
+ status_code=status_code
31
+ )
@@ -1,12 +1,13 @@
1
1
  from fastapi import APIRouter
2
2
 
3
- from src.api.router.v1.main_router import main_v1_api_router
3
+ from api.router.v1.main_router import main_v1_api_router
4
4
 
5
5
  main_api_router = APIRouter()
6
6
 
7
- # API Error Info
7
+ # V1 API Router
8
+
8
9
 
9
10
  main_api_router.include_router(
11
+ prefix="/v1",
10
12
  router=main_v1_api_router,
11
- prefix="/api/v1"
12
13
  )
@@ -0,0 +1,22 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from api.schema.common.out import ErrorCommonSO, RawDataCommonSO
5
+ from util.read_arpakitlib_project_template_file import read_arpakitlib_project_template_file
6
+
7
+ api_router = APIRouter()
8
+
9
+
10
+ @api_router.get(
11
+ "",
12
+ name="Get arpakitlib info",
13
+ status_code=fastapi.status.HTTP_200_OK,
14
+ response_model=RawDataCommonSO | ErrorCommonSO
15
+ )
16
+ async def _(
17
+ *,
18
+ request: fastapi.requests.Request,
19
+ response: fastapi.responses.Response,
20
+ ):
21
+ arpakitlib_project_template_data = read_arpakitlib_project_template_file()
22
+ return RawDataCommonSO(data=arpakitlib_project_template_data)
@@ -0,0 +1,30 @@
1
+ import fastapi.requests
2
+ from fastapi import APIRouter, Depends
3
+
4
+ from api.auth import APIAuthData, api_auth, correct_api_keys_from_settings__validate_api_key_func, \
5
+ correct_tokens_from_settings__validate_api_key_func
6
+ from api.schema.common.out import ErrorCommonSO, RawDataCommonSO
7
+
8
+ api_router = APIRouter()
9
+
10
+
11
+ @api_router.get(
12
+ path="",
13
+ name="Check auth",
14
+ status_code=fastapi.status.HTTP_200_OK,
15
+ response_model=RawDataCommonSO | ErrorCommonSO,
16
+ )
17
+ async def _(
18
+ *,
19
+ request: fastapi.requests.Request,
20
+ response: fastapi.responses.Response,
21
+ api_auth_data: APIAuthData = Depends(api_auth(
22
+ require_api_key_string=False,
23
+ require_token_string=False,
24
+ validate_api_key_func=correct_api_keys_from_settings__validate_api_key_func(),
25
+ validate_token_func=correct_tokens_from_settings__validate_api_key_func(),
26
+ require_correct_api_key=False,
27
+ require_correct_token=False,
28
+ ))
29
+ ):
30
+ return RawDataCommonSO(data=api_auth_data.model_dump())
@@ -0,0 +1,25 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from api.schema.common.out import RawDataCommonSO, ErrorCommonSO
5
+ from arpakitlib.ar_logging_util import init_log_file
6
+ from core.settings import get_cached_settings
7
+
8
+ api_router = APIRouter()
9
+
10
+
11
+ @api_router.get(
12
+ path="",
13
+ name="Clear log file",
14
+ status_code=fastapi.status.HTTP_200_OK,
15
+ response_model=RawDataCommonSO | ErrorCommonSO,
16
+ )
17
+ async def _(
18
+ *,
19
+ request: fastapi.requests.Request,
20
+ response: fastapi.responses.Response,
21
+ ):
22
+ init_log_file(log_filepath=get_cached_settings().log_filepath)
23
+ with open(file=get_cached_settings().log_filepath, mode="w") as f:
24
+ f.write("")
25
+ return RawDataCommonSO(data={"log_file_was_cleared": True})
@@ -0,0 +1,24 @@
1
+ import fastapi.requests
2
+ from fastapi import APIRouter
3
+
4
+ from api.const import APIErrorCodes, APIErrorSpecificationCodes
5
+ from api.schema.common.out import ErrorCommonSO, ErrorsInfoCommonSO
6
+
7
+ api_router = APIRouter()
8
+
9
+
10
+ @api_router.get(
11
+ "",
12
+ name="Get errors info",
13
+ status_code=fastapi.status.HTTP_200_OK,
14
+ response_model=ErrorsInfoCommonSO | ErrorCommonSO,
15
+ )
16
+ async def _(
17
+ *,
18
+ request: fastapi.requests.Request,
19
+ response: fastapi.responses.Response,
20
+ ):
21
+ return ErrorsInfoCommonSO(
22
+ api_error_codes=APIErrorCodes.values_list(),
23
+ api_error_specification_codes=APIErrorSpecificationCodes.values_list()
24
+ )
@@ -0,0 +1,23 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+ from fastapi.responses import FileResponse
4
+
5
+ from arpakitlib.ar_logging_util import init_log_file
6
+ from core.settings import get_cached_settings
7
+
8
+ api_router = APIRouter()
9
+
10
+
11
+ @api_router.get(
12
+ path="",
13
+ name="Get log file",
14
+ status_code=fastapi.status.HTTP_200_OK,
15
+ response_class=FileResponse
16
+ )
17
+ async def _(
18
+ *,
19
+ request: fastapi.requests.Request,
20
+ response: fastapi.responses.Response,
21
+ ):
22
+ init_log_file(log_filepath=get_cached_settings().log_filepath)
23
+ return FileResponse(path=get_cached_settings().log_filepath)
@@ -0,0 +1,21 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from api.schema.common.out import ErrorCommonSO
5
+ from api.schema.v1.out import HealthcheckV1SO
6
+
7
+ api_router = APIRouter()
8
+
9
+
10
+ @api_router.get(
11
+ "",
12
+ name="Healthcheck",
13
+ status_code=fastapi.status.HTTP_200_OK,
14
+ response_model=HealthcheckV1SO | ErrorCommonSO,
15
+ )
16
+ async def _(
17
+ *,
18
+ request: fastapi.requests.Request,
19
+ response: fastapi.responses.Response,
20
+ ):
21
+ return HealthcheckV1SO(is_ok=True)
@@ -0,0 +1,67 @@
1
+ from fastapi import APIRouter
2
+
3
+ from api.router.v1 import healthcheck, get_errors_info, now_utc_datetime, clear_log_file, get_log_file
4
+ from api.router.v1 import raise_fake_error, check_auth
5
+
6
+ main_v1_api_router = APIRouter()
7
+
8
+ # Healthcheck
9
+
10
+ main_v1_api_router.include_router(
11
+ router=healthcheck.api_router,
12
+ prefix="/healthcheck",
13
+ tags=["Healthcheck"]
14
+ )
15
+
16
+ # arpakitlib_
17
+
18
+ main_v1_api_router.include_router(
19
+ router=arpakitlib_.api_router,
20
+ prefix="/arpakitlib",
21
+ tags=["arpakitlib"]
22
+ )
23
+
24
+ # Get errors info
25
+
26
+ main_v1_api_router.include_router(
27
+ router=get_errors_info.api_router,
28
+ prefix="/get_errors_info",
29
+ tags=["Errors info"]
30
+ )
31
+
32
+ # Check auth
33
+
34
+ main_v1_api_router.include_router(
35
+ router=check_auth.api_router,
36
+ prefix="/check_auth",
37
+ tags=["Check auth"]
38
+ )
39
+
40
+ # Raise fake error
41
+
42
+ main_v1_api_router.include_router(
43
+ router=raise_fake_error.api_router,
44
+ prefix="/raise_fake_error",
45
+ tags=["Fake error"]
46
+ )
47
+
48
+ # Now UTC Datetime
49
+
50
+ main_v1_api_router.include_router(
51
+ router=now_utc_datetime.api_router,
52
+ prefix="/now_utc_datetime",
53
+ tags=["Now UTC datetime"]
54
+ )
55
+
56
+ # Log file
57
+
58
+ main_v1_api_router.include_router(
59
+ router=clear_log_file.api_router,
60
+ prefix="/clear_log_file",
61
+ tags=["Log file"]
62
+ )
63
+ main_v1_api_router.include_router(
64
+ router=get_log_file.api_router,
65
+ prefix="/get_log_file",
66
+ tags=["Log file"]
67
+ )
@@ -0,0 +1,21 @@
1
+ import fastapi
2
+ from fastapi import APIRouter
3
+
4
+ from api.schema.common.out import ErrorCommonSO, DatetimeCommonSO
5
+ from arpakitlib.ar_datetime_util import now_utc_dt
6
+
7
+ api_router = APIRouter()
8
+
9
+
10
+ @api_router.get(
11
+ "",
12
+ name="Now UTC datetime",
13
+ status_code=fastapi.status.HTTP_200_OK,
14
+ response_model=DatetimeCommonSO | ErrorCommonSO,
15
+ )
16
+ async def _(
17
+ *,
18
+ request: fastapi.requests.Request,
19
+ response: fastapi.responses.Response,
20
+ ):
21
+ return DatetimeCommonSO.from_datetime(datetime_=now_utc_dt())
@@ -0,0 +1,35 @@
1
+ import fastapi
2
+ import starlette.exceptions
3
+ from fastapi import APIRouter
4
+
5
+ from api.schema.common.out import ErrorCommonSO
6
+
7
+ api_router = APIRouter()
8
+
9
+
10
+ @api_router.get(
11
+ "",
12
+ name="Raise fake error",
13
+ response_model=ErrorCommonSO,
14
+ status_code=fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
15
+ )
16
+ async def _(
17
+ *,
18
+ request: fastapi.requests.Request,
19
+ response: fastapi.responses.Response,
20
+ n: int | None = None
21
+ ):
22
+ if n == 1:
23
+ raise fastapi.HTTPException(
24
+ detail={"n": n},
25
+ status_code=fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
26
+ )
27
+ elif n == 2:
28
+ raise starlette.exceptions.HTTPException(
29
+ detail=f"fake_error, n={n}",
30
+ status_code=fastapi.status.HTTP_500_INTERNAL_SERVER_ERROR
31
+ )
32
+ elif n == 3:
33
+ raise ValueError(f"fake error n={n}")
34
+ else:
35
+ raise Exception(f"fake error, n={n}")
@@ -0,0 +1,26 @@
1
+ from typing import Any
2
+
3
+ from pydantic import ConfigDict, BaseModel
4
+
5
+
6
+ class BaseSchema(BaseModel):
7
+ model_config = ConfigDict(extra="ignore", arbitrary_types_allowed=True, from_attributes=True)
8
+
9
+ @classmethod
10
+ def __pydantic_init_subclass__(cls, **kwargs: Any) -> None:
11
+ if not (
12
+ cls.__name__.endswith("SO")
13
+ or cls.__name__.endswith("SI")
14
+ or cls.__name__.endswith("SchemaIn")
15
+ or cls.__name__.endswith("SchemaOut")
16
+ ):
17
+ raise ValueError("APISchema class should ends with SO | SI | SchemaIn | SchemaOut")
18
+ super().__init_subclass__(**kwargs)
19
+
20
+
21
+ class BaseSI(BaseSchema):
22
+ pass
23
+
24
+
25
+ class BaseSO(BaseSchema):
26
+ pass