@aviaryhq/cloudglue-js 0.3.3 → 0.3.5

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.
@@ -11,13 +11,6 @@ export declare class CloudGlueError extends Error {
11
11
  readonly responseData?: any | undefined;
12
12
  constructor(message: string, statusCode?: number | undefined, data?: string | undefined, headers?: Record<string, any> | undefined, responseData?: any | undefined);
13
13
  }
14
- /**
15
- * Helper function to convert a local file path to base64 encoded string
16
- * Only supports JPG and PNG image formats
17
- * @param filePath - Path to the local image file (must be .jpg, .jpeg, or .png)
18
- * @returns Promise<string> - Base64 encoded string with data URL prefix
19
- */
20
- export declare function convertFileToBase64(filePath: string): Promise<string>;
21
14
  /**
22
15
  * Configuration options for initializing the CloudGlue client
23
16
  */
@@ -187,7 +180,7 @@ declare class EnhancedFilesApi {
187
180
  limit: number;
188
181
  offset: number;
189
182
  }>;
190
- uploadFile(params: UploadFileParams): Promise<any>;
183
+ uploadFile(params: UploadFileParams): Promise<import("axios").AxiosResponse<any, any>>;
191
184
  getFile(fileId: string): Promise<import("zod").objectOutputType<{
192
185
  id: import("zod").ZodString;
193
186
  status: import("zod").ZodEnum<["pending", "processing", "completed", "failed", "not_applicable"]>;
@@ -1,40 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
2
  Object.defineProperty(exports, "__esModule", { value: true });
36
3
  exports.CloudGlue = exports.CloudGlueError = void 0;
37
- exports.convertFileToBase64 = convertFileToBase64;
38
4
  const Files_1 = require("../generated/Files");
39
5
  const Collections_1 = require("../generated/Collections");
40
6
  const Chat_1 = require("../generated/Chat");
@@ -48,7 +14,6 @@ const Webhooks_1 = require("../generated/Webhooks");
48
14
  const Frames_1 = require("../generated/Frames");
49
15
  const Face_Detection_1 = require("../generated/Face_Detection");
50
16
  const Face_Match_1 = require("../generated/Face_Match");
51
- const fs = __importStar(require("fs"));
52
17
  class CloudGlueError extends Error {
53
18
  constructor(message, statusCode, data, headers, responseData) {
54
19
  super(message);
@@ -60,39 +25,6 @@ class CloudGlueError extends Error {
60
25
  }
61
26
  }
62
27
  exports.CloudGlueError = CloudGlueError;
63
- /**
64
- * Helper function to convert a local file path to base64 encoded string
65
- * Only supports JPG and PNG image formats
66
- * @param filePath - Path to the local image file (must be .jpg, .jpeg, or .png)
67
- * @returns Promise<string> - Base64 encoded string with data URL prefix
68
- */
69
- async function convertFileToBase64(filePath) {
70
- try {
71
- const fileBuffer = await fs.promises.readFile(filePath);
72
- const base64String = fileBuffer.toString('base64');
73
- // Determine MIME type based on file extension (only JPG and PNG supported)
74
- const extension = filePath.toLowerCase().split('.').pop();
75
- let mimeType;
76
- switch (extension) {
77
- case 'png':
78
- mimeType = 'image/png';
79
- break;
80
- case 'jpg':
81
- case 'jpeg':
82
- mimeType = 'image/jpeg';
83
- break;
84
- default:
85
- throw new CloudGlueError(`Unsupported file format: ${extension}. Only JPG and PNG files are supported.`);
86
- }
87
- return `data:${mimeType};base64,${base64String}`;
88
- }
89
- catch (error) {
90
- if (error instanceof CloudGlueError) {
91
- throw error;
92
- }
93
- throw new CloudGlueError(`Failed to read file at path "${filePath}": ${error instanceof Error ? error.message : 'Unknown error'}`);
94
- }
95
- }
96
28
  // Enhanced API client classes
97
29
  class EnhancedFilesApi {
98
30
  constructor(api) {
@@ -134,7 +66,7 @@ class EnhancedFilesApi {
134
66
  formData.append("enable_segment_thumbnails", params.enable_segment_thumbnails.toString());
135
67
  }
136
68
  // Use axios directly to bypass Zodios validation
137
- const response = await this.api.axios({
69
+ return this.api.axios({
138
70
  method: "post",
139
71
  url: "/files",
140
72
  data: formData,
@@ -142,7 +74,6 @@ class EnhancedFilesApi {
142
74
  "Content-Type": "multipart/form-data",
143
75
  },
144
76
  });
145
- return response.data;
146
77
  }
147
78
  async getFile(fileId) {
148
79
  return this.api.getFile({ params: { file_id: fileId } });
@@ -634,18 +565,6 @@ class EnhancedFaceMatchApi {
634
565
  this.api = api;
635
566
  }
636
567
  async createFaceMatch(params) {
637
- // Handle local file path by converting to base64
638
- if (params.source_image.file_path) {
639
- const base64Image = await convertFileToBase64(params.source_image.file_path);
640
- const { file_path, ...restSourceImage } = params.source_image;
641
- return this.api.createFaceMatch({
642
- ...params,
643
- source_image: {
644
- ...restSourceImage,
645
- base64_image: base64Image
646
- }
647
- });
648
- }
649
568
  return this.api.createFaceMatch(params);
650
569
  }
651
570
  async getFaceMatch(faceMatchId, params = {}) {
@@ -691,7 +610,7 @@ class CloudGlue {
691
610
  headers: {
692
611
  Authorization: `Bearer ${this.apiKey}`,
693
612
  'x-sdk-client': 'cloudglue-js',
694
- 'x-sdk-version': '0.3.3',
613
+ 'x-sdk-version': '0.3.5',
695
614
  },
696
615
  baseURL: this.baseUrl,
697
616
  timeout: this.timeout,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaryhq/cloudglue-js",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Cloudglue API client for Node.js",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",