@seamapi/nextlove-sdk-generator 1.11.4 → 1.12.0
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 +23 -21
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/templates/routes.py.template.js +4 -2
- package/lib/generate-python-sdk/templates/routes.py.template.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/generate-python-sdk/class-file.ts +58 -59
- package/src/lib/generate-python-sdk/templates/routes.py.template.ts +7 -2
- package/lib/generate-python-sdk/templates/utils/action-attempt.d.ts +0 -19
- package/lib/generate-python-sdk/templates/utils/action-attempt.js +0 -73
- package/lib/generate-python-sdk/templates/utils/action-attempt.js.map +0 -1
- package/src/lib/generate-python-sdk/templates/utils/action-attempt.ts +0 -74
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js";
|
|
2
1
|
export class ClassFile {
|
|
3
2
|
constructor(name, namespace, child_class_identifiers) {
|
|
4
3
|
this.name = name;
|
|
@@ -13,7 +12,7 @@ export class ClassFile {
|
|
|
13
12
|
const has_child_classes = this.child_class_identifiers.length > 0;
|
|
14
13
|
return [
|
|
15
14
|
`class Abstract${this.name}(abc.ABC):`,
|
|
16
|
-
this.methods.length === 0 ? ` pass` : "",
|
|
15
|
+
this.methods.length === 0 && !has_child_classes ? ` pass` : "",
|
|
17
16
|
`${has_child_classes
|
|
18
17
|
? this.child_class_identifiers
|
|
19
18
|
.map((i) => [
|
|
@@ -24,13 +23,9 @@ export class ClassFile {
|
|
|
24
23
|
].join("\n"))
|
|
25
24
|
.join("\n\n")
|
|
26
25
|
: ""}`,
|
|
27
|
-
...this.methods
|
|
28
|
-
.concat(this.name === "ActionAttempts" ? action_attempt_utils_specs : [])
|
|
29
|
-
.map(({ method_name, parameters, return_resource }) => {
|
|
26
|
+
...this.methods.map(({ method_name, parameters, return_resource }) => {
|
|
30
27
|
const has_params = parameters.length > 0;
|
|
31
|
-
const
|
|
32
|
-
const can_method_poll_action_attempt = return_resource === "ActionAttempt" &&
|
|
33
|
-
!action_attempt_util_method_names.includes(method_name);
|
|
28
|
+
const can_method_poll_action_attempt = return_resource === "ActionAttempt";
|
|
34
29
|
return [
|
|
35
30
|
"",
|
|
36
31
|
"",
|
|
@@ -60,10 +55,10 @@ export class ClassFile {
|
|
|
60
55
|
...Array.from(new Set(this.methods.map((m) => m.return_resource.replace(/^List\[/, "").replace(/\]$/, "")))),
|
|
61
56
|
].filter((classInstance) => classInstance !== "");
|
|
62
57
|
const has_child_classes = this.child_class_identifiers.length > 0;
|
|
63
|
-
const
|
|
58
|
+
const should_import_resolve_action_attempt = this.methods.some(({ return_resource }) => return_resource === "ActionAttempt");
|
|
64
59
|
return [
|
|
65
60
|
`from typing import Optional, Any, List, Dict, Union`,
|
|
66
|
-
`from ..
|
|
61
|
+
`from ..client import SeamHttpClient`,
|
|
67
62
|
`from .models import (${validClasses
|
|
68
63
|
.filter((cls) => cls !== "None")
|
|
69
64
|
.join(",")})`,
|
|
@@ -72,17 +67,18 @@ export class ClassFile {
|
|
|
72
67
|
.map((i) => `from .${this.namespace}_${i.namespace} import ${i.class_name}`)
|
|
73
68
|
.join("\n")
|
|
74
69
|
: ""}`,
|
|
75
|
-
`${
|
|
70
|
+
`${should_import_resolve_action_attempt
|
|
71
|
+
? "from ..modules.action_attempts import resolve_action_attempt"
|
|
72
|
+
: ""}`,
|
|
76
73
|
"",
|
|
77
74
|
`class ${this.name}(Abstract${this.name}):`,
|
|
78
75
|
// TODO DOCSTRING
|
|
79
|
-
`
|
|
80
|
-
|
|
81
|
-
`
|
|
82
|
-
` self.seam = seam`,
|
|
76
|
+
` def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):`,
|
|
77
|
+
` self.client = client`,
|
|
78
|
+
` self.defaults = defaults`,
|
|
83
79
|
`${has_child_classes
|
|
84
80
|
? this.child_class_identifiers
|
|
85
|
-
.map((i) => ` self._${i.namespace} = ${i.class_name}(
|
|
81
|
+
.map((i) => ` self._${i.namespace} = ${i.class_name}(client=client, defaults = defaults)`)
|
|
86
82
|
.join("\n")
|
|
87
83
|
: ""}`,
|
|
88
84
|
"",
|
|
@@ -123,17 +119,24 @@ export class ClassFile {
|
|
|
123
119
|
"",
|
|
124
120
|
...parameters.map(({ name }) => ` if ${name} is not None:\n json_payload["${name}"] = ${name}`),
|
|
125
121
|
"",
|
|
126
|
-
` ${is_none_return_type ? "" : "res = "}self.
|
|
122
|
+
` ${is_none_return_type ? "" : "res = "}self.client.post(`,
|
|
127
123
|
` "${path}",`,
|
|
128
124
|
` json=json_payload`,
|
|
129
125
|
` )`,
|
|
130
126
|
"",
|
|
131
127
|
can_method_poll_action_attempt
|
|
132
128
|
? [
|
|
133
|
-
"
|
|
134
|
-
|
|
135
|
-
|
|
129
|
+
" wait_for_action_attempt = (",
|
|
130
|
+
" self.defaults.get('wait_for_action_attempt')",
|
|
131
|
+
" if wait_for_action_attempt is None",
|
|
132
|
+
" else wait_for_action_attempt",
|
|
136
133
|
" )",
|
|
134
|
+
"",
|
|
135
|
+
" return resolve_action_attempt(",
|
|
136
|
+
` client=self.client,`,
|
|
137
|
+
` action_attempt=ActionAttempt.from_dict(res["action_attempt"]),`,
|
|
138
|
+
` wait_for_action_attempt=wait_for_action_attempt`,
|
|
139
|
+
" )",
|
|
137
140
|
].join("\n")
|
|
138
141
|
: "",
|
|
139
142
|
"",
|
|
@@ -148,7 +151,6 @@ export class ClassFile {
|
|
|
148
151
|
.map((s) => ` ${s}`)
|
|
149
152
|
.join("\n");
|
|
150
153
|
}),
|
|
151
|
-
is_action_attempt_class ? action_attempt_utils_definitions : "",
|
|
152
154
|
].join("\n");
|
|
153
155
|
}
|
|
154
156
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-file.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/class-file.ts"],"names":[],"mappings":"
|
|
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,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;YAC/D,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,CAAC,CAAC,EACN,EAAE;YACF,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,WAAW,EAAE,UAAU,EAAE,eAAe,EAAE,EAAE,EAAE;gBACnE,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAA;gBACxC,MAAM,8B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,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;SACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;CACF"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { pascalCase } from "change-case";
|
|
2
2
|
export default (namespaces) => [
|
|
3
|
+
`from typing import Any, Dict`,
|
|
4
|
+
`from ..client import SeamHttpClient`,
|
|
3
5
|
`from .models import AbstractRoutes`,
|
|
4
6
|
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`),
|
|
5
7
|
``,
|
|
6
8
|
`class Routes(AbstractRoutes):`,
|
|
7
|
-
` def __init__(self):`,
|
|
8
|
-
...namespaces.map((ns) => ` self.${ns} = ${pascalCase(ns)}(
|
|
9
|
+
` def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):`,
|
|
10
|
+
...namespaces.map((ns) => ` self.${ns} = ${pascalCase(ns)}(client=client, defaults=defaults)`),
|
|
9
11
|
].join("\n");
|
|
10
12
|
//# sourceMappingURL=routes.py.template.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/routes.py.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,eAAe,CAAC,UAAoB,EAAE,EAAE,CACtC;IACE,oCAAoC;IACpC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,WAAW,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;IACjE,EAAE;IACF,+BAA+B;IAC/B,
|
|
1
|
+
{"version":3,"file":"routes.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/routes.py.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,eAAe,CAAC,UAAoB,EAAE,EAAE,CACtC;IACE,8BAA8B;IAC9B,qCAAqC;IACrC,oCAAoC;IACpC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,SAAS,EAAE,WAAW,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC;IACjE,EAAE;IACF,+BAA+B;IAC/B,yEAAyE;IACzE,GAAG,UAAU,CAAC,GAAG,CACf,CAAC,EAAE,EAAE,EAAE,CACL,YAAY,EAAE,MAAM,UAAU,CAAC,EAAE,CAAC,oCAAoC,CACzE;CACF,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
action_attempt_imports,
|
|
3
|
-
action_attempt_utils_definitions,
|
|
4
|
-
action_attempt_utils_specs,
|
|
5
|
-
} from "./templates/utils/action-attempt.js"
|
|
6
|
-
|
|
7
1
|
export type ClassFileMethodBase = {
|
|
8
2
|
method_name: string
|
|
9
3
|
path: string
|
|
@@ -59,7 +53,7 @@ export class ClassFile {
|
|
|
59
53
|
|
|
60
54
|
return [
|
|
61
55
|
`class Abstract${this.name}(abc.ABC):`,
|
|
62
|
-
this.methods.length === 0 ? ` pass` : "",
|
|
56
|
+
this.methods.length === 0 && !has_child_classes ? ` pass` : "",
|
|
63
57
|
`${
|
|
64
58
|
has_child_classes
|
|
65
59
|
? this.child_class_identifiers
|
|
@@ -74,46 +68,39 @@ export class ClassFile {
|
|
|
74
68
|
.join("\n\n")
|
|
75
69
|
: ""
|
|
76
70
|
}`,
|
|
77
|
-
...this.methods
|
|
78
|
-
.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
.map(({ method_name, parameters, return_resource }) => {
|
|
82
|
-
const has_params = parameters.length > 0
|
|
83
|
-
const action_attempt_util_method_names =
|
|
84
|
-
action_attempt_utils_specs.map((item) => item.method_name)
|
|
85
|
-
const can_method_poll_action_attempt =
|
|
86
|
-
return_resource === "ActionAttempt" &&
|
|
87
|
-
!action_attempt_util_method_names.includes(method_name)
|
|
71
|
+
...this.methods.map(({ method_name, parameters, return_resource }) => {
|
|
72
|
+
const has_params = parameters.length > 0
|
|
73
|
+
const can_method_poll_action_attempt =
|
|
74
|
+
return_resource === "ActionAttempt"
|
|
88
75
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
76
|
+
return [
|
|
77
|
+
"",
|
|
78
|
+
"",
|
|
79
|
+
`@abc.abstractmethod`,
|
|
80
|
+
`def ${method_name}(self,${has_params ? " *," : ""} ${parameters
|
|
81
|
+
.sort(
|
|
82
|
+
(a, b) =>
|
|
83
|
+
(a.position ?? a.required ? 1000 : 9999) -
|
|
84
|
+
(b.position ?? b.required ? 1000 : 9999)
|
|
85
|
+
)
|
|
86
|
+
.map(({ name, type, required, default_value }) =>
|
|
87
|
+
required
|
|
88
|
+
? `${name}: ${type}`
|
|
89
|
+
: `${name}: Optional[${type}] = ${default_value ?? "None"}`
|
|
90
|
+
)
|
|
91
|
+
.concat(
|
|
92
|
+
can_method_poll_action_attempt
|
|
93
|
+
? [
|
|
94
|
+
"wait_for_action_attempt: Optional[Union[bool, Dict[str, float]]] = None",
|
|
95
|
+
]
|
|
96
|
+
: []
|
|
97
|
+
)
|
|
98
|
+
.join(", ")}) -> ${return_resource}:`,
|
|
99
|
+
` raise NotImplementedError()`,
|
|
100
|
+
]
|
|
101
|
+
.map((s) => ` ${s}`)
|
|
102
|
+
.join("\n")
|
|
103
|
+
}),
|
|
117
104
|
].join("\n")
|
|
118
105
|
}
|
|
119
106
|
|
|
@@ -129,11 +116,13 @@ export class ClassFile {
|
|
|
129
116
|
),
|
|
130
117
|
].filter((classInstance) => classInstance !== "")
|
|
131
118
|
const has_child_classes = this.child_class_identifiers.length > 0
|
|
132
|
-
const
|
|
119
|
+
const should_import_resolve_action_attempt = this.methods.some(
|
|
120
|
+
({ return_resource }) => return_resource === "ActionAttempt"
|
|
121
|
+
)
|
|
133
122
|
|
|
134
123
|
return [
|
|
135
124
|
`from typing import Optional, Any, List, Dict, Union`,
|
|
136
|
-
`from ..
|
|
125
|
+
`from ..client import SeamHttpClient`,
|
|
137
126
|
`from .models import (${validClasses
|
|
138
127
|
.filter((cls) => cls !== "None")
|
|
139
128
|
.join(",")})`,
|
|
@@ -147,19 +136,23 @@ export class ClassFile {
|
|
|
147
136
|
.join("\n")
|
|
148
137
|
: ""
|
|
149
138
|
}`,
|
|
150
|
-
`${
|
|
139
|
+
`${
|
|
140
|
+
should_import_resolve_action_attempt
|
|
141
|
+
? "from ..modules.action_attempts import resolve_action_attempt"
|
|
142
|
+
: ""
|
|
143
|
+
}`,
|
|
151
144
|
"",
|
|
152
145
|
`class ${this.name}(Abstract${this.name}):`,
|
|
153
146
|
// TODO DOCSTRING
|
|
154
|
-
`
|
|
155
|
-
|
|
156
|
-
`
|
|
157
|
-
` self.seam = seam`,
|
|
147
|
+
` def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):`,
|
|
148
|
+
` self.client = client`,
|
|
149
|
+
` self.defaults = defaults`,
|
|
158
150
|
`${
|
|
159
151
|
has_child_classes
|
|
160
152
|
? this.child_class_identifiers
|
|
161
153
|
.map(
|
|
162
|
-
(i) =>
|
|
154
|
+
(i) =>
|
|
155
|
+
` self._${i.namespace} = ${i.class_name}(client=client, defaults = defaults)`
|
|
163
156
|
)
|
|
164
157
|
.join("\n")
|
|
165
158
|
: ""
|
|
@@ -225,7 +218,7 @@ export class ClassFile {
|
|
|
225
218
|
),
|
|
226
219
|
"",
|
|
227
220
|
|
|
228
|
-
` ${is_none_return_type ? "" : "res = "}self.
|
|
221
|
+
` ${is_none_return_type ? "" : "res = "}self.client.post(`,
|
|
229
222
|
` "${path}",`,
|
|
230
223
|
` json=json_payload`,
|
|
231
224
|
` )`,
|
|
@@ -233,10 +226,17 @@ export class ClassFile {
|
|
|
233
226
|
|
|
234
227
|
can_method_poll_action_attempt
|
|
235
228
|
? [
|
|
236
|
-
"
|
|
237
|
-
|
|
238
|
-
|
|
229
|
+
" wait_for_action_attempt = (",
|
|
230
|
+
" self.defaults.get('wait_for_action_attempt')",
|
|
231
|
+
" if wait_for_action_attempt is None",
|
|
232
|
+
" else wait_for_action_attempt",
|
|
239
233
|
" )",
|
|
234
|
+
"",
|
|
235
|
+
" return resolve_action_attempt(",
|
|
236
|
+
` client=self.client,`,
|
|
237
|
+
` action_attempt=ActionAttempt.from_dict(res["action_attempt"]),`,
|
|
238
|
+
` wait_for_action_attempt=wait_for_action_attempt`,
|
|
239
|
+
" )",
|
|
240
240
|
].join("\n")
|
|
241
241
|
: "",
|
|
242
242
|
"",
|
|
@@ -257,7 +257,6 @@ export class ClassFile {
|
|
|
257
257
|
.join("\n")
|
|
258
258
|
}
|
|
259
259
|
),
|
|
260
|
-
is_action_attempt_class ? action_attempt_utils_definitions : "",
|
|
261
260
|
].join("\n")
|
|
262
261
|
}
|
|
263
262
|
}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import { pascalCase } from "change-case"
|
|
2
2
|
export default (namespaces: string[]) =>
|
|
3
3
|
[
|
|
4
|
+
`from typing import Any, Dict`,
|
|
5
|
+
`from ..client import SeamHttpClient`,
|
|
4
6
|
`from .models import AbstractRoutes`,
|
|
5
7
|
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`),
|
|
6
8
|
``,
|
|
7
9
|
`class Routes(AbstractRoutes):`,
|
|
8
|
-
` def __init__(self):`,
|
|
9
|
-
...namespaces.map(
|
|
10
|
+
` def __init__(self, client: SeamHttpClient, defaults: Dict[str, Any]):`,
|
|
11
|
+
...namespaces.map(
|
|
12
|
+
(ns) =>
|
|
13
|
+
` self.${ns} = ${pascalCase(ns)}(client=client, defaults=defaults)`
|
|
14
|
+
),
|
|
10
15
|
].join("\n")
|
|
@@ -1,19 +0,0 @@
|
|
|
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;
|
|
19
|
-
export declare const action_attempt_imports = "import time\nfrom ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError\n";
|
|
@@ -1,73 +0,0 @@
|
|
|
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 SeamActionAttemptTimeoutError(action_attempt, timeout)",
|
|
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 SeamActionAttemptFailedError(action_attempt)",
|
|
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
|
-
" if 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
|
-
export const action_attempt_imports = `import time
|
|
71
|
-
from ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError
|
|
72
|
-
`;
|
|
73
|
-
//# sourceMappingURL=action-attempt.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,sEAAsE;IACtE,EAAE;IACF,kDAAkD;IAClD,2FAA2F;IAC3F,SAAS;IACT,EAAE;IACF,2CAA2C;IAC3C,0DAA0D;IAC1D,EAAE;IACF,2BAA2B;IAC3B,EAAE;IACF,0JAA0J;IAC1J,uHAAuH;IACvH,EAAE;IACF,+BAA+B;IAC/B,6GAA6G;IAC7G,yCAAyC;IACzC,uNAAuN;IACvN,EAAE;IACF,2BAA2B;CAC5B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAEZ,MAAM,CAAC,MAAM,sBAAsB,GAAG;;CAErC,CAAA"}
|
|
@@ -1,74 +0,0 @@
|
|
|
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 SeamActionAttemptTimeoutError(action_attempt, timeout)",
|
|
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 SeamActionAttemptFailedError(action_attempt)",
|
|
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
|
-
" if 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")
|
|
71
|
-
|
|
72
|
-
export const action_attempt_imports = `import time
|
|
73
|
-
from ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError
|
|
74
|
-
`
|