syncforge 1.0.0__tar.gz → 1.0.1__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.
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syncforge
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Official Python SDK for SyncForge — control exactly when data syncs between your database and clients.
5
5
  Author-email: SyncForge <sureshdulupolai@gmail.com>
6
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/sureshdulupolai/syncforge
8
8
  Project-URL: Documentation, https://syncforge.dev/docs/
9
9
  Project-URL: Repository, https://github.com/sureshdulupolai/syncforge
@@ -11,7 +11,6 @@ Project-URL: Bug Tracker, https://github.com/sureshdulupolai/syncforge/issues
11
11
  Keywords: syncforge,sync,database,cache,invalidation,django,fastapi
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
14
  Classifier: Programming Language :: Python :: 3
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
@@ -4,10 +4,11 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "syncforge"
7
- version = "1.0.0"
7
+ version = "1.0.1"
8
8
  description = "Official Python SDK for SyncForge — control exactly when data syncs between your database and clients."
9
9
  readme = "README.md"
10
- license = { text = "MIT" }
10
+ license = "MIT"
11
+ license-files = ["LICENSE"]
11
12
  authors = [
12
13
  { name = "SyncForge", email = "sureshdulupolai@gmail.com" }
13
14
  ]
@@ -15,7 +16,6 @@ keywords = ["syncforge", "sync", "database", "cache", "invalidation", "django",
15
16
  classifiers = [
16
17
  "Development Status :: 5 - Production/Stable",
17
18
  "Intended Audience :: Developers",
18
- "License :: OSI Approved :: MIT License",
19
19
  "Programming Language :: Python :: 3",
20
20
  "Programming Language :: Python :: 3.8",
21
21
  "Programming Language :: Python :: 3.9",
@@ -157,6 +157,32 @@ class SyncForge:
157
157
  data = self._request("GET", url)
158
158
  return data.get("tables", [])
159
159
 
160
+ def create_table(self, table_name: str, sync_mode: str = "event") -> bool:
161
+ """
162
+ Register a new table programmatically.
163
+
164
+ Args:
165
+ table_name: The name of the table to register.
166
+ sync_mode: The sync mode (e.g. 'event', 'manual', 'schedule_5m').
167
+
168
+ Returns:
169
+ bool: True if created, False if it already existed.
170
+ """
171
+ table_name = table_name.strip().lower()
172
+ if not table_name:
173
+ raise ValueError("Table name cannot be empty.")
174
+
175
+ url = f"{self._base_url}/v1/tables/"
176
+ try:
177
+ res = self._request("POST", url, json_data={"table_name": table_name, "sync_mode": sync_mode})
178
+ return res.get("created", False)
179
+ except SyncForgeError as exc:
180
+ if self._silent:
181
+ import warnings
182
+ warnings.warn(f"[SyncForge] create_table failed: {exc}", stacklevel=2)
183
+ return False
184
+ raise
185
+
160
186
  # ── Internal ──────────────────────────────────────────────────────────────
161
187
 
162
188
  def _refresh_all(self, tables: tuple) -> List[SyncResult]:
@@ -196,14 +222,16 @@ class SyncForge:
196
222
  status_code = 200,
197
223
  )
198
224
 
199
- def _request(self, method: str, url: str) -> dict:
225
+ def _request(self, method: str, url: str, json_data: dict = None) -> dict:
200
226
  headers = {
201
227
  "X-API-Key": self._api_key,
202
228
  "Content-Type": "application/json",
203
229
  "Accept": "application/json",
204
- "User-Agent": "syncforge-python/1.0.0",
230
+ "User-Agent": "syncforge-python/1.0.1",
205
231
  }
206
232
  body = b"" if method == "GET" else b"{}"
233
+ if json_data is not None:
234
+ body = json.dumps(json_data).encode("utf-8")
207
235
  req = urllib.request.Request(url, data=body, headers=headers, method=method)
208
236
 
209
237
  try:
@@ -1,9 +1,9 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: syncforge
3
- Version: 1.0.0
3
+ Version: 1.0.1
4
4
  Summary: Official Python SDK for SyncForge — control exactly when data syncs between your database and clients.
5
5
  Author-email: SyncForge <sureshdulupolai@gmail.com>
6
- License: MIT
6
+ License-Expression: MIT
7
7
  Project-URL: Homepage, https://github.com/sureshdulupolai/syncforge
8
8
  Project-URL: Documentation, https://syncforge.dev/docs/
9
9
  Project-URL: Repository, https://github.com/sureshdulupolai/syncforge
@@ -11,7 +11,6 @@ Project-URL: Bug Tracker, https://github.com/sureshdulupolai/syncforge/issues
11
11
  Keywords: syncforge,sync,database,cache,invalidation,django,fastapi
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
- Classifier: License :: OSI Approved :: MIT License
15
14
  Classifier: Programming Language :: Python :: 3
16
15
  Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
File without changes
File without changes
File without changes
File without changes