update
This commit is contained in:
@ -1,41 +1,41 @@
|
||||
{
|
||||
"app": {
|
||||
"name": "Service Users",
|
||||
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
|
||||
"version": "1.0.0",
|
||||
"env": "Development"
|
||||
},
|
||||
"server": {
|
||||
"port": "7001",
|
||||
"host": "0.0.0.0",
|
||||
"host_swagger": "http://127.0.0.1:7001",
|
||||
"max_body": "50mb",
|
||||
"max_upload": 104857600,
|
||||
"morgan": "combined",
|
||||
"cors": "*",
|
||||
"ssl": {
|
||||
"enable": false,
|
||||
"cert": "",
|
||||
"key": ""
|
||||
}
|
||||
},
|
||||
"database": {
|
||||
"engine": "postgres",
|
||||
"host": "127.0.0.1",
|
||||
"port": "15432",
|
||||
"username": "saude_tl",
|
||||
"password": "saude_tl_local",
|
||||
"database": "saude_tl",
|
||||
"synchronize": true,
|
||||
"logging": true
|
||||
},
|
||||
"auth": {
|
||||
"refresh_token_lifetime_day": 30,
|
||||
"access_token_lifetime": 86400,
|
||||
"reset_password_url": "https://tcelanatl.shiblysolution.id/auth/reset-password/"
|
||||
},
|
||||
"service": {
|
||||
"notification": "http://127.0.0.1:7004/",
|
||||
"hrms": "https://tcelanatl.shiblysolution.id/hrms/"
|
||||
}
|
||||
"app": {
|
||||
"name": "Service Users",
|
||||
"description": "Purpose of this service is to provide authorization, roles, user activity and etc",
|
||||
"version": "1.0.0",
|
||||
"env": "Development"
|
||||
},
|
||||
"server": {
|
||||
"port": "7001",
|
||||
"host": "0.0.0.0",
|
||||
"host_swagger": "http://127.0.0.1:7001",
|
||||
"max_body": "50mb",
|
||||
"max_upload": 104857600,
|
||||
"morgan": "combined",
|
||||
"cors": "*",
|
||||
"ssl": {
|
||||
"enable": false,
|
||||
"cert": "",
|
||||
"key": ""
|
||||
}
|
||||
},
|
||||
"database": {
|
||||
"engine": "postgres",
|
||||
"host": "127.0.0.1",
|
||||
"port": "15432",
|
||||
"username": "saude_tl",
|
||||
"password": "saude_tl_local",
|
||||
"database": "saude_tl",
|
||||
"synchronize": true,
|
||||
"logging": true
|
||||
},
|
||||
"auth": {
|
||||
"refresh_token_lifetime_day": 30,
|
||||
"access_token_lifetime": 86400,
|
||||
"reset_password_url": "https://tcelanatl.shiblysolution.id/auth/reset-password/"
|
||||
},
|
||||
"service": {
|
||||
"notification": "http://127.0.0.1:7004/",
|
||||
"hrms": "https://tcelanatl.shiblysolution.id/hrms/"
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,7 +6,11 @@
|
||||
"scripts": {
|
||||
"dev": "nodemon",
|
||||
"build": "tsc",
|
||||
"swagger": "node src/swagger/builder.js"
|
||||
"swagger": "node src/swagger/builder.js",
|
||||
"seeder": "NODE_ENV=default ts-node src/scripts/seed-auth-data.ts",
|
||||
"seeder:default": "NODE_ENV=default ts-node src/scripts/seed-auth-data.ts",
|
||||
"seeder:stag": "NODE_ENV=stag ts-node src/scripts/seed-auth-data.ts",
|
||||
"seeder:prod": "NODE_ENV=prod ts-node src/scripts/seed-auth-data.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"BRI"
|
||||
|
||||
12
seed/auth/application_202604141440.json
Normal file
12
seed/auth/application_202604141440.json
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
"application": [
|
||||
{
|
||||
"id" : "saude",
|
||||
"name" : "saude",
|
||||
"reset_password_url" : "http:\/\/127.0.0.1",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-06T04:01:56.880Z",
|
||||
"updated_at" : "2026-02-06T04:01:56.880Z",
|
||||
"deleted_at" : null
|
||||
}
|
||||
]}
|
||||
325
seed/auth/menus_202604141440.json
Normal file
325
seed/auth/menus_202604141440.json
Normal file
@ -0,0 +1,325 @@
|
||||
{
|
||||
"menus": [
|
||||
{
|
||||
"id" : "0107161a-7981-4dce-8512-1cda689394f5",
|
||||
"module" : "Patient",
|
||||
"name" : "List",
|
||||
"link" : "\/patient\/create",
|
||||
"id_parent" : "1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2",
|
||||
"order_number" : 2,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T07:53:37.296Z",
|
||||
"updated_at" : "2026-02-12T07:56:06.133Z",
|
||||
"deleted_at" : "2026-02-12T07:56:06.133Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "236ba50b-80d4-4199-af85-4f77a824916b",
|
||||
"module" : "Create",
|
||||
"name" : "Outpatient",
|
||||
"link" : "\/registration\/create\/outpatient",
|
||||
"id_parent" : "dee8031f-85ad-4356-a584-55c6664a7bdd",
|
||||
"order_number" : 1,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T08:01:04.414Z",
|
||||
"updated_at" : "2026-02-12T08:01:04.414Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "85341d36-0c0a-4533-b29b-a20c21d5c28d",
|
||||
"module" : "Create",
|
||||
"name" : "Inpatient",
|
||||
"link" : "\/registration\/create\/inpatient",
|
||||
"id_parent" : "dee8031f-85ad-4356-a584-55c6664a7bdd",
|
||||
"order_number" : 2,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T08:01:25.386Z",
|
||||
"updated_at" : "2026-02-12T08:01:25.386Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "fb7d89ac-cc46-4a60-b42b-88f8fecafca0",
|
||||
"module" : "Create",
|
||||
"name" : "Emergency",
|
||||
"link" : "\/registration\/create\/emergency",
|
||||
"id_parent" : "dee8031f-85ad-4356-a584-55c6664a7bdd",
|
||||
"order_number" : 3,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T08:01:44.569Z",
|
||||
"updated_at" : "2026-02-12T08:01:44.569Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "1cc57849-016c-4fe2-b176-b0a78ed361ac",
|
||||
"module" : "Create",
|
||||
"name" : "Hemodialysis",
|
||||
"link" : "\/registration\/create\/Hemodialysis",
|
||||
"id_parent" : "dee8031f-85ad-4356-a584-55c6664a7bdd",
|
||||
"order_number" : 4,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T08:02:15.980Z",
|
||||
"updated_at" : "2026-02-12T08:02:15.980Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "beabac71-caf1-4b86-8f5e-f3c953133545",
|
||||
"module" : "Outpatient",
|
||||
"name" : "Outpatient",
|
||||
"link" : "\/outpatient",
|
||||
"id_parent" : null,
|
||||
"order_number" : 4,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T08:03:35.400Z",
|
||||
"updated_at" : "2026-02-12T08:03:35.400Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "d31a11ce-5243-4172-ace5-5d456a1d6a1f",
|
||||
"module" : "Registration",
|
||||
"name" : "List",
|
||||
"link" : "\/registration\/list",
|
||||
"id_parent" : "fd3ee75c-5389-461b-9489-ae286a0acc17",
|
||||
"order_number" : 1,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T07:58:48.939Z",
|
||||
"updated_at" : "2026-02-16T05:03:35.908Z",
|
||||
"deleted_at" : "2026-02-16T05:03:35.908Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "dee8031f-85ad-4356-a584-55c6664a7bdd",
|
||||
"module" : "Registration",
|
||||
"name" : "Create",
|
||||
"link" : "\/",
|
||||
"id_parent" : "fd3ee75c-5389-461b-9489-ae286a0acc17",
|
||||
"order_number" : 2,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T07:59:09.357Z",
|
||||
"updated_at" : "2026-02-16T05:03:48.499Z",
|
||||
"deleted_at" : "2026-02-16T05:03:48.499Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "fd3ee75c-5389-461b-9489-ae286a0acc17",
|
||||
"module" : "Registration",
|
||||
"name" : "Registration",
|
||||
"link" : "\/registration",
|
||||
"id_parent" : null,
|
||||
"order_number" : 3,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T07:58:07.313Z",
|
||||
"updated_at" : "2026-02-16T05:05:11.780Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "821bb298-35a9-4da0-8dc4-607545f1e3d8",
|
||||
"module" : "Settings",
|
||||
"name" : "User",
|
||||
"link" : "\/settings\/user",
|
||||
"id_parent" : "573d086b-5d7b-4e8b-9b40-d86ea6638d7b",
|
||||
"order_number" : 2,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T05:34:45.824Z",
|
||||
"updated_at" : "2026-02-16T05:09:39.512Z",
|
||||
"deleted_at" : "2026-02-16T05:09:39.512Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "830f5206-34aa-4e7d-bd3f-2c941356d634",
|
||||
"module" : "Settings",
|
||||
"name" : "Role",
|
||||
"link" : "\/settings\/role",
|
||||
"id_parent" : "573d086b-5d7b-4e8b-9b40-d86ea6638d7b",
|
||||
"order_number" : 1,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T05:36:06.730Z",
|
||||
"updated_at" : "2026-02-16T05:09:44.678Z",
|
||||
"deleted_at" : "2026-02-16T05:09:44.678Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "7a2be7d5-dbbe-4ead-8423-c8a2811bca72",
|
||||
"module" : "Patient",
|
||||
"name" : "List",
|
||||
"link" : "\/patient\/list",
|
||||
"id_parent" : "1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2",
|
||||
"order_number" : 1,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T04:32:59.078Z",
|
||||
"updated_at" : "2026-02-16T05:17:28.627Z",
|
||||
"deleted_at" : "2026-02-16T05:17:28.627Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "c3c0f6ed-933f-42ff-b6f5-c0ee788a3f1d",
|
||||
"module" : "Patient",
|
||||
"name" : "Create",
|
||||
"link" : "\/patient\/create",
|
||||
"id_parent" : "1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2",
|
||||
"order_number" : 2,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T07:55:10.075Z",
|
||||
"updated_at" : "2026-02-16T05:17:42.623Z",
|
||||
"deleted_at" : "2026-02-16T05:17:42.623Z",
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2",
|
||||
"module" : "Patient",
|
||||
"name" : "Patient",
|
||||
"link" : "\/patient",
|
||||
"id_parent" : null,
|
||||
"order_number" : 2,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T04:32:01.328Z",
|
||||
"updated_at" : "2026-02-16T05:19:13.950Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "3e948499-06ad-4eb1-8855-769f7d65bc59",
|
||||
"module" : "Queue",
|
||||
"name" : "Queue",
|
||||
"link" : "\/queue",
|
||||
"id_parent" : null,
|
||||
"order_number" : 13,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-19T05:13:32.731Z",
|
||||
"updated_at" : "2026-02-19T05:13:32.731Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "79b8fa05-11c2-46ea-ab68-87d20fb9f96f",
|
||||
"module" : "Laboratory",
|
||||
"name" : "Laboratory",
|
||||
"link" : "\/laboratory",
|
||||
"id_parent" : null,
|
||||
"order_number" : 18,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-19T05:13:55.436Z",
|
||||
"updated_at" : "2026-02-19T05:13:55.436Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "a54063b3-0713-42df-b807-aafa0d93727b",
|
||||
"module" : "Radiology",
|
||||
"name" : "Radiology",
|
||||
"link" : "\/radiology",
|
||||
"id_parent" : null,
|
||||
"order_number" : 23,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-19T05:16:09.613Z",
|
||||
"updated_at" : "2026-02-19T05:16:09.613Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "d88970cd-181b-48af-a494-b4f0e617d6ea",
|
||||
"module" : "dashboard",
|
||||
"name" : "Dashboard",
|
||||
"link" : "\/dashboard",
|
||||
"id_parent" : null,
|
||||
"order_number" : 1,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-06T04:24:04.218Z",
|
||||
"updated_at" : "2026-03-02T06:20:11.170Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "3317b351-870e-403e-8dc9-60e48506281b",
|
||||
"module" : "Kiosk",
|
||||
"name" : "Kiosk",
|
||||
"link" : "\/kiosk",
|
||||
"id_parent" : null,
|
||||
"order_number" : 4,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-03-03T03:06:08.901Z",
|
||||
"updated_at" : "2026-03-03T03:06:08.901Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "12410358-e737-4a16-8aa9-d81e69ec07c7",
|
||||
"module" : "Medical Record",
|
||||
"name" : "Medical Record",
|
||||
"link" : "\/medical-record",
|
||||
"id_parent" : null,
|
||||
"order_number" : 98,
|
||||
"icon" : "",
|
||||
"status" : "N",
|
||||
"created_at" : "2026-03-02T03:02:24.676Z",
|
||||
"updated_at" : "2026-03-09T17:38:43.109Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "56755dd2-0154-44eb-8b34-0f0ef737e5b2",
|
||||
"module" : "Pharmacy",
|
||||
"name" : "Pharmacy",
|
||||
"link" : "\/pharmacy",
|
||||
"id_parent" : null,
|
||||
"order_number" : 95,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-03-11T03:26:04.505Z",
|
||||
"updated_at" : "2026-03-11T03:26:04.505Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "573d086b-5d7b-4e8b-9b40-d86ea6638d7b",
|
||||
"module" : "Settings",
|
||||
"name" : "Settings",
|
||||
"link" : "\/settings",
|
||||
"id_parent" : null,
|
||||
"order_number" : 99,
|
||||
"icon" : "setting-2",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T05:16:43.231Z",
|
||||
"updated_at" : "2026-03-19T14:58:29.173Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "abc44cb4-11c4-4876-bc0e-70c49b718719",
|
||||
"module" : "Cashier",
|
||||
"name" : "Cashier",
|
||||
"link" : "\/cashier",
|
||||
"id_parent" : null,
|
||||
"order_number" : 100,
|
||||
"icon" : "",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-04-02T02:41:19.958Z",
|
||||
"updated_at" : "2026-04-07T06:38:39.006Z",
|
||||
"deleted_at" : null,
|
||||
"application" : "saude"
|
||||
}
|
||||
]}
|
||||
133
seed/auth/user_roles_202604141440.json
Normal file
133
seed/auth/user_roles_202604141440.json
Normal file
@ -0,0 +1,133 @@
|
||||
{
|
||||
"user_roles": [
|
||||
{
|
||||
"id" : "470ab23b-8eae-417b-b25b-fa115bb327c3",
|
||||
"name" : "Administrator",
|
||||
"roles" : "[\"4a6991b6-78a0-4b3b-bf5c-fa0af5f69be8\", \"1a1221b6-78a0-4b3b-bf5c-fa0af5f69be8\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-11T08:04:26.067Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-11T08:04:26.068Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : null
|
||||
},
|
||||
{
|
||||
"id" : "a1e5cf48-0109-4f69-9a24-b1d6df05fc7b",
|
||||
"name" : "Queue System",
|
||||
"roles" : "[\"3e948499-06ad-4eb1-8855-769f7d65bc59\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-03-03T04:51:55.693Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-03-03T04:52:11.093Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "240d4594-05cc-4914-97b9-eadc501edeaf",
|
||||
"name" : "Doctor",
|
||||
"roles" : "[\"beabac71-caf1-4b86-8f5e-f3c953133545\", \"d88970cd-181b-48af-a494-b4f0e617d6ea\", \"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-26T03:38:40.187Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-03-06T08:00:40.772Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "47178a5a-d8b1-4857-a6c8-74a3c846bbe3",
|
||||
"name" : "All Access",
|
||||
"roles" : "[\"d88970cd-181b-48af-a494-b4f0e617d6ea\", \"beabac71-caf1-4b86-8f5e-f3c953133545\", \"79b8fa05-11c2-46ea-ab68-87d20fb9f96f\", \"12410358-e737-4a16-8aa9-d81e69ec07c7\", \"573d086b-5d7b-4e8b-9b40-d86ea6638d7b\", \"a54063b3-0713-42df-b807-aafa0d93727b\", \"3317b351-870e-403e-8dc9-60e48506281b\", \"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\", \"fd3ee75c-5389-461b-9489-ae286a0acc17\", \"3e948499-06ad-4eb1-8855-769f7d65bc59\", \"56755dd2-0154-44eb-8b34-0f0ef737e5b2\", \"abc44cb4-11c4-4876-bc0e-70c49b718719\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-04-14T04:07:03.115Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-04-14T04:07:49.258Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "7272cd23-efe2-4af3-9fa9-ce2633523843",
|
||||
"name" : "Super Administrator",
|
||||
"roles" : "[\"d88970cd-181b-48af-a494-b4f0e617d6ea\", \"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\", \"7a2be7d5-dbbe-4ead-8423-c8a2811bca72\", \"573d086b-5d7b-4e8b-9b40-d86ea6638d7b\", \"821bb298-35a9-4da0-8dc4-607545f1e3d8\", \"830f5206-34aa-4e7d-bd3f-2c941356d634\", \"c3c0f6ed-933f-42ff-b6f5-c0ee788a3f1d\", \"fd3ee75c-5389-461b-9489-ae286a0acc17\", \"d31a11ce-5243-4172-ace5-5d456a1d6a1f\", \"dee8031f-85ad-4356-a584-55c6664a7bdd\", \"236ba50b-80d4-4199-af85-4f77a824916b\", \"beabac71-caf1-4b86-8f5e-f3c953133545\", \"3e948499-06ad-4eb1-8855-769f7d65bc59\", \"79b8fa05-11c2-46ea-ab68-87d20fb9f96f\", \"a54063b3-0713-42df-b807-aafa0d93727b\", \"3317b351-870e-403e-8dc9-60e48506281b\", \"56755dd2-0154-44eb-8b34-0f0ef737e5b2\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-06T04:22:23.055Z",
|
||||
"created_by" : null,
|
||||
"updated_at" : "2026-03-11T03:41:01.849Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "d0898e0c-e369-40d7-8034-051d5e0fa6d6",
|
||||
"name" : "Role test",
|
||||
"roles" : "[\"d88970cd-181b-48af-a494-b4f0e617d6ea\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T06:01:44.055Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-24T08:58:18.025Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "99d4309a-fe7e-425f-96a7-c0e3fd1448b5",
|
||||
"name" : "Registration Staff",
|
||||
"roles" : "[\"fd3ee75c-5389-461b-9489-ae286a0acc17\", \"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\", \"beabac71-caf1-4b86-8f5e-f3c953133545\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-26T03:38:01.634Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-26T03:38:01.634Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "6e7fada2-4528-4c74-9ec9-3e4d6af5300b",
|
||||
"name" : "Laboratory Staff",
|
||||
"roles" : "[\"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\", \"79b8fa05-11c2-46ea-ab68-87d20fb9f96f\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-26T03:39:46.326Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-26T03:39:46.327Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "195ebd37-ce92-4498-9a7f-259828fd0d2a",
|
||||
"name" : "Radiology Staff",
|
||||
"roles" : "[\"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\", \"a54063b3-0713-42df-b807-aafa0d93727b\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-26T03:39:56.749Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-26T03:39:56.749Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
},
|
||||
{
|
||||
"id" : "a1da2230-68cb-4e21-bf8f-3cbdac02bdc2",
|
||||
"name" : "Nurse (OPD)",
|
||||
"roles" : "[\"beabac71-caf1-4b86-8f5e-f3c953133545\", \"1ba6ddb2-9399-4dd0-80d2-8130a7afa0e2\"]",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-26T03:39:30.901Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-26T03:40:17.744Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"application" : "saude"
|
||||
}
|
||||
]}
|
||||
451
seed/auth/users_202604141440.json
Normal file
451
seed/auth/users_202604141440.json
Normal file
@ -0,0 +1,451 @@
|
||||
{
|
||||
"users": [
|
||||
{
|
||||
"id" : "f3cd121f-51ad-453a-8066-ecfa14cb3707",
|
||||
"email" : "admin@gmail.com",
|
||||
"password" : "12345aA!",
|
||||
"username" : "admin",
|
||||
"name" : "Admin",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-06T04:21:44.060Z",
|
||||
"created_by" : null,
|
||||
"updated_at" : "2026-02-06T04:21:44.060Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "6b91596e-1ef7-413f-a8a5-966b7cfc23cd",
|
||||
"email" : "admin6@gmail.com",
|
||||
"password" : "$2a$08$jRwp3.gqwYcKb7u\/dt84Ce6w0HklDyby.MhrWEHGO7\/bicccDveQe",
|
||||
"username" : "admin6",
|
||||
"name" : "Administrator 6",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-09T11:06:38.448Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-09T11:23:08.127Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : "2026-02-09T11:23:08.127Z",
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "ce8e4949-c136-4e6a-a60a-7f3cfa9569cf",
|
||||
"email" : "admin5@gmail.com",
|
||||
"password" : "$2a$08$.djsh4vY.7rE5HNXKSQ6DeJIboCn.lq5sl1ouFxC9O2VHIyjXnAfG",
|
||||
"username" : "admin5",
|
||||
"name" : "Administrator 5",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-09T11:03:31.743Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-09T11:23:20.626Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : "2026-02-09T11:23:20.626Z",
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "39f168c5-c001-4e9e-b6b2-2d181c0afc2a",
|
||||
"email" : "tina@gmail.com",
|
||||
"password" : "$2a$08$agvY1G.99950MVyD8jRt8el6K1ZyRrKZ3PCf6XGI9gKEyA2MyP8vG",
|
||||
"username" : "Tina",
|
||||
"name" : "Dr. Tina",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:56:56.444Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:56:56.450Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "d3d2fa5d-6df6-4858-bfe2-ec2cae8004d7",
|
||||
"email" : "joana@gmail.com",
|
||||
"password" : "$2a$08$hXvlZmZfoRDR2SeRSnj1v.5044H.IJtDybDKnELztrCBtgHvF717G",
|
||||
"username" : "Joana",
|
||||
"name" : "Dr. Joana",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:57:37.833Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:57:37.837Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "d33a81f1-90f7-485c-81b2-10c7ae838dea",
|
||||
"email" : "queue@gmail.com",
|
||||
"password" : "$2a$08$UeMkGg05IBwFfdcGT9dlTOytQM\/sG1MYzeMnHhTplNGP4zOLf8p9W",
|
||||
"username" : "queue_display",
|
||||
"name" : "Queue Display",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-03-03T04:53:16.756Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-03-03T04:53:16.760Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "3df16202-49c7-450e-9283-51784b3d0103",
|
||||
"email" : "lily@gmail.com",
|
||||
"password" : "$2a$08$xzEF6hpcy\/uCaBkZDivdHO2oe0YMrOL41N6SJCpDGdg\/ENT9n5Bum",
|
||||
"username" : "lily",
|
||||
"name" : "Dr. Lily",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:58:26.930Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:58:26.934Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "117eecd7-89e2-4af0-8f58-5d2b3f79805e",
|
||||
"email" : "juan@gmail.com",
|
||||
"password" : "$2a$08$bIFd0fGYAumBtM.h3yB0RuGEBrwYaWxDa4CsZTAlrlWyd0bYhPuN.",
|
||||
"username" : "Juan",
|
||||
"name" : "Dr. Juan",
|
||||
"reset_token" : "51fac519-3512-4e2a-b16f-f4a5425596e6",
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:47:11.318Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-03-13T03:53:49.524Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "ee7bdb41-f697-4105-8ceb-1fd90034d9d8",
|
||||
"email" : "user2@gmail.com",
|
||||
"password" : "$2a$08$7dtpoFJ0eSUfkpnFWB61yuKD5rfBQm1x4l4fqLl.CRiVn8TV5JdZK",
|
||||
"username" : "user2",
|
||||
"name" : "User 2 ",
|
||||
"reset_token" : null,
|
||||
"status" : "N",
|
||||
"created_at" : "2026-02-10T04:14:49.914Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-12T07:03:22.437Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "aa3f7492-02b3-4a9e-983a-2043e6e071d2",
|
||||
"email" : "user3@gmail.com",
|
||||
"password" : "$2a$08$r6wfgRSpP\/Qlne6HrJGJXOFp6UxDcFxkGT8UQAQ8QOUCn9hbUq0m.",
|
||||
"username" : "user3",
|
||||
"name" : "User 3",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-12T07:07:23.409Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-12T07:07:23.413Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "9c18a8f8-60bd-4cc2-8d0c-a663970f561d",
|
||||
"email" : "pringgosutono@gmail.com",
|
||||
"password" : "$2a$12$CqN3XAhEr0\/GS8Xr\/Bn3h.7YyJii\/vI7AcYBE55985ni2vaIrrveC",
|
||||
"username" : "go",
|
||||
"name" : "go",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-04-02T07:52:34.284Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-04-02T07:52:34.284Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "ed2f0e88-14f3-4840-a8fb-c641ea2a0bf1",
|
||||
"email" : "brunof@gmail.com",
|
||||
"password" : "$2a$08$duF.7Obg8aTMkc6KTk0fe.\/gOUjyCaisaPg4iRdClh.IXLzrYEQmq",
|
||||
"username" : "brunof",
|
||||
"name" : "Dr. Bruno Fernandes",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-10T03:25:39.029Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-10T07:26:11.322Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "5613173b-186f-45b0-b05d-3d4a2eb04598",
|
||||
"email" : "igorb@gmail.com",
|
||||
"password" : "$2a$08$XAQfVz5aS2UkG0f2ra4CWe75yLlNkNgamFW31le2qFMg3zsBG83Ne",
|
||||
"username" : "igorb",
|
||||
"name" : "Dr. Igor Bastian",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-09T09:03:52.038Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-12T08:10:41.364Z",
|
||||
"updated_by" : "Admin",
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "93d5866b-5776-487a-9b44-74633242fd3a",
|
||||
"email" : "tiana@gmail.com",
|
||||
"password" : "$2a$08$PkQ1KLsdKunPjGuO2veXluzxJ4aRvyLLFQx83x0mL3z4KI0gEbTTe",
|
||||
"username" : "Tiana",
|
||||
"name" : "Dr. Tiana",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:43:24.168Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:43:24.169Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "46db4077-f6b6-4551-9735-a3310a6bc91a",
|
||||
"email" : "bian@gmail.com",
|
||||
"password" : "$2a$08$9KBBaiwwefnpffFbolltGOarZAvil4At.M9JtsaQrDR9dYQ5i4mxi",
|
||||
"username" : "Bian",
|
||||
"name" : "Dr. Bian",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:44:33.656Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:44:33.660Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "6ad5aed6-7011-43a3-80f8-d6087555b486",
|
||||
"email" : "laura@gmail.com",
|
||||
"password" : "$2a$08$0O9YrKH61UIh1tF3pDJGLesx3GLRXfdQkI9Yty3TBq9d9KPRyj\/Yu",
|
||||
"username" : "Laura",
|
||||
"name" : "Dr. Laura",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:45:30.151Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:45:30.155Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "aecbd6e9-7523-402d-82d2-9fe55f8c14fb",
|
||||
"email" : "chris@gmail.com",
|
||||
"password" : "$2a$08$XMuOyUcgebXy9.0mQYZk6OB75pXpoFCP8i6ZiU1ebwzTp6waq.u1u",
|
||||
"username" : "Chris",
|
||||
"name" : "Dr. Chris",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:46:20.945Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:46:20.951Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "2f6cd077-9300-4d54-a070-fc3de81f9918",
|
||||
"email" : "balen@gmail.com",
|
||||
"password" : "$2a$08$I9gphuQlbZSzDtOlHaERUu6y6oSOs6bM8JacM8a0i1ZLHPW0H\/rgG",
|
||||
"username" : "Balen",
|
||||
"name" : "Dr. Balen",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:48:10.200Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:48:10.202Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "bc2e9de8-147b-4f9a-8a71-2187f856aa3a",
|
||||
"email" : "rayn@gmail.com",
|
||||
"password" : "$2a$08$cyb4KTn2YaPhKl7EGOHHKekvOgYjWy4dCUhK\/26hbZO\/Z.jjVrmM.",
|
||||
"username" : "Rayn",
|
||||
"name" : "Dr. Rayn",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:48:57.917Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:48:57.918Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "feb89896-a92d-400b-a27b-c7b9eabf837a",
|
||||
"email" : "ziana@gmail.com",
|
||||
"password" : "$2a$08$NcapPkif1O1pUdhOKrFGhuWmKkYoe\/GapWni\/ada2ACcyPnbL055W",
|
||||
"username" : "Ziana",
|
||||
"name" : "Dr. Ziana",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:49:40.727Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:49:40.728Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "2f47245f-6093-4bd8-9e0e-e5e509443576",
|
||||
"email" : "donita@gmail.com",
|
||||
"password" : "$2a$08$jp08R7o\/AfHNaYOqUe5n8uWmGcaSbdsTZUCKLiBKPKa54Eku\/2YTe",
|
||||
"username" : "Donita",
|
||||
"name" : "Dr. Donita",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:50:29.063Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:50:29.063Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "54c2f80e-c6d1-4528-b4a2-457b65bbc5de",
|
||||
"email" : "helen@gmail.com",
|
||||
"password" : "$2a$08$lyJ03YdUyWDYDJteMpXfuOf0HeG7wcEIyQ5FAeW45FSuDcBH0wdvO",
|
||||
"username" : "Helen",
|
||||
"name" : "Dr. Helen",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:51:22.370Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:51:22.371Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "2669feb9-72b5-467a-b189-c281aa9947b0",
|
||||
"email" : "julia@gmail.com",
|
||||
"password" : "$2a$08$Y4mdJ0bsj.eUfb32S\/Jz5ufac3iZj5LeFPLlbQdVLn7QMjnKwc30i",
|
||||
"username" : "Julia",
|
||||
"name" : "Dr. Julia",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:52:33.102Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:52:33.107Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "71044175-ce34-47c7-ac13-09309cccae67",
|
||||
"email" : "heris@gmail.com",
|
||||
"password" : "$2a$08$YsH5Ki0bP66wJGBOQq65qu2Hh2qB8ClHul4guBZSXPbCXjxTb\/FnS",
|
||||
"username" : "Heris",
|
||||
"name" : "Dr. Heris",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:53:25.406Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:53:25.410Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "e27f5d98-d379-4991-9271-b53d9cbbbc41",
|
||||
"email" : "danil@gmail.com",
|
||||
"password" : "$2a$08$MEBJyDI.NIJ9fzSTIEdAK.HxUflrK4AAVC6ruYOSckw4Znnbhz\/Ii",
|
||||
"username" : "Danil",
|
||||
"name" : "Dr. Danil",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:54:08.511Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:54:08.515Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "5f98a432-cc28-4d13-b3da-68cc707ab0ff",
|
||||
"email" : "veya@gmail.com",
|
||||
"password" : "$2a$08$FHf98Q6aIj7u5pE8rexO3uRQF98Ni\/PjwF19eZ5OTR80MEysIQ1jS",
|
||||
"username" : "Veya",
|
||||
"name" : "Dr. Veya",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:55:03.937Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:55:03.942Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "4f68f5d7-7be1-4b1d-9ccf-4dc8b79fc2c6",
|
||||
"email" : "angel@gmail.com",
|
||||
"password" : "$2a$08$FRUzqFgsVSPXNO.OzW5mFONZkp7ningDifo22dr9pjKNS1TeX9ga.",
|
||||
"username" : "Angel",
|
||||
"name" : "Dr. Angel",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-02-27T09:55:43.179Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-02-27T09:55:43.183Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
},
|
||||
{
|
||||
"id" : "9916995e-904e-4475-8e4c-81f3010ba95b",
|
||||
"email" : "drhugo@gmail.com",
|
||||
"password" : "$2a$08$ireXxseMbeHQFTF..BPx5OQdPGguLYTI1FQzwt1.aIDinpUUUP.jG",
|
||||
"username" : "drhugo",
|
||||
"name" : "dr. Hugo Strange",
|
||||
"reset_token" : null,
|
||||
"status" : "Y",
|
||||
"created_at" : "2026-04-14T05:02:00.511Z",
|
||||
"created_by" : "Admin",
|
||||
"updated_at" : "2026-04-14T05:02:00.516Z",
|
||||
"updated_by" : null,
|
||||
"deleted_at" : null,
|
||||
"deleted_by" : null,
|
||||
"employeeId" : null
|
||||
}
|
||||
]}
|
||||
104
seed/auth/users_roles_user_roles_202604141440.json
Normal file
104
seed/auth/users_roles_user_roles_202604141440.json
Normal file
@ -0,0 +1,104 @@
|
||||
{
|
||||
"users_roles_user_roles": [
|
||||
{
|
||||
"usersId": "f3cd121f-51ad-453a-8066-ecfa14cb3707",
|
||||
"userRolesId": "7272cd23-efe2-4af3-9fa9-ce2633523843"
|
||||
},
|
||||
{
|
||||
"usersId": "ee7bdb41-f697-4105-8ceb-1fd90034d9d8",
|
||||
"userRolesId": "d0898e0c-e369-40d7-8034-051d5e0fa6d6"
|
||||
},
|
||||
{
|
||||
"usersId": "ed2f0e88-14f3-4840-a8fb-c641ea2a0bf1",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "5613173b-186f-45b0-b05d-3d4a2eb04598",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "93d5866b-5776-487a-9b44-74633242fd3a",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "46db4077-f6b6-4551-9735-a3310a6bc91a",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "6ad5aed6-7011-43a3-80f8-d6087555b486",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "aecbd6e9-7523-402d-82d2-9fe55f8c14fb",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "117eecd7-89e2-4af0-8f58-5d2b3f79805e",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "2f6cd077-9300-4d54-a070-fc3de81f9918",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "bc2e9de8-147b-4f9a-8a71-2187f856aa3a",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "feb89896-a92d-400b-a27b-c7b9eabf837a",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "2f47245f-6093-4bd8-9e0e-e5e509443576",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "54c2f80e-c6d1-4528-b4a2-457b65bbc5de",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "2669feb9-72b5-467a-b189-c281aa9947b0",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "71044175-ce34-47c7-ac13-09309cccae67",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "e27f5d98-d379-4991-9271-b53d9cbbbc41",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "5f98a432-cc28-4d13-b3da-68cc707ab0ff",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "4f68f5d7-7be1-4b1d-9ccf-4dc8b79fc2c6",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "39f168c5-c001-4e9e-b6b2-2d181c0afc2a",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "d3d2fa5d-6df6-4858-bfe2-ec2cae8004d7",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "3df16202-49c7-450e-9283-51784b3d0103",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
},
|
||||
{
|
||||
"usersId": "d33a81f1-90f7-485c-81b2-10c7ae838dea",
|
||||
"userRolesId": "a1e5cf48-0109-4f69-9a24-b1d6df05fc7b"
|
||||
},
|
||||
{
|
||||
"usersId": "9c18a8f8-60bd-4cc2-8d0c-a663970f561d",
|
||||
"userRolesId": "7272cd23-efe2-4af3-9fa9-ce2633523843"
|
||||
},
|
||||
{
|
||||
"usersId": "9916995e-904e-4475-8e4c-81f3010ba95b",
|
||||
"userRolesId": "240d4594-05cc-4914-97b9-eadc501edeaf"
|
||||
}
|
||||
]
|
||||
}
|
||||
716
src/scripts/seed-auth-data.ts
Normal file
716
src/scripts/seed-auth-data.ts
Normal file
@ -0,0 +1,716 @@
|
||||
/**
|
||||
* Usage:
|
||||
* ts-node src/scripts/seed-auth-data.ts
|
||||
* npm run seeder
|
||||
*/
|
||||
|
||||
import { ILogObj, Logger } from "tslog";
|
||||
import { Application, Menu, Status, User, UserRole } from "entity";
|
||||
import { OrmHelper } from "../helpers/orm";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import * as fastcsv from "fast-csv";
|
||||
|
||||
const log: Logger<ILogObj> = new Logger({
|
||||
name: "[seed-auth-data]",
|
||||
type: "pretty",
|
||||
});
|
||||
|
||||
function sleep(ms: number) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
async function waitForDbInitialized(timeoutMs: number = 15000) {
|
||||
const start = Date.now();
|
||||
while (!OrmHelper.DB || !OrmHelper.DB.isInitialized) {
|
||||
if (Date.now() - start > timeoutMs) {
|
||||
throw new Error("Database initialization timeout");
|
||||
}
|
||||
await sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
async function ensureAuthSchemaReady() {
|
||||
// OrmHelper uses `synchronize: true`, but in some environments the connection can become
|
||||
// initialized before all tables are actually present/visible. Running synchronize again is safe
|
||||
// and ensures required auth tables exist before seeding.
|
||||
await OrmHelper.DB.synchronize();
|
||||
|
||||
const qr = OrmHelper.DB.createQueryRunner();
|
||||
try {
|
||||
const hasApplication = await qr.hasTable("application");
|
||||
if (!hasApplication) {
|
||||
throw new Error(
|
||||
'Table "application" is not available after synchronize()',
|
||||
);
|
||||
}
|
||||
} finally {
|
||||
await qr.release();
|
||||
}
|
||||
}
|
||||
|
||||
async function upsertApplication(data: {
|
||||
id: string;
|
||||
name: string;
|
||||
reset_password_url: string;
|
||||
status?: Status;
|
||||
deleted_at?: Date | null;
|
||||
}) {
|
||||
const repo = OrmHelper.DB.getRepository(Application);
|
||||
|
||||
let app = await repo.findOne({
|
||||
where: { id: data.id },
|
||||
});
|
||||
|
||||
if (!app) {
|
||||
app = new Application();
|
||||
app.id = data.id;
|
||||
}
|
||||
|
||||
app.name = data.name;
|
||||
app.reset_password_url = data.reset_password_url;
|
||||
app.status = data.status ?? Status.Active;
|
||||
if (data.deleted_at !== undefined) {
|
||||
app.deleted_at = data.deleted_at ?? null;
|
||||
}
|
||||
|
||||
return await repo.save(app);
|
||||
}
|
||||
|
||||
async function upsertMenu(data: {
|
||||
id: string;
|
||||
application: Application;
|
||||
module: string;
|
||||
name: string;
|
||||
link: string;
|
||||
order_number: number;
|
||||
icon?: string;
|
||||
id_parent?: string;
|
||||
status?: Status;
|
||||
deleted_at?: Date | null;
|
||||
}) {
|
||||
const repo = OrmHelper.DB.getRepository(Menu);
|
||||
|
||||
let menu = await repo.findOne({ where: { id: data.id } as any });
|
||||
|
||||
if (!menu) {
|
||||
menu = new Menu();
|
||||
menu.id = data.id;
|
||||
}
|
||||
|
||||
menu.application = data.application;
|
||||
menu.module = data.module;
|
||||
menu.name = data.name;
|
||||
menu.link = data.link;
|
||||
menu.id_parent = data.id_parent ?? null;
|
||||
menu.order_number = data.order_number;
|
||||
menu.icon = data.icon ?? null;
|
||||
menu.status = data.status ?? Status.Active;
|
||||
if (data.deleted_at !== undefined) {
|
||||
menu.deleted_at = data.deleted_at ?? null;
|
||||
}
|
||||
|
||||
return await repo.save(menu);
|
||||
}
|
||||
|
||||
async function upsertUserRole(data: {
|
||||
id: string;
|
||||
application: Application;
|
||||
name: string;
|
||||
roles: string[];
|
||||
status?: Status;
|
||||
created_by?: string;
|
||||
updated_by?: string;
|
||||
deleted_at?: Date | null;
|
||||
deleted_by?: string | null;
|
||||
}) {
|
||||
const repo = OrmHelper.DB.getRepository(UserRole);
|
||||
|
||||
let role = await repo.findOne({
|
||||
relations: { application: true } as any,
|
||||
where: { id: data.id } as any,
|
||||
});
|
||||
|
||||
if (!role) {
|
||||
role = new UserRole();
|
||||
role.id = data.id;
|
||||
role.application = data.application;
|
||||
role.name = data.name;
|
||||
role.created_by = data.created_by ?? "system-seed";
|
||||
role.created_at = new Date();
|
||||
}
|
||||
|
||||
role.application = data.application;
|
||||
role.name = data.name;
|
||||
role.roles = data.roles;
|
||||
role.status = data.status ?? Status.Active;
|
||||
role.updated_by = data.updated_by ?? "system-seed";
|
||||
role.updated_at = new Date();
|
||||
if (data.deleted_at !== undefined) {
|
||||
role.deleted_at = data.deleted_at ?? null;
|
||||
}
|
||||
if (data.deleted_by !== undefined) {
|
||||
role.deleted_by = data.deleted_by ?? null;
|
||||
}
|
||||
|
||||
return await repo.save(role);
|
||||
}
|
||||
|
||||
async function upsertUser(data: {
|
||||
id?: string;
|
||||
email: string;
|
||||
username: string;
|
||||
name: string;
|
||||
password: string;
|
||||
status?: Status;
|
||||
created_by?: string;
|
||||
updated_by?: string;
|
||||
reset_token?: string | null;
|
||||
deleted_at?: Date | null;
|
||||
deleted_by?: string | null;
|
||||
}) {
|
||||
const repo = OrmHelper.DB.getRepository(User);
|
||||
|
||||
const id = data.id && isUuid(data.id) ? data.id : null;
|
||||
|
||||
let user = id
|
||||
? await repo.findOne({
|
||||
relations: { roles: true } as any,
|
||||
where: { id } as any,
|
||||
})
|
||||
: await repo.findOne({
|
||||
relations: { roles: true } as any,
|
||||
where: { username: data.username } as any,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
user = new User();
|
||||
user.email = data.email;
|
||||
user.username = data.username;
|
||||
user.name = data.name;
|
||||
user.status = data.status ?? Status.Active;
|
||||
user.employee = null;
|
||||
user.created_by = data.created_by ?? "system-seed";
|
||||
user.created_at = new Date();
|
||||
|
||||
if (id) {
|
||||
user.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
user.email = data.email;
|
||||
user.username = data.username;
|
||||
user.name = data.name;
|
||||
user.status = data.status ?? Status.Active;
|
||||
|
||||
user.updated_by = data.updated_by ?? "system-seed";
|
||||
user.updated_at = new Date();
|
||||
|
||||
if (data.reset_token !== undefined) {
|
||||
user.reset_token = data.reset_token ?? null;
|
||||
}
|
||||
if (data.deleted_at !== undefined) {
|
||||
user.deleted_at = data.deleted_at ?? null;
|
||||
}
|
||||
if (data.deleted_by !== undefined) {
|
||||
user.deleted_by = data.deleted_by ?? null;
|
||||
}
|
||||
|
||||
user.password = data.password;
|
||||
// Preserve bcrypt hashes from seed; only hash plain passwords.
|
||||
if (!isBcryptHash(user.password)) {
|
||||
user.hashPassword();
|
||||
}
|
||||
|
||||
return await repo.save(user);
|
||||
}
|
||||
|
||||
function isBcryptHash(value: string) {
|
||||
return typeof value === "string" && /^\$2[aby]\$\d{2}\$/.test(value);
|
||||
}
|
||||
|
||||
function isUuid(value: any) {
|
||||
return (
|
||||
typeof value === "string" &&
|
||||
/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(
|
||||
value,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
function parseStatus(value: any): Status {
|
||||
if (value === Status.Active || value === Status["Not Active"]) {
|
||||
return value as Status;
|
||||
}
|
||||
if (value === "Y") return Status.Active;
|
||||
if (value === "N") return Status["Not Active"];
|
||||
return Status.Active;
|
||||
}
|
||||
|
||||
function parseNullableString(value: any) {
|
||||
if (value === undefined || value === null) return null;
|
||||
const s = String(value).trim();
|
||||
return s === "" ? null : s;
|
||||
}
|
||||
|
||||
function parseNullableDate(value: any): Date | null {
|
||||
if (value === undefined || value === null) return null;
|
||||
const s = String(value).trim();
|
||||
if (s === "" || s.toLowerCase() === "null") return null;
|
||||
const d = new Date(s);
|
||||
return Number.isNaN(d.getTime()) ? null : d;
|
||||
}
|
||||
|
||||
function parseIntSafe(value: any, fallback: number = 0) {
|
||||
const n = Number.parseInt(String(value), 10);
|
||||
return Number.isFinite(n) ? n : fallback;
|
||||
}
|
||||
|
||||
async function readCsv<T = any>(filePath: string): Promise<T[]> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const rows: T[] = [];
|
||||
|
||||
fs.createReadStream(filePath)
|
||||
.pipe(
|
||||
fastcsv.parse({
|
||||
headers: true,
|
||||
ignoreEmpty: true,
|
||||
trim: true,
|
||||
}),
|
||||
)
|
||||
.on("error", reject)
|
||||
.on("data", (row: any) => rows.push(row))
|
||||
.on("end", () => resolve(rows));
|
||||
});
|
||||
}
|
||||
|
||||
function pickLatestSeedFile(seedDir: string, prefix: string) {
|
||||
const files = fs
|
||||
.readdirSync(seedDir)
|
||||
.filter((f) => f.startsWith(prefix) && f.endsWith(".csv"));
|
||||
if (files.length === 0) {
|
||||
throw new Error(`Seed file not found: ${prefix}*.csv in ${seedDir}`);
|
||||
}
|
||||
|
||||
files.sort();
|
||||
return path.join(seedDir, files[files.length - 1]);
|
||||
}
|
||||
|
||||
function pickLatestSeedJsonFile(seedDir: string, prefix: string) {
|
||||
const files = fs
|
||||
.readdirSync(seedDir)
|
||||
.filter((f) => f.startsWith(prefix) && f.endsWith(".json"));
|
||||
if (files.length === 0) {
|
||||
throw new Error(`Seed file not found: ${prefix}*.json in ${seedDir}`);
|
||||
}
|
||||
|
||||
files.sort();
|
||||
return path.join(seedDir, files[files.length - 1]);
|
||||
}
|
||||
|
||||
function escapeRegex(value: string) {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
function listSeedJsonFiles(seedDir: string, prefix: string) {
|
||||
// Match strictly: "<prefix><timestamp>.json" to avoid overlap
|
||||
// e.g. "users_" should not match "users_roles_user_roles_..."
|
||||
const pattern = new RegExp(`^${escapeRegex(prefix)}\\d+\\.json$`);
|
||||
const files = fs.readdirSync(seedDir).filter((f) => pattern.test(f));
|
||||
files.sort();
|
||||
return files.map((f) => path.join(seedDir, f));
|
||||
}
|
||||
|
||||
async function readJsonFile<T = any>(filePath: string): Promise<T> {
|
||||
const raw = await fs.promises.readFile(filePath, "utf8");
|
||||
return JSON.parse(raw) as T;
|
||||
}
|
||||
|
||||
async function main() {
|
||||
OrmHelper.setup();
|
||||
await waitForDbInitialized();
|
||||
|
||||
try {
|
||||
log.info("Starting seed auth data...");
|
||||
await ensureAuthSchemaReady();
|
||||
|
||||
// Source of truth for auth seed (JSON exports)
|
||||
const seedDir = path.resolve(process.cwd(), "seed", "auth");
|
||||
|
||||
// IMPORTANT:
|
||||
// Seeder must be 100% synchronized with seed/auth.
|
||||
// That means we process *all* JSON files in this folder (not only the latest export).
|
||||
const expectedPrefixes = [
|
||||
"application_",
|
||||
"menus_",
|
||||
"user_roles_",
|
||||
"users_",
|
||||
"users_roles_user_roles_",
|
||||
] as const;
|
||||
|
||||
const allJsonFiles = fs
|
||||
.readdirSync(seedDir)
|
||||
.filter((f) => f.endsWith(".json"))
|
||||
.sort();
|
||||
if (allJsonFiles.length === 0) {
|
||||
throw new Error(`No JSON seed files found in ${seedDir}`);
|
||||
}
|
||||
|
||||
const filesByPrefix: Record<(typeof expectedPrefixes)[number], string[]> = {
|
||||
application_: listSeedJsonFiles(seedDir, "application_"),
|
||||
menus_: listSeedJsonFiles(seedDir, "menus_"),
|
||||
user_roles_: listSeedJsonFiles(seedDir, "user_roles_"),
|
||||
users_: listSeedJsonFiles(seedDir, "users_"),
|
||||
users_roles_user_roles_: listSeedJsonFiles(
|
||||
seedDir,
|
||||
"users_roles_user_roles_",
|
||||
),
|
||||
};
|
||||
|
||||
for (const prefix of expectedPrefixes) {
|
||||
if (filesByPrefix[prefix].length === 0) {
|
||||
throw new Error(`Seed file not found: ${prefix}*.json in ${seedDir}`);
|
||||
}
|
||||
}
|
||||
|
||||
const recognized = new Set<string>();
|
||||
for (const prefix of expectedPrefixes) {
|
||||
for (const fp of filesByPrefix[prefix]) recognized.add(path.basename(fp));
|
||||
}
|
||||
const unrecognized = allJsonFiles.filter((f) => !recognized.has(f));
|
||||
if (unrecognized.length > 0) {
|
||||
// Fail fast so we never silently miss new seed files.
|
||||
throw new Error(
|
||||
`Unrecognized seed/auth files: ${unrecognized.join(", ")}`,
|
||||
);
|
||||
}
|
||||
|
||||
log.info("Using seed/auth files:", {
|
||||
application: filesByPrefix["application_"].map((f) => path.basename(f)),
|
||||
menus: filesByPrefix["menus_"].map((f) => path.basename(f)),
|
||||
user_roles: filesByPrefix["user_roles_"].map((f) => path.basename(f)),
|
||||
users: filesByPrefix["users_"].map((f) => path.basename(f)),
|
||||
users_roles_user_roles: filesByPrefix["users_roles_user_roles_"].map(
|
||||
(f) => path.basename(f),
|
||||
),
|
||||
total_files: allJsonFiles.length,
|
||||
});
|
||||
|
||||
// applications
|
||||
const appById: Record<string, Application> = {};
|
||||
let defaultApp: Application = null;
|
||||
let applicationsTotal = 0;
|
||||
for (const fileApplications of filesByPrefix["application_"]) {
|
||||
const appsDoc = await readJsonFile<{ application?: any[] }>(
|
||||
fileApplications,
|
||||
);
|
||||
const appsRaw = Array.isArray(appsDoc?.application)
|
||||
? appsDoc.application
|
||||
: null;
|
||||
if (!appsRaw) {
|
||||
throw new Error(
|
||||
`Invalid JSON structure for applications: ${path.basename(fileApplications)}`,
|
||||
);
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
for (const row of appsRaw) {
|
||||
if (row?.id === undefined || row?.id === null) {
|
||||
throw new Error(
|
||||
`Invalid application row (missing id) in ${path.basename(fileApplications)}`,
|
||||
);
|
||||
}
|
||||
const app = await upsertApplication({
|
||||
id: String(row.id),
|
||||
name: String(row.name),
|
||||
reset_password_url: String(row.reset_password_url ?? ""),
|
||||
status: parseStatus(row.status),
|
||||
deleted_at: parseNullableDate(row.deleted_at),
|
||||
});
|
||||
appById[app.id] = app;
|
||||
if (!defaultApp) {
|
||||
defaultApp = app;
|
||||
}
|
||||
processed++;
|
||||
}
|
||||
applicationsTotal += processed;
|
||||
log.info("Seeded applications file", {
|
||||
file: path.basename(fileApplications),
|
||||
rows: processed,
|
||||
});
|
||||
}
|
||||
|
||||
// menus
|
||||
let menusTotal = 0;
|
||||
for (const fileMenus of filesByPrefix["menus_"]) {
|
||||
const menusDoc = await readJsonFile<{ menus?: any[] }>(fileMenus);
|
||||
const menusRaw = Array.isArray(menusDoc?.menus) ? menusDoc.menus : null;
|
||||
if (!menusRaw) {
|
||||
throw new Error(
|
||||
`Invalid JSON structure for menus: ${path.basename(fileMenus)}`,
|
||||
);
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
for (const row of menusRaw) {
|
||||
const menuId = parseNullableString(row.id);
|
||||
if (!menuId) {
|
||||
throw new Error(
|
||||
`Invalid menu row (missing id) in ${path.basename(fileMenus)}`,
|
||||
);
|
||||
}
|
||||
if (!isUuid(menuId)) {
|
||||
throw new Error(
|
||||
`Invalid menu id (not uuid): ${menuId} in ${path.basename(fileMenus)}`,
|
||||
);
|
||||
}
|
||||
|
||||
const appId = parseNullableString(row.application) ?? defaultApp?.id;
|
||||
if (!appId) {
|
||||
throw new Error(
|
||||
`Application not found for menu: ${String(row.application ?? "")}`,
|
||||
);
|
||||
}
|
||||
const app =
|
||||
appById[appId] ??
|
||||
(await OrmHelper.DB.getRepository(Application).findOneBy({
|
||||
id: appId,
|
||||
}));
|
||||
if (!app) {
|
||||
throw new Error(`Application not found for menu: ${appId}`);
|
||||
}
|
||||
|
||||
await upsertMenu({
|
||||
id: menuId,
|
||||
application: app,
|
||||
module: String(row.module),
|
||||
name: String(row.name),
|
||||
link: String(row.link),
|
||||
id_parent: parseNullableString(row.id_parent) ?? undefined,
|
||||
order_number: parseIntSafe(row.order_number, 1),
|
||||
icon: parseNullableString(row.icon) ?? undefined,
|
||||
status: parseStatus(row.status),
|
||||
deleted_at: parseNullableDate(row.deleted_at),
|
||||
});
|
||||
processed++;
|
||||
}
|
||||
menusTotal += processed;
|
||||
log.info("Seeded menus file", {
|
||||
file: path.basename(fileMenus),
|
||||
rows: processed,
|
||||
});
|
||||
}
|
||||
|
||||
// user_roles
|
||||
const roleById: Record<string, UserRole> = {};
|
||||
let rolesTotal = 0;
|
||||
for (const fileUserRoles of filesByPrefix["user_roles_"]) {
|
||||
const rolesDoc = await readJsonFile<{ user_roles?: any[] }>(
|
||||
fileUserRoles,
|
||||
);
|
||||
const rolesRaw = Array.isArray(rolesDoc?.user_roles)
|
||||
? rolesDoc.user_roles
|
||||
: null;
|
||||
if (!rolesRaw) {
|
||||
throw new Error(
|
||||
`Invalid JSON structure for user_roles: ${path.basename(fileUserRoles)}`,
|
||||
);
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
for (const row of rolesRaw) {
|
||||
const roleId = parseNullableString(row.id);
|
||||
if (!roleId) {
|
||||
throw new Error(
|
||||
`Invalid user_role row (missing id) in ${path.basename(fileUserRoles)}`,
|
||||
);
|
||||
}
|
||||
if (!isUuid(roleId)) {
|
||||
throw new Error(
|
||||
`Invalid user_role id (not uuid): ${roleId} in ${path.basename(fileUserRoles)}`,
|
||||
);
|
||||
}
|
||||
|
||||
const appId = parseNullableString(row.application) ?? defaultApp?.id;
|
||||
if (!appId) {
|
||||
throw new Error(
|
||||
`Application not found for user_role: ${String(row.application ?? "")}`,
|
||||
);
|
||||
}
|
||||
const app =
|
||||
appById[appId] ??
|
||||
(await OrmHelper.DB.getRepository(Application).findOneBy({
|
||||
id: appId,
|
||||
}));
|
||||
if (!app) {
|
||||
throw new Error(`Application not found for user_role: ${appId}`);
|
||||
}
|
||||
|
||||
const rolesList =
|
||||
typeof row.roles === "string" && row.roles.trim() !== ""
|
||||
? JSON.parse(row.roles)
|
||||
: (row.roles ?? []);
|
||||
|
||||
const role = await upsertUserRole({
|
||||
id: roleId,
|
||||
application: app,
|
||||
name: String(row.name),
|
||||
roles: Array.isArray(rolesList) ? rolesList.map(String) : [],
|
||||
status: parseStatus(row.status),
|
||||
created_by: parseNullableString(row.created_by) ?? "system-seed",
|
||||
updated_by: parseNullableString(row.updated_by) ?? "system-seed",
|
||||
deleted_at: parseNullableDate(row.deleted_at),
|
||||
deleted_by: parseNullableString(row.deleted_by),
|
||||
});
|
||||
|
||||
roleById[role.id] = role;
|
||||
processed++;
|
||||
}
|
||||
rolesTotal += processed;
|
||||
log.info("Seeded user_roles file", {
|
||||
file: path.basename(fileUserRoles),
|
||||
rows: processed,
|
||||
});
|
||||
}
|
||||
|
||||
// users
|
||||
const userById: Record<string, User> = {};
|
||||
let usersTotal = 0;
|
||||
for (const fileUsers of filesByPrefix["users_"]) {
|
||||
const usersDoc = await readJsonFile<{ users?: any[] }>(fileUsers);
|
||||
const usersRaw = Array.isArray(usersDoc?.users) ? usersDoc.users : null;
|
||||
if (!usersRaw) {
|
||||
throw new Error(
|
||||
`Invalid JSON structure for users: ${path.basename(fileUsers)}`,
|
||||
);
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
for (const row of usersRaw) {
|
||||
const userId = parseNullableString(row.id);
|
||||
if (userId && !isUuid(userId)) {
|
||||
throw new Error(
|
||||
`Invalid user id (not uuid): ${userId} in ${path.basename(fileUsers)}`,
|
||||
);
|
||||
}
|
||||
const passwordFromSeed = String(row.password ?? "");
|
||||
const user = await upsertUser({
|
||||
id: userId ?? undefined,
|
||||
email: String(row.email),
|
||||
username: String(row.username),
|
||||
name: String(row.name),
|
||||
password: passwordFromSeed,
|
||||
status: parseStatus(row.status),
|
||||
created_by: parseNullableString(row.created_by) ?? "system-seed",
|
||||
updated_by: parseNullableString(row.updated_by) ?? "system-seed",
|
||||
reset_token: parseNullableString(row.reset_token),
|
||||
deleted_at: parseNullableDate(row.deleted_at),
|
||||
deleted_by: parseNullableString(row.deleted_by),
|
||||
});
|
||||
if (user && user.id) {
|
||||
userById[user.id] = user;
|
||||
}
|
||||
processed++;
|
||||
}
|
||||
usersTotal += processed;
|
||||
log.info("Seeded users file", {
|
||||
file: path.basename(fileUsers),
|
||||
rows: processed,
|
||||
});
|
||||
}
|
||||
|
||||
// users_roles_user_roles (join table)
|
||||
const userRepo = OrmHelper.DB.getRepository(User);
|
||||
const userRoleRepo = OrmHelper.DB.getRepository(UserRole);
|
||||
|
||||
const joinsByUserId: Record<string, string[]> = {};
|
||||
let joinsTotal = 0;
|
||||
for (const fileUsersRoles of filesByPrefix["users_roles_user_roles_"]) {
|
||||
const joinsDoc = await readJsonFile<{ users_roles_user_roles?: any[] }>(
|
||||
fileUsersRoles,
|
||||
);
|
||||
const joinsRaw = Array.isArray(joinsDoc?.users_roles_user_roles)
|
||||
? joinsDoc.users_roles_user_roles
|
||||
: null;
|
||||
if (!joinsRaw) {
|
||||
throw new Error(
|
||||
`Invalid JSON structure for users_roles_user_roles: ${path.basename(fileUsersRoles)}`,
|
||||
);
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
for (const row of joinsRaw) {
|
||||
const usersId = parseNullableString(row.usersId);
|
||||
const userRolesId = parseNullableString(row.userRolesId);
|
||||
if (!usersId || !userRolesId) {
|
||||
throw new Error(
|
||||
`Invalid join row (missing usersId/userRolesId) in ${path.basename(fileUsersRoles)}`,
|
||||
);
|
||||
}
|
||||
if (!isUuid(usersId) || !isUuid(userRolesId)) {
|
||||
throw new Error(
|
||||
`Invalid join row ids (must be uuid) usersId=${usersId} userRolesId=${userRolesId} in ${path.basename(fileUsersRoles)}`,
|
||||
);
|
||||
}
|
||||
if (!joinsByUserId[usersId]) joinsByUserId[usersId] = [];
|
||||
joinsByUserId[usersId].push(userRolesId);
|
||||
processed++;
|
||||
}
|
||||
joinsTotal += processed;
|
||||
log.info("Loaded join file", {
|
||||
file: path.basename(fileUsersRoles),
|
||||
rows: processed,
|
||||
});
|
||||
}
|
||||
|
||||
for (const userId of Object.keys(joinsByUserId)) {
|
||||
if (!isUuid(userId)) {
|
||||
throw new Error(`Invalid user id in join map (not uuid): ${userId}`);
|
||||
}
|
||||
const user =
|
||||
userById[userId] ??
|
||||
(await userRepo.findOne({
|
||||
relations: { roles: true } as any,
|
||||
where: { id: userId } as any,
|
||||
}));
|
||||
|
||||
if (!user) continue;
|
||||
|
||||
if (!user.roles) user.roles = [];
|
||||
|
||||
for (const roleId of joinsByUserId[userId]) {
|
||||
const role =
|
||||
roleById[roleId] ??
|
||||
(await userRoleRepo.findOne({
|
||||
relations: { application: true } as any,
|
||||
where: { id: roleId } as any,
|
||||
}));
|
||||
|
||||
if (!role) continue;
|
||||
|
||||
if (!user.roles.find((r) => r.id === role.id)) {
|
||||
user.roles.push(role);
|
||||
}
|
||||
}
|
||||
|
||||
await userRepo.save(user);
|
||||
}
|
||||
|
||||
log.info("Seed auth data summary", {
|
||||
applications_rows: applicationsTotal,
|
||||
menus_rows: menusTotal,
|
||||
user_roles_rows: rolesTotal,
|
||||
users_rows: usersTotal,
|
||||
join_rows: joinsTotal,
|
||||
files_processed: allJsonFiles.length,
|
||||
});
|
||||
|
||||
log.info("✅ Seed auth data completed");
|
||||
process.exit(0);
|
||||
} catch (error) {
|
||||
log.error("Fatal error:", error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
main();
|
||||
Reference in New Issue
Block a user