@kortexya/reasoninglayer 2.0.0 → 2.1.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/dist/index.cjs +228 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +769 -339
- package/dist/index.d.ts +769 -339
- package/dist/index.js +228 -61
- package/dist/index.js.map +1 -1
- package/package.json +9 -8
package/dist/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var __export = (target, all) => {
|
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
// src/config.ts
|
|
8
|
-
var SDK_VERSION = "2.
|
|
8
|
+
var SDK_VERSION = "2.1.1";
|
|
9
9
|
function resolveConfig(config) {
|
|
10
10
|
if (!config.baseUrl) {
|
|
11
11
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -15869,31 +15869,42 @@ function convertFeatures(features) {
|
|
|
15869
15869
|
}
|
|
15870
15870
|
|
|
15871
15871
|
// src/normalizers/homoiconic.ts
|
|
15872
|
-
function
|
|
15872
|
+
function assertPresent(value, what) {
|
|
15873
|
+
if (value === null || value === void 0) {
|
|
15874
|
+
throw new ValidationError(
|
|
15875
|
+
`${what} is required \u2014 received ${value === null ? "null" : "undefined"}.`,
|
|
15876
|
+
what
|
|
15877
|
+
);
|
|
15878
|
+
}
|
|
15879
|
+
}
|
|
15880
|
+
function FeatureInputValueDtoFromFrontToApi(value, path = "feature value") {
|
|
15881
|
+
assertPresent(value, path);
|
|
15873
15882
|
if (typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
15874
15883
|
return value;
|
|
15875
15884
|
}
|
|
15876
15885
|
if (Array.isArray(value)) {
|
|
15877
|
-
return value.map(
|
|
15886
|
+
return value.map(
|
|
15887
|
+
(element, index) => FeatureInputValueDtoFromFrontToApi(element, `${path}[${index}]`)
|
|
15888
|
+
);
|
|
15878
15889
|
}
|
|
15879
15890
|
if ("name" in value && "constraint" in value) {
|
|
15880
15891
|
return {
|
|
15881
15892
|
name: value.name,
|
|
15882
|
-
constraint: TermInputDtoFromFrontToApi(value.constraint)
|
|
15893
|
+
constraint: TermInputDtoFromFrontToApi(value.constraint, `${path}.constraint`)
|
|
15883
15894
|
};
|
|
15884
15895
|
}
|
|
15885
15896
|
if ("name" in value) {
|
|
15886
15897
|
return { name: value.name };
|
|
15887
15898
|
}
|
|
15888
15899
|
if ("sortId" in value) {
|
|
15889
|
-
const features = value.features ? featuresInputFromFrontToApi(value.features) : void 0;
|
|
15900
|
+
const features = value.features ? featuresInputFromFrontToApi(value.features, `${path}.features`) : void 0;
|
|
15890
15901
|
return {
|
|
15891
15902
|
sort_id: value.sortId,
|
|
15892
15903
|
...features ? { features } : {}
|
|
15893
15904
|
};
|
|
15894
15905
|
}
|
|
15895
15906
|
if ("sortName" in value) {
|
|
15896
|
-
const features = value.features ? featuresInputFromFrontToApi(value.features) : void 0;
|
|
15907
|
+
const features = value.features ? featuresInputFromFrontToApi(value.features, `${path}.features`) : void 0;
|
|
15897
15908
|
return {
|
|
15898
15909
|
sort_name: value.sortName,
|
|
15899
15910
|
...features ? { features } : {}
|
|
@@ -15904,14 +15915,15 @@ function FeatureInputValueDtoFromFrontToApi(value) {
|
|
|
15904
15915
|
}
|
|
15905
15916
|
return { term_id: value.termId };
|
|
15906
15917
|
}
|
|
15907
|
-
function featuresInputFromFrontToApi(features) {
|
|
15918
|
+
function featuresInputFromFrontToApi(features, path = "features") {
|
|
15908
15919
|
const result = {};
|
|
15909
15920
|
for (const [key, val] of Object.entries(features)) {
|
|
15910
|
-
result[key] = FeatureInputValueDtoFromFrontToApi(val);
|
|
15921
|
+
result[key] = FeatureInputValueDtoFromFrontToApi(val, `${path}.${key}`);
|
|
15911
15922
|
}
|
|
15912
15923
|
return result;
|
|
15913
15924
|
}
|
|
15914
|
-
function TermInputDtoFromFrontToApi(model) {
|
|
15925
|
+
function TermInputDtoFromFrontToApi(model, path = "term") {
|
|
15926
|
+
assertPresent(model, path);
|
|
15915
15927
|
if ("termId" in model) {
|
|
15916
15928
|
return { term_id: model.termId };
|
|
15917
15929
|
}
|
|
@@ -15926,14 +15938,14 @@ function TermInputDtoFromFrontToApi(model) {
|
|
|
15926
15938
|
if ("sortId" in model) {
|
|
15927
15939
|
const inline = {
|
|
15928
15940
|
sort_id: model.sortId,
|
|
15929
|
-
features: featuresInputFromFrontToApi(model.features)
|
|
15941
|
+
features: featuresInputFromFrontToApi(model.features, `${path}.features`)
|
|
15930
15942
|
};
|
|
15931
15943
|
if (model.binding !== void 0) inline.binding = model.binding;
|
|
15932
15944
|
return inline;
|
|
15933
15945
|
}
|
|
15934
15946
|
const byName = {
|
|
15935
15947
|
sort_name: model.sortName,
|
|
15936
|
-
features: model.features ? featuresInputFromFrontToApi(model.features) : void 0
|
|
15948
|
+
features: model.features ? featuresInputFromFrontToApi(model.features, `${path}.features`) : void 0
|
|
15937
15949
|
};
|
|
15938
15950
|
if (model.binding !== void 0) byName.binding = model.binding;
|
|
15939
15951
|
return byName;
|
|
@@ -16495,7 +16507,9 @@ function RuleAggregatorDtoFromFrontToApi(model) {
|
|
|
16495
16507
|
function AddRuleRequestFromFrontToApi(model) {
|
|
16496
16508
|
return {
|
|
16497
16509
|
term: TermInputDtoFromFrontToApi(model.term),
|
|
16498
|
-
antecedents: model.antecedents?.map(
|
|
16510
|
+
antecedents: model.antecedents?.map(
|
|
16511
|
+
(t, i) => TermInputDtoFromFrontToApi(t, `antecedents[${i}]`)
|
|
16512
|
+
),
|
|
16499
16513
|
certainty: model.certainty,
|
|
16500
16514
|
aggregator: model.aggregator ? RuleAggregatorDtoFromFrontToApi(model.aggregator) : model.aggregator
|
|
16501
16515
|
};
|
|
@@ -16512,7 +16526,7 @@ function BulkAddRulesRequestFromFrontToApi(model) {
|
|
|
16512
16526
|
}
|
|
16513
16527
|
function BulkAddFactsRequestFromFrontToApi(model) {
|
|
16514
16528
|
return {
|
|
16515
|
-
facts: model.facts.map(TermInputDtoFromFrontToApi)
|
|
16529
|
+
facts: model.facts.map((t, i) => TermInputDtoFromFrontToApi(t, `facts[${i}]`))
|
|
16516
16530
|
};
|
|
16517
16531
|
}
|
|
16518
16532
|
function BackwardChainRequestFromFrontToApi(model) {
|
|
@@ -16530,12 +16544,15 @@ function BackwardChainRequestFromFrontToApi(model) {
|
|
|
16530
16544
|
}
|
|
16531
16545
|
function ForwardChainRequestFromFrontToApi(model) {
|
|
16532
16546
|
return {
|
|
16533
|
-
initial_facts: model.initialFacts?.map(
|
|
16547
|
+
initial_facts: model.initialFacts?.map(
|
|
16548
|
+
(t, i) => TermInputDtoFromFrontToApi(t, `initialFacts[${i}]`)
|
|
16549
|
+
),
|
|
16534
16550
|
keep_derived: model.keepDerived,
|
|
16535
16551
|
enable_provenance_tags: model.enableProvenanceTags,
|
|
16536
16552
|
max_iterations: model.maxIterations,
|
|
16537
16553
|
max_facts: model.maxFacts,
|
|
16538
|
-
emit_provenance: model.emitProvenance
|
|
16554
|
+
emit_provenance: model.emitProvenance,
|
|
16555
|
+
timeout_ms: model.timeoutMs ?? void 0
|
|
16539
16556
|
};
|
|
16540
16557
|
}
|
|
16541
16558
|
function FuzzyProveRequestFromFrontToApi(model) {
|
|
@@ -16552,7 +16569,7 @@ function FuzzyProveRequestFromFrontToApi(model) {
|
|
|
16552
16569
|
}
|
|
16553
16570
|
function BulkFuzzyProveRequestFromFrontToApi(model) {
|
|
16554
16571
|
return {
|
|
16555
|
-
goals: model.goals?.map(TermInputDtoFromFrontToApi),
|
|
16572
|
+
goals: model.goals?.map((t, i) => TermInputDtoFromFrontToApi(t, `goals[${i}]`)),
|
|
16556
16573
|
goal_ids: model.goalIds ?? void 0,
|
|
16557
16574
|
max_depth: model.maxDepth,
|
|
16558
16575
|
min_degree: model.minDegree,
|
|
@@ -16575,7 +16592,7 @@ function BayesianPredictRequestFromFrontToApi(model) {
|
|
|
16575
16592
|
}
|
|
16576
16593
|
function CreateGoalRequestFromFrontToApi(model) {
|
|
16577
16594
|
return {
|
|
16578
|
-
clauses: model.clauses.map(TermInputDtoFromFrontToApi),
|
|
16595
|
+
clauses: model.clauses.map((t, i) => TermInputDtoFromFrontToApi(t, `clauses[${i}]`)),
|
|
16579
16596
|
constraints: model.constraints?.map(ConstraintInputDtoFromFrontToApi),
|
|
16580
16597
|
min_degree: model.minDegree ?? void 0
|
|
16581
16598
|
};
|
|
@@ -23943,7 +23960,7 @@ function EntailmentRequestFromFrontToApi(model) {
|
|
|
23943
23960
|
return {
|
|
23944
23961
|
antecedent: TermInputDtoFromFrontToApi(model.antecedent),
|
|
23945
23962
|
consequent: TermInputDtoFromFrontToApi(model.consequent),
|
|
23946
|
-
facts: model.facts?.map(TermInputDtoFromFrontToApi)
|
|
23963
|
+
facts: model.facts?.map((t, i) => TermInputDtoFromFrontToApi(t, `facts[${i}]`))
|
|
23947
23964
|
};
|
|
23948
23965
|
}
|
|
23949
23966
|
function EntailmentResponseFromApiToFront(dto) {
|
|
@@ -23957,7 +23974,7 @@ function DisentailmentRequestFromFrontToApi(model) {
|
|
|
23957
23974
|
return {
|
|
23958
23975
|
antecedent: TermInputDtoFromFrontToApi(model.antecedent),
|
|
23959
23976
|
consequent: TermInputDtoFromFrontToApi(model.consequent),
|
|
23960
|
-
facts: model.facts?.map(TermInputDtoFromFrontToApi)
|
|
23977
|
+
facts: model.facts?.map((t, i) => TermInputDtoFromFrontToApi(t, `facts[${i}]`))
|
|
23961
23978
|
};
|
|
23962
23979
|
}
|
|
23963
23980
|
function DisentailmentResponseFromApiToFront(dto) {
|
|
@@ -25548,12 +25565,25 @@ function SourceDetailResponseFromApiToFront(dto) {
|
|
|
25548
25565
|
supportedModes: dto.supported_modes
|
|
25549
25566
|
};
|
|
25550
25567
|
}
|
|
25568
|
+
function ConfigFieldDtoFromApiToFront(dto) {
|
|
25569
|
+
return {
|
|
25570
|
+
// `name` is the factory's own JSON key and goes back on the wire
|
|
25571
|
+
// verbatim — never camelCased, in either direction (#14).
|
|
25572
|
+
name: dto.name,
|
|
25573
|
+
type: dto.type,
|
|
25574
|
+
required: dto.required
|
|
25575
|
+
};
|
|
25576
|
+
}
|
|
25551
25577
|
function SourceTypeDtoFromApiToFront(dto) {
|
|
25552
25578
|
return {
|
|
25553
25579
|
sourceType: dto.source_type,
|
|
25554
25580
|
aliases: dto.aliases,
|
|
25555
25581
|
available: dto.available,
|
|
25556
|
-
supportedModes: dto.supported_modes
|
|
25582
|
+
supportedModes: dto.supported_modes,
|
|
25583
|
+
// Defaulted rather than left absent: the field is required on the current
|
|
25584
|
+
// engine, and an empty list reads correctly on an older one — a form built
|
|
25585
|
+
// from no fields is visibly empty, where an absent list is a crash.
|
|
25586
|
+
configFields: (dto.config_fields ?? []).map(ConfigFieldDtoFromApiToFront)
|
|
25557
25587
|
};
|
|
25558
25588
|
}
|
|
25559
25589
|
function ListSourceTypesResponseFromApiToFront(dto) {
|
|
@@ -25573,6 +25603,7 @@ function DiscoverableTypeDtoFromApiToFront(dto) {
|
|
|
25573
25603
|
return {
|
|
25574
25604
|
comment: dto.comment,
|
|
25575
25605
|
estimatedRows: dto.estimated_rows,
|
|
25606
|
+
columnCount: dto.column_count,
|
|
25576
25607
|
name: dto.name
|
|
25577
25608
|
};
|
|
25578
25609
|
}
|
|
@@ -25583,6 +25614,15 @@ function ListTablesResponseFromApiToFront(dto) {
|
|
|
25583
25614
|
total: dto.total
|
|
25584
25615
|
};
|
|
25585
25616
|
}
|
|
25617
|
+
function KeyProvenanceDtoFromApiToFront(dto) {
|
|
25618
|
+
return {
|
|
25619
|
+
source: dto.source,
|
|
25620
|
+
chosenBy: dto.chosen_by,
|
|
25621
|
+
explanation: dto.explanation,
|
|
25622
|
+
guaranteedUnique: dto.guaranteed_unique,
|
|
25623
|
+
durability: dto.durability
|
|
25624
|
+
};
|
|
25625
|
+
}
|
|
25586
25626
|
function DiscoveredFeatureDtoFromApiToFront(dto) {
|
|
25587
25627
|
return {
|
|
25588
25628
|
constraints: dto.constraints,
|
|
@@ -25590,10 +25630,16 @@ function DiscoveredFeatureDtoFromApiToFront(dto) {
|
|
|
25590
25630
|
isIdentifier: dto.is_identifier,
|
|
25591
25631
|
isRelation: dto.is_relation,
|
|
25592
25632
|
name: dto.name,
|
|
25633
|
+
// The engine's own OSFQL-readable spelling. Defaulted to `name`, which it
|
|
25634
|
+
// is identical to, so an older engine that predates it stays usable.
|
|
25635
|
+
featureName: dto.feature_name ?? dto.name,
|
|
25593
25636
|
relationTarget: dto.relation_target,
|
|
25594
25637
|
required: dto.required,
|
|
25595
25638
|
sourceName: dto.source_name,
|
|
25596
|
-
typeHint: dto.type_hint
|
|
25639
|
+
typeHint: dto.type_hint,
|
|
25640
|
+
// The difference between a declared primary key and a guess. Carried
|
|
25641
|
+
// through so a mapping wizard can present the guess as a guess (#14).
|
|
25642
|
+
identifierProvenance: dto.identifier_provenance ? KeyProvenanceDtoFromApiToFront(dto.identifier_provenance) : dto.identifier_provenance
|
|
25597
25643
|
};
|
|
25598
25644
|
}
|
|
25599
25645
|
function DiscoveredSortDtoFromApiToFront(dto) {
|
|
@@ -31443,7 +31489,9 @@ var OptimizeClient = class {
|
|
|
31443
31489
|
}
|
|
31444
31490
|
const ruleResponse = await this.inferenceApi.addRule({
|
|
31445
31491
|
term: TermInputDtoFromFrontToApi(compiled.solutionTerm),
|
|
31446
|
-
antecedents: compiled.antecedents.map(
|
|
31492
|
+
antecedents: compiled.antecedents.map(
|
|
31493
|
+
(t, i) => TermInputDtoFromFrontToApi(t, `antecedents[${i}]`)
|
|
31494
|
+
),
|
|
31447
31495
|
certainty: 1
|
|
31448
31496
|
}, toRequestParams(requestOptions));
|
|
31449
31497
|
ruleTermId = extractRuleTermId(ruleResponse.data);
|
|
@@ -32122,6 +32170,7 @@ function OsfqlResponseFromApiToFront(dto) {
|
|
|
32122
32170
|
bindings,
|
|
32123
32171
|
fetched,
|
|
32124
32172
|
producedTermIds: dto.produced_term_ids,
|
|
32173
|
+
updatedTermIds: dto.updated_term_ids,
|
|
32125
32174
|
definedSortIds: dto.defined_sort_ids,
|
|
32126
32175
|
diagnostics: dto.diagnostics,
|
|
32127
32176
|
statementCount: dto.statement_count
|
|
@@ -32193,11 +32242,25 @@ function OsfqlPreviewAffectedFromApiToFront(dto) {
|
|
|
32193
32242
|
affected.exact = dto.exact;
|
|
32194
32243
|
}
|
|
32195
32244
|
if (dto.sample_rows !== void 0) {
|
|
32196
|
-
const rows =
|
|
32197
|
-
|
|
32198
|
-
|
|
32245
|
+
const rows = [];
|
|
32246
|
+
let unparsed = 0;
|
|
32247
|
+
const wireRows = dto.sample_rows;
|
|
32248
|
+
if (Array.isArray(wireRows)) {
|
|
32249
|
+
for (const row of wireRows) {
|
|
32250
|
+
const parsed = OsfqlBindingFromApiToFront(row);
|
|
32251
|
+
if (parsed === void 0) {
|
|
32252
|
+
unparsed += 1;
|
|
32253
|
+
} else {
|
|
32254
|
+
rows.push(parsed);
|
|
32255
|
+
}
|
|
32256
|
+
}
|
|
32257
|
+
} else {
|
|
32258
|
+
unparsed = 1;
|
|
32199
32259
|
}
|
|
32200
32260
|
affected.sampleRows = rows;
|
|
32261
|
+
if (unparsed > 0) {
|
|
32262
|
+
affected.unparsedSampleRows = unparsed;
|
|
32263
|
+
}
|
|
32201
32264
|
}
|
|
32202
32265
|
if (dto.by_sort !== void 0) {
|
|
32203
32266
|
affected.bySort = dto.by_sort.map(OsfqlPreviewSortCountFromApiToFront);
|
|
@@ -32218,34 +32281,15 @@ function OsfqlPreviewStatementFromApiToFront(dto) {
|
|
|
32218
32281
|
source: dto.source
|
|
32219
32282
|
};
|
|
32220
32283
|
if (dto.affected !== void 0) {
|
|
32221
|
-
|
|
32222
|
-
if (affected === void 0) {
|
|
32223
|
-
return void 0;
|
|
32224
|
-
}
|
|
32225
|
-
statement.affected = affected;
|
|
32284
|
+
statement.affected = OsfqlPreviewAffectedFromApiToFront(dto.affected);
|
|
32226
32285
|
}
|
|
32227
32286
|
if (dto.nested !== void 0) {
|
|
32228
|
-
|
|
32229
|
-
for (const child of dto.nested) {
|
|
32230
|
-
const parsed = OsfqlPreviewStatementFromApiToFront(child);
|
|
32231
|
-
if (parsed === void 0) {
|
|
32232
|
-
return void 0;
|
|
32233
|
-
}
|
|
32234
|
-
nested.push(parsed);
|
|
32235
|
-
}
|
|
32236
|
-
statement.nested = nested;
|
|
32287
|
+
statement.nested = dto.nested.map(OsfqlPreviewStatementFromApiToFront);
|
|
32237
32288
|
}
|
|
32238
32289
|
return statement;
|
|
32239
32290
|
}
|
|
32240
32291
|
function OsfqlPreviewResponseFromApiToFront(dto) {
|
|
32241
|
-
const statements =
|
|
32242
|
-
for (const entry of dto.statements) {
|
|
32243
|
-
const parsed = OsfqlPreviewStatementFromApiToFront(entry);
|
|
32244
|
-
if (parsed === void 0) {
|
|
32245
|
-
return void 0;
|
|
32246
|
-
}
|
|
32247
|
-
statements.push(parsed);
|
|
32248
|
-
}
|
|
32292
|
+
const statements = dto.statements.map(OsfqlPreviewStatementFromApiToFront);
|
|
32249
32293
|
const response = { mutates: dto.mutates, statements };
|
|
32250
32294
|
if (dto.atomic_refusal !== void 0) {
|
|
32251
32295
|
response.atomicRefusal = dto.atomic_refusal ? OsfqlAtomicRefusalFromApiToFront(dto.atomic_refusal) : dto.atomic_refusal;
|
|
@@ -32341,8 +32385,6 @@ var OsfqlClient = class {
|
|
|
32341
32385
|
* atomic refusal when there is one.
|
|
32342
32386
|
* @throws {ApiError} If the program does not parse (HTTP 400, `OsfqlErrorResponse`),
|
|
32343
32387
|
* or the request otherwise fails.
|
|
32344
|
-
* @throws {ReasoningLayerError} If a sample row carries a value that does not satisfy
|
|
32345
|
-
* the published {@link OsfqlValue} contract.
|
|
32346
32388
|
*
|
|
32347
32389
|
* @remarks
|
|
32348
32390
|
* **Why call this instead of classifying the program client-side.** Three
|
|
@@ -32377,9 +32419,16 @@ var OsfqlClient = class {
|
|
|
32377
32419
|
* Two further measured facts. The top-level `mutates` DOES fold nested
|
|
32378
32420
|
* statements now: the `IF` program above answers `true`, and so does an `IF`
|
|
32379
32421
|
* whose only writing branch is the `ELSE` — the earlier defect where an `IF`
|
|
32380
|
-
* with a writing branch answered `false` is fixed. And `affected`
|
|
32381
|
-
*
|
|
32382
|
-
*
|
|
32422
|
+
* with a writing branch answered `false` is fixed. And `affected` is NOT
|
|
32423
|
+
* ambiguous: a destructive statement that matches zero rows answers
|
|
32424
|
+
* `{count: 0, exact: true}` rather than omitting the block. Measured
|
|
32425
|
+
* 2026-09-21 — `preview('RETRACT widget(name: "nobody");')` against an empty
|
|
32426
|
+
* `widget` answers `affected: {"count":0,"exact":true}`, while
|
|
32427
|
+
* `preview('MATCH widget(name: ?N);')` carries no `affected` key at all. So
|
|
32428
|
+
* an ABSENT block means the statement has no affected-row set; `count: 0`
|
|
32429
|
+
* means the rows were counted and there are none. A confirm dialog can tell
|
|
32430
|
+
* the two apart, which is what the block was separated for. See
|
|
32431
|
+
* {@link OsfqlPreviewAffected.count}.
|
|
32383
32432
|
*
|
|
32384
32433
|
* `statement.index` is a single counter over the whole program: an `IF` at
|
|
32385
32434
|
* index 1 carries nested entries at index 2 and 3.
|
|
@@ -32420,13 +32469,7 @@ var OsfqlClient = class {
|
|
|
32420
32469
|
OsfqlRequestFromFrontToApi({ ...options, query }),
|
|
32421
32470
|
toRequestParams(requestOptions)
|
|
32422
32471
|
);
|
|
32423
|
-
|
|
32424
|
-
if (parsed === void 0) {
|
|
32425
|
-
throw new ReasoningLayerError(
|
|
32426
|
-
"osfql/preview returned an affected sample row that does not match the published OsfqlValue contract (expected tagged values with a lowercase `type` discriminator)"
|
|
32427
|
-
);
|
|
32428
|
-
}
|
|
32429
|
-
return parsed;
|
|
32472
|
+
return OsfqlPreviewResponseFromApiToFront(response.data);
|
|
32430
32473
|
}
|
|
32431
32474
|
/**
|
|
32432
32475
|
* Diagnose an OSFQL program for contradictions and inconsistencies.
|
|
@@ -34359,6 +34402,27 @@ function AuditPageFromApiToFront(dto) {
|
|
|
34359
34402
|
offset: dto.offset
|
|
34360
34403
|
};
|
|
34361
34404
|
}
|
|
34405
|
+
function RiskTotalsDtoFromApiToFront(dto) {
|
|
34406
|
+
return {
|
|
34407
|
+
nSafe: dto.n_safe,
|
|
34408
|
+
nWarning: dto.n_warning,
|
|
34409
|
+
nUnsafe: dto.n_unsafe,
|
|
34410
|
+
nUngraded: dto.n_ungraded,
|
|
34411
|
+
nGradedByVerification: dto.n_graded_by_verification,
|
|
34412
|
+
nVerified: dto.n_verified,
|
|
34413
|
+
nRefuted: dto.n_refuted,
|
|
34414
|
+
nAbstained: dto.n_abstained,
|
|
34415
|
+
nFabricationDetected: dto.n_fabrication_detected,
|
|
34416
|
+
nFabricationClean: dto.n_fabrication_clean,
|
|
34417
|
+
nFabricationUnknown: dto.n_fabrication_unknown,
|
|
34418
|
+
nClaimsTotal: dto.n_claims_total,
|
|
34419
|
+
nClaimsRefuted: dto.n_claims_refuted,
|
|
34420
|
+
// Carried through as `null`, never folded to `0`. `null` is "not
|
|
34421
|
+
// measured" — the denominator is checked responses only — and `0` would
|
|
34422
|
+
// report a clean fabrication rate for a ledger nobody checked (#11).
|
|
34423
|
+
fabricationRate: dto.fabrication_rate
|
|
34424
|
+
};
|
|
34425
|
+
}
|
|
34362
34426
|
function SummaryResponseFromApiToFront(dto) {
|
|
34363
34427
|
const out = {
|
|
34364
34428
|
nRecords: dto.n_records,
|
|
@@ -34368,6 +34432,12 @@ function SummaryResponseFromApiToFront(dto) {
|
|
|
34368
34432
|
};
|
|
34369
34433
|
if (dto.ts_first) out.tsFirst = dto.ts_first;
|
|
34370
34434
|
if (dto.ts_last) out.tsLast = dto.ts_last;
|
|
34435
|
+
if (dto.risk !== void 0 && dto.risk !== null) {
|
|
34436
|
+
out.risk = RiskTotalsDtoFromApiToFront(dto.risk);
|
|
34437
|
+
}
|
|
34438
|
+
if (dto.n_oversight_decisions !== void 0 && dto.n_oversight_decisions !== null) {
|
|
34439
|
+
out.nOversightDecisions = dto.n_oversight_decisions;
|
|
34440
|
+
}
|
|
34371
34441
|
return out;
|
|
34372
34442
|
}
|
|
34373
34443
|
function VerifyResponseFromApiToFront(dto) {
|
|
@@ -36594,6 +36664,23 @@ function ImportOwlResponseFromApiToFront(dto) {
|
|
|
36594
36664
|
sortsCreated: dto.sorts_created
|
|
36595
36665
|
};
|
|
36596
36666
|
}
|
|
36667
|
+
function ExecuteTranspiledRequestFromFrontToApi(model) {
|
|
36668
|
+
return {
|
|
36669
|
+
osfql: model.osfql
|
|
36670
|
+
};
|
|
36671
|
+
}
|
|
36672
|
+
function ExecuteTranspiledResponseFromApiToFront(dto) {
|
|
36673
|
+
return {
|
|
36674
|
+
// `rows` are the source's OWN records; their keys are its column names and
|
|
36675
|
+
// are data, carried verbatim. The generated type erases them to `any[]`,
|
|
36676
|
+
// so the shipped surface narrows them to one object per row (#12).
|
|
36677
|
+
rows: dto.rows,
|
|
36678
|
+
rowCount: dto.row_count,
|
|
36679
|
+
query: dto.query,
|
|
36680
|
+
dialect: dto.dialect,
|
|
36681
|
+
sourceId: dto.source_id
|
|
36682
|
+
};
|
|
36683
|
+
}
|
|
36597
36684
|
function TranspileRequestFromFrontToApi(model) {
|
|
36598
36685
|
return {
|
|
36599
36686
|
dialect: model.dialect,
|
|
@@ -36852,6 +36939,46 @@ var OntologyBridgeClient = class {
|
|
|
36852
36939
|
);
|
|
36853
36940
|
return TranspileResponseFromApiToFront(response.data);
|
|
36854
36941
|
}
|
|
36942
|
+
/**
|
|
36943
|
+
* Transpile an OSFQL query AND run it on the source it is bound to.
|
|
36944
|
+
*
|
|
36945
|
+
* @param request - The OSFQL query. No dialect: the binding names the
|
|
36946
|
+
* source, and the source's type decides the dialect.
|
|
36947
|
+
* @param requestOptions - Per-call request options.
|
|
36948
|
+
* @returns The rows the source returned, the native query that fetched them,
|
|
36949
|
+
* its dialect, and the source id.
|
|
36950
|
+
* @throws {ApiError} If the request fails.
|
|
36951
|
+
*
|
|
36952
|
+
* @remarks
|
|
36953
|
+
* Sent to `POST /api/v1/ontology/query`. The response uses the snake_case
|
|
36954
|
+
* wire format (`row_count`, `source_id`); this client normalizes at the
|
|
36955
|
+
* boundary. `rows` are the source's own records, one object per row, and
|
|
36956
|
+
* their KEYS are the source's column names — data, carried verbatim.
|
|
36957
|
+
*
|
|
36958
|
+
* **This is the second half of {@link OntologyBridgeClient.transpile}, and
|
|
36959
|
+
* for a `transpile`-mode source it is the only route that answers.** Such a
|
|
36960
|
+
* source deliberately ingests nothing: its bound sorts are live views over
|
|
36961
|
+
* the operator's own database, so every KB query over them reports no
|
|
36962
|
+
* results. `transpile` emits the native query and stops; this runs it.
|
|
36963
|
+
*
|
|
36964
|
+
* @example
|
|
36965
|
+
* ```typescript
|
|
36966
|
+
* const result = await client.ontologyBridge.executeTranspiled({
|
|
36967
|
+
* osfql: 'MATCH person(name: ?N);',
|
|
36968
|
+
* });
|
|
36969
|
+
* console.log(result.dialect); // "postgres"
|
|
36970
|
+
* console.log(result.query); // the SQL that ran
|
|
36971
|
+
* console.log(result.rowCount); // 12
|
|
36972
|
+
* for (const row of result.rows) console.log(row['name']);
|
|
36973
|
+
* ```
|
|
36974
|
+
*/
|
|
36975
|
+
async executeTranspiled(request, requestOptions) {
|
|
36976
|
+
const response = await this.api.executeTranspiled(
|
|
36977
|
+
ExecuteTranspiledRequestFromFrontToApi(request),
|
|
36978
|
+
toRequestParams(requestOptions)
|
|
36979
|
+
);
|
|
36980
|
+
return ExecuteTranspiledResponseFromApiToFront(response.data);
|
|
36981
|
+
}
|
|
36855
36982
|
/**
|
|
36856
36983
|
* Remove a sort-table binding.
|
|
36857
36984
|
*
|
|
@@ -39097,12 +39224,46 @@ function ConformanceRequestFromFrontToApi(model) {
|
|
|
39097
39224
|
ontology: model.ontology
|
|
39098
39225
|
};
|
|
39099
39226
|
}
|
|
39227
|
+
function stringAt(source, key) {
|
|
39228
|
+
const value = Reflect.get(source, key);
|
|
39229
|
+
return typeof value === "string" ? value : void 0;
|
|
39230
|
+
}
|
|
39231
|
+
function suggestedFixesAt(source) {
|
|
39232
|
+
const value = Reflect.get(source, "suggested_fixes");
|
|
39233
|
+
if (!Array.isArray(value)) return void 0;
|
|
39234
|
+
const fixes = [];
|
|
39235
|
+
for (const entry of value) {
|
|
39236
|
+
if (typeof entry === "object" && entry !== null && !Array.isArray(entry)) {
|
|
39237
|
+
fixes.push({ ...entry });
|
|
39238
|
+
}
|
|
39239
|
+
}
|
|
39240
|
+
return fixes;
|
|
39241
|
+
}
|
|
39242
|
+
function ConformanceViolationDtoFromApiToFront(dto) {
|
|
39243
|
+
if (typeof dto !== "object" || dto === null) return {};
|
|
39244
|
+
const violation = {};
|
|
39245
|
+
const subject = stringAt(dto, "subject");
|
|
39246
|
+
if (subject !== void 0) violation.subject = subject;
|
|
39247
|
+
const object = stringAt(dto, "object");
|
|
39248
|
+
if (object !== void 0) violation.object = object;
|
|
39249
|
+
const feature = stringAt(dto, "feature");
|
|
39250
|
+
if (feature !== void 0) violation.feature = feature;
|
|
39251
|
+
const subjectSort = stringAt(dto, "subject_sort");
|
|
39252
|
+
if (subjectSort !== void 0) violation.subjectSort = subjectSort;
|
|
39253
|
+
const objectSort = stringAt(dto, "object_sort");
|
|
39254
|
+
if (objectSort !== void 0) violation.objectSort = objectSort;
|
|
39255
|
+
const kind = stringAt(dto, "kind");
|
|
39256
|
+
if (kind !== void 0) violation.kind = kind;
|
|
39257
|
+
const suggestedFixes = suggestedFixesAt(dto);
|
|
39258
|
+
if (suggestedFixes !== void 0) violation.suggestedFixes = suggestedFixes;
|
|
39259
|
+
return violation;
|
|
39260
|
+
}
|
|
39100
39261
|
function ConformanceCheckResponseFromApiToFront(dto) {
|
|
39101
39262
|
return {
|
|
39102
39263
|
conformant: dto.conformant,
|
|
39103
39264
|
totalViolations: dto.total_violations,
|
|
39104
39265
|
byKind: ViolationCountsDtoFromApiToFront(dto.by_kind),
|
|
39105
|
-
violations: dto.violations.map(
|
|
39266
|
+
violations: dto.violations.map(ConformanceViolationDtoFromApiToFront)
|
|
39106
39267
|
};
|
|
39107
39268
|
}
|
|
39108
39269
|
function ConformanceRepairResponseFromApiToFront(dto) {
|
|
@@ -39140,6 +39301,11 @@ var ConformanceClient = class {
|
|
|
39140
39301
|
* The ontology travels as an opaque string in the declared RDF format; no
|
|
39141
39302
|
* value serialization is applied to it.
|
|
39142
39303
|
*
|
|
39304
|
+
* Each violation is a {@link ConformanceViolationDto}, NOT the shared
|
|
39305
|
+
* `ViolationDto`. The two share no key, and the route's OpenAPI slot holds
|
|
39306
|
+
* the wrong one — which is why the fields are narrowed from the wire in the
|
|
39307
|
+
* normalizer and why every one of them is optional (#13).
|
|
39308
|
+
*
|
|
39143
39309
|
* @example
|
|
39144
39310
|
* ```typescript
|
|
39145
39311
|
* const result = await client.conformance.check({
|
|
@@ -39151,7 +39317,8 @@ var ConformanceClient = class {
|
|
|
39151
39317
|
* console.log(result.totalViolations, 'violations');
|
|
39152
39318
|
* console.log(result.byKind.v1Inversion, 'subject/object inversions');
|
|
39153
39319
|
* for (const violation of result.violations) {
|
|
39154
|
-
* console.log(violation.
|
|
39320
|
+
* console.log(violation.kind, violation.subject, violation.feature, violation.object);
|
|
39321
|
+
* console.log(violation.suggestedFixes); // [{ action: 'swap' }]
|
|
39155
39322
|
* }
|
|
39156
39323
|
* }
|
|
39157
39324
|
* ```
|