@seamapi/nextlove-sdk-generator 1.10.5 → 1.11.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 +10 -6
- package/lib/generate-python-sdk/class-file.js.map +1 -1
- package/lib/generate-python-sdk/generate-python-sdk.js +7 -39
- package/lib/generate-python-sdk/generate-python-sdk.js.map +1 -1
- package/lib/generate-python-sdk/templates/abstract-routes.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/resource-dataclass.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/utils/action-attempt.d.ts +2 -1
- package/lib/generate-python-sdk/templates/utils/action-attempt.js +19 -5
- package/lib/generate-python-sdk/templates/utils/action-attempt.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/generate-python-sdk/class-file.ts +10 -6
- package/src/lib/generate-python-sdk/generate-python-sdk.ts +7 -41
- package/src/lib/generate-python-sdk/templates/utils/action-attempt.ts +20 -5
- package/lib/generate-python-sdk/templates/.gitignore.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/.gitignore.template.js +0 -11
- package/lib/generate-python-sdk/templates/.gitignore.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/__init__.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/__init__.py.template.js +0 -13
- package/lib/generate-python-sdk/templates/__init__.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/auth.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/auth.py.template.js +0 -103
- package/lib/generate-python-sdk/templates/auth.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/conftest.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/conftest.py.template.js +0 -14
- package/lib/generate-python-sdk/templates/conftest.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/options.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/options.py.template.js +0 -68
- package/lib/generate-python-sdk/templates/options.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/parse_options.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/parse_options.py.template.js +0 -28
- package/lib/generate-python-sdk/templates/parse_options.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/pyproject.toml.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/pyproject.toml.template.js +0 -22
- package/lib/generate-python-sdk/templates/pyproject.toml.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/readme.md.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/readme.md.template.js +0 -48
- package/lib/generate-python-sdk/templates/readme.md.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/seam.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/seam.py.template.js +0 -118
- package/lib/generate-python-sdk/templates/seam.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +0 -44
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.js +0 -17
- package/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/test_smoke.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/test_smoke.py.template.js +0 -13
- package/lib/generate-python-sdk/templates/test_smoke.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/token.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/token.py.template.js +0 -49
- package/lib/generate-python-sdk/templates/token.py.template.js.map +0 -1
- package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.d.ts +0 -2
- package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.js +0 -24
- package/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.js.map +0 -1
- package/src/lib/generate-python-sdk/templates/.gitignore.template.ts +0 -10
- package/src/lib/generate-python-sdk/templates/__init__.py.template.ts +0 -12
- package/src/lib/generate-python-sdk/templates/auth.py.template.ts +0 -102
- package/src/lib/generate-python-sdk/templates/conftest.py.template.ts +0 -13
- package/src/lib/generate-python-sdk/templates/options.py.template.ts +0 -67
- package/src/lib/generate-python-sdk/templates/parse_options.py.template.ts +0 -27
- package/src/lib/generate-python-sdk/templates/pyproject.toml.template.ts +0 -21
- package/src/lib/generate-python-sdk/templates/readme.md.template.ts +0 -47
- package/src/lib/generate-python-sdk/templates/seam.py.template.ts +0 -117
- package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +0 -43
- package/src/lib/generate-python-sdk/templates/snippets/seam-api-exception-class.template.ts +0 -16
- package/src/lib/generate-python-sdk/templates/test_smoke.py.template.ts +0 -12
- package/src/lib/generate-python-sdk/templates/token.py.template.ts +0 -48
- package/src/lib/generate-python-sdk/templates/utils/action_attempt_errors.py.template.ts +0 -23
- /package/lib/generate-python-sdk/templates/{snippets/abstract-routes.template.d.ts → abstract-routes.template.d.ts} +0 -0
- /package/lib/generate-python-sdk/templates/{snippets/abstract-routes.template.js → abstract-routes.template.js} +0 -0
- /package/lib/generate-python-sdk/templates/{snippets/resource-dataclass.template.d.ts → resource-dataclass.template.d.ts} +0 -0
- /package/lib/generate-python-sdk/templates/{snippets/resource-dataclass.template.js → resource-dataclass.template.js} +0 -0
- /package/src/lib/generate-python-sdk/templates/{snippets/abstract-routes.template.ts → abstract-routes.template.ts} +0 -0
- /package/src/lib/generate-python-sdk/templates/{snippets/resource-dataclass.template.ts → resource-dataclass.template.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, } from "./templates/utils/action-attempt.js";
|
|
1
|
+
import { action_attempt_imports, action_attempt_utils_definitions, action_attempt_utils_specs, action_attempt_error_definitions, } from "./templates/utils/action-attempt.js";
|
|
2
2
|
export class ClassFile {
|
|
3
3
|
constructor(name, namespace, child_class_identifiers) {
|
|
4
4
|
this.name = name;
|
|
@@ -57,21 +57,25 @@ export class ClassFile {
|
|
|
57
57
|
serializeToClass() {
|
|
58
58
|
const validClasses = [
|
|
59
59
|
`Abstract${this.name}`,
|
|
60
|
-
`AbstractSeam as Seam`,
|
|
61
60
|
...Array.from(new Set(this.methods.map((m) => m.return_resource.replace(/^List\[/, "").replace(/\]$/, "")))),
|
|
62
61
|
].filter((classInstance) => classInstance !== "");
|
|
63
62
|
const has_child_classes = this.child_class_identifiers.length > 0;
|
|
63
|
+
const is_action_attempt_class = this.name === "ActionAttempts";
|
|
64
64
|
return [
|
|
65
|
-
`from seam.types import
|
|
65
|
+
`from seam.types import AbstractSeam as Seam`,
|
|
66
|
+
`from seam.routes.types import (${validClasses
|
|
66
67
|
.filter((cls) => cls !== "None")
|
|
67
68
|
.join(",")})`,
|
|
68
69
|
`from typing import Optional, Any, List, Dict, Union`,
|
|
69
70
|
`${has_child_classes
|
|
70
71
|
? this.child_class_identifiers
|
|
71
|
-
.map((i) => `from seam.${this.namespace}_${i.namespace} import ${i.class_name}`)
|
|
72
|
+
.map((i) => `from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}`)
|
|
72
73
|
.join("\n")
|
|
73
74
|
: ""}`,
|
|
74
|
-
`${
|
|
75
|
+
`${is_action_attempt_class ? action_attempt_imports : ""}`,
|
|
76
|
+
"",
|
|
77
|
+
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`,
|
|
78
|
+
"",
|
|
75
79
|
`class ${this.name}(Abstract${this.name}):`,
|
|
76
80
|
// TODO DOCSTRING
|
|
77
81
|
` seam: Seam`,
|
|
@@ -147,7 +151,7 @@ export class ClassFile {
|
|
|
147
151
|
.map((s) => ` ${s}`)
|
|
148
152
|
.join("\n");
|
|
149
153
|
}),
|
|
150
|
-
|
|
154
|
+
is_action_attempt_class ? action_attempt_utils_definitions : "",
|
|
151
155
|
].join("\n");
|
|
152
156
|
}
|
|
153
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"class-file.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/class-file.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,0BAA0B,
|
|
1
|
+
{"version":3,"file":"class-file.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/class-file.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,gCAAgC,EAChC,0BAA0B,EAC1B,gCAAgC,GACjC,MAAM,qCAAqC,CAAA;AA+B5C,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,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE;YACzC,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,CAA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,mBAAmB,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,yBAAyB;oBACjE,aAAa;oBACb,QAAQ,IAAI,IAAI;oBAChB,uBAAuB;oBACvB,KAAK;oBACL,EAAE;oBAEF,8BAA8B;wBAC5B,CAAC,CAAC;4BACE,qDAAqD;4BACrD,oEAAoE;4BACpE,qDAAqD;4BACrD,KAAK;yBACN,CAAC,IAAI,CAAC,IAAI,CAAC;wBACd,CAAC,CAAC,EAAE;oBACN,EAAE;oBAEF,CAAC,8BAA8B;wBAC7B,CAAC,CAAC,mBAAmB;4BACnB,CAAC,CAAC,eAAe;4BACjB,CAAC,CAAC,uBAAuB;gCACzB,CAAC,CAAC,aAAa,oBAAoB,qCAAqC,WAAW,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,uBAAuB,CAAC,CAAC,CAAC,gCAAgC,CAAC,CAAC,CAAC,EAAE;SAChE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACd,CAAC;CACF"}
|
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { ClassFile } from "./class-file.js";
|
|
2
2
|
import { pascalCase } from "change-case";
|
|
3
3
|
import { flattenObjSchema } from "../../lib/openapi/index.js";
|
|
4
|
-
import conftestPyTemplate from "./templates/conftest.py.template.js";
|
|
5
4
|
import routesPyTemplate from "./templates/routes.py.template.js";
|
|
6
|
-
import seamPyTemplate from "./templates/seam.py.template.js";
|
|
7
|
-
import test_smokePyTemplate from "./templates/test_smoke.py.template.js";
|
|
8
|
-
import pyprojectTomlTemplate from "./templates/pyproject.toml.template.js";
|
|
9
5
|
import { mapPythonType } from "./map-python-type.js";
|
|
10
6
|
import deepAttrDictPyTemplate from "./templates/utils/deep_attr_dict.py.template.js";
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import abstractSeamTemplate from "./templates/snippets/abstract-seam.template.js";
|
|
14
|
-
import resourceDataclassTemplate from "./templates/snippets/resource-dataclass.template.js";
|
|
15
|
-
import readmeMdTemplate from "./templates/readme.md.template.js";
|
|
16
|
-
import initTemplate from "./templates/__init__.py.template.js";
|
|
17
|
-
import gitignoreTemplate from "./templates/.gitignore.template.js";
|
|
18
|
-
import SeamApiExceptionClassTemplate from "./templates/snippets/seam-api-exception-class.template.js";
|
|
19
|
-
import authPyTemplate from "./templates/auth.py.template.js";
|
|
20
|
-
import parseOptionsPyTemplate from "./templates/parse_options.py.template.js";
|
|
21
|
-
import optionsPyTemplate from "./templates/options.py.template.js";
|
|
22
|
-
import tokenPyTemplate from "./templates/token.py.template.js";
|
|
7
|
+
import abstractRoutesTemplate from "./templates/abstract-routes.template.js";
|
|
8
|
+
import resourceDataclassTemplate from "./templates/resource-dataclass.template.js";
|
|
23
9
|
import { getParameterAndResponseSchema } from "../../lib/openapi/get-parameter-and-response-schema.js";
|
|
24
10
|
import mapParentToChildResources from "../../lib/openapi/map-parent-to-children-resource.js";
|
|
25
11
|
import { deepFlattenOneOfAndAllOfSchema } from "../../lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.js";
|
|
@@ -105,14 +91,14 @@ export const generatePythonSDK = async (options = {}) => {
|
|
|
105
91
|
.map((ns) => (ns.length === 1 ? ns[0] : null))
|
|
106
92
|
.filter(Boolean);
|
|
107
93
|
for (const [_, cls] of Object.entries(class_map)) {
|
|
108
|
-
fs[`seam/${cls.namespace}.py`] = cls.serializeToClass();
|
|
94
|
+
fs[`seam/routes/${cls.namespace}.py`] = cls.serializeToClass();
|
|
109
95
|
}
|
|
110
|
-
fs[`seam/types.py`] = [
|
|
96
|
+
fs[`seam/routes/types.py`] = [
|
|
111
97
|
`from typing import Any, Dict, List, Optional, Union`,
|
|
112
98
|
`from typing_extensions import Self`,
|
|
113
99
|
`import abc`,
|
|
114
100
|
`from dataclasses import dataclass`,
|
|
115
|
-
`from seam.utils.deep_attr_dict import DeepAttrDict`,
|
|
101
|
+
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`,
|
|
116
102
|
"",
|
|
117
103
|
"",
|
|
118
104
|
...Object.entries(openapi.components.schemas)
|
|
@@ -123,9 +109,6 @@ export const generatePythonSDK = async (options = {}) => {
|
|
|
123
109
|
})))),
|
|
124
110
|
"",
|
|
125
111
|
"",
|
|
126
|
-
SeamApiExceptionClassTemplate(),
|
|
127
|
-
"",
|
|
128
|
-
"",
|
|
129
112
|
...Object.entries(class_map)
|
|
130
113
|
.sort(
|
|
131
114
|
// define classes without children first for parent-child referencing
|
|
@@ -134,24 +117,9 @@ export const generatePythonSDK = async (options = {}) => {
|
|
|
134
117
|
"",
|
|
135
118
|
"",
|
|
136
119
|
abstractRoutesTemplate(top_level_namespaces),
|
|
137
|
-
"",
|
|
138
|
-
abstractSeamTemplate(),
|
|
139
120
|
].join("\n");
|
|
140
|
-
fs["
|
|
141
|
-
fs["
|
|
142
|
-
fs[".gitignore"] = gitignoreTemplate();
|
|
143
|
-
fs["seam/__init__.py"] = initTemplate();
|
|
144
|
-
fs["seam/routes.py"] = routesPyTemplate(top_level_namespaces);
|
|
145
|
-
fs["seam/seam.py"] = seamPyTemplate();
|
|
146
|
-
fs["seam/auth.py"] = authPyTemplate();
|
|
147
|
-
fs["seam/token.py"] = tokenPyTemplate();
|
|
148
|
-
fs["seam/options.py"] = optionsPyTemplate();
|
|
149
|
-
fs["seam/parse_options.py"] = parseOptionsPyTemplate();
|
|
150
|
-
fs["seam/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate();
|
|
151
|
-
fs["seam/utils/action_attempt_errors.py"] = actionAttemptsErrorsPyTemplate();
|
|
152
|
-
fs["tests/conftest.py"] = conftestPyTemplate();
|
|
153
|
-
fs["tests/test_smoke.py"] = test_smokePyTemplate();
|
|
154
|
-
fs["tests/__init__.py"] = "";
|
|
121
|
+
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces);
|
|
122
|
+
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate();
|
|
155
123
|
return fs;
|
|
156
124
|
};
|
|
157
125
|
function determineReturnResource({ route_path, response_arr_type, response_obj_type, }) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-python-sdk.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/generate-python-sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,
|
|
1
|
+
{"version":3,"file":"generate-python-sdk.js","sourceRoot":"","sources":["../../src/lib/generate-python-sdk/generate-python-sdk.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,gBAAgB,MAAM,mCAAmC,CAAA;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAA;AACpD,OAAO,sBAAsB,MAAM,iDAAiD,CAAA;AACpF,OAAO,sBAAsB,MAAM,yCAAyC,CAAA;AAC5E,OAAO,yBAAyB,MAAM,4CAA4C,CAAA;AAClF,OAAO,EAAE,6BAA6B,EAAE,MAAM,kDAAkD,CAAA;AAChG,OAAO,yBAAyB,MAAM,gDAAgD,CAAA;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,qEAAqE,CAAA;AACpH,OAAO,EACL,6CAA6C,EAC7C,sBAAsB,GACvB,MAAM,uBAAu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;KAC7C,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAEZ,EAAE,CAAC,uBAAuB,CAAC,GAAG,gBAAgB,CAAC,oBAAoB,CAAC,CAAA;IACpE,EAAE,CAAC,qCAAqC,CAAC,GAAG,sBAAsB,EAAE,CAAA;IAEpE,OAAO,EAAE,CAAA;AACX,CAAC,CAAA;AAED,SAAS,uBAAuB,CAAC,EAC/B,UAAU,EACV,iBAAiB,EACjB,iBAAiB,GAKlB;IACC,IAAI,6CAA6C,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACtE,OAAO,MAAM,CAAA;KACd;IAED,IAAI,iBAAiB,EAAE;QACrB,OAAO,UAAU,CAAC,iBAAiB,CAAC,CAAA;KACrC;IAED,IAAI,iBAAiB,EAAE;QACrB,OAAO,QAAQ,UAAU,CAAC,iBAAiB,CAAC,GAAG,CAAA;KAChD;IAED,OAAO,MAAM,CAAA;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"abstract-routes.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/abstract-routes.template.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAExC,eAAe,CAAC,UAAoB,EAAE,EAAE,CAAC;;EAEvC,UAAU,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,aAAa,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CACxE,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-dataclass.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/resource-dataclass.template.ts"],"names":[],"mappings":"AAAA,eAAe,CACb,IAAY,EACZ,UAGE,EACF,EAAE,CAAC;QACG,IAAI;EACV,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;;;;aAI/C,IAAI;EACf,UAAU;KACT,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;IACT,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAA;IAE1E,OAAO,SAAS,CAAC,CAAC,IAAI,IAAI,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,UAC5D,CAAC,CAAC,IACJ,WAAW,aAAa,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAA;AACxC,CAAC,CAAC;KACD,IAAI,CAAC,IAAI,CAAC;QACL,CAAA"}
|
|
@@ -16,4 +16,5 @@ export declare const action_attempt_utils_specs: {
|
|
|
16
16
|
path: string;
|
|
17
17
|
}[];
|
|
18
18
|
export declare const action_attempt_utils_definitions: string;
|
|
19
|
-
export declare const action_attempt_imports = "import time\n
|
|
19
|
+
export declare const action_attempt_imports = "import time\n";
|
|
20
|
+
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";
|
|
@@ -67,11 +67,25 @@ export const action_attempt_utils_definitions = [
|
|
|
67
67
|
"",
|
|
68
68
|
" return action_attempt",
|
|
69
69
|
].join("\n");
|
|
70
|
-
export const action_attempt_imports = `import time
|
|
70
|
+
export const action_attempt_imports = `import time\n`;
|
|
71
|
+
export const action_attempt_error_definitions = `class SeamActionAttemptError(Exception):
|
|
72
|
+
def __init__(self, message: str, action_attempt: ActionAttempt):
|
|
73
|
+
super().__init__(message)
|
|
74
|
+
self.name = self.__class__.__name__
|
|
75
|
+
self.action_attempt = action_attempt
|
|
71
76
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
)
|
|
77
|
+
|
|
78
|
+
class SeamActionAttemptFailedError(SeamActionAttemptError):
|
|
79
|
+
def __init__(self, action_attempt: ActionAttempt):
|
|
80
|
+
super().__init__(action_attempt.error.message, action_attempt)
|
|
81
|
+
self.name = self.__class__.__name__
|
|
82
|
+
self.code = action_attempt.error.type
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class SeamActionAttemptTimeoutError(SeamActionAttemptError):
|
|
86
|
+
def __init__(self, action_attempt: ActionAttempt, timeout: str):
|
|
87
|
+
message = f"Timed out waiting for action attempt after {timeout}s"
|
|
88
|
+
super().__init__(message, action_attempt)
|
|
89
|
+
self.name = self.__class__.__name__
|
|
76
90
|
`;
|
|
77
91
|
//# sourceMappingURL=action-attempt.js.map
|
|
@@ -1 +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,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
|
|
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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ED
|
@@ -2,6 +2,7 @@ import {
|
|
|
2
2
|
action_attempt_imports,
|
|
3
3
|
action_attempt_utils_definitions,
|
|
4
4
|
action_attempt_utils_specs,
|
|
5
|
+
action_attempt_error_definitions,
|
|
5
6
|
} from "./templates/utils/action-attempt.js"
|
|
6
7
|
|
|
7
8
|
export type ClassFileMethodBase = {
|
|
@@ -120,7 +121,6 @@ export class ClassFile {
|
|
|
120
121
|
serializeToClass(): string {
|
|
121
122
|
const validClasses = [
|
|
122
123
|
`Abstract${this.name}`,
|
|
123
|
-
`AbstractSeam as Seam`,
|
|
124
124
|
...Array.from(
|
|
125
125
|
new Set(
|
|
126
126
|
this.methods.map((m) =>
|
|
@@ -130,9 +130,11 @@ export class ClassFile {
|
|
|
130
130
|
),
|
|
131
131
|
].filter((classInstance) => classInstance !== "")
|
|
132
132
|
const has_child_classes = this.child_class_identifiers.length > 0
|
|
133
|
+
const is_action_attempt_class = this.name === "ActionAttempts"
|
|
133
134
|
|
|
134
135
|
return [
|
|
135
|
-
`from seam.types import
|
|
136
|
+
`from seam.types import AbstractSeam as Seam`,
|
|
137
|
+
`from seam.routes.types import (${validClasses
|
|
136
138
|
.filter((cls) => cls !== "None")
|
|
137
139
|
.join(",")})`,
|
|
138
140
|
`from typing import Optional, Any, List, Dict, Union`,
|
|
@@ -141,13 +143,15 @@ export class ClassFile {
|
|
|
141
143
|
? this.child_class_identifiers
|
|
142
144
|
.map(
|
|
143
145
|
(i) =>
|
|
144
|
-
`from seam.${this.namespace}_${i.namespace} import ${i.class_name}`
|
|
146
|
+
`from seam.routes.${this.namespace}_${i.namespace} import ${i.class_name}`
|
|
145
147
|
)
|
|
146
148
|
.join("\n")
|
|
147
149
|
: ""
|
|
148
150
|
}`,
|
|
149
|
-
`${
|
|
150
|
-
|
|
151
|
+
`${is_action_attempt_class ? action_attempt_imports : ""}`,
|
|
152
|
+
"",
|
|
153
|
+
`${is_action_attempt_class ? action_attempt_error_definitions : ""}`,
|
|
154
|
+
"",
|
|
151
155
|
`class ${this.name}(Abstract${this.name}):`,
|
|
152
156
|
// TODO DOCSTRING
|
|
153
157
|
` seam: Seam`,
|
|
@@ -257,7 +261,7 @@ export class ClassFile {
|
|
|
257
261
|
.join("\n")
|
|
258
262
|
}
|
|
259
263
|
),
|
|
260
|
-
|
|
264
|
+
is_action_attempt_class ? action_attempt_utils_definitions : "",
|
|
261
265
|
].join("\n")
|
|
262
266
|
}
|
|
263
267
|
}
|
|
@@ -2,25 +2,11 @@ import type { ObjSchema, Route, SdkGeneratorOptions } from "lib/types.js"
|
|
|
2
2
|
import { ClassFile } from "./class-file.js"
|
|
3
3
|
import { pascalCase } from "change-case"
|
|
4
4
|
import { flattenObjSchema } from "lib/openapi/index.js"
|
|
5
|
-
import conftestPyTemplate from "./templates/conftest.py.template.js"
|
|
6
5
|
import routesPyTemplate from "./templates/routes.py.template.js"
|
|
7
|
-
import seamPyTemplate from "./templates/seam.py.template.js"
|
|
8
|
-
import test_smokePyTemplate from "./templates/test_smoke.py.template.js"
|
|
9
|
-
import pyprojectTomlTemplate from "./templates/pyproject.toml.template.js"
|
|
10
6
|
import { mapPythonType } from "./map-python-type.js"
|
|
11
7
|
import deepAttrDictPyTemplate from "./templates/utils/deep_attr_dict.py.template.js"
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import abstractSeamTemplate from "./templates/snippets/abstract-seam.template.js"
|
|
15
|
-
import resourceDataclassTemplate from "./templates/snippets/resource-dataclass.template.js"
|
|
16
|
-
import readmeMdTemplate from "./templates/readme.md.template.js"
|
|
17
|
-
import initTemplate from "./templates/__init__.py.template.js"
|
|
18
|
-
import gitignoreTemplate from "./templates/.gitignore.template.js"
|
|
19
|
-
import SeamApiExceptionClassTemplate from "./templates/snippets/seam-api-exception-class.template.js"
|
|
20
|
-
import authPyTemplate from "./templates/auth.py.template.js"
|
|
21
|
-
import parseOptionsPyTemplate from "./templates/parse_options.py.template.js"
|
|
22
|
-
import optionsPyTemplate from "./templates/options.py.template.js"
|
|
23
|
-
import tokenPyTemplate from "./templates/token.py.template.js"
|
|
8
|
+
import abstractRoutesTemplate from "./templates/abstract-routes.template.js"
|
|
9
|
+
import resourceDataclassTemplate from "./templates/resource-dataclass.template.js"
|
|
24
10
|
import { getParameterAndResponseSchema } from "lib/openapi/get-parameter-and-response-schema.js"
|
|
25
11
|
import mapParentToChildResources from "lib/openapi/map-parent-to-children-resource.js"
|
|
26
12
|
import { deepFlattenOneOfAndAllOfSchema } from "lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.js"
|
|
@@ -136,15 +122,15 @@ export const generatePythonSDK = async (options: SdkGeneratorOptions = {}) => {
|
|
|
136
122
|
.filter<string>(Boolean as any)
|
|
137
123
|
|
|
138
124
|
for (const [_, cls] of Object.entries(class_map)) {
|
|
139
|
-
fs[`seam/${cls.namespace}.py`] = cls.serializeToClass()
|
|
125
|
+
fs[`seam/routes/${cls.namespace}.py`] = cls.serializeToClass()
|
|
140
126
|
}
|
|
141
127
|
|
|
142
|
-
fs[`seam/types.py`] = [
|
|
128
|
+
fs[`seam/routes/types.py`] = [
|
|
143
129
|
`from typing import Any, Dict, List, Optional, Union`,
|
|
144
130
|
`from typing_extensions import Self`,
|
|
145
131
|
`import abc`,
|
|
146
132
|
`from dataclasses import dataclass`,
|
|
147
|
-
`from seam.utils.deep_attr_dict import DeepAttrDict`,
|
|
133
|
+
`from seam.routes.utils.deep_attr_dict import DeepAttrDict`,
|
|
148
134
|
"",
|
|
149
135
|
"",
|
|
150
136
|
...Object.entries(openapi.components.schemas)
|
|
@@ -163,9 +149,6 @@ export const generatePythonSDK = async (options: SdkGeneratorOptions = {}) => {
|
|
|
163
149
|
),
|
|
164
150
|
"",
|
|
165
151
|
"",
|
|
166
|
-
SeamApiExceptionClassTemplate(),
|
|
167
|
-
"",
|
|
168
|
-
"",
|
|
169
152
|
...Object.entries(class_map)
|
|
170
153
|
.sort(
|
|
171
154
|
// define classes without children first for parent-child referencing
|
|
@@ -176,27 +159,10 @@ export const generatePythonSDK = async (options: SdkGeneratorOptions = {}) => {
|
|
|
176
159
|
"",
|
|
177
160
|
"",
|
|
178
161
|
abstractRoutesTemplate(top_level_namespaces),
|
|
179
|
-
"",
|
|
180
|
-
abstractSeamTemplate(),
|
|
181
162
|
].join("\n")
|
|
182
163
|
|
|
183
|
-
fs["
|
|
184
|
-
fs["
|
|
185
|
-
fs[".gitignore"] = gitignoreTemplate()
|
|
186
|
-
|
|
187
|
-
fs["seam/__init__.py"] = initTemplate()
|
|
188
|
-
fs["seam/routes.py"] = routesPyTemplate(top_level_namespaces)
|
|
189
|
-
fs["seam/seam.py"] = seamPyTemplate()
|
|
190
|
-
fs["seam/auth.py"] = authPyTemplate()
|
|
191
|
-
fs["seam/token.py"] = tokenPyTemplate()
|
|
192
|
-
fs["seam/options.py"] = optionsPyTemplate()
|
|
193
|
-
fs["seam/parse_options.py"] = parseOptionsPyTemplate()
|
|
194
|
-
fs["seam/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate()
|
|
195
|
-
fs["seam/utils/action_attempt_errors.py"] = actionAttemptsErrorsPyTemplate()
|
|
196
|
-
|
|
197
|
-
fs["tests/conftest.py"] = conftestPyTemplate()
|
|
198
|
-
fs["tests/test_smoke.py"] = test_smokePyTemplate()
|
|
199
|
-
fs["tests/__init__.py"] = ""
|
|
164
|
+
fs["seam/routes/routes.py"] = routesPyTemplate(top_level_namespaces)
|
|
165
|
+
fs["seam/routes/utils/deep_attr_dict.py"] = deepAttrDictPyTemplate()
|
|
200
166
|
|
|
201
167
|
return fs
|
|
202
168
|
}
|
|
@@ -69,10 +69,25 @@ export const action_attempt_utils_definitions = [
|
|
|
69
69
|
" return action_attempt",
|
|
70
70
|
].join("\n")
|
|
71
71
|
|
|
72
|
-
export const action_attempt_imports = `import time
|
|
72
|
+
export const action_attempt_imports = `import time\n`
|
|
73
73
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
export const action_attempt_error_definitions = `class SeamActionAttemptError(Exception):
|
|
75
|
+
def __init__(self, message: str, action_attempt: ActionAttempt):
|
|
76
|
+
super().__init__(message)
|
|
77
|
+
self.name = self.__class__.__name__
|
|
78
|
+
self.action_attempt = action_attempt
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class SeamActionAttemptFailedError(SeamActionAttemptError):
|
|
82
|
+
def __init__(self, action_attempt: ActionAttempt):
|
|
83
|
+
super().__init__(action_attempt.error.message, action_attempt)
|
|
84
|
+
self.name = self.__class__.__name__
|
|
85
|
+
self.code = action_attempt.error.type
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
class SeamActionAttemptTimeoutError(SeamActionAttemptError):
|
|
89
|
+
def __init__(self, action_attempt: ActionAttempt, timeout: str):
|
|
90
|
+
message = f"Timed out waiting for action attempt after {timeout}s"
|
|
91
|
+
super().__init__(message, action_attempt)
|
|
92
|
+
self.name = self.__class__.__name__
|
|
78
93
|
`
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":".gitignore.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/.gitignore.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;CASpB,CAAA"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default () => `# flake8: noqa
|
|
2
|
-
# type: ignore
|
|
3
|
-
|
|
4
|
-
from seam.seam import Seam, SeamApiException
|
|
5
|
-
from seam.options import SeamHttpInvalidOptionsError
|
|
6
|
-
from seam.auth import SeamHttpInvalidTokenError
|
|
7
|
-
from seam.utils.action_attempt_errors import (
|
|
8
|
-
SeamActionAttemptError,
|
|
9
|
-
SeamActionAttemptFailedError,
|
|
10
|
-
SeamActionAttemptTimeoutError,
|
|
11
|
-
)
|
|
12
|
-
`;
|
|
13
|
-
//# sourceMappingURL=__init__.py.template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"__init__.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/__init__.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;CAWpB,CAAA"}
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
export default () => `from typing import Optional
|
|
2
|
-
from seam.options import (
|
|
3
|
-
SeamHttpInvalidOptionsError,
|
|
4
|
-
is_seam_http_options_with_api_key,
|
|
5
|
-
is_seam_http_options_with_personal_access_token,
|
|
6
|
-
)
|
|
7
|
-
from seam.token import (
|
|
8
|
-
is_jwt,
|
|
9
|
-
is_access_token,
|
|
10
|
-
is_client_session_token,
|
|
11
|
-
is_publishable_key,
|
|
12
|
-
is_seam_token,
|
|
13
|
-
TOKEN_PREFIX,
|
|
14
|
-
ACCESS_TOKEN_PREFIX,
|
|
15
|
-
)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class SeamHttpInvalidTokenError(Exception):
|
|
19
|
-
def __init__(self, message):
|
|
20
|
-
super().__init__(f"SeamHttp received an invalid token: {message}")
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def get_auth_headers(
|
|
24
|
-
api_key: Optional[str] = None,
|
|
25
|
-
personal_access_token: Optional[str] = None,
|
|
26
|
-
workspace_id: Optional[str] = None,
|
|
27
|
-
):
|
|
28
|
-
if is_seam_http_options_with_api_key(
|
|
29
|
-
api_key=api_key,
|
|
30
|
-
personal_access_token=personal_access_token,
|
|
31
|
-
):
|
|
32
|
-
return get_auth_headers_for_api_key(api_key)
|
|
33
|
-
|
|
34
|
-
if is_seam_http_options_with_personal_access_token(
|
|
35
|
-
personal_access_token=personal_access_token,
|
|
36
|
-
api_key=api_key,
|
|
37
|
-
workspace_id=workspace_id,
|
|
38
|
-
):
|
|
39
|
-
return get_auth_headers_for_personal_access_token(
|
|
40
|
-
personal_access_token, workspace_id
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
raise SeamHttpInvalidOptionsError(
|
|
44
|
-
"Must specify an api_key or personal_access_token. "
|
|
45
|
-
"Attempted reading configuration from the environment, "
|
|
46
|
-
"but the environment variable SEAM_API_KEY is not set."
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
def get_auth_headers_for_api_key(api_key: str) -> dict:
|
|
51
|
-
if is_client_session_token(api_key):
|
|
52
|
-
raise SeamHttpInvalidTokenError(
|
|
53
|
-
"A Client Session Token cannot be used as an api_key"
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
if is_jwt(api_key):
|
|
57
|
-
raise SeamHttpInvalidTokenError("A JWT cannot be used as an api_key")
|
|
58
|
-
|
|
59
|
-
if is_access_token(api_key):
|
|
60
|
-
raise SeamHttpInvalidTokenError("An Access Token cannot be used as an api_key")
|
|
61
|
-
|
|
62
|
-
if is_publishable_key(api_key):
|
|
63
|
-
raise SeamHttpInvalidTokenError(
|
|
64
|
-
"A Publishable Key cannot be used as an api_key"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
if not is_seam_token(api_key):
|
|
68
|
-
raise SeamHttpInvalidTokenError(
|
|
69
|
-
f"Unknown or invalid api_key format, expected token to start with {TOKEN_PREFIX}"
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
return {"authorization": f"Bearer {api_key}"}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def get_auth_headers_for_personal_access_token(
|
|
76
|
-
personal_access_token: str, workspace_id: str
|
|
77
|
-
) -> dict:
|
|
78
|
-
if is_jwt(personal_access_token):
|
|
79
|
-
raise SeamHttpInvalidTokenError(
|
|
80
|
-
"A JWT cannot be used as a personal_access_token"
|
|
81
|
-
)
|
|
82
|
-
|
|
83
|
-
if is_client_session_token(personal_access_token):
|
|
84
|
-
raise SeamHttpInvalidTokenError(
|
|
85
|
-
"A Client Session Token cannot be used as a personal_access_token"
|
|
86
|
-
)
|
|
87
|
-
|
|
88
|
-
if is_publishable_key(personal_access_token):
|
|
89
|
-
raise SeamHttpInvalidTokenError(
|
|
90
|
-
"A Publishable Key cannot be used as a personal_access_token"
|
|
91
|
-
)
|
|
92
|
-
|
|
93
|
-
if not is_access_token(personal_access_token):
|
|
94
|
-
raise SeamHttpInvalidTokenError(
|
|
95
|
-
f"Unknown or invalid personal_access_token format, expected token to start with {ACCESS_TOKEN_PREFIX}"
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
return {
|
|
99
|
-
"authorization": f"Bearer {personal_access_token}",
|
|
100
|
-
"seam-workspace": workspace_id,
|
|
101
|
-
}
|
|
102
|
-
`;
|
|
103
|
-
//# sourceMappingURL=auth.py.template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/auth.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqGpB,CAAA"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default () => `import pytest
|
|
2
|
-
from seam import Seam
|
|
3
|
-
import random
|
|
4
|
-
import string
|
|
5
|
-
|
|
6
|
-
@pytest.fixture(scope="function")
|
|
7
|
-
def seam():
|
|
8
|
-
r = "".join(random.choices(string.ascii_uppercase + string.digits, k=10))
|
|
9
|
-
seam = Seam(
|
|
10
|
-
endpoint=f"https://{r}.fakeseamconnect.seam.vc", api_key="seam_apikey1_token"
|
|
11
|
-
)
|
|
12
|
-
yield seam
|
|
13
|
-
`;
|
|
14
|
-
//# sourceMappingURL=conftest.py.template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"conftest.py.template.js","sourceRoot":"","sources":["../../../src/lib/generate-python-sdk/templates/conftest.py.template.ts"],"names":[],"mappings":"AAAA,eAAe,GAAG,EAAE,CAAC;;;;;;;;;;;;CAYpB,CAAA"}
|