@aviaryhq/cloudglue-js 0.3.3 → 0.3.4

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
  */
@@ -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) {
@@ -634,18 +566,6 @@ class EnhancedFaceMatchApi {
634
566
  this.api = api;
635
567
  }
636
568
  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
569
  return this.api.createFaceMatch(params);
650
570
  }
651
571
  async getFaceMatch(faceMatchId, params = {}) {
@@ -691,7 +611,7 @@ class CloudGlue {
691
611
  headers: {
692
612
  Authorization: `Bearer ${this.apiKey}`,
693
613
  'x-sdk-client': 'cloudglue-js',
694
- 'x-sdk-version': '0.3.3',
614
+ 'x-sdk-version': '0.3.4',
695
615
  },
696
616
  baseURL: this.baseUrl,
697
617
  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.4",
4
4
  "description": "Cloudglue API client for Node.js",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",