@aventara/core 1.0.0-rc.4 → 1.0.0-rc.9
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/CHANGELOG.md +157 -0
- package/ERRORS.md +2 -2
- package/README.md +80 -7
- package/dist/adapters/adapter-field.d.ts +8 -0
- package/dist/adapters/adapter-identifier.d.ts +9 -0
- package/dist/adapters/adapter-identifier.js +6 -1
- package/dist/adapters/adapter-operation.d.ts +12 -6
- package/dist/compiler/contract-compiler-diagnostic.guidance.js +2 -2
- package/dist/compiler/contract.compiler.js +26 -3
- package/dist/config/config.resolver.d.ts +2 -0
- package/dist/config/config.resolver.js +7 -2
- package/dist/config/config.validator.js +36 -12
- package/dist/config/exact-framework-config.d.ts +11 -1
- package/dist/config/framework-config.d.ts +14 -1
- package/dist/contracts/contract-canonicalizer.js +2 -0
- package/dist/contracts/contract.d.ts +15 -1
- package/dist/contracts/field.d.ts +17 -0
- package/dist/contracts/scalar-value-type.d.ts +3 -1
- package/dist/framework/contract-view.d.ts +9 -1
- package/dist/framework/framework-construction.error.d.ts +2 -1
- package/dist/framework/framework-construction.error.js +13 -1
- package/dist/framework/framework.d.ts +26 -5
- package/dist/framework/framework.factory.js +29 -10
- package/dist/framework/operation-facade.d.ts +59 -12
- package/dist/index.d.ts +8 -4
- package/dist/internal.d.ts +2 -2
- package/dist/internal.js +2 -0
- package/dist/operations/operation-arguments.d.ts +43 -27
- package/dist/operations/operation-call.d.ts +2 -2
- package/dist/operations/operation-result.d.ts +1 -1
- package/dist/policy/access-provider.interface.d.ts +36 -0
- package/dist/policy/access-provider.interface.js +1 -0
- package/dist/policy/access-provider.registry.d.ts +9 -0
- package/dist/policy/access-provider.registry.js +10 -0
- package/dist/policy/policy-admission.js +12 -3
- package/dist/policy/policy-after-update.runtime.js +5 -4
- package/dist/policy/policy-engine.d.ts +11 -4
- package/dist/policy/policy-nested-write.runtime.js +11 -7
- package/dist/policy/policy-read.runtime.d.ts +0 -2
- package/dist/policy/policy-read.runtime.js +18 -9
- package/dist/policy/policy-request.d.ts +7 -3
- package/dist/policy/policy-request.js +14 -3
- package/dist/policy/policy-session.d.ts +14 -4
- package/dist/policy/policy-session.js +12 -11
- package/dist/policy/policy-startup.validator.js +13 -15
- package/dist/policy/policy-write.runtime.d.ts +7 -0
- package/dist/policy/policy-write.runtime.js +23 -8
- package/dist/prebuilt/core-version.generated.d.ts +1 -1
- package/dist/prebuilt/core-version.generated.js +1 -1
- package/dist/prebuilt/prebuilt-changes.d.ts +28 -0
- package/dist/prebuilt/prebuilt-changes.js +65 -0
- package/dist/prebuilt/prebuilt-contracts.loader.js +11 -56
- package/dist/prebuilt/prebuilt-inputs.fingerprint.js +16 -1
- package/dist/protocol/absent-route.responder.d.ts +4 -4
- package/dist/protocol/http-request.decoder.d.ts +2 -2
- package/dist/protocol/http-request.reader.d.ts +2 -2
- package/dist/protocol/http-response.encoder.js +2 -2
- package/dist/protocol/protocol-headers.d.ts +3 -3
- package/dist/runtime/caller-data.copier.js +3 -4
- package/dist/runtime/computed-read-runtime.js +2 -7
- package/dist/runtime/context-executor.runtime.d.ts +2 -2
- package/dist/runtime/core-class.brand.d.ts +10 -0
- package/dist/runtime/core-class.brand.js +21 -0
- package/dist/runtime/create-requirement.js +1 -1
- package/dist/runtime/decimal.d.ts +14 -0
- package/dist/runtime/decimal.js +21 -0
- package/dist/runtime/diagnostics-reporter.d.ts +5 -5
- package/dist/runtime/diagnostics-reporter.js +13 -1
- package/dist/runtime/framework-error.js +9 -0
- package/dist/runtime/operation-request.d.ts +9 -9
- package/dist/runtime/operation-runtime.d.ts +8 -8
- package/dist/runtime/operation-runtime.js +30 -9
- package/dist/runtime/owned-execution.registry.d.ts +2 -2
- package/dist/runtime/readonly-value.d.ts +1 -1
- package/dist/runtime/readonly-value.js +2 -2
- package/dist/runtime/referential-action.d.ts +1 -1
- package/dist/runtime/scalar-runtime.js +4 -5
- package/dist/transactions/operation-arguments-encoder.js +8 -3
- package/dist/transactions/sql-statement.d.ts +2 -2
- package/dist/transactions/sql-statement.validator.js +2 -2
- package/dist/transactions/transaction-integrity-error.js +2 -0
- package/dist/transactions/transaction-plan-assembler.d.ts +11 -4
- package/dist/transactions/transaction-plan-assembler.js +17 -2
- package/dist/transactions/transaction-plan-validator.d.ts +5 -5
- package/dist/transactions/transaction-request.d.ts +8 -8
- package/dist/transactions/transaction-runtime.d.ts +2 -2
- package/dist/transactions/transaction-runtime.js +12 -7
- package/dist/transactions/transaction-slot-path-error.js +2 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AvRequestProtocol } from "../runtime/operation-request.js";
|
|
2
2
|
import type { AvTransportContext } from "../runtime/pipeline.js";
|
|
3
3
|
import type { AvState } from "../runtime/request-state.js";
|
|
4
4
|
type TransactionRequestBase = {
|
|
@@ -11,29 +11,29 @@ type TransactionRequestBase = {
|
|
|
11
11
|
readonly state?: AvState;
|
|
12
12
|
};
|
|
13
13
|
/** An in-process transaction request, run under the Application Contract. */
|
|
14
|
-
export type
|
|
14
|
+
export type AvApplicationTransactionRequest = TransactionRequestBase & {
|
|
15
15
|
readonly origin: "application";
|
|
16
16
|
readonly protocol?: never;
|
|
17
17
|
readonly transport?: never;
|
|
18
18
|
};
|
|
19
19
|
/** A remote transaction request, run under the Client Contract. */
|
|
20
|
-
export type
|
|
20
|
+
export type AvClientTransactionRequest = TransactionRequestBase & {
|
|
21
21
|
readonly origin: "client";
|
|
22
|
-
readonly protocol:
|
|
22
|
+
readonly protocol: AvRequestProtocol;
|
|
23
23
|
readonly transport?: AvTransportContext;
|
|
24
24
|
};
|
|
25
25
|
/** An AI agent's transaction request, run under the Agent Contract. */
|
|
26
|
-
export type
|
|
26
|
+
export type AvAgentTransactionRequest = TransactionRequestBase & {
|
|
27
27
|
readonly origin: "agent";
|
|
28
|
-
readonly protocol:
|
|
28
|
+
readonly protocol: AvRequestProtocol;
|
|
29
29
|
readonly transport?: AvTransportContext;
|
|
30
30
|
};
|
|
31
31
|
/** One transaction request, as `framework.executeTransaction` takes it. */
|
|
32
|
-
export type
|
|
32
|
+
export type AvTransactionRequest = AvApplicationTransactionRequest | AvClientTransactionRequest | AvAgentTransactionRequest;
|
|
33
33
|
/**
|
|
34
34
|
* The origin one plan operation runs under: its own layer's Contract, its own
|
|
35
35
|
* pipelines, and — for a client or agent step — the protocol identity it is
|
|
36
36
|
* accepted with.
|
|
37
37
|
*/
|
|
38
|
-
export type TransactionOperationOrigin = Pick<
|
|
38
|
+
export type TransactionOperationOrigin = Pick<AvApplicationTransactionRequest, "origin"> | Pick<AvClientTransactionRequest, "origin" | "protocol" | "transport"> | Pick<AvAgentTransactionRequest, "origin" | "protocol" | "transport">;
|
|
39
39
|
export {};
|
|
@@ -3,7 +3,7 @@ import { type PolicyCaller } from "../policy/policy-request.js";
|
|
|
3
3
|
import type { TransactionDiagnosticsChannel } from "../runtime/diagnostics-reporter.js";
|
|
4
4
|
import type { OperationPipelineDependencies, OperationRuntimeDependencies } from "../runtime/operation-runtime.js";
|
|
5
5
|
import type { PlanArguments } from "./transaction-plan-validator.js";
|
|
6
|
-
import type {
|
|
6
|
+
import type { AvTransactionRequest, TransactionOperationOrigin } from "./transaction-request.js";
|
|
7
7
|
import type { AvTransactionResponse } from "./transaction-response.js";
|
|
8
8
|
/**
|
|
9
9
|
* The transaction executor core. Like the operation executor it owns no
|
|
@@ -14,7 +14,7 @@ import type { AvTransactionResponse } from "./transaction-response.js";
|
|
|
14
14
|
* runner's mixed plans), and `planArguments` whether the steps' arguments are
|
|
15
15
|
* copied at the door; see `validateTransactionPlan`.
|
|
16
16
|
*/
|
|
17
|
-
export type FrameworkTransactionExecutor = (request:
|
|
17
|
+
export type FrameworkTransactionExecutor = (request: AvTransactionRequest, diagnostics: TransactionDiagnosticsChannel, origins: readonly TransactionOperationOrigin[] | undefined, planArguments: PlanArguments,
|
|
18
18
|
/** The principal an application run's steps run as (`{ as }`), when it names one. */
|
|
19
19
|
caller?: PolicyCaller) => Promise<AvTransactionResponse>;
|
|
20
20
|
/**
|
|
@@ -88,12 +88,15 @@ async function executeTransactionPlan(runtime, dependencies, request, plan, stat
|
|
|
88
88
|
if (known !== undefined) {
|
|
89
89
|
return known;
|
|
90
90
|
}
|
|
91
|
+
const settle = (policy) => {
|
|
92
|
+
const step = policy === undefined
|
|
93
|
+
? { ...operation.request, state }
|
|
94
|
+
: { ...operation.request, state, policy };
|
|
95
|
+
steps.set(operation, step);
|
|
96
|
+
return step;
|
|
97
|
+
};
|
|
91
98
|
const policy = openRequestPolicy(runtime.config.policy, runtime.contracts.core, { origin: operation.request.origin, state }, caller, adapter);
|
|
92
|
-
|
|
93
|
-
? { ...operation.request, state }
|
|
94
|
-
: { ...operation.request, state, policy };
|
|
95
|
-
steps.set(operation, step);
|
|
96
|
-
return step;
|
|
99
|
+
return policy instanceof Promise ? policy.then(settle) : settle(policy);
|
|
97
100
|
};
|
|
98
101
|
const admitted = [];
|
|
99
102
|
const standing = [];
|
|
@@ -106,7 +109,8 @@ async function executeTransactionPlan(runtime, dependencies, request, plan, stat
|
|
|
106
109
|
const report = diagnostics.operation(step.request, step.index);
|
|
107
110
|
let stepRequest;
|
|
108
111
|
try {
|
|
109
|
-
|
|
112
|
+
const opened = stateful(step);
|
|
113
|
+
stepRequest = opened instanceof Promise ? await opened : opened;
|
|
110
114
|
}
|
|
111
115
|
catch (error) {
|
|
112
116
|
report(error, "A3000");
|
|
@@ -140,7 +144,8 @@ async function executeTransactionPlan(runtime, dependencies, request, plan, stat
|
|
|
140
144
|
const runPlanOperation = async (operation, args, transactionPiped, executor, results, outer) => {
|
|
141
145
|
const report = diagnostics.operation(operation.request, operation.index);
|
|
142
146
|
const argumentsPath = planOperationArgumentsPath(operation.index);
|
|
143
|
-
const
|
|
147
|
+
const opened = stateful(operation);
|
|
148
|
+
const stepRequest = opened instanceof Promise ? await opened : opened;
|
|
144
149
|
try {
|
|
145
150
|
let live = standing[operation.index] ?? operation.references;
|
|
146
151
|
if (transactionPiped) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { brandCoreClass } from "../runtime/core-class.brand.js";
|
|
1
2
|
const TRANSACTION_SLOT_PATH_MESSAGES = {
|
|
2
3
|
"slot-prefix": "Transaction slot path does not name a member below the operation's arguments.",
|
|
3
4
|
"absent-member": "Transaction slot path names an absent member of the operation arguments.",
|
|
@@ -11,3 +12,4 @@ export class AvTransactionSlotPathError extends Error {
|
|
|
11
12
|
this.violation = violation;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
15
|
+
brandCoreClass(AvTransactionSlotPathError, "AvTransactionSlotPathError");
|