zrb 1.0.0a17__py3-none-any.whl → 1.0.0a19__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (144) hide show
  1. zrb/__init__.py +2 -0
  2. zrb/builtin/project/add/fastapp/fastapp_task.py +25 -39
  3. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/.flake8 +3 -0
  4. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/column/create_column_task.py +14 -0
  5. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_task.py +128 -0
  6. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/add_entity_util.py +213 -0
  7. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/any_client_method.template.py → my_app_name/_zrb/entity/template/any_client_method.py} +1 -1
  8. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/module_template → my_app_name/_zrb/entity/template/app_template/module/my_module}/service/my_entity/my_entity_usecase.py +4 -5
  9. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/entity/template/app_template/module/my_module/service/my_entity/repository/factory.py +13 -0
  10. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/module_template → my_app_name/_zrb/entity/template/app_template/module/my_module}/service/my_entity/repository/my_entity_db_repository.py +4 -4
  11. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/module_template → my_app_name/_zrb/entity/template/app_template/module/my_module}/service/my_entity/repository/my_entity_repository.py +1 -2
  12. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/format_task.py +17 -0
  13. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/input.py +1 -4
  14. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_task.py +85 -0
  15. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/add_module_util.py +154 -0
  16. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/api_client.py +6 -0
  17. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/direct_client.py +6 -0
  18. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/_zrb/module/template/app_template/module/my_module/client/factory.py +9 -0
  19. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/env.py +2 -4
  20. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/script.py.mako +1 -0
  21. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/route.py +3 -3
  22. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/task.py +12 -14
  23. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/util.py +1 -1
  24. zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/venv_task.py +1 -1
  25. zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/app.py +2 -2
  26. zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/base_db_repository.py +1 -1
  27. zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/db_engine.py +1 -1
  28. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/main.py +7 -0
  29. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/migrate.py +3 -0
  30. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/client/any_client.py +1 -1
  31. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/api_client.py +7 -0
  32. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/direct_client.py +6 -0
  33. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/client/factory.py +9 -0
  34. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/env.py +2 -4
  35. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/script.py.mako +1 -0
  36. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration_metadata.py +1 -1
  37. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/route.py +4 -4
  38. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/auth/service/user/repository/factory.py +13 -0
  39. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/repository/user_db_repository.py +4 -4
  40. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/repository/user_repository.py +1 -2
  41. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/user_usecase.py +4 -5
  42. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration/env.py +2 -4
  43. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration/script.py.mako +1 -0
  44. zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/route.py +5 -5
  45. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/module/gateway/subroute/auth.py +0 -0
  46. zrb/builtin/project/add/fastapp/fastapp_template/my_app_name/schema/__init__.py +0 -0
  47. zrb/builtin/project/add/fastapp/fastapp_util.py +29 -5
  48. zrb/builtin/python.py +4 -1
  49. zrb/builtin/todo.py +35 -14
  50. zrb/callback/callback.py +0 -1
  51. zrb/config.py +1 -0
  52. zrb/content_transformer/content_transformer.py +5 -3
  53. zrb/context/any_context.py +6 -6
  54. zrb/group/group.py +0 -1
  55. zrb/input/any_input.py +4 -0
  56. zrb/input/base_input.py +4 -4
  57. zrb/input/bool_input.py +1 -1
  58. zrb/input/float_input.py +2 -2
  59. zrb/input/int_input.py +1 -1
  60. zrb/input/option_input.py +2 -2
  61. zrb/input/password_input.py +2 -2
  62. zrb/input/text_input.py +2 -2
  63. zrb/runner/cli.py +2 -31
  64. zrb/runner/common_util.py +31 -0
  65. zrb/runner/web_app.py +25 -6
  66. zrb/runner/web_controller/static/pico.min.css +1 -1
  67. zrb/runner/web_controller/static/task-ui/common-util.js +63 -0
  68. zrb/runner/web_controller/static/task-ui/current-session.js +164 -0
  69. zrb/runner/web_controller/static/task-ui/event.js +120 -0
  70. zrb/runner/web_controller/static/task-ui/past-session.js +138 -0
  71. zrb/runner/web_controller/task_ui/controller.py +20 -19
  72. zrb/runner/web_controller/task_ui/view.html +12 -15
  73. zrb/session_state_logger/any_session_state_logger.py +0 -1
  74. zrb/session_state_logger/file_session_state_logger.py +0 -1
  75. zrb/task/base_trigger.py +0 -1
  76. zrb/task/llm_task.py +0 -1
  77. zrb/task/make_task.py +0 -1
  78. zrb/task/scaffolder.py +6 -4
  79. zrb/task/scheduler.py +0 -1
  80. zrb/util/cmd/command.py +0 -1
  81. zrb/util/codemod/append_code_to_class.py +4 -4
  82. zrb/util/codemod/append_code_to_function.py +2 -2
  83. zrb/util/codemod/append_code_to_method.py +2 -2
  84. zrb/util/codemod/prepend_code_to_module.py +2 -2
  85. zrb/util/file.py +1 -1
  86. zrb/util/todo.py +100 -17
  87. zrb/xcom/xcom.py +0 -1
  88. {zrb-1.0.0a17.dist-info → zrb-1.0.0a19.dist-info}/METADATA +1 -1
  89. zrb-1.0.0a19.dist-info/RECORD +241 -0
  90. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/column/create_column_task.py +0 -11
  91. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/entity/module_template/service/my_entity/repository/factory.py +0 -13
  92. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/entity/task.py +0 -260
  93. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/task.py +0 -143
  94. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/template/module_template/client/api_client.py +0 -6
  95. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/template/module_template/client/direct_client.py +0 -6
  96. zrb/builtin/project/add/fastapp/fastapp_template/_zrb/module/template/module_template/client/factory.py +0 -9
  97. zrb/builtin/project/add/fastapp/fastapp_template/main.py +0 -7
  98. zrb/builtin/project/add/fastapp/fastapp_template/migrate.py +0 -3
  99. zrb/builtin/project/add/fastapp/fastapp_template/module/auth/client/api_client.py +0 -7
  100. zrb/builtin/project/add/fastapp/fastapp_template/module/auth/client/direct_client.py +0 -6
  101. zrb/builtin/project/add/fastapp/fastapp_template/module/auth/client/factory.py +0 -9
  102. zrb/builtin/project/add/fastapp/fastapp_template/module/auth/service/user/repository/factory.py +0 -13
  103. zrb/runner/web_controller/task_ui/partial/common-util.js +0 -37
  104. zrb/runner/web_controller/task_ui/partial/main.js +0 -195
  105. zrb/runner/web_controller/task_ui/partial/show-existing-session.js +0 -97
  106. zrb/runner/web_controller/task_ui/partial/visualize-history.js +0 -104
  107. zrb-1.0.0a17.dist-info/RECORD +0 -234
  108. /zrb/builtin/project/add/fastapp/fastapp_template/{.gitignore → my_app_name/.gitignore} +0 -0
  109. /zrb/builtin/project/add/fastapp/fastapp_template/{README.md → my_app_name/README.md} +0 -0
  110. /zrb/builtin/project/add/fastapp/fastapp_template/{__init__.py → my_app_name/__init__.py} +0 -0
  111. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/config.py +0 -0
  112. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/entity/schema.template.py → my_app_name/_zrb/entity/template/app_template/schema/my_entity.py} +0 -0
  113. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb → my_app_name/_zrb}/group.py +0 -0
  114. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template/migration/versions/.gitkeep → my_app_name/_zrb/module/template/app_template/module/gateway/subroute/my_module.py} +0 -0
  115. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/alembic.ini +0 -0
  116. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/client/any_client.py +0 -0
  117. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/README +0 -0
  118. /zrb/builtin/project/add/fastapp/fastapp_template/{module/gateway → my_app_name/_zrb/module/template/app_template/module/my_module}/migration/versions/.gitkeep +0 -0
  119. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/migration_metadata.py +0 -0
  120. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/module_template → my_app_name/_zrb/module/template/app_template/module/my_module}/service/__init__.py +0 -0
  121. /zrb/builtin/project/add/fastapp/fastapp_template/{_zrb/module/template/task_definition.py → my_app_name/_zrb/module/template/module_task_definition.py} +0 -0
  122. /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/__init__.py +0 -0
  123. /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/base_usecase.py +0 -0
  124. /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/error.py +0 -0
  125. /zrb/builtin/project/add/fastapp/fastapp_template/{common → my_app_name/common}/schema.py +0 -0
  126. /zrb/builtin/project/add/fastapp/fastapp_template/{config.py → my_app_name/config.py} +0 -0
  127. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/__init__.py +0 -0
  128. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/alembic.ini +0 -0
  129. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/README +0 -0
  130. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/migration/versions/3093c7336477_add_user_table.py +0 -0
  131. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/__init__.py +0 -0
  132. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/__init__.py +0 -0
  133. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/auth/service/user/repository/__init__.py +0 -0
  134. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/alembic.ini +0 -0
  135. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration/README +0 -0
  136. /zrb/builtin/project/add/fastapp/fastapp_template/{schema/__init__.py → my_app_name/module/gateway/migration/versions/.gitkeep} +0 -0
  137. /zrb/builtin/project/add/fastapp/fastapp_template/{module → my_app_name/module}/gateway/migration_metadata.py +0 -0
  138. /zrb/builtin/project/add/fastapp/fastapp_template/{requirements.txt → my_app_name/requirements.txt} +0 -0
  139. /zrb/builtin/project/add/fastapp/fastapp_template/{schema → my_app_name/schema}/permission.py +0 -0
  140. /zrb/builtin/project/add/fastapp/fastapp_template/{schema → my_app_name/schema}/role.py +0 -0
  141. /zrb/builtin/project/add/fastapp/fastapp_template/{schema → my_app_name/schema}/user.py +0 -0
  142. /zrb/builtin/project/add/fastapp/fastapp_template/{template.env → my_app_name/template.env} +0 -0
  143. {zrb-1.0.0a17.dist-info → zrb-1.0.0a19.dist-info}/WHEEL +0 -0
  144. {zrb-1.0.0a17.dist-info → zrb-1.0.0a19.dist-info}/entry_points.txt +0 -0
@@ -1,260 +0,0 @@
1
- import os
2
-
3
- from fastapp_template._zrb.config import APP_DIR
4
- from fastapp_template._zrb.group import app_create_group
5
- from fastapp_template._zrb.input import (
6
- existing_module_input,
7
- new_entity_column_input,
8
- new_entity_input,
9
- plural_entity_input,
10
- )
11
- from fastapp_template._zrb.util import (
12
- get_existing_module_names,
13
- get_existing_schema_names,
14
- )
15
-
16
- from zrb import AnyContext, Scaffolder, Task, make_task
17
- from zrb.util.codemod.append_code_to_class import append_code_to_class
18
- from zrb.util.codemod.append_code_to_function import append_code_to_function
19
- from zrb.util.codemod.prepend_code_to_module import prepend_code_to_module
20
- from zrb.util.codemod.prepend_parent_to_class import prepend_parent_class
21
- from zrb.util.file import read_file, write_file
22
- from zrb.util.string.conversion import to_pascal_case, to_snake_case
23
-
24
-
25
- @make_task(
26
- name="validate-create-my-app-name-entity",
27
- input=[
28
- existing_module_input,
29
- new_entity_input,
30
- plural_entity_input,
31
- new_entity_column_input,
32
- ],
33
- retries=0,
34
- )
35
- async def validate_create_my_app_name_entity(ctx: AnyContext):
36
- module_name = to_snake_case(ctx.input.module)
37
- if module_name not in get_existing_module_names():
38
- raise ValueError(f"Module not exist: {module_name}")
39
- schema_name = to_snake_case(ctx.input.entity)
40
- if schema_name in get_existing_schema_names():
41
- raise ValueError(f"Schema already exists: {schema_name}")
42
-
43
-
44
- scaffold_my_app_name_schema = Scaffolder(
45
- name="scaffold-my-app-name-schema",
46
- input=[
47
- existing_module_input,
48
- new_entity_input,
49
- new_entity_column_input,
50
- ],
51
- source_path=os.path.join(os.path.dirname(__file__), "schema.template.py"),
52
- render_source_path=False,
53
- destination_path=lambda ctx: os.path.join(
54
- APP_DIR,
55
- "schema",
56
- f"{to_snake_case(ctx.input.entity)}.py",
57
- ),
58
- transform_content={
59
- "MyEntity": "{to_pascal_case(ctx.input.entity)}",
60
- "my_column": "{to_snake_case(ctx.input.column)}",
61
- },
62
- retries=0,
63
- upstream=validate_create_my_app_name_entity,
64
- )
65
-
66
- scaffold_my_app_name_module_entity = Scaffolder(
67
- name="scaffold-my-app-name-schema",
68
- input=[
69
- existing_module_input,
70
- new_entity_input,
71
- plural_entity_input,
72
- ],
73
- source_path=os.path.join(os.path.dirname(__file__), "module_template"),
74
- render_source_path=False,
75
- destination_path=lambda ctx: os.path.join(
76
- APP_DIR,
77
- "module",
78
- f"{to_snake_case(ctx.input.module)}",
79
- ),
80
- transform_content={
81
- "my_module": "{to_snake_case(ctx.input.module)}",
82
- "MyEntity": "{to_pascal_case(ctx.input.entity)}",
83
- "my_entity": "{to_snake_case(ctx.input.entity)}",
84
- "my_entities": "{to_snake_case(ctx.input.plural)}",
85
- "my-entities": "{to_kebab_case(ctx.input.plural)}",
86
- },
87
- transform_path={
88
- "my_entity": "{to_snake_case(ctx.input.entity)}",
89
- },
90
- retries=0,
91
- upstream=validate_create_my_app_name_entity,
92
- )
93
-
94
-
95
- @make_task(
96
- name="register-my-app-name-migration",
97
- input=[existing_module_input, new_entity_input],
98
- retries=0,
99
- upstream=validate_create_my_app_name_entity,
100
- )
101
- async def register_my_app_name_migration(ctx: AnyContext):
102
- migration_metadata_file_path = os.path.join(
103
- APP_DIR, "module", to_snake_case(ctx.input.module), "migration_metadata.py"
104
- )
105
- app_name = os.path.basename(APP_DIR)
106
- file_content = read_file(migration_metadata_file_path)
107
- snake_entity_name = to_snake_case(ctx.input.entity)
108
- pascal_entity_name = to_pascal_case(ctx.input.entity)
109
- new_file_content_list = (
110
- [f"from {app_name}.schema.{snake_entity_name} import {pascal_entity_name}"]
111
- + file_content.strip()
112
- + [
113
- f"{pascal_entity_name}.metadata = metadata",
114
- f"{pascal_entity_name}.__table__.tometadata(metadata)",
115
- "",
116
- ]
117
- )
118
- write_file(migration_metadata_file_path, "\n".join(new_file_content_list))
119
-
120
-
121
- @make_task(
122
- name="register-my-app-name-api-client",
123
- input=[existing_module_input, new_entity_input],
124
- retries=0,
125
- upstream=validate_create_my_app_name_entity,
126
- )
127
- async def register_my_app_name_api_client(ctx: AnyContext):
128
- api_client_file_path = os.path.join(
129
- APP_DIR, "module", to_snake_case(ctx.input.module), "client", "api_client.py"
130
- )
131
- file_content = read_file(api_client_file_path)
132
- upper_snake_module_name = to_snake_case(ctx.input.module).upper()
133
- new_code = prepend_code_to_module(
134
- file_content,
135
- f"user_api_client = user_usecase.as_api_client(base_url=APP_{upper_snake_module_name}_BASE_URL)", # noqa
136
- )
137
- new_code = prepend_parent_class(
138
- original_code=new_code,
139
- class_name="APIClient",
140
- parent_class_name="user_api_client",
141
- )
142
- app_name = os.path.basename(APP_DIR)
143
- snake_entity_name = to_snake_case(ctx.input.entity)
144
- snake_module_name = to_snake_case(ctx.input.module)
145
- write_file(
146
- api_client_file_path,
147
- [
148
- f"from {app_name}.module.{snake_module_name}.service.{snake_entity_name}.{snake_entity_name}_usecase import {snake_entity_name}_usecase", # noqa
149
- new_code.strip(),
150
- "",
151
- ],
152
- )
153
-
154
-
155
- @make_task(
156
- name="register-my-app-name-direct-client",
157
- input=[existing_module_input, new_entity_input],
158
- retries=0,
159
- upstream=validate_create_my_app_name_entity,
160
- )
161
- async def register_my_app_name_direct_client(ctx: AnyContext):
162
- direct_client_file_path = os.path.join(
163
- APP_DIR, "module", to_snake_case(ctx.input.module), "client", "direct_client.py"
164
- )
165
- file_content = read_file(direct_client_file_path)
166
- app_name = os.path.basename(APP_DIR)
167
- snake_entity_name = to_snake_case(ctx.input.entity)
168
- snake_module_name = to_snake_case(ctx.input.module)
169
- write_file(
170
- direct_client_file_path,
171
- [
172
- f"from {app_name}.module.{snake_module_name}.service.{snake_entity_name}.{snake_entity_name}_usecase import {snake_entity_name}_usecase", # noqa
173
- prepend_code_to_module(
174
- prepend_parent_class(
175
- file_content, "DirectClient", "user_direct_client"
176
- ),
177
- "user_direct_client = user_usecase.as_direct_client()",
178
- ).strip(),
179
- "",
180
- ],
181
- )
182
-
183
-
184
- @make_task(
185
- name="register-my-app-name-route",
186
- input=[existing_module_input, new_entity_input],
187
- retries=0,
188
- upstream=validate_create_my_app_name_entity,
189
- )
190
- async def register_my_app_name_route(ctx: AnyContext):
191
- direct_client_file_path = os.path.join(
192
- APP_DIR, "module", to_snake_case(ctx.input.module), "route.py"
193
- )
194
- file_content = read_file(direct_client_file_path)
195
- entity_name = to_snake_case(ctx.input.entity)
196
- new_code = append_code_to_function(
197
- file_content, "serve_route", f"{entity_name}_usecase.serve_route(app)"
198
- )
199
- app_name = os.path.basename(APP_DIR)
200
- module_name = to_snake_case(ctx.input.module)
201
- new_file_content_list = [
202
- f"from {app_name}.module.{module_name}.service.{entity_name}.{entity_name}_usecase import {entity_name}_usecase", # noqa
203
- new_code.strip(),
204
- "",
205
- ]
206
- write_file(direct_client_file_path, "\n".join(new_file_content_list))
207
-
208
-
209
- @make_task(
210
- name="register-my-app-name-client-method",
211
- input=[existing_module_input, new_entity_input],
212
- retries=0,
213
- upstream=validate_create_my_app_name_entity,
214
- )
215
- async def register_my_app_name_client_method(ctx: AnyContext):
216
- any_client_file_path = os.path.join(
217
- APP_DIR, "module", to_snake_case(ctx.input.module), "route.py"
218
- )
219
- file_content = read_file(any_client_file_path)
220
- app_name = os.path.basename(APP_DIR)
221
- snake_entity_name = to_snake_case(ctx.input.entity)
222
- pascal_entity_name = to_pascal_case(ctx.input.entity)
223
- # TODO: Register client methods
224
- # get methods
225
- any_client_method_template_path = (
226
- os.path.join(os.path.dirname(__file__), "any_client_method.template.py"),
227
- )
228
- any_client_method_template = read_file(any_client_method_template_path)
229
- any_client_method = any_client_method_template.replace(
230
- "my_entity", snake_entity_name
231
- ).replace("MyEntity", pascal_entity_name)
232
- new_code = append_code_to_class(file_content, "AnyClient", any_client_method)
233
- new_file_content_list = [
234
- f"from {app_name}.schema.{snake_entity_name}.{snake_entity_name} import (",
235
- f" {pascal_entity_name}CreateWithAudit, {pascal_entity_name}Response, {pascal_entity_name}UpdateWithAudit",
236
- ")",
237
- new_code.strip(),
238
- "",
239
- ]
240
- write_file(any_client_file_path, "\n".join(new_file_content_list))
241
-
242
-
243
- # TODO: Register gateway route
244
-
245
-
246
- create_my_app_name_entity = app_create_group.add_task(
247
- Task(
248
- name="create-my-app-name-entity",
249
- description="🏗️ Create new entity on a module",
250
- successor="",
251
- ),
252
- alias="entity",
253
- )
254
- create_my_app_name_entity << [
255
- scaffold_my_app_name_schema,
256
- scaffold_my_app_name_module_entity,
257
- register_my_app_name_api_client,
258
- register_my_app_name_direct_client,
259
- register_my_app_name_route,
260
- ]
@@ -1,143 +0,0 @@
1
- import os
2
-
3
- from fastapp_template._zrb.config import APP_DIR
4
- from fastapp_template._zrb.group import app_create_group
5
- from fastapp_template._zrb.input import new_module_input
6
- from fastapp_template._zrb.util import get_existing_module_names
7
-
8
- from zrb import AnyContext, Scaffolder, Task, make_task
9
- from zrb.util.file import read_file, write_file
10
- from zrb.util.string.conversion import to_kebab_case, to_pascal_case, to_snake_case
11
-
12
-
13
- @make_task(
14
- name="validate-create-my-app-name-module",
15
- input=new_module_input,
16
- retries=0,
17
- )
18
- async def validate_create_my_app_name_module(ctx: AnyContext):
19
- if ctx.input.module in get_existing_module_names():
20
- raise ValueError(f"Module already exists: {ctx.input.module}")
21
-
22
-
23
- scaffold_my_app_name_module = Scaffolder(
24
- name="scaffold-my-app-name-module",
25
- input=new_module_input,
26
- source_path=os.path.join(os.path.dirname(__file__), "template", "module_template"),
27
- render_source_path=False,
28
- destination_path=lambda ctx: os.path.join(
29
- APP_DIR,
30
- "module",
31
- to_snake_case(ctx.input.module),
32
- ),
33
- transform_content={
34
- "module_template": "{to_snake_case(ctx.input.module)}",
35
- "MY_MODULE": "{to_snake_case(ctx.input.module).upper()}",
36
- "my_module": "{to_snake_case(ctx.input.module)}",
37
- },
38
- retries=0,
39
- upstream=validate_create_my_app_name_module,
40
- )
41
-
42
-
43
- @make_task(
44
- name="register-my-app-name-module-config",
45
- input=new_module_input,
46
- upstream=validate_create_my_app_name_module,
47
- retries=0,
48
- )
49
- async def register_my_app_name_module_config(ctx: AnyContext):
50
- """Registering module to config.py"""
51
- existing_module_names = get_existing_module_names()
52
- module_port = 3000 + len(
53
- [
54
- module_name
55
- for module_name in existing_module_names
56
- if module_name != to_snake_case(ctx.input.module)
57
- ]
58
- )
59
- module_base_url = f"http://localhost:{module_port}"
60
- config_file_name = os.path.join(APP_DIR, "config.py")
61
- upper_module_name = to_snake_case(ctx.input.module).upper()
62
- config_name = f"APP_{upper_module_name}_BASE_URL"
63
- env_name = f"MY_APP_NAME_{upper_module_name}_BASE_URL"
64
- # TODO: check before write
65
- write_file(
66
- config_file_name,
67
- [
68
- read_file(config_file_name),
69
- f'{config_name} = os.getenv("{env_name}", "{module_base_url}")\n',
70
- ],
71
- )
72
-
73
-
74
- @make_task(
75
- name="register-my-app-name-module",
76
- input=new_module_input,
77
- upstream=validate_create_my_app_name_module,
78
- retries=0,
79
- )
80
- async def register_my_app_name_module(ctx: AnyContext):
81
- """Registering module to application's main.py"""
82
- app_main_file_name = os.path.join(APP_DIR, "main.py")
83
- module_name = to_snake_case(ctx.input.module)
84
- import_code = f"from fastapp_template.module.{module_name} import route as {module_name}_route" # noqa
85
- assert_code = f"assert {module_name}_route"
86
- code = read_file(app_main_file_name)
87
- new_code = "\n".join([import_code, code.strip(), assert_code, ""])
88
- # TODO: check before write
89
- write_file(app_main_file_name, new_code)
90
-
91
-
92
- # TODO: Register to zrb's config
93
-
94
-
95
- @make_task(
96
- name="add-my-app-name-module-task-to-zrb-init",
97
- input=new_module_input,
98
- upstream=validate_create_my_app_name_module,
99
- retries=0,
100
- )
101
- async def add_my_app_name_module_task_to_zrb_init(ctx: AnyContext):
102
- """Registering module to _zrb's task.py"""
103
- task_main_file_name = os.path.join(APP_DIR, "_zrb", "task.py")
104
- existing_module_names = get_existing_module_names()
105
- module_port = 3001 + len(
106
- [
107
- module_name
108
- for module_name in existing_module_names
109
- if module_name != to_snake_case(ctx.input.module)
110
- ]
111
- )
112
- module_snake_name = to_snake_case(ctx.input.module)
113
- module_kebab_name = to_kebab_case(ctx.input.module)
114
- module_pascal_name = to_pascal_case(ctx.input.module)
115
- module_runner_code = read_file(
116
- os.path.join(os.path.dirname(__file__), "template", "task_definition.py"),
117
- {
118
- "my_module": module_snake_name,
119
- "my-module": module_kebab_name,
120
- "My Module": module_pascal_name,
121
- "3000": f"{module_port}",
122
- },
123
- )
124
- code = read_file(task_main_file_name)
125
- new_code = "\n".join([code.strip(), "", module_runner_code, ""])
126
- # TODO: check before write
127
- write_file(task_main_file_name, new_code)
128
-
129
-
130
- create_my_app_name_module = app_create_group.add_task(
131
- Task(
132
- name="create-my-app-name-module",
133
- description="🧩 Create new module on My App Name",
134
- upstream=[
135
- scaffold_my_app_name_module,
136
- register_my_app_name_module,
137
- register_my_app_name_module_config,
138
- add_my_app_name_module_task_to_zrb_init,
139
- ],
140
- retries=0,
141
- ),
142
- alias="module",
143
- )
@@ -1,6 +0,0 @@
1
- from fastapp_template.config import APP_MY_MODULE_BASE_URL
2
- from fastapp_template.module.module_template.client.any_client import AnyClient
3
-
4
-
5
- class APIClient(AnyClient):
6
- pass
@@ -1,6 +0,0 @@
1
- from fastapp_template.module.module_template.client.any_client import AnyClient
2
- from fastapp_template.module.module_template.service.user.usecase import user_usecase
3
-
4
-
5
- class DirectClient(AnyClient):
6
- pass
@@ -1,9 +0,0 @@
1
- from fastapp_template.config import APP_COMMUNICATION
2
- from fastapp_template.module.module_template.client.any_client import AnyClient
3
- from fastapp_template.module.module_template.client.api_client import APIClient
4
- from fastapp_template.module.module_template.client.direct_client import DirectClient
5
-
6
- if APP_COMMUNICATION == "direct":
7
- client: AnyClient = DirectClient()
8
- elif APP_COMMUNICATION == "api":
9
- client: AnyClient = APIClient()
@@ -1,7 +0,0 @@
1
- from fastapp_template.common.app import app
2
- from fastapp_template.module.auth import route as auth_route
3
- from fastapp_template.module.gateway import route as gateway_route
4
-
5
- assert app
6
- assert gateway_route
7
- assert auth_route
@@ -1,3 +0,0 @@
1
- from fastapp_template.module.auth import migration as auth_migration
2
-
3
- assert auth_migration
@@ -1,7 +0,0 @@
1
- from fastapp_template.config import APP_AUTH_BASE_URL
2
- from fastapp_template.module.auth.client.any_client import AnyClient
3
- from fastapp_template.module.auth.service.user.user_usecase import user_usecase
4
-
5
-
6
- class APIClient(user_usecase.as_api_client(base_url=APP_AUTH_BASE_URL), AnyClient):
7
- pass
@@ -1,6 +0,0 @@
1
- from fastapp_template.module.auth.client.any_client import AnyClient
2
- from fastapp_template.module.auth.service.user.user_usecase import user_usecase
3
-
4
-
5
- class DirectClient(user_usecase.as_direct_client(), AnyClient):
6
- pass
@@ -1,9 +0,0 @@
1
- from fastapp_template.config import APP_COMMUNICATION
2
- from fastapp_template.module.auth.client.any_client import AnyClient
3
- from fastapp_template.module.auth.client.api_client import APIClient
4
- from fastapp_template.module.auth.client.direct_client import DirectClient
5
-
6
- if APP_COMMUNICATION == "direct":
7
- client: AnyClient = DirectClient()
8
- elif APP_COMMUNICATION == "api":
9
- client: AnyClient = APIClient()
@@ -1,13 +0,0 @@
1
- from fastapp_template.common.db_engine import engine
2
- from fastapp_template.config import APP_REPOSITORY_TYPE
3
- from fastapp_template.module.auth.service.user.repository.user_db_repository import (
4
- UserDBRepository,
5
- )
6
- from fastapp_template.module.auth.service.user.repository.user_repository import (
7
- UserRepository,
8
- )
9
-
10
- if APP_REPOSITORY_TYPE == "db":
11
- user_repository: UserRepository = UserDBRepository(engine)
12
- else:
13
- user_repository: UserRepository = None
@@ -1,37 +0,0 @@
1
- function getFinalColor(finalStatus) {
2
- switch(finalStatus) {
3
- case "started":
4
- return "#3498db";
5
- case "ready":
6
- return "#f39c12";
7
- case "completed":
8
- return "#2ecc71";
9
- case "skipped":
10
- return "#95a5a6";
11
- case "failed":
12
- return "#e74c3c";
13
- case "permanently-failed":
14
- return "#c0392b";
15
- case "terminated":
16
- return "#ffffff";
17
- default:
18
- return "#ffffff";
19
- }
20
- }
21
-
22
- function getFinalTaskStatus(taskStatus) {
23
- if (taskStatus.is_completed) {
24
- return "completed";
25
- }
26
- if (taskStatus.is_terminated) {
27
- return "terminated"
28
- }
29
- if (taskStatus.is_permanently_failed) {
30
- return "permanently-failed"
31
- }
32
- const histories = taskStatus.history;
33
- if (histories.length > 0) {
34
- return histories[histories.length - 1].status;
35
- }
36
- return "";
37
- }