FastAPI-fastkit 1.0.0__py3-none-any.whl → 1.0.2__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 (128) hide show
  1. fastapi_fastkit/__init__.py +10 -1
  2. fastapi_fastkit/backend/main.py +482 -482
  3. fastapi_fastkit/backend/transducer.py +106 -106
  4. fastapi_fastkit/cli.py +664 -631
  5. fastapi_fastkit/core/settings.py +155 -155
  6. fastapi_fastkit/fastapi_project_template/README.md +90 -90
  7. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/.env-tpl +1 -1
  8. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/.gitignore-tpl +30 -30
  9. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/README.md-tpl +107 -107
  10. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/requirements.txt-tpl +36 -36
  11. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/format.sh-tpl +5 -5
  12. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/lint.sh-tpl +5 -5
  13. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/run-server.sh-tpl +8 -8
  14. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/scripts/test.sh-tpl +6 -6
  15. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/setup.cfg-tpl +14 -14
  16. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/setup.py-tpl +25 -25
  17. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/api/api.py-tpl +9 -9
  18. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/api/routes/items.py-tpl +57 -57
  19. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/core/config.py-tpl +64 -64
  20. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/crud/items.py-tpl +21 -21
  21. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/main.py-tpl +26 -26
  22. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/mocks/mock_items.json-tpl +8 -8
  23. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/src/schemas/items.py-tpl +22 -22
  24. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/tests/conftest.py-tpl +42 -42
  25. fastapi_fastkit/fastapi_project_template/fastapi-async-crud/tests/test_items.py-tpl +48 -48
  26. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/.env-tpl +1 -1
  27. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/.gitignore-tpl +191 -191
  28. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/README.md-tpl +156 -156
  29. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/requirements.txt-tpl +36 -36
  30. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/format.sh-tpl +5 -5
  31. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/lint.sh-tpl +5 -5
  32. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/run-server.sh-tpl +8 -8
  33. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/scripts/test.sh-tpl +6 -6
  34. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/setup.cfg-tpl +12 -12
  35. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/setup.py-tpl +27 -27
  36. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/.DS_Store +0 -0
  37. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/api/api.py-tpl +9 -9
  38. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/api/routes/items.py-tpl +172 -172
  39. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/core/config.py-tpl +64 -64
  40. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/crud/items.py-tpl +21 -21
  41. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/helper/exceptions.py-tpl +103 -103
  42. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/helper/pagination.py-tpl +72 -72
  43. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/main.py-tpl +39 -39
  44. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/mocks/mock_items.json-tpl +8 -8
  45. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/schemas/base.py-tpl +49 -49
  46. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/schemas/items.py-tpl +22 -22
  47. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/src/utils/documents.py-tpl +20 -20
  48. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/tests/conftest.py-tpl +42 -42
  49. fastapi_fastkit/fastapi_project_template/fastapi-custom-response/tests/test_items.py-tpl +61 -61
  50. fastapi_fastkit/fastapi_project_template/fastapi-default/README.md-tpl +101 -101
  51. fastapi_fastkit/fastapi_project_template/fastapi-default/scripts/run-server.sh-tpl +8 -8
  52. fastapi_fastkit/fastapi_project_template/fastapi-default/setup.py-tpl +22 -22
  53. fastapi_fastkit/fastapi_project_template/fastapi-default/src/mocks/mock_items.json-tpl +8 -8
  54. fastapi_fastkit/fastapi_project_template/fastapi-default/tests/conftest.py-tpl +30 -30
  55. fastapi_fastkit/fastapi_project_template/fastapi-default/tests/test_items.py-tpl +44 -44
  56. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/.env-tpl +1 -1
  57. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/.gitignore-tpl +30 -30
  58. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/Dockerfile-tpl +23 -23
  59. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/README.md-tpl +119 -119
  60. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/requirements.txt-tpl +36 -36
  61. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/format.sh-tpl +5 -5
  62. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/lint.sh-tpl +5 -5
  63. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/run-server.sh-tpl +8 -8
  64. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/scripts/test.sh-tpl +6 -6
  65. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/setup.cfg-tpl +13 -13
  66. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/setup.py-tpl +22 -22
  67. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/api/api.py-tpl +6 -6
  68. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/api/routes/items.py-tpl +54 -54
  69. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/core/config.py-tpl +64 -64
  70. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/crud/items.py-tpl +15 -15
  71. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/main.py-tpl +26 -26
  72. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/mocks/mock_items.json-tpl +8 -8
  73. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/src/schemas/items.py-tpl +19 -19
  74. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/tests/conftest.py-tpl +30 -30
  75. fastapi_fastkit/fastapi_project_template/fastapi-dockerized/tests/test_items.py-tpl +44 -44
  76. fastapi_fastkit/fastapi_project_template/fastapi-empty/.env-tpl +1 -1
  77. fastapi_fastkit/fastapi_project_template/fastapi-empty/setup.py-tpl +22 -22
  78. fastapi_fastkit/fastapi_project_template/fastapi-empty/src/core/config.py-tpl +75 -75
  79. fastapi_fastkit/fastapi_project_template/fastapi-empty/src/main.py-tpl +36 -36
  80. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/.env-tpl +9 -9
  81. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/.gitignore-tpl +30 -30
  82. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/Dockerfile-tpl +23 -23
  83. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/README.md-tpl +144 -144
  84. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/alembic.ini-tpl +119 -119
  85. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/docker-compose.yml-tpl +44 -44
  86. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/requirements.txt-tpl +41 -41
  87. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/format.sh-tpl +5 -5
  88. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/lint.sh-tpl +5 -5
  89. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/pre-start.sh-tpl +16 -16
  90. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/run-server.sh-tpl +8 -8
  91. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/scripts/test.sh-tpl +10 -10
  92. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/setup.cfg-tpl +13 -13
  93. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/setup.py-tpl +25 -25
  94. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/README-tpl +1 -1
  95. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/env.py-tpl +85 -85
  96. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/script.py.mako-tpl +26 -26
  97. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/alembic/versions/bedcdc35b64a_first_alembic.py-tpl +37 -37
  98. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/api.py-tpl +11 -11
  99. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/deps.py-tpl +19 -19
  100. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/api/routes/items.py-tpl +109 -109
  101. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/core/config.py-tpl +88 -88
  102. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/core/db.py-tpl +53 -53
  103. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/crud/items.py-tpl +102 -102
  104. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/main.py-tpl +45 -45
  105. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/schemas/items.py-tpl +54 -54
  106. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/backend_pre_start.py-tpl +39 -39
  107. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/init_data.py-tpl +23 -23
  108. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/src/utils/tests_pre_start.py-tpl +39 -39
  109. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/tests/conftest.py-tpl +63 -63
  110. fastapi_fastkit/fastapi_project_template/fastapi-psql-orm/tests/test_items.py-tpl +44 -44
  111. fastapi_fastkit/fastapi_project_template/modules/api/routes/new_route.py-tpl +64 -64
  112. fastapi_fastkit/fastapi_project_template/modules/crud/new_route.py-tpl +29 -29
  113. fastapi_fastkit/fastapi_project_template/modules/schemas/new_route.py-tpl +23 -23
  114. fastapi_fastkit/logs/fastkit_debug_20250702_161423.log +21 -0
  115. fastapi_fastkit/logs/fastkit_debug_20250702_162706.log +20 -0
  116. fastapi_fastkit/logs/fastkit_debug_20250702_163010.log +21 -0
  117. fastapi_fastkit/logs/fastkit_debug_20250702_163526.log +21 -0
  118. fastapi_fastkit/logs/fastkit_debug_20250702_164053.log +21 -0
  119. fastapi_fastkit/logs/fastkit_debug_20250702_165220.log +21 -0
  120. fastapi_fastkit/logs/fastkit_debug_20250702_165647.log +21 -0
  121. fastapi_fastkit/utils/logging.py +112 -1
  122. fastapi_fastkit/utils/main.py +140 -129
  123. fastapi_fastkit-1.0.2.dist-info/METADATA +320 -0
  124. {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/RECORD +127 -119
  125. {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/WHEEL +1 -1
  126. {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/licenses/LICENSE +21 -21
  127. fastapi_fastkit-1.0.0.dist-info/METADATA +0 -208
  128. {fastapi_fastkit-1.0.0.dist-info → fastapi_fastkit-1.0.2.dist-info}/entry_points.txt +0 -0
@@ -1,106 +1,106 @@
1
- # --------------------------------------------------------------------------
2
- # The Module transduces .*-tpl extension files to their respective file extensions
3
- # and copies them to user's local directory.
4
- #
5
- # This will handle .py-tpl, .txt-tpl, .md-tpl, etc.
6
- #
7
- # @author bnbong
8
- # --------------------------------------------------------------------------
9
- import os
10
- import shutil
11
-
12
-
13
- def _convert_tpl_to_real_extension(file_path: str) -> str:
14
- """
15
- Converts a file ending in `.*-tpl` to its respective file extension by removing the `-tpl` suffix.
16
-
17
- :param file_path: The full path of the `.*-tpl` file.
18
- :type file_path: str
19
- :return: The new path of the file with the `-tpl` suffix removed.
20
- """
21
- # Remove the '-tpl' suffix from any file extension
22
- if file_path.endswith("-tpl"):
23
- new_file_path = file_path.replace("-tpl", "")
24
- os.rename(file_path, new_file_path)
25
- return new_file_path
26
- return file_path
27
-
28
-
29
- def copy_and_convert_template(
30
- template_dir: str, target_dir: str, project_name: str = ""
31
- ) -> None:
32
- """
33
- Copies all files from the template directory to the target directory,
34
- converting any files ending in `.*-tpl` during the copy process.
35
-
36
- :param project_name: name of new project user defined at CLI.
37
- :param template_dir: The source directory containing the template files.
38
- :type template_dir: str
39
- :param target_dir: The destination directory where files will be copied.
40
- :type target_dir: str
41
- """
42
- template_name = os.path.basename(template_dir)
43
- if project_name is None:
44
- project_name = template_name
45
- target_path = os.path.join(target_dir, project_name)
46
- os.makedirs(target_path, exist_ok=True)
47
-
48
- for root, dirs, files in os.walk(template_dir):
49
- relative_path = os.path.relpath(root, template_dir)
50
- destination_dir = os.path.join(target_path, relative_path)
51
-
52
- if not os.path.exists(destination_dir):
53
- os.makedirs(destination_dir)
54
-
55
- for file in files:
56
- src_file = os.path.join(root, file)
57
-
58
- if file.endswith("-tpl"):
59
- dst_file = os.path.join(destination_dir, file.replace("-tpl", ""))
60
- shutil.copy2(src_file, dst_file)
61
- _convert_tpl_to_real_extension(dst_file)
62
- else:
63
- dst_file = os.path.join(destination_dir, file)
64
- shutil.copy2(src_file, dst_file)
65
-
66
-
67
- def copy_and_convert_template_file(
68
- source_file: str, target_file: str, replacements: dict = None # type: ignore
69
- ) -> bool:
70
- """
71
- Copies a single template file to the target location, converting it from .*-tpl
72
- to its proper extension and replacing any placeholders with provided values.
73
-
74
- :param source_file: Path to the source template file (with -tpl extension)
75
- :param target_file: Path to target destination file (without -tpl extension)
76
- :param replacements: Dictionary of placeholder replacements {placeholder: value}
77
- :return: True if successful, False otherwise
78
- """
79
- try:
80
- if not os.path.exists(source_file):
81
- return False
82
-
83
- # Read a single source content (with .py-tpl extension)
84
- with open(source_file, "r") as src_file:
85
- content = src_file.read()
86
-
87
- if replacements and isinstance(replacements, dict):
88
- for placeholder, value in replacements.items():
89
- content = content.replace(placeholder, value)
90
-
91
- target_dir = os.path.dirname(target_file)
92
- os.makedirs(target_dir, exist_ok=True)
93
-
94
- with open(target_file, "w") as tgt_file:
95
- tgt_file.write(content)
96
-
97
- return True
98
- except Exception as e:
99
- print(f"Error copying template file: {e}")
100
- return False
101
-
102
-
103
- def _convert_real_extension_to_tpl() -> None:
104
- # TODO : impl this for converting runnable FastAPI app code to template - debugging operation for contributors
105
- # this will be used at inspector module, not package user's runtime.
106
- pass
1
+ # --------------------------------------------------------------------------
2
+ # The Module transduces .*-tpl extension files to their respective file extensions
3
+ # and copies them to user's local directory.
4
+ #
5
+ # This will handle .py-tpl, .txt-tpl, .md-tpl, etc.
6
+ #
7
+ # @author bnbong
8
+ # --------------------------------------------------------------------------
9
+ import os
10
+ import shutil
11
+
12
+
13
+ def _convert_tpl_to_real_extension(file_path: str) -> str:
14
+ """
15
+ Converts a file ending in `.*-tpl` to its respective file extension by removing the `-tpl` suffix.
16
+
17
+ :param file_path: The full path of the `.*-tpl` file.
18
+ :type file_path: str
19
+ :return: The new path of the file with the `-tpl` suffix removed.
20
+ """
21
+ # Remove the '-tpl' suffix from any file extension
22
+ if file_path.endswith("-tpl"):
23
+ new_file_path = file_path.replace("-tpl", "")
24
+ os.rename(file_path, new_file_path)
25
+ return new_file_path
26
+ return file_path
27
+
28
+
29
+ def copy_and_convert_template(
30
+ template_dir: str, target_dir: str, project_name: str = ""
31
+ ) -> None:
32
+ """
33
+ Copies all files from the template directory to the target directory,
34
+ converting any files ending in `.*-tpl` during the copy process.
35
+
36
+ :param project_name: name of new project user defined at CLI.
37
+ :param template_dir: The source directory containing the template files.
38
+ :type template_dir: str
39
+ :param target_dir: The destination directory where files will be copied.
40
+ :type target_dir: str
41
+ """
42
+ template_name = os.path.basename(template_dir)
43
+ if project_name is None:
44
+ project_name = template_name
45
+ target_path = os.path.join(target_dir, project_name)
46
+ os.makedirs(target_path, exist_ok=True)
47
+
48
+ for root, dirs, files in os.walk(template_dir):
49
+ relative_path = os.path.relpath(root, template_dir)
50
+ destination_dir = os.path.join(target_path, relative_path)
51
+
52
+ if not os.path.exists(destination_dir):
53
+ os.makedirs(destination_dir)
54
+
55
+ for file in files:
56
+ src_file = os.path.join(root, file)
57
+
58
+ if file.endswith("-tpl"):
59
+ dst_file = os.path.join(destination_dir, file.replace("-tpl", ""))
60
+ shutil.copy2(src_file, dst_file)
61
+ _convert_tpl_to_real_extension(dst_file)
62
+ else:
63
+ dst_file = os.path.join(destination_dir, file)
64
+ shutil.copy2(src_file, dst_file)
65
+
66
+
67
+ def copy_and_convert_template_file(
68
+ source_file: str, target_file: str, replacements: dict = None # type: ignore
69
+ ) -> bool:
70
+ """
71
+ Copies a single template file to the target location, converting it from .*-tpl
72
+ to its proper extension and replacing any placeholders with provided values.
73
+
74
+ :param source_file: Path to the source template file (with -tpl extension)
75
+ :param target_file: Path to target destination file (without -tpl extension)
76
+ :param replacements: Dictionary of placeholder replacements {placeholder: value}
77
+ :return: True if successful, False otherwise
78
+ """
79
+ try:
80
+ if not os.path.exists(source_file):
81
+ return False
82
+
83
+ # Read a single source content (with .py-tpl extension)
84
+ with open(source_file, "r") as src_file:
85
+ content = src_file.read()
86
+
87
+ if replacements and isinstance(replacements, dict):
88
+ for placeholder, value in replacements.items():
89
+ content = content.replace(placeholder, value)
90
+
91
+ target_dir = os.path.dirname(target_file)
92
+ os.makedirs(target_dir, exist_ok=True)
93
+
94
+ with open(target_file, "w") as tgt_file:
95
+ tgt_file.write(content)
96
+
97
+ return True
98
+ except Exception as e:
99
+ print(f"Error copying template file: {e}")
100
+ return False
101
+
102
+
103
+ def _convert_real_extension_to_tpl() -> None:
104
+ # TODO : impl this for converting runnable FastAPI app code to template - debugging operation for contributors
105
+ # this will be used at inspector module, not package user's runtime.
106
+ pass