dataman-engine 0.3.0__tar.gz → 0.4.0__tar.gz

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 (28) hide show
  1. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/PKG-INFO +1 -1
  2. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/pyproject.toml +1 -1
  3. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/pyproject.toml.orig +1 -1
  4. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/__init__.py +1 -1
  5. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/cli.py +101 -71
  6. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/README.md +0 -0
  7. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/asgi.py +0 -0
  8. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/__init__.py +0 -0
  9. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/apps.py +0 -0
  10. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/audit.py +0 -0
  11. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/auth.py +0 -0
  12. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/crypto.py +0 -0
  13. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/fields.py +0 -0
  14. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/masking.py +0 -0
  15. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/middleware.py +0 -0
  16. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/migrations/0001_initial.py +0 -0
  17. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/migrations/__init__.py +0 -0
  18. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/models.py +0 -0
  19. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/permissions.py +0 -0
  20. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/router.py +0 -0
  21. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/signals.py +0 -0
  22. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/templates/admin/dashboard.html +0 -0
  23. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/templates/admin/login.html +0 -0
  24. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/urls.py +0 -0
  25. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/core/views.py +0 -0
  26. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/django_setup.py +0 -0
  27. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/py.typed +0 -0
  28. {dataman_engine-0.3.0 → dataman_engine-0.4.0}/src/dataman/wsgi.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dataman-engine
3
- Version: 0.3.0
3
+ Version: 0.4.0
4
4
  Summary: A dynamic, headless data layer framework built on Django and DRF for instant CRUD APIs and custom business logic.
5
5
  Keywords: django,rest,api,crud,headless,generator,scaffold
6
6
  Author: Vikash G
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataman-engine"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "A dynamic, headless data layer framework built on Django and DRF for instant CRUD APIs and custom business logic."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dataman-engine"
3
- version = "0.3.0"
3
+ version = "0.4.0"
4
4
  description = "A dynamic, headless data layer framework built on Django and DRF for instant CRUD APIs and custom business logic."
5
5
  readme = "README.md"
6
6
  license = "MIT"
@@ -9,7 +9,7 @@ from dataman.core.fields import (
9
9
  EncryptedTextField,
10
10
  )
11
11
 
12
- __version__ = "0.3.0"
12
+ __version__ = "0.4.0"
13
13
  __all__ = [
14
14
  "EncryptedCharField",
15
15
  "EncryptedTextField",
@@ -36,84 +36,114 @@ def init():
36
36
  tables_dir = cwd / "tables"
37
37
  migrations_dir = tables_dir / "migrations"
38
38
 
39
- if env_path.exists() and (database_file.exists() or tables_dir.exists()):
39
+ if env_path.exists() and database_file.exists() and tables_dir.exists():
40
40
  click.echo(
41
41
  click.style("Project already initialized in this directory.", fg="yellow")
42
42
  )
43
43
  return
44
44
 
45
- # Create .env
46
- secret_key = secrets.token_urlsafe(50)
47
- with open(env_path, "w") as f:
48
- f.write(f"DATAMAN_SECRET_KEY='{secret_key}'\n")
49
- f.write("DEBUG=True\n")
50
- f.write("DATABASE_URL=sqlite:///db.sqlite3\n")
51
- f.write("ALLOWED_HOSTS=127.0.0.1,localhost\n")
52
- click.echo(click.style("Created .env file.", fg="green"))
53
-
54
- # Create database.py
55
- with open(database_file, "w") as f:
56
- f.write(
57
- '"""\n'
58
- "DataMan Database Configuration\n"
59
- "Configure your primary and replica database connections here.\n"
60
- '"""\n'
61
- "import os\n"
62
- "from pathlib import Path\n"
63
- "import dj_database_url\n\n"
64
- "BASE_DIR = Path(__file__).resolve().parent\n\n"
65
- "# Default SQLite database configuration\n"
66
- "DATABASES = {\n"
67
- ' "default": dj_database_url.config(\n'
68
- ' default=os.getenv("DATABASE_URL", f"sqlite:///{BASE_DIR}/db.sqlite3"),\n'
69
- " conn_max_age=600,\n"
70
- " conn_health_checks=True,\n"
71
- " )\n"
72
- "}\n\n"
73
- "# --- Examples for Other Database Engines ---\n"
74
- "# PostgreSQL (Production recommended):\n"
75
- '# DATABASES["analytics"] = dj_database_url.parse(\n'
76
- '# os.getenv("ANALYTICS_DATABASE_URL", "postgres://user:password@localhost:5432/analytics_db"),\n'
77
- "# conn_max_age=600,\n"
78
- "# conn_health_checks=True,\n"
79
- "# )\n"
80
- "#\n"
81
- "# MySQL / MariaDB:\n"
82
- '# DATABASES["legacy"] = dj_database_url.parse(\n'
83
- '# os.getenv("LEGACY_DATABASE_URL", "mysql://user:password@localhost:3306/legacy_db"),\n'
84
- "# conn_max_age=600,\n"
85
- "# )\n"
86
- )
87
- click.echo(click.style("Created database.py.", fg="green"))
45
+ # 1. Handle .env safely without destructive overwrite
46
+ if env_path.exists():
47
+ existing_env = env_path.read_text(encoding="utf-8")
48
+ to_append = []
49
+ if "DATAMAN_SECRET_KEY" not in existing_env:
50
+ secret_key = secrets.token_urlsafe(50)
51
+ to_append.append(f"DATAMAN_SECRET_KEY='{secret_key}'")
52
+ if "DEBUG=" not in existing_env:
53
+ to_append.append("DEBUG=True")
54
+ if "DATABASE_URL=" not in existing_env:
55
+ to_append.append("DATABASE_URL=sqlite:///db.sqlite3")
56
+ if "ALLOWED_HOSTS=" not in existing_env:
57
+ to_append.append("ALLOWED_HOSTS=127.0.0.1,localhost")
58
+
59
+ if to_append:
60
+ with open(env_path, "a", encoding="utf-8") as f:
61
+ if existing_env and not existing_env.endswith("\n"):
62
+ f.write("\n")
63
+ f.write("\n# DataMan Configuration\n" + "\n".join(to_append) + "\n")
64
+ click.echo(
65
+ click.style("Updated existing .env with DataMan settings.", fg="green")
66
+ )
67
+ else:
68
+ click.echo(click.style("Preserved existing .env file.", fg="green"))
69
+ else:
70
+ secret_key = secrets.token_urlsafe(50)
71
+ with open(env_path, "w", encoding="utf-8") as f:
72
+ f.write(f"DATAMAN_SECRET_KEY='{secret_key}'\n")
73
+ f.write("DEBUG=True\n")
74
+ f.write("DATABASE_URL=sqlite:///db.sqlite3\n")
75
+ f.write("ALLOWED_HOSTS=127.0.0.1,localhost\n")
76
+ click.echo(click.style("Created .env file.", fg="green"))
77
+
78
+ # 2. Handle database.py
79
+ if database_file.exists():
80
+ click.echo(click.style("Preserved existing database.py file.", fg="green"))
81
+ else:
82
+ with open(database_file, "w", encoding="utf-8") as f:
83
+ f.write(
84
+ '"""\n'
85
+ "DataMan Database Configuration\n"
86
+ "Configure your primary and replica database connections here.\n"
87
+ '"""\n'
88
+ "import os\n"
89
+ "from pathlib import Path\n"
90
+ "import dj_database_url\n\n"
91
+ "BASE_DIR = Path(__file__).resolve().parent\n\n"
92
+ "# Default SQLite database configuration\n"
93
+ "DATABASES = {\n"
94
+ ' "default": dj_database_url.config(\n'
95
+ ' default=os.getenv("DATABASE_URL", f"sqlite:///{BASE_DIR}/db.sqlite3"),\n'
96
+ " conn_max_age=600,\n"
97
+ " conn_health_checks=True,\n"
98
+ " )\n"
99
+ "}\n\n"
100
+ "# --- Examples for Other Database Engines ---\n"
101
+ "# PostgreSQL (Production recommended):\n"
102
+ '# DATABASES["analytics"] = dj_database_url.parse(\n'
103
+ '# os.getenv("ANALYTICS_DATABASE_URL", "postgres://user:password@localhost:5432/analytics_db"),\n'
104
+ "# conn_max_age=600,\n"
105
+ "# conn_health_checks=True,\n"
106
+ "# )\n"
107
+ "#\n"
108
+ "# MySQL / MariaDB:\n"
109
+ '# DATABASES["legacy"] = dj_database_url.parse(\n'
110
+ '# os.getenv("LEGACY_DATABASE_URL", "mysql://user:password@localhost:3306/legacy_db"),\n'
111
+ "# conn_max_age=600,\n"
112
+ "# )\n"
113
+ )
114
+ click.echo(click.style("Created database.py.", fg="green"))
88
115
 
89
- # Create config.py
90
- with open(config_file, "w") as f:
91
- f.write(
92
- '"""\n'
93
- "DataMan Project Configuration\n"
94
- "Customize global settings, security policies, CORS, pagination, and middleware.\n"
95
- '"""\n'
96
- "import os\n\n"
97
- "# Security & Environment\n"
98
- 'DEBUG = os.getenv("DEBUG", "True").lower() in ("true", "1", "yes")\n'
99
- 'ALLOWED_HOSTS = [h.strip() for h in os.getenv("ALLOWED_HOSTS", "*").split(",") if h.strip()]\n\n'
100
- "# Global Pagination & Throttling\n"
101
- "PAGE_SIZE = 100\n"
102
- "MAX_PAGE_SIZE = 500\n\n"
103
- "# Audit & Telemetry\n"
104
- "ENABLE_AUDIT_LOGGING = True\n"
105
- "ENABLE_TELEMETRY = True\n"
106
- 'TELEMETRY_BACKEND = "db" # Options: "db" (default), "stdout", "none"\n\n'
107
- "# Webhooks (pluggable queue or worker dispatcher)\n"
108
- "# WEBHOOK_DISPATCHER = 'my_app.tasks.emit_webhook'\n\n"
109
- "# Custom Installed Apps (e.g. third-party Django apps)\n"
110
- "EXTRA_INSTALLED_APPS = []\n\n"
111
- "# Custom Middleware (appended to request/response pipeline)\n"
112
- "EXTRA_MIDDLEWARE = []\n"
113
- )
114
- click.echo(click.style("Created config.py.", fg="green"))
116
+ # 3. Handle config.py
117
+ if config_file.exists():
118
+ click.echo(click.style("Preserved existing config.py file.", fg="green"))
119
+ else:
120
+ with open(config_file, "w", encoding="utf-8") as f:
121
+ f.write(
122
+ '"""\n'
123
+ "DataMan Project Configuration\n"
124
+ "Customize global settings, security policies, CORS, pagination, and middleware.\n"
125
+ '"""\n'
126
+ "import os\n\n"
127
+ "# Security & Environment\n"
128
+ 'DEBUG = os.getenv("DEBUG", "True").lower() in ("true", "1", "yes")\n'
129
+ 'ALLOWED_HOSTS = [h.strip() for h in os.getenv("ALLOWED_HOSTS", "*").split(",") if h.strip()]\n\n'
130
+ "# Global Pagination & Throttling\n"
131
+ "PAGE_SIZE = 100\n"
132
+ "MAX_PAGE_SIZE = 500\n\n"
133
+ "# Audit & Telemetry\n"
134
+ "ENABLE_AUDIT_LOGGING = True\n"
135
+ "ENABLE_TELEMETRY = True\n"
136
+ 'TELEMETRY_BACKEND = "db" # Options: "db" (default), "stdout", "none"\n\n'
137
+ "# Webhooks (pluggable queue or worker dispatcher)\n"
138
+ "# WEBHOOK_DISPATCHER = 'my_app.tasks.emit_webhook'\n\n"
139
+ "# Custom Installed Apps (e.g. third-party Django apps)\n"
140
+ "EXTRA_INSTALLED_APPS = []\n\n"
141
+ "# Custom Middleware (appended to request/response pipeline)\n"
142
+ "EXTRA_MIDDLEWARE = []\n"
143
+ )
144
+ click.echo(click.style("Created config.py.", fg="green"))
115
145
 
116
- # Create tables/ directory and migrations
146
+ # 4. Create tables/ directory and migrations
117
147
  tables_dir.mkdir(exist_ok=True)
118
148
  (tables_dir / "__init__.py").touch()
119
149
  migrations_dir.mkdir(exist_ok=True)
File without changes