@litusarchieve18/agricore-utils 1.0.19 → 1.0.21
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/README.md +6 -2
- package/dist/{chunk-3QM4RXHC.mjs → chunk-DZW2VL6D.mjs} +53 -13
- package/dist/{constants-BOhAy2Xv.d.mts → constants-BQmsBTQ7.d.mts} +13 -4
- package/dist/{constants-BOhAy2Xv.d.ts → constants-BQmsBTQ7.d.ts} +13 -4
- package/dist/constants.d.mts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +53 -13
- package/dist/constants.mjs +1 -1
- package/dist/index.d.mts +3 -12
- package/dist/index.d.ts +3 -12
- package/dist/index.js +53 -65
- package/dist/index.mjs +1 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,9 +183,13 @@ Run the publish command:
|
|
|
183
183
|
Bash
|
|
184
184
|
npm publish --access public
|
|
185
185
|
📝 Version History
|
|
186
|
-
V1.0.
|
|
186
|
+
V1.0.20 — add finance access and some top menu section that were missing
|
|
187
187
|
|
|
188
|
-
V1.0.
|
|
188
|
+
V1.0.20 — add inventory access reconcile
|
|
189
|
+
|
|
190
|
+
V1.0.19 — refactor inventory access in RESOURCE_PATHS
|
|
191
|
+
|
|
192
|
+
V1.0.18 — refactor menu structure
|
|
189
193
|
|
|
190
194
|
V1.0.17 — refactor type and enum
|
|
191
195
|
|
|
@@ -345,35 +345,47 @@ var RESOURCE_PATHS = {
|
|
|
345
345
|
// ── Operations ────────────────────────────────────────────────────────────
|
|
346
346
|
farmManagement: "operations.farmManagement",
|
|
347
347
|
packhouse: "operations.packhouse",
|
|
348
|
+
accommodation: "operations.accommodation",
|
|
348
349
|
// ── Inventory ────────────────────────────────────────────────────────────
|
|
349
350
|
// === Consumables ===
|
|
351
|
+
inventory: "inventory",
|
|
352
|
+
inventoryConsumable: "inventory.consumable",
|
|
350
353
|
inventoryConsumableProduct: "inventory.consumable.product",
|
|
351
354
|
inventoryConsumableStock: "inventory.consumable.stock",
|
|
352
355
|
inventoryConsumableStockEditThreshold: "inventory.consumable.stock.editThreshold",
|
|
356
|
+
inventoryConsumableStockReconcile: "inventory.consumable.stock.reconcile",
|
|
353
357
|
inventoryConsumableStockMovement: "inventory.consumable.stockMovement",
|
|
354
358
|
inventoryConsumableStockMovementTransfer: "inventory.consumable.stockMovement.transfer",
|
|
355
|
-
inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
359
|
+
// inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
356
360
|
// === Chemicals ===
|
|
361
|
+
inventoryChemical: "inventory.chemical",
|
|
357
362
|
inventoryChemicalProduct: "inventory.chemical.product",
|
|
358
363
|
inventoryChemicalStock: "inventory.chemical.stock",
|
|
359
364
|
inventoryChemicalStockEditThreshold: "inventory.chemical.stock.editThreshold",
|
|
365
|
+
inventoryChemicalStockReconcile: "inventory.chemical.stock.reconcile",
|
|
360
366
|
inventoryChemicalStockMovement: "inventory.chemical.stockMovement",
|
|
361
367
|
inventoryChemicalStockMovementTransfer: "inventory.chemical.stockMovement.transfer",
|
|
362
|
-
inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
368
|
+
// inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
363
369
|
// === Maintenance Parts ===
|
|
370
|
+
inventoryMaintenancePart: "inventory.maintenancePart",
|
|
364
371
|
inventoryMaintenancePartProduct: "inventory.maintenancePart.product",
|
|
365
372
|
inventoryMaintenancePartStock: "inventory.maintenancePart.stock",
|
|
366
373
|
inventoryMaintenancePartStockEditThreshold: "inventory.maintenancePart.stock.editThreshold",
|
|
374
|
+
inventoryMaintenancePartStockReconcile: "inventory.maintenancePart.stock.reconcile",
|
|
367
375
|
inventoryMaintenancePartStockMovement: "inventory.maintenancePart.stockMovement",
|
|
368
376
|
inventoryMaintenancePartStockMovementTransfer: "inventory.maintenancePart.stockMovement.transfer",
|
|
369
|
-
inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
370
|
-
accommodation: "operations.accommodation",
|
|
377
|
+
// inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
371
378
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
372
379
|
equipPreStart: "equipment.preStart",
|
|
373
380
|
equipMaintenance: "equipment.maintenance",
|
|
374
381
|
equipFuelRegister: "equipment.fuelRegister",
|
|
375
382
|
equipCalibration: "equipment.calibration",
|
|
376
383
|
equipFleet: "equipment.fleetManagement",
|
|
384
|
+
finance: "finance",
|
|
385
|
+
financeProductRequisition: "finance.product.requistion",
|
|
386
|
+
financeDashboard: "finance.dashboard",
|
|
387
|
+
financeTransaction: "finance.transaction",
|
|
388
|
+
financeBudgetAllocation: "finance.budgetAllocation",
|
|
377
389
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
378
390
|
safetyAuditing: "safety.auditing",
|
|
379
391
|
safetyFood: "safety.foodSafety",
|
|
@@ -399,14 +411,20 @@ var RESOURCE_MODULE_MAP = {
|
|
|
399
411
|
[RESOURCE_PATHS.equipment]: ALL_OPERATIONS,
|
|
400
412
|
[RESOURCE_PATHS.safety]: ALL_OPERATIONS,
|
|
401
413
|
[RESOURCE_PATHS.team]: ALL_OPERATIONS,
|
|
414
|
+
[RESOURCE_PATHS.inventory]: ALL_OPERATIONS,
|
|
415
|
+
[RESOURCE_PATHS.finance]: ALL_OPERATIONS,
|
|
402
416
|
[RESOURCE_PATHS.records]: ALL_OPERATIONS,
|
|
403
417
|
[RESOURCE_PATHS.adminSettings]: ALL_OPERATIONS,
|
|
404
418
|
// ── Inventory ──────────────────────────────────────────────────────
|
|
419
|
+
[RESOURCE_PATHS.inventoryConsumable]: ALL_OPERATIONS,
|
|
405
420
|
[RESOURCE_PATHS.inventoryConsumableProduct]: ALL_OPERATIONS,
|
|
406
421
|
[RESOURCE_PATHS.inventoryConsumableStock]: ALL_OPERATIONS,
|
|
407
422
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: ALL_OPERATIONS,
|
|
423
|
+
[RESOURCE_PATHS.inventoryChemical]: ALL_OPERATIONS,
|
|
408
424
|
[RESOURCE_PATHS.inventoryChemicalProduct]: ALL_OPERATIONS,
|
|
409
425
|
[RESOURCE_PATHS.inventoryChemicalStock]: ALL_OPERATIONS,
|
|
426
|
+
[RESOURCE_PATHS.inventoryChemicalStockMovement]: ALL_OPERATIONS,
|
|
427
|
+
[RESOURCE_PATHS.inventoryMaintenancePart]: ALL_OPERATIONS,
|
|
410
428
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: ALL_OPERATIONS,
|
|
411
429
|
[RESOURCE_PATHS.inventoryMaintenancePartStock]: ALL_OPERATIONS,
|
|
412
430
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: ALL_OPERATIONS,
|
|
@@ -488,13 +506,16 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
488
506
|
[RESOURCE_PATHS.inventoryConsumableStockEditThreshold]: {
|
|
489
507
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
490
508
|
},
|
|
509
|
+
[RESOURCE_PATHS.inventoryConsumableStockReconcile]: {
|
|
510
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
511
|
+
},
|
|
491
512
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: { allowedRoles: EVERYONE },
|
|
492
513
|
[RESOURCE_PATHS.inventoryConsumableStockMovementTransfer]: {
|
|
493
514
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
494
515
|
},
|
|
495
|
-
[RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
496
|
-
|
|
497
|
-
},
|
|
516
|
+
// [RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
517
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
518
|
+
// },
|
|
498
519
|
// CHEMICALS PERMISSIONS
|
|
499
520
|
[RESOURCE_PATHS.inventoryChemicalProduct]: {
|
|
500
521
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -503,13 +524,16 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
503
524
|
[RESOURCE_PATHS.inventoryChemicalStockEditThreshold]: {
|
|
504
525
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
505
526
|
},
|
|
527
|
+
[RESOURCE_PATHS.inventoryChemicalStockReconcile]: {
|
|
528
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
529
|
+
},
|
|
506
530
|
[RESOURCE_PATHS.inventoryChemicalStockMovement]: { allowedRoles: EVERYONE },
|
|
507
531
|
[RESOURCE_PATHS.inventoryChemicalStockMovementTransfer]: {
|
|
508
532
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
509
533
|
},
|
|
510
|
-
[RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
511
|
-
|
|
512
|
-
},
|
|
534
|
+
// [RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
535
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
536
|
+
// },
|
|
513
537
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: {
|
|
514
538
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
515
539
|
},
|
|
@@ -517,12 +541,28 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
517
541
|
[RESOURCE_PATHS.inventoryMaintenancePartStockEditThreshold]: {
|
|
518
542
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
519
543
|
},
|
|
544
|
+
[RESOURCE_PATHS.inventoryMaintenancePartStockReconcile]: {
|
|
545
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
546
|
+
},
|
|
520
547
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: { allowedRoles: EVERYONE },
|
|
521
|
-
[RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
548
|
+
// [RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
549
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
550
|
+
// },
|
|
551
|
+
// ── Finance ────────────────────────────────────────────────────────────────
|
|
552
|
+
[RESOURCE_PATHS.financeProductRequisition]: {
|
|
522
553
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
523
554
|
},
|
|
524
|
-
[RESOURCE_PATHS.
|
|
525
|
-
allowedRoles: [UserRole.OWNER,
|
|
555
|
+
[RESOURCE_PATHS.financeBudgetAllocation]: {
|
|
556
|
+
allowedRoles: [UserRole.OWNER],
|
|
557
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
558
|
+
},
|
|
559
|
+
[RESOURCE_PATHS.financeDashboard]: {
|
|
560
|
+
allowedRoles: [UserRole.OWNER],
|
|
561
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
562
|
+
},
|
|
563
|
+
[RESOURCE_PATHS.financeTransaction]: {
|
|
564
|
+
allowedRoles: [UserRole.OWNER],
|
|
565
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
526
566
|
},
|
|
527
567
|
// ── Admin Settings ─────────────────────────────────────────────────────────
|
|
528
568
|
[RESOURCE_PATHS.adminUserRoster]: {
|
|
@@ -430,30 +430,39 @@ declare const RESOURCE_PATHS: {
|
|
|
430
430
|
adminCompanySettings: string;
|
|
431
431
|
farmManagement: string;
|
|
432
432
|
packhouse: string;
|
|
433
|
+
accommodation: string;
|
|
434
|
+
inventory: string;
|
|
435
|
+
inventoryConsumable: string;
|
|
433
436
|
inventoryConsumableProduct: string;
|
|
434
437
|
inventoryConsumableStock: string;
|
|
435
438
|
inventoryConsumableStockEditThreshold: string;
|
|
439
|
+
inventoryConsumableStockReconcile: string;
|
|
436
440
|
inventoryConsumableStockMovement: string;
|
|
437
441
|
inventoryConsumableStockMovementTransfer: string;
|
|
438
|
-
|
|
442
|
+
inventoryChemical: string;
|
|
439
443
|
inventoryChemicalProduct: string;
|
|
440
444
|
inventoryChemicalStock: string;
|
|
441
445
|
inventoryChemicalStockEditThreshold: string;
|
|
446
|
+
inventoryChemicalStockReconcile: string;
|
|
442
447
|
inventoryChemicalStockMovement: string;
|
|
443
448
|
inventoryChemicalStockMovementTransfer: string;
|
|
444
|
-
|
|
449
|
+
inventoryMaintenancePart: string;
|
|
445
450
|
inventoryMaintenancePartProduct: string;
|
|
446
451
|
inventoryMaintenancePartStock: string;
|
|
447
452
|
inventoryMaintenancePartStockEditThreshold: string;
|
|
453
|
+
inventoryMaintenancePartStockReconcile: string;
|
|
448
454
|
inventoryMaintenancePartStockMovement: string;
|
|
449
455
|
inventoryMaintenancePartStockMovementTransfer: string;
|
|
450
|
-
inventoryMaintenancePartStockMovementPurchase: string;
|
|
451
|
-
accommodation: string;
|
|
452
456
|
equipPreStart: string;
|
|
453
457
|
equipMaintenance: string;
|
|
454
458
|
equipFuelRegister: string;
|
|
455
459
|
equipCalibration: string;
|
|
456
460
|
equipFleet: string;
|
|
461
|
+
finance: string;
|
|
462
|
+
financeProductRequisition: string;
|
|
463
|
+
financeDashboard: string;
|
|
464
|
+
financeTransaction: string;
|
|
465
|
+
financeBudgetAllocation: string;
|
|
457
466
|
safetyAuditing: string;
|
|
458
467
|
safetyFood: string;
|
|
459
468
|
safetyWhs: string;
|
|
@@ -430,30 +430,39 @@ declare const RESOURCE_PATHS: {
|
|
|
430
430
|
adminCompanySettings: string;
|
|
431
431
|
farmManagement: string;
|
|
432
432
|
packhouse: string;
|
|
433
|
+
accommodation: string;
|
|
434
|
+
inventory: string;
|
|
435
|
+
inventoryConsumable: string;
|
|
433
436
|
inventoryConsumableProduct: string;
|
|
434
437
|
inventoryConsumableStock: string;
|
|
435
438
|
inventoryConsumableStockEditThreshold: string;
|
|
439
|
+
inventoryConsumableStockReconcile: string;
|
|
436
440
|
inventoryConsumableStockMovement: string;
|
|
437
441
|
inventoryConsumableStockMovementTransfer: string;
|
|
438
|
-
|
|
442
|
+
inventoryChemical: string;
|
|
439
443
|
inventoryChemicalProduct: string;
|
|
440
444
|
inventoryChemicalStock: string;
|
|
441
445
|
inventoryChemicalStockEditThreshold: string;
|
|
446
|
+
inventoryChemicalStockReconcile: string;
|
|
442
447
|
inventoryChemicalStockMovement: string;
|
|
443
448
|
inventoryChemicalStockMovementTransfer: string;
|
|
444
|
-
|
|
449
|
+
inventoryMaintenancePart: string;
|
|
445
450
|
inventoryMaintenancePartProduct: string;
|
|
446
451
|
inventoryMaintenancePartStock: string;
|
|
447
452
|
inventoryMaintenancePartStockEditThreshold: string;
|
|
453
|
+
inventoryMaintenancePartStockReconcile: string;
|
|
448
454
|
inventoryMaintenancePartStockMovement: string;
|
|
449
455
|
inventoryMaintenancePartStockMovementTransfer: string;
|
|
450
|
-
inventoryMaintenancePartStockMovementPurchase: string;
|
|
451
|
-
accommodation: string;
|
|
452
456
|
equipPreStart: string;
|
|
453
457
|
equipMaintenance: string;
|
|
454
458
|
equipFuelRegister: string;
|
|
455
459
|
equipCalibration: string;
|
|
456
460
|
equipFleet: string;
|
|
461
|
+
finance: string;
|
|
462
|
+
financeProductRequisition: string;
|
|
463
|
+
financeDashboard: string;
|
|
464
|
+
financeTransaction: string;
|
|
465
|
+
financeBudgetAllocation: string;
|
|
457
466
|
safetyAuditing: string;
|
|
458
467
|
safetyFood: string;
|
|
459
468
|
safetyWhs: string;
|
package/dist/constants.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, x as CatalogSyncStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a1 as NotificationMode, a2 as OrderStatus, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a8 as ProductUnit, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ah as ResourceRequirement, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, ao as SoilTexture, ap as StockPolicyTier, ar as StoragePhases, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-
|
|
1
|
+
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, x as CatalogSyncStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a1 as NotificationMode, a2 as OrderStatus, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a8 as ProductUnit, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ah as ResourceRequirement, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, ao as SoilTexture, ap as StockPolicyTier, ar as StoragePhases, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-BQmsBTQ7.mjs';
|
package/dist/constants.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, x as CatalogSyncStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a1 as NotificationMode, a2 as OrderStatus, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a8 as ProductUnit, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ah as ResourceRequirement, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, ao as SoilTexture, ap as StockPolicyTier, ar as StoragePhases, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-
|
|
1
|
+
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, B as BarcodeNamespace, l as BarcodeType, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, x as CatalogSyncStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a1 as NotificationMode, a2 as OrderStatus, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a8 as ProductUnit, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ah as ResourceRequirement, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, ao as SoilTexture, ap as StockPolicyTier, ar as StoragePhases, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-BQmsBTQ7.js';
|
package/dist/constants.js
CHANGED
|
@@ -430,35 +430,47 @@ var RESOURCE_PATHS = {
|
|
|
430
430
|
// ── Operations ────────────────────────────────────────────────────────────
|
|
431
431
|
farmManagement: "operations.farmManagement",
|
|
432
432
|
packhouse: "operations.packhouse",
|
|
433
|
+
accommodation: "operations.accommodation",
|
|
433
434
|
// ── Inventory ────────────────────────────────────────────────────────────
|
|
434
435
|
// === Consumables ===
|
|
436
|
+
inventory: "inventory",
|
|
437
|
+
inventoryConsumable: "inventory.consumable",
|
|
435
438
|
inventoryConsumableProduct: "inventory.consumable.product",
|
|
436
439
|
inventoryConsumableStock: "inventory.consumable.stock",
|
|
437
440
|
inventoryConsumableStockEditThreshold: "inventory.consumable.stock.editThreshold",
|
|
441
|
+
inventoryConsumableStockReconcile: "inventory.consumable.stock.reconcile",
|
|
438
442
|
inventoryConsumableStockMovement: "inventory.consumable.stockMovement",
|
|
439
443
|
inventoryConsumableStockMovementTransfer: "inventory.consumable.stockMovement.transfer",
|
|
440
|
-
inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
444
|
+
// inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
441
445
|
// === Chemicals ===
|
|
446
|
+
inventoryChemical: "inventory.chemical",
|
|
442
447
|
inventoryChemicalProduct: "inventory.chemical.product",
|
|
443
448
|
inventoryChemicalStock: "inventory.chemical.stock",
|
|
444
449
|
inventoryChemicalStockEditThreshold: "inventory.chemical.stock.editThreshold",
|
|
450
|
+
inventoryChemicalStockReconcile: "inventory.chemical.stock.reconcile",
|
|
445
451
|
inventoryChemicalStockMovement: "inventory.chemical.stockMovement",
|
|
446
452
|
inventoryChemicalStockMovementTransfer: "inventory.chemical.stockMovement.transfer",
|
|
447
|
-
inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
453
|
+
// inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
448
454
|
// === Maintenance Parts ===
|
|
455
|
+
inventoryMaintenancePart: "inventory.maintenancePart",
|
|
449
456
|
inventoryMaintenancePartProduct: "inventory.maintenancePart.product",
|
|
450
457
|
inventoryMaintenancePartStock: "inventory.maintenancePart.stock",
|
|
451
458
|
inventoryMaintenancePartStockEditThreshold: "inventory.maintenancePart.stock.editThreshold",
|
|
459
|
+
inventoryMaintenancePartStockReconcile: "inventory.maintenancePart.stock.reconcile",
|
|
452
460
|
inventoryMaintenancePartStockMovement: "inventory.maintenancePart.stockMovement",
|
|
453
461
|
inventoryMaintenancePartStockMovementTransfer: "inventory.maintenancePart.stockMovement.transfer",
|
|
454
|
-
inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
455
|
-
accommodation: "operations.accommodation",
|
|
462
|
+
// inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
456
463
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
457
464
|
equipPreStart: "equipment.preStart",
|
|
458
465
|
equipMaintenance: "equipment.maintenance",
|
|
459
466
|
equipFuelRegister: "equipment.fuelRegister",
|
|
460
467
|
equipCalibration: "equipment.calibration",
|
|
461
468
|
equipFleet: "equipment.fleetManagement",
|
|
469
|
+
finance: "finance",
|
|
470
|
+
financeProductRequisition: "finance.product.requistion",
|
|
471
|
+
financeDashboard: "finance.dashboard",
|
|
472
|
+
financeTransaction: "finance.transaction",
|
|
473
|
+
financeBudgetAllocation: "finance.budgetAllocation",
|
|
462
474
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
463
475
|
safetyAuditing: "safety.auditing",
|
|
464
476
|
safetyFood: "safety.foodSafety",
|
|
@@ -484,14 +496,20 @@ var RESOURCE_MODULE_MAP = {
|
|
|
484
496
|
[RESOURCE_PATHS.equipment]: ALL_OPERATIONS,
|
|
485
497
|
[RESOURCE_PATHS.safety]: ALL_OPERATIONS,
|
|
486
498
|
[RESOURCE_PATHS.team]: ALL_OPERATIONS,
|
|
499
|
+
[RESOURCE_PATHS.inventory]: ALL_OPERATIONS,
|
|
500
|
+
[RESOURCE_PATHS.finance]: ALL_OPERATIONS,
|
|
487
501
|
[RESOURCE_PATHS.records]: ALL_OPERATIONS,
|
|
488
502
|
[RESOURCE_PATHS.adminSettings]: ALL_OPERATIONS,
|
|
489
503
|
// ── Inventory ──────────────────────────────────────────────────────
|
|
504
|
+
[RESOURCE_PATHS.inventoryConsumable]: ALL_OPERATIONS,
|
|
490
505
|
[RESOURCE_PATHS.inventoryConsumableProduct]: ALL_OPERATIONS,
|
|
491
506
|
[RESOURCE_PATHS.inventoryConsumableStock]: ALL_OPERATIONS,
|
|
492
507
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: ALL_OPERATIONS,
|
|
508
|
+
[RESOURCE_PATHS.inventoryChemical]: ALL_OPERATIONS,
|
|
493
509
|
[RESOURCE_PATHS.inventoryChemicalProduct]: ALL_OPERATIONS,
|
|
494
510
|
[RESOURCE_PATHS.inventoryChemicalStock]: ALL_OPERATIONS,
|
|
511
|
+
[RESOURCE_PATHS.inventoryChemicalStockMovement]: ALL_OPERATIONS,
|
|
512
|
+
[RESOURCE_PATHS.inventoryMaintenancePart]: ALL_OPERATIONS,
|
|
495
513
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: ALL_OPERATIONS,
|
|
496
514
|
[RESOURCE_PATHS.inventoryMaintenancePartStock]: ALL_OPERATIONS,
|
|
497
515
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: ALL_OPERATIONS,
|
|
@@ -573,13 +591,16 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
573
591
|
[RESOURCE_PATHS.inventoryConsumableStockEditThreshold]: {
|
|
574
592
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
575
593
|
},
|
|
594
|
+
[RESOURCE_PATHS.inventoryConsumableStockReconcile]: {
|
|
595
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
596
|
+
},
|
|
576
597
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: { allowedRoles: EVERYONE },
|
|
577
598
|
[RESOURCE_PATHS.inventoryConsumableStockMovementTransfer]: {
|
|
578
599
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
579
600
|
},
|
|
580
|
-
[RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
581
|
-
|
|
582
|
-
},
|
|
601
|
+
// [RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
602
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
603
|
+
// },
|
|
583
604
|
// CHEMICALS PERMISSIONS
|
|
584
605
|
[RESOURCE_PATHS.inventoryChemicalProduct]: {
|
|
585
606
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -588,13 +609,16 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
588
609
|
[RESOURCE_PATHS.inventoryChemicalStockEditThreshold]: {
|
|
589
610
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
590
611
|
},
|
|
612
|
+
[RESOURCE_PATHS.inventoryChemicalStockReconcile]: {
|
|
613
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
614
|
+
},
|
|
591
615
|
[RESOURCE_PATHS.inventoryChemicalStockMovement]: { allowedRoles: EVERYONE },
|
|
592
616
|
[RESOURCE_PATHS.inventoryChemicalStockMovementTransfer]: {
|
|
593
617
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
594
618
|
},
|
|
595
|
-
[RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
596
|
-
|
|
597
|
-
},
|
|
619
|
+
// [RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
620
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
621
|
+
// },
|
|
598
622
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: {
|
|
599
623
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
600
624
|
},
|
|
@@ -602,12 +626,28 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
602
626
|
[RESOURCE_PATHS.inventoryMaintenancePartStockEditThreshold]: {
|
|
603
627
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
604
628
|
},
|
|
629
|
+
[RESOURCE_PATHS.inventoryMaintenancePartStockReconcile]: {
|
|
630
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
631
|
+
},
|
|
605
632
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: { allowedRoles: EVERYONE },
|
|
606
|
-
[RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
633
|
+
// [RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
634
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
635
|
+
// },
|
|
636
|
+
// ── Finance ────────────────────────────────────────────────────────────────
|
|
637
|
+
[RESOURCE_PATHS.financeProductRequisition]: {
|
|
607
638
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
608
639
|
},
|
|
609
|
-
[RESOURCE_PATHS.
|
|
610
|
-
allowedRoles: [UserRole.OWNER,
|
|
640
|
+
[RESOURCE_PATHS.financeBudgetAllocation]: {
|
|
641
|
+
allowedRoles: [UserRole.OWNER],
|
|
642
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
643
|
+
},
|
|
644
|
+
[RESOURCE_PATHS.financeDashboard]: {
|
|
645
|
+
allowedRoles: [UserRole.OWNER],
|
|
646
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
647
|
+
},
|
|
648
|
+
[RESOURCE_PATHS.financeTransaction]: {
|
|
649
|
+
allowedRoles: [UserRole.OWNER],
|
|
650
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
611
651
|
},
|
|
612
652
|
// ── Admin Settings ─────────────────────────────────────────────────────────
|
|
613
653
|
[RESOURCE_PATHS.adminUserRoster]: {
|
package/dist/constants.mjs
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as AgriCoreSession, aF as UserRoleType, ah as ResourceRequirement, c as AccessLevelType, j as AvailableScope, U as InfrastructureFields, S as FormMeta, av as TabConfig, af as ResolvedError } from './constants-
|
|
2
|
-
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, t as CanonicalId, u as CarSupportedEvidenceMimeType, v as CarSupportedSignatureMimeType, w as CarTemplateFileMetadata, x as CatalogSyncStatus, y as CatalogSyncStatusType, z as CompanyConfig, D as CorrectiveActionCompileTaskMetadata, E as CorrectiveActionGenerationSource, F as CorrectiveActionStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, R as FileUploadTaskType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a0 as NormalizedSignatureValue, a1 as NotificationMode, a2 as OrderStatus, a3 as PermissionLevel, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a7 as ProductTypeType, a8 as ProductUnit, a9 as ProductUnitType, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ag as ResourceOverrides, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, al as ScopeType, am as SignatureInput, an as SignatureMode, ao as SoilTexture, ap as StockPolicyTier, aq as StockPolicyTierType, ar as StoragePhases, as as StorageType, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, az as TaskTypeConfig, aA as TemplateScopeLevel, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-
|
|
1
|
+
import { d as AgriCoreSession, aF as UserRoleType, ah as ResourceRequirement, c as AccessLevelType, j as AvailableScope, U as InfrastructureFields, S as FormMeta, av as TabConfig, af as ResolvedError } from './constants-BQmsBTQ7.mjs';
|
|
2
|
+
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, t as CanonicalId, u as CarSupportedEvidenceMimeType, v as CarSupportedSignatureMimeType, w as CarTemplateFileMetadata, x as CatalogSyncStatus, y as CatalogSyncStatusType, z as CompanyConfig, D as CorrectiveActionCompileTaskMetadata, E as CorrectiveActionGenerationSource, F as CorrectiveActionStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, R as FileUploadTaskType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a0 as NormalizedSignatureValue, a1 as NotificationMode, a2 as OrderStatus, a3 as PermissionLevel, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a7 as ProductTypeType, a8 as ProductUnit, a9 as ProductUnitType, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ag as ResourceOverrides, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, al as ScopeType, am as SignatureInput, an as SignatureMode, ao as SoilTexture, ap as StockPolicyTier, aq as StockPolicyTierType, ar as StoragePhases, as as StorageType, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, az as TaskTypeConfig, aA as TemplateScopeLevel, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-BQmsBTQ7.mjs';
|
|
3
3
|
|
|
4
4
|
declare const AgriLogger: {
|
|
5
5
|
log(level: "INFO" | "WARN" | "ERROR", message: string, meta: any): void;
|
|
@@ -104,24 +104,15 @@ declare function generateCanonicalId(): string;
|
|
|
104
104
|
* Standardizes the creation of new entities by walking up the scope tree.
|
|
105
105
|
*/
|
|
106
106
|
declare function generateInfrastructureFields(activeScope: AvailableScope, availableScopes: AvailableScope[]): InfrastructureFields;
|
|
107
|
-
declare function buildRlsFilter(session: AgriCoreSession, extra?: Record<string, any>): {
|
|
108
|
-
authScopeId: {
|
|
109
|
-
$in: string[];
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
declare function canRead(session: AgriCoreSession, authScopeId: string): boolean;
|
|
113
|
-
declare function canWrite(session: AgriCoreSession, authScopeId: string, resourcePath: string): boolean;
|
|
114
107
|
/**
|
|
115
108
|
* Hard-throws if the user cannot write.
|
|
116
109
|
* Use this on the backend (inside Deno functions) to enforce server-side.
|
|
117
110
|
*/
|
|
118
|
-
declare function assertCanWrite(session: AgriCoreSession, authScopeId: string, resourcePath: string): void;
|
|
119
111
|
/**
|
|
120
112
|
* Full resolution: DB override → static config fallback → public default.
|
|
121
113
|
* Returns 'NONE' | 'READ' | 'WRITE'.
|
|
122
114
|
*/
|
|
123
115
|
declare function resolveAccess(session: AgriCoreSession, activeScopeId: string, tabConfig: TabConfig): 'NONE' | 'READ' | 'WRITE';
|
|
124
|
-
declare function resolveMenuVisibility(session: AgriCoreSession, authScopeId: string, resourcePath: string): 'hidden' | 'read_only' | 'active';
|
|
125
116
|
declare function isTabVisible(session: AgriCoreSession, activeScopeId: string, tabConfig: TabConfig): boolean;
|
|
126
117
|
declare function isTabWritable(session: AgriCoreSession, activeScopeId: string, tabConfig: TabConfig): boolean;
|
|
127
118
|
declare function evaluateBaseAccess(resourcePath: string, session: {
|
|
@@ -172,4 +163,4 @@ declare function calculateFileMetadataMatch(criteria: {
|
|
|
172
163
|
contextMatch?: string[];
|
|
173
164
|
}, fileMetadata: Record<string, any>, auditContext: Record<string, any>): number;
|
|
174
165
|
|
|
175
|
-
export { AccessLevelType, AgriCoreSession, AgriLogger, AppError, AvailableScope, Converter, ErrorFactory, FormMeta, InfrastructureFields, ResolvedError, ResourceRequirement, TabConfig, UserRoleType, Validator,
|
|
166
|
+
export { AccessLevelType, AgriCoreSession, AgriLogger, AppError, AvailableScope, Converter, ErrorFactory, FormMeta, InfrastructureFields, ResolvedError, ResourceRequirement, TabConfig, UserRoleType, Validator, assertTenantBoundary, calculateFileMetadataMatch, evaluateBaseAccess, extractAppCode, findSpecificOverride, generateCanonicalId, generateDocumentPath, generateInfrastructureFields, getAcceptedMimeTypes, getApproveAction, getFormMeta, getFormsGroupedByModule, getTaskTypeOptions, handleAppErrorResponse, isTabVisible, isTabWritable, resolveAccess, resolveAppError, resolveEffectiveAccess, resolveError, verifyAndExtractSession, withAgriLogging };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as AgriCoreSession, aF as UserRoleType, ah as ResourceRequirement, c as AccessLevelType, j as AvailableScope, U as InfrastructureFields, S as FormMeta, av as TabConfig, af as ResolvedError } from './constants-
|
|
2
|
-
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, t as CanonicalId, u as CarSupportedEvidenceMimeType, v as CarSupportedSignatureMimeType, w as CarTemplateFileMetadata, x as CatalogSyncStatus, y as CatalogSyncStatusType, z as CompanyConfig, D as CorrectiveActionCompileTaskMetadata, E as CorrectiveActionGenerationSource, F as CorrectiveActionStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, R as FileUploadTaskType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a0 as NormalizedSignatureValue, a1 as NotificationMode, a2 as OrderStatus, a3 as PermissionLevel, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a7 as ProductTypeType, a8 as ProductUnit, a9 as ProductUnitType, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ag as ResourceOverrides, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, al as ScopeType, am as SignatureInput, an as SignatureMode, ao as SoilTexture, ap as StockPolicyTier, aq as StockPolicyTierType, ar as StoragePhases, as as StorageType, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, az as TaskTypeConfig, aA as TemplateScopeLevel, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-
|
|
1
|
+
import { d as AgriCoreSession, aF as UserRoleType, ah as ResourceRequirement, c as AccessLevelType, j as AvailableScope, U as InfrastructureFields, S as FormMeta, av as TabConfig, af as ResolvedError } from './constants-BQmsBTQ7.js';
|
|
2
|
+
export { A as ACCESS_RANK, a as ACT, b as AccessLevel, e as ApprovalStatus, f as ApprovalType, g as AuditStatus, h as AuditType, i as AuthScopeFields, B as BarcodeNamespace, k as BarcodeNamespaceType, l as BarcodeType, m as BarcodeTypeType, n as Base44Id, C as CAR_SUPPORTED_EVIDENCE_MIME_TYPES, o as CAR_SUPPORTED_SIGNATURE_MIME_TYPES, p as CAT, q as CATEGORY_TABS, r as CORRECTIVE_ACTION_GENERATION_SOURCES, s as CORRECTIVE_ACTION_STATUSES, t as CanonicalId, u as CarSupportedEvidenceMimeType, v as CarSupportedSignatureMimeType, w as CarTemplateFileMetadata, x as CatalogSyncStatus, y as CatalogSyncStatusType, z as CompanyConfig, D as CorrectiveActionCompileTaskMetadata, E as CorrectiveActionGenerationSource, F as CorrectiveActionStatus, G as CropCycleStatus, H as DOCUMENT_DISPLAY_INFO, I as DOCUMENT_MENU_MAP, J as DocumentCategory, K as DocumentType, L as ERROR_DICTIONARY, M as EVERYONE, N as EmitterType, O as EnabledModule, P as FORM_REGISTRY, Q as FacilityType, R as FileUploadTaskType, T as HarvestMethod, V as LinkedStatus, W as MOD, X as MODULE_LABELS, Y as MicroclimateZone, Z as MimeType, _ as ModCode, $ as NettingType, a0 as NormalizedSignatureValue, a1 as NotificationMode, a2 as OrderStatus, a3 as PermissionLevel, a4 as PhysicalState, a5 as PlantingMethod, a6 as ProductType, a7 as ProductTypeType, a8 as ProductUnit, a9 as ProductUnitType, aa as RESOURCE_MODULE_MAP, ab as RESOURCE_PATHS, ac as RESOURCE_REQUIREMENTS, ad as ROLE_SECTIONS_BY_KEY, ae as RelationshipType, ag as ResourceOverrides, ai as RowOrientation, aj as SENTINEL_UUID, ak as SIGNATURE_MODES, al as ScopeType, am as SignatureInput, an as SignatureMode, ao as SoilTexture, ap as StockPolicyTier, aq as StockPolicyTierType, ar as StoragePhases, as as StorageType, at as TASK_TYPE_REGISTRY, au as TEMPLATE_SCOPE_LEVELS, aw as TargetEntityType, ax as TaskStatus, ay as TaskType, az as TaskTypeConfig, aA as TemplateScopeLevel, aB as TransactionType, aC as TrellisType, aD as UserPrivilege, aE as UserRole, aG as VigorRating, aH as WaterSource } from './constants-BQmsBTQ7.js';
|
|
3
3
|
|
|
4
4
|
declare const AgriLogger: {
|
|
5
5
|
log(level: "INFO" | "WARN" | "ERROR", message: string, meta: any): void;
|
|
@@ -104,24 +104,15 @@ declare function generateCanonicalId(): string;
|
|
|
104
104
|
* Standardizes the creation of new entities by walking up the scope tree.
|
|
105
105
|
*/
|
|
106
106
|
declare function generateInfrastructureFields(activeScope: AvailableScope, availableScopes: AvailableScope[]): InfrastructureFields;
|
|
107
|
-
declare function buildRlsFilter(session: AgriCoreSession, extra?: Record<string, any>): {
|
|
108
|
-
authScopeId: {
|
|
109
|
-
$in: string[];
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
declare function canRead(session: AgriCoreSession, authScopeId: string): boolean;
|
|
113
|
-
declare function canWrite(session: AgriCoreSession, authScopeId: string, resourcePath: string): boolean;
|
|
114
107
|
/**
|
|
115
108
|
* Hard-throws if the user cannot write.
|
|
116
109
|
* Use this on the backend (inside Deno functions) to enforce server-side.
|
|
117
110
|
*/
|
|
118
|
-
declare function assertCanWrite(session: AgriCoreSession, authScopeId: string, resourcePath: string): void;
|
|
119
111
|
/**
|
|
120
112
|
* Full resolution: DB override → static config fallback → public default.
|
|
121
113
|
* Returns 'NONE' | 'READ' | 'WRITE'.
|
|
122
114
|
*/
|
|
123
115
|
declare function resolveAccess(session: AgriCoreSession, activeScopeId: string, tabConfig: TabConfig): 'NONE' | 'READ' | 'WRITE';
|
|
124
|
-
declare function resolveMenuVisibility(session: AgriCoreSession, authScopeId: string, resourcePath: string): 'hidden' | 'read_only' | 'active';
|
|
125
116
|
declare function isTabVisible(session: AgriCoreSession, activeScopeId: string, tabConfig: TabConfig): boolean;
|
|
126
117
|
declare function isTabWritable(session: AgriCoreSession, activeScopeId: string, tabConfig: TabConfig): boolean;
|
|
127
118
|
declare function evaluateBaseAccess(resourcePath: string, session: {
|
|
@@ -172,4 +163,4 @@ declare function calculateFileMetadataMatch(criteria: {
|
|
|
172
163
|
contextMatch?: string[];
|
|
173
164
|
}, fileMetadata: Record<string, any>, auditContext: Record<string, any>): number;
|
|
174
165
|
|
|
175
|
-
export { AccessLevelType, AgriCoreSession, AgriLogger, AppError, AvailableScope, Converter, ErrorFactory, FormMeta, InfrastructureFields, ResolvedError, ResourceRequirement, TabConfig, UserRoleType, Validator,
|
|
166
|
+
export { AccessLevelType, AgriCoreSession, AgriLogger, AppError, AvailableScope, Converter, ErrorFactory, FormMeta, InfrastructureFields, ResolvedError, ResourceRequirement, TabConfig, UserRoleType, Validator, assertTenantBoundary, calculateFileMetadataMatch, evaluateBaseAccess, extractAppCode, findSpecificOverride, generateCanonicalId, generateDocumentPath, generateInfrastructureFields, getAcceptedMimeTypes, getApproveAction, getFormMeta, getFormsGroupedByModule, getTaskTypeOptions, handleAppErrorResponse, isTabVisible, isTabWritable, resolveAccess, resolveAppError, resolveEffectiveAccess, resolveError, verifyAndExtractSession, withAgriLogging };
|
package/dist/index.js
CHANGED
|
@@ -87,12 +87,8 @@ __export(index_exports, {
|
|
|
87
87
|
Validator: () => Validator,
|
|
88
88
|
VigorRating: () => VigorRating,
|
|
89
89
|
WaterSource: () => WaterSource,
|
|
90
|
-
assertCanWrite: () => assertCanWrite,
|
|
91
90
|
assertTenantBoundary: () => assertTenantBoundary,
|
|
92
|
-
buildRlsFilter: () => buildRlsFilter,
|
|
93
91
|
calculateFileMetadataMatch: () => calculateFileMetadataMatch,
|
|
94
|
-
canRead: () => canRead,
|
|
95
|
-
canWrite: () => canWrite,
|
|
96
92
|
evaluateBaseAccess: () => evaluateBaseAccess,
|
|
97
93
|
extractAppCode: () => extractAppCode,
|
|
98
94
|
findSpecificOverride: () => findSpecificOverride,
|
|
@@ -111,7 +107,6 @@ __export(index_exports, {
|
|
|
111
107
|
resolveAppError: () => resolveAppError,
|
|
112
108
|
resolveEffectiveAccess: () => resolveEffectiveAccess,
|
|
113
109
|
resolveError: () => resolveError,
|
|
114
|
-
resolveMenuVisibility: () => resolveMenuVisibility,
|
|
115
110
|
verifyAndExtractSession: () => verifyAndExtractSession,
|
|
116
111
|
withAgriLogging: () => withAgriLogging
|
|
117
112
|
});
|
|
@@ -651,35 +646,47 @@ var RESOURCE_PATHS = {
|
|
|
651
646
|
// ── Operations ────────────────────────────────────────────────────────────
|
|
652
647
|
farmManagement: "operations.farmManagement",
|
|
653
648
|
packhouse: "operations.packhouse",
|
|
649
|
+
accommodation: "operations.accommodation",
|
|
654
650
|
// ── Inventory ────────────────────────────────────────────────────────────
|
|
655
651
|
// === Consumables ===
|
|
652
|
+
inventory: "inventory",
|
|
653
|
+
inventoryConsumable: "inventory.consumable",
|
|
656
654
|
inventoryConsumableProduct: "inventory.consumable.product",
|
|
657
655
|
inventoryConsumableStock: "inventory.consumable.stock",
|
|
658
656
|
inventoryConsumableStockEditThreshold: "inventory.consumable.stock.editThreshold",
|
|
657
|
+
inventoryConsumableStockReconcile: "inventory.consumable.stock.reconcile",
|
|
659
658
|
inventoryConsumableStockMovement: "inventory.consumable.stockMovement",
|
|
660
659
|
inventoryConsumableStockMovementTransfer: "inventory.consumable.stockMovement.transfer",
|
|
661
|
-
inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
660
|
+
// inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
662
661
|
// === Chemicals ===
|
|
662
|
+
inventoryChemical: "inventory.chemical",
|
|
663
663
|
inventoryChemicalProduct: "inventory.chemical.product",
|
|
664
664
|
inventoryChemicalStock: "inventory.chemical.stock",
|
|
665
665
|
inventoryChemicalStockEditThreshold: "inventory.chemical.stock.editThreshold",
|
|
666
|
+
inventoryChemicalStockReconcile: "inventory.chemical.stock.reconcile",
|
|
666
667
|
inventoryChemicalStockMovement: "inventory.chemical.stockMovement",
|
|
667
668
|
inventoryChemicalStockMovementTransfer: "inventory.chemical.stockMovement.transfer",
|
|
668
|
-
inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
669
|
+
// inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
669
670
|
// === Maintenance Parts ===
|
|
671
|
+
inventoryMaintenancePart: "inventory.maintenancePart",
|
|
670
672
|
inventoryMaintenancePartProduct: "inventory.maintenancePart.product",
|
|
671
673
|
inventoryMaintenancePartStock: "inventory.maintenancePart.stock",
|
|
672
674
|
inventoryMaintenancePartStockEditThreshold: "inventory.maintenancePart.stock.editThreshold",
|
|
675
|
+
inventoryMaintenancePartStockReconcile: "inventory.maintenancePart.stock.reconcile",
|
|
673
676
|
inventoryMaintenancePartStockMovement: "inventory.maintenancePart.stockMovement",
|
|
674
677
|
inventoryMaintenancePartStockMovementTransfer: "inventory.maintenancePart.stockMovement.transfer",
|
|
675
|
-
inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
676
|
-
accommodation: "operations.accommodation",
|
|
678
|
+
// inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
677
679
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
678
680
|
equipPreStart: "equipment.preStart",
|
|
679
681
|
equipMaintenance: "equipment.maintenance",
|
|
680
682
|
equipFuelRegister: "equipment.fuelRegister",
|
|
681
683
|
equipCalibration: "equipment.calibration",
|
|
682
684
|
equipFleet: "equipment.fleetManagement",
|
|
685
|
+
finance: "finance",
|
|
686
|
+
financeProductRequisition: "finance.product.requistion",
|
|
687
|
+
financeDashboard: "finance.dashboard",
|
|
688
|
+
financeTransaction: "finance.transaction",
|
|
689
|
+
financeBudgetAllocation: "finance.budgetAllocation",
|
|
683
690
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
684
691
|
safetyAuditing: "safety.auditing",
|
|
685
692
|
safetyFood: "safety.foodSafety",
|
|
@@ -705,14 +712,20 @@ var RESOURCE_MODULE_MAP = {
|
|
|
705
712
|
[RESOURCE_PATHS.equipment]: ALL_OPERATIONS,
|
|
706
713
|
[RESOURCE_PATHS.safety]: ALL_OPERATIONS,
|
|
707
714
|
[RESOURCE_PATHS.team]: ALL_OPERATIONS,
|
|
715
|
+
[RESOURCE_PATHS.inventory]: ALL_OPERATIONS,
|
|
716
|
+
[RESOURCE_PATHS.finance]: ALL_OPERATIONS,
|
|
708
717
|
[RESOURCE_PATHS.records]: ALL_OPERATIONS,
|
|
709
718
|
[RESOURCE_PATHS.adminSettings]: ALL_OPERATIONS,
|
|
710
719
|
// ── Inventory ──────────────────────────────────────────────────────
|
|
720
|
+
[RESOURCE_PATHS.inventoryConsumable]: ALL_OPERATIONS,
|
|
711
721
|
[RESOURCE_PATHS.inventoryConsumableProduct]: ALL_OPERATIONS,
|
|
712
722
|
[RESOURCE_PATHS.inventoryConsumableStock]: ALL_OPERATIONS,
|
|
713
723
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: ALL_OPERATIONS,
|
|
724
|
+
[RESOURCE_PATHS.inventoryChemical]: ALL_OPERATIONS,
|
|
714
725
|
[RESOURCE_PATHS.inventoryChemicalProduct]: ALL_OPERATIONS,
|
|
715
726
|
[RESOURCE_PATHS.inventoryChemicalStock]: ALL_OPERATIONS,
|
|
727
|
+
[RESOURCE_PATHS.inventoryChemicalStockMovement]: ALL_OPERATIONS,
|
|
728
|
+
[RESOURCE_PATHS.inventoryMaintenancePart]: ALL_OPERATIONS,
|
|
716
729
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: ALL_OPERATIONS,
|
|
717
730
|
[RESOURCE_PATHS.inventoryMaintenancePartStock]: ALL_OPERATIONS,
|
|
718
731
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: ALL_OPERATIONS,
|
|
@@ -794,13 +807,16 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
794
807
|
[RESOURCE_PATHS.inventoryConsumableStockEditThreshold]: {
|
|
795
808
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
796
809
|
},
|
|
810
|
+
[RESOURCE_PATHS.inventoryConsumableStockReconcile]: {
|
|
811
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
812
|
+
},
|
|
797
813
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: { allowedRoles: EVERYONE },
|
|
798
814
|
[RESOURCE_PATHS.inventoryConsumableStockMovementTransfer]: {
|
|
799
815
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
800
816
|
},
|
|
801
|
-
[RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
802
|
-
|
|
803
|
-
},
|
|
817
|
+
// [RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
818
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
819
|
+
// },
|
|
804
820
|
// CHEMICALS PERMISSIONS
|
|
805
821
|
[RESOURCE_PATHS.inventoryChemicalProduct]: {
|
|
806
822
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -809,13 +825,16 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
809
825
|
[RESOURCE_PATHS.inventoryChemicalStockEditThreshold]: {
|
|
810
826
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
811
827
|
},
|
|
828
|
+
[RESOURCE_PATHS.inventoryChemicalStockReconcile]: {
|
|
829
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
830
|
+
},
|
|
812
831
|
[RESOURCE_PATHS.inventoryChemicalStockMovement]: { allowedRoles: EVERYONE },
|
|
813
832
|
[RESOURCE_PATHS.inventoryChemicalStockMovementTransfer]: {
|
|
814
833
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
815
834
|
},
|
|
816
|
-
[RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
817
|
-
|
|
818
|
-
},
|
|
835
|
+
// [RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
836
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
837
|
+
// },
|
|
819
838
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: {
|
|
820
839
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
821
840
|
},
|
|
@@ -823,12 +842,28 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
823
842
|
[RESOURCE_PATHS.inventoryMaintenancePartStockEditThreshold]: {
|
|
824
843
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
825
844
|
},
|
|
845
|
+
[RESOURCE_PATHS.inventoryMaintenancePartStockReconcile]: {
|
|
846
|
+
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
847
|
+
},
|
|
826
848
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: { allowedRoles: EVERYONE },
|
|
827
|
-
[RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
849
|
+
// [RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
850
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
851
|
+
// },
|
|
852
|
+
// ── Finance ────────────────────────────────────────────────────────────────
|
|
853
|
+
[RESOURCE_PATHS.financeProductRequisition]: {
|
|
828
854
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
829
855
|
},
|
|
830
|
-
[RESOURCE_PATHS.
|
|
831
|
-
allowedRoles: [UserRole.OWNER,
|
|
856
|
+
[RESOURCE_PATHS.financeBudgetAllocation]: {
|
|
857
|
+
allowedRoles: [UserRole.OWNER],
|
|
858
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
859
|
+
},
|
|
860
|
+
[RESOURCE_PATHS.financeDashboard]: {
|
|
861
|
+
allowedRoles: [UserRole.OWNER],
|
|
862
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
863
|
+
},
|
|
864
|
+
[RESOURCE_PATHS.financeTransaction]: {
|
|
865
|
+
allowedRoles: [UserRole.OWNER],
|
|
866
|
+
requiredPrivileges: [UserPrivilege.FINANCE]
|
|
832
867
|
},
|
|
833
868
|
// ── Admin Settings ─────────────────────────────────────────────────────────
|
|
834
869
|
[RESOURCE_PATHS.adminUserRoster]: {
|
|
@@ -1296,39 +1331,6 @@ function generateInfrastructureFields(activeScope, availableScopes) {
|
|
|
1296
1331
|
authScopeId: activeScope.authScopeId
|
|
1297
1332
|
};
|
|
1298
1333
|
}
|
|
1299
|
-
function buildRlsFilter(session, extra = {}) {
|
|
1300
|
-
return { ...extra, authScopeId: { $in: session.readScopes || [] } };
|
|
1301
|
-
}
|
|
1302
|
-
function canRead(session, authScopeId) {
|
|
1303
|
-
return session.readScopes?.includes(authScopeId) ?? false;
|
|
1304
|
-
}
|
|
1305
|
-
function canWrite(session, authScopeId, resourcePath) {
|
|
1306
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
1307
|
-
if (override === "WRITE") return true;
|
|
1308
|
-
if (override === "NONE" || override === "READ") return false;
|
|
1309
|
-
return session.writeScopes?.includes(authScopeId) ?? false;
|
|
1310
|
-
}
|
|
1311
|
-
function assertCanWrite(session, authScopeId, resourcePath) {
|
|
1312
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
1313
|
-
if (override === "WRITE") return;
|
|
1314
|
-
if (override === "NONE" || override === "READ") {
|
|
1315
|
-
throw new AppError(
|
|
1316
|
-
403,
|
|
1317
|
-
MOD.SESSION,
|
|
1318
|
-
CAT.PERMISSION,
|
|
1319
|
-
ACT.GENERIC,
|
|
1320
|
-
`You do not have write access to "${resourcePath}" in this scope.`
|
|
1321
|
-
);
|
|
1322
|
-
}
|
|
1323
|
-
if (session.writeScopes?.includes(authScopeId)) return;
|
|
1324
|
-
throw new AppError(
|
|
1325
|
-
403,
|
|
1326
|
-
MOD.SESSION,
|
|
1327
|
-
CAT.PERMISSION,
|
|
1328
|
-
ACT.GENERIC,
|
|
1329
|
-
"You do not have permission to modify records in this scope."
|
|
1330
|
-
);
|
|
1331
|
-
}
|
|
1332
1334
|
function resolveAccess(session, activeScopeId, tabConfig) {
|
|
1333
1335
|
const resourcePath = tabConfig?.resourceId;
|
|
1334
1336
|
const overrides = session.resourceOverrides?.[activeScopeId] ?? {};
|
|
@@ -1352,15 +1354,6 @@ function resolveAccess(session, activeScopeId, tabConfig) {
|
|
|
1352
1354
|
}
|
|
1353
1355
|
return "READ";
|
|
1354
1356
|
}
|
|
1355
|
-
function resolveMenuVisibility(session, authScopeId, resourcePath) {
|
|
1356
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
1357
|
-
if (override === "NONE") return "hidden";
|
|
1358
|
-
if (override === "READ") return "read_only";
|
|
1359
|
-
if (override === "WRITE") return "active";
|
|
1360
|
-
if (session.writeScopes?.includes(authScopeId)) return "active";
|
|
1361
|
-
if (session.readScopes?.includes(authScopeId)) return "read_only";
|
|
1362
|
-
return "hidden";
|
|
1363
|
-
}
|
|
1364
1357
|
function isTabVisible(session, activeScopeId, tabConfig) {
|
|
1365
1358
|
return resolveAccess(session, activeScopeId, tabConfig) !== "NONE";
|
|
1366
1359
|
}
|
|
@@ -1574,12 +1567,8 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
1574
1567
|
Validator,
|
|
1575
1568
|
VigorRating,
|
|
1576
1569
|
WaterSource,
|
|
1577
|
-
assertCanWrite,
|
|
1578
1570
|
assertTenantBoundary,
|
|
1579
|
-
buildRlsFilter,
|
|
1580
1571
|
calculateFileMetadataMatch,
|
|
1581
|
-
canRead,
|
|
1582
|
-
canWrite,
|
|
1583
1572
|
evaluateBaseAccess,
|
|
1584
1573
|
extractAppCode,
|
|
1585
1574
|
findSpecificOverride,
|
|
@@ -1598,7 +1587,6 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
1598
1587
|
resolveAppError,
|
|
1599
1588
|
resolveEffectiveAccess,
|
|
1600
1589
|
resolveError,
|
|
1601
|
-
resolveMenuVisibility,
|
|
1602
1590
|
verifyAndExtractSession,
|
|
1603
1591
|
withAgriLogging
|
|
1604
1592
|
});
|
package/dist/index.mjs
CHANGED
|
@@ -61,7 +61,7 @@ import {
|
|
|
61
61
|
UserRole,
|
|
62
62
|
VigorRating,
|
|
63
63
|
WaterSource
|
|
64
|
-
} from "./chunk-
|
|
64
|
+
} from "./chunk-DZW2VL6D.mjs";
|
|
65
65
|
|
|
66
66
|
// src/index.ts
|
|
67
67
|
import { jwtVerify } from "jose";
|
|
@@ -360,39 +360,6 @@ function generateInfrastructureFields(activeScope, availableScopes) {
|
|
|
360
360
|
authScopeId: activeScope.authScopeId
|
|
361
361
|
};
|
|
362
362
|
}
|
|
363
|
-
function buildRlsFilter(session, extra = {}) {
|
|
364
|
-
return { ...extra, authScopeId: { $in: session.readScopes || [] } };
|
|
365
|
-
}
|
|
366
|
-
function canRead(session, authScopeId) {
|
|
367
|
-
return session.readScopes?.includes(authScopeId) ?? false;
|
|
368
|
-
}
|
|
369
|
-
function canWrite(session, authScopeId, resourcePath) {
|
|
370
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
371
|
-
if (override === "WRITE") return true;
|
|
372
|
-
if (override === "NONE" || override === "READ") return false;
|
|
373
|
-
return session.writeScopes?.includes(authScopeId) ?? false;
|
|
374
|
-
}
|
|
375
|
-
function assertCanWrite(session, authScopeId, resourcePath) {
|
|
376
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
377
|
-
if (override === "WRITE") return;
|
|
378
|
-
if (override === "NONE" || override === "READ") {
|
|
379
|
-
throw new AppError(
|
|
380
|
-
403,
|
|
381
|
-
MOD.SESSION,
|
|
382
|
-
CAT.PERMISSION,
|
|
383
|
-
ACT.GENERIC,
|
|
384
|
-
`You do not have write access to "${resourcePath}" in this scope.`
|
|
385
|
-
);
|
|
386
|
-
}
|
|
387
|
-
if (session.writeScopes?.includes(authScopeId)) return;
|
|
388
|
-
throw new AppError(
|
|
389
|
-
403,
|
|
390
|
-
MOD.SESSION,
|
|
391
|
-
CAT.PERMISSION,
|
|
392
|
-
ACT.GENERIC,
|
|
393
|
-
"You do not have permission to modify records in this scope."
|
|
394
|
-
);
|
|
395
|
-
}
|
|
396
363
|
function resolveAccess(session, activeScopeId, tabConfig) {
|
|
397
364
|
const resourcePath = tabConfig?.resourceId;
|
|
398
365
|
const overrides = session.resourceOverrides?.[activeScopeId] ?? {};
|
|
@@ -416,15 +383,6 @@ function resolveAccess(session, activeScopeId, tabConfig) {
|
|
|
416
383
|
}
|
|
417
384
|
return "READ";
|
|
418
385
|
}
|
|
419
|
-
function resolveMenuVisibility(session, authScopeId, resourcePath) {
|
|
420
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
421
|
-
if (override === "NONE") return "hidden";
|
|
422
|
-
if (override === "READ") return "read_only";
|
|
423
|
-
if (override === "WRITE") return "active";
|
|
424
|
-
if (session.writeScopes?.includes(authScopeId)) return "active";
|
|
425
|
-
if (session.readScopes?.includes(authScopeId)) return "read_only";
|
|
426
|
-
return "hidden";
|
|
427
|
-
}
|
|
428
386
|
function isTabVisible(session, activeScopeId, tabConfig) {
|
|
429
387
|
return resolveAccess(session, activeScopeId, tabConfig) !== "NONE";
|
|
430
388
|
}
|
|
@@ -637,12 +595,8 @@ export {
|
|
|
637
595
|
Validator,
|
|
638
596
|
VigorRating,
|
|
639
597
|
WaterSource,
|
|
640
|
-
assertCanWrite,
|
|
641
598
|
assertTenantBoundary,
|
|
642
|
-
buildRlsFilter,
|
|
643
599
|
calculateFileMetadataMatch,
|
|
644
|
-
canRead,
|
|
645
|
-
canWrite,
|
|
646
600
|
evaluateBaseAccess,
|
|
647
601
|
extractAppCode,
|
|
648
602
|
findSpecificOverride,
|
|
@@ -661,7 +615,6 @@ export {
|
|
|
661
615
|
resolveAppError,
|
|
662
616
|
resolveEffectiveAccess,
|
|
663
617
|
resolveError,
|
|
664
|
-
resolveMenuVisibility,
|
|
665
618
|
verifyAndExtractSession,
|
|
666
619
|
withAgriLogging
|
|
667
620
|
};
|