@seamapi/nextlove-sdk-generator
Advanced tools
Comparing version 1.11.2 to 1.11.3
@@ -1,2 +0,2 @@ | ||
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js"; | ||
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, action_attempt_error_definitions, } from "./templates/utils/action-attempt.js"; | ||
export class ClassFile { | ||
@@ -65,10 +65,10 @@ constructor(name, namespace, child_class_identifiers) { | ||
return [ | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`from ..models import AbstractSeam as Seam`, | ||
`from .models import (${validClasses | ||
`from seam.types import AbstractSeam as Seam`, | ||
`from seam.routes.types import (${validClasses | ||
.filter((cls) => cls !== "None") | ||
.join(",")})`, | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`${has_child_classes | ||
? this.child_class_identifiers | ||
.map((i) => `from .${this.namespace}_${i.namespace} import ${i.class_name}`) | ||
.map((i) => `from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}`) | ||
.join("\n") | ||
@@ -78,2 +78,4 @@ : ""}`, | ||
"", | ||
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`, | ||
"", | ||
`class ${this.name}(Abstract${this.name}):`, | ||
@@ -80,0 +82,0 @@ // TODO DOCSTRING |
@@ -6,2 +6,3 @@ import { ClassFile } from "./class-file.js"; | ||
import { mapPythonType } from "./map-python-type.js"; | ||
import deepAttrDictPyTemplate from "./templates/utils/deep_attr_dict.py.template.js"; | ||
import abstractRoutesTemplate from "./templates/abstract-routes.template.js"; | ||
@@ -96,3 +97,3 @@ import resourceDataclassTemplate from "./templates/resource-dataclass.template.js"; | ||
} | ||
fs[`seam/routes/models.py`] = [ | ||
fs[`seam/routes/types.py`] = [ | ||
`from typing import Any, Dict, List, Optional, Union`, | ||
@@ -102,3 +103,3 @@ `from typing_extensions import Self`, | ||
`from dataclasses import dataclass`, | ||
`from ..utils.deep_attr_dict import DeepAttrDict`, | ||
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`, | ||
"", | ||
@@ -123,3 +124,4 @@ "", | ||
].join("\n"); | ||
fs["seam/routes/__init__.py"] = routesPyTemplate(top_level_namespaces); | ||
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces); | ||
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate(); | ||
return fs; | ||
@@ -126,0 +128,0 @@ }; |
import { pascalCase } from "change-case"; | ||
export default (namespaces) => [ | ||
`from .models import AbstractRoutes`, | ||
`from .types import AbstractRoutes`, | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`), | ||
@@ -5,0 +5,0 @@ ``, |
@@ -19,2 +19,3 @@ export declare const action_attempt_utils_specs: { | ||
export declare const action_attempt_utils_definitions: string; | ||
export declare const action_attempt_imports = "import time\nfrom ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError\n"; | ||
export declare const action_attempt_imports = "import time\n"; | ||
export declare const action_attempt_error_definitions = "class SeamActionAttemptError(Exception):\n def __init__(self, message: str, action_attempt: ActionAttempt):\n super().__init__(message)\n self.name = self.__class__.__name__\n self.action_attempt = action_attempt\n\n\nclass SeamActionAttemptFailedError(SeamActionAttemptError):\n def __init__(self, action_attempt: ActionAttempt):\n super().__init__(action_attempt.error.message, action_attempt)\n self.name = self.__class__.__name__\n self.code = action_attempt.error.type\n\n\nclass SeamActionAttemptTimeoutError(SeamActionAttemptError):\n def __init__(self, action_attempt: ActionAttempt, timeout: str):\n message = f\"Timed out waiting for action attempt after {timeout}s\"\n super().__init__(message, action_attempt)\n self.name = self.__class__.__name__\n"; |
@@ -70,5 +70,23 @@ export const action_attempt_utils_specs = [ | ||
].join("\n"); | ||
export const action_attempt_imports = `import time | ||
from ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError | ||
export const action_attempt_imports = `import time\n`; | ||
export const action_attempt_error_definitions = `class SeamActionAttemptError(Exception): | ||
def __init__(self, message: str, action_attempt: ActionAttempt): | ||
super().__init__(message) | ||
self.name = self.__class__.__name__ | ||
self.action_attempt = action_attempt | ||
class SeamActionAttemptFailedError(SeamActionAttemptError): | ||
def __init__(self, action_attempt: ActionAttempt): | ||
super().__init__(action_attempt.error.message, action_attempt) | ||
self.name = self.__class__.__name__ | ||
self.code = action_attempt.error.type | ||
class SeamActionAttemptTimeoutError(SeamActionAttemptError): | ||
def __init__(self, action_attempt: ActionAttempt, timeout: str): | ||
message = f"Timed out waiting for action attempt after {timeout}s" | ||
super().__init__(message, action_attempt) | ||
self.name = self.__class__.__name__ | ||
`; | ||
//# sourceMappingURL=action-attempt.js.map |
{ | ||
"name": "@seamapi/nextlove-sdk-generator", | ||
"version": "1.11.2", | ||
"version": "1.11.3", | ||
"description": "Utilities for building NextLove SDK Generators", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -5,2 +5,3 @@ import { | ||
action_attempt_utils_specs, | ||
action_attempt_error_definitions, | ||
} from "./templates/utils/action-attempt.js" | ||
@@ -136,7 +137,7 @@ | ||
return [ | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`from ..models import AbstractSeam as Seam`, | ||
`from .models import (${validClasses | ||
`from seam.types import AbstractSeam as Seam`, | ||
`from seam.routes.types import (${validClasses | ||
.filter((cls) => cls !== "None") | ||
.join(",")})`, | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`${ | ||
@@ -147,3 +148,3 @@ has_child_classes | ||
(i) => | ||
`from .${this.namespace}_${i.namespace} import ${i.class_name}` | ||
`from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}` | ||
) | ||
@@ -155,2 +156,4 @@ .join("\n") | ||
"", | ||
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`, | ||
"", | ||
`class ${this.name}(Abstract${this.name}):`, | ||
@@ -157,0 +160,0 @@ // TODO DOCSTRING |
@@ -7,2 +7,3 @@ import type { ObjSchema, Route, SdkGeneratorOptions } from "lib/types.js" | ||
import { mapPythonType } from "./map-python-type.js" | ||
import deepAttrDictPyTemplate from "./templates/utils/deep_attr_dict.py.template.js" | ||
import abstractRoutesTemplate from "./templates/abstract-routes.template.js" | ||
@@ -128,3 +129,3 @@ import resourceDataclassTemplate from "./templates/resource-dataclass.template.js" | ||
fs[`seam/routes/models.py`] = [ | ||
fs[`seam/routes/types.py`] = [ | ||
`from typing import Any, Dict, List, Optional, Union`, | ||
@@ -134,3 +135,3 @@ `from typing_extensions import Self`, | ||
`from dataclasses import dataclass`, | ||
`from ..utils.deep_attr_dict import DeepAttrDict`, | ||
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`, | ||
"", | ||
@@ -166,3 +167,4 @@ "", | ||
fs["seam/routes/__init__.py"] = routesPyTemplate(top_level_namespaces) | ||
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces) | ||
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate() | ||
@@ -169,0 +171,0 @@ return fs |
import { pascalCase } from "change-case" | ||
export default (namespaces: string[]) => | ||
[ | ||
`from .models import AbstractRoutes`, | ||
`from .types import AbstractRoutes`, | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`), | ||
@@ -6,0 +6,0 @@ ``, |
@@ -72,4 +72,23 @@ export const action_attempt_utils_specs = [ | ||
export const action_attempt_imports = `import time | ||
from ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError | ||
export const action_attempt_imports = `import time\n` | ||
export const action_attempt_error_definitions = `class SeamActionAttemptError(Exception): | ||
def __init__(self, message: str, action_attempt: ActionAttempt): | ||
super().__init__(message) | ||
self.name = self.__class__.__name__ | ||
self.action_attempt = action_attempt | ||
class SeamActionAttemptFailedError(SeamActionAttemptError): | ||
def __init__(self, action_attempt: ActionAttempt): | ||
super().__init__(action_attempt.error.message, action_attempt) | ||
self.name = self.__class__.__name__ | ||
self.code = action_attempt.error.type | ||
class SeamActionAttemptTimeoutError(SeamActionAttemptError): | ||
def __init__(self, action_attempt: ActionAttempt, timeout: str): | ||
message = f"Timed out waiting for action attempt after {timeout}s" | ||
super().__init__(message, action_attempt) | ||
self.name = self.__class__.__name__ | ||
` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
699837
331
9334