@aviaryhq/cloudglue-js 0.2.1 → 0.2.3

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.
@@ -333,6 +333,10 @@ export declare const FilesApi: import("@zodios/core").ZodiosInstance<[{
333
333
  name: "sort";
334
334
  type: "Query";
335
335
  schema: z.ZodDefault<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
336
+ }, {
337
+ name: "filter";
338
+ type: "Query";
339
+ schema: z.ZodOptional<z.ZodString>;
336
340
  }];
337
341
  response: z.ZodType<FileList, z.ZodTypeDef, FileList>;
338
342
  errors: [{
@@ -1624,6 +1628,10 @@ export declare function createApiClient(baseUrl: string, options?: ZodiosOptions
1624
1628
  name: "sort";
1625
1629
  type: "Query";
1626
1630
  schema: z.ZodDefault<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
1631
+ }, {
1632
+ name: "filter";
1633
+ type: "Query";
1634
+ schema: z.ZodOptional<z.ZodString>;
1627
1635
  }];
1628
1636
  response: z.ZodType<FileList, z.ZodTypeDef, FileList>;
1629
1637
  errors: [{
@@ -147,6 +147,11 @@ const endpoints = (0, core_1.makeApi)([
147
147
  type: "Query",
148
148
  schema: zod_1.z.enum(["asc", "desc"]).optional().default("desc"),
149
149
  },
150
+ {
151
+ name: "filter",
152
+ type: "Query",
153
+ schema: zod_1.z.string().optional(),
154
+ },
150
155
  ],
151
156
  response: FileList,
152
157
  errors: [
@@ -1,6 +1,7 @@
1
1
  import { type ZodiosOptions } from "@zodios/core";
2
2
  import { z } from "zod";
3
3
  type SearchResponse = {
4
+ id: string;
4
5
  object: "search";
5
6
  query: string;
6
7
  scope: "file" | "segment";
@@ -65,7 +66,7 @@ type SearchFilter = Partial<{
65
66
  }>;
66
67
  type SearchFilterCriteria = {
67
68
  path: string;
68
- operator: "NotEqual" | "Equal" | "LessThan" | "GreaterThan" | "ContainsAny" | "ContainsAll" | "In";
69
+ operator: "NotEqual" | "Equal" | "LessThan" | "GreaterThan" | "ContainsAny" | "ContainsAll" | "In" | "Like";
69
70
  valueText?: string | undefined;
70
71
  valueTextArray?: Array<string> | undefined;
71
72
  };
@@ -15,6 +15,7 @@ const SearchFilterCriteria = zod_1.z
15
15
  "ContainsAny",
16
16
  "ContainsAll",
17
17
  "In",
18
+ "Like",
18
19
  ]),
19
20
  valueText: zod_1.z.string().optional(),
20
21
  valueTextArray: zod_1.z.array(zod_1.z.string()).optional(),
@@ -115,6 +116,7 @@ const SegmentSearchResult = zod_1.z
115
116
  .passthrough();
116
117
  const SearchResponse = zod_1.z
117
118
  .object({
119
+ id: zod_1.z.string().uuid(),
118
120
  object: zod_1.z.literal("search"),
119
121
  query: zod_1.z.string(),
120
122
  scope: zod_1.z.enum(["file", "segment"]),
@@ -1,4 +1,5 @@
1
1
  import { FilesApi, CollectionsApi, ChatApi, TranscribeApi, ExtractApi, SearchApi, DescribeApi } from "../generated";
2
+ import { FilterOperator } from "./types";
2
3
  import type { File, SegmentationConfig, UpdateFileParams } from "./types";
3
4
  import { SegmentationsApi } from "../generated/Segmentations";
4
5
  import { ThumbnailsConfig } from "../generated/common";
@@ -20,7 +21,27 @@ export interface CloudGlueConfig {
20
21
  */
21
22
  timeout?: number;
22
23
  }
23
- interface ListFilesParams {
24
+ export interface Filter {
25
+ metadata?: Array<{
26
+ path: string;
27
+ operator: FilterOperator;
28
+ valueText?: string;
29
+ valueTextArray?: string[];
30
+ }>;
31
+ video_info?: Array<{
32
+ path: "duration_seconds" | "has_audio";
33
+ operator: FilterOperator;
34
+ valueText?: string;
35
+ valueTextArray?: string[];
36
+ }>;
37
+ file?: Array<{
38
+ path: "bytes" | "filename" | "uri" | "created_at" | "id";
39
+ operator: FilterOperator;
40
+ valueText?: string;
41
+ valueTextArray?: string[];
42
+ }>;
43
+ }
44
+ export interface ListFilesParams {
24
45
  status?: "pending" | "processing" | "completed" | "failed" | "not_applicable";
25
46
  limit?: number;
26
47
  offset?: number;
@@ -28,6 +49,7 @@ interface ListFilesParams {
28
49
  sort?: "asc" | "desc";
29
50
  created_before?: string;
30
51
  created_after?: string;
52
+ filter?: Filter;
31
53
  }
32
54
  interface UploadFileParams {
33
55
  file: globalThis.File;
@@ -139,26 +161,7 @@ interface SearchParams {
139
161
  collections: string[];
140
162
  query: string;
141
163
  limit?: number;
142
- filter?: {
143
- metadata?: Array<{
144
- path: string;
145
- operator: "NotEqual" | "Equal" | "LessThan" | "GreaterThan" | "ContainsAny" | "ContainsAll" | "In";
146
- valueText?: string;
147
- valueTextArray?: string[];
148
- }>;
149
- video_info?: Array<{
150
- path: "duration_seconds" | "has_audio";
151
- operator: "NotEqual" | "Equal" | "LessThan" | "GreaterThan" | "ContainsAny" | "ContainsAll" | "In";
152
- valueText?: string;
153
- valueTextArray?: string[];
154
- }>;
155
- file?: Array<{
156
- path: "bytes" | "filename" | "uri" | "created_at" | "id";
157
- operator: "NotEqual" | "Equal" | "LessThan" | "GreaterThan" | "ContainsAny" | "ContainsAll" | "In";
158
- valueText?: string;
159
- valueTextArray?: string[];
160
- }>;
161
- };
164
+ filter?: Filter;
162
165
  }
163
166
  interface WaitForReadyOptions {
164
167
  /** Interval in milliseconds between polling attempts. Defaults to 5000ms (5 seconds). */
@@ -176,7 +179,7 @@ declare class EnhancedFilesApi {
176
179
  limit: number;
177
180
  offset: number;
178
181
  }>;
179
- uploadFile(params: UploadFileParams): Promise<import("axios").AxiosResponse<any, any>>;
182
+ uploadFile(params: UploadFileParams): Promise<import("axios").AxiosResponse<any, any, {}>>;
180
183
  getFile(fileId: string): Promise<import("zod").objectOutputType<{
181
184
  id: import("zod").ZodString;
182
185
  status: import("zod").ZodEnum<["pending", "processing", "completed", "failed", "not_applicable"]>;
@@ -2679,6 +2682,7 @@ declare class EnhancedSearchApi {
2679
2682
  private readonly api;
2680
2683
  constructor(api: typeof SearchApi);
2681
2684
  searchContent(params: SearchParams): Promise<{
2685
+ id: string;
2682
2686
  object: "search";
2683
2687
  query: string;
2684
2688
  scope: "file" | "segment";
@@ -25,7 +25,18 @@ class EnhancedFilesApi {
25
25
  this.api = api;
26
26
  }
27
27
  async listFiles(params = {}) {
28
- return this.api.listFiles({ queries: params });
28
+ const { filter, ...otherParams } = params;
29
+ // Convert filter object to JSON string if provided
30
+ const queries = { ...otherParams };
31
+ if (filter) {
32
+ try {
33
+ queries.filter = JSON.stringify(filter);
34
+ }
35
+ catch (error) {
36
+ throw new CloudGlueError(`Failed to serialize filter object: ${error instanceof Error ? error.message : 'Unknown error'}`);
37
+ }
38
+ }
39
+ return this.api.listFiles({ queries });
29
40
  }
30
41
  async uploadFile(params) {
31
42
  // File uploads require special handling for multipart/form-data that the generated Zodios client doesn't handle automatically.
@@ -38,7 +49,12 @@ class EnhancedFilesApi {
38
49
  formData.append("file", params.file);
39
50
  // Add metadata if provided
40
51
  if (params.metadata) {
41
- formData.append("metadata", JSON.stringify(params.metadata));
52
+ try {
53
+ formData.append("metadata", JSON.stringify(params.metadata));
54
+ }
55
+ catch (error) {
56
+ throw new CloudGlueError(`Failed to serialize metadata object: ${error instanceof Error ? error.message : 'Unknown error'}`);
57
+ }
42
58
  }
43
59
  if (params.enable_segment_thumbnails !== undefined) {
44
60
  formData.append("enable_segment_thumbnails", params.enable_segment_thumbnails.toString());
@@ -426,7 +442,7 @@ class CloudGlue {
426
442
  headers: {
427
443
  Authorization: `Bearer ${this.apiKey}`,
428
444
  'x-sdk-client': 'cloudglue-js',
429
- 'x-sdk-version': '0.2.1',
445
+ 'x-sdk-version': '0.2.3',
430
446
  },
431
447
  baseURL: this.baseUrl,
432
448
  timeout: this.timeout,
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Main CloudGlue client class and configuration types
3
3
  */
4
- export { CloudGlue, type CloudGlueConfig, type CloudGlueError } from './client';
4
+ export { CloudGlue, type CloudGlueConfig, type CloudGlueError, type Filter, type ListFilesParams } from './client';
5
5
  /**
6
6
  * Generated API clients for advanced usage
7
7
  * These provide direct access to the underlying API endpoints
@@ -11,6 +11,20 @@ import { SegmentationUniformConfig as SegmentationUniformConfigType, Segmentatio
11
11
  * Contains metadata about the file including its status, size, and video information
12
12
  */
13
13
  export type { File } from '../generated/common';
14
+ /**
15
+ * Filter operators for metadata, video info, and file property filtering
16
+ * Used across different APIs for consistent filtering behavior
17
+ */
18
+ export declare enum FilterOperator {
19
+ NotEqual = "NotEqual",
20
+ Equal = "Equal",
21
+ LessThan = "LessThan",
22
+ GreaterThan = "GreaterThan",
23
+ ContainsAny = "ContainsAny",
24
+ ContainsAll = "ContainsAll",
25
+ In = "In",
26
+ Like = "Like"
27
+ }
14
28
  /**
15
29
  * Represents the status of a job
16
30
  * TODO: would be better to use a common type for all jobs
package/dist/src/types.js CHANGED
@@ -1,2 +1,18 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterOperator = void 0;
4
+ /**
5
+ * Filter operators for metadata, video info, and file property filtering
6
+ * Used across different APIs for consistent filtering behavior
7
+ */
8
+ var FilterOperator;
9
+ (function (FilterOperator) {
10
+ FilterOperator["NotEqual"] = "NotEqual";
11
+ FilterOperator["Equal"] = "Equal";
12
+ FilterOperator["LessThan"] = "LessThan";
13
+ FilterOperator["GreaterThan"] = "GreaterThan";
14
+ FilterOperator["ContainsAny"] = "ContainsAny";
15
+ FilterOperator["ContainsAll"] = "ContainsAll";
16
+ FilterOperator["In"] = "In";
17
+ FilterOperator["Like"] = "Like";
18
+ })(FilterOperator || (exports.FilterOperator = FilterOperator = {}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aviaryhq/cloudglue-js",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Cloudglue API client for Node.js",
5
5
  "main": "dist/src/index.js",
6
6
  "types": "dist/src/index.d.ts",