lumera 0.9.4__tar.gz → 0.9.5__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.
- {lumera-0.9.4 → lumera-0.9.5}/PKG-INFO +1 -1
- {lumera-0.9.4 → lumera-0.9.5}/lumera/__init__.py +1 -1
- {lumera-0.9.4 → lumera-0.9.5}/lumera/pb.py +25 -16
- {lumera-0.9.4 → lumera-0.9.5}/lumera/sdk.py +17 -10
- {lumera-0.9.4 → lumera-0.9.5}/lumera.egg-info/PKG-INFO +1 -1
- {lumera-0.9.4 → lumera-0.9.5}/pyproject.toml +1 -1
- {lumera-0.9.4 → lumera-0.9.5}/tests/test_sdk.py +1 -1
- {lumera-0.9.4 → lumera-0.9.5}/lumera/_utils.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/automations.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/exceptions.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/google.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/integrations/__init__.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/integrations/google.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/llm.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/locks.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/storage.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera/webhooks.py +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera.egg-info/SOURCES.txt +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera.egg-info/dependency_links.txt +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera.egg-info/requires.txt +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/lumera.egg-info/top_level.txt +0 -0
- {lumera-0.9.4 → lumera-0.9.5}/setup.cfg +0 -0
|
@@ -5,7 +5,7 @@ This SDK provides helpers for automations running within the Lumera environment
|
|
|
5
5
|
to interact with the Lumera API and define dynamic user interfaces.
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
|
-
from importlib.metadata import
|
|
8
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
9
9
|
|
|
10
10
|
try:
|
|
11
11
|
__version__ = version("lumera")
|
|
@@ -510,7 +510,8 @@ def iter_all(
|
|
|
510
510
|
yield from items
|
|
511
511
|
|
|
512
512
|
# Check if there are more pages
|
|
513
|
-
|
|
513
|
+
# Use `or 0` instead of default to handle None values
|
|
514
|
+
total_pages = result.get("totalPages") or 0
|
|
514
515
|
if page >= total_pages:
|
|
515
516
|
break
|
|
516
517
|
|
|
@@ -563,6 +564,7 @@ def ensure_collection(
|
|
|
563
564
|
name: str,
|
|
564
565
|
schema: Sequence[dict[str, Any]] | None = None,
|
|
565
566
|
*,
|
|
567
|
+
id: str | None = None,
|
|
566
568
|
indexes: Sequence[str] | None = None,
|
|
567
569
|
) -> dict[str, Any]:
|
|
568
570
|
"""Ensure a collection exists with the given schema (idempotent).
|
|
@@ -579,7 +581,7 @@ def ensure_collection(
|
|
|
579
581
|
If you omit schema or indexes, existing values are preserved.
|
|
580
582
|
|
|
581
583
|
Args:
|
|
582
|
-
name: Collection name (
|
|
584
|
+
name: Collection name (can be renamed later in UI)
|
|
583
585
|
schema: List of field definitions. If provided, replaces all user fields.
|
|
584
586
|
Each field is a dict with:
|
|
585
587
|
- name: Field name (required)
|
|
@@ -587,33 +589,40 @@ def ensure_collection(
|
|
|
587
589
|
relation, select, editor, lumera_file
|
|
588
590
|
- required: Whether field is required (default False)
|
|
589
591
|
- options: Type-specific options (e.g., collectionId for relations)
|
|
592
|
+
id: Optional stable identifier for the collection. If provided on creation,
|
|
593
|
+
this ID will be used instead of an auto-generated one. The ID remains
|
|
594
|
+
stable even if the collection is renamed, making it ideal for use in
|
|
595
|
+
automations and hooks. Must be alphanumeric with underscores only.
|
|
596
|
+
Cannot be changed after creation.
|
|
590
597
|
indexes: Optional list of user index DDL statements. If provided,
|
|
591
598
|
replaces all user indexes.
|
|
592
599
|
|
|
593
600
|
Returns:
|
|
594
601
|
Collection object with:
|
|
602
|
+
- id: The collection's stable identifier
|
|
603
|
+
- name: The collection's display name
|
|
595
604
|
- schema: User-defined fields only (what you can modify)
|
|
596
605
|
- indexes: User-defined indexes only (what you can modify)
|
|
597
606
|
- systemInfo: Read-only system fields and indexes (automatically managed)
|
|
598
607
|
|
|
599
608
|
Example:
|
|
600
|
-
>>> # Create
|
|
601
|
-
>>> col = pb.ensure_collection(
|
|
602
|
-
...
|
|
603
|
-
...
|
|
604
|
-
...
|
|
609
|
+
>>> # Create with stable ID for use in automations
|
|
610
|
+
>>> col = pb.ensure_collection(
|
|
611
|
+
... "Customer Orders Q1",
|
|
612
|
+
... schema=[
|
|
613
|
+
... {"name": "amount", "type": "number", "required": True},
|
|
614
|
+
... {"name": "status", "type": "text"},
|
|
615
|
+
... ],
|
|
616
|
+
... id="orders", # stable reference
|
|
617
|
+
... )
|
|
605
618
|
>>>
|
|
606
|
-
>>> #
|
|
607
|
-
>>>
|
|
608
|
-
>>> col["schema"].append({"name": "notes", "type": "text"})
|
|
609
|
-
>>> pb.ensure_collection("deposits", col["schema"])
|
|
619
|
+
>>> # Later, collection can be renamed but ID stays "orders"
|
|
620
|
+
>>> # Automations using pb.search("orders", ...) still work!
|
|
610
621
|
>>>
|
|
611
|
-
>>> #
|
|
612
|
-
>>> pb.ensure_collection("deposits",
|
|
613
|
-
... "CREATE INDEX idx_status ON deposits (status)"
|
|
614
|
-
... ])
|
|
622
|
+
>>> # Create without custom ID (auto-generated)
|
|
623
|
+
>>> col = pb.ensure_collection("deposits", [...])
|
|
615
624
|
"""
|
|
616
|
-
return _ensure_collection(name, schema=schema, indexes=indexes)
|
|
625
|
+
return _ensure_collection(name, schema=schema, id=id, indexes=indexes)
|
|
617
626
|
|
|
618
627
|
|
|
619
628
|
def delete_collection(name: str) -> None:
|
|
@@ -185,6 +185,7 @@ def ensure_collection(
|
|
|
185
185
|
*,
|
|
186
186
|
collection_type: str = "base",
|
|
187
187
|
schema: Iterable[CollectionField] | object = _UNSET,
|
|
188
|
+
id: str | None = None,
|
|
188
189
|
indexes: Iterable[str] | object = _UNSET,
|
|
189
190
|
) -> dict[str, Any]:
|
|
190
191
|
"""Ensure a collection exists with the given schema and indexes.
|
|
@@ -200,34 +201,37 @@ def ensure_collection(
|
|
|
200
201
|
(external_id unique index, updated index) are automatically managed.
|
|
201
202
|
|
|
202
203
|
Args:
|
|
203
|
-
name: Collection name
|
|
204
|
+
name: Collection name (display name, can be renamed later).
|
|
204
205
|
collection_type: Collection type, defaults to "base".
|
|
205
206
|
schema: List of field definitions. If provided, replaces all user fields.
|
|
206
207
|
If omitted, existing fields are preserved.
|
|
208
|
+
id: Optional stable identifier. If provided on creation, this ID will be
|
|
209
|
+
used instead of an auto-generated one. The ID remains stable even if
|
|
210
|
+
the collection is renamed. Must be alphanumeric with underscores only.
|
|
211
|
+
Cannot be changed after creation.
|
|
207
212
|
indexes: List of index DDL statements. If provided, replaces all user indexes.
|
|
208
213
|
If omitted, existing indexes are preserved.
|
|
209
214
|
|
|
210
215
|
Returns:
|
|
211
216
|
The collection data including:
|
|
217
|
+
- id: The collection's stable identifier
|
|
218
|
+
- name: The collection's display name
|
|
212
219
|
- schema: User-defined fields only
|
|
213
220
|
- indexes: User-defined indexes only
|
|
214
221
|
- systemInfo: Object with system-managed fields and indexes (read-only)
|
|
215
222
|
|
|
216
223
|
Example:
|
|
217
|
-
# Create
|
|
224
|
+
# Create with stable ID for automations
|
|
218
225
|
coll = ensure_collection(
|
|
219
|
-
"
|
|
226
|
+
"Customer Orders Q1",
|
|
220
227
|
schema=[
|
|
221
|
-
{"name": "
|
|
222
|
-
{"name": "email", "type": "text"},
|
|
228
|
+
{"name": "amount", "type": "number", "required": True},
|
|
223
229
|
],
|
|
224
|
-
|
|
230
|
+
id="orders", # stable reference
|
|
225
231
|
)
|
|
226
232
|
|
|
227
|
-
#
|
|
228
|
-
|
|
229
|
-
coll["schema"].append({"name": "phone", "type": "text"})
|
|
230
|
-
ensure_collection("customers", schema=coll["schema"])
|
|
233
|
+
# Later, rename collection but ID stays "orders"
|
|
234
|
+
# Automations using search("orders", ...) still work!
|
|
231
235
|
"""
|
|
232
236
|
if not name or not name.strip():
|
|
233
237
|
raise ValueError("name is required")
|
|
@@ -238,6 +242,9 @@ def ensure_collection(
|
|
|
238
242
|
if collection_type:
|
|
239
243
|
payload["type"] = collection_type
|
|
240
244
|
|
|
245
|
+
if id is not None and id.strip():
|
|
246
|
+
payload["id"] = id.strip()
|
|
247
|
+
|
|
241
248
|
if schema is not _UNSET:
|
|
242
249
|
if schema is None:
|
|
243
250
|
raise ValueError("schema cannot be None; provide an iterable of fields or omit")
|
|
@@ -196,7 +196,7 @@ def test_create_collection_uses_ensure(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
|
196
196
|
|
|
197
197
|
captured: dict[str, object] = {}
|
|
198
198
|
|
|
199
|
-
def fake_request(method: str, url: str, **
|
|
199
|
+
def fake_request(method: str, url: str, **_kwargs: object) -> DummyResponse:
|
|
200
200
|
captured["method"] = method
|
|
201
201
|
captured["url"] = url
|
|
202
202
|
return DummyResponse(status_code=200, json_data={"id": "new"})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|