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