@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.
Files changed (81) hide show
  1. package/README.md +3 -2
  2. package/dist/UtilsApi.d.ts +3 -3
  3. package/dist/UtilsApi.d.ts.map +1 -1
  4. package/dist/UtilsApi.js +12 -15
  5. package/dist/UtilsApi.js.map +1 -1
  6. package/dist/base.d.ts.map +1 -1
  7. package/dist/base.js +3 -8
  8. package/dist/base.js.map +1 -1
  9. package/dist/client/apis/AnalyticsApi.d.ts.map +1 -1
  10. package/dist/client/apis/AnalyticsApi.js.map +1 -1
  11. package/dist/client/apis/ArSceneApi.d.ts.map +1 -1
  12. package/dist/client/apis/ArSceneApi.js.map +1 -1
  13. package/dist/client/apis/AssetsApi.d.ts.map +1 -1
  14. package/dist/client/apis/AssetsApi.js.map +1 -1
  15. package/dist/client/apis/AuthGroupApi.d.ts.map +1 -1
  16. package/dist/client/apis/AuthGroupApi.js.map +1 -1
  17. package/dist/client/apis/ExportApi.d.ts.map +1 -1
  18. package/dist/client/apis/ExportApi.js.map +1 -1
  19. package/dist/client/apis/FileApi.d.ts.map +1 -1
  20. package/dist/client/apis/FileApi.js.map +1 -1
  21. package/dist/client/apis/GltfApi.d.ts.map +1 -1
  22. package/dist/client/apis/GltfApi.js.map +1 -1
  23. package/dist/client/apis/LogApi.d.ts.map +1 -1
  24. package/dist/client/apis/LogApi.js.map +1 -1
  25. package/dist/client/apis/ModelApi.d.ts +12 -1
  26. package/dist/client/apis/ModelApi.d.ts.map +1 -1
  27. package/dist/client/apis/ModelApi.js +52 -0
  28. package/dist/client/apis/ModelApi.js.map +1 -1
  29. package/dist/client/apis/ModelStateApi.d.ts.map +1 -1
  30. package/dist/client/apis/ModelStateApi.js.map +1 -1
  31. package/dist/client/apis/OutputApi.d.ts.map +1 -1
  32. package/dist/client/apis/OutputApi.js.map +1 -1
  33. package/dist/client/apis/ScriptApi.d.ts.map +1 -1
  34. package/dist/client/apis/ScriptApi.js.map +1 -1
  35. package/dist/client/apis/SdtfApi.d.ts.map +1 -1
  36. package/dist/client/apis/SdtfApi.js.map +1 -1
  37. package/dist/client/apis/SessionApi.d.ts.map +1 -1
  38. package/dist/client/apis/SessionApi.js.map +1 -1
  39. package/dist/client/apis/SystemApi.d.ts.map +1 -1
  40. package/dist/client/apis/SystemApi.js.map +1 -1
  41. package/dist/client/apis/TextureApi.d.ts.map +1 -1
  42. package/dist/client/apis/TextureApi.js.map +1 -1
  43. package/dist/client/models/index.d.ts +43 -0
  44. package/dist/client/models/index.d.ts.map +1 -1
  45. package/dist/client/models/index.js +29 -24
  46. package/dist/client/models/index.js.map +1 -1
  47. package/dist/client/runtime.d.ts +1 -0
  48. package/dist/client/runtime.d.ts.map +1 -1
  49. package/dist/client/runtime.js +5 -1
  50. package/dist/client/runtime.js.map +1 -1
  51. package/dist/configuration.d.ts.map +1 -1
  52. package/dist/configuration.js +8 -10
  53. package/dist/configuration.js.map +1 -1
  54. package/dist/utils.d.ts +3 -3
  55. package/dist/utils.d.ts.map +1 -1
  56. package/dist/utils.js +18 -7
  57. package/dist/utils.js.map +1 -1
  58. package/package.json +5 -6
  59. package/src/UtilsApi.ts +40 -41
  60. package/src/base.ts +9 -16
  61. package/src/client/apis/AnalyticsApi.ts +22 -1
  62. package/src/client/apis/ArSceneApi.ts +10 -1
  63. package/src/client/apis/AssetsApi.ts +40 -1
  64. package/src/client/apis/AuthApi.ts +1 -1
  65. package/src/client/apis/AuthGroupApi.ts +4 -1
  66. package/src/client/apis/ExportApi.ts +40 -1
  67. package/src/client/apis/FileApi.ts +43 -1
  68. package/src/client/apis/GltfApi.ts +10 -1
  69. package/src/client/apis/LogApi.ts +7 -1
  70. package/src/client/apis/ModelApi.ts +243 -1
  71. package/src/client/apis/ModelStateApi.ts +37 -1
  72. package/src/client/apis/OutputApi.ts +40 -1
  73. package/src/client/apis/ScriptApi.ts +7 -1
  74. package/src/client/apis/SdtfApi.ts +34 -1
  75. package/src/client/apis/SessionApi.ts +60 -1
  76. package/src/client/apis/SystemApi.ts +10 -1
  77. package/src/client/apis/TextureApi.ts +7 -1
  78. package/src/client/models/index.ts +179 -1777
  79. package/src/client/runtime.ts +14 -2
  80. package/src/configuration.ts +15 -18
  81. package/src/utils.ts +32 -32
@@ -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.5.0
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.toISOString())}`;
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) {
@@ -3,10 +3,12 @@ import {
3
3
  ConfigurationParameters as ClientConfigParams,
4
4
  } from './client/runtime';
5
5
 
6
- const SDK_VERSION = '4.2.2'; // WARNING: This value is updated automatically!
6
+ const SDK_VERSION = '4.4.0'; // WARNING: This value is updated automatically!
7
7
 
8
- export interface ConfigurationParameters
9
- extends Pick<ClientConfigParams, 'accessToken' | 'basePath' | 'fetchApi' | 'headers' | 'middleware' | 'queryParamsStringify'> {
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() === "node" && !normalizedHeaders.has('User-Agent')) {
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(): "node" | "browser" | "unknown" {
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 === "string") {
88
- return "node";
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 "browser";
97
+ return 'browser';
101
98
  }
102
99
 
103
- return "unknown";
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
- type SdErrorObject = {
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, any> | undefined): {
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
- // Extract size from Content-Length header
31
- const contentLength = headers['Content-Length'] || headers['content-length'];
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
- // Extract filename from Content-Disposition header
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').replace(/[^\x00-\x7F]/g, ''); // Transliterates to ASCII
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?.status === 404) return false;
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 | undefined> {
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
- return error instanceof Error ? error : new Error(String(error));
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
- response.status,
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
  }