@seamapi/nextlove-sdk-generator 1.8.5 → 1.10.0
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.
- package/lib/generate-python-sdk/class-file.js +2 -2
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/generate-python-sdk.js +11 -2
- package/lib/generate-python-sdk/generate-python-sdk.js.map +1 -1
- package/lib/generate-python-sdk/templates/__init__.py.template.js +8 -2
- package/lib/generate-python-sdk/templates/__init__.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/auth.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/auth.py.template.js +103 -0
- package/lib/generate-python-sdk/templates/auth.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/conftest.py.template.js +8 -17
- package/lib/generate-python-sdk/templates/conftest.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/parse_options.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/parse_options.py.template.js +91 -0
- package/lib/generate-python-sdk/templates/parse_options.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/routes.py.template.js +0 -3
- package/lib/generate-python-sdk/templates/routes.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/seam.py.template.js +55 -36
- package/lib/generate-python-sdk/templates/seam.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.js +1 -4
- package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +34 -9
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/token.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/token.py.template.js +49 -0
- package/lib/generate-python-sdk/templates/token.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/utils/action-attempt.d.ts +1 -0
- package/lib/generate-python-sdk/templates/utils/action-attempt.js +9 -2
- package/lib/generate-python-sdk/templates/utils/action-attempt.js.map +1 -1
- package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.js +24 -0
- package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.js.map +1 -0
- package/package.json +1 -1
- package/src/lib/generate-python-sdk/class-file.ts +2 -1
- package/src/lib/generate-python-sdk/generate-python-sdk.ts +11 -2
- package/src/lib/generate-python-sdk/templates/__init__.py.template.ts +8 -2
- package/src/lib/generate-python-sdk/templates/auth.py.template.ts +102 -0
- package/src/lib/generate-python-sdk/templates/conftest.py.template.ts +8 -17
- package/src/lib/generate-python-sdk/templates/parse_options.py.template.ts +90 -0
- package/src/lib/generate-python-sdk/templates/routes.py.template.ts +0 -3
- package/src/lib/generate-python-sdk/templates/seam.py.template.ts +55 -36
- package/src/lib/generate-python-sdk/templates/snippets/abstract-routes.template.ts +1 -4
- package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +34 -9
- package/src/lib/generate-python-sdk/templates/token.py.template.ts +48 -0
- package/src/lib/generate-python-sdk/templates/utils/action-attempt.ts +10 -2
- package/src/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.ts +23 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export default () => `token_prefix = "seam_"
|
|
2
|
+
|
|
3
|
+
access_token_prefix = "seam_at"
|
|
4
|
+
|
|
5
|
+
jwt_prefix = "ey"
|
|
6
|
+
|
|
7
|
+
client_session_token_prefix = "seam_cst"
|
|
8
|
+
|
|
9
|
+
publishable_key_token_prefix = "seam_pk"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def is_access_token(token: str) -> bool:
|
|
13
|
+
return token.startswith(access_token_prefix)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def is_jwt(token: str) -> bool:
|
|
17
|
+
return token.startswith(jwt_prefix)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def is_seam_token(token: str) -> bool:
|
|
21
|
+
return token.startswith(token_prefix)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
def is_api_key(token: str) -> bool:
|
|
25
|
+
return (
|
|
26
|
+
not is_client_session_token(token)
|
|
27
|
+
and not is_jwt(token)
|
|
28
|
+
and not is_access_token(token)
|
|
29
|
+
and not is_publishable_key(token)
|
|
30
|
+
and is_seam_token(token)
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def is_client_session_token(token: str) -> bool:
|
|
35
|
+
return token.startswith(client_session_token_prefix)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def is_publishable_key(token: str) -> bool:
|
|
39
|
+
return token.startswith(publishable_key_token_prefix)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def is_console_session_token(token: str) -> bool:
|
|
43
|
+
return is_jwt(token)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def is_personal_access_token(token: str) -> bool:
|
|
47
|
+
return is_access_token(token)
|
|
48
|
+
`
|
|
@@ -47,14 +47,14 @@ export const action_attempt_utils_definitions = [
|
|
|
47
47
|
" time_waiting += polling_interval",
|
|
48
48
|
"",
|
|
49
49
|
" if time_waiting > timeout:",
|
|
50
|
-
" raise
|
|
50
|
+
" raise SeamActionAttemptTimeoutError(action_attempt, timeout)",
|
|
51
51
|
"",
|
|
52
52
|
" action_attempt = seam.action_attempts.get(",
|
|
53
53
|
" action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
54
54
|
" )",
|
|
55
55
|
"",
|
|
56
56
|
" if action_attempt.status == 'failed':",
|
|
57
|
-
" raise
|
|
57
|
+
" raise SeamActionAttemptFailedError(action_attempt)",
|
|
58
58
|
"",
|
|
59
59
|
" return action_attempt",
|
|
60
60
|
"",
|
|
@@ -68,3 +68,11 @@ export const action_attempt_utils_definitions = [
|
|
|
68
68
|
"",
|
|
69
69
|
" return action_attempt",
|
|
70
70
|
].join("\n")
|
|
71
|
+
|
|
72
|
+
export const action_attempt_imports = `import time
|
|
73
|
+
|
|
74
|
+
from seam.utils.action_attempt_errors import (
|
|
75
|
+
SeamActionAttemptFailedError,
|
|
76
|
+
SeamActionAttemptTimeoutError,
|
|
77
|
+
)
|
|
78
|
+
`
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default () => `from seam.types import ActionAttempt
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class SeamActionAttemptError(Exception):
|
|
5
|
+
def __init__(self, message: str, action_attempt: ActionAttempt):
|
|
6
|
+
super().__init__(message)
|
|
7
|
+
self.name = self.__class__.__name__
|
|
8
|
+
self.action_attempt = action_attempt
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class SeamActionAttemptFailedError(SeamActionAttemptError):
|
|
12
|
+
def __init__(self, action_attempt: ActionAttempt):
|
|
13
|
+
super().__init__(action_attempt.error.message, action_attempt)
|
|
14
|
+
self.name = self.__class__.__name__
|
|
15
|
+
self.code = action_attempt.error.type
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class SeamActionAttemptTimeoutError(SeamActionAttemptError):
|
|
19
|
+
def __init__(self, action_attempt: ActionAttempt, timeout: str):
|
|
20
|
+
message = f"Timed out waiting for action attempt after {timeout}s"
|
|
21
|
+
super().__init__(message, action_attempt)
|
|
22
|
+
self.name = self.__class__.__name__
|
|
23
|
+
`
|