import { IbGibAddr, TjpIbGibAddr } from '@ibgib/ts-gib/dist/types.mjs'; import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/index.mjs'; import { IbGibSpaceAny } from '../../witness/space/space-base-v1.mjs'; import { MetaspaceService } from '../../witness/space/metaspace/metaspace-types.mjs'; import { FlatIbGibGraph } from './graph-types.mjs'; /** * Options when getting dependency graph for ibGib(s). * * Note that this is used both in local and outer space contexts. * When you want to default to the local user space in the local context, * i.e. in `IbgibsService` atow, pass in `null` for {@link space}. */ export interface GetGraphOptions { /** * source ibGib to grab dependencies of. * * caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`. */ ibGib?: IbGib_V1; /** * source ibGibs to grab dependencies of. * * caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`. */ ibGibs?: IbGib_V1[]; /** * source ibGib address to grab dependencies of. * * caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`. */ ibGibAddr?: IbGibAddr; /** * source ibGib addresses to grab dependencies of. * * caller can pass in `ibGib` or `ibGibs` or `ibGibAddr` or `ibGibAddrs`. */ ibGibAddrs?: IbGibAddr[]; /** * If true, for each timeline in each "frozen" ibgib graph we will get the * latest address in the timeline and recheck rel8d ibgibs for newly * added timeline branches. * * If false, this will only look in the past for each rel8d ibgib. * * ## notes * * Say you have a source ibgib with a comment "child" (relative to our * source ibgib). Now say you add an ibgib to that child comment. The rel8d * addr in the source ibgib will still point to the child comment's initial * addr - before it was changed by adding its own "child" ("grandchild" to * the source). So if you get a live dependency graph on the parent, it will * come across the child's timeline and get the latest for that timeline * (and associated ibgibs like the child's dna transforms that add the * grandchild). This will include the grandchild. If it's not a live graph, * then the parent will only have the child and will exclude the grandchild. */ live?: boolean; /** * object that will be populated through recursive calls to this function. * * First caller of this function should not provide this and I'm not atow * coding a separate implementation function to ensure this. * * @see {@link skipAddrs} */ gotten?: { [addr: string]: IbGib_V1; }; /** * used when doing {@link live} dependency graph gets. Same use as * {@link gotten}, but with regards to timelines. */ tjpAddrsAlreadyAnalyzed?: TjpIbGibAddr[]; /** * List of ibgib addresses to skip not retrive in the dependency graph. * * This will also skip any ibgib addresses that would have occurred in the * past of these ibgibs, as when skipping an ibgib, you are also skipping * its dependencies implicitly as well (unless those others are related via * another ibgib that is not skipped of course). * * ## driving use case * * We don't want to get ibgibs that we already have, and this is cleaner * than pre-populating the `gotten` parameter for double-duty. That property * should be strictly used within this call recursively. * * @see {@link gotten} */ skipAddrs?: IbGibAddr[] | Set; /** * Skip these particular rel8n names. * * ## driving intent * * I'm adding this to be able to skip getting dna ibgibs. * * ## see also * * @see {@link onlyRel8nNames} for whitelist of rel8n names for traversal */ skipRel8nNames?: string[]; /** * whitelist of rel8nNames to traverse. * * ## see also * * @see {@link skipRel8nNames} for a blacklist of rel8n names for traversal */ onlyRel8nNames?: string[]; /** * If not found when getting dependency graph, do we retry? This is the * max number of retries. */ maxRetries?: number; /** * If provided and {@link maxRetries} is non-zero, the next retry will be * delayed this amount of time if one or more addrs are not found. */ msBetweenRetries?: number; /** * Space within which we should be looking for ibGibs. * Mutually exclusive with {@link spaces}. */ space?: IbGibSpaceAny | null; /** * Spaces within which we should be looking for ibGibs. * Mutually exclusive with {@link space}. */ spaces?: IbGibSpaceAny[]; /** * If supplied, will make intermittent calls to console.timeLog using this name. */ timeLogName?: string; /** * When getting the live dependency graph, this is used so we don't * duplicate work in recursive calls. * * IOW, in the first run of{@link getGraphProjection_Live}, we call * getLatestAddrs which maps some addrs to the latest addrs in the space. So * we now have a reference to the latest and if we need to call the function * {@link getGraphProjection_Live} recursively, then we can provide this * info to reduce unnecessary computation. */ mapTjpAddrToLatestAddrsInSpace?: { [tjpAddr: string]: IbGibAddr; }; } export type GetGraphResult = FlatIbGibGraph; export interface GetGraphProjectionOptions extends GetGraphOptions { } export interface GetDependencyGraphOptions extends GetGraphProjectionOptions { } /** * * @returns dependency graph, live or non-live depending on {@link GetDependencyGraphOptions} * * Getting a `live` dependency graph means that we will be looking in the given * @see {@link GetDependencyGraphOptions.space} for updates to ibGibs' timelines * (those ibGibs that have timelines/tjps). This is more costly computationally * in the short-term, but often cheaper in the long-term. */ export declare function getDependencyGraph({ ibGib, ibGibs, ibGibAddr, ibGibAddrs, live, gotten, tjpAddrsAlreadyAnalyzed, skipAddrs, skipRel8nNames, onlyRel8nNames, maxRetries, msBetweenRetries, space, spaces, timeLogName, mapTjpAddrToLatestAddrsInSpace, }: GetGraphProjectionOptions): Promise; export declare function getGraphProjection(opts: GetDependencyGraphOptions): Promise; /** * Get the dependency graph for {@link ibGibAddr} since {@link latestCommonFrameAddr}. * * if ibGibAddr is A^5 and latestCommonFrameAddr is A^3, then this should * get all dependencies in A^5 dependency graph NOT ALREADY IN the A^3 * graph. * * NOTE: The {@link live} param is for the delta graph itself. The graph * corresponding to {@link latestCommonFrameAddr} is always calculated live === * false. */ export declare function getDeltaDependencyGraph({ ibGibAddr, latestCommonFrameAddr, live, skipRel8nNames, space, spaces, }: { ibGibAddr: string; latestCommonFrameAddr: string; live: boolean; skipRel8nNames?: string[]; space?: IbGibSpaceAny; spaces?: IbGibSpaceAny[]; }): Promise; /** * Helper function to convert an array of {@link ibGibs} (or undefined) to a * {@link FlatIbGibGraph} ([addr] -> ibGib map). * @returns if ibGibs undefined returns undefined, else flat graph map */ export declare function toFlatGraph({ ibGibs }: { ibGibs: IbGib_V1[] | undefined; }): FlatIbGibGraph | undefined; /** * compare two graphs for "equivalency". * * The default just checks that sizes and addrs are the same. * * The more thorough check does the json strings of the values (as dtos). */ export declare function graphsAreEquivalent({ graphA, graphB, slowButThorough, }: { graphA: FlatIbGibGraph; graphB: FlatIbGibGraph; /** * if true, will actually compare the dto strings of each ibgib in the graph */ slowButThorough?: boolean; }): boolean; export interface ReifyDependencyGraphOpts { /** Either ibGib or ibGibAddr required. NOT BOTH (throws error if both or neither provided). */ ibGib?: IbGib_V1; /** Either ibGib or ibGibAddr required. NOT BOTH (throws error if both or neither provided). */ ibGibAddr?: IbGibAddr; /** * If provided, traverses and reifies ONLY relationships matching these names. * Throws error if provided as an empty array `[]` or if it contains forbidden * intrinsic/lineage rel8ns ('past', 'dna', 'tjp', 'ancestor'). */ onlyRel8nNames?: string[]; /** * Relationship names to explicitly skip during traversal (defaults to skipping * intrinsic/lineage rel8ns like 'past', 'dna', 'tjp', 'ancestor'). */ skipRel8nNames?: string[]; /** Metaspace service instance used for fallback lookups & registrations. */ metaspace: MetaspaceService; /** Target space containing the registered ibgibs and updated timeline tips. */ space: IbGibSpaceAny; } export interface ReifyDependencyGraphResult { /** The root ibgib (either original if unchanged, or newly evolved if any descendants changed). */ reifiedIbGib: IbGib_V1; /** True if one or more nodes in the graph evolved to new tips. */ hasChanges: boolean; /** Map of old address -> new address for every node that evolved in this reification run. */ reifiedAddrsMap: { [oldAddr: string]: string; }; /** All newly evolved and persisted intermediate/root ibgibs created during reification. */ evolvedIbGibs: IbGib_V1[]; } /** * Reifies a dependency graph bottom-up (post-order traversal). * * Checks all constituent relationship targets for newer timeline tips in `space`. * Whenever a child timeline has advanced to a newer frame, the parent is evolved * via `rel8` with the updated child address, persisted to `space`, and registered. * This bubbles all descendant updates up through the DAG to produce a newly reified root ibgib. */ export declare function reifyDependencyGraph({ ibGib, ibGibAddr, onlyRel8nNames, skipRel8nNames, metaspace, space, }: ReifyDependencyGraphOpts): Promise; //# sourceMappingURL=graph-helper.d.mts.map