@avakado.ai/schemas 1.1.25 → 1.1.26
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 +0 -1
- package/models.d.ts +1 -1
- package/package.json +1 -1
- package/src/enums/index.js +1 -1
- package/src/models/Agent.js +0 -1
- package/src/models/User.js +4 -22
- package/src/models/index.js +0 -3
- package/src/models/market.js +0 -1
- package/types.d.ts +0 -54
- package/src/models/Collection.js +0 -189
- package/src/models/Data.js +0 -35
- package/src/models/Document.js +0 -15
- package/types/models/Collection.d.ts +0 -3
- package/types/models/Document.d.ts +0 -3
package/README.md
CHANGED
|
@@ -76,7 +76,6 @@ of fields (and a superset of enums) so a save in any service still has a path to
|
|
|
76
76
|
| `Job` | `Job` | discriminator `outboundCall` |
|
|
77
77
|
| `Notification` | `Notification` | |
|
|
78
78
|
| `Ticket` | `Ticket` | |
|
|
79
|
-
| `Document` | `documents` | mongoose model name is `document` |
|
|
80
79
|
| `Data` | `Data` | |
|
|
81
80
|
| `Workflow` | `Workflow` | `updateStatus` / `getNextNode` live here; `execute` stays in socketio-server |
|
|
82
81
|
| `WorkflowLogs` | `WorkflowLogs` | |
|
package/models.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// Generated by scripts/emit-types.mjs. Run `npm run types` after a schema change.
|
|
2
2
|
|
|
3
|
-
export { Action, AgentModel, AmountSchema, Api, ApiAuthenticationSchema, ApiAuthenticators, BillingLog, Business, BusinessSchema, CallSession, Campaign, CampaignSchema, Channel, ChannelCapabilityDefaults, Collection, Conversation, ConversationSchema, Data, DemonstrationModel,
|
|
3
|
+
export { Action, AgentModel, AmountSchema, Api, ApiAuthenticationSchema, ApiAuthenticators, BillingLog, Business, BusinessSchema, CallSession, Campaign, CampaignSchema, Channel, ChannelCapabilityDefaults, Collection, Conversation, ConversationSchema, Data, DemonstrationModel, Lead, LeadTemplate, Log, Message, MessageSession, Notification, OAuthAuthorizationCode, OAuthClient, OAuthRefreshToken, OAuthRevokedJti, Payment, PaymentSchema, Plan, Providers, RoleScopes, ScopesEnum, Subscription, SubscriptionSchema, Task, TaskSchema, Template, Ticket, TriggerTemplate, UsageLog, UsageLogSchema, User, Workflow, WorkflowLogs } from "./types.js";
|
package/package.json
CHANGED
package/src/enums/index.js
CHANGED
|
@@ -43,7 +43,7 @@ export const PAYMENT_STATUS = ["authorized", "captured", "failed", "refunded"];
|
|
|
43
43
|
|
|
44
44
|
export const LEDGER_DIRECTIONS = ["credit", "debit", "reset"];
|
|
45
45
|
export const LEDGER_STATUSES = ["posted", "pending", "failed", "reversed"];
|
|
46
|
-
export const LEDGER_SOURCE_TYPES = ["Message", "CallSession", "Subscription", "Payment"
|
|
46
|
+
export const LEDGER_SOURCE_TYPES = ["Message", "CallSession", "Subscription", "Payment"];
|
|
47
47
|
|
|
48
48
|
export const LEDGER_CATEGORY = {
|
|
49
49
|
PLAN_GRANT: "plan.grant",
|
package/src/models/Agent.js
CHANGED
|
@@ -201,7 +201,6 @@ const AgentSchema = new Schema({
|
|
|
201
201
|
runtime: { type: String, enum: ['TURN_BASED', 'REALTIME', 'BACKGROUND'], default: 'TURN_BASED' },
|
|
202
202
|
modelConfig: ModelConfigSchema,
|
|
203
203
|
workflow: { type: Schema.Types.ObjectId, ref: 'Workflow' },
|
|
204
|
-
collections: [{ type: Schema.Types.ObjectId, ref: 'Collection' }],
|
|
205
204
|
channels: [{ type: Schema.Types.ObjectId, ref: 'Channel' }],
|
|
206
205
|
actions: [{ type: Schema.Types.ObjectId, ref: 'Action' }],
|
|
207
206
|
tool_choice: { type: String, enum: ['auto', 'none', 'required'], default: "auto" },
|
package/src/models/User.js
CHANGED
|
@@ -31,14 +31,6 @@ const ScopesEnum = {
|
|
|
31
31
|
'agent:view_conversations': 'User can view agent conversations',
|
|
32
32
|
'agent:manage_prompts': 'User can manage agent prompts',
|
|
33
33
|
|
|
34
|
-
// Collection Management
|
|
35
|
-
'collection:read': 'User can read knowledge collections',
|
|
36
|
-
'collection:create': 'User can create new collections',
|
|
37
|
-
'collection:update': 'User can update collection content',
|
|
38
|
-
'collection:delete': 'User can delete collections',
|
|
39
|
-
'collection:upload_files': 'User can upload files to collections',
|
|
40
|
-
'collection:manage_permissions': 'User can manage collection access',
|
|
41
|
-
|
|
42
34
|
// Channel Management
|
|
43
35
|
'channel:read': 'User can read channel configurations',
|
|
44
36
|
'channel:create': 'User can create new channels',
|
|
@@ -78,6 +70,7 @@ const ScopesEnum = {
|
|
|
78
70
|
'analytics:real_time': 'User can view real-time analytics',
|
|
79
71
|
|
|
80
72
|
// File Management
|
|
73
|
+
'file:read': 'User can read files',
|
|
81
74
|
'file:upload': 'User can upload files',
|
|
82
75
|
'file:download': 'User can download files',
|
|
83
76
|
'file:delete': 'User can delete files',
|
|
@@ -208,12 +201,6 @@ const RoleScopes = {
|
|
|
208
201
|
'agent:test',
|
|
209
202
|
'agent:view_conversations',
|
|
210
203
|
'agent:manage_prompts',
|
|
211
|
-
'collection:read',
|
|
212
|
-
'collection:create',
|
|
213
|
-
'collection:update',
|
|
214
|
-
'collection:delete',
|
|
215
|
-
'collection:upload_files',
|
|
216
|
-
'collection:manage_permissions',
|
|
217
204
|
'channel:read',
|
|
218
205
|
'channel:create',
|
|
219
206
|
'channel:update',
|
|
@@ -242,6 +229,7 @@ const RoleScopes = {
|
|
|
242
229
|
'analytics:export',
|
|
243
230
|
'analytics:custom_reports',
|
|
244
231
|
'analytics:real_time',
|
|
232
|
+
'file:read',
|
|
245
233
|
'file:upload',
|
|
246
234
|
'file:download',
|
|
247
235
|
'file:delete',
|
|
@@ -303,12 +291,6 @@ const RoleScopes = {
|
|
|
303
291
|
'agent:test',
|
|
304
292
|
'agent:view_conversations',
|
|
305
293
|
'agent:manage_prompts',
|
|
306
|
-
'collection:read',
|
|
307
|
-
'collection:create',
|
|
308
|
-
'collection:update',
|
|
309
|
-
'collection:delete',
|
|
310
|
-
'collection:upload_files',
|
|
311
|
-
'collection:manage_permissions',
|
|
312
294
|
'channel:read',
|
|
313
295
|
'channel:create',
|
|
314
296
|
'channel:update',
|
|
@@ -337,6 +319,7 @@ const RoleScopes = {
|
|
|
337
319
|
'analytics:export',
|
|
338
320
|
'analytics:custom_reports',
|
|
339
321
|
'analytics:real_time',
|
|
322
|
+
'file:read',
|
|
340
323
|
'file:upload',
|
|
341
324
|
'file:download',
|
|
342
325
|
'file:delete',
|
|
@@ -383,8 +366,6 @@ const RoleScopes = {
|
|
|
383
366
|
'agent:read',
|
|
384
367
|
'agent:test',
|
|
385
368
|
'agent:view_conversations',
|
|
386
|
-
'collection:read',
|
|
387
|
-
'collection:upload_files',
|
|
388
369
|
'channel:read',
|
|
389
370
|
'action:read',
|
|
390
371
|
'action:test',
|
|
@@ -396,6 +377,7 @@ const RoleScopes = {
|
|
|
396
377
|
'ticket:update',
|
|
397
378
|
'analytics:read',
|
|
398
379
|
'analytics:export',
|
|
380
|
+
'file:read',
|
|
399
381
|
'file:upload',
|
|
400
382
|
'file:download',
|
|
401
383
|
'file:share',
|
package/src/models/index.js
CHANGED
|
@@ -19,11 +19,8 @@ export { BillingLog } from "./BillingLogs.js";
|
|
|
19
19
|
export { ApiAuthenticators, ApiAuthenticationSchema } from "./apiAuthenticator.js";
|
|
20
20
|
export { DemonstrationModel } from "./Demonstarations.js";
|
|
21
21
|
export { Action } from "./Action.js";
|
|
22
|
-
export { Collection } from "./Collection.js";
|
|
23
22
|
export { Notification } from "./notifications.js";
|
|
24
23
|
export { Ticket } from "./Tickets.js";
|
|
25
|
-
export { Document } from "./Document.js";
|
|
26
|
-
export { Data } from "./Data.js";
|
|
27
24
|
export { Workflow } from "./Workflow.js";
|
|
28
25
|
export { WorkflowLogs } from "./WorkflowLogs.js";
|
|
29
26
|
export { OAuthClient, OAuthAuthorizationCode, OAuthRefreshToken, OAuthRevokedJti } from "./OAuth.js";
|
package/src/models/market.js
CHANGED
|
@@ -39,7 +39,6 @@ const AgentData = new Schema(
|
|
|
39
39
|
model: { type: String, default: 'gpt-4.1-mini' },
|
|
40
40
|
temperature: { type: Number, default: 0.5 },
|
|
41
41
|
},
|
|
42
|
-
collections: [{ type: Schema.Types.ObjectId, ref: 'Collection' }],
|
|
43
42
|
actions: [{ type: Schema.Types.ObjectId, ref: 'StandardProduct' }],
|
|
44
43
|
facets: [String],
|
|
45
44
|
},
|
package/types.d.ts
CHANGED
|
@@ -33,7 +33,6 @@ export interface AgentModel {
|
|
|
33
33
|
runtime?: "TURN_BASED" | "REALTIME" | "BACKGROUND";
|
|
34
34
|
modelConfig?: { provider: "openai" | "gemini" | "anthropic" | "custom"; customProviderRef: string; providerData?: any; model: string; modelSettings?: { temperature?: number; toolChoice?: string; topP?: number; frequencyPenalty?: number; presencePenalty?: number; parallelToolCalls?: boolean; truncation?: "auto" | "disabled"; maxTokens?: number; store?: boolean; promptCacheRetention?: string; reasoning?: { effort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max"; mode?: string; context?: string; summary?: "auto" | "concise" | "detailed"; }; text?: { verbosity?: "low" | "medium" | "high"; }; promptCacheOptions?: { mode?: "implicit" | "explicit"; ttl?: "30m"; }; }; };
|
|
35
35
|
workflow?: Types.ObjectId;
|
|
36
|
-
collections?: Types.ObjectId[];
|
|
37
36
|
channels?: Types.ObjectId[];
|
|
38
37
|
actions?: Types.ObjectId[];
|
|
39
38
|
tool_choice?: "auto" | "none" | "required";
|
|
@@ -214,33 +213,7 @@ export interface ChannelMethods {
|
|
|
214
213
|
updateStatus(status?: any): any;
|
|
215
214
|
}
|
|
216
215
|
|
|
217
|
-
export interface Collection {
|
|
218
|
-
name: string;
|
|
219
|
-
source?: "website" | "youtube" | "file" | "text";
|
|
220
|
-
status?: "active" | "loading" | "failed" | "cancelled";
|
|
221
|
-
error?: string;
|
|
222
|
-
metaData?: { progressStages?: { name?: "webcrawler" | "embed and upsert" | "Chunking" | "Parsing"; accomplished?: boolean; status?: "PENDING" | "RUNNING" | "COMPLETED" | "FAILED" | "CANCELLED"; error?: string; startedAt?: Date; completedAt?: Date; failedAt?: Date; moreInfo?: any; }[]; webcrawler?: { options?: any; jobId?: string; lastUpdate?: any; urls?: string[]; }; chunkingDetails?: { strategy?: "recursiveStructural" | "recursiveSemantic"; tunables?: { MIN_TOKENS?: number; MAX_TOKENS?: number; OVERLAP_TOKENS?: number; }; }; parserDetails?: { tier?: "fast" | "cost_effective" | "agentic" | "agentic_plus"; expand?: "text" | "items" | "markdown" | "metadata" | "images_content_metadata" | "xlsx_content_metadata" | "output_pdf_content_metadata"[]; version?: "latest"; source_url?: string; jobId?: string; lastUpdate?: any; advancedOptions?: { disable_cache?: boolean; page_ranges?: { target_pages?: string; max_pages?: number; }; agentic_options?: { custom_prompt?: string; }; output_options?: { extract_printed_page_number?: boolean; images_to_save?: "screenshot" | "embedded" | "layout"[]; markdown?: { annotate_links?: boolean; inline_images?: boolean; tables?: { compact_markdown_tables?: boolean; markdown_table_multiline_separator?: string; merge_continued_tables?: boolean; output_tables_as_markdown?: boolean; }; spatial_text?: { do_not_unroll_columns?: boolean; preserve_layout_alignment_across_pages?: boolean; preserve_very_small_text?: boolean; }; tables_as_spreadsheet?: { enable?: boolean; guess_sheet_name?: boolean; }; }; }; input_options?: { html?: { make_all_elements_visible?: boolean; remove_fixed_elements?: boolean; remove_navigation_elements?: boolean; }; presentation?: { out_of_bounds_content?: boolean; skip_embedded_data?: boolean; }; spreadsheet?: { detect_sub_tables_in_sheets?: boolean; force_formula_computation_in_sheets?: boolean; include_hidden_sheets?: boolean; }; }; processing_options?: { aggressive_table_extraction?: boolean; disable_heuristics?: boolean; specialized_chart_parsing?: "agentic_plus" | "agentic" | "efficient"; cost_optimizer?: { enable?: boolean; }; ignore?: { ignore_diagonal_text?: boolean; ignore_text_in_image?: boolean; ignore_hidden_text?: boolean; }; ocr_parameters?: { languages?: "en" | "fr" | "de" | "es" | "it" | "pt" | "ru" | "zh"[]; }; }; processing_control?: { job_failure_conditions?: { allowed_page_failure_ratio?: number; fail_on_buggy_font?: boolean; fail_on_image_extraction_error?: boolean; fail_on_image_ocr_error?: boolean; fail_on_markdown_reconstruction_error?: boolean; }; timeouts?: { base_in_seconds?: number; extra_time_per_page_in_seconds?: number; }; }; }; }; };
|
|
223
|
-
description?: string;
|
|
224
|
-
tags?: string[];
|
|
225
|
-
business?: Types.ObjectId;
|
|
226
|
-
createdBy?: Types.ObjectId;
|
|
227
|
-
isPublic?: boolean;
|
|
228
|
-
isFeatured?: boolean;
|
|
229
|
-
_id: Types.ObjectId;
|
|
230
|
-
createdAt?: Date;
|
|
231
|
-
updatedAt?: Date;
|
|
232
|
-
}
|
|
233
216
|
|
|
234
|
-
export interface CollectionStatics {
|
|
235
|
-
updateStage(collectionId?: any, stageName?: any, updates?: any): Promise<any>;
|
|
236
|
-
startStage(collectionId?: any, stageName?: any, moreInfo?: any): any;
|
|
237
|
-
cancelStage(collectionId?: any, stageName?: any, moreInfo?: any): any;
|
|
238
|
-
pendingStage(collectionId?: any, stageName?: any, moreInfo?: any): any;
|
|
239
|
-
completeStage(collectionId?: any, stageName?: any, moreInfo?: any): any;
|
|
240
|
-
failStage(collectionId?: any, stageName?: any, error?: any, moreInfo?: any): any;
|
|
241
|
-
updateMetadata(collectionId?: any, updates?: any): Promise<any>;
|
|
242
|
-
updateStatus(collectionId?: any, status?: any, error?: any): Promise<any>;
|
|
243
|
-
}
|
|
244
217
|
|
|
245
218
|
export interface Conversation {
|
|
246
219
|
agent?: Types.ObjectId;
|
|
@@ -262,18 +235,6 @@ export interface ConversationMethods {
|
|
|
262
235
|
updateStatus(status?: any): Promise<any>;
|
|
263
236
|
}
|
|
264
237
|
|
|
265
|
-
export interface Data {
|
|
266
|
-
collection?: Types.ObjectId;
|
|
267
|
-
content?: string;
|
|
268
|
-
chunkNumber?: number;
|
|
269
|
-
summary?: string;
|
|
270
|
-
embeddingVector?: number[];
|
|
271
|
-
newTopics?: string[];
|
|
272
|
-
_id: Types.ObjectId;
|
|
273
|
-
createdAt?: Date;
|
|
274
|
-
updatedAt?: Date;
|
|
275
|
-
metadata?: { tokensUsed?: number; chunkSize?: number; createdAt?: Date; url?: string; tokenUsage?: { embeddingTokens?: number; embeddingModel?: string; summarizationInputTokens?: number; summarizationOutputTokens?: number; summarizationTotalTokens?: number; summarizationModel?: string; }; };
|
|
276
|
-
}
|
|
277
238
|
|
|
278
239
|
export interface DemonstrationModel {
|
|
279
240
|
transcripts?: any;
|
|
@@ -287,17 +248,6 @@ export interface DemonstrationModel {
|
|
|
287
248
|
organization?: { id?: string; name?: string; industry?: string; };
|
|
288
249
|
}
|
|
289
250
|
|
|
290
|
-
export interface Document {
|
|
291
|
-
name?: string;
|
|
292
|
-
contentType?: string;
|
|
293
|
-
user?: Types.ObjectId;
|
|
294
|
-
viewers?: Types.ObjectId[];
|
|
295
|
-
type?: string;
|
|
296
|
-
_id: Types.ObjectId;
|
|
297
|
-
createdAt?: Date;
|
|
298
|
-
updatedAt?: Date;
|
|
299
|
-
data?: { FileName?: string; resource_id?: string; mimetype?: string; originalname?: string; fileIdentifier?: string; preview_url?: string; download_url?: string; };
|
|
300
|
-
}
|
|
301
251
|
|
|
302
252
|
export interface Lead {
|
|
303
253
|
template?: Types.ObjectId;
|
|
@@ -709,12 +659,8 @@ export const Collection: Model<Collection, {}, {}> & CollectionStatics;
|
|
|
709
659
|
|
|
710
660
|
export const Conversation: Model<Conversation, {}, ConversationMethods>;
|
|
711
661
|
|
|
712
|
-
export const Data: Model<Data, {}, {}>;
|
|
713
|
-
|
|
714
662
|
export const DemonstrationModel: Model<DemonstrationModel, {}, {}>;
|
|
715
663
|
|
|
716
|
-
export const Document: Model<Document, {}, {}>;
|
|
717
|
-
|
|
718
664
|
export const Lead: Model<Lead, {}, {}>;
|
|
719
665
|
|
|
720
666
|
export const LeadTemplate: Model<LeadTemplate, {}, {}>;
|
package/src/models/Collection.js
DELETED
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import { Schema } from "mongoose";
|
|
2
|
-
import { defineModel } from "../runtime.js";
|
|
3
|
-
const metaData = new Schema({
|
|
4
|
-
webcrawler: {
|
|
5
|
-
options: Object,
|
|
6
|
-
jobId: String,
|
|
7
|
-
lastUpdate: Schema.Types.Mixed,
|
|
8
|
-
urls: [String]
|
|
9
|
-
},
|
|
10
|
-
chunkingDetails: {
|
|
11
|
-
strategy: { type: String, enum: ["recursiveStructural", "recursiveSemantic"], default: 'recursiveStructural' },
|
|
12
|
-
tunables: {
|
|
13
|
-
MIN_TOKENS: { type: Number, default: 30 },
|
|
14
|
-
MAX_TOKENS: { type: Number, default: 512 },
|
|
15
|
-
OVERLAP_TOKENS: { type: Number, default: 50 },
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
parserDetails: {
|
|
19
|
-
tier: { type: String, enum: ['fast', 'cost_effective', 'agentic', "agentic_plus"], default: 'cost_effective' },
|
|
20
|
-
expand: { type: [String], enum: ['text', 'items', "markdown", 'metadata', 'images_content_metadata', 'xlsx_content_metadata', 'output_pdf_content_metadata'], default: ['items', "markdown", 'metadata', 'images_content_metadata'] },
|
|
21
|
-
version: { type: String, enum: ['latest'], default: 'latest' },
|
|
22
|
-
source_url: String,
|
|
23
|
-
advancedOptions: {
|
|
24
|
-
page_ranges: {
|
|
25
|
-
target_pages: String,
|
|
26
|
-
max_pages: Number,
|
|
27
|
-
},
|
|
28
|
-
disable_cache: Boolean,
|
|
29
|
-
agentic_options: {
|
|
30
|
-
custom_prompt: String
|
|
31
|
-
},
|
|
32
|
-
output_options: {
|
|
33
|
-
extract_printed_page_number: Boolean,
|
|
34
|
-
images_to_save: { type: [String], enum: ["screenshot", "embedded", "layout"] },
|
|
35
|
-
markdown: {
|
|
36
|
-
annotate_links: Boolean,
|
|
37
|
-
inline_images: Boolean,
|
|
38
|
-
tables: {
|
|
39
|
-
compact_markdown_tables: Boolean,
|
|
40
|
-
markdown_table_multiline_separator: String,
|
|
41
|
-
merge_continued_tables: Boolean,
|
|
42
|
-
output_tables_as_markdown: Boolean,
|
|
43
|
-
},
|
|
44
|
-
spatial_text: {
|
|
45
|
-
do_not_unroll_columns: Boolean,
|
|
46
|
-
preserve_layout_alignment_across_pages: Boolean,
|
|
47
|
-
preserve_very_small_text: Boolean,
|
|
48
|
-
},
|
|
49
|
-
tables_as_spreadsheet: {
|
|
50
|
-
enable: Boolean,
|
|
51
|
-
guess_sheet_name: Boolean,
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
input_options: {
|
|
56
|
-
html: {
|
|
57
|
-
make_all_elements_visible: Boolean,
|
|
58
|
-
remove_fixed_elements: Boolean,
|
|
59
|
-
remove_navigation_elements: Boolean,
|
|
60
|
-
},
|
|
61
|
-
presentation: {
|
|
62
|
-
out_of_bounds_content: Boolean,
|
|
63
|
-
skip_embedded_data: Boolean,
|
|
64
|
-
},
|
|
65
|
-
spreadsheet: {
|
|
66
|
-
detect_sub_tables_in_sheets: Boolean,
|
|
67
|
-
force_formula_computation_in_sheets: Boolean,
|
|
68
|
-
include_hidden_sheets: Boolean,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
processing_options: {
|
|
72
|
-
aggressive_table_extraction: Boolean,
|
|
73
|
-
cost_optimizer: {
|
|
74
|
-
enable: Boolean,
|
|
75
|
-
},
|
|
76
|
-
disable_heuristics: Boolean,
|
|
77
|
-
ignore: {
|
|
78
|
-
ignore_diagonal_text: Boolean,
|
|
79
|
-
ignore_text_in_image: Boolean,
|
|
80
|
-
ignore_hidden_text: Boolean,
|
|
81
|
-
},
|
|
82
|
-
ocr_parameters: {
|
|
83
|
-
languages: { type: [String], enum: ["en", "fr", "de", "es", "it", "pt", "ru", "zh"] },
|
|
84
|
-
},
|
|
85
|
-
specialized_chart_parsing: { type: String, enum: ["agentic_plus", "agentic", "efficient"] }
|
|
86
|
-
},
|
|
87
|
-
// webhook_configurations: {
|
|
88
|
-
// webhook_events: { type: [String], enum: ["parsing_completed", "parsing_failed", "parsing_progress"] },
|
|
89
|
-
// webhook_headers: { type: Object },
|
|
90
|
-
// webhook_url: { type: String },
|
|
91
|
-
// },
|
|
92
|
-
processing_control: {
|
|
93
|
-
job_failure_conditions: {
|
|
94
|
-
allowed_page_failure_ratio: Number,
|
|
95
|
-
fail_on_buggy_font: Boolean,
|
|
96
|
-
fail_on_image_extraction_error: Boolean,
|
|
97
|
-
fail_on_image_ocr_error: Boolean,
|
|
98
|
-
fail_on_markdown_reconstruction_error: Boolean,
|
|
99
|
-
},
|
|
100
|
-
timeouts: {
|
|
101
|
-
base_in_seconds: Number,
|
|
102
|
-
extra_time_per_page_in_seconds: Number,
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
jobId: String,
|
|
107
|
-
lastUpdate: Schema.Types.Mixed,
|
|
108
|
-
},
|
|
109
|
-
progressStages: [{
|
|
110
|
-
name: { type: String, enum: ['webcrawler', 'embed and upsert', 'Chunking', 'Parsing'] },
|
|
111
|
-
accomplished: { type: Boolean, default: false },
|
|
112
|
-
status: { type: String, default: "PENDING", enum: ["PENDING", "RUNNING", "COMPLETED", "FAILED", "CANCELLED"] },
|
|
113
|
-
error: { type: String },
|
|
114
|
-
startedAt: { type: Date, default: Date.now },
|
|
115
|
-
completedAt: { type: Date },
|
|
116
|
-
failedAt: { type: Date },
|
|
117
|
-
moreInfo: { type: Schema.Types.Mixed }
|
|
118
|
-
}],
|
|
119
|
-
}, { _id: false });
|
|
120
|
-
const CollectionSchema = new Schema({
|
|
121
|
-
name: { type: String, required: true, },
|
|
122
|
-
source: { type: String, enum: ['website', 'youtube', 'file', 'text'] },
|
|
123
|
-
status: { type: String, default: "loading", enum: ["active", "loading", "failed", "cancelled"] },
|
|
124
|
-
error: { type: String },
|
|
125
|
-
metaData: metaData,
|
|
126
|
-
description: { type: String },
|
|
127
|
-
tags: [String],
|
|
128
|
-
business: { type: Schema.Types.ObjectId, ref: 'Businesses' },
|
|
129
|
-
createdBy: { type: Schema.Types.ObjectId, ref: 'Users' },
|
|
130
|
-
isPublic: { type: Boolean, default: false },
|
|
131
|
-
isFeatured: { type: Boolean, default: false }
|
|
132
|
-
}, {
|
|
133
|
-
timestamps: true
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
CollectionSchema.statics.updateStage = async function (collectionId, stageName, updates) {
|
|
137
|
-
return this.findOneAndUpdate({ _id: collectionId, 'metaData.progressStages.name': stageName }, { $set: updates }, { new: true });
|
|
138
|
-
};
|
|
139
|
-
CollectionSchema.statics.startStage = function (collectionId, stageName, moreInfo) {
|
|
140
|
-
return this.updateStage(collectionId, stageName, {
|
|
141
|
-
'metaData.progressStages.$.status': 'RUNNING',
|
|
142
|
-
'metaData.progressStages.$.startedAt': new Date(),
|
|
143
|
-
'metaData.progressStages.$.error': null,
|
|
144
|
-
'metaData.progressStages.$.moreInfo': moreInfo
|
|
145
|
-
});
|
|
146
|
-
};
|
|
147
|
-
CollectionSchema.statics.cancelStage = function (collectionId, stageName, moreInfo) {
|
|
148
|
-
return this.updateStage(collectionId, stageName, {
|
|
149
|
-
'metaData.progressStages.$.status': 'CANCELLED',
|
|
150
|
-
'metaData.progressStages.$.completedAt': new Date(),
|
|
151
|
-
'metaData.progressStages.$.error': 'Cancelled by user',
|
|
152
|
-
'metaData.progressStages.$.moreInfo': moreInfo
|
|
153
|
-
});
|
|
154
|
-
};
|
|
155
|
-
CollectionSchema.statics.pendingStage = function (collectionId, stageName, moreInfo) {
|
|
156
|
-
return this.updateStage(collectionId, stageName, {
|
|
157
|
-
'metaData.progressStages.$.status': 'PENDING',
|
|
158
|
-
'metaData.progressStages.$.startedAt': null,
|
|
159
|
-
'metaData.progressStages.$.completedAt': null,
|
|
160
|
-
'metaData.progressStages.$.failedAt': null,
|
|
161
|
-
'metaData.progressStages.$.error': null,
|
|
162
|
-
'metaData.progressStages.$.moreInfo': moreInfo
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
CollectionSchema.statics.completeStage = function (collectionId, stageName, moreInfo) {
|
|
166
|
-
return this.updateStage(collectionId, stageName, {
|
|
167
|
-
'metaData.progressStages.$.accomplished': true,
|
|
168
|
-
'metaData.progressStages.$.status': 'COMPLETED',
|
|
169
|
-
'metaData.progressStages.$.completedAt': new Date(),
|
|
170
|
-
'metaData.progressStages.$.error': null,
|
|
171
|
-
'metaData.progressStages.$.moreInfo': moreInfo
|
|
172
|
-
});
|
|
173
|
-
};
|
|
174
|
-
CollectionSchema.statics.failStage = function (collectionId, stageName, error, moreInfo) {
|
|
175
|
-
return this.updateStage(collectionId, stageName, {
|
|
176
|
-
'metaData.progressStages.$.accomplished': false,
|
|
177
|
-
'metaData.progressStages.$.status': 'FAILED',
|
|
178
|
-
'metaData.progressStages.$.failedAt': new Date(),
|
|
179
|
-
'metaData.progressStages.$.error': error?.message || error,
|
|
180
|
-
'metaData.progressStages.$.moreInfo': moreInfo
|
|
181
|
-
});
|
|
182
|
-
};
|
|
183
|
-
CollectionSchema.statics.updateMetadata = async function (collectionId, updates) {
|
|
184
|
-
return await this.findOneAndUpdate({ _id: collectionId, 'metaData': { $exists: true } }, { $set: updates }, { new: true });
|
|
185
|
-
};
|
|
186
|
-
CollectionSchema.statics.updateStatus = async function (collectionId, status, error) {
|
|
187
|
-
return await this.findOneAndUpdate({ _id: collectionId }, { $set: { status, error: error?.message || error } }, { new: true });
|
|
188
|
-
};
|
|
189
|
-
export const Collection = defineModel('Collection', CollectionSchema, "Collection");
|
package/src/models/Data.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Schema } from "mongoose";
|
|
2
|
-
import { defineModel } from "../runtime.js";
|
|
3
|
-
|
|
4
|
-
const DataSchema = new Schema({
|
|
5
|
-
collection: { type: Schema.Types.ObjectId, ref: "Collection" },
|
|
6
|
-
content: String,
|
|
7
|
-
chunkNumber: Number,
|
|
8
|
-
summary: String,
|
|
9
|
-
embeddingVector: [Number],
|
|
10
|
-
newTopics: [String],
|
|
11
|
-
metadata: {
|
|
12
|
-
tokensUsed: Number,
|
|
13
|
-
chunkSize: Number, // length of content
|
|
14
|
-
createdAt: { type: Date, default: Date.now }, // time of creation
|
|
15
|
-
url: String,
|
|
16
|
-
tokenUsage: {
|
|
17
|
-
embeddingTokens: Number,
|
|
18
|
-
embeddingModel: String,
|
|
19
|
-
summarizationInputTokens: Number,
|
|
20
|
-
summarizationOutputTokens: Number,
|
|
21
|
-
summarizationTotalTokens: Number,
|
|
22
|
-
summarizationModel: String
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}, {
|
|
26
|
-
timestamps: true,
|
|
27
|
-
suppressReservedKeysWarning: true,
|
|
28
|
-
});
|
|
29
|
-
DataSchema.pre('save', function (next) {
|
|
30
|
-
if (this.content) {
|
|
31
|
-
this.metadata.chunkSize = this.content.length;
|
|
32
|
-
}
|
|
33
|
-
next();
|
|
34
|
-
});
|
|
35
|
-
export const Data = defineModel('Data', DataSchema, "Data");
|
package/src/models/Document.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Schema } from "mongoose";
|
|
2
|
-
import { defineModel } from "../runtime.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const documentSchema = Schema({
|
|
6
|
-
name: String,
|
|
7
|
-
data: { FileName: String, resource_id: String, mimetype: String, originalname: String, fileIdentifier: String, preview_url: String, download_url: String },
|
|
8
|
-
contentType: String,
|
|
9
|
-
user: { type: Schema.Types.ObjectId, ref: "Users" },
|
|
10
|
-
viewers: [{ type: Schema.Types.ObjectId, ref: "Users" }],
|
|
11
|
-
type: String
|
|
12
|
-
}, { timestamps: true });
|
|
13
|
-
const Document = defineModel('document', documentSchema);
|
|
14
|
-
export { Document };
|
|
15
|
-
export default Document
|