chatifai 1.0.22 → 1.0.23

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.d.ts CHANGED
@@ -394,7 +394,7 @@ export declare const ChunkSchema: Schema<any, import("mongoose").Model<any, any,
394
394
  } & {
395
395
  __v: number;
396
396
  }>;
397
- export declare const QuerySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
397
+ export declare const PreDefinedQuerySchema: Schema<any, import("mongoose").Model<any, any, any, any, any, any>, {}, {}, {}, {}, {
398
398
  versionKey: false;
399
399
  toJSON: {
400
400
  virtuals: true;
package/dist/index.js CHANGED
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.FullFileTextSchema = exports.QuerySchema = exports.ChunkSchema = exports.ContextSchema = exports.AgentSchema = exports.UserSchema = exports.OrganizationSchema = void 0;
17
+ exports.FullFileTextSchema = exports.PreDefinedQuerySchema = exports.ChunkSchema = exports.ContextSchema = exports.AgentSchema = exports.UserSchema = exports.OrganizationSchema = void 0;
18
18
  // Export types for consumers
19
19
  __exportStar(require("./types"), exports);
20
20
  const mongoose_1 = require("mongoose");
@@ -143,7 +143,7 @@ exports.ChunkSchema = new mongoose_1.Schema({
143
143
  id: true,
144
144
  // encryptionType: 'csfle',
145
145
  });
146
- exports.QuerySchema = new mongoose_1.Schema({
146
+ exports.PreDefinedQuerySchema = new mongoose_1.Schema({
147
147
  organization_id: { type: String },
148
148
  title: { type: String, minlength: 1, maxlength: 100 },
149
149
  query: { type: String, required: true },
package/dist/types.d.ts CHANGED
@@ -199,37 +199,6 @@ export declare const zodAgentSchema: z.ZodObject<{
199
199
  message_count_limit?: number | undefined;
200
200
  is_editable?: boolean | undefined;
201
201
  }>;
202
- export declare const zodQuerySchema: z.ZodObject<{
203
- _id: z.ZodOptional<z.ZodString>;
204
- organization_id: z.ZodOptional<z.ZodString>;
205
- title: z.ZodOptional<z.ZodString>;
206
- query: z.ZodString;
207
- context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
208
- status: z.ZodDefault<z.ZodEnum<["active", "inactive", "archived"]>>;
209
- users_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
210
- created_at: z.ZodOptional<z.ZodNumber>;
211
- updated_at: z.ZodOptional<z.ZodNumber>;
212
- }, "strip", z.ZodTypeAny, {
213
- status: "active" | "inactive" | "archived";
214
- query: string;
215
- _id?: string | undefined;
216
- title?: string | undefined;
217
- created_at?: number | undefined;
218
- updated_at?: number | undefined;
219
- organization_id?: string | undefined;
220
- context_ids?: string[] | undefined;
221
- users_ids?: string[] | undefined;
222
- }, {
223
- query: string;
224
- _id?: string | undefined;
225
- title?: string | undefined;
226
- status?: "active" | "inactive" | "archived" | undefined;
227
- created_at?: number | undefined;
228
- updated_at?: number | undefined;
229
- organization_id?: string | undefined;
230
- context_ids?: string[] | undefined;
231
- users_ids?: string[] | undefined;
232
- }>;
233
202
  export declare const zodChunkSchema: z.ZodObject<{
234
203
  _id: z.ZodOptional<z.ZodString>;
235
204
  chunk_id: z.ZodOptional<z.ZodString>;
@@ -343,6 +312,59 @@ export declare const zodFullTextSchema: z.ZodObject<{
343
312
  full_text: string;
344
313
  _id?: string | undefined;
345
314
  }>;
315
+ export declare const zodPreDefinedQuerySchema: z.ZodObject<{
316
+ _id: z.ZodOptional<z.ZodString>;
317
+ organization_id: z.ZodOptional<z.ZodString>;
318
+ title: z.ZodOptional<z.ZodString>;
319
+ query: z.ZodString;
320
+ context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
321
+ status: z.ZodDefault<z.ZodEnum<["active", "inactive", "archived"]>>;
322
+ users_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
323
+ created_at: z.ZodOptional<z.ZodNumber>;
324
+ updated_at: z.ZodOptional<z.ZodNumber>;
325
+ }, "strip", z.ZodTypeAny, {
326
+ status: "active" | "inactive" | "archived";
327
+ query: string;
328
+ _id?: string | undefined;
329
+ title?: string | undefined;
330
+ created_at?: number | undefined;
331
+ updated_at?: number | undefined;
332
+ organization_id?: string | undefined;
333
+ context_ids?: string[] | undefined;
334
+ users_ids?: string[] | undefined;
335
+ }, {
336
+ query: string;
337
+ _id?: string | undefined;
338
+ title?: string | undefined;
339
+ status?: "active" | "inactive" | "archived" | undefined;
340
+ created_at?: number | undefined;
341
+ updated_at?: number | undefined;
342
+ organization_id?: string | undefined;
343
+ context_ids?: string[] | undefined;
344
+ users_ids?: string[] | undefined;
345
+ }>;
346
+ export declare const zodQuerySchema: z.ZodObject<{
347
+ thread_id: z.ZodOptional<z.ZodString>;
348
+ context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
349
+ organization_id: z.ZodString;
350
+ user_id: z.ZodString;
351
+ query: z.ZodString;
352
+ timestamp: z.ZodNumber;
353
+ }, "strip", z.ZodTypeAny, {
354
+ organization_id: string;
355
+ query: string;
356
+ user_id: string;
357
+ timestamp: number;
358
+ context_ids?: string[] | undefined;
359
+ thread_id?: string | undefined;
360
+ }, {
361
+ organization_id: string;
362
+ query: string;
363
+ user_id: string;
364
+ timestamp: number;
365
+ context_ids?: string[] | undefined;
366
+ thread_id?: string | undefined;
367
+ }>;
346
368
  export type EventAttributeType = {
347
369
  http_request: {
348
370
  client_ip?: string;
@@ -350,12 +372,8 @@ export type EventAttributeType = {
350
372
  };
351
373
  };
352
374
  /**
353
- * {
354
- context_id: context._id,
355
- organization_id: context.organization_id,
356
- data: context,
357
- timestamp: Date.now(),
358
- },
375
+ * Used for queue message bodies
376
+ * Used in context processing queue
359
377
  */
360
378
  export type QueueMessageBodyType<T> = {
361
379
  organization_id: string;
@@ -367,10 +385,11 @@ export type UserType = z.infer<typeof zodUserSchema>;
367
385
  export type AgentType = z.infer<typeof zodAgentSchema>;
368
386
  export type ContextType = z.infer<typeof zodContextSchema>;
369
387
  export type ChunkType = z.infer<typeof zodChunkSchema>;
370
- export type QueryType = z.infer<typeof zodQuerySchema>;
388
+ export type PreDefinedQueryType = z.infer<typeof zodPreDefinedQuerySchema>;
371
389
  export type ModelType = (typeof modelsList)[number];
372
390
  export type UserRoleType = (typeof userRoles)[number];
373
391
  export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
392
+ export type QueryType = z.infer<typeof zodQuerySchema>;
374
393
  export declare enum FileType {
375
394
  PDF = "application/pdf",
376
395
  WORD = "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.QueuesList = exports.FileType = exports.zodFullTextSchema = exports.zodChunkSchema = exports.zodQuerySchema = exports.zodAgentSchema = exports.zodContextSchema = exports.zodUserSchema = exports.zodOrganizationSchema = exports.userRoles = exports.modelsList = void 0;
3
+ exports.QueuesList = exports.FileType = exports.zodQuerySchema = exports.zodPreDefinedQuerySchema = exports.zodFullTextSchema = exports.zodChunkSchema = exports.zodAgentSchema = exports.zodContextSchema = exports.zodUserSchema = exports.zodOrganizationSchema = exports.userRoles = exports.modelsList = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.modelsList = [
6
6
  'gemini-2.5-flash-lite',
@@ -84,17 +84,6 @@ exports.zodAgentSchema = zod_1.z.object({
84
84
  created_at: zod_1.z.number().optional(),
85
85
  updated_at: zod_1.z.number().optional(),
86
86
  });
87
- exports.zodQuerySchema = zod_1.z.object({
88
- _id: zod_1.z.string().optional(),
89
- organization_id: zod_1.z.string().optional(),
90
- title: zod_1.z.string().min(1).max(100).optional(),
91
- query: zod_1.z.string().min(1),
92
- context_ids: zod_1.z.array(zod_1.z.string()).optional(),
93
- status: zod_1.z.enum(['active', 'inactive', 'archived']).default('active'),
94
- users_ids: zod_1.z.array(zod_1.z.string()).optional(),
95
- created_at: zod_1.z.number().optional(),
96
- updated_at: zod_1.z.number().optional(),
97
- });
98
87
  exports.zodChunkSchema = zod_1.z.object({
99
88
  _id: zod_1.z.string().optional(),
100
89
  chunk_id: zod_1.z.string().optional(),
@@ -128,6 +117,25 @@ exports.zodFullTextSchema = zod_1.z.object({
128
117
  context_id: zod_1.z.string(),
129
118
  full_text: zod_1.z.string(),
130
119
  });
120
+ exports.zodPreDefinedQuerySchema = zod_1.z.object({
121
+ _id: zod_1.z.string().optional(),
122
+ organization_id: zod_1.z.string().optional(),
123
+ title: zod_1.z.string().min(1).max(100).optional(),
124
+ query: zod_1.z.string().min(1),
125
+ context_ids: zod_1.z.array(zod_1.z.string()).optional(),
126
+ status: zod_1.z.enum(['active', 'inactive', 'archived']).default('active'),
127
+ users_ids: zod_1.z.array(zod_1.z.string()).optional(),
128
+ created_at: zod_1.z.number().optional(),
129
+ updated_at: zod_1.z.number().optional(),
130
+ });
131
+ exports.zodQuerySchema = zod_1.z.object({
132
+ thread_id: zod_1.z.string().optional(),
133
+ context_ids: zod_1.z.array(zod_1.z.string()).optional(),
134
+ organization_id: zod_1.z.string(),
135
+ user_id: zod_1.z.string(),
136
+ query: zod_1.z.string().min(1),
137
+ timestamp: zod_1.z.number(),
138
+ });
131
139
  var FileType;
132
140
  (function (FileType) {
133
141
  FileType["PDF"] = "application/pdf";
package/index.ts CHANGED
@@ -148,7 +148,7 @@ export const ChunkSchema = new Schema(
148
148
  }
149
149
  );
150
150
 
151
- export const QuerySchema = new Schema(
151
+ export const PreDefinedQuerySchema = new Schema(
152
152
  {
153
153
  organization_id: { type: String },
154
154
  title: { type: String, minlength: 1, maxlength: 100 },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatifai",
3
- "version": "1.0.22",
3
+ "version": "1.0.23",
4
4
  "description": "SDK for interacting with the Chatifai API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types.ts CHANGED
@@ -88,17 +88,6 @@ export const zodAgentSchema = z.object({
88
88
  updated_at: z.number().optional(),
89
89
  });
90
90
 
91
- export const zodQuerySchema = z.object({
92
- _id: z.string().optional(),
93
- organization_id: z.string().optional(),
94
- title: z.string().min(1).max(100).optional(),
95
- query: z.string().min(1),
96
- context_ids: z.array(z.string()).optional(),
97
- status: z.enum(['active', 'inactive', 'archived']).default('active'),
98
- users_ids: z.array(z.string()).optional(),
99
- created_at: z.number().optional(),
100
- updated_at: z.number().optional(),
101
- });
102
91
 
103
92
  export const zodChunkSchema = z.object({
104
93
  _id: z.string().optional(),
@@ -135,6 +124,27 @@ export const zodFullTextSchema = z.object({
135
124
  full_text: z.string(),
136
125
  });
137
126
 
127
+ export const zodPreDefinedQuerySchema = z.object({
128
+ _id: z.string().optional(),
129
+ organization_id: z.string().optional(),
130
+ title: z.string().min(1).max(100).optional(),
131
+ query: z.string().min(1),
132
+ context_ids: z.array(z.string()).optional(),
133
+ status: z.enum(['active', 'inactive', 'archived']).default('active'),
134
+ users_ids: z.array(z.string()).optional(),
135
+ created_at: z.number().optional(),
136
+ updated_at: z.number().optional(),
137
+ });
138
+
139
+ export const zodQuerySchema = z.object({
140
+ thread_id: z.string().optional(), // If there is not thread id provided, a new thread will be created
141
+ context_ids: z.array(z.string()).optional(), // Run on all organization files unless specific file ids are provided
142
+ organization_id: z.string(), // Will be used to fetch the agent, contexts, chunks, etc.
143
+ user_id: z.string(),
144
+ query: z.string().min(1),
145
+ timestamp: z.number(),
146
+ })
147
+
138
148
  export type EventAttributeType = {
139
149
  http_request: {
140
150
  client_ip?: string;
@@ -143,12 +153,8 @@ export type EventAttributeType = {
143
153
  };
144
154
 
145
155
  /**
146
- * {
147
- context_id: context._id,
148
- organization_id: context.organization_id,
149
- data: context,
150
- timestamp: Date.now(),
151
- },
156
+ * Used for queue message bodies
157
+ * Used in context processing queue
152
158
  */
153
159
  export type QueueMessageBodyType<T> = {
154
160
  organization_id: string;
@@ -161,10 +167,11 @@ export type UserType = z.infer<typeof zodUserSchema>;
161
167
  export type AgentType = z.infer<typeof zodAgentSchema>;
162
168
  export type ContextType = z.infer<typeof zodContextSchema>;
163
169
  export type ChunkType = z.infer<typeof zodChunkSchema>;
164
- export type QueryType = z.infer<typeof zodQuerySchema>;
170
+ export type PreDefinedQueryType = z.infer<typeof zodPreDefinedQuerySchema>;
165
171
  export type ModelType = (typeof modelsList)[number];
166
172
  export type UserRoleType = (typeof userRoles)[number];
167
173
  export type FullFileTextType = z.infer<typeof zodFullTextSchema>;
174
+ export type QueryType = z.infer<typeof zodQuerySchema>;
168
175
 
169
176
  export enum FileType {
170
177
  PDF = 'application/pdf',