asfur 1.0.1

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 ADDED
@@ -0,0 +1,40 @@
1
+ # Taqila SDK
2
+
3
+ A simple SDK for interacting with the Taqila API.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install Taqila
9
+ # or
10
+ yarn add Taqila
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```typescript
16
+ import { Taqila } from 'Taqila';
17
+
18
+ const Taqila = new Taqila({
19
+ apiKey: 'your_api_key',
20
+ });
21
+
22
+ // Make API calls
23
+ async function main() {
24
+ // Create a new Thread
25
+ const newThread = await Taqila.createThread();
26
+
27
+ // Get the Thread with all the messages
28
+ const getThread = await Taqila.getThread(newThread.id, {
29
+ limit: 20
30
+ });
31
+
32
+ // Add a message or messages to the thread
33
+ const addMessages = await Taqila.addMessages(newThread.id, [
34
+ {
35
+ role: 'user',
36
+ content: 'Hello, how are you?',
37
+ },
38
+ ]);
39
+ }
40
+ ```
@@ -0,0 +1 @@
1
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
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
+ // Export types for consumers
18
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,175 @@
1
+ import { z } from 'zod';
2
+ export declare const platformsList: readonly ["telegram", "facebook", "instagram", "tiktok", "website", "other"];
3
+ export declare const sourceSchema: z.ZodObject<{
4
+ _id: z.ZodOptional<z.ZodString>;
5
+ platform: z.ZodEnum<["telegram", "facebook", "instagram", "tiktok", "website", "other"]>;
6
+ source_id: z.ZodString;
7
+ source_public_id: z.ZodOptional<z.ZodString>;
8
+ source_name: z.ZodString;
9
+ last_text_id: z.ZodOptional<z.ZodNumber>;
10
+ url: z.ZodOptional<z.ZodString>;
11
+ description: z.ZodOptional<z.ZodString>;
12
+ language: z.ZodOptional<z.ZodString>;
13
+ source_geo: z.ZodOptional<z.ZodString>;
14
+ tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
15
+ status: z.ZodEnum<["approved", "pending", "rejected"]>;
16
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
17
+ created_at: z.ZodDate;
18
+ updated_at: z.ZodOptional<z.ZodDate>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
21
+ status: "approved" | "pending" | "rejected";
22
+ source_id: string;
23
+ source_name: string;
24
+ created_at: Date;
25
+ _id?: string | undefined;
26
+ source_public_id?: string | undefined;
27
+ last_text_id?: number | undefined;
28
+ url?: string | undefined;
29
+ description?: string | undefined;
30
+ language?: string | undefined;
31
+ source_geo?: string | undefined;
32
+ tags?: string[] | undefined;
33
+ metadata?: Record<string, any> | undefined;
34
+ updated_at?: Date | undefined;
35
+ }, {
36
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
37
+ status: "approved" | "pending" | "rejected";
38
+ source_id: string;
39
+ source_name: string;
40
+ created_at: Date;
41
+ _id?: string | undefined;
42
+ source_public_id?: string | undefined;
43
+ last_text_id?: number | undefined;
44
+ url?: string | undefined;
45
+ description?: string | undefined;
46
+ language?: string | undefined;
47
+ source_geo?: string | undefined;
48
+ tags?: string[] | undefined;
49
+ metadata?: Record<string, any> | undefined;
50
+ updated_at?: Date | undefined;
51
+ }>;
52
+ /**
53
+ * ids:
54
+ * 1. _id: MongoDB ObjectId as string
55
+ * 2. source_id: reference to Source _id
56
+ * 3. platform_id: e.g., 'telegram:1234567890' (channel_id)
57
+ * 4. original_id: ID from the platform (e.g., message_id
58
+ *
59
+ * INDEXES:
60
+ * - source_id: reference to Source _id
61
+ * - timestamp: date in milliseconds (e.g., 1751210833000)
62
+ * - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
63
+ */
64
+ export declare const textSchema: z.ZodObject<{
65
+ _id: z.ZodOptional<z.ZodString>;
66
+ source_id: z.ZodString;
67
+ source_name: z.ZodString;
68
+ platform_id: z.ZodString;
69
+ platform: z.ZodEnum<["telegram", "facebook", "instagram", "tiktok", "website", "other"]>;
70
+ original_text_id: z.ZodString;
71
+ original_text: z.ZodOptional<z.ZodString>;
72
+ translated_text: z.ZodOptional<z.ZodString>;
73
+ timestamp: z.ZodDate;
74
+ language: z.ZodOptional<z.ZodString>;
75
+ text_geo: z.ZodArray<z.ZodString, "many">;
76
+ source_geo: z.ZodOptional<z.ZodString>;
77
+ replied_to_post_id: z.ZodOptional<z.ZodString>;
78
+ metadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
79
+ created_at: z.ZodDate;
80
+ updated_at: z.ZodOptional<z.ZodDate>;
81
+ media: z.ZodOptional<z.ZodArray<z.ZodObject<{
82
+ type: z.ZodEnum<["image", "video", "audio", "link"]>;
83
+ url: z.ZodString;
84
+ caption: z.ZodOptional<z.ZodString>;
85
+ }, "strip", z.ZodTypeAny, {
86
+ type: "image" | "video" | "audio" | "link";
87
+ url: string;
88
+ caption?: string | undefined;
89
+ }, {
90
+ type: "image" | "video" | "audio" | "link";
91
+ url: string;
92
+ caption?: string | undefined;
93
+ }>, "many">>;
94
+ }, "strip", z.ZodTypeAny, {
95
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
96
+ source_id: string;
97
+ source_name: string;
98
+ created_at: Date;
99
+ platform_id: string;
100
+ original_text_id: string;
101
+ timestamp: Date;
102
+ text_geo: string[];
103
+ _id?: string | undefined;
104
+ language?: string | undefined;
105
+ source_geo?: string | undefined;
106
+ metadata?: Record<string, any> | undefined;
107
+ updated_at?: Date | undefined;
108
+ original_text?: string | undefined;
109
+ translated_text?: string | undefined;
110
+ replied_to_post_id?: string | undefined;
111
+ media?: {
112
+ type: "image" | "video" | "audio" | "link";
113
+ url: string;
114
+ caption?: string | undefined;
115
+ }[] | undefined;
116
+ }, {
117
+ platform: "telegram" | "facebook" | "instagram" | "tiktok" | "website" | "other";
118
+ source_id: string;
119
+ source_name: string;
120
+ created_at: Date;
121
+ platform_id: string;
122
+ original_text_id: string;
123
+ timestamp: Date;
124
+ text_geo: string[];
125
+ _id?: string | undefined;
126
+ language?: string | undefined;
127
+ source_geo?: string | undefined;
128
+ metadata?: Record<string, any> | undefined;
129
+ updated_at?: Date | undefined;
130
+ original_text?: string | undefined;
131
+ translated_text?: string | undefined;
132
+ replied_to_post_id?: string | undefined;
133
+ media?: {
134
+ type: "image" | "video" | "audio" | "link";
135
+ url: string;
136
+ caption?: string | undefined;
137
+ }[] | undefined;
138
+ }>;
139
+ export declare const querySchema: z.ZodObject<{
140
+ sources: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
141
+ query: z.ZodOptional<z.ZodString>;
142
+ time_range: z.ZodOptional<z.ZodObject<{
143
+ start: z.ZodOptional<z.ZodDate>;
144
+ end: z.ZodOptional<z.ZodDate>;
145
+ }, "strip", z.ZodTypeAny, {
146
+ start?: Date | undefined;
147
+ end?: Date | undefined;
148
+ }, {
149
+ start?: Date | undefined;
150
+ end?: Date | undefined;
151
+ }>>;
152
+ user_id: z.ZodOptional<z.ZodString>;
153
+ thread_id: z.ZodOptional<z.ZodString>;
154
+ }, "strip", z.ZodTypeAny, {
155
+ sources?: string[] | undefined;
156
+ query?: string | undefined;
157
+ time_range?: {
158
+ start?: Date | undefined;
159
+ end?: Date | undefined;
160
+ } | undefined;
161
+ user_id?: string | undefined;
162
+ thread_id?: string | undefined;
163
+ }, {
164
+ sources?: string[] | undefined;
165
+ query?: string | undefined;
166
+ time_range?: {
167
+ start?: Date | undefined;
168
+ end?: Date | undefined;
169
+ } | undefined;
170
+ user_id?: string | undefined;
171
+ thread_id?: string | undefined;
172
+ }>;
173
+ export type SourceType = z.infer<typeof sourceSchema>;
174
+ export type TextType = z.infer<typeof textSchema>;
175
+ export type QueryType = z.infer<typeof querySchema>;
package/dist/types.js ADDED
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.querySchema = exports.textSchema = exports.sourceSchema = exports.platformsList = void 0;
4
+ const zod_1 = require("zod");
5
+ exports.platformsList = [
6
+ 'telegram',
7
+ 'facebook',
8
+ 'instagram',
9
+ 'tiktok',
10
+ 'website',
11
+ 'other',
12
+ ];
13
+ exports.sourceSchema = zod_1.z.object({
14
+ _id: zod_1.z.string().optional(),
15
+ platform: zod_1.z.enum(exports.platformsList),
16
+ source_id: zod_1.z.string(),
17
+ source_public_id: zod_1.z.string().optional(),
18
+ source_name: zod_1.z.string(),
19
+ last_text_id: zod_1.z.number().optional(),
20
+ url: zod_1.z.string().url().optional(),
21
+ description: zod_1.z.string().optional(),
22
+ language: zod_1.z.string().optional(),
23
+ source_geo: zod_1.z.string().optional(),
24
+ tags: zod_1.z.array(zod_1.z.string()).optional(),
25
+ status: zod_1.z.enum(['approved', 'pending', 'rejected']),
26
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
27
+ created_at: zod_1.z.coerce.date(),
28
+ updated_at: zod_1.z.coerce.date().optional(),
29
+ });
30
+ /**
31
+ * ids:
32
+ * 1. _id: MongoDB ObjectId as string
33
+ * 2. source_id: reference to Source _id
34
+ * 3. platform_id: e.g., 'telegram:1234567890' (channel_id)
35
+ * 4. original_id: ID from the platform (e.g., message_id
36
+ *
37
+ * INDEXES:
38
+ * - source_id: reference to Source _id
39
+ * - timestamp: date in milliseconds (e.g., 1751210833000)
40
+ * - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
41
+ */
42
+ exports.textSchema = zod_1.z.object({
43
+ _id: zod_1.z.string().optional(),
44
+ source_id: zod_1.z.string(),
45
+ source_name: zod_1.z.string(),
46
+ platform_id: zod_1.z.string(),
47
+ platform: zod_1.z.enum(exports.platformsList),
48
+ original_text_id: zod_1.z.string(),
49
+ original_text: zod_1.z.string().optional(),
50
+ translated_text: zod_1.z.string().optional(),
51
+ timestamp: zod_1.z.coerce.date(),
52
+ language: zod_1.z.string().optional(),
53
+ text_geo: zod_1.z.array(zod_1.z.string()),
54
+ source_geo: zod_1.z.string().optional(),
55
+ replied_to_post_id: zod_1.z.string().optional(),
56
+ metadata: zod_1.z.record(zod_1.z.string(), zod_1.z.any()).optional(),
57
+ created_at: zod_1.z.coerce.date(),
58
+ updated_at: zod_1.z.coerce.date().optional(),
59
+ media: zod_1.z
60
+ .array(zod_1.z.object({
61
+ type: zod_1.z.enum(['image', 'video', 'audio', 'link']),
62
+ url: zod_1.z.string().url(),
63
+ caption: zod_1.z.string().optional(),
64
+ }))
65
+ .optional(), // media attachments
66
+ });
67
+ exports.querySchema = zod_1.z.object({
68
+ sources: zod_1.z.array(zod_1.z.string()).optional(),
69
+ query: zod_1.z.string().optional(),
70
+ time_range: zod_1.z
71
+ .object({
72
+ start: zod_1.z.coerce.date().optional(),
73
+ end: zod_1.z.coerce.date().optional(), // end date
74
+ })
75
+ .optional(),
76
+ user_id: zod_1.z.string().optional(),
77
+ thread_id: zod_1.z.string().optional(), // optional thread identifier
78
+ });
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Export types for consumers
2
+ export * from './types';
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "asfur",
3
+ "version": "1.0.1",
4
+ "description": "SDK for interacting with the Asfur API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "repository": {
8
+ "url": "https://github.com/eretztzvi/asfur.sdk",
9
+ "type": "git"
10
+ },
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "test": "jest",
14
+ "prepublish": "npm run build"
15
+ },
16
+ "keywords": [
17
+ "asfur",
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
+ "zod": "^3.25.76"
31
+ }
32
+ }
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,86 @@
1
+ import { z } from 'zod';
2
+
3
+ export const platformsList = [
4
+ 'telegram',
5
+ 'facebook',
6
+ 'instagram',
7
+ 'tiktok',
8
+ 'website',
9
+ 'other',
10
+ ] as const;
11
+
12
+ export const sourceSchema = z.object({
13
+ _id: z.string().optional(),
14
+ platform: z.enum(platformsList), // e.g., 'telegram', 'facebook'
15
+ source_id: z.string(), // original channel_id
16
+ source_public_id: z.string().optional(), // e.g., '@telegram_channel_id'
17
+ source_name: z.string(), // e.g., 'Telegram Channel Name'
18
+ last_text_id: z.number().optional(), // last processed text ID
19
+ url: z.string().url().optional(), // e.g., 'https://t.me/telegram_channel_name'
20
+ description: z.string().optional(), // e.g., 'A channel about news and updates'
21
+ language: z.string().optional(),
22
+ source_geo: z.string().optional(), // e.g., country or region
23
+ tags: z.array(z.string()).optional(),
24
+ status: z.enum(['approved', 'pending', 'rejected']), // INDEX
25
+ metadata: z.record(z.string(), z.any()).optional(), // flexible per platform
26
+ created_at: z.coerce.date(),
27
+ updated_at: z.coerce.date().optional(),
28
+ });
29
+
30
+ /**
31
+ * ids:
32
+ * 1. _id: MongoDB ObjectId as string
33
+ * 2. source_id: reference to Source _id
34
+ * 3. platform_id: e.g., 'telegram:1234567890' (channel_id)
35
+ * 4. original_id: ID from the platform (e.g., message_id
36
+ *
37
+ * INDEXES:
38
+ * - source_id: reference to Source _id
39
+ * - timestamp: date in milliseconds (e.g., 1751210833000)
40
+ * - text_geo: array of strings (e.g., ["sinjil", "ramallah", "west bank"])
41
+ */
42
+
43
+ export const textSchema = z.object({
44
+ _id: z.string().optional(),
45
+ source_id: z.string(), // INDEX - reference to Source _id (e.g., '60c72b2f9b1e8d3f4c8b4567')
46
+ source_name: z.string(), // e.g., 'Telegram Channel Name'
47
+ platform_id: z.string(), // channel_id reference to Source source_id
48
+ platform: z.enum(platformsList), // e.g., 'telegram', 'facebook'
49
+ original_text_id: z.string(), // message_id
50
+ original_text: z.string().optional(), // original text content
51
+ translated_text: z.string().optional(), // translated text if available - most of the time it will be translated to English
52
+ timestamp: z.coerce.date(), // INDEX - date in milliseconds - e.g., 1751210833000
53
+ language: z.string().optional(),
54
+ text_geo: z.array(z.string()), // INDEX - e.g., ["sinjil", "ramallah", "west bank"]
55
+ source_geo: z.string().optional(), // e.g., 'hebron'
56
+ replied_to_post_id: z.string().optional(),
57
+ metadata: z.record(z.string(), z.any()).optional(), // platform-specific fields
58
+ created_at: z.coerce.date(),
59
+ updated_at: z.coerce.date().optional(),
60
+ media: z
61
+ .array(
62
+ z.object({
63
+ type: z.enum(['image', 'video', 'audio', 'link']),
64
+ url: z.string().url(),
65
+ caption: z.string().optional(),
66
+ })
67
+ )
68
+ .optional(), // media attachments
69
+ });
70
+
71
+ export const querySchema = z.object({
72
+ sources: z.array(z.string()).optional(), // array of source _id strings
73
+ query: z.string().optional(), // search query includes geo information where it should be extracted with LLM
74
+ time_range: z
75
+ .object({
76
+ start: z.coerce.date().optional(), // start date
77
+ end: z.coerce.date().optional(), // end date
78
+ })
79
+ .optional(),
80
+ user_id: z.string().optional(), // optional user identifier
81
+ thread_id: z.string().optional(), // optional thread identifier
82
+ });
83
+
84
+ export type SourceType = z.infer<typeof sourceSchema>;
85
+ export type TextType = z.infer<typeof textSchema>;
86
+ export type QueryType = z.infer<typeof querySchema>;