hammad-python 0.0.14__py3-none-any.whl → 0.0.15__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 (101) hide show
  1. hammad_python-0.0.15.dist-info/METADATA +184 -0
  2. hammad_python-0.0.15.dist-info/RECORD +4 -0
  3. hammad/__init__.py +0 -1
  4. hammad/ai/__init__.py +0 -1
  5. hammad/ai/_utils.py +0 -142
  6. hammad/ai/completions/__init__.py +0 -45
  7. hammad/ai/completions/client.py +0 -684
  8. hammad/ai/completions/create.py +0 -710
  9. hammad/ai/completions/settings.py +0 -100
  10. hammad/ai/completions/types.py +0 -792
  11. hammad/ai/completions/utils.py +0 -486
  12. hammad/ai/embeddings/__init__.py +0 -35
  13. hammad/ai/embeddings/client/__init__.py +0 -1
  14. hammad/ai/embeddings/client/base_embeddings_client.py +0 -26
  15. hammad/ai/embeddings/client/fastembed_text_embeddings_client.py +0 -200
  16. hammad/ai/embeddings/client/litellm_embeddings_client.py +0 -288
  17. hammad/ai/embeddings/create.py +0 -159
  18. hammad/ai/embeddings/types.py +0 -69
  19. hammad/cache/__init__.py +0 -40
  20. hammad/cache/base_cache.py +0 -181
  21. hammad/cache/cache.py +0 -169
  22. hammad/cache/decorators.py +0 -261
  23. hammad/cache/file_cache.py +0 -80
  24. hammad/cache/ttl_cache.py +0 -74
  25. hammad/cli/__init__.py +0 -33
  26. hammad/cli/animations.py +0 -573
  27. hammad/cli/plugins.py +0 -781
  28. hammad/cli/styles/__init__.py +0 -55
  29. hammad/cli/styles/settings.py +0 -139
  30. hammad/cli/styles/types.py +0 -358
  31. hammad/cli/styles/utils.py +0 -480
  32. hammad/data/__init__.py +0 -56
  33. hammad/data/collections/__init__.py +0 -34
  34. hammad/data/collections/base_collection.py +0 -58
  35. hammad/data/collections/collection.py +0 -452
  36. hammad/data/collections/searchable_collection.py +0 -556
  37. hammad/data/collections/vector_collection.py +0 -596
  38. hammad/data/configurations/__init__.py +0 -35
  39. hammad/data/configurations/configuration.py +0 -564
  40. hammad/data/databases/__init__.py +0 -21
  41. hammad/data/databases/database.py +0 -902
  42. hammad/data/models/__init__.py +0 -44
  43. hammad/data/models/base/__init__.py +0 -35
  44. hammad/data/models/base/fields.py +0 -546
  45. hammad/data/models/base/model.py +0 -1078
  46. hammad/data/models/base/utils.py +0 -280
  47. hammad/data/models/pydantic/__init__.py +0 -55
  48. hammad/data/models/pydantic/converters.py +0 -632
  49. hammad/data/models/pydantic/models/__init__.py +0 -28
  50. hammad/data/models/pydantic/models/arbitrary_model.py +0 -46
  51. hammad/data/models/pydantic/models/cacheable_model.py +0 -79
  52. hammad/data/models/pydantic/models/fast_model.py +0 -318
  53. hammad/data/models/pydantic/models/function_model.py +0 -176
  54. hammad/data/models/pydantic/models/subscriptable_model.py +0 -63
  55. hammad/data/types/__init__.py +0 -41
  56. hammad/data/types/file.py +0 -358
  57. hammad/data/types/multimodal/__init__.py +0 -24
  58. hammad/data/types/multimodal/audio.py +0 -96
  59. hammad/data/types/multimodal/image.py +0 -80
  60. hammad/data/types/text.py +0 -1066
  61. hammad/formatting/__init__.py +0 -38
  62. hammad/formatting/json/__init__.py +0 -21
  63. hammad/formatting/json/converters.py +0 -152
  64. hammad/formatting/text/__init__.py +0 -63
  65. hammad/formatting/text/converters.py +0 -723
  66. hammad/formatting/text/markdown.py +0 -131
  67. hammad/formatting/yaml/__init__.py +0 -26
  68. hammad/formatting/yaml/converters.py +0 -5
  69. hammad/logging/__init__.py +0 -35
  70. hammad/logging/decorators.py +0 -834
  71. hammad/logging/logger.py +0 -954
  72. hammad/mcp/__init__.py +0 -50
  73. hammad/mcp/client/__init__.py +0 -1
  74. hammad/mcp/client/client.py +0 -523
  75. hammad/mcp/client/client_service.py +0 -393
  76. hammad/mcp/client/settings.py +0 -178
  77. hammad/mcp/servers/__init__.py +0 -1
  78. hammad/mcp/servers/launcher.py +0 -1161
  79. hammad/performance/__init__.py +0 -36
  80. hammad/performance/imports.py +0 -231
  81. hammad/performance/runtime/__init__.py +0 -32
  82. hammad/performance/runtime/decorators.py +0 -142
  83. hammad/performance/runtime/run.py +0 -299
  84. hammad/py.typed +0 -0
  85. hammad/service/__init__.py +0 -49
  86. hammad/service/create.py +0 -532
  87. hammad/service/decorators.py +0 -285
  88. hammad/typing/__init__.py +0 -407
  89. hammad/web/__init__.py +0 -43
  90. hammad/web/http/__init__.py +0 -1
  91. hammad/web/http/client.py +0 -944
  92. hammad/web/models.py +0 -245
  93. hammad/web/openapi/__init__.py +0 -1
  94. hammad/web/openapi/client.py +0 -740
  95. hammad/web/search/__init__.py +0 -1
  96. hammad/web/search/client.py +0 -988
  97. hammad/web/utils.py +0 -472
  98. hammad_python-0.0.14.dist-info/METADATA +0 -70
  99. hammad_python-0.0.14.dist-info/RECORD +0 -99
  100. {hammad_python-0.0.14.dist-info → hammad_python-0.0.15.dist-info}/WHEEL +0 -0
  101. {hammad_python-0.0.14.dist-info → hammad_python-0.0.15.dist-info}/licenses/LICENSE +0 -0
@@ -1,480 +0,0 @@
1
- """hammad.cli.styles.utils"""
2
-
3
- import time
4
- from typing import Optional, TYPE_CHECKING
5
-
6
- if TYPE_CHECKING:
7
- from rich import get_console as get_rich_console
8
- from rich.console import Console, RenderableType
9
- from rich.live import Live
10
- from rich.panel import Panel
11
- from rich.style import Style
12
- from rich.text import Text
13
-
14
- from .types import (
15
- CLIStyleError,
16
- CLIStyleType,
17
- CLIStyleBackgroundType,
18
- )
19
- from .settings import (
20
- CLIStyleRenderableSettings,
21
- CLIStyleBackgroundSettings,
22
- CLIStyleLiveSettings,
23
- )
24
-
25
- # Lazy import cache for rich components
26
- _RICH_CACHE = {}
27
-
28
-
29
- def _get_rich_console():
30
- """Lazy import for rich console"""
31
- if "get_console" not in _RICH_CACHE:
32
- from rich import get_console as get_rich_console
33
-
34
- _RICH_CACHE["get_console"] = get_rich_console
35
- return _RICH_CACHE["get_console"]
36
-
37
-
38
- def _get_rich_classes():
39
- """Lazy import for rich classes"""
40
- if "classes" not in _RICH_CACHE:
41
- from rich.console import Console, RenderableType
42
- from rich.live import Live
43
- from rich.panel import Panel
44
- from rich.style import Style
45
- from rich.text import Text
46
-
47
- _RICH_CACHE["classes"] = {
48
- "Console": Console,
49
- "RenderableType": RenderableType,
50
- "Live": Live,
51
- "Panel": Panel,
52
- "Style": Style,
53
- "Text": Text,
54
- }
55
- return _RICH_CACHE["classes"]
56
-
57
-
58
- def live_render(
59
- r,
60
- live_settings: CLIStyleLiveSettings,
61
- console=None,
62
- ) -> None:
63
- """Runs a rich live renderable.
64
-
65
- Args:
66
- r : The renderable to run.
67
- settings : The settings to use for the live renderable.
68
- console : The console to use for the live renderable."""
69
-
70
- rich_classes = _get_rich_classes()
71
- RenderableType = rich_classes["RenderableType"]
72
- Live = rich_classes["Live"]
73
-
74
- if console is None:
75
- get_rich_console = _get_rich_console()
76
- console = get_rich_console()
77
-
78
- if not isinstance(r, RenderableType):
79
- raise CLIStyleError("The renderable must be a RenderableType.")
80
-
81
- if not live_settings.get("duration"):
82
- duration = 2.0
83
- else:
84
- duration = live_settings["duration"]
85
- if "duration" in live_settings:
86
- del live_settings["duration"]
87
-
88
- if not live_settings.get("refresh_rate"):
89
- refresh_rate = 20
90
- else:
91
- refresh_rate = live_settings["refresh_rate"]
92
- if "refresh_rate" in live_settings:
93
- del live_settings["refresh_rate"]
94
-
95
- if not live_settings.get("auto_refresh"):
96
- live_settings["auto_refresh"] = True
97
- if not live_settings.get("transient"):
98
- live_settings["transient"] = False
99
- if not live_settings.get("redirect_stdout"):
100
- live_settings["redirect_stdout"] = True
101
- if not live_settings.get("redirect_stderr"):
102
- live_settings["redirect_stderr"] = True
103
- if not live_settings.get("vertical_overflow"):
104
- live_settings["vertical_overflow"] = "ellipsis"
105
-
106
- try:
107
- with Live(r, console=console, **live_settings) as live:
108
- start_time = time.time()
109
- while time.time() - start_time < duration:
110
- time.sleep(1 / refresh_rate)
111
- live.refresh()
112
- except Exception as e:
113
- raise CLIStyleError(f"Error running rich live: {e}") from e
114
-
115
-
116
- def style_renderable(
117
- r,
118
- style: CLIStyleType | None = None,
119
- style_settings: CLIStyleRenderableSettings | None = None,
120
- bg: CLIStyleBackgroundType | None = None,
121
- bg_settings: CLIStyleBackgroundSettings | None = None,
122
- ):
123
- """Styles a renderable with a rich string tag or settings.
124
-
125
- Args:
126
- r : The renderable to style.
127
- style : The rich string tag to apply to the renderable.
128
- style_settings : The settings to apply to the renderable.
129
- bg : The rich string tag to apply to the background.
130
- bg_settings : The settings to apply to the background.
131
- """
132
-
133
- try:
134
- rich_classes = _get_rich_classes()
135
- Style = rich_classes["Style"]
136
- Text = rich_classes["Text"]
137
- Panel = rich_classes["Panel"]
138
-
139
- # First handle style processing to get styled_renderable
140
- styled_renderable = r
141
-
142
- # Handle string-based styles (including color tags and complex styles)
143
- if isinstance(style, str):
144
- try:
145
- # For strings, use Rich's style parsing directly to support things like 'black on red'
146
- rich_style = Style.parse(style)
147
- styled_renderable = (
148
- Text(r, style=rich_style) if isinstance(r, str) else r
149
- )
150
- except Exception:
151
- # Fallback to treating as simple color if parsing fails
152
- rich_style = Style(color=style)
153
- styled_renderable = (
154
- Text(r, style=rich_style) if isinstance(r, str) else r
155
- )
156
-
157
- # Handle tuple-based styles (RGB color tuples)
158
- elif isinstance(style, tuple):
159
- try:
160
- # Convert tuple to RGB format for Rich
161
- rgb_color = f"rgb({style[0]},{style[1]},{style[2]})"
162
- rich_style = Style(color=rgb_color)
163
- styled_renderable = (
164
- Text(r, style=rich_style) if isinstance(r, str) else r
165
- )
166
- except Exception:
167
- # Fallback to original renderable if tuple processing fails
168
- styled_renderable = r
169
-
170
- # Handle dict-based styles passed as style parameter
171
- elif isinstance(style, dict):
172
- try:
173
- # Process text/style properties from dict
174
- text_style_kwargs = {}
175
-
176
- # Handle color from style dict
177
- if "color" in style:
178
- try:
179
- color_value = style["color"]
180
- if isinstance(color_value, tuple):
181
- text_style_kwargs["color"] = (
182
- f"rgb({color_value[0]},{color_value[1]},{color_value[2]})"
183
- )
184
- else:
185
- text_style_kwargs["color"] = color_value
186
- except Exception:
187
- # Skip color if processing fails
188
- pass
189
-
190
- # Handle text style properties
191
- text_style_props = [
192
- "bold",
193
- "dim",
194
- "italic",
195
- "underline",
196
- "blink",
197
- "blink2",
198
- "reverse",
199
- "conceal",
200
- "strike",
201
- "underline2",
202
- "frame",
203
- "encircle",
204
- "overline",
205
- "link",
206
- ]
207
-
208
- for prop in text_style_props:
209
- if prop in style:
210
- try:
211
- text_style_kwargs[prop] = style[prop]
212
- except Exception:
213
- # Skip property if processing fails
214
- continue
215
-
216
- # Create rich style from text properties
217
- try:
218
- rich_style = (
219
- Style(**text_style_kwargs) if text_style_kwargs else None
220
- )
221
- except Exception:
222
- rich_style = None
223
-
224
- # Apply text style to renderable
225
- try:
226
- if isinstance(r, str):
227
- styled_renderable = (
228
- Text(r, style=rich_style) if rich_style else Text(r)
229
- )
230
- elif isinstance(r, Text) and rich_style:
231
- styled_renderable = Text(r.plain, style=rich_style)
232
- else:
233
- styled_renderable = r
234
- except Exception:
235
- styled_renderable = r
236
-
237
- except Exception:
238
- # Fallback to original renderable if dict processing fails
239
- styled_renderable = r
240
-
241
- # Handle style_settings dict
242
- elif style_settings:
243
- try:
244
- # Process text/style properties
245
- text_style_kwargs = {}
246
-
247
- # Handle color from style settings
248
- if "color" in style_settings:
249
- try:
250
- color_value = style_settings["color"]
251
- if isinstance(color_value, tuple):
252
- text_style_kwargs["color"] = (
253
- f"rgb({color_value[0]},{color_value[1]},{color_value[2]})"
254
- )
255
- else:
256
- text_style_kwargs["color"] = color_value
257
- except Exception:
258
- # Skip color if processing fails
259
- pass
260
-
261
- # Handle text style properties
262
- text_style_props = [
263
- "bold",
264
- "dim",
265
- "italic",
266
- "underline",
267
- "blink",
268
- "blink2",
269
- "reverse",
270
- "conceal",
271
- "strike",
272
- "underline2",
273
- "frame",
274
- "encircle",
275
- "overline",
276
- "link",
277
- ]
278
-
279
- for prop in text_style_props:
280
- if prop in style_settings:
281
- try:
282
- text_style_kwargs[prop] = style_settings[prop]
283
- except Exception:
284
- # Skip property if processing fails
285
- continue
286
-
287
- # Create rich style from text properties
288
- try:
289
- rich_style = (
290
- Style(**text_style_kwargs) if text_style_kwargs else None
291
- )
292
- except Exception:
293
- rich_style = None
294
-
295
- # Apply text style to renderable
296
- try:
297
- if isinstance(r, str):
298
- styled_renderable = (
299
- Text(r, style=rich_style) if rich_style else Text(r)
300
- )
301
- elif isinstance(r, Text) and rich_style:
302
- styled_renderable = Text(r.plain, style=rich_style)
303
- else:
304
- styled_renderable = r
305
- except Exception:
306
- styled_renderable = r
307
-
308
- except Exception:
309
- # Fallback to original renderable if dict processing fails
310
- styled_renderable = r
311
-
312
- # Handle background settings (from bg or bg_settings parameter)
313
- if bg or bg_settings:
314
- try:
315
- if bg_settings:
316
- # Full background configuration
317
- panel_kwargs = {}
318
-
319
- # Handle box style
320
- if "box" in bg_settings:
321
- try:
322
- box_name = bg_settings["box"]
323
- from rich import box as rich_box_module
324
-
325
- box_map = {
326
- "ascii": rich_box_module.ASCII,
327
- "ascii2": rich_box_module.ASCII2,
328
- "ascii_double_head": rich_box_module.ASCII_DOUBLE_HEAD,
329
- "square": rich_box_module.SQUARE,
330
- "square_double_head": rich_box_module.SQUARE_DOUBLE_HEAD,
331
- "minimal": rich_box_module.MINIMAL,
332
- "minimal_heavy_head": rich_box_module.MINIMAL_HEAVY_HEAD,
333
- "minimal_double_head": rich_box_module.MINIMAL_DOUBLE_HEAD,
334
- "simple": rich_box_module.SIMPLE,
335
- "simple_head": rich_box_module.SIMPLE_HEAD,
336
- "simple_heavy": rich_box_module.SIMPLE_HEAVY,
337
- "horizontals": rich_box_module.HORIZONTALS,
338
- "rounded": rich_box_module.ROUNDED,
339
- "heavy": rich_box_module.HEAVY,
340
- "heavy_edge": rich_box_module.HEAVY_EDGE,
341
- "heavy_head": rich_box_module.HEAVY_HEAD,
342
- "double": rich_box_module.DOUBLE,
343
- "double_edge": rich_box_module.DOUBLE_EDGE,
344
- "markdown": getattr(
345
- rich_box_module,
346
- "MARKDOWN",
347
- rich_box_module.ROUNDED,
348
- ),
349
- }
350
- panel_kwargs["box"] = box_map.get(
351
- box_name, rich_box_module.ROUNDED
352
- )
353
- except Exception:
354
- # Use default box if box processing fails
355
- pass
356
-
357
- # Handle panel properties
358
- panel_props = [
359
- "title",
360
- "subtitle",
361
- "title_align",
362
- "subtitle_align",
363
- "safe_box",
364
- "expand",
365
- "width",
366
- "height",
367
- "padding",
368
- "highlight",
369
- ]
370
-
371
- for prop in panel_props:
372
- if prop in bg_settings:
373
- try:
374
- panel_kwargs[prop] = bg_settings[prop]
375
- except Exception:
376
- # Skip property if processing fails
377
- continue
378
-
379
- # Handle background style
380
- if "style" in bg_settings:
381
- try:
382
- bg_style = bg_settings["style"]
383
- if isinstance(bg_style, dict):
384
- bg_style_kwargs = {}
385
- if "color" in bg_style:
386
- try:
387
- color_value = bg_style["color"]
388
- if isinstance(color_value, tuple):
389
- bg_style_kwargs["bgcolor"] = (
390
- f"rgb({color_value[0]},{color_value[1]},{color_value[2]})"
391
- )
392
- else:
393
- bg_style_kwargs["bgcolor"] = color_value
394
- except Exception:
395
- pass
396
- panel_kwargs["style"] = Style(**bg_style_kwargs)
397
- else:
398
- # Handle string or tuple background style
399
- if isinstance(bg_style, tuple):
400
- panel_kwargs["style"] = Style(
401
- bgcolor=f"rgb({bg_style[0]},{bg_style[1]},{bg_style[2]})"
402
- )
403
- else:
404
- panel_kwargs["style"] = Style(bgcolor=bg_style)
405
- except Exception:
406
- # Skip background style if processing fails
407
- pass
408
-
409
- # Handle border style
410
- if "border_style" in bg_settings:
411
- try:
412
- border_style = bg_settings["border_style"]
413
- if isinstance(border_style, dict):
414
- border_style_kwargs = {}
415
- if "color" in border_style:
416
- try:
417
- color_value = border_style["color"]
418
- if isinstance(color_value, tuple):
419
- border_style_kwargs["color"] = (
420
- f"rgb({color_value[0]},{color_value[1]},{color_value[2]})"
421
- )
422
- else:
423
- border_style_kwargs["color"] = color_value
424
- except Exception:
425
- pass
426
-
427
- for prop in ["bold", "dim", "italic"]:
428
- if prop in border_style:
429
- try:
430
- border_style_kwargs[prop] = border_style[
431
- prop
432
- ]
433
- except Exception:
434
- continue
435
-
436
- panel_kwargs["border_style"] = Style(
437
- **border_style_kwargs
438
- )
439
- except Exception:
440
- # Skip border style if processing fails
441
- pass
442
-
443
- # Handle background color if specified at top level
444
- if "color" in bg_settings and "style" not in bg_settings:
445
- try:
446
- color_value = bg_settings["color"]
447
- if isinstance(color_value, tuple):
448
- panel_kwargs["style"] = Style(
449
- bgcolor=f"rgb({color_value[0]},{color_value[1]},{color_value[2]})"
450
- )
451
- else:
452
- panel_kwargs["style"] = Style(bgcolor=color_value)
453
- except Exception:
454
- # Skip background color if processing fails
455
- pass
456
-
457
- try:
458
- return Panel(styled_renderable, **panel_kwargs)
459
- except Exception:
460
- # Fallback to styled renderable if panel creation fails
461
- return styled_renderable
462
-
463
- elif bg:
464
- # Simple background color (string from bg parameter)
465
- try:
466
- bg_style = Style(bgcolor=bg)
467
- return Panel(styled_renderable, style=bg_style)
468
- except Exception:
469
- # Fallback to styled renderable if panel creation fails
470
- return styled_renderable
471
- except Exception:
472
- # Skip background processing if it fails
473
- pass
474
-
475
- # Return styled renderable (with or without background processing)
476
- return styled_renderable
477
-
478
- except Exception:
479
- # Ultimate fallback - return original renderable
480
- return r
hammad/data/__init__.py DELETED
@@ -1,56 +0,0 @@
1
- """hammad.data"""
2
-
3
- from typing import TYPE_CHECKING
4
- from ..performance.imports import create_getattr_importer
5
-
6
- if TYPE_CHECKING:
7
- from .configurations import (
8
- Configuration,
9
- read_configuration_from_file,
10
- read_configuration_from_url,
11
- read_configuration_from_os_vars,
12
- read_configuration_from_os_prefix,
13
- read_configuration_from_dotenv,
14
- )
15
- from .collections import (
16
- Collection,
17
- BaseCollection,
18
- VectorCollection,
19
- VectorCollectionSettings,
20
- SearchableCollection,
21
- SearchableCollectionSettings,
22
- create_collection,
23
- )
24
- from .databases import Database, create_database
25
-
26
-
27
- __all__ = (
28
- # hammad.data.configurations
29
- "Configuration",
30
- "read_configuration_from_file",
31
- "read_configuration_from_url",
32
- "read_configuration_from_os_vars",
33
- "read_configuration_from_os_prefix",
34
- "read_configuration_from_dotenv",
35
-
36
- # hammad.data.collections
37
- "Collection",
38
- "BaseCollection",
39
- "VectorCollection",
40
- "VectorCollectionSettings",
41
- "SearchableCollection",
42
- "SearchableCollectionSettings",
43
- "create_collection",
44
-
45
- # hammad.data.databases
46
- "Database",
47
- "create_database",
48
- )
49
-
50
-
51
- __getattr__ = create_getattr_importer(__all__)
52
-
53
-
54
- def __dir__() -> list[str]:
55
- """Get the attributes of the data module."""
56
- return list(__all__)
@@ -1,34 +0,0 @@
1
- """hammad.data.collections"""
2
-
3
- from typing import TYPE_CHECKING
4
- from ...performance.imports import create_getattr_importer
5
-
6
- if TYPE_CHECKING:
7
- from .base_collection import BaseCollection
8
- from .searchable_collection import SearchableCollection
9
- from .vector_collection import VectorCollection
10
- from .collection import (
11
- create_collection,
12
- VectorCollectionSettings,
13
- SearchableCollectionSettings,
14
- Collection,
15
- )
16
-
17
-
18
- __all__ = (
19
- "BaseCollection",
20
- "SearchableCollection",
21
- "VectorCollection",
22
- "create_collection",
23
- "VectorCollectionSettings",
24
- "SearchableCollectionSettings",
25
- "Collection",
26
- )
27
-
28
-
29
- __getattr__ = create_getattr_importer(__all__)
30
-
31
-
32
- def __dir__() -> list[str]:
33
- """Get the attributes of the data.collections module."""
34
- return list(__all__)
@@ -1,58 +0,0 @@
1
- """hammad.data.collections.base_collection"""
2
-
3
- from typing import Any, Dict, Optional, List, TypeVar, Union, Type, Generic
4
- from abc import ABC, abstractmethod
5
-
6
- __all__ = (
7
- "BaseCollection",
8
- "Object",
9
- "Filters",
10
- "Schema",
11
- )
12
-
13
-
14
- Object = TypeVar("Object")
15
- """Represents an object that can be stored within a collection."""
16
-
17
-
18
- Filters = Dict[str, object]
19
- """Represents a dictionary of filters that can be applied to objects within
20
- a collection."""
21
-
22
-
23
- Schema = Union[Type[Any], Dict[str, Any], None]
24
- """Represents a strict schema that a collection can optionally enforce."""
25
-
26
-
27
- class BaseCollection(ABC, Generic[Object]):
28
- """Base class defining the interface for collections. This
29
- class does not provide any functionality.
30
- """
31
-
32
- @abstractmethod
33
- def get(self, id: str, *, filters: Optional[Filters] = None) -> Optional[Any]:
34
- """Get an item by ID."""
35
- pass
36
-
37
- @abstractmethod
38
- def add(
39
- self,
40
- entry: Any,
41
- *,
42
- id: Optional[str] = None,
43
- filters: Optional[Filters] = None,
44
- ttl: Optional[int] = None,
45
- ) -> None:
46
- """Add an item to the collection."""
47
- pass
48
-
49
- @abstractmethod
50
- def query(
51
- self,
52
- *,
53
- filters: Optional[Filters] = None,
54
- search: Optional[str] = None,
55
- limit: Optional[int] = None,
56
- ) -> List[Any]:
57
- """Query items from the collection."""
58
- pass