@objectstack/platform-objects 9.11.0 → 10.2.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.
@@ -376,6 +376,19 @@ var SysUser = ObjectSchema.create({
376
376
  required: false,
377
377
  group: "Profile"
378
378
  }),
379
+ // ── Organization ─────────────────────────────────────────────
380
+ manager_id: Field.lookup("sys_user", {
381
+ label: "Manager",
382
+ required: false,
383
+ group: "Organization",
384
+ description: "This user's direct manager. Forms the reporting chain the `own_and_reports` hierarchy scope walks (ADR-0057 / @objectstack/security-enterprise)."
385
+ }),
386
+ primary_business_unit_id: Field.lookup("sys_business_unit", {
387
+ label: "Primary Business Unit",
388
+ required: false,
389
+ group: "Organization",
390
+ description: "The user's primary business unit \u2014 a denormalised projection of sys_business_unit_member.is_primary, maintained by plugin-sharing (ADR-0057 addendum D12). Lets a user-lookup filter candidates by business unit without traversing the membership junction. Do not edit directly; set it via business-unit membership."
391
+ }),
379
392
  // ── System (auto-managed, hidden from create/edit forms) ─────
380
393
  id: Field.text({
381
394
  label: "User ID",
@@ -1156,7 +1169,10 @@ var SysMember = ObjectSchema.create({
1156
1169
  }),
1157
1170
  organization_id: Field.lookup("sys_organization", {
1158
1171
  label: "Organization",
1159
- required: true
1172
+ // Optional: single-tenant has no sys_organization row and no auto-stamp
1173
+ // (org-scoping is multi-tenant-only). Multi-tenant: OrgScopingPlugin stamps it
1174
+ // and tenant-isolation RLS hides null-org rows (fail-closed). ADR-0057 addendum.
1175
+ required: false
1160
1176
  }),
1161
1177
  user_id: Field.lookup("sys_user", {
1162
1178
  label: "User",
@@ -1343,7 +1359,10 @@ var SysInvitation = ObjectSchema.create({
1343
1359
  }),
1344
1360
  organization_id: Field.lookup("sys_organization", {
1345
1361
  label: "Organization",
1346
- required: true
1362
+ // Optional: single-tenant has no sys_organization row and no auto-stamp
1363
+ // (org-scoping is multi-tenant-only). Multi-tenant: OrgScopingPlugin stamps it
1364
+ // and tenant-isolation RLS hides null-org rows (fail-closed). ADR-0057 addendum.
1365
+ required: false
1347
1366
  }),
1348
1367
  email: Field.email({
1349
1368
  label: "Email",
@@ -1503,8 +1522,13 @@ var SysTeam = ObjectSchema.create({
1503
1522
  }),
1504
1523
  organization_id: Field.lookup("sys_organization", {
1505
1524
  label: "Organization",
1506
- required: true,
1507
- description: "Parent organization for this team",
1525
+ // Optional: single-tenant deployments have no organization row (org-scoping
1526
+ // is multi-tenant-only, nothing auto-stamps one) — requiring it would make
1527
+ // the object uncreatable single-tenant. In multi-tenant, OrgScopingPlugin
1528
+ // auto-stamps this from the active tenant and tenant-isolation RLS hides any
1529
+ // null-org row (fail-closed). ADR-0057 addendum.
1530
+ required: false,
1531
+ description: "Parent organization for this team. Null in single-tenant; auto-stamped in multi-tenant.",
1508
1532
  group: "Identity"
1509
1533
  }),
1510
1534
  // ── System ───────────────────────────────────────────────────
@@ -1633,24 +1657,42 @@ var SysTeamMember = ObjectSchema.create({
1633
1657
  mru: false
1634
1658
  }
1635
1659
  });
1636
- var SysDepartment = ObjectSchema.create({
1637
- name: "sys_department",
1638
- label: "Department",
1639
- pluralLabel: "Departments",
1660
+ var SysBusinessUnit = ObjectSchema.create({
1661
+ name: "sys_business_unit",
1662
+ label: "Business Unit",
1663
+ pluralLabel: "Business Units",
1640
1664
  icon: "building",
1641
1665
  isSystem: true,
1642
1666
  managedBy: "platform",
1643
- description: "Hierarchical org-skeleton node (department / division / business unit / office).",
1667
+ description: "Canonical Business Unit tree \u2014 hierarchical org/data-partition node (company / division / department / region / office). ADR-0057 D2.",
1644
1668
  displayNameField: "name",
1645
1669
  titleFormat: "{name}",
1646
- compactLayout: ["name", "kind", "parent_department_id", "manager_user_id"],
1670
+ compactLayout: ["name", "kind", "parent_business_unit_id", "manager_user_id"],
1647
1671
  listViews: {
1672
+ // Org chart — the hierarchy view. Surfaces the self-referencing
1673
+ // `parent_business_unit_id` tree (ADR-0057 D2) as an indented, expand/
1674
+ // collapse tree-grid. Listed first so it's the default tab; the grids
1675
+ // below stay for search / filter / bulk edit.
1676
+ org_chart: {
1677
+ type: "tree",
1678
+ name: "org_chart",
1679
+ label: "Org Chart",
1680
+ data: { provider: "object", object: "sys_business_unit" },
1681
+ columns: ["name", "kind", "manager_user_id", "active"],
1682
+ tree: {
1683
+ parentField: "parent_business_unit_id",
1684
+ labelField: "name",
1685
+ fields: ["kind", "manager_user_id", "active"],
1686
+ defaultExpandedDepth: 1
1687
+ },
1688
+ sort: [{ field: "name", order: "asc" }]
1689
+ },
1648
1690
  active: {
1649
1691
  type: "grid",
1650
1692
  name: "active",
1651
1693
  label: "Active",
1652
- data: { provider: "object", object: "sys_department" },
1653
- columns: ["name", "code", "kind", "parent_department_id", "manager_user_id", "effective_from"],
1694
+ data: { provider: "object", object: "sys_business_unit" },
1695
+ columns: ["name", "code", "kind", "parent_business_unit_id", "manager_user_id", "effective_from"],
1654
1696
  filter: [{ field: "active", operator: "equals", value: true }],
1655
1697
  sort: [{ field: "name", order: "asc" }],
1656
1698
  pagination: { pageSize: 100 }
@@ -1659,7 +1701,7 @@ var SysDepartment = ObjectSchema.create({
1659
1701
  type: "grid",
1660
1702
  name: "inactive",
1661
1703
  label: "Inactive",
1662
- data: { provider: "object", object: "sys_department" },
1704
+ data: { provider: "object", object: "sys_business_unit" },
1663
1705
  columns: ["name", "code", "kind", "effective_to"],
1664
1706
  filter: [{ field: "active", operator: "equals", value: false }],
1665
1707
  sort: [{ field: "effective_to", order: "desc" }],
@@ -1669,8 +1711,8 @@ var SysDepartment = ObjectSchema.create({
1669
1711
  type: "grid",
1670
1712
  name: "by_kind",
1671
1713
  label: "By Kind",
1672
- data: { provider: "object", object: "sys_department" },
1673
- columns: ["kind", "name", "code", "parent_department_id", "manager_user_id", "active"],
1714
+ data: { provider: "object", object: "sys_business_unit" },
1715
+ columns: ["kind", "name", "code", "parent_business_unit_id", "manager_user_id", "active"],
1674
1716
  sort: [{ field: "kind", order: "asc" }, { field: "name", order: "asc" }],
1675
1717
  grouping: { fields: [{ field: "kind", order: "asc", collapsed: false }] },
1676
1718
  pagination: { pageSize: 100 }
@@ -1679,8 +1721,8 @@ var SysDepartment = ObjectSchema.create({
1679
1721
  type: "grid",
1680
1722
  name: "all_departments",
1681
1723
  label: "All",
1682
- data: { provider: "object", object: "sys_department" },
1683
- columns: ["name", "code", "kind", "parent_department_id", "manager_user_id", "active"],
1724
+ data: { provider: "object", object: "sys_business_unit" },
1725
+ columns: ["name", "code", "kind", "parent_business_unit_id", "manager_user_id", "active"],
1684
1726
  sort: [{ field: "name", order: "asc" }],
1685
1727
  pagination: { pageSize: 100 }
1686
1728
  }
@@ -1703,7 +1745,7 @@ var SysDepartment = ObjectSchema.create({
1703
1745
  group: "Identity"
1704
1746
  }),
1705
1747
  kind: Field.select(
1706
- ["company", "division", "department", "team", "office", "cost_center"],
1748
+ ["company", "division", "department", "office", "cost_center"],
1707
1749
  {
1708
1750
  label: "Kind",
1709
1751
  required: true,
@@ -1713,23 +1755,28 @@ var SysDepartment = ObjectSchema.create({
1713
1755
  }
1714
1756
  ),
1715
1757
  // ── Hierarchy ────────────────────────────────────────────────
1716
- parent_department_id: Field.lookup("sys_department", {
1717
- label: "Parent Department",
1758
+ parent_business_unit_id: Field.lookup("sys_business_unit", {
1759
+ label: "Parent Business Unit",
1718
1760
  required: false,
1719
1761
  description: "Self-reference for the org tree. Null = root of tenant.",
1720
1762
  group: "Hierarchy"
1721
1763
  }),
1722
1764
  organization_id: Field.lookup("sys_organization", {
1723
1765
  label: "Organization",
1724
- required: true,
1725
- description: "Tenant scope.",
1766
+ // Optional: single-tenant deployments have no organization row (org-scoping
1767
+ // is multi-tenant-only, nothing auto-stamps one) — requiring it would make
1768
+ // the object uncreatable single-tenant. In multi-tenant, OrgScopingPlugin
1769
+ // auto-stamps this from the active tenant and tenant-isolation RLS hides any
1770
+ // null-org row (fail-closed). ADR-0057 addendum.
1771
+ required: false,
1772
+ description: "Tenant scope. Null in single-tenant; auto-stamped in multi-tenant.",
1726
1773
  group: "Hierarchy"
1727
1774
  }),
1728
1775
  // ── Leadership ───────────────────────────────────────────────
1729
1776
  manager_user_id: Field.lookup("sys_user", {
1730
- label: "Department Head",
1777
+ label: "Business Unit Head",
1731
1778
  required: false,
1732
- description: "User responsible for this org unit (department head / lead).",
1779
+ description: "User responsible for this org unit (business unit head / lead).",
1733
1780
  group: "Leadership"
1734
1781
  }),
1735
1782
  // ── Lifecycle ────────────────────────────────────────────────
@@ -1743,13 +1790,13 @@ var SysDepartment = ObjectSchema.create({
1743
1790
  effective_from: Field.datetime({
1744
1791
  label: "Effective From",
1745
1792
  required: false,
1746
- description: "When this department came into existence (HRIS sync).",
1793
+ description: "When this business unit came into existence (HRIS sync).",
1747
1794
  group: "Lifecycle"
1748
1795
  }),
1749
1796
  effective_to: Field.datetime({
1750
1797
  label: "Effective To",
1751
1798
  required: false,
1752
- description: "When this department was retired (HRIS sync).",
1799
+ description: "When this business unit was retired (HRIS sync).",
1753
1800
  group: "Lifecycle"
1754
1801
  }),
1755
1802
  external_ref: Field.text({
@@ -1761,7 +1808,7 @@ var SysDepartment = ObjectSchema.create({
1761
1808
  }),
1762
1809
  // ── System ───────────────────────────────────────────────────
1763
1810
  id: Field.text({
1764
- label: "Department ID",
1811
+ label: "Business Unit ID",
1765
1812
  required: true,
1766
1813
  readonly: true,
1767
1814
  group: "System"
@@ -1781,7 +1828,7 @@ var SysDepartment = ObjectSchema.create({
1781
1828
  },
1782
1829
  indexes: [
1783
1830
  { fields: ["organization_id"] },
1784
- { fields: ["parent_department_id"] },
1831
+ { fields: ["parent_business_unit_id"] },
1785
1832
  { fields: ["code", "organization_id"], unique: true },
1786
1833
  { fields: ["active"] }
1787
1834
  ],
@@ -1794,16 +1841,16 @@ var SysDepartment = ObjectSchema.create({
1794
1841
  mru: false
1795
1842
  }
1796
1843
  });
1797
- var SysDepartmentMember = ObjectSchema.create({
1798
- name: "sys_department_member",
1799
- label: "Department Member",
1800
- pluralLabel: "Department Members",
1844
+ var SysBusinessUnitMember = ObjectSchema.create({
1845
+ name: "sys_business_unit_member",
1846
+ label: "Business Unit Member",
1847
+ pluralLabel: "Business Unit Members",
1801
1848
  icon: "user-cog",
1802
1849
  isSystem: true,
1803
1850
  managedBy: "platform",
1804
- description: "User assignment to a department (matrix-org friendly, effective-dated).",
1805
- titleFormat: "{user_id} in {department_id}",
1806
- compactLayout: ["user_id", "department_id", "role_in_department", "is_primary"],
1851
+ description: "User assignment to a business unit (matrix-org friendly, effective-dated).",
1852
+ titleFormat: "{user_id} in {business_unit_id}",
1853
+ compactLayout: ["user_id", "business_unit_id", "role_in_business_unit", "is_primary"],
1807
1854
  fields: {
1808
1855
  id: Field.text({
1809
1856
  label: "Member ID",
@@ -1811,8 +1858,8 @@ var SysDepartmentMember = ObjectSchema.create({
1811
1858
  readonly: true,
1812
1859
  group: "System"
1813
1860
  }),
1814
- department_id: Field.lookup("sys_department", {
1815
- label: "Department",
1861
+ business_unit_id: Field.lookup("sys_business_unit", {
1862
+ label: "Business Unit",
1816
1863
  required: true,
1817
1864
  group: "Assignment"
1818
1865
  }),
@@ -1821,10 +1868,10 @@ var SysDepartmentMember = ObjectSchema.create({
1821
1868
  required: true,
1822
1869
  group: "Assignment"
1823
1870
  }),
1824
- role_in_department: Field.select(
1871
+ role_in_business_unit: Field.select(
1825
1872
  ["member", "lead", "deputy"],
1826
1873
  {
1827
- label: "Role in Department",
1874
+ label: "Role in Business Unit",
1828
1875
  required: false,
1829
1876
  defaultValue: "member",
1830
1877
  description: "`lead` is the day-to-day head; `deputy` may stand in for the lead in approval routing.",
@@ -1835,7 +1882,7 @@ var SysDepartmentMember = ObjectSchema.create({
1835
1882
  label: "Primary Assignment",
1836
1883
  required: false,
1837
1884
  defaultValue: true,
1838
- description: "When the user is in multiple departments, this marks the canonical one for reporting.",
1885
+ description: "When the user is in multiple business units, this marks the canonical one for reporting.",
1839
1886
  group: "Assignment"
1840
1887
  }),
1841
1888
  effective_from: Field.datetime({
@@ -1862,7 +1909,7 @@ var SysDepartmentMember = ObjectSchema.create({
1862
1909
  })
1863
1910
  },
1864
1911
  indexes: [
1865
- { fields: ["department_id", "user_id"], unique: true },
1912
+ { fields: ["business_unit_id", "user_id"], unique: true },
1866
1913
  { fields: ["user_id"] },
1867
1914
  { fields: ["is_primary"] }
1868
1915
  ],
@@ -3108,6 +3155,6 @@ var SysJwks = ObjectSchema.create({
3108
3155
  }
3109
3156
  });
3110
3157
 
3111
- export { SysAccount, SysApiKey, SysDepartment, SysDepartmentMember, SysDeviceCode, SysInvitation, SysJwks, SysMember, SysOauthAccessToken, SysOauthApplication, SysOauthConsent, SysOauthRefreshToken, SysOrganization, SysSession, SysTeam, SysTeamMember, SysTwoFactor, SysUser, SysUserPreference, SysVerification };
3158
+ export { SysAccount, SysApiKey, SysBusinessUnit, SysBusinessUnitMember, SysDeviceCode, SysInvitation, SysJwks, SysMember, SysOauthAccessToken, SysOauthApplication, SysOauthConsent, SysOauthRefreshToken, SysOrganization, SysSession, SysTeam, SysTeamMember, SysTwoFactor, SysUser, SysUserPreference, SysVerification };
3112
3159
  //# sourceMappingURL=index.mjs.map
3113
3160
  //# sourceMappingURL=index.mjs.map