asfur 1.0.15 → 1.0.17

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
@@ -202,3 +202,303 @@ export declare const MongoDataSchema: Schema<{
202
202
  }> & {
203
203
  __v: number;
204
204
  }>;
205
+ export declare const MongoInstructionsSchema: Schema<{
206
+ user_id: string;
207
+ prompt: string;
208
+ _id?: string | undefined;
209
+ created_at?: number | Date | undefined;
210
+ updated_at?: number | Date | undefined;
211
+ }, import("mongoose").Model<{
212
+ user_id: string;
213
+ prompt: string;
214
+ _id?: string | undefined;
215
+ created_at?: number | Date | undefined;
216
+ updated_at?: number | Date | undefined;
217
+ }, any, any, any, import("mongoose").Document<unknown, any, {
218
+ user_id: string;
219
+ prompt: string;
220
+ _id?: string | undefined;
221
+ created_at?: number | Date | undefined;
222
+ updated_at?: number | Date | undefined;
223
+ }, any> & {
224
+ user_id: string;
225
+ prompt: string;
226
+ _id?: string | undefined;
227
+ created_at?: number | Date | undefined;
228
+ updated_at?: number | Date | undefined;
229
+ } & Required<{
230
+ _id: string;
231
+ }> & {
232
+ __v: number;
233
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
234
+ user_id: string;
235
+ prompt: string;
236
+ _id?: string | undefined;
237
+ created_at?: number | Date | undefined;
238
+ updated_at?: number | Date | undefined;
239
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
240
+ user_id: string;
241
+ prompt: string;
242
+ _id?: string | undefined;
243
+ created_at?: number | Date | undefined;
244
+ updated_at?: number | Date | undefined;
245
+ }>, {}> & import("mongoose").FlatRecord<{
246
+ user_id: string;
247
+ prompt: string;
248
+ _id?: string | undefined;
249
+ created_at?: number | Date | undefined;
250
+ updated_at?: number | Date | undefined;
251
+ }> & Required<{
252
+ _id: string;
253
+ }> & {
254
+ __v: number;
255
+ }>;
256
+ export declare const MongoSourceSchema: Schema<{
257
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
258
+ status: "approved" | "pending" | "inactive" | "in_review";
259
+ source_id: string | number;
260
+ source_name: string;
261
+ is_public: boolean;
262
+ created_at: Date;
263
+ _id?: string | undefined;
264
+ title?: string | undefined;
265
+ source_public_id?: string | number | undefined;
266
+ last_text_id?: number | undefined;
267
+ url?: string | undefined;
268
+ description?: string | undefined;
269
+ language?: string | undefined;
270
+ source_geo?: string | undefined;
271
+ tags?: string[] | undefined;
272
+ metadata?: Record<string, any> | undefined;
273
+ updated_at?: Date | undefined;
274
+ }, import("mongoose").Model<{
275
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
276
+ status: "approved" | "pending" | "inactive" | "in_review";
277
+ source_id: string | number;
278
+ source_name: string;
279
+ is_public: boolean;
280
+ created_at: Date;
281
+ _id?: string | undefined;
282
+ title?: string | undefined;
283
+ source_public_id?: string | number | undefined;
284
+ last_text_id?: number | undefined;
285
+ url?: string | undefined;
286
+ description?: string | undefined;
287
+ language?: string | undefined;
288
+ source_geo?: string | undefined;
289
+ tags?: string[] | undefined;
290
+ metadata?: Record<string, any> | undefined;
291
+ updated_at?: Date | undefined;
292
+ }, any, any, any, import("mongoose").Document<unknown, any, {
293
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
294
+ status: "approved" | "pending" | "inactive" | "in_review";
295
+ source_id: string | number;
296
+ source_name: string;
297
+ is_public: boolean;
298
+ created_at: Date;
299
+ _id?: string | undefined;
300
+ title?: string | undefined;
301
+ source_public_id?: string | number | undefined;
302
+ last_text_id?: number | undefined;
303
+ url?: string | undefined;
304
+ description?: string | undefined;
305
+ language?: string | undefined;
306
+ source_geo?: string | undefined;
307
+ tags?: string[] | undefined;
308
+ metadata?: Record<string, any> | undefined;
309
+ updated_at?: Date | undefined;
310
+ }, any> & {
311
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
312
+ status: "approved" | "pending" | "inactive" | "in_review";
313
+ source_id: string | number;
314
+ source_name: string;
315
+ is_public: boolean;
316
+ created_at: Date;
317
+ _id?: string | undefined;
318
+ title?: string | undefined;
319
+ source_public_id?: string | number | undefined;
320
+ last_text_id?: number | undefined;
321
+ url?: string | undefined;
322
+ description?: string | undefined;
323
+ language?: string | undefined;
324
+ source_geo?: string | undefined;
325
+ tags?: string[] | undefined;
326
+ metadata?: Record<string, any> | undefined;
327
+ updated_at?: Date | undefined;
328
+ } & Required<{
329
+ _id: string;
330
+ }> & {
331
+ __v: number;
332
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
333
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
334
+ status: "approved" | "pending" | "inactive" | "in_review";
335
+ source_id: string | number;
336
+ source_name: string;
337
+ is_public: boolean;
338
+ created_at: Date;
339
+ _id?: string | undefined;
340
+ title?: string | undefined;
341
+ source_public_id?: string | number | undefined;
342
+ last_text_id?: number | undefined;
343
+ url?: string | undefined;
344
+ description?: string | undefined;
345
+ language?: string | undefined;
346
+ source_geo?: string | undefined;
347
+ tags?: string[] | undefined;
348
+ metadata?: Record<string, any> | undefined;
349
+ updated_at?: Date | undefined;
350
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
351
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
352
+ status: "approved" | "pending" | "inactive" | "in_review";
353
+ source_id: string | number;
354
+ source_name: string;
355
+ is_public: boolean;
356
+ created_at: Date;
357
+ _id?: string | undefined;
358
+ title?: string | undefined;
359
+ source_public_id?: string | number | undefined;
360
+ last_text_id?: number | undefined;
361
+ url?: string | undefined;
362
+ description?: string | undefined;
363
+ language?: string | undefined;
364
+ source_geo?: string | undefined;
365
+ tags?: string[] | undefined;
366
+ metadata?: Record<string, any> | undefined;
367
+ updated_at?: Date | undefined;
368
+ }>, {}> & import("mongoose").FlatRecord<{
369
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
370
+ status: "approved" | "pending" | "inactive" | "in_review";
371
+ source_id: string | number;
372
+ source_name: string;
373
+ is_public: boolean;
374
+ created_at: Date;
375
+ _id?: string | undefined;
376
+ title?: string | undefined;
377
+ source_public_id?: string | number | undefined;
378
+ last_text_id?: number | undefined;
379
+ url?: string | undefined;
380
+ description?: string | undefined;
381
+ language?: string | undefined;
382
+ source_geo?: string | undefined;
383
+ tags?: string[] | undefined;
384
+ metadata?: Record<string, any> | undefined;
385
+ updated_at?: Date | undefined;
386
+ }> & Required<{
387
+ _id: string;
388
+ }> & {
389
+ __v: number;
390
+ }>;
391
+ export declare const MongoQuerySchema: Schema<{
392
+ sources: string[];
393
+ time_range: {
394
+ type: "relative";
395
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
396
+ } | {
397
+ type: "absolute";
398
+ start: number | Date;
399
+ end: number | Date;
400
+ };
401
+ user_id: string;
402
+ is_default: boolean;
403
+ title?: string | undefined;
404
+ query?: string | undefined;
405
+ user_instructions?: string | undefined;
406
+ }, import("mongoose").Model<{
407
+ sources: string[];
408
+ time_range: {
409
+ type: "relative";
410
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
411
+ } | {
412
+ type: "absolute";
413
+ start: number | Date;
414
+ end: number | Date;
415
+ };
416
+ user_id: string;
417
+ is_default: boolean;
418
+ title?: string | undefined;
419
+ query?: string | undefined;
420
+ user_instructions?: string | undefined;
421
+ }, any, any, any, import("mongoose").Document<unknown, any, {
422
+ sources: string[];
423
+ time_range: {
424
+ type: "relative";
425
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
426
+ } | {
427
+ type: "absolute";
428
+ start: number | Date;
429
+ end: number | Date;
430
+ };
431
+ user_id: string;
432
+ is_default: boolean;
433
+ title?: string | undefined;
434
+ query?: string | undefined;
435
+ user_instructions?: string | undefined;
436
+ }, any> & {
437
+ sources: string[];
438
+ time_range: {
439
+ type: "relative";
440
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
441
+ } | {
442
+ type: "absolute";
443
+ start: number | Date;
444
+ end: number | Date;
445
+ };
446
+ user_id: string;
447
+ is_default: boolean;
448
+ title?: string | undefined;
449
+ query?: string | undefined;
450
+ user_instructions?: string | undefined;
451
+ } & {
452
+ _id: import("mongoose").Types.ObjectId;
453
+ } & {
454
+ __v: number;
455
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
456
+ sources: string[];
457
+ time_range: {
458
+ type: "relative";
459
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
460
+ } | {
461
+ type: "absolute";
462
+ start: number | Date;
463
+ end: number | Date;
464
+ };
465
+ user_id: string;
466
+ is_default: boolean;
467
+ title?: string | undefined;
468
+ query?: string | undefined;
469
+ user_instructions?: string | undefined;
470
+ }, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
471
+ sources: string[];
472
+ time_range: {
473
+ type: "relative";
474
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
475
+ } | {
476
+ type: "absolute";
477
+ start: number | Date;
478
+ end: number | Date;
479
+ };
480
+ user_id: string;
481
+ is_default: boolean;
482
+ title?: string | undefined;
483
+ query?: string | undefined;
484
+ user_instructions?: string | undefined;
485
+ }>, {}> & import("mongoose").FlatRecord<{
486
+ sources: string[];
487
+ time_range: {
488
+ type: "relative";
489
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
490
+ } | {
491
+ type: "absolute";
492
+ start: number | Date;
493
+ end: number | Date;
494
+ };
495
+ user_id: string;
496
+ is_default: boolean;
497
+ title?: string | undefined;
498
+ query?: string | undefined;
499
+ user_instructions?: string | undefined;
500
+ }> & {
501
+ _id: import("mongoose").Types.ObjectId;
502
+ } & {
503
+ __v: number;
504
+ }>;
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.MongoDataSchema = void 0;
17
+ exports.MongoQuerySchema = exports.MongoSourceSchema = exports.MongoInstructionsSchema = exports.MongoDataSchema = void 0;
18
18
  // Export types for consumers
19
19
  __exportStar(require("./types"), exports);
20
20
  const mongoose_1 = require("mongoose");
@@ -40,4 +40,68 @@ exports.MongoDataSchema = new mongoose_1.Schema({
40
40
  toJSON: { virtuals: true },
41
41
  toObject: { virtuals: true },
42
42
  });
43
- // export const DataModel = model('DataModel', MongoDataSchema, 'data');
43
+ exports.MongoInstructionsSchema = new mongoose_1.Schema({
44
+ user_id: { type: String, required: true },
45
+ prompt: { type: String },
46
+ created_at: { type: Number, default: Date.now },
47
+ updated_at: { type: Number, default: Date.now },
48
+ }, {
49
+ versionKey: false,
50
+ toJSON: { virtuals: true },
51
+ toObject: { virtuals: true },
52
+ });
53
+ exports.MongoSourceSchema = new mongoose_1.Schema({
54
+ title: { type: String, required: true },
55
+ platform: {
56
+ type: String,
57
+ enum: [
58
+ 'telegram',
59
+ 'facebook',
60
+ 'twitter',
61
+ 'instagram',
62
+ 'tiktok',
63
+ 'youtube',
64
+ 'website',
65
+ 'document',
66
+ 'other',
67
+ ],
68
+ required: true,
69
+ },
70
+ source_id: { type: String || Number, required: true },
71
+ source_public_id: { type: String || Number, required: true },
72
+ is_public: { type: Boolean, default: true },
73
+ description: { type: String },
74
+ last_text_id: { type: Number },
75
+ source_geo: { type: String },
76
+ source_name: { type: String, required: true },
77
+ status: {
78
+ type: String,
79
+ enum: ['approved', 'pending', 'inactive', 'in_review'],
80
+ default: 'pending',
81
+ },
82
+ tags: { type: [String], default: [] },
83
+ url: { type: String },
84
+ metadata: { type: Object, default: {} },
85
+ created_at: { type: Date, default: Date.now },
86
+ updated_at: { type: Date, default: Date.now },
87
+ }, {
88
+ versionKey: false,
89
+ toJSON: { virtuals: true },
90
+ toObject: { virtuals: true },
91
+ });
92
+ exports.MongoQuerySchema = new mongoose_1.Schema({
93
+ title: { type: String },
94
+ query: { type: String },
95
+ sources: { type: [String], required: true },
96
+ time_range: {
97
+ type: mongoose_1.Schema.Types.Mixed,
98
+ required: true,
99
+ },
100
+ user_id: { type: String, required: true },
101
+ is_default: { type: Boolean, default: false },
102
+ user_instructions: { type: String }, // optional user instructions for the query
103
+ }, {
104
+ versionKey: false,
105
+ toJSON: { virtuals: true },
106
+ toObject: { virtuals: true },
107
+ });
package/dist/types.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  export declare const platformsList: readonly ["telegram", "facebook", "instagram", "tiktok", "website", "document", "other"];
3
+ export declare const statusList: readonly ["approved", "pending", "inactive", "in_review"];
3
4
  export declare const zodSourceSchema: z.ZodObject<{
4
5
  _id: z.ZodOptional<z.ZodString>;
5
6
  title: z.ZodOptional<z.ZodString>;
@@ -13,14 +14,14 @@ export declare const zodSourceSchema: z.ZodObject<{
13
14
  language: z.ZodOptional<z.ZodString>;
14
15
  source_geo: z.ZodOptional<z.ZodString>;
15
16
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
16
- status: z.ZodEnum<["approved", "pending", "inactive"]>;
17
+ status: z.ZodEnum<["approved", "pending", "inactive", "in_review"]>;
17
18
  is_public: z.ZodDefault<z.ZodBoolean>;
18
19
  metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
19
20
  created_at: z.ZodDate;
20
21
  updated_at: z.ZodOptional<z.ZodDate>;
21
22
  }, "strip", z.ZodTypeAny, {
22
23
  platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
23
- status: "approved" | "pending" | "inactive";
24
+ status: "approved" | "pending" | "inactive" | "in_review";
24
25
  source_id: string | number;
25
26
  source_name: string;
26
27
  is_public: boolean;
@@ -38,7 +39,7 @@ export declare const zodSourceSchema: z.ZodObject<{
38
39
  updated_at?: Date | undefined;
39
40
  }, {
40
41
  platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
41
- status: "approved" | "pending" | "inactive";
42
+ status: "approved" | "pending" | "inactive" | "in_review";
42
43
  source_id: string | number;
43
44
  source_name: string;
44
45
  created_at: Date;
@@ -55,18 +56,6 @@ export declare const zodSourceSchema: z.ZodObject<{
55
56
  metadata?: Record<string, any> | undefined;
56
57
  updated_at?: Date | undefined;
57
58
  }>;
58
- /**
59
- * ids:
60
- * 1. _id: MongoDB ObjectId as string
61
- * 2. source_id: reference to Source _id
62
- * 3. platform_id: e.g., 'telegram:1234567890' (channel_id)
63
- * 4. original_id: ID from the platform (e.g., message_id
64
- *
65
- * INDEXES:
66
- * - source_id: reference to Source _id
67
- * - timestamp: date in milliseconds (e.g., 1751210833000)
68
- * - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
69
- */
70
59
  export declare const zodDataSchema: z.ZodObject<{
71
60
  _id: z.ZodOptional<z.ZodString>;
72
61
  source_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
@@ -148,42 +137,88 @@ export declare const zodDataSchema: z.ZodObject<{
148
137
  caption?: string | undefined;
149
138
  }[] | undefined;
150
139
  }>;
140
+ export declare const zodRelativeTimeRangeSchema: z.ZodObject<{
141
+ type: z.ZodLiteral<"relative">;
142
+ time: z.ZodEnum<["last_12_hours", "last_24_hours", "last_48_hours", "last_72_hours", "last_week"]>;
143
+ }, "strip", z.ZodTypeAny, {
144
+ type: "relative";
145
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
146
+ }, {
147
+ type: "relative";
148
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
149
+ }>;
150
+ export declare const zodAbsoluteTimeRangeSchema: z.ZodObject<{
151
+ type: z.ZodLiteral<"absolute">;
152
+ start: z.ZodUnion<[z.ZodDate, z.ZodNumber]>;
153
+ end: z.ZodUnion<[z.ZodDate, z.ZodNumber]>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ type: "absolute";
156
+ start: number | Date;
157
+ end: number | Date;
158
+ }, {
159
+ type: "absolute";
160
+ start: number | Date;
161
+ end: number | Date;
162
+ }>;
151
163
  export declare const zodQuerySchema: z.ZodObject<{
164
+ title: z.ZodOptional<z.ZodString>;
165
+ query: z.ZodOptional<z.ZodString>;
152
166
  sources: z.ZodArray<z.ZodString, "many">;
153
- query: z.ZodString;
154
- user_instructions: z.ZodOptional<z.ZodString>;
155
- time_range: z.ZodObject<{
167
+ time_range: z.ZodUnion<[z.ZodObject<{
168
+ type: z.ZodLiteral<"relative">;
169
+ time: z.ZodEnum<["last_12_hours", "last_24_hours", "last_48_hours", "last_72_hours", "last_week"]>;
170
+ }, "strip", z.ZodTypeAny, {
171
+ type: "relative";
172
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
173
+ }, {
174
+ type: "relative";
175
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
176
+ }>, z.ZodObject<{
177
+ type: z.ZodLiteral<"absolute">;
156
178
  start: z.ZodUnion<[z.ZodDate, z.ZodNumber]>;
157
179
  end: z.ZodUnion<[z.ZodDate, z.ZodNumber]>;
158
180
  }, "strip", z.ZodTypeAny, {
181
+ type: "absolute";
159
182
  start: number | Date;
160
183
  end: number | Date;
161
184
  }, {
185
+ type: "absolute";
162
186
  start: number | Date;
163
187
  end: number | Date;
164
- }>;
188
+ }>]>;
189
+ user_instructions: z.ZodOptional<z.ZodString>;
165
190
  user_id: z.ZodString;
166
- thread_id: z.ZodOptional<z.ZodString>;
191
+ is_default: z.ZodDefault<z.ZodBoolean>;
167
192
  }, "strip", z.ZodTypeAny, {
168
193
  sources: string[];
169
- query: string;
170
194
  time_range: {
195
+ type: "relative";
196
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
197
+ } | {
198
+ type: "absolute";
171
199
  start: number | Date;
172
200
  end: number | Date;
173
201
  };
174
202
  user_id: string;
203
+ is_default: boolean;
204
+ title?: string | undefined;
205
+ query?: string | undefined;
175
206
  user_instructions?: string | undefined;
176
- thread_id?: string | undefined;
177
207
  }, {
178
208
  sources: string[];
179
- query: string;
180
209
  time_range: {
210
+ type: "relative";
211
+ time: "last_12_hours" | "last_24_hours" | "last_48_hours" | "last_72_hours" | "last_week";
212
+ } | {
213
+ type: "absolute";
181
214
  start: number | Date;
182
215
  end: number | Date;
183
216
  };
184
217
  user_id: string;
218
+ title?: string | undefined;
219
+ query?: string | undefined;
185
220
  user_instructions?: string | undefined;
186
- thread_id?: string | undefined;
221
+ is_default?: boolean | undefined;
187
222
  }>;
188
223
  export declare const zodInstructionsSchema: z.ZodObject<{
189
224
  _id: z.ZodOptional<z.ZodString>;
@@ -208,3 +243,6 @@ export type SourceType = z.infer<typeof zodSourceSchema>;
208
243
  export type DataType = z.infer<typeof zodDataSchema>;
209
244
  export type QueryType = z.infer<typeof zodQuerySchema>;
210
245
  export type InstructionsType = z.infer<typeof zodInstructionsSchema>;
246
+ export type StatusType = (typeof statusList)[number];
247
+ export type TimeRangeType = z.infer<typeof zodRelativeTimeRangeSchema> | z.infer<typeof zodAbsoluteTimeRangeSchema>;
248
+ export type TimeRangeTypeLiteral = 'relative' | 'absolute';
package/dist/types.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zodInstructionsSchema = exports.zodQuerySchema = exports.zodDataSchema = exports.zodSourceSchema = exports.platformsList = void 0;
3
+ exports.zodInstructionsSchema = exports.zodQuerySchema = exports.zodAbsoluteTimeRangeSchema = exports.zodRelativeTimeRangeSchema = exports.zodDataSchema = exports.zodSourceSchema = exports.statusList = exports.platformsList = void 0;
4
4
  const zod_1 = require("zod");
5
5
  exports.platformsList = [
6
6
  'telegram',
@@ -11,6 +11,12 @@ exports.platformsList = [
11
11
  'document',
12
12
  'other',
13
13
  ];
14
+ exports.statusList = [
15
+ 'approved',
16
+ 'pending',
17
+ 'inactive',
18
+ 'in_review',
19
+ ];
14
20
  exports.zodSourceSchema = zod_1.z.object({
15
21
  _id: zod_1.z.string().optional(),
16
22
  title: zod_1.z.string().optional(),
@@ -24,24 +30,12 @@ exports.zodSourceSchema = zod_1.z.object({
24
30
  language: zod_1.z.string().optional(),
25
31
  source_geo: zod_1.z.string().optional(),
26
32
  tags: zod_1.z.array(zod_1.z.string()).optional(),
27
- status: zod_1.z.enum(['approved', 'pending', 'inactive']),
33
+ status: zod_1.z.enum(exports.statusList),
28
34
  is_public: zod_1.z.boolean().default(true),
29
35
  metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
30
36
  created_at: zod_1.z.coerce.date(),
31
37
  updated_at: zod_1.z.coerce.date().optional(),
32
38
  });
33
- /**
34
- * ids:
35
- * 1. _id: MongoDB ObjectId as string
36
- * 2. source_id: reference to Source _id
37
- * 3. platform_id: e.g., 'telegram:1234567890' (channel_id)
38
- * 4. original_id: ID from the platform (e.g., message_id
39
- *
40
- * INDEXES:
41
- * - source_id: reference to Source _id
42
- * - timestamp: date in milliseconds (e.g., 1751210833000)
43
- * - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
44
- */
45
39
  exports.zodDataSchema = zod_1.z.object({
46
40
  _id: zod_1.z.string().optional(),
47
41
  source_id: zod_1.z.string().or(zod_1.z.number()),
@@ -69,16 +63,29 @@ exports.zodDataSchema = zod_1.z.object({
69
63
  }))
70
64
  .optional(), // media attachments
71
65
  });
66
+ exports.zodRelativeTimeRangeSchema = zod_1.z.object({
67
+ type: zod_1.z.literal('relative'),
68
+ time: zod_1.z.enum([
69
+ 'last_12_hours',
70
+ 'last_24_hours',
71
+ 'last_48_hours',
72
+ 'last_72_hours',
73
+ 'last_week',
74
+ ]),
75
+ });
76
+ exports.zodAbsoluteTimeRangeSchema = zod_1.z.object({
77
+ type: zod_1.z.literal('absolute'),
78
+ start: zod_1.z.coerce.date().or(zod_1.z.number()),
79
+ end: zod_1.z.coerce.date().or(zod_1.z.number()), // end date
80
+ });
72
81
  exports.zodQuerySchema = zod_1.z.object({
82
+ title: zod_1.z.string().optional(),
83
+ query: zod_1.z.string().optional(),
73
84
  sources: zod_1.z.array(zod_1.z.string()),
74
- query: zod_1.z.string().nonempty('Query cannot be empty'),
85
+ time_range: exports.zodRelativeTimeRangeSchema.or(exports.zodAbsoluteTimeRangeSchema),
75
86
  user_instructions: zod_1.z.string().optional(),
76
- time_range: zod_1.z.object({
77
- start: zod_1.z.coerce.date().or(zod_1.z.number()),
78
- end: zod_1.z.coerce.date().or(zod_1.z.number()), // end date
79
- }),
80
87
  user_id: zod_1.z.string().nonempty('User ID must be provided'),
81
- thread_id: zod_1.z.string().optional(), // optional thread identifier
88
+ is_default: zod_1.z.boolean().default(false), // true if this is a default query
82
89
  });
83
90
  exports.zodInstructionsSchema = zod_1.z.object({
84
91
  _id: zod_1.z.string().optional(),
package/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  // Export types for consumers
2
2
  export * from './types';
3
3
 
4
- import { Schema, model } from 'mongoose';
5
- import { DataType } from './types';
4
+ import { Schema } from 'mongoose';
5
+ import { DataType, InstructionsType, QueryType, SourceType } from './types';
6
6
 
7
7
  export const MongoDataSchema = new Schema<DataType>(
8
8
  {
@@ -22,13 +22,87 @@ export const MongoDataSchema = new Schema<DataType>(
22
22
  reply_to_message_id: { type: String || Number },
23
23
  created_at: { type: Number, default: Date.now },
24
24
  updated_at: { type: Number, default: Date.now },
25
+ },
26
+ {
27
+ versionKey: false,
28
+ toJSON: { virtuals: true },
29
+ toObject: { virtuals: true },
30
+ }
31
+ );
25
32
 
33
+ export const MongoInstructionsSchema = new Schema<InstructionsType>(
34
+ {
35
+ user_id: { type: String, required: true },
36
+ prompt: { type: String },
37
+ created_at: { type: Number, default: Date.now },
38
+ updated_at: { type: Number, default: Date.now },
26
39
  },
27
40
  {
28
41
  versionKey: false,
29
42
  toJSON: { virtuals: true },
30
43
  toObject: { virtuals: true },
44
+ }
45
+ );
46
+
47
+ export const MongoSourceSchema = new Schema<SourceType>(
48
+ {
49
+ title: { type: String, required: true }, // e.g., 'Telegram Channel Name'
50
+ platform: {
51
+ type: String,
52
+ enum: [
53
+ 'telegram',
54
+ 'facebook',
55
+ 'twitter',
56
+ 'instagram',
57
+ 'tiktok',
58
+ 'youtube',
59
+ 'website',
60
+ 'document',
61
+ 'other',
62
+ ],
63
+ required: true,
64
+ },
65
+ source_id: { type: String || Number, required: true }, // original channel_id
66
+ source_public_id: { type: String || Number, required: true }, // e.g., '@telegram_channel_id'
67
+ is_public: { type: Boolean, default: true }, // true if the source is public
68
+ description: { type: String }, // e.g., 'A channel about news and updates'
69
+ last_text_id: { type: Number }, // last processed text ID
70
+ source_geo: { type: String }, // e.g., country or region
71
+ source_name: { type: String, required: true }, // e.g., 'Telegram Channel Name'
72
+ status: {
73
+ type: String,
74
+ enum: ['approved', 'pending', 'inactive', 'in_review'],
75
+ default: 'pending',
76
+ }, // INDEX
77
+ tags: { type: [String], default: [] }, // array of tags
78
+ url: { type: String }, // e.g., 'https://t.me/telegram_channel_name'
79
+ metadata: { type: Object, default: {} }, // flexible per platform
80
+ created_at: { type: Date, default: Date.now },
81
+ updated_at: { type: Date, default: Date.now },
31
82
  },
83
+ {
84
+ versionKey: false,
85
+ toJSON: { virtuals: true },
86
+ toObject: { virtuals: true },
87
+ }
32
88
  );
33
89
 
34
- // export const DataModel = model('DataModel', MongoDataSchema, 'data');
90
+ export const MongoQuerySchema = new Schema<QueryType>(
91
+ {
92
+ title: { type: String }, // e.g., 'Search Query'
93
+ query: { type: String }, // search query includes geo information where it should be extracted with LLM
94
+ sources: { type: [String], required: true }, // array of source _id strings
95
+ time_range: {
96
+ type: Schema.Types.Mixed, // can be relative or absolute time range
97
+ required: true,
98
+ },
99
+ user_id: { type: String, required: true }, // user identifier
100
+ is_default: { type: Boolean, default: false }, // true if this is a default query
101
+ user_instructions: { type: String }, // optional user instructions for the query
102
+ },
103
+ {
104
+ versionKey: false,
105
+ toJSON: { virtuals: true },
106
+ toObject: { virtuals: true },
107
+ }
108
+ );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "asfur",
3
- "version": "1.0.15",
3
+ "version": "1.0.17",
4
4
  "description": "SDK for interacting with the Asfur API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/types.ts CHANGED
@@ -10,6 +10,13 @@ export const platformsList = [
10
10
  'other',
11
11
  ] as const;
12
12
 
13
+ export const statusList = [
14
+ 'approved',
15
+ 'pending',
16
+ 'inactive',
17
+ 'in_review',
18
+ ] as const;
19
+
13
20
  export const zodSourceSchema = z.object({
14
21
  _id: z.string().optional(),
15
22
  title: z.string().optional(), // e.g., 'Telegram Channel Name'
@@ -23,26 +30,13 @@ export const zodSourceSchema = z.object({
23
30
  language: z.string().optional(),
24
31
  source_geo: z.string().optional(), // e.g., country or region
25
32
  tags: z.array(z.string()).optional(),
26
- status: z.enum(['approved', 'pending', 'inactive']), // INDEX
33
+ status: z.enum(statusList), // INDEX
27
34
  is_public: z.boolean().default(true), // true if the source is public
28
35
  metadata: z.record(z.string(), z.any()).optional(), // flexible per platform
29
36
  created_at: z.coerce.date(),
30
37
  updated_at: z.coerce.date().optional(),
31
38
  });
32
39
 
33
- /**
34
- * ids:
35
- * 1. _id: MongoDB ObjectId as string
36
- * 2. source_id: reference to Source _id
37
- * 3. platform_id: e.g., 'telegram:1234567890' (channel_id)
38
- * 4. original_id: ID from the platform (e.g., message_id
39
- *
40
- * INDEXES:
41
- * - source_id: reference to Source _id
42
- * - timestamp: date in milliseconds (e.g., 1751210833000)
43
- * - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
44
- */
45
-
46
40
  export const zodDataSchema = z.object({
47
41
  _id: z.string().optional(),
48
42
  source_id: z.string().or(z.number()), // INDEX - reference to Source _id (e.g., '60c72b2f9b1e8d3f4c8b4567')
@@ -73,16 +67,31 @@ export const zodDataSchema = z.object({
73
67
  .optional(), // media attachments
74
68
  });
75
69
 
70
+ export const zodRelativeTimeRangeSchema = z.object({
71
+ type: z.literal('relative'),
72
+ time: z.enum([
73
+ 'last_12_hours',
74
+ 'last_24_hours',
75
+ 'last_48_hours',
76
+ 'last_72_hours',
77
+ 'last_week',
78
+ ]),
79
+ });
80
+
81
+ export const zodAbsoluteTimeRangeSchema = z.object({
82
+ type: z.literal('absolute'),
83
+ start: z.coerce.date().or(z.number()), // start date
84
+ end: z.coerce.date().or(z.number()), // end date
85
+ });
86
+
76
87
  export const zodQuerySchema = z.object({
88
+ title: z.string().optional(), // optional title for the query
89
+ query: z.string().optional(), // search query includes geo information where it should be extracted with LLM
77
90
  sources: z.array(z.string()), // array of source _id strings
78
- query: z.string().nonempty('Query cannot be empty'), // search query includes geo information where it should be extracted with LLM
91
+ time_range: zodRelativeTimeRangeSchema.or(zodAbsoluteTimeRangeSchema), // optional time range for the query
79
92
  user_instructions: z.string().optional(), // optional user instructions for the query
80
- time_range: z.object({
81
- start: z.coerce.date().or(z.number()), // start date
82
- end: z.coerce.date().or(z.number()), // end date
83
- }),
84
93
  user_id: z.string().nonempty('User ID must be provided'), // user identifier
85
- thread_id: z.string().optional(), // optional thread identifier
94
+ is_default: z.boolean().default(false), // true if this is a default query
86
95
  });
87
96
 
88
97
  export const zodInstructionsSchema = z.object({
@@ -91,9 +100,17 @@ export const zodInstructionsSchema = z.object({
91
100
  prompt: z.string().nonempty('Prompt cannot be empty'), // user prompt
92
101
  created_at: z.coerce.date().or(z.number()).optional(), // creation date
93
102
  updated_at: z.coerce.date().or(z.number()).optional(), // last update date
94
- })
103
+ });
95
104
 
96
105
  export type SourceType = z.infer<typeof zodSourceSchema>;
97
106
  export type DataType = z.infer<typeof zodDataSchema>;
98
107
  export type QueryType = z.infer<typeof zodQuerySchema>;
99
108
  export type InstructionsType = z.infer<typeof zodInstructionsSchema>;
109
+ export type StatusType = (typeof statusList)[number];
110
+ export type TimeRangeType =
111
+ | z.infer<typeof zodRelativeTimeRangeSchema>
112
+ | z.infer<typeof zodAbsoluteTimeRangeSchema>;
113
+ export type TimeRangeTypeLiteral =
114
+ | 'relative'
115
+ | 'absolute';
116
+