@zodic/shared 0.0.321 → 0.0.322

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/app/api/index.ts CHANGED
@@ -347,7 +347,7 @@ export const Api = (env: BackendBindings) => ({
347
347
  }
348
348
  },
349
349
 
350
- generatePresignedUrl: async (): Promise<{
350
+ generatePresignedUrl: async (extension: string): Promise<{
351
351
  id: string;
352
352
  fields: string;
353
353
  key: string;
@@ -358,14 +358,14 @@ export const Api = (env: BackendBindings) => ({
358
358
  Authorization: `Bearer ${env.LEONARDO_API_KEY}`,
359
359
  'Content-Type': 'application/json',
360
360
  };
361
-
361
+
362
362
  try {
363
363
  const response = await fetch(endpoint, {
364
364
  method: 'POST',
365
365
  headers,
366
- body: JSON.stringify({}),
366
+ body: JSON.stringify({ extension }), // Include the extension in the request body
367
367
  });
368
-
368
+
369
369
  if (!response.ok) {
370
370
  const error = await response.json();
371
371
  console.error(
@@ -374,10 +374,10 @@ export const Api = (env: BackendBindings) => ({
374
374
  );
375
375
  throw new Error(`Leonardo API Error: ${response.status}`);
376
376
  }
377
-
377
+
378
378
  const data = await response.json() as any;
379
379
  const result = data.uploadInitImage;
380
-
380
+
381
381
  if (
382
382
  !result ||
383
383
  !result.id ||
@@ -388,7 +388,7 @@ export const Api = (env: BackendBindings) => ({
388
388
  console.error('❌ Invalid response from Leonardo API:', data);
389
389
  throw new Error('Invalid response structure from Leonardo API');
390
390
  }
391
-
391
+
392
392
  return {
393
393
  id: result.id,
394
394
  fields: result.fields,
@@ -168,7 +168,7 @@ export class LeonardoService {
168
168
  try {
169
169
  const presignedUrlData = await this.context
170
170
  .api()
171
- .callLeonardo.generatePresignedUrl();
171
+ .callLeonardo.generatePresignedUrl(fileExtension);
172
172
  await this.context.api().callLeonardo.uploadImageToPresignedUrl(file, {
173
173
  fields: presignedUrlData.fields,
174
174
  url: presignedUrlData.url,
@@ -225,7 +225,7 @@ export class LeonardoService {
225
225
 
226
226
  const presignedUrlData = await this.context
227
227
  .api()
228
- .callLeonardo.generatePresignedUrl();
228
+ .callLeonardo.generatePresignedUrl(fileExtension);
229
229
  await this.context
230
230
  .api()
231
231
  .callLeonardo.uploadImageToPresignedUrl(file as File, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zodic/shared",
3
- "version": "0.0.321",
3
+ "version": "0.0.322",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "publishConfig": {