zrb 1.0.0a21__py3-none-any.whl → 1.0.0b3__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 +3 -3
- zrb/builtin/__init__.py +3 -0
- zrb/builtin/group.py +1 -0
- zrb/builtin/llm/llm_chat.py +5 -3
- zrb/builtin/llm/tool/cli.py +1 -1
- zrb/builtin/llm/tool/rag.py +108 -145
- 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 +74 -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 +230 -102
- 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 +37 -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 +169 -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 +89 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/repository/role_repository.py +67 -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 +137 -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 +179 -12
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/user_repository.py +67 -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 +127 -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 +200 -30
- 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 +78 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/session.py +48 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/user.py +69 -5
- zrb/builtin/python.py +1 -1
- zrb/builtin/random.py +61 -0
- zrb/cmd/cmd_val.py +6 -5
- zrb/config.py +14 -1
- 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} +4 -3
- 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_controller/static → web_route/static/resources}/session/current-session.js +5 -2
- zrb/runner/{web_controller/static → web_route/static/resources}/session/event.js +5 -2
- 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 +147 -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 +56 -8
- 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 +184 -71
- 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/util/llm/tool.py +3 -7
- {zrb-1.0.0a21.dist-info → zrb-1.0.0b3.dist-info}/METADATA +2 -1
- zrb-1.0.0b3.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/past-session.js +0 -0
- {zrb-1.0.0a21.dist-info → zrb-1.0.0b3.dist-info}/WHEEL +0 -0
- {zrb-1.0.0a21.dist-info → zrb-1.0.0b3.dist-info}/entry_points.txt +0 -0
@@ -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
|
@@ -0,0 +1,113 @@
|
|
1
|
+
from logging import Logger
|
2
|
+
|
3
|
+
from my_app_name.common.base_service import BaseService
|
4
|
+
from my_app_name.module.my_module.service.my_entity.repository.my_entity_repository import (
|
5
|
+
MyEntityRepository,
|
6
|
+
)
|
7
|
+
from my_app_name.schema.my_entity import (
|
8
|
+
MultipleMyEntityResponse,
|
9
|
+
MyEntityCreateWithAudit,
|
10
|
+
MyEntityResponse,
|
11
|
+
MyEntityUpdateWithAudit,
|
12
|
+
)
|
13
|
+
|
14
|
+
|
15
|
+
class MyEntityService(BaseService):
|
16
|
+
|
17
|
+
def __init__(self, logger: Logger, my_entity_repository: MyEntityRepository):
|
18
|
+
super().__init__(logger)
|
19
|
+
self.my_entity_repository = my_entity_repository
|
20
|
+
|
21
|
+
@BaseService.route(
|
22
|
+
"/api/v1/my-entities/{my_entity_id}",
|
23
|
+
methods=["get"],
|
24
|
+
response_model=MyEntityResponse,
|
25
|
+
)
|
26
|
+
async def get_my_entity_by_id(self, my_entity_id: str) -> MyEntityResponse:
|
27
|
+
return await self.my_entity_repository.get_by_id(my_entity_id)
|
28
|
+
|
29
|
+
@BaseService.route(
|
30
|
+
"/api/v1/my-entities",
|
31
|
+
methods=["get"],
|
32
|
+
response_model=MultipleMyEntityResponse,
|
33
|
+
)
|
34
|
+
async def get_my_entities(
|
35
|
+
self,
|
36
|
+
page: int = 1,
|
37
|
+
page_size: int = 10,
|
38
|
+
sort: str | None = None,
|
39
|
+
filter: str | None = None,
|
40
|
+
) -> MultipleMyEntityResponse:
|
41
|
+
my_entities = await self.my_entity_repository.get(page, page_size, filter, sort)
|
42
|
+
count = await self.my_entity_repository.count(filter)
|
43
|
+
return MultipleMyEntityResponse(data=my_entities, count=count)
|
44
|
+
|
45
|
+
@BaseService.route(
|
46
|
+
"/api/v1/my-entities/bulk",
|
47
|
+
methods=["post"],
|
48
|
+
response_model=list[MyEntityResponse],
|
49
|
+
)
|
50
|
+
async def create_my_entity_bulk(
|
51
|
+
self, data: list[MyEntityCreateWithAudit]
|
52
|
+
) -> list[MyEntityResponse]:
|
53
|
+
my_entities = await self.my_entity_repository.create_bulk(data)
|
54
|
+
return await self.my_entity_repository.get_by_ids(
|
55
|
+
[my_entity.id for my_entity in my_entities]
|
56
|
+
)
|
57
|
+
|
58
|
+
@BaseService.route(
|
59
|
+
"/api/v1/my-entities",
|
60
|
+
methods=["post"],
|
61
|
+
response_model=MyEntityResponse,
|
62
|
+
)
|
63
|
+
async def create_my_entity(self, data: MyEntityCreateWithAudit) -> MyEntityResponse:
|
64
|
+
my_entity = await self.my_entity_repository.create(data)
|
65
|
+
return await self.my_entity_repository.get_by_id(my_entity.id)
|
66
|
+
|
67
|
+
@BaseService.route(
|
68
|
+
"/api/v1/my-entities/bulk",
|
69
|
+
methods=["put"],
|
70
|
+
response_model=MyEntityResponse,
|
71
|
+
)
|
72
|
+
async def update_my_entity_bulk(
|
73
|
+
self, my_entity_ids: list[str], data: MyEntityUpdateWithAudit
|
74
|
+
) -> MyEntityResponse:
|
75
|
+
my_entities = await self.my_entity_repository.update_bulk(my_entity_ids, data)
|
76
|
+
return await self.my_entity_repository.get_by_ids(
|
77
|
+
[my_entity.id for my_entity in my_entities]
|
78
|
+
)
|
79
|
+
|
80
|
+
@BaseService.route(
|
81
|
+
"/api/v1/my-entities/{my_entity_id}",
|
82
|
+
methods=["put"],
|
83
|
+
response_model=MyEntityResponse,
|
84
|
+
)
|
85
|
+
async def update_my_entity(
|
86
|
+
self, my_entity_id: str, data: MyEntityUpdateWithAudit
|
87
|
+
) -> MyEntityResponse:
|
88
|
+
my_entity = await self.my_entity_repository.update(my_entity_id, data)
|
89
|
+
return await self.my_entity_repository.get_by_id(my_entity.id)
|
90
|
+
|
91
|
+
@BaseService.route(
|
92
|
+
"/api/v1/my-entities/{my_entity_id}",
|
93
|
+
methods=["delete"],
|
94
|
+
response_model=MyEntityResponse,
|
95
|
+
)
|
96
|
+
async def delete_my_entity_bulk(
|
97
|
+
self, my_entity_ids: list[str], deleted_by: str
|
98
|
+
) -> MyEntityResponse:
|
99
|
+
my_entities = await self.my_entity_repository.delete_bulk(my_entity_ids)
|
100
|
+
return await self.my_entity_repository.get_by_ids(
|
101
|
+
[my_entity.id for my_entity in my_entities]
|
102
|
+
)
|
103
|
+
|
104
|
+
@BaseService.route(
|
105
|
+
"/api/v1/my-entities/{my_entity_id}",
|
106
|
+
methods=["delete"],
|
107
|
+
response_model=MyEntityResponse,
|
108
|
+
)
|
109
|
+
async def delete_my_entity(
|
110
|
+
self, my_entity_id: str, deleted_by: str
|
111
|
+
) -> MyEntityResponse:
|
112
|
+
my_entity = await self.my_entity_repository.delete(my_entity_id)
|
113
|
+
return await self.my_entity_repository.get_by_id(my_entity.id)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
from my_app_name.common.logger_factory import logger
|
2
|
+
from my_app_name.module.my_module.service.my_entity.my_entity_service import (
|
3
|
+
MyEntityService,
|
4
|
+
)
|
5
|
+
from my_app_name.module.my_module.service.my_entity.repository.my_entity_repository_factory import (
|
6
|
+
my_entity_repository,
|
7
|
+
)
|
8
|
+
|
9
|
+
my_entity_service = MyEntityService(logger, my_entity_repository=my_entity_repository)
|
@@ -1,5 +1,4 @@
|
|
1
1
|
from my_app_name.common.base_db_repository import BaseDBRepository
|
2
|
-
from my_app_name.common.error import NotFoundError
|
3
2
|
from my_app_name.module.my_module.service.my_entity.repository.my_entity_repository import (
|
4
3
|
MyEntityRepository,
|
5
4
|
)
|
@@ -10,15 +9,6 @@ from my_app_name.schema.my_entity import (
|
|
10
9
|
MyEntityUpdateWithAudit,
|
11
10
|
)
|
12
11
|
from passlib.context import CryptContext
|
13
|
-
from sqlalchemy.ext.asyncio import AsyncSession
|
14
|
-
from sqlmodel import Session, select
|
15
|
-
|
16
|
-
# Password hashing context
|
17
|
-
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")
|
18
|
-
|
19
|
-
|
20
|
-
def hash_password(password: str) -> str:
|
21
|
-
return pwd_context.hash(password)
|
22
12
|
|
23
13
|
|
24
14
|
class MyEntityDBRepository(
|
@@ -9,30 +9,51 @@ from my_app_name.schema.my_entity import (
|
|
9
9
|
|
10
10
|
|
11
11
|
class MyEntityRepository(ABC):
|
12
|
+
|
13
|
+
@abstractmethod
|
14
|
+
async def get_by_id(self, id: str) -> MyEntityResponse:
|
15
|
+
"""Get my entity by id"""
|
16
|
+
|
17
|
+
@abstractmethod
|
18
|
+
async def get_by_ids(self, id_list: list[str]) -> MyEntityResponse:
|
19
|
+
"""Get my entities by ids"""
|
20
|
+
|
21
|
+
@abstractmethod
|
22
|
+
async def get(
|
23
|
+
self,
|
24
|
+
page: int = 1,
|
25
|
+
page_size: int = 10,
|
26
|
+
filter: str | None = None,
|
27
|
+
sort: str | None = None,
|
28
|
+
) -> list[MyEntity]:
|
29
|
+
"""Get my entities by filter and sort"""
|
30
|
+
|
31
|
+
@abstractmethod
|
32
|
+
async def count(self, filter: str | None = None) -> int:
|
33
|
+
"""Count my entities by filter"""
|
34
|
+
|
12
35
|
@abstractmethod
|
13
|
-
async def create(self,
|
14
|
-
|
36
|
+
async def create(self, data: MyEntityCreateWithAudit) -> MyEntity:
|
37
|
+
"""Create a new my entity"""
|
15
38
|
|
16
39
|
@abstractmethod
|
17
|
-
async def
|
18
|
-
|
40
|
+
async def create_bulk(self, data: list[MyEntityCreateWithAudit]) -> list[MyEntity]:
|
41
|
+
"""Create some my entities"""
|
19
42
|
|
20
43
|
@abstractmethod
|
21
|
-
async def
|
22
|
-
|
44
|
+
async def delete(self, id: str) -> MyEntity:
|
45
|
+
"""Delete a my entity"""
|
23
46
|
|
24
47
|
@abstractmethod
|
25
|
-
async def
|
26
|
-
|
27
|
-
) -> MyEntity:
|
28
|
-
pass
|
48
|
+
async def delete_bulk(self, id_list: list[str]) -> list[MyEntity]:
|
49
|
+
"""Delete some my entities"""
|
29
50
|
|
30
51
|
@abstractmethod
|
31
|
-
async def
|
32
|
-
|
52
|
+
async def update(self, id: str, data: MyEntityUpdateWithAudit) -> MyEntity:
|
53
|
+
"""Update a my entity"""
|
33
54
|
|
34
55
|
@abstractmethod
|
35
|
-
async def
|
36
|
-
self,
|
37
|
-
) -> list[
|
38
|
-
|
56
|
+
async def update_bulk(
|
57
|
+
self, id_list: list[str], data: MyEntityUpdateWithAudit
|
58
|
+
) -> list[MyEntity]:
|
59
|
+
"""Update some my entities"""
|
@@ -1,4 +1,4 @@
|
|
1
|
-
from my_app_name.common.
|
1
|
+
from my_app_name.common.db_engine_factory import db_engine
|
2
2
|
from my_app_name.config import APP_REPOSITORY_TYPE
|
3
3
|
from my_app_name.module.my_module.service.my_entity.repository.my_entity_db_repository import (
|
4
4
|
MyEntityDBRepository,
|
@@ -8,6 +8,6 @@ from my_app_name.module.my_module.service.my_entity.repository.my_entity_reposit
|
|
8
8
|
)
|
9
9
|
|
10
10
|
if APP_REPOSITORY_TYPE == "db":
|
11
|
-
my_entity_repository: MyEntityRepository = MyEntityDBRepository(
|
11
|
+
my_entity_repository: MyEntityRepository = MyEntityDBRepository(db_engine)
|
12
12
|
else:
|
13
13
|
my_entity_repository: MyEntityRepository = None
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import datetime
|
2
2
|
|
3
3
|
import ulid
|
4
|
+
from pydantic import BaseModel
|
4
5
|
from sqlmodel import Field, SQLModel
|
5
6
|
|
6
7
|
|
@@ -9,7 +10,8 @@ class MyEntityBase(SQLModel):
|
|
9
10
|
|
10
11
|
|
11
12
|
class MyEntityCreate(MyEntityBase):
|
12
|
-
|
13
|
+
def with_audit(self, created_by: str) -> "MyEntityCreateWithAudit":
|
14
|
+
return MyEntityCreateWithAudit(**self.model_dump(), created_by=created_by)
|
13
15
|
|
14
16
|
|
15
17
|
class MyEntityCreateWithAudit(MyEntityCreate):
|
@@ -19,6 +21,9 @@ class MyEntityCreateWithAudit(MyEntityCreate):
|
|
19
21
|
class MyEntityUpdate(SQLModel):
|
20
22
|
my_column: str | None = None
|
21
23
|
|
24
|
+
def with_audit(self, updated_by: str) -> "MyEntityUpdateWithAudit":
|
25
|
+
return MyEntityUpdateWithAudit(**self.model_dump(), updated_by=updated_by)
|
26
|
+
|
22
27
|
|
23
28
|
class MyEntityUpdateWithAudit(MyEntityUpdate):
|
24
29
|
updated_by: str
|
@@ -28,10 +33,15 @@ class MyEntityResponse(MyEntityBase):
|
|
28
33
|
id: str
|
29
34
|
|
30
35
|
|
36
|
+
class MultipleMyEntityResponse(BaseModel):
|
37
|
+
data: list[MyEntityResponse]
|
38
|
+
count: int
|
39
|
+
|
40
|
+
|
31
41
|
class MyEntity(SQLModel, table=True):
|
32
42
|
id: str = Field(default_factory=lambda: ulid.new().str, primary_key=True)
|
33
|
-
created_at: datetime.datetime
|
34
|
-
created_by: str
|
35
|
-
updated_at: datetime.datetime
|
36
|
-
updated_by: str
|
37
|
-
my_column: str
|
43
|
+
created_at: datetime.datetime = Field(index=True)
|
44
|
+
created_by: str = Field(index=True)
|
45
|
+
updated_at: datetime.datetime | None = Field(index=True)
|
46
|
+
updated_by: str | None = Field(index=True)
|
47
|
+
my_column: str = Field(index=True)
|
zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/client_method.py
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# MyEntity related methods
|
2
|
+
|
3
|
+
|
4
|
+
@abstractmethod
|
5
|
+
async def get_my_entity_by_id(self, my_entity_id: str) -> MyEntityResponse:
|
6
|
+
"""Get my entity by id"""
|
7
|
+
|
8
|
+
|
9
|
+
@abstractmethod
|
10
|
+
async def get_my_entities(
|
11
|
+
self,
|
12
|
+
page: int = 1,
|
13
|
+
page_size: int = 10,
|
14
|
+
sort: str | None = None,
|
15
|
+
filter: str | None = None,
|
16
|
+
) -> MultipleMyEntityResponse:
|
17
|
+
"""Get my entities by filter and sort"""
|
18
|
+
|
19
|
+
|
20
|
+
@abstractmethod
|
21
|
+
async def create_my_entity_bulk(
|
22
|
+
self, data: list[MyEntityCreateWithAudit]
|
23
|
+
) -> list[MyEntityResponse]:
|
24
|
+
"""Create new my entities"""
|
25
|
+
|
26
|
+
|
27
|
+
@abstractmethod
|
28
|
+
async def create_my_entity(self, data: MyEntityCreateWithAudit) -> MyEntityResponse:
|
29
|
+
"""Create a new my entities"""
|
30
|
+
|
31
|
+
|
32
|
+
@abstractmethod
|
33
|
+
async def update_my_entity_bulk(
|
34
|
+
self, my_entity_ids: list[str], data: MyEntityUpdateWithAudit
|
35
|
+
) -> MyEntityResponse:
|
36
|
+
"""Update some my entities"""
|
37
|
+
|
38
|
+
|
39
|
+
@abstractmethod
|
40
|
+
async def update_my_entity(
|
41
|
+
self, my_entity_id: str, data: MyEntityUpdateWithAudit
|
42
|
+
) -> MyEntityResponse:
|
43
|
+
"""Update a my entity"""
|
44
|
+
|
45
|
+
|
46
|
+
@abstractmethod
|
47
|
+
async def delete_my_entity_bulk(
|
48
|
+
self, my_entity_ids: str, deleted_by: str
|
49
|
+
) -> MyEntityResponse:
|
50
|
+
"""Delete some my entities"""
|
51
|
+
|
52
|
+
|
53
|
+
@abstractmethod
|
54
|
+
async def delete_my_entity(
|
55
|
+
self, my_entity_id: str, deleted_by: str
|
56
|
+
) -> MyEntityResponse:
|
57
|
+
"""Delete a my entity"""
|