@devlider001/washlab-backend 1.0.8 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,6 +8,7 @@
8
8
  * @module
9
9
  */
10
10
 
11
+ import type * as actions from "../actions.js";
11
12
  import type * as admin from "../admin.js";
12
13
  import type * as analytics from "../analytics.js";
13
14
  import type * as attendants from "../attendants.js";
@@ -16,14 +17,20 @@ import type * as branches from "../branches.js";
16
17
  import type * as clerk from "../clerk.js";
17
18
  import type * as customers from "../customers.js";
18
19
  import type * as http from "../http.js";
20
+ import type * as lib_attendance from "../lib/attendance.js";
19
21
  import type * as lib_audit from "../lib/audit.js";
20
22
  import type * as lib_auth from "../lib/auth.js";
23
+ import type * as lib_biometricComparison from "../lib/biometricComparison.js";
24
+ import type * as lib_biometricEncryption from "../lib/biometricEncryption.js";
25
+ import type * as lib_passwordHashing from "../lib/passwordHashing.js";
26
+ import type * as lib_tokenHashing from "../lib/tokenHashing.js";
21
27
  import type * as lib_utils from "../lib/utils.js";
22
28
  import type * as loyalty from "../loyalty.js";
23
29
  import type * as notifications from "../notifications.js";
24
30
  import type * as orders from "../orders.js";
25
31
  import type * as payments from "../payments.js";
26
32
  import type * as resources from "../resources.js";
33
+ import type * as stations from "../stations.js";
27
34
  import type * as vouchers from "../vouchers.js";
28
35
 
29
36
  import type {
@@ -33,6 +40,7 @@ import type {
33
40
  } from "convex/server";
34
41
 
35
42
  declare const fullApi: ApiFromModules<{
43
+ actions: typeof actions;
36
44
  admin: typeof admin;
37
45
  analytics: typeof analytics;
38
46
  attendants: typeof attendants;
@@ -41,14 +49,20 @@ declare const fullApi: ApiFromModules<{
41
49
  clerk: typeof clerk;
42
50
  customers: typeof customers;
43
51
  http: typeof http;
52
+ "lib/attendance": typeof lib_attendance;
44
53
  "lib/audit": typeof lib_audit;
45
54
  "lib/auth": typeof lib_auth;
55
+ "lib/biometricComparison": typeof lib_biometricComparison;
56
+ "lib/biometricEncryption": typeof lib_biometricEncryption;
57
+ "lib/passwordHashing": typeof lib_passwordHashing;
58
+ "lib/tokenHashing": typeof lib_tokenHashing;
46
59
  "lib/utils": typeof lib_utils;
47
60
  loyalty: typeof loyalty;
48
61
  notifications: typeof notifications;
49
62
  orders: typeof orders;
50
63
  payments: typeof payments;
51
64
  resources: typeof resources;
65
+ stations: typeof stations;
52
66
  vouchers: typeof vouchers;
53
67
  }>;
54
68
 
@@ -0,0 +1,158 @@
1
+ /**
2
+ * Action Execution Functions
3
+ *
4
+ * Handles attendance-linked action execution with verification.
5
+ * All critical actions must be linked to an active attendance session.
6
+ */
7
+ import { MutationCtx } from "./_generated/server";
8
+ import { Id } from "./_generated/dataModel";
9
+ /**
10
+ * Create action log entry (attendance-linked)
11
+ * This is called after verifying attendance and executing the action
12
+ * Note: This function requires MutationCtx for insert operations
13
+ */
14
+ export declare function createActionLog(ctx: MutationCtx, attendanceId: Id<"attendanceLogs">, attendantId: Id<"attendants">, branchId: Id<"branches">, actionType: string, entityType: string, entityId: string | Id<"orders">, deviceId?: string, metadata?: Record<string, any>, actionStatus?: "pending" | "completed" | "failed" | "cancelled"): Promise<Id<"actionLogs">>;
15
+ /**
16
+ * Execute action with attendance verification
17
+ * This is the main entry point for critical actions
18
+ */
19
+ export declare const executeAction: import("convex/server").RegisteredMutation<"public", {
20
+ branchId?: import("convex/values").GenericId<"branches"> | undefined;
21
+ deviceId?: string | undefined;
22
+ metadata?: string | undefined;
23
+ entityType: string;
24
+ entityId: string;
25
+ actionType: string;
26
+ }, Promise<{
27
+ success: boolean;
28
+ actionLogId: Id<"actionLogs">;
29
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
30
+ timestamp: number;
31
+ }>>;
32
+ /**
33
+ * Get actions by attendance session
34
+ */
35
+ export declare const getActionsByAttendance: import("convex/server").RegisteredQuery<"public", {
36
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
37
+ }, Promise<{
38
+ _id: import("convex/values").GenericId<"actionLogs">;
39
+ _creationTime: number;
40
+ amount?: number | undefined;
41
+ completedAt?: number | undefined;
42
+ entityType?: string | undefined;
43
+ entityId?: import("convex/values").GenericId<"orders"> | undefined;
44
+ errorMessage?: string | undefined;
45
+ actionData?: string | undefined;
46
+ verificationMethod?: "biometric_face" | "biometric_hand" | "pin" | "password" | undefined;
47
+ verificationId?: import("convex/values").GenericId<"biometricVerifications"> | undefined;
48
+ createdAt: number;
49
+ branchId: import("convex/values").GenericId<"branches">;
50
+ attendantId: import("convex/values").GenericId<"attendants">;
51
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
52
+ actionType: string;
53
+ actionStatus: "pending" | "completed" | "cancelled" | "failed";
54
+ }[]>>;
55
+ /**
56
+ * Get actions by attendant (with pagination)
57
+ */
58
+ export declare const getActionsByAttendant: import("convex/server").RegisteredQuery<"public", {
59
+ attendantId: import("convex/values").GenericId<"attendants">;
60
+ paginationOpts: {
61
+ id?: number;
62
+ endCursor?: string | null;
63
+ maximumRowsRead?: number;
64
+ maximumBytesRead?: number;
65
+ numItems: number;
66
+ cursor: string | null;
67
+ };
68
+ }, Promise<import("convex/server").PaginationResult<{
69
+ _id: import("convex/values").GenericId<"actionLogs">;
70
+ _creationTime: number;
71
+ amount?: number | undefined;
72
+ completedAt?: number | undefined;
73
+ entityType?: string | undefined;
74
+ entityId?: import("convex/values").GenericId<"orders"> | undefined;
75
+ errorMessage?: string | undefined;
76
+ actionData?: string | undefined;
77
+ verificationMethod?: "biometric_face" | "biometric_hand" | "pin" | "password" | undefined;
78
+ verificationId?: import("convex/values").GenericId<"biometricVerifications"> | undefined;
79
+ createdAt: number;
80
+ branchId: import("convex/values").GenericId<"branches">;
81
+ attendantId: import("convex/values").GenericId<"attendants">;
82
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
83
+ actionType: string;
84
+ actionStatus: "pending" | "completed" | "cancelled" | "failed";
85
+ }>>>;
86
+ /**
87
+ * Get actions by branch (with pagination)
88
+ */
89
+ export declare const getActionsByBranch: import("convex/server").RegisteredQuery<"public", {
90
+ actionType?: string | undefined;
91
+ startDate?: number | undefined;
92
+ endDate?: number | undefined;
93
+ branchId: import("convex/values").GenericId<"branches">;
94
+ paginationOpts: {
95
+ id?: number;
96
+ endCursor?: string | null;
97
+ maximumRowsRead?: number;
98
+ maximumBytesRead?: number;
99
+ numItems: number;
100
+ cursor: string | null;
101
+ };
102
+ }, Promise<import("convex/server").PaginationResult<{
103
+ _id: import("convex/values").GenericId<"actionLogs">;
104
+ _creationTime: number;
105
+ amount?: number | undefined;
106
+ completedAt?: number | undefined;
107
+ entityType?: string | undefined;
108
+ entityId?: import("convex/values").GenericId<"orders"> | undefined;
109
+ errorMessage?: string | undefined;
110
+ actionData?: string | undefined;
111
+ verificationMethod?: "biometric_face" | "biometric_hand" | "pin" | "password" | undefined;
112
+ verificationId?: import("convex/values").GenericId<"biometricVerifications"> | undefined;
113
+ createdAt: number;
114
+ branchId: import("convex/values").GenericId<"branches">;
115
+ attendantId: import("convex/values").GenericId<"attendants">;
116
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
117
+ actionType: string;
118
+ actionStatus: "pending" | "completed" | "cancelled" | "failed";
119
+ }>>>;
120
+ /**
121
+ * Get actions by entity (e.g., all actions on a specific order)
122
+ * Note: Currently only supports orders as entityType due to schema limitation
123
+ * This query is not optimized for large datasets - consider using pagination or adding an index
124
+ */
125
+ export declare const getActionsByEntity: import("convex/server").RegisteredQuery<"public", {
126
+ entityType: string;
127
+ entityId: import("convex/values").GenericId<"orders">;
128
+ }, Promise<{
129
+ _id: import("convex/values").GenericId<"actionLogs">;
130
+ _creationTime: number;
131
+ amount?: number | undefined;
132
+ completedAt?: number | undefined;
133
+ entityType?: string | undefined;
134
+ entityId?: import("convex/values").GenericId<"orders"> | undefined;
135
+ errorMessage?: string | undefined;
136
+ actionData?: string | undefined;
137
+ verificationMethod?: "biometric_face" | "biometric_hand" | "pin" | "password" | undefined;
138
+ verificationId?: import("convex/values").GenericId<"biometricVerifications"> | undefined;
139
+ createdAt: number;
140
+ branchId: import("convex/values").GenericId<"branches">;
141
+ attendantId: import("convex/values").GenericId<"attendants">;
142
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
143
+ actionType: string;
144
+ actionStatus: "pending" | "completed" | "cancelled" | "failed";
145
+ }[]>>;
146
+ /**
147
+ * Get action statistics for an attendance session
148
+ */
149
+ export declare const getAttendanceActionStats: import("convex/server").RegisteredQuery<"public", {
150
+ attendanceId: import("convex/values").GenericId<"attendanceLogs">;
151
+ }, Promise<{
152
+ totalActions: number;
153
+ actionsByType: Record<string, number>;
154
+ firstAction: number | null;
155
+ lastAction: number | null;
156
+ durationMinutes: number | null;
157
+ }>>;
158
+ //# sourceMappingURL=actions.d.ts.map
package/convex/admin.d.ts CHANGED
@@ -38,18 +38,20 @@ export declare const getBranches: import("convex/server").RegisteredQuery<"publi
38
38
  _id: import("convex/values").GenericId<"branches">;
39
39
  _creationTime: number;
40
40
  email?: string | undefined;
41
+ stationPinHash?: string | undefined;
42
+ requireStationLogin?: boolean | undefined;
41
43
  phoneNumber: string;
42
44
  name: string;
43
45
  createdAt: number;
44
46
  isDeleted: boolean;
45
47
  isActive: boolean;
48
+ createdBy: import("convex/values").GenericId<"admins">;
46
49
  code: string;
47
50
  address: string;
48
51
  city: string;
49
52
  country: string;
50
53
  pricingPerKg: number;
51
54
  deliveryFee: number;
52
- createdBy: import("convex/values").GenericId<"admins">;
53
55
  }[];
54
56
  isDone: boolean;
55
57
  continueCursor: string;
@@ -63,18 +65,20 @@ export declare const getBranchByCode: import("convex/server").RegisteredQuery<"p
63
65
  _id: import("convex/values").GenericId<"branches">;
64
66
  _creationTime: number;
65
67
  email?: string | undefined;
68
+ stationPinHash?: string | undefined;
69
+ requireStationLogin?: boolean | undefined;
66
70
  phoneNumber: string;
67
71
  name: string;
68
72
  createdAt: number;
69
73
  isDeleted: boolean;
70
74
  isActive: boolean;
75
+ createdBy: import("convex/values").GenericId<"admins">;
71
76
  code: string;
72
77
  address: string;
73
78
  city: string;
74
79
  country: string;
75
80
  pricingPerKg: number;
76
81
  deliveryFee: number;
77
- createdBy: import("convex/values").GenericId<"admins">;
78
82
  } | null>>;
79
83
  /**
80
84
  * Get single branch by ID
@@ -85,18 +89,20 @@ export declare const getBranch: import("convex/server").RegisteredQuery<"public"
85
89
  _id: import("convex/values").GenericId<"branches">;
86
90
  _creationTime: number;
87
91
  email?: string | undefined;
92
+ stationPinHash?: string | undefined;
93
+ requireStationLogin?: boolean | undefined;
88
94
  phoneNumber: string;
89
95
  name: string;
90
96
  createdAt: number;
91
97
  isDeleted: boolean;
92
98
  isActive: boolean;
99
+ createdBy: import("convex/values").GenericId<"admins">;
93
100
  code: string;
94
101
  address: string;
95
102
  city: string;
96
103
  country: string;
97
104
  pricingPerKg: number;
98
105
  deliveryFee: number;
99
- createdBy: import("convex/values").GenericId<"admins">;
100
106
  } | null>>;
101
107
  /**
102
108
  * Get all attendants - Paginated
@@ -104,23 +110,44 @@ export declare const getBranch: import("convex/server").RegisteredQuery<"public"
104
110
  */
105
111
  export declare const getAttendants: import("convex/server").RegisteredQuery<"public", {
106
112
  branchId?: import("convex/values").GenericId<"branches"> | undefined;
107
- includeInactive?: boolean | undefined;
108
113
  numItems?: number | undefined;
109
114
  cursor?: string | undefined;
115
+ includeInactive?: boolean | undefined;
110
116
  }, Promise<{
111
117
  page: {
112
118
  _id: import("convex/values").GenericId<"attendants">;
113
119
  _creationTime: number;
120
+ clerkUserId?: string | undefined;
114
121
  lastLoginAt?: number | undefined;
115
- passcode?: string | undefined;
122
+ passcodeHash?: string | undefined;
123
+ authenticationMethods?: ("biometric_face" | "biometric_hand" | "pin" | "password")[] | undefined;
124
+ enrollmentTokenHash?: string | undefined;
125
+ enrollmentTokenExpiresAt?: number | undefined;
126
+ enrolledAt?: number | undefined;
127
+ enrolledBy?: import("convex/values").GenericId<"admins"> | undefined;
128
+ biometricTemplateHash?: string | undefined;
129
+ biometricDataEncrypted?: string | undefined;
130
+ biometricCaptureMetadata?: {
131
+ deviceInfo?: string | undefined;
132
+ captureType: "face" | "hand";
133
+ anglesCaptured: string[];
134
+ captureQuality: number;
135
+ livenessPassed: boolean;
136
+ captureTimestamp: number;
137
+ } | undefined;
138
+ lastVerificationAt?: number | undefined;
139
+ lastVerificationSuccess?: boolean | undefined;
140
+ verificationTimeoutAt?: number | undefined;
116
141
  phoneNumber: string;
117
142
  email: string;
118
143
  name: string;
119
- clerkUserId: string;
120
144
  createdAt: number;
121
145
  isDeleted: boolean;
122
146
  branchId: import("convex/values").GenericId<"branches">;
123
147
  isActive: boolean;
148
+ enrollmentStatus: "active" | "suspended" | "invited" | "enrolling" | "locked";
149
+ consecutiveFailures: number;
150
+ createdBy: import("convex/values").GenericId<"admins">;
124
151
  }[];
125
152
  isDone: boolean;
126
153
  continueCursor: string;
@@ -290,6 +317,8 @@ export declare const deleteCustomer: import("convex/server").RegisteredMutation<
290
317
  */
291
318
  export declare const createBranch: import("convex/server").RegisteredMutation<"public", {
292
319
  email?: string | undefined;
320
+ requireStationLogin?: boolean | undefined;
321
+ stationPin?: string | undefined;
293
322
  phoneNumber: string;
294
323
  name: string;
295
324
  code: string;
@@ -313,6 +342,8 @@ export declare const updateBranch: import("convex/server").RegisteredMutation<"p
313
342
  country?: string | undefined;
314
343
  pricingPerKg?: number | undefined;
315
344
  deliveryFee?: number | undefined;
345
+ requireStationLogin?: boolean | undefined;
346
+ stationPin?: string | undefined;
316
347
  branchId: import("convex/values").GenericId<"branches">;
317
348
  }, Promise<import("convex/values").GenericId<"branches">>>;
318
349
  /**
@@ -349,9 +380,9 @@ export declare const updateAttendant: import("convex/server").RegisteredMutation
349
380
  phoneNumber?: string | undefined;
350
381
  email?: string | undefined;
351
382
  name?: string | undefined;
352
- passcode?: string | undefined;
353
383
  branchId?: import("convex/values").GenericId<"branches"> | undefined;
354
384
  isActive?: boolean | undefined;
385
+ passcode?: string | undefined;
355
386
  attendantId: import("convex/values").GenericId<"attendants">;
356
387
  }, Promise<import("convex/values").GenericId<"attendants">>>;
357
388
  /**
@@ -361,6 +392,70 @@ export declare const assignAttendantToBranch: import("convex/server").Registered
361
392
  branchId: import("convex/values").GenericId<"branches">;
362
393
  attendantId: import("convex/values").GenericId<"attendants">;
363
394
  }, Promise<import("convex/values").GenericId<"attendants">>>;
395
+ /**
396
+ * Change attendant enrollment status (suspend, activate, lock, unlock)
397
+ */
398
+ export declare const changeAttendantStatus: import("convex/server").RegisteredMutation<"public", {
399
+ reason?: string | undefined;
400
+ status: "active" | "suspended" | "invited" | "enrolling" | "locked";
401
+ attendantId: import("convex/values").GenericId<"attendants">;
402
+ }, Promise<{
403
+ attendantId: import("convex/values").GenericId<"attendants">;
404
+ oldStatus: "active" | "suspended" | "invited" | "enrolling" | "locked";
405
+ newStatus: "active" | "suspended" | "invited" | "enrolling" | "locked";
406
+ }>>;
407
+ /**
408
+ * Suspend attendant (convenience function)
409
+ */
410
+ export declare const suspendAttendant: import("convex/server").RegisteredMutation<"public", {
411
+ reason?: string | undefined;
412
+ attendantId: import("convex/values").GenericId<"attendants">;
413
+ }, Promise<{
414
+ attendantId: import("convex/values").GenericId<"attendants">;
415
+ oldStatus: "active" | "invited" | "enrolling" | "locked";
416
+ newStatus: string;
417
+ }>>;
418
+ /**
419
+ * Activate attendant (convenience function - unsuspend/unlock)
420
+ */
421
+ export declare const activateAttendant: import("convex/server").RegisteredMutation<"public", {
422
+ reason?: string | undefined;
423
+ attendantId: import("convex/values").GenericId<"attendants">;
424
+ }, Promise<{
425
+ attendantId: import("convex/values").GenericId<"attendants">;
426
+ oldStatus: "suspended" | "invited" | "enrolling" | "locked";
427
+ newStatus: string;
428
+ }>>;
429
+ /**
430
+ * Lock attendant (convenience function)
431
+ */
432
+ export declare const lockAttendant: import("convex/server").RegisteredMutation<"public", {
433
+ reason?: string | undefined;
434
+ attendantId: import("convex/values").GenericId<"attendants">;
435
+ }, Promise<{
436
+ attendantId: import("convex/values").GenericId<"attendants">;
437
+ oldStatus: "active" | "suspended" | "invited" | "enrolling";
438
+ newStatus: string;
439
+ }>>;
440
+ /**
441
+ * Reset attendant verification failures
442
+ */
443
+ export declare const resetAttendantFailures: import("convex/server").RegisteredMutation<"public", {
444
+ reason?: string | undefined;
445
+ attendantId: import("convex/values").GenericId<"attendants">;
446
+ }, Promise<{
447
+ attendantId: import("convex/values").GenericId<"attendants">;
448
+ }>>;
449
+ /**
450
+ * Revoke all active sessions for an attendant
451
+ */
452
+ export declare const revokeAttendantSessions: import("convex/server").RegisteredMutation<"public", {
453
+ reason?: string | undefined;
454
+ attendantId: import("convex/values").GenericId<"attendants">;
455
+ }, Promise<{
456
+ attendantId: import("convex/values").GenericId<"attendants">;
457
+ sessionsRevoked: number;
458
+ }>>;
364
459
  /**
365
460
  * Delete attendant (soft delete)
366
461
  */
@@ -463,4 +558,50 @@ export declare const getOrderDetails: import("convex/server").RegisteredQuery<"p
463
558
  changedAt: number;
464
559
  }[];
465
560
  } | null>>;
561
+ /**
562
+ * Create attendant enrollment (Admin)
563
+ * Generates enrollment link for attendant to complete biometric setup
564
+ */
565
+ export declare const createAttendantEnrollment: import("convex/server").RegisteredMutation<"public", {
566
+ expiresInHours?: number | undefined;
567
+ phoneNumber: string;
568
+ email: string;
569
+ name: string;
570
+ branchId: import("convex/values").GenericId<"branches">;
571
+ }, Promise<{
572
+ attendantId: Id<"attendants">;
573
+ enrollmentToken: string;
574
+ enrollmentLink: string;
575
+ expiresAt: number;
576
+ }>>;
577
+ /**
578
+ * List attendant enrollments (Admin)
579
+ */
580
+ export declare const listAttendantEnrollments: import("convex/server").RegisteredQuery<"public", {
581
+ status?: "active" | "suspended" | "invited" | "enrolling" | "locked" | undefined;
582
+ branchId?: import("convex/values").GenericId<"branches"> | undefined;
583
+ }, Promise<{
584
+ id: import("convex/values").GenericId<"attendants">;
585
+ name: string;
586
+ email: string;
587
+ phoneNumber: string;
588
+ branchId: import("convex/values").GenericId<"branches">;
589
+ enrollmentStatus: "active" | "suspended" | "invited" | "enrolling" | "locked";
590
+ enrolledAt: number | undefined;
591
+ enrollmentTokenExpiresAt: number | undefined;
592
+ lastVerificationAt: number | undefined;
593
+ consecutiveFailures: number;
594
+ createdAt: number;
595
+ }[]>>;
596
+ /**
597
+ * Resend enrollment link (Admin)
598
+ */
599
+ export declare const resendEnrollmentLink: import("convex/server").RegisteredMutation<"public", {
600
+ expiresInHours?: number | undefined;
601
+ attendantId: import("convex/values").GenericId<"attendants">;
602
+ }, Promise<{
603
+ enrollmentToken: string;
604
+ enrollmentLink: string;
605
+ expiresAt: number;
606
+ }>>;
466
607
  //# sourceMappingURL=admin.d.ts.map