@machynx/data-db 1.0.0 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/edge.js +43 -11
- package/client/index-browser.js +39 -7
- package/client/index.d.ts +5459 -1072
- package/client/index.js +43 -11
- package/client/package.json +3 -3
- package/client/schema.prisma +108 -42
- package/index.d.ts +10 -1
- package/index.js +11 -4
- package/package.json +10 -6
- package/prisma/migrations/{20251121171653_init → 20260113113840_init}/migration.sql +136 -56
package/client/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "prisma-client-
|
|
2
|
+
"name": "prisma-client-dc8ca5ca13bedb37e8d4d0350444242b69929018853f9ee7e4753b5342df10b3",
|
|
3
3
|
"main": "index.js",
|
|
4
4
|
"types": "index.d.ts",
|
|
5
5
|
"browser": "default.js",
|
|
@@ -109,10 +109,10 @@
|
|
|
109
109
|
},
|
|
110
110
|
"./*": "./*"
|
|
111
111
|
},
|
|
112
|
-
"version": "7.
|
|
112
|
+
"version": "7.2.0",
|
|
113
113
|
"sideEffects": false,
|
|
114
114
|
"dependencies": {
|
|
115
|
-
"@prisma/client-runtime-utils": "7.
|
|
115
|
+
"@prisma/client-runtime-utils": "7.2.0"
|
|
116
116
|
},
|
|
117
117
|
"imports": {
|
|
118
118
|
"#wasm-compiler-loader": {
|
package/client/schema.prisma
CHANGED
|
@@ -26,6 +26,8 @@ model MachineHourlyAnalytics {
|
|
|
26
26
|
|
|
27
27
|
@@unique([organizationId, machineId, startDateTime], map: "unique_machineHourlyCompound")
|
|
28
28
|
@@index([machineId, startDateTime])
|
|
29
|
+
@@index([organizationId, startDateTime]) // For org-wide queries
|
|
30
|
+
@@index([machineId, startDateTime, endDateTime]) // For range scans
|
|
29
31
|
@@schema("analytics")
|
|
30
32
|
}
|
|
31
33
|
|
|
@@ -240,24 +242,24 @@ model DevicePowerSensorHourlyAnalytics {
|
|
|
240
242
|
// ----------------------------------------------------------------------
|
|
241
243
|
|
|
242
244
|
model AuditLog {
|
|
243
|
-
id
|
|
244
|
-
entityName
|
|
245
|
-
entityId
|
|
246
|
-
action
|
|
247
|
-
userId
|
|
248
|
-
|
|
249
|
-
timestamp
|
|
250
|
-
httpMethod
|
|
251
|
-
route
|
|
252
|
-
statusCode
|
|
253
|
-
ipAddress
|
|
254
|
-
userAgent
|
|
255
|
-
oldValues
|
|
256
|
-
newValues
|
|
245
|
+
id BigInt @id @default(autoincrement()) @db.BigInt
|
|
246
|
+
entityName String
|
|
247
|
+
entityId Int?
|
|
248
|
+
action String
|
|
249
|
+
userId Int? // ID for CoreUser
|
|
250
|
+
organizationId Int? // ID for CoreOrganization
|
|
251
|
+
timestamp DateTime @default(now())
|
|
252
|
+
httpMethod String
|
|
253
|
+
route String
|
|
254
|
+
statusCode Int
|
|
255
|
+
ipAddress String?
|
|
256
|
+
userAgent String?
|
|
257
|
+
oldValues Json?
|
|
258
|
+
newValues Json?
|
|
257
259
|
|
|
258
260
|
@@index([entityName, entityId])
|
|
259
261
|
@@index([userId])
|
|
260
|
-
@@index([
|
|
262
|
+
@@index([organizationId])
|
|
261
263
|
@@schema("audit")
|
|
262
264
|
}
|
|
263
265
|
|
|
@@ -371,11 +373,11 @@ model Device {
|
|
|
371
373
|
// PRODUCTION CRITICAL: The Link to your Global Inventory
|
|
372
374
|
globalDeviceUid String @unique // Immutable ID printed on the sticker (Core DB)
|
|
373
375
|
|
|
374
|
-
deviceUid
|
|
375
|
-
deviceName
|
|
376
|
-
isActive
|
|
377
|
-
|
|
378
|
-
gatewayId
|
|
376
|
+
deviceUid String @unique @default(cuid()) // Local Internal ID
|
|
377
|
+
deviceName String?
|
|
378
|
+
isActive Boolean @default(true)
|
|
379
|
+
organizationId Int
|
|
380
|
+
gatewayId Int?
|
|
379
381
|
|
|
380
382
|
// Hardware
|
|
381
383
|
sensors Sensor[] @relation("DeviceSensors")
|
|
@@ -400,8 +402,11 @@ model Device {
|
|
|
400
402
|
createdAt DateTime @default(now())
|
|
401
403
|
updatedAt DateTime @updatedAt
|
|
402
404
|
|
|
403
|
-
@@index([
|
|
405
|
+
@@index([organizationId])
|
|
404
406
|
@@index([globalDeviceUid])
|
|
407
|
+
@@index([gatewayId])
|
|
408
|
+
@@index([machineId])
|
|
409
|
+
@@index([factoryId])
|
|
405
410
|
@@schema("device")
|
|
406
411
|
}
|
|
407
412
|
|
|
@@ -487,6 +492,9 @@ model MachineDeviceAssignment {
|
|
|
487
492
|
machine Machine @relation("MachineToDeviceAssignments", fields: [machineId], references: [id])
|
|
488
493
|
|
|
489
494
|
@@index([deviceId])
|
|
495
|
+
@@index([machineId])
|
|
496
|
+
@@index([assignedAt])
|
|
497
|
+
@@index([unassignedAt])
|
|
490
498
|
@@schema("device")
|
|
491
499
|
}
|
|
492
500
|
|
|
@@ -507,6 +515,9 @@ model SensorLog {
|
|
|
507
515
|
updatedAt DateTime @default(now())
|
|
508
516
|
|
|
509
517
|
@@unique([sensorId, senseTime])
|
|
518
|
+
@@index([isProcessed])
|
|
519
|
+
@@index([sensorId, isProcessed])
|
|
520
|
+
@@index([senseTime])
|
|
510
521
|
@@schema("device")
|
|
511
522
|
}
|
|
512
523
|
|
|
@@ -523,6 +534,9 @@ model RFIDSensorLog {
|
|
|
523
534
|
createdAt DateTime @default(now())
|
|
524
535
|
updatedAt DateTime @updatedAt
|
|
525
536
|
|
|
537
|
+
@@index([operatorId])
|
|
538
|
+
@@index([rfid])
|
|
539
|
+
@@index([sensorLogId])
|
|
526
540
|
@@schema("device")
|
|
527
541
|
}
|
|
528
542
|
|
|
@@ -621,6 +635,8 @@ model Factory {
|
|
|
621
635
|
requestCategories MaintenanceRequestCategory[] @relation("FactoryMaintenanceRequestCategories")
|
|
622
636
|
hourlyAnalytics FactoryHourlyAnalytics[] @relation("FactoryToHourlyAnalytics")
|
|
623
637
|
|
|
638
|
+
userAccess OrganizationUserFactoryEntityAccess[] @relation("UserToFactory")
|
|
639
|
+
|
|
624
640
|
createdAt DateTime @default(now())
|
|
625
641
|
updatedAt DateTime @updatedAt
|
|
626
642
|
|
|
@@ -645,7 +661,6 @@ model Floor {
|
|
|
645
661
|
devicesDirect Device[] @relation("FloorToDevicesDirect")
|
|
646
662
|
hourlyAnalytics FloorHourlyAnalytics[] @relation("FloorToHourlyAnalytics")
|
|
647
663
|
|
|
648
|
-
// Access Control (FIXED: Added this relation)
|
|
649
664
|
userAccess OrganizationUserFactoryEntityAccess[] @relation("UserToFloors")
|
|
650
665
|
|
|
651
666
|
floorTypeId Int?
|
|
@@ -692,11 +707,12 @@ model FloorSetting {
|
|
|
692
707
|
}
|
|
693
708
|
|
|
694
709
|
model AssemblyLine {
|
|
695
|
-
id
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
710
|
+
id Int @id @default(autoincrement())
|
|
711
|
+
organizationId Int
|
|
712
|
+
code String?
|
|
713
|
+
name String
|
|
714
|
+
description String?
|
|
715
|
+
floorId Int
|
|
700
716
|
|
|
701
717
|
machines Machine[] @relation("LineToMachines")
|
|
702
718
|
sensors Sensor[] @relation("AssemblyLineToSensors")
|
|
@@ -979,14 +995,14 @@ enum MaintenanceLogStatus {
|
|
|
979
995
|
}
|
|
980
996
|
|
|
981
997
|
model MaintenanceLog {
|
|
982
|
-
id
|
|
983
|
-
machineId
|
|
984
|
-
|
|
985
|
-
reportedById
|
|
986
|
-
description
|
|
987
|
-
status
|
|
988
|
-
startTime
|
|
989
|
-
endTime
|
|
998
|
+
id Int @id @default(autoincrement())
|
|
999
|
+
machineId Int
|
|
1000
|
+
organizationId Int
|
|
1001
|
+
reportedById Int?
|
|
1002
|
+
description String?
|
|
1003
|
+
status MaintenanceLogStatus @default(OPEN)
|
|
1004
|
+
startTime DateTime?
|
|
1005
|
+
endTime DateTime?
|
|
990
1006
|
|
|
991
1007
|
machine Machine @relation("MachineMaintenance", fields: [machineId], references: [id])
|
|
992
1008
|
|
|
@@ -1171,6 +1187,10 @@ model OperatorTimeLog {
|
|
|
1171
1187
|
createdAt DateTime @default(now())
|
|
1172
1188
|
updatedAt DateTime @updatedAt
|
|
1173
1189
|
|
|
1190
|
+
@@index([operatorId, checkInAt])
|
|
1191
|
+
@@index([deviceId, checkInAt])
|
|
1192
|
+
@@index([machineId, checkInAt])
|
|
1193
|
+
@@index([checkInAt, checkOutAt])
|
|
1174
1194
|
@@schema("operator")
|
|
1175
1195
|
}
|
|
1176
1196
|
|
|
@@ -1243,6 +1263,7 @@ model Order {
|
|
|
1243
1263
|
@@index([organizationId])
|
|
1244
1264
|
@@index([customerId])
|
|
1245
1265
|
@@index([factoryId])
|
|
1266
|
+
@@index([erpSource, externalId])
|
|
1246
1267
|
@@schema("order")
|
|
1247
1268
|
}
|
|
1248
1269
|
|
|
@@ -1365,17 +1386,62 @@ model ProductionUnitQC {
|
|
|
1365
1386
|
}
|
|
1366
1387
|
|
|
1367
1388
|
model OrganizationUserFactoryEntityAccess {
|
|
1368
|
-
id
|
|
1369
|
-
userId
|
|
1389
|
+
id Int @id @default(autoincrement())
|
|
1390
|
+
userId Int
|
|
1391
|
+
organizationId Int
|
|
1392
|
+
|
|
1393
|
+
factoryId Int?
|
|
1394
|
+
floorId Int?
|
|
1395
|
+
assemblyLineId Int?
|
|
1396
|
+
machineId Int?
|
|
1397
|
+
|
|
1398
|
+
factory Factory? @relation("UserToFactory", fields: [factoryId], references: [id], onDelete: Cascade)
|
|
1399
|
+
floor Floor? @relation("UserToFloors", fields: [floorId], references: [id], onDelete: Cascade)
|
|
1400
|
+
assemblyLine AssemblyLine? @relation("UserToAssemblyLines", fields: [assemblyLineId], references: [id], onDelete: Cascade)
|
|
1401
|
+
machine Machine? @relation("UserToMachines", fields: [machineId], references: [id], onDelete: Cascade)
|
|
1402
|
+
|
|
1370
1403
|
createdAt DateTime @default(now())
|
|
1371
1404
|
updatedAt DateTime @updatedAt
|
|
1372
1405
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1406
|
+
@@unique([userId, factoryId, floorId, assemblyLineId, machineId], name: "unique_user_entity")
|
|
1407
|
+
@@index([userId, organizationId])
|
|
1408
|
+
@@index([factoryId])
|
|
1409
|
+
@@index([floorId])
|
|
1410
|
+
@@index([assemblyLineId])
|
|
1411
|
+
@@index([machineId])
|
|
1412
|
+
@@schema("organization")
|
|
1413
|
+
}
|
|
1377
1414
|
|
|
1378
|
-
|
|
1415
|
+
model MaintenanceSpecialization {
|
|
1416
|
+
id Int @id @default(autoincrement())
|
|
1417
|
+
organizationId Int
|
|
1418
|
+
name String
|
|
1419
|
+
|
|
1420
|
+
@@unique([organizationId, name])
|
|
1421
|
+
@@schema("organization")
|
|
1422
|
+
}
|
|
1423
|
+
|
|
1424
|
+
model OrganizationCustomer {
|
|
1425
|
+
id Int @id @default(autoincrement())
|
|
1426
|
+
organizationId Int
|
|
1427
|
+
name String
|
|
1428
|
+
description String?
|
|
1429
|
+
createdAt DateTime @default(now())
|
|
1430
|
+
updatedAt DateTime @updatedAt
|
|
1431
|
+
|
|
1432
|
+
@@index([organizationId])
|
|
1433
|
+
@@schema("organization")
|
|
1434
|
+
}
|
|
1435
|
+
|
|
1436
|
+
model AssemblyLineType {
|
|
1437
|
+
id Int @id @default(autoincrement())
|
|
1438
|
+
name String
|
|
1439
|
+
organizationId Int
|
|
1440
|
+
createdAt DateTime @default(now())
|
|
1441
|
+
updatedAt DateTime @updatedAt
|
|
1442
|
+
|
|
1443
|
+
@@unique([organizationId, name])
|
|
1444
|
+
@@index([organizationId])
|
|
1379
1445
|
@@schema("organization")
|
|
1380
1446
|
}
|
|
1381
1447
|
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// @machynx/
|
|
1
|
+
// @machynx/data-db/index.d.ts
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* THIS FILE IS ZERO-MAINTENANCE.
|
|
@@ -16,3 +16,12 @@ export { PrismaClient } from "./client";
|
|
|
16
16
|
|
|
17
17
|
// Re-export the global Prisma namespace (for inputs like TaskCreateInput).
|
|
18
18
|
export type { Prisma } from "./client";
|
|
19
|
+
|
|
20
|
+
// Re-export Prisma runtime error classes for convenient import
|
|
21
|
+
export {
|
|
22
|
+
PrismaClientKnownRequestError,
|
|
23
|
+
PrismaClientValidationError,
|
|
24
|
+
PrismaClientInitializationError,
|
|
25
|
+
PrismaClientRustPanicError,
|
|
26
|
+
PrismaClientUnknownRequestError,
|
|
27
|
+
} from "./client/runtime/client";
|
package/index.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
// @machynx/
|
|
1
|
+
// @machynx/data-db/index.js
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports =
|
|
3
|
+
const client = require("./client");
|
|
4
|
+
|
|
5
|
+
module.exports = {
|
|
6
|
+
...client,
|
|
7
|
+
PrismaClientKnownRequestError: client.PrismaClientKnownRequestError,
|
|
8
|
+
PrismaClientValidationError: client.PrismaClientValidationError,
|
|
9
|
+
PrismaClientInitializationError: client.PrismaClientInitializationError,
|
|
10
|
+
PrismaClientRustPanicError: client.PrismaClientRustPanicError,
|
|
11
|
+
PrismaClientUnknownRequestError: client.PrismaClientUnknownRequestError,
|
|
12
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machynx/data-db",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Machynx Data Plane Database - Shared Prisma schema & client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"import": "./index.js",
|
|
10
10
|
"require": "./index.js"
|
|
11
|
+
},
|
|
12
|
+
"./client/runtime/client": {
|
|
13
|
+
"import": "./client/runtime/client.js",
|
|
14
|
+
"require": "./client/runtime/client.js"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"scripts": {
|
|
@@ -17,9 +21,9 @@
|
|
|
17
21
|
"db:push": "prisma db push --skip-generate",
|
|
18
22
|
"db:seed": "ts-node prisma/seed.ts",
|
|
19
23
|
"prisma:studio": "prisma studio",
|
|
20
|
-
"release:patch": "npm version patch -m \"chore: release v%s\" &&
|
|
21
|
-
"release:minor": "npm version minor -m \"chore: release v%s\" &&
|
|
22
|
-
"release:major": "npm version major -m \"chore: release v%s\" &&
|
|
24
|
+
"release:patch": "npm version patch -m \"chore: release v%s\" && npm run release:git",
|
|
25
|
+
"release:minor": "npm version minor -m \"chore: release v%s\" && npm run release:git",
|
|
26
|
+
"release:major": "npm version major -m \"chore: release v%s\" && npm run release:git",
|
|
23
27
|
"release:git": "git push && git push --tags",
|
|
24
28
|
"release:publish": "npm publish --access public"
|
|
25
29
|
},
|
|
@@ -54,8 +58,8 @@
|
|
|
54
58
|
"prisma": "^7.0.0"
|
|
55
59
|
},
|
|
56
60
|
"devDependencies": {
|
|
57
|
-
"@types/node": "^
|
|
58
|
-
"prisma": "^7.
|
|
61
|
+
"@types/node": "^25.0.7",
|
|
62
|
+
"prisma": "^7.2.0",
|
|
59
63
|
"ts-node": "^10.9.2",
|
|
60
64
|
"typescript": "^5.9.3"
|
|
61
65
|
}
|