@kortexya/reasoninglayer 1.23.0 → 1.25.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 +315 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +983 -48
- package/dist/index.d.ts +983 -48
- package/dist/index.js +315 -9
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
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 = "1.
|
|
8
|
+
var SDK_VERSION = "1.25.0";
|
|
9
9
|
function resolveConfig(config) {
|
|
10
10
|
if (!config.baseUrl) {
|
|
11
11
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -1875,6 +1875,23 @@ var Inference = class {
|
|
|
1875
1875
|
format: "json",
|
|
1876
1876
|
...params
|
|
1877
1877
|
});
|
|
1878
|
+
/**
|
|
1879
|
+
* @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, and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
|
|
1880
|
+
*
|
|
1881
|
+
* @tags inference
|
|
1882
|
+
* @name DeleteRule
|
|
1883
|
+
* @summary Delete a rule.
|
|
1884
|
+
* @request DELETE:/api/v1/inference/rules/{id}
|
|
1885
|
+
* @secure
|
|
1886
|
+
*/
|
|
1887
|
+
deleteRule = (id, query, params = {}) => this.http.request({
|
|
1888
|
+
path: `/api/v1/inference/rules/${id}`,
|
|
1889
|
+
method: "DELETE",
|
|
1890
|
+
query,
|
|
1891
|
+
secure: true,
|
|
1892
|
+
format: "json",
|
|
1893
|
+
...params
|
|
1894
|
+
});
|
|
1878
1895
|
/**
|
|
1879
1896
|
* @description Never writes to the KB — returns validated drafts for human review.
|
|
1880
1897
|
*
|
|
@@ -1997,16 +2014,16 @@ var Inference = class {
|
|
|
1997
2014
|
...params
|
|
1998
2015
|
});
|
|
1999
2016
|
/**
|
|
2000
|
-
* @description # Authorization Requires X-Tenant-Id header.
|
|
2017
|
+
* @description # Authorization Requires X-Tenant-Id header, and the path tenant must equal it. # The path segment Named `{id}` because `DELETE` and `PUT` on the same path address ONE RULE by term id (#231), and one segment cannot carry two names. Here it is the tenant — and a redundant one, since any value but the authenticated principal is refused.
|
|
2001
2018
|
*
|
|
2002
2019
|
* @tags inference
|
|
2003
2020
|
* @name GetRules
|
|
2004
2021
|
* @summary Get all rules (clauses with antecedents) for a tenant
|
|
2005
|
-
* @request GET:/api/v1/inference/rules/{
|
|
2022
|
+
* @request GET:/api/v1/inference/rules/{id}
|
|
2006
2023
|
* @secure
|
|
2007
2024
|
*/
|
|
2008
|
-
getRules = (
|
|
2009
|
-
path: `/api/v1/inference/rules/${
|
|
2025
|
+
getRules = (id, params = {}) => this.http.request({
|
|
2026
|
+
path: `/api/v1/inference/rules/${id}`,
|
|
2010
2027
|
method: "GET",
|
|
2011
2028
|
secure: true,
|
|
2012
2029
|
format: "json",
|
|
@@ -2064,6 +2081,24 @@ var Inference = class {
|
|
|
2064
2081
|
format: "json",
|
|
2065
2082
|
...params
|
|
2066
2083
|
});
|
|
2084
|
+
/**
|
|
2085
|
+
* @description # An edit addresses ONE clause "Edit the rule for X" is ambiguous, because the authoring UI's "add clause" writes a *second* rule with the same conclusion, OR-unioned with the first. The path names a single rule term — one disjunct — so a client cannot silently edit the wrong one. # The old rule is withdrawn, not amended Everything `DELETE` does happens, always with the retract disposition: an edit that leaves the pre-edit clause's conclusions standing is exactly the defect this route exists to fix. The replacement is created through the same code `POST /api/v1/inference/rules` runs, so creation's guards — #227's guard canonicalisation, #219's range restriction, #217's certainty distinction — hold for an edit too, and a rejected replacement leaves the rule base untouched because the build runs BEFORE the clause is de-indexed. The response carries `previous_rule_id` alongside the new rule: a rule's id is its conclusion term id, so an edit changes it by construction. When the replacement is content-addressed to the same id (identical conclusion under `OSFKB_RULE_STABLE_IDS=1`), the two are equal and the edit was applied in place — the outgoing clause's now-unused antecedents are still collected and deleted. # Authorization Identical to `DELETE`: the delete guard on the outgoing rule, `If-Match` against its conclusion, and audit capture.
|
|
2086
|
+
*
|
|
2087
|
+
* @tags inference
|
|
2088
|
+
* @name ReplaceRule
|
|
2089
|
+
* @summary Replace a rule.
|
|
2090
|
+
* @request PUT:/api/v1/inference/rules/{id}
|
|
2091
|
+
* @secure
|
|
2092
|
+
*/
|
|
2093
|
+
replaceRule = (id, data, params = {}) => this.http.request({
|
|
2094
|
+
path: `/api/v1/inference/rules/${id}`,
|
|
2095
|
+
method: "PUT",
|
|
2096
|
+
body: data,
|
|
2097
|
+
secure: true,
|
|
2098
|
+
type: "application/json",
|
|
2099
|
+
format: "json",
|
|
2100
|
+
...params
|
|
2101
|
+
});
|
|
2067
2102
|
/**
|
|
2068
2103
|
* @description In OSF/LIFE terms, the orchestrator pushes the conclusion gate and each antecedent gate toward the dual-weighted satisfaction objective `1 − ( w_D · K_D + w_K · K_K )` (paper eq. 4). Each call performs exactly one epoch over the supplied batch — the response carries the per-epoch metrics for that single epoch (multi-epoch aggregation is the caller's responsibility). # Authorization Requires `X-Tenant-Id` header.
|
|
2069
2104
|
*
|
|
@@ -8403,6 +8438,23 @@ var Functions = class {
|
|
|
8403
8438
|
constructor(http) {
|
|
8404
8439
|
this.http = http;
|
|
8405
8440
|
}
|
|
8441
|
+
/**
|
|
8442
|
+
* @description # The disposition is the caller's `?callers=refuse` (the default) refuses while anything calls the function and names every caller; `?callers=orphan` withdraws it anyway and reports the callers left naming something that no longer resolves. A withdrawal that silently orphans its callers is the state the missing route already produced. # Authorization Requires `X-Tenant-Id`. The function store is tenant-keyed, so another tenant's function is `404` rather than forbidden. Every request is captured by the audit middleware.
|
|
8443
|
+
*
|
|
8444
|
+
* @tags functions
|
|
8445
|
+
* @name DeleteFunction
|
|
8446
|
+
* @summary Withdraw a registered function.
|
|
8447
|
+
* @request DELETE:/api/v1/functions/{name}
|
|
8448
|
+
* @secure
|
|
8449
|
+
*/
|
|
8450
|
+
deleteFunction = (name, query, params = {}) => this.http.request({
|
|
8451
|
+
path: `/api/v1/functions/${name}`,
|
|
8452
|
+
method: "DELETE",
|
|
8453
|
+
query,
|
|
8454
|
+
secure: true,
|
|
8455
|
+
format: "json",
|
|
8456
|
+
...params
|
|
8457
|
+
});
|
|
8406
8458
|
/**
|
|
8407
8459
|
* @description Never writes to the KB — returns a validated draft for human review.
|
|
8408
8460
|
*
|
|
@@ -8473,6 +8525,24 @@ var Functions = class {
|
|
|
8473
8525
|
format: "json",
|
|
8474
8526
|
...params
|
|
8475
8527
|
});
|
|
8528
|
+
/**
|
|
8529
|
+
* @description # Why this is not `POST /functions/register` Registration already replaces by name — silently, reporting nothing about what it displaced. `PUT` is the operation that says so: it refuses when nothing is registered under the name (that is registration's job), and answers with the previous signature, the new one, whether the arity moved, and everything that calls the function. # The arity is the hazard A function's identity is its NAME, so a replacement keeps every caller's reference valid — nothing dangles. That is exactly why an arity change is dangerous rather than merely breaking: every call still resolves, and one passing the old number of arguments starts failing at evaluation time. Reported, not refused: the caller may be replacing the function precisely because its signature was wrong. # Authorization Identical to `DELETE`: tenant-keyed, plugin-owned functions refused, audited.
|
|
8530
|
+
*
|
|
8531
|
+
* @tags functions
|
|
8532
|
+
* @name ReplaceFunction
|
|
8533
|
+
* @summary Replace a registered function's definition.
|
|
8534
|
+
* @request PUT:/api/v1/functions/{name}
|
|
8535
|
+
* @secure
|
|
8536
|
+
*/
|
|
8537
|
+
replaceFunction = (name, data, params = {}) => this.http.request({
|
|
8538
|
+
path: `/api/v1/functions/${name}`,
|
|
8539
|
+
method: "PUT",
|
|
8540
|
+
body: data,
|
|
8541
|
+
secure: true,
|
|
8542
|
+
type: "application/json",
|
|
8543
|
+
format: "json",
|
|
8544
|
+
...params
|
|
8545
|
+
});
|
|
8476
8546
|
};
|
|
8477
8547
|
|
|
8478
8548
|
// src/api-spec/generated/WebhookActions.ts
|
|
@@ -14295,7 +14365,13 @@ function RuleEntryDtoFromApiToFront(dto) {
|
|
|
14295
14365
|
ruleId: dto.rule_id,
|
|
14296
14366
|
head: PsiTermDtoFromApiToFront(dto.head),
|
|
14297
14367
|
body: dto.body.map(PsiTermDtoFromApiToFront),
|
|
14298
|
-
certainty: dto.certainty ?? void 0
|
|
14368
|
+
certainty: dto.certainty ?? void 0,
|
|
14369
|
+
origin: dto.origin,
|
|
14370
|
+
withdrawable: dto.withdrawable,
|
|
14371
|
+
notWithdrawable: dto.not_withdrawable ? {
|
|
14372
|
+
code: dto.not_withdrawable.code,
|
|
14373
|
+
reason: dto.not_withdrawable.reason
|
|
14374
|
+
} : void 0
|
|
14299
14375
|
};
|
|
14300
14376
|
}
|
|
14301
14377
|
function GetRulesResponseFromApiToFront(dto) {
|
|
@@ -14304,6 +14380,35 @@ function GetRulesResponseFromApiToFront(dto) {
|
|
|
14304
14380
|
rules: dto.rules.map(RuleEntryDtoFromApiToFront)
|
|
14305
14381
|
};
|
|
14306
14382
|
}
|
|
14383
|
+
function RuleWithdrawalReportFromApiToFront(dto) {
|
|
14384
|
+
return {
|
|
14385
|
+
ruleId: dto.rule_id,
|
|
14386
|
+
termsDeleted: dto.terms_deleted,
|
|
14387
|
+
termsRetainedShared: dto.terms_retained_shared,
|
|
14388
|
+
derivationsRemoved: dto.derivations_removed,
|
|
14389
|
+
derivationsWeakened: dto.derivations_weakened,
|
|
14390
|
+
derivationsTruncated: dto.derivations_truncated,
|
|
14391
|
+
consequencesInvalidated: dto.consequences_invalidated,
|
|
14392
|
+
queuedEventsCancelled: dto.queued_events_cancelled
|
|
14393
|
+
};
|
|
14394
|
+
}
|
|
14395
|
+
function RuleCertificationDeltaFromApiToFront(dto) {
|
|
14396
|
+
return {
|
|
14397
|
+
terminatedBefore: dto.terminated_before,
|
|
14398
|
+
terminatesAfter: dto.terminates_after,
|
|
14399
|
+
orderIndependentBefore: dto.order_independent_before,
|
|
14400
|
+
orderIndependentAfter: dto.order_independent_after,
|
|
14401
|
+
regressed: dto.regressed
|
|
14402
|
+
};
|
|
14403
|
+
}
|
|
14404
|
+
function ReplaceRuleResponseFromApiToFront(dto) {
|
|
14405
|
+
return {
|
|
14406
|
+
previousRuleId: dto.previous_rule_id,
|
|
14407
|
+
term: PsiTermDtoFromApiToFront(dto.term),
|
|
14408
|
+
withdrawal: RuleWithdrawalReportFromApiToFront(dto.withdrawal),
|
|
14409
|
+
certification: RuleCertificationDeltaFromApiToFront(dto.certification)
|
|
14410
|
+
};
|
|
14411
|
+
}
|
|
14307
14412
|
function MetaSortsResponseFromApiToFront(dto) {
|
|
14308
14413
|
return {
|
|
14309
14414
|
absConstraint: dto.abs_constraint,
|
|
@@ -14791,6 +14896,89 @@ var InferenceClient = class {
|
|
|
14791
14896
|
const response = await this.api.getRules(this.tenantId);
|
|
14792
14897
|
return GetRulesResponseFromApiToFront(response.data);
|
|
14793
14898
|
}
|
|
14899
|
+
/**
|
|
14900
|
+
* Withdraw one rule from the knowledge base.
|
|
14901
|
+
*
|
|
14902
|
+
* @param ruleId - Term id of the rule (its conclusion), as returned by
|
|
14903
|
+
* {@link InferenceClient.addRule} or {@link InferenceClient.getRules}.
|
|
14904
|
+
* @param options - `derivations` decides what happens to the conclusions the
|
|
14905
|
+
* rule derived. Defaults to `'refuse'`.
|
|
14906
|
+
* @returns What the withdrawal removed, tier by tier.
|
|
14907
|
+
* @throws {ApiError} 400 if the id names a fact rather than a rule, or if the
|
|
14908
|
+
* rule still supports derivations under the default `'refuse'`; 403 for a
|
|
14909
|
+
* system, plugin-owned or bootstrap rule; 404 if no such rule exists.
|
|
14910
|
+
*
|
|
14911
|
+
* @remarks
|
|
14912
|
+
* A rule is not a row. Withdrawing one deletes its conclusion AND the
|
|
14913
|
+
* antecedent pattern, guard and variable terms it exclusively owns — a
|
|
14914
|
+
* conclusion-only delete would leave those patterns readable as ordinary
|
|
14915
|
+
* facts — while keeping every term the rest of the knowledge base still
|
|
14916
|
+
* holds.
|
|
14917
|
+
*
|
|
14918
|
+
* `'refuse'` (the default) refuses while the rule still proves materialized
|
|
14919
|
+
* conclusions and says how many; `'retract'` withdraws them with it. A delete
|
|
14920
|
+
* that silently drops derivations is as wrong as one that silently keeps
|
|
14921
|
+
* them, so neither is the unnamed default.
|
|
14922
|
+
*
|
|
14923
|
+
* @example
|
|
14924
|
+
* ```typescript
|
|
14925
|
+
* const report = await client.inference.deleteRule(ruleId, { derivations: 'retract' });
|
|
14926
|
+
* console.log(report.termsDeleted, report.derivationsRemoved);
|
|
14927
|
+
* ```
|
|
14928
|
+
*/
|
|
14929
|
+
async deleteRule(ruleId, options) {
|
|
14930
|
+
const response = await this.api.deleteRule(
|
|
14931
|
+
ruleId,
|
|
14932
|
+
options?.derivations === void 0 ? void 0 : { derivations: options.derivations }
|
|
14933
|
+
);
|
|
14934
|
+
return RuleWithdrawalReportFromApiToFront(response.data);
|
|
14935
|
+
}
|
|
14936
|
+
/**
|
|
14937
|
+
* Replace one rule with a new one.
|
|
14938
|
+
*
|
|
14939
|
+
* @param ruleId - Term id of the rule (its conclusion) to replace.
|
|
14940
|
+
* @param request - The replacement rule, in the same shape
|
|
14941
|
+
* {@link InferenceClient.addRule} takes.
|
|
14942
|
+
* @returns The replacement, the id it replaced, what the withdrawal removed,
|
|
14943
|
+
* and how the rule base's guarantees moved.
|
|
14944
|
+
* @throws {ApiError} 422 if the replacement is rejected by the authoring
|
|
14945
|
+
* guards — in which case the original rule is left live; 400/403/404 as for
|
|
14946
|
+
* {@link InferenceClient.deleteRule}.
|
|
14947
|
+
*
|
|
14948
|
+
* @remarks
|
|
14949
|
+
* A rule's id IS its conclusion term id, so an edit changes it by
|
|
14950
|
+
* construction. The response carries `previousRuleId` alongside the new
|
|
14951
|
+
* rule; a client holding the old id must adopt the new one.
|
|
14952
|
+
*
|
|
14953
|
+
* The path names ONE rule term — one disjunct. Two rules with the same
|
|
14954
|
+
* conclusion are OR-unioned, so "edit the rule for X" is ambiguous and this
|
|
14955
|
+
* addresses a single clause.
|
|
14956
|
+
*
|
|
14957
|
+
* @example
|
|
14958
|
+
* ```typescript
|
|
14959
|
+
* const result = await client.inference.replaceRule(ruleId, {
|
|
14960
|
+
* term: psi('retiree', { name: Var('N') }),
|
|
14961
|
+
* antecedents: [psi('person', { name: Var('N') })],
|
|
14962
|
+
* });
|
|
14963
|
+
* console.log(result.previousRuleId, '->', result.term.termId);
|
|
14964
|
+
* if (result.certification.regressed) {
|
|
14965
|
+
* console.warn('the edit weakened the rule base guarantees');
|
|
14966
|
+
* }
|
|
14967
|
+
* ```
|
|
14968
|
+
*/
|
|
14969
|
+
async replaceRule(ruleId, request) {
|
|
14970
|
+
const wireRequest = {
|
|
14971
|
+
term: convertTermArg(request.term),
|
|
14972
|
+
antecedents: request.antecedents?.map(convertTermArg),
|
|
14973
|
+
certainty: request.certainty,
|
|
14974
|
+
aggregator: request.aggregator
|
|
14975
|
+
};
|
|
14976
|
+
const response = await this.api.replaceRule(
|
|
14977
|
+
ruleId,
|
|
14978
|
+
AddRuleRequestFromFrontToApi(wireRequest)
|
|
14979
|
+
);
|
|
14980
|
+
return ReplaceRuleResponseFromApiToFront(response.data);
|
|
14981
|
+
}
|
|
14794
14982
|
/**
|
|
14795
14983
|
* Query for matching data by searching rules and facts backwards from a goal pattern.
|
|
14796
14984
|
*
|
|
@@ -15082,7 +15270,8 @@ function FindBySortRequestFromFrontToApi(model) {
|
|
|
15082
15270
|
return {
|
|
15083
15271
|
sort_id: model.sortId ?? void 0,
|
|
15084
15272
|
sort_name: model.sortName ?? void 0,
|
|
15085
|
-
filter: model.filter ?? void 0
|
|
15273
|
+
filter: model.filter ?? void 0,
|
|
15274
|
+
limit: model.limit ?? void 0
|
|
15086
15275
|
};
|
|
15087
15276
|
}
|
|
15088
15277
|
function OsfSearchRequestFromFrontToApi(model) {
|
|
@@ -17254,7 +17443,7 @@ var ConstraintsClient = class {
|
|
|
17254
17443
|
type: "application/json",
|
|
17255
17444
|
format: "json"
|
|
17256
17445
|
});
|
|
17257
|
-
return response.data;
|
|
17446
|
+
return ConstraintGraphResponseFromApiToFront(response.data);
|
|
17258
17447
|
}
|
|
17259
17448
|
// --- Session Management ---
|
|
17260
17449
|
/**
|
|
@@ -23329,9 +23518,11 @@ function StructuredIngestionStatsDtoFromApiToFront(dto) {
|
|
|
23329
23518
|
elapsedMs: dto.elapsed_ms,
|
|
23330
23519
|
entitiesCreated: dto.entities_created,
|
|
23331
23520
|
entitiesExtracted: dto.entities_extracted,
|
|
23521
|
+
recordsAvailable: dto.records_available,
|
|
23332
23522
|
recordsProcessed: dto.records_processed,
|
|
23333
23523
|
relationsCreated: dto.relations_created,
|
|
23334
23524
|
relationsDiscovered: dto.relations_discovered,
|
|
23525
|
+
rowsCollapsed: dto.rows_collapsed,
|
|
23335
23526
|
sortsCreated: dto.sorts_created,
|
|
23336
23527
|
tablesDiscovered: dto.tables_discovered,
|
|
23337
23528
|
termsCreated: dto.terms_created,
|
|
@@ -26188,6 +26379,34 @@ function DraftFunctionResponseFromApiToFront(dto) {
|
|
|
26188
26379
|
warnings: dto.warnings
|
|
26189
26380
|
};
|
|
26190
26381
|
}
|
|
26382
|
+
function FunctionCallerFromApiToFront(dto) {
|
|
26383
|
+
return {
|
|
26384
|
+
kind: dto.kind,
|
|
26385
|
+
name: dto.name,
|
|
26386
|
+
termId: dto.term_id ?? void 0
|
|
26387
|
+
};
|
|
26388
|
+
}
|
|
26389
|
+
function FunctionWithdrawalReportFromApiToFront(dto) {
|
|
26390
|
+
return {
|
|
26391
|
+
name: dto.name,
|
|
26392
|
+
functionId: dto.function_id,
|
|
26393
|
+
carrierDeleted: dto.carrier_deleted,
|
|
26394
|
+
deregistered: dto.deregistered,
|
|
26395
|
+
// The wire omits the field when nothing was orphaned; the SDK always
|
|
26396
|
+
// hands back an array, so a caller never has to guard the read.
|
|
26397
|
+
callersOrphaned: (dto.callers_orphaned ?? []).map(FunctionCallerFromApiToFront)
|
|
26398
|
+
};
|
|
26399
|
+
}
|
|
26400
|
+
function ReplaceFunctionResponseFromApiToFront(dto) {
|
|
26401
|
+
return {
|
|
26402
|
+
name: dto.name,
|
|
26403
|
+
functionId: dto.function_id,
|
|
26404
|
+
previous: FunctionSummaryDtoFromApiToFront(dto.previous),
|
|
26405
|
+
current: FunctionSummaryDtoFromApiToFront(dto.current),
|
|
26406
|
+
arityChanged: dto.arity_changed,
|
|
26407
|
+
callers: (dto.callers ?? []).map(FunctionCallerFromApiToFront)
|
|
26408
|
+
};
|
|
26409
|
+
}
|
|
26191
26410
|
|
|
26192
26411
|
// src/resources/functions.ts
|
|
26193
26412
|
var FunctionsClient = class {
|
|
@@ -26332,6 +26551,85 @@ var FunctionsClient = class {
|
|
|
26332
26551
|
const response = await this.api.listFunctions();
|
|
26333
26552
|
return ListFunctionsResponseFromApiToFront(response.data);
|
|
26334
26553
|
}
|
|
26554
|
+
/**
|
|
26555
|
+
* Withdraw a registered function.
|
|
26556
|
+
*
|
|
26557
|
+
* @param name - The registered function's name — its identity.
|
|
26558
|
+
* @param options - `callers` decides what happens to the things that call
|
|
26559
|
+
* it. Defaults to `'refuse'`.
|
|
26560
|
+
* @returns What the withdrawal removed, in each representation that held it.
|
|
26561
|
+
* @throws {ApiError} 400 if something still calls the function under the
|
|
26562
|
+
* default `'refuse'` (the body carries `code: 'function_has_callers'` and
|
|
26563
|
+
* the caller list); 403 for a plugin-contributed function; 404 if nothing
|
|
26564
|
+
* is registered under that name.
|
|
26565
|
+
*
|
|
26566
|
+
* @remarks
|
|
26567
|
+
* A function is carried twice — the durable `meta.function` carrier that is
|
|
26568
|
+
* the source of truth, and the evaluator's own registry used for dispatch
|
|
26569
|
+
* and recursive cross-calls — and the report names both, because forgetting
|
|
26570
|
+
* either leaves it half-alive: still evaluable, or back after a restart.
|
|
26571
|
+
*
|
|
26572
|
+
* `'refuse'` names every caller; `'orphan'` withdraws anyway and reports the
|
|
26573
|
+
* callers left naming something that no longer resolves.
|
|
26574
|
+
*
|
|
26575
|
+
* @example
|
|
26576
|
+
* ```typescript
|
|
26577
|
+
* const report = await client.functions.deleteFunction('scale', { callers: 'orphan' });
|
|
26578
|
+
* for (const orphan of report.callersOrphaned) {
|
|
26579
|
+
* console.warn(`${orphan.kind} ${orphan.name} now calls a function that is gone`);
|
|
26580
|
+
* }
|
|
26581
|
+
* ```
|
|
26582
|
+
*/
|
|
26583
|
+
async deleteFunction(name, options) {
|
|
26584
|
+
const response = await this.api.deleteFunction(
|
|
26585
|
+
name,
|
|
26586
|
+
options?.callers === void 0 ? void 0 : { callers: options.callers }
|
|
26587
|
+
);
|
|
26588
|
+
return FunctionWithdrawalReportFromApiToFront(response.data);
|
|
26589
|
+
}
|
|
26590
|
+
/**
|
|
26591
|
+
* Replace a registered function's definition.
|
|
26592
|
+
*
|
|
26593
|
+
* @param name - The registered function's name. Unchanged by the
|
|
26594
|
+
* replacement — the name IS the identity.
|
|
26595
|
+
* @param request - The replacement's arity and clauses.
|
|
26596
|
+
* @returns Both signatures, whether the arity moved, and everything that
|
|
26597
|
+
* calls the function.
|
|
26598
|
+
* @throws {ApiError} 400 if the replacement's clauses are rejected — in
|
|
26599
|
+
* which case the registration is left exactly as it was; 403 for a
|
|
26600
|
+
* plugin-contributed function; 404 if nothing is registered under that
|
|
26601
|
+
* name (creating one is {@link FunctionsClient.registerFunction}'s job).
|
|
26602
|
+
*
|
|
26603
|
+
* @remarks
|
|
26604
|
+
* `registerFunction` already replaces by name — silently, reporting nothing
|
|
26605
|
+
* about what it displaced. This is the operation that says so.
|
|
26606
|
+
*
|
|
26607
|
+
* A function's identity is its NAME, so a replacement keeps every caller's
|
|
26608
|
+
* reference valid: nothing dangles. That is exactly why an arity change is
|
|
26609
|
+
* the dangerous edit — every call still resolves, and one passing the old
|
|
26610
|
+
* argument count starts failing at evaluation time. `arityChanged` is
|
|
26611
|
+
* reported rather than refused, because a caller may be replacing the
|
|
26612
|
+
* function precisely because its signature was wrong.
|
|
26613
|
+
*
|
|
26614
|
+
* @example
|
|
26615
|
+
* ```typescript
|
|
26616
|
+
* const result = await client.functions.replaceFunction('scale', {
|
|
26617
|
+
* arity: 2,
|
|
26618
|
+
* clauses: [multiplyClause],
|
|
26619
|
+
* });
|
|
26620
|
+
* if (result.arityChanged) {
|
|
26621
|
+
* console.warn(`arity ${result.previous.arity} -> ${result.current.arity};`,
|
|
26622
|
+
* `${result.callers.length} caller(s) were written against the old one`);
|
|
26623
|
+
* }
|
|
26624
|
+
* ```
|
|
26625
|
+
*/
|
|
26626
|
+
async replaceFunction(name, request) {
|
|
26627
|
+
const response = await this.api.replaceFunction(name, {
|
|
26628
|
+
arity: request.arity,
|
|
26629
|
+
clauses: request.clauses.map(FunctionClauseDtoFromFrontToApi)
|
|
26630
|
+
});
|
|
26631
|
+
return ReplaceFunctionResponseFromApiToFront(response.data);
|
|
26632
|
+
}
|
|
26335
26633
|
/**
|
|
26336
26634
|
* Draft a user-defined function from a natural-language description.
|
|
26337
26635
|
*
|
|
@@ -27585,6 +27883,7 @@ function ClearTenantResponseFromApiToFront(dto) {
|
|
|
27585
27883
|
sortsDeleted: dto.sorts_deleted,
|
|
27586
27884
|
inferenceStateCleared: dto.inference_state_cleared,
|
|
27587
27885
|
cacheInvalidated: dto.cache_invalidated,
|
|
27886
|
+
vectorsDeleted: dto.vectors_deleted,
|
|
27588
27887
|
pluginInstallsDeleted: dto.plugin_installs_deleted
|
|
27589
27888
|
};
|
|
27590
27889
|
}
|
|
@@ -32749,7 +33048,14 @@ function BindingSummaryDtoFromApiToFront(dto) {
|
|
|
32749
33048
|
keyColumns: dto.key_columns,
|
|
32750
33049
|
sortId: dto.sort_id,
|
|
32751
33050
|
sourceId: dto.source_id,
|
|
32752
|
-
tableName: dto.table_name
|
|
33051
|
+
tableName: dto.table_name,
|
|
33052
|
+
keyProvenance: {
|
|
33053
|
+
source: dto.key_provenance.source,
|
|
33054
|
+
chosenBy: dto.key_provenance.chosen_by,
|
|
33055
|
+
explanation: dto.key_provenance.explanation,
|
|
33056
|
+
guaranteedUnique: dto.key_provenance.guaranteed_unique,
|
|
33057
|
+
durability: dto.key_provenance.durability
|
|
33058
|
+
}
|
|
32753
33059
|
};
|
|
32754
33060
|
}
|
|
32755
33061
|
function ListBindingsResponseFromApiToFront(dto) {
|