amsdal_cli 0.5.3__py3-none-any.whl → 0.5.5__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.
- amsdal_cli/__about__.py +1 -1
- amsdal_cli/commands/callbacks.py +2 -2
- amsdal_cli/commands/cloud/dependency/sub_commands/dependency_list.py +1 -1
- amsdal_cli/commands/cloud/dependency/sub_commands/dependency_new.py +1 -1
- amsdal_cli/commands/cloud/deploy/sub_commands/deploy_list.py +1 -1
- amsdal_cli/commands/generate/sub_commands/generate_model.py +1 -1
- amsdal_cli/commands/migrations/sub_commands/__init__.py +2 -0
- amsdal_cli/commands/migrations/sub_commands/make_contrib.py +179 -0
- amsdal_cli/commands/plugin/__init__.py +0 -0
- amsdal_cli/commands/plugin/command.py +152 -0
- amsdal_cli/commands/plugin/templates/.amsdal-cli +10 -0
- amsdal_cli/commands/plugin/templates/README.md +50 -0
- amsdal_cli/commands/plugin/templates/config.yml +20 -0
- amsdal_cli/commands/plugin/templates/pyproject.toml +16 -0
- amsdal_cli/commands/plugin/templates/src/__about__.py +1 -0
- amsdal_cli/commands/plugin/templates/src/__init__.py +0 -0
- amsdal_cli/commands/plugin/templates/src/models/__init__.py +1 -0
- amsdal_cli/commands/plugin/templates/src/transactions/__init__.py +1 -0
- amsdal_cli/commands/plugin/templates/src/transactions/example_transaction.py +47 -0
- amsdal_cli/config/main.py +1 -0
- amsdal_cli/utils/cli_config.py +1 -0
- {amsdal_cli-0.5.3.dist-info → amsdal_cli-0.5.5.dist-info}/METADATA +1 -1
- {amsdal_cli-0.5.3.dist-info → amsdal_cli-0.5.5.dist-info}/RECORD +26 -14
- {amsdal_cli-0.5.3.dist-info → amsdal_cli-0.5.5.dist-info}/WHEEL +0 -0
- {amsdal_cli-0.5.3.dist-info → amsdal_cli-0.5.5.dist-info}/entry_points.txt +0 -0
- {amsdal_cli-0.5.3.dist-info → amsdal_cli-0.5.5.dist-info}/licenses/LICENSE.txt +0 -0
amsdal_cli/__about__.py
CHANGED
amsdal_cli/commands/callbacks.py
CHANGED
|
@@ -8,7 +8,7 @@ from amsdal_utils.config.manager import AmsdalConfigManager
|
|
|
8
8
|
from rich import print as rprint
|
|
9
9
|
from typer import Option
|
|
10
10
|
|
|
11
|
-
COMMANDS_DO_NOT_REQUIRE_APP_PATH = ('new', 'n', 'api-check')
|
|
11
|
+
COMMANDS_DO_NOT_REQUIRE_APP_PATH = ('new', 'n', 'plugin', 'api-check')
|
|
12
12
|
|
|
13
13
|
|
|
14
14
|
def init_app_context(
|
|
@@ -94,7 +94,7 @@ def init_app_context(
|
|
|
94
94
|
try:
|
|
95
95
|
amsdal_config = AmsdalConfigManager().get_config()
|
|
96
96
|
except Exception:
|
|
97
|
-
AmsdalConfigManager().load_config(
|
|
97
|
+
AmsdalConfigManager().load_config(config.config_path)
|
|
98
98
|
|
|
99
99
|
amsdal_config = AmsdalConfigManager().get_config()
|
|
100
100
|
|
|
@@ -47,7 +47,7 @@ async def list_command(
|
|
|
47
47
|
|
|
48
48
|
manager.authenticate()
|
|
49
49
|
|
|
50
|
-
AmsdalConfigManager().load_config(
|
|
50
|
+
AmsdalConfigManager().load_config(cli_config.config_path)
|
|
51
51
|
|
|
52
52
|
try:
|
|
53
53
|
list_response = manager.cloud_actions_manager.list_deploys(list_all=list_all)
|
|
@@ -151,7 +151,7 @@ def generate_model(
|
|
|
151
151
|
models_package_path=output_path,
|
|
152
152
|
models_module_path=settings.USER_MODELS_MODULE,
|
|
153
153
|
object_schema=ObjectSchema(**json_schema),
|
|
154
|
-
module_type=ModuleType.USER,
|
|
154
|
+
module_type=ModuleType.CONTRIB if cli_config.is_plugin else ModuleType.USER,
|
|
155
155
|
dependencies=schema_repository.model_module_info, # type: ignore[arg-type]
|
|
156
156
|
indent_width=' ' * cli_config.indent,
|
|
157
157
|
)
|
|
@@ -7,10 +7,12 @@ from amsdal_cli.commands.migrations.app import sub_app
|
|
|
7
7
|
from amsdal_cli.commands.migrations.sub_commands.apply import apply_migrations
|
|
8
8
|
from amsdal_cli.commands.migrations.sub_commands.list import list_migrations
|
|
9
9
|
from amsdal_cli.commands.migrations.sub_commands.make import make_migrations
|
|
10
|
+
from amsdal_cli.commands.migrations.sub_commands.make_contrib import make_contrib_migrations
|
|
10
11
|
|
|
11
12
|
__all__ = [
|
|
12
13
|
'apply_migrations',
|
|
13
14
|
'list_migrations',
|
|
15
|
+
'make_contrib_migrations',
|
|
14
16
|
'make_migrations',
|
|
15
17
|
]
|
|
16
18
|
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
from typing import Annotated
|
|
5
|
+
|
|
6
|
+
import typer
|
|
7
|
+
from rich import print as rprint
|
|
8
|
+
|
|
9
|
+
from amsdal_cli.commands.migrations.app import sub_app
|
|
10
|
+
from amsdal_cli.utils.cli_config import ModelsFormat
|
|
11
|
+
|
|
12
|
+
if TYPE_CHECKING:
|
|
13
|
+
from amsdal_cli.utils.cli_config import CliConfig
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def _sync_make_contrib_migrations(
|
|
17
|
+
name: str | None,
|
|
18
|
+
*,
|
|
19
|
+
is_data: bool,
|
|
20
|
+
cli_config: 'CliConfig',
|
|
21
|
+
) -> None:
|
|
22
|
+
from amsdal.configs.constants import CORE_MIGRATIONS_PATH
|
|
23
|
+
from amsdal.configs.main import settings
|
|
24
|
+
from amsdal.manager import AmsdalManager
|
|
25
|
+
from amsdal_models.migration.data_classes import MigrationFile
|
|
26
|
+
from amsdal_models.migration.file_migration_generator import FileMigrationGenerator
|
|
27
|
+
from amsdal_utils.utils.text import to_snake_case
|
|
28
|
+
|
|
29
|
+
from amsdal_cli.commands.generate.enums import SOURCES_DIR
|
|
30
|
+
from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
|
|
31
|
+
from amsdal_cli.utils.schema_repository import build_schema_repository
|
|
32
|
+
from amsdal_cli.utils.text import rich_info
|
|
33
|
+
from amsdal_cli.utils.text import rich_success
|
|
34
|
+
|
|
35
|
+
amsdal_manager = AmsdalManager()
|
|
36
|
+
if not amsdal_manager._is_setup:
|
|
37
|
+
amsdal_manager.setup()
|
|
38
|
+
amsdal_manager.authenticate()
|
|
39
|
+
amsdal_manager.post_setup() # type: ignore[call-arg]
|
|
40
|
+
|
|
41
|
+
schema_repository = build_schema_repository(cli_config=cli_config)
|
|
42
|
+
migrations_dir: Path = cli_config.app_directory / SOURCES_DIR / MIGRATIONS_DIR_NAME
|
|
43
|
+
|
|
44
|
+
generator = FileMigrationGenerator(
|
|
45
|
+
core_migrations_path=CORE_MIGRATIONS_PATH,
|
|
46
|
+
app_migrations_path=migrations_dir,
|
|
47
|
+
contrib_migrations_directory_name=settings.CONTRIB_MIGRATIONS_DIRECTORY_NAME,
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
try:
|
|
51
|
+
name = to_snake_case(name) if name else None
|
|
52
|
+
migration: MigrationFile = generator.make_migrations(
|
|
53
|
+
schemas=schema_repository.contrib_schemas,
|
|
54
|
+
name=name,
|
|
55
|
+
is_data=is_data,
|
|
56
|
+
)
|
|
57
|
+
except UserWarning as warn:
|
|
58
|
+
rprint(rich_info(str(warn)))
|
|
59
|
+
else:
|
|
60
|
+
rprint(rich_success(f'Contrib migration created: {migration.path.name}'))
|
|
61
|
+
|
|
62
|
+
try:
|
|
63
|
+
amsdal_manager.teardown()
|
|
64
|
+
AmsdalManager.invalidate()
|
|
65
|
+
except Exception: # noqa: S110
|
|
66
|
+
pass
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
async def _async_make_contrib_migrations(
|
|
70
|
+
name: str | None,
|
|
71
|
+
*,
|
|
72
|
+
is_data: bool,
|
|
73
|
+
cli_config: 'CliConfig',
|
|
74
|
+
) -> None:
|
|
75
|
+
from amsdal.configs.constants import CORE_MIGRATIONS_PATH
|
|
76
|
+
from amsdal.configs.main import settings
|
|
77
|
+
from amsdal.manager import AsyncAmsdalManager
|
|
78
|
+
from amsdal_models.migration.data_classes import MigrationFile
|
|
79
|
+
from amsdal_models.migration.file_migration_generator import AsyncFileMigrationGenerator
|
|
80
|
+
from amsdal_utils.utils.text import to_snake_case
|
|
81
|
+
|
|
82
|
+
from amsdal_cli.commands.generate.enums import SOURCES_DIR
|
|
83
|
+
from amsdal_cli.commands.migrations.constants import MIGRATIONS_DIR_NAME
|
|
84
|
+
from amsdal_cli.utils.schema_repository import build_schema_repository
|
|
85
|
+
from amsdal_cli.utils.text import rich_info
|
|
86
|
+
from amsdal_cli.utils.text import rich_success
|
|
87
|
+
|
|
88
|
+
amsdal_manager = AsyncAmsdalManager()
|
|
89
|
+
if not amsdal_manager.is_setup:
|
|
90
|
+
await amsdal_manager.setup()
|
|
91
|
+
amsdal_manager.authenticate()
|
|
92
|
+
await amsdal_manager.post_setup() # type: ignore[call-arg, misc]
|
|
93
|
+
|
|
94
|
+
schema_repository = build_schema_repository(cli_config=cli_config)
|
|
95
|
+
migrations_dir: Path = cli_config.app_directory / SOURCES_DIR / MIGRATIONS_DIR_NAME
|
|
96
|
+
|
|
97
|
+
generator = AsyncFileMigrationGenerator(
|
|
98
|
+
core_migrations_path=CORE_MIGRATIONS_PATH,
|
|
99
|
+
app_migrations_path=migrations_dir,
|
|
100
|
+
contrib_migrations_directory_name=settings.CONTRIB_MODELS_PACKAGE_NAME,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
try:
|
|
104
|
+
name = to_snake_case(name) if name else None
|
|
105
|
+
migration: MigrationFile = await generator.make_migrations(
|
|
106
|
+
schemas=schema_repository.contrib_schemas,
|
|
107
|
+
name=name,
|
|
108
|
+
is_data=is_data,
|
|
109
|
+
)
|
|
110
|
+
except UserWarning as warn:
|
|
111
|
+
rprint(rich_info(str(warn)))
|
|
112
|
+
else:
|
|
113
|
+
rprint(rich_success(f'Contrib migration created: {migration.path.name}'))
|
|
114
|
+
|
|
115
|
+
await amsdal_manager.teardown()
|
|
116
|
+
AsyncAmsdalManager.invalidate()
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
@sub_app.command(name='new-contrib, nc')
|
|
120
|
+
def make_contrib_migrations(
|
|
121
|
+
ctx: typer.Context,
|
|
122
|
+
build_dir: Annotated[Path, typer.Option('--build-dir', '-b')] = Path('.'),
|
|
123
|
+
*,
|
|
124
|
+
name: Annotated[str, typer.Option('--name', '-n', help='Migration name')] = None, # type: ignore # noqa: RUF013
|
|
125
|
+
is_data: Annotated[bool, typer.Option('--data', '-d', help='Create data migration')] = False,
|
|
126
|
+
config: Annotated[Path, typer.Option('--config', '-c')] = None, # type: ignore # noqa: RUF013
|
|
127
|
+
) -> None:
|
|
128
|
+
"""
|
|
129
|
+
Creates schema migration based on the changes in the contrib models' schemas or
|
|
130
|
+
creates an empty data migration using --data flag.
|
|
131
|
+
|
|
132
|
+
Example usage:
|
|
133
|
+
|
|
134
|
+
1. Automatically creates a schema migrations based on the changes in the contrib models' schemas:
|
|
135
|
+
```bash
|
|
136
|
+
amsdal migrations new-contrib
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
2. Creates a schema migration with a custom name:
|
|
140
|
+
```bash
|
|
141
|
+
amsdal migrations new-contrib --name my_custom_contrib_migration
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
3. Creates a data migration:
|
|
145
|
+
```bash
|
|
146
|
+
amsdal migrations new-contrib --data --name my_contrib_data_migration
|
|
147
|
+
```
|
|
148
|
+
The data migrations allow you to write a python script to migrate your data. Useful for example when you have added
|
|
149
|
+
a new column to the table and you want to populate it with some data. So you first generate a schema migration that
|
|
150
|
+
adds the column and then you create a data migration that populates the column with the data.
|
|
151
|
+
"""
|
|
152
|
+
from amsdal_utils.config.manager import AmsdalConfigManager
|
|
153
|
+
|
|
154
|
+
from amsdal_cli.commands.build.services.builder import AppBuilder
|
|
155
|
+
from amsdal_cli.utils.cli_config import CliConfig
|
|
156
|
+
|
|
157
|
+
cli_config: CliConfig = ctx.meta['config']
|
|
158
|
+
|
|
159
|
+
app_builder = AppBuilder(
|
|
160
|
+
cli_config=cli_config,
|
|
161
|
+
config_path=config or cli_config.config_path,
|
|
162
|
+
)
|
|
163
|
+
app_builder.build(build_dir, is_silent=True)
|
|
164
|
+
cli_config.models_format = ModelsFormat.PY
|
|
165
|
+
|
|
166
|
+
if AmsdalConfigManager().get_config().async_mode:
|
|
167
|
+
asyncio.run(
|
|
168
|
+
_async_make_contrib_migrations(
|
|
169
|
+
name=name,
|
|
170
|
+
is_data=is_data,
|
|
171
|
+
cli_config=cli_config,
|
|
172
|
+
)
|
|
173
|
+
)
|
|
174
|
+
else:
|
|
175
|
+
_sync_make_contrib_migrations(
|
|
176
|
+
name=name,
|
|
177
|
+
is_data=is_data,
|
|
178
|
+
cli_config=cli_config,
|
|
179
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import random
|
|
2
|
+
import string
|
|
3
|
+
import uuid
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Annotated
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
import typer
|
|
9
|
+
from rich import print as rprint
|
|
10
|
+
|
|
11
|
+
from amsdal_cli.app import app
|
|
12
|
+
from amsdal_cli.utils.cli_config import ModelsFormat
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@app.command(name='plugin')
|
|
16
|
+
def plugin_command(
|
|
17
|
+
plugin_name: str = typer.Argument(
|
|
18
|
+
...,
|
|
19
|
+
help='The Plugin name. For example: MyPlugin',
|
|
20
|
+
),
|
|
21
|
+
output_path: Path = typer.Argument( # noqa: B008
|
|
22
|
+
...,
|
|
23
|
+
help='Output path, where the plugin will be created.',
|
|
24
|
+
),
|
|
25
|
+
*,
|
|
26
|
+
models_format: Annotated[
|
|
27
|
+
ModelsFormat,
|
|
28
|
+
typer.Option(help='The format of models used in this plugin.'),
|
|
29
|
+
] = ModelsFormat.PY,
|
|
30
|
+
is_async_mode: Annotated[
|
|
31
|
+
bool,
|
|
32
|
+
typer.Option('--async', help='Whether to run the plugin in async mode.'),
|
|
33
|
+
] = False,
|
|
34
|
+
) -> None:
|
|
35
|
+
"""
|
|
36
|
+
Generates a new AMSDAL plugin.
|
|
37
|
+
|
|
38
|
+
Example:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
amsdal plugin MyPlugin .
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
It will create `my_plugin` directory in the current directory with AMSDAL plugin structure.
|
|
45
|
+
"""
|
|
46
|
+
from amsdal.__about__ import __version__ as amsdal_version
|
|
47
|
+
from amsdal_utils.utils.text import slugify
|
|
48
|
+
from amsdal_utils.utils.text import to_snake_case
|
|
49
|
+
|
|
50
|
+
from amsdal_cli.commands.generate.enums import SOURCES_DIR
|
|
51
|
+
from amsdal_cli.utils.copier import copy_blueprints_from_directory
|
|
52
|
+
from amsdal_cli.utils.text import rich_error
|
|
53
|
+
from amsdal_cli.utils.text import rich_success
|
|
54
|
+
|
|
55
|
+
if not output_path.exists():
|
|
56
|
+
rprint(rich_error(f'The output path "{output_path.resolve()}" does not exist.'))
|
|
57
|
+
raise typer.Exit
|
|
58
|
+
|
|
59
|
+
if output_path.is_file():
|
|
60
|
+
rprint(rich_error(f'The output path "{output_path.resolve()}" is not a directory.'))
|
|
61
|
+
raise typer.Exit
|
|
62
|
+
|
|
63
|
+
output_path /= to_snake_case(plugin_name)
|
|
64
|
+
|
|
65
|
+
if output_path.exists():
|
|
66
|
+
if output_path.is_file():
|
|
67
|
+
rprint(rich_error(f'The path "{output_path.resolve()}" is not a directory.'))
|
|
68
|
+
raise typer.Exit
|
|
69
|
+
|
|
70
|
+
if any(output_path.iterdir()):
|
|
71
|
+
rprint(rich_error(f'The directory "{output_path.resolve()}" is not empty.'))
|
|
72
|
+
raise typer.Exit
|
|
73
|
+
|
|
74
|
+
application_uuid = (random.choice(string.ascii_lowercase) + uuid.uuid4().hex[:31]).lower() # noqa: S311
|
|
75
|
+
|
|
76
|
+
context = {
|
|
77
|
+
'application_uuid': application_uuid,
|
|
78
|
+
'plugin_name': plugin_name,
|
|
79
|
+
'plugin_name_slugify': slugify(plugin_name),
|
|
80
|
+
'plugin_name_snake': to_snake_case(plugin_name),
|
|
81
|
+
'amsdal_version': amsdal_version,
|
|
82
|
+
'models_format': models_format.value,
|
|
83
|
+
'is_async_mode': is_async_mode,
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
copy_blueprints_from_directory(
|
|
87
|
+
source_path=Path(__file__).parent / 'templates',
|
|
88
|
+
destination_path=output_path,
|
|
89
|
+
context=context,
|
|
90
|
+
)
|
|
91
|
+
(output_path / SOURCES_DIR).mkdir(exist_ok=True)
|
|
92
|
+
|
|
93
|
+
# Create example model based on format
|
|
94
|
+
_create_example_model(output_path, models_format, context)
|
|
95
|
+
|
|
96
|
+
rprint(rich_success(f'The plugin is successfully created in {output_path.resolve()}'))
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _create_example_model(output_path: Path, models_format: ModelsFormat, context: dict[str, Any]) -> None:
|
|
100
|
+
"""Create an example model based on the specified format."""
|
|
101
|
+
from amsdal_cli.utils.copier import write_file
|
|
102
|
+
|
|
103
|
+
models_dir = output_path / 'src' / 'models'
|
|
104
|
+
|
|
105
|
+
if models_format == ModelsFormat.JSON:
|
|
106
|
+
# Create JSON model
|
|
107
|
+
model_dir = models_dir / 'example_model'
|
|
108
|
+
model_dir.mkdir(exist_ok=True)
|
|
109
|
+
|
|
110
|
+
json_content = """{
|
|
111
|
+
"title": "ExampleModel",
|
|
112
|
+
"type": "object",
|
|
113
|
+
"properties": {
|
|
114
|
+
"name": {
|
|
115
|
+
"title": "name",
|
|
116
|
+
"type": "string"
|
|
117
|
+
},
|
|
118
|
+
"description": {
|
|
119
|
+
"title": "description",
|
|
120
|
+
"type": "string"
|
|
121
|
+
},
|
|
122
|
+
"is_active": {
|
|
123
|
+
"title": "is_active",
|
|
124
|
+
"type": "boolean",
|
|
125
|
+
"default": true
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"required": [
|
|
129
|
+
"name"
|
|
130
|
+
],
|
|
131
|
+
"indexed": [
|
|
132
|
+
"name"
|
|
133
|
+
]
|
|
134
|
+
}"""
|
|
135
|
+
write_file(json_content, model_dir / 'model.json', confirm_overwriting=False)
|
|
136
|
+
else:
|
|
137
|
+
# Create Python model
|
|
138
|
+
py_content = f"""from amsdal.types import BaseModel
|
|
139
|
+
from amsdal.types import Field
|
|
140
|
+
from amsdal_utils.models.enums import ModuleType
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
class ExampleModel(BaseModel):
|
|
144
|
+
\"\"\"Example model for {context['plugin_name']} plugin.\"\"\"
|
|
145
|
+
|
|
146
|
+
__module_type__ = ModuleType.CONTRIB
|
|
147
|
+
|
|
148
|
+
name: str = Field(..., index=True)
|
|
149
|
+
description: str = Field(default="")
|
|
150
|
+
is_active: bool = Field(default=True)
|
|
151
|
+
"""
|
|
152
|
+
write_file(py_content, models_dir / 'example_model.py', confirm_overwriting=False)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"config_path": "./config.yml",
|
|
3
|
+
"http_port": 8080,
|
|
4
|
+
"check_model_exists": true,
|
|
5
|
+
"json_indent": 4,
|
|
6
|
+
"application_uuid": "{{ ctx.application_uuid }}",
|
|
7
|
+
"application_name": "{{ ctx.plugin_name }}",
|
|
8
|
+
"models_format": "{{ ctx.models_format }}",
|
|
9
|
+
"is_plugin": true
|
|
10
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
# {{ ctx.plugin_name }}
|
|
2
|
+
|
|
3
|
+
This plugin provides custom models, properties, transactions, and hooks for the AMSDAL Framework.
|
|
4
|
+
|
|
5
|
+
## Plugin Structure
|
|
6
|
+
|
|
7
|
+
- `src/models/` - Contains model definitions{% if ctx.models_format == 'json' %} in JSON format{% else %} in Python format{% endif %}
|
|
8
|
+
- `src/transactions/` - Contains transaction definitions
|
|
9
|
+
- `pyproject.toml` - Plugin configuration file
|
|
10
|
+
- `config.yml` - Configuration for connections
|
|
11
|
+
|
|
12
|
+
## Installing this Plugin
|
|
13
|
+
|
|
14
|
+
To use this plugin in an AMSDAL application:
|
|
15
|
+
|
|
16
|
+
1. Copy the plugin directory to your AMSDAL application
|
|
17
|
+
2. Import the models and transactions as needed
|
|
18
|
+
3. Register the plugin in your application configuration
|
|
19
|
+
|
|
20
|
+
## Development
|
|
21
|
+
|
|
22
|
+
This plugin uses {% if ctx.is_async_mode %}async{% else %}sync{% endif %} mode.
|
|
23
|
+
|
|
24
|
+
### Adding Models
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
amsdal generate model ModelName --format {{ ctx.models_format }}
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Adding Properties
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
amsdal generate property --model ModelName property_name
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Adding Transactions
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
amsdal generate transaction TransactionName
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
### Adding Hooks
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
amsdal generate hook --model ModelName on_create
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Testing
|
|
49
|
+
|
|
50
|
+
Test your plugin by integrating it with an AMSDAL application and running the application's test suite.
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
application_name: {{ ctx.plugin_name_slugify }}
|
|
2
|
+
async_mode: {{ 'true' if ctx.is_async_mode else 'false' }}
|
|
3
|
+
connections:
|
|
4
|
+
- name: sqlite_history
|
|
5
|
+
backend: {{ ctx.historical_backend }}
|
|
6
|
+
credentials:
|
|
7
|
+
- db_path: ./warehouse/amsdal_historical.sqlite3
|
|
8
|
+
- check_same_thread: false
|
|
9
|
+
- name: sqlite_state
|
|
10
|
+
backend: {{ ctx.state_backend }}
|
|
11
|
+
credentials:
|
|
12
|
+
- db_path: ./warehouse/amsdal_state.sqlite3
|
|
13
|
+
- check_same_thread: false
|
|
14
|
+
- name: lock
|
|
15
|
+
backend: amsdal_data.lock.implementations.thread_lock.ThreadLock
|
|
16
|
+
resources_config:
|
|
17
|
+
lakehouse: sqlite_history
|
|
18
|
+
lock: lock
|
|
19
|
+
repository:
|
|
20
|
+
default: sqlite_state
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[tool.hatch.build.targets.wheel]
|
|
6
|
+
packages = ["src/"]
|
|
7
|
+
|
|
8
|
+
[project]
|
|
9
|
+
name = "{{ ctx.plugin_name_slugify }}_amsdal_plugin"
|
|
10
|
+
version = "0.1.0"
|
|
11
|
+
description = "{{ ctx.plugin_name }} plugin for AMSDAL Framework"
|
|
12
|
+
readme = "README.md"
|
|
13
|
+
requires-python = ">=3.11"
|
|
14
|
+
dependencies = [
|
|
15
|
+
"amsdal[cli]=={{ ctx.amsdal_version }}"
|
|
16
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = '0.1.0'
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Models module for {{ ctx.plugin_name }} plugin
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Transactions module for {{ ctx.plugin_name }} plugin
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{% if ctx.is_async_mode %}from amsdal.core.classes.base import transaction
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
@transaction(name='ExampleTransaction')
|
|
5
|
+
async def example_transaction(name: str, description: str = "") -> None:
|
|
6
|
+
"""
|
|
7
|
+
Example transaction for {{ ctx.plugin_name }} plugin.
|
|
8
|
+
|
|
9
|
+
Args:
|
|
10
|
+
name: Name for the example model
|
|
11
|
+
description: Description for the example model
|
|
12
|
+
"""
|
|
13
|
+
# TODO: Add your transaction logic here
|
|
14
|
+
# Example:
|
|
15
|
+
# from models.example_model import ExampleModel
|
|
16
|
+
#
|
|
17
|
+
# new_model = ExampleModel(
|
|
18
|
+
# name=name,
|
|
19
|
+
# description=description,
|
|
20
|
+
# is_active=True
|
|
21
|
+
# )
|
|
22
|
+
# await new_model.async_save()
|
|
23
|
+
pass
|
|
24
|
+
{% else %}from amsdal.core.classes.base import transaction
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@transaction(name='ExampleTransaction')
|
|
28
|
+
def example_transaction(name: str, description: str = "") -> None:
|
|
29
|
+
"""
|
|
30
|
+
Example transaction for {{ ctx.plugin_name }} plugin.
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
name: Name for the example model
|
|
34
|
+
description: Description for the example model
|
|
35
|
+
"""
|
|
36
|
+
# TODO: Add your transaction logic here
|
|
37
|
+
# Example:
|
|
38
|
+
# from models.example_model import ExampleModel
|
|
39
|
+
#
|
|
40
|
+
# new_model = ExampleModel(
|
|
41
|
+
# name=name,
|
|
42
|
+
# description=description,
|
|
43
|
+
# is_active=True
|
|
44
|
+
# )
|
|
45
|
+
# new_model.save()
|
|
46
|
+
pass
|
|
47
|
+
{% endif %}
|
amsdal_cli/config/main.py
CHANGED
amsdal_cli/utils/cli_config.py
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
amsdal_cli/Third-Party Materials - AMSDAL Dependencies - License Notices.md,sha256=uHJlGG0D4tbpUi8cq-497NNO9ltQ67a5448k-T14HTw,68241
|
|
2
|
-
amsdal_cli/__about__.py,sha256=
|
|
2
|
+
amsdal_cli/__about__.py,sha256=EPO0yn5_cRRN4L7o2A8njb26ZvPG7OJ4hIGTxQSuB6o,124
|
|
3
3
|
amsdal_cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
amsdal_cli/app.py,sha256=_ucuLT5ospf1ifFKEG0IMfVnxKjnvPUQ4iMhkvOfCrc,466
|
|
5
5
|
amsdal_cli/main.py,sha256=LtH-BD1eJrAUecjKzC8Gx7kYFUstOMH1erdeJUVqFB8,144
|
|
6
6
|
amsdal_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
7
|
amsdal_cli/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
amsdal_cli/commands/callbacks.py,sha256=
|
|
8
|
+
amsdal_cli/commands/callbacks.py,sha256=B6SXqOsV7c12c-PCrmk7WYosH4d3Nk-U0IZ0ZJrMyJg,4181
|
|
9
9
|
amsdal_cli/commands/api_check/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
amsdal_cli/commands/api_check/command.py,sha256=dKi37KfkRY6S2PBSeG2kopnZs8OvCkefQCkPx4ud_4Y,4193
|
|
11
11
|
amsdal_cli/commands/api_check/config.py,sha256=X398zfXddxHCJY4v3PBz6IyWsAsTXJRNNt07Nf_0ow8,6711
|
|
@@ -61,14 +61,14 @@ amsdal_cli/commands/cloud/dependency/app.py,sha256=m2pcB5z3257uU7pKt9XoOdQn7J3PU
|
|
|
61
61
|
amsdal_cli/commands/cloud/dependency/command.py,sha256=6nri04NBl4fy4FlrZyorY05samMbYU1-2j88m4t2FD4,272
|
|
62
62
|
amsdal_cli/commands/cloud/dependency/sub_commands/__init__.py,sha256=ZH89xFzDRJmV2e7MdCVDgaZ30B7jxRVUKTNzHAgTFeE,419
|
|
63
63
|
amsdal_cli/commands/cloud/dependency/sub_commands/dependency_delete.py,sha256=8IL5JE4-tBIStoHEteiBWo-Onsv8vLriy79ITSg18Hg,2849
|
|
64
|
-
amsdal_cli/commands/cloud/dependency/sub_commands/dependency_list.py,sha256=
|
|
65
|
-
amsdal_cli/commands/cloud/dependency/sub_commands/dependency_new.py,sha256=
|
|
64
|
+
amsdal_cli/commands/cloud/dependency/sub_commands/dependency_list.py,sha256=2wpRoKLLlOm_BU1NUbitPntCct7MrtsJakxtyXOE-RA,5299
|
|
65
|
+
amsdal_cli/commands/cloud/dependency/sub_commands/dependency_new.py,sha256=BknJ-5151EPVemDuTETBXnTRMMdgwVmOD9dt6698cSE,2993
|
|
66
66
|
amsdal_cli/commands/cloud/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
67
67
|
amsdal_cli/commands/cloud/deploy/app.py,sha256=_t2LVD8apbyvBrcWdNv1_nXtubng1hLW9fIV97_F8VU,222
|
|
68
68
|
amsdal_cli/commands/cloud/deploy/command.py,sha256=LIX07pTU55GUA9KmTiKDtoCj5Ytx9ZDC7XQsVYUYsh8,262
|
|
69
69
|
amsdal_cli/commands/cloud/deploy/sub_commands/__init__.py,sha256=I7MJEyceCIgCXP7JpX06nLvEA6HUkjj9LSDAb7VfTGo,353
|
|
70
70
|
amsdal_cli/commands/cloud/deploy/sub_commands/deploy_delete.py,sha256=pRLumeigF4e_Nod32p6XkgJsYxbB9H3WSxbv0IwA5Eo,3221
|
|
71
|
-
amsdal_cli/commands/cloud/deploy/sub_commands/deploy_list.py,sha256=
|
|
71
|
+
amsdal_cli/commands/cloud/deploy/sub_commands/deploy_list.py,sha256=ozr7tVbPrTnx_YscyAb1_ZockFfQQSwd6XDijrkZSWk,5534
|
|
72
72
|
amsdal_cli/commands/cloud/deploy/sub_commands/deploy_new.py,sha256=G28mt1cMv8js80FTtzxahCCWV8AVcu7BWe4w7Nqvp04,12748
|
|
73
73
|
amsdal_cli/commands/cloud/environments/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
74
74
|
amsdal_cli/commands/cloud/environments/app.py,sha256=kkzf_kW2jpl3d44qWuIZB5C3uWXzpNpnTIvUpuuPJHE,238
|
|
@@ -115,7 +115,7 @@ amsdal_cli/commands/generate/enums.py,sha256=4Nvbe4aJEUOMkFqjNbr2xtnvzqrJEh2qDiw
|
|
|
115
115
|
amsdal_cli/commands/generate/sub_commands/__init__.py,sha256=WyZ4kE6IH9O_igOVJ31UQtqE12cCKyATi4E-qgslN3k,941
|
|
116
116
|
amsdal_cli/commands/generate/sub_commands/generate_frontend_config.py,sha256=SkEzx7-mWgrPINwPXGRmYO1SVA0RZojOd6BZFQRmG0Q,2574
|
|
117
117
|
amsdal_cli/commands/generate/sub_commands/generate_hook.py,sha256=C0Oy5VokM3BXPq33Kknjvtjwd7hdfSxQFKxJcHu_bgg,1738
|
|
118
|
-
amsdal_cli/commands/generate/sub_commands/generate_model.py,sha256=
|
|
118
|
+
amsdal_cli/commands/generate/sub_commands/generate_model.py,sha256=nscCBi-PRa_JWdZlMo7ij5Ukg2eEk5tqMhMiLOs1Jv4,5927
|
|
119
119
|
amsdal_cli/commands/generate/sub_commands/generate_modifier.py,sha256=NyN7vMTBGaQv6u815WT1lqAlqI4xP1AmIZWq5edZ-5g,1426
|
|
120
120
|
amsdal_cli/commands/generate/sub_commands/generate_permission.py,sha256=gfRhZsnNnd_m_HxdOCB8C22tbMkopg2FTKo-T68b13s,2824
|
|
121
121
|
amsdal_cli/commands/generate/sub_commands/generate_property.py,sha256=XrCjf48oEzuMPqsTuC5Qsn1WbIQzUVW8BNOmXssfUM8,1599
|
|
@@ -146,10 +146,11 @@ amsdal_cli/commands/migrations/app.py,sha256=0HsKjZ5D2j9xkOi2Fuvs3VdlhWyQnS8XJ6p
|
|
|
146
146
|
amsdal_cli/commands/migrations/command.py,sha256=jlpdYZAc02ZUBxSdzGSzkDxEb1nlHNzoq05FdRCSzus,206
|
|
147
147
|
amsdal_cli/commands/migrations/constants.py,sha256=846-DQ-Iqcxw2akd5aBAmbnXHDmRFqEKu6vai2ZFBkU,35
|
|
148
148
|
amsdal_cli/commands/migrations/utils.py,sha256=Fvu6NlIFL3OAz0MhLkvnucIsHBZlDDCOZZ38VhNahws,2700
|
|
149
|
-
amsdal_cli/commands/migrations/sub_commands/__init__.py,sha256=
|
|
149
|
+
amsdal_cli/commands/migrations/sub_commands/__init__.py,sha256=HHxiJxcbJUQLv6QOLwcvcSjTYJTixiRJ89IUb1H7sRo,1100
|
|
150
150
|
amsdal_cli/commands/migrations/sub_commands/apply.py,sha256=4MyO_gP7r4PBRz_agi2xnoMTHcLlvxlo4335mmLrpYQ,8696
|
|
151
151
|
amsdal_cli/commands/migrations/sub_commands/list.py,sha256=vC-oeTVHjYNzI_HhiylZSNeOsIFvnDZ6TRwrqQ-wpUk,5833
|
|
152
152
|
amsdal_cli/commands/migrations/sub_commands/make.py,sha256=5DiSp5j_iv1Mk7eVFRJ_yCVdc1lZGkctmtY-tNbqaTk,6322
|
|
153
|
+
amsdal_cli/commands/migrations/sub_commands/make_contrib.py,sha256=KbB19I95Uh3dy00Peg9dDc09rcxI2c8FrTIazSaTVw8,6449
|
|
153
154
|
amsdal_cli/commands/new/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
154
155
|
amsdal_cli/commands/new/command.py,sha256=NDuDZNwreyuHsv4tbE-yrNOJViB8wk35IcKvGKQXPXo,3302
|
|
155
156
|
amsdal_cli/commands/new/templates/.amsdal-cli,sha256=PdXPovcT8AfPhqwDLI_4EWFYAS6e3J5JcsHVityBdF8,304
|
|
@@ -160,6 +161,17 @@ amsdal_cli/commands/new/templates/requirements.txt,sha256=SZ3s8KxuCFfat3FHl8-ZF3
|
|
|
160
161
|
amsdal_cli/commands/new/templates/.amsdal/.dependencies,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
161
162
|
amsdal_cli/commands/new/templates/.amsdal/.environment,sha256=DW5AeeNnA-vTfAByL1iR0osOKBHcEUsSkhUSOtzONgU,4
|
|
162
163
|
amsdal_cli/commands/new/templates/.amsdal/.secrets,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
164
|
+
amsdal_cli/commands/plugin/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
165
|
+
amsdal_cli/commands/plugin/command.py,sha256=alrKEIjpy2stMIEqb0fUZ1STu9VroaaKDx03fEJKdgA,4588
|
|
166
|
+
amsdal_cli/commands/plugin/templates/.amsdal-cli,sha256=fhvckKLvaFEzt6ePdgre01vFkr-_AmWHVfJlD6rZZaQ,289
|
|
167
|
+
amsdal_cli/commands/plugin/templates/README.md,sha256=FMwYTXOJ0ZsrhY-wq-c3pH8OeT-oAckjK48s5kh9lW4,1231
|
|
168
|
+
amsdal_cli/commands/plugin/templates/config.yml,sha256=ZEjr5RA0iSG3Nwf_N11WFwpNI8xKbcqoEip_BZgtOtw,635
|
|
169
|
+
amsdal_cli/commands/plugin/templates/pyproject.toml,sha256=fIHM2_nj1Jcw9JqFo_eE22uAazvpuj1fLTcRDr88wpY,387
|
|
170
|
+
amsdal_cli/commands/plugin/templates/src/__about__.py,sha256=IMjkMO3twhQzluVTo8Z6rE7Eg-9U79_LGKMcsWLKBkY,22
|
|
171
|
+
amsdal_cli/commands/plugin/templates/src/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
172
|
+
amsdal_cli/commands/plugin/templates/src/models/__init__.py,sha256=93F5MjA9NayBY6wY_ypyf55KYER3eovgj5K0IM8w3Qs,49
|
|
173
|
+
amsdal_cli/commands/plugin/templates/src/transactions/__init__.py,sha256=NzpIjXV6XKtBiZoteisyuWYjZNebuh3EAZ3tzrkAFvU,55
|
|
174
|
+
amsdal_cli/commands/plugin/templates/src/transactions/example_transaction.py,sha256=4NZVRuZ2BXM-nREvGbZv7H36EbzQHGSWBGFaTYWc_E4,1293
|
|
163
175
|
amsdal_cli/commands/register_connection/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
164
176
|
amsdal_cli/commands/register_connection/command.py,sha256=MdW8j1Q4TfufMl3Z4JVECX_OXIVya0tQ-vJj0Zc5Bdk,5145
|
|
165
177
|
amsdal_cli/commands/register_connection/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -196,11 +208,11 @@ amsdal_cli/commands/worker/command.py,sha256=e3uL38VYCp71-XsVYvE1xlt2FqhP54ujlhV
|
|
|
196
208
|
amsdal_cli/commands/worker/sub_commands/__init__.py,sha256=5AVFexW1UpfPpfNfYoioA6Pix1uiRSEjVEa-_wP89j4,100
|
|
197
209
|
amsdal_cli/commands/worker/sub_commands/run.py,sha256=gQ5fuQwB4Xouyosau0X2YB38DsomkZyUt2MREXeg7jE,4355
|
|
198
210
|
amsdal_cli/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
199
|
-
amsdal_cli/config/main.py,sha256=
|
|
211
|
+
amsdal_cli/config/main.py,sha256=leYnDJlzhzIAYWOH65QhPLu4zk3ii26ogMBWGYx3uqM,2874
|
|
200
212
|
amsdal_cli/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
201
213
|
amsdal_cli/utils/alias_group.py,sha256=v0ninrhZGtZFuJtUH6ZZZ97Irs96nkmIBFm2gY1NdmU,991
|
|
202
214
|
amsdal_cli/utils/check_versions.py,sha256=4Q3GwY_0xgP_RV_ITuFSDigXds-f1QhqCqkUkn-CSMI,1475
|
|
203
|
-
amsdal_cli/utils/cli_config.py,sha256=
|
|
215
|
+
amsdal_cli/utils/cli_config.py,sha256=t1R-U6lh3xzKkBpTgd-Wg7scVeEmf-RAPaL_-DSDaPU,2772
|
|
204
216
|
amsdal_cli/utils/copier.py,sha256=nKo0-P1AhWIb7IjbndYr3Vnvd_avCa566iIbXLK_5a0,5122
|
|
205
217
|
amsdal_cli/utils/markdown_patch.py,sha256=RW58pJhRoUYW1fhId70hw8MD2DF-UqXTYfv7JrSGz5I,1816
|
|
206
218
|
amsdal_cli/utils/render_template.py,sha256=wVjw6K4JZDKz0VElC76Dkgme8di4yfhHIb6hVju9el4,645
|
|
@@ -211,8 +223,8 @@ amsdal_cli/utils/vcs/base.py,sha256=jC05ExJZDnyHAsW7_4IDf8gQcYgK4dXq3zNlFIX66T4,
|
|
|
211
223
|
amsdal_cli/utils/vcs/dummy.py,sha256=Lk8MT-b0YlHHUsiXsq5cvmPwcl4jTYdo8piN5_C8ORA,434
|
|
212
224
|
amsdal_cli/utils/vcs/enums.py,sha256=tYR9LN1IOr8BZFbSeX_vDlhn8fPl4IU-Yakii8lRDYs,69
|
|
213
225
|
amsdal_cli/utils/vcs/git.py,sha256=xHynbZcV6p2D3RFCwu1MGGpV9D7eK-pGUtO8kVexTQM,1269
|
|
214
|
-
amsdal_cli-0.5.
|
|
215
|
-
amsdal_cli-0.5.
|
|
216
|
-
amsdal_cli-0.5.
|
|
217
|
-
amsdal_cli-0.5.
|
|
218
|
-
amsdal_cli-0.5.
|
|
226
|
+
amsdal_cli-0.5.5.dist-info/METADATA,sha256=-0tbpUZNEWRSiaJW4Z7hbA3e1IDEI8ASUHFkrrIXhOY,57105
|
|
227
|
+
amsdal_cli-0.5.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
228
|
+
amsdal_cli-0.5.5.dist-info/entry_points.txt,sha256=GC-8LZsD3W--Pd9_gD4W3tw3ZZyPbSvkZ-qWc9Fx0NI,47
|
|
229
|
+
amsdal_cli-0.5.5.dist-info/licenses/LICENSE.txt,sha256=hG-541PFYfNJi9WRZi_hno91UyqNg7YLK8LR3vLblZA,27355
|
|
230
|
+
amsdal_cli-0.5.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|