@seamapi/nextlove-sdk-generator
Advanced tools
Comparing version 1.7.8 to 1.7.9
@@ -0,1 +1,2 @@ | ||
import { action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js"; | ||
export class ClassFile { | ||
@@ -27,43 +28,8 @@ constructor(name, namespace, child_class_identifiers) { | ||
...this.methods | ||
.concat(this.name === "ActionAttempts" | ||
? [ | ||
{ | ||
method_name: "poll_until_ready", | ||
parameters: [ | ||
{ name: "action_attempt_id", type: "str", required: true }, | ||
{ name: "timeout", type: "float", default_value: "5.0" }, | ||
{ | ||
name: "polling_interval", | ||
type: "float", | ||
default_value: "0.5", | ||
}, | ||
], | ||
return_path: [], | ||
return_resource: "ActionAttempt", | ||
path: "", | ||
}, | ||
{ | ||
method_name: "decide_and_wait", | ||
parameters: [ | ||
{ | ||
name: "action_attempt", | ||
type: "ActionAttempt", | ||
required: true, | ||
}, | ||
{ | ||
name: "wait_for_action_attempt", | ||
type: "Union[bool, Dict[str, float]]", | ||
required: true, | ||
}, | ||
], | ||
return_path: [], | ||
return_resource: "ActionAttempt", | ||
path: "", | ||
}, | ||
] | ||
: []) | ||
.concat(this.name === "ActionAttempts" ? action_attempt_utils_specs : []) | ||
.map(({ method_name, parameters, return_resource }) => { | ||
const has_params = parameters.length > 0; | ||
const action_attempt_util_method_names = action_attempt_utils_specs.map((item) => item.method_name); | ||
const can_method_poll_action_attempt = return_resource === "ActionAttempt" && | ||
method_name !== "poll_until_ready"; | ||
!action_attempt_util_method_names.includes(method_name); | ||
return [ | ||
@@ -185,38 +151,3 @@ "", | ||
}), | ||
this.name === "ActionAttempts" | ||
? [ | ||
"", | ||
" def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:", | ||
" seam = self.seam", | ||
" time_waiting = 0.0", | ||
"", | ||
" action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)", | ||
"", | ||
" while action_attempt.status == 'pending':", | ||
" time.sleep(polling_interval)", | ||
" time_waiting += polling_interval", | ||
"", | ||
" if time_waiting > timeout:", | ||
" raise Exception('Timed out waiting for action attempt to be ready')", | ||
"", | ||
" action_attempt = seam.action_attempts.get(", | ||
" action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False", | ||
" )", | ||
"", | ||
" if action_attempt.status == 'failed':", | ||
" raise Exception(f'Action Attempt failed: {action_attempt.error.message}')", | ||
"", | ||
" return action_attempt", | ||
"", | ||
" def decide_and_wait(self, *, action_attempt: ActionAttempt, wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None) -> ActionAttempt:", | ||
" wait_decision = self.seam.wait_for_action_attempt if wait_for_action_attempt is None else wait_for_action_attempt", | ||
"", | ||
" if wait_decision is True:", | ||
" return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id)", | ||
" elif isinstance(wait_decision, dict):", | ||
" 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))", | ||
"", | ||
" return action_attempt", | ||
].join("\n") | ||
: "", | ||
this.name === "ActionAttempts" ? action_attempt_utils_definitions : "", | ||
].join("\n"); | ||
@@ -223,0 +154,0 @@ } |
{ | ||
"name": "@seamapi/nextlove-sdk-generator", | ||
"version": "1.7.8", | ||
"version": "1.7.9", | ||
"description": "Utilities for building NextLove SDK Generators", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -0,1 +1,6 @@ | ||
import { | ||
action_attempt_utils_definitions, | ||
action_attempt_utils_specs, | ||
} from "./templates/utils/action-attempt.js" | ||
export type ClassFileMethodBase = { | ||
@@ -73,45 +78,11 @@ method_name: string | ||
.concat( | ||
this.name === "ActionAttempts" | ||
? [ | ||
{ | ||
method_name: "poll_until_ready", | ||
parameters: [ | ||
{ name: "action_attempt_id", type: "str", required: true }, | ||
{ name: "timeout", type: "float", default_value: "5.0" }, | ||
{ | ||
name: "polling_interval", | ||
type: "float", | ||
default_value: "0.5", | ||
}, | ||
], | ||
return_path: [], | ||
return_resource: "ActionAttempt", | ||
path: "", | ||
}, | ||
{ | ||
method_name: "decide_and_wait", | ||
parameters: [ | ||
{ | ||
name: "action_attempt", | ||
type: "ActionAttempt", | ||
required: true, | ||
}, | ||
{ | ||
name: "wait_for_action_attempt", | ||
type: "Union[bool, Dict[str, float]]", | ||
required: true, | ||
}, | ||
], | ||
return_path: [], | ||
return_resource: "ActionAttempt", | ||
path: "", | ||
}, | ||
] | ||
: [] | ||
this.name === "ActionAttempts" ? action_attempt_utils_specs : [] | ||
) | ||
.map(({ method_name, parameters, return_resource }) => { | ||
const has_params = parameters.length > 0 | ||
const action_attempt_util_method_names = | ||
action_attempt_utils_specs.map((item) => item.method_name) | ||
const can_method_poll_action_attempt = | ||
return_resource === "ActionAttempt" && | ||
method_name !== "poll_until_ready" | ||
!action_attempt_util_method_names.includes(method_name) | ||
@@ -289,40 +260,5 @@ return [ | ||
), | ||
this.name === "ActionAttempts" | ||
? [ | ||
"", | ||
" def poll_until_ready(self, *, action_attempt_id: str, timeout: Optional[float] = 5.0, polling_interval: Optional[float] = 0.5) -> ActionAttempt:", | ||
" seam = self.seam", | ||
" time_waiting = 0.0", | ||
"", | ||
" action_attempt = seam.action_attempts.get(action_attempt_id=action_attempt_id, wait_for_action_attempt=False)", | ||
"", | ||
" while action_attempt.status == 'pending':", | ||
" time.sleep(polling_interval)", | ||
" time_waiting += polling_interval", | ||
"", | ||
" if time_waiting > timeout:", | ||
" raise Exception('Timed out waiting for action attempt to be ready')", | ||
"", | ||
" action_attempt = seam.action_attempts.get(", | ||
" action_attempt_id=action_attempt.action_attempt_id, wait_for_action_attempt=False", | ||
" )", | ||
"", | ||
" if action_attempt.status == 'failed':", | ||
" raise Exception(f'Action Attempt failed: {action_attempt.error.message}')", | ||
"", | ||
" return action_attempt", | ||
"", | ||
" def decide_and_wait(self, *, action_attempt: ActionAttempt, wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None) -> ActionAttempt:", | ||
" wait_decision = self.seam.wait_for_action_attempt if wait_for_action_attempt is None else wait_for_action_attempt", | ||
"", | ||
" if wait_decision is True:", | ||
" return self.seam.action_attempts.poll_until_ready(action_attempt_id=action_attempt.action_attempt_id)", | ||
" elif isinstance(wait_decision, dict):", | ||
" 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))", | ||
"", | ||
" return action_attempt", | ||
].join("\n") | ||
: "", | ||
this.name === "ActionAttempts" ? action_attempt_utils_definitions : "", | ||
].join("\n") | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
359
9571
707822