kodexa 7.0.12399293688__py3-none-any.whl → 7.4.5a13228665254__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.
kodexa/platform/client.py CHANGED
@@ -86,7 +86,8 @@ from kodexa.model.objects import (
86
86
  PageExtensionPack,
87
87
  PageOrganization,
88
88
  DocumentFamilyStatistics, MessageContext, PagePrompt, Prompt, GuidanceSet, PageGuidanceSet, DocumentEmbedding,
89
- DocumentExternalData, Task, PageTask, RetainedGuidance, PageRetainedGuidance,
89
+ DocumentExternalData, Task, PageTask, RetainedGuidance, PageRetainedGuidance, TaskTemplate, TaskStatus,
90
+ TaskActivity, TaskDocumentFamily, TaskTag,
90
91
  )
91
92
 
92
93
  logger = logging.getLogger()
@@ -1174,8 +1175,166 @@ class PagePipelineEndpoint(PagePipeline, PageEndpoint):
1174
1175
 
1175
1176
 
1176
1177
  class PageTaskEndpoint(PageTask, PageEndpoint):
1178
+ """
1179
+ Represents a page of tasks.
1180
+ """
1181
+ def get_type(self) -> Optional[str]:
1182
+ return "tasks"
1183
+
1184
+ class PageTaskActivityEndpoint(PageEndpoint):
1185
+ """
1186
+ Represents a page of task activities.
1187
+ """
1188
+ def get_type(self) -> Optional[str]:
1189
+ return "taskActivities"
1190
+
1191
+ class PageTaskDocumentFamilyEndpoint(PageEndpoint):
1192
+ """
1193
+ Represents a page of task document families.
1194
+ """
1195
+ def get_type(self) -> Optional[str]:
1196
+ return "taskDocumentFamilies"
1197
+
1198
+ class PageTaskTagEndpoint(PageEndpoint):
1199
+ """
1200
+ Represents a page of task tags.
1201
+ """
1177
1202
  def get_type(self) -> Optional[str]:
1178
- return "task"
1203
+ return "taskTags"
1204
+
1205
+ class TaskEndpoint(EntityEndpoint, Task):
1206
+ """
1207
+ Represents a task endpoint.
1208
+ """
1209
+ def get_type(self) -> str:
1210
+ return "tasks"
1211
+
1212
+ def create_with_request(self, task: Task, task_template: Optional[TaskTemplate] = None, document_families: Optional[List[DocumentFamily]] = None):
1213
+ """Create a task with the given request."""
1214
+ url = "/api/tasks/createTaskWithRequest"
1215
+ response = self.client.post(url, body={
1216
+ "task": task.model_dump(mode="json", by_alias=True),
1217
+ "taskTemplate": task_template.model_dump(mode="json", by_alias=True) if task_template else None,
1218
+ "documentFamilies": [df.model_dump(mode="json", by_alias=True) for df in document_families] if document_families else None
1219
+ })
1220
+ return TaskEndpoint.model_validate(response.json()).set_client(self.client)
1221
+
1222
+ def update_status(self, status: TaskStatus):
1223
+ """Update the status of the task."""
1224
+ url = f"/api/tasks/{self.id}/status"
1225
+ response = self.client.put(url, body=status)
1226
+ return TaskEndpoint.model_validate(response.json()).set_client(self.client)
1227
+
1228
+ def remove_status(self):
1229
+ """Remove the task status."""
1230
+ url = f"/api/tasks/{self.id}/status"
1231
+ response = self.client.delete(url)
1232
+ return TaskEndpoint.model_validate(response.json()).set_client(self.client)
1233
+
1234
+ def update_assignee(self, assignee: User):
1235
+ """Update the assignee of the task."""
1236
+ url = f"/api/tasks/{self.id}/assignee"
1237
+ response = self.client.put(url, body=assignee.model_dump(mode="json", by_alias=True))
1238
+ return TaskEndpoint.model_validate(response.json()).set_client(self.client)
1239
+
1240
+ def remove_assignee(self):
1241
+ """Remove the task assignee."""
1242
+ url = f"/api/tasks/{self.id}/assignee"
1243
+ response = self.client.delete(url)
1244
+ return TaskEndpoint.model_validate(response.json()).set_client(self.client)
1245
+
1246
+ class TasksEndpoint(EntitiesEndpoint):
1247
+ """
1248
+ Represents tasks endpoints.
1249
+ """
1250
+ def get_type(self) -> str:
1251
+ return "tasks"
1252
+
1253
+ def get_instance_class(self, object_dict=None):
1254
+ return TaskEndpoint
1255
+
1256
+ def get_page_class(self, object_dict=None):
1257
+ return PageTaskEndpoint
1258
+
1259
+ class TaskTemplateEndpoint(EntityEndpoint, TaskTemplate):
1260
+ """
1261
+ Represents a task template endpoint.
1262
+ """
1263
+ def get_type(self) -> str:
1264
+ return "taskTemplates"
1265
+
1266
+ class TaskTemplatesEndpoint(EntitiesEndpoint):
1267
+ """
1268
+ Represents task templates endpoints.
1269
+ """
1270
+ def get_type(self) -> str:
1271
+ return "taskTemplates"
1272
+
1273
+ def get_instance_class(self, object_dict=None):
1274
+ return TaskTemplateEndpoint
1275
+
1276
+ def get_page_class(self, object_dict=None):
1277
+ return PageTaskTemplateEndpoint
1278
+
1279
+ class TaskActivityEndpoint(EntityEndpoint, TaskActivity):
1280
+ """
1281
+ Represents a task activity endpoint.
1282
+ """
1283
+ def get_type(self) -> str:
1284
+ return "taskActivities"
1285
+
1286
+ class TaskActivitiesEndpoint(EntitiesEndpoint):
1287
+ """
1288
+ Represents task activities endpoints.
1289
+ """
1290
+ def get_type(self) -> str:
1291
+ return "taskActivities"
1292
+
1293
+ def get_instance_class(self, object_dict=None):
1294
+ return TaskActivityEndpoint
1295
+
1296
+ def get_page_class(self, object_dict=None):
1297
+ return PageTaskActivityEndpoint
1298
+
1299
+ class TaskDocumentFamilyEndpoint(EntityEndpoint, TaskDocumentFamily):
1300
+ """
1301
+ Represents a task document family endpoint.
1302
+ """
1303
+ def get_type(self) -> str:
1304
+ return "taskDocumentFamilies"
1305
+
1306
+ class TaskDocumentFamiliesEndpoint(EntitiesEndpoint):
1307
+ """
1308
+ Represents task document families endpoints.
1309
+ """
1310
+ def get_type(self) -> str:
1311
+ return "taskDocumentFamilies"
1312
+
1313
+ def get_instance_class(self, object_dict=None):
1314
+ return TaskDocumentFamilyEndpoint
1315
+
1316
+ def get_page_class(self, object_dict=None):
1317
+ return PageTaskDocumentFamilyEndpoint
1318
+
1319
+ class TaskTagEndpoint(EntityEndpoint, TaskTag):
1320
+ """
1321
+ Represents a task tag endpoint.
1322
+ """
1323
+ def get_type(self) -> str:
1324
+ return "taskTags"
1325
+
1326
+ class TaskTagsEndpoint(EntitiesEndpoint):
1327
+ """
1328
+ Represents task tags endpoints.
1329
+ """
1330
+ def get_type(self) -> str:
1331
+ return "taskTags"
1332
+
1333
+ def get_instance_class(self, object_dict=None):
1334
+ return TaskTagEndpoint
1335
+
1336
+ def get_page_class(self, object_dict=None):
1337
+ return PageTaskTagEndpoint
1179
1338
 
1180
1339
 
1181
1340
  class PageRetainedGuidanceEndpoint(PageRetainedGuidance, PageEndpoint):
@@ -4577,7 +4736,7 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4577
4736
 
4578
4737
  def unlock(self):
4579
4738
  """
4580
- Lock the document family.
4739
+ Unlock the document family.
4581
4740
  """
4582
4741
  url = f"/api/stores/{self.store_ref.replace(':', '/')}/families/{self.id}/unlock"
4583
4742
  response = self.client.put(url)
@@ -4616,6 +4775,35 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4616
4775
  url = f"/api/documentFamilies/{self.id}/externalData"
4617
4776
  response = self.client.put(url, body=external_data)
4618
4777
  return response.json()
4778
+
4779
+ def get_json(
4780
+ self,
4781
+ project_id: str,
4782
+ friendly_names=False,
4783
+ ) -> str:
4784
+ """Get the JSON export for the document family
4785
+
4786
+ Args:
4787
+ project_id str: The project ID
4788
+ friendly_names (bool): Whether to use friendly names. Defaults to False
4789
+
4790
+ Returns:
4791
+ str: The JSON
4792
+ """
4793
+ if project_id is None:
4794
+ raise Exception(
4795
+ f"Project ID is required"
4796
+ )
4797
+
4798
+ url = f"/api/stores/{self.store_ref.replace(':', '/')}/families/{self.id}/dataObjects"
4799
+ params = {
4800
+ "format": "json",
4801
+ "friendlyNames": friendly_names,
4802
+ "projectId": project_id,
4803
+ }
4804
+
4805
+ response = self.client.get(url, params=params)
4806
+ return response.text
4619
4807
 
4620
4808
  def export(self) -> bytes:
4621
4809
  """
@@ -4651,6 +4839,7 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4651
4839
  mixin: Optional[str] = None,
4652
4840
  label: Optional[str] = None,
4653
4841
  timeout: int = 60,
4842
+ polling_delay_in_seconds: int = 5,
4654
4843
  ) -> "DocumentFamilyEndpoint":
4655
4844
  """
4656
4845
  Wait for the document family to be ready.
@@ -4659,6 +4848,7 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4659
4848
  mixin (Optional[str]): The mixin. Defaults to None.
4660
4849
  label (Optional[str]): The label. Defaults to None.
4661
4850
  timeout (int): The timeout. Defaults to 60.
4851
+ polling_delay_in_seconds (int): The polling delay in seconds. Defaults to 5. 5 is the minimum value.
4662
4852
 
4663
4853
  Returns:
4664
4854
  DocumentFamilyEndpoint: The updated document family endpoint.
@@ -4667,6 +4857,9 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4667
4857
  "Waiting for mixin and/or label to be available on document family %s",
4668
4858
  self.id,
4669
4859
  )
4860
+ if polling_delay_in_seconds < 5:
4861
+ polling_delay_in_seconds = 5
4862
+
4670
4863
  start = time.time()
4671
4864
  while time.time() - start < timeout:
4672
4865
  url = f"/api/stores/{self.store_ref.replace(':', '/')}/families/{self.id}"
@@ -4680,7 +4873,7 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4680
4873
  ):
4681
4874
  return updated_document_family
4682
4875
 
4683
- time.sleep(5)
4876
+ time.sleep(polling_delay_in_seconds)
4684
4877
 
4685
4878
  raise Exception(f"Not available on document family {self.id}")
4686
4879
 
@@ -4783,7 +4976,8 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4783
4976
  self.client.put(url, body=document_status.model_dump(by_alias=True))
4784
4977
 
4785
4978
  def add_document(
4786
- self, document: Document, content_object: Optional[ContentObject] = None
4979
+ self, document: Document, content_object: Optional[ContentObject] = None,
4980
+ taxonomies: Optional[List[Taxonomy]] = None, data_store: Optional[Store] = None
4787
4981
  ):
4788
4982
  """
4789
4983
  Add a document to the document family.
@@ -4791,22 +4985,36 @@ class DocumentFamilyEndpoint(DocumentFamily, ClientEndpoint):
4791
4985
  Args:
4792
4986
  document (Document): The document to add.
4793
4987
  content_object (Optional[ContentObject]): The content object. Defaults to None.
4988
+ taxonomies (Optional[List[Taxonomy]]): List of taxonomies to use. Defaults to None.
4989
+ data_store (Optional[Store]): Data store to add document to. Defaults to None.
4794
4990
  """
4795
4991
  url = (
4796
4992
  f'/api/stores/{self.store_ref.replace(":", "/")}/families/{self.id}/objects'
4797
4993
  )
4798
4994
  if content_object is None:
4799
4995
  content_object = self.content_objects[-1]
4996
+
4997
+ params = {
4998
+ "sourceContentObjectId": content_object.id,
4999
+ "transitionType": "DERIVED",
5000
+ "documentVersion": document.version
5001
+ }
5002
+
5003
+ # If we have a store but no taxonomies or the other way around then we need to throw an error
5004
+ if (data_store and not taxonomies) or (taxonomies and not data_store):
5005
+ raise Exception("If you provide a data store you must also provide taxonomies and vice-versa")
5006
+
5007
+ if taxonomies:
5008
+ params["taxonomyRefs"] = ",".join([taxonomy.ref for taxonomy in taxonomies])
5009
+
5010
+ if data_store:
5011
+ params["dataStoreRef"] = data_store.ref
5012
+
4800
5013
  self.client.post(
4801
5014
  url,
4802
- params={
4803
- "sourceContentObjectId": content_object.id,
4804
- "transitionType": "DERIVED",
4805
- "documentVersion": document.version,
4806
- },
5015
+ params=params,
4807
5016
  files={"file": document.to_kddb()},
4808
5017
  )
4809
-
4810
5018
  def export_as_zip(self) -> bytes:
4811
5019
  """
4812
5020
  Export the document family as bytes.
@@ -5123,7 +5331,7 @@ class DataStoreEndpoint(StoreEndpoint):
5123
5331
 
5124
5332
  response = self.client.get(url, params=params)
5125
5333
  return response.text
5126
-
5334
+
5127
5335
  def get_taxonomies(self) -> List[Taxonomy]:
5128
5336
  """Get the taxonomies of the store
5129
5337
 
@@ -5428,6 +5636,7 @@ class DocumentStoreEndpoint(StoreEndpoint):
5428
5636
  replace=False,
5429
5637
  additional_metadata: Optional[dict] = None,
5430
5638
  external_data: Optional[dict] = None,
5639
+ document: Optional[Document] = None,
5431
5640
  ):
5432
5641
  """
5433
5642
  Upload a file to the store.
@@ -5438,6 +5647,7 @@ class DocumentStoreEndpoint(StoreEndpoint):
5438
5647
  replace (bool): Replace the file if it already exists (Default False).
5439
5648
  additional_metadata (Optional[dict]): Additional metadata to add to the file (Default None).
5440
5649
  external_data (Optional[dict]): External data to add to the file (Default None).
5650
+ document (Optional[Document]): The document to add to the file (Default None).
5441
5651
  """
5442
5652
  if Path(file_path).is_file():
5443
5653
  logger.info(f"Uploading {file_path}")
@@ -5447,7 +5657,8 @@ class DocumentStoreEndpoint(StoreEndpoint):
5447
5657
  content=path_content,
5448
5658
  replace=replace,
5449
5659
  additional_metadata=additional_metadata,
5450
- external_data=external_data
5660
+ external_data=external_data,
5661
+ document=document,
5451
5662
  )
5452
5663
  else:
5453
5664
  raise Exception(f"{file_path} is not a file")
@@ -5459,6 +5670,7 @@ class DocumentStoreEndpoint(StoreEndpoint):
5459
5670
  replace=False,
5460
5671
  additional_metadata: Optional[dict] = None,
5461
5672
  external_data: Optional[dict] = None,
5673
+ document: Optional[Document] = None,
5462
5674
  ) -> DocumentFamilyEndpoint:
5463
5675
  """
5464
5676
  Put the content into the store at the given path.
@@ -5469,11 +5681,12 @@ class DocumentStoreEndpoint(StoreEndpoint):
5469
5681
  replace (bool): Replace the content if it exists.
5470
5682
  additional_metadata (Optional[dict]): Additional metadata to store with the document (not it can't include 'path').
5471
5683
  external_data (Optional[dict]): External data to store with the document.
5684
+ document (Optional[Document]): The document to store with the content.
5472
5685
 
5473
5686
  Returns:
5474
5687
  DocumentFamilyEndpoint: The document family that was created.
5475
5688
  """
5476
- files = {"file": content}
5689
+ files = {"file": content, "document": document.to_kddb()} if document else {"file": content}
5477
5690
 
5478
5691
  if additional_metadata is None:
5479
5692
  additional_metadata = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: kodexa
3
- Version: 7.0.12399293688
3
+ Version: 7.4.5a13228665254
4
4
  Summary: Python SDK for the Kodexa Platform
5
5
  Author: Austin Redenbaugh
6
6
  Author-email: austin@kodexa.com
@@ -3,22 +3,23 @@ kodexa/assistant/__init__.py,sha256=nlXm_YnV_50hgn0TIT2Fkc2fQ-86OjmctY_j8My9nc4,
3
3
  kodexa/assistant/assistant.py,sha256=5KFdbqFSLIZJyDRyZdpcfr448fT-CW4JhYu9A6B9DGY,14663
4
4
  kodexa/connectors/__init__.py,sha256=WF6G_MUeU32TlKSUKkpNoNX7dq8iBPliFMep4E8BmZc,328
5
5
  kodexa/connectors/connectors.py,sha256=FpUZDkSyHld2b9eYRuVOWzaFtuGoaRuPXXicJB7THbc,10413
6
- kodexa/dataclasses/__init__.py,sha256=DKLWMALnUWYFDMraEc9We85GI_rvpp-z7Q1fKX-3jQI,18561
6
+ kodexa/dataclasses/__init__.py,sha256=CHMNsOamWA3gY5203gn8Ef5q1fgcczMtWKEvNjIOzPs,19486
7
7
  kodexa/dataclasses/templates/llm_data_class.j2,sha256=YWjStW136chV_59JM3AYis3i-0jdrqDvLXsISUW9zDU,660
8
8
  kodexa/model/__init__.py,sha256=rtLXYJBxB-rnukhslN9rlqoB3--1H3253HyHGbD_Gc8,796
9
9
  kodexa/model/base.py,sha256=CaZK8nMhT1LdCpt4aLhebJGcorjq9qRID1FjnXnP14M,521
10
10
  kodexa/model/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
11
  kodexa/model/entities/check_response.py,sha256=eqBHxO6G2OAziL3p9bHGI-oiPkAG82H6Choc8wyvtM4,3949
12
- kodexa/model/entities/product.py,sha256=ZDpHuBE_9FJ-klnkyBvTfPwYOqBkM1wraZMtHqNA8FQ,3526
12
+ kodexa/model/entities/product.py,sha256=StUhTEeLXmc05cj6XnZppQfeJsqCPbX1jdhsysHH--Q,5787
13
+ kodexa/model/entities/product_group.py,sha256=540fRGyUf34h1BzAN1DiWu6rGgvaj3xDFhZ2k-RvSFY,3617
13
14
  kodexa/model/entities/product_subscription.py,sha256=UcmWR-qgLfdV7VCtJNwzgkanoS8nBSL6ngVuxQUK1M8,3810
14
- kodexa/model/model.py,sha256=Bjy1n6_9kQLLch-wCUDpT31sTctE2kCGdi4cb1ptZN4,118647
15
- kodexa/model/objects.py,sha256=4Oyjs6omlHfwziAK1m2tFk4jSnzN7lFdXACog07ed1c,185124
16
- kodexa/model/persistence.py,sha256=P4DmC9UdczmjJgXNeeTlhwKH9nSAdzYZOaDTyqaDPOA,69501
15
+ kodexa/model/model.py,sha256=qh1YUew3UgtjU0t4fAwSXYYuzQjXTOZWZkafyFp_w8M,118801
16
+ kodexa/model/objects.py,sha256=x9Iah3Wo2UvQKDrL1BcrN4qF68ljCQDRnlyKJ4OgKsE,188900
17
+ kodexa/model/persistence.py,sha256=HX_uIkGs8bqHwqyE5wB2qMlGIG5ZnjuTu7xMdvKhEzA,72033
17
18
  kodexa/model/utils.py,sha256=6R-3rFiW9irBwj0Mq5yhp7EDXkNUFaeFhr3bWmnlW4g,2961
18
19
  kodexa/pipeline/__init__.py,sha256=sA7f5D6qkdMrpp2xTIeefnrUBI6xxEEWostvxfX_1Cs,236
19
- kodexa/pipeline/pipeline.py,sha256=ZYpJAWcwV4YRK589DUhU0vXGQlkNSj4J2TsGbYqTLjo,25221
20
+ kodexa/pipeline/pipeline.py,sha256=Z4O6UwoISeP_HMlxm6l6kbcvFBDw3Glm7lT4cUibri4,25461
20
21
  kodexa/platform/__init__.py,sha256=1O3oiWMg292NPL_NacKDnK1T3_R6cMorrPRue_9e-O4,216
21
- kodexa/platform/client.py,sha256=PWn-Xk3vH993Ne5YXDKqJT9rmj7okwVBivuQv9rt2UQ,226591
22
+ kodexa/platform/client.py,sha256=kw1UOSwGV0zl_V0oOsSS7sP-IJzCQNyua4P52HFpO7U,233867
22
23
  kodexa/platform/interaction.py,sha256=6zpcwXKNZstUGNS6m4JsoRXAqCZPJHWI-ZN3co8nnF0,1055
23
24
  kodexa/platform/kodexa.py,sha256=tPXHO500q3S75GhKGDcaxO51Viq2PNlHmAzpBZlahgo,34857
24
25
  kodexa/selectors/__init__.py,sha256=xA9-4vpyaAZWPSk3bh2kvDLkdv6XEmm7PjFbpziiTIk,100
@@ -43,7 +44,7 @@ kodexa/testing/test_utils.py,sha256=v44p__gE7ia67W7WeHN2HBFCWSCUrCZt7G4xBNCmwf8,
43
44
  kodexa/training/__init__.py,sha256=xs2L62YpRkIRfslQwtQZ5Yxjhm7sLzX2TrVX6EuBnZQ,52
44
45
  kodexa/training/train_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
46
  kodexa/utils/__init__.py,sha256=Pnim1o9_db5YEnNvDTxpM7HG-qTlL6n8JwFwOafU9wo,5928
46
- kodexa-7.0.12399293688.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
47
- kodexa-7.0.12399293688.dist-info/METADATA,sha256=oQ8cDBBYml0HvYWVGK-klGpt_kpMzPARlO5JY0l0wdY,3527
48
- kodexa-7.0.12399293688.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
49
- kodexa-7.0.12399293688.dist-info/RECORD,,
47
+ kodexa-7.4.5a13228665254.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
48
+ kodexa-7.4.5a13228665254.dist-info/METADATA,sha256=G1W-0oXbyNlThnUxTzTZrxLQSX3KfRkG12lVTEqV_vU,3529
49
+ kodexa-7.4.5a13228665254.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
50
+ kodexa-7.4.5a13228665254.dist-info/RECORD,,