asfur 1.0.5 → 1.0.7
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 +203 -0
- package/dist/index.js +25 -0
- package/dist/types.d.ts +22 -16
- package/dist/types.js +8 -5
- package/index.ts +33 -1
- package/package.json +2 -1
- package/types.ts +10 -7
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,204 @@
|
|
|
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" />
|
|
1
26
|
export * from './types';
|
|
27
|
+
import { Schema } from 'mongoose';
|
|
28
|
+
export declare const MongoDataSchema: Schema<{
|
|
29
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
30
|
+
source_id: string | number;
|
|
31
|
+
source_public_id: string | number;
|
|
32
|
+
source_name: string;
|
|
33
|
+
created_at: number | Date;
|
|
34
|
+
platform_id: string | number;
|
|
35
|
+
original_text_id: string | number;
|
|
36
|
+
timestamp: number | Date;
|
|
37
|
+
text_geo: string[];
|
|
38
|
+
_id?: string | undefined;
|
|
39
|
+
language?: string | undefined;
|
|
40
|
+
source_geo?: string | undefined;
|
|
41
|
+
metadata?: Record<string, any> | undefined;
|
|
42
|
+
updated_at?: number | Date | undefined;
|
|
43
|
+
original_text?: string | undefined;
|
|
44
|
+
translated_text?: string | undefined;
|
|
45
|
+
is_reply?: boolean | undefined;
|
|
46
|
+
reply_to_message_id?: string | number | undefined;
|
|
47
|
+
media?: {
|
|
48
|
+
type: "image" | "video" | "audio" | "link";
|
|
49
|
+
url: string;
|
|
50
|
+
caption?: string | undefined;
|
|
51
|
+
}[] | undefined;
|
|
52
|
+
}, import("mongoose").Model<{
|
|
53
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
54
|
+
source_id: string | number;
|
|
55
|
+
source_public_id: string | number;
|
|
56
|
+
source_name: string;
|
|
57
|
+
created_at: number | Date;
|
|
58
|
+
platform_id: string | number;
|
|
59
|
+
original_text_id: string | number;
|
|
60
|
+
timestamp: number | Date;
|
|
61
|
+
text_geo: string[];
|
|
62
|
+
_id?: string | undefined;
|
|
63
|
+
language?: string | undefined;
|
|
64
|
+
source_geo?: string | undefined;
|
|
65
|
+
metadata?: Record<string, any> | undefined;
|
|
66
|
+
updated_at?: number | Date | undefined;
|
|
67
|
+
original_text?: string | undefined;
|
|
68
|
+
translated_text?: string | undefined;
|
|
69
|
+
is_reply?: boolean | undefined;
|
|
70
|
+
reply_to_message_id?: string | number | undefined;
|
|
71
|
+
media?: {
|
|
72
|
+
type: "image" | "video" | "audio" | "link";
|
|
73
|
+
url: string;
|
|
74
|
+
caption?: string | undefined;
|
|
75
|
+
}[] | undefined;
|
|
76
|
+
}, any, any, any, import("mongoose").Document<unknown, any, {
|
|
77
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
78
|
+
source_id: string | number;
|
|
79
|
+
source_public_id: string | number;
|
|
80
|
+
source_name: string;
|
|
81
|
+
created_at: number | Date;
|
|
82
|
+
platform_id: string | number;
|
|
83
|
+
original_text_id: string | number;
|
|
84
|
+
timestamp: number | Date;
|
|
85
|
+
text_geo: string[];
|
|
86
|
+
_id?: string | undefined;
|
|
87
|
+
language?: string | undefined;
|
|
88
|
+
source_geo?: string | undefined;
|
|
89
|
+
metadata?: Record<string, any> | undefined;
|
|
90
|
+
updated_at?: number | Date | undefined;
|
|
91
|
+
original_text?: string | undefined;
|
|
92
|
+
translated_text?: string | undefined;
|
|
93
|
+
is_reply?: boolean | undefined;
|
|
94
|
+
reply_to_message_id?: string | number | undefined;
|
|
95
|
+
media?: {
|
|
96
|
+
type: "image" | "video" | "audio" | "link";
|
|
97
|
+
url: string;
|
|
98
|
+
caption?: string | undefined;
|
|
99
|
+
}[] | undefined;
|
|
100
|
+
}, any> & {
|
|
101
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
102
|
+
source_id: string | number;
|
|
103
|
+
source_public_id: string | number;
|
|
104
|
+
source_name: string;
|
|
105
|
+
created_at: number | Date;
|
|
106
|
+
platform_id: string | number;
|
|
107
|
+
original_text_id: string | number;
|
|
108
|
+
timestamp: number | Date;
|
|
109
|
+
text_geo: string[];
|
|
110
|
+
_id?: string | undefined;
|
|
111
|
+
language?: string | undefined;
|
|
112
|
+
source_geo?: string | undefined;
|
|
113
|
+
metadata?: Record<string, any> | undefined;
|
|
114
|
+
updated_at?: number | Date | undefined;
|
|
115
|
+
original_text?: string | undefined;
|
|
116
|
+
translated_text?: string | undefined;
|
|
117
|
+
is_reply?: boolean | undefined;
|
|
118
|
+
reply_to_message_id?: string | number | undefined;
|
|
119
|
+
media?: {
|
|
120
|
+
type: "image" | "video" | "audio" | "link";
|
|
121
|
+
url: string;
|
|
122
|
+
caption?: string | undefined;
|
|
123
|
+
}[] | undefined;
|
|
124
|
+
} & Required<{
|
|
125
|
+
_id: string;
|
|
126
|
+
}> & {
|
|
127
|
+
__v: number;
|
|
128
|
+
}, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, {
|
|
129
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
130
|
+
source_id: string | number;
|
|
131
|
+
source_public_id: string | number;
|
|
132
|
+
source_name: string;
|
|
133
|
+
created_at: number | Date;
|
|
134
|
+
platform_id: string | number;
|
|
135
|
+
original_text_id: string | number;
|
|
136
|
+
timestamp: number | Date;
|
|
137
|
+
text_geo: string[];
|
|
138
|
+
_id?: string | undefined;
|
|
139
|
+
language?: string | undefined;
|
|
140
|
+
source_geo?: string | undefined;
|
|
141
|
+
metadata?: Record<string, any> | undefined;
|
|
142
|
+
updated_at?: number | Date | undefined;
|
|
143
|
+
original_text?: string | undefined;
|
|
144
|
+
translated_text?: string | undefined;
|
|
145
|
+
is_reply?: boolean | undefined;
|
|
146
|
+
reply_to_message_id?: string | number | undefined;
|
|
147
|
+
media?: {
|
|
148
|
+
type: "image" | "video" | "audio" | "link";
|
|
149
|
+
url: string;
|
|
150
|
+
caption?: string | undefined;
|
|
151
|
+
}[] | undefined;
|
|
152
|
+
}, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<{
|
|
153
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
154
|
+
source_id: string | number;
|
|
155
|
+
source_public_id: string | number;
|
|
156
|
+
source_name: string;
|
|
157
|
+
created_at: number | Date;
|
|
158
|
+
platform_id: string | number;
|
|
159
|
+
original_text_id: string | number;
|
|
160
|
+
timestamp: number | Date;
|
|
161
|
+
text_geo: string[];
|
|
162
|
+
_id?: string | undefined;
|
|
163
|
+
language?: string | undefined;
|
|
164
|
+
source_geo?: string | undefined;
|
|
165
|
+
metadata?: Record<string, any> | undefined;
|
|
166
|
+
updated_at?: number | Date | undefined;
|
|
167
|
+
original_text?: string | undefined;
|
|
168
|
+
translated_text?: string | undefined;
|
|
169
|
+
is_reply?: boolean | undefined;
|
|
170
|
+
reply_to_message_id?: string | number | undefined;
|
|
171
|
+
media?: {
|
|
172
|
+
type: "image" | "video" | "audio" | "link";
|
|
173
|
+
url: string;
|
|
174
|
+
caption?: string | undefined;
|
|
175
|
+
}[] | undefined;
|
|
176
|
+
}>, {}> & import("mongoose").FlatRecord<{
|
|
177
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
178
|
+
source_id: string | number;
|
|
179
|
+
source_public_id: string | number;
|
|
180
|
+
source_name: string;
|
|
181
|
+
created_at: number | Date;
|
|
182
|
+
platform_id: string | number;
|
|
183
|
+
original_text_id: string | number;
|
|
184
|
+
timestamp: number | Date;
|
|
185
|
+
text_geo: string[];
|
|
186
|
+
_id?: string | undefined;
|
|
187
|
+
language?: string | undefined;
|
|
188
|
+
source_geo?: string | undefined;
|
|
189
|
+
metadata?: Record<string, any> | undefined;
|
|
190
|
+
updated_at?: number | Date | undefined;
|
|
191
|
+
original_text?: string | undefined;
|
|
192
|
+
translated_text?: string | undefined;
|
|
193
|
+
is_reply?: boolean | undefined;
|
|
194
|
+
reply_to_message_id?: string | number | undefined;
|
|
195
|
+
media?: {
|
|
196
|
+
type: "image" | "video" | "audio" | "link";
|
|
197
|
+
url: string;
|
|
198
|
+
caption?: string | undefined;
|
|
199
|
+
}[] | undefined;
|
|
200
|
+
}> & Required<{
|
|
201
|
+
_id: string;
|
|
202
|
+
}> & {
|
|
203
|
+
__v: number;
|
|
204
|
+
}>;
|
package/dist/index.js
CHANGED
|
@@ -14,5 +14,30 @@ 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
18
|
// Export types for consumers
|
|
18
19
|
__exportStar(require("./types"), exports);
|
|
20
|
+
const mongoose_1 = require("mongoose");
|
|
21
|
+
exports.MongoDataSchema = new mongoose_1.Schema({
|
|
22
|
+
source_id: { type: String || Number },
|
|
23
|
+
source_public_id: { type: String || Number },
|
|
24
|
+
source_name: String,
|
|
25
|
+
platform: String,
|
|
26
|
+
media: Object,
|
|
27
|
+
metadata: Object,
|
|
28
|
+
timestamp: { type: Number, required: true },
|
|
29
|
+
text_geo: { type: [String], default: [] },
|
|
30
|
+
source_geo: String,
|
|
31
|
+
platform_id: { type: String || Number },
|
|
32
|
+
original_text_id: { type: String || Number },
|
|
33
|
+
original_text: String,
|
|
34
|
+
translated_text: String,
|
|
35
|
+
reply_to_message_id: { type: String || Number },
|
|
36
|
+
created_at: { type: Number, default: Date.now },
|
|
37
|
+
updated_at: { type: Number, default: Date.now },
|
|
38
|
+
}, {
|
|
39
|
+
versionKey: false,
|
|
40
|
+
toJSON: { virtuals: true },
|
|
41
|
+
toObject: { virtuals: true },
|
|
42
|
+
});
|
|
43
|
+
// export const DataModel = model('DataModel', MongoDataSchema, 'data');
|
package/dist/types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
export declare const platformsList: readonly ["telegram", "facebook", "instagram", "tiktok", "website", "other"];
|
|
3
|
-
export declare const
|
|
2
|
+
export declare const platformsList: readonly ["telegram", "facebook", "instagram", "tiktok", "website", "document", "other"];
|
|
3
|
+
export declare const zodSourceSchema: z.ZodObject<{
|
|
4
4
|
_id: z.ZodOptional<z.ZodString>;
|
|
5
|
-
|
|
5
|
+
title: z.ZodOptional<z.ZodString>;
|
|
6
|
+
platform: z.ZodEnum<["telegram", "facebook", "instagram", "tiktok", "website", "document", "other"]>;
|
|
6
7
|
source_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
7
8
|
source_public_id: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber]>>;
|
|
8
9
|
source_name: z.ZodString;
|
|
@@ -12,17 +13,20 @@ export declare const sourceSchema: z.ZodObject<{
|
|
|
12
13
|
language: z.ZodOptional<z.ZodString>;
|
|
13
14
|
source_geo: z.ZodOptional<z.ZodString>;
|
|
14
15
|
tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
15
|
-
status: z.ZodEnum<["approved", "pending", "
|
|
16
|
+
status: z.ZodEnum<["approved", "pending", "inactive"]>;
|
|
17
|
+
is_public: z.ZodDefault<z.ZodBoolean>;
|
|
16
18
|
metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
17
19
|
created_at: z.ZodDate;
|
|
18
20
|
updated_at: z.ZodOptional<z.ZodDate>;
|
|
19
21
|
}, "strip", z.ZodTypeAny, {
|
|
20
|
-
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
|
|
21
|
-
status: "approved" | "pending" | "
|
|
22
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
23
|
+
status: "approved" | "pending" | "inactive";
|
|
22
24
|
source_id: string | number;
|
|
23
25
|
source_name: string;
|
|
26
|
+
is_public: boolean;
|
|
24
27
|
created_at: Date;
|
|
25
28
|
_id?: string | undefined;
|
|
29
|
+
title?: string | undefined;
|
|
26
30
|
source_public_id?: string | number | undefined;
|
|
27
31
|
last_text_id?: number | undefined;
|
|
28
32
|
url?: string | undefined;
|
|
@@ -33,12 +37,13 @@ export declare const sourceSchema: z.ZodObject<{
|
|
|
33
37
|
metadata?: Record<string, any> | undefined;
|
|
34
38
|
updated_at?: Date | undefined;
|
|
35
39
|
}, {
|
|
36
|
-
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
|
|
37
|
-
status: "approved" | "pending" | "
|
|
40
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
41
|
+
status: "approved" | "pending" | "inactive";
|
|
38
42
|
source_id: string | number;
|
|
39
43
|
source_name: string;
|
|
40
44
|
created_at: Date;
|
|
41
45
|
_id?: string | undefined;
|
|
46
|
+
title?: string | undefined;
|
|
42
47
|
source_public_id?: string | number | undefined;
|
|
43
48
|
last_text_id?: number | undefined;
|
|
44
49
|
url?: string | undefined;
|
|
@@ -46,6 +51,7 @@ export declare const sourceSchema: z.ZodObject<{
|
|
|
46
51
|
language?: string | undefined;
|
|
47
52
|
source_geo?: string | undefined;
|
|
48
53
|
tags?: string[] | undefined;
|
|
54
|
+
is_public?: boolean | undefined;
|
|
49
55
|
metadata?: Record<string, any> | undefined;
|
|
50
56
|
updated_at?: Date | undefined;
|
|
51
57
|
}>;
|
|
@@ -61,13 +67,13 @@ export declare const sourceSchema: z.ZodObject<{
|
|
|
61
67
|
* - timestamp: date in milliseconds (e.g., 1751210833000)
|
|
62
68
|
* - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
|
|
63
69
|
*/
|
|
64
|
-
export declare const
|
|
70
|
+
export declare const zodDataSchema: z.ZodObject<{
|
|
65
71
|
_id: z.ZodOptional<z.ZodString>;
|
|
66
72
|
source_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
67
73
|
source_public_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
68
74
|
source_name: z.ZodString;
|
|
69
75
|
platform_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
70
|
-
platform: z.ZodEnum<["telegram", "facebook", "instagram", "tiktok", "website", "other"]>;
|
|
76
|
+
platform: z.ZodEnum<["telegram", "facebook", "instagram", "tiktok", "website", "document", "other"]>;
|
|
71
77
|
original_text_id: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
72
78
|
original_text: z.ZodOptional<z.ZodString>;
|
|
73
79
|
translated_text: z.ZodOptional<z.ZodString>;
|
|
@@ -94,7 +100,7 @@ export declare const textSchema: z.ZodObject<{
|
|
|
94
100
|
caption?: string | undefined;
|
|
95
101
|
}>, "many">>;
|
|
96
102
|
}, "strip", z.ZodTypeAny, {
|
|
97
|
-
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
|
|
103
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
98
104
|
source_id: string | number;
|
|
99
105
|
source_public_id: string | number;
|
|
100
106
|
source_name: string;
|
|
@@ -118,7 +124,7 @@ export declare const textSchema: z.ZodObject<{
|
|
|
118
124
|
caption?: string | undefined;
|
|
119
125
|
}[] | undefined;
|
|
120
126
|
}, {
|
|
121
|
-
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
|
|
127
|
+
platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "document" | "other";
|
|
122
128
|
source_id: string | number;
|
|
123
129
|
source_public_id: string | number;
|
|
124
130
|
source_name: string;
|
|
@@ -142,7 +148,7 @@ export declare const textSchema: z.ZodObject<{
|
|
|
142
148
|
caption?: string | undefined;
|
|
143
149
|
}[] | undefined;
|
|
144
150
|
}>;
|
|
145
|
-
export declare const
|
|
151
|
+
export declare const zodQuerySchema: z.ZodObject<{
|
|
146
152
|
sources: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
147
153
|
query: z.ZodOptional<z.ZodString>;
|
|
148
154
|
time_range: z.ZodOptional<z.ZodObject<{
|
|
@@ -176,6 +182,6 @@ export declare const querySchema: z.ZodObject<{
|
|
|
176
182
|
user_id?: string | undefined;
|
|
177
183
|
thread_id?: string | undefined;
|
|
178
184
|
}>;
|
|
179
|
-
export type SourceType = z.infer<typeof
|
|
180
|
-
export type
|
|
181
|
-
export type QueryType = z.infer<typeof
|
|
185
|
+
export type SourceType = z.infer<typeof zodSourceSchema>;
|
|
186
|
+
export type DataType = z.infer<typeof zodDataSchema>;
|
|
187
|
+
export type QueryType = z.infer<typeof zodQuerySchema>;
|
package/dist/types.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.zodQuerySchema = exports.zodDataSchema = exports.zodSourceSchema = exports.platformsList = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
exports.platformsList = [
|
|
6
6
|
'telegram',
|
|
@@ -8,10 +8,12 @@ exports.platformsList = [
|
|
|
8
8
|
'instagram',
|
|
9
9
|
'tiktok',
|
|
10
10
|
'website',
|
|
11
|
+
'document',
|
|
11
12
|
'other',
|
|
12
13
|
];
|
|
13
|
-
exports.
|
|
14
|
+
exports.zodSourceSchema = zod_1.z.object({
|
|
14
15
|
_id: zod_1.z.string().optional(),
|
|
16
|
+
title: zod_1.z.string().optional(),
|
|
15
17
|
platform: zod_1.z.enum(exports.platformsList),
|
|
16
18
|
source_id: zod_1.z.string().or(zod_1.z.number()),
|
|
17
19
|
source_public_id: zod_1.z.string().or(zod_1.z.number()).optional(),
|
|
@@ -22,7 +24,8 @@ exports.sourceSchema = zod_1.z.object({
|
|
|
22
24
|
language: zod_1.z.string().optional(),
|
|
23
25
|
source_geo: zod_1.z.string().optional(),
|
|
24
26
|
tags: zod_1.z.array(zod_1.z.string()).optional(),
|
|
25
|
-
status: zod_1.z.enum(['approved', 'pending', '
|
|
27
|
+
status: zod_1.z.enum(['approved', 'pending', 'inactive']),
|
|
28
|
+
is_public: zod_1.z.boolean().default(true),
|
|
26
29
|
metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
|
|
27
30
|
created_at: zod_1.z.coerce.date(),
|
|
28
31
|
updated_at: zod_1.z.coerce.date().optional(),
|
|
@@ -39,7 +42,7 @@ exports.sourceSchema = zod_1.z.object({
|
|
|
39
42
|
* - timestamp: date in milliseconds (e.g., 1751210833000)
|
|
40
43
|
* - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
|
|
41
44
|
*/
|
|
42
|
-
exports.
|
|
45
|
+
exports.zodDataSchema = zod_1.z.object({
|
|
43
46
|
_id: zod_1.z.string().optional(),
|
|
44
47
|
source_id: zod_1.z.string().or(zod_1.z.number()),
|
|
45
48
|
source_public_id: zod_1.z.string().or(zod_1.z.number()),
|
|
@@ -66,7 +69,7 @@ exports.textSchema = zod_1.z.object({
|
|
|
66
69
|
}))
|
|
67
70
|
.optional(), // media attachments
|
|
68
71
|
});
|
|
69
|
-
exports.
|
|
72
|
+
exports.zodQuerySchema = zod_1.z.object({
|
|
70
73
|
sources: zod_1.z.array(zod_1.z.string()).optional(),
|
|
71
74
|
query: zod_1.z.string().optional(),
|
|
72
75
|
time_range: zod_1.z
|
package/index.ts
CHANGED
|
@@ -1,2 +1,34 @@
|
|
|
1
1
|
// Export types for consumers
|
|
2
|
-
export * from './types';
|
|
2
|
+
export * from './types';
|
|
3
|
+
|
|
4
|
+
import { Schema, model } from 'mongoose';
|
|
5
|
+
import { DataType } from './types';
|
|
6
|
+
|
|
7
|
+
export const MongoDataSchema = new Schema<DataType>(
|
|
8
|
+
{
|
|
9
|
+
source_id: { type: String || Number },
|
|
10
|
+
source_public_id: { type: String || Number },
|
|
11
|
+
source_name: String,
|
|
12
|
+
platform: String,
|
|
13
|
+
media: Object,
|
|
14
|
+
metadata: Object,
|
|
15
|
+
timestamp: { type: Number, required: true },
|
|
16
|
+
text_geo: { type: [String], default: [] },
|
|
17
|
+
source_geo: String,
|
|
18
|
+
platform_id: { type: String || Number },
|
|
19
|
+
original_text_id: { type: String || Number },
|
|
20
|
+
original_text: String,
|
|
21
|
+
translated_text: String,
|
|
22
|
+
reply_to_message_id: { type: String || Number },
|
|
23
|
+
created_at: { type: Number, default: Date.now },
|
|
24
|
+
updated_at: { type: Number, default: Date.now },
|
|
25
|
+
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
versionKey: false,
|
|
29
|
+
toJSON: { virtuals: true },
|
|
30
|
+
toObject: { virtuals: true },
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
// export const DataModel = model('DataModel', MongoDataSchema, 'data');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "asfur",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "SDK for interacting with the Asfur API",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"axios": "^1.9.0",
|
|
30
|
+
"mongoose": "^8.16.4",
|
|
30
31
|
"zod": "^3.25.76"
|
|
31
32
|
}
|
|
32
33
|
}
|
package/types.ts
CHANGED
|
@@ -6,11 +6,13 @@ export const platformsList = [
|
|
|
6
6
|
'instagram',
|
|
7
7
|
'tiktok',
|
|
8
8
|
'website',
|
|
9
|
+
'document',
|
|
9
10
|
'other',
|
|
10
11
|
] as const;
|
|
11
12
|
|
|
12
|
-
export const
|
|
13
|
+
export const zodSourceSchema = z.object({
|
|
13
14
|
_id: z.string().optional(),
|
|
15
|
+
title: z.string().optional(), // e.g., 'Telegram Channel Name'
|
|
14
16
|
platform: z.enum(platformsList), // e.g., 'telegram', 'facebook'
|
|
15
17
|
source_id: z.string().or(z.number()), // original channel_id
|
|
16
18
|
source_public_id: z.string().or(z.number()).optional(), // e.g., '@telegram_channel_id'
|
|
@@ -21,7 +23,8 @@ export const sourceSchema = z.object({
|
|
|
21
23
|
language: z.string().optional(),
|
|
22
24
|
source_geo: z.string().optional(), // e.g., country or region
|
|
23
25
|
tags: z.array(z.string()).optional(),
|
|
24
|
-
status: z.enum(['approved', 'pending', '
|
|
26
|
+
status: z.enum(['approved', 'pending', 'inactive']), // INDEX
|
|
27
|
+
is_public: z.boolean().default(true), // true if the source is public
|
|
25
28
|
metadata: z.record(z.string(), z.any()).optional(), // flexible per platform
|
|
26
29
|
created_at: z.coerce.date(),
|
|
27
30
|
updated_at: z.coerce.date().optional(),
|
|
@@ -40,7 +43,7 @@ export const sourceSchema = z.object({
|
|
|
40
43
|
* - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
|
|
41
44
|
*/
|
|
42
45
|
|
|
43
|
-
export const
|
|
46
|
+
export const zodDataSchema = z.object({
|
|
44
47
|
_id: z.string().optional(),
|
|
45
48
|
source_id: z.string().or(z.number()), // INDEX - reference to Source _id (e.g., '60c72b2f9b1e8d3f4c8b4567')
|
|
46
49
|
source_public_id: z.string().or(z.number()), // e.g., 'telegram:1234567890' (message_id)
|
|
@@ -70,7 +73,7 @@ export const textSchema = z.object({
|
|
|
70
73
|
.optional(), // media attachments
|
|
71
74
|
});
|
|
72
75
|
|
|
73
|
-
export const
|
|
76
|
+
export const zodQuerySchema = z.object({
|
|
74
77
|
sources: z.array(z.string()).optional(), // array of source _id strings
|
|
75
78
|
query: z.string().optional(), // search query includes geo information where it should be extracted with LLM
|
|
76
79
|
time_range: z
|
|
@@ -83,6 +86,6 @@ export const querySchema = z.object({
|
|
|
83
86
|
thread_id: z.string().optional(), // optional thread identifier
|
|
84
87
|
});
|
|
85
88
|
|
|
86
|
-
export type SourceType = z.infer<typeof
|
|
87
|
-
export type
|
|
88
|
-
export type QueryType = z.infer<typeof
|
|
89
|
+
export type SourceType = z.infer<typeof zodSourceSchema>;
|
|
90
|
+
export type DataType = z.infer<typeof zodDataSchema>;
|
|
91
|
+
export type QueryType = z.infer<typeof zodQuerySchema>;
|