chatifai 1.0.0
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/README.md +16 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +82 -0
- package/dist/types.d.ts +165 -0
- package/dist/types.js +70 -0
- package/index.ts +77 -0
- package/package.json +33 -0
- package/tsconfig.json +14 -0
- package/types.ts +82 -0
package/README.md
ADDED
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/// <reference types="mongoose/types/aggregate" />
|
|
2
|
+
/// <reference types="mongoose/types/callback" />
|
|
3
|
+
/// <reference types="mongoose/types/collection" />
|
|
4
|
+
/// <reference types="mongoose/types/connection" />
|
|
5
|
+
/// <reference types="mongoose/types/cursor" />
|
|
6
|
+
/// <reference types="mongoose/types/document" />
|
|
7
|
+
/// <reference types="mongoose/types/error" />
|
|
8
|
+
/// <reference types="mongoose/types/expressions" />
|
|
9
|
+
/// <reference types="mongoose/types/helpers" />
|
|
10
|
+
/// <reference types="mongoose/types/middlewares" />
|
|
11
|
+
/// <reference types="mongoose/types/indexes" />
|
|
12
|
+
/// <reference types="mongoose/types/models" />
|
|
13
|
+
/// <reference types="mongoose/types/mongooseoptions" />
|
|
14
|
+
/// <reference types="mongoose/types/pipelinestage" />
|
|
15
|
+
/// <reference types="mongoose/types/populate" />
|
|
16
|
+
/// <reference types="mongoose/types/query" />
|
|
17
|
+
/// <reference types="mongoose/types/schemaoptions" />
|
|
18
|
+
/// <reference types="mongoose/types/session" />
|
|
19
|
+
/// <reference types="mongoose/types/types" />
|
|
20
|
+
/// <reference types="mongoose/types/utility" />
|
|
21
|
+
/// <reference types="mongoose/types/validation" />
|
|
22
|
+
/// <reference types="mongoose/types/virtuals" />
|
|
23
|
+
/// <reference types="mongoose/types/schematypes" />
|
|
24
|
+
/// <reference types="mongoose/types/inferschematype" />
|
|
25
|
+
/// <reference types="mongoose/types/inferrawdoctype" />
|
|
26
|
+
export * from './types';
|
|
27
|
+
import { Schema as MongoSchema, SchemaOptions } from 'mongoose';
|
|
28
|
+
export declare const OrganizationSchema: MongoSchema<any, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
29
|
+
_id: import("mongoose").Types.ObjectId;
|
|
30
|
+
} & {
|
|
31
|
+
__v: number;
|
|
32
|
+
}, any>, {}, {}, {}, {}, SchemaOptions<unknown, {}, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
33
|
+
_id: import("mongoose").Types.ObjectId;
|
|
34
|
+
} & {
|
|
35
|
+
__v: number;
|
|
36
|
+
}, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
37
|
+
_id: import("mongoose").Types.ObjectId;
|
|
38
|
+
} & {
|
|
39
|
+
__v: number;
|
|
40
|
+
}, any>>, Record<string, any>, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
41
|
+
_id: import("mongoose").Types.ObjectId;
|
|
42
|
+
} & {
|
|
43
|
+
__v: number;
|
|
44
|
+
}>;
|
|
45
|
+
export declare const UserSchema: MongoSchema<any, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
46
|
+
_id: import("mongoose").Types.ObjectId;
|
|
47
|
+
} & {
|
|
48
|
+
__v: number;
|
|
49
|
+
}, any>, {}, {}, {}, {}, SchemaOptions<unknown, {}, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
50
|
+
_id: import("mongoose").Types.ObjectId;
|
|
51
|
+
} & {
|
|
52
|
+
__v: number;
|
|
53
|
+
}, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
54
|
+
_id: import("mongoose").Types.ObjectId;
|
|
55
|
+
} & {
|
|
56
|
+
__v: number;
|
|
57
|
+
}, any>>, Record<string, any>, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
58
|
+
_id: import("mongoose").Types.ObjectId;
|
|
59
|
+
} & {
|
|
60
|
+
__v: number;
|
|
61
|
+
}>;
|
|
62
|
+
export declare const AgentSchema: MongoSchema<any, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
63
|
+
_id: import("mongoose").Types.ObjectId;
|
|
64
|
+
} & {
|
|
65
|
+
__v: number;
|
|
66
|
+
}, any>, {}, {}, {}, {}, SchemaOptions<unknown, {}, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
67
|
+
_id: import("mongoose").Types.ObjectId;
|
|
68
|
+
} & {
|
|
69
|
+
__v: number;
|
|
70
|
+
}, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
71
|
+
_id: import("mongoose").Types.ObjectId;
|
|
72
|
+
} & {
|
|
73
|
+
__v: number;
|
|
74
|
+
}, any>>, Record<string, any>, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
75
|
+
_id: import("mongoose").Types.ObjectId;
|
|
76
|
+
} & {
|
|
77
|
+
__v: number;
|
|
78
|
+
}>;
|
|
79
|
+
export declare const ContextSchema: MongoSchema<any, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
80
|
+
_id: import("mongoose").Types.ObjectId;
|
|
81
|
+
} & {
|
|
82
|
+
__v: number;
|
|
83
|
+
}, any>, {}, {}, {}, {}, SchemaOptions<unknown, {}, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
84
|
+
_id: import("mongoose").Types.ObjectId;
|
|
85
|
+
} & {
|
|
86
|
+
__v: number;
|
|
87
|
+
}, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
88
|
+
_id: import("mongoose").Types.ObjectId;
|
|
89
|
+
} & {
|
|
90
|
+
__v: number;
|
|
91
|
+
}, any>>, Record<string, any>, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
92
|
+
_id: import("mongoose").Types.ObjectId;
|
|
93
|
+
} & {
|
|
94
|
+
__v: number;
|
|
95
|
+
}>;
|
|
96
|
+
export declare const QuerySchema: MongoSchema<any, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
97
|
+
_id: import("mongoose").Types.ObjectId;
|
|
98
|
+
} & {
|
|
99
|
+
__v: number;
|
|
100
|
+
}, any>, {}, {}, {}, {}, SchemaOptions<unknown, {}, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
101
|
+
_id: import("mongoose").Types.ObjectId;
|
|
102
|
+
} & {
|
|
103
|
+
__v: number;
|
|
104
|
+
}, import("mongoose").Model<unknown, {}, {}, {}, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
105
|
+
_id: import("mongoose").Types.ObjectId;
|
|
106
|
+
} & {
|
|
107
|
+
__v: number;
|
|
108
|
+
}, any>>, Record<string, any>, import("mongoose").Document<unknown, {}, unknown, {}> & {
|
|
109
|
+
_id: import("mongoose").Types.ObjectId;
|
|
110
|
+
} & {
|
|
111
|
+
__v: number;
|
|
112
|
+
}>;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.QuerySchema = exports.ContextSchema = exports.AgentSchema = exports.UserSchema = exports.OrganizationSchema = void 0;
|
|
18
|
+
// Export types for consumers
|
|
19
|
+
__exportStar(require("./types"), exports);
|
|
20
|
+
const mongoose_1 = require("mongoose");
|
|
21
|
+
const types_1 = require("./types");
|
|
22
|
+
const mongoDefaultOptions = {
|
|
23
|
+
versionKey: false,
|
|
24
|
+
toJSON: { virtuals: true },
|
|
25
|
+
toObject: { virtuals: true },
|
|
26
|
+
timestamps: true,
|
|
27
|
+
id: true,
|
|
28
|
+
// encryptionType: 'csfle',
|
|
29
|
+
};
|
|
30
|
+
const Schema = (values) => {
|
|
31
|
+
return new mongoose_1.Schema(values, mongoDefaultOptions);
|
|
32
|
+
};
|
|
33
|
+
exports.OrganizationSchema = Schema({
|
|
34
|
+
clerk_organization_id: { type: String, required: true },
|
|
35
|
+
title: { type: String, required: true, minlength: 1, maxlength: 100 },
|
|
36
|
+
image: { type: String },
|
|
37
|
+
client_email: { type: String },
|
|
38
|
+
plan: { type: String, minlength: 1, maxlength: 100 },
|
|
39
|
+
active_user_limit: { type: Number, min: 1 },
|
|
40
|
+
documents_size_limit: { type: Number, min: 1 },
|
|
41
|
+
allowed_models: { type: [String], enum: types_1.modelsList },
|
|
42
|
+
queries_limit: { type: Number, min: 1 },
|
|
43
|
+
});
|
|
44
|
+
exports.UserSchema = Schema({
|
|
45
|
+
organization_id: { type: String, required: true },
|
|
46
|
+
clerk_user_id: { type: String, required: true },
|
|
47
|
+
email: { type: String, required: true },
|
|
48
|
+
first_name: { type: String },
|
|
49
|
+
last_name: { type: String },
|
|
50
|
+
active_until: { type: Number },
|
|
51
|
+
notes: { type: String, maxlength: 500 },
|
|
52
|
+
avatar: { type: String },
|
|
53
|
+
user_role: { type: String, enum: types_1.userRoles, required: true },
|
|
54
|
+
});
|
|
55
|
+
exports.AgentSchema = Schema({
|
|
56
|
+
organization_id: { type: String },
|
|
57
|
+
title: { type: String, required: true, minlength: 1, maxlength: 100 },
|
|
58
|
+
description: { type: String, minlength: 1, maxlength: 500 },
|
|
59
|
+
instructions: { type: String, minlength: 1, maxlength: 1000 },
|
|
60
|
+
model: { type: String, enum: types_1.modelsList, required: true },
|
|
61
|
+
temperature: { type: Number, min: 0, max: 1 },
|
|
62
|
+
max_tokens: { type: Number, min: 1, max: 4000 },
|
|
63
|
+
elevenlabs_voice_id: { type: String, minlength: 1, maxlength: 100 },
|
|
64
|
+
message_count_limit: { type: Number, min: 1 },
|
|
65
|
+
is_editable: { type: Boolean, default: true },
|
|
66
|
+
});
|
|
67
|
+
exports.ContextSchema = Schema({
|
|
68
|
+
organization_id: { type: String },
|
|
69
|
+
title: { type: String, required: true, minlength: 1, maxlength: 100 },
|
|
70
|
+
description: { type: String, minlength: 1, maxlength: 500 },
|
|
71
|
+
document_url: { type: String },
|
|
72
|
+
type: { type: String, minlength: 1, maxlength: 100 },
|
|
73
|
+
content: { type: String, required: true, minlength: 1 },
|
|
74
|
+
});
|
|
75
|
+
exports.QuerySchema = Schema({
|
|
76
|
+
organization_id: { type: String },
|
|
77
|
+
title: { type: String, minlength: 1, maxlength: 100 },
|
|
78
|
+
query: { type: String, required: true },
|
|
79
|
+
context_ids: { type: [String] },
|
|
80
|
+
status: { type: String, enum: ['active', 'inactive', 'archived'], default: 'active', required: true },
|
|
81
|
+
users_ids: { type: [String] },
|
|
82
|
+
});
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const modelsList: readonly ["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro", "grok-4-fast-non-reasoning", "grok-4-fast-reasoning", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano"];
|
|
3
|
+
export declare const userRoles: readonly ["admin", "member", "client"];
|
|
4
|
+
export declare const zodOrganizationSchema: z.ZodObject<{
|
|
5
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
6
|
+
clerk_organization_id: z.ZodString;
|
|
7
|
+
title: z.ZodString;
|
|
8
|
+
image: z.ZodOptional<z.ZodString>;
|
|
9
|
+
client_email: z.ZodOptional<z.ZodString>;
|
|
10
|
+
plan: z.ZodOptional<z.ZodString>;
|
|
11
|
+
active_user_limit: z.ZodOptional<z.ZodNumber>;
|
|
12
|
+
documents_size_limit: z.ZodOptional<z.ZodNumber>;
|
|
13
|
+
allowed_models: z.ZodOptional<z.ZodArray<z.ZodEnum<["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro", "grok-4-fast-non-reasoning", "grok-4-fast-reasoning", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano"]>, "many">>;
|
|
14
|
+
queries_limit: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
clerk_organization_id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
_id?: string | undefined;
|
|
19
|
+
image?: string | undefined;
|
|
20
|
+
client_email?: string | undefined;
|
|
21
|
+
plan?: string | undefined;
|
|
22
|
+
active_user_limit?: number | undefined;
|
|
23
|
+
documents_size_limit?: number | undefined;
|
|
24
|
+
allowed_models?: ("gemini-2.5-flash-lite" | "gemini-2.5-flash" | "gemini-2.5-pro" | "grok-4-fast-non-reasoning" | "grok-4-fast-reasoning" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano")[] | undefined;
|
|
25
|
+
queries_limit?: number | undefined;
|
|
26
|
+
}, {
|
|
27
|
+
clerk_organization_id: string;
|
|
28
|
+
title: string;
|
|
29
|
+
_id?: string | undefined;
|
|
30
|
+
image?: string | undefined;
|
|
31
|
+
client_email?: string | undefined;
|
|
32
|
+
plan?: string | undefined;
|
|
33
|
+
active_user_limit?: number | undefined;
|
|
34
|
+
documents_size_limit?: number | undefined;
|
|
35
|
+
allowed_models?: ("gemini-2.5-flash-lite" | "gemini-2.5-flash" | "gemini-2.5-pro" | "grok-4-fast-non-reasoning" | "grok-4-fast-reasoning" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano")[] | undefined;
|
|
36
|
+
queries_limit?: number | undefined;
|
|
37
|
+
}>;
|
|
38
|
+
export declare const zodUserSchema: z.ZodObject<{
|
|
39
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
40
|
+
organization_id: z.ZodString;
|
|
41
|
+
clerk_user_id: z.ZodString;
|
|
42
|
+
email: z.ZodString;
|
|
43
|
+
first_name: z.ZodOptional<z.ZodString>;
|
|
44
|
+
last_name: z.ZodOptional<z.ZodString>;
|
|
45
|
+
active_until: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
47
|
+
avatar: z.ZodOptional<z.ZodString>;
|
|
48
|
+
user_role: z.ZodOptional<z.ZodDefault<z.ZodEnum<["admin", "member", "client"]>>>;
|
|
49
|
+
}, "strip", z.ZodTypeAny, {
|
|
50
|
+
organization_id: string;
|
|
51
|
+
clerk_user_id: string;
|
|
52
|
+
email: string;
|
|
53
|
+
_id?: string | undefined;
|
|
54
|
+
first_name?: string | undefined;
|
|
55
|
+
last_name?: string | undefined;
|
|
56
|
+
active_until?: number | undefined;
|
|
57
|
+
notes?: string | undefined;
|
|
58
|
+
avatar?: string | undefined;
|
|
59
|
+
user_role?: "admin" | "member" | "client" | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
organization_id: string;
|
|
62
|
+
clerk_user_id: string;
|
|
63
|
+
email: string;
|
|
64
|
+
_id?: string | undefined;
|
|
65
|
+
first_name?: string | undefined;
|
|
66
|
+
last_name?: string | undefined;
|
|
67
|
+
active_until?: number | undefined;
|
|
68
|
+
notes?: string | undefined;
|
|
69
|
+
avatar?: string | undefined;
|
|
70
|
+
user_role?: "admin" | "member" | "client" | undefined;
|
|
71
|
+
}>;
|
|
72
|
+
export declare const zodAgentSchema: z.ZodObject<{
|
|
73
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
74
|
+
organization_id: z.ZodOptional<z.ZodString>;
|
|
75
|
+
title: z.ZodString;
|
|
76
|
+
description: z.ZodOptional<z.ZodString>;
|
|
77
|
+
instructions: z.ZodOptional<z.ZodString>;
|
|
78
|
+
model: z.ZodEnum<["gemini-2.5-flash-lite", "gemini-2.5-flash", "gemini-2.5-pro", "grok-4-fast-non-reasoning", "grok-4-fast-reasoning", "gpt-4.1", "gpt-4.1-mini", "gpt-4.1-nano"]>;
|
|
79
|
+
temperature: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
max_tokens: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
elevenlabs_voice_id: z.ZodOptional<z.ZodString>;
|
|
82
|
+
message_count_limit: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
is_editable: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
|
|
84
|
+
}, "strip", z.ZodTypeAny, {
|
|
85
|
+
title: string;
|
|
86
|
+
model: "gemini-2.5-flash-lite" | "gemini-2.5-flash" | "gemini-2.5-pro" | "grok-4-fast-non-reasoning" | "grok-4-fast-reasoning" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano";
|
|
87
|
+
_id?: string | undefined;
|
|
88
|
+
organization_id?: string | undefined;
|
|
89
|
+
description?: string | undefined;
|
|
90
|
+
instructions?: string | undefined;
|
|
91
|
+
temperature?: number | undefined;
|
|
92
|
+
max_tokens?: number | undefined;
|
|
93
|
+
elevenlabs_voice_id?: string | undefined;
|
|
94
|
+
message_count_limit?: number | undefined;
|
|
95
|
+
is_editable?: boolean | undefined;
|
|
96
|
+
}, {
|
|
97
|
+
title: string;
|
|
98
|
+
model: "gemini-2.5-flash-lite" | "gemini-2.5-flash" | "gemini-2.5-pro" | "grok-4-fast-non-reasoning" | "grok-4-fast-reasoning" | "gpt-4.1" | "gpt-4.1-mini" | "gpt-4.1-nano";
|
|
99
|
+
_id?: string | undefined;
|
|
100
|
+
organization_id?: string | undefined;
|
|
101
|
+
description?: string | undefined;
|
|
102
|
+
instructions?: string | undefined;
|
|
103
|
+
temperature?: number | undefined;
|
|
104
|
+
max_tokens?: number | undefined;
|
|
105
|
+
elevenlabs_voice_id?: string | undefined;
|
|
106
|
+
message_count_limit?: number | undefined;
|
|
107
|
+
is_editable?: boolean | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
export declare const zodContextSchema: z.ZodObject<{
|
|
110
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
111
|
+
organization_id: z.ZodOptional<z.ZodString>;
|
|
112
|
+
title: z.ZodString;
|
|
113
|
+
description: z.ZodOptional<z.ZodString>;
|
|
114
|
+
document_url: z.ZodOptional<z.ZodString>;
|
|
115
|
+
type: z.ZodOptional<z.ZodString>;
|
|
116
|
+
content: z.ZodOptional<z.ZodString>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
title: string;
|
|
119
|
+
_id?: string | undefined;
|
|
120
|
+
type?: string | undefined;
|
|
121
|
+
organization_id?: string | undefined;
|
|
122
|
+
description?: string | undefined;
|
|
123
|
+
document_url?: string | undefined;
|
|
124
|
+
content?: string | undefined;
|
|
125
|
+
}, {
|
|
126
|
+
title: string;
|
|
127
|
+
_id?: string | undefined;
|
|
128
|
+
type?: string | undefined;
|
|
129
|
+
organization_id?: string | undefined;
|
|
130
|
+
description?: string | undefined;
|
|
131
|
+
document_url?: string | undefined;
|
|
132
|
+
content?: string | undefined;
|
|
133
|
+
}>;
|
|
134
|
+
export declare const zodQuerySchema: z.ZodObject<{
|
|
135
|
+
_id: z.ZodOptional<z.ZodString>;
|
|
136
|
+
organization_id: z.ZodOptional<z.ZodString>;
|
|
137
|
+
title: z.ZodOptional<z.ZodString>;
|
|
138
|
+
query: z.ZodString;
|
|
139
|
+
context_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
140
|
+
status: z.ZodDefault<z.ZodEnum<["active", "inactive", "archived"]>>;
|
|
141
|
+
users_ids: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
142
|
+
}, "strip", z.ZodTypeAny, {
|
|
143
|
+
status: "active" | "inactive" | "archived";
|
|
144
|
+
query: string;
|
|
145
|
+
_id?: string | undefined;
|
|
146
|
+
title?: string | undefined;
|
|
147
|
+
organization_id?: string | undefined;
|
|
148
|
+
context_ids?: string[] | undefined;
|
|
149
|
+
users_ids?: string[] | undefined;
|
|
150
|
+
}, {
|
|
151
|
+
query: string;
|
|
152
|
+
_id?: string | undefined;
|
|
153
|
+
title?: string | undefined;
|
|
154
|
+
status?: "active" | "inactive" | "archived" | undefined;
|
|
155
|
+
organization_id?: string | undefined;
|
|
156
|
+
context_ids?: string[] | undefined;
|
|
157
|
+
users_ids?: string[] | undefined;
|
|
158
|
+
}>;
|
|
159
|
+
export type OrganizationType = z.infer<typeof zodOrganizationSchema>;
|
|
160
|
+
export type UseType = z.infer<typeof zodUserSchema>;
|
|
161
|
+
export type AgentType = z.infer<typeof zodAgentSchema>;
|
|
162
|
+
export type ContextType = z.infer<typeof zodContextSchema>;
|
|
163
|
+
export type QueryType = z.infer<typeof zodQuerySchema>;
|
|
164
|
+
export type ModelType = (typeof modelsList)[number];
|
|
165
|
+
export type UserRoleType = (typeof userRoles)[number];
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.zodQuerySchema = exports.zodContextSchema = exports.zodAgentSchema = exports.zodUserSchema = exports.zodOrganizationSchema = exports.userRoles = exports.modelsList = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
exports.modelsList = [
|
|
6
|
+
'gemini-2.5-flash-lite',
|
|
7
|
+
'gemini-2.5-flash',
|
|
8
|
+
'gemini-2.5-pro',
|
|
9
|
+
'grok-4-fast-non-reasoning',
|
|
10
|
+
'grok-4-fast-reasoning',
|
|
11
|
+
'gpt-4.1',
|
|
12
|
+
'gpt-4.1-mini',
|
|
13
|
+
'gpt-4.1-nano',
|
|
14
|
+
];
|
|
15
|
+
exports.userRoles = ['admin', 'member', 'client'];
|
|
16
|
+
exports.zodOrganizationSchema = zod_1.z.object({
|
|
17
|
+
_id: zod_1.z.string().optional(),
|
|
18
|
+
clerk_organization_id: zod_1.z.string(),
|
|
19
|
+
title: zod_1.z.string().min(1).max(100),
|
|
20
|
+
image: zod_1.z.string().url().optional(),
|
|
21
|
+
client_email: zod_1.z.string().email().optional(),
|
|
22
|
+
plan: zod_1.z.string().min(1).max(100).optional(),
|
|
23
|
+
active_user_limit: zod_1.z.number().min(1).optional(),
|
|
24
|
+
documents_size_limit: zod_1.z.number().min(1).optional(),
|
|
25
|
+
allowed_models: zod_1.z.array(zod_1.z.enum(exports.modelsList)).optional(),
|
|
26
|
+
queries_limit: zod_1.z.number().min(1).optional(),
|
|
27
|
+
});
|
|
28
|
+
exports.zodUserSchema = zod_1.z.object({
|
|
29
|
+
_id: zod_1.z.string().optional(),
|
|
30
|
+
organization_id: zod_1.z.string(),
|
|
31
|
+
clerk_user_id: zod_1.z.string(),
|
|
32
|
+
email: zod_1.z.string().email(),
|
|
33
|
+
first_name: zod_1.z.string().optional(),
|
|
34
|
+
last_name: zod_1.z.string().optional(),
|
|
35
|
+
active_until: zod_1.z.number().optional(),
|
|
36
|
+
notes: zod_1.z.string().max(500).optional(),
|
|
37
|
+
avatar: zod_1.z.string().url().optional(),
|
|
38
|
+
user_role: zod_1.z.enum(exports.userRoles).default('member').optional(),
|
|
39
|
+
});
|
|
40
|
+
exports.zodAgentSchema = zod_1.z.object({
|
|
41
|
+
_id: zod_1.z.string().optional(),
|
|
42
|
+
organization_id: zod_1.z.string().optional(),
|
|
43
|
+
title: zod_1.z.string().min(1).max(100),
|
|
44
|
+
description: zod_1.z.string().min(1).max(500).optional(),
|
|
45
|
+
instructions: zod_1.z.string().min(1).max(1000).optional(),
|
|
46
|
+
model: zod_1.z.enum(exports.modelsList),
|
|
47
|
+
temperature: zod_1.z.number().min(0).max(1).optional(),
|
|
48
|
+
max_tokens: zod_1.z.number().min(1).max(4000).optional(),
|
|
49
|
+
elevenlabs_voice_id: zod_1.z.string().min(1).max(100).optional(),
|
|
50
|
+
message_count_limit: zod_1.z.number().min(1).optional(),
|
|
51
|
+
is_editable: zod_1.z.boolean().default(true).optional(),
|
|
52
|
+
});
|
|
53
|
+
exports.zodContextSchema = zod_1.z.object({
|
|
54
|
+
_id: zod_1.z.string().optional(),
|
|
55
|
+
organization_id: zod_1.z.string().optional(),
|
|
56
|
+
title: zod_1.z.string().min(1).max(100),
|
|
57
|
+
description: zod_1.z.string().min(1).max(500).optional(),
|
|
58
|
+
document_url: zod_1.z.string().optional(),
|
|
59
|
+
type: zod_1.z.string().min(1).max(100).optional(),
|
|
60
|
+
content: zod_1.z.string().min(1).optional(),
|
|
61
|
+
});
|
|
62
|
+
exports.zodQuerySchema = zod_1.z.object({
|
|
63
|
+
_id: zod_1.z.string().optional(),
|
|
64
|
+
organization_id: zod_1.z.string().optional(),
|
|
65
|
+
title: zod_1.z.string().min(1).max(100).optional(),
|
|
66
|
+
query: zod_1.z.string().min(1),
|
|
67
|
+
context_ids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
68
|
+
status: zod_1.z.enum(['active', 'inactive', 'archived']).default('active'),
|
|
69
|
+
users_ids: zod_1.z.array(zod_1.z.string()).optional(),
|
|
70
|
+
});
|
package/index.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
// Export types for consumers
|
|
2
|
+
export * from './types';
|
|
3
|
+
|
|
4
|
+
import { Schema as MongoSchema, SchemaOptions } from 'mongoose';
|
|
5
|
+
import { modelsList, userRoles } from './types';
|
|
6
|
+
|
|
7
|
+
const mongoDefaultOptions: SchemaOptions = {
|
|
8
|
+
versionKey: false,
|
|
9
|
+
toJSON: { virtuals: true },
|
|
10
|
+
toObject: { virtuals: true },
|
|
11
|
+
timestamps: true,
|
|
12
|
+
id: true,
|
|
13
|
+
// encryptionType: 'csfle',
|
|
14
|
+
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Schema = (values: Record<string, any>) => {
|
|
18
|
+
return new MongoSchema(
|
|
19
|
+
values,
|
|
20
|
+
mongoDefaultOptions
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export const OrganizationSchema = Schema({
|
|
25
|
+
clerk_organization_id: { type: String, required: true },
|
|
26
|
+
title: { type: String, required: true, minlength: 1, maxlength: 100 },
|
|
27
|
+
image: { type: String },
|
|
28
|
+
client_email: { type: String },
|
|
29
|
+
plan: { type: String, minlength: 1, maxlength: 100 },
|
|
30
|
+
active_user_limit: { type: Number, min: 1 },
|
|
31
|
+
documents_size_limit: { type: Number, min: 1 },
|
|
32
|
+
allowed_models: { type: [String], enum: modelsList },
|
|
33
|
+
queries_limit: { type: Number, min: 1 },
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
export const UserSchema = Schema({
|
|
37
|
+
organization_id: { type: String, required: true },
|
|
38
|
+
clerk_user_id: { type: String, required: true },
|
|
39
|
+
email: { type: String, required: true },
|
|
40
|
+
first_name: { type: String },
|
|
41
|
+
last_name: { type: String },
|
|
42
|
+
active_until: { type: Number },
|
|
43
|
+
notes: { type: String, maxlength: 500 },
|
|
44
|
+
avatar: { type: String },
|
|
45
|
+
user_role: { type: String, enum: userRoles, required: true },
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
export const AgentSchema = Schema({
|
|
49
|
+
organization_id: { type: String },
|
|
50
|
+
title: { type: String, required: true, minlength: 1, maxlength: 100 },
|
|
51
|
+
description: { type: String, minlength: 1, maxlength: 500 },
|
|
52
|
+
instructions: { type: String, minlength: 1, maxlength: 1000 },
|
|
53
|
+
model: { type: String, enum: modelsList, required: true },
|
|
54
|
+
temperature: { type: Number, min: 0, max: 1 },
|
|
55
|
+
max_tokens: { type: Number, min: 1, max: 4000 },
|
|
56
|
+
elevenlabs_voice_id: { type: String, minlength: 1, maxlength: 100 },
|
|
57
|
+
message_count_limit: { type: Number, min: 1 },
|
|
58
|
+
is_editable: { type: Boolean, default: true },
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
export const ContextSchema = Schema({
|
|
62
|
+
organization_id: { type: String },
|
|
63
|
+
title: { type: String, required: true, minlength: 1, maxlength: 100 },
|
|
64
|
+
description: { type: String, minlength: 1, maxlength: 500 },
|
|
65
|
+
document_url: { type: String },
|
|
66
|
+
type: { type: String, minlength: 1, maxlength: 100 },
|
|
67
|
+
content: { type: String, required: true, minlength: 1 },
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
export const QuerySchema = Schema({
|
|
71
|
+
organization_id: { type: String },
|
|
72
|
+
title: { type: String, minlength: 1, maxlength: 100 },
|
|
73
|
+
query: { type: String, required: true },
|
|
74
|
+
context_ids: { type: [String] },
|
|
75
|
+
status: { type: String, enum: ['active', 'inactive', 'archived'], default: 'active', required: true },
|
|
76
|
+
users_ids: { type: [String] },
|
|
77
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chatifai",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "SDK for interacting with the Chatifai API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/eretztzvi/chatifai.sdk",
|
|
9
|
+
"type": "git"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "jest",
|
|
14
|
+
"prepublish": "npm run build"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"chatifai",
|
|
18
|
+
"sdk",
|
|
19
|
+
"api"
|
|
20
|
+
],
|
|
21
|
+
"author": "deerland",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"devDependencies": {
|
|
24
|
+
"@types/jest": "^29.5.0",
|
|
25
|
+
"jest": "^29.5.0",
|
|
26
|
+
"typescript": "^4.9.5"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"axios": "^1.9.0",
|
|
30
|
+
"mongoose": "^8.16.4",
|
|
31
|
+
"zod": "^3.25.76"
|
|
32
|
+
}
|
|
33
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es2018",
|
|
4
|
+
"module": "commonjs",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"outDir": "./dist",
|
|
7
|
+
"strict": true,
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true
|
|
11
|
+
},
|
|
12
|
+
"include": ["index.ts", "types.ts"],
|
|
13
|
+
"exclude": ["node_modules", "dist"]
|
|
14
|
+
}
|
package/types.ts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
export const modelsList = [
|
|
4
|
+
'gemini-2.5-flash-lite',
|
|
5
|
+
'gemini-2.5-flash',
|
|
6
|
+
'gemini-2.5-pro',
|
|
7
|
+
'grok-4-fast-non-reasoning',
|
|
8
|
+
'grok-4-fast-reasoning',
|
|
9
|
+
'gpt-4.1',
|
|
10
|
+
'gpt-4.1-mini',
|
|
11
|
+
'gpt-4.1-nano',
|
|
12
|
+
] as const;
|
|
13
|
+
|
|
14
|
+
export const userRoles = ['admin', 'member', 'client'] as const;
|
|
15
|
+
|
|
16
|
+
export const zodOrganizationSchema = z.object({
|
|
17
|
+
_id: z.string().optional(),
|
|
18
|
+
clerk_organization_id: z.string(),
|
|
19
|
+
title: z.string().min(1).max(100),
|
|
20
|
+
image: z.string().url().optional(),
|
|
21
|
+
client_email: z.string().email().optional(),
|
|
22
|
+
plan: z.string().min(1).max(100).optional(),
|
|
23
|
+
active_user_limit: z.number().min(1).optional(),
|
|
24
|
+
documents_size_limit: z.number().min(1).optional(),
|
|
25
|
+
allowed_models: z.array(z.enum(modelsList)).optional(),
|
|
26
|
+
queries_limit: z.number().min(1).optional(),
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
export const zodUserSchema = z.object({
|
|
30
|
+
_id: z.string().optional(),
|
|
31
|
+
organization_id: z.string(),
|
|
32
|
+
clerk_user_id: z.string(),
|
|
33
|
+
email: z.string().email(),
|
|
34
|
+
first_name: z.string().optional(),
|
|
35
|
+
last_name: z.string().optional(),
|
|
36
|
+
active_until: z.number().optional(),
|
|
37
|
+
notes: z.string().max(500).optional(),
|
|
38
|
+
avatar: z.string().url().optional(),
|
|
39
|
+
user_role: z.enum(userRoles).default('member').optional(),
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const zodAgentSchema = z.object({
|
|
43
|
+
_id: z.string().optional(),
|
|
44
|
+
organization_id: z.string().optional(),
|
|
45
|
+
title: z.string().min(1).max(100),
|
|
46
|
+
description: z.string().min(1).max(500).optional(),
|
|
47
|
+
instructions: z.string().min(1).max(1000).optional(),
|
|
48
|
+
model: z.enum(modelsList),
|
|
49
|
+
temperature: z.number().min(0).max(1).optional(),
|
|
50
|
+
max_tokens: z.number().min(1).max(4000).optional(),
|
|
51
|
+
elevenlabs_voice_id: z.string().min(1).max(100).optional(),
|
|
52
|
+
message_count_limit: z.number().min(1).optional(),
|
|
53
|
+
is_editable: z.boolean().default(true).optional(),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export const zodContextSchema = z.object({
|
|
57
|
+
_id: z.string().optional(),
|
|
58
|
+
organization_id: z.string().optional(),
|
|
59
|
+
title: z.string().min(1).max(100),
|
|
60
|
+
description: z.string().min(1).max(500).optional(),
|
|
61
|
+
document_url: z.string().optional(),
|
|
62
|
+
type: z.string().min(1).max(100).optional(),
|
|
63
|
+
content: z.string().min(1).optional(),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
export const zodQuerySchema = z.object({
|
|
67
|
+
_id: z.string().optional(),
|
|
68
|
+
organization_id: z.string().optional(),
|
|
69
|
+
title: z.string().min(1).max(100).optional(),
|
|
70
|
+
query: z.string().min(1),
|
|
71
|
+
context_ids: z.array(z.string()).optional(),
|
|
72
|
+
status: z.enum(['active', 'inactive', 'archived']).default('active'),
|
|
73
|
+
users_ids: z.array(z.string()).optional(),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export type OrganizationType = z.infer<typeof zodOrganizationSchema>;
|
|
77
|
+
export type UseType = z.infer<typeof zodUserSchema>;
|
|
78
|
+
export type AgentType = z.infer<typeof zodAgentSchema>;
|
|
79
|
+
export type ContextType = z.infer<typeof zodContextSchema>;
|
|
80
|
+
export type QueryType = z.infer<typeof zodQuerySchema>;
|
|
81
|
+
export type ModelType = (typeof modelsList)[number];
|
|
82
|
+
export type UserRoleType = (typeof userRoles)[number];
|