@litusarchieve18/agricore-utils 1.0.20 → 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 +2 -0
- package/dist/{chunk-XD36URZU.mjs → chunk-DZW2VL6D.mjs} +41 -13
- package/dist/{constants-C_Pwif6Q.d.mts → constants-BQmsBTQ7.d.mts} +10 -4
- package/dist/{constants-C_Pwif6Q.d.ts → constants-BQmsBTQ7.d.ts} +10 -4
- package/dist/constants.d.mts +1 -1
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +41 -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 +41 -65
- package/dist/index.mjs +1 -48
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -183,6 +183,8 @@ Run the publish command:
|
|
|
183
183
|
Bash
|
|
184
184
|
npm publish --access public
|
|
185
185
|
📝 Version History
|
|
186
|
+
V1.0.20 — add finance access and some top menu section that were missing
|
|
187
|
+
|
|
186
188
|
V1.0.20 — add inventory access reconcile
|
|
187
189
|
|
|
188
190
|
V1.0.19 — refactor inventory access in RESOURCE_PATHS
|
|
@@ -345,38 +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",
|
|
353
356
|
inventoryConsumableStockReconcile: "inventory.consumable.stock.reconcile",
|
|
354
357
|
inventoryConsumableStockMovement: "inventory.consumable.stockMovement",
|
|
355
358
|
inventoryConsumableStockMovementTransfer: "inventory.consumable.stockMovement.transfer",
|
|
356
|
-
inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
359
|
+
// inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
357
360
|
// === Chemicals ===
|
|
361
|
+
inventoryChemical: "inventory.chemical",
|
|
358
362
|
inventoryChemicalProduct: "inventory.chemical.product",
|
|
359
363
|
inventoryChemicalStock: "inventory.chemical.stock",
|
|
360
364
|
inventoryChemicalStockEditThreshold: "inventory.chemical.stock.editThreshold",
|
|
361
365
|
inventoryChemicalStockReconcile: "inventory.chemical.stock.reconcile",
|
|
362
366
|
inventoryChemicalStockMovement: "inventory.chemical.stockMovement",
|
|
363
367
|
inventoryChemicalStockMovementTransfer: "inventory.chemical.stockMovement.transfer",
|
|
364
|
-
inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
368
|
+
// inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
365
369
|
// === Maintenance Parts ===
|
|
370
|
+
inventoryMaintenancePart: "inventory.maintenancePart",
|
|
366
371
|
inventoryMaintenancePartProduct: "inventory.maintenancePart.product",
|
|
367
372
|
inventoryMaintenancePartStock: "inventory.maintenancePart.stock",
|
|
368
373
|
inventoryMaintenancePartStockEditThreshold: "inventory.maintenancePart.stock.editThreshold",
|
|
369
374
|
inventoryMaintenancePartStockReconcile: "inventory.maintenancePart.stock.reconcile",
|
|
370
375
|
inventoryMaintenancePartStockMovement: "inventory.maintenancePart.stockMovement",
|
|
371
376
|
inventoryMaintenancePartStockMovementTransfer: "inventory.maintenancePart.stockMovement.transfer",
|
|
372
|
-
inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
373
|
-
accommodation: "operations.accommodation",
|
|
377
|
+
// inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
374
378
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
375
379
|
equipPreStart: "equipment.preStart",
|
|
376
380
|
equipMaintenance: "equipment.maintenance",
|
|
377
381
|
equipFuelRegister: "equipment.fuelRegister",
|
|
378
382
|
equipCalibration: "equipment.calibration",
|
|
379
383
|
equipFleet: "equipment.fleetManagement",
|
|
384
|
+
finance: "finance",
|
|
385
|
+
financeProductRequisition: "finance.product.requistion",
|
|
386
|
+
financeDashboard: "finance.dashboard",
|
|
387
|
+
financeTransaction: "finance.transaction",
|
|
388
|
+
financeBudgetAllocation: "finance.budgetAllocation",
|
|
380
389
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
381
390
|
safetyAuditing: "safety.auditing",
|
|
382
391
|
safetyFood: "safety.foodSafety",
|
|
@@ -402,14 +411,20 @@ var RESOURCE_MODULE_MAP = {
|
|
|
402
411
|
[RESOURCE_PATHS.equipment]: ALL_OPERATIONS,
|
|
403
412
|
[RESOURCE_PATHS.safety]: ALL_OPERATIONS,
|
|
404
413
|
[RESOURCE_PATHS.team]: ALL_OPERATIONS,
|
|
414
|
+
[RESOURCE_PATHS.inventory]: ALL_OPERATIONS,
|
|
415
|
+
[RESOURCE_PATHS.finance]: ALL_OPERATIONS,
|
|
405
416
|
[RESOURCE_PATHS.records]: ALL_OPERATIONS,
|
|
406
417
|
[RESOURCE_PATHS.adminSettings]: ALL_OPERATIONS,
|
|
407
418
|
// ── Inventory ──────────────────────────────────────────────────────
|
|
419
|
+
[RESOURCE_PATHS.inventoryConsumable]: ALL_OPERATIONS,
|
|
408
420
|
[RESOURCE_PATHS.inventoryConsumableProduct]: ALL_OPERATIONS,
|
|
409
421
|
[RESOURCE_PATHS.inventoryConsumableStock]: ALL_OPERATIONS,
|
|
410
422
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: ALL_OPERATIONS,
|
|
423
|
+
[RESOURCE_PATHS.inventoryChemical]: ALL_OPERATIONS,
|
|
411
424
|
[RESOURCE_PATHS.inventoryChemicalProduct]: ALL_OPERATIONS,
|
|
412
425
|
[RESOURCE_PATHS.inventoryChemicalStock]: ALL_OPERATIONS,
|
|
426
|
+
[RESOURCE_PATHS.inventoryChemicalStockMovement]: ALL_OPERATIONS,
|
|
427
|
+
[RESOURCE_PATHS.inventoryMaintenancePart]: ALL_OPERATIONS,
|
|
413
428
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: ALL_OPERATIONS,
|
|
414
429
|
[RESOURCE_PATHS.inventoryMaintenancePartStock]: ALL_OPERATIONS,
|
|
415
430
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: ALL_OPERATIONS,
|
|
@@ -498,9 +513,9 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
498
513
|
[RESOURCE_PATHS.inventoryConsumableStockMovementTransfer]: {
|
|
499
514
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
500
515
|
},
|
|
501
|
-
[RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
502
|
-
|
|
503
|
-
},
|
|
516
|
+
// [RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
517
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
518
|
+
// },
|
|
504
519
|
// CHEMICALS PERMISSIONS
|
|
505
520
|
[RESOURCE_PATHS.inventoryChemicalProduct]: {
|
|
506
521
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -516,9 +531,9 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
516
531
|
[RESOURCE_PATHS.inventoryChemicalStockMovementTransfer]: {
|
|
517
532
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
518
533
|
},
|
|
519
|
-
[RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
520
|
-
|
|
521
|
-
},
|
|
534
|
+
// [RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
535
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
536
|
+
// },
|
|
522
537
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: {
|
|
523
538
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
524
539
|
},
|
|
@@ -530,11 +545,24 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
530
545
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
531
546
|
},
|
|
532
547
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: { allowedRoles: EVERYONE },
|
|
533
|
-
[RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
548
|
+
// [RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
549
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
550
|
+
// },
|
|
551
|
+
// ── Finance ────────────────────────────────────────────────────────────────
|
|
552
|
+
[RESOURCE_PATHS.financeProductRequisition]: {
|
|
534
553
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
535
554
|
},
|
|
536
|
-
[RESOURCE_PATHS.
|
|
537
|
-
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]
|
|
538
566
|
},
|
|
539
567
|
// ── Admin Settings ─────────────────────────────────────────────────────────
|
|
540
568
|
[RESOURCE_PATHS.adminUserRoster]: {
|
|
@@ -430,33 +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;
|
|
436
439
|
inventoryConsumableStockReconcile: string;
|
|
437
440
|
inventoryConsumableStockMovement: string;
|
|
438
441
|
inventoryConsumableStockMovementTransfer: string;
|
|
439
|
-
|
|
442
|
+
inventoryChemical: string;
|
|
440
443
|
inventoryChemicalProduct: string;
|
|
441
444
|
inventoryChemicalStock: string;
|
|
442
445
|
inventoryChemicalStockEditThreshold: string;
|
|
443
446
|
inventoryChemicalStockReconcile: string;
|
|
444
447
|
inventoryChemicalStockMovement: string;
|
|
445
448
|
inventoryChemicalStockMovementTransfer: string;
|
|
446
|
-
|
|
449
|
+
inventoryMaintenancePart: string;
|
|
447
450
|
inventoryMaintenancePartProduct: string;
|
|
448
451
|
inventoryMaintenancePartStock: string;
|
|
449
452
|
inventoryMaintenancePartStockEditThreshold: string;
|
|
450
453
|
inventoryMaintenancePartStockReconcile: string;
|
|
451
454
|
inventoryMaintenancePartStockMovement: string;
|
|
452
455
|
inventoryMaintenancePartStockMovementTransfer: string;
|
|
453
|
-
inventoryMaintenancePartStockMovementPurchase: string;
|
|
454
|
-
accommodation: string;
|
|
455
456
|
equipPreStart: string;
|
|
456
457
|
equipMaintenance: string;
|
|
457
458
|
equipFuelRegister: string;
|
|
458
459
|
equipCalibration: string;
|
|
459
460
|
equipFleet: string;
|
|
461
|
+
finance: string;
|
|
462
|
+
financeProductRequisition: string;
|
|
463
|
+
financeDashboard: string;
|
|
464
|
+
financeTransaction: string;
|
|
465
|
+
financeBudgetAllocation: string;
|
|
460
466
|
safetyAuditing: string;
|
|
461
467
|
safetyFood: string;
|
|
462
468
|
safetyWhs: string;
|
|
@@ -430,33 +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;
|
|
436
439
|
inventoryConsumableStockReconcile: string;
|
|
437
440
|
inventoryConsumableStockMovement: string;
|
|
438
441
|
inventoryConsumableStockMovementTransfer: string;
|
|
439
|
-
|
|
442
|
+
inventoryChemical: string;
|
|
440
443
|
inventoryChemicalProduct: string;
|
|
441
444
|
inventoryChemicalStock: string;
|
|
442
445
|
inventoryChemicalStockEditThreshold: string;
|
|
443
446
|
inventoryChemicalStockReconcile: string;
|
|
444
447
|
inventoryChemicalStockMovement: string;
|
|
445
448
|
inventoryChemicalStockMovementTransfer: string;
|
|
446
|
-
|
|
449
|
+
inventoryMaintenancePart: string;
|
|
447
450
|
inventoryMaintenancePartProduct: string;
|
|
448
451
|
inventoryMaintenancePartStock: string;
|
|
449
452
|
inventoryMaintenancePartStockEditThreshold: string;
|
|
450
453
|
inventoryMaintenancePartStockReconcile: string;
|
|
451
454
|
inventoryMaintenancePartStockMovement: string;
|
|
452
455
|
inventoryMaintenancePartStockMovementTransfer: string;
|
|
453
|
-
inventoryMaintenancePartStockMovementPurchase: string;
|
|
454
|
-
accommodation: string;
|
|
455
456
|
equipPreStart: string;
|
|
456
457
|
equipMaintenance: string;
|
|
457
458
|
equipFuelRegister: string;
|
|
458
459
|
equipCalibration: string;
|
|
459
460
|
equipFleet: string;
|
|
461
|
+
finance: string;
|
|
462
|
+
financeProductRequisition: string;
|
|
463
|
+
financeDashboard: string;
|
|
464
|
+
financeTransaction: string;
|
|
465
|
+
financeBudgetAllocation: string;
|
|
460
466
|
safetyAuditing: string;
|
|
461
467
|
safetyFood: string;
|
|
462
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,38 +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",
|
|
438
441
|
inventoryConsumableStockReconcile: "inventory.consumable.stock.reconcile",
|
|
439
442
|
inventoryConsumableStockMovement: "inventory.consumable.stockMovement",
|
|
440
443
|
inventoryConsumableStockMovementTransfer: "inventory.consumable.stockMovement.transfer",
|
|
441
|
-
inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
444
|
+
// inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
442
445
|
// === Chemicals ===
|
|
446
|
+
inventoryChemical: "inventory.chemical",
|
|
443
447
|
inventoryChemicalProduct: "inventory.chemical.product",
|
|
444
448
|
inventoryChemicalStock: "inventory.chemical.stock",
|
|
445
449
|
inventoryChemicalStockEditThreshold: "inventory.chemical.stock.editThreshold",
|
|
446
450
|
inventoryChemicalStockReconcile: "inventory.chemical.stock.reconcile",
|
|
447
451
|
inventoryChemicalStockMovement: "inventory.chemical.stockMovement",
|
|
448
452
|
inventoryChemicalStockMovementTransfer: "inventory.chemical.stockMovement.transfer",
|
|
449
|
-
inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
453
|
+
// inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
450
454
|
// === Maintenance Parts ===
|
|
455
|
+
inventoryMaintenancePart: "inventory.maintenancePart",
|
|
451
456
|
inventoryMaintenancePartProduct: "inventory.maintenancePart.product",
|
|
452
457
|
inventoryMaintenancePartStock: "inventory.maintenancePart.stock",
|
|
453
458
|
inventoryMaintenancePartStockEditThreshold: "inventory.maintenancePart.stock.editThreshold",
|
|
454
459
|
inventoryMaintenancePartStockReconcile: "inventory.maintenancePart.stock.reconcile",
|
|
455
460
|
inventoryMaintenancePartStockMovement: "inventory.maintenancePart.stockMovement",
|
|
456
461
|
inventoryMaintenancePartStockMovementTransfer: "inventory.maintenancePart.stockMovement.transfer",
|
|
457
|
-
inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
458
|
-
accommodation: "operations.accommodation",
|
|
462
|
+
// inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
459
463
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
460
464
|
equipPreStart: "equipment.preStart",
|
|
461
465
|
equipMaintenance: "equipment.maintenance",
|
|
462
466
|
equipFuelRegister: "equipment.fuelRegister",
|
|
463
467
|
equipCalibration: "equipment.calibration",
|
|
464
468
|
equipFleet: "equipment.fleetManagement",
|
|
469
|
+
finance: "finance",
|
|
470
|
+
financeProductRequisition: "finance.product.requistion",
|
|
471
|
+
financeDashboard: "finance.dashboard",
|
|
472
|
+
financeTransaction: "finance.transaction",
|
|
473
|
+
financeBudgetAllocation: "finance.budgetAllocation",
|
|
465
474
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
466
475
|
safetyAuditing: "safety.auditing",
|
|
467
476
|
safetyFood: "safety.foodSafety",
|
|
@@ -487,14 +496,20 @@ var RESOURCE_MODULE_MAP = {
|
|
|
487
496
|
[RESOURCE_PATHS.equipment]: ALL_OPERATIONS,
|
|
488
497
|
[RESOURCE_PATHS.safety]: ALL_OPERATIONS,
|
|
489
498
|
[RESOURCE_PATHS.team]: ALL_OPERATIONS,
|
|
499
|
+
[RESOURCE_PATHS.inventory]: ALL_OPERATIONS,
|
|
500
|
+
[RESOURCE_PATHS.finance]: ALL_OPERATIONS,
|
|
490
501
|
[RESOURCE_PATHS.records]: ALL_OPERATIONS,
|
|
491
502
|
[RESOURCE_PATHS.adminSettings]: ALL_OPERATIONS,
|
|
492
503
|
// ── Inventory ──────────────────────────────────────────────────────
|
|
504
|
+
[RESOURCE_PATHS.inventoryConsumable]: ALL_OPERATIONS,
|
|
493
505
|
[RESOURCE_PATHS.inventoryConsumableProduct]: ALL_OPERATIONS,
|
|
494
506
|
[RESOURCE_PATHS.inventoryConsumableStock]: ALL_OPERATIONS,
|
|
495
507
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: ALL_OPERATIONS,
|
|
508
|
+
[RESOURCE_PATHS.inventoryChemical]: ALL_OPERATIONS,
|
|
496
509
|
[RESOURCE_PATHS.inventoryChemicalProduct]: ALL_OPERATIONS,
|
|
497
510
|
[RESOURCE_PATHS.inventoryChemicalStock]: ALL_OPERATIONS,
|
|
511
|
+
[RESOURCE_PATHS.inventoryChemicalStockMovement]: ALL_OPERATIONS,
|
|
512
|
+
[RESOURCE_PATHS.inventoryMaintenancePart]: ALL_OPERATIONS,
|
|
498
513
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: ALL_OPERATIONS,
|
|
499
514
|
[RESOURCE_PATHS.inventoryMaintenancePartStock]: ALL_OPERATIONS,
|
|
500
515
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: ALL_OPERATIONS,
|
|
@@ -583,9 +598,9 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
583
598
|
[RESOURCE_PATHS.inventoryConsumableStockMovementTransfer]: {
|
|
584
599
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
585
600
|
},
|
|
586
|
-
[RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
587
|
-
|
|
588
|
-
},
|
|
601
|
+
// [RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
602
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
603
|
+
// },
|
|
589
604
|
// CHEMICALS PERMISSIONS
|
|
590
605
|
[RESOURCE_PATHS.inventoryChemicalProduct]: {
|
|
591
606
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -601,9 +616,9 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
601
616
|
[RESOURCE_PATHS.inventoryChemicalStockMovementTransfer]: {
|
|
602
617
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
603
618
|
},
|
|
604
|
-
[RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
605
|
-
|
|
606
|
-
},
|
|
619
|
+
// [RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
620
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
621
|
+
// },
|
|
607
622
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: {
|
|
608
623
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
609
624
|
},
|
|
@@ -615,11 +630,24 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
615
630
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
616
631
|
},
|
|
617
632
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: { allowedRoles: EVERYONE },
|
|
618
|
-
[RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
633
|
+
// [RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
634
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
635
|
+
// },
|
|
636
|
+
// ── Finance ────────────────────────────────────────────────────────────────
|
|
637
|
+
[RESOURCE_PATHS.financeProductRequisition]: {
|
|
619
638
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
620
639
|
},
|
|
621
|
-
[RESOURCE_PATHS.
|
|
622
|
-
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]
|
|
623
651
|
},
|
|
624
652
|
// ── Admin Settings ─────────────────────────────────────────────────────────
|
|
625
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,38 +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",
|
|
659
657
|
inventoryConsumableStockReconcile: "inventory.consumable.stock.reconcile",
|
|
660
658
|
inventoryConsumableStockMovement: "inventory.consumable.stockMovement",
|
|
661
659
|
inventoryConsumableStockMovementTransfer: "inventory.consumable.stockMovement.transfer",
|
|
662
|
-
inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
660
|
+
// inventoryConsumableStockMovementPurchase: "inventory.consumable.stockMovement.purchase",
|
|
663
661
|
// === Chemicals ===
|
|
662
|
+
inventoryChemical: "inventory.chemical",
|
|
664
663
|
inventoryChemicalProduct: "inventory.chemical.product",
|
|
665
664
|
inventoryChemicalStock: "inventory.chemical.stock",
|
|
666
665
|
inventoryChemicalStockEditThreshold: "inventory.chemical.stock.editThreshold",
|
|
667
666
|
inventoryChemicalStockReconcile: "inventory.chemical.stock.reconcile",
|
|
668
667
|
inventoryChemicalStockMovement: "inventory.chemical.stockMovement",
|
|
669
668
|
inventoryChemicalStockMovementTransfer: "inventory.chemical.stockMovement.transfer",
|
|
670
|
-
inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
669
|
+
// inventoryChemicalStockMovementPurchase: "inventory.chemical.stockMovement.purchase",
|
|
671
670
|
// === Maintenance Parts ===
|
|
671
|
+
inventoryMaintenancePart: "inventory.maintenancePart",
|
|
672
672
|
inventoryMaintenancePartProduct: "inventory.maintenancePart.product",
|
|
673
673
|
inventoryMaintenancePartStock: "inventory.maintenancePart.stock",
|
|
674
674
|
inventoryMaintenancePartStockEditThreshold: "inventory.maintenancePart.stock.editThreshold",
|
|
675
675
|
inventoryMaintenancePartStockReconcile: "inventory.maintenancePart.stock.reconcile",
|
|
676
676
|
inventoryMaintenancePartStockMovement: "inventory.maintenancePart.stockMovement",
|
|
677
677
|
inventoryMaintenancePartStockMovementTransfer: "inventory.maintenancePart.stockMovement.transfer",
|
|
678
|
-
inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
679
|
-
accommodation: "operations.accommodation",
|
|
678
|
+
// inventoryMaintenancePartStockMovementPurchase: "inventory.maintenancePart.stockMovement.purchase",
|
|
680
679
|
// ── Equipment & Fleet ──────────────────────────────────────────────────────
|
|
681
680
|
equipPreStart: "equipment.preStart",
|
|
682
681
|
equipMaintenance: "equipment.maintenance",
|
|
683
682
|
equipFuelRegister: "equipment.fuelRegister",
|
|
684
683
|
equipCalibration: "equipment.calibration",
|
|
685
684
|
equipFleet: "equipment.fleetManagement",
|
|
685
|
+
finance: "finance",
|
|
686
|
+
financeProductRequisition: "finance.product.requistion",
|
|
687
|
+
financeDashboard: "finance.dashboard",
|
|
688
|
+
financeTransaction: "finance.transaction",
|
|
689
|
+
financeBudgetAllocation: "finance.budgetAllocation",
|
|
686
690
|
// ── Safety, Quality & Compliance ──────────────────────────────────────────
|
|
687
691
|
safetyAuditing: "safety.auditing",
|
|
688
692
|
safetyFood: "safety.foodSafety",
|
|
@@ -708,14 +712,20 @@ var RESOURCE_MODULE_MAP = {
|
|
|
708
712
|
[RESOURCE_PATHS.equipment]: ALL_OPERATIONS,
|
|
709
713
|
[RESOURCE_PATHS.safety]: ALL_OPERATIONS,
|
|
710
714
|
[RESOURCE_PATHS.team]: ALL_OPERATIONS,
|
|
715
|
+
[RESOURCE_PATHS.inventory]: ALL_OPERATIONS,
|
|
716
|
+
[RESOURCE_PATHS.finance]: ALL_OPERATIONS,
|
|
711
717
|
[RESOURCE_PATHS.records]: ALL_OPERATIONS,
|
|
712
718
|
[RESOURCE_PATHS.adminSettings]: ALL_OPERATIONS,
|
|
713
719
|
// ── Inventory ──────────────────────────────────────────────────────
|
|
720
|
+
[RESOURCE_PATHS.inventoryConsumable]: ALL_OPERATIONS,
|
|
714
721
|
[RESOURCE_PATHS.inventoryConsumableProduct]: ALL_OPERATIONS,
|
|
715
722
|
[RESOURCE_PATHS.inventoryConsumableStock]: ALL_OPERATIONS,
|
|
716
723
|
[RESOURCE_PATHS.inventoryConsumableStockMovement]: ALL_OPERATIONS,
|
|
724
|
+
[RESOURCE_PATHS.inventoryChemical]: ALL_OPERATIONS,
|
|
717
725
|
[RESOURCE_PATHS.inventoryChemicalProduct]: ALL_OPERATIONS,
|
|
718
726
|
[RESOURCE_PATHS.inventoryChemicalStock]: ALL_OPERATIONS,
|
|
727
|
+
[RESOURCE_PATHS.inventoryChemicalStockMovement]: ALL_OPERATIONS,
|
|
728
|
+
[RESOURCE_PATHS.inventoryMaintenancePart]: ALL_OPERATIONS,
|
|
719
729
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: ALL_OPERATIONS,
|
|
720
730
|
[RESOURCE_PATHS.inventoryMaintenancePartStock]: ALL_OPERATIONS,
|
|
721
731
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: ALL_OPERATIONS,
|
|
@@ -804,9 +814,9 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
804
814
|
[RESOURCE_PATHS.inventoryConsumableStockMovementTransfer]: {
|
|
805
815
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
806
816
|
},
|
|
807
|
-
[RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
808
|
-
|
|
809
|
-
},
|
|
817
|
+
// [RESOURCE_PATHS.inventoryConsumableStockMovementPurchase]: {
|
|
818
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
819
|
+
// },
|
|
810
820
|
// CHEMICALS PERMISSIONS
|
|
811
821
|
[RESOURCE_PATHS.inventoryChemicalProduct]: {
|
|
812
822
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
@@ -822,9 +832,9 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
822
832
|
[RESOURCE_PATHS.inventoryChemicalStockMovementTransfer]: {
|
|
823
833
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
824
834
|
},
|
|
825
|
-
[RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
826
|
-
|
|
827
|
-
},
|
|
835
|
+
// [RESOURCE_PATHS.inventoryChemicalStockMovementPurchase]: {
|
|
836
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
837
|
+
// },
|
|
828
838
|
[RESOURCE_PATHS.inventoryMaintenancePartProduct]: {
|
|
829
839
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
830
840
|
},
|
|
@@ -836,11 +846,24 @@ var RESOURCE_REQUIREMENTS = {
|
|
|
836
846
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER, UserRole.SUPERVISOR]
|
|
837
847
|
},
|
|
838
848
|
[RESOURCE_PATHS.inventoryMaintenancePartStockMovement]: { allowedRoles: EVERYONE },
|
|
839
|
-
[RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
849
|
+
// [RESOURCE_PATHS.inventoryMaintenancePartStockMovementPurchase]: {
|
|
850
|
+
// allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
851
|
+
// },
|
|
852
|
+
// ── Finance ────────────────────────────────────────────────────────────────
|
|
853
|
+
[RESOURCE_PATHS.financeProductRequisition]: {
|
|
840
854
|
allowedRoles: [UserRole.OWNER, UserRole.MANAGER]
|
|
841
855
|
},
|
|
842
|
-
[RESOURCE_PATHS.
|
|
843
|
-
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]
|
|
844
867
|
},
|
|
845
868
|
// ── Admin Settings ─────────────────────────────────────────────────────────
|
|
846
869
|
[RESOURCE_PATHS.adminUserRoster]: {
|
|
@@ -1308,39 +1331,6 @@ function generateInfrastructureFields(activeScope, availableScopes) {
|
|
|
1308
1331
|
authScopeId: activeScope.authScopeId
|
|
1309
1332
|
};
|
|
1310
1333
|
}
|
|
1311
|
-
function buildRlsFilter(session, extra = {}) {
|
|
1312
|
-
return { ...extra, authScopeId: { $in: session.readScopes || [] } };
|
|
1313
|
-
}
|
|
1314
|
-
function canRead(session, authScopeId) {
|
|
1315
|
-
return session.readScopes?.includes(authScopeId) ?? false;
|
|
1316
|
-
}
|
|
1317
|
-
function canWrite(session, authScopeId, resourcePath) {
|
|
1318
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
1319
|
-
if (override === "WRITE") return true;
|
|
1320
|
-
if (override === "NONE" || override === "READ") return false;
|
|
1321
|
-
return session.writeScopes?.includes(authScopeId) ?? false;
|
|
1322
|
-
}
|
|
1323
|
-
function assertCanWrite(session, authScopeId, resourcePath) {
|
|
1324
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
1325
|
-
if (override === "WRITE") return;
|
|
1326
|
-
if (override === "NONE" || override === "READ") {
|
|
1327
|
-
throw new AppError(
|
|
1328
|
-
403,
|
|
1329
|
-
MOD.SESSION,
|
|
1330
|
-
CAT.PERMISSION,
|
|
1331
|
-
ACT.GENERIC,
|
|
1332
|
-
`You do not have write access to "${resourcePath}" in this scope.`
|
|
1333
|
-
);
|
|
1334
|
-
}
|
|
1335
|
-
if (session.writeScopes?.includes(authScopeId)) return;
|
|
1336
|
-
throw new AppError(
|
|
1337
|
-
403,
|
|
1338
|
-
MOD.SESSION,
|
|
1339
|
-
CAT.PERMISSION,
|
|
1340
|
-
ACT.GENERIC,
|
|
1341
|
-
"You do not have permission to modify records in this scope."
|
|
1342
|
-
);
|
|
1343
|
-
}
|
|
1344
1334
|
function resolveAccess(session, activeScopeId, tabConfig) {
|
|
1345
1335
|
const resourcePath = tabConfig?.resourceId;
|
|
1346
1336
|
const overrides = session.resourceOverrides?.[activeScopeId] ?? {};
|
|
@@ -1364,15 +1354,6 @@ function resolveAccess(session, activeScopeId, tabConfig) {
|
|
|
1364
1354
|
}
|
|
1365
1355
|
return "READ";
|
|
1366
1356
|
}
|
|
1367
|
-
function resolveMenuVisibility(session, authScopeId, resourcePath) {
|
|
1368
|
-
const override = session.resourceOverrides?.[authScopeId]?.[resourcePath];
|
|
1369
|
-
if (override === "NONE") return "hidden";
|
|
1370
|
-
if (override === "READ") return "read_only";
|
|
1371
|
-
if (override === "WRITE") return "active";
|
|
1372
|
-
if (session.writeScopes?.includes(authScopeId)) return "active";
|
|
1373
|
-
if (session.readScopes?.includes(authScopeId)) return "read_only";
|
|
1374
|
-
return "hidden";
|
|
1375
|
-
}
|
|
1376
1357
|
function isTabVisible(session, activeScopeId, tabConfig) {
|
|
1377
1358
|
return resolveAccess(session, activeScopeId, tabConfig) !== "NONE";
|
|
1378
1359
|
}
|
|
@@ -1586,12 +1567,8 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
1586
1567
|
Validator,
|
|
1587
1568
|
VigorRating,
|
|
1588
1569
|
WaterSource,
|
|
1589
|
-
assertCanWrite,
|
|
1590
1570
|
assertTenantBoundary,
|
|
1591
|
-
buildRlsFilter,
|
|
1592
1571
|
calculateFileMetadataMatch,
|
|
1593
|
-
canRead,
|
|
1594
|
-
canWrite,
|
|
1595
1572
|
evaluateBaseAccess,
|
|
1596
1573
|
extractAppCode,
|
|
1597
1574
|
findSpecificOverride,
|
|
@@ -1610,7 +1587,6 @@ function calculateFileMetadataMatch(criteria, fileMetadata, auditContext) {
|
|
|
1610
1587
|
resolveAppError,
|
|
1611
1588
|
resolveEffectiveAccess,
|
|
1612
1589
|
resolveError,
|
|
1613
|
-
resolveMenuVisibility,
|
|
1614
1590
|
verifyAndExtractSession,
|
|
1615
1591
|
withAgriLogging
|
|
1616
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
|
};
|