@seamapi/nextlove-sdk-generator 1.6.1 → 1.6.2
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 +25 -21
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/templates/readme.md.template.js +1 -1
- package/lib/generate-python-sdk/templates/seam.py.template.js +8 -2
- package/lib/generate-python-sdk/templates/seam.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +1 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/generate-python-sdk/class-file.ts +14 -11
- package/src/lib/generate-python-sdk/templates/readme.md.template.ts +1 -1
- package/src/lib/generate-python-sdk/templates/seam.py.template.ts +8 -2
- package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +1 -0
|
@@ -43,21 +43,24 @@ export class ClassFile {
|
|
|
43
43
|
},
|
|
44
44
|
]
|
|
45
45
|
: [])
|
|
46
|
-
.map(({ method_name, parameters }) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
.
|
|
52
|
-
(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
46
|
+
.map(({ method_name, parameters, return_resource }) => {
|
|
47
|
+
const has_params = parameters.length > 0;
|
|
48
|
+
return [
|
|
49
|
+
"",
|
|
50
|
+
"",
|
|
51
|
+
`@abc.abstractmethod`,
|
|
52
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
53
|
+
.sort((a, b) => (a.position ?? a.required ? 1000 : 9999) -
|
|
54
|
+
(b.position ?? b.required ? 1000 : 9999))
|
|
55
|
+
.map(({ name, type, required, default_value }) => required
|
|
56
|
+
? `${name}: ${type}`
|
|
57
|
+
: `${name}: Optional[${type}] = ${default_value ?? "None"}`)
|
|
58
|
+
.join(", ")}) -> ${return_resource}:`,
|
|
59
|
+
` raise NotImplementedError()`,
|
|
60
|
+
]
|
|
61
|
+
.map((s) => ` ${s}`)
|
|
62
|
+
.join("\n");
|
|
63
|
+
}),
|
|
61
64
|
].join("\n");
|
|
62
65
|
}
|
|
63
66
|
serializeToClass() {
|
|
@@ -107,10 +110,11 @@ export class ClassFile {
|
|
|
107
110
|
}
|
|
108
111
|
const can_method_poll_action_attempt = return_resource === "ActionAttempt" && !is_return_resource_list;
|
|
109
112
|
const is_none_return_type = return_resource_item === "None";
|
|
113
|
+
const has_params = parameters.length > 0;
|
|
110
114
|
return [
|
|
111
115
|
"",
|
|
112
116
|
"",
|
|
113
|
-
`def ${method_name}(self
|
|
117
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
114
118
|
.sort((a, b) => (a.position ?? a.required ? 1000 : 9999) -
|
|
115
119
|
(b.position ?? b.required ? 1000 : 9999))
|
|
116
120
|
.map(({ name, type, required }) => required
|
|
@@ -136,13 +140,13 @@ export class ClassFile {
|
|
|
136
140
|
? [
|
|
137
141
|
" if isinstance(wait_for_action_attempt, dict):",
|
|
138
142
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
139
|
-
" res['action_attempt']['action_attempt_id'],",
|
|
143
|
+
" action_attempt_id=res['action_attempt']['action_attempt_id'],",
|
|
140
144
|
" timeout=wait_for_action_attempt.get('timeout', None),",
|
|
141
145
|
" polling_interval=wait_for_action_attempt.get('polling_interval', None),",
|
|
142
146
|
" )",
|
|
143
147
|
" elif wait_for_action_attempt is True:",
|
|
144
148
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
145
|
-
" res['action_attempt']['action_attempt_id']",
|
|
149
|
+
" action_attempt_id=res['action_attempt']['action_attempt_id']",
|
|
146
150
|
" )",
|
|
147
151
|
" else:",
|
|
148
152
|
` return ${return_resource}.from_dict(res["${return_path.join('"]["')}"])`,
|
|
@@ -165,11 +169,11 @@ export class ClassFile {
|
|
|
165
169
|
this.name === "ActionAttempts"
|
|
166
170
|
? [
|
|
167
171
|
"",
|
|
168
|
-
" def poll_until_ready(self, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
|
|
172
|
+
" def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
|
|
169
173
|
" seam = self.seam",
|
|
170
174
|
" time_waiting = 0.0",
|
|
171
175
|
"",
|
|
172
|
-
" action_attempt = seam.action_attempts.get(action_attempt_id, wait_for_action_attempt=False)",
|
|
176
|
+
" action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
|
|
173
177
|
"",
|
|
174
178
|
" while action_attempt.status == 'pending':",
|
|
175
179
|
" time.sleep(polling_interval)",
|
|
@@ -179,7 +183,7 @@ export class ClassFile {
|
|
|
179
183
|
" raise Exception('Timed out waiting for action attempt to be ready')",
|
|
180
184
|
"",
|
|
181
185
|
" action_attempt = seam.action_attempts.get(",
|
|
182
|
-
" action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
186
|
+
" action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
183
187
|
" )",
|
|
184
188
|
"",
|
|
185
189
|
" if action_attempt.status == 'failed':",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-file.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/class-file.ts"],"names":[],"mappings":"AA6BA,MAAM,OAAO,SAAS;IAMpB,YACE,IAAY,EACZ,SAA6B,EAC7B,uBAA+C;QAE/C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,OAAO,GAAG,EAAE,CAAA;QACjB,IAAI,CAAC,uBAAuB,GAAG,uBAAuB,CAAA;I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AmB,WAAW,CAAC,IAAI,CAClE,MAAM,CACP,KAAK;4BACN,EAAE;4BACF,mCAAmC;yBACpC,CAAC,IAAI,CAAC,IAAI,CAAC;wBACd,CAAC,CAAC,EAAE;oBACN,EAAE;oBAEF,CAAC,8BAA8B;wBAC7B,CAAC,CAAC,mBAAmB;4BACnB,CAAC,CAAC,eAAe;4BACjB,CAAC,CAAC,uBAAuB;gCACzB,CAAC,CAAC,aAAa,oBAAoB,qCAAqC,WAAW,CAAC,IAAI,CACpF,MAAM,CACP,KAAK;gCACR,CAAC,CAAC,YAAY,eAAe,mBAAmB,WAAW,CAAC,IAAI,CAC5D,MAAM,CACP,KAAK;wBACV,CAAC,CAAC,EAAE;iBACP;qBACE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;qBACpB,IAAI,CAAC,IAAI,CAAC,CAAA;YACf,CAAC,CACF;YACD,IAAI,CAAC,IAAI,KAAK,gBAAgB;gBAC5B,CAAC,CAAC;oBACE,EAAE;oBACF,oJAAoJ;oBACpJ,sBAAsB;oBACtB,wBAAwB;oBACxB,EAAE;oBACF,mHAAmH;oBACnH,EAAE;oBACF,+CAA+C;oBAC/C,oCAAoC;oBACpC,wCAAwC;oBACxC,EAAE;oBACF,kCAAkC;oBAClC,6EAA6E;oBAC7E,EAAE;oBACF,kDAAkD;oBAClD,2FAA2F;oBAC3F,SAAS;oBACT,EAAE;oBACF,2CAA2C;oBAC3C,iFAAiF;oBACjF,EAAE;oBACF,2BAA2B;iBAC5B,CAAC,IAAI,CAAC,IAAI,CAAC;gBACd,CAAC,CAAC,EAAE;SACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;CACF"}
|
|
@@ -19,8 +19,10 @@ class Seam(AbstractSeam):
|
|
|
19
19
|
----------
|
|
20
20
|
api_key : str
|
|
21
21
|
API key (default None)
|
|
22
|
-
api_url : str
|
|
23
|
-
API url (default
|
|
22
|
+
api_url : str
|
|
23
|
+
API url (default "https://connect.getseam.com")
|
|
24
|
+
lts_version : str
|
|
25
|
+
LTS version
|
|
24
26
|
workspaces : Workspaces
|
|
25
27
|
Workspaces class
|
|
26
28
|
connected_accounts : ConnectedAccounts
|
|
@@ -41,10 +43,12 @@ class Seam(AbstractSeam):
|
|
|
41
43
|
|
|
42
44
|
api_key: str
|
|
43
45
|
api_url: str = "https://connect.getseam.com"
|
|
46
|
+
lts_version: str = '1.0.0'
|
|
44
47
|
|
|
45
48
|
def __init__(
|
|
46
49
|
self,
|
|
47
50
|
api_key: Optional[str] = None,
|
|
51
|
+
*,
|
|
48
52
|
workspace_id: Optional[str] = None,
|
|
49
53
|
api_url: Optional[str] = None,
|
|
50
54
|
should_report_exceptions: Optional[bool] = False,
|
|
@@ -73,6 +77,7 @@ class Seam(AbstractSeam):
|
|
|
73
77
|
workspace_id = os.environ.get("SEAM_WORKSPACE_ID", None)
|
|
74
78
|
self.api_key = api_key
|
|
75
79
|
self.workspace_id = workspace_id
|
|
80
|
+
self.lts_version = Seam.lts_version
|
|
76
81
|
|
|
77
82
|
if os.environ.get("SEAM_API_URL", None) is not None:
|
|
78
83
|
print(
|
|
@@ -120,6 +125,7 @@ class Seam(AbstractSeam):
|
|
|
120
125
|
"User-Agent": "Python SDK v" + sdk_version + " (https://github.com/seamapi/python)",
|
|
121
126
|
"seam-sdk-name": "seamapi/python",
|
|
122
127
|
"seam-sdk-version": sdk_version,
|
|
128
|
+
"seam-lts-version": self.lts_version,
|
|
123
129
|
}
|
|
124
130
|
if self.workspace_id is not None:
|
|
125
131
|
headers["seam-workspace"] = self.workspace_id
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0JpB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
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
|
|
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;;;;;;;;;;;;;;;kCAea,CAAA"}
|
package/package.json
CHANGED
|
@@ -90,12 +90,14 @@ export class ClassFile {
|
|
|
90
90
|
]
|
|
91
91
|
: []
|
|
92
92
|
)
|
|
93
|
-
.map(({ method_name, parameters }) =>
|
|
94
|
-
|
|
93
|
+
.map(({ method_name, parameters, return_resource }) => {
|
|
94
|
+
const has_params = parameters.length > 0
|
|
95
|
+
|
|
96
|
+
return [
|
|
95
97
|
"",
|
|
96
98
|
"",
|
|
97
99
|
`@abc.abstractmethod`,
|
|
98
|
-
`def ${method_name}(self
|
|
100
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
99
101
|
.sort(
|
|
100
102
|
(a, b) =>
|
|
101
103
|
(a.position ?? a.required ? 1000 : 9999) -
|
|
@@ -106,12 +108,12 @@ export class ClassFile {
|
|
|
106
108
|
? `${name}: ${type}`
|
|
107
109
|
: `${name}: Optional[${type}] = ${default_value ?? "None"}`
|
|
108
110
|
)
|
|
109
|
-
.join(", ")}):`,
|
|
111
|
+
.join(", ")}) -> ${return_resource}:`,
|
|
110
112
|
` raise NotImplementedError()`,
|
|
111
113
|
]
|
|
112
114
|
.map((s) => ` ${s}`)
|
|
113
115
|
.join("\n")
|
|
114
|
-
),
|
|
116
|
+
}),
|
|
115
117
|
].join("\n")
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -188,11 +190,12 @@ export class ClassFile {
|
|
|
188
190
|
const can_method_poll_action_attempt =
|
|
189
191
|
return_resource === "ActionAttempt" && !is_return_resource_list
|
|
190
192
|
const is_none_return_type = return_resource_item === "None"
|
|
193
|
+
const has_params = parameters.length > 0
|
|
191
194
|
|
|
192
195
|
return [
|
|
193
196
|
"",
|
|
194
197
|
"",
|
|
195
|
-
`def ${method_name}(self
|
|
198
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
196
199
|
.sort(
|
|
197
200
|
(a, b) =>
|
|
198
201
|
(a.position ?? a.required ? 1000 : 9999) -
|
|
@@ -232,13 +235,13 @@ export class ClassFile {
|
|
|
232
235
|
? [
|
|
233
236
|
" if isinstance(wait_for_action_attempt, dict):",
|
|
234
237
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
235
|
-
" res['action_attempt']['action_attempt_id'],",
|
|
238
|
+
" action_attempt_id=res['action_attempt']['action_attempt_id'],",
|
|
236
239
|
" timeout=wait_for_action_attempt.get('timeout', None),",
|
|
237
240
|
" polling_interval=wait_for_action_attempt.get('polling_interval', None),",
|
|
238
241
|
" )",
|
|
239
242
|
" elif wait_for_action_attempt is True:",
|
|
240
243
|
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
241
|
-
" res['action_attempt']['action_attempt_id']",
|
|
244
|
+
" action_attempt_id=res['action_attempt']['action_attempt_id']",
|
|
242
245
|
" )",
|
|
243
246
|
" else:",
|
|
244
247
|
` return ${return_resource}.from_dict(res["${return_path.join(
|
|
@@ -269,11 +272,11 @@ export class ClassFile {
|
|
|
269
272
|
this.name === "ActionAttempts"
|
|
270
273
|
? [
|
|
271
274
|
"",
|
|
272
|
-
" def poll_until_ready(self, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
|
|
275
|
+
" def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
|
|
273
276
|
" seam = self.seam",
|
|
274
277
|
" time_waiting = 0.0",
|
|
275
278
|
"",
|
|
276
|
-
" action_attempt = seam.action_attempts.get(action_attempt_id, wait_for_action_attempt=False)",
|
|
279
|
+
" action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
|
|
277
280
|
"",
|
|
278
281
|
" while action_attempt.status == 'pending':",
|
|
279
282
|
" time.sleep(polling_interval)",
|
|
@@ -283,7 +286,7 @@ export class ClassFile {
|
|
|
283
286
|
" raise Exception('Timed out waiting for action attempt to be ready')",
|
|
284
287
|
"",
|
|
285
288
|
" action_attempt = seam.action_attempts.get(",
|
|
286
|
-
" action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
289
|
+
" action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
|
|
287
290
|
" )",
|
|
288
291
|
"",
|
|
289
292
|
" if action_attempt.status == 'failed':",
|
|
@@ -19,8 +19,10 @@ class Seam(AbstractSeam):
|
|
|
19
19
|
----------
|
|
20
20
|
api_key : str
|
|
21
21
|
API key (default None)
|
|
22
|
-
api_url : str
|
|
23
|
-
API url (default
|
|
22
|
+
api_url : str
|
|
23
|
+
API url (default "https://connect.getseam.com")
|
|
24
|
+
lts_version : str
|
|
25
|
+
LTS version
|
|
24
26
|
workspaces : Workspaces
|
|
25
27
|
Workspaces class
|
|
26
28
|
connected_accounts : ConnectedAccounts
|
|
@@ -41,10 +43,12 @@ class Seam(AbstractSeam):
|
|
|
41
43
|
|
|
42
44
|
api_key: str
|
|
43
45
|
api_url: str = "https://connect.getseam.com"
|
|
46
|
+
lts_version: str = '1.0.0'
|
|
44
47
|
|
|
45
48
|
def __init__(
|
|
46
49
|
self,
|
|
47
50
|
api_key: Optional[str] = None,
|
|
51
|
+
*,
|
|
48
52
|
workspace_id: Optional[str] = None,
|
|
49
53
|
api_url: Optional[str] = None,
|
|
50
54
|
should_report_exceptions: Optional[bool] = False,
|
|
@@ -73,6 +77,7 @@ class Seam(AbstractSeam):
|
|
|
73
77
|
workspace_id = os.environ.get("SEAM_WORKSPACE_ID", None)
|
|
74
78
|
self.api_key = api_key
|
|
75
79
|
self.workspace_id = workspace_id
|
|
80
|
+
self.lts_version = Seam.lts_version
|
|
76
81
|
|
|
77
82
|
if os.environ.get("SEAM_API_URL", None) is not None:
|
|
78
83
|
print(
|
|
@@ -120,6 +125,7 @@ class Seam(AbstractSeam):
|
|
|
120
125
|
"User-Agent": "Python SDK v" + sdk_version + " (https://github.com/seamapi/python)",
|
|
121
126
|
"seam-sdk-name": "seamapi/python",
|
|
122
127
|
"seam-sdk-version": sdk_version,
|
|
128
|
+
"seam-lts-version": self.lts_version,
|
|
123
129
|
}
|
|
124
130
|
if self.workspace_id is not None:
|
|
125
131
|
headers["seam-workspace"] = self.workspace_id
|