elody 0.0.182__py3-none-any.whl → 0.0.184__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.
elody/error_codes.py CHANGED
@@ -31,6 +31,7 @@ class ErrorCode(Enum):
31
31
  NO_PERMISSION_TO_TENANT = ("1010", ["tenant_id", "line_number"])
32
32
  XTENANT_NOT_FOUND = ("1011", ["x_tenant_id"])
33
33
  NO_DOWNLOAD_PERMISSION = ("1012", [])
34
+ INVALID_TOKEN = ("1013", [])
34
35
 
35
36
  # Database error codes
36
37
  DATABASE_NOT_INITIALIZED = ("2000", [])
elody/job.py CHANGED
@@ -65,7 +65,6 @@ def init_job(
65
65
  get_user_context=get_user_context
66
66
  or (lambda: type("UserContext", (object,), {"email": user_email})()),
67
67
  )
68
- del job["computed_values"]["created_at"]
69
68
 
70
69
  _post_crud_hook(
71
70
  crud="create", document=job, parent_id=parent_id, get_rabbit=get_rabbit
@@ -17,6 +17,9 @@ class ElodyConfiguration(BaseObjectConfiguration):
17
17
  "creator": lambda post_body, **kwargs: self._creator(post_body, **kwargs),
18
18
  "post_crud_hook": lambda **kwargs: self._post_crud_hook(**kwargs),
19
19
  "pre_crud_hook": lambda **kwargs: self._pre_crud_hook(**kwargs),
20
+ "sorting": lambda key_order_map, **kwargs: self._sorting(
21
+ key_order_map, **kwargs
22
+ ),
20
23
  }
21
24
  return {**super().crud(), **crud}
22
25
 
@@ -55,10 +58,6 @@ class ElodyConfiguration(BaseObjectConfiguration):
55
58
 
56
59
  template = {
57
60
  "_id": _id,
58
- "computed_values": {
59
- "created_at": datetime.now(timezone.utc),
60
- "event": "create",
61
- },
62
61
  "identifiers": list(
63
62
  set([_id, *identifiers, *document_defaults.pop("identifiers", [])])
64
63
  ),
@@ -66,8 +65,6 @@ class ElodyConfiguration(BaseObjectConfiguration):
66
65
  "relations": [],
67
66
  "schema": {"type": self.SCHEMA_TYPE, "version": self.SCHEMA_VERSION},
68
67
  }
69
- if user_context_id := self._get_user_context_id():
70
- template["computed_values"]["created_by"] = user_context_id
71
68
 
72
69
  for key, object_list_key in self.document_info()["object_lists"].items():
73
70
  if not key.startswith("lookup.virtual_relations"):
@@ -77,18 +74,10 @@ class ElodyConfiguration(BaseObjectConfiguration):
77
74
  object_list_key,
78
75
  )
79
76
  document = {**template, **document_defaults, **post_body}
80
-
81
- document = self._sanitize_document(
82
- document=document,
83
- object_list_name="metadata",
84
- object_list_value_field_name="value",
85
- )
86
- document = self._sort_document_keys(document)
77
+ document = self._pre_crud_hook(crud="create", document=document)
87
78
  return document
88
79
 
89
- def _document_content_patcher(
90
- self, *, document, content, overwrite=False, **kwargs
91
- ):
80
+ def _document_content_patcher(self, *, document, content, overwrite=False, **_):
92
81
  object_lists = self.document_info().get("object_lists", {})
93
82
  if overwrite:
94
83
  document = content
@@ -122,7 +111,7 @@ class ElodyConfiguration(BaseObjectConfiguration):
122
111
  object_list_name="metadata",
123
112
  object_list_value_field_name="value",
124
113
  )
125
- document = self.__patch_document_computed_values(crud, document)
114
+ document = self.__patch_document(crud, document)
126
115
  document = self._sort_document_keys(document)
127
116
  return document
128
117
 
@@ -136,11 +125,43 @@ class ElodyConfiguration(BaseObjectConfiguration):
136
125
  sanitized_document[object_list_name].remove(element)
137
126
  return sanitized_document
138
127
 
139
- def __patch_document_computed_values(self, crud, document):
140
- if not document.get("computed_values"):
141
- document["computed_values"] = {}
142
- document["computed_values"].update({"event": crud})
143
- document["computed_values"].update({"modified_at": datetime.now(timezone.utc)})
128
+ def __patch_document(self, crud, document):
129
+ document.update({f"date_{crud}d": datetime.now(timezone.utc)})
144
130
  if email := self._get_user_context_id():
145
- document["computed_values"].update({"modified_by": email})
131
+ document.update({"last_editor": email})
146
132
  return document
133
+
134
+ def _sorting(self, key_order_map, **_):
135
+ addFields, sort = {}, {}
136
+ for key, order in key_order_map.items():
137
+ if key not in ["date_created", "date_updated", "last_editor"]:
138
+ addFields.update(
139
+ {
140
+ key: {
141
+ "$arrayElemAt": [
142
+ {
143
+ "$map": {
144
+ "input": {
145
+ "$filter": {
146
+ "input": "$metadata",
147
+ "as": "metadata",
148
+ "cond": {
149
+ "$eq": ["$$metadata.key", key]
150
+ },
151
+ }
152
+ },
153
+ "as": "metadata",
154
+ "in": "$$metadata.value",
155
+ }
156
+ },
157
+ 0,
158
+ ]
159
+ }
160
+ }
161
+ )
162
+ sort.update({key: order})
163
+
164
+ pipeline = [{"$sort": sort}]
165
+ if addFields:
166
+ pipeline.append({"$addFields": addFields})
167
+ return pipeline
@@ -31,7 +31,7 @@ class JobConfiguration(ElodyConfiguration):
31
31
  def _creator(self, post_body, *, get_user_context={}, **_):
32
32
  document = super()._creator(post_body)
33
33
  if email := get_user_context().email:
34
- document["computed_values"]["created_by"] = email
34
+ document["last_editor"] = email
35
35
  return document
36
36
 
37
37
  def _post_crud_hook(self, *, crud, document, get_rabbit, **kwargs):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: elody
3
- Version: 0.0.182
3
+ Version: 0.0.184
4
4
  Summary: elody SDK for Python
5
5
  Author-email: Inuits <developers@inuits.eu>
6
6
  License: GNU GENERAL PUBLIC LICENSE
@@ -2,9 +2,9 @@ __init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  elody/__init__.py,sha256=d0Q6Fn44e7wFfLabDOBxpcJ1DPKWlFunGYDUBmO-4hA,22
3
3
  elody/client.py,sha256=VFjUUaE9edtK1XuAF5T3ayem2UEBr-Anww8AhITYLdI,8575
4
4
  elody/csv.py,sha256=7ZTqwmB4CQzqN3ddoaTOKPgFHpk2UyJte-oN2994dIg,15911
5
- elody/error_codes.py,sha256=LZ4SRV2SCC1e1z9zgVD9y3p45kq8iZpsJcqLcyKznz0,4194
5
+ elody/error_codes.py,sha256=Derbr10Lb3HZcePjargz_XsYnw2SC0edD5KHZeKlp1s,4227
6
6
  elody/exceptions.py,sha256=5KSw2sPCZz3lDIJX4LiR2iL9n4m4KIil04D1d3X5rd0,968
7
- elody/job.py,sha256=0nBCxupyxpVO-aqLd7yekgR0SsREkuON-30i0VdArAs,4216
7
+ elody/job.py,sha256=44PeBTJucHeeEQeYiA-iTv9fxTUhbAoctIAiMzGPmAA,4171
8
8
  elody/loader.py,sha256=Mr7zyP5DP5psYerf2-DnP90GiqtFlKZpcLIPD7P4pSU,5242
9
9
  elody/schemas.py,sha256=WtKdZEAX-PtEuAaRohyS3Md8H4-8yKVXMkHfCQ2SDR4,4676
10
10
  elody/util.py,sha256=QqcqkV7GZ_1p4Uf_GJnc_nfAJt0mkBGzQ7-wCxMJ1ZM,9080
@@ -13,8 +13,8 @@ elody/migration/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
13
  elody/migration/base_object_migrator.py,sha256=n8uvgGfjEUy60G47RD7Y-oxp1vHLOauwPMDl87LcxtU,436
14
14
  elody/object_configurations/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  elody/object_configurations/base_object_configuration.py,sha256=dXhzQLWtIEQHx3WSPs2R-dvN3ulcPA27G3oNGAsImBQ,6756
16
- elody/object_configurations/elody_configuration.py,sha256=uoTYN0lzWh3Z0uN4k-o-SbRnt9YrA9AkUnIi80LWcGI,5428
17
- elody/object_configurations/job_configuration.py,sha256=simi4TBiZ5cQePlzFHAd-C-khViWN9VUbAOKq9FYwk8,2057
16
+ elody/object_configurations/elody_configuration.py,sha256=Fzd9If44UNEI65i3iB5w42O4vkIgVOra8BVmwmTYpPo,6328
17
+ elody/object_configurations/job_configuration.py,sha256=HMDxaRUyfqhIy0q3yQDDMH9uW5iCd7VCmqknQofXNt0,2039
18
18
  elody/policies/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
19
19
  elody/policies/helpers.py,sha256=AV3wtvthJafW6ueEYGxggB5kk5knWTWzh3zq29Y1-ws,1434
20
20
  elody/policies/permission_handler.py,sha256=HIKWzl736qaeATJOhXSR_4f7taTEjYCR1t__9F6u39U,9606
@@ -40,8 +40,8 @@ tests/data.py,sha256=Q3oxduf-E3m-Z5G_p3fcs8jVy6g10I7zXKL1m94UVMI,2906
40
40
  tests/unit/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
41
41
  tests/unit/test_csv.py,sha256=NQaOhehfQ4GuXku0Y1SA8DYjJeqqidbF50zEHAi8RZA,15923
42
42
  tests/unit/test_utils.py,sha256=g63szcEZyHhCOtrW4BnNbcgVca3oYPIOLjBdIzNwwN0,8784
43
- elody-0.0.182.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
44
- elody-0.0.182.dist-info/METADATA,sha256=VabnJt25XNrYZpUnLlZabgkEXK3XETFIk0BaXhSKfU0,23336
45
- elody-0.0.182.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
46
- elody-0.0.182.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
47
- elody-0.0.182.dist-info/RECORD,,
43
+ elody-0.0.184.dist-info/LICENSE,sha256=gXf5dRMhNSbfLPYYTY_5hsZ1r7UU1OaKQEAQUhuIBkM,18092
44
+ elody-0.0.184.dist-info/METADATA,sha256=zFLbm3NXLS9k_aJC8NgVBDM2z2blcrPlTwBHE2xHCDo,23336
45
+ elody-0.0.184.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
46
+ elody-0.0.184.dist-info/top_level.txt,sha256=E0mImupLj0KmtUUCXRYEoLDRaSkuiGaOIIseAa0oQ-M,21
47
+ elody-0.0.184.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.8.0)
2
+ Generator: setuptools (76.0.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5