@seamapi/nextlove-sdk-generator 1.7.7 → 1.7.9

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.
@@ -1,3 +1,4 @@
1
+ import { action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js";
1
2
  export class ClassFile {
2
3
  constructor(name, namespace, child_class_identifiers) {
3
4
  this.name = name;
@@ -24,28 +25,12 @@ export class ClassFile {
24
25
  .join("\n\n")
25
26
  : ""}`,
26
27
  ...this.methods
27
- .concat(this.name === "ActionAttempts"
28
- ? [
29
- {
30
- method_name: "poll_until_ready",
31
- parameters: [
32
- { name: "action_attempt_id", type: "str", required: true },
33
- { name: "timeout", type: "float", default_value: "5.0" },
34
- {
35
- name: "polling_interval",
36
- type: "float",
37
- default_value: "0.5",
38
- },
39
- ],
40
- return_path: [],
41
- return_resource: "ActionAttempt",
42
- path: "",
43
- },
44
- ]
45
- : [])
28
+ .concat(this.name === "ActionAttempts" ? action_attempt_utils_specs : [])
46
29
  .map(({ method_name, parameters, return_resource }) => {
47
30
  const has_params = parameters.length > 0;
48
- const can_method_poll_action_attempt = return_resource === "ActionAttempt";
31
+ const action_attempt_util_method_names = action_attempt_utils_specs.map((item) => item.method_name);
32
+ const can_method_poll_action_attempt = return_resource === "ActionAttempt" &&
33
+ !action_attempt_util_method_names.includes(method_name);
49
34
  return [
50
35
  "",
51
36
  "",
@@ -58,7 +43,7 @@ export class ClassFile {
58
43
  : `${name}: Optional[${type}] = ${default_value ?? "None"}`)
59
44
  .concat(can_method_poll_action_attempt
60
45
  ? [
61
- "wait_for_action_attempt: Union[bool, Dict[str, float]] = False",
46
+ "wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
62
47
  ]
63
48
  : [])
64
49
  .join(", ")}) -> ${return_resource}:`,
@@ -128,7 +113,7 @@ export class ClassFile {
128
113
  : `${name}: Optional[${type}] = None`)
129
114
  .concat(can_method_poll_action_attempt
130
115
  ? [
131
- "wait_for_action_attempt: Union[bool, Dict[str, float]] = False",
116
+ "wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
132
117
  ]
133
118
  : [])
134
119
  .join(", ")}) -> ${return_resource}:`,
@@ -144,20 +129,10 @@ export class ClassFile {
144
129
  "",
145
130
  can_method_poll_action_attempt
146
131
  ? [
147
- " if isinstance(wait_for_action_attempt, dict):",
148
- ` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
149
- " action_attempt_id=res['action_attempt']['action_attempt_id'],",
150
- " timeout=wait_for_action_attempt.get('timeout', None),",
151
- " polling_interval=wait_for_action_attempt.get('polling_interval', None),",
152
- " )",
153
- " elif wait_for_action_attempt is True:",
154
- ` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
155
- " action_attempt_id=res['action_attempt']['action_attempt_id']",
156
- " )",
157
- " else:",
158
- ` return ${return_resource}.from_dict(res["${return_path.join('"]["')}"])`,
159
- "",
160
- " return updated_action_attempt",
132
+ " return self.seam.action_attempts.decide_and_wait(",
133
+ ` action_attempt=ActionAttempt.from_dict(res["action_attempt"]),`,
134
+ ` wait_for_action_attempt=wait_for_action_attempt`,
135
+ " )",
161
136
  ].join("\n")
162
137
  : "",
163
138
  "",
@@ -172,32 +147,7 @@ export class ClassFile {
172
147
  .map((s) => ` ${s}`)
173
148
  .join("\n");
174
149
  }),
175
- this.name === "ActionAttempts"
176
- ? [
177
- "",
178
- " def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
179
- " seam = self.seam",
180
- " time_waiting = 0.0",
181
- "",
182
- " action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
183
- "",
184
- " while action_attempt.status == 'pending':",
185
- " time.sleep(polling_interval)",
186
- " time_waiting += polling_interval",
187
- "",
188
- " if time_waiting > timeout:",
189
- " raise Exception('Timed out waiting for action attempt to be ready')",
190
- "",
191
- " action_attempt = seam.action_attempts.get(",
192
- " action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
193
- " )",
194
- "",
195
- " if action_attempt.status == 'failed':",
196
- " raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
197
- "",
198
- " return action_attempt",
199
- ].join("\n")
200
- : "",
150
+ this.name === "ActionAttempts" ? action_attempt_utils_definitions : "",
201
151
  ].join("\n");
202
152
  }
203
153
  }
@@ -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;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,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S;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"}
1
+ {"version":3,"file":"class-file.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/class-file.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gCAAgC,EAChC,0BAA0B,GAC3B,MAAM,qCAAqC,CAAA;AA+B5C,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;gBACjB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AI,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,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE;SACvE,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgGpB,CAAA"}
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,6 +4,7 @@ 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__(
@@ -12,6 +13,7 @@ class AbstractSeam(AbstractRoutes):
12
13
  *,
13
14
  workspace_id: Optional[str] = None,
14
15
  api_url: Optional[str] = None,
16
+ wait_for_action_attempt: Optional[bool] = False,
15
17
  ):
16
18
  raise NotImplementedError`;
17
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;;;;;;;;;;;;;;;kCAea,CAAA"}
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"}
@@ -0,0 +1,18 @@
1
+ export declare const action_attempt_utils_specs: {
2
+ method_name: string;
3
+ parameters: ({
4
+ name: string;
5
+ type: string;
6
+ required: boolean;
7
+ default_value?: never;
8
+ } | {
9
+ name: string;
10
+ type: string;
11
+ default_value: string;
12
+ required?: never;
13
+ })[];
14
+ return_path: never[];
15
+ return_resource: string;
16
+ path: string;
17
+ }[];
18
+ export declare const action_attempt_utils_definitions: string;
@@ -0,0 +1,70 @@
1
+ export const action_attempt_utils_specs = [
2
+ {
3
+ method_name: "poll_until_ready",
4
+ parameters: [
5
+ { name: "action_attempt_id", type: "str", required: true },
6
+ { name: "timeout", type: "float", default_value: "5.0" },
7
+ {
8
+ name: "polling_interval",
9
+ type: "float",
10
+ default_value: "0.5",
11
+ },
12
+ ],
13
+ return_path: [],
14
+ return_resource: "ActionAttempt",
15
+ path: "",
16
+ },
17
+ {
18
+ method_name: "decide_and_wait",
19
+ parameters: [
20
+ {
21
+ name: "action_attempt",
22
+ type: "ActionAttempt",
23
+ required: true,
24
+ },
25
+ {
26
+ name: "wait_for_action_attempt",
27
+ type: "Union[bool, Dict[str, float]]",
28
+ required: true,
29
+ },
30
+ ],
31
+ return_path: [],
32
+ return_resource: "ActionAttempt",
33
+ path: "",
34
+ },
35
+ ];
36
+ export const action_attempt_utils_definitions = [
37
+ "",
38
+ " def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
39
+ " seam = self.seam",
40
+ " time_waiting = 0.0",
41
+ "",
42
+ " action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
43
+ "",
44
+ " while action_attempt.status == 'pending':",
45
+ " time.sleep(polling_interval)",
46
+ " time_waiting += polling_interval",
47
+ "",
48
+ " if time_waiting > timeout:",
49
+ " raise Exception('Timed out waiting for action attempt to be ready')",
50
+ "",
51
+ " action_attempt = seam.action_attempts.get(",
52
+ " action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
53
+ " )",
54
+ "",
55
+ " if action_attempt.status == 'failed':",
56
+ " raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
57
+ "",
58
+ " return action_attempt",
59
+ "",
60
+ " def decide_and_wait(self, *, action_attempt: ActionAttempt, wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None) -> ActionAttempt:",
61
+ " wait_decision = self.seam.wait_for_action_attempt if wait_for_action_attempt is None else wait_for_action_attempt",
62
+ "",
63
+ " if wait_decision is True:",
64
+ " return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id)",
65
+ " elif isinstance(wait_decision, dict):",
66
+ " 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))",
67
+ "",
68
+ " return action_attempt",
69
+ ].join("\n");
70
+ //# sourceMappingURL=action-attempt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"action-attempt.js","sourceRoot":"","sources":["../../../../src/lib/generate-python-sdk/templates/utils/action-attempt.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC;QACE,WAAW,EAAE,kBAAkB;QAC/B,UAAU,EAAE;YACV,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE;YAC1D,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE;YACxD;gBACE,IAAI,EAAE,kBAAkB;gBACxB,IAAI,EAAE,OAAO;gBACb,aAAa,EAAE,KAAK;aACrB;SACF;QACD,WAAW,EAAE,EAAE;QACf,eAAe,EAAE,eAAe;QAChC,IAAI,EAAE,EAAE;KACT;IACD;QACE,WAAW,EAAE,iBAAiB;QAC9B,UAAU,EAAE;YACV;gBACE,IAAI,EAAE,gBAAgB;gBACtB,IAAI,EAAE,eAAe;gBACrB,QAAQ,EAAE,IAAI;aACf;YACD;gBACE,IAAI,EAAE,yBAAyB;gBAC/B,IAAI,EAAE,+BAA+B;gBACrC,QAAQ,EAAE,IAAI;aACf;SACF;QACD,WAAW,EAAE,EAAE;QACf,eAAe,EAAE,eAAe;QAChC,IAAI,EAAE,EAAE;KACT;CACF,CAAA;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG;IAC9C,EAAE;IACF,oJAAoJ;IACpJ,sBAAsB;IACtB,wBAAwB;IACxB,EAAE;IACF,mHAAmH;IACnH,EAAE;IACF,+CAA+C;IAC/C,oCAAoC;IACpC,wCAAwC;IACxC,EAAE;IACF,kCAAkC;IAClC,6EAA6E;IAC7E,EAAE;IACF,kDAAkD;IAClD,2FAA2F;IAC3F,SAAS;IACT,EAAE;IACF,2CAA2C;IAC3C,iFAAiF;IACjF,EAAE;IACF,2BAA2B;IAC3B,EAAE;IACF,0JAA0J;IAC1J,uHAAuH;IACvH,EAAE;IACF,+BAA+B;IAC/B,6GAA6G;IAC7G,2CAA2C;IAC3C,uNAAuN;IACvN,EAAE;IACF,2BAA2B;CAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/nextlove-sdk-generator",
3
- "version": "1.7.7",
3
+ "version": "1.7.9",
4
4
  "description": "Utilities for building NextLove SDK Generators",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -1,3 +1,8 @@
1
+ import {
2
+ action_attempt_utils_definitions,
3
+ action_attempt_utils_specs,
4
+ } from "./templates/utils/action-attempt.js"
5
+
1
6
  export type ClassFileMethodBase = {
2
7
  method_name: string
3
8
  path: string
@@ -70,30 +75,15 @@ export class ClassFile {
70
75
  }`,
71
76
  ...this.methods
72
77
  .concat(
73
- this.name === "ActionAttempts"
74
- ? [
75
- {
76
- method_name: "poll_until_ready",
77
- parameters: [
78
- { name: "action_attempt_id", type: "str", required: true },
79
- { name: "timeout", type: "float", default_value: "5.0" },
80
- {
81
- name: "polling_interval",
82
- type: "float",
83
- default_value: "0.5",
84
- },
85
- ],
86
- return_path: [],
87
- return_resource: "ActionAttempt",
88
- path: "",
89
- },
90
- ]
91
- : []
78
+ this.name === "ActionAttempts" ? action_attempt_utils_specs : []
92
79
  )
93
80
  .map(({ method_name, parameters, return_resource }) => {
94
81
  const has_params = parameters.length > 0
82
+ const action_attempt_util_method_names =
83
+ action_attempt_utils_specs.map((item) => item.method_name)
95
84
  const can_method_poll_action_attempt =
96
- return_resource === "ActionAttempt"
85
+ return_resource === "ActionAttempt" &&
86
+ !action_attempt_util_method_names.includes(method_name)
97
87
 
98
88
  return [
99
89
  "",
@@ -113,7 +103,7 @@ export class ClassFile {
113
103
  .concat(
114
104
  can_method_poll_action_attempt
115
105
  ? [
116
- "wait_for_action_attempt: Union[bool, Dict[str, float]] = False",
106
+ "wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
117
107
  ]
118
108
  : []
119
109
  )
@@ -218,7 +208,7 @@ export class ClassFile {
218
208
  .concat(
219
209
  can_method_poll_action_attempt
220
210
  ? [
221
- "wait_for_action_attempt: Union[bool, Dict[str, float]] = False",
211
+ "wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
222
212
  ]
223
213
  : []
224
214
  )
@@ -242,22 +232,10 @@ export class ClassFile {
242
232
 
243
233
  can_method_poll_action_attempt
244
234
  ? [
245
- " if isinstance(wait_for_action_attempt, dict):",
246
- ` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
247
- " action_attempt_id=res['action_attempt']['action_attempt_id'],",
248
- " timeout=wait_for_action_attempt.get('timeout', None),",
249
- " polling_interval=wait_for_action_attempt.get('polling_interval', None),",
250
- " )",
251
- " elif wait_for_action_attempt is True:",
252
- ` updated_action_attempt = self.seam.action_attempts.poll_until_ready(`,
253
- " action_attempt_id=res['action_attempt']['action_attempt_id']",
254
- " )",
255
- " else:",
256
- ` return ${return_resource}.from_dict(res["${return_path.join(
257
- '"]["'
258
- )}"])`,
259
- "",
260
- " return updated_action_attempt",
235
+ " return self.seam.action_attempts.decide_and_wait(",
236
+ ` action_attempt=ActionAttempt.from_dict(res["action_attempt"]),`,
237
+ ` wait_for_action_attempt=wait_for_action_attempt`,
238
+ " )",
261
239
  ].join("\n")
262
240
  : "",
263
241
  "",
@@ -278,32 +256,7 @@ export class ClassFile {
278
256
  .join("\n")
279
257
  }
280
258
  ),
281
- this.name === "ActionAttempts"
282
- ? [
283
- "",
284
- " def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
285
- " seam = self.seam",
286
- " time_waiting = 0.0",
287
- "",
288
- " action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
289
- "",
290
- " while action_attempt.status == 'pending':",
291
- " time.sleep(polling_interval)",
292
- " time_waiting += polling_interval",
293
- "",
294
- " if time_waiting > timeout:",
295
- " raise Exception('Timed out waiting for action attempt to be ready')",
296
- "",
297
- " action_attempt = seam.action_attempts.get(",
298
- " action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
299
- " )",
300
- "",
301
- " if action_attempt.status == 'failed':",
302
- " raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
303
- "",
304
- " return action_attempt",
305
- ].join("\n")
306
- : "",
259
+ this.name === "ActionAttempts" ? action_attempt_utils_definitions : "",
307
260
  ].join("\n")
308
261
  }
309
262
  }
@@ -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,6 +4,7 @@ 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__(
@@ -12,5 +13,6 @@ class AbstractSeam(AbstractRoutes):
12
13
  *,
13
14
  workspace_id: Optional[str] = None,
14
15
  api_url: Optional[str] = None,
16
+ wait_for_action_attempt: Optional[bool] = False,
15
17
  ):
16
18
  raise NotImplementedError`
@@ -0,0 +1,70 @@
1
+ export const action_attempt_utils_specs = [
2
+ {
3
+ method_name: "poll_until_ready",
4
+ parameters: [
5
+ { name: "action_attempt_id", type: "str", required: true },
6
+ { name: "timeout", type: "float", default_value: "5.0" },
7
+ {
8
+ name: "polling_interval",
9
+ type: "float",
10
+ default_value: "0.5",
11
+ },
12
+ ],
13
+ return_path: [],
14
+ return_resource: "ActionAttempt",
15
+ path: "",
16
+ },
17
+ {
18
+ method_name: "decide_and_wait",
19
+ parameters: [
20
+ {
21
+ name: "action_attempt",
22
+ type: "ActionAttempt",
23
+ required: true,
24
+ },
25
+ {
26
+ name: "wait_for_action_attempt",
27
+ type: "Union[bool, Dict[str, float]]",
28
+ required: true,
29
+ },
30
+ ],
31
+ return_path: [],
32
+ return_resource: "ActionAttempt",
33
+ path: "",
34
+ },
35
+ ]
36
+
37
+ export const action_attempt_utils_definitions = [
38
+ "",
39
+ " def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
40
+ " seam = self.seam",
41
+ " time_waiting = 0.0",
42
+ "",
43
+ " action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
44
+ "",
45
+ " while action_attempt.status == 'pending':",
46
+ " time.sleep(polling_interval)",
47
+ " time_waiting += polling_interval",
48
+ "",
49
+ " if time_waiting > timeout:",
50
+ " raise Exception('Timed out waiting for action attempt to be ready')",
51
+ "",
52
+ " action_attempt = seam.action_attempts.get(",
53
+ " action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
54
+ " )",
55
+ "",
56
+ " if action_attempt.status == 'failed':",
57
+ " raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
58
+ "",
59
+ " return action_attempt",
60
+ "",
61
+ " def decide_and_wait(self, *, action_attempt: ActionAttempt, wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None) -> ActionAttempt:",
62
+ " wait_decision = self.seam.wait_for_action_attempt if wait_for_action_attempt is None else wait_for_action_attempt",
63
+ "",
64
+ " if wait_decision is True:",
65
+ " return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id)",
66
+ " elif isinstance(wait_decision, dict):",
67
+ " 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))",
68
+ "",
69
+ " return action_attempt",
70
+ ].join("\n")