kibi-core 0.1.6 → 0.1.8
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/package.json +5 -2
- package/src/kb.pl +28 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kibi-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Core Prolog modules and RDF graph logic for Kibi",
|
|
6
6
|
"type": "module",
|
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
"bun": ">=1.0"
|
|
10
10
|
},
|
|
11
11
|
"main": "./src/kb.pl",
|
|
12
|
-
"files": [
|
|
12
|
+
"files": [
|
|
13
|
+
"src/**/*.pl",
|
|
14
|
+
"schema/**/*.pl"
|
|
15
|
+
],
|
|
13
16
|
"license": "AGPL-3.0-or-later",
|
|
14
17
|
"author": "Piotr Franczyk",
|
|
15
18
|
"repository": {
|
package/src/kb.pl
CHANGED
|
@@ -110,6 +110,16 @@ kb_detach :-
|
|
|
110
110
|
( kb_attached(_Directory)
|
|
111
111
|
-> (
|
|
112
112
|
kb_save,
|
|
113
|
+
% Unload RDF graph from memory to prevent duplication on reattach
|
|
114
|
+
( kb_graph(GraphURI)
|
|
115
|
+
-> rdf_unload_graph(GraphURI)
|
|
116
|
+
; true
|
|
117
|
+
),
|
|
118
|
+
% Sync and close audit log
|
|
119
|
+
( kb_audit_db(AuditLog)
|
|
120
|
+
-> db_sync(AuditLog)
|
|
121
|
+
; true
|
|
122
|
+
),
|
|
113
123
|
% Clear state
|
|
114
124
|
retractall(kb_attached(_)),
|
|
115
125
|
retractall(kb_audit_db(_)),
|
|
@@ -151,6 +161,8 @@ with_kb_mutex(Goal) :-
|
|
|
151
161
|
% Load legacy .pl entity files from the KB directory.
|
|
152
162
|
% These files use entity/4 format: entity(Type, Id, Title, Props).
|
|
153
163
|
load_kb_pl_files(Directory) :-
|
|
164
|
+
catch(abolish(entity/4), _, true),
|
|
165
|
+
dynamic(entity/4),
|
|
154
166
|
retractall(entity(_, _, _, _)),
|
|
155
167
|
directory_files(Directory, Files),
|
|
156
168
|
forall(
|
|
@@ -258,9 +270,21 @@ convert_legacy_prop(Prop, Prop, true).
|
|
|
258
270
|
kb_entities_by_source(SourcePath, Ids) :-
|
|
259
271
|
findall(Id,
|
|
260
272
|
(kb_entity(Id, _Type, Props),
|
|
261
|
-
memberchk(source
|
|
262
|
-
|
|
263
|
-
|
|
273
|
+
memberchk(source=RawSource, Props),
|
|
274
|
+
source_value_atom(RawSource, SourceAtom),
|
|
275
|
+
sub_atom(SourceAtom, _, _, _, SourcePath)),
|
|
276
|
+
RawIds),
|
|
277
|
+
sort(RawIds, Ids).
|
|
278
|
+
|
|
279
|
+
source_value_atom(Value, Atom) :-
|
|
280
|
+
( atom(Value)
|
|
281
|
+
-> Atom = Value
|
|
282
|
+
; string(Value)
|
|
283
|
+
-> atom_string(Atom, Value)
|
|
284
|
+
; Value = ^^(Inner, _)
|
|
285
|
+
-> source_value_atom(Inner, Atom)
|
|
286
|
+
; term_string(Value, Atom)
|
|
287
|
+
).
|
|
264
288
|
|
|
265
289
|
%% kb_assert_relationship(+Type, +From, +To, +Metadata)
|
|
266
290
|
% Assert a relationship between two entities with validation.
|
|
@@ -692,4 +716,4 @@ changed_symbol_violation(Symbol, MinLinks, Count, File, Line, Col, Name) :-
|
|
|
692
716
|
( changed_symbol_loc(Symbol, FileRaw, Line, Col, NameRaw)
|
|
693
717
|
-> File = FileRaw, Name = NameRaw
|
|
694
718
|
; File = '', Line = 0, Col = 0, Name = ''
|
|
695
|
-
).
|
|
719
|
+
).
|