zalo-mkt 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +93 -0
- package/bin/cli.js +46 -0
- package/package.json +47 -0
- package/prisma/schema.prisma +84 -0
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# zalo_mkt
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
## Getting started
|
|
6
|
+
|
|
7
|
+
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
|
8
|
+
|
|
9
|
+
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
|
10
|
+
|
|
11
|
+
## Add your files
|
|
12
|
+
|
|
13
|
+
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
|
14
|
+
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
|
15
|
+
|
|
16
|
+
```
|
|
17
|
+
cd existing_repo
|
|
18
|
+
git remote add origin https://gitlab.com/hellangel590/zalo_mkt.git
|
|
19
|
+
git branch -M main
|
|
20
|
+
git push -uf origin main
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Integrate with your tools
|
|
24
|
+
|
|
25
|
+
* [Set up project integrations](https://gitlab.com/hellangel590/zalo_mkt/-/settings/integrations)
|
|
26
|
+
|
|
27
|
+
## Collaborate with your team
|
|
28
|
+
|
|
29
|
+
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
|
30
|
+
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
|
31
|
+
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
|
32
|
+
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
|
33
|
+
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
|
34
|
+
|
|
35
|
+
## Test and Deploy
|
|
36
|
+
|
|
37
|
+
Use the built-in continuous integration in GitLab.
|
|
38
|
+
|
|
39
|
+
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
|
40
|
+
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
|
41
|
+
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
|
42
|
+
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
|
43
|
+
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
# Editing this README
|
|
48
|
+
|
|
49
|
+
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
|
50
|
+
|
|
51
|
+
## Suggestions for a good README
|
|
52
|
+
|
|
53
|
+
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
|
54
|
+
|
|
55
|
+
## Name
|
|
56
|
+
Choose a self-explaining name for your project.
|
|
57
|
+
|
|
58
|
+
## Description
|
|
59
|
+
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
60
|
+
|
|
61
|
+
## Badges
|
|
62
|
+
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
|
63
|
+
|
|
64
|
+
## Visuals
|
|
65
|
+
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
66
|
+
|
|
67
|
+
## Installation
|
|
68
|
+
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
69
|
+
|
|
70
|
+
## Usage
|
|
71
|
+
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
72
|
+
|
|
73
|
+
## Support
|
|
74
|
+
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
75
|
+
|
|
76
|
+
## Roadmap
|
|
77
|
+
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
State if you are open to contributions and what your requirements are for accepting them.
|
|
81
|
+
|
|
82
|
+
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
|
+
|
|
84
|
+
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
|
+
|
|
86
|
+
## Authors and acknowledgment
|
|
87
|
+
Show your appreciation to those who have contributed to the project.
|
|
88
|
+
|
|
89
|
+
## License
|
|
90
|
+
For open source projects, say how it is licensed.
|
|
91
|
+
|
|
92
|
+
## Project status
|
|
93
|
+
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const fs = require('fs');
|
|
6
|
+
const { execSync } = require('child_process');
|
|
7
|
+
|
|
8
|
+
console.log('🚀 Đang khởi động Zalo MKT Tool...');
|
|
9
|
+
|
|
10
|
+
// 1. Tạo thư mục chứa DB ở máy khách
|
|
11
|
+
const appDir = path.join(os.homedir(), '.zalo-mkt');
|
|
12
|
+
if (!fs.existsSync(appDir)) {
|
|
13
|
+
fs.mkdirSync(appDir, { recursive: true });
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 2. Set đường dẫn DB
|
|
17
|
+
const dbPath = path.join(appDir, 'data.db');
|
|
18
|
+
process.env.DATABASE_URL = `file:${dbPath}`;
|
|
19
|
+
console.log(`📁 Dữ liệu được lưu tại: ${dbPath}`);
|
|
20
|
+
|
|
21
|
+
// 3. Tự động khởi tạo cấu trúc DB
|
|
22
|
+
try {
|
|
23
|
+
console.log('⏳ Đang kiểm tra cấu trúc dữ liệu...');
|
|
24
|
+
// Lệnh này Prisma sẽ dựa vào code để tạo bảng tự động
|
|
25
|
+
// Chúng ta trỏ đường dẫn schema.prisma để đảm bảo nó lấy đúng file khi đã đóng gói NPM
|
|
26
|
+
const schemaPath = path.join(__dirname, '..', 'prisma', 'schema.prisma');
|
|
27
|
+
execSync(`npx prisma db push --schema="${schemaPath}" --accept-data-loss`, {
|
|
28
|
+
stdio: 'inherit',
|
|
29
|
+
env: process.env
|
|
30
|
+
});
|
|
31
|
+
} catch(e) {
|
|
32
|
+
console.log('Cảnh báo DB:', e.message);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// 4. Chạy web
|
|
36
|
+
const serverPath = path.join(__dirname, '..', '.next', 'standalone', 'server.js');
|
|
37
|
+
setTimeout(() => {
|
|
38
|
+
const startUrl = process.platform === 'win32' ? 'start' : process.platform === 'darwin' ? 'open' : 'xdg-open';
|
|
39
|
+
try {
|
|
40
|
+
execSync(`${startUrl} http://localhost:3000`);
|
|
41
|
+
} catch(err) {
|
|
42
|
+
// Ignore if failing to open browser
|
|
43
|
+
}
|
|
44
|
+
}, 3000);
|
|
45
|
+
|
|
46
|
+
require(serverPath);
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "zalo-mkt",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Zalo MKT project",
|
|
5
|
+
"author": "",
|
|
6
|
+
"license": "ISC",
|
|
7
|
+
"main": "server.js",
|
|
8
|
+
"bin": {
|
|
9
|
+
"zalo-mkt": "./bin/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"bin",
|
|
13
|
+
".next/standalone",
|
|
14
|
+
"prisma"
|
|
15
|
+
],
|
|
16
|
+
"scripts": {
|
|
17
|
+
"postinstall": "prisma generate",
|
|
18
|
+
"dev": "next dev",
|
|
19
|
+
"build": "next build",
|
|
20
|
+
"start": "next start",
|
|
21
|
+
"lint": "next lint",
|
|
22
|
+
"test:e2e": "playwright test"
|
|
23
|
+
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@prisma/client": "^5.22.0",
|
|
26
|
+
"@react-oauth/google": "^0.13.5",
|
|
27
|
+
"lucide-react": "^1.21.0",
|
|
28
|
+
"next": "16.2.9",
|
|
29
|
+
"papaparse": "^5.5.4",
|
|
30
|
+
"playwright": "^1.61.0",
|
|
31
|
+
"react": "19.2.4",
|
|
32
|
+
"react-dom": "19.2.4"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@playwright/test": "^1.61.0",
|
|
36
|
+
"@tailwindcss/postcss": "^4",
|
|
37
|
+
"@types/node": "^20",
|
|
38
|
+
"@types/papaparse": "^5.5.2",
|
|
39
|
+
"@types/react": "^19",
|
|
40
|
+
"@types/react-dom": "^19",
|
|
41
|
+
"eslint": "^9",
|
|
42
|
+
"eslint-config-next": "16.2.9",
|
|
43
|
+
"prisma": "^5.22.0",
|
|
44
|
+
"tailwindcss": "^4",
|
|
45
|
+
"typescript": "^5"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// This is your Prisma schema file,
|
|
2
|
+
// learn more about it in the docs: https://pris.ly/d/prisma-schema
|
|
3
|
+
|
|
4
|
+
// Get a free hosted Postgres database in seconds: `npx create-db`
|
|
5
|
+
|
|
6
|
+
generator client {
|
|
7
|
+
provider = "prisma-client-js"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
datasource db {
|
|
11
|
+
provider = "sqlite"
|
|
12
|
+
url = env("DATABASE_URL")
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
model User {
|
|
16
|
+
id Int @id @default(autoincrement())
|
|
17
|
+
name String
|
|
18
|
+
role String @default("Account")
|
|
19
|
+
status String @default("Active")
|
|
20
|
+
zaloId String?
|
|
21
|
+
phone String?
|
|
22
|
+
lastIp String?
|
|
23
|
+
proxy String?
|
|
24
|
+
createdAt DateTime @default(now())
|
|
25
|
+
updatedAt DateTime @updatedAt
|
|
26
|
+
|
|
27
|
+
campaigns CampaignAccount[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
model Campaign {
|
|
31
|
+
id Int @id @default(autoincrement())
|
|
32
|
+
name String
|
|
33
|
+
status String @default("Draft")
|
|
34
|
+
progress Int @default(0)
|
|
35
|
+
spent Float @default(0)
|
|
36
|
+
budget Float @default(0)
|
|
37
|
+
leads Int @default(0)
|
|
38
|
+
|
|
39
|
+
// Settings
|
|
40
|
+
switchAccountAfterErrors Int @default(5)
|
|
41
|
+
minMessagesPerAccount Int @default(20)
|
|
42
|
+
maxMessagesPerAccount Int @default(25)
|
|
43
|
+
minDelayBetweenMessages Int @default(10)
|
|
44
|
+
maxDelayBetweenMessages Int @default(15)
|
|
45
|
+
pauseAfterMessages Int @default(2)
|
|
46
|
+
pauseDuration Int @default(20)
|
|
47
|
+
|
|
48
|
+
filterDuplicatePhones Boolean @default(true)
|
|
49
|
+
distributePhonesEvenly Boolean @default(false)
|
|
50
|
+
autoSendFriendRequest Boolean @default(false)
|
|
51
|
+
sendWithImage Boolean @default(false)
|
|
52
|
+
sendFileFirst Boolean @default(true)
|
|
53
|
+
imagePath String?
|
|
54
|
+
messageContent String @default("")
|
|
55
|
+
|
|
56
|
+
endDate DateTime?
|
|
57
|
+
createdAt DateTime @default(now())
|
|
58
|
+
updatedAt DateTime @updatedAt
|
|
59
|
+
|
|
60
|
+
targets CampaignTarget[]
|
|
61
|
+
accounts CampaignAccount[]
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
model CampaignAccount {
|
|
65
|
+
id Int @id @default(autoincrement())
|
|
66
|
+
campaignId Int
|
|
67
|
+
userId Int
|
|
68
|
+
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
|
|
69
|
+
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
70
|
+
createdAt DateTime @default(now())
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
model CampaignTarget {
|
|
74
|
+
id Int @id @default(autoincrement())
|
|
75
|
+
campaignId Int
|
|
76
|
+
phone String
|
|
77
|
+
name String?
|
|
78
|
+
status String @default("Pending") // Pending, Sent, Failed
|
|
79
|
+
sentByUserId Int?
|
|
80
|
+
sentAt DateTime?
|
|
81
|
+
error String?
|
|
82
|
+
campaign Campaign @relation(fields: [campaignId], references: [id], onDelete: Cascade)
|
|
83
|
+
createdAt DateTime @default(now())
|
|
84
|
+
}
|