Problem: the hexagonal refactor churns the backend tree for nine more phases; the UI delivery stack (web/ SPA, cmd/desktop Wails wrapper, compose/web image) must move to its own repo first so doc/layout rewrites land once on a backend-only tree. Change: - New repo git.hubris.network/dtoro/oikos-web (v0.33.0): web/, desktop/ (updateURL repointed to oikos-web releases), compose/, own CI (web + desktop jobs), own deploy script (CI-green gate, TOCTOU guard, version-tagged images, prune-to-3), own webhook receiver on :9798 + launchd unit, own compose project publishing the same 8091:80. - Cutover executed on mac-mini in order: oikos stack's web service stopped+removed, oikos-web project brought up on 8091; outer Caddy untouched (targets the published port) — serving + Authentik flow + /wails 404 quirk verified post-cutover. - Stripped from oikos: web/, cmd/desktop/, compose/web/, desktop CI workflow, ci.yml web job, Makefile ui/desktop/desktop-package/install targets, the compose web service, oikos-web from deploy.sh's fallback prune list; wails + go-keyring dropped from go.mod, vendor synced. - README / CONTRIBUTING / AGENTS.md / .agents dev+operations docs now point at the new repo; mbse + mascot design docs carry a path note. Risk: production SPA serving depends on the new pipeline now; rollback is versioned-image re-up of the old web service from a pre-split checkout (port 8091). Desktop builds installed before the split still check dtoro/oikos releases — one manual reinstall, noted in the oikos-web release notes. Verification: go vet, make test (race), make generate-check, golangci (no new findings; baseline down 400→365); post-cutover curls — localhost:8091 200, /wails/runtime.js 404, outer Caddy 302 Authentik.
6.4 KiB
Graphology Utils
Miscellaneous utility functions to be used with graphology.
Installation
npm install graphology-utils
Usage
Assertions
Introspection
Typical edge patterns
Miscellaneous helpers
#.isGraph
Function returning whether the given value is a graphology implementation's instance.
import {isGraph} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import isGraph from 'graphology-utils/is-graph';
const graph = new Graph();
isGraph(graph);
>>> true
isGraph(45);
>>> false
isGraph({hello: 'world'});
>>> false
Arguments
- value any: value to test.
#.isGraphConstructor
Function returning whether the given value is a graphology constructor.
import {isGraphConstructor} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import isGraphConstructor from 'graphology-utils/is-graph-constructor';
isGraphConstructor(Graph);
>>> true
isGraphConstructor(45);
>>> false
isGraphConstructor(new Graph());
>>> false
Arguments
- value any: value to test.
#.inferMulti
Function returning whether the given graph is truly multi, i.e. if we can find at least one occurrence of multiple edges of the same type and direction between two nodes.
import {inferMulti} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import inferMulti from 'graphology-utils/infer-multi';
const graph = new MultiGraph();
graph.addEdge(1, 2);
inferMulti(graph);
>>> false
graph.addEdge(1, 2);
inferMulti(graph);
>>> true
#.inferType
Function returning the inferred type of the given graph. This function is useful to check whether a given mixed graph is in fact a mere directed or undirected graph based on its actual edges.
import {inferType} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import inferType from 'graphology-utils/infer-type';
const graph = new Graph();
graph.addUndirectedEdge(1, 2);
inferType(graph);
>>> 'directed'
#.mergeClique
Function adding a clique to the given graph.
import {mergeClique} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import mergeClique from 'graphology-utils/merge-clique';
const graph = new Graph();
mergeClique(graph, [1, 2, 3]);
graph.edges().map(e => graph.extremities(e));
>>> [[1, 2], [1, 3], [2, 3]]
#.mergeCycle
Function adding a cycle to the given graph.
import {mergeCycle} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import mergeCycle from 'graphology-utils/merge-cycle';
const graph = new Graph();
mergeCycle(graph, [1, 2, 3, 4, 5]);
graph.edges().map(e => graph.extremities(e));
>>> [[1, 2], [2, 3], [3, 4], [4, 5], [5, 1]]
Arguments
- graph Graph: target graph.
- cycle array: array of nodes representing the cycle to add.
#.mergePath
Function adding a path to the given graph.
import {mergePath} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import mergePath from 'graphology-utils/merge-path';
const graph = new Graph();
mergePath(graph, [1, 2, 3, 4, 5]);
graph.edges().map(e => graph.extremities(e));
>>> [[1, 2], [2, 3], [3, 4], [4, 5]]
Arguments
- graph Graph: target graph.
- path array: array of nodes representing the path to add.
#.mergeStar
Function adding a star to the given graph.
import {mergeStar} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import mergeStar from 'graphology-utils/merge-star';
const graph = new Graph();
mergeStar(graph, [1, 2, 3, 4, 5]);
graph.edges().map(e => graph.extremities(e));
>>> [[1, 2], [1, 3], [1, 4], [1, 5]]
Arguments
- graph Graph: target graph.
- star array: array of nodes representing the star to add.
#.renameGraphKeys
Function renaming the nodes & edges key of a graph using mappings and returning a new graph with renamed keys.
import {renameGraphKeys} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import renameGraphKeys from 'graphology-utils/rename-graph-keys';
const graph = new Graph();
graph.addNode('Martha');
graph.addNode('Catherine');
graph.addNode('John');
graph.addEdgeWithKey('M->C', 'Martha', 'Catherine');
graph.addEdgeWithKey('C->J', 'Catherine', 'John');
const renamedGraph = renameGraphKeys(
graph,
{Martha: 1, Catherine: 2, John: 3},
{'M->C': 'rel1', 'C->J': 'rel2'}
);
renamedGraph.nodes();
>>> [1, 2, 3];
renamedGraph.edges();
>>> ['rel1', 'rel2'];
Arguments
- graph Graph: target graph.
- nodeKeyMapping object: A key/value map for the node key mapping.
- edgeKeyMapping ?object: A key/value map for the edge key mapping.
#.updateGraphKeys
Function updating the nodes & edges key of a graph using functions and returning a new graph with updated keys.
import {updateGraphKeys} from 'graphology-utils';
// Alternatively, if you want to only load the relevant code:
import updateGraphKeys from 'graphology-utils/update-graph-keys';
const graph = new Graph();
graph.addNode('Martha');
graph.addNode('Catherine');
graph.addNode('John');
graph.addEdgeWithKey('M->C', 'Martha', 'Catherine');
graph.addEdgeWithKey('C->J', 'Catherine', 'John');
const updatedGraph = updateGraphKeys(
graph,
(key)=> {
if (key === 'Martha') return 1;
if (key === 'Catherine') return 2;
return 3;
},
(key) => {
if (key === 'M->C') return 'rel1';
return 'rel2';
}
);
updatedGraph.nodes();
>>> [1, 2, 3];
updatedGraph.edges();
>>> ['rel1', 'rel2'];
Arguments
- graph Graph: target graph.
- nodeKeyUdater function: A function to compute a new node key from the same arguments that would be given to
#.forEachNode. - edgeKeyUpdater function: A function to compute a new edge key from the same arguments that would be given to
#.forEachEdge.