@sparkstudio/storage-ui 1.0.9 → 1.0.12

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/dist/index.cjs CHANGED
@@ -26,6 +26,7 @@ __export(index_exports, {
26
26
  ContainerType: () => ContainerType,
27
27
  Home: () => Home,
28
28
  HomeView: () => HomeView,
29
+ S3: () => S3,
29
30
  SparkStudioStorageSDK: () => SparkStudioStorageSDK,
30
31
  UploadContainer: () => UploadContainer
31
32
  });
@@ -109,8 +110,8 @@ var Container = class {
109
110
  if (!response.ok) throw new Error(await response.text());
110
111
  return await response.json();
111
112
  }
112
- async Delete(id) {
113
- const url = `${this.baseUrl}/api/Container/Delete/` + id;
113
+ async DeleteContainer(id) {
114
+ const url = `${this.baseUrl}/api/Container/DeleteContainer/` + id;
114
115
  const token = localStorage.getItem("auth_token");
115
116
  const requestOptions = {
116
117
  method: "GET",
@@ -123,8 +124,8 @@ var Container = class {
123
124
  if (!response.ok) throw new Error(await response.text());
124
125
  return await response.json();
125
126
  }
126
- async GetPreSignedUrl(fileName, size, contentType) {
127
- const url = `${this.baseUrl}/api/Container/GetPreSignedUrl/` + fileName + `/` + size + `/` + contentType;
127
+ async CreateFileContainer(fileName, size, contentType) {
128
+ const url = `${this.baseUrl}/api/Container/CreateFileContainer/` + fileName + `/` + size + `/` + contentType;
128
129
  const token = localStorage.getItem("auth_token");
129
130
  const requestOptions = {
130
131
  method: "GET",
@@ -147,13 +148,53 @@ var Home = class {
147
148
  }
148
149
  };
149
150
 
151
+ // src/api/Controllers/S3.ts
152
+ var S3 = class {
153
+ baseUrl;
154
+ constructor(baseUrl) {
155
+ this.baseUrl = baseUrl;
156
+ }
157
+ async DeleteS3(containerDTO) {
158
+ const url = `${this.baseUrl}/api/S3/DeleteS3`;
159
+ const token = localStorage.getItem("auth_token");
160
+ const requestOptions = {
161
+ method: "POST",
162
+ headers: {
163
+ "Content-Type": "application/json",
164
+ ...token && { Authorization: `Bearer ${token}` }
165
+ },
166
+ body: JSON.stringify(containerDTO)
167
+ };
168
+ const response = await fetch(url, requestOptions);
169
+ if (!response.ok) throw new Error(await response.text());
170
+ return await response.json();
171
+ }
172
+ async GetPreSignedUrl(containerDTO) {
173
+ const url = `${this.baseUrl}/api/S3/GetPreSignedUrl`;
174
+ const token = localStorage.getItem("auth_token");
175
+ const requestOptions = {
176
+ method: "POST",
177
+ headers: {
178
+ "Content-Type": "application/json",
179
+ ...token && { Authorization: `Bearer ${token}` }
180
+ },
181
+ body: JSON.stringify(containerDTO)
182
+ };
183
+ const response = await fetch(url, requestOptions);
184
+ if (!response.ok) throw new Error(await response.text());
185
+ return await response.json();
186
+ }
187
+ };
188
+
150
189
  // src/api/SparkStudioStorageSDK.ts
151
190
  var SparkStudioStorageSDK = class {
152
191
  container;
153
192
  home;
193
+ s3;
154
194
  constructor(baseUrl) {
155
195
  this.container = new Container(baseUrl);
156
196
  this.home = new Home(baseUrl);
197
+ this.s3 = new S3(baseUrl);
157
198
  }
158
199
  };
159
200
 
@@ -392,9 +433,11 @@ function HomeView() {
392
433
  alert(user?.Id);
393
434
  }
394
435
  const getPresignedUrl = async (file) => {
395
- const sdk = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
396
- const result = await sdk.container.GetPreSignedUrl(file.name, file.size, encodeURIComponent(file.type));
397
- return result;
436
+ const sdkDb = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
437
+ const sdkS3 = new SparkStudioStorageSDK("https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod");
438
+ const containerDTO = await sdkDb.container.CreateFileContainer(file.name, file.size, encodeURIComponent(file.type));
439
+ const resultS3 = await sdkS3.s3.GetPreSignedUrl(containerDTO);
440
+ return resultS3;
398
441
  };
399
442
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
400
443
  import_authentication_ui.AuthenticatorProvider,
@@ -434,6 +477,7 @@ function HomeView() {
434
477
  ContainerType,
435
478
  Home,
436
479
  HomeView,
480
+ S3,
437
481
  SparkStudioStorageSDK,
438
482
  UploadContainer
439
483
  });
package/dist/index.d.cts CHANGED
@@ -33,6 +33,29 @@ declare class ContainerDTO implements IContainerDTO {
33
33
  constructor(init: ContainerDTOInit);
34
34
  }
35
35
 
36
+ /**
37
+ * Auto-generated client for the Container controller.
38
+ */
39
+ declare class Container {
40
+ private baseUrl;
41
+ constructor(baseUrl: string);
42
+ ReadChildrenByContainerId(parentId: string): Promise<ContainerDTO[]>;
43
+ ReadRootContainers(): Promise<ContainerDTO[]>;
44
+ Read(id: string): Promise<ContainerDTO>;
45
+ Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
46
+ Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
47
+ DeleteContainer(id: string): Promise<ContainerDTO>;
48
+ CreateFileContainer(fileName: string, size: number, contentType: string): Promise<ContainerDTO>;
49
+ }
50
+
51
+ /**
52
+ * Auto-generated client for the Home controller.
53
+ */
54
+ declare class Home {
55
+ private baseUrl;
56
+ constructor(baseUrl: string);
57
+ }
58
+
36
59
  /**
37
60
  * Represents an Auto-generated model for AWSPresignedUrlDTO.
38
61
  */
@@ -50,26 +73,13 @@ declare class AWSPresignedUrlDTO implements IAWSPresignedUrlDTO {
50
73
  }
51
74
 
52
75
  /**
53
- * Auto-generated client for the Container controller.
54
- */
55
- declare class Container {
56
- private baseUrl;
57
- constructor(baseUrl: string);
58
- ReadChildrenByContainerId(parentId: string): Promise<ContainerDTO[]>;
59
- ReadRootContainers(): Promise<ContainerDTO[]>;
60
- Read(id: string): Promise<ContainerDTO>;
61
- Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
62
- Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
63
- Delete(id: string): Promise<ContainerDTO>;
64
- GetPreSignedUrl(fileName: string, size: number, contentType: string): Promise<AWSPresignedUrlDTO>;
65
- }
66
-
67
- /**
68
- * Auto-generated client for the Home controller.
76
+ * Auto-generated client for the S3 controller.
69
77
  */
70
- declare class Home {
78
+ declare class S3 {
71
79
  private baseUrl;
72
80
  constructor(baseUrl: string);
81
+ DeleteS3(containerDTO: ContainerDTO): Promise<ContainerDTO>;
82
+ GetPreSignedUrl(containerDTO: ContainerDTO): Promise<AWSPresignedUrlDTO>;
73
83
  }
74
84
 
75
85
  /**
@@ -78,6 +88,7 @@ declare class Home {
78
88
  declare class SparkStudioStorageSDK {
79
89
  container: Container;
80
90
  home: Home;
91
+ s3: S3;
81
92
  constructor(baseUrl: string);
82
93
  }
83
94
 
@@ -111,4 +122,4 @@ declare const UploadContainer: React.FC<UploadContainerProps>;
111
122
 
112
123
  declare function HomeView(): react_jsx_runtime.JSX.Element;
113
124
 
114
- export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
125
+ export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, S3, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
package/dist/index.d.ts CHANGED
@@ -33,6 +33,29 @@ declare class ContainerDTO implements IContainerDTO {
33
33
  constructor(init: ContainerDTOInit);
34
34
  }
35
35
 
36
+ /**
37
+ * Auto-generated client for the Container controller.
38
+ */
39
+ declare class Container {
40
+ private baseUrl;
41
+ constructor(baseUrl: string);
42
+ ReadChildrenByContainerId(parentId: string): Promise<ContainerDTO[]>;
43
+ ReadRootContainers(): Promise<ContainerDTO[]>;
44
+ Read(id: string): Promise<ContainerDTO>;
45
+ Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
46
+ Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
47
+ DeleteContainer(id: string): Promise<ContainerDTO>;
48
+ CreateFileContainer(fileName: string, size: number, contentType: string): Promise<ContainerDTO>;
49
+ }
50
+
51
+ /**
52
+ * Auto-generated client for the Home controller.
53
+ */
54
+ declare class Home {
55
+ private baseUrl;
56
+ constructor(baseUrl: string);
57
+ }
58
+
36
59
  /**
37
60
  * Represents an Auto-generated model for AWSPresignedUrlDTO.
38
61
  */
@@ -50,26 +73,13 @@ declare class AWSPresignedUrlDTO implements IAWSPresignedUrlDTO {
50
73
  }
51
74
 
52
75
  /**
53
- * Auto-generated client for the Container controller.
54
- */
55
- declare class Container {
56
- private baseUrl;
57
- constructor(baseUrl: string);
58
- ReadChildrenByContainerId(parentId: string): Promise<ContainerDTO[]>;
59
- ReadRootContainers(): Promise<ContainerDTO[]>;
60
- Read(id: string): Promise<ContainerDTO>;
61
- Create(containerDTO: ContainerDTO): Promise<ContainerDTO>;
62
- Update(containerDTO: ContainerDTO): Promise<ContainerDTO>;
63
- Delete(id: string): Promise<ContainerDTO>;
64
- GetPreSignedUrl(fileName: string, size: number, contentType: string): Promise<AWSPresignedUrlDTO>;
65
- }
66
-
67
- /**
68
- * Auto-generated client for the Home controller.
76
+ * Auto-generated client for the S3 controller.
69
77
  */
70
- declare class Home {
78
+ declare class S3 {
71
79
  private baseUrl;
72
80
  constructor(baseUrl: string);
81
+ DeleteS3(containerDTO: ContainerDTO): Promise<ContainerDTO>;
82
+ GetPreSignedUrl(containerDTO: ContainerDTO): Promise<AWSPresignedUrlDTO>;
73
83
  }
74
84
 
75
85
  /**
@@ -78,6 +88,7 @@ declare class Home {
78
88
  declare class SparkStudioStorageSDK {
79
89
  container: Container;
80
90
  home: Home;
91
+ s3: S3;
81
92
  constructor(baseUrl: string);
82
93
  }
83
94
 
@@ -111,4 +122,4 @@ declare const UploadContainer: React.FC<UploadContainerProps>;
111
122
 
112
123
  declare function HomeView(): react_jsx_runtime.JSX.Element;
113
124
 
114
- export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
125
+ export { AWSPresignedUrlDTO, Container, ContainerDTO, ContainerType, Home, HomeView, type IAWSPresignedUrlDTO, type IContainerDTO, S3, SparkStudioStorageSDK, UploadContainer, type UploadContainerProps };
package/dist/index.js CHANGED
@@ -76,8 +76,8 @@ var Container = class {
76
76
  if (!response.ok) throw new Error(await response.text());
77
77
  return await response.json();
78
78
  }
79
- async Delete(id) {
80
- const url = `${this.baseUrl}/api/Container/Delete/` + id;
79
+ async DeleteContainer(id) {
80
+ const url = `${this.baseUrl}/api/Container/DeleteContainer/` + id;
81
81
  const token = localStorage.getItem("auth_token");
82
82
  const requestOptions = {
83
83
  method: "GET",
@@ -90,8 +90,8 @@ var Container = class {
90
90
  if (!response.ok) throw new Error(await response.text());
91
91
  return await response.json();
92
92
  }
93
- async GetPreSignedUrl(fileName, size, contentType) {
94
- const url = `${this.baseUrl}/api/Container/GetPreSignedUrl/` + fileName + `/` + size + `/` + contentType;
93
+ async CreateFileContainer(fileName, size, contentType) {
94
+ const url = `${this.baseUrl}/api/Container/CreateFileContainer/` + fileName + `/` + size + `/` + contentType;
95
95
  const token = localStorage.getItem("auth_token");
96
96
  const requestOptions = {
97
97
  method: "GET",
@@ -114,13 +114,53 @@ var Home = class {
114
114
  }
115
115
  };
116
116
 
117
+ // src/api/Controllers/S3.ts
118
+ var S3 = class {
119
+ baseUrl;
120
+ constructor(baseUrl) {
121
+ this.baseUrl = baseUrl;
122
+ }
123
+ async DeleteS3(containerDTO) {
124
+ const url = `${this.baseUrl}/api/S3/DeleteS3`;
125
+ const token = localStorage.getItem("auth_token");
126
+ const requestOptions = {
127
+ method: "POST",
128
+ headers: {
129
+ "Content-Type": "application/json",
130
+ ...token && { Authorization: `Bearer ${token}` }
131
+ },
132
+ body: JSON.stringify(containerDTO)
133
+ };
134
+ const response = await fetch(url, requestOptions);
135
+ if (!response.ok) throw new Error(await response.text());
136
+ return await response.json();
137
+ }
138
+ async GetPreSignedUrl(containerDTO) {
139
+ const url = `${this.baseUrl}/api/S3/GetPreSignedUrl`;
140
+ const token = localStorage.getItem("auth_token");
141
+ const requestOptions = {
142
+ method: "POST",
143
+ headers: {
144
+ "Content-Type": "application/json",
145
+ ...token && { Authorization: `Bearer ${token}` }
146
+ },
147
+ body: JSON.stringify(containerDTO)
148
+ };
149
+ const response = await fetch(url, requestOptions);
150
+ if (!response.ok) throw new Error(await response.text());
151
+ return await response.json();
152
+ }
153
+ };
154
+
117
155
  // src/api/SparkStudioStorageSDK.ts
118
156
  var SparkStudioStorageSDK = class {
119
157
  container;
120
158
  home;
159
+ s3;
121
160
  constructor(baseUrl) {
122
161
  this.container = new Container(baseUrl);
123
162
  this.home = new Home(baseUrl);
163
+ this.s3 = new S3(baseUrl);
124
164
  }
125
165
  };
126
166
 
@@ -359,9 +399,11 @@ function HomeView() {
359
399
  alert(user?.Id);
360
400
  }
361
401
  const getPresignedUrl = async (file) => {
362
- const sdk = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
363
- const result = await sdk.container.GetPreSignedUrl(file.name, file.size, encodeURIComponent(file.type));
364
- return result;
402
+ const sdkDb = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
403
+ const sdkS3 = new SparkStudioStorageSDK("https://iq0gmcn0pd.execute-api.us-east-2.amazonaws.com/Prod");
404
+ const containerDTO = await sdkDb.container.CreateFileContainer(file.name, file.size, encodeURIComponent(file.type));
405
+ const resultS3 = await sdkS3.s3.GetPreSignedUrl(containerDTO);
406
+ return resultS3;
365
407
  };
366
408
  return /* @__PURE__ */ jsxs2(
367
409
  AuthenticatorProvider,
@@ -400,6 +442,7 @@ export {
400
442
  ContainerType,
401
443
  Home,
402
444
  HomeView,
445
+ S3,
403
446
  SparkStudioStorageSDK,
404
447
  UploadContainer
405
448
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkstudio/storage-ui",
3
- "version": "1.0.9",
3
+ "version": "1.0.12",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",