@aventara/core 1.0.0-rc.0 → 1.0.0-rc.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.
Files changed (242) hide show
  1. package/CHANGELOG.md +1140 -0
  2. package/README.md +224 -57
  3. package/dist/adapters/adapter-discovery-diagnostic.d.ts +4 -4
  4. package/dist/adapters/adapter-field.d.ts +11 -11
  5. package/dist/adapters/adapter-identifier.d.ts +6 -6
  6. package/dist/adapters/adapter-model.d.ts +9 -9
  7. package/dist/adapters/adapter-operation-executor.interface.d.ts +4 -4
  8. package/dist/adapters/adapter-operation.d.ts +3 -3
  9. package/dist/adapters/adapter-resource.d.ts +18 -9
  10. package/dist/adapters/adapter-sql-statement.d.ts +19 -0
  11. package/dist/adapters/adapter-transaction-executor.interface.d.ts +19 -0
  12. package/dist/adapters/adapter.interface.d.ts +49 -29
  13. package/dist/avz/avz-check.factory.d.ts +83 -0
  14. package/dist/avz/avz-check.factory.js +116 -0
  15. package/dist/avz/avz-check.registry.d.ts +35 -0
  16. package/dist/avz/avz-check.registry.js +9 -0
  17. package/dist/avz/avz.d.ts +203 -0
  18. package/dist/{json → avz}/avz.js +150 -8
  19. package/dist/{json → avz}/index.d.ts +2 -1
  20. package/dist/{json → avz}/json-shape.registry.d.ts +7 -7
  21. package/dist/{json → avz}/zod-issue.translator.d.ts +8 -2
  22. package/dist/{json → avz}/zod-issue.translator.js +7 -0
  23. package/dist/compiler/contract-compiler-diagnostic.d.ts +31 -5
  24. package/dist/compiler/contract.compiler.d.ts +18 -18
  25. package/dist/compiler/contract.compiler.js +548 -441
  26. package/dist/compiler/create-requirements.projector.d.ts +49 -0
  27. package/dist/compiler/create-requirements.projector.js +423 -0
  28. package/dist/compiler/field-validator.compiler.d.ts +47 -0
  29. package/dist/compiler/field-validator.compiler.js +238 -0
  30. package/dist/config/any-framework-config.d.ts +19 -12
  31. package/dist/config/config-diagnostic.d.ts +11 -4
  32. package/dist/config/config-layer.d.ts +15 -6
  33. package/dist/config/config.resolver.d.ts +74 -31
  34. package/dist/config/config.resolver.js +108 -44
  35. package/dist/config/config.validator.d.ts +7 -7
  36. package/dist/config/config.validator.js +581 -72
  37. package/dist/config/define-resource.d.ts +57 -0
  38. package/dist/config/define-resource.js +14 -0
  39. package/dist/config/effective-fields.d.ts +19 -23
  40. package/dist/config/entrypoint.normalizer.d.ts +1 -1
  41. package/dist/config/exact-framework-config.d.ts +280 -0
  42. package/dist/config/field-compute.resolver.d.ts +19 -0
  43. package/dist/config/field-compute.resolver.js +115 -0
  44. package/dist/config/field-pipeline-config.d.ts +47 -0
  45. package/dist/config/forced-operation.validator.d.ts +10 -0
  46. package/dist/config/forced-operation.validator.js +66 -0
  47. package/dist/config/framework-config.d.ts +110 -39
  48. package/dist/config/framework-exemptions-config.d.ts +91 -0
  49. package/dist/config/framework-exemptions-config.js +1 -0
  50. package/dist/config/framework-field-definition.d.ts +78 -0
  51. package/dist/config/framework-field-definition.js +28 -0
  52. package/dist/config/framework-resources-config.d.ts +116 -0
  53. package/dist/config/framework-resources-config.js +1 -0
  54. package/dist/config/pipeline-config.d.ts +56 -20
  55. package/dist/config/pipeline-tree.resolver.d.ts +79 -0
  56. package/dist/config/pipeline-tree.resolver.js +220 -0
  57. package/dist/config/stage-type.eraser.d.ts +65 -0
  58. package/dist/config/stage-type.eraser.js +1 -0
  59. package/dist/contracts/capability.d.ts +11 -11
  60. package/dist/contracts/client-contract-structure.validator.d.ts +323 -28
  61. package/dist/contracts/client-contract-structure.validator.js +152 -8
  62. package/dist/contracts/contract-canonicalizer.d.ts +19 -3
  63. package/dist/contracts/contract-canonicalizer.js +141 -28
  64. package/dist/contracts/contract-hash.d.ts +12 -7
  65. package/dist/contracts/contract-hash.js +3 -2
  66. package/dist/contracts/contract-limits.d.ts +4 -1
  67. package/dist/contracts/contract-limits.js +1 -0
  68. package/dist/contracts/contract-lookup.d.ts +5 -5
  69. package/dist/contracts/contract-protocol.d.ts +4 -4
  70. package/dist/contracts/contract.d.ts +24 -16
  71. package/dist/contracts/create-requirements.d.ts +35 -0
  72. package/dist/contracts/create-requirements.js +1 -0
  73. package/dist/contracts/enum-definition.d.ts +1 -1
  74. package/dist/contracts/field-check.d.ts +101 -0
  75. package/dist/contracts/field-check.js +1 -0
  76. package/dist/contracts/field.d.ts +52 -42
  77. package/dist/contracts/identifier.d.ts +4 -4
  78. package/dist/contracts/json-shape.d.ts +12 -1
  79. package/dist/contracts/lifecycle-trait.d.ts +2 -2
  80. package/dist/contracts/resource-operations.d.ts +28 -28
  81. package/dist/contracts/resource.d.ts +15 -9
  82. package/dist/contracts/scalar-value-type.d.ts +15 -15
  83. package/dist/contracts/scalar.d.ts +3 -3
  84. package/dist/contracts/transaction-capability.d.ts +1 -1
  85. package/dist/contracts/wire-scalar-format.d.ts +4 -4
  86. package/dist/framework/contract-view.d.ts +213 -147
  87. package/dist/framework/framework-construction.error.d.ts +10 -10
  88. package/dist/framework/framework-construction.error.js +2 -2
  89. package/dist/framework/framework.d.ts +47 -23
  90. package/dist/framework/framework.factory.d.ts +8 -6
  91. package/dist/framework/framework.factory.js +40 -20
  92. package/dist/framework/operation-facade.d.ts +123 -52
  93. package/dist/framework/operation-facade.js +9 -1
  94. package/dist/index.d.ts +55 -50
  95. package/dist/index.js +6 -6
  96. package/dist/internal.d.ts +15 -10
  97. package/dist/internal.js +3 -1
  98. package/dist/operations/operation-arguments.d.ts +267 -202
  99. package/dist/operations/operation-call.d.ts +27 -28
  100. package/dist/operations/operation-identity.d.ts +10 -10
  101. package/dist/operations/operation-result.d.ts +21 -21
  102. package/dist/operations/operation-validator-core.d.ts +6 -6
  103. package/dist/operations/operation-validator-core.js +13 -2
  104. package/dist/operations/operation-validator.d.ts +9 -9
  105. package/dist/operations/projection-scope.resolver.d.ts +6 -6
  106. package/dist/operations/structural-limits.walker.d.ts +6 -6
  107. package/dist/operations/structural-limits.walker.js +145 -0
  108. package/dist/operations/validation-code.d.ts +11 -6
  109. package/dist/operations/validation-code.js +4 -0
  110. package/dist/operations/write-scope.resolver.d.ts +6 -6
  111. package/dist/protocol/absent-route.responder.d.ts +13 -12
  112. package/dist/protocol/absent-route.responder.js +19 -19
  113. package/dist/protocol/contract-document.responder.d.ts +3 -3
  114. package/dist/protocol/contract-document.responder.js +2 -2
  115. package/dist/protocol/http-request.decoder.d.ts +17 -13
  116. package/dist/protocol/http-request.decoder.js +10 -10
  117. package/dist/protocol/http-request.reader.d.ts +3 -3
  118. package/dist/protocol/http-response.encoder.d.ts +4 -4
  119. package/dist/protocol/http-response.encoder.js +94 -55
  120. package/dist/protocol/http-status.table.d.ts +2 -2
  121. package/dist/protocol/operation-response.guard.d.ts +2 -2
  122. package/dist/protocol/protocol-surface.d.ts +4 -4
  123. package/dist/protocol/protocol.binder.d.ts +50 -27
  124. package/dist/protocol/protocol.binder.js +12 -9
  125. package/dist/protocol/protocol.handler.d.ts +22 -13
  126. package/dist/protocol/protocol.handler.js +44 -9
  127. package/dist/protocol/unmounted-route.error.d.ts +4 -4
  128. package/dist/protocol/unmounted-route.error.js +2 -2
  129. package/dist/runtime/caller-data.copier.d.ts +5 -5
  130. package/dist/runtime/caller-data.copier.js +13 -13
  131. package/dist/runtime/caller-data.door.d.ts +6 -6
  132. package/dist/runtime/caller-data.door.js +6 -4
  133. package/dist/runtime/computed-read-runtime.d.ts +7 -6
  134. package/dist/runtime/computed-read-runtime.js +61 -48
  135. package/dist/runtime/computed-value.error.d.ts +6 -6
  136. package/dist/runtime/computed-value.error.js +3 -3
  137. package/dist/runtime/context-executor.runtime.d.ts +59 -0
  138. package/dist/runtime/context-executor.runtime.js +275 -0
  139. package/dist/runtime/create-requirement.d.ts +10 -81
  140. package/dist/runtime/create-requirement.js +80 -57
  141. package/dist/runtime/decimal.d.ts +2 -2
  142. package/dist/runtime/decimal.js +1 -1
  143. package/dist/runtime/diagnostics-reporter.d.ts +53 -27
  144. package/dist/runtime/diagnostics-reporter.js +24 -0
  145. package/dist/runtime/error-boundary.d.ts +65 -8
  146. package/dist/runtime/error-boundary.js +45 -19
  147. package/dist/runtime/execution-options.d.ts +10 -2
  148. package/dist/runtime/field-check.evaluator.d.ts +29 -0
  149. package/dist/runtime/field-check.evaluator.js +521 -0
  150. package/dist/runtime/field-compute.d.ts +64 -0
  151. package/dist/runtime/field-compute.js +1 -0
  152. package/dist/runtime/field-stage.plan.d.ts +15 -0
  153. package/dist/runtime/field-stage.plan.js +27 -0
  154. package/dist/runtime/field-stage.runtime.d.ts +35 -0
  155. package/dist/runtime/field-stage.runtime.js +143 -0
  156. package/dist/runtime/field-validator.runtime.d.ts +11 -0
  157. package/dist/runtime/field-validator.runtime.js +87 -0
  158. package/dist/runtime/framework-error-class.table.d.ts +33 -0
  159. package/dist/runtime/framework-error-class.table.js +25 -0
  160. package/dist/runtime/framework-error.d.ts +68 -8
  161. package/dist/runtime/framework-error.factory.d.ts +4 -0
  162. package/dist/runtime/framework-error.factory.js +15 -0
  163. package/dist/runtime/framework-error.js +23 -2
  164. package/dist/runtime/interceptor-next.error.d.ts +5 -0
  165. package/dist/runtime/interceptor-next.error.js +6 -0
  166. package/dist/runtime/json-value.d.ts +3 -3
  167. package/dist/runtime/level-lifecycle.runtime.d.ts +25 -0
  168. package/dist/runtime/level-lifecycle.runtime.js +42 -0
  169. package/dist/runtime/misuse-reporter.d.ts +12 -12
  170. package/dist/runtime/mutation-planner.d.ts +19 -10
  171. package/dist/runtime/mutation-planner.js +54 -30
  172. package/dist/runtime/nested-write.walker.d.ts +32 -0
  173. package/dist/runtime/nested-write.walker.js +73 -0
  174. package/dist/runtime/operation-request.d.ts +33 -6
  175. package/dist/runtime/operation-response.d.ts +17 -17
  176. package/dist/runtime/operation-runtime.d.ts +113 -25
  177. package/dist/runtime/operation-runtime.js +395 -74
  178. package/dist/runtime/outcome-mapper.d.ts +16 -5
  179. package/dist/runtime/outcome-mapper.js +23 -6
  180. package/dist/runtime/output-validator.d.ts +10 -10
  181. package/dist/runtime/output-validator.js +3 -3
  182. package/dist/runtime/owned-execution.registry.d.ts +6 -6
  183. package/dist/runtime/pipe-output.validator.d.ts +33 -18
  184. package/dist/runtime/pipe-output.validator.js +12 -12
  185. package/dist/runtime/pipeline.d.ts +196 -34
  186. package/dist/runtime/readonly-value.d.ts +32 -0
  187. package/dist/runtime/readonly-value.js +141 -0
  188. package/dist/runtime/request-envelope.validator.d.ts +3 -3
  189. package/dist/runtime/request-envelope.validator.js +12 -7
  190. package/dist/runtime/request-id.d.ts +1 -1
  191. package/dist/runtime/request-state.d.ts +14 -0
  192. package/dist/runtime/request-state.js +1 -0
  193. package/dist/runtime/request-state.resolver.d.ts +12 -0
  194. package/dist/runtime/request-state.resolver.js +20 -0
  195. package/dist/runtime/scalar-runtime.d.ts +31 -16
  196. package/dist/runtime/scalar-runtime.js +16 -18
  197. package/dist/transactions/deferred-operation.d.ts +35 -20
  198. package/dist/transactions/operation-arguments-encoder.d.ts +3 -3
  199. package/dist/transactions/operation-arguments-encoder.js +2 -2
  200. package/dist/transactions/sql-statement.d.ts +77 -0
  201. package/dist/transactions/sql-statement.js +47 -0
  202. package/dist/transactions/sql-statement.validator.d.ts +44 -0
  203. package/dist/transactions/sql-statement.validator.js +134 -0
  204. package/dist/transactions/transaction-envelope.d.ts +4 -4
  205. package/dist/transactions/transaction-integrity-error.d.ts +6 -6
  206. package/dist/transactions/transaction-integrity-error.js +5 -2
  207. package/dist/transactions/transaction-plan-assembler.d.ts +21 -11
  208. package/dist/transactions/transaction-plan-assembler.js +148 -34
  209. package/dist/transactions/transaction-plan-validator.d.ts +29 -20
  210. package/dist/transactions/transaction-plan-validator.js +70 -38
  211. package/dist/transactions/transaction-reference-collector.d.ts +5 -5
  212. package/dist/transactions/transaction-reference-resolver.d.ts +19 -2
  213. package/dist/transactions/transaction-reference-resolver.js +26 -14
  214. package/dist/transactions/transaction-reference-validator.d.ts +34 -4
  215. package/dist/transactions/transaction-reference-validator.js +58 -26
  216. package/dist/transactions/transaction-reference.d.ts +13 -13
  217. package/dist/transactions/transaction-request.d.ts +18 -5
  218. package/dist/transactions/transaction-response.d.ts +6 -6
  219. package/dist/transactions/transaction-runtime.d.ts +8 -7
  220. package/dist/transactions/transaction-runtime.js +166 -50
  221. package/dist/transactions/transaction-settlement.runtime.d.ts +51 -0
  222. package/dist/transactions/transaction-settlement.runtime.js +120 -0
  223. package/dist/transactions/transaction-slot-path-error.d.ts +4 -4
  224. package/dist/transactions/transaction-slot-path-error.js +2 -2
  225. package/dist/transactions/transaction-slot-writer.js +2 -2
  226. package/dist/transactions/transaction-stage.runtime.d.ts +81 -0
  227. package/dist/transactions/transaction-stage.runtime.js +123 -0
  228. package/package.json +6 -5
  229. package/src/runtime/field-check.evaluator.ts +720 -0
  230. package/dist/config/define-fields.d.ts +0 -42
  231. package/dist/config/define-fields.js +0 -3
  232. package/dist/config/framework-behaviors-config.d.ts +0 -30
  233. package/dist/config/framework-fields-config.d.ts +0 -42
  234. package/dist/config/framework-restrictions-config.d.ts +0 -142
  235. package/dist/json/avz.d.ts +0 -96
  236. package/dist/runtime/field-behavior.d.ts +0 -48
  237. /package/dist/{config/framework-behaviors-config.js → adapters/adapter-sql-statement.js} +0 -0
  238. /package/dist/{config/framework-fields-config.js → adapters/adapter-transaction-executor.interface.js} +0 -0
  239. /package/dist/{json → avz}/index.js +0 -0
  240. /package/dist/{json → avz}/json-shape.registry.js +0 -0
  241. /package/dist/config/{framework-restrictions-config.js → exact-framework-config.js} +0 -0
  242. /package/dist/{runtime/field-behavior.js → config/field-pipeline-config.js} +0 -0
@@ -1,28 +1,31 @@
1
1
  import { compileContracts } from "../compiler/contract.compiler.js";
2
2
  import { resolveFrameworkConfig } from "../config/config.resolver.js";
3
3
  import { validateFrameworkConfig } from "../config/config.validator.js";
4
+ import { validateForcedOperations } from "../config/forced-operation.validator.js";
4
5
  import { AVENTARA_PROTOCOL_VERSION } from "../contracts/contract-protocol.js";
5
6
  import { copyEnvelopeAtDoor, refuseCallerData, } from "../runtime/caller-data.door.js";
6
7
  import { createDiagnosticsReporter, createTransactionDiagnosticsChannel, recordDiagnosticsSink, } from "../runtime/diagnostics-reporter.js";
7
8
  import { createMisuseReporter, } from "../runtime/misuse-reporter.js";
8
9
  import { internalFailure, operationFailure, } from "../runtime/operation-response.js";
9
- import { createOperationRuntime } from "../runtime/operation-runtime.js";
10
+ import { createOperationRuntime, createPipelineDependencies, } from "../runtime/operation-runtime.js";
10
11
  import { recordOwnedExecution } from "../runtime/owned-execution.registry.js";
11
12
  import { validateOperationEnvelope, validateTransactionEnvelope, } from "../runtime/request-envelope.validator.js";
12
13
  import { requestIdOf } from "../runtime/request-id.js";
14
+ import { stateOptionOf } from "../runtime/request-state.resolver.js";
13
15
  import { createTransactionPlanAssembler } from "../transactions/transaction-plan-assembler.js";
14
16
  import { createTransactionRuntime } from "../transactions/transaction-runtime.js";
15
- import { FrameworkConstructionError } from "./framework-construction.error.js";
16
- import { createOperationFacade, createOperationTree, } from "./operation-facade.js";
17
+ import { AvConstructionError } from "./framework-construction.error.js";
18
+ import { createOperationFacade, createOperationTree, settleOperation, } from "./operation-facade.js";
19
+ const APPLICATION_SQL_BUILDER = "$sql";
17
20
  export async function createFramework(config) {
18
21
  const configDiagnostics = validateFrameworkConfig(config);
19
22
  if (configDiagnostics.length > 0) {
20
- throw new FrameworkConstructionError("configuration", configDiagnostics);
23
+ throw new AvConstructionError("configuration", configDiagnostics);
21
24
  }
22
25
  const model = config.adapter.model;
23
26
  if (model.transactions === "interactive" &&
24
27
  typeof config.adapter.transaction !== "function") {
25
- throw new FrameworkConstructionError("discovery", [
28
+ throw new AvConstructionError("discovery", [
26
29
  {
27
30
  code: "DISCOVERY_TRANSACTION_CAPABILITY_MISMATCH",
28
31
  path: "adapter.transactions",
@@ -33,18 +36,20 @@ export async function createFramework(config) {
33
36
  const resolvedConfig = resolveFrameworkConfig(config);
34
37
  const compilation = await compileContracts(model, resolvedConfig);
35
38
  if (!compilation.ok) {
36
- throw new FrameworkConstructionError("contract-compilation", compilation.diagnostics);
39
+ throw new AvConstructionError("contract-compilation", compilation.diagnostics);
37
40
  }
38
- const execute = createOperationRuntime({
39
- adapter: config.adapter,
40
- contracts: compilation.contracts,
41
- config: resolvedConfig,
42
- });
43
- const executeTransaction = createTransactionRuntime({
41
+ const forcing = validateForcedOperations(config, compilation.contracts);
42
+ if (forcing.length > 0) {
43
+ throw new AvConstructionError("configuration", forcing);
44
+ }
45
+ const runtimeDependencies = {
44
46
  adapter: config.adapter,
45
47
  contracts: compilation.contracts,
46
48
  config: resolvedConfig,
47
- });
49
+ };
50
+ const pipelineDependencies = createPipelineDependencies(runtimeDependencies, model);
51
+ const execute = createOperationRuntime(runtimeDependencies, pipelineDependencies);
52
+ const executeTransaction = createTransactionRuntime(runtimeDependencies, pipelineDependencies);
48
53
  const misuse = createMisuseReporter(resolvedConfig.misuse);
49
54
  const executeOperation = (request) => executeTotally(execute, request, resolvedConfig.diagnostics, "caller");
50
55
  const protocol = {
@@ -53,28 +58,34 @@ export async function createFramework(config) {
53
58
  };
54
59
  const assembler = createTransactionPlanAssembler(compilation.contracts, protocol, misuse);
55
60
  const framework = {
56
- entrypoint: resolvedConfig.entrypoint,
61
+ api: resolvedConfig.api,
62
+ mcp: resolvedConfig.mcp,
57
63
  contracts: compilation.contracts,
58
- application: createOperationFacade(model, (resource, identity, args, requestId) => ({
64
+ application: createOperationFacade(model, (resource, identity, args, requestId, state) => ({
59
65
  ...identity,
60
66
  origin: "application",
61
67
  requestId,
68
+ ...(state === undefined ? {} : { state }),
62
69
  resource,
63
70
  arguments: args,
64
71
  }), executeOperation),
65
- client: createOperationFacade(model, (resource, identity, args, requestId) => ({
72
+ client: createOperationFacade(model, (resource, identity, args, requestId, state) => ({
66
73
  ...identity,
67
74
  origin: "client",
68
75
  protocol,
69
76
  requestId,
77
+ ...(state === undefined ? {} : { state }),
70
78
  resource,
71
79
  arguments: args,
72
80
  }), executeOperation),
73
- appTx: createOperationTree(model, (resource, identity) => (args) => assembler.defer("application", resource, identity, args === undefined ? {} : args)),
81
+ appTx: Object.freeze({
82
+ ...createOperationTree(model, (resource, identity) => (args) => assembler.defer("application", resource, identity, args === undefined ? {} : args)),
83
+ [APPLICATION_SQL_BUILDER]: (strings, ...values) => assembler.deferSql(strings, values),
84
+ }),
74
85
  clientTx: createOperationTree(model, (resource, identity) => (args) => assembler.defer("client", resource, identity, args === undefined ? {} : args)),
75
86
  execute: (request) => executeRequestTotally(execute, request, resolvedConfig.diagnostics, misuse),
76
87
  executeTransaction: (request) => executeTransactionRequestTotally(executeTransaction, request, resolvedConfig.diagnostics, misuse),
77
- transaction: ((operations, options) => runTransactionTotally(executeTransaction, assembler, operations, requestIdOf(options), resolvedConfig.diagnostics)),
88
+ transaction: (async (operations, options) => settleOperation(await runTransactionTotally(executeTransaction, assembler, operations, requestIdOf(options), stateOptionOf(options), resolvedConfig.diagnostics))),
78
89
  };
79
90
  recordDiagnosticsSink(framework, resolvedConfig.diagnostics);
80
91
  recordOwnedExecution(framework, {
@@ -138,7 +149,7 @@ async function executeTransactionTotally(execute, request, diagnostics, origins,
138
149
  return internalFailure();
139
150
  }
140
151
  }
141
- async function runTransactionTotally(execute, assembler, operations, requestId, diagnostics) {
152
+ async function runTransactionTotally(execute, assembler, operations, requestId, state, diagnostics) {
142
153
  let assembled;
143
154
  try {
144
155
  assembled = await assembler.assemble(operations);
@@ -154,5 +165,14 @@ async function runTransactionTotally(execute, assembler, operations, requestId,
154
165
  if (!assembled.ok) {
155
166
  return assembled.response;
156
167
  }
157
- return executeTransactionTotally(execute, { origin: "application", requestId, plan: assembled.plan }, diagnostics, assembled.origins, { source: "owned", refused: assembled.refused });
168
+ return executeTransactionTotally(execute, {
169
+ origin: "application",
170
+ requestId,
171
+ ...(state === undefined ? {} : { state }),
172
+ plan: assembled.plan,
173
+ }, diagnostics, assembled.origins, {
174
+ source: "owned",
175
+ refused: assembled.refused,
176
+ statements: assembled.statements,
177
+ });
158
178
  }
@@ -1,72 +1,137 @@
1
- import type { AdapterModel } from "../adapters/adapter-model.js";
2
- import type { Contract } from "../contracts/contract.js";
3
- import type { ApplicationScalarForms, WireScalarForms } from "../contracts/scalar-value-type.js";
4
- import type { ResourceKey } from "../operations/operation-arguments.js";
5
- import type { DeferredOperationCall, OperationCall, OperationGrammar } from "../operations/operation-call.js";
6
- import type { OperationIdentity } from "../operations/operation-identity.js";
7
- import type { ExecutionOptions } from "../runtime/execution-options.js";
1
+ import type { AvAdapterModel } from "../adapters/adapter-model.js";
2
+ import type { AvContract } from "../contracts/contract.js";
3
+ import type { AvApplicationScalarForms, AvWireScalarForms } from "../contracts/scalar-value-type.js";
4
+ import type { AvResourceKey } from "../operations/operation-arguments.js";
5
+ import type { AvDeferredOperationCall, AvOperationCall, AvOperationGrammar } from "../operations/operation-call.js";
6
+ import type { AvOperationIdentity } from "../operations/operation-identity.js";
7
+ import type { AvExecutionOptions } from "../runtime/execution-options.js";
8
8
  import type { FrameworkOperationRequest } from "../runtime/operation-request.js";
9
- import type { OperationResponse } from "../runtime/operation-response.js";
10
- import type { ApplicationContractView, ClientContractView } from "./contract-view.js";
9
+ import type { AvOperationResponse } from "../runtime/operation-response.js";
10
+ import type { AvState } from "../runtime/request-state.js";
11
+ import type { SqlStatementBuilder } from "../transactions/sql-statement.js";
12
+ import type { AvTransactionResponse } from "../transactions/transaction-response.js";
13
+ import type { AvContractApplicationView, ClientContractView } from "./contract-view.js";
11
14
  /**
12
- * A model whose Resource names are not literal — the abstract `AdapterModel` behind
13
- * the default `Framework` — has no Contract to type a call against, so a surface over
15
+ * A model whose Resource names are not literal — the abstract `AvAdapterModel` behind
16
+ * the default `AvFramework` — has no Contract to type a call against, so a surface over
14
17
  * it is typed as the opaque object it is, and such a caller uses `execute`.
15
18
  */
16
19
  type OpaqueSurface = {
17
20
  readonly [resource: string]: unknown;
18
21
  };
22
+ /** The four typed surfaces of an `AvFramework`, named by the member that holds each. */
23
+ type FacadeSurface = "application" | "client" | "appTx" | "clientTx";
19
24
  /**
20
- * `framework.application`: one call per operation the Application Contract's
21
- * view advertises, its arguments in the application forms.
25
+ * One variant on a surface: a direct call (application or wire forms), or a
26
+ * deferred one for a transaction (`appTx`, `clientTx`).
22
27
  */
23
- export type ApplicationOperations<M extends AdapterModel, Cfg> = ApplicationFacade<ApplicationContractView<M, Cfg>>;
24
- type ApplicationFacade<C> = C extends Contract ? string extends ResourceKey<C> ? OpaqueSurface : {
25
- readonly [R in ResourceKey<C>]: {
26
- readonly [F in keyof OperationGrammar<C>[R]]: {
27
- readonly [V in keyof OperationGrammar<C>[R][F]]: OperationCall<C, R, OperationGrammar<C>[R][F][V] & OperationIdentity, ApplicationScalarForms, ApplicationScalarForms, "response", ExecutionOptions>;
28
- };
29
- };
30
- } : never;
28
+ type SurfaceCall<C extends AvContract, R extends AvResourceKey<C>, I extends AvOperationIdentity, S extends FacadeSurface> = S extends "application" ? AvOperationCall<C, R, I, AvApplicationScalarForms, AvApplicationScalarForms, AvExecutionOptions> : S extends "client" ? AvOperationCall<C, R, I, AvWireScalarForms, AvApplicationScalarForms, AvExecutionOptions> : S extends "appTx" ? AvDeferredOperationCall<C, R, I, AvApplicationScalarForms, AvApplicationScalarForms, "application"> : AvDeferredOperationCall<C, R, I, AvWireScalarForms, AvApplicationScalarForms, "client">;
29
+ /** The families view `C` advertises on Resource `R`. */
30
+ type FamilyKey<C extends AvContract, R extends AvResourceKey<C>> = keyof AvOperationGrammar<C>[R];
31
+ /** One family node of surface `S`; the public names below are its four instances. */
32
+ type FamilyNode<C extends AvContract, S extends FacadeSurface, R extends AvResourceKey<C>, F extends FamilyKey<C, R>> = {
33
+ readonly [V in keyof AvOperationGrammar<C>[R][F]]: SurfaceCall<C, R, AvOperationGrammar<C>[R][F][V] & AvOperationIdentity, S>;
34
+ };
35
+ /** `framework.application.<Resource>.<family>`: one direct call per variant, application forms. */
36
+ export type AvApplicationFamilyFacade<in out C extends AvContract, in out R extends AvResourceKey<C>, in out F extends FamilyKey<C, R>> = FamilyNode<C, "application", R, F>;
37
+ /** `framework.client.<Resource>.<family>`: one direct call per variant, wire forms. */
38
+ export type AvClientFamilyFacade<in out C extends AvContract, in out R extends AvResourceKey<C>, in out F extends FamilyKey<C, R>> = FamilyNode<C, "client", R, F>;
39
+ /** `framework.appTx.<Resource>.<family>`: one deferred operation per variant. */
40
+ export type AvAppTxFamilyFacade<in out C extends AvContract, in out R extends AvResourceKey<C>, in out F extends FamilyKey<C, R>> = FamilyNode<C, "appTx", R, F>;
41
+ /** `framework.clientTx.<Resource>.<family>`: one deferred operation per variant. */
42
+ export type AvClientTxFamilyFacade<in out C extends AvContract, in out R extends AvResourceKey<C>, in out F extends FamilyKey<C, R>> = FamilyNode<C, "clientTx", R, F>;
43
+ /** `framework.application.<Resource>`: one {@link AvApplicationFamilyFacade} per family. */
44
+ export type AvApplicationResourceFacade<in out C extends AvContract, in out R extends AvResourceKey<C>> = {
45
+ readonly [F in FamilyKey<C, R>]: AvApplicationFamilyFacade<C, R, F>;
46
+ };
47
+ /** `framework.client.<Resource>`: one {@link AvClientFamilyFacade} per family. */
48
+ export type AvClientResourceFacade<in out C extends AvContract, in out R extends AvResourceKey<C>> = {
49
+ readonly [F in FamilyKey<C, R>]: AvClientFamilyFacade<C, R, F>;
50
+ };
51
+ /** `framework.appTx.<Resource>`: one {@link AvAppTxFamilyFacade} per family. */
52
+ export type AvAppTxResourceFacade<in out C extends AvContract, in out R extends AvResourceKey<C>> = {
53
+ readonly [F in FamilyKey<C, R>]: AvAppTxFamilyFacade<C, R, F>;
54
+ };
55
+ /** `framework.clientTx.<Resource>`: one {@link AvClientTxFamilyFacade} per family. */
56
+ export type AvClientTxResourceFacade<in out C extends AvContract, in out R extends AvResourceKey<C>> = {
57
+ readonly [F in FamilyKey<C, R>]: AvClientTxFamilyFacade<C, R, F>;
58
+ };
31
59
  /**
32
- * `framework.client`: the same over the Client Contract's view, its arguments in
33
- * the wire forms.
60
+ * `framework.application`: one {@link AvApplicationResourceFacade} per Resource
61
+ * of `C`, the Application Contract's view.
34
62
  */
35
- export type ClientOperations<M extends AdapterModel, Cfg> = ClientFacade<ClientContractView<M, Cfg>>;
36
- type ClientFacade<C> = C extends Contract ? string extends ResourceKey<C> ? OpaqueSurface : {
37
- readonly [R in ResourceKey<C>]: {
38
- readonly [F in keyof OperationGrammar<C>[R]]: {
39
- readonly [V in keyof OperationGrammar<C>[R][F]]: OperationCall<C, R, OperationGrammar<C>[R][F][V] & OperationIdentity, WireScalarForms, ApplicationScalarForms, "response", ExecutionOptions>;
40
- };
41
- };
42
- } : never;
63
+ export type AvApplicationFacade<C extends AvContract> = {
64
+ readonly [R in AvResourceKey<C>]: AvApplicationResourceFacade<C, R>;
65
+ };
43
66
  /**
44
- * `framework.appTx`: one deferred operation per operation the Application
45
- * Contract's view advertises — application rules, application forms.
67
+ * `framework.client`: one {@link AvClientResourceFacade} per Resource of `C`,
68
+ * the Client Contract's view.
46
69
  */
47
- export type ApplicationTransactionBuilders<M extends AdapterModel, Cfg> = ApplicationDeferredSurface<ApplicationContractView<M, Cfg>>;
48
- type ApplicationDeferredSurface<C> = C extends Contract ? string extends ResourceKey<C> ? OpaqueSurface : {
49
- readonly [R in ResourceKey<C>]: {
50
- readonly [F in keyof OperationGrammar<C>[R]]: {
51
- readonly [V in keyof OperationGrammar<C>[R][F]]: DeferredOperationCall<C, R, OperationGrammar<C>[R][F][V] & OperationIdentity, ApplicationScalarForms, ApplicationScalarForms>;
70
+ export type AvClientFacade<C extends AvContract> = {
71
+ readonly [R in AvResourceKey<C>]: AvClientResourceFacade<C, R>;
72
+ };
73
+ /** `framework.appTx.$sql`: the developer SQL step only an application transaction has. */
74
+ type ApplicationSqlStep = {
75
+ /**
76
+ * A developer SQL step, written only as a tagged template:
77
+ * ``framework.appTx.$sql<Row>`select … ${value}` ``. Every interpolated value
78
+ * is bound as a parameter. See {@link SqlStatementBuilder}.
79
+ */
80
+ readonly $sql: SqlStatementBuilder;
81
+ };
82
+ /**
83
+ * `framework.appTx`: one {@link AvAppTxResourceFacade} per Resource of `C`, the
84
+ * Application Contract's view, and `$sql`.
85
+ */
86
+ export type AvAppTxFacade<C extends AvContract> = {
87
+ readonly [R in AvResourceKey<C>]: AvAppTxResourceFacade<C, R>;
88
+ } & ApplicationSqlStep;
89
+ /**
90
+ * `framework.clientTx`: one {@link AvClientTxResourceFacade} per Resource of
91
+ * `C`, the Client Contract's view.
92
+ */
93
+ export type AvClientTxFacade<C extends AvContract> = {
94
+ readonly [R in AvResourceKey<C>]: AvClientTxResourceFacade<C, R>;
95
+ };
96
+ type ApplicationSurface<C> = C extends AvContract ? string extends AvResourceKey<C> ? OpaqueSurface : AvApplicationFacade<C> : never;
97
+ type ClientSurface<C> = C extends AvContract ? string extends AvResourceKey<C> ? OpaqueSurface : AvClientFacade<C> : never;
98
+ type ApplicationDeferredSurface<C> = C extends AvContract ? string extends AvResourceKey<C> ? OpaqueSurface & ApplicationSqlStep : AvAppTxFacade<C> : never;
99
+ type ClientDeferredSurface<C> = C extends AvContract ? string extends AvResourceKey<C> ? OpaqueSurface : AvClientTxFacade<C> : never;
100
+ /** `framework.application`'s type: {@link AvApplicationFacade}, or opaque. */
101
+ export type ApplicationOperations<M extends AvAdapterModel, Cfg> = ApplicationSurface<AvContractApplicationView<M, Cfg>>;
102
+ /** `framework.client`'s type: {@link AvClientFacade}, or opaque. */
103
+ export type ClientOperations<M extends AvAdapterModel, Cfg> = ClientSurface<ClientContractView<M, Cfg>>;
104
+ /** `framework.appTx`'s type: {@link AvAppTxFacade}, or opaque with `$sql`. */
105
+ export type ApplicationTransactionBuilders<M extends AvAdapterModel, Cfg> = ApplicationDeferredSurface<AvContractApplicationView<M, Cfg>>;
106
+ /** `framework.clientTx`'s type: {@link AvClientTxFacade}, or opaque. */
107
+ export type ClientTransactionBuilders<M extends AvAdapterModel, Cfg> = ClientDeferredSurface<ClientContractView<M, Cfg>>;
108
+ /**
109
+ * The Resources of a pipeline ctx: `ctx.<Resource>.<family>.<variant>(args)`,
110
+ * application-origin, resolving the operation's data.
111
+ */
112
+ export type AvContextOperations<M extends AvAdapterModel> = ContextFacade<AvContractApplicationView<M>>;
113
+ type ContextFacade<C> = C extends AvContract ? string extends AvResourceKey<C> ? unknown : {
114
+ readonly [R in AvResourceKey<C>]: {
115
+ readonly [F in keyof AvOperationGrammar<C>[R]]: {
116
+ readonly [V in keyof AvOperationGrammar<C>[R][F]]: AvOperationCall<C, R, AvOperationGrammar<C>[R][F][V] & AvOperationIdentity, AvApplicationScalarForms, AvApplicationScalarForms, never>;
52
117
  };
53
118
  };
54
119
  } : never;
55
120
  /**
56
- * `framework.clientTx`: the same over the Client Contract's view — ClientContract
57
- * rules, wire forms.
121
+ * The Resources of compute's read-only ctx: `ctx.<Resource>.find.<variant>(args)`
122
+ * only (`find.count` included).
58
123
  */
59
- export type ClientTransactionBuilders<M extends AdapterModel, Cfg> = ClientDeferredSurface<ClientContractView<M, Cfg>>;
60
- type ClientDeferredSurface<C> = C extends Contract ? string extends ResourceKey<C> ? OpaqueSurface : {
61
- readonly [R in ResourceKey<C>]: {
62
- readonly [F in keyof OperationGrammar<C>[R]]: {
63
- readonly [V in keyof OperationGrammar<C>[R][F]]: DeferredOperationCall<C, R, OperationGrammar<C>[R][F][V] & OperationIdentity, WireScalarForms, ApplicationScalarForms>;
124
+ export type AvComputeReads<M extends AvAdapterModel> = ComputeReadFacade<AvContractApplicationView<M>>;
125
+ type ComputeReadFacade<C> = C extends AvContract ? string extends AvResourceKey<C> ? unknown : {
126
+ readonly [R in AvResourceKey<C>]: {
127
+ readonly [F in Extract<keyof AvOperationGrammar<C>[R], "find">]: {
128
+ readonly [V in keyof AvOperationGrammar<C>[R][F]]: AvOperationCall<C, R, AvOperationGrammar<C>[R][F][V] & AvOperationIdentity, AvApplicationScalarForms, AvApplicationScalarForms, never>;
64
129
  };
65
130
  };
66
131
  } : never;
67
- /** Builds the request one façade call hands to `execute`, under its request id. */
68
- export type FacadeRequest = (resource: string, identity: OperationIdentity, args: unknown, requestId: string) => FrameworkOperationRequest;
69
- type FacadeExecutor = (request: FrameworkOperationRequest) => Promise<OperationResponse>;
132
+ /** Builds the request one façade call hands to `execute`, under its request id and state. */
133
+ export type FacadeRequest = (resource: string, identity: AvOperationIdentity, args: unknown, requestId: string, state: AvState | undefined) => FrameworkOperationRequest;
134
+ type FacadeExecutor = (request: FrameworkOperationRequest) => Promise<AvOperationResponse>;
70
135
  /**
71
136
  * Builds a façade over `model`, the same object its types are read from, so a
72
137
  * call that type-checks always reaches `execute`: a Resource, variant or field
@@ -74,20 +139,26 @@ type FacadeExecutor = (request: FrameworkOperationRequest) => Promise<OperationR
74
139
  * validation layer answers it.
75
140
  *
76
141
  * Each call's request is `request`'s — its origin — under the caller's
77
- * `ExecutionOptions.requestId`, or a freshly minted id when there is none; an
142
+ * `AvExecutionOptions.requestId`, or a freshly minted id when there is none, and
143
+ * with the caller's `AvExecutionOptions.state` when it gives one; an
78
144
  * omitted argument is the empty argument object, which the type admits only
79
145
  * when every member is optional.
80
146
  */
81
- export declare function createOperationFacade<Facade>(model: AdapterModel, request: FacadeRequest, execute: FacadeExecutor): Facade;
147
+ export declare function createOperationFacade<Facade>(model: AvAdapterModel, request: FacadeRequest, execute: FacadeExecutor): Facade;
148
+ /**
149
+ * An in-process call's settlement (a façade call or `framework.transaction`):
150
+ * the response's data, or its failure thrown.
151
+ */
152
+ export declare function settleOperation(response: AvOperationResponse | AvTransactionResponse): unknown;
82
153
  /**
83
154
  * One leaf of an operation tree: the callable for one advertised variant. The
84
155
  * second parameter is a façade call's options; a builder leaf ignores it.
85
156
  */
86
- export type OperationLeaf = (resource: string, identity: OperationIdentity) => (args?: unknown, options?: unknown) => unknown;
157
+ export type OperationLeaf = (resource: string, identity: AvOperationIdentity) => (args?: unknown, options?: unknown) => unknown;
87
158
  /**
88
159
  * The runtime shape every façade and builder shares: one frozen property per
89
160
  * Resource of `model`, one per family under it, one leaf per variant the model
90
161
  * advertises in the standard grammar.
91
162
  */
92
- export declare function createOperationTree<Tree>(model: AdapterModel, leaf: OperationLeaf): Tree;
163
+ export declare function createOperationTree<Tree>(model: AvAdapterModel, leaf: OperationLeaf): Tree;
93
164
  export {};
@@ -1,8 +1,16 @@
1
1
  import { isOperationVariantAvailable } from "../contracts/resource-operations.js";
2
2
  import { parseOperationIdentity } from "../operations/operation-identity.js";
3
+ import { thrownFailure } from "../runtime/framework-error.factory.js";
3
4
  import { requestIdOf } from "../runtime/request-id.js";
5
+ import { stateOptionOf } from "../runtime/request-state.resolver.js";
4
6
  export function createOperationFacade(model, request, execute) {
5
- return createOperationTree(model, (resource, identity) => (args, options) => execute(request(resource, identity, args === undefined ? {} : args, requestIdOf(options))));
7
+ return createOperationTree(model, (resource, identity) => async (args, options) => settleOperation(await execute(request(resource, identity, args === undefined ? {} : args, requestIdOf(options), stateOptionOf(options)))));
8
+ }
9
+ export function settleOperation(response) {
10
+ if (response.cause !== null) {
11
+ throw thrownFailure(response);
12
+ }
13
+ return response.data;
6
14
  }
7
15
  export function createOperationTree(model, leaf) {
8
16
  const resources = Object.entries(model.resources).map(([resource, { operations }]) => {
package/dist/index.d.ts CHANGED
@@ -1,51 +1,56 @@
1
- export type { Adapter } from "./adapters/adapter.interface.js";
2
- export type { AdapterDiscoveryDiagnostic, AdapterDiscoveryDiagnosticCode, } from "./adapters/adapter-discovery-diagnostic.js";
3
- export type { AdapterModel } from "./adapters/adapter-model.js";
4
- export type { FrameworkContracts } from "./compiler/contract.compiler.js";
5
- export type { ContractCompilerDiagnostic, ContractCompilerDiagnosticCode, } from "./compiler/contract-compiler-diagnostic.js";
6
- export type { ConfigDiagnostic, ConfigDiagnosticCode, } from "./config/config-diagnostic.js";
7
- export type { ConfigLayer, RequestOrigin } from "./config/config-layer.js";
8
- export type { AddedScalarFieldConfig, FrameworkFieldsShape, KnownScalarFieldConfig, } from "./config/define-fields.js";
9
- export { defineFields } from "./config/define-fields.js";
10
- export type { ConfigFieldKey, EffectiveFieldKey, } from "./config/effective-fields.js";
11
- export type { FrameworkFieldBehaviorConfig, FrameworkReadBehavior, FrameworkResourceBehaviorsConfig, } from "./config/framework-behaviors-config.js";
12
- export type { AnyFieldsBlock, AnyFrameworkConfig, AnyScopeConfig, FrameworkBehaviorsConfig, FrameworkCapabilitySetRestriction, FrameworkConfig, FrameworkFieldLifecycleTrait, FrameworkFieldRestrictions, FrameworkFieldsConfig, FrameworkLimitsConfig, FrameworkProjectionScopeRestriction, FrameworkRelationCapabilityRestrictions, FrameworkRelationFieldRestrictions, FrameworkRelationMutationRestriction, FrameworkRelationReducerRestriction, FrameworkResourceFieldRestrictions, FrameworkResourceFieldsConfig, FrameworkResourceKey, FrameworkResourceOperationRestrictions, FrameworkResourceRestrictions, FrameworkRestrictionsConfig, FrameworkScalarCapabilityRestrictions, FrameworkScalarFieldConfig, FrameworkScalarFieldRestrictions, FrameworkScalarTypeRef, FrameworkScopeConfig, } from "./config/framework-config.js";
13
- export type { PipelineConfig } from "./config/pipeline-config.js";
14
- export type { PaginationCapability, ProjectionScope, RelationFilterCapability, RelationMutationDirective, RelationReducer, ScalarFilterOperator, ScalarMutationDirective, WriteScope, } from "./contracts/capability.js";
15
- export type { ApplicationContract, ClientContract, Contract, CoreContract, } from "./contracts/contract.js";
16
- export type { ContractLimits } from "./contracts/contract-limits.js";
17
- export type { ClientContractProtocol, ContractHash, ContractProtocol, } from "./contracts/contract-protocol.js";
18
- export type { EnumDefinition } from "./contracts/enum-definition.js";
19
- export type { Field, ProjectionScopes, RelationField, RelationFieldCapabilities, RelationMutationCapability, RelationProjectionCapability, RelationReducerCapability, ScalarField, ScalarFieldCapabilities, ScalarFormat, ScopedRelationMutations, ScopedRelationReducers, WriteScopes, } from "./contracts/field.js";
20
- export type { Identifier, ScalarFieldKey } from "./contracts/identifier.js";
21
- export type { LifecycleTrait } from "./contracts/lifecycle-trait.js";
22
- export type { Resource, ResourceFieldMap } from "./contracts/resource.js";
23
- export type { OperationAvailability, OperationVariantScopes, ResourceOperations, } from "./contracts/resource-operations.js";
24
- export type { BuiltInScalar, ScalarDefinition, ScalarRegistry, } from "./contracts/scalar.js";
25
- export type { ApplicationScalarForms, ScalarValueType, WireScalarForms, } from "./contracts/scalar-value-type.js";
26
- export type { TransactionCapability } from "./contracts/transaction-capability.js";
1
+ export type { AvAdapter } from "./adapters/adapter.interface.js";
2
+ export type { AvAdapterDiscoveryDiagnostic, AvAdapterDiscoveryDiagnosticCode, } from "./adapters/adapter-discovery-diagnostic.js";
3
+ export type { AvAdapterModel } from "./adapters/adapter-model.js";
4
+ export type { AvContracts } from "./compiler/contract.compiler.js";
5
+ export type { AvContractCompilerDiagnostic, AvContractCompilerDiagnosticCode, } from "./compiler/contract-compiler-diagnostic.js";
6
+ export type { AvMcpEndpoint } from "./config/config.resolver.js";
7
+ export type { AvConfigDiagnostic, AvConfigDiagnosticCode, } from "./config/config-diagnostic.js";
8
+ export type { AvConfigLayerName, AvRequestOrigin, } from "./config/config-layer.js";
9
+ export { type AvDefinedResource, defineResource, } from "./config/define-resource.js";
10
+ export type { AvConfigFieldKey, AvEffectiveFieldKey, } from "./config/effective-fields.js";
11
+ export type { AvConfigExact } from "./config/exact-framework-config.js";
12
+ export type { AvConfig, AvConfigAddedFieldDefinition, AvConfigAgentLayer, AvConfigAny, AvConfigExemptions, AvConfigFamily, AvConfigFieldDefinition, AvConfigFieldLifecycleTrait, AvConfigKnownFieldDefinition, AvConfigLayer, AvConfigLayerAny, AvConfigLayerKind, AvConfigLimits, AvConfigMcp, AvConfigOperations, AvConfigOperationsExemption, AvConfigOverlayField, AvConfigRelationFieldExemption, AvConfigResource, AvConfigResourceExemption, AvConfigResourceFields, AvConfigResourceKey, AvConfigResources, AvConfigResourcesAny, AvConfigResourceTransactions, AvConfigRootField, AvConfigScalarFieldExemption, AvConfigScalarTypeRef, AvConfigVariant, AvFieldCompute, AvRelationFieldCapabilityName, AvRelationFieldPipeline, AvScalarFieldCapabilityName, AvScalarFieldPipeline, AvZCheck, AvZFormat, } from "./config/framework-config.js";
13
+ export type { AvPipeline, AvTransactionPipeline, } from "./config/pipeline-config.js";
14
+ export type { AvPaginationCapability, AvProjectionScope, AvRelationFilterCapability, AvRelationMutationDirective, AvRelationReducer, AvScalarFilterOperator, AvScalarMutationDirective, AvWriteScope, } from "./contracts/capability.js";
15
+ export type { AvContract, AvContractAgent, AvContractApplication, AvContractClient, AvContractCore, } from "./contracts/contract.js";
16
+ export type { AvContractLimits } from "./contracts/contract-limits.js";
17
+ export type { AvContractClientProtocol, AvContractHash, AvContractProtocol, } from "./contracts/contract-protocol.js";
18
+ export type { AvCreateRequirementGroup, AvCreateRequirements, } from "./contracts/create-requirements.js";
19
+ export type { AvEnumDefinition } from "./contracts/enum-definition.js";
20
+ export type { AvField, AvProjectionScopes, AvRelationField, AvRelationFieldCapabilities, AvRelationMutationCapability, AvRelationProjectionCapability, AvRelationReducerCapability, AvScalarField, AvScalarFieldCapabilities, AvScalarFormat, AvScopedRelationMutations, AvScopedRelationReducers, AvWriteScopes, } from "./contracts/field.js";
21
+ export type { AvFieldCheck } from "./contracts/field-check.js";
22
+ export type { AvIdentifier, AvScalarFieldKey } from "./contracts/identifier.js";
23
+ export type { AvLifecycleTrait } from "./contracts/lifecycle-trait.js";
24
+ export type { AvResource, AvResourceFieldMap } from "./contracts/resource.js";
25
+ export type { AvOperationAvailability, AvOperationVariantScopes, AvResourceOperations, } from "./contracts/resource-operations.js";
26
+ export type { AvBuiltInScalar, AvScalarDefinition, AvScalarRegistry, } from "./contracts/scalar.js";
27
+ export type { AvApplicationScalarForms, AvScalarValueType, AvWireScalarForms, } from "./contracts/scalar-value-type.js";
28
+ export type { AvTransactionCapability } from "./contracts/transaction-capability.js";
27
29
  export { createFramework } from "./framework/framework.factory.js";
28
- export type { Framework } from "./framework/framework.js";
29
- export type { FrameworkConstructionDiagnostic, FrameworkConstructionStage, } from "./framework/framework-construction.error.js";
30
- export { FrameworkConstructionError } from "./framework/framework-construction.error.js";
31
- export type { CreateDataInput, CursorInput, FieldKey, IncludeInput, NullsOrder, OperationArgumentMap, OperationArgumentsFor, OrderByEntry, OrderByInput, ProjectionEntry, RelationProjectionInput, ResourceKey, ScalarOrderInput, SelectInput, SortDirection, UniqueWhereInput, UpdateDataInput, WhereInput, } from "./operations/operation-arguments.js";
32
- export type { DeferredOperationCall, OperationCall, OperationGrammar, OperationSlot, } from "./operations/operation-call.js";
33
- export type { OperationFamily, OperationIdentity, OperationVariant, } from "./operations/operation-identity.js";
34
- export type { OperationResultFor } from "./operations/operation-result.js";
35
- export type { ValidationCode, ValidationIssue, } from "./operations/validation-code.js";
36
- export { Decimal } from "./runtime/decimal.js";
37
- export type { FrameworkDiagnostic, FrameworkDiagnosticsSink, OperationDiagnostic, TransactionDiagnostic, } from "./runtime/diagnostics-reporter.js";
38
- export type { ExecutionOptions } from "./runtime/execution-options.js";
39
- export type { ComputedReadBehavior, ComputeOnCreate, ComputeOnRead, ComputeOnUpdate, } from "./runtime/field-behavior.js";
40
- export { FrameworkError } from "./runtime/framework-error.js";
41
- export type { JsonValue } from "./runtime/json-value.js";
42
- export type { FrameworkMisuseEvent, FrameworkMisuseSink, } from "./runtime/misuse-reporter.js";
43
- export type { Cause, OperationCode, OperationErrorCode, OperationFailureResponse, OperationNoMatchResponse, OperationResponse, OperationSuccessCode, OperationSuccessDataCode, OperationSuccessResponse, } from "./runtime/operation-response.js";
44
- export type { AfterHook, BeforeHook, Filter, Guard, Interceptor, Pipe, PipelineContext, PipelineTransportContext, } from "./runtime/pipeline.js";
45
- export type { Operation, OperationReferenceSurface, ReferenceableField, ReferenceBuilder, SingleRowResult, TransactionResults, TransactionRunner, } from "./transactions/deferred-operation.js";
46
- export type { TransactionIntegrityViolation } from "./transactions/transaction-integrity-error.js";
47
- export { TransactionIntegrityError } from "./transactions/transaction-integrity-error.js";
48
- export type { TransactionReference } from "./transactions/transaction-reference.js";
49
- export type { TransactionCommittedResponse, TransactionResponse, } from "./transactions/transaction-response.js";
50
- export type { TransactionSlotPathViolation } from "./transactions/transaction-slot-path-error.js";
51
- export { TransactionSlotPathError } from "./transactions/transaction-slot-path-error.js";
30
+ export type { AvFramework } from "./framework/framework.js";
31
+ export type { AvConstructionDiagnostic, AvConstructionStage, } from "./framework/framework-construction.error.js";
32
+ export { AvConstructionError } from "./framework/framework-construction.error.js";
33
+ export type { AvApplicationFacade, AvApplicationFamilyFacade, AvApplicationResourceFacade, AvAppTxFacade, AvAppTxFamilyFacade, AvAppTxResourceFacade, AvClientFacade, AvClientFamilyFacade, AvClientResourceFacade, AvClientTxFacade, AvClientTxFamilyFacade, AvClientTxResourceFacade, } from "./framework/operation-facade.js";
34
+ export type { AvCreateDataInput, AvCursorInput, AvFieldKey, AvIncludeInput, AvNullsOrder, AvOperationArgumentMap, AvOperationArgumentsFor, AvOrderByEntry, AvOrderByInput, AvProjectionEntry, AvRelationProjectionInput, AvResourceKey, AvScalarOrderInput, AvSelectInput, AvSortDirection, AvUniqueWhereInput, AvUpdateDataInput, AvWhereInput, } from "./operations/operation-arguments.js";
35
+ export type { AvDeferredOperationCall, AvOperationCall, AvOperationGrammar, AvOperationSlot, } from "./operations/operation-call.js";
36
+ export type { AvOperationFamily, AvOperationIdentity, AvOperationVariant, } from "./operations/operation-identity.js";
37
+ export type { AvOperationResultFor } from "./operations/operation-result.js";
38
+ export type { AvValidationCode, AvValidationIssue, } from "./operations/validation-code.js";
39
+ export { AvDecimal } from "./runtime/decimal.js";
40
+ export type { AvDiagnostic, AvDiagnosticsSink, AvMcpDiagnostic, AvOperationDiagnostic, AvTransactionDiagnostic, } from "./runtime/diagnostics-reporter.js";
41
+ export type { AvExecutionOptions } from "./runtime/execution-options.js";
42
+ export type { AvComputeContext, AvComputeCreate, AvComputeRead, AvComputeUpdate, } from "./runtime/field-compute.js";
43
+ export { AvAuthError, AvConflictError, AvContractMismatchError, AvError, AvInternalError, AvNotFoundError, AvProtocolError, AvValidationError, } from "./runtime/framework-error.js";
44
+ export type { AvJsonValue } from "./runtime/json-value.js";
45
+ export type { AvMisuseEvent, AvMisuseSink, } from "./runtime/misuse-reporter.js";
46
+ export type { AvCause, AvOperationCode, AvOperationErrorCode, AvOperationFailureResponse, AvOperationNoMatchResponse, AvOperationResponse, AvOperationSuccessCode, AvOperationSuccessDataCode, AvOperationSuccessResponse, } from "./runtime/operation-response.js";
47
+ export type { AvAfterHook, AvBeforeHook, AvContext, AvFieldGuard, AvFieldPipe, AvFilter, AvGuard, AvInterceptor, AvPipe, AvTransactionAfterHook, AvTransactionBeforeHook, AvTransactionContext, AvTransactionFilter, AvTransactionGuard, AvTransactionInterceptor, AvTransactionPipe, AvTransactionStep, AvTransportContext, } from "./runtime/pipeline.js";
48
+ export type { AvDeepReadonly } from "./runtime/readonly-value.js";
49
+ export type { AvState } from "./runtime/request-state.js";
50
+ export type { AvOperation, AvOperationHandle, AvOperationReferenceSurface, AvReferenceableField, AvReferenceBuilder, AvSingleRowResult, AvTransactionResults, AvTransactionRunner, } from "./transactions/deferred-operation.js";
51
+ export type { AvTransactionIntegrityViolation } from "./transactions/transaction-integrity-error.js";
52
+ export { AvTransactionIntegrityError } from "./transactions/transaction-integrity-error.js";
53
+ export type { AvTransactionReference } from "./transactions/transaction-reference.js";
54
+ export type { AvTransactionCommittedResponse, AvTransactionResponse, } from "./transactions/transaction-response.js";
55
+ export type { AvTransactionSlotPathViolation } from "./transactions/transaction-slot-path-error.js";
56
+ export { AvTransactionSlotPathError } from "./transactions/transaction-slot-path-error.js";
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- export { defineFields } from "./config/define-fields.js";
1
+ export { defineResource, } from "./config/define-resource.js";
2
2
  export { createFramework } from "./framework/framework.factory.js";
3
- export { FrameworkConstructionError } from "./framework/framework-construction.error.js";
4
- export { Decimal } from "./runtime/decimal.js";
5
- export { FrameworkError } from "./runtime/framework-error.js";
6
- export { TransactionIntegrityError } from "./transactions/transaction-integrity-error.js";
7
- export { TransactionSlotPathError } from "./transactions/transaction-slot-path-error.js";
3
+ export { AvConstructionError } from "./framework/framework-construction.error.js";
4
+ export { AvDecimal } from "./runtime/decimal.js";
5
+ export { AvAuthError, AvConflictError, AvContractMismatchError, AvError, AvInternalError, AvNotFoundError, AvProtocolError, AvValidationError, } from "./runtime/framework-error.js";
6
+ export { AvTransactionIntegrityError } from "./transactions/transaction-integrity-error.js";
7
+ export { AvTransactionSlotPathError } from "./transactions/transaction-slot-path-error.js";
@@ -6,17 +6,19 @@
6
6
  * stability promise: any export here may change or disappear in any release,
7
7
  * including a patch release. Applications import from `@aventara/core`.
8
8
  */
9
- export type { AdapterField, AdapterLifecycleTrait, AdapterRelationField, AdapterScalarField, } from "./adapters/adapter-field.js";
10
- export type { AdapterIdentifier, AdapterScalarFieldKey, } from "./adapters/adapter-identifier.js";
11
- export type { AdapterOperation } from "./adapters/adapter-operation.js";
12
- export type { AdapterOperationExecutor } from "./adapters/adapter-operation-executor.interface.js";
13
- export type { AdapterFieldKey, AdapterFieldMap, AdapterResource, } from "./adapters/adapter-resource.js";
9
+ export type { AvAdapterField, AvAdapterLifecycleTrait, AvAdapterRelationField, AvAdapterScalarField, } from "./adapters/adapter-field.js";
10
+ export type { AvAdapterIdentifier, AvAdapterScalarFieldKey, } from "./adapters/adapter-identifier.js";
11
+ export type { AvAdapterOperation } from "./adapters/adapter-operation.js";
12
+ export type { AvAdapterOperationExecutor } from "./adapters/adapter-operation-executor.interface.js";
13
+ export type { AvAdapterFieldKey, AvAdapterFieldMap, AvAdapterResource, } from "./adapters/adapter-resource.js";
14
+ export type { AvAdapterSqlStatement, AvAdapterSqlValue, } from "./adapters/adapter-sql-statement.js";
15
+ export type { AvAdapterTransactionExecutor } from "./adapters/adapter-transaction-executor.interface.js";
14
16
  export { compileContracts } from "./compiler/contract.compiler.js";
15
17
  export { resolveFrameworkConfig } from "./config/config.resolver.js";
16
18
  export { PROJECTION_SCOPES, WRITE_SCOPES } from "./contracts/capability.js";
17
19
  export { validateClientContractStructure } from "./contracts/client-contract-structure.validator.js";
18
- export { CanonicalJsonError, canonicalizeContract, canonicalizeJson, } from "./contracts/contract-canonicalizer.js";
19
- export type { ClientContractHashInput } from "./contracts/contract-hash.js";
20
+ export { AvCanonicalJsonError, canonicalizeContract, canonicalizeJson, } from "./contracts/contract-canonicalizer.js";
21
+ export type { AvContractClientHashInput } from "./contracts/contract-hash.js";
20
22
  export { computeClientContractHash, verifyClientContractHash, } from "./contracts/contract-hash.js";
21
23
  export { DEFAULT_CONTRACT_LIMITS } from "./contracts/contract-limits.js";
22
24
  export { AVENTARA_PROTOCOL_VERSION } from "./contracts/contract-protocol.js";
@@ -25,11 +27,14 @@ export { LIFECYCLE_TRAITS } from "./contracts/lifecycle-trait.js";
25
27
  export { isOperationVariantAvailable, projectionScopeOf, writeScopeOf, } from "./contracts/resource-operations.js";
26
28
  export { BUILT_IN_SCALARS } from "./contracts/scalar.js";
27
29
  export { TRANSACTION_CAPABILITIES } from "./contracts/transaction-capability.js";
28
- export type { ApplicationContractView } from "./framework/contract-view.js";
30
+ export type { AvContractApplicationView } from "./framework/contract-view.js";
29
31
  export type { SemanticOperationArguments } from "./operations/operation-validator.js";
30
32
  export { VALIDATION_CODES } from "./operations/validation-code.js";
31
- export type { ApplicationOperationRequest, ClientOperationRequest, ClientProtocolIdentity, FrameworkOperationRequest, } from "./runtime/operation-request.js";
33
+ export { mcpFailureReporterOf } from "./runtime/diagnostics-reporter.js";
34
+ export type { AvErrorClassName } from "./runtime/framework-error-class.table.js";
35
+ export { FRAMEWORK_ERROR_CLASS_OF } from "./runtime/framework-error-class.table.js";
36
+ export type { AgentOperationRequest, ApplicationOperationRequest, ClientOperationRequest, ClientProtocolIdentity, FrameworkOperationRequest, } from "./runtime/operation-request.js";
32
37
  export { OPERATION_CODES } from "./runtime/operation-response.js";
33
38
  export type { BuiltinNonRow, OperationFingerprint, } from "./transactions/deferred-operation.js";
34
39
  export { computeOperationFingerprint } from "./transactions/operation-fingerprint.js";
35
- export type { ApplicationTransactionRequest, ClientTransactionRequest, FrameworkTransactionRequest, } from "./transactions/transaction-request.js";
40
+ export type { AgentTransactionRequest, ApplicationTransactionRequest, ClientTransactionRequest, FrameworkTransactionRequest, } from "./transactions/transaction-request.js";
package/dist/internal.js CHANGED
@@ -2,7 +2,7 @@ export { compileContracts } from "./compiler/contract.compiler.js";
2
2
  export { resolveFrameworkConfig } from "./config/config.resolver.js";
3
3
  export { PROJECTION_SCOPES, WRITE_SCOPES } from "./contracts/capability.js";
4
4
  export { validateClientContractStructure } from "./contracts/client-contract-structure.validator.js";
5
- export { CanonicalJsonError, canonicalizeContract, canonicalizeJson, } from "./contracts/contract-canonicalizer.js";
5
+ export { AvCanonicalJsonError, canonicalizeContract, canonicalizeJson, } from "./contracts/contract-canonicalizer.js";
6
6
  export { computeClientContractHash, verifyClientContractHash, } from "./contracts/contract-hash.js";
7
7
  export { DEFAULT_CONTRACT_LIMITS } from "./contracts/contract-limits.js";
8
8
  export { AVENTARA_PROTOCOL_VERSION } from "./contracts/contract-protocol.js";
@@ -12,5 +12,7 @@ export { isOperationVariantAvailable, projectionScopeOf, writeScopeOf, } from ".
12
12
  export { BUILT_IN_SCALARS } from "./contracts/scalar.js";
13
13
  export { TRANSACTION_CAPABILITIES } from "./contracts/transaction-capability.js";
14
14
  export { VALIDATION_CODES } from "./operations/validation-code.js";
15
+ export { mcpFailureReporterOf } from "./runtime/diagnostics-reporter.js";
16
+ export { FRAMEWORK_ERROR_CLASS_OF } from "./runtime/framework-error-class.table.js";
15
17
  export { OPERATION_CODES } from "./runtime/operation-response.js";
16
18
  export { computeOperationFingerprint } from "./transactions/operation-fingerprint.js";