API Reference
Complete API reference for all Hyperbasis types.
Models
HBSpace
public struct HBSpace: Codable, Identifiable, EquatableProperties
| Property | Type | Description |
|---|---|---|
id | UUID | Unique identifier |
name | String? | Human-readable name |
worldMapData | Data | Serialized ARWorldMap |
createdAt | Date | Creation timestamp |
updatedAt | Date | Last modification timestamp |
Initializers
// From ARWorldMap
init(id: UUID = UUID(), name: String? = nil, worldMap: ARWorldMap) throws
// From serialized data
init(id: UUID, name: String?, worldMapData: Data, createdAt: Date, updatedAt: Date)Methods
// Serialization
static func serialize(worldMap: ARWorldMap) throws -> Data
static func deserialize(worldMapData: Data) throws -> ARWorldMap
func arWorldMap() throws -> ARWorldMap
// Mutation
mutating func update(worldMap: ARWorldMap) throws
mutating func update(name: String?)
// Utilities
func validate() -> Bool
var worldMapSize: Int { get }
var worldMapSizeFormatted: String { get }HBAnchor
public struct HBAnchor: Codable, Identifiable, EquatableProperties
| Property | Type | Description |
|---|---|---|
id | UUID | Unique identifier |
spaceId | UUID | Parent space ID |
transform | [Float] | 16 floats (4x4 matrix) |
metadata | [String: AnyCodableValue] | Custom data |
createdAt | Date | Creation timestamp |
updatedAt | Date | Last modification timestamp |
deletedAt | Date? | Soft delete timestamp |
Initializers
// From simd_float4x4
init(id: UUID = UUID(), spaceId: UUID, transform: simd_float4x4, metadata: [String: AnyCodableValue] = [:])
// From flat array
init(id: UUID, spaceId: UUID, transform: [Float], metadata: [String: AnyCodableValue], createdAt: Date, updatedAt: Date, deletedAt: Date?)Methods
// Transform
static func flatten(_ matrix: simd_float4x4) -> [Float]
static func unflatten(_ array: [Float]) throws -> simd_float4x4
func simdTransform() throws -> simd_float4x4
var validSimdTransform: simd_float4x4? { get }
var position: SIMD3<Float> { get }
mutating func update(transform: simd_float4x4)
// Metadata
func metadata(forKey key: String) -> AnyCodableValue?
func stringMetadata(forKey key: String) -> String?
func intMetadata(forKey key: String) -> Int?
func boolMetadata(forKey key: String) -> Bool?
mutating func updateMetadata(key: String, value: AnyCodableValue?)
mutating func update(metadata: [String: AnyCodableValue])
// Deletion
mutating func markDeleted()
mutating func restore()
var isDeleted: Bool { get }
// Validation
func validate() -> BoolAnyCodableValue
public enum AnyCodableValue: Codable, EquatableCases
case string(String)
case int(Int)
case double(Double)
case bool(Bool)
case array([AnyCodableValue])
case dictionary([String: AnyCodableValue])
case nullAccessor Properties
var stringValue: String? { get }
var intValue: Int? { get }
var doubleValue: Double? { get }
var boolValue: Bool? { get }
var arrayValue: [AnyCodableValue]? { get }
var dictionaryValue: [String: AnyCodableValue]? { get }
var isNull: Bool { get }Storage
HBStorage
public class HBStorageInitializers
init()
init(config: HBStorageConfig)Space Operations
func save(_ space: HBSpace) async throws
func loadSpace(id: UUID) async throws -> HBSpace?
func loadAllSpaces() async throws -> [HBSpace]
func deleteSpace(id: UUID) async throwsAnchor Operations
func save(_ anchor: HBAnchor) async throws
func loadAnchor(id: UUID) async throws -> HBAnchor?
func loadAnchors(spaceId: UUID, includeDeleted: Bool = false) async throws -> [HBAnchor]
func deleteAnchor(id: UUID) async throws
func purgeDeletedAnchors(before: Date) async throwsSync Operations
func sync() async throws
var isCloudEnabled: Bool { get }
var pendingOperationCount: Int { get }Data Management
func clearLocalStorage() throws
func localStorageSize() throws -> IntVersioning
func timeline(spaceId: UUID) async throws -> HBTimeline
func anchorsAt(spaceId: UUID, date: Date) async throws -> [HBAnchor]
func diff(spaceId: UUID, from: Date, to: Date) async throws -> HBDiff
func history(anchorId: UUID) async throws -> [HBAnchorEvent]
func rollback(anchorId: UUID, toVersion: Int) async throws -> HBAnchorHBStorageConfig
public struct HBStorageConfigProperties
let backend: HBBackend
let syncStrategy: HBSyncStrategy
let compression: HBCompressionLevelStatic Properties
static let `default`: HBStorageConfigHBBackend
public enum HBBackend {
case localOnly
case supabase(url: String, anonKey: String)
}HBSyncStrategy
public enum HBSyncStrategy {
case manual
case onSave
}HBCompressionLevel
public enum HBCompressionLevel {
case none
case balanced
}Errors
HBStorageError
public enum HBStorageError: LocalizedError {
case notFound(type: String, id: UUID)
case encodingFailed(underlying: Error)
case decodingFailed(underlying: Error)
case fileSystemError(underlying: Error)
case compressionFailed(underlying: Error)
case decompressionFailed(underlying: Error)
case cloudNotConfigured
case cloudSyncFailed(underlying: Error)
case networkError(underlying: Error)
case unauthorized
case serverError(statusCode: Int, message: String?)
// Versioning errors
case versionNotFound(anchorId: UUID, version: Int)
case reconstructionFailed(anchorId: UUID)
case eventLogCorrupted(spaceId: UUID)
}HBSpaceError
public enum HBSpaceError: LocalizedError {
case serializationFailed(underlying: Error?)
case deserializationFailed(underlying: Error?)
case invalidWorldMapData
}HBAnchorError
public enum HBAnchorError: LocalizedError {
case invalidTransform(count: Int)
case alreadyDeleted
case metadataKeyNotFound(key: String)
}Compression
HBCompression
public enum HBCompression {
static func compress(_ data: Data, level: HBCompressionLevel) throws -> Data
static func decompress(_ data: Data) throws -> Data
}Versioning
HBAnchorEvent
public struct HBAnchorEvent: Codable, Identifiable, EquatableProperties
| Property | Type | Description |
|---|---|---|
id | UUID | Unique event ID |
anchorId | UUID | Anchor this event affects |
spaceId | UUID | Parent space |
type | EventType | Type of change |
timestamp | Date | When event occurred |
version | Int | Sequential version number |
transform | [Float]? | Transform snapshot |
metadata | [String: AnyCodableValue]? | Metadata snapshot |
actorId | String? | Optional actor identifier |
EventType
public enum EventType: String, Codable {
case created
case moved
case updated
case deleted
case restored
}HBTimeline
public struct HBTimelineProperties
| Property | Type | Description |
|---|---|---|
spaceId | UUID | Space ID |
events | [HBAnchorEvent] | Chronological events |
startDate | Date? | Earliest event |
endDate | Date? | Latest event |
duration | TimeInterval? | Time span |
anchorIds | Set<UUID> | All anchor IDs |
Methods
func events(for anchorId: UUID) -> [HBAnchorEvent]
func events(from: Date, to: Date) -> [HBAnchorEvent]
func events(ofType type: EventType) -> [HBAnchorEvent]
func state(at date: Date) -> [HBAnchor]
func diff(from: Date, to: Date) -> HBDiff
func scrubberDates(from: Date?, to: Date?, steps: Int) -> [Date]
func closestEvent(to date: Date) -> HBAnchorEvent?
var significantDates: [Date]HBDiff
public struct HBDiff: EquatableProperties
| Property | Type | Description |
|---|---|---|
spaceId | UUID | Space ID |
fromDate | Date | Range start |
toDate | Date | Range end |
added | [HBAnchor] | New anchors |
removed | [HBAnchor] | Deleted anchors |
moved | [MovedAnchor] | Transform changes |
updated | [UpdatedAnchor] | Metadata changes |
unchanged | [HBAnchor] | No changes |
Computed Properties
var changeCount: Int
var hasChanges: Bool
var summary: String
var currentAnchors: [HBAnchor]
var previousAnchors: [HBAnchor]MovedAnchor
struct MovedAnchor: Equatable {
let anchor: HBAnchor
let previousTransform: [Float]
var previousPosition: SIMD3<Float>
var currentPosition: SIMD3<Float>
var distanceMoved: Float
}UpdatedAnchor
struct UpdatedAnchor: Equatable {
let anchor: HBAnchor
let previousMetadata: [String: AnyCodableValue]
var addedKeys: Set<String>
var removedKeys: Set<String>
var changedKeys: Set<String>
}