@seamapi/nextlove-sdk-generator
Advanced tools
Comparing version 1.11.0 to 1.11.1
@@ -1,2 +0,2 @@ | ||
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, action_attempt_error_definitions, } from "./templates/utils/action-attempt.js"; | ||
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js"; | ||
export class ClassFile { | ||
@@ -65,10 +65,10 @@ constructor(name, namespace, child_class_identifiers) { | ||
return [ | ||
`from seam.types import AbstractSeam as Seam`, | ||
`from seam.routes.types import (${validClasses | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`from ..models import AbstractSeam as Seam`, | ||
`from .models 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 seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}`) | ||
.map((i) => `from .${this.namespace}_${i.namespace} import ${i.class_name}`) | ||
.join("\n") | ||
@@ -78,4 +78,2 @@ : ""}`, | ||
"", | ||
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`, | ||
"", | ||
`class ${this.name}(Abstract${this.name}):`, | ||
@@ -82,0 +80,0 @@ // TODO DOCSTRING |
@@ -6,3 +6,2 @@ 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"; | ||
@@ -97,3 +96,3 @@ import resourceDataclassTemplate from "./templates/resource-dataclass.template.js"; | ||
} | ||
fs[`seam/routes/types.py`] = [ | ||
fs[`seam/routes/models.py`] = [ | ||
`from typing import Any, Dict, List, Optional, Union`, | ||
@@ -103,3 +102,3 @@ `from typing_extensions import Self`, | ||
`from dataclasses import dataclass`, | ||
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`, | ||
`from ..utils.deep_attr_dict import DeepAttrDict`, | ||
"", | ||
@@ -124,4 +123,3 @@ "", | ||
].join("\n"); | ||
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces); | ||
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate(); | ||
fs["seam/routes/__init__.py"] = routesPyTemplate(top_level_namespaces); | ||
return fs; | ||
@@ -128,0 +126,0 @@ }; |
import { pascalCase } from "change-case"; | ||
export default (namespaces) => [ | ||
`from .types import AbstractRoutes`, | ||
`from .models import AbstractRoutes`, | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`), | ||
@@ -5,0 +5,0 @@ ``, |
@@ -19,3 +19,2 @@ export declare const action_attempt_utils_specs: { | ||
export declare const action_attempt_utils_definitions: string; | ||
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"; | ||
export declare const action_attempt_imports = "import time\nfrom ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError\n"; |
@@ -70,23 +70,5 @@ export const action_attempt_utils_specs = [ | ||
].join("\n"); | ||
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__ | ||
export const action_attempt_imports = `import time | ||
from ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError | ||
`; | ||
//# sourceMappingURL=action-attempt.js.map |
{ | ||
"name": "@seamapi/nextlove-sdk-generator", | ||
"version": "1.11.0", | ||
"version": "1.11.1", | ||
"description": "Utilities for building NextLove SDK Generators", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -5,3 +5,2 @@ import { | ||
action_attempt_utils_specs, | ||
action_attempt_error_definitions, | ||
} from "./templates/utils/action-attempt.js" | ||
@@ -137,7 +136,7 @@ | ||
return [ | ||
`from seam.types import AbstractSeam as Seam`, | ||
`from seam.routes.types import (${validClasses | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`from ..models import AbstractSeam as Seam`, | ||
`from .models import (${validClasses | ||
.filter((cls) => cls !== "None") | ||
.join(",")})`, | ||
`from typing import Optional, Any, List, Dict, Union`, | ||
`${ | ||
@@ -148,3 +147,3 @@ has_child_classes | ||
(i) => | ||
`from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}` | ||
`from .${this.namespace}_${i.namespace} import ${i.class_name}` | ||
) | ||
@@ -156,4 +155,2 @@ .join("\n") | ||
"", | ||
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`, | ||
"", | ||
`class ${this.name}(Abstract${this.name}):`, | ||
@@ -160,0 +157,0 @@ // TODO DOCSTRING |
@@ -7,3 +7,2 @@ 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" | ||
@@ -129,3 +128,3 @@ import resourceDataclassTemplate from "./templates/resource-dataclass.template.js" | ||
fs[`seam/routes/types.py`] = [ | ||
fs[`seam/routes/models.py`] = [ | ||
`from typing import Any, Dict, List, Optional, Union`, | ||
@@ -135,3 +134,3 @@ `from typing_extensions import Self`, | ||
`from dataclasses import dataclass`, | ||
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`, | ||
`from ..utils.deep_attr_dict import DeepAttrDict`, | ||
"", | ||
@@ -167,4 +166,3 @@ "", | ||
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces) | ||
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate() | ||
fs["seam/routes/__init__.py"] = routesPyTemplate(top_level_namespaces) | ||
@@ -171,0 +169,0 @@ return fs |
import { pascalCase } from "change-case" | ||
export default (namespaces: string[]) => | ||
[ | ||
`from .types import AbstractRoutes`, | ||
`from .models import AbstractRoutes`, | ||
...namespaces.map((ns) => `from .${ns} import ${pascalCase(ns)}`), | ||
@@ -6,0 +6,0 @@ ``, |
@@ -72,23 +72,4 @@ export const action_attempt_utils_specs = [ | ||
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__ | ||
export const action_attempt_imports = `import time | ||
from ..exceptions import SeamActionAttemptFailedError, SeamActionAttemptTimeoutError | ||
` |
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
694533
327
9248