tina4-nodejs 3.13.110 → 3.13.111
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +2 -2
- package/package.json +1 -1
- package/packages/cli/dist/bin.js +787 -3
- package/packages/core/dist/index.js +787 -3
- package/packages/orm/dist/index.js +794 -0
- package/packages/orm/src/graph/adapters/arango.ts +256 -0
- package/packages/orm/src/graph/adapters/bolt.ts +259 -0
- package/packages/orm/src/graph/adapters/ultipa.ts +271 -0
- package/packages/orm/src/graph/connectTimeout.ts +39 -0
- package/packages/orm/src/graph/errors.ts +29 -0
- package/packages/orm/src/graph/graphAdapter.ts +53 -0
- package/packages/orm/src/graph/graphDatabase.ts +114 -0
- package/packages/orm/src/graph/graphUrl.ts +98 -0
- package/packages/orm/src/graph/shapes.ts +95 -0
- package/packages/orm/src/index.ts +137 -115
- package/types/orm/src/graph/adapters/arango.d.ts +42 -0
- package/types/orm/src/graph/adapters/bolt.d.ts +43 -0
- package/types/orm/src/graph/adapters/ultipa.d.ts +39 -0
- package/types/orm/src/graph/connectTimeout.d.ts +12 -0
- package/types/orm/src/graph/errors.d.ts +21 -0
- package/types/orm/src/graph/graphAdapter.d.ts +38 -0
- package/types/orm/src/graph/graphDatabase.d.ts +44 -0
- package/types/orm/src/graph/graphUrl.d.ts +28 -0
- package/types/orm/src/graph/shapes.d.ts +37 -0
- package/types/orm/src/index.d.ts +8 -0
|
@@ -42620,6 +42620,775 @@ var init_docstore = __esm({
|
|
|
42620
42620
|
}
|
|
42621
42621
|
});
|
|
42622
42622
|
|
|
42623
|
+
// src/graph/graphUrl.ts
|
|
42624
|
+
var SCHEME_ENGINE, ENGINE_DEFAULT_PORT, GraphUrl;
|
|
42625
|
+
var init_graphUrl = __esm({
|
|
42626
|
+
"src/graph/graphUrl.ts"() {
|
|
42627
|
+
"use strict";
|
|
42628
|
+
SCHEME_ENGINE = {
|
|
42629
|
+
ultipa: "ultipa",
|
|
42630
|
+
ultipas: "ultipa",
|
|
42631
|
+
// TLS variant
|
|
42632
|
+
neo4j: "bolt",
|
|
42633
|
+
"neo4j+s": "bolt",
|
|
42634
|
+
bolt: "bolt",
|
|
42635
|
+
"bolt+s": "bolt",
|
|
42636
|
+
memgraph: "bolt",
|
|
42637
|
+
arango: "arango",
|
|
42638
|
+
arangodb: "arango"
|
|
42639
|
+
};
|
|
42640
|
+
ENGINE_DEFAULT_PORT = {
|
|
42641
|
+
ultipa: 60061,
|
|
42642
|
+
bolt: 7687,
|
|
42643
|
+
arango: 8529
|
|
42644
|
+
};
|
|
42645
|
+
GraphUrl = class _GraphUrl {
|
|
42646
|
+
raw;
|
|
42647
|
+
scheme;
|
|
42648
|
+
engine;
|
|
42649
|
+
host;
|
|
42650
|
+
port;
|
|
42651
|
+
/** The graph/database name (leading slash stripped), or null when absent. */
|
|
42652
|
+
graph;
|
|
42653
|
+
username;
|
|
42654
|
+
password;
|
|
42655
|
+
params;
|
|
42656
|
+
useTls;
|
|
42657
|
+
constructor(url) {
|
|
42658
|
+
this.raw = url;
|
|
42659
|
+
let parsed;
|
|
42660
|
+
try {
|
|
42661
|
+
parsed = new URL(url);
|
|
42662
|
+
} catch {
|
|
42663
|
+
throw new Error(
|
|
42664
|
+
`Unsupported graph URL '${url}' \u2014 expected scheme://[user[:password]@]host[:port]/graph (e.g. ultipa://host:60061/mygraph).`
|
|
42665
|
+
);
|
|
42666
|
+
}
|
|
42667
|
+
const scheme = parsed.protocol.replace(/:$/, "").toLowerCase();
|
|
42668
|
+
const engine = SCHEME_ENGINE[scheme];
|
|
42669
|
+
if (engine === void 0) {
|
|
42670
|
+
throw new Error(
|
|
42671
|
+
`Unsupported graph URL scheme '${scheme}'. Supported: ${Object.keys(SCHEME_ENGINE).sort().join(", ")} (e.g. ultipa://host:60061/mygraph).`
|
|
42672
|
+
);
|
|
42673
|
+
}
|
|
42674
|
+
this.scheme = scheme;
|
|
42675
|
+
this.engine = engine;
|
|
42676
|
+
this.host = parsed.hostname || "localhost";
|
|
42677
|
+
this.port = parsed.port ? parseInt(parsed.port, 10) : ENGINE_DEFAULT_PORT[engine];
|
|
42678
|
+
const path8 = (parsed.pathname || "").replace(/^\//, "");
|
|
42679
|
+
this.graph = path8 === "" ? null : path8;
|
|
42680
|
+
this.username = parsed.username ? decodeURIComponent(parsed.username) : null;
|
|
42681
|
+
this.password = parsed.password ? decodeURIComponent(parsed.password) : null;
|
|
42682
|
+
this.params = {};
|
|
42683
|
+
for (const [key, value] of parsed.searchParams) {
|
|
42684
|
+
if (!(key in this.params)) this.params[key] = value;
|
|
42685
|
+
}
|
|
42686
|
+
this.useTls = scheme.endsWith("s") || this.params.tls === "1" || this.params.tls === "true";
|
|
42687
|
+
}
|
|
42688
|
+
/** host:port/graph — for messages, never carrying credentials. */
|
|
42689
|
+
getDsn() {
|
|
42690
|
+
const target = this.port ? `${this.host}:${this.port}` : this.host;
|
|
42691
|
+
return this.graph ? `${target}/${this.graph}` : target;
|
|
42692
|
+
}
|
|
42693
|
+
static fromEnv(envKey = "TINA4_GRAPH_URL") {
|
|
42694
|
+
const url = (process.env[envKey] ?? "").trim();
|
|
42695
|
+
return url === "" ? null : new _GraphUrl(url);
|
|
42696
|
+
}
|
|
42697
|
+
};
|
|
42698
|
+
}
|
|
42699
|
+
});
|
|
42700
|
+
|
|
42701
|
+
// src/graph/errors.ts
|
|
42702
|
+
var GraphError, GraphConnectTimeout;
|
|
42703
|
+
var init_errors = __esm({
|
|
42704
|
+
"src/graph/errors.ts"() {
|
|
42705
|
+
"use strict";
|
|
42706
|
+
GraphError = class extends Error {
|
|
42707
|
+
constructor(message, cause) {
|
|
42708
|
+
super(message, cause === void 0 ? void 0 : { cause });
|
|
42709
|
+
this.name = "GraphError";
|
|
42710
|
+
}
|
|
42711
|
+
};
|
|
42712
|
+
GraphConnectTimeout = class extends GraphError {
|
|
42713
|
+
constructor(message, cause) {
|
|
42714
|
+
super(message, cause);
|
|
42715
|
+
this.name = "GraphConnectTimeout";
|
|
42716
|
+
}
|
|
42717
|
+
};
|
|
42718
|
+
}
|
|
42719
|
+
});
|
|
42720
|
+
|
|
42721
|
+
// src/graph/shapes.ts
|
|
42722
|
+
var GraphNode, GraphEdge, GraphResult;
|
|
42723
|
+
var init_shapes = __esm({
|
|
42724
|
+
"src/graph/shapes.ts"() {
|
|
42725
|
+
"use strict";
|
|
42726
|
+
GraphNode = class {
|
|
42727
|
+
id;
|
|
42728
|
+
labels;
|
|
42729
|
+
properties;
|
|
42730
|
+
constructor(id, labels = null, properties = null) {
|
|
42731
|
+
this.id = id;
|
|
42732
|
+
this.labels = [...labels ?? []];
|
|
42733
|
+
this.properties = { ...properties ?? {} };
|
|
42734
|
+
}
|
|
42735
|
+
toDict() {
|
|
42736
|
+
return { id: this.id, labels: this.labels, properties: this.properties };
|
|
42737
|
+
}
|
|
42738
|
+
};
|
|
42739
|
+
GraphEdge = class {
|
|
42740
|
+
id;
|
|
42741
|
+
type;
|
|
42742
|
+
from;
|
|
42743
|
+
to;
|
|
42744
|
+
properties;
|
|
42745
|
+
constructor(id, type2, from, to, properties = null) {
|
|
42746
|
+
this.id = id;
|
|
42747
|
+
this.type = type2;
|
|
42748
|
+
this.from = from;
|
|
42749
|
+
this.to = to;
|
|
42750
|
+
this.properties = { ...properties ?? {} };
|
|
42751
|
+
}
|
|
42752
|
+
toDict() {
|
|
42753
|
+
return {
|
|
42754
|
+
id: this.id,
|
|
42755
|
+
type: this.type,
|
|
42756
|
+
from: this.from,
|
|
42757
|
+
to: this.to,
|
|
42758
|
+
properties: this.properties
|
|
42759
|
+
};
|
|
42760
|
+
}
|
|
42761
|
+
};
|
|
42762
|
+
GraphResult = class {
|
|
42763
|
+
records;
|
|
42764
|
+
columns;
|
|
42765
|
+
constructor(records = null, columns = null) {
|
|
42766
|
+
this.records = [...records ?? []];
|
|
42767
|
+
this.columns = [...columns ?? []];
|
|
42768
|
+
}
|
|
42769
|
+
toArray() {
|
|
42770
|
+
return this.records;
|
|
42771
|
+
}
|
|
42772
|
+
/** The first value of the first record, or null. */
|
|
42773
|
+
scalar() {
|
|
42774
|
+
if (this.records.length === 0) return null;
|
|
42775
|
+
const values = Object.values(this.records[0]);
|
|
42776
|
+
return values.length ? values[0] : null;
|
|
42777
|
+
}
|
|
42778
|
+
[Symbol.iterator]() {
|
|
42779
|
+
return this.records[Symbol.iterator]();
|
|
42780
|
+
}
|
|
42781
|
+
get length() {
|
|
42782
|
+
return this.records.length;
|
|
42783
|
+
}
|
|
42784
|
+
};
|
|
42785
|
+
}
|
|
42786
|
+
});
|
|
42787
|
+
|
|
42788
|
+
// src/graph/connectTimeout.ts
|
|
42789
|
+
function resolveGraphConnectTimeout() {
|
|
42790
|
+
const raw = (process.env[GRAPH_CONNECT_TIMEOUT_VARIABLE] ?? "").trim();
|
|
42791
|
+
if (raw === "") {
|
|
42792
|
+
return DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS;
|
|
42793
|
+
}
|
|
42794
|
+
const seconds = Number(raw);
|
|
42795
|
+
if (!Number.isFinite(seconds)) {
|
|
42796
|
+
Log.warning(
|
|
42797
|
+
`${GRAPH_CONNECT_TIMEOUT_VARIABLE}="${raw}" is not a number of seconds \u2014 bounding graph connects at the ${DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS}s default instead`
|
|
42798
|
+
);
|
|
42799
|
+
return DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS;
|
|
42800
|
+
}
|
|
42801
|
+
return seconds <= 0 ? null : seconds;
|
|
42802
|
+
}
|
|
42803
|
+
var GRAPH_CONNECT_TIMEOUT_VARIABLE, DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS;
|
|
42804
|
+
var init_connectTimeout2 = __esm({
|
|
42805
|
+
"src/graph/connectTimeout.ts"() {
|
|
42806
|
+
"use strict";
|
|
42807
|
+
init_src2();
|
|
42808
|
+
GRAPH_CONNECT_TIMEOUT_VARIABLE = "TINA4_GRAPH_CONNECT_TIMEOUT";
|
|
42809
|
+
DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS = 10;
|
|
42810
|
+
}
|
|
42811
|
+
});
|
|
42812
|
+
|
|
42813
|
+
// src/graph/adapters/ultipa.ts
|
|
42814
|
+
var ultipa_exports = {};
|
|
42815
|
+
__export(ultipa_exports, {
|
|
42816
|
+
UltipaGraphAdapter: () => UltipaGraphAdapter
|
|
42817
|
+
});
|
|
42818
|
+
function propClause(properties) {
|
|
42819
|
+
const props = properties ?? {};
|
|
42820
|
+
const keys = Object.keys(props);
|
|
42821
|
+
if (keys.length === 0) return { clause: "{}", params: {} };
|
|
42822
|
+
const pairs = keys.map((key) => `${key}: $p_${key}`).join(", ");
|
|
42823
|
+
const params = {};
|
|
42824
|
+
for (const key of keys) params[`p_${key}`] = props[key];
|
|
42825
|
+
return { clause: `{${pairs}}`, params };
|
|
42826
|
+
}
|
|
42827
|
+
function errorMessage(exc) {
|
|
42828
|
+
if (exc instanceof Error) return exc.message;
|
|
42829
|
+
return String(exc);
|
|
42830
|
+
}
|
|
42831
|
+
var DRIVER_PACKAGE2, driver, UltipaClient, UltipaConnectError, UNBOUNDED_CONNECT_SECONDS, UltipaGraphAdapter;
|
|
42832
|
+
var init_ultipa = __esm({
|
|
42833
|
+
async "src/graph/adapters/ultipa.ts"() {
|
|
42834
|
+
"use strict";
|
|
42835
|
+
init_shapes();
|
|
42836
|
+
init_errors();
|
|
42837
|
+
init_connectTimeout2();
|
|
42838
|
+
DRIVER_PACKAGE2 = "tina4-ultipa";
|
|
42839
|
+
driver = await import(DRIVER_PACKAGE2);
|
|
42840
|
+
UltipaClient = driver.UltipaClient;
|
|
42841
|
+
UltipaConnectError = driver.UltipaConnectError;
|
|
42842
|
+
UNBOUNDED_CONNECT_SECONDS = 31536e4;
|
|
42843
|
+
UltipaGraphAdapter = class {
|
|
42844
|
+
url;
|
|
42845
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
42846
|
+
client;
|
|
42847
|
+
lastError = null;
|
|
42848
|
+
constructor(graphUrl, credentials = {}) {
|
|
42849
|
+
this.url = graphUrl;
|
|
42850
|
+
const timeout = resolveGraphConnectTimeout();
|
|
42851
|
+
this.client = new UltipaClient({
|
|
42852
|
+
host: graphUrl.host,
|
|
42853
|
+
port: graphUrl.port,
|
|
42854
|
+
username: graphUrl.username || credentials.username || null,
|
|
42855
|
+
password: graphUrl.password || credentials.password || null,
|
|
42856
|
+
graph: graphUrl.graph,
|
|
42857
|
+
connectTimeout: timeout ?? UNBOUNDED_CONNECT_SECONDS,
|
|
42858
|
+
useTls: graphUrl.useTls
|
|
42859
|
+
});
|
|
42860
|
+
}
|
|
42861
|
+
// -- connection + raw pass-through -------------------------------------
|
|
42862
|
+
async run(gql, params = null, readOnly = true) {
|
|
42863
|
+
try {
|
|
42864
|
+
await this.client.connect();
|
|
42865
|
+
} catch (exc) {
|
|
42866
|
+
this.lastError = errorMessage(exc);
|
|
42867
|
+
if (exc instanceof UltipaConnectError || exc?.name === "UltipaConnectError") {
|
|
42868
|
+
const elapsed = typeof exc?.elapsed === "number" ? exc.elapsed : 0;
|
|
42869
|
+
throw new GraphConnectTimeout(
|
|
42870
|
+
`Graph connect to ${this.url.host}:${this.url.port} timed out after ${elapsed.toFixed(1)}s (${GRAPH_CONNECT_TIMEOUT_VARIABLE}). Raise ${GRAPH_CONNECT_TIMEOUT_VARIABLE} if the server is simply slow, or set it to 0 to wait indefinitely.`,
|
|
42871
|
+
exc
|
|
42872
|
+
);
|
|
42873
|
+
}
|
|
42874
|
+
throw new GraphError(this.lastError, exc);
|
|
42875
|
+
}
|
|
42876
|
+
try {
|
|
42877
|
+
return await this.client.query(gql, { params: params ?? null, readOnly });
|
|
42878
|
+
} catch (exc) {
|
|
42879
|
+
this.lastError = errorMessage(exc);
|
|
42880
|
+
throw new GraphError(this.lastError, exc);
|
|
42881
|
+
}
|
|
42882
|
+
}
|
|
42883
|
+
async query(text, params = null) {
|
|
42884
|
+
const result = await this.run(text, params, true);
|
|
42885
|
+
return new GraphResult(result.dicts(), result.columns);
|
|
42886
|
+
}
|
|
42887
|
+
async execute(text, params = null) {
|
|
42888
|
+
const result = await this.run(text, params, false);
|
|
42889
|
+
return new GraphResult(result.dicts(), result.columns);
|
|
42890
|
+
}
|
|
42891
|
+
// -- portable node/edge/traverse core (GQL) ----------------------------
|
|
42892
|
+
nodeFromRow(row) {
|
|
42893
|
+
if (row === null || row === void 0) return null;
|
|
42894
|
+
return new GraphNode(
|
|
42895
|
+
String(row.id),
|
|
42896
|
+
row.labels ?? [],
|
|
42897
|
+
row.props ?? {}
|
|
42898
|
+
);
|
|
42899
|
+
}
|
|
42900
|
+
async addNode(label, properties = null) {
|
|
42901
|
+
const { clause, params } = propClause(properties);
|
|
42902
|
+
const gql = `INSERT (n:\`${label}\` ${clause}) RETURN id(n) AS id, labels(n) AS labels, properties(n) AS props`;
|
|
42903
|
+
const rows = (await this.run(gql, params, false)).dicts();
|
|
42904
|
+
return rows.length ? this.nodeFromRow(rows[0]) : null;
|
|
42905
|
+
}
|
|
42906
|
+
async addEdge(fromId, toId, type2, properties = null) {
|
|
42907
|
+
const { clause, params } = propClause(properties);
|
|
42908
|
+
params.from_id = fromId;
|
|
42909
|
+
params.to_id = toId;
|
|
42910
|
+
const gql = `MATCH (a), (b) WHERE id(a) = $from_id AND id(b) = $to_id INSERT (a)-[e:\`${type2}\` ${clause}]->(b) RETURN id(e) AS id, type(e) AS type, id(a) AS f, id(b) AS t, properties(e) AS props`;
|
|
42911
|
+
const rows = (await this.run(gql, params, false)).dicts();
|
|
42912
|
+
if (rows.length === 0) return null;
|
|
42913
|
+
const row = rows[0];
|
|
42914
|
+
return new GraphEdge(
|
|
42915
|
+
String(row.id),
|
|
42916
|
+
String(row.type),
|
|
42917
|
+
String(row.f),
|
|
42918
|
+
String(row.t),
|
|
42919
|
+
row.props ?? {}
|
|
42920
|
+
);
|
|
42921
|
+
}
|
|
42922
|
+
async getNode(nodeId) {
|
|
42923
|
+
const gql = `MATCH (n) WHERE id(n) = $id RETURN id(n) AS id, labels(n) AS labels, properties(n) AS props`;
|
|
42924
|
+
const rows = (await this.run(gql, { id: nodeId }, true)).dicts();
|
|
42925
|
+
return rows.length ? this.nodeFromRow(rows[0]) : null;
|
|
42926
|
+
}
|
|
42927
|
+
async updateNode(nodeId, properties) {
|
|
42928
|
+
const props = properties ?? {};
|
|
42929
|
+
const keys = Object.keys(props);
|
|
42930
|
+
const sets = keys.map((key) => `n.${key} = $p_${key}`).join(", ");
|
|
42931
|
+
const params = { id: nodeId };
|
|
42932
|
+
for (const key of keys) params[`p_${key}`] = props[key];
|
|
42933
|
+
const gql = `MATCH (n) WHERE id(n) = $id SET ${sets} RETURN id(n) AS id, labels(n) AS labels, properties(n) AS props`;
|
|
42934
|
+
const rows = (await this.run(gql, params, false)).dicts();
|
|
42935
|
+
return rows.length ? this.nodeFromRow(rows[0]) : null;
|
|
42936
|
+
}
|
|
42937
|
+
async deleteNode(nodeId) {
|
|
42938
|
+
const gql = "MATCH (n) WHERE id(n) = $id DETACH DELETE n";
|
|
42939
|
+
await this.run(gql, { id: nodeId }, false);
|
|
42940
|
+
return true;
|
|
42941
|
+
}
|
|
42942
|
+
async neighbors(nodeId, options = {}) {
|
|
42943
|
+
const direction = options.direction ?? "both";
|
|
42944
|
+
const limit = options.limit ?? 100;
|
|
42945
|
+
const edge = options.edgeType ? `:\`${options.edgeType}\`` : "";
|
|
42946
|
+
const pattern = {
|
|
42947
|
+
out: `(n)-[${edge}]->(m)`,
|
|
42948
|
+
in: `(n)<-[${edge}]-(m)`,
|
|
42949
|
+
both: `(n)-[${edge}]-(m)`
|
|
42950
|
+
}[direction];
|
|
42951
|
+
const gql = `MATCH ${pattern} WHERE id(n) = $id RETURN DISTINCT id(m) AS id, labels(m) AS labels, properties(m) AS props LIMIT ${Math.trunc(limit)}`;
|
|
42952
|
+
const rows = (await this.run(gql, { id: nodeId }, true)).dicts();
|
|
42953
|
+
return rows.map((row) => this.nodeFromRow(row)).filter((node) => node !== null);
|
|
42954
|
+
}
|
|
42955
|
+
async traverse(startId, options = {}) {
|
|
42956
|
+
const depth = options.depth ?? 1;
|
|
42957
|
+
const direction = options.direction ?? "both";
|
|
42958
|
+
const limit = options.limit ?? 1e3;
|
|
42959
|
+
const edge = options.edgeType ? `:\`${options.edgeType}\`` : "";
|
|
42960
|
+
const quant = `{1,${Math.trunc(depth)}}`;
|
|
42961
|
+
const pattern = {
|
|
42962
|
+
out: `(n)-[${edge}]->${quant}(m)`,
|
|
42963
|
+
in: `(n)<-[${edge}]-${quant}(m)`,
|
|
42964
|
+
both: `(n)-[${edge}]-${quant}(m)`
|
|
42965
|
+
}[direction];
|
|
42966
|
+
const gql = `MATCH ${pattern} WHERE id(n) = $start RETURN DISTINCT id(m) AS id, labels(m) AS labels, properties(m) AS props LIMIT ${Math.trunc(limit)}`;
|
|
42967
|
+
const rows = (await this.run(gql, { start: startId }, true)).dicts();
|
|
42968
|
+
return rows.map((row) => this.nodeFromRow(row)).filter((node) => node !== null);
|
|
42969
|
+
}
|
|
42970
|
+
close() {
|
|
42971
|
+
this.client.close();
|
|
42972
|
+
}
|
|
42973
|
+
getError() {
|
|
42974
|
+
return this.lastError;
|
|
42975
|
+
}
|
|
42976
|
+
};
|
|
42977
|
+
}
|
|
42978
|
+
});
|
|
42979
|
+
|
|
42980
|
+
// src/graph/adapters/bolt.ts
|
|
42981
|
+
var bolt_exports = {};
|
|
42982
|
+
__export(bolt_exports, {
|
|
42983
|
+
BoltGraphAdapter: () => BoltGraphAdapter
|
|
42984
|
+
});
|
|
42985
|
+
function errorMessage2(exc) {
|
|
42986
|
+
if (exc instanceof Error) return exc.message;
|
|
42987
|
+
return String(exc);
|
|
42988
|
+
}
|
|
42989
|
+
function boltId(id) {
|
|
42990
|
+
const value = Number(id);
|
|
42991
|
+
return Number.isNaN(value) ? -1 : value;
|
|
42992
|
+
}
|
|
42993
|
+
var DRIVER_PACKAGE3, driverModule, neo4j, BoltGraphAdapter;
|
|
42994
|
+
var init_bolt = __esm({
|
|
42995
|
+
async "src/graph/adapters/bolt.ts"() {
|
|
42996
|
+
"use strict";
|
|
42997
|
+
init_shapes();
|
|
42998
|
+
init_errors();
|
|
42999
|
+
init_connectTimeout2();
|
|
43000
|
+
DRIVER_PACKAGE3 = "neo4j-driver";
|
|
43001
|
+
driverModule = await import(DRIVER_PACKAGE3);
|
|
43002
|
+
neo4j = driverModule.default ?? driverModule;
|
|
43003
|
+
BoltGraphAdapter = class {
|
|
43004
|
+
url;
|
|
43005
|
+
database;
|
|
43006
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43007
|
+
driver;
|
|
43008
|
+
lastError = null;
|
|
43009
|
+
constructor(graphUrl, credentials = {}) {
|
|
43010
|
+
this.url = graphUrl;
|
|
43011
|
+
this.database = graphUrl.graph || null;
|
|
43012
|
+
const user = graphUrl.username || credentials.username || "neo4j";
|
|
43013
|
+
const pwd = graphUrl.password || credentials.password || "";
|
|
43014
|
+
const scheme = graphUrl.useTls ? "bolt+s" : "bolt";
|
|
43015
|
+
const uri = `${scheme}://${graphUrl.host}:${graphUrl.port}`;
|
|
43016
|
+
const timeout = resolveGraphConnectTimeout();
|
|
43017
|
+
const config = { disableLosslessIntegers: true };
|
|
43018
|
+
if (timeout !== null) {
|
|
43019
|
+
const ms = Math.max(1, Math.ceil(timeout * 1e3));
|
|
43020
|
+
config.connectionTimeout = ms;
|
|
43021
|
+
config.connectionAcquisitionTimeout = ms;
|
|
43022
|
+
config.maxTransactionRetryTime = ms;
|
|
43023
|
+
}
|
|
43024
|
+
this.driver = neo4j.driver(uri, neo4j.auth.basic(user, pwd), config);
|
|
43025
|
+
}
|
|
43026
|
+
// -- connection + raw pass-through -------------------------------------
|
|
43027
|
+
async run(cypher, params = null) {
|
|
43028
|
+
const session = this.database ? this.driver.session({ database: this.database }) : this.driver.session();
|
|
43029
|
+
try {
|
|
43030
|
+
const result = await session.run(cypher, params ?? {});
|
|
43031
|
+
return result.records.map((record) => record.toObject());
|
|
43032
|
+
} catch (exc) {
|
|
43033
|
+
this.lastError = errorMessage2(exc);
|
|
43034
|
+
const code = exc?.code ?? "";
|
|
43035
|
+
const message = this.lastError.toLowerCase();
|
|
43036
|
+
if (code === "ServiceUnavailable" || code === neo4j.error?.SERVICE_UNAVAILABLE || message.includes("timed out") || message.includes("timeout")) {
|
|
43037
|
+
throw new GraphConnectTimeout(
|
|
43038
|
+
`Graph connect to ${this.url.host}:${this.url.port} timed out (${GRAPH_CONNECT_TIMEOUT_VARIABLE}). Raise ${GRAPH_CONNECT_TIMEOUT_VARIABLE} if the server is simply slow, or set it to 0 to wait indefinitely.`,
|
|
43039
|
+
exc
|
|
43040
|
+
);
|
|
43041
|
+
}
|
|
43042
|
+
throw new GraphError(this.lastError, exc);
|
|
43043
|
+
} finally {
|
|
43044
|
+
await session.close();
|
|
43045
|
+
}
|
|
43046
|
+
}
|
|
43047
|
+
async query(text, params = null) {
|
|
43048
|
+
const rows = await this.run(text, params);
|
|
43049
|
+
const columns = rows.length ? Object.keys(rows[0]) : [];
|
|
43050
|
+
return new GraphResult(rows, columns);
|
|
43051
|
+
}
|
|
43052
|
+
async execute(text, params = null) {
|
|
43053
|
+
return this.query(text, params);
|
|
43054
|
+
}
|
|
43055
|
+
// -- portable node/edge/traverse core (Cypher) -------------------------
|
|
43056
|
+
nodeFromRow(row) {
|
|
43057
|
+
if (row === null || row === void 0) return null;
|
|
43058
|
+
return new GraphNode(
|
|
43059
|
+
String(row.id),
|
|
43060
|
+
row.labels ?? [],
|
|
43061
|
+
row.props ?? {}
|
|
43062
|
+
);
|
|
43063
|
+
}
|
|
43064
|
+
async addNode(label, properties = null) {
|
|
43065
|
+
const cypher = `CREATE (n:\`${label}\` $props) RETURN id(n) AS id, labels(n) AS labels, properties(n) AS props`;
|
|
43066
|
+
const rows = await this.run(cypher, { props: properties ?? {} });
|
|
43067
|
+
return rows.length ? this.nodeFromRow(rows[0]) : null;
|
|
43068
|
+
}
|
|
43069
|
+
async addEdge(fromId, toId, type2, properties = null) {
|
|
43070
|
+
const cypher = `MATCH (a), (b) WHERE id(a) = $from_id AND id(b) = $to_id CREATE (a)-[e:\`${type2}\` $props]->(b) RETURN id(e) AS id, type(e) AS type, id(a) AS f, id(b) AS t, properties(e) AS props`;
|
|
43071
|
+
const rows = await this.run(cypher, {
|
|
43072
|
+
from_id: boltId(fromId),
|
|
43073
|
+
to_id: boltId(toId),
|
|
43074
|
+
props: properties ?? {}
|
|
43075
|
+
});
|
|
43076
|
+
if (rows.length === 0) return null;
|
|
43077
|
+
const row = rows[0];
|
|
43078
|
+
return new GraphEdge(
|
|
43079
|
+
String(row.id),
|
|
43080
|
+
String(row.type),
|
|
43081
|
+
String(row.f),
|
|
43082
|
+
String(row.t),
|
|
43083
|
+
row.props ?? {}
|
|
43084
|
+
);
|
|
43085
|
+
}
|
|
43086
|
+
async getNode(nodeId) {
|
|
43087
|
+
const cypher = `MATCH (n) WHERE id(n) = $id RETURN id(n) AS id, labels(n) AS labels, properties(n) AS props`;
|
|
43088
|
+
const rows = await this.run(cypher, { id: boltId(nodeId) });
|
|
43089
|
+
return rows.length ? this.nodeFromRow(rows[0]) : null;
|
|
43090
|
+
}
|
|
43091
|
+
async updateNode(nodeId, properties) {
|
|
43092
|
+
const cypher = `MATCH (n) WHERE id(n) = $id SET n += $props RETURN id(n) AS id, labels(n) AS labels, properties(n) AS props`;
|
|
43093
|
+
const rows = await this.run(cypher, { id: boltId(nodeId), props: properties ?? {} });
|
|
43094
|
+
return rows.length ? this.nodeFromRow(rows[0]) : null;
|
|
43095
|
+
}
|
|
43096
|
+
async deleteNode(nodeId) {
|
|
43097
|
+
await this.run("MATCH (n) WHERE id(n) = $id DETACH DELETE n", { id: boltId(nodeId) });
|
|
43098
|
+
return true;
|
|
43099
|
+
}
|
|
43100
|
+
async neighbors(nodeId, options = {}) {
|
|
43101
|
+
const direction = options.direction ?? "both";
|
|
43102
|
+
const limit = options.limit ?? 100;
|
|
43103
|
+
const edge = options.edgeType ? `:\`${options.edgeType}\`` : "";
|
|
43104
|
+
const pattern = {
|
|
43105
|
+
out: `(n)-[${edge}]->(m)`,
|
|
43106
|
+
in: `(n)<-[${edge}]-(m)`,
|
|
43107
|
+
both: `(n)-[${edge}]-(m)`
|
|
43108
|
+
}[direction];
|
|
43109
|
+
const cypher = `MATCH ${pattern} WHERE id(n) = $id RETURN DISTINCT id(m) AS id, labels(m) AS labels, properties(m) AS props LIMIT ${Math.trunc(limit)}`;
|
|
43110
|
+
const rows = await this.run(cypher, { id: boltId(nodeId) });
|
|
43111
|
+
return rows.map((row) => this.nodeFromRow(row)).filter((node) => node !== null);
|
|
43112
|
+
}
|
|
43113
|
+
async traverse(startId, options = {}) {
|
|
43114
|
+
const depth = options.depth ?? 1;
|
|
43115
|
+
const direction = options.direction ?? "both";
|
|
43116
|
+
const limit = options.limit ?? 1e3;
|
|
43117
|
+
const edge = options.edgeType ? `:\`${options.edgeType}\`` : "";
|
|
43118
|
+
const range = `*1..${Math.trunc(depth)}`;
|
|
43119
|
+
const arrow = {
|
|
43120
|
+
out: `-[${edge}${range}]->`,
|
|
43121
|
+
in: `<-[${edge}${range}]-`,
|
|
43122
|
+
both: `-[${edge}${range}]-`
|
|
43123
|
+
}[direction];
|
|
43124
|
+
const cypher = `MATCH (n)${arrow}(m) WHERE id(n) = $start RETURN DISTINCT id(m) AS id, labels(m) AS labels, properties(m) AS props LIMIT ${Math.trunc(limit)}`;
|
|
43125
|
+
const rows = await this.run(cypher, { start: boltId(startId) });
|
|
43126
|
+
return rows.map((row) => this.nodeFromRow(row)).filter((node) => node !== null);
|
|
43127
|
+
}
|
|
43128
|
+
async close() {
|
|
43129
|
+
await this.driver.close();
|
|
43130
|
+
}
|
|
43131
|
+
getError() {
|
|
43132
|
+
return this.lastError;
|
|
43133
|
+
}
|
|
43134
|
+
};
|
|
43135
|
+
}
|
|
43136
|
+
});
|
|
43137
|
+
|
|
43138
|
+
// src/graph/adapters/arango.ts
|
|
43139
|
+
var arango_exports = {};
|
|
43140
|
+
__export(arango_exports, {
|
|
43141
|
+
ArangoGraphAdapter: () => ArangoGraphAdapter
|
|
43142
|
+
});
|
|
43143
|
+
function cleanProps(doc) {
|
|
43144
|
+
const props = {};
|
|
43145
|
+
for (const [key, value] of Object.entries(doc)) {
|
|
43146
|
+
if (!RESERVED.has(key)) props[key] = value;
|
|
43147
|
+
}
|
|
43148
|
+
return props;
|
|
43149
|
+
}
|
|
43150
|
+
function errorMessage3(exc) {
|
|
43151
|
+
if (exc instanceof Error) return exc.message;
|
|
43152
|
+
return String(exc);
|
|
43153
|
+
}
|
|
43154
|
+
var DRIVER_PACKAGE4, driverModule2, ArangoDatabase, VERTEX_COLLECTION, EDGE_COLLECTION, RESERVED, ArangoGraphAdapter;
|
|
43155
|
+
var init_arango = __esm({
|
|
43156
|
+
async "src/graph/adapters/arango.ts"() {
|
|
43157
|
+
"use strict";
|
|
43158
|
+
init_shapes();
|
|
43159
|
+
init_errors();
|
|
43160
|
+
init_connectTimeout2();
|
|
43161
|
+
DRIVER_PACKAGE4 = "arangojs";
|
|
43162
|
+
driverModule2 = await import(DRIVER_PACKAGE4);
|
|
43163
|
+
ArangoDatabase = driverModule2.Database ?? driverModule2.default?.Database;
|
|
43164
|
+
VERTEX_COLLECTION = "tina4_nodes";
|
|
43165
|
+
EDGE_COLLECTION = "tina4_edges";
|
|
43166
|
+
RESERVED = /* @__PURE__ */ new Set(["_id", "_key", "_rev", "_from", "_to", "_labels", "_type"]);
|
|
43167
|
+
ArangoGraphAdapter = class {
|
|
43168
|
+
url;
|
|
43169
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
43170
|
+
db;
|
|
43171
|
+
ensured = false;
|
|
43172
|
+
lastError = null;
|
|
43173
|
+
constructor(graphUrl, credentials = {}) {
|
|
43174
|
+
this.url = graphUrl;
|
|
43175
|
+
const scheme = graphUrl.useTls ? "https" : "http";
|
|
43176
|
+
const user = graphUrl.username || credentials.username || "root";
|
|
43177
|
+
const pwd = graphUrl.password || credentials.password || "";
|
|
43178
|
+
const database = graphUrl.graph || "_system";
|
|
43179
|
+
const timeout = resolveGraphConnectTimeout();
|
|
43180
|
+
const config = {
|
|
43181
|
+
url: `${scheme}://${graphUrl.host}:${graphUrl.port}`,
|
|
43182
|
+
databaseName: database,
|
|
43183
|
+
auth: { username: user, password: pwd }
|
|
43184
|
+
};
|
|
43185
|
+
if (timeout !== null) config.timeout = Math.max(1, Math.ceil(timeout * 1e3));
|
|
43186
|
+
this.db = new ArangoDatabase(config);
|
|
43187
|
+
}
|
|
43188
|
+
connectOrError(exc) {
|
|
43189
|
+
const text = errorMessage3(exc).toLowerCase();
|
|
43190
|
+
if (text.includes("timed out") || text.includes("timeout") || text.includes("connection") || text.includes("econnrefused") || text.includes("etimedout") || text.includes("max retries")) {
|
|
43191
|
+
return new GraphConnectTimeout(
|
|
43192
|
+
`Graph connect to ${this.url.host}:${this.url.port} timed out (${GRAPH_CONNECT_TIMEOUT_VARIABLE}). Raise ${GRAPH_CONNECT_TIMEOUT_VARIABLE} if the server is simply slow, or set it to 0 to wait indefinitely.`,
|
|
43193
|
+
exc
|
|
43194
|
+
);
|
|
43195
|
+
}
|
|
43196
|
+
return new GraphError(errorMessage3(exc), exc);
|
|
43197
|
+
}
|
|
43198
|
+
async ensureCollections() {
|
|
43199
|
+
if (this.ensured) return;
|
|
43200
|
+
try {
|
|
43201
|
+
const nodes = this.db.collection(VERTEX_COLLECTION);
|
|
43202
|
+
if (!await nodes.exists()) await this.db.createCollection(VERTEX_COLLECTION);
|
|
43203
|
+
const edges = this.db.collection(EDGE_COLLECTION);
|
|
43204
|
+
if (!await edges.exists()) await this.db.createEdgeCollection(EDGE_COLLECTION);
|
|
43205
|
+
this.ensured = true;
|
|
43206
|
+
} catch (exc) {
|
|
43207
|
+
this.lastError = errorMessage3(exc);
|
|
43208
|
+
throw this.connectOrError(exc);
|
|
43209
|
+
}
|
|
43210
|
+
}
|
|
43211
|
+
async aql(query, bind2 = null) {
|
|
43212
|
+
await this.ensureCollections();
|
|
43213
|
+
try {
|
|
43214
|
+
const cursor = await this.db.query({ query, bindVars: bind2 ?? {} });
|
|
43215
|
+
return await cursor.all();
|
|
43216
|
+
} catch (exc) {
|
|
43217
|
+
this.lastError = errorMessage3(exc);
|
|
43218
|
+
throw this.connectOrError(exc);
|
|
43219
|
+
}
|
|
43220
|
+
}
|
|
43221
|
+
async query(text, params = null) {
|
|
43222
|
+
const rows = await this.aql(text, params);
|
|
43223
|
+
const first = rows[0];
|
|
43224
|
+
const columns = rows.length && first && typeof first === "object" ? Object.keys(first) : [];
|
|
43225
|
+
return new GraphResult(rows, columns);
|
|
43226
|
+
}
|
|
43227
|
+
async execute(text, params = null) {
|
|
43228
|
+
return this.query(text, params);
|
|
43229
|
+
}
|
|
43230
|
+
// -- portable node/edge/traverse core (AQL) ----------------------------
|
|
43231
|
+
nodeFromDoc(doc) {
|
|
43232
|
+
if (doc === null || doc === void 0) return null;
|
|
43233
|
+
return new GraphNode(
|
|
43234
|
+
String(doc._id),
|
|
43235
|
+
doc._labels ?? [],
|
|
43236
|
+
cleanProps(doc)
|
|
43237
|
+
);
|
|
43238
|
+
}
|
|
43239
|
+
async addNode(label, properties = null) {
|
|
43240
|
+
const doc = { ...properties ?? {}, _labels: [label] };
|
|
43241
|
+
const rows = await this.aql(`INSERT @doc INTO ${VERTEX_COLLECTION} RETURN NEW`, { doc });
|
|
43242
|
+
return rows.length ? this.nodeFromDoc(rows[0]) : null;
|
|
43243
|
+
}
|
|
43244
|
+
async addEdge(fromId, toId, type2, properties = null) {
|
|
43245
|
+
const doc = { ...properties ?? {}, _from: fromId, _to: toId, _type: type2 };
|
|
43246
|
+
const rows = await this.aql(`INSERT @doc INTO ${EDGE_COLLECTION} RETURN NEW`, { doc });
|
|
43247
|
+
if (rows.length === 0) return null;
|
|
43248
|
+
const row = rows[0];
|
|
43249
|
+
return new GraphEdge(
|
|
43250
|
+
String(row._id),
|
|
43251
|
+
String(row._type),
|
|
43252
|
+
String(row._from),
|
|
43253
|
+
String(row._to),
|
|
43254
|
+
cleanProps(row)
|
|
43255
|
+
);
|
|
43256
|
+
}
|
|
43257
|
+
async getNode(nodeId) {
|
|
43258
|
+
const rows = await this.aql("RETURN DOCUMENT(@id)", { id: nodeId });
|
|
43259
|
+
return rows.length && rows[0] ? this.nodeFromDoc(rows[0]) : null;
|
|
43260
|
+
}
|
|
43261
|
+
async updateNode(nodeId, properties) {
|
|
43262
|
+
const rows = await this.aql(
|
|
43263
|
+
`UPDATE PARSE_IDENTIFIER(@id).key WITH @props IN ${VERTEX_COLLECTION} RETURN NEW`,
|
|
43264
|
+
{ id: nodeId, props: properties ?? {} }
|
|
43265
|
+
);
|
|
43266
|
+
return rows.length ? this.nodeFromDoc(rows[0]) : null;
|
|
43267
|
+
}
|
|
43268
|
+
async deleteNode(nodeId) {
|
|
43269
|
+
await this.aql(
|
|
43270
|
+
`FOR e IN ${EDGE_COLLECTION} FILTER e._from == @id OR e._to == @id REMOVE e IN ${EDGE_COLLECTION}`,
|
|
43271
|
+
{ id: nodeId }
|
|
43272
|
+
);
|
|
43273
|
+
await this.aql(
|
|
43274
|
+
`REMOVE PARSE_IDENTIFIER(@id).key IN ${VERTEX_COLLECTION}`,
|
|
43275
|
+
{ id: nodeId }
|
|
43276
|
+
);
|
|
43277
|
+
return true;
|
|
43278
|
+
}
|
|
43279
|
+
async neighbors(nodeId, options = {}) {
|
|
43280
|
+
const direction = options.direction ?? "both";
|
|
43281
|
+
const limit = options.limit ?? 100;
|
|
43282
|
+
const arangoDir = { out: "OUTBOUND", in: "INBOUND", both: "ANY" }[direction];
|
|
43283
|
+
const typeFilter = options.edgeType ? "FILTER e._type == @etype " : "";
|
|
43284
|
+
const bind2 = { start: nodeId, limit: Math.trunc(limit) };
|
|
43285
|
+
if (options.edgeType) bind2.etype = options.edgeType;
|
|
43286
|
+
const rows = await this.aql(
|
|
43287
|
+
`FOR v, e IN 1..1 ${arangoDir} @start ${EDGE_COLLECTION} ${typeFilter}LIMIT @limit RETURN DISTINCT v`,
|
|
43288
|
+
bind2
|
|
43289
|
+
);
|
|
43290
|
+
return rows.map((doc) => this.nodeFromDoc(doc)).filter((node) => node !== null);
|
|
43291
|
+
}
|
|
43292
|
+
async traverse(startId, options = {}) {
|
|
43293
|
+
const depth = options.depth ?? 1;
|
|
43294
|
+
const direction = options.direction ?? "both";
|
|
43295
|
+
const limit = options.limit ?? 1e3;
|
|
43296
|
+
const arangoDir = { out: "OUTBOUND", in: "INBOUND", both: "ANY" }[direction];
|
|
43297
|
+
const typeFilter = options.edgeType ? "FILTER e._type == @etype " : "";
|
|
43298
|
+
const bind2 = { start: startId, limit: Math.trunc(limit) };
|
|
43299
|
+
if (options.edgeType) bind2.etype = options.edgeType;
|
|
43300
|
+
const rows = await this.aql(
|
|
43301
|
+
`FOR v, e IN 1..${Math.trunc(depth)} ${arangoDir} @start ${EDGE_COLLECTION} ${typeFilter}LIMIT @limit RETURN DISTINCT v`,
|
|
43302
|
+
bind2
|
|
43303
|
+
);
|
|
43304
|
+
return rows.map((doc) => this.nodeFromDoc(doc)).filter((node) => node !== null);
|
|
43305
|
+
}
|
|
43306
|
+
async close() {
|
|
43307
|
+
if (typeof this.db.close === "function") this.db.close();
|
|
43308
|
+
}
|
|
43309
|
+
getError() {
|
|
43310
|
+
return this.lastError;
|
|
43311
|
+
}
|
|
43312
|
+
};
|
|
43313
|
+
}
|
|
43314
|
+
});
|
|
43315
|
+
|
|
43316
|
+
// src/graph/graphDatabase.ts
|
|
43317
|
+
var ENGINE_ADAPTERS, GraphDatabase;
|
|
43318
|
+
var init_graphDatabase = __esm({
|
|
43319
|
+
"src/graph/graphDatabase.ts"() {
|
|
43320
|
+
"use strict";
|
|
43321
|
+
init_graphUrl();
|
|
43322
|
+
init_errors();
|
|
43323
|
+
ENGINE_ADAPTERS = {
|
|
43324
|
+
ultipa: {
|
|
43325
|
+
load: () => init_ultipa().then(() => ultipa_exports),
|
|
43326
|
+
className: "UltipaGraphAdapter",
|
|
43327
|
+
package: "tina4-ultipa",
|
|
43328
|
+
installCommand: "npm install tina4-ultipa"
|
|
43329
|
+
},
|
|
43330
|
+
bolt: {
|
|
43331
|
+
// Neo4j AND Memgraph — both speak Bolt/Cypher over the neo4j-driver package.
|
|
43332
|
+
load: () => init_bolt().then(() => bolt_exports),
|
|
43333
|
+
className: "BoltGraphAdapter",
|
|
43334
|
+
package: "neo4j-driver",
|
|
43335
|
+
installCommand: "npm install neo4j-driver"
|
|
43336
|
+
},
|
|
43337
|
+
arango: {
|
|
43338
|
+
load: () => init_arango().then(() => arango_exports),
|
|
43339
|
+
className: "ArangoGraphAdapter",
|
|
43340
|
+
package: "arangojs",
|
|
43341
|
+
installCommand: "npm install arangojs"
|
|
43342
|
+
}
|
|
43343
|
+
};
|
|
43344
|
+
GraphDatabase = class _GraphDatabase {
|
|
43345
|
+
/**
|
|
43346
|
+
* Parse the URL, pick the engine adapter, connect lazily.
|
|
43347
|
+
*
|
|
43348
|
+
* The engine driver is imported only here (first use of that engine); if it is
|
|
43349
|
+
* absent the error names the package and the install command. Async because the
|
|
43350
|
+
* driver import is dynamic — the connect itself still happens lazily on first
|
|
43351
|
+
* operation (mirroring the relational adapters).
|
|
43352
|
+
*/
|
|
43353
|
+
static async create(url, credentials = {}) {
|
|
43354
|
+
const graphUrl = new GraphUrl(url);
|
|
43355
|
+
const registration = ENGINE_ADAPTERS[graphUrl.engine];
|
|
43356
|
+
if (registration === void 0) {
|
|
43357
|
+
throw new GraphError(
|
|
43358
|
+
`No graph adapter for engine '${graphUrl.engine}' yet (scheme '${graphUrl.scheme}'). Available: ${Object.keys(ENGINE_ADAPTERS).sort().join(", ")}.`
|
|
43359
|
+
);
|
|
43360
|
+
}
|
|
43361
|
+
let module;
|
|
43362
|
+
try {
|
|
43363
|
+
module = await registration.load();
|
|
43364
|
+
} catch (cause) {
|
|
43365
|
+
throw new GraphError(
|
|
43366
|
+
`The graph driver for '${graphUrl.engine}' is not installed (${registration.package}). Install it with:
|
|
43367
|
+
${registration.installCommand}`,
|
|
43368
|
+
cause
|
|
43369
|
+
);
|
|
43370
|
+
}
|
|
43371
|
+
const AdapterClass = module[registration.className];
|
|
43372
|
+
if (AdapterClass === void 0) {
|
|
43373
|
+
throw new GraphError(
|
|
43374
|
+
`The graph adapter '${registration.className}' is missing from its module for engine '${graphUrl.engine}'.`
|
|
43375
|
+
);
|
|
43376
|
+
}
|
|
43377
|
+
return new AdapterClass(graphUrl, credentials);
|
|
43378
|
+
}
|
|
43379
|
+
/** Build from TINA4_GRAPH_URL (+ TINA4_GRAPH_USERNAME/_PASSWORD). */
|
|
43380
|
+
static async fromEnv(envKey = "TINA4_GRAPH_URL") {
|
|
43381
|
+
const url = (process.env[envKey] ?? "").trim();
|
|
43382
|
+
if (url === "") return null;
|
|
43383
|
+
return _GraphDatabase.create(url, {
|
|
43384
|
+
username: process.env.TINA4_GRAPH_USERNAME,
|
|
43385
|
+
password: process.env.TINA4_GRAPH_PASSWORD
|
|
43386
|
+
});
|
|
43387
|
+
}
|
|
43388
|
+
};
|
|
43389
|
+
}
|
|
43390
|
+
});
|
|
43391
|
+
|
|
42623
43392
|
// src/realtime/models/workspace.ts
|
|
42624
43393
|
var Workspace;
|
|
42625
43394
|
var init_workspace = __esm({
|
|
@@ -43178,6 +43947,7 @@ __export(index_exports, {
|
|
|
43178
43947
|
CachedDatabaseAdapter: () => CachedDatabaseAdapter,
|
|
43179
43948
|
Cursor: () => Cursor,
|
|
43180
43949
|
DEFAULT_DATABASE_CONNECT_TIMEOUT_SECONDS: () => DEFAULT_DATABASE_CONNECT_TIMEOUT_SECONDS,
|
|
43950
|
+
DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS: () => DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS,
|
|
43181
43951
|
DEFAULT_SRID: () => DEFAULT_SRID,
|
|
43182
43952
|
Database: () => Database,
|
|
43183
43953
|
DatabaseResult: () => DatabaseResult,
|
|
@@ -43185,6 +43955,14 @@ __export(index_exports, {
|
|
|
43185
43955
|
DocStoreDriverMissing: () => DocStoreDriverMissing,
|
|
43186
43956
|
FakeData: () => FakeData2,
|
|
43187
43957
|
FirebirdAdapter: () => FirebirdAdapter,
|
|
43958
|
+
GRAPH_CONNECT_TIMEOUT_VARIABLE: () => GRAPH_CONNECT_TIMEOUT_VARIABLE,
|
|
43959
|
+
GraphConnectTimeout: () => GraphConnectTimeout,
|
|
43960
|
+
GraphDatabase: () => GraphDatabase,
|
|
43961
|
+
GraphEdge: () => GraphEdge,
|
|
43962
|
+
GraphError: () => GraphError,
|
|
43963
|
+
GraphNode: () => GraphNode,
|
|
43964
|
+
GraphResult: () => GraphResult,
|
|
43965
|
+
GraphUrl: () => GraphUrl,
|
|
43188
43966
|
InvalidId: () => InvalidId,
|
|
43189
43967
|
LocalStorage: () => LocalStorage,
|
|
43190
43968
|
Migration: () => Migration,
|
|
@@ -43266,6 +44044,7 @@ __export(index_exports, {
|
|
|
43266
44044
|
resetRequestCaches: () => resetRequestCaches2,
|
|
43267
44045
|
resolveDbPool: () => resolveDbPool,
|
|
43268
44046
|
resolveFirebirdCharset: () => resolveFirebirdCharset,
|
|
44047
|
+
resolveGraphConnectTimeout: () => resolveGraphConnectTimeout,
|
|
43269
44048
|
rollback: () => rollback,
|
|
43270
44049
|
seedModels: () => seedModels,
|
|
43271
44050
|
seedOrm: () => seedOrm,
|
|
@@ -43314,6 +44093,11 @@ var init_index = __esm({
|
|
|
43314
44093
|
init_firebird();
|
|
43315
44094
|
init_mongodb();
|
|
43316
44095
|
init_odbc();
|
|
44096
|
+
init_graphDatabase();
|
|
44097
|
+
init_graphUrl();
|
|
44098
|
+
init_shapes();
|
|
44099
|
+
init_errors();
|
|
44100
|
+
init_connectTimeout2();
|
|
43317
44101
|
init_realtime2();
|
|
43318
44102
|
}
|
|
43319
44103
|
});
|
|
@@ -43325,6 +44109,7 @@ export {
|
|
|
43325
44109
|
CachedDatabaseAdapter,
|
|
43326
44110
|
Cursor,
|
|
43327
44111
|
DEFAULT_DATABASE_CONNECT_TIMEOUT_SECONDS,
|
|
44112
|
+
DEFAULT_GRAPH_CONNECT_TIMEOUT_SECONDS,
|
|
43328
44113
|
DEFAULT_SRID,
|
|
43329
44114
|
Database,
|
|
43330
44115
|
DatabaseResult,
|
|
@@ -43332,6 +44117,14 @@ export {
|
|
|
43332
44117
|
DocStoreDriverMissing,
|
|
43333
44118
|
FakeData2 as FakeData,
|
|
43334
44119
|
FirebirdAdapter,
|
|
44120
|
+
GRAPH_CONNECT_TIMEOUT_VARIABLE,
|
|
44121
|
+
GraphConnectTimeout,
|
|
44122
|
+
GraphDatabase,
|
|
44123
|
+
GraphEdge,
|
|
44124
|
+
GraphError,
|
|
44125
|
+
GraphNode,
|
|
44126
|
+
GraphResult,
|
|
44127
|
+
GraphUrl,
|
|
43335
44128
|
InvalidId,
|
|
43336
44129
|
LocalStorage,
|
|
43337
44130
|
Migration,
|
|
@@ -43413,6 +44206,7 @@ export {
|
|
|
43413
44206
|
resetRequestCaches2 as resetRequestCaches,
|
|
43414
44207
|
resolveDbPool,
|
|
43415
44208
|
resolveFirebirdCharset,
|
|
44209
|
+
resolveGraphConnectTimeout,
|
|
43416
44210
|
rollback,
|
|
43417
44211
|
seedModels,
|
|
43418
44212
|
seedOrm,
|