@shapediver/sdk.geometry-api-sdk-v2 1.8.3 → 1.9.1

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 +4 -8
  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 +32 -15
  45. package/dist/resources/ShapeDiverUtilsApi.js.map +1 -1
  46. package/dist/utils/utils.d.ts +3 -1
  47. package/dist/utils/utils.d.ts.map +1 -1
  48. package/dist/utils/utils.js +35 -9
  49. package/dist/utils/utils.js.map +1 -1
  50. package/package.json +2 -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 +127 -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 +294 -231
  67. package/src/utils/utils.ts +100 -54
@@ -1,123 +1,142 @@
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 { filenameFromContentDisposition, sendRequest } from "../utils/utils";
4
11
 
5
12
  export interface ShapeDiverResponseFileInfo {
6
- filename?: string,
7
- size?: number,
13
+ filename?: string;
14
+ size?: number;
8
15
  }
9
16
 
10
17
  export class ShapeDiverFileApi extends BaseResourceApi {
18
+ constructor(api: ShapeDiverSdkApi) {
19
+ super(api);
20
+ }
11
21
 
12
- constructor (api: ShapeDiverSdkApi) {
13
- super(api)
14
- }
22
+ /**
23
+ * List all file-assets of the given parameter.
24
+ *
25
+ * @param sessionId
26
+ * @param paramId
27
+ */
28
+ async list(
29
+ sessionId: string,
30
+ paramId: string,
31
+ ): Promise<ShapeDiverResponseDto> {
32
+ return await sendRequest(
33
+ async () =>
34
+ (
35
+ await this.api.get<ShapeDiverResponseDto>(
36
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/list`,
37
+ )
38
+ )[1],
39
+ );
40
+ }
15
41
 
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],
42
+ /**
43
+ * Get information about a file-asset of a parameter.
44
+ *
45
+ * @param sessionId
46
+ * @param paramId
47
+ */
48
+ async info(
49
+ sessionId: string,
50
+ paramId: string,
51
+ fileId: string,
52
+ ): Promise<ShapeDiverResponseFileInfo> {
53
+ return await sendRequest(async () => {
54
+ const headers = (
55
+ await this.api.head(
56
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
27
57
  )
28
- }
58
+ )[0];
29
59
 
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]
60
+ const res: ShapeDiverResponseFileInfo = {
61
+ size: Number(
62
+ headers.get("Content-Length") || headers.get("content-length"),
63
+ ),
64
+ };
45
65
 
46
- const res: ShapeDiverResponseFileInfo = {
47
- size: Number(headers.get("Content-Length") || headers.get("content-length")),
48
- }
66
+ // Extract filename from Content-Disposition header if available
67
+ const contentDispositionHeader =
68
+ headers.get("Content-Disposition") ||
69
+ headers.get("content-disposition");
70
+ if (typeof contentDispositionHeader === "string")
71
+ res.filename = filenameFromContentDisposition(contentDispositionHeader);
49
72
 
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
- }
73
+ return res;
74
+ });
75
+ }
61
76
 
62
- return res
63
- })
64
- }
77
+ /**
78
+ * Download a file-asset.
79
+ *
80
+ * @param sessionId
81
+ * @param paramId
82
+ * @param fileId
83
+ */
84
+ async get(
85
+ sessionId: string,
86
+ paramId: string,
87
+ fileId: string,
88
+ ): Promise<ArrayBuffer> {
89
+ return await sendRequest(
90
+ async () =>
91
+ (
92
+ await this.api.get<ArrayBuffer>(
93
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
94
+ { responseType: ShapeDiverSdkApiResponseType.DATA },
95
+ )
96
+ )[1],
97
+ );
98
+ }
65
99
 
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
- }
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
- }
104
-
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
- }
100
+ /**
101
+ * Delete a file-asset.
102
+ *
103
+ * @param sessionId
104
+ * @param paramId
105
+ * @param fileId
106
+ */
107
+ async delete(
108
+ sessionId: string,
109
+ paramId: string,
110
+ fileId: string,
111
+ ): Promise<ShapeDiverResponseDto> {
112
+ return await sendRequest(
113
+ async () =>
114
+ (
115
+ await this.api.delete<ShapeDiverResponseDto>(
116
+ `${this.buildSessionUri(sessionId)}/file/${paramId}/${fileId}`,
117
+ )
118
+ )[1],
119
+ );
120
+ }
122
121
 
122
+ /**
123
+ * Request an Upload-URL for a file.
124
+ *
125
+ * @param sessionId
126
+ * @param body
127
+ */
128
+ async requestUpload(
129
+ sessionId: string,
130
+ body: ShapeDiverRequestFileUpload,
131
+ ): Promise<ShapeDiverResponseDto> {
132
+ return await sendRequest(
133
+ async () =>
134
+ (
135
+ await this.api.post<ShapeDiverResponseDto>(
136
+ this.buildSessionUri(sessionId) + "/file/upload",
137
+ body,
138
+ )
139
+ )[1],
140
+ );
141
+ }
123
142
  }
@@ -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
  }