zrb 1.0.0b8__py3-none-any.whl → 1.0.0b10__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/__main__.py +3 -0
- zrb/builtin/project/add/fastapp/fastapp_task.py +1 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/.coveragerc +11 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/.gitignore +4 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/column/add_column_task.py +4 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/config.py +5 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_task.py +108 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +67 -4
- 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 +5 -5
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/schema/my_entity.py +1 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/test/my_module/my_entity/test_create_my_entity.py +53 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/test/my_module/my_entity/test_delete_my_entity.py +62 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/test/my_module/my_entity/test_read_my_entity.py +65 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/test/my_module/my_entity/test_update_my_entity.py +61 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/gateway_subroute.py +57 -13
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/input.py +8 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +2 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/gateway/subroute/my_module.py +6 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/module_task_definition.py +10 -6
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/task.py +65 -14
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/task_util.py +106 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/util.py +6 -86
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/base_db_repository.py +27 -11
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/base_service.py +140 -51
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/error.py +15 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/common/util/parser.py +1 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/config.py +22 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/auth_client.py +21 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/migration/versions/3093c7336477_add_auth_tables.py +106 -61
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/migration/versions/8ed025bcc845_create_permissions.py +69 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/migration_metadata.py +3 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/route.py +15 -14
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/permission/permission_service.py +4 -4
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/repository/role_db_repository.py +24 -5
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/role/role_service.py +14 -12
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/user_db_repository.py +134 -97
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/user_repository.py +28 -11
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/user_service.py +215 -13
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/user_service_factory.py +30 -2
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/subroute/auth.py +216 -41
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/util/auth.py +57 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/requirements.txt +7 -1
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/permission.py +2 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/role.py +13 -12
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/user.py +64 -12
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/_util/access_token.py +19 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/auth/permission/test_create_permission.py +59 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/auth/permission/test_delete_permission.py +68 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/auth/permission/test_read_permission.py +71 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/auth/permission/test_update_permission.py +66 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/auth/test_user_session.py +195 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/test_health_and_readiness.py +28 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/test_homepage.py +17 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test/test_not_found_error.py +16 -0
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/test.sh +7 -0
- zrb/task/base_task.py +10 -10
- zrb/task/cmd_task.py +2 -5
- zrb/util/cmd/command.py +39 -48
- zrb/util/codemod/modification_mode.py +3 -0
- zrb/util/codemod/modify_class.py +58 -0
- zrb/util/codemod/modify_class_parent.py +68 -0
- zrb/util/codemod/modify_class_property.py +128 -0
- zrb/util/codemod/modify_dict.py +75 -0
- zrb/util/codemod/modify_function.py +65 -0
- zrb/util/codemod/modify_function_call.py +68 -0
- zrb/util/codemod/modify_method.py +88 -0
- zrb/util/codemod/{prepend_code_to_module.py → modify_module.py} +2 -3
- zrb/util/file.py +3 -2
- {zrb-1.0.0b8.dist-info → zrb-1.0.0b10.dist-info}/METADATA +2 -1
- {zrb-1.0.0b8.dist-info → zrb-1.0.0b10.dist-info}/RECORD +72 -55
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/migrate.py +0 -3
- zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/session.py +0 -48
- zrb/util/codemod/append_code_to_class.py +0 -35
- zrb/util/codemod/append_code_to_function.py +0 -38
- zrb/util/codemod/append_code_to_method.py +0 -55
- zrb/util/codemod/append_key_to_dict.py +0 -51
- zrb/util/codemod/append_param_to_function_call.py +0 -39
- zrb/util/codemod/prepend_parent_to_class.py +0 -38
- zrb/util/codemod/prepend_property_to_class.py +0 -55
- {zrb-1.0.0b8.dist-info → zrb-1.0.0b10.dist-info}/WHEEL +0 -0
- {zrb-1.0.0b8.dist-info → zrb-1.0.0b10.dist-info}/entry_points.txt +0 -0
@@ -1,39 +0,0 @@
|
|
1
|
-
import libcst as cst
|
2
|
-
|
3
|
-
|
4
|
-
class FunctionCallParamAdder(cst.CSTTransformer):
|
5
|
-
def __init__(self, func_name: str, new_param: str):
|
6
|
-
self.func_name = func_name
|
7
|
-
# Parse the new parameter to ensure it’s a valid CST node
|
8
|
-
self.new_param = cst.parse_expression(new_param)
|
9
|
-
self.param_added = False
|
10
|
-
|
11
|
-
def leave_Call(self, original_node: cst.Call, updated_node: cst.Call) -> cst.Call:
|
12
|
-
# Check if the function call name matches the target function
|
13
|
-
if (
|
14
|
-
isinstance(original_node.func, cst.Name)
|
15
|
-
and original_node.func.value == self.func_name
|
16
|
-
): # noqa
|
17
|
-
# Add the new parameter to the function call arguments
|
18
|
-
new_args = updated_node.args + (cst.Arg(value=self.new_param),)
|
19
|
-
self.param_added = True
|
20
|
-
return updated_node.with_changes(args=new_args)
|
21
|
-
return updated_node
|
22
|
-
|
23
|
-
|
24
|
-
def append_param_to_function_call(
|
25
|
-
original_code: str, func_name: str, new_param: str
|
26
|
-
) -> str:
|
27
|
-
# Parse the original code into a module
|
28
|
-
module = cst.parse_module(original_code)
|
29
|
-
# Initialize the transformer with the necessary information
|
30
|
-
transformer = FunctionCallParamAdder(func_name, new_param)
|
31
|
-
# Apply the transformation
|
32
|
-
modified_module = module.visit(transformer)
|
33
|
-
# Error handling: raise an error if the function call is not found
|
34
|
-
if not transformer.param_added:
|
35
|
-
raise ValueError(
|
36
|
-
f"Function call to {func_name} not found in the provided code."
|
37
|
-
)
|
38
|
-
# Return the modified code
|
39
|
-
return modified_module.code
|
@@ -1,38 +0,0 @@
|
|
1
|
-
import libcst as cst
|
2
|
-
|
3
|
-
|
4
|
-
class ParentClassAdder(cst.CSTTransformer):
|
5
|
-
def __init__(self, class_name: str, parent_class_name: str):
|
6
|
-
self.class_name = class_name
|
7
|
-
self.parent_class_name = parent_class_name
|
8
|
-
self.class_found = False
|
9
|
-
|
10
|
-
def leave_ClassDef(
|
11
|
-
self, original_node: cst.ClassDef, updated_node: cst.ClassDef
|
12
|
-
) -> cst.ClassDef:
|
13
|
-
# Check if this is the target class
|
14
|
-
if original_node.name.value == self.class_name:
|
15
|
-
self.class_found = True
|
16
|
-
# Add the parent class to the existing bases
|
17
|
-
new_bases = (
|
18
|
-
cst.Arg(value=cst.Name(self.parent_class_name)),
|
19
|
-
*updated_node.bases,
|
20
|
-
)
|
21
|
-
return updated_node.with_changes(bases=new_bases)
|
22
|
-
return updated_node
|
23
|
-
|
24
|
-
|
25
|
-
def prepend_parent_class(
|
26
|
-
original_code: str, class_name: str, parent_class_name: str
|
27
|
-
) -> str:
|
28
|
-
# Parse the original code into a module
|
29
|
-
module = cst.parse_module(original_code)
|
30
|
-
# Initialize transformer with the class name and parent class name
|
31
|
-
transformer = ParentClassAdder(class_name, parent_class_name)
|
32
|
-
# Apply the transformation
|
33
|
-
modified_module = module.visit(transformer)
|
34
|
-
# Check if the class was found
|
35
|
-
if not transformer.class_found:
|
36
|
-
raise ValueError(f"Class {class_name} not found in the provided code.")
|
37
|
-
# Return the modified code
|
38
|
-
return modified_module.code
|
@@ -1,55 +0,0 @@
|
|
1
|
-
import libcst as cst
|
2
|
-
|
3
|
-
|
4
|
-
class ClassPropertyAdder(cst.CSTTransformer):
|
5
|
-
def __init__(
|
6
|
-
self, class_name: str, property_name: str, annotation: str, default_value: str
|
7
|
-
):
|
8
|
-
self.class_name = class_name
|
9
|
-
self.property_name = property_name
|
10
|
-
self.annotation = cst.Annotation(cst.parse_expression(annotation))
|
11
|
-
self.default_value = cst.parse_expression(default_value)
|
12
|
-
self.class_found = False
|
13
|
-
|
14
|
-
def leave_ClassDef(
|
15
|
-
self, original_node: cst.ClassDef, updated_node: cst.ClassDef
|
16
|
-
) -> cst.ClassDef:
|
17
|
-
# Check if this is the target class
|
18
|
-
if original_node.name.value == self.class_name:
|
19
|
-
self.class_found = True
|
20
|
-
# Create the annotated property with a default value
|
21
|
-
new_property = cst.SimpleStatementLine(
|
22
|
-
body=[
|
23
|
-
cst.AnnAssign(
|
24
|
-
target=cst.Name(self.property_name),
|
25
|
-
annotation=self.annotation,
|
26
|
-
value=self.default_value,
|
27
|
-
)
|
28
|
-
]
|
29
|
-
)
|
30
|
-
# Insert the new property at the start of the class body with a newline
|
31
|
-
new_body = cst.IndentedBlock(body=(new_property,) + updated_node.body.body)
|
32
|
-
return updated_node.with_changes(body=new_body)
|
33
|
-
return updated_node
|
34
|
-
|
35
|
-
|
36
|
-
def prepend_property_to_class(
|
37
|
-
original_code: str,
|
38
|
-
class_name: str,
|
39
|
-
property_name: str,
|
40
|
-
annotation: str,
|
41
|
-
default_value: str,
|
42
|
-
) -> str:
|
43
|
-
# Parse the original code into a module
|
44
|
-
module = cst.parse_module(original_code)
|
45
|
-
# Initialize transformer with the class name, property name, annotation, and default value
|
46
|
-
transformer = ClassPropertyAdder(
|
47
|
-
class_name, property_name, annotation, default_value
|
48
|
-
)
|
49
|
-
# Apply the transformation
|
50
|
-
modified_module = module.visit(transformer)
|
51
|
-
# Check if the class was found
|
52
|
-
if not transformer.class_found:
|
53
|
-
raise ValueError(f"Class {class_name} not found in the provided code.")
|
54
|
-
# Return the modified code
|
55
|
-
return modified_module.code
|
File without changes
|
File without changes
|