dokuments 2.0.0__tar.gz → 3.0.0__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.
- {dokuments-2.0.0 → dokuments-3.0.0}/PKG-INFO +2 -2
- {dokuments-2.0.0 → dokuments-3.0.0}/README.md +1 -1
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/api/schema.graphql +11 -3
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/api/schema.py +74 -10
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/links/upload.py +14 -7
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/traits.py +1 -1
- {dokuments-2.0.0 → dokuments-3.0.0}/.gitignore +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/__init__.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/api/project.json +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/arkitekt.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/contrib/__init__.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/contrib/fakts/__init__.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/datalayer.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/dokuments.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/io/__init__.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/io/download.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/py.typed +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/rath.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/dokuments/scalars.py +0 -0
- {dokuments-2.0.0 → dokuments-3.0.0}/pyproject.toml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dokuments
|
|
3
|
-
Version:
|
|
3
|
+
Version: 3.0.0
|
|
4
4
|
Summary: The python client for dokuments, the arkitekt document service
|
|
5
5
|
Author-email: jhnnsrs <jhnnsrs@gmail.com>
|
|
6
6
|
Requires-Python: >=3.11
|
|
@@ -71,7 +71,7 @@ from dokuments import dokuments_service
|
|
|
71
71
|
with easy("my-script", dokuments_service) as dokuments:
|
|
72
72
|
file = dokuments.from_file_like(file="scan.pdf") # a path, a Path or a binary file object
|
|
73
73
|
document = dokuments.create_document(title="My scan", file=file.id)
|
|
74
|
-
print(document.id, file.store.
|
|
74
|
+
print(document.id, file.store.download()) # the bytes, through a scoped read grant
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
Uploads go straight to the datalayer: the client asks the server for upload
|
|
@@ -56,7 +56,7 @@ from dokuments import dokuments_service
|
|
|
56
56
|
with easy("my-script", dokuments_service) as dokuments:
|
|
57
57
|
file = dokuments.from_file_like(file="scan.pdf") # a path, a Path or a binary file object
|
|
58
58
|
document = dokuments.create_document(title="My scan", file=file.id)
|
|
59
|
-
print(document.id, file.store.
|
|
59
|
+
print(document.id, file.store.download()) # the bytes, through a scoped read grant
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
Uploads go straight to the datalayer: the client asks the server for upload
|
|
@@ -94,14 +94,13 @@ input FromFileLike {
|
|
|
94
94
|
|
|
95
95
|
"""Temporary S3 credentials for reading a media object."""
|
|
96
96
|
type GeneralMediaAccessGrant {
|
|
97
|
-
path: String!
|
|
98
|
-
store: String
|
|
99
97
|
status: String!
|
|
100
98
|
accessKey: String!
|
|
101
99
|
secretKey: String!
|
|
102
100
|
sessionToken: String!
|
|
103
101
|
region: String!
|
|
104
102
|
bucket: String!
|
|
103
|
+
prefix: String!
|
|
105
104
|
expiresIn: Int!
|
|
106
105
|
}
|
|
107
106
|
|
|
@@ -168,6 +167,11 @@ type Mutation {
|
|
|
168
167
|
"""Finalize an upload after the client has written the object."""
|
|
169
168
|
finishMediaUpload(input: FinishMediaUploadInput!): MediaStore! @auth(any_role_of: ["admin", "editor", "bot"])
|
|
170
169
|
|
|
170
|
+
"""
|
|
171
|
+
Reissue upload credentials for a media upload still in flight, to the same key, so a write that outlives its credentials carries on. Only the uploader may, never for a finished store, and never past the upload's time limit
|
|
172
|
+
"""
|
|
173
|
+
refreshMediaUpload(input: RefreshUploadInput!): MediaUploadGrant! @auth(any_role_of: ["admin", "editor", "bot"])
|
|
174
|
+
|
|
171
175
|
"""Request temporary S3 read credentials for an uploaded file."""
|
|
172
176
|
requestMediaAccess(input: RequestMediaAccessInput!): MediaAccessGrant!
|
|
173
177
|
|
|
@@ -259,6 +263,10 @@ type Query {
|
|
|
259
263
|
): Page!
|
|
260
264
|
}
|
|
261
265
|
|
|
266
|
+
input RefreshUploadInput {
|
|
267
|
+
storeId: String!
|
|
268
|
+
}
|
|
269
|
+
|
|
262
270
|
input RequestGeneralMediaAccessInput {
|
|
263
271
|
expiresIn: Int = null
|
|
264
272
|
}
|
|
@@ -269,7 +277,7 @@ input RequestMediaAccessInput {
|
|
|
269
277
|
|
|
270
278
|
input RequestMediaUploadInput {
|
|
271
279
|
originalFileName: String!
|
|
272
|
-
fileSize: ByteCount
|
|
280
|
+
fileSize: ByteCount!
|
|
273
281
|
contentType: String = null
|
|
274
282
|
}
|
|
275
283
|
|
|
@@ -110,6 +110,18 @@ class OCRTextLineInput(BaseModel):
|
|
|
110
110
|
)
|
|
111
111
|
|
|
112
112
|
|
|
113
|
+
class RefreshUploadInput(BaseModel):
|
|
114
|
+
"""No documentation"""
|
|
115
|
+
|
|
116
|
+
store_id: str = Field(
|
|
117
|
+
validation_alias=AliasChoices("store_id", "storeId"),
|
|
118
|
+
serialization_alias="storeId",
|
|
119
|
+
)
|
|
120
|
+
model_config = ConfigDict(
|
|
121
|
+
frozen=True, extra="forbid", populate_by_name=True, use_enum_values=True
|
|
122
|
+
)
|
|
123
|
+
|
|
124
|
+
|
|
113
125
|
class RequestMediaAccessInput(BaseModel):
|
|
114
126
|
"""No documentation"""
|
|
115
127
|
|
|
@@ -129,10 +141,9 @@ class RequestMediaUploadInput(BaseModel):
|
|
|
129
141
|
validation_alias=AliasChoices("original_file_name", "originalFileName"),
|
|
130
142
|
serialization_alias="originalFileName",
|
|
131
143
|
)
|
|
132
|
-
file_size: int
|
|
144
|
+
file_size: int = Field(
|
|
133
145
|
validation_alias=AliasChoices("file_size", "fileSize"),
|
|
134
146
|
serialization_alias="fileSize",
|
|
135
|
-
default=None,
|
|
136
147
|
)
|
|
137
148
|
content_type: str | None = Field(
|
|
138
149
|
validation_alias=AliasChoices("content_type", "contentType"),
|
|
@@ -357,6 +368,25 @@ class RequestMediaAccessMutation(BaseModel):
|
|
|
357
368
|
document = "fragment MediaAccessGrant on MediaAccessGrant {\n accessKey\n secretKey\n sessionToken\n path\n key\n bucket\n region\n expiresIn\n store\n __typename\n}\n\nmutation RequestMediaAccess($input: RequestMediaAccessInput!) {\n requestMediaAccess(input: $input) {\n ...MediaAccessGrant\n __typename\n }\n}"
|
|
358
369
|
|
|
359
370
|
|
|
371
|
+
class RefreshMediaUploadMutation(BaseModel):
|
|
372
|
+
"""Reissues credentials for an upload still in flight, to the same key: a write that outlives its
|
|
373
|
+
credentials asks for this before they expire and carries on. Only the uploader may.
|
|
374
|
+
"""
|
|
375
|
+
|
|
376
|
+
refresh_media_upload: MediaUploadGrant = Field(alias="refreshMediaUpload")
|
|
377
|
+
"Reissue upload credentials for a media upload still in flight, to the same key, so a write that outlives its credentials carries on. Only the uploader may, never for a finished store, and never past the upload's time limit"
|
|
378
|
+
|
|
379
|
+
class Arguments(BaseModel):
|
|
380
|
+
"""Arguments for RefreshMediaUpload"""
|
|
381
|
+
|
|
382
|
+
input: RefreshUploadInput
|
|
383
|
+
|
|
384
|
+
class Meta:
|
|
385
|
+
"""Meta class for RefreshMediaUpload"""
|
|
386
|
+
|
|
387
|
+
document = "fragment MediaUploadGrant on MediaUploadGrant {\n accessKey\n secretKey\n sessionToken\n path\n key\n bucket\n region\n expiresIn\n maxBytes\n store\n __typename\n}\n\nmutation RefreshMediaUpload($input: RefreshUploadInput!) {\n refreshMediaUpload(input: $input) {\n ...MediaUploadGrant\n __typename\n }\n}"
|
|
388
|
+
|
|
389
|
+
|
|
360
390
|
class CreatePageMutation(BaseModel):
|
|
361
391
|
"""No documentation found for this operation."""
|
|
362
392
|
|
|
@@ -554,7 +584,7 @@ class DokumentsApi:
|
|
|
554
584
|
async def arequest_media_upload(
|
|
555
585
|
self,
|
|
556
586
|
original_file_name: str,
|
|
557
|
-
file_size: int
|
|
587
|
+
file_size: int,
|
|
558
588
|
content_type: str | None | UnsetType = UNSET,
|
|
559
589
|
) -> MediaUploadGrant:
|
|
560
590
|
"""RequestMediaUpload
|
|
@@ -563,7 +593,7 @@ class DokumentsApi:
|
|
|
563
593
|
|
|
564
594
|
Args:
|
|
565
595
|
original_file_name: The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. (required)
|
|
566
|
-
file_size: A number of bytes. 64-bit, unlike Int: serialized as a JSON number, and accepted as a number or a numeric string.
|
|
596
|
+
file_size: A number of bytes. 64-bit, unlike Int: serialized as a JSON number, and accepted as a number or a numeric string. (required)
|
|
567
597
|
content_type: The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
|
|
568
598
|
|
|
569
599
|
Returns:
|
|
@@ -572,8 +602,7 @@ class DokumentsApi:
|
|
|
572
602
|
variables: dict[str, builtins.object] = {}
|
|
573
603
|
_input: dict[str, builtins.object] = {}
|
|
574
604
|
_input["originalFileName"] = original_file_name
|
|
575
|
-
|
|
576
|
-
_input["fileSize"] = file_size
|
|
605
|
+
_input["fileSize"] = file_size
|
|
577
606
|
if content_type is not UNSET:
|
|
578
607
|
_input["contentType"] = content_type
|
|
579
608
|
variables["input"] = _input
|
|
@@ -584,7 +613,7 @@ class DokumentsApi:
|
|
|
584
613
|
def request_media_upload(
|
|
585
614
|
self,
|
|
586
615
|
original_file_name: str,
|
|
587
|
-
file_size: int
|
|
616
|
+
file_size: int,
|
|
588
617
|
content_type: str | None | UnsetType = UNSET,
|
|
589
618
|
) -> MediaUploadGrant:
|
|
590
619
|
"""RequestMediaUpload
|
|
@@ -593,7 +622,7 @@ class DokumentsApi:
|
|
|
593
622
|
|
|
594
623
|
Args:
|
|
595
624
|
original_file_name: The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. (required)
|
|
596
|
-
file_size: A number of bytes. 64-bit, unlike Int: serialized as a JSON number, and accepted as a number or a numeric string.
|
|
625
|
+
file_size: A number of bytes. 64-bit, unlike Int: serialized as a JSON number, and accepted as a number or a numeric string. (required)
|
|
597
626
|
content_type: The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.
|
|
598
627
|
|
|
599
628
|
Returns:
|
|
@@ -602,8 +631,7 @@ class DokumentsApi:
|
|
|
602
631
|
variables: dict[str, builtins.object] = {}
|
|
603
632
|
_input: dict[str, builtins.object] = {}
|
|
604
633
|
_input["originalFileName"] = original_file_name
|
|
605
|
-
|
|
606
|
-
_input["fileSize"] = file_size
|
|
634
|
+
_input["fileSize"] = file_size
|
|
607
635
|
if content_type is not UNSET:
|
|
608
636
|
_input["contentType"] = content_type
|
|
609
637
|
variables["input"] = _input
|
|
@@ -685,6 +713,42 @@ class DokumentsApi:
|
|
|
685
713
|
variables["input"] = _input
|
|
686
714
|
return self.execute(RequestMediaAccessMutation, variables).request_media_access
|
|
687
715
|
|
|
716
|
+
async def arefresh_media_upload(self, store_id: str) -> MediaUploadGrant:
|
|
717
|
+
"""RefreshMediaUpload
|
|
718
|
+
Reissues credentials for an upload still in flight, to the same key: a write that outlives its
|
|
719
|
+
credentials asks for this before they expire and carries on. Only the uploader may.
|
|
720
|
+
|
|
721
|
+
Args:
|
|
722
|
+
store_id: The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. (required)
|
|
723
|
+
|
|
724
|
+
Returns:
|
|
725
|
+
MediaUploadGrant
|
|
726
|
+
"""
|
|
727
|
+
variables: dict[str, builtins.object] = {}
|
|
728
|
+
_input: dict[str, builtins.object] = {}
|
|
729
|
+
_input["storeId"] = store_id
|
|
730
|
+
variables["input"] = _input
|
|
731
|
+
return (
|
|
732
|
+
await self.aexecute(RefreshMediaUploadMutation, variables)
|
|
733
|
+
).refresh_media_upload
|
|
734
|
+
|
|
735
|
+
def refresh_media_upload(self, store_id: str) -> MediaUploadGrant:
|
|
736
|
+
"""RefreshMediaUpload
|
|
737
|
+
Reissues credentials for an upload still in flight, to the same key: a write that outlives its
|
|
738
|
+
credentials asks for this before they expire and carries on. Only the uploader may.
|
|
739
|
+
|
|
740
|
+
Args:
|
|
741
|
+
store_id: The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text. (required)
|
|
742
|
+
|
|
743
|
+
Returns:
|
|
744
|
+
MediaUploadGrant
|
|
745
|
+
"""
|
|
746
|
+
variables: dict[str, builtins.object] = {}
|
|
747
|
+
_input: dict[str, builtins.object] = {}
|
|
748
|
+
_input["storeId"] = store_id
|
|
749
|
+
variables["input"] = _input
|
|
750
|
+
return self.execute(RefreshMediaUploadMutation, variables).refresh_media_upload
|
|
751
|
+
|
|
688
752
|
async def acreate_page(
|
|
689
753
|
self,
|
|
690
754
|
image: FileLike,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import asyncio
|
|
2
|
-
import
|
|
2
|
+
import io
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
from dokuments.scalars import FileLike
|
|
@@ -53,12 +53,19 @@ async def apply_recursive(
|
|
|
53
53
|
return obj # type: ignore
|
|
54
54
|
|
|
55
55
|
|
|
56
|
-
def _size_of(file: FileLike) -> int
|
|
57
|
-
"""
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
def _size_of(file: FileLike) -> int:
|
|
57
|
+
"""How many bytes the upload will send: the size the grant declares, and is then held to.
|
|
58
|
+
|
|
59
|
+
A file object is measured from where it stands to its end -- that is what gets read --
|
|
60
|
+
and left where it was; raw bytes by their length.
|
|
61
|
+
"""
|
|
62
|
+
value = file.value
|
|
63
|
+
if isinstance(value, (bytes, bytearray, memoryview)):
|
|
64
|
+
return len(value)
|
|
65
|
+
position = value.tell()
|
|
66
|
+
end = value.seek(0, io.SEEK_END)
|
|
67
|
+
value.seek(position)
|
|
68
|
+
return end - position
|
|
62
69
|
|
|
63
70
|
|
|
64
71
|
class UploadLink(ParsingLink):
|
|
@@ -27,4 +27,4 @@ class HasDownloadAccessor(ContextBound, BaseModel):
|
|
|
27
27
|
if not isinstance(client, Dokuments):
|
|
28
28
|
raise ValueError("This store was not fetched through a Dokuments client, so there is none to ask for a read grant.")
|
|
29
29
|
store_id, key = get_attributes_or_error(self, "id", "key")
|
|
30
|
-
return download_file(client, store_id, file_name or key)
|
|
30
|
+
return download_file(client, store_id, file_name or key.rsplit("/", 1)[-1])
|
|
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
|