eyeling 1.28.9 → 1.29.1
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/README.md +73 -2
- package/dist/browser/eyeling.browser.js +1284 -33
- package/dist/browser/index.mjs +10 -0
- package/eyeling.js +1284 -33
- package/index.d.ts +59 -0
- package/index.js +17 -0
- package/lib/cli.js +309 -33
- package/lib/engine.js +279 -0
- package/lib/entry.js +4 -0
- package/lib/rdfjs.js +1 -0
- package/lib/store.js +688 -0
- package/package.json +8 -3
- package/test/store.test.js +167 -0
- package/test/stream_messages.test.js +13 -0
- package/tools/bundle.js +10 -0
package/README.md
CHANGED
|
@@ -321,6 +321,7 @@ Import from the package root for Node.js:
|
|
|
321
321
|
const {
|
|
322
322
|
reason,
|
|
323
323
|
reasonStream,
|
|
324
|
+
runAsync,
|
|
324
325
|
reasonRdfJs,
|
|
325
326
|
rdfjs,
|
|
326
327
|
registerBuiltin,
|
|
@@ -328,6 +329,7 @@ const {
|
|
|
328
329
|
registerBuiltinModule,
|
|
329
330
|
loadBuiltinModule,
|
|
330
331
|
listBuiltinIris,
|
|
332
|
+
createFactStore,
|
|
331
333
|
INFERENCE_FUSE_EXIT_CODE,
|
|
332
334
|
} = require('eyeling');
|
|
333
335
|
```
|
|
@@ -357,6 +359,9 @@ Useful options:
|
|
|
357
359
|
| `args` | Extra CLI-style arguments. |
|
|
358
360
|
| `maxBuffer` | Child-process output buffer limit. |
|
|
359
361
|
| `builtinModules` | Custom built-in module path or paths. |
|
|
362
|
+
| `store` | Optional persistent store name or options object; passed through to CLI `--store`. |
|
|
363
|
+
| `storePath` | Optional Node.js persistent store directory. |
|
|
364
|
+
| `storeClear` | Clear the named persistent store before the run. |
|
|
360
365
|
|
|
361
366
|
`reason()` accepts N3 text, supported RDF-JS input objects, AST bundles, and multi-source inputs.
|
|
362
367
|
|
|
@@ -427,6 +432,64 @@ Useful options:
|
|
|
427
432
|
| `skipUnsupportedRdfJs` | Skip N3-only terms when producing RDF-JS quads. |
|
|
428
433
|
| `builtinModules` | Register custom built-ins before reasoning. |
|
|
429
434
|
|
|
435
|
+
### `runAsync(input, options)`
|
|
436
|
+
|
|
437
|
+
`runAsync()` is the async execution API. Without a `store` option it keeps the same in-memory behavior as `reasonStream()`, but can also normalize async RDF-JS iterables before reasoning. With `store`, Eyeling opens a named persistent fact store, adds the new explicit facts, reuses facts already present in that store, reasons over the combined closure, and writes newly inferred facts back as inferred facts.
|
|
438
|
+
|
|
439
|
+
```js
|
|
440
|
+
const { runAsync } = require('eyeling');
|
|
441
|
+
|
|
442
|
+
await runAsync(input); // memory store
|
|
443
|
+
|
|
444
|
+
await runAsync(input, {
|
|
445
|
+
store: 'my-dataset',
|
|
446
|
+
});
|
|
447
|
+
|
|
448
|
+
await runAsync(input, {
|
|
449
|
+
store: {
|
|
450
|
+
name: 'my-dataset',
|
|
451
|
+
clear: true,
|
|
452
|
+
path: './.eyeling-store', // Node.js path override
|
|
453
|
+
},
|
|
454
|
+
});
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Named persistent stores are created automatically when first opened. Persistent stores use a term dictionary plus `spo`, `pos`, and `osp` triple indexes. Exact lookup and all subject/predicate/object bound-pattern scans are available through the `FactStore` API:
|
|
458
|
+
|
|
459
|
+
```js
|
|
460
|
+
const { createFactStore, rdfjs } = require('eyeling');
|
|
461
|
+
|
|
462
|
+
const store = await createFactStore({ name: 'my-dataset' });
|
|
463
|
+
for await (const triple of store.match(null, rdfjs.namedNode('http://example.org/p'), null)) {
|
|
464
|
+
console.log(triple);
|
|
465
|
+
}
|
|
466
|
+
await store.close();
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
Node.js uses `classic-level` when it is installed and falls back to a small JSON-file key/value backend for dependency-free use and tests. Browser runtimes use IndexedDB through the same abstraction. The current synchronous `reasonStream()` path remains the default and does not open persistent storage.
|
|
470
|
+
|
|
471
|
+
CLI equivalents:
|
|
472
|
+
|
|
473
|
+
```bash
|
|
474
|
+
eyeling input.n3
|
|
475
|
+
# memory store
|
|
476
|
+
|
|
477
|
+
eyeling input.n3 --store my-dataset
|
|
478
|
+
# persistent store
|
|
479
|
+
|
|
480
|
+
eyeling input.n3 --store my-dataset --store-clear
|
|
481
|
+
# clear persistent store first
|
|
482
|
+
|
|
483
|
+
eyeling input.n3 --store my-dataset --store-path ./.eyeling-store
|
|
484
|
+
# Node.js path override
|
|
485
|
+
|
|
486
|
+
# Stream line-oriented RDF input into a store without reading one giant string.
|
|
487
|
+
eyeling --rdf big.nt --store my-dataset --store-path ./.eyeling-store
|
|
488
|
+
|
|
489
|
+
# Stream RDF Message Logs one message at a time and persist facts/inferences.
|
|
490
|
+
eyeling --rdf --stream-messages rules.n3 messages.trig --store my-dataset
|
|
491
|
+
```
|
|
492
|
+
|
|
430
493
|
### `reasonRdfJs(input, options)`
|
|
431
494
|
|
|
432
495
|
`reasonRdfJs()` returns an async iterable of derived RDF-JS quads:
|
|
@@ -560,6 +623,12 @@ For one-message-at-a-time processing:
|
|
|
560
623
|
eyeling --rdf --stream-messages rules.n3 messages.trig
|
|
561
624
|
```
|
|
562
625
|
|
|
626
|
+
`--stream-messages` can also be combined with `--store` to create/reuse a named store and persist each message's explicit facts and inferred facts while keeping only one replay message in memory at a time:
|
|
627
|
+
|
|
628
|
+
```bash
|
|
629
|
+
eyeling --rdf --stream-messages rules.n3 messages.trig --store my-dataset --store-path ./.eyeling-store
|
|
630
|
+
```
|
|
631
|
+
|
|
563
632
|
Eyeling materializes a replay view under the `eymsg:` vocabulary:
|
|
564
633
|
|
|
565
634
|
```n3
|
|
@@ -929,6 +998,7 @@ CLI output, API result, proof document, RDF-JS quads, or browser result
|
|
|
929
998
|
| `lib/entry.js` | Bundle entry that exposes public APIs and selected playground internals. |
|
|
930
999
|
| `lib/cli.js` | CLI argument handling, source loading, syntax errors, stream message mode. |
|
|
931
1000
|
| `lib/engine.js` | Core reasoning engine, proof collection, stream APIs, RDF-JS output hooks. |
|
|
1001
|
+
| `lib/store.js` | Optional async fact-store abstraction with memory and persistent backends. |
|
|
932
1002
|
| `lib/builtins.js` | Built-in predicates, custom built-in registry, helper API. |
|
|
933
1003
|
| `lib/lexer.js` | Lexer and compatibility normalization. |
|
|
934
1004
|
| `lib/parser.js` | Parser for supported N3/RDF syntax. |
|
|
@@ -973,7 +1043,7 @@ Everything else should be treated as internal unless explicitly documented.
|
|
|
973
1043
|
├── dist/browser/ Browser bundle and ESM wrapper
|
|
974
1044
|
├── examples/ N3 examples, RDF message inputs, and generated decks
|
|
975
1045
|
├── spec/ RDF 1.2 parser test adapter
|
|
976
|
-
├── test/ API, built-in, example, package, playground, and stream tests
|
|
1046
|
+
├── test/ API, built-in, store, example, package, playground, and stream tests
|
|
977
1047
|
├── tools/ Build tooling
|
|
978
1048
|
├── playground.html Browser playground
|
|
979
1049
|
└── demo.html Simple browser demo
|
|
@@ -1040,6 +1110,7 @@ Package scripts are defined in `package.json`.
|
|
|
1040
1110
|
| `npm run test:manifest` | Validate example/test manifest expectations. |
|
|
1041
1111
|
| `npm run test:playground` | Check playground serving headers. |
|
|
1042
1112
|
| `npm run test:package` | Verify package-level behavior. |
|
|
1113
|
+
| `npm run test:store` | Verify memory and persistent fact-store matching. |
|
|
1043
1114
|
| `npm run test:rdf12` | Run RDF 1.2 Turtle, N-Triples, N-Quads, and TriG syntax suites. |
|
|
1044
1115
|
| `npm test` | Build and run the full suite. |
|
|
1045
1116
|
|
|
@@ -1194,7 +1265,7 @@ reasonStream(input, { rdf: true });
|
|
|
1194
1265
|
|
|
1195
1266
|
### `--stream-messages` fails immediately
|
|
1196
1267
|
|
|
1197
|
-
`--stream-messages` requires RDF mode and cannot be combined with `--ast`, `--stream`, or proof output.
|
|
1268
|
+
`--stream-messages` requires RDF mode and cannot be combined with `--ast`, `--stream`, or proof output. It can be combined with `--store`.
|
|
1198
1269
|
|
|
1199
1270
|
Use:
|
|
1200
1271
|
|