@shapediver/sdk.geometry-api-sdk-v2 1.12.2 → 2.0.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/README.md +133 -58
- package/dist/UtilsApi.d.ts +20 -0
- package/dist/UtilsApi.d.ts.map +1 -0
- package/dist/UtilsApi.js +185 -0
- package/dist/UtilsApi.js.map +1 -0
- package/dist/client/api.d.ts +2117 -0
- package/dist/client/api.d.ts.map +1 -0
- package/dist/client/api.js +3473 -0
- package/dist/client/api.js.map +1 -0
- package/dist/client/base.d.ts +32 -0
- package/dist/client/base.d.ts.map +1 -0
- package/dist/client/base.js +37 -0
- package/dist/client/base.js.map +1 -0
- package/dist/client/common.d.ts +14 -0
- package/dist/client/common.d.ts.map +1 -0
- package/dist/client/common.js +108 -0
- package/dist/client/common.js.map +1 -0
- package/dist/client/configuration.d.ts +23 -0
- package/dist/client/configuration.d.ts.map +1 -0
- package/dist/client/configuration.js +21 -0
- package/dist/client/configuration.js.map +1 -0
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -0
- package/dist/client/index.js +19 -0
- package/dist/client/index.js.map +1 -0
- package/dist/configuration.d.ts +8 -0
- package/dist/configuration.d.ts.map +1 -0
- package/dist/configuration.js +22 -0
- package/dist/configuration.js.map +1 -0
- package/dist/error.d.ts +22 -0
- package/dist/error.d.ts.map +1 -0
- package/dist/error.js +48 -0
- package/dist/error.js.map +1 -0
- package/dist/index.d.ts +5 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -17
- package/dist/index.js.map +1 -1
- package/dist/utils.d.ts +12 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +93 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -57
- package/src/UtilsApi.ts +393 -0
- package/src/client/api.ts +14084 -0
- package/src/client/base.ts +86 -0
- package/src/client/common.ts +150 -0
- package/src/client/configuration.ts +110 -0
- package/src/client/index.ts +18 -0
- package/src/configuration.ts +27 -0
- package/src/error.ts +92 -0
- package/src/index.ts +5 -17
- package/src/utils.ts +126 -0
- package/dist/ShapeDiverErrors.d.ts +0 -10
- package/dist/ShapeDiverErrors.d.ts.map +0 -1
- package/dist/ShapeDiverErrors.js +0 -18
- package/dist/ShapeDiverErrors.js.map +0 -1
- package/dist/ShapeDiverSdk.d.ts +0 -48
- package/dist/ShapeDiverSdk.d.ts.map +0 -1
- package/dist/ShapeDiverSdk.js +0 -87
- package/dist/ShapeDiverSdk.js.map +0 -1
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts +0 -12
- package/dist/resources/ShapeDiverAnalyticsApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverAnalyticsApi.js +0 -63
- package/dist/resources/ShapeDiverAnalyticsApi.js.map +0 -1
- package/dist/resources/ShapeDiverArSceneApi.d.ts +0 -8
- package/dist/resources/ShapeDiverArSceneApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverArSceneApi.js +0 -63
- package/dist/resources/ShapeDiverArSceneApi.js.map +0 -1
- package/dist/resources/ShapeDiverAssetApi.d.ts +0 -13
- package/dist/resources/ShapeDiverAssetApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverAssetApi.js +0 -131
- package/dist/resources/ShapeDiverAssetApi.js.map +0 -1
- package/dist/resources/ShapeDiverExportApi.d.ts +0 -10
- package/dist/resources/ShapeDiverExportApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverExportApi.js +0 -49
- package/dist/resources/ShapeDiverExportApi.js.map +0 -1
- package/dist/resources/ShapeDiverFileApi.d.ts +0 -15
- package/dist/resources/ShapeDiverFileApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverFileApi.js +0 -67
- package/dist/resources/ShapeDiverFileApi.js.map +0 -1
- package/dist/resources/ShapeDiverGltfApi.d.ts +0 -7
- package/dist/resources/ShapeDiverGltfApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverGltfApi.js +0 -32
- package/dist/resources/ShapeDiverGltfApi.js.map +0 -1
- package/dist/resources/ShapeDiverModelApi.d.ts +0 -22
- package/dist/resources/ShapeDiverModelApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverModelApi.js +0 -156
- package/dist/resources/ShapeDiverModelApi.js.map +0 -1
- package/dist/resources/ShapeDiverModelStateApi.d.ts +0 -14
- package/dist/resources/ShapeDiverModelStateApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverModelStateApi.js +0 -104
- package/dist/resources/ShapeDiverModelStateApi.js.map +0 -1
- package/dist/resources/ShapeDiverOutputApi.d.ts +0 -10
- package/dist/resources/ShapeDiverOutputApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverOutputApi.js +0 -52
- package/dist/resources/ShapeDiverOutputApi.js.map +0 -1
- package/dist/resources/ShapeDiverSdtfApi.d.ts +0 -10
- package/dist/resources/ShapeDiverSdtfApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverSdtfApi.js +0 -52
- package/dist/resources/ShapeDiverSdtfApi.js.map +0 -1
- package/dist/resources/ShapeDiverSessionApi.d.ts +0 -11
- package/dist/resources/ShapeDiverSessionApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverSessionApi.js +0 -66
- package/dist/resources/ShapeDiverSessionApi.js.map +0 -1
- package/dist/resources/ShapeDiverSystemApi.d.ts +0 -12
- package/dist/resources/ShapeDiverSystemApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverSystemApi.js +0 -63
- package/dist/resources/ShapeDiverSystemApi.js.map +0 -1
- package/dist/resources/ShapeDiverTextureApi.d.ts +0 -7
- package/dist/resources/ShapeDiverTextureApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverTextureApi.js +0 -31
- package/dist/resources/ShapeDiverTextureApi.js.map +0 -1
- package/dist/resources/ShapeDiverUtilsApi.d.ts +0 -18
- package/dist/resources/ShapeDiverUtilsApi.d.ts.map +0 -1
- package/dist/resources/ShapeDiverUtilsApi.js +0 -146
- package/dist/resources/ShapeDiverUtilsApi.js.map +0 -1
- package/dist/utils/utils.d.ts +0 -12
- package/dist/utils/utils.d.ts.map +0 -1
- package/dist/utils/utils.js +0 -109
- package/dist/utils/utils.js.map +0 -1
- package/src/ShapeDiverErrors.ts +0 -34
- package/src/ShapeDiverSdk.ts +0 -121
- package/src/resources/ShapeDiverAnalyticsApi.ts +0 -108
- package/src/resources/ShapeDiverArSceneApi.ts +0 -77
- package/src/resources/ShapeDiverAssetApi.ts +0 -241
- package/src/resources/ShapeDiverExportApi.ts +0 -103
- package/src/resources/ShapeDiverFileApi.ts +0 -150
- package/src/resources/ShapeDiverGltfApi.ts +0 -46
- package/src/resources/ShapeDiverModelApi.ts +0 -374
- package/src/resources/ShapeDiverModelStateApi.ts +0 -163
- package/src/resources/ShapeDiverOutputApi.ts +0 -109
- package/src/resources/ShapeDiverSdtfApi.ts +0 -103
- package/src/resources/ShapeDiverSessionApi.ts +0 -142
- package/src/resources/ShapeDiverSystemApi.ts +0 -118
- package/src/resources/ShapeDiverTextureApi.ts +0 -36
- package/src/resources/ShapeDiverUtilsApi.ts +0 -318
- package/src/utils/utils.ts +0 -135
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Geometry Backend API v2
|
|
5
|
+
* The ShapeDiver Geometry Backend system is used to: * host Grasshopper models in a secure, reliable, scalable, and performant way, * run computations of Grasshopper models, * and cache and output the results of computations and exports.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.6.1
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import type { Configuration } from './configuration';
|
|
17
|
+
// Some imports not used depending on template conditions
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
|
20
|
+
import globalAxios from 'axios';
|
|
21
|
+
|
|
22
|
+
export const BASE_PATH = "http://localhost".replace(/\/+$/, "");
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
*
|
|
26
|
+
* @export
|
|
27
|
+
*/
|
|
28
|
+
export const COLLECTION_FORMATS = {
|
|
29
|
+
csv: ",",
|
|
30
|
+
ssv: " ",
|
|
31
|
+
tsv: "\t",
|
|
32
|
+
pipes: "|",
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @interface RequestArgs
|
|
39
|
+
*/
|
|
40
|
+
export interface RequestArgs {
|
|
41
|
+
url: string;
|
|
42
|
+
options: RawAxiosRequestConfig;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @export
|
|
48
|
+
* @class BaseAPI
|
|
49
|
+
*/
|
|
50
|
+
export class BaseAPI {
|
|
51
|
+
protected configuration: Configuration | undefined;
|
|
52
|
+
|
|
53
|
+
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
|
54
|
+
if (configuration) {
|
|
55
|
+
this.configuration = configuration;
|
|
56
|
+
this.basePath = configuration.basePath ?? basePath;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @export
|
|
64
|
+
* @class RequiredError
|
|
65
|
+
* @extends {Error}
|
|
66
|
+
*/
|
|
67
|
+
export class RequiredError extends Error {
|
|
68
|
+
constructor(public field: string, msg?: string) {
|
|
69
|
+
super(msg);
|
|
70
|
+
this.name = "RequiredError"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
interface ServerMap {
|
|
75
|
+
[key: string]: {
|
|
76
|
+
url: string,
|
|
77
|
+
description: string,
|
|
78
|
+
}[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @export
|
|
84
|
+
*/
|
|
85
|
+
export const operationServerMap: ServerMap = {
|
|
86
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Geometry Backend API v2
|
|
5
|
+
* The ShapeDiver Geometry Backend system is used to: * host Grasshopper models in a secure, reliable, scalable, and performant way, * run computations of Grasshopper models, * and cache and output the results of computations and exports.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.6.1
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
import type { Configuration } from "./configuration";
|
|
17
|
+
import type { RequestArgs } from "./base";
|
|
18
|
+
import type { AxiosInstance, AxiosResponse } from 'axios';
|
|
19
|
+
import { RequiredError } from "./base";
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
*
|
|
23
|
+
* @export
|
|
24
|
+
*/
|
|
25
|
+
export const DUMMY_BASE_URL = 'https://example.com'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @throws {RequiredError}
|
|
30
|
+
* @export
|
|
31
|
+
*/
|
|
32
|
+
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
|
33
|
+
if (paramValue === null || paramValue === undefined) {
|
|
34
|
+
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
*
|
|
40
|
+
* @export
|
|
41
|
+
*/
|
|
42
|
+
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
|
43
|
+
if (configuration && configuration.apiKey) {
|
|
44
|
+
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
|
45
|
+
? await configuration.apiKey(keyParamName)
|
|
46
|
+
: await configuration.apiKey;
|
|
47
|
+
object[keyParamName] = localVarApiKeyValue;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
*
|
|
53
|
+
* @export
|
|
54
|
+
*/
|
|
55
|
+
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
|
|
56
|
+
if (configuration && (configuration.username || configuration.password)) {
|
|
57
|
+
object["auth"] = { username: configuration.username, password: configuration.password };
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @export
|
|
64
|
+
*/
|
|
65
|
+
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
|
66
|
+
if (configuration && configuration.accessToken) {
|
|
67
|
+
const accessToken = typeof configuration.accessToken === 'function'
|
|
68
|
+
? await configuration.accessToken()
|
|
69
|
+
: await configuration.accessToken;
|
|
70
|
+
object["Authorization"] = "Bearer " + accessToken;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
*
|
|
76
|
+
* @export
|
|
77
|
+
*/
|
|
78
|
+
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
|
|
79
|
+
if (configuration && configuration.accessToken) {
|
|
80
|
+
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
|
81
|
+
? await configuration.accessToken(name, scopes)
|
|
82
|
+
: await configuration.accessToken;
|
|
83
|
+
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
|
88
|
+
if (parameter == null) return;
|
|
89
|
+
if (typeof parameter === "object") {
|
|
90
|
+
if (Array.isArray(parameter)) {
|
|
91
|
+
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
Object.keys(parameter).forEach(currentKey =>
|
|
95
|
+
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
if (urlSearchParams.has(key)) {
|
|
101
|
+
urlSearchParams.append(key, parameter);
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
urlSearchParams.set(key, parameter);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
*
|
|
111
|
+
* @export
|
|
112
|
+
*/
|
|
113
|
+
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
|
114
|
+
const searchParams = new URLSearchParams(url.search);
|
|
115
|
+
setFlattenedQueryParams(searchParams, objects);
|
|
116
|
+
url.search = searchParams.toString();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
*
|
|
121
|
+
* @export
|
|
122
|
+
*/
|
|
123
|
+
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
|
124
|
+
const nonString = typeof value !== 'string';
|
|
125
|
+
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
|
126
|
+
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
|
127
|
+
: nonString;
|
|
128
|
+
return needsSerialization
|
|
129
|
+
? JSON.stringify(value !== undefined ? value : {})
|
|
130
|
+
: (value || "");
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
* @export
|
|
136
|
+
*/
|
|
137
|
+
export const toPathString = function (url: URL) {
|
|
138
|
+
return url.pathname + url.search + url.hash
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
*
|
|
143
|
+
* @export
|
|
144
|
+
*/
|
|
145
|
+
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
|
146
|
+
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
|
147
|
+
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
|
|
148
|
+
return axios.request<T, R>(axiosRequestArgs);
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Geometry Backend API v2
|
|
5
|
+
* The ShapeDiver Geometry Backend system is used to: * host Grasshopper models in a secure, reliable, scalable, and performant way, * run computations of Grasshopper models, * and cache and output the results of computations and exports.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.6.1
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export interface ConfigurationParameters {
|
|
17
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
18
|
+
username?: string;
|
|
19
|
+
password?: string;
|
|
20
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
21
|
+
basePath?: string;
|
|
22
|
+
serverIndex?: number;
|
|
23
|
+
baseOptions?: any;
|
|
24
|
+
formDataCtor?: new () => any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export class Configuration {
|
|
28
|
+
/**
|
|
29
|
+
* parameter for apiKey security
|
|
30
|
+
* @param name security name
|
|
31
|
+
* @memberof Configuration
|
|
32
|
+
*/
|
|
33
|
+
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
|
34
|
+
/**
|
|
35
|
+
* parameter for basic security
|
|
36
|
+
*
|
|
37
|
+
* @type {string}
|
|
38
|
+
* @memberof Configuration
|
|
39
|
+
*/
|
|
40
|
+
username?: string;
|
|
41
|
+
/**
|
|
42
|
+
* parameter for basic security
|
|
43
|
+
*
|
|
44
|
+
* @type {string}
|
|
45
|
+
* @memberof Configuration
|
|
46
|
+
*/
|
|
47
|
+
password?: string;
|
|
48
|
+
/**
|
|
49
|
+
* parameter for oauth2 security
|
|
50
|
+
* @param name security name
|
|
51
|
+
* @param scopes oauth2 scope
|
|
52
|
+
* @memberof Configuration
|
|
53
|
+
*/
|
|
54
|
+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
|
55
|
+
/**
|
|
56
|
+
* override base path
|
|
57
|
+
*
|
|
58
|
+
* @type {string}
|
|
59
|
+
* @memberof Configuration
|
|
60
|
+
*/
|
|
61
|
+
basePath?: string;
|
|
62
|
+
/**
|
|
63
|
+
* override server index
|
|
64
|
+
*
|
|
65
|
+
* @type {number}
|
|
66
|
+
* @memberof Configuration
|
|
67
|
+
*/
|
|
68
|
+
serverIndex?: number;
|
|
69
|
+
/**
|
|
70
|
+
* base options for axios calls
|
|
71
|
+
*
|
|
72
|
+
* @type {any}
|
|
73
|
+
* @memberof Configuration
|
|
74
|
+
*/
|
|
75
|
+
baseOptions?: any;
|
|
76
|
+
/**
|
|
77
|
+
* The FormData constructor that will be used to create multipart form data
|
|
78
|
+
* requests. You can inject this here so that execution environments that
|
|
79
|
+
* do not support the FormData class can still run the generated client.
|
|
80
|
+
*
|
|
81
|
+
* @type {new () => FormData}
|
|
82
|
+
*/
|
|
83
|
+
formDataCtor?: new () => any;
|
|
84
|
+
|
|
85
|
+
constructor(param: ConfigurationParameters = {}) {
|
|
86
|
+
this.apiKey = param.apiKey;
|
|
87
|
+
this.username = param.username;
|
|
88
|
+
this.password = param.password;
|
|
89
|
+
this.accessToken = param.accessToken;
|
|
90
|
+
this.basePath = param.basePath;
|
|
91
|
+
this.serverIndex = param.serverIndex;
|
|
92
|
+
this.baseOptions = param.baseOptions;
|
|
93
|
+
this.formDataCtor = param.formDataCtor;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Check if the given MIME is a JSON MIME.
|
|
98
|
+
* JSON MIME examples:
|
|
99
|
+
* application/json
|
|
100
|
+
* application/json; charset=UTF8
|
|
101
|
+
* APPLICATION/JSON
|
|
102
|
+
* application/vnd.company+json
|
|
103
|
+
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
|
104
|
+
* @return True if the given MIME is JSON, false otherwise.
|
|
105
|
+
*/
|
|
106
|
+
public isJsonMime(mime: string): boolean {
|
|
107
|
+
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
|
108
|
+
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* Geometry Backend API v2
|
|
5
|
+
* The ShapeDiver Geometry Backend system is used to: * host Grasshopper models in a secure, reliable, scalable, and performant way, * run computations of Grasshopper models, * and cache and output the results of computations and exports.
|
|
6
|
+
*
|
|
7
|
+
* The version of the OpenAPI document: 1.6.1
|
|
8
|
+
*
|
|
9
|
+
*
|
|
10
|
+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
11
|
+
* https://openapi-generator.tech
|
|
12
|
+
* Do not edit the class manually.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
export * from "./api";
|
|
17
|
+
export * from "./configuration";
|
|
18
|
+
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Configuration as ClientConfig,
|
|
3
|
+
ConfigurationParameters as ClientConfigParams,
|
|
4
|
+
} from './client/configuration';
|
|
5
|
+
|
|
6
|
+
export interface ConfigurationParameters extends ClientConfigParams {}
|
|
7
|
+
|
|
8
|
+
export class Configuration extends ClientConfig {
|
|
9
|
+
protected readonly sdkVersion = '2.0.0'; // WARNING: This value is updated automatically!
|
|
10
|
+
|
|
11
|
+
constructor(param: ConfigurationParameters = {}) {
|
|
12
|
+
super(param);
|
|
13
|
+
|
|
14
|
+
this.baseOptions = this.baseOptions ?? {};
|
|
15
|
+
this.baseOptions.headers = this.baseOptions.headers ?? {};
|
|
16
|
+
|
|
17
|
+
const userAgent = `sd-sdk/typescript/${this.sdkVersion}`;
|
|
18
|
+
|
|
19
|
+
if (typeof process === 'object' && !this.baseOptions.headers['User-Agent']) {
|
|
20
|
+
// Overwrite User-Agent on Node.js applications.
|
|
21
|
+
this.baseOptions.headers['User-Agent'] = userAgent;
|
|
22
|
+
} else if (!this.baseOptions.headers['x-shapediver-useragent']) {
|
|
23
|
+
// Set a custom User-Agent header on Browser applications.
|
|
24
|
+
this.baseOptions.headers['x-shapediver-useragent'] = userAgent;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/error.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { ResErrorType } from './client';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Represents a generic (non-request and non-response) error.
|
|
5
|
+
*
|
|
6
|
+
* Something happened in setting up the request that triggered an Error.
|
|
7
|
+
* @export
|
|
8
|
+
* @class SdError
|
|
9
|
+
* @extends {Error}
|
|
10
|
+
*/
|
|
11
|
+
export class SdError extends Error {
|
|
12
|
+
constructor(message: string) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'SdError';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* This error builds on top of an Axios request error.
|
|
20
|
+
*
|
|
21
|
+
* The request was made but no response was received.
|
|
22
|
+
* @export
|
|
23
|
+
* @class SdRequestError
|
|
24
|
+
* @extends {Error}
|
|
25
|
+
*/
|
|
26
|
+
export class SdRequestError extends Error {
|
|
27
|
+
constructor(message: string) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = 'SdRequestError';
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* This error builds on top of an Axios response error.
|
|
35
|
+
*
|
|
36
|
+
* The request was made and the server responded with a status code that falls out of the range of
|
|
37
|
+
* 2xx.
|
|
38
|
+
* @export
|
|
39
|
+
* @class SdResponseError
|
|
40
|
+
* @extends {Error}
|
|
41
|
+
*/
|
|
42
|
+
export class SdResponseError extends Error {
|
|
43
|
+
/** The HTTP status code from the server response. */
|
|
44
|
+
public readonly status: number;
|
|
45
|
+
|
|
46
|
+
/** The type of the error. */
|
|
47
|
+
public readonly type: ResErrorType;
|
|
48
|
+
|
|
49
|
+
/** General description of the error type. */
|
|
50
|
+
public readonly description: string;
|
|
51
|
+
|
|
52
|
+
constructor(status: number, message: string, desc: string, type?: string) {
|
|
53
|
+
super(message);
|
|
54
|
+
this.name = 'SdResponseError';
|
|
55
|
+
this.status = status;
|
|
56
|
+
this.description = desc;
|
|
57
|
+
this.type =
|
|
58
|
+
type && Object.values(ResErrorType).includes(type as ResErrorType)
|
|
59
|
+
? (type as ResErrorType)
|
|
60
|
+
: ResErrorType.UNKNOWN;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* @export
|
|
66
|
+
* @class IllegalArgumentError
|
|
67
|
+
* @extends {Error}
|
|
68
|
+
*/
|
|
69
|
+
export class IllegalArgumentError extends Error {
|
|
70
|
+
constructor(
|
|
71
|
+
public field: string,
|
|
72
|
+
msg?: string
|
|
73
|
+
) {
|
|
74
|
+
super(msg);
|
|
75
|
+
this.name = 'IllegalArgumentError';
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* @export
|
|
81
|
+
* @class TimeoutError
|
|
82
|
+
* @extends {Error}
|
|
83
|
+
*/
|
|
84
|
+
export class TimeoutError extends Error {
|
|
85
|
+
constructor(
|
|
86
|
+
public field: string,
|
|
87
|
+
msg?: string
|
|
88
|
+
) {
|
|
89
|
+
super(msg);
|
|
90
|
+
this.name = 'TimeoutError';
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
ShapeDiverSdkConfig,
|
|
7
|
-
ShapeDiverSdkConfigType,
|
|
8
|
-
} from "@shapediver/sdk.geometry-api-sdk-core";
|
|
9
|
-
export { ShapeDiverResponseError } from "./ShapeDiverErrors";
|
|
10
|
-
export { ShapeDiverSdk, create } from "./ShapeDiverSdk";
|
|
11
|
-
export { ShapeDiverResponseFileInfo } from "./resources/ShapeDiverFileApi";
|
|
12
|
-
export {
|
|
13
|
-
isGBError,
|
|
14
|
-
isGBGenericError,
|
|
15
|
-
isGBRequestError,
|
|
16
|
-
isGBResponseError,
|
|
17
|
-
} from "./utils/utils";
|
|
1
|
+
export * from './client/api';
|
|
2
|
+
export * from './UtilsApi';
|
|
3
|
+
export * from './configuration';
|
|
4
|
+
export * from './error';
|
|
5
|
+
export * from './utils';
|
package/src/utils.ts
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { AxiosError, AxiosPromise } from 'axios';
|
|
2
|
+
import { SdError, SdRequestError, SdResponseError } from './error';
|
|
3
|
+
|
|
4
|
+
/** Delays the response for the given number of milliseconds */
|
|
5
|
+
export function sleep(ms: number): Promise<void> {
|
|
6
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Parse HTTP headers to extract size and filename information.
|
|
11
|
+
* @param {Record<string, any>} headers The HTTP headers of a file-metadata response.
|
|
12
|
+
* @return An object with 'size' and 'filename' properties.
|
|
13
|
+
*/
|
|
14
|
+
export function extractFileInfo(headers: Record<string, any> | undefined): {
|
|
15
|
+
size: number | undefined;
|
|
16
|
+
filename: string | undefined;
|
|
17
|
+
} {
|
|
18
|
+
if (!headers) return { size: undefined, filename: undefined };
|
|
19
|
+
|
|
20
|
+
// Extract size from Content-Length header
|
|
21
|
+
const contentLength = headers['Content-Length'] || headers['content-length'];
|
|
22
|
+
const size = contentLength ? parseInt(contentLength) : undefined;
|
|
23
|
+
|
|
24
|
+
// Extract filename from Content-Disposition header
|
|
25
|
+
const contentDisposition = headers['Content-Disposition'] || headers['content-disposition'];
|
|
26
|
+
const filename = contentDisposition
|
|
27
|
+
? filenameFromContentDisposition(contentDisposition)
|
|
28
|
+
: undefined;
|
|
29
|
+
|
|
30
|
+
return { size, filename };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Set content headers according to RFC 5987.
|
|
35
|
+
* @param {string} filename The file name to use.
|
|
36
|
+
* @return A content-disposition header string.
|
|
37
|
+
*/
|
|
38
|
+
export function contentDispositionFromFilename(filename: string): string {
|
|
39
|
+
// Normalize the filename to ASCII
|
|
40
|
+
const asciiName = filename.normalize('NFKD').replace(/[^\x00-\x7F]/g, ''); // Transliterates to ASCII
|
|
41
|
+
let header = `attachment; filename="${asciiName}"`;
|
|
42
|
+
|
|
43
|
+
if (asciiName !== filename) {
|
|
44
|
+
const quotedName = encodeURIComponent(filename);
|
|
45
|
+
header += `; filename*=UTF-8''${quotedName}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return header;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Extract and return the filename from a content-disposition HTTP header.
|
|
53
|
+
* Decodes the `filename*` property if set.
|
|
54
|
+
* @param {string} contentDisposition Content-Disposition header value.
|
|
55
|
+
* @return The extracted filename.
|
|
56
|
+
*/
|
|
57
|
+
export function filenameFromContentDisposition(contentDisposition: string): string | undefined {
|
|
58
|
+
let filename: string | undefined;
|
|
59
|
+
let filenameStar: string | undefined;
|
|
60
|
+
|
|
61
|
+
// Search for filename
|
|
62
|
+
const filenameMatch = contentDisposition.match(/filename="([^"]+)"/);
|
|
63
|
+
if (filenameMatch) filename = filenameMatch[1];
|
|
64
|
+
|
|
65
|
+
// Search for filename*
|
|
66
|
+
const filenameStarMatch = contentDisposition.match(/filename\*=([^'']+''|)?(.+)/);
|
|
67
|
+
if (filenameStarMatch) {
|
|
68
|
+
const encoding = filenameStarMatch[1] ? filenameStarMatch[1] : 'utf-8';
|
|
69
|
+
const encodedFilename = filenameStarMatch[2];
|
|
70
|
+
if (encoding.toLowerCase().startsWith('utf-8'))
|
|
71
|
+
filenameStar = decodeURIComponent(encodedFilename);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// Prefer filename* over filename
|
|
75
|
+
return filenameStar || filename;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Helper function to check if an API call succeeded. This is useful for `metadata` endpoints when
|
|
80
|
+
* we want to check if a resource exists or not.
|
|
81
|
+
*
|
|
82
|
+
* @param apiCall The API call to execute.
|
|
83
|
+
* @returns A promise that resolves to `true` if the API call resulted in a `200` HTTP status, and
|
|
84
|
+
* `false` for a `404` HTTP error status. Any other error status will be propagated.
|
|
85
|
+
*/
|
|
86
|
+
export async function exists(apiCall: () => AxiosPromise<unknown>): Promise<boolean> {
|
|
87
|
+
return apiCall()
|
|
88
|
+
.then(() => true)
|
|
89
|
+
.catch((error) => {
|
|
90
|
+
if (error.response?.status === 404) return false;
|
|
91
|
+
throw error;
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Converts a generic Axios error into a more specific ShapeDiver error.
|
|
97
|
+
* @param error The Axios error to convert.
|
|
98
|
+
*/
|
|
99
|
+
export function processError(
|
|
100
|
+
error: AxiosError | Error
|
|
101
|
+
): SdError | SdRequestError | SdResponseError {
|
|
102
|
+
if ('response' in error) {
|
|
103
|
+
const err = error as AxiosError,
|
|
104
|
+
status = err.response!.status,
|
|
105
|
+
data = err.response!.data;
|
|
106
|
+
|
|
107
|
+
if (
|
|
108
|
+
data &&
|
|
109
|
+
typeof data === 'object' &&
|
|
110
|
+
'desc' in data &&
|
|
111
|
+
typeof data.desc === 'string' &&
|
|
112
|
+
'error' in data &&
|
|
113
|
+
typeof data.error === 'string' &&
|
|
114
|
+
'message' in data &&
|
|
115
|
+
typeof data.message === 'string'
|
|
116
|
+
) {
|
|
117
|
+
return new SdResponseError(status, data.message, data.desc, data.error);
|
|
118
|
+
} else {
|
|
119
|
+
return new SdResponseError(status, err.message, 'No error description provided');
|
|
120
|
+
}
|
|
121
|
+
} else if ('request' in error) {
|
|
122
|
+
return new SdRequestError(error.message);
|
|
123
|
+
} else {
|
|
124
|
+
return new SdError(error.message);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { ShapeDiverResponseError as ShapeDiverResponseErrorDto, ShapeDiverResponseErrorType } from "@shapediver/api.geometry-api-dto-v2";
|
|
2
|
-
import { ShapeDiverError, ShapeDiverErrorType, ShapeDiverResponseError as ShapeDiverResponseErrorCore } from "@shapediver/sdk.geometry-api-sdk-core";
|
|
3
|
-
export declare class ShapeDiverResponseError extends ShapeDiverError implements ShapeDiverResponseErrorDto {
|
|
4
|
-
readonly errorType: ShapeDiverErrorType;
|
|
5
|
-
readonly status: number;
|
|
6
|
-
readonly error: ShapeDiverResponseErrorType;
|
|
7
|
-
readonly desc: string;
|
|
8
|
-
constructor(e: ShapeDiverResponseErrorCore);
|
|
9
|
-
}
|
|
10
|
-
//# sourceMappingURL=ShapeDiverErrors.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeDiverErrors.d.ts","sourceRoot":"","sources":["../src/ShapeDiverErrors.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,IAAI,0BAA0B,EACrD,2BAA2B,EAC5B,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,uBAAuB,IAAI,2BAA2B,EACvD,MAAM,uCAAuC,CAAC;AAG/C,qBAAa,uBACX,SAAQ,eACR,YAAW,0BAA0B;IAErC,SAAgB,SAAS,EAAE,mBAAmB,CAAgC;IAE9E,SAAgB,MAAM,EAAE,MAAM,CAAC;IAC/B,SAAgB,KAAK,EAAE,2BAA2B,CAAC;IACnD,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,CAAC,EAAE,2BAA2B;CAY3C"}
|
package/dist/ShapeDiverErrors.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShapeDiverResponseError = void 0;
|
|
4
|
-
const api_geometry_api_dto_v2_1 = require("@shapediver/api.geometry-api-dto-v2");
|
|
5
|
-
const sdk_geometry_api_sdk_core_1 = require("@shapediver/sdk.geometry-api-sdk-core");
|
|
6
|
-
class ShapeDiverResponseError extends sdk_geometry_api_sdk_core_1.ShapeDiverError {
|
|
7
|
-
constructor(e) {
|
|
8
|
-
super(e.message);
|
|
9
|
-
this.errorType = sdk_geometry_api_sdk_core_1.ShapeDiverErrorType.Response;
|
|
10
|
-
this.status = e.status;
|
|
11
|
-
this.desc = e.desc;
|
|
12
|
-
this.error = Object.values(api_geometry_api_dto_v2_1.ShapeDiverResponseErrorType).includes(e.error)
|
|
13
|
-
? e.error
|
|
14
|
-
: api_geometry_api_dto_v2_1.ShapeDiverResponseErrorType.UNKNOWN;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ShapeDiverResponseError = ShapeDiverResponseError;
|
|
18
|
-
//# sourceMappingURL=ShapeDiverErrors.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ShapeDiverErrors.js","sourceRoot":"","sources":["../src/ShapeDiverErrors.ts"],"names":[],"mappings":";;;AAAA,iFAG6C;AAC7C,qFAI+C;AAG/C,MAAa,uBACX,SAAQ,2CAAe;IASvB,YAAY,CAA8B;QACxC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAPH,cAAS,GAAwB,+CAAmB,CAAC,QAAQ,CAAC;QAS5E,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC;QAEnB,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,qDAA2B,CAAC,CAAC,QAAQ,CAC9D,CAAC,CAAC,KAAY,CACf;YACC,CAAC,CAAE,CAAC,CAAC,KAAqC;YAC1C,CAAC,CAAC,qDAA2B,CAAC,OAAO,CAAC;IAC1C,CAAC;CACF;AAtBD,0DAsBC"}
|