zrb 1.0.0a21__py3-none-any.whl → 1.0.0b2__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.
- zrb/__init__.py +2 -1
- zrb/__main__.py +0 -3
- zrb/builtin/__init__.py +3 -0
- zrb/builtin/group.py +1 -0
- zrb/builtin/llm/llm_chat.py +2 -2
- zrb/builtin/llm/tool/web.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_task.py +2 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/config.py +5 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_task.py +80 -20
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +150 -42
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/my_entity_service.py +113 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/my_entity_service_factory.py +9 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/repository/my_entity_db_repository.py +0 -10
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/repository/my_entity_repository.py +37 -16
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/repository/{factory.py → my_entity_repository_factory.py} +2 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/schema/my_entity.py +16 -6
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/client_method.py +57 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/gateway_subroute.py +72 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/format_task.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/input.py +13 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_task.py +23 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +42 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/gateway/subroute/my_module.py +7 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/my_module_api_client.py +6 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/{any_client.py → my_module_client.py} +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/my_module_client_factory.py +11 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/my_module_direct_client.py +5 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/route.py +11 -11
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/module_task_definition.py +2 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/task.py +8 -8
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/util.py +47 -20
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/app_factory.py +29 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/base_db_repository.py +185 -101
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/base_service.py +236 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/{db_engine.py → db_engine_factory.py} +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/error.py +12 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/logger_factory.py +10 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/parser_factory.py +7 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/util/app.py +47 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/util/parser.py +105 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/util/user_agent.py +58 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/util/view.py +37 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/config.py +25 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/main.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/auth_api_client.py +16 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/auth_client.py +163 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/auth_client_factory.py +9 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/auth_direct_client.py +15 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/migration/versions/3093c7336477_add_auth_tables.py +160 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/migration_metadata.py +18 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/route.py +7 -3
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/permission_service.py +117 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/permission_service_factory.py +11 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/repository/permission_db_repository.py +26 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/repository/permission_repository.py +61 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/repository/permission_repository_factory.py +13 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/repository/role_db_repository.py +75 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/repository/role_repository.py +59 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/repository/role_repository_factory.py +13 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/role_service.py +105 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/role_service_factory.py +7 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/user_db_repository.py +42 -13
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/user_repository.py +38 -17
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/user_repository_factory.py +2 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/user_service.py +105 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/user_service_factory.py +7 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/route.py +43 -14
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/subroute/auth.py +198 -28
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/util/view.py +74 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/content/error.html +6 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/content/homepage.html +6 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/images/android-chrome-192x192.png +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/images/android-chrome-512x512.png +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/images/favicon-32x32.png +0 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.amber.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.blue.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.cyan.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.fuchsia.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.green.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.grey.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.indigo.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.jade.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.lime.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.orange.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.pink.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.pumpkin.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.purple.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.red.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.sand.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.slate.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.violet.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.yellow.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/static/pico-css/pico.zinc.min.css +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/view/template/default.html +34 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/requirements.txt +1 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/permission.py +17 -5
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/role.py +50 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/session.py +52 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/user.py +30 -5
- zrb/builtin/python.py +1 -1
- zrb/builtin/random.py +61 -0
- zrb/cmd/cmd_val.py +6 -5
- zrb/content_transformer/any_content_transformer.py +7 -0
- zrb/content_transformer/content_transformer.py +6 -0
- zrb/runner/cli.py +14 -7
- zrb/runner/web_app.py +28 -280
- zrb/runner/web_config/config.py +91 -0
- zrb/runner/web_config/config_factory.py +26 -0
- zrb/runner/web_route/docs_route.py +17 -0
- zrb/runner/web_route/error_page/serve_default_404.py +28 -0
- zrb/runner/{web_controller/error_page/controller.py → web_route/error_page/show_error_page.py} +2 -2
- zrb/runner/{web_controller → web_route}/error_page/view.html +5 -0
- zrb/runner/web_route/home_page/home_page_route.py +51 -0
- zrb/runner/web_route/login_api_route.py +31 -0
- zrb/runner/web_route/login_page/login_page_route.py +39 -0
- zrb/runner/web_route/logout_api_route.py +18 -0
- zrb/runner/web_route/logout_page/logout_page_route.py +40 -0
- zrb/runner/{web_controller/group_info_page/controller.py → web_route/node_page/group/show_group_page.py} +3 -3
- zrb/runner/web_route/node_page/node_page_route.py +50 -0
- zrb/runner/{web_controller/session_page/controller.py → web_route/node_page/task/show_task_page.py} +3 -3
- zrb/runner/web_route/refresh_token_api_route.py +38 -0
- zrb/runner/web_route/static/static_route.py +44 -0
- zrb/runner/web_route/task_input_api_route.py +47 -0
- zrb/runner/web_route/task_session_api_route.py +102 -0
- zrb/runner/web_schema/session.py +5 -0
- zrb/runner/web_schema/token.py +11 -0
- zrb/runner/web_schema/user.py +32 -0
- zrb/runner/web_util/cookie.py +29 -0
- zrb/runner/{web_util.py → web_util/html.py} +1 -23
- zrb/runner/web_util/token.py +72 -0
- zrb/runner/web_util/user.py +63 -0
- zrb/session/session.py +6 -4
- zrb/session_state_logger/{default_session_state_logger.py → session_state_logger_factory.py} +1 -1
- zrb/task/base_task.py +53 -6
- zrb/task/base_trigger.py +2 -0
- zrb/task/cmd_task.py +9 -5
- zrb/task/http_check.py +2 -0
- zrb/task/llm_task.py +2 -0
- zrb/task/make_task.py +2 -0
- zrb/task/rsync_task.py +2 -0
- zrb/task/scaffolder.py +8 -5
- zrb/task/scheduler.py +2 -0
- zrb/task/tcp_check.py +2 -0
- zrb/task_status/task_status.py +4 -3
- zrb/util/cmd/command.py +1 -0
- zrb/util/file.py +7 -1
- {zrb-1.0.0a21.dist-info → zrb-1.0.0b2.dist-info}/METADATA +1 -1
- zrb-1.0.0b2.dist-info/RECORD +307 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/any_client_method.py +0 -27
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/my_entity_usecase.py +0 -65
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/api_client.py +0 -6
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/direct_client.py +0 -6
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/factory.py +0 -9
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/app.py +0 -20
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/base_usecase.py +0 -245
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/any_client.py +0 -33
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/api_client.py +0 -7
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/direct_client.py +0 -6
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/factory.py +0 -9
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/migration/versions/3093c7336477_add_user_table.py +0 -37
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/user_usecase.py +0 -53
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/user_usecase_factory.py +0 -6
- zrb/runner/web_config.py +0 -274
- zrb/runner/web_controller/home_page/controller.py +0 -33
- zrb/runner/web_controller/login_page/controller.py +0 -25
- zrb/runner/web_controller/logout_page/controller.py +0 -26
- zrb-1.0.0a21.dist-info/RECORD +0 -244
- /zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/column/{create_column_task.py → add_column_task.py} +0 -0
- /zrb/{runner/web_controller → builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission}/__init__.py +0 -0
- /zrb/{runner/web_controller/group_info_page → builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role}/__init__.py +0 -0
- /zrb/runner/{web_controller/home_page → web_route}/__init__.py +0 -0
- /zrb/runner/{web_controller/session_page → web_route/home_page}/__init__.py +0 -0
- /zrb/runner/{web_controller → web_route}/home_page/view.html +0 -0
- /zrb/runner/{web_controller → web_route}/login_page/view.html +0 -0
- /zrb/runner/{web_controller → web_route}/logout_page/view.html +0 -0
- /zrb/runner/{web_controller/group_info_page → web_route/node_page/group}/view.html +0 -0
- /zrb/runner/{web_controller/session_page → web_route/node_page/task}/partial/input.html +0 -0
- /zrb/runner/{web_controller/session_page → web_route/node_page/task}/view.html +0 -0
- /zrb/runner/{refresh-token.template.js → web_route/static/refresh-token.template.js} +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/common.css +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/favicon-32x32.png +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/login/event.js +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/logout/event.js +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/pico.min.css +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/session/common-util.js +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/session/current-session.js +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/session/event.js +0 -0
- /zrb/runner/{web_controller/static → web_route/static/resources}/session/past-session.js +0 -0
- {zrb-1.0.0a21.dist-info → zrb-1.0.0b2.dist-info}/WHEEL +0 -0
- {zrb-1.0.0a21.dist-info → zrb-1.0.0b2.dist-info}/entry_points.txt +0 -0
zrb/__init__.py
CHANGED
@@ -34,7 +34,8 @@ from zrb.input.password_input import PasswordInput
|
|
34
34
|
from zrb.input.str_input import StrInput
|
35
35
|
from zrb.input.text_input import TextInput
|
36
36
|
from zrb.runner.cli import cli
|
37
|
-
from zrb.runner.web_config import
|
37
|
+
from zrb.runner.web_config.config_factory import web_config
|
38
|
+
from zrb.runner.web_schema.user import User
|
38
39
|
from zrb.session.session import Session
|
39
40
|
from zrb.task.any_task import AnyTask
|
40
41
|
from zrb.task.base_task import BaseTask
|
zrb/__main__.py
CHANGED
@@ -14,9 +14,6 @@ def serve_cli():
|
|
14
14
|
for init_script in INIT_SCRIPTS:
|
15
15
|
load_file(init_script, -1)
|
16
16
|
cli.run(sys.argv[1:])
|
17
|
-
except RuntimeError as e:
|
18
|
-
if "Event loop is closed" not in f"{e}":
|
19
|
-
raise e
|
20
17
|
except KeyboardInterrupt:
|
21
18
|
print(stylize_warning("\nStopped"), file=sys.stderr)
|
22
19
|
except NodeNotFoundError as e:
|
zrb/builtin/__init__.py
CHANGED
@@ -12,6 +12,7 @@ from zrb.builtin.md5 import hash_md5, sum_md5
|
|
12
12
|
from zrb.builtin.project.add.fastapp.fastapp_task import add_fastapp_to_project
|
13
13
|
from zrb.builtin.project.create.project_task import create_project
|
14
14
|
from zrb.builtin.python import format_python_code
|
15
|
+
from zrb.builtin.random import shuffle_values, throw_dice
|
15
16
|
from zrb.builtin.setup.asdf.asdf import setup_asdf
|
16
17
|
from zrb.builtin.setup.latex.ubuntu import setup_latex_on_ubuntu
|
17
18
|
from zrb.builtin.setup.tmux.tmux import setup_tmux
|
@@ -55,6 +56,8 @@ assert edit_todo
|
|
55
56
|
assert complete_todo
|
56
57
|
assert log_todo
|
57
58
|
assert show_todo
|
59
|
+
assert throw_dice
|
60
|
+
assert shuffle_values
|
58
61
|
assert setup_ubuntu
|
59
62
|
assert setup_latex_on_ubuntu
|
60
63
|
assert setup_asdf
|
zrb/builtin/group.py
CHANGED
@@ -2,6 +2,7 @@ from zrb.group.group import Group
|
|
2
2
|
from zrb.runner.cli import cli
|
3
3
|
|
4
4
|
base64_group = cli.add_group(Group(name="base64", description="📄 Base64 operations"))
|
5
|
+
random_group = cli.add_group(Group(name="random", description="🔀 Random operation"))
|
5
6
|
git_group = cli.add_group(Group(name="git", description="🌱 Git related commands"))
|
6
7
|
git_branch_group = git_group.add_group(
|
7
8
|
Group(name="branch", description="🌿 Git branch related commands")
|
zrb/builtin/llm/llm_chat.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
from zrb.builtin.group import llm_group
|
2
2
|
from zrb.builtin.llm.tool.cli import run_shell_command
|
3
|
-
from zrb.builtin.llm.tool.web import
|
3
|
+
from zrb.builtin.llm.tool.web import open_web_route, query_internet
|
4
4
|
from zrb.config import (
|
5
5
|
LLM_ALLOW_ACCESS_SHELL,
|
6
6
|
LLM_ALLOW_ACCESS_WEB,
|
@@ -43,5 +43,5 @@ if LLM_ALLOW_ACCESS_SHELL:
|
|
43
43
|
llm_chat.add_tool(run_shell_command)
|
44
44
|
|
45
45
|
if LLM_ALLOW_ACCESS_WEB:
|
46
|
-
llm_chat.add_tool(
|
46
|
+
llm_chat.add_tool(open_web_route)
|
47
47
|
llm_chat.add_tool(query_internet)
|
zrb/builtin/llm/tool/web.py
CHANGED
@@ -49,6 +49,7 @@ scaffold_fastapp = Scaffolder(
|
|
49
49
|
transform_content=[
|
50
50
|
# Common transformation (project_dir/app_dir/**/*)
|
51
51
|
ContentTransformer(
|
52
|
+
name="transform-app-dir",
|
52
53
|
match=is_in_project_app_dir,
|
53
54
|
transform={
|
54
55
|
"My App Name": "{ctx.input.app.title()}",
|
@@ -60,6 +61,7 @@ scaffold_fastapp = Scaffolder(
|
|
60
61
|
),
|
61
62
|
# Register fastapp's tasks to project's zrb_init (project_dir/zrb_init.py)
|
62
63
|
ContentTransformer(
|
64
|
+
name="trasnform-zrb-init",
|
63
65
|
match=is_project_zrb_init_file,
|
64
66
|
transform=update_project_zrb_init_file,
|
65
67
|
),
|
@@ -9,9 +9,12 @@ MICROSERVICES_ENV_VARS = {
|
|
9
9
|
"MY_APP_NAME_MODE": "microservices",
|
10
10
|
"MY_APP_NAME_AUTH_BASE_URL": "http://localhost:3002",
|
11
11
|
}
|
12
|
-
MONOLITH_ENV_VARS = {
|
12
|
+
MONOLITH_ENV_VARS = {
|
13
|
+
"MY_APP_NAME_MODE": "monolith",
|
14
|
+
"MY_APP_NAME_MODULES": "",
|
15
|
+
}
|
13
16
|
|
14
17
|
if platform.system() == "Windows":
|
15
18
|
ACTIVATE_VENV_SCRIPT = "Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser; . .venv\\Scripts\\Activate" # noqa
|
16
19
|
else:
|
17
|
-
ACTIVATE_VENV_SCRIPT = "
|
20
|
+
ACTIVATE_VENV_SCRIPT = ". .venv/bin/activate"
|
@@ -1,19 +1,21 @@
|
|
1
1
|
import os
|
2
2
|
|
3
|
-
from my_app_name._zrb.config import APP_DIR
|
3
|
+
from my_app_name._zrb.config import ACTIVATE_VENV_SCRIPT, APP_DIR
|
4
4
|
from my_app_name._zrb.entity.add_entity_util import (
|
5
5
|
is_in_app_schema_dir,
|
6
6
|
is_in_module_entity_dir,
|
7
|
-
is_module_any_client_file,
|
8
7
|
is_module_api_client_file,
|
8
|
+
is_module_client_file,
|
9
9
|
is_module_direct_client_file,
|
10
|
+
is_module_gateway_subroute_file,
|
10
11
|
is_module_migration_metadata_file,
|
11
12
|
is_module_route_file,
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
update_api_client_file,
|
14
|
+
update_client_file,
|
15
|
+
update_direct_client_file,
|
16
|
+
update_gateway_subroute_file,
|
17
|
+
update_migration_metadata_file,
|
18
|
+
update_route_file,
|
17
19
|
)
|
18
20
|
from my_app_name._zrb.format_task import format_my_app_name_code
|
19
21
|
from my_app_name._zrb.group import app_create_group
|
@@ -23,9 +25,25 @@ from my_app_name._zrb.input import (
|
|
23
25
|
new_entity_input,
|
24
26
|
plural_entity_input,
|
25
27
|
)
|
26
|
-
from my_app_name._zrb.util import
|
28
|
+
from my_app_name._zrb.util import (
|
29
|
+
cd_module_script,
|
30
|
+
get_existing_module_names,
|
31
|
+
get_existing_schema_names,
|
32
|
+
set_create_migration_db_url_env,
|
33
|
+
set_env,
|
34
|
+
)
|
35
|
+
from my_app_name._zrb.venv_task import prepare_venv
|
27
36
|
|
28
|
-
from zrb import
|
37
|
+
from zrb import (
|
38
|
+
AnyContext,
|
39
|
+
Cmd,
|
40
|
+
CmdTask,
|
41
|
+
ContentTransformer,
|
42
|
+
EnvFile,
|
43
|
+
Scaffolder,
|
44
|
+
Task,
|
45
|
+
make_task,
|
46
|
+
)
|
29
47
|
from zrb.util.string.conversion import to_snake_case
|
30
48
|
|
31
49
|
|
@@ -66,6 +84,7 @@ scaffold_my_app_name_entity = Scaffolder(
|
|
66
84
|
transform_content=[
|
67
85
|
# Schema tranformation (my_app_name/schema/snake_entity_name)
|
68
86
|
ContentTransformer(
|
87
|
+
name="transform-schema-file",
|
69
88
|
match=is_in_app_schema_dir,
|
70
89
|
transform={
|
71
90
|
"MyEntity": "{to_pascal_case(ctx.input.entity)}",
|
@@ -75,6 +94,7 @@ scaffold_my_app_name_entity = Scaffolder(
|
|
75
94
|
# Common module's entity transformation
|
76
95
|
# (my_app_name/module/snake_module_name/service/snake_entity_name)
|
77
96
|
ContentTransformer(
|
97
|
+
name="transform-module-entity-dir",
|
78
98
|
match=is_in_module_entity_dir,
|
79
99
|
transform={
|
80
100
|
"my_module": "{to_snake_case(ctx.input.module)}",
|
@@ -87,40 +107,80 @@ scaffold_my_app_name_entity = Scaffolder(
|
|
87
107
|
# Add entity to migration metadata
|
88
108
|
# (my_app_name/module/snake_module_name/migration_metadata.py)
|
89
109
|
ContentTransformer(
|
110
|
+
name="transform-module-migration-metadata",
|
90
111
|
match=is_module_migration_metadata_file,
|
91
|
-
transform=
|
112
|
+
transform=update_migration_metadata_file,
|
92
113
|
),
|
93
|
-
# Update API Client
|
114
|
+
# Update API Client
|
115
|
+
# (my_app_name/module/snake_module_name/client/snake_module_name_api_client.py)
|
94
116
|
ContentTransformer(
|
117
|
+
name="transform-module-api-client",
|
95
118
|
match=is_module_api_client_file,
|
96
|
-
transform=
|
119
|
+
transform=update_api_client_file,
|
97
120
|
),
|
98
|
-
# Update Direct Client
|
121
|
+
# Update Direct Client
|
122
|
+
# (my_app_name/module/snake_module_name/client/snake_module_name_direct_client.py)
|
99
123
|
ContentTransformer(
|
124
|
+
name="transform-module-direct-client",
|
100
125
|
match=is_module_direct_client_file,
|
101
|
-
transform=
|
126
|
+
transform=update_direct_client_file,
|
102
127
|
),
|
103
|
-
# Update
|
128
|
+
# Update Client
|
129
|
+
# (my_app_name/module/snake_module_name/client/snake_module_name_client.py)
|
104
130
|
ContentTransformer(
|
105
|
-
|
106
|
-
|
131
|
+
name="transform-module-any-client",
|
132
|
+
match=is_module_client_file,
|
133
|
+
transform=update_client_file,
|
107
134
|
),
|
108
135
|
# Update module route (my_app_name/module/route.py)
|
109
136
|
ContentTransformer(
|
137
|
+
name="transform-module-route",
|
110
138
|
match=is_module_route_file,
|
111
|
-
transform=
|
139
|
+
transform=update_route_file,
|
140
|
+
),
|
141
|
+
# Update module gateway subroute
|
142
|
+
# (my_app_name/module/gateway/subroute/snake_module_name.py)
|
143
|
+
ContentTransformer(
|
144
|
+
name="transform-module-gateway-subroute",
|
145
|
+
match=is_module_gateway_subroute_file,
|
146
|
+
transform=update_gateway_subroute_file,
|
112
147
|
),
|
113
|
-
# TODO: Register gateway route
|
114
148
|
],
|
115
149
|
retries=0,
|
116
150
|
upstream=validate_create_my_app_name_entity,
|
117
151
|
)
|
118
152
|
|
153
|
+
create_my_app_name_entity_migration = CmdTask(
|
154
|
+
name="create-my-app-name-entity-migration",
|
155
|
+
input=[
|
156
|
+
existing_module_input,
|
157
|
+
new_entity_input,
|
158
|
+
],
|
159
|
+
env=EnvFile(path=os.path.join(APP_DIR, "template.env")),
|
160
|
+
cwd=APP_DIR,
|
161
|
+
cmd=[
|
162
|
+
ACTIVATE_VENV_SCRIPT,
|
163
|
+
Cmd(lambda ctx: set_create_migration_db_url_env(ctx.input.module)),
|
164
|
+
Cmd(lambda ctx: set_env("MY_APP_NAME_MODULES", ctx.input.module)),
|
165
|
+
Cmd(lambda ctx: cd_module_script(ctx.input.module)),
|
166
|
+
"alembic upgrade head",
|
167
|
+
Cmd(
|
168
|
+
'alembic revision --autogenerate -m "create_{to_snake_case(ctx.input.entity)}_table"', # noqa
|
169
|
+
),
|
170
|
+
],
|
171
|
+
render_cmd=False,
|
172
|
+
retries=0,
|
173
|
+
upstream=[
|
174
|
+
prepare_venv,
|
175
|
+
scaffold_my_app_name_entity,
|
176
|
+
],
|
177
|
+
)
|
178
|
+
|
119
179
|
add_my_app_name_entity = app_create_group.add_task(
|
120
180
|
Task(
|
121
181
|
name="add-my-app-name-entity",
|
122
182
|
description="🏗️ Create new entity on a module",
|
123
|
-
upstream=
|
183
|
+
upstream=create_my_app_name_entity_migration,
|
124
184
|
successor=format_my_app_name_code,
|
125
185
|
retries=0,
|
126
186
|
),
|
@@ -8,7 +8,7 @@ from zrb.util.codemod.append_code_to_function import append_code_to_function
|
|
8
8
|
from zrb.util.codemod.prepend_code_to_module import prepend_code_to_module
|
9
9
|
from zrb.util.codemod.prepend_parent_to_class import prepend_parent_class
|
10
10
|
from zrb.util.file import read_file, write_file
|
11
|
-
from zrb.util.string.conversion import to_pascal_case, to_snake_case
|
11
|
+
from zrb.util.string.conversion import to_kebab_case, to_pascal_case, to_snake_case
|
12
12
|
|
13
13
|
|
14
14
|
def is_in_app_schema_dir(ctx: AnyContext, file_path: str) -> bool:
|
@@ -49,13 +49,13 @@ def is_module_migration_metadata_file(ctx: AnyContext, file_path: str) -> bool:
|
|
49
49
|
return file_path == module_migration_metadata_file
|
50
50
|
|
51
51
|
|
52
|
-
def
|
52
|
+
def is_module_client_file(ctx: AnyContext, file_path: str) -> bool:
|
53
53
|
module_any_client_file = os.path.join(
|
54
54
|
APP_DIR,
|
55
55
|
"module",
|
56
56
|
to_snake_case(ctx.input.module),
|
57
57
|
"client",
|
58
|
-
"
|
58
|
+
f"{to_snake_case(ctx.input.module)}_client.py",
|
59
59
|
)
|
60
60
|
return file_path == module_any_client_file
|
61
61
|
|
@@ -66,7 +66,7 @@ def is_module_api_client_file(ctx: AnyContext, file_path: str) -> bool:
|
|
66
66
|
"module",
|
67
67
|
to_snake_case(ctx.input.module),
|
68
68
|
"client",
|
69
|
-
"
|
69
|
+
f"{to_snake_case(ctx.input.module)}_api_client.py",
|
70
70
|
)
|
71
71
|
return file_path == module_api_client_file
|
72
72
|
|
@@ -77,29 +77,40 @@ def is_module_direct_client_file(ctx: AnyContext, file_path: str) -> bool:
|
|
77
77
|
"module",
|
78
78
|
to_snake_case(ctx.input.module),
|
79
79
|
"client",
|
80
|
-
"
|
80
|
+
f"{to_snake_case(ctx.input.module)}_direct_client.py",
|
81
81
|
)
|
82
82
|
return file_path == module_direct_client_file
|
83
83
|
|
84
84
|
|
85
|
-
def
|
85
|
+
def is_module_gateway_subroute_file(ctx: AnyContext, file_path: str) -> bool:
|
86
|
+
module_gateway_subroute_file = os.path.join(
|
87
|
+
APP_DIR,
|
88
|
+
"module",
|
89
|
+
"gateway",
|
90
|
+
"subroute",
|
91
|
+
f"{to_snake_case(ctx.input.module)}.py",
|
92
|
+
)
|
93
|
+
return file_path == module_gateway_subroute_file
|
94
|
+
|
95
|
+
|
96
|
+
def update_migration_metadata_file(ctx: AnyContext, migration_metadata_file_path: str):
|
86
97
|
app_name = os.path.basename(APP_DIR)
|
87
98
|
existing_migration_metadata_code = read_file(migration_metadata_file_path)
|
88
99
|
write_file(
|
89
100
|
file_path=migration_metadata_file_path,
|
90
101
|
content=[
|
91
|
-
|
102
|
+
_get_migration_import_schema_code(
|
92
103
|
existing_migration_metadata_code, app_name, ctx.input.entity
|
93
104
|
),
|
94
105
|
existing_migration_metadata_code.strip(),
|
95
|
-
|
106
|
+
_get_migration_entity_metadata_assignment_code(
|
96
107
|
existing_migration_metadata_code, ctx.input.entity
|
97
108
|
),
|
98
109
|
],
|
99
110
|
)
|
100
111
|
|
101
112
|
|
102
|
-
def
|
113
|
+
def _get_migration_import_schema_code(
|
103
114
|
existing_code: str, app_name: str, entity_name: str
|
104
115
|
) -> str | None:
|
105
116
|
snake_entity_name = to_snake_case(entity_name)
|
@@ -111,7 +122,7 @@ def _get_import_schema_code(
|
|
111
122
|
return import_schema_code
|
112
123
|
|
113
124
|
|
114
|
-
def
|
125
|
+
def _get_migration_entity_metadata_assignment_code(
|
115
126
|
existing_code: str, entity_name: str
|
116
127
|
) -> str | None:
|
117
128
|
pascal_entity_name = to_pascal_case(entity_name)
|
@@ -126,76 +137,105 @@ def _get_entity_metadata_assignment_code(
|
|
126
137
|
return entity_metadata_assignment_code
|
127
138
|
|
128
139
|
|
129
|
-
def
|
130
|
-
|
131
|
-
|
140
|
+
def update_client_file(ctx: AnyContext, client_file_path: str):
|
141
|
+
existing_client_code = read_file(client_file_path)
|
142
|
+
pascal_module_name = to_pascal_case(ctx.input.module)
|
132
143
|
snake_entity_name = to_snake_case(ctx.input.entity)
|
133
144
|
snake_plural_entity_name = to_snake_case(ctx.input.plural)
|
134
145
|
pascal_entity_name = to_pascal_case(ctx.input.entity)
|
135
|
-
any_client_method = read_file(
|
136
|
-
file_path=os.path.join(
|
137
|
-
os.path.dirname(__file__), "template", "any_client_method.py"
|
138
|
-
),
|
139
|
-
replace_map={
|
140
|
-
"my_entity": snake_entity_name,
|
141
|
-
"my_entities": snake_plural_entity_name,
|
142
|
-
"MyEntity": pascal_entity_name,
|
143
|
-
},
|
144
|
-
)
|
145
|
-
new_code = append_code_to_class(
|
146
|
-
existing_any_client_code, "AnyClient", any_client_method
|
147
|
-
)
|
148
146
|
write_file(
|
149
|
-
file_path=
|
147
|
+
file_path=client_file_path,
|
150
148
|
content=[
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
149
|
+
_get_import_schema_for_client_code(
|
150
|
+
existing_code=existing_client_code, entity_name=ctx.input.entity
|
151
|
+
),
|
152
|
+
append_code_to_class(
|
153
|
+
original_code=existing_client_code,
|
154
|
+
class_name=f"{pascal_module_name}Client",
|
155
|
+
new_code=read_file(
|
156
|
+
file_path=os.path.join(
|
157
|
+
os.path.dirname(__file__), "template", "client_method.py"
|
158
|
+
),
|
159
|
+
replace_map={
|
160
|
+
"my_entity": snake_entity_name,
|
161
|
+
"my_entities": snake_plural_entity_name,
|
162
|
+
"MyEntity": pascal_entity_name,
|
163
|
+
},
|
164
|
+
),
|
165
|
+
),
|
155
166
|
],
|
156
167
|
)
|
157
168
|
|
158
169
|
|
159
|
-
def
|
170
|
+
def _get_import_schema_for_client_code(
|
171
|
+
existing_code: str, entity_name: str
|
172
|
+
) -> str | None:
|
173
|
+
snake_entity_name = to_snake_case(entity_name)
|
174
|
+
pascal_entity_name = to_pascal_case(entity_name)
|
175
|
+
schema_import_path = f"my_app_name.schema.{snake_entity_name}"
|
176
|
+
new_code = "\n".join(
|
177
|
+
[
|
178
|
+
f"from {schema_import_path} import (",
|
179
|
+
f" Multiple{pascal_entity_name}Response,",
|
180
|
+
f" {pascal_entity_name}Create,",
|
181
|
+
f" {pascal_entity_name}CreateWithAudit,",
|
182
|
+
f" {pascal_entity_name}Response,",
|
183
|
+
f" {pascal_entity_name}Update,",
|
184
|
+
f" {pascal_entity_name}UpdateWithAudit,",
|
185
|
+
")",
|
186
|
+
]
|
187
|
+
)
|
188
|
+
if new_code in existing_code:
|
189
|
+
return None
|
190
|
+
return new_code
|
191
|
+
|
192
|
+
|
193
|
+
def update_api_client_file(ctx: AnyContext, api_client_file_path: str):
|
160
194
|
existing_api_client_code = read_file(api_client_file_path)
|
161
195
|
upper_snake_module_name = to_snake_case(ctx.input.module).upper()
|
162
196
|
app_name = os.path.basename(APP_DIR)
|
163
197
|
snake_entity_name = to_snake_case(ctx.input.entity)
|
164
198
|
snake_module_name = to_snake_case(ctx.input.module)
|
199
|
+
pascal_module_name = to_pascal_case(ctx.input.module)
|
165
200
|
write_file(
|
166
201
|
file_path=api_client_file_path,
|
167
202
|
content=[
|
168
|
-
f"from {app_name}.module.{snake_module_name}.service.{snake_entity_name}.{snake_entity_name}
|
203
|
+
f"from {app_name}.module.{snake_module_name}.service.{snake_entity_name}.{snake_entity_name}_service_factory import {snake_entity_name}_service", # noqa
|
169
204
|
prepend_code_to_module(
|
170
205
|
prepend_parent_class(
|
171
|
-
existing_api_client_code,
|
206
|
+
original_code=existing_api_client_code,
|
207
|
+
class_name=f"{pascal_module_name}APIClient",
|
208
|
+
parent_class_name=f"{snake_entity_name}_api_client",
|
172
209
|
),
|
173
|
-
f"
|
210
|
+
f"{snake_entity_name}_api_client = {snake_entity_name}_service.as_api_client(base_url=APP_{upper_snake_module_name}_BASE_URL)", # noqa
|
174
211
|
),
|
175
212
|
],
|
176
213
|
)
|
177
214
|
|
178
215
|
|
179
|
-
def
|
216
|
+
def update_direct_client_file(ctx: AnyContext, direct_client_file_path: str):
|
180
217
|
existing_direct_client_code = read_file(direct_client_file_path)
|
181
218
|
app_name = os.path.basename(APP_DIR)
|
182
219
|
snake_entity_name = to_snake_case(ctx.input.entity)
|
183
220
|
snake_module_name = to_snake_case(ctx.input.module)
|
221
|
+
pascal_module_name = to_pascal_case(ctx.input.module)
|
184
222
|
write_file(
|
185
223
|
file_path=direct_client_file_path,
|
186
224
|
content=[
|
187
|
-
f"from {app_name}.module.{snake_module_name}.service.{snake_entity_name}.{snake_entity_name}
|
225
|
+
f"from {app_name}.module.{snake_module_name}.service.{snake_entity_name}.{snake_entity_name}_service_factory import {snake_entity_name}_service", # noqa
|
188
226
|
prepend_code_to_module(
|
189
227
|
prepend_parent_class(
|
190
|
-
existing_direct_client_code,
|
228
|
+
original_code=existing_direct_client_code,
|
229
|
+
class_name=f"{pascal_module_name}DirectClient",
|
230
|
+
parent_class_name=f"{snake_entity_name}_direct_client",
|
191
231
|
),
|
192
|
-
"
|
232
|
+
f"{snake_entity_name}_direct_client = {snake_entity_name}_service.as_direct_client()", # noqa
|
193
233
|
).strip(),
|
194
234
|
],
|
195
235
|
)
|
196
236
|
|
197
237
|
|
198
|
-
def
|
238
|
+
def update_route_file(ctx: AnyContext, route_file_path: str):
|
199
239
|
existing_route_code = read_file(route_file_path)
|
200
240
|
entity_name = to_snake_case(ctx.input.entity)
|
201
241
|
app_name = os.path.basename(APP_DIR)
|
@@ -203,11 +243,79 @@ def update_route(ctx: AnyContext, route_file_path: str):
|
|
203
243
|
write_file(
|
204
244
|
file_path=route_file_path,
|
205
245
|
content=[
|
206
|
-
f"from {app_name}.module.{module_name}.service.{entity_name}.{entity_name}
|
246
|
+
f"from {app_name}.module.{module_name}.service.{entity_name}.{entity_name}_service_factory import {entity_name}_service", # noqa
|
207
247
|
append_code_to_function(
|
208
248
|
existing_route_code,
|
209
249
|
"serve_route",
|
210
|
-
f"{entity_name}
|
250
|
+
f"{entity_name}_service.serve_route(app)",
|
251
|
+
),
|
252
|
+
],
|
253
|
+
)
|
254
|
+
|
255
|
+
|
256
|
+
def update_gateway_subroute_file(ctx: AnyContext, module_gateway_subroute_path: str):
|
257
|
+
snake_module_name = to_snake_case(ctx.input.module)
|
258
|
+
snake_entity_name = to_snake_case(ctx.input.entity)
|
259
|
+
snake_plural_entity_name = to_snake_case(ctx.input.plural)
|
260
|
+
kebab_plural_entity_name = to_kebab_case(ctx.input.plural)
|
261
|
+
pascal_entity_name = to_pascal_case(ctx.input.entity)
|
262
|
+
existing_gateway_subroute_code = read_file(module_gateway_subroute_path)
|
263
|
+
write_file(
|
264
|
+
file_path=module_gateway_subroute_path,
|
265
|
+
content=[
|
266
|
+
_get_import_client_for_gateway_subroute_code(
|
267
|
+
existing_gateway_subroute_code, module_name=ctx.input.module
|
268
|
+
),
|
269
|
+
_get_import_schema_for_gateway_subroute_code(
|
270
|
+
existing_gateway_subroute_code, entity_name=ctx.input.entity
|
271
|
+
),
|
272
|
+
append_code_to_function(
|
273
|
+
original_code=existing_gateway_subroute_code,
|
274
|
+
function_name=f"serve_{snake_module_name}_route",
|
275
|
+
new_code=read_file(
|
276
|
+
file_path=os.path.join(
|
277
|
+
os.path.dirname(__file__), "template", "gateway_subroute.py"
|
278
|
+
),
|
279
|
+
replace_map={
|
280
|
+
"my_module": snake_module_name,
|
281
|
+
"my_entity": snake_entity_name,
|
282
|
+
"my_entities": snake_plural_entity_name,
|
283
|
+
"my-entities": kebab_plural_entity_name,
|
284
|
+
"MyEntity": pascal_entity_name,
|
285
|
+
},
|
286
|
+
),
|
211
287
|
),
|
212
288
|
],
|
213
289
|
)
|
290
|
+
|
291
|
+
|
292
|
+
def _get_import_client_for_gateway_subroute_code(
|
293
|
+
existing_code: str, module_name: str
|
294
|
+
) -> str | None:
|
295
|
+
snake_module_name = to_snake_case(module_name)
|
296
|
+
client_import_path = f"my_app_name.module.{snake_module_name}.client.{snake_module_name}_client_factory" # noqa
|
297
|
+
new_code = f"from {client_import_path} import {snake_module_name}_client"
|
298
|
+
if new_code in existing_code:
|
299
|
+
return None
|
300
|
+
return new_code
|
301
|
+
|
302
|
+
|
303
|
+
def _get_import_schema_for_gateway_subroute_code(
|
304
|
+
existing_code: str, entity_name: str
|
305
|
+
) -> str | None:
|
306
|
+
snake_entity_name = to_snake_case(entity_name)
|
307
|
+
pascal_entity_name = to_pascal_case(entity_name)
|
308
|
+
schema_import_path = f"my_app_name.schema.{snake_entity_name}"
|
309
|
+
new_code = "\n".join(
|
310
|
+
[
|
311
|
+
f"from {schema_import_path} import (",
|
312
|
+
f" Multiple{pascal_entity_name}Response,",
|
313
|
+
f" {pascal_entity_name}Create,",
|
314
|
+
f" {pascal_entity_name}Response,",
|
315
|
+
f" {pascal_entity_name}Update,",
|
316
|
+
")",
|
317
|
+
]
|
318
|
+
)
|
319
|
+
if new_code in existing_code:
|
320
|
+
return None
|
321
|
+
return new_code
|