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