@thatopen/services 0.11.0 → 0.12.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.
@@ -1576,6 +1576,239 @@ export type HelloWorld = InstanceType<typeof _HelloWorld>;
1576
1576
  */
1577
1577
  export const HelloWorld = { uuid: '2c4ae432-fc24-43e9-9783-0c960c674e96' } as typeof _HelloWorld & { uuid: '2c4ae432-fc24-43e9-9783-0c960c674e96' };
1578
1578
 
1579
+ export type ProjectNamespaceKey = "origin" | "georeferencing" | "appSettings";
1580
+ export interface ProjectNamespace {
1581
+ label: string;
1582
+ description?: string;
1583
+ }
1584
+ export interface ProjectEntity<T = unknown> {
1585
+ namespaceId: ProjectNamespaceKey;
1586
+ label: string;
1587
+ description?: string;
1588
+ data: T;
1589
+ }
1590
+ /** GIS origin point that fixes the scene's (0,0,0) to a real-world coordinate. */
1591
+ export interface OriginData {
1592
+ lat: number;
1593
+ lon: number;
1594
+ height: number;
1595
+ rotation: number;
1596
+ }
1597
+ export interface BimSite {
1598
+ label: string;
1599
+ description?: string;
1600
+ lat: number;
1601
+ lon: number;
1602
+ height: number;
1603
+ rotation: number;
1604
+ /** Column-major 4x4 matrix (16 values) mapping BIM local space to the site's georeferenced frame. */
1605
+ baseMatrix: number[];
1606
+ }
1607
+ export interface BimCoordinatesData {
1608
+ defaultSiteId?: string;
1609
+ sites: Record<string, BimSite>;
1610
+ }
1611
+ export type AssetCoordinateType = "splat" | "ifc" | "point-cloud" | (string & {});
1612
+ export interface AssetCoordinate {
1613
+ fileId: string;
1614
+ type: AssetCoordinateType;
1615
+ lat: number;
1616
+ lon: number;
1617
+ height: number;
1618
+ rotation: number;
1619
+ }
1620
+ export interface GraphicsSettingsData {
1621
+ stylePreset: string;
1622
+ postproduction: boolean;
1623
+ edges: {
1624
+ enabled: boolean;
1625
+ color: string;
1626
+ opacity: number;
1627
+ };
1628
+ ambientOcclusion: {
1629
+ enabled: boolean;
1630
+ value: number;
1631
+ };
1632
+ tonalShading: {
1633
+ enabled: boolean;
1634
+ value: number;
1635
+ };
1636
+ surfaceColor: {
1637
+ enabled: boolean;
1638
+ };
1639
+ transparentBackground: {
1640
+ enabled: boolean;
1641
+ color: string;
1642
+ };
1643
+ grid: {
1644
+ enabled: boolean;
1645
+ color: string;
1646
+ };
1647
+ gridHeight: {
1648
+ auto: boolean;
1649
+ value: number;
1650
+ };
1651
+ antiAliasing: boolean;
1652
+ nativeResolution: boolean;
1653
+ adaptiveResolution: {
1654
+ enabled: boolean;
1655
+ value: number;
1656
+ };
1657
+ minResolution: number;
1658
+ renderScale: number;
1659
+ }
1660
+ export interface ProjectManagerData {
1661
+ schemaVersion: 1;
1662
+ namespaces: Record<ProjectNamespaceKey, ProjectNamespace>;
1663
+ entities: {
1664
+ origin: ProjectEntity<OriginData>;
1665
+ bimCoordinates: ProjectEntity<BimCoordinatesData>;
1666
+ assetCoordinates: ProjectEntity<AssetCoordinate[]>;
1667
+ graphicsSettings: ProjectEntity<GraphicsSettingsData>;
1668
+ };
1669
+ }
1670
+ export interface SingletonEntity<T> {
1671
+ get(): T | undefined;
1672
+ set(data: T): Promise<void>;
1673
+ update(partial: Partial<T>): Promise<void>;
1674
+ }
1675
+ export interface BimCoordinatesEntity {
1676
+ get(): BimCoordinatesData;
1677
+ getSites(): Record<string, BimSite>;
1678
+ getSite(siteId: string): BimSite | undefined;
1679
+ getDefaultSite(): BimSite | undefined;
1680
+ /** Creates a new site. `ProjectManager` generates the opaque `siteId` — callers
1681
+ * never invent their own (see the class-level JSDoc on `ProjectManager` for why). */
1682
+ createSite(site: BimSite): Promise<string>;
1683
+ /** Updates a site that already exists (from `createSite`). Throws if `siteId`
1684
+ * isn't in `sites` — this is not an upsert; use `createSite` to add one. */
1685
+ setSite(siteId: string, site: BimSite): Promise<void>;
1686
+ setDefaultSite(siteId: string): Promise<void>;
1687
+ removeSite(siteId: string): Promise<void>;
1688
+ }
1689
+ export interface AssetCoordinatesEntity {
1690
+ getAll(): AssetCoordinate[];
1691
+ get(fileId: string): AssetCoordinate | undefined;
1692
+ getByType(type: AssetCoordinateType): AssetCoordinate[];
1693
+ set(fileId: string, data: Omit<AssetCoordinate, "fileId">): Promise<void>;
1694
+ remove(fileId: string): Promise<void>;
1695
+ }
1696
+
1697
+ /**
1698
+ * ProjectManager is the platform's canonical store for project-level
1699
+ * configuration and data — origin/georeferencing/app-settings today, with
1700
+ * room to grow. It persists a single JSON file (`${ProjectManager.uuid}.json`)
1701
+ * loose directly inside `__project_data` (same folder convention `GISManager`
1702
+ * already used) — NOT in a per-app subfolder like `collider`/`cde`, which are
1703
+ * for secondary, per-builtin data. Sharing that root folder with other
1704
+ * builtins doesn't change its role: it's still the one canonical project
1705
+ * record, meant to stop each builtin from inventing its own ad-hoc
1706
+ * project-persistence pattern.
1707
+ *
1708
+ * Schema shape (see `src/types.ts` for the full rationale):
1709
+ * - `namespaces`/`entities` are maps keyed by a fixed, readable slug — a
1710
+ * closed set this code defines, never created at runtime.
1711
+ * - `bimCoordinates.data.sites` is the one open, runtime-created collection
1712
+ * today, so its keys are opaque generated ids instead of slugs.
1713
+ * - `origin`/`graphicsSettings` are singletons; `sites`/`assetCoordinates`
1714
+ * are collections.
1715
+ * - `entities[id]` is a uniform envelope: `namespaceId`, mandatory `label`,
1716
+ * optional `description` (omitted, not stored empty), free-form `data`.
1717
+ *
1718
+ * Id generation rule: whenever a collection needs an opaque id (today just
1719
+ * `sites`, potentially more collections later), `ProjectManager` generates it
1720
+ * internally (`crypto.randomUUID()`, no prefix) — callers never invent their
1721
+ * own. `createSite` is the current example; follow the same pattern for any
1722
+ * future `create*` method.
1723
+ */
1724
+ declare class _ProjectManager extends OBC.Component {
1725
+ static readonly uuid: "6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f";
1726
+ enabled: boolean;
1727
+ /** True once init(client) has been called — safe to use the entity accessors. */
1728
+ get ready(): boolean;
1729
+ /** Suppress auto-save while bulk-loading data. */
1730
+ private _loadingData;
1731
+ readonly onSaveStart: OBC.Event<void>;
1732
+ readonly onSaveComplete: OBC.Event<boolean>;
1733
+ private _client?;
1734
+ private _fileId?;
1735
+ private _data;
1736
+ private _saveTimer?;
1737
+ private _savePromise?;
1738
+ private _scheduleSave;
1739
+ private _queueSave;
1740
+ private _doSave;
1741
+ /** Cancels the pending debounce and runs the save immediately. Awaits completion. */
1742
+ flush(): Promise<void>;
1743
+ init(client: PlatformClient): Promise<void>;
1744
+ /** Opaque id generator for any collection needing one (currently just
1745
+ * `bimCoordinates.sites`) — see the class-level JSDoc's id-generation rule. */
1746
+ private _generateId;
1747
+ origin: SingletonEntity<OriginData>;
1748
+ graphicsSettings: SingletonEntity<GraphicsSettingsData>;
1749
+ bimCoordinates: BimCoordinatesEntity;
1750
+ assetCoordinates: AssetCoordinatesEntity;
1751
+ getNamespaces(): Record<ProjectNamespaceKey, ProjectNamespace>;
1752
+ getNamespace(key: ProjectNamespaceKey): Record<string, unknown>;
1753
+ }
1754
+
1755
+ /**
1756
+ * ProjectManager is the platform's canonical store for project-level
1757
+ * configuration and data — origin/georeferencing/app-settings today, with
1758
+ * room to grow. It persists a single JSON file (`${ProjectManager.uuid}.json`)
1759
+ * loose directly inside `__project_data` (same folder convention `GISManager`
1760
+ * already used) — NOT in a per-app subfolder like `collider`/`cde`, which are
1761
+ * for secondary, per-builtin data. Sharing that root folder with other
1762
+ * builtins doesn't change its role: it's still the one canonical project
1763
+ * record, meant to stop each builtin from inventing its own ad-hoc
1764
+ * project-persistence pattern.
1765
+ *
1766
+ * Schema shape (see `src/types.ts` for the full rationale):
1767
+ * - `namespaces`/`entities` are maps keyed by a fixed, readable slug — a
1768
+ * closed set this code defines, never created at runtime.
1769
+ * - `bimCoordinates.data.sites` is the one open, runtime-created collection
1770
+ * today, so its keys are opaque generated ids instead of slugs.
1771
+ * - `origin`/`graphicsSettings` are singletons; `sites`/`assetCoordinates`
1772
+ * are collections.
1773
+ * - `entities[id]` is a uniform envelope: `namespaceId`, mandatory `label`,
1774
+ * optional `description` (omitted, not stored empty), free-form `data`.
1775
+ *
1776
+ * Id generation rule: whenever a collection needs an opaque id (today just
1777
+ * `sites`, potentially more collections later), `ProjectManager` generates it
1778
+ * internally (`crypto.randomUUID()`, no prefix) — callers never invent their
1779
+ * own. `createSite` is the current example; follow the same pattern for any
1780
+ * future `create*` method.
1781
+ */
1782
+ export type ProjectManager = InstanceType<typeof _ProjectManager>;
1783
+ /**
1784
+ * ProjectManager is the platform's canonical store for project-level
1785
+ * configuration and data — origin/georeferencing/app-settings today, with
1786
+ * room to grow. It persists a single JSON file (`${ProjectManager.uuid}.json`)
1787
+ * loose directly inside `__project_data` (same folder convention `GISManager`
1788
+ * already used) — NOT in a per-app subfolder like `collider`/`cde`, which are
1789
+ * for secondary, per-builtin data. Sharing that root folder with other
1790
+ * builtins doesn't change its role: it's still the one canonical project
1791
+ * record, meant to stop each builtin from inventing its own ad-hoc
1792
+ * project-persistence pattern.
1793
+ *
1794
+ * Schema shape (see `src/types.ts` for the full rationale):
1795
+ * - `namespaces`/`entities` are maps keyed by a fixed, readable slug — a
1796
+ * closed set this code defines, never created at runtime.
1797
+ * - `bimCoordinates.data.sites` is the one open, runtime-created collection
1798
+ * today, so its keys are opaque generated ids instead of slugs.
1799
+ * - `origin`/`graphicsSettings` are singletons; `sites`/`assetCoordinates`
1800
+ * are collections.
1801
+ * - `entities[id]` is a uniform envelope: `namespaceId`, mandatory `label`,
1802
+ * optional `description` (omitted, not stored empty), free-form `data`.
1803
+ *
1804
+ * Id generation rule: whenever a collection needs an opaque id (today just
1805
+ * `sites`, potentially more collections later), `ProjectManager` generates it
1806
+ * internally (`crypto.randomUUID()`, no prefix) — callers never invent their
1807
+ * own. `createSite` is the current example; follow the same pattern for any
1808
+ * future `create*` method.
1809
+ */
1810
+ export const ProjectManager = { uuid: '6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f' } as typeof _ProjectManager & { uuid: '6f3a9c2e-8b1d-4e6a-9c3f-1d7b5a8e2c4f' };
1811
+
1579
1812
  /** `main.bcf`'s path relative to `__project_data/` — shared with
1580
1813
  * `requestBcfSave` (`UIManager/src/utils/bcf-storage.ts`) so both sides of
1581
1814
  * the save/load round-trip agree on where the file lives. */