@shapediver/sdk.geometry-api-sdk-v2 4.2.2 → 4.4.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 +3 -2
- package/dist/UtilsApi.d.ts +3 -3
- package/dist/UtilsApi.d.ts.map +1 -1
- package/dist/UtilsApi.js +12 -15
- package/dist/UtilsApi.js.map +1 -1
- package/dist/base.d.ts.map +1 -1
- package/dist/base.js +3 -8
- package/dist/base.js.map +1 -1
- package/dist/client/apis/AnalyticsApi.d.ts.map +1 -1
- package/dist/client/apis/AnalyticsApi.js.map +1 -1
- package/dist/client/apis/ArSceneApi.d.ts.map +1 -1
- package/dist/client/apis/ArSceneApi.js.map +1 -1
- package/dist/client/apis/AssetsApi.d.ts.map +1 -1
- package/dist/client/apis/AssetsApi.js.map +1 -1
- package/dist/client/apis/AuthGroupApi.d.ts.map +1 -1
- package/dist/client/apis/AuthGroupApi.js.map +1 -1
- package/dist/client/apis/ExportApi.d.ts.map +1 -1
- package/dist/client/apis/ExportApi.js.map +1 -1
- package/dist/client/apis/FileApi.d.ts.map +1 -1
- package/dist/client/apis/FileApi.js.map +1 -1
- package/dist/client/apis/GltfApi.d.ts.map +1 -1
- package/dist/client/apis/GltfApi.js.map +1 -1
- package/dist/client/apis/LogApi.d.ts.map +1 -1
- package/dist/client/apis/LogApi.js.map +1 -1
- package/dist/client/apis/ModelApi.d.ts +12 -1
- package/dist/client/apis/ModelApi.d.ts.map +1 -1
- package/dist/client/apis/ModelApi.js +52 -0
- package/dist/client/apis/ModelApi.js.map +1 -1
- package/dist/client/apis/ModelStateApi.d.ts.map +1 -1
- package/dist/client/apis/ModelStateApi.js.map +1 -1
- package/dist/client/apis/OutputApi.d.ts.map +1 -1
- package/dist/client/apis/OutputApi.js.map +1 -1
- package/dist/client/apis/ScriptApi.d.ts.map +1 -1
- package/dist/client/apis/ScriptApi.js.map +1 -1
- package/dist/client/apis/SdtfApi.d.ts.map +1 -1
- package/dist/client/apis/SdtfApi.js.map +1 -1
- package/dist/client/apis/SessionApi.d.ts.map +1 -1
- package/dist/client/apis/SessionApi.js.map +1 -1
- package/dist/client/apis/SystemApi.d.ts.map +1 -1
- package/dist/client/apis/SystemApi.js.map +1 -1
- package/dist/client/apis/TextureApi.d.ts.map +1 -1
- package/dist/client/apis/TextureApi.js.map +1 -1
- package/dist/client/models/index.d.ts +43 -0
- package/dist/client/models/index.d.ts.map +1 -1
- package/dist/client/models/index.js +29 -24
- package/dist/client/models/index.js.map +1 -1
- package/dist/client/runtime.d.ts +1 -0
- package/dist/client/runtime.d.ts.map +1 -1
- package/dist/client/runtime.js +5 -1
- package/dist/client/runtime.js.map +1 -1
- package/dist/configuration.d.ts.map +1 -1
- package/dist/configuration.js +8 -10
- package/dist/configuration.js.map +1 -1
- package/dist/utils.d.ts +3 -3
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +18 -7
- package/dist/utils.js.map +1 -1
- package/package.json +5 -6
- package/src/UtilsApi.ts +40 -41
- package/src/base.ts +9 -16
- package/src/client/apis/AnalyticsApi.ts +22 -1
- package/src/client/apis/ArSceneApi.ts +10 -1
- package/src/client/apis/AssetsApi.ts +40 -1
- package/src/client/apis/AuthApi.ts +1 -1
- package/src/client/apis/AuthGroupApi.ts +4 -1
- package/src/client/apis/ExportApi.ts +40 -1
- package/src/client/apis/FileApi.ts +43 -1
- package/src/client/apis/GltfApi.ts +10 -1
- package/src/client/apis/LogApi.ts +7 -1
- package/src/client/apis/ModelApi.ts +243 -1
- package/src/client/apis/ModelStateApi.ts +37 -1
- package/src/client/apis/OutputApi.ts +40 -1
- package/src/client/apis/ScriptApi.ts +7 -1
- package/src/client/apis/SdtfApi.ts +34 -1
- package/src/client/apis/SessionApi.ts +60 -1
- package/src/client/apis/SystemApi.ts +10 -1
- package/src/client/apis/TextureApi.ts +7 -1
- package/src/client/models/index.ts +179 -1777
- package/src/client/runtime.ts +14 -2
- package/src/configuration.ts +15 -18
- package/src/utils.ts +32 -32
package/src/client/runtime.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Geometry Backend API v2
|
|
5
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
6
|
*
|
|
7
|
-
* The version of the OpenAPI document: 2.
|
|
7
|
+
* The version of the OpenAPI document: 2.6.0
|
|
8
8
|
*
|
|
9
9
|
*
|
|
10
10
|
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
|
@@ -346,7 +346,7 @@ function querystringSingleKey(key: string, value: string | number | null | undef
|
|
|
346
346
|
return querystringSingleKey(key, valueAsArray, keyPrefix);
|
|
347
347
|
}
|
|
348
348
|
if (value instanceof Date) {
|
|
349
|
-
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value
|
|
349
|
+
return `${encodeURIComponent(fullKey)}=${encodeURIComponent(serializeDateTime(value))}`;
|
|
350
350
|
}
|
|
351
351
|
if (value instanceof Object) {
|
|
352
352
|
return querystring(value as HTTPQuery, fullKey);
|
|
@@ -359,6 +359,18 @@ export function exists(json: any, key: string) {
|
|
|
359
359
|
return value !== null && value !== undefined;
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
+
/**
|
|
363
|
+
* Every generated date call site routes through these.
|
|
364
|
+
*
|
|
365
|
+
* `format: date` is a calendar date, with no time and no offset, so it is converted
|
|
366
|
+
* against the local calendar on both ends: they have to agree or the date shifts by
|
|
367
|
+
* a day. `format: date-time` is an instant and uses UTC.
|
|
368
|
+
*/
|
|
369
|
+
export function serializeDateTime(value: Date): string {
|
|
370
|
+
return value.toISOString();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
|
|
362
374
|
|
|
363
375
|
export function canConsumeForm(consumes: Consume[]): boolean {
|
|
364
376
|
for (const consume of consumes) {
|
package/src/configuration.ts
CHANGED
|
@@ -3,10 +3,12 @@ import {
|
|
|
3
3
|
ConfigurationParameters as ClientConfigParams,
|
|
4
4
|
} from './client/runtime';
|
|
5
5
|
|
|
6
|
-
const SDK_VERSION = '4.
|
|
6
|
+
const SDK_VERSION = '4.4.0'; // WARNING: This value is updated automatically!
|
|
7
7
|
|
|
8
|
-
export interface ConfigurationParameters
|
|
9
|
-
|
|
8
|
+
export interface ConfigurationParameters extends Pick<
|
|
9
|
+
ClientConfigParams,
|
|
10
|
+
'accessToken' | 'basePath' | 'fetchApi' | 'headers' | 'middleware' | 'queryParamsStringify'
|
|
11
|
+
> {
|
|
10
12
|
/**
|
|
11
13
|
* Specifies the maximum number of automatic HTTP retries for failed requests.
|
|
12
14
|
*
|
|
@@ -34,7 +36,7 @@ export class Configuration extends ClientConfig {
|
|
|
34
36
|
|
|
35
37
|
/** Converts an existing SDK configuration into constructor parameters. */
|
|
36
38
|
function configurationParameters(
|
|
37
|
-
param: ConfigurationParameters | ClientConfig
|
|
39
|
+
param: ConfigurationParameters | ClientConfig
|
|
38
40
|
): ConfigurationParameters {
|
|
39
41
|
if (!(param instanceof ClientConfig)) return param;
|
|
40
42
|
|
|
@@ -49,14 +51,12 @@ function configurationParameters(
|
|
|
49
51
|
};
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
function createHeaders(
|
|
53
|
-
headers?: ClientConfigParams['headers'],
|
|
54
|
-
): Record<string, string> {
|
|
54
|
+
function createHeaders(headers?: ClientConfigParams['headers']): Record<string, string> {
|
|
55
55
|
const result: Record<string, string> = {};
|
|
56
56
|
const normalizedHeaders = new Headers(headers);
|
|
57
57
|
const userAgent = `sd-sdk/typescript/${SDK_VERSION}`;
|
|
58
58
|
|
|
59
|
-
if (detectRuntime() ===
|
|
59
|
+
if (detectRuntime() === 'node' && !normalizedHeaders.has('User-Agent')) {
|
|
60
60
|
// Overwrite User-Agent on Node.js applications.
|
|
61
61
|
normalizedHeaders.set('User-Agent', userAgent);
|
|
62
62
|
} else if (!normalizedHeaders.has('X-ShapeDiver-UserAgent')) {
|
|
@@ -71,7 +71,7 @@ function createHeaders(
|
|
|
71
71
|
return result;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
function detectRuntime():
|
|
74
|
+
function detectRuntime(): 'node' | 'browser' | 'unknown' {
|
|
75
75
|
const global = globalThis as typeof globalThis & {
|
|
76
76
|
process?: {
|
|
77
77
|
versions?: {
|
|
@@ -84,21 +84,18 @@ function detectRuntime(): "node" | "browser" | "unknown" {
|
|
|
84
84
|
navigator?: unknown;
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
-
if (typeof global.process?.versions?.node ===
|
|
88
|
-
return
|
|
87
|
+
if (typeof global.process?.versions?.node === 'string') {
|
|
88
|
+
return 'node';
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
const isBrowserMainThread =
|
|
92
|
-
global.window === globalThis &&
|
|
93
|
-
typeof global.document !== "undefined";
|
|
92
|
+
global.window === globalThis && typeof global.document !== 'undefined';
|
|
94
93
|
|
|
95
|
-
const isBrowserWorker =
|
|
96
|
-
global.self === globalThis &&
|
|
97
|
-
typeof global.navigator !== "undefined";
|
|
94
|
+
const isBrowserWorker = global.self === globalThis && typeof global.navigator !== 'undefined';
|
|
98
95
|
|
|
99
96
|
if (isBrowserMainThread || isBrowserWorker) {
|
|
100
|
-
return
|
|
97
|
+
return 'browser';
|
|
101
98
|
}
|
|
102
99
|
|
|
103
|
-
return
|
|
100
|
+
return 'unknown';
|
|
104
101
|
}
|
package/src/utils.ts
CHANGED
|
@@ -1,38 +1,45 @@
|
|
|
1
|
-
import {
|
|
2
|
-
FetchError,
|
|
3
|
-
ResponseError as ClientResponseError,
|
|
4
|
-
} from './client/runtime';
|
|
1
|
+
import { FetchError, ResponseError as ClientResponseError } from './client/runtime';
|
|
5
2
|
import { RequestError, ResponseError } from './error';
|
|
6
3
|
|
|
7
4
|
/** ShapeDiver error object structure. */
|
|
8
|
-
|
|
5
|
+
interface SdErrorObject {
|
|
9
6
|
error: string;
|
|
10
7
|
desc: string;
|
|
11
8
|
message: string;
|
|
12
|
-
}
|
|
9
|
+
}
|
|
13
10
|
|
|
14
11
|
/** Delays the response for the given number of milliseconds */
|
|
15
12
|
export function sleep(ms: number): Promise<void> {
|
|
16
13
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
17
14
|
}
|
|
18
15
|
|
|
16
|
+
function headerValue(
|
|
17
|
+
headers: Record<string, string | null | undefined>,
|
|
18
|
+
...names: string[]
|
|
19
|
+
): string | undefined {
|
|
20
|
+
for (const name of names) {
|
|
21
|
+
const value = headers[name];
|
|
22
|
+
if (typeof value === 'string' && value.length > 0) return value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
19
28
|
/**
|
|
20
29
|
* Parse HTTP headers to extract size and filename information.
|
|
21
30
|
* @param headers The HTTP headers of a file-metadata response.
|
|
22
31
|
* @return An object with 'size' and 'filename' properties.
|
|
23
32
|
*/
|
|
24
|
-
export function extractFileInfo(headers: Record<string,
|
|
33
|
+
export function extractFileInfo(headers: Record<string, string | null | undefined> | undefined): {
|
|
25
34
|
size: number | undefined;
|
|
26
35
|
filename: string | undefined;
|
|
27
36
|
} {
|
|
28
37
|
if (!headers) return { size: undefined, filename: undefined };
|
|
29
38
|
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
const size = contentLength ? parseInt(contentLength) : undefined;
|
|
39
|
+
const contentLength = headerValue(headers, 'Content-Length', 'content-length');
|
|
40
|
+
const size = contentLength ? parseInt(contentLength, 10) : undefined;
|
|
33
41
|
|
|
34
|
-
|
|
35
|
-
const contentDisposition = headers['Content-Disposition'] || headers['content-disposition'];
|
|
42
|
+
const contentDisposition = headerValue(headers, 'Content-Disposition', 'content-disposition');
|
|
36
43
|
const filename = contentDisposition
|
|
37
44
|
? filenameFromContentDisposition(contentDisposition)
|
|
38
45
|
: undefined;
|
|
@@ -47,7 +54,9 @@ export function extractFileInfo(headers: Record<string, any> | undefined): {
|
|
|
47
54
|
*/
|
|
48
55
|
export function contentDispositionFromFilename(filename: string): string {
|
|
49
56
|
// Normalize the filename to ASCII
|
|
50
|
-
const asciiName = filename.normalize('NFKD')
|
|
57
|
+
const asciiName = [...filename.normalize('NFKD')]
|
|
58
|
+
.filter((char) => char.charCodeAt(0) <= 0x7f)
|
|
59
|
+
.join('');
|
|
51
60
|
let header = `attachment; filename="${asciiName}"`;
|
|
52
61
|
|
|
53
62
|
if (asciiName !== filename) {
|
|
@@ -96,8 +105,9 @@ export function filenameFromContentDisposition(contentDisposition: string): stri
|
|
|
96
105
|
export async function exists(apiCall: () => Promise<unknown>): Promise<boolean> {
|
|
97
106
|
return apiCall()
|
|
98
107
|
.then(() => true)
|
|
99
|
-
.catch((error) => {
|
|
100
|
-
if (error.response
|
|
108
|
+
.catch((error: unknown) => {
|
|
109
|
+
if (error instanceof ClientResponseError && error.response.status === 404)
|
|
110
|
+
return false;
|
|
101
111
|
throw error;
|
|
102
112
|
});
|
|
103
113
|
}
|
|
@@ -117,7 +127,7 @@ function isErrorObject(value: unknown): value is SdErrorObject {
|
|
|
117
127
|
/** Helper function that wraps JSON.parse and returns undefined on failure. */
|
|
118
128
|
async function tryParseJson(
|
|
119
129
|
input: string | (() => string) | (() => Promise<string>)
|
|
120
|
-
): Promise<unknown
|
|
130
|
+
): Promise<unknown> {
|
|
121
131
|
try {
|
|
122
132
|
const text = typeof input === 'function' ? await input() : input;
|
|
123
133
|
return JSON.parse(text);
|
|
@@ -178,17 +188,16 @@ export async function processError(
|
|
|
178
188
|
}
|
|
179
189
|
|
|
180
190
|
if (typeof Response !== 'undefined' && error instanceof Response) {
|
|
181
|
-
return processResponseError(
|
|
182
|
-
error,
|
|
183
|
-
error.statusText || 'Response returned an error code'
|
|
184
|
-
);
|
|
191
|
+
return processResponseError(error, error.statusText || 'Response returned an error code');
|
|
185
192
|
}
|
|
186
193
|
|
|
187
194
|
if (error instanceof FetchError) {
|
|
188
195
|
return new RequestError(error.cause.message);
|
|
189
196
|
}
|
|
190
197
|
|
|
191
|
-
|
|
198
|
+
if (error instanceof Error) return error;
|
|
199
|
+
|
|
200
|
+
return new Error('Unknown error');
|
|
192
201
|
}
|
|
193
202
|
|
|
194
203
|
/** Converts a non-success Fetch response into the SDK's public response error. */
|
|
@@ -199,15 +208,6 @@ async function processResponseError(
|
|
|
199
208
|
const errorObj = await tryExtractErrorObject(await response.clone().text());
|
|
200
209
|
|
|
201
210
|
return errorObj
|
|
202
|
-
? new ResponseError(
|
|
203
|
-
|
|
204
|
-
errorObj.message,
|
|
205
|
-
errorObj.desc,
|
|
206
|
-
errorObj.error
|
|
207
|
-
)
|
|
208
|
-
: new ResponseError(
|
|
209
|
-
response.status,
|
|
210
|
-
fallbackMessage,
|
|
211
|
-
'No error description provided'
|
|
212
|
-
);
|
|
211
|
+
? new ResponseError(response.status, errorObj.message, errorObj.desc, errorObj.error)
|
|
212
|
+
: new ResponseError(response.status, fallbackMessage, 'No error description provided');
|
|
213
213
|
}
|