g3-toolkit API Reference
    Preparing search index...

    Class UGM

    @g3-toolkit/core public API.

    Framework-agnostic (D6): zero React, zero Zustand, zero Cytoscape imports.

    The boundary here is enforced two ways: (1) physical separation (packages/core/src/ cannot relatively-import from packages/react/src/), and (2) the module-boundary test in test/module-boundary.test.ts which dynamically imports every entry below and asserts none of them pull in React.

    Index

    Constructors

    Accessors

    Methods

    • Add an edge with Qualified Edge metadata (D1). Uses input.key as the edge ID when given (a stable id the host owns, which snapshots and exports then carry unchanged); otherwise auto-generates one for multi-edge support. Graphology's generator skips ids already present, so a restored keyed id can never collide with a later generated one.

      Parameters

      Returns string

      the edge ID

      when input.key names an edge that already exists

    • Drop the stamp for one property. The value stays; it is now a source value as far as every reader is concerned.

      Parameters

      • nodeId: string
      • property: string

      Returns void

    • Iterate all edges.

      Parameters

      • callback: (
            edgeId: string,
            attributes: EdgeAttributes,
            source: string,
            target: string,
        ) => void

      Returns void

    • Deserialize from a JSON object produced by toJSON(). Edge ids are restored as keys, so a snapshot round-trip keeps every edge id (host-supplied or generated); before issue #31 the restore regenerated them, and an undo step silently renamed every edge.

      Reads versions 1 (no version field, or version: 1) and 2 (derivations); any other version throws UnsupportedVersionError and a stamp naming a node the document does not contain throws MalformedDocumentError, the throwing convention of model/document-errors.ts (a snapshot has no useful partial reading).

      Parameters

      Returns UGM

    • The stamp for a derived property, or undefined when the value is a source value (never derived, or overwritten since).

      Parameters

      • nodeId: string
      • property: string

      Returns DerivationStamp | undefined

    • Get the source and target of an edge.

      Parameters

      • edgeId: string

      Returns { source: string; target: string } | undefined

    • Get edges between two specific nodes (multi-edge support).

      Parameters

      • source: string
      • target: string

      Returns string[]

    • Subscribe to a UGM event. Returns an unsubscribe function.

      Type Parameters

      Parameters

      • event: T
      • handler: EventHandler<
            T extends "nodeAdded"
            | "nodeRemoved"
                ? NodeEventPayload
                : T extends "edgeAdded"
                | "edgeRemoved"
                    ? EdgeEventPayload
                    : T extends "nodeAttributesUpdated"
                    | "edgeAttributesUpdated"
                        ? AttributeUpdatePayload
                        : null,
        >

      Returns () => void

    • Record that property on nodeId currently holds a DERIVED value written by stamp.definitionId. Replaces any earlier stamp for the pair. The value itself is written through updateNodeProperties first (which clears the old stamp), then stamped.

      Parameters

      Returns void

      when the node does not exist

    • Update properties on an existing edge. Merges with existing.

      Parameters

      • edgeId: string
      • properties: Record<string, unknown>

      Returns void

    • Update properties on an existing node. Merges with existing.

      This is a SOURCE write as far as the derivation registry is concerned: every key written here loses its stamp, since whatever value is there afterwards was not produced by the stamped definition. DerivedPropertyEngine writes through this method too and re-stamps immediately after, which is the only ordering that keeps the registry honest without a second, privileged write path.

      Parameters

      • id: string
      • properties: Record<string, unknown>

      Returns void