From 30ffd843c725da79ed035e2d9564f60a6babcda8 Mon Sep 17 00:00:00 2001 From: Blake Matthes Date: Thu, 30 Apr 2026 17:02:21 -0500 Subject: [PATCH] feat(mobile): update notifications and more error handling added --- backend/db/schema/scanlog.schema.ts | 20 + backend/system/serverData.controller.ts | 24 +- backend/system/system.mobileApp.ts | 50 +- backend/utils/returnHelper.utils.ts | 3 +- lstMobile/app.json | 16 +- lstMobile/package-lock.json | 117 ++ lstMobile/package.json | 7 +- lstMobile/plugins/withZebraScanner.js | 29 +- lstMobile/scripts/runBuild.ts | 57 + lstMobile/src/app/(tabs)/_layout.tsx | 9 + lstMobile/src/app/_layout.tsx | 13 +- lstMobile/src/app/index.tsx | 25 +- lstMobile/src/app/setup.tsx | 10 +- lstMobile/src/app/updateScreen.tsx | 44 +- lstMobile/src/components/ProdScanner.tsx | 83 +- lstMobile/src/components/ScannedLabels.tsx | 15 +- lstMobile/src/components/UpdateFooter.tsx | 40 + lstMobile/src/components/ui/separator.tsx | 24 + lstMobile/src/hooks/useScannerStore.ts | 6 +- lstMobile/src/hooks/useServerCheck.ts | 29 + lstMobile/src/lib/tcpScan.ts | 323 ++-- migrations/0041_bright_tempest.sql | 10 + migrations/meta/0041_snapshot.json | 2023 ++++++++++++++++++++ migrations/meta/_journal.json | 7 + 24 files changed, 2784 insertions(+), 200 deletions(-) create mode 100644 backend/db/schema/scanlog.schema.ts create mode 100644 lstMobile/scripts/runBuild.ts create mode 100644 lstMobile/src/components/UpdateFooter.tsx create mode 100644 lstMobile/src/components/ui/separator.tsx create mode 100644 lstMobile/src/hooks/useServerCheck.ts create mode 100644 migrations/0041_bright_tempest.sql create mode 100644 migrations/meta/0041_snapshot.json diff --git a/backend/db/schema/scanlog.schema.ts b/backend/db/schema/scanlog.schema.ts new file mode 100644 index 0000000..c17e0cb --- /dev/null +++ b/backend/db/schema/scanlog.schema.ts @@ -0,0 +1,20 @@ +import { jsonb, pgTable, text, timestamp, uuid } from "drizzle-orm/pg-core"; +import { createInsertSchema, createSelectSchema } from "drizzle-zod"; +import type z from "zod"; + +export const scanLog = pgTable("scan_log", { + id: uuid("id").defaultRandom().primaryKey(), + scannerId: text("scanner_id"), + message: text("message").notNull(), + prompt: text("prompt"), + commandDescription: text("command_description"), + status: text("status"), + lines: jsonb("lines").default([]), + add_Date: timestamp("add_Date").defaultNow(), +}); + +export const scanLogSchema = createSelectSchema(scanLog); +export const newScanLogSchema = createInsertSchema(scanLog); + +export type Printer = z.infer; +export type NewPrinter = z.infer; diff --git a/backend/system/serverData.controller.ts b/backend/system/serverData.controller.ts index 852969c..21b4120 100644 --- a/backend/system/serverData.controller.ts +++ b/backend/system/serverData.controller.ts @@ -56,7 +56,7 @@ const servers: NewServerData[] = [ name: "Dayton", server: "usday1VMS006", plantToken: "usday1", - idAddress: "10.44.0.56", + idAddress: "10.44.0.56", // 3000 opened and working greatPlainsPlantCode: "80", contactEmail: "", contactPhone: "", @@ -140,6 +140,28 @@ const servers: NewServerData[] = [ serverLoc: "D$\\LST_V3", buildNumber: 1, }, + { + name: "Bowling Green 1", + server: "USBOW1VMS006", + plantToken: "usbow1", + idAddress: "10.25.0.26", // 3000 is open REQ0236527 + greatPlainsPlantCode: "55", + contactEmail: "", + contactPhone: "", + serverLoc: "D$\\LST_V3", + buildNumber: 1, + }, + { + name: "Bethlehem", + server: "USBET1VMS006", + plantToken: "usbet1", + idAddress: "10.25.0.26", + greatPlainsPlantCode: "75", + contactEmail: "", + contactPhone: "", + serverLoc: "D$\\LST_V3", + buildNumber: 1, + }, ]; // notes here for when it comes time to pull in all the server address info [test1_AlplaPROD2.0_Read].[masterData].[Plant] has everything from every server :D diff --git a/backend/system/system.mobileApp.ts b/backend/system/system.mobileApp.ts index 5485cd6..0385b9d 100644 --- a/backend/system/system.mobileApp.ts +++ b/backend/system/system.mobileApp.ts @@ -2,6 +2,9 @@ import fs from "node:fs"; import { Router } from "express"; import path from "path"; import { fileURLToPath } from "url"; +import { db } from "../db/db.controller.js"; +import { scanLog } from "../db/schema/scanlog.schema.js"; +import { apiReturn } from "../utils/returnHelper.utils.js"; const router = Router(); @@ -12,27 +15,23 @@ const downloadDir = path.resolve(__dirname, "../../downloads/mobile"); const projectRoot = path.resolve("./lstMobile"); // adjust as needed const appJsonPath = path.join(projectRoot, "app.json"); -const raw = fs.readFileSync(appJsonPath, "utf-8"); -const config = JSON.parse(raw); - -const exp = config.expo; - const currentApk = { - packageName: exp.android?.package, - versionName: exp.version, - versionCode: exp.android?.versionCode, - minSupportedVersionCode: 1, // keep this custom if needed fileName: "lst-mobile.apk", }; router.get("/version", async (req, res) => { const baseUrl = `${req.protocol}://${req.get("host")}`; + const raw = fs.readFileSync(appJsonPath, "utf-8"); + const config = JSON.parse(raw); + + const exp = config.expo; + res.json({ - packageName: currentApk.packageName, - versionName: currentApk.versionName, - versionCode: currentApk.versionCode, - minSupportedVersionCode: currentApk.minSupportedVersionCode, + packageName: exp.android?.package, + versionName: exp.version, + versionCode: exp.android?.versionCode, + minSupportedVersionCode: exp?.android?.minSupportedVersionCode ?? 0, downloadUrl: `${baseUrl}/lst/api/mobile/apk/latest`, }); }); @@ -66,4 +65,29 @@ router.get("/apk/ehs", (_, res) => { return res.sendFile(apkPath); }); +router.post("/logs", async (req, res) => { + const body = req.body; + const newLog = await db + .insert(scanLog) + .values({ + scannerId: body.data.scannerId, + message: body.data.message, + prompt: body.data.prompt, + commandDescription: body.data.commandDescription, + status: body.data.status, + lines: body.data.lines, + }) + .returning(); + + return apiReturn(res, { + success: true, + level: "info", + module: "mobile", + subModule: "scan logs", + message: `New log from ${body.data.scannerId}`, + data: newLog, + status: 200, + }); +}); + export default router; diff --git a/backend/utils/returnHelper.utils.ts b/backend/utils/returnHelper.utils.ts index 176f294..d1b77e7 100644 --- a/backend/utils/returnHelper.utils.ts +++ b/backend/utils/returnHelper.utils.ts @@ -15,7 +15,8 @@ export interface ReturnHelper { | "purchase" | "tcp" | "logistics" - | "admin"; + | "admin" + | "mobile"; subModule: string; level: "info" | "error" | "debug" | "fatal" | "warn"; diff --git a/lstMobile/app.json b/lstMobile/app.json index 6ffdbfc..d8cadb8 100644 --- a/lstMobile/app.json +++ b/lstMobile/app.json @@ -15,8 +15,8 @@ "foregroundImage": "./assets/adaptive-icon-white.png", "backgroundColor": "#ffffff" }, - "versionCode": 10, - "minSupportedVersionCode": 5, + "versionCode": 21, + "minSupportedVersionCode": 21, "predictiveBackGestureEnabled": false, "package": "net.alpla.lst.mobile" }, @@ -44,11 +44,19 @@ } } ], - "expo-audio" + "expo-audio", + [ + "expo-build-properties", + { + "android": { + "usesCleartextTraffic": true + } + } + ] ], "experiments": { "typedRoutes": true, "reactCompiler": true } } -} +} \ No newline at end of file diff --git a/lstMobile/package-lock.json b/lstMobile/package-lock.json index 11f9e38..2b6102b 100644 --- a/lstMobile/package-lock.json +++ b/lstMobile/package-lock.json @@ -13,6 +13,7 @@ "@react-navigation/elements": "^2.9.10", "@react-navigation/native": "^7.1.33", "@rn-primitives/portal": "^1.4.0", + "@rn-primitives/separator": "^1.4.0", "@rn-primitives/slot": "^1.4.0", "@tanstack/react-query": "^5.99.0", "axios": "^1.15.0", @@ -24,6 +25,7 @@ "expo-application": "~55.0.14", "expo-audio": "~55.0.14", "expo-av": "^16.0.8", + "expo-build-properties": "~55.0.13", "expo-constants": "~55.0.14", "expo-device": "~55.0.15", "expo-font": "~55.0.6", @@ -3974,6 +3976,76 @@ } } }, + "node_modules/@rn-primitives/separator": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@rn-primitives/separator/-/separator-1.4.0.tgz", + "integrity": "sha512-Wv6miGxrqf/yYWIUDbk1l7NHU8ZCYJJkygQ8LbD6AwiVOiMJHF8q+Dfuq/Eoe3T09a+e/ctb1E4dFKfN/K/btw==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-separator": "^1.1.8", + "@rn-primitives/slot": "1.4.0", + "@rn-primitives/types": "1.4.0" + }, + "peerDependencies": { + "react": "*", + "react-native": "*", + "react-native-web": "*" + }, + "peerDependenciesMeta": { + "react-native": { + "optional": true + }, + "react-native-web": { + "optional": true + } + } + }, + "node_modules/@rn-primitives/separator/node_modules/@radix-ui/react-separator": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/@radix-ui/react-separator/-/react-separator-1.1.8.tgz", + "integrity": "sha512-sDvqVY4itsKwwSMEe0jtKgfTh+72Sy3gPmQpjqcQneqQ4PFmr/1I0YA+2/puilhggCe2gJcx5EBAYFkWkdpa5g==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-primitive": "2.1.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, + "node_modules/@rn-primitives/separator/node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@radix-ui/react-primitive/-/react-primitive-2.1.4.tgz", + "integrity": "sha512-9hQc4+GNVtJAIEPEqlYqW5RiYdrr8ea5XQ0ZOnD6fgru+83kqT15mq2OCcbe8KnjRZl5vF3ks69AKz3kh1jrhg==", + "license": "MIT", + "dependencies": { + "@radix-ui/react-slot": "1.2.4" + }, + "peerDependencies": { + "@types/react": "*", + "@types/react-dom": "*", + "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", + "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" + }, + "peerDependenciesMeta": { + "@types/react": { + "optional": true + }, + "@types/react-dom": { + "optional": true + } + } + }, "node_modules/@rn-primitives/slot": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@rn-primitives/slot/-/slot-1.4.0.tgz", @@ -3993,6 +4065,25 @@ } } }, + "node_modules/@rn-primitives/types": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@rn-primitives/types/-/types-1.4.0.tgz", + "integrity": "sha512-U7El2BbYXZG8WZrOIV4y1wpxH8aJA/sKH3SL2tZTL153ENj8aOpZ9QwyUoAU2t+sKVPDejrKjo89HeNuIuwPGQ==", + "license": "MIT", + "peerDependencies": { + "react": "*", + "react-native": "*", + "react-native-web": "*" + }, + "peerDependenciesMeta": { + "react-native": { + "optional": true + }, + "react-native-web": { + "optional": true + } + } + }, "node_modules/@segment/ajv-human-errors": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/@segment/ajv-human-errors/-/ajv-human-errors-2.16.0.tgz", @@ -7639,6 +7730,32 @@ } } }, + "node_modules/expo-build-properties": { + "version": "55.0.13", + "resolved": "https://registry.npmjs.org/expo-build-properties/-/expo-build-properties-55.0.13.tgz", + "integrity": "sha512-UYZhUKyh7YQhbJdkBvo68WUQ7fOtZeSV7F8kfYkjEiN/ADRHG0WfEIiddvGfi9cH/5iwpptv/+Lu5cx6uvfegA==", + "license": "MIT", + "dependencies": { + "@expo/schema-utils": "^55.0.3", + "resolve-from": "^5.0.0", + "semver": "^7.6.0" + }, + "peerDependencies": { + "expo": "*" + } + }, + "node_modules/expo-build-properties/node_modules/semver": { + "version": "7.7.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", + "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/expo-constants": { "version": "55.0.14", "resolved": "https://registry.npmjs.org/expo-constants/-/expo-constants-55.0.14.tgz", diff --git a/lstMobile/package.json b/lstMobile/package.json index bcd735a..aa7bf98 100644 --- a/lstMobile/package.json +++ b/lstMobile/package.json @@ -11,8 +11,11 @@ "lint": "expo lint", "build:apk:clean": "expo prebuild --clean && cd android && gradlew.bat assembleRelease && npm run copy:apk", "build:apk": "expo prebuild && cd android && gradlew.bat assembleRelease && npm run copy:apk", + "build:mobile": "cd scripts && node runBuild.ts", + "build:mobile:bump": "cd scripts && node runBuild.ts --bump", "copy:apk": "cd android && copy /Y app\\build\\outputs\\apk\\release\\app-release.apk ..\\..\\downloads\\mobile\\lst-mobile.apk", - "update": "adb install android/app/build/outputs/apk/release/app-release.apk" + "update": "adb install android/app/build/outputs/apk/release/app-release.apk", + "checklogs": "adb logcat -v time -s ReactNativeJS" }, "dependencies": { "@react-native-async-storage/async-storage": "2.2.0", @@ -20,6 +23,7 @@ "@react-navigation/elements": "^2.9.10", "@react-navigation/native": "^7.1.33", "@rn-primitives/portal": "^1.4.0", + "@rn-primitives/separator": "^1.4.0", "@rn-primitives/slot": "^1.4.0", "@tanstack/react-query": "^5.99.0", "axios": "^1.15.0", @@ -31,6 +35,7 @@ "expo-application": "~55.0.14", "expo-audio": "~55.0.14", "expo-av": "^16.0.8", + "expo-build-properties": "~55.0.13", "expo-constants": "~55.0.14", "expo-device": "~55.0.15", "expo-font": "~55.0.6", diff --git a/lstMobile/plugins/withZebraScanner.js b/lstMobile/plugins/withZebraScanner.js index 77fd8f6..a0ed266 100644 --- a/lstMobile/plugins/withZebraScanner.js +++ b/lstMobile/plugins/withZebraScanner.js @@ -145,30 +145,35 @@ class ZebraScannerModule( Thread.sleep(500) - val barcodeConfig = Bundle().apply { - putString("PLUGIN_NAME", "BARCODE") - putString("RESET_CONFIG", "true") + val barcodeConfig = Bundle().apply { + putString("PLUGIN_NAME", "BARCODE") + putString("RESET_CONFIG", "true") - val props = Bundle().apply { - putString("scanner_input_enabled", "true") + val isLegacyTc8000 = + android.os.Build.MODEL.contains("TC8000", ignoreCase = true) - // Auto-select internal scanner - putString("scanner_selection", "auto") + val props = Bundle().apply { + putString("scanner_input_enabled", "true") + + // Baseline that should be safe on old and new Zebra devices + putString("scanner_selection", "auto") + + if (!isLegacyTc8000) { + // Newer Zebra devices putString("scanner_selection_by_identifier", "AUTO") - // Hardware trigger behavior putString("hardware_trigger_enabled", "true") - putString("trigger_mode", "2") // 2 = HARD trigger + putString("trigger_mode", "2") // HARD trigger - // Disable Zebra's loud initial decode feedback putString("decode_audio_feedback_uri", "") putString("decode_haptic_feedback", "false") putString("decode_led_feedback", "false") } - - putBundle("PARAM_LIST", props) } + putBundle("PARAM_LIST", props) + } + val intentConfig = Bundle().apply { putString("PLUGIN_NAME", "INTENT") putString("RESET_CONFIG", "true") diff --git a/lstMobile/scripts/runBuild.ts b/lstMobile/scripts/runBuild.ts new file mode 100644 index 0000000..22eded1 --- /dev/null +++ b/lstMobile/scripts/runBuild.ts @@ -0,0 +1,57 @@ +import { execSync } from "child_process"; +import fs from "fs"; +import path from "path"; + +const appJsonPath = path.resolve("../app.json"); + +// detect flags +const args = process.argv.slice(2); +const shouldBumpMin = args.includes("--bump"); + +try { + // šŸ“– read file + const raw = fs.readFileSync(appJsonPath, "utf-8"); + const json = JSON.parse(raw); + + const expo = json.expo ?? json; // supports both formats + + if (!expo.android) { + throw new Error("No android config found in app.json"); + } + + // šŸ”¢ current values + const currentVersionCode = expo.android.versionCode ?? 1; + const currentMin = expo.android.minSupportedVersionCode ?? 1; + + // šŸš€ increment version + const newVersionCode = currentVersionCode + 1; + + expo.android.versionCode = newVersionCode; + + if (shouldBumpMin) { + expo.android.minSupportedVersionCode = newVersionCode; + } else { + // keep existing min if not bumping + expo.android.minSupportedVersionCode = currentMin; + } + + // šŸ’¾ write back + fs.writeFileSync(appJsonPath, JSON.stringify(json, null, 2)); + + console.log("āœ… app.json updated:"); + console.log(" versionCode:", newVersionCode); + console.log( + " minSupportedVersionCode:", + expo.android.minSupportedVersionCode, + ); + + // šŸ— run build + console.log("\n🚧 Running build:apk...\n"); + execSync("npm run build:apk", { stdio: "inherit" }); + + console.log("\nšŸŽ‰ Build complete!"); +} catch (err) { + console.error("āŒ Build script failed:"); + console.error(err); + process.exit(1); +} diff --git a/lstMobile/src/app/(tabs)/_layout.tsx b/lstMobile/src/app/(tabs)/_layout.tsx index 9714d84..63d1005 100644 --- a/lstMobile/src/app/(tabs)/_layout.tsx +++ b/lstMobile/src/app/(tabs)/_layout.tsx @@ -15,6 +15,15 @@ export default function TabsLayout() { options={{ title: "Scan", tabBarIcon: ({ color, size }) => , + // header: ({ route }) => { + // const version = serverVersion?.versionCode; + + // const hasUpdate = version && version > build; + + // if (!hasUpdate) return null; // šŸ‘ˆ hides header completely + + // return ; + // }, }} /> - {/* */} + + + diff --git a/lstMobile/src/app/index.tsx b/lstMobile/src/app/index.tsx index 8a53119..2ecead3 100644 --- a/lstMobile/src/app/index.tsx +++ b/lstMobile/src/app/index.tsx @@ -1,18 +1,22 @@ import axios from "axios"; +import Constants from "expo-constants"; import { Redirect, useRouter } from "expo-router"; import { useEffect, useState } from "react"; import { ActivityIndicator, Text, View } from "react-native"; import { useAppStore } from "../hooks/useAppStore"; +import { useServerStore } from "../hooks/useServerCheck"; import { devDelay } from "../lib/devMode"; export default function Index() { const router = useRouter(); const [message, setMessage] = useState(Starting app...); const [ready, setReady] = useState(false); + const setServerVersion = useServerStore((s) => s.setServerVersion); const hasHydrated = useAppStore((s) => s.hasHydrated); const serverPort = useAppStore((s) => s.serverPort); const serverIp = useAppStore((s) => s.serverIp); + const build = Constants.expoConfig?.android?.versionCode ?? 1; const hasValidSetup = useAppStore((s) => s.hasValidSetup); useEffect(() => { @@ -46,6 +50,18 @@ export default function Index() { ); console.log(res.data); + + // if the build version dose not match the latest server version force update + if (res.status === 200) { + setServerVersion(res.data); + } + + // TODO: change the header to show orange and theres a new version + // console.log(build < res.data.minSupportedVersionCode); + // if (build < res.data.minSupportedVersionCode) { + // router.replace("/updateScreen"); + // return; + // } } catch (error) { console.log("Error: ", error); } @@ -79,7 +95,14 @@ export default function Index() { }; startup(); - }, [hasHydrated, hasValidSetup, serverPort, serverIp, router]); + }, [ + hasHydrated, + hasValidSetup, + serverPort, + serverIp, + router, + setServerVersion, + ]); if (ready) { return ; diff --git a/lstMobile/src/app/setup.tsx b/lstMobile/src/app/setup.tsx index 951a877..195d482 100644 --- a/lstMobile/src/app/setup.tsx +++ b/lstMobile/src/app/setup.tsx @@ -3,6 +3,7 @@ import { useRouter } from "expo-router"; import { useState } from "react"; import { Alert, Button, Text, TextInput, View } from "react-native"; import { useAppStore } from "../hooks/useAppStore"; +import { useServerStore } from "../hooks/useServerCheck"; export default function Setup() { const router = useRouter(); @@ -22,6 +23,8 @@ export default function Setup() { const [serverPort, setLocalServerPort] = useState(serverPortFromStore); const [scannerId, setScannerId] = useState(scannerIdFromStore); + const server = useServerStore((s) => s.serverVersion); + const authCheck = () => { if (pin === "6971") { setAuth(true); @@ -151,8 +154,11 @@ export default function Setup() { marginBottom: 12, }} > - - LST Scanner v{version}-{build} + + App v{version}-{build} + + + Server version - v{server?.versionName}-{server?.versionCode} diff --git a/lstMobile/src/app/updateScreen.tsx b/lstMobile/src/app/updateScreen.tsx index a40201f..04cc2f2 100644 --- a/lstMobile/src/app/updateScreen.tsx +++ b/lstMobile/src/app/updateScreen.tsx @@ -1,9 +1,47 @@ +import Constants from "expo-constants"; +import { Link } from "expo-router"; import { Text, View } from "react-native"; +import { + Card, + CardContent, + CardFooter, + CardHeader, +} from "../components/ui/card"; +import { Separator } from "../components/ui/separator"; +import { useServerStore } from "../hooks/useServerCheck"; -export default function blocked() { +export default function Update() { + const version = Constants.expoConfig?.version; + const build = Constants.expoConfig?.android?.versionCode ?? 1; + const server = useServerStore((s) => s.serverVersion); return ( - - Blocked + + + + Update Required + + + Your app is out of date and needs to be updated + + + App version - v{version}-{build} + + + Server version - v{server?.versionName}-{server?.versionCode} + + + + To update the app please head go to a computer and open LST. + + Then head to Scan. + Click update Then follow the instructions on screen + + + {server && server?.versionCode >= build && ( + + Home + + )} ); } diff --git a/lstMobile/src/components/ProdScanner.tsx b/lstMobile/src/components/ProdScanner.tsx index 6330b7f..afdfddd 100644 --- a/lstMobile/src/components/ProdScanner.tsx +++ b/lstMobile/src/components/ProdScanner.tsx @@ -1,3 +1,4 @@ +import axios from "axios"; import { format } from "date-fns-tz"; import { useCallback, useEffect, useState } from "react"; import { Text, View } from "react-native"; @@ -7,6 +8,8 @@ import { scannerFeedback } from "../lib/feedbackScan"; import { sendTcpMessage } from "../lib/tcpScan"; import { type ZebraScanResult, zebraScanner } from "../lib/ZebraScanner"; import { ScannedLabelBox } from "./ScannedLabels"; +import { GlobalFooter } from "./UpdateFooter"; +import { Separator } from "./ui/separator"; const STX = "\x02"; const ETX = "\x03"; @@ -23,12 +26,6 @@ export default function ProdScanner() { const handleScan = useCallback( async (scan: ZebraScanResult) => { let commandToSend = `${STX}${scannerIdFromStore}@${scan.data}${ETX}`; - await scannerFeedback({ - type: "good", - sound: true, - vibrate: true, - led: true, - }); // if we are sscc we need to scan like this .... 98@]C100090087710038712256 if (scan.data.startsWith("000")) { @@ -42,41 +39,54 @@ export default function ProdScanner() { ]); } - // if we change commands we want to zero out the last scanned labels - if (/^[a-zA-Z]/.test(scan.data)) { - setTagScans([]); - } - const scanned = (await sendTcpMessage( commandToSend, serverIp, parseInt(serverPort || "0", 10), )) as any; - // Later this is where your TCP send goes. - // const response = await sendTcpMessage(tcpMessage); - console.log(scanned); - await scannerFeedback({ - type: scanned.data[0]?.type === "error" ? "bad" : "good", - sound: true, - vibrate: true, - led: true, - }); + // send the logs to lst but allow it to time out if it dose not exist just bc. - if (scanned.data[0]?.type !== "error") { + try { + await axios.post( + `http://${serverIp.trim()}:3000/lst/api/mobile/logs`, + scanned, + ); + } catch (error) { + console.log(error); + } + // const response = await sendTcpMessage(tcpMessage); + console.log(scanned.data); + if (scanned.data.status !== "error") { + await scannerFeedback({ + type: "good", + sound: true, + vibrate: true, + led: true, + }); setBGColor("bg-green-500"); setTimeout(() => { setBGColor(null); }, 1 * 1000); } - if (scanned.data[0]?.type === "error") { + if (scanned.data.status === "error") { + await scannerFeedback({ + type: scanned.data.status === "error" ? "bad" : "good", + sound: true, + vibrate: true, + led: true, + }); setBGColor("bg-red-500"); setTimeout(() => { setBGColor(null); }, 1 * 1000); } - setLastScan(scanned.data[0]); - //console.log("TCP response:", something); + setLastScan(scanned.data); + + // if we change commands we want to zero out the last scanned labels + if (/^[a-zA-Z]/.test(scan.data)) { + setTagScans([]); + } }, [scannerIdFromStore, serverIp, serverPort, setLastScan], ); @@ -85,7 +95,7 @@ export default function ProdScanner() { setTagScans([]); }; - console.log(lastScan); + //console.log(lastScan); useEffect(() => { zebraScanner.ensureProfile(); @@ -109,6 +119,7 @@ export default function ProdScanner() { Scanner ID: {parseInt(scannerIdFromStore || "0", 10)} + {!lastScan ? ( Ready to scan @@ -121,18 +132,19 @@ export default function ProdScanner() { alignItems: "center", }} > - - - {lastScan.action} - - - - {lastScan.message} - - + {lastScan.lines + ?.filter((line) => !/^\d+@$/.test(line)) + .map((i) => { + return ( + + {i} + + ); + })} )} + + + + ); } diff --git a/lstMobile/src/components/ScannedLabels.tsx b/lstMobile/src/components/ScannedLabels.tsx index ba0b82c..875f382 100644 --- a/lstMobile/src/components/ScannedLabels.tsx +++ b/lstMobile/src/components/ScannedLabels.tsx @@ -2,6 +2,7 @@ import { ScrollView, View } from "react-native"; import { SafeAreaView } from "react-native-safe-area-context"; import { Button } from "@/components/ui/button"; import { Text } from "@/components/ui/text"; +import { Card } from "./ui/card"; type ScannedLabel = { label: string; @@ -29,27 +30,29 @@ export function ScannedLabelBox({ {labels.length === 0 ? ( - No labels scanned yet + + pending new labels to be scanned... + ) : ( {labels.map((i, index) => ( - {i.label} - {i.date.toString()} - + ))} )} - {labels.length !== 0 && ( + {/* {labels.length !== 0 && ( - )} + )} */} ); } diff --git a/lstMobile/src/components/UpdateFooter.tsx b/lstMobile/src/components/UpdateFooter.tsx new file mode 100644 index 0000000..2f58d80 --- /dev/null +++ b/lstMobile/src/components/UpdateFooter.tsx @@ -0,0 +1,40 @@ +import Constants from "expo-constants"; +import { Link } from "expo-router"; +import { Text, View } from "react-native"; +import { useServerStore } from "../hooks/useServerCheck"; + +export function GlobalFooter() { + const build = Constants.expoConfig?.android?.versionCode ?? 1; + const serverVersion = useServerStore((s) => s.serverVersion); + const hasUpdate = + serverVersion && serverVersion?.minSupportedVersionCode > build; + const shouldUpdate = serverVersion && serverVersion?.versionCode > build; + + if (serverVersion && serverVersion?.versionCode <= build) return; + return ( + + + {hasUpdate && ( + + + + Critical updates pending, once you are completed with your task + please click me for instructions to update + + + + )} + + {!hasUpdate && shouldUpdate && ( + + + + There is an update click me for instructions + + + + )} + + + ); +} diff --git a/lstMobile/src/components/ui/separator.tsx b/lstMobile/src/components/ui/separator.tsx new file mode 100644 index 0000000..78f09fd --- /dev/null +++ b/lstMobile/src/components/ui/separator.tsx @@ -0,0 +1,24 @@ +import { cn } from '@/lib/utils'; +import * as SeparatorPrimitive from '@rn-primitives/separator'; + +function Separator({ + className, + orientation = 'horizontal', + decorative = true, + ...props +}: React.ComponentProps) { + return ( + + ); +} + +export { Separator }; diff --git a/lstMobile/src/hooks/useScannerStore.ts b/lstMobile/src/hooks/useScannerStore.ts index 91f6427..bb8ccef 100644 --- a/lstMobile/src/hooks/useScannerStore.ts +++ b/lstMobile/src/hooks/useScannerStore.ts @@ -1,10 +1,12 @@ import { create } from "zustand"; type LastScan = { - action?: string; - type?: "success" | "error" | string; + terminalId?: string; + screen?: string; prompt?: string; message?: string; + status: "success" | "error" | "location" | "unknown"; + lines?: string[]; timestamp?: number; }; diff --git a/lstMobile/src/hooks/useServerCheck.ts b/lstMobile/src/hooks/useServerCheck.ts new file mode 100644 index 0000000..5766757 --- /dev/null +++ b/lstMobile/src/hooks/useServerCheck.ts @@ -0,0 +1,29 @@ +import { create } from "zustand"; + +type ServerVersion = { + packageName: string; + versionName: string; + versionCode: number; + minSupportedVersionCode: number; + downloadUrl: string; +}; + +type AppState = { + serverVersion: ServerVersion | null; + + setServerVersion: (data: ServerVersion) => void; +}; + +export const useServerStore = create((set, get) => ({ + serverVersion: null, + hasUpdate: () => { + const v = get().serverVersion; + if (!v) return false; + + return v.versionCode < v.minSupportedVersionCode; + }, + setServerVersion: (data) => + set(() => ({ + serverVersion: data, + })), +})); diff --git a/lstMobile/src/lib/tcpScan.ts b/lstMobile/src/lib/tcpScan.ts index 7a07f9b..f542ce7 100644 --- a/lstMobile/src/lib/tcpScan.ts +++ b/lstMobile/src/lib/tcpScan.ts @@ -9,136 +9,217 @@ type TcpResponse = { data: string[]; }; -function parseErpResponse(buffer: Buffer) { - const text = buffer - .toString("utf8") - .replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|#[0-9A-Za-z])/g, "") - .replace(/\x02/g, "") - .replace(/\x03/g, "") - .trim(); +type ScannerEvent = { + scannerId?: string; + commandDescription?: string; + prompt?: string; + message?: string; + status: "success" | "error" | "location" | "unknown" | "scan"; + lines?: string[]; +}; - const noHeader = text.replace(/^\d+@/, ""); - console.log(text); - if (!noHeader.includes("Scan:")) { - return { - raw: text, - type: "error", - message: noHeader.trim(), - lines: [noHeader.trim()], - }; - } +// const ERROR_MESSAGES = [ +// "Invalid barcode", +// "Already scanned", +// "Not on stock", +// "Article tolerance for consolidation not satisfied.", +// ]; - const [actionPart, scanPart = ""] = noHeader.split("Scan:"); - const action = actionPart.trim(); - const scanClean = scanPart.trim(); +const ERROR_KEYWORDS = [ + "invalid barcode", + "already", + "not on stock", + "article tolerance", + "unloaded", + "delivered", + "blocked", +]; - const successMatch = scanClean.match(/^(.*?)\s+V$/); +// function parseErpResponse(buffer: Buffer) { +// const text = buffer +// .toString("utf8") +// .replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~]|#[0-9A-Za-z])/g, "") +// .replace(/\x02/g, "") +// .replace(/\x03/g, "") +// .trim(); - if (successMatch) { - const prompt = successMatch[1].trim(); +// const noHeader = text.replace(/^\d+@/, ""); +// console.log(text); +// if (!noHeader.includes("Scan:")) { +// return { +// raw: text, +// type: "error", +// message: noHeader.trim(), +// lines: [noHeader.trim()], +// }; +// } - return { - raw: text, - type: "success", - action, - prompt, - status: "V", - lines: [action, prompt, "V"], - }; - } +// const [actionPart, scanPart = ""] = noHeader.split("Scan:"); +// const action = actionPart.trim(); +// const scanClean = scanPart.trim(); - // // Handles: "Production lotInvalid barcode" - // const knownErrors = [ - // "Invalid barcode", - // "Invalid machine", - // "Not on stock", - // "Article tolerance for consolidation not satisfied", - // ].sort((a, b) => b.length - a.length); +// const successMatch = scanClean.match(/^(.*?)\s+V$/); - // const foundError = knownErrors.find((err) => scanClean.includes(err)); +// if (successMatch) { +// const prompt = successMatch[1].trim(); - // if (foundError) { - // const prompt = scanClean.replace(foundError, "").trim(); +// return { +// raw: text, +// type: "success", +// action, +// prompt, +// status: "V", +// lines: [action, prompt, "V"], +// }; +// } - // return { - // raw: text, - // type: "error", - // action, - // prompt, - // message: foundError, - // lines: [action, prompt, foundError].filter(Boolean), - // }; - // } +// // // Handles: "Production lotInvalid barcode" +// // const knownErrors = [ +// // "Invalid barcode", +// // "Invalid machine", +// // "Not on stock", +// // "Article tolerance for consolidation not satisfied", +// // ].sort((a, b) => b.length - a.length); - // return { - // raw: text, - // type: "pending", - // action, - // prompt: scanClean, - // lines: [action, scanClean].filter(Boolean), - // }; +// // const foundError = knownErrors.find((err) => scanClean.includes(err)); - const unitMatch = scanClean.match(/^(Unit\s+\d+\/\d+)(.*)$/); +// // if (foundError) { +// // const prompt = scanClean.replace(foundError, "").trim(); - if (unitMatch) { - const prompt = unitMatch[1].trim(); // "Unit 1/4" - const remainder = unitMatch[2].trim(); // everything after +// // return { +// // raw: text, +// // type: "error", +// // action, +// // prompt, +// // message: foundError, +// // lines: [action, prompt, foundError].filter(Boolean), +// // }; +// // } - // SUCCESS - if (remainder === "V") { - return { - raw: text, - type: "success", - action, - prompt, - status: "V", - lines: [action, prompt, "V"], - }; - } +// // return { +// // raw: text, +// // type: "pending", +// // action, +// // prompt: scanClean, +// // lines: [action, scanClean].filter(Boolean), +// // }; - // Known ERP errors - const knownErrors = [ - "Invalid barcode", - "Invalid machine", - "Not on stock", - "Article tolerance for consolidation not satisfied", - ]; +// const unitMatch = scanClean.match(/^(Unit\s+\d+\/\d+)(.*)$/); - const foundError = knownErrors.find((err) => - remainder.toLowerCase().includes(err.toLowerCase()), - ); +// if (unitMatch) { +// const prompt = unitMatch[1].trim(); // "Unit 1/4" +// const remainder = unitMatch[2].trim(); // everything after - if (foundError) { - return { - raw: text, - type: "error", - action, - prompt, - message: foundError, - lines: [action, prompt, foundError], - }; - } +// // SUCCESS +// if (remainder === "V") { +// return { +// raw: text, +// type: "success", +// action, +// prompt, +// status: "V", +// lines: [action, prompt, "V"], +// }; +// } - if (remainder) { - return { - raw: text, - type: "prompt", - action, - prompt, - message: remainder, - lines: [action, prompt, remainder], - }; - } +// // Known ERP errors +// const knownErrors = [ +// "Invalid barcode", +// "Invalid machine", +// "Not on stock", +// "Article tolerance for consolidation not satisfied", +// ]; - return { - raw: text, - type: "pending", - action, - prompt, - lines: [action, prompt], - }; - } -} +// const foundError = knownErrors.find((err) => +// remainder.toLowerCase().includes(err.toLowerCase()), +// ); + +// if (foundError) { +// return { +// raw: text, +// type: "error", +// action, +// prompt, +// message: foundError, +// lines: [action, prompt, foundError], +// }; +// } + +// if (remainder) { +// return { +// raw: text, +// type: "prompt", +// action, +// prompt, +// message: remainder, +// lines: [action, prompt, remainder], +// }; +// } + +// return { +// raw: text, +// type: "pending", +// action, +// prompt, +// lines: [action, prompt], +// }; +// } +// } + +const parseScannerText = (buffer: Buffer) => { + const text = buffer.toString("utf8"); + + return ( + text + // remove cursor movement like ESC[122C, ESC[2;1H, ESC[8q + .replace(/\x1B\[[0-9;]*[A-Za-z]/g, "\n") + + // remove other ANSI sequences like ESC#5 + .replace(/\x1B#[0-9]/g, "\n") + + // normalize carriage returns + .replace(/\r/g, "\n") + + // split into clean lines + .split(/\n+/) + + // clean each line + .map((line) => line.trim()) + + // remove blanks + .filter(Boolean) + ); +}; + +const parseScannerEvent = (lines: string[]): ScannerEvent => { + const scannerId = lines[0]; + const messageLines = lines.slice(1); + const message = messageLines.at(-1); + + const commandDescription = messageLines.find((x) => /^\d+\s+/.test(x)); + const prompt = messageLines.find((x) => /^Scan:/i.test(x)); + + let status: ScannerEvent["status"] = "unknown"; + + const msg = message?.toLowerCase() ?? ""; + + if (msg === "v") status = "success"; + else if (msg && ERROR_KEYWORDS.some((keyword) => msg.includes(keyword))) + status = "error"; + else if (msg?.includes("scan")) status = "success"; + // everything else will just be a location + else if (commandDescription?.includes("Relocate")) status = "location"; + + // TODO: split command description and use the command id next to description for sorting. + return { + scannerId, + commandDescription, + prompt, + message, + status, + lines, + }; +}; /** * Sends a Zebra-style TCP message: @@ -154,7 +235,7 @@ export async function sendTcpMessage( const responses: any = []; const client = TcpSocket.createConnection({ host, port }, () => { - console.log("Sending TCP (visible):", `${command}`); + //console.log("Sending TCP (visible):", `${command}`); client.write(command); }); @@ -170,16 +251,20 @@ export async function sendTcpMessage( }, timeoutMs); client.on("data", (data) => { - //const text = data.toString(); //console.log("TCP received:", text); - const parsed = parseErpResponse(data); + const parsed = parseScannerText(data); + //console.log("scanned:", parsed); - responses.push(parsed); + //responses.push(parsed); + + const cleaned = parseScannerEvent(parsed); + + //console.log(responses); clearTimeout(timeout); resolve({ success: true, message: "TCP Response", - data: responses, + data: cleaned as any, }); }); @@ -190,7 +275,7 @@ export async function sendTcpMessage( resolve({ success: false, message: err.message, - data: responses, + data: ["Error", "Please try again"], }); }); @@ -200,7 +285,7 @@ export async function sendTcpMessage( resolve({ success: true, message: "TCP complete", - data: responses, + data: ["Error", "Please try again"], }); }); }); diff --git a/migrations/0041_bright_tempest.sql b/migrations/0041_bright_tempest.sql new file mode 100644 index 0000000..534ba6c --- /dev/null +++ b/migrations/0041_bright_tempest.sql @@ -0,0 +1,10 @@ +CREATE TABLE "scan_log" ( + "id" uuid PRIMARY KEY DEFAULT gen_random_uuid() NOT NULL, + "scanner_id" text, + "message" text NOT NULL, + "prompt" text, + "command_description" text, + "status" text, + "lines" jsonb DEFAULT '[]'::jsonb, + "add_Date" timestamp DEFAULT now() +); diff --git a/migrations/meta/0041_snapshot.json b/migrations/meta/0041_snapshot.json new file mode 100644 index 0000000..31fcb40 --- /dev/null +++ b/migrations/meta/0041_snapshot.json @@ -0,0 +1,2023 @@ +{ + "id": "cb2f81d0-2d5a-4e1e-8946-df35b9a7888d", + "prevId": "025ef65f-b773-48ca-a8c4-44af505b8388", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.alpla_purchase_history": { + "name": "alpla_purchase_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "apo": { + "name": "apo", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "revision": { + "name": "revision", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "confirmed": { + "name": "confirmed", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status_text": { + "name": "status_text", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "journal_num": { + "name": "journal_num", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "approved_status": { + "name": "approved_status", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'new'" + }, + "position": { + "name": "position", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.job_audit_log": { + "name": "job_audit_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "job_name": { + "name": "job_name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start_at": { + "name": "start_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "finished_at": { + "name": "finished_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "duration_ms": { + "name": "duration_ms", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_message": { + "name": "error_message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "error_stack": { + "name": "error_stack", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "meta_data": { + "name": "meta_data", + "type": "jsonb", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": { + "idx_job_audit_logs_cleanup": { + "name": "idx_job_audit_logs_cleanup", + "columns": [ + { + "expression": "start_at", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.account": { + "name": "account", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "account_id": { + "name": "account_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "provider_id": { + "name": "provider_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "access_token": { + "name": "access_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "refresh_token": { + "name": "refresh_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id_token": { + "name": "id_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "access_token_expires_at": { + "name": "access_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "refresh_token_expires_at": { + "name": "refresh_token_expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "scope": { + "name": "scope", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "password": { + "name": "password", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + } + }, + "indexes": { + "account_userId_idx": { + "name": "account_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "account_user_id_user_id_fk": { + "name": "account_user_id_user_id_fk", + "tableFrom": "account", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.apikey": { + "name": "apikey", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "start": { + "name": "start", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "prefix": { + "name": "prefix", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "key": { + "name": "key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "refill_interval": { + "name": "refill_interval", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "refill_amount": { + "name": "refill_amount", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_refill_at": { + "name": "last_refill_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "enabled": { + "name": "enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "rate_limit_enabled": { + "name": "rate_limit_enabled", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "rate_limit_time_window": { + "name": "rate_limit_time_window", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 86400000 + }, + "rate_limit_max": { + "name": "rate_limit_max", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 10 + }, + "request_count": { + "name": "request_count", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 0 + }, + "remaining": { + "name": "remaining", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "last_request": { + "name": "last_request", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "permissions": { + "name": "permissions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "metadata": { + "name": "metadata", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "apikey_key_idx": { + "name": "apikey_key_idx", + "columns": [ + { + "expression": "key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "apikey_userId_idx": { + "name": "apikey_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "apikey_user_id_user_id_fk": { + "name": "apikey_user_id_user_id_fk", + "tableFrom": "apikey", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.jwks": { + "name": "jwks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "public_key": { + "name": "public_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "private_key": { + "name": "private_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.session": { + "name": "session", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "token": { + "name": "token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "ip_address": { + "name": "ip_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_agent": { + "name": "user_agent", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "impersonated_by": { + "name": "impersonated_by", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "session_userId_idx": { + "name": "session_userId_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "session_user_id_user_id_fk": { + "name": "session_user_id_user_id_fk", + "tableFrom": "session", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "session_token_unique": { + "name": "session_token_unique", + "nullsNotDistinct": false, + "columns": [ + "token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.user": { + "name": "user", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "email_verified": { + "name": "email_verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "image": { + "name": "image", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "role": { + "name": "role", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "banned": { + "name": "banned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "ban_reason": { + "name": "ban_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ban_expires": { + "name": "ban_expires", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "username": { + "name": "username", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "display_username": { + "name": "display_username", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "user_email_unique": { + "name": "user_email_unique", + "nullsNotDistinct": false, + "columns": [ + "email" + ] + }, + "user_username_unique": { + "name": "user_username_unique", + "nullsNotDistinct": false, + "columns": [ + "username" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.verification": { + "name": "verification", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "identifier": { + "name": "identifier", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "value": { + "name": "value", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "expires_at": { + "name": "expires_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "verification_identifier_idx": { + "name": "verification_identifier_idx", + "columns": [ + { + "expression": "identifier", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.deployment_history": { + "name": "deployment_history", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "server_id": { + "name": "server_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "build_number": { + "name": "build_number", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.datamart": { + "name": "datamart", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "query": { + "name": "query", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "version": { + "name": "version", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "options": { + "name": "options", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "public_access": { + "name": "public_access", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "add_date": { + "name": "add_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "add_user": { + "name": "add_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst-system'" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'lst-system'" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "datamart_name_unique": { + "name": "datamart_name_unique", + "nullsNotDistinct": false, + "columns": [ + "name" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.inv_historical_data": { + "name": "inv_historical_data", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "hist_date": { + "name": "hist_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "plant_token": { + "name": "plant_token", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "article": { + "name": "article", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "article_description": { + "name": "article_description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "material_type": { + "name": "material_type", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "total_QTY": { + "name": "total_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "available_QTY": { + "name": "available_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "coa_QTY": { + "name": "coa_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "held_QTY": { + "name": "held_QTY", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "consignment_qty": { + "name": "consignment_qty", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lot_number": { + "name": "lot_number", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location_id": { + "name": "location_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "whse_id": { + "name": "whse_id", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "''" + }, + "whse_name": { + "name": "whse_name", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'missing whseName'" + }, + "upd_user": { + "name": "upd_user", + "type": "text", + "primaryKey": false, + "notNull": false, + "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.logs": { + "name": "logs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "level": { + "name": "level", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "module": { + "name": "module", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subModule": { + "name": "subModule", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "stack": { + "name": "stack", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "checked": { + "name": "checked", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "hostname": { + "name": "hostname", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "interval": { + "name": "interval", + "type": "text", + "primaryKey": false, + "notNull": false, + "default": "'5'" + }, + "options": { + "name": "options", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + } + }, + "indexes": { + "notify_name": { + "name": "notify_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.notification_sub": { + "name": "notification_sub", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "notification_id": { + "name": "notification_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "emails": { + "name": "emails", + "type": "text[]", + "primaryKey": false, + "notNull": false, + "default": "'{}'" + } + }, + "indexes": {}, + "foreignKeys": { + "notification_sub_user_id_user_id_fk": { + "name": "notification_sub_user_id_user_id_fk", + "tableFrom": "notification_sub", + "tableTo": "user", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notification_sub_notification_id_notifications_id_fk": { + "name": "notification_sub_notification_id_notifications_id_fk", + "tableFrom": "notification_sub", + "tableTo": "notifications", + "columnsFrom": [ + "notification_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "notification_sub_user_notification_unique": { + "name": "notification_sub_user_notification_unique", + "nullsNotDistinct": false, + "columns": [ + "user_id", + "notification_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.opendock_apt": { + "name": "opendock_apt", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "release": { + "name": "release", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "open_dock_apt_id": { + "name": "open_dock_apt_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "appointment": { + "name": "appointment", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[]'::jsonb" + }, + "upd_date": { + "name": "upd_date", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "opendock_apt_release_idx": { + "name": "opendock_apt_release_idx", + "columns": [ + { + "expression": "release", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "opendock_apt_opendock_id_idx": { + "name": "opendock_apt_opendock_id_idx", + "columns": [ + { + "expression": "open_dock_apt_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "opendock_apt_release_unique": { + "name": "opendock_apt_release_unique", + "nullsNotDistinct": false, + "columns": [ + "release" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printer_log": { + "name": "printer_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "identity": { + "type": "always", + "name": "printer_log_id_seq", + "schema": "public", + "increment": "1", + "startWith": "1", + "minValue": "1", + "maxValue": "2147483647", + "cache": "1", + "cycle": false + } + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "ip": { + "name": "ip", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printer_sn": { + "name": "printer_sn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "condition": { + "name": "condition", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.printer_data": { + "name": "printer_data", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "humanReadable_id": { + "name": "humanReadable_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ipAddress": { + "name": "ipAddress", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "port": { + "name": "port", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "statusText": { + "name": "statusText", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printer_sn": { + "name": "printer_sn", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_time_printed": { + "name": "last_time_printed", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "assigned": { + "name": "assigned", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + }, + "remark": { + "name": "remark", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "printDelay": { + "name": "printDelay", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 90 + }, + "processes": { + "name": "processes", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "print_delay_override": { + "name": "print_delay_override", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": 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": { + "printer_id": { + "name": "printer_id", + "columns": [ + { + "expression": "humanReadable_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "printer_data_humanReadable_id_unique": { + "name": "printer_data_humanReadable_id_unique", + "nullsNotDistinct": false, + "columns": [ + "humanReadable_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.scan_log": { + "name": "scan_log", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "scanner_id": { + "name": "scanner_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "prompt": { + "name": "prompt", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "command_description": { + "name": "command_description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "lines": { + "name": "lines", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'[]'::jsonb" + }, + "add_Date": { + "name": "add_Date", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.server_data": { + "name": "server_data", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "server": { + "name": "server", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "plant_token": { + "name": "plant_token", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "id_address": { + "name": "id_address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "great_plains_plant_code": { + "name": "great_plains_plant_code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_email": { + "name": "contact_email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "contact_phone": { + "name": "contact_phone", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "server_loc": { + "name": "server_loc", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "build_number": { + "name": "build_number", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "is_upgrading": { + "name": "is_upgrading", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "server_data_plant_token_unique": { + "name": "server_data_plant_token_unique", + "nullsNotDistinct": false, + "columns": [ + "plant_token" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.settings": { + "name": "settings", + "schema": "", + "columns": { + "settings_id": { + "name": "settings_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 + }, + "active": { + "name": "active", + "type": "boolean", + "primaryKey": false, + "notNull": false, + "default": true + }, + "roles": { + "name": "roles", + "type": "jsonb", + "primaryKey": false, + "notNull": true, + "default": "'[\"systemAdmin\"]'::jsonb" + }, + "settingType": { + "name": "settingType", + "type": "setting_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "seed_version": { + "name": "seed_version", + "type": "integer", + "primaryKey": false, + "notNull": false, + "default": 1 + }, + "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.app_stats": { + "name": "app_stats", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true, + "default": "'primary'" + }, + "current_build": { + "name": "current_build", + "type": "integer", + "primaryKey": false, + "notNull": true, + "default": 1 + }, + "last_build_at": { + "name": "last_build_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "last_deploy_at": { + "name": "last_deploy_at", + "type": "timestamp", + "primaryKey": false, + "notNull": false + }, + "building": { + "name": "building", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "updating": { + "name": "updating", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "last_updated": { + "name": "last_updated", + "type": "timestamp", + "primaryKey": false, + "notNull": false, + "default": "now()" + }, + "meta": { + "name": "meta", + "type": "jsonb", + "primaryKey": false, + "notNull": false, + "default": "'{}'::jsonb" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.setting_type": { + "name": "setting_type", + "schema": "public", + "values": [ + "feature", + "system", + "standard" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index 2c49bf7..98e17f8 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -288,6 +288,13 @@ "when": 1776770845947, "tag": "0040_rainy_white_tiger", "breakpoints": true + }, + { + "idx": 41, + "version": "7", + "when": 1777509638464, + "tag": "0041_bright_tempest", + "breakpoints": true } ] } \ No newline at end of file