Compare commits
15 Commits
5c2d79c125
...
0054c8f7d4
| Author | SHA1 | Date | |
|---|---|---|---|
| 0054c8f7d4 | |||
| 80567d2dd9 | |||
| d6942dd982 | |||
| 155b7d92aa | |||
| 6158f254b7 | |||
| 58975ca117 | |||
| 78dc597477 | |||
| 90d0760352 | |||
| c386c5ea8b | |||
| d95b81d303 | |||
| 2130adedb3 | |||
| f69a40af3a | |||
| 9c66e6aac6 | |||
| b9724aa89c | |||
| 3c2b10b28c |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -3,6 +3,8 @@ frontend/dist
|
||||
server/dist
|
||||
dist
|
||||
apiDocsLSTV2
|
||||
testFiles
|
||||
|
||||
|
||||
# ---> Node
|
||||
bun.lock
|
||||
@@ -143,3 +145,5 @@ dist
|
||||
|
||||
nssm.exe
|
||||
|
||||
backend-0.1.2-217.zip
|
||||
postgresql-17.2-3-windows-x64.exe
|
||||
|
||||
34
database/migrations/0013_conscious_rhodey.sql
Normal file
34
database/migrations/0013_conscious_rhodey.sql
Normal file
@@ -0,0 +1,34 @@
|
||||
CREATE TABLE "apiHits" (
|
||||
"ip" text,
|
||||
"endpoint" text,
|
||||
"action" text,
|
||||
"lastBody" text,
|
||||
"stats" text,
|
||||
"add_date" timestamp DEFAULT now(),
|
||||
"upd_date" timestamp DEFAULT now()
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE "serverData" (
|
||||
"server_id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL,
|
||||
"sName" text NOT NULL,
|
||||
"serverDNS" text NOT NULL,
|
||||
"plantToken" text NOT NULL,
|
||||
"idAddress" text NOT NULL,
|
||||
"greatPlainsPlantCode" numeric NOT NULL,
|
||||
"streetAddress" text NOT NULL,
|
||||
"cityState" text NOT NULL,
|
||||
"zipcode" numeric,
|
||||
"contactEmail" text,
|
||||
"contactPhone" text,
|
||||
"customerTiAcc" text,
|
||||
"lstServerPort" numeric DEFAULT '4000',
|
||||
"active" boolean DEFAULT true,
|
||||
"serverLoc" text NOT NULL,
|
||||
"oldVersion" text NOT NULL,
|
||||
"lastUpdated" timestamp DEFAULT now(),
|
||||
"shippingHours" text DEFAULT '[{"early": "06:30", "late": "23:00"}]',
|
||||
"tiPostTime" text DEFAULT '[{"from": "24", "to": "24"}]',
|
||||
"otherSettings" jsonb DEFAULT '[{"specialInstructions":"something for ti","active":false}]'::jsonb NOT NULL
|
||||
);
|
||||
--> statement-breakpoint
|
||||
CREATE UNIQUE INDEX "plantToken" ON "serverData" USING btree ("plantToken");
|
||||
10
database/migrations/0014_illegal_thundra.sql
Normal file
10
database/migrations/0014_illegal_thundra.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
ALTER TABLE "serverData" ALTER COLUMN "serverDNS" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "plantToken" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "idAddress" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "greatPlainsPlantCode" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "streetAddress" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "cityState" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "lstServerPort" DROP DEFAULT;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "serverLoc" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "oldVersion" DROP NOT NULL;--> statement-breakpoint
|
||||
ALTER TABLE "serverData" ALTER COLUMN "otherSettings" DROP NOT NULL;
|
||||
899
database/migrations/meta/0013_snapshot.json
Normal file
899
database/migrations/meta/0013_snapshot.json
Normal file
@@ -0,0 +1,899 @@
|
||||
{
|
||||
"id": "ffa912bc-dc39-4a3a-a23b-75bd2293fe74",
|
||||
"prevId": "756faedf-1bcb-43eb-b122-93287c80122e",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
"public.apiHits": {
|
||||
"name": "apiHits",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"ip": {
|
||||
"name": "ip",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"endpoint": {
|
||||
"name": "endpoint",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"action": {
|
||||
"name": "action",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"lastBody": {
|
||||
"name": "lastBody",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"stats": {
|
||||
"name": "stats",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"add_date": {
|
||||
"name": "add_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.eom": {
|
||||
"name": "eom",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"eomMonth": {
|
||||
"name": "eomMonth",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"article": {
|
||||
"name": "article",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"articleDescription": {
|
||||
"name": "articleDescription",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.logs": {
|
||||
"name": "logs",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"log_id": {
|
||||
"name": "log_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"level": {
|
||||
"name": "level",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'LST_Serivce'"
|
||||
},
|
||||
"service": {
|
||||
"name": "service",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'system'"
|
||||
},
|
||||
"message": {
|
||||
"name": "message",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.modules": {
|
||||
"name": "modules",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"module_id": {
|
||||
"name": "module_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"roles": {
|
||||
"name": "roles",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'[\"view\",\"systemAdmin\"]'::jsonb"
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"module_name": {
|
||||
"name": "module_name",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.ocmeData": {
|
||||
"name": "ocmeData",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"ocme_id": {
|
||||
"name": "ocme_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"sscc": {
|
||||
"name": "sscc",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"runningNr": {
|
||||
"name": "runningNr",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"completed": {
|
||||
"name": "completed",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"lineNum": {
|
||||
"name": "lineNum",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"pickedUp": {
|
||||
"name": "pickedUp",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"areaFrom": {
|
||||
"name": "areaFrom",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.roles": {
|
||||
"name": "roles",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"role_id": {
|
||||
"name": "role_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"role_name": {
|
||||
"name": "role_name",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.serverData": {
|
||||
"name": "serverData",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"server_id": {
|
||||
"name": "server_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"sName": {
|
||||
"name": "sName",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"serverDNS": {
|
||||
"name": "serverDNS",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"plantToken": {
|
||||
"name": "plantToken",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"idAddress": {
|
||||
"name": "idAddress",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"greatPlainsPlantCode": {
|
||||
"name": "greatPlainsPlantCode",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"streetAddress": {
|
||||
"name": "streetAddress",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"cityState": {
|
||||
"name": "cityState",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"zipcode": {
|
||||
"name": "zipcode",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"contactEmail": {
|
||||
"name": "contactEmail",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"contactPhone": {
|
||||
"name": "contactPhone",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"customerTiAcc": {
|
||||
"name": "customerTiAcc",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"lstServerPort": {
|
||||
"name": "lstServerPort",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'4000'"
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": true
|
||||
},
|
||||
"serverLoc": {
|
||||
"name": "serverLoc",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"oldVersion": {
|
||||
"name": "oldVersion",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"lastUpdated": {
|
||||
"name": "lastUpdated",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"shippingHours": {
|
||||
"name": "shippingHours",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'[{\"early\": \"06:30\", \"late\": \"23:00\"}]'"
|
||||
},
|
||||
"tiPostTime": {
|
||||
"name": "tiPostTime",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'[{\"from\": \"24\", \"to\": \"24\"}]'"
|
||||
},
|
||||
"otherSettings": {
|
||||
"name": "otherSettings",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'[{\"specialInstructions\":\"something for ti\",\"active\":false}]'::jsonb"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"plantToken": {
|
||||
"name": "plantToken",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "plantToken",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.settings": {
|
||||
"name": "settings",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"role_id": {
|
||||
"name": "role_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"value": {
|
||||
"name": "value",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"moduleName": {
|
||||
"name": "moduleName",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"roles": {
|
||||
"name": "roles",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'[\"systemAdmin\"]'::jsonb"
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
"name": "name",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.userRoles": {
|
||||
"name": "userRoles",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"role_id": {
|
||||
"name": "role_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"module_id": {
|
||||
"name": "module_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"user_module_unique": {
|
||||
"name": "user_module_unique",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "module_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"userRoles_user_id_users_user_id_fk": {
|
||||
"name": "userRoles_user_id_users_user_id_fk",
|
||||
"tableFrom": "userRoles",
|
||||
"tableTo": "users",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"user_id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"userRoles_role_id_roles_role_id_fk": {
|
||||
"name": "userRoles_role_id_roles_role_id_fk",
|
||||
"tableFrom": "userRoles",
|
||||
"tableTo": "roles",
|
||||
"columnsFrom": [
|
||||
"role_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"role_id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"userRoles_module_id_modules_module_id_fk": {
|
||||
"name": "userRoles_module_id_modules_module_id_fk",
|
||||
"tableFrom": "userRoles",
|
||||
"tableTo": "modules",
|
||||
"columnsFrom": [
|
||||
"module_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"module_id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.users": {
|
||||
"name": "users",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"password": {
|
||||
"name": "password",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"passwordToken": {
|
||||
"name": "passwordToken",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"passwordTokenExpires": {
|
||||
"name": "passwordTokenExpires",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": true
|
||||
},
|
||||
"pingcode": {
|
||||
"name": "pingcode",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'user'"
|
||||
},
|
||||
"lastLogin": {
|
||||
"name": "lastLogin",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"username": {
|
||||
"name": "username",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "username",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"sequences": {},
|
||||
"roles": {},
|
||||
"policies": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
898
database/migrations/meta/0014_snapshot.json
Normal file
898
database/migrations/meta/0014_snapshot.json
Normal file
@@ -0,0 +1,898 @@
|
||||
{
|
||||
"id": "fdf28fe7-3743-4581-bd1f-ab0dd92f5857",
|
||||
"prevId": "ffa912bc-dc39-4a3a-a23b-75bd2293fe74",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
"public.apiHits": {
|
||||
"name": "apiHits",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"ip": {
|
||||
"name": "ip",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"endpoint": {
|
||||
"name": "endpoint",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"action": {
|
||||
"name": "action",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"lastBody": {
|
||||
"name": "lastBody",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"stats": {
|
||||
"name": "stats",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"add_date": {
|
||||
"name": "add_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.eom": {
|
||||
"name": "eom",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"eomMonth": {
|
||||
"name": "eomMonth",
|
||||
"type": "date",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"article": {
|
||||
"name": "article",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"articleDescription": {
|
||||
"name": "articleDescription",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.logs": {
|
||||
"name": "logs",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"log_id": {
|
||||
"name": "log_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"level": {
|
||||
"name": "level",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'LST_Serivce'"
|
||||
},
|
||||
"service": {
|
||||
"name": "service",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'system'"
|
||||
},
|
||||
"message": {
|
||||
"name": "message",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.modules": {
|
||||
"name": "modules",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"module_id": {
|
||||
"name": "module_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"roles": {
|
||||
"name": "roles",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'[\"view\",\"systemAdmin\"]'::jsonb"
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"module_name": {
|
||||
"name": "module_name",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.ocmeData": {
|
||||
"name": "ocmeData",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"ocme_id": {
|
||||
"name": "ocme_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"sscc": {
|
||||
"name": "sscc",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"runningNr": {
|
||||
"name": "runningNr",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"completed": {
|
||||
"name": "completed",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"lineNum": {
|
||||
"name": "lineNum",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"pickedUp": {
|
||||
"name": "pickedUp",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": false
|
||||
},
|
||||
"areaFrom": {
|
||||
"name": "areaFrom",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.roles": {
|
||||
"name": "roles",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"role_id": {
|
||||
"name": "role_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"role_name": {
|
||||
"name": "role_name",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.serverData": {
|
||||
"name": "serverData",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"server_id": {
|
||||
"name": "server_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"sName": {
|
||||
"name": "sName",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"serverDNS": {
|
||||
"name": "serverDNS",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"plantToken": {
|
||||
"name": "plantToken",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"idAddress": {
|
||||
"name": "idAddress",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"greatPlainsPlantCode": {
|
||||
"name": "greatPlainsPlantCode",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"streetAddress": {
|
||||
"name": "streetAddress",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"cityState": {
|
||||
"name": "cityState",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"zipcode": {
|
||||
"name": "zipcode",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"contactEmail": {
|
||||
"name": "contactEmail",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"contactPhone": {
|
||||
"name": "contactPhone",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"customerTiAcc": {
|
||||
"name": "customerTiAcc",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"lstServerPort": {
|
||||
"name": "lstServerPort",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": true
|
||||
},
|
||||
"serverLoc": {
|
||||
"name": "serverLoc",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"oldVersion": {
|
||||
"name": "oldVersion",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"lastUpdated": {
|
||||
"name": "lastUpdated",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"shippingHours": {
|
||||
"name": "shippingHours",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'[{\"early\": \"06:30\", \"late\": \"23:00\"}]'"
|
||||
},
|
||||
"tiPostTime": {
|
||||
"name": "tiPostTime",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'[{\"from\": \"24\", \"to\": \"24\"}]'"
|
||||
},
|
||||
"otherSettings": {
|
||||
"name": "otherSettings",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "'[{\"specialInstructions\":\"something for ti\",\"active\":false}]'::jsonb"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"plantToken": {
|
||||
"name": "plantToken",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "plantToken",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.settings": {
|
||||
"name": "settings",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"role_id": {
|
||||
"name": "role_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"name": {
|
||||
"name": "name",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"value": {
|
||||
"name": "value",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"description": {
|
||||
"name": "description",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"moduleName": {
|
||||
"name": "moduleName",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"roles": {
|
||||
"name": "roles",
|
||||
"type": "jsonb",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'[\"systemAdmin\"]'::jsonb"
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"name": {
|
||||
"name": "name",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "name",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.userRoles": {
|
||||
"name": "userRoles",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"role_id": {
|
||||
"name": "role_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"module_id": {
|
||||
"name": "module_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"user_module_unique": {
|
||||
"name": "user_module_unique",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "user_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
},
|
||||
{
|
||||
"expression": "module_id",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {
|
||||
"userRoles_user_id_users_user_id_fk": {
|
||||
"name": "userRoles_user_id_users_user_id_fk",
|
||||
"tableFrom": "userRoles",
|
||||
"tableTo": "users",
|
||||
"columnsFrom": [
|
||||
"user_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"user_id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"userRoles_role_id_roles_role_id_fk": {
|
||||
"name": "userRoles_role_id_roles_role_id_fk",
|
||||
"tableFrom": "userRoles",
|
||||
"tableTo": "roles",
|
||||
"columnsFrom": [
|
||||
"role_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"role_id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
},
|
||||
"userRoles_module_id_modules_module_id_fk": {
|
||||
"name": "userRoles_module_id_modules_module_id_fk",
|
||||
"tableFrom": "userRoles",
|
||||
"tableTo": "modules",
|
||||
"columnsFrom": [
|
||||
"module_id"
|
||||
],
|
||||
"columnsTo": [
|
||||
"module_id"
|
||||
],
|
||||
"onDelete": "no action",
|
||||
"onUpdate": "no action"
|
||||
}
|
||||
},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
},
|
||||
"public.users": {
|
||||
"name": "users",
|
||||
"schema": "",
|
||||
"columns": {
|
||||
"user_id": {
|
||||
"name": "user_id",
|
||||
"type": "uuid",
|
||||
"primaryKey": true,
|
||||
"notNull": true,
|
||||
"default": "gen_random_uuid()"
|
||||
},
|
||||
"username": {
|
||||
"name": "username",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"email": {
|
||||
"name": "email",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"password": {
|
||||
"name": "password",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true
|
||||
},
|
||||
"passwordToken": {
|
||||
"name": "passwordToken",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"passwordTokenExpires": {
|
||||
"name": "passwordTokenExpires",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"active": {
|
||||
"name": "active",
|
||||
"type": "boolean",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": true
|
||||
},
|
||||
"pingcode": {
|
||||
"name": "pingcode",
|
||||
"type": "numeric",
|
||||
"primaryKey": false,
|
||||
"notNull": false
|
||||
},
|
||||
"role": {
|
||||
"name": "role",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'user'"
|
||||
},
|
||||
"lastLogin": {
|
||||
"name": "lastLogin",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"add_User": {
|
||||
"name": "add_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"add_Date": {
|
||||
"name": "add_Date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
},
|
||||
"upd_User": {
|
||||
"name": "upd_User",
|
||||
"type": "text",
|
||||
"primaryKey": false,
|
||||
"notNull": true,
|
||||
"default": "'LST_System'"
|
||||
},
|
||||
"upd_date": {
|
||||
"name": "upd_date",
|
||||
"type": "timestamp",
|
||||
"primaryKey": false,
|
||||
"notNull": false,
|
||||
"default": "now()"
|
||||
}
|
||||
},
|
||||
"indexes": {
|
||||
"username": {
|
||||
"name": "username",
|
||||
"columns": [
|
||||
{
|
||||
"expression": "username",
|
||||
"isExpression": false,
|
||||
"asc": true,
|
||||
"nulls": "last"
|
||||
}
|
||||
],
|
||||
"isUnique": true,
|
||||
"concurrently": false,
|
||||
"method": "btree",
|
||||
"with": {}
|
||||
}
|
||||
},
|
||||
"foreignKeys": {},
|
||||
"compositePrimaryKeys": {},
|
||||
"uniqueConstraints": {},
|
||||
"policies": {},
|
||||
"checkConstraints": {},
|
||||
"isRLSEnabled": false
|
||||
}
|
||||
},
|
||||
"enums": {},
|
||||
"schemas": {},
|
||||
"sequences": {},
|
||||
"roles": {},
|
||||
"policies": {},
|
||||
"views": {},
|
||||
"_meta": {
|
||||
"columns": {},
|
||||
"schemas": {},
|
||||
"tables": {}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,20 @@
|
||||
"when": 1741366351980,
|
||||
"tag": "0012_mixed_captain_stacy",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 13,
|
||||
"version": "7",
|
||||
"when": 1741890357924,
|
||||
"tag": "0013_conscious_rhodey",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 14,
|
||||
"version": "7",
|
||||
"when": 1741892067501,
|
||||
"tag": "0014_illegal_thundra",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
35
database/schema/serverData.ts
Normal file
35
database/schema/serverData.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import {boolean, date, jsonb, numeric, pgTable, text, timestamp, uniqueIndex, uuid} from "drizzle-orm/pg-core";
|
||||
import {createSelectSchema} from "drizzle-zod";
|
||||
|
||||
export const serverData = pgTable(
|
||||
"serverData",
|
||||
{
|
||||
server_id: uuid("server_id").defaultRandom().primaryKey(),
|
||||
sName: text("sName").notNull(),
|
||||
serverDNS: text("serverDNS"),
|
||||
plantToken: text("plantToken"),
|
||||
idAddress: text("idAddress"),
|
||||
greatPlainsPlantCode: numeric("greatPlainsPlantCode"),
|
||||
streetAddress: text("streetAddress"),
|
||||
cityState: text("cityState"),
|
||||
zipcode: numeric("zipcode"),
|
||||
contactEmail: text("contactEmail"),
|
||||
contactPhone: text("contactPhone"),
|
||||
customerTiAcc: text("customerTiAcc"),
|
||||
lstServerPort: numeric("lstServerPort"),
|
||||
active: boolean("active").default(true),
|
||||
serverLoc: text("serverLoc"),
|
||||
oldVersion: text("oldVersion"),
|
||||
lastUpdated: timestamp("lastUpdated").defaultNow(),
|
||||
shippingHours: text("shippingHours").default('[{"early": "06:30", "late": "23:00"}]'),
|
||||
tiPostTime: text("tiPostTime").default('[{"from": "24", "to": "24"}]'),
|
||||
otherSettings: jsonb("otherSettings").default([{specialInstructions: "something for ti", active: false}]),
|
||||
},
|
||||
|
||||
(table) => [
|
||||
// uniqueIndex('emailUniqueIndex').on(sql`lower(${table.email})`),
|
||||
uniqueIndex("plantToken").on(table.plantToken),
|
||||
]
|
||||
);
|
||||
|
||||
export const selectRolesSchema = createSelectSchema(serverData);
|
||||
@@ -11,7 +11,7 @@
|
||||
"build": "npm run build:server && npm run build:frontend",
|
||||
"build:server": "rimraf dist && tsc --build && xcopy server\\scripts dist\\server\\scripts /E /I /Y",
|
||||
"build:frontend": "cd frontend && npm run build",
|
||||
"start": "npm run start:server",
|
||||
"start": "set NODE_ENV=production && npm run start:server",
|
||||
"start:server": "dotenvx run -f .env -- node dist/server/index.js",
|
||||
"db:generate": "npx drizzle-kit generate",
|
||||
"db:migrate": "npx drizzle-kit push",
|
||||
|
||||
@@ -21,7 +21,7 @@ export const apiHit = async (
|
||||
// Extract IP from request headers or connection info
|
||||
const forwarded = c.req.header("host");
|
||||
|
||||
console.log(forwarded);
|
||||
//console.log(forwarded);
|
||||
// Validate the data
|
||||
const checkData = {
|
||||
ip: forwarded!,
|
||||
|
||||
@@ -17,11 +17,18 @@ import sqlService from "./services/sqlServer/sqlService.js";
|
||||
import logistics from "./services/logistics/logisticsService.js";
|
||||
import {db} from "../database/dbclient.js";
|
||||
import {settings} from "../database/schema/settings.js";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {count, eq} from "drizzle-orm";
|
||||
|
||||
// create the main prodlogin here
|
||||
const username = "lst_user";
|
||||
const password = "Alpla$$Prod";
|
||||
export const lstAuth = btoa(`${username}:${password}`);
|
||||
|
||||
// checking to make sure we have the settings intialized
|
||||
const serverIntialized = await db.select({count: count()}).from(settings);
|
||||
export const installed = serverIntialized[0].count === 0 && process.env.NODE_ENV !== "development" ? false : true;
|
||||
createLog("info", "LST", "server", `Server is installed: ${installed}`);
|
||||
|
||||
// plant token
|
||||
const dbServer = await db.select().from(settings).where(eq(settings.name, "dbServer"));
|
||||
const serverPort = await db.select().from(settings).where(eq(settings.name, "serverPort"));
|
||||
const allowedOrigins = [
|
||||
"http://localhost:3000",
|
||||
"http://localhost:4000",
|
||||
|
||||
130
server/scripts/install.md
Normal file
130
server/scripts/install.md
Normal file
@@ -0,0 +1,130 @@
|
||||
# Install
|
||||
## Files needed to be downloaded before install.
|
||||
### To run the server
|
||||
* [PostgresSQL](https://www.postgresql.org/download/windows/) - current version using is 17
|
||||
* [NodeJS](https://nodejs.org)
|
||||
* [NSSM](https://nssm.cc/)
|
||||
### To manage the server
|
||||
* [VSCODE](https://code.visualstudio.com/)
|
||||
* [Postman](https://www.postman.com/downloads/)
|
||||
|
||||
## Creating directories needed
|
||||
* Create a new folder where we will host the server files.
|
||||
* Copy the nssm.exe into this folder
|
||||
* Copy the build files to the server (only needed for intial install).
|
||||
* This will house all the compiles and minified files needed to start the server up, this includes the frontend.
|
||||
* Save the nssm.exe into this folder as well, this will be used to control the service.
|
||||
|
||||
## Do the intial install
|
||||
### DB instal setup
|
||||
1. Install postgres
|
||||
2. Open pgAdmin
|
||||
3. create a new Database named lst_db
|
||||
|
||||
### Intial server setup
|
||||
1. Open VSCode and navigate to the folder where you extracted the files.
|
||||
2. Click trusted when it pops up.
|
||||
3. Open a terminal window inside vscode.
|
||||
4. Run the install script this will install all dependaceys needed as well as do all the database migrations
|
||||
```bash
|
||||
npm run prodinstall
|
||||
```
|
||||
### Create the .env file
|
||||
In the root of the folder create a new .env file
|
||||
add in the below and change each setting area that says change me to something that suits your needs
|
||||
```env
|
||||
# PORTS
|
||||
# To keep it all simple we will pass VITE to the ports that are used on both sides.
|
||||
VITE_SERVER_PORT=4400
|
||||
|
||||
# logLevel
|
||||
LOG_LEVEL=debug
|
||||
|
||||
# Auth stuff
|
||||
SALTING=12
|
||||
SECRET=CHANGEME
|
||||
JWT_SECRET=CHANGEME
|
||||
JWT_REFRESH_SECRET=CHANGEME
|
||||
|
||||
# Expire info plus refresh change as needed
|
||||
JWT_EXPIRES=60
|
||||
JWT_REFRESH_THRESHOLD=30
|
||||
JWT_ACCESS_EXPIRATION="1h"
|
||||
JWT_REFRESH_EXPIRATION="7d"
|
||||
|
||||
# this code will need to be used when a user needs to have access to everything.
|
||||
SECRETOVERRIDECODE="mVSDCpBdxreIJ979ziI71GRubBc2mqVqvZdfA22CB7smBfqlE9S3rKTE909yCHte"
|
||||
|
||||
# Database url - please change the password if this is all you changed
|
||||
DATABASE_URL="postgresql://postgres:PASSWORD@localhost:5432/lst_db"
|
||||
|
||||
# This is for usday1 restrictions with the lgvs and customer constraints.
|
||||
FIFO=100
|
||||
MAXLOTS=3
|
||||
```
|
||||
|
||||
### Run the start command to get all the basic settings and modules installed
|
||||
1. Run the below
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
This command will start up the server and seed the database.
|
||||
* Settings will be set here.
|
||||
* All modules will be added.
|
||||
|
||||
2. Press CTRL + C to stop the server.
|
||||
3. Reopen postgres and review the settings make the changes to match the server your going to be running in.
|
||||
* Change the server
|
||||
* change the dbServer
|
||||
* change plantToken
|
||||
* then the remaining settings confirm if you need on or want to leave as default.
|
||||
|
||||
### Creating first user.
|
||||
1. Start the server back up.
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
2. Open http://[SERVER]:[PORT]/api/docs or postman and create a user.
|
||||
* Please do not try to manually enter a new user this is due to how the password is hashed, as well as setting systemAdmin for the first user.
|
||||
* Change the server and port to what you changed in the DB.
|
||||
3. Stop the server again with CTRL + C.
|
||||
|
||||
### Running as a serivice.
|
||||
You want to CD into the scripts folder.
|
||||
```bash
|
||||
cd .\dist\server\scripts\
|
||||
```
|
||||
Next use the example command below to get the service up and running.
|
||||
* Options legend
|
||||
* serviceName = not recommended to change to reduce issues with the update process
|
||||
* option = use install for the install, but you can use this script later to stop, start, restart the service.
|
||||
* appPath = where did you extract the server files
|
||||
* description = no need to change this unless you want it to be something else
|
||||
* command = do not change this unless you know what your doing and really need to change this.
|
||||
```powershell
|
||||
.\services.ps1 -serviceName "LSTV2" -option "install" -appPath "E:\LST\lstV2" -description "Logistics Support Tool V2" -command "run start"
|
||||
```
|
||||
|
||||
# Migrating From V1 to V2
|
||||
## User migration
|
||||
1. Open the sqlite db and export to sql the users table
|
||||
2. OPen the sql in notepad++ or your editor of choice and change the query to be similar to below.
|
||||
* we only need to have save the username, role, email, password
|
||||
|
||||
An example new query will look like
|
||||
* Below is how it looks when exported from sqlite
|
||||
```sql
|
||||
INSERT INTO "User" ("id", "username", "email", "role", "password", "passwordToken", "tokenExpire", "active", "pinCode", "lastLogin", "add_user", "add_date", "upd_user", "upd_date") VALUES
|
||||
(1, 'matthes01', 'blake.matthes@alpla.com', 'admin', 'JDJiJDEMUJEdGtL', NULL, NULL, '1', NULL, '1721075647687', 'LST_System', '1721075647687', 'LST_System', '1721075647687');
|
||||
```
|
||||
|
||||
The way we want to put recreate the query to work with the new db
|
||||
* Below example
|
||||
```sql
|
||||
INSERT INTO "users" ("username", "email", "role", "password") VALUES
|
||||
('matthes01','blake.matthes@alpla.com','admin','JDJiJDE1FuNFpkYlk4NGdHUXpEMzlHR1BD'),
|
||||
('leland001','jordan.leland@alpla.com','manager','vekJhN1dIVVVZa3pxR1l0T2hX'),
|
||||
('brandon001','brandon.harry@alpla.com','manager','wdm1RSXJlZnJDYTZP');
|
||||
;
|
||||
```
|
||||
* You could have many users and just add like above with the identical info from the db
|
||||
14
server/scripts/update.ps1
Normal file
14
server/scripts/update.ps1
Normal file
@@ -0,0 +1,14 @@
|
||||
$serverDataFile = "..\services\server\utils\serverData.json"
|
||||
|
||||
|
||||
$jsonContent = Get-Content -Path $serverDataFile -Raw
|
||||
|
||||
# Convert the JSON content to a PowerShell object
|
||||
$jsonObject = $jsonContent | ConvertFrom-Json
|
||||
|
||||
# Access the data in the JSON object
|
||||
$servers = $jsonObject.servers
|
||||
|
||||
|
||||
|
||||
Write-Host $servers
|
||||
@@ -12,7 +12,9 @@ import {areRolesIn} from "./utils/roleCheck.js";
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
// run the role check
|
||||
setTimeout(() => {
|
||||
areRolesIn();
|
||||
}, 5000);
|
||||
|
||||
app.route("auth/login", login);
|
||||
app.route("auth/register", register);
|
||||
|
||||
@@ -4,6 +4,7 @@ import {db} from "../../../../../database/dbclient.js";
|
||||
import {userRoles} from "../../../../../database/schema/userRoles.js";
|
||||
import {modules} from "../../../../../database/schema/modules.js";
|
||||
import {roles} from "../../../../../database/schema/roles.js";
|
||||
import {createLog} from "../../../logger/logger.js";
|
||||
|
||||
export const setSysAdmin = async (user: any, roleName: any): Promise<void> => {
|
||||
// remove all userRoles to prevent errors
|
||||
@@ -25,9 +26,14 @@ export const setSysAdmin = async (user: any, roleName: any): Promise<void> => {
|
||||
module_id: module[i].module_id,
|
||||
role: roleName,
|
||||
});
|
||||
console.log(`${user[0].username} has been granted access to ${module[i].name} with the role ${roleName}`);
|
||||
createLog(
|
||||
"info",
|
||||
user[0].username,
|
||||
"auth",
|
||||
`${user[0].username} has been granted access to ${module[i].name} with the role ${roleName}`
|
||||
);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
createLog("info", "lst", "auth", `Error settings user access: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -35,10 +35,10 @@ export const areRolesIn = async () => {
|
||||
`${JSON.stringify(newRole)}, "Roles were just added due to missing them on server startup"`
|
||||
);
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "auth", "There was an error adding new roles to the db");
|
||||
createLog("error", "lst", "auth", `There was an error adding new roles to the db, ${error}`);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "auth", "There was an error getting or adding new roles");
|
||||
createLog("error", "lst", "auth", `There was an error adding new roles to the db, ${error}`);
|
||||
}
|
||||
};
|
||||
|
||||
30
server/services/ocme/controller/getShipmentData.ts
Normal file
30
server/services/ocme/controller/getShipmentData.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import {addDays, format, subDays} from "date-fns";
|
||||
import {db} from "../../../../database/dbclient.js";
|
||||
import {settings} from "../../../../database/schema/settings.js";
|
||||
import {prodEndpointCreation} from "../../../globalUtils/createUrl.js";
|
||||
import axios from "axios";
|
||||
import {lstAuth} from "../../../index.js";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
|
||||
export const getShipmentData = async () => {
|
||||
let shiptmentInfo: any = [];
|
||||
let url = await prodEndpointCreation("/public/v1.0/Warehousing/GetTrucksAndLoadingPlans");
|
||||
const setting = await db.select().from(settings);
|
||||
const today = new Date(Date.now());
|
||||
const checkDays = parseInt(setting.filter((n) => n.name === "dayCheck")[0].value);
|
||||
|
||||
const postData = {
|
||||
fromDate: `${format(subDays(today, checkDays), "yyyy-MM-dd")}`,
|
||||
toDate: `${format(addDays(today, checkDays), "yyyy-MM-dd")}`,
|
||||
};
|
||||
|
||||
try {
|
||||
const result = await axios.post(url, postData, {headers: {Authorization: `Basic ${lstAuth}`}});
|
||||
shiptmentInfo = result.data;
|
||||
createLog("info", "ocme", "ocme", `Shipment info based on shipping id was just processed`);
|
||||
return {success: true, message: "Shipment data", data: shiptmentInfo};
|
||||
} catch (error) {
|
||||
createLog("error", "ocme", "ocme", `There was an error getting the shipment data: ${error}`);
|
||||
return {success: false, message: "Error in getting shipment data", data: error};
|
||||
}
|
||||
};
|
||||
137
server/services/ocme/controller/getShipmentPallets.ts
Normal file
137
server/services/ocme/controller/getShipmentPallets.ts
Normal file
@@ -0,0 +1,137 @@
|
||||
import axios from "axios";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
import {shipmentPallets} from "../../sqlServer/querys/ocme/shipmentPallets.js";
|
||||
import {getShipmentData} from "./getShipmentData.js";
|
||||
import {query} from "../../sqlServer/prodSqlServer.js";
|
||||
import {db} from "../../../../database/dbclient.js";
|
||||
import {settings} from "../../../../database/schema/settings.js";
|
||||
import {lotRestriction} from "./lotrestriction.js";
|
||||
|
||||
export const getShipmentPallets = async (shipmentID: any) => {
|
||||
let ocmeLanes: any = [];
|
||||
const setting = await db.select().from(settings);
|
||||
// get the current shipments avalible
|
||||
|
||||
let connect;
|
||||
try {
|
||||
let res = await axios.get("http://usday1vms010:3250/api/v1/getlanes");
|
||||
ocmeLanes = res.data.data;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
||||
const shipments = await getShipmentData();
|
||||
|
||||
// filter the shipment so we can get the correct data from it.
|
||||
const filteredShipment = shipments.data.filter((order: any) => order.LoadingOrderId === parseInt(shipmentID));
|
||||
|
||||
// getting the criteria we want to look at.
|
||||
let tmpCheck: any = [];
|
||||
if (filteredShipment.length === 0) {
|
||||
createLog("error", "ocme", "ocme", "Invalid shipment id was provided and cant do anything else.");
|
||||
return {
|
||||
success: false,
|
||||
message: "Invalid shipmentID sent over please try again",
|
||||
};
|
||||
} else {
|
||||
tmpCheck = filteredShipment[0].Remark.split(",")
|
||||
.map((item: any) => item.trim()) // removes accedental spaces if there are any
|
||||
.map((i: any) => i.toLowerCase());
|
||||
}
|
||||
|
||||
// removing the agv out of the array
|
||||
let checks = tmpCheck.filter((i: any) => i !== "agv");
|
||||
|
||||
let shipmentQ = shipmentPallets
|
||||
.replaceAll("[article]", filteredShipment[0].LoadingPlan[0].ArticleVariantId)
|
||||
.replaceAll("[fifo]", setting.filter((n) => n.name === "fifoCheck")[0].value);
|
||||
|
||||
const addressCheck = setting.filter((n) => n.name === "monitorAddress");
|
||||
|
||||
if (parseInt(addressCheck[0].value) === filteredShipment[0].LoadingPlan[0].AddressId) {
|
||||
// if there really ends up being more than 5000 pallets then well we need to fix this later, also an insane issue to have this many that would need to be monitored
|
||||
shipmentQ = shipmentQ.replaceAll("[totalPallets]", "5000");
|
||||
} else {
|
||||
shipmentQ = shipmentQ.replaceAll("[totalPallets]", filteredShipment[0].LoadingPlan[0].PackagingQuantity);
|
||||
}
|
||||
|
||||
// temp situation only getting the lanes we want to look in
|
||||
// Convert laneArray to a comma-separated string with each value quoted
|
||||
let noBlock;
|
||||
if (checks.includes("all")) {
|
||||
noBlock = shipmentQ.replaceAll("and GesperrtAktivSum in (0) ", "--and GesperrtAktivSum in (0) ");
|
||||
} else {
|
||||
noBlock = shipmentQ;
|
||||
}
|
||||
|
||||
// getting the lanes we want to pull the info from if we passed over?
|
||||
let laneString;
|
||||
if (checks.includes("lanes")) {
|
||||
// let lanes = checks.slice(2);
|
||||
let lanes = checks.filter((i: any) => i !== "all");
|
||||
laneString = lanes.map((lane: any) => `'${lane}'`).join(",");
|
||||
// something cool
|
||||
} else {
|
||||
// console.log(ocmeLanes);
|
||||
laneString = ocmeLanes.map((lane: any) => `'${lane}'`).join(",");
|
||||
}
|
||||
|
||||
let shipmentLane = shipmentQ.replaceAll("[lanes]", laneString);
|
||||
|
||||
let shipmentPals = [];
|
||||
//console.log(shipmentLane);
|
||||
try {
|
||||
shipmentPals = await query(shipmentLane, "Get shipmentPals");
|
||||
} catch (err) {
|
||||
createLog("error", "ocme", "ocme", `Error from running the shippment pallets query: ${err}`);
|
||||
return {success: false, message: err, data: []};
|
||||
}
|
||||
|
||||
let filteredPallets = shipmentPals;
|
||||
|
||||
// if we have all or lanes just send whats in the query
|
||||
if (tmpCheck.includes("all") || tmpCheck.includes("lanes")) {
|
||||
return {
|
||||
success: true,
|
||||
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
||||
data: filteredPallets.splice(0, filteredShipment[0].LoadingPlan[0].PackagingQuantity),
|
||||
};
|
||||
}
|
||||
|
||||
// if we have just lanes send whats in the query
|
||||
if (tmpCheck.includes("lanes")) {
|
||||
return {
|
||||
success: true,
|
||||
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
||||
data: filteredPallets,
|
||||
};
|
||||
}
|
||||
|
||||
// will return everything in the fifo range and the total amount requested
|
||||
if (tmpCheck.includes("all")) {
|
||||
return {
|
||||
success: true,
|
||||
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
||||
data: filteredPallets.splice(0, filteredShipment[0].LoadingPlan[0].PackagingQuantity),
|
||||
};
|
||||
}
|
||||
|
||||
// for "what ever case" follow the logic. to check addresses and resitrions
|
||||
if (parseInt(addressCheck[0].value) === filteredShipment[0].LoadingPlan[0].AddressId) {
|
||||
createLog(
|
||||
"info",
|
||||
"ocme",
|
||||
"ocme",
|
||||
"This shipment has restrictions on it and will go throught the lots filtering process"
|
||||
);
|
||||
filteredPallets = await lotRestriction(shipmentPals, filteredShipment[0].LoadingPlan[0].PackagingQuantity);
|
||||
} else {
|
||||
createLog("info", "ocme", "ocme", "This shipment is cleared to send what ever.");
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: `There are a total of ${filteredPallets.length} pallet(s) that are in this shipment.`,
|
||||
data: filteredPallets,
|
||||
};
|
||||
};
|
||||
62
server/services/ocme/controller/lotrestriction.ts
Normal file
62
server/services/ocme/controller/lotrestriction.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
import {db} from "../../../../database/dbclient.js";
|
||||
import {settings} from "../../../../database/schema/settings.js";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
|
||||
export const lotRestriction = async (pallets: any, truckQty: number) => {
|
||||
// get the settings so we have these.
|
||||
const setting = await db.select().from(settings);
|
||||
const maxLots = parseInt(setting.filter((n) => n.name === "maxLotPerTruck")[0].value);
|
||||
// sort by production date so we can get the oldest ones first
|
||||
pallets.sort((a: any, b: any) => new Date(a.productionDate).getTime() - new Date(b.productionDate).getTime());
|
||||
|
||||
// group all pallets by the lot numbers
|
||||
const groupedByLotNum = pallets.reduce((acc: any, item: any) => {
|
||||
if (!acc[item.lotNum]) {
|
||||
acc[item.lotNum] = [];
|
||||
}
|
||||
acc[item.lotNum].push(item);
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// select the oldest lots until we have 3 lots that meet or exceed 22 pallets
|
||||
const selectedLots = [];
|
||||
let totalPallets = 0;
|
||||
|
||||
// Sort lots by the oldest productionDate in each lot
|
||||
const sortedLots = Object.keys(groupedByLotNum).sort((a, b) => {
|
||||
return (
|
||||
new Date(groupedByLotNum[a][0].productionDate).getTime() -
|
||||
new Date(groupedByLotNum[b][0].productionDate).getTime()
|
||||
);
|
||||
});
|
||||
|
||||
for (const lotNum of sortedLots) {
|
||||
// Add the current lot to the selection
|
||||
selectedLots.push(lotNum);
|
||||
totalPallets += groupedByLotNum[lotNum].length;
|
||||
|
||||
// If we have 3 lots, check if the total pallets meet or exceed 22
|
||||
if (selectedLots.length === maxLots) {
|
||||
if (totalPallets >= truckQty) {
|
||||
// We have enough pallets, exit the loop
|
||||
break;
|
||||
} else {
|
||||
// Remove the last added lot and try the next one
|
||||
const removedLot = selectedLots.pop();
|
||||
totalPallets -= groupedByLotNum[removedLot!].length;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// flatten the selected lots into a single array
|
||||
let result = selectedLots.flatMap((lotNum) => groupedByLotNum[lotNum]);
|
||||
|
||||
// trim down to be only the the truck qty
|
||||
if (result.length > truckQty) {
|
||||
result = result.slice(0, truckQty);
|
||||
}
|
||||
|
||||
createLog("info", "ocme", "ocme", `Total pallets: ${result.length}`);
|
||||
createLog("info", "ocme", "ocme", `Unique lotNums:", ${new Set(result.map((pallet) => pallet.lotNum)).size}`);
|
||||
return result;
|
||||
};
|
||||
@@ -1,5 +1,6 @@
|
||||
import {createRoute, OpenAPIHono, z} from "@hono/zod-openapi";
|
||||
import {apiHit} from "../../../globalUtils/apiHits.js";
|
||||
import {getShipmentPallets} from "../controller/getShipmentPallets.js";
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
@@ -72,9 +73,19 @@ app.openapi(
|
||||
const data = await c.req.json();
|
||||
apiHit(c, {endpoint: "api/ocme/getshipmentpallets", lastBody: data});
|
||||
|
||||
const postPallet = {success: true, message: "Something", data: []};
|
||||
if (!data.shipmentID) {
|
||||
return c.json(
|
||||
{success: false, message: "You are missing the shipment id please try again.", data: []},
|
||||
400
|
||||
);
|
||||
}
|
||||
|
||||
return c.json({success: postPallet.success, message: postPallet.message, data: postPallet.data ?? []}, 200);
|
||||
const shiptmentData = await getShipmentPallets(data.shipmentID);
|
||||
|
||||
return c.json(
|
||||
{success: shiptmentData.success, message: shiptmentData.message, data: shiptmentData.data ?? []},
|
||||
200
|
||||
);
|
||||
} catch (error) {
|
||||
return c.json({success: false, message: "There was an error getting the shipment data.", data: error}, 400);
|
||||
}
|
||||
|
||||
@@ -9,10 +9,15 @@ import addSetting from "./route/settings/addSetting.js";
|
||||
import getSettings from "./route/settings/getSettings.js";
|
||||
import updateSetting from "./route/settings/updateSetting.js";
|
||||
import {areSettingsIn} from "./utils/settingsCheck.js";
|
||||
import {serversCheckPoint} from "./utils/serverData.js";
|
||||
|
||||
// making sure all modules are in properly
|
||||
setTimeout(() => {
|
||||
areSettingsIn();
|
||||
areModulesIn();
|
||||
serversCheckPoint();
|
||||
}, 5000);
|
||||
|
||||
const app = new OpenAPIHono();
|
||||
|
||||
const routes = [
|
||||
|
||||
344
server/services/server/utils/serverData.json
Normal file
344
server/services/server/utils/serverData.json
Normal file
@@ -0,0 +1,344 @@
|
||||
{
|
||||
"servers": [
|
||||
{
|
||||
"sName": "test",
|
||||
"serverDNS": "usmcd1vms036",
|
||||
"plantToken": "test3",
|
||||
"idAdress": "10.193.0.56",
|
||||
"greatPlainsPlantCode": "1",
|
||||
"streetAddress": "289 GA-155 S",
|
||||
"cityState": "McDonough, GA",
|
||||
"zipcode": "30253",
|
||||
"contactEmail": "noreply@alpla.com",
|
||||
"contactPhone": "770-914-1407",
|
||||
"customerTiAcc": "ALPLA01INTGROUP",
|
||||
"lstServerPort": "4000",
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Bethlehem",
|
||||
"serverDNS": "usbet1vms006",
|
||||
"plantToken": "usbet1",
|
||||
"idAddress": "10.204.0.26",
|
||||
"greatPlainsPlantCode": "75",
|
||||
"streetAddress": "2120 Spillman Dr",
|
||||
"cityState": "Bethlehem, PA",
|
||||
"zipcode": "18015",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01BETHINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Huston",
|
||||
"serverDNS": "ushou1vms006",
|
||||
"plantToken": "ushou1",
|
||||
"idAddress": "10.195.0.26",
|
||||
"greatPlainsPlantCode": "20",
|
||||
"streetAddress": "5800 Armour Dr",
|
||||
"cityState": "Houston, TX",
|
||||
"zipcode": "77020",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01HOUSINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Bowling Green 1",
|
||||
"serverDNS": "usbow1vms006",
|
||||
"plantToken": "usbow1",
|
||||
"idAddress": "10.25.0.26",
|
||||
"greatPlainsPlantCode": "55",
|
||||
"streetAddress": "215 Technology Way",
|
||||
"cityState": "Bowling Green, KY",
|
||||
"zipcode": "42101",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01BG1INT",
|
||||
"lstServerPort": "4000",
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Iowa ISBM",
|
||||
"serverDNS": "usiow1vms006",
|
||||
"plantToken": "usiow2",
|
||||
"idAddress": "10.75.0.26",
|
||||
"greatPlainsPlantCode": "31",
|
||||
"streetAddress": "2309 Heinz Rd",
|
||||
"cityState": "Iowa CIty, IA",
|
||||
"zipcode": "52240",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01IA2INT",
|
||||
"lstServerPort": "4001",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "D:\\lst\\lst_backend_2",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Kansas City",
|
||||
"serverDNS": "usksc1vms006",
|
||||
"plantToken": "usksc1",
|
||||
"idAddress": "10.42.9.26",
|
||||
"greatPlainsPlantCode": "85",
|
||||
"streetAddress": "1800 E 94th St Suite 300",
|
||||
"cityState": "Kansas City, MO",
|
||||
"zipcode": "64131",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01KCINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Bowling Green 2",
|
||||
"serverDNS": "usbow2vms006",
|
||||
"plantToken": "usbow2",
|
||||
"idAddress": "10.106.0.26",
|
||||
"greatPlainsPlantCode": "56",
|
||||
"streetAddress": "377 Southwood Ct",
|
||||
"cityState": "Bowling Green, KY",
|
||||
"zipcode": "42101",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01BG2INT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "MCDonough",
|
||||
"serverDNS": "usmcd1vms006",
|
||||
"plantToken": "usmcd1",
|
||||
"idAddress": "10.193.0.26",
|
||||
"greatPlainsPlantCode": "10",
|
||||
"streetAddress": "289 GA-155 S",
|
||||
"cityState": "McDonough, GA",
|
||||
"zipcode": "30253",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01MCDINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": true,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Dayton",
|
||||
"serverDNS": "usday1vms006",
|
||||
"plantToken": "usday1",
|
||||
"idAddress": "10.44.0.26",
|
||||
"greatPlainsPlantCode": "80",
|
||||
"streetAddress": "2700 Concorde Dr Suite 200",
|
||||
"cityState": "Vandalia, OH",
|
||||
"zipcode": "45377",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01DAYTONINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Salt Lake City",
|
||||
"serverDNS": "usslc1vms006",
|
||||
"plantToken": "usslc1",
|
||||
"idAddress": "10.202.0.26",
|
||||
"greatPlainsPlantCode": "70",
|
||||
"streetAddress": "4324 Commercial Way Suite A",
|
||||
"cityState": "Salt Lake City, UT",
|
||||
"zipcode": "84104",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01SLCINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Lima",
|
||||
"serverDNS": "uslim1vms006",
|
||||
"plantToken": "uslim1",
|
||||
"idAddress": "10.53.0.26",
|
||||
"greatPlainsPlantCode": "50",
|
||||
"streetAddress": "3320 Fort Shawnee Industrial Dr",
|
||||
"cityState": "Lima, OH",
|
||||
"zipcode": "45806",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01LIMAINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Florence",
|
||||
"serverDNS": "usflo1vms006",
|
||||
"plantToken": "usflo1",
|
||||
"idAddress": "10.203.0.26",
|
||||
"greatPlainsPlantCode": "22",
|
||||
"streetAddress": "7080 New Buffington Rd",
|
||||
"cityState": "Florence, KY",
|
||||
"zipcode": "41042",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01FLORINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Iowa EBM",
|
||||
"serverDNS": "usiow1vms006",
|
||||
"plantToken": "usiow1",
|
||||
"idAddress": "10.75.0.26",
|
||||
"greatPlainsPlantCode": "30",
|
||||
"streetAddress": "2258 Heinz Rd",
|
||||
"cityState": "Iowa CIty, IA",
|
||||
"zipcode": "52240",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01IA1INT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Jefferson city",
|
||||
"serverDNS": "usjci1vms006",
|
||||
"plantToken": "usjci1",
|
||||
"idAddress": "10.167.0.26",
|
||||
"greatPlainsPlantCode": "40",
|
||||
"streetAddress": "2662 Militia Dr",
|
||||
"cityState": "Jefferson City, MO",
|
||||
"zipcode": "65101",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01JCINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "D:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "Sherman",
|
||||
"serverDNS": "usshe1vms006",
|
||||
"plantToken": "usshe1",
|
||||
"idAddress": "10.205.0.26",
|
||||
"greatPlainsPlantCode": "21",
|
||||
"streetAddress": "4000 Howe Dr",
|
||||
"cityState": "Sherman, TX",
|
||||
"zipcode": "75092",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01SHERMANINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
},
|
||||
{
|
||||
"sName": "West Bend",
|
||||
"serverDNS": "usweb1vms006",
|
||||
"plantToken": "usweb1",
|
||||
"idAddress": "10.80.0.26",
|
||||
"greatPlainsPlantCode": "65",
|
||||
"streetAddress": "825 Rail Way",
|
||||
"cityState": "West Bend, WI",
|
||||
"zipcode": "53095",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01WBINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "C:\\Users\\adm_matthes01\\Desktop\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti", "active": false}]
|
||||
},
|
||||
{
|
||||
"sName": "St Peters",
|
||||
"serverDNS": "usstp1vms006",
|
||||
"plantToken": "usstp1",
|
||||
"idAddress": "10.37.0.26",
|
||||
"greatPlainsPlantCode": "45",
|
||||
"streetAddress": "9 Cermak Blvd",
|
||||
"cityState": "St Peters, MO",
|
||||
"zipcode": "63376",
|
||||
"contactEmail": "blake.matthes@alpla.com",
|
||||
"contactPhone": "6366970253",
|
||||
"customerTiAcc": "ALPL01STPINT",
|
||||
"lstServerPort": "4000",
|
||||
"active": false,
|
||||
"serverLoc": "E:\\LST\\lstv2",
|
||||
"oldVersion": "E:\\LST\\lst_backend",
|
||||
"shippingHours": "[{\"early\": \"06:30\", \"late\": \"23:00\"}]",
|
||||
"tiPostTime": "[{\"from\": \"24\", \"to\": \"24\"}]",
|
||||
"otherSettings": [{"specialInstructions": "something for ti"}]
|
||||
}
|
||||
]
|
||||
}
|
||||
51
server/services/server/utils/serverData.ts
Normal file
51
server/services/server/utils/serverData.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
// This will help maintain the server db so when we run an update it will show up here all the time.
|
||||
// kinda bad too but this will help us keep the db identical.
|
||||
|
||||
import {db} from "../../../../database/dbclient.js";
|
||||
import {serverData} from "../../../../database/schema/serverData.js";
|
||||
import {createLog} from "../../logger/logger.js";
|
||||
import fs from "fs";
|
||||
|
||||
export const serversCheckPoint = async () => {
|
||||
let servers: any;
|
||||
fs.readFile("./data.json", "utf8", (err, data) => {
|
||||
if (err) {
|
||||
console.error("Error reading JSON file:", err);
|
||||
return;
|
||||
}
|
||||
servers = JSON.parse(data);
|
||||
});
|
||||
|
||||
// get the roles
|
||||
try {
|
||||
const settingsCheck = await db.select().from(serverData);
|
||||
|
||||
try {
|
||||
for (let i = 0; i < servers.length; i++) {
|
||||
const newRole = await db
|
||||
.insert(serverData)
|
||||
.values(servers[i])
|
||||
.onConflictDoUpdate({
|
||||
target: serverData.plantToken,
|
||||
set: {
|
||||
sName: servers[i].sName,
|
||||
serverDNS: servers[i].serverDNS,
|
||||
active: servers[i].active,
|
||||
contactEmail: servers[i].contactEmail,
|
||||
contactPhone: servers[i].contactPhone,
|
||||
shippingHours: servers[i].shippingHours,
|
||||
customerTiAcc: servers[i].customerTiAcc,
|
||||
tiPostTime: servers[i].tiPostTime,
|
||||
otherSettings: servers[i].otherSettings,
|
||||
},
|
||||
}) // this will only update the ones that are new :D
|
||||
.returning({name: serverData.sName});
|
||||
}
|
||||
createLog("info", "lst", "server", "Servers were just added/updated due to server startup");
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "server", `There was an error adding serverData to the db, ${error}`);
|
||||
}
|
||||
} catch (error) {
|
||||
createLog("error", "lst", "server", `There was an error adding serverData to the db, ${error}`);
|
||||
}
|
||||
};
|
||||
@@ -62,6 +62,24 @@ const newSettings = [
|
||||
description: "How far back do we want to check for fifo default 45, putting 0 will ignore.",
|
||||
moduleName: "ocme",
|
||||
},
|
||||
{
|
||||
name: "dayCheck",
|
||||
value: "3",
|
||||
description: "how many days +/- to check for shipments in alplaprod",
|
||||
moduleName: "ocme",
|
||||
},
|
||||
{
|
||||
name: "maxLotPerTruck",
|
||||
value: "3",
|
||||
description: "How mant lots can we have per truck?",
|
||||
moduleName: "ocme",
|
||||
},
|
||||
{
|
||||
name: "monitorAddress",
|
||||
value: "8",
|
||||
description: "What address is monitored to be limited to the amount of lots that can be added to a truck.",
|
||||
moduleName: "ocme",
|
||||
},
|
||||
];
|
||||
export const areSettingsIn = async () => {
|
||||
// get the roles
|
||||
|
||||
@@ -4,11 +4,32 @@ import {createLog} from "../logger/logger.js";
|
||||
import {db} from "../../../database/dbclient.js";
|
||||
import {settings} from "../../../database/schema/settings.js";
|
||||
import {eq} from "drizzle-orm";
|
||||
import {installed} from "../../index.js";
|
||||
|
||||
let pool: any;
|
||||
let connected: boolean = false;
|
||||
export const initializeProdPool = async () => {
|
||||
if (connected) return {success: false, message: "There is already a connection."};
|
||||
if (!installed) {
|
||||
createLog("info", "lst", "sqlProd", "The server was not installed will reconnect in 5 seconds");
|
||||
setTimeout(() => {
|
||||
initializeProdPool();
|
||||
}, 5 * 1000);
|
||||
|
||||
return {success: false, message: "The server is not installed."};
|
||||
}
|
||||
|
||||
// make sure the server is not set to localhost this will prevent some weird issues later but can be localhost on the dev
|
||||
const serverLoc = await db.select().from(settings).where(eq(settings.name, "dbServer"));
|
||||
if (serverLoc[0].value === "localhost" && process.env.NODE_ENV !== "development") {
|
||||
createLog("error", "lst", "sqlProd", "The server is set to localhost, and you are not in development mode.");
|
||||
return {success: false, message: "The server is set to localhost, and you are not in development mode."};
|
||||
}
|
||||
|
||||
// if you were restarting from the endpoint you get this lovely error
|
||||
if (connected) {
|
||||
createLog("error", "lst", "sqlProd", "There is already a connection.");
|
||||
return {success: false, message: "There is already a connection."};
|
||||
}
|
||||
try {
|
||||
const config = await prodSqlConfig();
|
||||
pool = await sql.connect(config!);
|
||||
@@ -40,6 +61,9 @@ export const closePool = async () => {
|
||||
};
|
||||
|
||||
export async function query(queryToRun: string, name: string) {
|
||||
/**
|
||||
* We no longer need to send over the plant token change as we do it inside the query function.
|
||||
*/
|
||||
const plantToken = await db.select().from(settings).where(eq(settings.name, "plantToken"));
|
||||
const query = queryToRun.replaceAll("test1", plantToken[0].value);
|
||||
try {
|
||||
|
||||
@@ -4,10 +4,12 @@ LagerAbteilungKurzBez as lane,
|
||||
Produktionslos as lotNum,
|
||||
lfdnr as runningNumber,
|
||||
IdAdresse as addressID,
|
||||
BewegungsDatumMax as lastMove, IdArtikelVarianten as article
|
||||
ProduktionsDatumMin as productionDate,
|
||||
IdArtikelVarianten as article
|
||||
from AlplaPROD_test1.dbo.V_LagerPositionenBarcodes (nolock)
|
||||
where IdArtikelVarianten = [article]
|
||||
and LagerAbteilungKurzBez in ([lanes])
|
||||
and IdWarenlager not in (1)
|
||||
and GesperrtAktivSum in (0)
|
||||
order by CASE
|
||||
WHEN BewegungsDatumMax <= DATEADD(DAY, -[fifo], GETDATE()) THEN 0
|
||||
|
||||
@@ -10,7 +10,7 @@ const app = new OpenAPIHono();
|
||||
// intially start the pool up.
|
||||
setTimeout(() => {
|
||||
initializeProdPool();
|
||||
}, 5000);
|
||||
}, 500);
|
||||
|
||||
app.route("/sqlprod/connect", connect);
|
||||
app.route("/sqlprod/close", closeConnection);
|
||||
|
||||
Reference in New Issue
Block a user