@apptimate/core-lib 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apptimate/core-lib",
3
- "version": "3.3.0",
3
+ "version": "3.5.0",
4
4
  "main": "src/index.ts",
5
5
  "types": "src/index.ts",
6
6
  "publishConfig": {
@@ -2,6 +2,7 @@ export interface SubMenuItem {
2
2
  id: string;
3
3
  label: string;
4
4
  path: string;
5
+ permission?: string | null;
5
6
  }
6
7
 
7
8
  export interface SubMenuGroup {
@@ -130,33 +131,34 @@ export const MENU_ITEM_REGISTRY: RegistryItem[] = [
130
131
  { key: 'finance__bank_statements', label: 'Bank Statements', path: '/finance/bank-statements', module: 'Finance', defaultGroup: 'Reports', permission: null },
131
132
 
132
133
  // ── Jewelry Module ──
133
- { key: 'jewelry__items', label: 'Jewelry Items', path: '/jewelry/items', module: 'Jewelry', defaultGroup: 'Catalog', permission: null },
134
-
135
- { key: 'jewelry__categories', label: 'Categories', path: '/jewelry/categories', module: 'Jewelry', defaultGroup: 'Catalog', permission: null },
136
- { key: 'jewelry__material_types', label: 'Material Types', path: '/jewelry/material-types', module: 'Jewelry', defaultGroup: 'Master Data', permission: null },
137
- { key: 'jewelry__purities', label: 'Purities', path: '/jewelry/purities', module: 'Jewelry', defaultGroup: 'Master Data', permission: null },
138
- { key: 'jewelry__metal_rates', label: 'Metal Rates', path: '/jewelry/metal-rates', module: 'Jewelry', defaultGroup: 'Master Data', permission: null },
139
- { key: 'jewelry__purchase_orders', label: 'Purchase Orders', path: '/jewelry/procurement/orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: null },
140
- { key: 'jewelry__grn', label: 'Goods Receipt', path: '/jewelry/procurement/grn', module: 'Jewelry', defaultGroup: 'Procurement', permission: null },
141
- { key: 'jewelry__custom_orders', label: 'Custom Orders', path: '/jewelry/custom-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: null },
142
- { key: 'jewelry__service_orders', label: 'Service Orders', path: '/jewelry/service-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: null },
143
- { key: 'jewelry__opening_stock', label: 'Opening Stock', path: '/jewelry/procurement/opening_stock', module: 'Jewelry', defaultGroup: 'Procurement', permission: null },
144
- { key: 'jewelry__transformations', label: 'Transformations', path: '/jewelry/procurement/transformations', module: 'Jewelry', defaultGroup: 'Procurement', permission: null },
145
- { key: 'jewelry__old_gold_purchases', label: 'Old Material Purchases', path: '/jewelry/old-gold-purchases', module: 'Jewelry', defaultGroup: 'Buying', permission: null },
146
- { key: 'jewelry__sales', label: 'Sales', path: '/jewelry/sales', module: 'Jewelry', defaultGroup: 'Sales', permission: null },
147
- { key: 'jewelry__sales_returns', label: 'Sales Returns', path: '/jewelry/sales-returns', module: 'Jewelry', defaultGroup: 'Sales', permission: null },
148
-
149
- { key: 'jewelry__stock_balances', label: 'Stock Balances', path: '/jewelry/stock/balances', module: 'Jewelry', defaultGroup: 'Stock', permission: null },
150
- { key: 'jewelry__stock_movements', label: 'Stock Movements', path: '/jewelry/stock/movements', module: 'Jewelry', defaultGroup: 'Stock', permission: null },
151
- { key: 'jewelry__stock_transfers', label: 'Transfers', path: '/jewelry/stock-transfers', module: 'Jewelry', defaultGroup: 'Stock', permission: null },
152
- { key: 'jewelry__party_transactions', label: 'Party Transactions', path: '/jewelry/party-transactions', module: 'Jewelry', defaultGroup: 'Karigar', permission: null },
153
-
154
- { key: 'jewelry__karigar_making_charges', label: 'Making Charges', path: '/jewelry/karigar-making-charges', module: 'Jewelry', defaultGroup: 'Karigar', permission: null },
155
- { key: 'jewelry__party_metal_balances', label: 'Party Metal Balances', path: '/jewelry/party-metal-balances', module: 'Jewelry', defaultGroup: 'Karigar', permission: null },
156
- { key: 'jewelry__metal_settlements', label: 'Metal Settlements', path: '/jewelry/metal-settlements', module: 'Jewelry', defaultGroup: 'Karigar', permission: null },
157
- { key: 'jewelry__settings', label: 'Settings', path: '/jewelry/settings', module: 'Jewelry', defaultGroup: 'Configuration', permission: null },
158
- { key: 'jewelry__billing_templates', label: 'Billing Templates', path: '/jewelry/billing-templates', module: 'Jewelry', defaultGroup: 'Configuration', permission: null },
159
- { key: 'jewelry__reports', label: 'Reports & Dashboards', path: '/reports/jewelry', module: 'Jewelry', defaultGroup: 'Analytics', permission: null },
134
+ { key: 'jewelry__items', label: 'Jewelry Items', path: '/jewelry/items', module: 'Jewelry', defaultGroup: 'Catalog', permission: 'jewelry.items.view' },
135
+
136
+ { key: 'jewelry__categories', label: 'Categories', path: '/jewelry/categories', module: 'Jewelry', defaultGroup: 'Catalog', permission: 'jewelry.categories.view' },
137
+ { key: 'jewelry__material_types', label: 'Material Types', path: '/jewelry/material-types', module: 'Jewelry', defaultGroup: 'Master Data', permission: 'jewelry.material_types.view' },
138
+ { key: 'jewelry__purities', label: 'Purities', path: '/jewelry/purities', module: 'Jewelry', defaultGroup: 'Master Data', permission: 'jewelry.purities.view' },
139
+ { key: 'jewelry__metal_rates', label: 'Metal Rates', path: '/jewelry/metal-rates', module: 'Jewelry', defaultGroup: 'Master Data', permission: 'jewelry.metal_rates.view' },
140
+ { key: 'jewelry__purchase_orders', label: 'Purchase Orders', path: '/jewelry/procurement/orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.purchase_orders.view' },
141
+ { key: 'jewelry__grn', label: 'Goods Receipt', path: '/jewelry/procurement/grn', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.grn.view' },
142
+ { key: 'jewelry__custom_orders', label: 'Custom Orders', path: '/jewelry/custom-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.custom_orders.view' },
143
+ { key: 'jewelry__service_orders', label: 'Service Orders', path: '/jewelry/service-orders', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.services.view' },
144
+ { key: 'jewelry__opening_stock', label: 'Opening Stock', path: '/jewelry/procurement/opening_stock', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.opening_stock.view' },
145
+ { key: 'jewelry__transformations', label: 'Transformations', path: '/jewelry/procurement/transformations', module: 'Jewelry', defaultGroup: 'Procurement', permission: 'jewelry.transformations.view' },
146
+ { key: 'jewelry__old_gold_purchases', label: 'Old Material Purchases', path: '/jewelry/old-gold-purchases', module: 'Jewelry', defaultGroup: 'Buying', permission: 'jewelry.old_gold_purchases.view' },
147
+ { key: 'jewelry__sales', label: 'Sales', path: '/jewelry/sales', module: 'Jewelry', defaultGroup: 'Sales', permission: 'jewelry.sales.view' },
148
+ { key: 'jewelry__sales_returns', label: 'Sales Returns', path: '/jewelry/sales-returns', module: 'Jewelry', defaultGroup: 'Sales', permission: 'jewelry.sale_returns.view' },
149
+
150
+ { key: 'jewelry__stock_balances', label: 'Stock Balances', path: '/jewelry/stock/balances', module: 'Jewelry', defaultGroup: 'Stock', permission: 'jewelry.stock_balances.view' },
151
+ { key: 'jewelry__stock_movements', label: 'Stock Movements', path: '/jewelry/stock/movements', module: 'Jewelry', defaultGroup: 'Stock', permission: 'jewelry.stock_movements.view' },
152
+ { key: 'jewelry__stock_transfers', label: 'Transfers', path: '/jewelry/stock-transfers', module: 'Jewelry', defaultGroup: 'Stock', permission: 'jewelry.stock_transfers.view' },
153
+ { key: 'jewelry__party_transactions', label: 'Party Transactions', path: '/jewelry/party-transactions', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'jewelry.karigar_transactions.view' },
154
+
155
+ { key: 'jewelry__karigar_making_charges', label: 'Making Charges', path: '/jewelry/karigar-making-charges', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'jewelry.karigar_making_charges.view' },
156
+ { key: 'jewelry__party_metal_balances', label: 'Party Metal Balances', path: '/jewelry/party-metal-balances', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'jewelry.party_metal_balances.view' },
157
+ { key: 'jewelry__metal_settlements', label: 'Metal Settlements', path: '/jewelry/metal-settlements', module: 'Jewelry', defaultGroup: 'Karigar', permission: 'metal_settlement.view' },
158
+ { key: 'jewelry__settings', label: 'Settings', path: '/jewelry/settings', module: 'Jewelry', defaultGroup: 'Configuration', permission: 'jewelry.settings.view' },
159
+ { key: 'jewelry__billing_templates', label: 'Billing Templates', path: '/jewelry/billing-templates', module: 'Jewelry', defaultGroup: 'Configuration', permission: 'jewelry.billing_templates.view' },
160
+ { key: 'jewelry__reports', label: 'Reports & Dashboards', path: '/reports/jewelry', module: 'Jewelry', defaultGroup: 'Analytics', permission: 'jewelry.reports.view' },
161
+
160
162
 
161
163
  // ── HR Module ──
162
164
  { key: 'hr__employees', label: 'Employees', path: '/hr/employees', module: 'HR', defaultGroup: 'Core', permission: null },
@@ -185,22 +187,22 @@ export const MENU_ITEM_REGISTRY: RegistryItem[] = [
185
187
  { key: 'hr__ot_policies', label: 'OT Policies', path: '/hr/ot-policies', module: 'HR', defaultGroup: 'Payroll', permission: null },
186
188
  { key: 'hr__ot_rate_templates', label: 'OT Rate Templates', path: '/hr/ot-rate-templates', module: 'HR', defaultGroup: 'Payroll', permission: null },
187
189
  // ── Money Exchange Module ──
188
- { key: 'money_exchange__dashboard', label: 'Dashboard', path: '/money-exchange', module: 'Money Exchange', defaultGroup: 'Overview', permission: null },
189
- { key: 'money_exchange__rates', label: 'Rates Management', path: '/money-exchange/rates', module: 'Money Exchange', defaultGroup: 'Overview', permission: null },
190
- { key: 'money_exchange__pos', label: 'Point of Sale', path: '/money-exchange/pos', module: 'Money Exchange', defaultGroup: 'Operations', permission: null },
191
- { key: 'money_exchange__transactions', label: 'Transactions', path: '/money-exchange/transactions', module: 'Money Exchange', defaultGroup: 'Operations', permission: null },
192
- { key: 'money_exchange__till', label: 'Till', path: '/money-exchange/till', module: 'Money Exchange', defaultGroup: 'Inventory & Stock', permission: null },
193
- { key: 'money_exchange__branch_stock', label: 'Vault', path: '/money-exchange/branch-stock', module: 'Money Exchange', defaultGroup: 'Inventory & Stock', permission: null },
194
- { key: 'money_exchange__opening_stock', label: 'Opening Stock', path: '/money-exchange/opening-stock', module: 'Money Exchange', defaultGroup: 'Config', permission: null },
195
- { key: 'money_exchange__internal_transfers', label: 'Internal Transfers', path: '/money-exchange/internal-transfers', module: 'Money Exchange', defaultGroup: 'Inventory & Stock', permission: null },
196
- { key: 'money_exchange__wholesale', label: 'Wholesale Operations', path: '/money-exchange/wholesale', module: 'Money Exchange', defaultGroup: 'Wholesale', permission: null },
190
+ { key: 'money_exchange__dashboard', label: 'Dashboard', path: '/money-exchange', module: 'Money Exchange', defaultGroup: 'Overview', permission: 'money_exchange.dashboard.view' },
191
+ { key: 'money_exchange__rates', label: 'Rates Management', path: '/money-exchange/rates', module: 'Money Exchange', defaultGroup: 'Overview', permission: 'money_exchange.currency_rates.view' },
192
+ { key: 'money_exchange__pos', label: 'Point of Sale', path: '/money-exchange/pos', module: 'Money Exchange', defaultGroup: 'Operations', permission: 'money_exchange.pos.create' },
193
+ { key: 'money_exchange__transactions', label: 'Transactions', path: '/money-exchange/transactions', module: 'Money Exchange', defaultGroup: 'Operations', permission: 'money_exchange.transactions.view' },
194
+ { key: 'money_exchange__till', label: 'Till', path: '/money-exchange/till', module: 'Money Exchange', defaultGroup: 'Inventory & Stock', permission: 'money_exchange.till.view' },
195
+ { key: 'money_exchange__branch_stock', label: 'Vault', path: '/money-exchange/branch-stock', module: 'Money Exchange', defaultGroup: 'Inventory & Stock', permission: 'money_exchange.branch_stock.view' },
196
+ { key: 'money_exchange__opening_stock', label: 'Opening Stock', path: '/money-exchange/opening-stock', module: 'Money Exchange', defaultGroup: 'Config', permission: 'money_exchange.opening_stock.view' },
197
+ { key: 'money_exchange__internal_transfers', label: 'Internal Transfers', path: '/money-exchange/internal-transfers', module: 'Money Exchange', defaultGroup: 'Inventory & Stock', permission: 'money_exchange.internal_transfers.view' },
198
+ { key: 'money_exchange__wholesale', label: 'Wholesale Operations', path: '/money-exchange/wholesale', module: 'Money Exchange', defaultGroup: 'Wholesale', permission: 'money_exchange.wholesale.view' },
197
199
  // { key: 'money_exchange__remittance_agents', label: 'Agent Registry', path: '/money-exchange/agents', module: 'Money Exchange', defaultGroup: 'Remittances', permission: null },
198
200
  // { key: 'money_exchange__remittance_corridors', label: 'Corridors', path: '/money-exchange/corridors', module: 'Money Exchange', defaultGroup: 'Remittances', permission: null },
199
201
  // { key: 'money_exchange__remittances', label: 'Transactions', path: '/money-exchange/remittances', module: 'Money Exchange', defaultGroup: 'Remittances', permission: null },
200
202
  // { key: 'money_exchange__remittance_settlements', label: 'Settlements', path: '/money-exchange/settlements', module: 'Money Exchange', defaultGroup: 'Remittances', permission: null },
201
- { key: 'money_exchange__denominations', label: 'Denomination', path: '/money-exchange/denominations', module: 'Money Exchange', defaultGroup: 'Config', permission: null },
202
- { key: 'money_exchange__till_thresholds', label: 'Till Thresholds', path: '/money-exchange/till-thresholds', module: 'Money Exchange', defaultGroup: 'Config', permission: null },
203
- { key: 'money_exchange__cross_currency', label: 'Margin Rate', path: '/money-exchange/cross-currency', module: 'Money Exchange', defaultGroup: 'Config', permission: null },
203
+ { key: 'money_exchange__denominations', label: 'Denomination', path: '/money-exchange/denominations', module: 'Money Exchange', defaultGroup: 'Config', permission: 'money_exchange.denominations.view' },
204
+ { key: 'money_exchange__till_thresholds', label: 'Till Thresholds', path: '/money-exchange/till-thresholds', module: 'Money Exchange', defaultGroup: 'Config', permission: 'money_exchange.till_thresholds.view' },
205
+ { key: 'money_exchange__cross_currency', label: 'Margin Rate', path: '/money-exchange/cross-currency', module: 'Money Exchange', defaultGroup: 'Config', permission: 'money_exchange.cross_currency.view' },
204
206
 
205
207
  // ── Reports Module (Admin/General) ──
206
208
  { key: 'reports__jewelry', label: 'Jewelry', path: '/reports/jewelry', module: 'Reporting', defaultGroup: 'Dashboards', permission: null },
@@ -251,6 +253,7 @@ export function resolveRegistryKeys(items: SecondaryItemConfig[]): SubMenuGroup[
251
253
  id: cfg.key,
252
254
  label: cfg.label || reg.label,
253
255
  path: reg.path,
256
+ permission: reg.permission,
254
257
  });
255
258
  }
256
259
 
@@ -423,3 +426,17 @@ export function buildMenusFromConfig(config: {
423
426
  groups: resolveRegistryKeys(pm.secondaryItems),
424
427
  }));
425
428
  }
429
+
430
+ export function filterMenusByPermission(menus: MainMenuItem[], can: (code: string) => boolean): MainMenuItem[] {
431
+ return menus.map(mainMenu => {
432
+ const filteredGroups = mainMenu.groups.map(group => {
433
+ const filteredItems = group.items.filter(item => {
434
+ if (!item.permission) return true;
435
+ return can(item.permission);
436
+ });
437
+ return { ...group, items: filteredItems };
438
+ }).filter(group => group.items.length > 0);
439
+
440
+ return { ...mainMenu, groups: filteredGroups };
441
+ }).filter(mainMenu => mainMenu.groups.length > 0);
442
+ }