@seamapi/nextlove-sdk-generator 1.10.5 → 1.11.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.
Files changed (77) hide show
  1. package/lib/generate-python-sdk/class-file.js +10 -6
  2. package/lib/generate-python-sdk/class-file.js.map +1 -1
  3. package/lib/generate-python-sdk/generate-python-sdk.js +7 -39
  4. package/lib/generate-python-sdk/generate-python-sdk.js.map +1 -1
  5. package/lib/generate-python-sdk/templates/abstract-routes.template.js.map +1 -0
  6. package/lib/generate-python-sdk/templates/resource-dataclass.template.js.map +1 -0
  7. package/lib/generate-python-sdk/templates/utils/action-attempt.d.ts +2 -1
  8. package/lib/generate-python-sdk/templates/utils/action-attempt.js +19 -5
  9. package/lib/generate-python-sdk/templates/utils/action-attempt.js.map +1 -1
  10. package/package.json +1 -1
  11. package/src/lib/generate-python-sdk/class-file.ts +10 -6
  12. package/src/lib/generate-python-sdk/generate-python-sdk.ts +7 -41
  13. package/src/lib/generate-python-sdk/templates/utils/action-attempt.ts +20 -5
  14. package/lib/generate-python-sdk/templates/.gitignore.template.d.ts +0 -2
  15. package/lib/generate-python-sdk/templates/.gitignore.template.js +0 -11
  16. package/lib/generate-python-sdk/templates/.gitignore.template.js.map +0 -1
  17. package/lib/generate-python-sdk/templates/__init__.py.template.d.ts +0 -2
  18. package/lib/generate-python-sdk/templates/__init__.py.template.js +0 -13
  19. package/lib/generate-python-sdk/templates/__init__.py.template.js.map +0 -1
  20. package/lib/generate-python-sdk/templates/auth.py.template.d.ts +0 -2
  21. package/lib/generate-python-sdk/templates/auth.py.template.js +0 -103
  22. package/lib/generate-python-sdk/templates/auth.py.template.js.map +0 -1
  23. package/lib/generate-python-sdk/templates/conftest.py.template.d.ts +0 -2
  24. package/lib/generate-python-sdk/templates/conftest.py.template.js +0 -14
  25. package/lib/generate-python-sdk/templates/conftest.py.template.js.map +0 -1
  26. package/lib/generate-python-sdk/templates/options.py.template.d.ts +0 -2
  27. package/lib/generate-python-sdk/templates/options.py.template.js +0 -68
  28. package/lib/generate-python-sdk/templates/options.py.template.js.map +0 -1
  29. package/lib/generate-python-sdk/templates/parse_options.py.template.d.ts +0 -2
  30. package/lib/generate-python-sdk/templates/parse_options.py.template.js +0 -28
  31. package/lib/generate-python-sdk/templates/parse_options.py.template.js.map +0 -1
  32. package/lib/generate-python-sdk/templates/pyproject.toml.template.d.ts +0 -2
  33. package/lib/generate-python-sdk/templates/pyproject.toml.template.js +0 -22
  34. package/lib/generate-python-sdk/templates/pyproject.toml.template.js.map +0 -1
  35. package/lib/generate-python-sdk/templates/readme.md.template.d.ts +0 -2
  36. package/lib/generate-python-sdk/templates/readme.md.template.js +0 -48
  37. package/lib/generate-python-sdk/templates/readme.md.template.js.map +0 -1
  38. package/lib/generate-python-sdk/templates/seam.py.template.d.ts +0 -2
  39. package/lib/generate-python-sdk/templates/seam.py.template.js +0 -118
  40. package/lib/generate-python-sdk/templates/seam.py.template.js.map +0 -1
  41. package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.js.map +0 -1
  42. package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.d.ts +0 -2
  43. package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +0 -44
  44. package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js.map +0 -1
  45. package/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.js.map +0 -1
  46. package/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.d.ts +0 -2
  47. package/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.js +0 -17
  48. package/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.js.map +0 -1
  49. package/lib/generate-python-sdk/templates/test_smoke.py.template.d.ts +0 -2
  50. package/lib/generate-python-sdk/templates/test_smoke.py.template.js +0 -13
  51. package/lib/generate-python-sdk/templates/test_smoke.py.template.js.map +0 -1
  52. package/lib/generate-python-sdk/templates/token.py.template.d.ts +0 -2
  53. package/lib/generate-python-sdk/templates/token.py.template.js +0 -49
  54. package/lib/generate-python-sdk/templates/token.py.template.js.map +0 -1
  55. package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.d.ts +0 -2
  56. package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.js +0 -24
  57. package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.js.map +0 -1
  58. package/src/lib/generate-python-sdk/templates/.gitignore.template.ts +0 -10
  59. package/src/lib/generate-python-sdk/templates/__init__.py.template.ts +0 -12
  60. package/src/lib/generate-python-sdk/templates/auth.py.template.ts +0 -102
  61. package/src/lib/generate-python-sdk/templates/conftest.py.template.ts +0 -13
  62. package/src/lib/generate-python-sdk/templates/options.py.template.ts +0 -67
  63. package/src/lib/generate-python-sdk/templates/parse_options.py.template.ts +0 -27
  64. package/src/lib/generate-python-sdk/templates/pyproject.toml.template.ts +0 -21
  65. package/src/lib/generate-python-sdk/templates/readme.md.template.ts +0 -47
  66. package/src/lib/generate-python-sdk/templates/seam.py.template.ts +0 -117
  67. package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +0 -43
  68. package/src/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.ts +0 -16
  69. package/src/lib/generate-python-sdk/templates/test_smoke.py.template.ts +0 -12
  70. package/src/lib/generate-python-sdk/templates/token.py.template.ts +0 -48
  71. package/src/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.ts +0 -23
  72. /package/lib/generate-python-sdk/templates/{snippets/abstract-routes.template.d.ts → abstract-routes.template.d.ts} +0 -0
  73. /package/lib/generate-python-sdk/templates/{snippets/abstract-routes.template.js → abstract-routes.template.js} +0 -0
  74. /package/lib/generate-python-sdk/templates/{snippets/resource-dataclass.template.d.ts → resource-dataclass.template.d.ts} +0 -0
  75. /package/lib/generate-python-sdk/templates/{snippets/resource-dataclass.template.js → resource-dataclass.template.js} +0 -0
  76. /package/src/lib/generate-python-sdk/templates/{snippets/abstract-routes.template.ts → abstract-routes.template.ts} +0 -0
  77. /package/src/lib/generate-python-sdk/templates/{snippets/resource-dataclass.template.ts → resource-dataclass.template.ts} +0 -0
@@ -1,68 +0,0 @@
1
- export default () => `import os
2
- from typing import Optional
3
-
4
-
5
- def get_endpoint_from_env():
6
- seam_api_url = os.getenv("SEAM_API_URL")
7
- seam_endpoint = os.getenv("SEAM_ENDPOINT")
8
-
9
- if seam_api_url is not None:
10
- print(
11
- "\\033[93m"
12
- "Using the SEAM_API_URL environment variable is deprecated. "
13
- "Support will be removed in a later major version. Use SEAM_ENDPOINT instead."
14
- "\\033[0m"
15
- )
16
-
17
- if seam_api_url is not None and seam_endpoint is not None:
18
- print(
19
- "\\033[93m"
20
- "Detected both the SEAM_API_URL and SEAM_ENDPOINT environment variables. "
21
- "Using SEAM_ENDPOINT."
22
- "\\033[0m"
23
- )
24
-
25
- return seam_endpoint or seam_api_url
26
-
27
-
28
- class SeamHttpInvalidOptionsError(Exception):
29
- def __init__(self, message):
30
- super().__init__(f"SeamHttp received invalid options: {message}")
31
-
32
-
33
- def is_seam_http_options_with_api_key(
34
- api_key: Optional[str] = None,
35
- personal_access_token: Optional[str] = None,
36
- ) -> bool:
37
- if api_key is None:
38
- return False
39
-
40
- if personal_access_token is not None:
41
- raise SeamHttpInvalidOptionsError(
42
- "The personal_access_token option cannot be used with the api_key option"
43
- )
44
-
45
- return True
46
-
47
-
48
- def is_seam_http_options_with_personal_access_token(
49
- personal_access_token: Optional[str] = None,
50
- api_key: Optional[str] = None,
51
- workspace_id: Optional[str] = None,
52
- ) -> bool:
53
- if personal_access_token is None:
54
- return False
55
-
56
- if api_key is not None:
57
- raise SeamHttpInvalidOptionsError(
58
- "The api_key option cannot be used with the personal_access_token option"
59
- )
60
-
61
- if workspace_id is None:
62
- raise SeamHttpInvalidOptionsError(
63
- "Must pass a workspace_id when using a personal_access_token"
64
- )
65
-
66
- return True
67
- `;
68
- //# sourceMappingURL=options.py.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"options.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/options.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkEpB,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,28 +0,0 @@
1
- export default () => `import os
2
- from typing import Optional
3
-
4
- from seam.auth import get_auth_headers
5
- from seam.options import get_endpoint_from_env
6
-
7
- DEFAULT_ENDPOINT = "https://connect.getseam.com"
8
-
9
-
10
- def parse_options(
11
- api_key: Optional[str] = None,
12
- personal_access_token: Optional[str] = None,
13
- workspace_id: Optional[str] = None,
14
- endpoint: Optional[str] = None,
15
- ):
16
- if personal_access_token is None:
17
- api_key = api_key or os.getenv("SEAM_API_KEY")
18
-
19
- auth_headers = get_auth_headers(
20
- api_key=api_key,
21
- personal_access_token=personal_access_token,
22
- workspace_id=workspace_id,
23
- )
24
- endpoint = endpoint or get_endpoint_from_env() or DEFAULT_ENDPOINT
25
-
26
- return auth_headers, endpoint
27
- `;
28
- //# sourceMappingURL=parse_options.py.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"parse_options.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/parse_options.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;CA0BpB,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,22 +0,0 @@
1
- export default () => `[tool.poetry]
2
- name = "seam"
3
- version = "2.19.0"
4
- description = "A Python Library for Seam's API https://getseam.com"
5
- authors = ["Severin Ibarluzea <seveibar@gmail.com>"]
6
- license = "MIT"
7
-
8
- [tool.poetry.dependencies]
9
- python = "^3.8"
10
- requests = "^2.26.0"
11
- dataclasses-json = "^0.6.4"
12
-
13
- [tool.poetry.dev-dependencies]
14
- pytest = "^8.1.1"
15
- python-dotenv = "^1.0.1"
16
- black = "^24.3.0"
17
-
18
- [build-system]
19
- requires = ["poetry-core>=1.0.0"]
20
- build-backend = "poetry.core.masonry.api"
21
- `;
22
- //# sourceMappingURL=pyproject.toml.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"pyproject.toml.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/pyproject.toml.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;CAoBpB,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,48 +0,0 @@
1
- export default () => `# Seam for Python
2
-
3
- Control locks, lights and other internet of things devices with Seam's simple API. Check out the [documentation](https://docs.getseam.com) or [some examples](examples)
4
-
5
- ## Setup
6
-
7
- \`\`\`bash
8
- pip install seam
9
- \`\`\`
10
-
11
- ## Usage
12
-
13
- \`\`\`python
14
- from seam import Seam
15
-
16
- # export SEAM_API_KEY=***
17
- seam = Seam()
18
-
19
- some_lock = seam.locks.get(
20
- name="Front Door"
21
- )
22
-
23
- seam.locks.lock_door(device_id=some_lock.device_id)
24
- \`\`\`
25
-
26
- ## Development
27
-
28
- This project uses [poetry](https://github.com/python-poetry/poetry)
29
-
30
- - To setup the project and install dependencies run \`poetry install\`
31
- - To run tests, run \`poetry run pytest -s\`
32
- - To build the project for publishing, run \`poetry build\`
33
-
34
- Commits to \`main\` following [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) will automatically be published to PyPI.
35
-
36
- Our tests use a seam sandbox environment given by the environment
37
- variables \`SEAM_SANDBOX_API_KEY\`. If you want to run the tests, you should
38
- first create a sandbox workspace [on your Developer Console](https://console.getseam.com)
39
- then create a sandbox workspace.
40
-
41
- > NOTE: For installation on m1 mac, you may need to export the following lines
42
- > prior to \`poetry install\`...
43
- >
44
- > \`export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include"\`
45
- >
46
- > \`export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib -L\${HOME}/.pyenv/versions/3.8.10/lib"\`
47
- `;
48
- //# sourceMappingURL=readme.md.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"readme.md.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/readme.md.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8CpB,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,118 +0,0 @@
1
- export default () => `import requests
2
- from importlib.metadata import version
3
- from typing import Optional, Union, Dict
4
- from typing_extensions import Self
5
-
6
- from seam.parse_options import parse_options
7
- from .routes import Routes
8
- from .types import AbstractSeam, SeamApiException
9
-
10
-
11
- class Seam(AbstractSeam):
12
- """
13
- Initial Seam class used to interact with Seam API
14
- """
15
-
16
- lts_version: str = '1.0.0'
17
-
18
- def __init__(
19
- self,
20
- api_key: Optional[str] = None,
21
- *,
22
- personal_access_token: Optional[str] = None,
23
- workspace_id: Optional[str] = None,
24
- endpoint: Optional[str] = None,
25
- wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = False,
26
- ):
27
- """
28
- Parameters
29
- ----------
30
- api_key : str, optional
31
- API key.
32
- personal_access_token : str, optional
33
- Personal access token.
34
- workspace_id : str, optional
35
- Workspace id.
36
- endpoint : str, optional
37
- The API endpoint to which the request should be sent.
38
- wait_for_action_attempt : bool or dict, optional
39
- Controls whether to wait for an action attempt to complete, either as a boolean or as a dictionary specifying \`timeout\` and \`poll_interval\`. Defaults to \`False\`.
40
- """
41
-
42
- Routes.__init__(self)
43
-
44
- self.lts_version = Seam.lts_version
45
- self.wait_for_action_attempt = wait_for_action_attempt
46
- auth_headers, endpoint = parse_options(
47
- api_key=api_key,
48
- personal_access_token=personal_access_token,
49
- workspace_id=workspace_id,
50
- endpoint=endpoint,
51
- )
52
- self.__auth_headers = auth_headers
53
- self.__endpoint = endpoint
54
-
55
- def make_request(self, method: str, path: str, **kwargs):
56
- """
57
- Makes a request to the API
58
-
59
- Parameters
60
- ----------
61
- method : str
62
- Request method
63
- path : str
64
- Request path
65
- **kwargs
66
- Keyword arguments passed to requests.request
67
- """
68
-
69
- url = self.__endpoint + path
70
- sdk_version = version("seam")
71
- headers = {
72
- **self.__auth_headers,
73
- "Content-Type": "application/json",
74
- "User-Agent": "Python SDK v" + sdk_version + " (https://github.com/seamapi/python-next)",
75
- "seam-sdk-name": "seamapi/python",
76
- "seam-sdk-version": sdk_version,
77
- "seam-lts-version": self.lts_version,
78
- }
79
-
80
- response = requests.request(method, url, headers=headers, **kwargs)
81
-
82
- if response.status_code != 200:
83
- raise SeamApiException(response)
84
-
85
- if "application/json" in response.headers["content-type"]:
86
- return response.json()
87
-
88
- return response.text
89
-
90
- @classmethod
91
- def from_api_key(
92
- cls,
93
- api_key: str,
94
- *,
95
- endpoint: Optional[str] = None,
96
- wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = False,
97
- ) -> Self:
98
- return cls(
99
- api_key, endpoint=endpoint, wait_for_action_attempt=wait_for_action_attempt
100
- )
101
-
102
- @classmethod
103
- def from_personal_access_token(
104
- cls,
105
- personal_access_token: str,
106
- workspace_id: str,
107
- *,
108
- endpoint: Optional[str] = None,
109
- wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = False,
110
- ) -> Self:
111
- return cls(
112
- personal_access_token=personal_access_token,
113
- workspace_id=workspace_id,
114
- endpoint=endpoint,
115
- wait_for_action_attempt=wait_for_action_attempt,
116
- )
117
- `;
118
- //# sourceMappingURL=seam.py.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seam.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/seam.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoHpB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"abstract-routes.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-python-sdk/templates/snippets/abstract-routes.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,eAAe,CAAC,UAAoB,EAAE,EAAE,CAAC;;EAEvC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,aAAa,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CACxE,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,44 +0,0 @@
1
- export default () => `class AbstractSeam(AbstractRoutes):
2
- lts_version: str
3
-
4
- @abc.abstractmethod
5
- def __init__(
6
- self,
7
- api_key: Optional[str] = None,
8
- *,
9
- personal_access_token: Optional[str] = None,
10
- workspace_id: Optional[str] = None,
11
- endpoint: Optional[str] = None,
12
- wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = False,
13
- ):
14
- self.wait_for_action_attempt = wait_for_action_attempt
15
- self.lts_version = AbstractSeam.lts_version
16
-
17
- @abc.abstractmethod
18
- def make_request(self, method: str, path: str, **kwargs) -> Any:
19
- raise NotImplementedError
20
-
21
- @classmethod
22
- @abc.abstractmethod
23
- def from_api_key(
24
- cls,
25
- api_key: str,
26
- *,
27
- endpoint: Optional[str] = None,
28
- wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = False,
29
- ) -> Self:
30
- raise NotImplementedError
31
-
32
- @classmethod
33
- @abc.abstractmethod
34
- def from_personal_access_token(
35
- cls,
36
- personal_access_token: str,
37
- workspace_id: str,
38
- *,
39
- endpoint: Optional[str] = None,
40
- wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = False,
41
- ) -> Self:
42
- raise NotImplementedError
43
- `;
44
- //# sourceMappingURL=abstract-seam.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"abstract-seam.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CpB,CAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"resource-dataclass.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.ts"],"names":[],"mappings":"AAAA,eAAe,CACb,IAAY,EACZ,UAGE,EACF,EAAE,CAAC;QACG,IAAI;EACV,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;aAI/C,IAAI;EACf,UAAU;KACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;IACT,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAA;IAE1E,OAAO,SAAS,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,UAC5D,CAAC,CAAC,IACJ,WAAW,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAA;AACxC,CAAC,CAAC;KACD,IAAI,CAAC,IAAI,CAAC;QACL,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,17 +0,0 @@
1
- export default () => `class SeamApiException(Exception):
2
- def __init__(
3
- self,
4
- response,
5
- ):
6
- self.status_code = response.status_code
7
- self.request_id = response.headers.get("seam-request-id", None)
8
-
9
- self.metadata = None
10
- if "application/json" in response.headers["content-type"]:
11
- parsed_response = response.json()
12
- self.metadata = parsed_response.get("error", None)
13
-
14
- super().__init__(
15
- f"SeamApiException: status={self.status_code}, request_id={self.request_id}, metadata={self.metadata}"
16
- )`;
17
- //# sourceMappingURL=seam-api-exception-class.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"seam-api-exception-class.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;QAeb,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,13 +0,0 @@
1
- export default () => `from seam import Seam
2
-
3
-
4
- def test_get_devices(seam: Seam):
5
- devices_response = seam.devices.list()
6
- assert devices_response[0].device_id
7
-
8
-
9
- def test_create_access_code(seam: Seam):
10
- access_code = seam.access_codes.create(device_id="august_device_1", code="1234")
11
- assert access_code.status == "setting"
12
- assert access_code.code == "1234"`;
13
- //# sourceMappingURL=test_smoke.py.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"test_smoke.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/test_smoke.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;sCAWiB,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,49 +0,0 @@
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
- `;
49
- //# sourceMappingURL=token.py.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"token.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/token.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA+CpB,CAAA"}
@@ -1,2 +0,0 @@
1
- declare const _default: () => string;
2
- export default _default;
@@ -1,24 +0,0 @@
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
- `;
24
- //# sourceMappingURL=action_attempt_errors.py.template.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"action_attempt_errors.py.template.js","sourceRoot":"","sources":["../../../../src/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAA"}
@@ -1,10 +0,0 @@
1
- export default () => `dist
2
- .env
3
- __pycache__
4
- */__pycache__
5
- node_modules
6
-
7
- .deeper
8
- .yalc
9
- yalc.lock
10
- `
@@ -1,12 +0,0 @@
1
- export default () => `# flake8: noqa
2
- # type: ignore
3
-
4
- from seam.seam import Seam, SeamApiException
5
- from seam.options import SeamHttpInvalidOptionsError
6
- from seam.auth import SeamHttpInvalidTokenError
7
- from seam.utils.action_attempt_errors import (
8
- SeamActionAttemptError,
9
- SeamActionAttemptFailedError,
10
- SeamActionAttemptTimeoutError,
11
- )
12
- `
@@ -1,102 +0,0 @@
1
- export default () => `from typing import Optional
2
- from seam.options import (
3
- SeamHttpInvalidOptionsError,
4
- is_seam_http_options_with_api_key,
5
- is_seam_http_options_with_personal_access_token,
6
- )
7
- from seam.token import (
8
- is_jwt,
9
- is_access_token,
10
- is_client_session_token,
11
- is_publishable_key,
12
- is_seam_token,
13
- TOKEN_PREFIX,
14
- ACCESS_TOKEN_PREFIX,
15
- )
16
-
17
-
18
- class SeamHttpInvalidTokenError(Exception):
19
- def __init__(self, message):
20
- super().__init__(f"SeamHttp received an invalid token: {message}")
21
-
22
-
23
- def get_auth_headers(
24
- api_key: Optional[str] = None,
25
- personal_access_token: Optional[str] = None,
26
- workspace_id: Optional[str] = None,
27
- ):
28
- if is_seam_http_options_with_api_key(
29
- api_key=api_key,
30
- personal_access_token=personal_access_token,
31
- ):
32
- return get_auth_headers_for_api_key(api_key)
33
-
34
- if is_seam_http_options_with_personal_access_token(
35
- personal_access_token=personal_access_token,
36
- api_key=api_key,
37
- workspace_id=workspace_id,
38
- ):
39
- return get_auth_headers_for_personal_access_token(
40
- personal_access_token, workspace_id
41
- )
42
-
43
- raise SeamHttpInvalidOptionsError(
44
- "Must specify an api_key or personal_access_token. "
45
- "Attempted reading configuration from the environment, "
46
- "but the environment variable SEAM_API_KEY is not set."
47
- )
48
-
49
-
50
- def get_auth_headers_for_api_key(api_key: str) -> dict:
51
- if is_client_session_token(api_key):
52
- raise SeamHttpInvalidTokenError(
53
- "A Client Session Token cannot be used as an api_key"
54
- )
55
-
56
- if is_jwt(api_key):
57
- raise SeamHttpInvalidTokenError("A JWT cannot be used as an api_key")
58
-
59
- if is_access_token(api_key):
60
- raise SeamHttpInvalidTokenError("An Access Token cannot be used as an api_key")
61
-
62
- if is_publishable_key(api_key):
63
- raise SeamHttpInvalidTokenError(
64
- "A Publishable Key cannot be used as an api_key"
65
- )
66
-
67
- if not is_seam_token(api_key):
68
- raise SeamHttpInvalidTokenError(
69
- f"Unknown or invalid api_key format, expected token to start with {TOKEN_PREFIX}"
70
- )
71
-
72
- return {"authorization": f"Bearer {api_key}"}
73
-
74
-
75
- def get_auth_headers_for_personal_access_token(
76
- personal_access_token: str, workspace_id: str
77
- ) -> dict:
78
- if is_jwt(personal_access_token):
79
- raise SeamHttpInvalidTokenError(
80
- "A JWT cannot be used as a personal_access_token"
81
- )
82
-
83
- if is_client_session_token(personal_access_token):
84
- raise SeamHttpInvalidTokenError(
85
- "A Client Session Token cannot be used as a personal_access_token"
86
- )
87
-
88
- if is_publishable_key(personal_access_token):
89
- raise SeamHttpInvalidTokenError(
90
- "A Publishable Key cannot be used as a personal_access_token"
91
- )
92
-
93
- if not is_access_token(personal_access_token):
94
- raise SeamHttpInvalidTokenError(
95
- f"Unknown or invalid personal_access_token format, expected token to start with {ACCESS_TOKEN_PREFIX}"
96
- )
97
-
98
- return {
99
- "authorization": f"Bearer {personal_access_token}",
100
- "seam-workspace": workspace_id,
101
- }
102
- `
@@ -1,13 +0,0 @@
1
- export default () => `import pytest
2
- from seam import Seam
3
- import random
4
- import string
5
-
6
- @pytest.fixture(scope="function")
7
- def seam():
8
- r = "".join(random.choices(string.ascii_uppercase + string.digits, k=10))
9
- seam = Seam(
10
- endpoint=f"https://{r}.fakeseamconnect.seam.vc", api_key="seam_apikey1_token"
11
- )
12
- yield seam
13
- `