@seamapi/nextlove-sdk-generator 1.7.8 → 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,47 +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
- 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
- },
62
- ]
63
- : [])
28
+ .concat(this.name === "ActionAttempts" ? action_attempt_utils_specs : [])
64
29
  .map(({ method_name, parameters, return_resource }) => {
65
30
  const has_params = parameters.length > 0;
31
+ const action_attempt_util_method_names = action_attempt_utils_specs.map((item) => item.method_name);
66
32
  const can_method_poll_action_attempt = return_resource === "ActionAttempt" &&
67
- method_name !== "poll_until_ready";
33
+ !action_attempt_util_method_names.includes(method_name);
68
34
  return [
69
35
  "",
70
36
  "",
@@ -181,42 +147,7 @@ export class ClassFile {
181
147
  .map((s) => ` ${s}`)
182
148
  .join("\n");
183
149
  }),
184
- this.name === "ActionAttempts"
185
- ? [
186
- "",
187
- " def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
188
- " seam = self.seam",
189
- " time_waiting = 0.0",
190
- "",
191
- " action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
192
- "",
193
- " while action_attempt.status == 'pending':",
194
- " time.sleep(polling_interval)",
195
- " time_waiting += polling_interval",
196
- "",
197
- " if time_waiting > timeout:",
198
- " raise Exception('Timed out waiting for action attempt to be ready')",
199
- "",
200
- " action_attempt = seam.action_attempts.get(",
201
- " action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
202
- " )",
203
- "",
204
- " if action_attempt.status == 'failed':",
205
- " raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
206
- "",
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",
218
- ].join("\n")
219
- : "",
150
+ this.name === "ActionAttempts" ? action_attempt_utils_definitions : "",
220
151
  ].join("\n");
221
152
  }
222
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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W,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"}
@@ -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,m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"version": "1.7.8",
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,49 +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
- 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
- },
108
- ]
109
- : []
78
+ this.name === "ActionAttempts" ? action_attempt_utils_specs : []
110
79
  )
111
80
  .map(({ method_name, parameters, return_resource }) => {
112
81
  const has_params = parameters.length > 0
82
+ const action_attempt_util_method_names =
83
+ action_attempt_utils_specs.map((item) => item.method_name)
113
84
  const can_method_poll_action_attempt =
114
85
  return_resource === "ActionAttempt" &&
115
- method_name !== "poll_until_ready"
86
+ !action_attempt_util_method_names.includes(method_name)
116
87
 
117
88
  return [
118
89
  "",
@@ -285,42 +256,7 @@ export class ClassFile {
285
256
  .join("\n")
286
257
  }
287
258
  ),
288
- this.name === "ActionAttempts"
289
- ? [
290
- "",
291
- " def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:",
292
- " seam = self.seam",
293
- " time_waiting = 0.0",
294
- "",
295
- " action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)",
296
- "",
297
- " while action_attempt.status == 'pending':",
298
- " time.sleep(polling_interval)",
299
- " time_waiting += polling_interval",
300
- "",
301
- " if time_waiting > timeout:",
302
- " raise Exception('Timed out waiting for action attempt to be ready')",
303
- "",
304
- " action_attempt = seam.action_attempts.get(",
305
- " action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False",
306
- " )",
307
- "",
308
- " if action_attempt.status == 'failed':",
309
- " raise Exception(f'Action Attempt failed: {action_attempt.error.message}')",
310
- "",
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",
322
- ].join("\n")
323
- : "",
259
+ this.name === "ActionAttempts" ? action_attempt_utils_definitions : "",
324
260
  ].join("\n")
325
261
  }
326
262
  }
@@ -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")