Files
oikos/web/node_modules/graphology/specs/iteration/nodes.js
dtoro d4d99a7473
Some checks failed
ci / build-test (push) Has been cancelled
ci / docker-build (push) Has been cancelled
feat: Phase 1 — extract the client (web SPA + desktop) to dtoro/oikos-web
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.
2026-08-15 22:27:52 +02:00

219 lines
7.3 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = nodesIteration;
var _assert = _interopRequireDefault(require("assert"));
var _helpers = require("../helpers");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
/**
* Graphology Nodes Iteration Specs
* =================================
*
* Testing the nodes iteration-related methods of the graph.
*/
function nodesIteration(Graph, checkers) {
var invalid = checkers.invalid;
return {
'#.nodes': {
'it should return the list of nodes of the graph.': function it_should_return_the_list_of_nodes_of_the_graph() {
var graph = new Graph();
(0, _helpers.addNodesFrom)(graph, ['one', 'two', 'three']);
_assert["default"].deepStrictEqual(graph.nodes(), ['one', 'two', 'three']);
}
},
'#.forEachNode': {
'it should throw if given callback is not a function.': function it_should_throw_if_given_callback_is_not_a_function() {
var graph = new Graph();
_assert["default"]["throws"](function () {
graph.forEachNode(null);
}, invalid());
},
'it should be possible to iterate over nodes and their attributes.': function it_should_be_possible_to_iterate_over_nodes_and_their_attributes() {
var graph = new Graph();
graph.addNode('John', {
age: 34
});
graph.addNode('Martha', {
age: 33
});
var count = 0;
graph.forEachNode(function (key, attributes) {
_assert["default"].strictEqual(key, count ? 'Martha' : 'John');
_assert["default"].deepStrictEqual(attributes, count ? {
age: 33
} : {
age: 34
});
count++;
});
_assert["default"].strictEqual(count, 2);
}
},
'#.findNode': {
'it should throw if given callback is not a function.': function it_should_throw_if_given_callback_is_not_a_function() {
var graph = new Graph();
_assert["default"]["throws"](function () {
graph.findNode(null);
}, invalid());
},
'it should be possible to find a node in the graph.': function it_should_be_possible_to_find_a_node_in_the_graph() {
var graph = new Graph();
graph.addNode('John', {
age: 34
});
graph.addNode('Martha', {
age: 33
});
var count = 0;
var found = graph.findNode(function (key, attributes) {
_assert["default"].strictEqual(key, 'John');
_assert["default"].deepStrictEqual(attributes, {
age: 34
});
count++;
if (key === 'John') return true;
});
_assert["default"].strictEqual(found, 'John');
_assert["default"].strictEqual(count, 1);
found = graph.findNode(function () {
return false;
});
_assert["default"].strictEqual(found, undefined);
}
},
'#.mapNodes': {
'it should be possible to map nodes.': function it_should_be_possible_to_map_nodes() {
var graph = new Graph();
graph.addNode('one', {
weight: 2
});
graph.addNode('two', {
weight: 3
});
var result = graph.mapNodes(function (node, attr) {
return attr.weight * 2;
});
_assert["default"].deepStrictEqual(result, [4, 6]);
}
},
'#.someNode': {
'it should always return false on empty sets.': function it_should_always_return_false_on_empty_sets() {
var graph = new Graph();
_assert["default"].strictEqual(graph.someNode(function () {
return true;
}), false);
},
'it should be possible to find if some node matches a predicate.': function it_should_be_possible_to_find_if_some_node_matches_a_predicate() {
var graph = new Graph();
graph.addNode('one', {
weight: 2
});
graph.addNode('two', {
weight: 3
});
_assert["default"].strictEqual(graph.someNode(function (node, attr) {
return attr.weight > 6;
}), false);
_assert["default"].strictEqual(graph.someNode(function (node, attr) {
return attr.weight > 2;
}), true);
}
},
'#.everyNode': {
'it should always return true on empty sets.': function it_should_always_return_true_on_empty_sets() {
var graph = new Graph();
_assert["default"].strictEqual(graph.everyNode(function () {
return true;
}), true);
},
'it should be possible to find if all node matches a predicate.': function it_should_be_possible_to_find_if_all_node_matches_a_predicate() {
var graph = new Graph();
graph.addNode('one', {
weight: 2
});
graph.addNode('two', {
weight: 3
});
_assert["default"].strictEqual(graph.everyNode(function (node, attr) {
return attr.weight > 2;
}), false);
_assert["default"].strictEqual(graph.everyNode(function (node, attr) {
return attr.weight > 1;
}), true);
}
},
'#.filterNodes': {
'it should be possible to filter nodes.': function it_should_be_possible_to_filter_nodes() {
var graph = new Graph();
graph.addNode('one', {
weight: 2
});
graph.addNode('two', {
weight: 3
});
graph.addNode('three', {
weight: 4
});
var result = graph.filterNodes(function (node, _ref) {
var weight = _ref.weight;
return weight >= 3;
});
_assert["default"].deepStrictEqual(result, ['two', 'three']);
}
},
'#.reduceNodes': {
'it should throw if initial value is not given.': function it_should_throw_if_initial_value_is_not_given() {
var graph = new Graph();
_assert["default"]["throws"](function () {
graph.reduceNodes(function (x, _, attr) {
return x + attr.weight;
});
}, invalid());
},
'it should be possible to reduce nodes.': function it_should_be_possible_to_reduce_nodes() {
var graph = new Graph();
graph.addNode('one', {
weight: 2
});
graph.addNode('two', {
weight: 3
});
graph.addNode('three', {
weight: 4
});
var result = graph.reduceNodes(function (x, _, attr) {
return x + attr.weight;
}, 0);
_assert["default"].strictEqual(result, 9);
}
},
'#.nodeEntries': {
'it should be possible to create a nodes iterator.': function it_should_be_possible_to_create_a_nodes_iterator() {
var graph = new Graph();
(0, _helpers.addNodesFrom)(graph, ['one', 'two', 'three']);
graph.replaceNodeAttributes('two', {
hello: 'world'
});
var iterator = graph.nodeEntries();
_assert["default"].deepStrictEqual(iterator.next().value, {
node: 'one',
attributes: {}
});
_assert["default"].deepStrictEqual(iterator.next().value, {
node: 'two',
attributes: {
hello: 'world'
}
});
_assert["default"].deepStrictEqual(iterator.next().value, {
node: 'three',
attributes: {}
});
_assert["default"].strictEqual(iterator.next().done, true);
}
}
};
}