@kortexya/reasoninglayer 4.0.0 → 4.1.0
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 +1 -1
- package/dist/index.cjs +47 -24
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +117 -41
- package/dist/index.d.ts +117 -41
- package/dist/index.js +47 -24
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -316,7 +316,7 @@ pnpm run docs:build # Build documentation site
|
|
|
316
316
|
|
|
317
317
|
| SDK Version | Min Backend Version | Node | Browser |
|
|
318
318
|
| ----------- | ------------------- | ---- | ------- |
|
|
319
|
-
| 4.
|
|
319
|
+
| 4.1.0 | engine `308ed2a25` | 20+ | ES2022+ |
|
|
320
320
|
|
|
321
321
|
## License
|
|
322
322
|
|
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var __export = (target, all) => {
|
|
|
7
7
|
};
|
|
8
8
|
|
|
9
9
|
// src/config.ts
|
|
10
|
-
var SDK_VERSION = "4.
|
|
10
|
+
var SDK_VERSION = "4.1.0";
|
|
11
11
|
function resolveConfig(config) {
|
|
12
12
|
if (!config.baseUrl) {
|
|
13
13
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -2532,7 +2532,7 @@ var Inference = class {
|
|
|
2532
2532
|
...params
|
|
2533
2533
|
});
|
|
2534
2534
|
/**
|
|
2535
|
-
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag
|
|
2535
|
+
* @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag — the tag [`rule_content_tag`] publishes on the rule routes (#473) — and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
|
|
2536
2536
|
*
|
|
2537
2537
|
* @tags inference
|
|
2538
2538
|
* @name DeleteRule
|
|
@@ -28616,10 +28616,11 @@ var TermsClient = class {
|
|
|
28616
28616
|
* `etag` is optional in every case, not only for `asOf`. A historical read
|
|
28617
28617
|
* carries none (a past state is not a representation `If-Match` can guard,
|
|
28618
28618
|
* and a client that could capture one could overwrite the present with the
|
|
28619
|
-
* past), and neither does a
|
|
28620
|
-
*
|
|
28621
|
-
*
|
|
28622
|
-
* {@link
|
|
28619
|
+
* past), and neither does a term answered straight from durable storage.
|
|
28620
|
+
* A rule's id answers 404 here; read the tag
|
|
28621
|
+
* {@link InferenceClient.deleteRule} and {@link InferenceClient.replaceRule}
|
|
28622
|
+
* take as `ifMatch` from the rule routes ({@link AddRuleResponse.etag},
|
|
28623
|
+
* {@link RuleEntryDto.etag}).
|
|
28623
28624
|
*
|
|
28624
28625
|
* @example
|
|
28625
28626
|
* ```typescript
|
|
@@ -29601,6 +29602,7 @@ function RuleEntryDtoFromApiToFront(dto) {
|
|
|
29601
29602
|
if (dto.aggregator !== void 0 && dto.aggregator !== null) {
|
|
29602
29603
|
entry.aggregator = RuleAggregatorDtoFromApiToFront(dto.aggregator);
|
|
29603
29604
|
}
|
|
29605
|
+
if (dto.etag !== void 0 && dto.etag !== null) entry.etag = dto.etag;
|
|
29604
29606
|
if (dto.osfql !== void 0 && dto.osfql !== null) entry.osfql = dto.osfql;
|
|
29605
29607
|
return entry;
|
|
29606
29608
|
}
|
|
@@ -30052,7 +30054,8 @@ var InferenceClient = class {
|
|
|
30052
30054
|
*
|
|
30053
30055
|
* @param request - Rule definition using TermInputDto. Set `aggregator` to declare an
|
|
30054
30056
|
* engine-side head aggregator (see {@link RuleAggregatorDto}).
|
|
30055
|
-
* @returns The created rule wrapped in an AddRuleResponse
|
|
30057
|
+
* @returns The created rule wrapped in an AddRuleResponse, with its
|
|
30058
|
+
* {@link AddRuleResponse.etag} when the engine sends the `ETag` header.
|
|
30056
30059
|
* @throws {ApiError} If the rule is rejected or the request fails — 422 when
|
|
30057
30060
|
* it is unusable as written: a head or body antecedent naming a sort or
|
|
30058
30061
|
* term that does not exist (the message names it and its position — `the
|
|
@@ -30075,6 +30078,9 @@ var InferenceClient = class {
|
|
|
30075
30078
|
*
|
|
30076
30079
|
* Ask {@link InferenceClient.validateRule} first to learn every reason the
|
|
30077
30080
|
* write would refuse, without writing.
|
|
30081
|
+
* The `ETag` response header is the rule's content tag, folded into
|
|
30082
|
+
* `etag`: the `ifMatch` for {@link InferenceClient.deleteRule} and
|
|
30083
|
+
* {@link InferenceClient.replaceRule}.
|
|
30078
30084
|
* A `{ termId }` reference to a term that is durable but not yet loaded
|
|
30079
30085
|
* into the engine process resolves: the route loads the terms the request
|
|
30080
30086
|
* names before it converts them.
|
|
@@ -30099,7 +30105,7 @@ var InferenceClient = class {
|
|
|
30099
30105
|
AddRuleRequestFromFrontToApi(wireRequest),
|
|
30100
30106
|
toRequestParams(requestOptions)
|
|
30101
30107
|
);
|
|
30102
|
-
return decodeResponse(response, AddRuleResponseFromApiToFront);
|
|
30108
|
+
return withRuleEtag(decodeResponse(response, AddRuleResponseFromApiToFront), response.headers);
|
|
30103
30109
|
}
|
|
30104
30110
|
/**
|
|
30105
30111
|
* Run every check {@link InferenceClient.addRule} runs — without writing.
|
|
@@ -30321,8 +30327,8 @@ var InferenceClient = class {
|
|
|
30321
30327
|
* @param ruleId - Term id of the rule (its conclusion), as returned by
|
|
30322
30328
|
* {@link InferenceClient.addRule} or {@link InferenceClient.getRules}.
|
|
30323
30329
|
* @param options - `derivations` decides what happens to the conclusions the
|
|
30324
|
-
* rule derived (defaults to `'refuse'`); `ifMatch` is the
|
|
30325
|
-
*
|
|
30330
|
+
* rule derived (defaults to `'refuse'`); `ifMatch` is the rule's content
|
|
30331
|
+
* tag, sent as the `If-Match` header.
|
|
30326
30332
|
* @param requestOptions - Per-call request options.
|
|
30327
30333
|
* @returns What the withdrawal removed, tier by tier.
|
|
30328
30334
|
* @throws {@link ApiError} 400 if the id names a fact rather than a rule, or
|
|
@@ -30351,14 +30357,16 @@ var InferenceClient = class {
|
|
|
30351
30357
|
* conclusions are resident is refused too; `'retract'` removes them and
|
|
30352
30358
|
* {@link RuleWithdrawalReport.consequencesInvalidated} counts them.
|
|
30353
30359
|
*
|
|
30354
|
-
* **Optimistic concurrency.**
|
|
30355
|
-
*
|
|
30356
|
-
*
|
|
30357
|
-
* edited since answers 412.
|
|
30360
|
+
* **Optimistic concurrency.** Read the rule's tag from
|
|
30361
|
+
* {@link AddRuleResponse.etag}, {@link ReplaceRuleResponse.etag} or the
|
|
30362
|
+
* listing's {@link RuleEntryDto.etag} ({@link InferenceClient.getRules}),
|
|
30363
|
+
* and pass it as `ifMatch`; a rule edited since answers 412. The term route
|
|
30364
|
+
* does not serve it: `client.terms.getTerm(ruleId)` answers 404 for a rule.
|
|
30358
30365
|
*
|
|
30359
30366
|
* @example
|
|
30360
30367
|
* ```typescript
|
|
30361
|
-
* const {
|
|
30368
|
+
* const { rules } = await client.inference.getRules();
|
|
30369
|
+
* const etag = rules.find((rule) => rule.ruleId === ruleId)?.etag;
|
|
30362
30370
|
* const report = await client.inference.deleteRule(ruleId, {
|
|
30363
30371
|
* derivations: 'retract',
|
|
30364
30372
|
* ifMatch: etag,
|
|
@@ -30379,11 +30387,12 @@ var InferenceClient = class {
|
|
|
30379
30387
|
*
|
|
30380
30388
|
* @param ruleId - Term id of the rule (its conclusion) to replace.
|
|
30381
30389
|
* @param request - The replacement rule, in the same shape
|
|
30382
|
-
* {@link InferenceClient.addRule} takes, plus `ifMatch`: the
|
|
30383
|
-
* outgoing rule
|
|
30390
|
+
* {@link InferenceClient.addRule} takes, plus `ifMatch`: the content tag
|
|
30391
|
+
* of the outgoing rule, sent as the `If-Match` header and never in the body.
|
|
30384
30392
|
* @param requestOptions - Per-call request options.
|
|
30385
30393
|
* @returns The replacement, the id it replaced, what the withdrawal removed,
|
|
30386
|
-
* and how the rule base's guarantees moved
|
|
30394
|
+
* and how the rule base's guarantees moved; `etag` is the replacement's
|
|
30395
|
+
* content tag when the engine sends the `ETag` header.
|
|
30387
30396
|
* @throws {@link ApiError} 422 if the replacement is rejected by the
|
|
30388
30397
|
* authoring guards — in which case the original rule is left live. An
|
|
30389
30398
|
* empty `antecedents` list is one such refusal (`rule rejected: a rule
|
|
@@ -30406,16 +30415,23 @@ var InferenceClient = class {
|
|
|
30406
30415
|
* addresses a single clause.
|
|
30407
30416
|
*
|
|
30408
30417
|
* `ifMatch` guards the edit exactly as it guards
|
|
30409
|
-
* {@link InferenceClient.deleteRule}: read the tag
|
|
30410
|
-
*
|
|
30418
|
+
* {@link InferenceClient.deleteRule}: read the tag from
|
|
30419
|
+
* {@link AddRuleResponse.etag}, a previous {@link ReplaceRuleResponse.etag}
|
|
30420
|
+
* or the listing's {@link RuleEntryDto.etag}. The response's own `etag` is
|
|
30421
|
+
* the REPLACEMENT's tag, the `ifMatch` for the next edit.
|
|
30411
30422
|
*
|
|
30412
30423
|
* **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
|
|
30413
30424
|
*
|
|
30414
30425
|
* @example
|
|
30415
30426
|
* ```typescript
|
|
30416
|
-
* const
|
|
30427
|
+
* const created = await client.inference.addRule({
|
|
30428
|
+
* term: psi('senior', { name: Var('N') }),
|
|
30429
|
+
* antecedents: [psi('person', { name: Var('N') })],
|
|
30430
|
+
* });
|
|
30431
|
+
* const result = await client.inference.replaceRule(created.term.termId, {
|
|
30417
30432
|
* term: psi('retiree', { name: Var('N') }),
|
|
30418
30433
|
* antecedents: [psi('person', { name: Var('N') })],
|
|
30434
|
+
* ifMatch: created.etag,
|
|
30419
30435
|
* });
|
|
30420
30436
|
* console.log(result.previousRuleId, '->', result.term.termId);
|
|
30421
30437
|
* if (result.certification.regressed) {
|
|
@@ -30435,7 +30451,10 @@ var InferenceClient = class {
|
|
|
30435
30451
|
AddRuleRequestFromFrontToApi(wireRequest),
|
|
30436
30452
|
ifMatchParams(request.ifMatch, requestOptions)
|
|
30437
30453
|
);
|
|
30438
|
-
return
|
|
30454
|
+
return withRuleEtag(
|
|
30455
|
+
decodeResponse(response, ReplaceRuleResponseFromApiToFront),
|
|
30456
|
+
response.headers
|
|
30457
|
+
);
|
|
30439
30458
|
}
|
|
30440
30459
|
/**
|
|
30441
30460
|
* Query for matching data by searching rules and facts backwards from a goal pattern.
|
|
@@ -30933,6 +30952,10 @@ var InferenceClient = class {
|
|
|
30933
30952
|
function convertTermArg(input) {
|
|
30934
30953
|
return isPsiTermInput(input) ? toTermInputDto(input) : input;
|
|
30935
30954
|
}
|
|
30955
|
+
function withRuleEtag(body, headers) {
|
|
30956
|
+
const etag = headers.get("etag");
|
|
30957
|
+
return etag === null ? body : { ...body, etag };
|
|
30958
|
+
}
|
|
30936
30959
|
|
|
30937
30960
|
// src/normalizers/query.ts
|
|
30938
30961
|
function TermPatternDtoFromFrontToApi(model) {
|
|
@@ -43048,8 +43071,8 @@ function MaterializeScenarioRequestFromFrontToApi(model) {
|
|
|
43048
43071
|
return {
|
|
43049
43072
|
// The prefix keys are data (`''`, `myOnt`), copied verbatim.
|
|
43050
43073
|
prefixes: model.prefixes === void 0 ? void 0 : { ...model.prefixes },
|
|
43051
|
-
//
|
|
43052
|
-
//
|
|
43074
|
+
// The scenario is user data sent verbatim (RAW_BODY_HEADER, #39): every
|
|
43075
|
+
// key reaches the engine under the spelling the caller wrote.
|
|
43053
43076
|
scenario: model.scenario
|
|
43054
43077
|
};
|
|
43055
43078
|
}
|