@shapediver/sdk.geometry-api-sdk-v2 1.8.3 → 1.9.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 (67) hide show
  1. package/dist/ShapeDiverErrors.d.ts.map +1 -1
  2. package/dist/ShapeDiverErrors.js +1 -1
  3. package/dist/ShapeDiverErrors.js.map +1 -1
  4. package/dist/ShapeDiverSdk.d.ts.map +1 -1
  5. package/dist/ShapeDiverSdk.js.map +1 -1
  6. package/dist/index.d.ts +2 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/resources/ShapeDiverAnalyticsApi.d.ts.map +1 -1
  10. package/dist/resources/ShapeDiverAnalyticsApi.js +3 -1
  11. package/dist/resources/ShapeDiverAnalyticsApi.js.map +1 -1
  12. package/dist/resources/ShapeDiverArSceneApi.d.ts.map +1 -1
  13. package/dist/resources/ShapeDiverArSceneApi.js.map +1 -1
  14. package/dist/resources/ShapeDiverAssetApi.d.ts.map +1 -1
  15. package/dist/resources/ShapeDiverAssetApi.js.map +1 -1
  16. package/dist/resources/ShapeDiverExportApi.d.ts.map +1 -1
  17. package/dist/resources/ShapeDiverExportApi.js.map +1 -1
  18. package/dist/resources/ShapeDiverFileApi.d.ts.map +1 -1
  19. package/dist/resources/ShapeDiverFileApi.js +10 -7
  20. package/dist/resources/ShapeDiverFileApi.js.map +1 -1
  21. package/dist/resources/ShapeDiverGltfApi.d.ts.map +1 -1
  22. package/dist/resources/ShapeDiverGltfApi.js +4 -1
  23. package/dist/resources/ShapeDiverGltfApi.js.map +1 -1
  24. package/dist/resources/ShapeDiverModelApi.d.ts.map +1 -1
  25. package/dist/resources/ShapeDiverModelApi.js +52 -15
  26. package/dist/resources/ShapeDiverModelApi.js.map +1 -1
  27. package/dist/resources/ShapeDiverOutputApi.d.ts.map +1 -1
  28. package/dist/resources/ShapeDiverOutputApi.js +12 -4
  29. package/dist/resources/ShapeDiverOutputApi.js.map +1 -1
  30. package/dist/resources/ShapeDiverSdtfApi.d.ts.map +1 -1
  31. package/dist/resources/ShapeDiverSdtfApi.js +9 -3
  32. package/dist/resources/ShapeDiverSdtfApi.js.map +1 -1
  33. package/dist/resources/ShapeDiverSessionApi.d.ts.map +1 -1
  34. package/dist/resources/ShapeDiverSessionApi.js +3 -1
  35. package/dist/resources/ShapeDiverSessionApi.js.map +1 -1
  36. package/dist/resources/ShapeDiverSystemApi.d.ts.map +1 -1
  37. package/dist/resources/ShapeDiverSystemApi.js +18 -6
  38. package/dist/resources/ShapeDiverSystemApi.js.map +1 -1
  39. package/dist/resources/ShapeDiverTextureApi.d.ts.map +1 -1
  40. package/dist/resources/ShapeDiverTextureApi.js +3 -1
  41. package/dist/resources/ShapeDiverTextureApi.js.map +1 -1
  42. package/dist/resources/ShapeDiverUtilsApi.d.ts +3 -5
  43. package/dist/resources/ShapeDiverUtilsApi.d.ts.map +1 -1
  44. package/dist/resources/ShapeDiverUtilsApi.js +31 -15
  45. package/dist/resources/ShapeDiverUtilsApi.js.map +1 -1
  46. package/dist/utils/utils.d.ts +1 -1
  47. package/dist/utils/utils.d.ts.map +1 -1
  48. package/dist/utils/utils.js +9 -9
  49. package/dist/utils/utils.js.map +1 -1
  50. package/package.json +4 -2
  51. package/src/ShapeDiverErrors.ts +24 -23
  52. package/src/ShapeDiverSdk.ts +110 -109
  53. package/src/index.ts +15 -16
  54. package/src/resources/ShapeDiverAnalyticsApi.ts +30 -18
  55. package/src/resources/ShapeDiverArSceneApi.ts +68 -69
  56. package/src/resources/ShapeDiverAssetApi.ts +207 -183
  57. package/src/resources/ShapeDiverExportApi.ts +92 -77
  58. package/src/resources/ShapeDiverFileApi.ts +136 -108
  59. package/src/resources/ShapeDiverGltfApi.ts +41 -30
  60. package/src/resources/ShapeDiverModelApi.ts +351 -240
  61. package/src/resources/ShapeDiverOutputApi.ts +92 -56
  62. package/src/resources/ShapeDiverSdtfApi.ts +88 -54
  63. package/src/resources/ShapeDiverSessionApi.ts +104 -82
  64. package/src/resources/ShapeDiverSystemApi.ts +106 -70
  65. package/src/resources/ShapeDiverTextureApi.ts +24 -18
  66. package/src/resources/ShapeDiverUtilsApi.ts +290 -231
  67. package/src/utils/utils.ts +61 -53
@@ -1,123 +1,151 @@
1
- import { ShapeDiverRequestFileUpload, ShapeDiverResponseDto } from "@shapediver/api.geometry-api-dto-v2"
2
- import { BaseResourceApi, ShapeDiverSdkApi, ShapeDiverSdkApiResponseType } from "@shapediver/sdk.geometry-api-sdk-core"
3
- import { sendRequest } from "../utils/utils"
1
+ import {
2
+ ShapeDiverRequestFileUpload,
3
+ ShapeDiverResponseDto,
4
+ } from "@shapediver/api.geometry-api-dto-v2";
5
+ import {
6
+ BaseResourceApi,
7
+ ShapeDiverSdkApi,
8
+ ShapeDiverSdkApiResponseType,
9
+ } from "@shapediver/sdk.geometry-api-sdk-core";
10
+ import { sendRequest } from "../utils/utils";
11
+
12
+ const contentDisposition = require("content-disposition");
4
13
 
5
14
  export interface ShapeDiverResponseFileInfo {
6
- filename?: string,
7
- size?: number,
15
+ filename?: string;
16
+ size?: number;
8
17
  }
9
18
 
10
19
  export class ShapeDiverFileApi extends BaseResourceApi {
20
+ constructor(api: ShapeDiverSdkApi) {
21
+ super(api);
22
+ }
11
23
 
12
- constructor (api: ShapeDiverSdkApi) {
13
- super(api)
14
- }
24
+ /**
25
+ * List all file-assets of the given parameter.
26
+ *
27
+ * @param sessionId
28
+ * @param paramId
29
+ */
30
+ async list(
31
+ sessionId: string,
32
+ paramId: string,
33
+ ): Promise<ShapeDiverResponseDto> {
34
+ return await sendRequest(
35
+ async () =>
36
+ (
37
+ await this.api.get<ShapeDiverResponseDto>(
38
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/list`,
39
+ )
40
+ )[1],
41
+ );
42
+ }
15
43
 
16
- /**
17
- * List all file-assets of the given parameter.
18
- *
19
- * @param sessionId
20
- * @param paramId
21
- */
22
- async list (sessionId: string, paramId: string): Promise<ShapeDiverResponseDto> {
23
- return await sendRequest(async () =>
24
- (await this.api.get<ShapeDiverResponseDto>(
25
- `${ this.buildSessionUri(sessionId) }/file/${ paramId }/list`,
26
- ))[1],
44
+ /**
45
+ * Get information about a file-asset of a parameter.
46
+ *
47
+ * @param sessionId
48
+ * @param paramId
49
+ */
50
+ async info(
51
+ sessionId: string,
52
+ paramId: string,
53
+ fileId: string,
54
+ ): Promise<ShapeDiverResponseFileInfo> {
55
+ return await sendRequest(async () => {
56
+ const headers = (
57
+ await this.api.head(
58
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
27
59
  )
28
- }
29
-
30
- /**
31
- * Get information about a file-asset of a parameter.
32
- *
33
- * @param sessionId
34
- * @param paramId
35
- */
36
- async info (
37
- sessionId: string,
38
- paramId: string,
39
- fileId: string,
40
- ): Promise<ShapeDiverResponseFileInfo> {
41
- return await sendRequest(async () => {
42
- const headers = (await this.api.head(
43
- `${ this.buildSessionUri(sessionId) }/file/${ paramId }/${ fileId }`,
44
- ))[0]
45
-
46
- const res: ShapeDiverResponseFileInfo = {
47
- size: Number(headers.get("Content-Length") || headers.get("content-length")),
48
- }
60
+ )[0];
49
61
 
50
- // Extract filename from Content-Disposition header if available
51
- const contentDisposition = headers.get("Content-Disposition")
52
- || headers.get("content-disposition")
53
- if (
54
- typeof contentDisposition === "string" &&
55
- contentDisposition.indexOf("=") > 0
56
- ) {
57
- res.filename = contentDisposition
58
- .split("=")[1] // Extract filename
59
- .slice(1, -1) // remove leading and trailing double quotes
60
- }
62
+ const res: ShapeDiverResponseFileInfo = {
63
+ size: Number(
64
+ headers.get("Content-Length") || headers.get("content-length"),
65
+ ),
66
+ };
61
67
 
62
- return res
63
- })
64
- }
68
+ // Extract filename from Content-Disposition header if available
69
+ const contentDispositionHeader =
70
+ headers.get("Content-Disposition") ||
71
+ headers.get("content-disposition");
72
+ if (typeof contentDispositionHeader === "string") {
73
+ try {
74
+ res.filename = contentDisposition.parse(
75
+ contentDispositionHeader,
76
+ ).parameters.filename;
77
+ } catch (_) {
78
+ res.filename = undefined;
79
+ }
80
+ }
65
81
 
66
- /**
67
- * Download a file-asset.
68
- *
69
- * @param sessionId
70
- * @param paramId
71
- * @param fileId
72
- */
73
- async get (
74
- sessionId: string,
75
- paramId: string,
76
- fileId: string,
77
- ): Promise<ArrayBuffer> {
78
- return await sendRequest(async () =>
79
- (await this.api.get<ArrayBuffer>(
80
- `${ this.buildSessionUri(sessionId) }/file/${ paramId }/${ fileId }`,
81
- { responseType: ShapeDiverSdkApiResponseType.DATA },
82
- ))[1],
83
- )
84
- }
82
+ return res;
83
+ });
84
+ }
85
85
 
86
- /**
87
- * Delete a file-asset.
88
- *
89
- * @param sessionId
90
- * @param paramId
91
- * @param fileId
92
- */
93
- async delete (
94
- sessionId: string,
95
- paramId: string,
96
- fileId: string,
97
- ): Promise<ShapeDiverResponseDto> {
98
- return await sendRequest(async () =>
99
- (await this.api.delete<ShapeDiverResponseDto>(
100
- `${ this.buildSessionUri(sessionId) }/file/${ paramId }/${ fileId }`,
101
- ))[1],
102
- )
103
- }
86
+ /**
87
+ * Download a file-asset.
88
+ *
89
+ * @param sessionId
90
+ * @param paramId
91
+ * @param fileId
92
+ */
93
+ async get(
94
+ sessionId: string,
95
+ paramId: string,
96
+ fileId: string,
97
+ ): Promise<ArrayBuffer> {
98
+ return await sendRequest(
99
+ async () =>
100
+ (
101
+ await this.api.get<ArrayBuffer>(
102
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
103
+ { responseType: ShapeDiverSdkApiResponseType.DATA },
104
+ )
105
+ )[1],
106
+ );
107
+ }
104
108
 
105
- /**
106
- * Request an Upload-URL for a file.
107
- *
108
- * @param sessionId
109
- * @param body
110
- */
111
- async requestUpload (
112
- sessionId: string,
113
- body: ShapeDiverRequestFileUpload,
114
- ): Promise<ShapeDiverResponseDto> {
115
- return await sendRequest(async () =>
116
- (await this.api.post<ShapeDiverResponseDto>(
117
- this.buildSessionUri(sessionId) + "/file/upload",
118
- body
119
- ))[1],
120
- )
121
- }
109
+ /**
110
+ * Delete a file-asset.
111
+ *
112
+ * @param sessionId
113
+ * @param paramId
114
+ * @param fileId
115
+ */
116
+ async delete(
117
+ sessionId: string,
118
+ paramId: string,
119
+ fileId: string,
120
+ ): Promise<ShapeDiverResponseDto> {
121
+ return await sendRequest(
122
+ async () =>
123
+ (
124
+ await this.api.delete<ShapeDiverResponseDto>(
125
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
126
+ )
127
+ )[1],
128
+ );
129
+ }
122
130
 
131
+ /**
132
+ * Request an Upload-URL for a file.
133
+ *
134
+ * @param sessionId
135
+ * @param body
136
+ */
137
+ async requestUpload(
138
+ sessionId: string,
139
+ body: ShapeDiverRequestFileUpload,
140
+ ): Promise<ShapeDiverResponseDto> {
141
+ return await sendRequest(
142
+ async () =>
143
+ (
144
+ await this.api.post<ShapeDiverResponseDto>(
145
+ this.buildSessionUri(sessionId) + "/file/upload",
146
+ body,
147
+ )
148
+ )[1],
149
+ );
150
+ }
123
151
  }
@@ -1,34 +1,45 @@
1
- import { ShapeDiverRequestGltfUploadQueryConversion, ShapeDiverResponseDto } from "@shapediver/api.geometry-api-dto-v2"
2
- import { BaseResourceApi, ShapeDiverSdkApi, ShapeDiverSdkApiResponseType } from "@shapediver/sdk.geometry-api-sdk-core"
3
- import { sendRequest } from "../utils/utils"
1
+ import {
2
+ ShapeDiverRequestGltfUploadQueryConversion,
3
+ ShapeDiverResponseDto,
4
+ } from "@shapediver/api.geometry-api-dto-v2";
5
+ import {
6
+ BaseResourceApi,
7
+ ShapeDiverSdkApi,
8
+ ShapeDiverSdkApiResponseType,
9
+ } from "@shapediver/sdk.geometry-api-sdk-core";
10
+ import { sendRequest } from "../utils/utils";
4
11
 
5
12
  export class ShapeDiverGltfApi extends BaseResourceApi {
13
+ constructor(api: ShapeDiverSdkApi) {
14
+ super(api);
15
+ }
6
16
 
7
- constructor (api: ShapeDiverSdkApi) {
8
- super(api)
9
- }
10
-
11
- /**
12
- * Upload a glTF file.
13
- *
14
- * @param sessionId
15
- * @param body
16
- * @param type
17
- * @param queryConvert
18
- */
19
- async upload (
20
- sessionId: string,
21
- body: ArrayBuffer,
22
- type: string,
23
- queryConvert: ShapeDiverRequestGltfUploadQueryConversion = ShapeDiverRequestGltfUploadQueryConversion.NONE,
24
- ): Promise<ShapeDiverResponseDto> {
25
- return await sendRequest(async () =>
26
- (await this.api.post<ShapeDiverResponseDto>(
27
- `${ this.buildSessionUri(sessionId) }/gltf?conversion=${ queryConvert }`,
28
- body,
29
- { contentType: type, responseType: ShapeDiverSdkApiResponseType.JSON },
30
- ))[1],
31
- )
32
- }
33
-
17
+ /**
18
+ * Upload a glTF file.
19
+ *
20
+ * @param sessionId
21
+ * @param body
22
+ * @param type
23
+ * @param queryConvert
24
+ */
25
+ async upload(
26
+ sessionId: string,
27
+ body: ArrayBuffer,
28
+ type: string,
29
+ queryConvert: ShapeDiverRequestGltfUploadQueryConversion = ShapeDiverRequestGltfUploadQueryConversion.NONE,
30
+ ): Promise<ShapeDiverResponseDto> {
31
+ return await sendRequest(
32
+ async () =>
33
+ (
34
+ await this.api.post<ShapeDiverResponseDto>(
35
+ `${this.buildSessionUri(sessionId)}/gltf?conversion=${queryConvert}`,
36
+ body,
37
+ {
38
+ contentType: type,
39
+ responseType: ShapeDiverSdkApiResponseType.JSON,
40
+ },
41
+ )
42
+ )[1],
43
+ );
44
+ }
34
45
  }