@seamapi/nextlove-sdk-generator 1.7.6 → 1.7.8
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 +41 -16
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/templates/seam.py.template.js +2 -0
- package/lib/generate-python-sdk/templates/seam.py.template.js.map +1 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +3 -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 +44 -18
- package/src/lib/generate-python-sdk/templates/seam.py.template.ts +2 -0
- package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +3 -0
|
@@ -41,10 +41,30 @@ export class ClassFile {
|
|
|
41
41
|
return_resource: "ActionAttempt",
|
|
42
42
|
path: "",
|
|
43
43
|
},
|
|
44
|
+
{
|
|
45
|
+
method_name: "decide_and_wait",
|
|
46
|
+
parameters: [
|
|
47
|
+
{
|
|
48
|
+
name: "action_attempt",
|
|
49
|
+
type: "ActionAttempt",
|
|
50
|
+
required: true,
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "wait_for_action_attempt",
|
|
54
|
+
type: "Union[bool, Dict[str, float]]",
|
|
55
|
+
required: true,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
return_path: [],
|
|
59
|
+
return_resource: "ActionAttempt",
|
|
60
|
+
path: "",
|
|
61
|
+
},
|
|
44
62
|
]
|
|
45
63
|
: [])
|
|
46
64
|
.map(({ method_name, parameters, return_resource }) => {
|
|
47
65
|
const has_params = parameters.length > 0;
|
|
66
|
+
const can_method_poll_action_attempt = return_resource === "ActionAttempt" &&
|
|
67
|
+
method_name !== "poll_until_ready";
|
|
48
68
|
return [
|
|
49
69
|
"",
|
|
50
70
|
"",
|
|
@@ -55,6 +75,11 @@ export class ClassFile {
|
|
|
55
75
|
.map(({ name, type, required, default_value }) => required
|
|
56
76
|
? `${name}: ${type}`
|
|
57
77
|
: `${name}: Optional[${type}] = ${default_value ?? "None"}`)
|
|
78
|
+
.concat(can_method_poll_action_attempt
|
|
79
|
+
? [
|
|
80
|
+
"wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
|
|
81
|
+
]
|
|
82
|
+
: [])
|
|
58
83
|
.join(", ")}) -> ${return_resource}:`,
|
|
59
84
|
` raise NotImplementedError()`,
|
|
60
85
|
]
|
|
@@ -108,7 +133,7 @@ export class ClassFile {
|
|
|
108
133
|
if (is_return_resource_list) {
|
|
109
134
|
return_resource_item = return_resource.slice(5, -1);
|
|
110
135
|
}
|
|
111
|
-
const can_method_poll_action_attempt = return_resource === "ActionAttempt"
|
|
136
|
+
const can_method_poll_action_attempt = return_resource === "ActionAttempt";
|
|
112
137
|
const is_none_return_type = return_resource_item === "None";
|
|
113
138
|
const has_params = parameters.length > 0;
|
|
114
139
|
return [
|
|
@@ -122,7 +147,7 @@ export class ClassFile {
|
|
|
122
147
|
: `${name}: Optional[${type}] = None`)
|
|
123
148
|
.concat(can_method_poll_action_attempt
|
|
124
149
|
? [
|
|
125
|
-
"wait_for_action_attempt: Union[bool, Dict[str, float]] =
|
|
150
|
+
"wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
|
|
126
151
|
]
|
|
127
152
|
: [])
|
|
128
153
|
.join(", ")}) -> ${return_resource}:`,
|
|
@@ -138,20 +163,10 @@ export class ClassFile {
|
|
|
138
163
|
"",
|
|
139
164
|
can_method_poll_action_attempt
|
|
140
165
|
? [
|
|
141
|
-
"
|
|
142
|
-
`
|
|
143
|
-
|
|
144
|
-
"
|
|
145
|
-
" polling_interval=wait_for_action_attempt.get('polling_interval', None),",
|
|
146
|
-
" )",
|
|
147
|
-
" elif wait_for_action_attempt is True:",
|
|
148
|
-
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
149
|
-
" action_attempt_id=res['action_attempt']['action_attempt_id']",
|
|
150
|
-
" )",
|
|
151
|
-
" else:",
|
|
152
|
-
` return ${return_resource}.from_dict(res["${return_path.join('"]["')}"])`,
|
|
153
|
-
"",
|
|
154
|
-
" return updated_action_attempt",
|
|
166
|
+
" return self.seam.action_attempts.decide_and_wait(",
|
|
167
|
+
` action_attempt=ActionAttempt.from_dict(res["action_attempt"]),`,
|
|
168
|
+
` wait_for_action_attempt=wait_for_action_attempt`,
|
|
169
|
+
" )",
|
|
155
170
|
].join("\n")
|
|
156
171
|
: "",
|
|
157
172
|
"",
|
|
@@ -190,6 +205,16 @@ export class ClassFile {
|
|
|
190
205
|
" raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
|
|
191
206
|
"",
|
|
192
207
|
" return action_attempt",
|
|
208
|
+
"",
|
|
209
|
+
" def decide_and_wait(self, *, action_attempt: ActionAttempt, wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None) -> ActionAttempt:",
|
|
210
|
+
" wait_decision = self.seam.wait_for_action_attempt if wait_for_action_attempt is None else wait_for_action_attempt",
|
|
211
|
+
"",
|
|
212
|
+
" if wait_decision is True:",
|
|
213
|
+
" return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id)",
|
|
214
|
+
" elif isinstance(wait_decision, dict):",
|
|
215
|
+
" return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id, timeout=wait_decision.get('timeout', None), polling_interval=wait_decision.get('polling_interval', None))",
|
|
216
|
+
"",
|
|
217
|
+
" return action_attempt",
|
|
193
218
|
].join("\n")
|
|
194
219
|
: "",
|
|
195
220
|
].join("\n");
|
|
@@ -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,G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ACF;wBACD,WAAW,EAAE,EAAE;wBACf,eAAe,EAAE,eAAe;wBAChC,IAAI,EAAE,EAAE;qBACT;iBACF;gBACH,CAAC,CAAC,EAAE,CACP;iBACA,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE;gBACpD,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAA;
|
|
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;IACxD,CAAC;IAED,SAAS,CAAC,MAAuB;QAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IAC3B,CAAC;IAED,sCAAsC;QACpC,MAAM,iBAAiB,GAAG,IAAI,CAAC,uBAAuB,CAAC,MAAM,GAAG,CAAC,CAAA;QAEjE,OAAO;YACL,iBAAiB,IAAI,CAAC,IAAI,YAAY;YACtC,IAAI,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;YACzC,GACE,iBAAiB;gBACf,CAAC,CAAC,IAAI,CAAC,uBAAuB;qBACzB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACT;oBACE,aAAa;oBACb,uBAAuB;oBACvB,SAAS,CAAC,CAAC,SAAS,qBAAqB,CAAC,CAAC,UAAU,GAAG;oBACxD,iCAAiC;iBAClC,CAAC,IAAI,CAAC,IAAI,CAAC,CACb;qBACA,IAAI,CAAC,MAAM,CAAC;gBAC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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;oBAC3B,EAAE;oBACF,0JAA0J;oBAC1J,uHAAuH;oBACvH,EAAE;oBACF,+BAA+B;oBAC/B,6GAA6G;oBAC7G,2CAA2C;oBAC3C,uNAAuN;oBACvN,EAAE;oBACF,2BAA2B;iBAC5B,CAAC,IAAI,CAAC,IAAI,CAAC;gBACd,CAAC,CAAC,EAAE;SACP,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;CACF"}
|
|
@@ -22,6 +22,7 @@ class Seam(AbstractSeam):
|
|
|
22
22
|
*,
|
|
23
23
|
workspace_id: Optional[str] = None,
|
|
24
24
|
api_url: Optional[str] = None,
|
|
25
|
+
wait_for_action_attempt: Optional[bool] = False,
|
|
25
26
|
):
|
|
26
27
|
"""
|
|
27
28
|
Parameters
|
|
@@ -46,6 +47,7 @@ class Seam(AbstractSeam):
|
|
|
46
47
|
self.api_key = api_key
|
|
47
48
|
self.workspace_id = workspace_id
|
|
48
49
|
self.lts_version = Seam.lts_version
|
|
50
|
+
self.wait_for_action_attempt = wait_for_action_attempt
|
|
49
51
|
|
|
50
52
|
if os.environ.get("SEAM_API_URL", None) is not None:
|
|
51
53
|
print(
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkGpB,CAAA"}
|
|
@@ -4,13 +4,16 @@ class AbstractSeam(AbstractRoutes):
|
|
|
4
4
|
workspace_id: str
|
|
5
5
|
api_url: str
|
|
6
6
|
lts_version: str
|
|
7
|
+
wait_for_action_attempt: bool
|
|
7
8
|
|
|
8
9
|
@abc.abstractmethod
|
|
9
10
|
def __init__(
|
|
10
11
|
self,
|
|
11
12
|
api_key: Optional[str] = None,
|
|
13
|
+
*,
|
|
12
14
|
workspace_id: Optional[str] = None,
|
|
13
15
|
api_url: Optional[str] = None,
|
|
16
|
+
wait_for_action_attempt: Optional[bool] = False,
|
|
14
17
|
):
|
|
15
18
|
raise NotImplementedError`;
|
|
16
19
|
//# sourceMappingURL=abstract-seam.template.js.map
|
|
@@ -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;;;;;;;;;;;;;;;;;kCAiBa,CAAA"}
|
package/package.json
CHANGED
|
@@ -87,11 +87,32 @@ export class ClassFile {
|
|
|
87
87
|
return_resource: "ActionAttempt",
|
|
88
88
|
path: "",
|
|
89
89
|
},
|
|
90
|
+
{
|
|
91
|
+
method_name: "decide_and_wait",
|
|
92
|
+
parameters: [
|
|
93
|
+
{
|
|
94
|
+
name: "action_attempt",
|
|
95
|
+
type: "ActionAttempt",
|
|
96
|
+
required: true,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: "wait_for_action_attempt",
|
|
100
|
+
type: "Union[bool, Dict[str, float]]",
|
|
101
|
+
required: true,
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
return_path: [],
|
|
105
|
+
return_resource: "ActionAttempt",
|
|
106
|
+
path: "",
|
|
107
|
+
},
|
|
90
108
|
]
|
|
91
109
|
: []
|
|
92
110
|
)
|
|
93
111
|
.map(({ method_name, parameters, return_resource }) => {
|
|
94
112
|
const has_params = parameters.length > 0
|
|
113
|
+
const can_method_poll_action_attempt =
|
|
114
|
+
return_resource === "ActionAttempt" &&
|
|
115
|
+
method_name !== "poll_until_ready"
|
|
95
116
|
|
|
96
117
|
return [
|
|
97
118
|
"",
|
|
@@ -108,6 +129,13 @@ export class ClassFile {
|
|
|
108
129
|
? `${name}: ${type}`
|
|
109
130
|
: `${name}: Optional[${type}] = ${default_value ?? "None"}`
|
|
110
131
|
)
|
|
132
|
+
.concat(
|
|
133
|
+
can_method_poll_action_attempt
|
|
134
|
+
? [
|
|
135
|
+
"wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
|
|
136
|
+
]
|
|
137
|
+
: []
|
|
138
|
+
)
|
|
111
139
|
.join(", ")}) -> ${return_resource}:`,
|
|
112
140
|
` raise NotImplementedError()`,
|
|
113
141
|
]
|
|
@@ -188,7 +216,7 @@ export class ClassFile {
|
|
|
188
216
|
}
|
|
189
217
|
|
|
190
218
|
const can_method_poll_action_attempt =
|
|
191
|
-
return_resource === "ActionAttempt"
|
|
219
|
+
return_resource === "ActionAttempt"
|
|
192
220
|
const is_none_return_type = return_resource_item === "None"
|
|
193
221
|
const has_params = parameters.length > 0
|
|
194
222
|
|
|
@@ -209,7 +237,7 @@ export class ClassFile {
|
|
|
209
237
|
.concat(
|
|
210
238
|
can_method_poll_action_attempt
|
|
211
239
|
? [
|
|
212
|
-
"wait_for_action_attempt: Union[bool, Dict[str, float]] =
|
|
240
|
+
"wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
|
|
213
241
|
]
|
|
214
242
|
: []
|
|
215
243
|
)
|
|
@@ -233,22 +261,10 @@ export class ClassFile {
|
|
|
233
261
|
|
|
234
262
|
can_method_poll_action_attempt
|
|
235
263
|
? [
|
|
236
|
-
"
|
|
237
|
-
`
|
|
238
|
-
|
|
239
|
-
"
|
|
240
|
-
" polling_interval=wait_for_action_attempt.get('polling_interval', None),",
|
|
241
|
-
" )",
|
|
242
|
-
" elif wait_for_action_attempt is True:",
|
|
243
|
-
` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
|
|
244
|
-
" action_attempt_id=res['action_attempt']['action_attempt_id']",
|
|
245
|
-
" )",
|
|
246
|
-
" else:",
|
|
247
|
-
` return ${return_resource}.from_dict(res["${return_path.join(
|
|
248
|
-
'"]["'
|
|
249
|
-
)}"])`,
|
|
250
|
-
"",
|
|
251
|
-
" return updated_action_attempt",
|
|
264
|
+
" return self.seam.action_attempts.decide_and_wait(",
|
|
265
|
+
` action_attempt=ActionAttempt.from_dict(res["action_attempt"]),`,
|
|
266
|
+
` wait_for_action_attempt=wait_for_action_attempt`,
|
|
267
|
+
" )",
|
|
252
268
|
].join("\n")
|
|
253
269
|
: "",
|
|
254
270
|
"",
|
|
@@ -293,6 +309,16 @@ export class ClassFile {
|
|
|
293
309
|
" raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
|
|
294
310
|
"",
|
|
295
311
|
" return action_attempt",
|
|
312
|
+
"",
|
|
313
|
+
" def decide_and_wait(self, *, action_attempt: ActionAttempt, wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None) -> ActionAttempt:",
|
|
314
|
+
" wait_decision = self.seam.wait_for_action_attempt if wait_for_action_attempt is None else wait_for_action_attempt",
|
|
315
|
+
"",
|
|
316
|
+
" if wait_decision is True:",
|
|
317
|
+
" return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id)",
|
|
318
|
+
" elif isinstance(wait_decision, dict):",
|
|
319
|
+
" return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id, timeout=wait_decision.get('timeout', None), polling_interval=wait_decision.get('polling_interval', None))",
|
|
320
|
+
"",
|
|
321
|
+
" return action_attempt",
|
|
296
322
|
].join("\n")
|
|
297
323
|
: "",
|
|
298
324
|
].join("\n")
|
|
@@ -22,6 +22,7 @@ class Seam(AbstractSeam):
|
|
|
22
22
|
*,
|
|
23
23
|
workspace_id: Optional[str] = None,
|
|
24
24
|
api_url: Optional[str] = None,
|
|
25
|
+
wait_for_action_attempt: Optional[bool] = False,
|
|
25
26
|
):
|
|
26
27
|
"""
|
|
27
28
|
Parameters
|
|
@@ -46,6 +47,7 @@ class Seam(AbstractSeam):
|
|
|
46
47
|
self.api_key = api_key
|
|
47
48
|
self.workspace_id = workspace_id
|
|
48
49
|
self.lts_version = Seam.lts_version
|
|
50
|
+
self.wait_for_action_attempt = wait_for_action_attempt
|
|
49
51
|
|
|
50
52
|
if os.environ.get("SEAM_API_URL", None) is not None:
|
|
51
53
|
print(
|
|
@@ -4,12 +4,15 @@ class AbstractSeam(AbstractRoutes):
|
|
|
4
4
|
workspace_id: str
|
|
5
5
|
api_url: str
|
|
6
6
|
lts_version: str
|
|
7
|
+
wait_for_action_attempt: bool
|
|
7
8
|
|
|
8
9
|
@abc.abstractmethod
|
|
9
10
|
def __init__(
|
|
10
11
|
self,
|
|
11
12
|
api_key: Optional[str] = None,
|
|
13
|
+
*,
|
|
12
14
|
workspace_id: Optional[str] = None,
|
|
13
15
|
api_url: Optional[str] = None,
|
|
16
|
+
wait_for_action_attempt: Optional[bool] = False,
|
|
14
17
|
):
|
|
15
18
|
raise NotImplementedError`
|