@aventara/testing 0.0.0-stage → 0.1.0-pilot.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +91 -0
- package/LICENSE-ADDITIONAL-PERMISSION.md +9 -0
- package/README.md +29 -2
- package/dist/adapters/adapter-factory.d.ts +3 -0
- package/dist/adapters/adapter-factory.js +1 -0
- package/dist/adapters/fake-adapter.d.ts +28 -0
- package/dist/adapters/fake-adapter.js +65 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +3 -0
- package/dist/protocol/corpus-contract.fixture.d.ts +418 -0
- package/dist/protocol/corpus-contract.fixture.js +334 -0
- package/dist/protocol/in-process.driver.d.ts +11 -0
- package/dist/protocol/in-process.driver.js +26 -0
- package/dist/protocol/per-route.driver.d.ts +12 -0
- package/dist/protocol/per-route.driver.js +36 -0
- package/dist/protocol/protocol-conformance.d.ts +32 -0
- package/dist/protocol/protocol-conformance.js +112 -0
- package/dist/protocol/protocol-driver.d.ts +18 -0
- package/dist/protocol/protocol-driver.js +1 -0
- package/dist/protocol/protocol-fixture.d.ts +53 -0
- package/dist/protocol/protocol-fixture.js +1 -0
- package/dist/protocol/protocol-fixtures.d.ts +2 -0
- package/dist/protocol/protocol-fixtures.js +1005 -0
- package/package.json +31 -3
package/LICENSE
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
Required Notice: Copyright 2026 Mohamed Ragheb
|
|
2
|
+
|
|
3
|
+
# PolyForm Shield License 1.0.0
|
|
4
|
+
|
|
5
|
+
<https://polyformproject.org/licenses/shield/1.0.0>
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the software to do everything you might do with the software that would otherwise infringe the licensor's copyright in it for any permitted purpose. However, you may only distribute the software according to [Distribution License](#distribution-license) and make changes or new works based on the software according to [Changes and New Works License](#changes-and-new-works-license).
|
|
14
|
+
|
|
15
|
+
## Distribution License
|
|
16
|
+
|
|
17
|
+
The licensor grants you an additional copyright license to distribute copies of the software. Your license to distribute covers distributing the software with changes and new works permitted by [Changes and New Works License](#changes-and-new-works-license).
|
|
18
|
+
|
|
19
|
+
## Notices
|
|
20
|
+
|
|
21
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms or the URL for them above, as well as copies of any plain-text lines beginning with `Required Notice:` that the licensor provided with the software. For example:
|
|
22
|
+
|
|
23
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
24
|
+
|
|
25
|
+
## Changes and New Works License
|
|
26
|
+
|
|
27
|
+
The licensor grants you an additional copyright license to make changes and new works based on the software for any permitted purpose.
|
|
28
|
+
|
|
29
|
+
## Patent License
|
|
30
|
+
|
|
31
|
+
The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software.
|
|
32
|
+
|
|
33
|
+
## Noncompete
|
|
34
|
+
|
|
35
|
+
Any purpose is a permitted purpose, except for providing any product that competes with the software or any product the licensor or any of its affiliates provides using the software.
|
|
36
|
+
|
|
37
|
+
## Competition
|
|
38
|
+
|
|
39
|
+
Goods and services compete even when they provide functionality through different kinds of interfaces or for different technical platforms. Applications can compete with services, libraries with plugins, frameworks with development tools, and so on, even if they're written in different programming languages or for different computer architectures. Goods and services compete even when provided free of charge. If you market a product as a practical substitute for the software or another product, it definitely competes.
|
|
40
|
+
|
|
41
|
+
## New Products
|
|
42
|
+
|
|
43
|
+
If you are using the software to provide a product that does not compete, but the licensor or any of its affiliates brings your product into competition by providing a new version of the software or another product using the software, you may continue using versions of the software available under these terms beforehand to provide your competing product, but not any later versions.
|
|
44
|
+
|
|
45
|
+
## Discontinued Products
|
|
46
|
+
|
|
47
|
+
You may begin using the software to compete with a product or service that the licensor or any of its affiliates has stopped providing, unless the licensor includes a plain-text line beginning with `Licensor Line of Business:` with the software that mentions that line of business. For example:
|
|
48
|
+
|
|
49
|
+
> Licensor Line of Business: YoyodyneCMS Content Management System (http://example.com/cms)
|
|
50
|
+
|
|
51
|
+
## Sales of Business
|
|
52
|
+
|
|
53
|
+
If the licensor or any of its affiliates sells a line of business developing the software or using the software to provide a product, the buyer can also enforce [Noncompete](#noncompete) for that product.
|
|
54
|
+
|
|
55
|
+
## Fair Use
|
|
56
|
+
|
|
57
|
+
You may have "fair use" rights for the software under the law. These terms do not limit them.
|
|
58
|
+
|
|
59
|
+
## No Other Rights
|
|
60
|
+
|
|
61
|
+
These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses.
|
|
62
|
+
|
|
63
|
+
## Patent Defense
|
|
64
|
+
|
|
65
|
+
If you make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
66
|
+
|
|
67
|
+
## Violations
|
|
68
|
+
|
|
69
|
+
The first time you are notified in writing that you have violated any of these terms, or done anything with the software not covered by your licenses, your licenses can nonetheless continue if you come into full compliance with these terms, and take practical steps to correct past violations, within 32 days of receiving notice. Otherwise, all your licenses end immediately.
|
|
70
|
+
|
|
71
|
+
## No Liability
|
|
72
|
+
|
|
73
|
+
***As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.***
|
|
74
|
+
|
|
75
|
+
## Definitions
|
|
76
|
+
|
|
77
|
+
The **licensor** is the individual or entity offering these terms, and the **software** is the software the licensor makes available under these terms.
|
|
78
|
+
|
|
79
|
+
A **product** can be a good or service, or a combination of them.
|
|
80
|
+
|
|
81
|
+
**You** refers to the individual or entity agreeing to these terms.
|
|
82
|
+
|
|
83
|
+
**Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all its affiliates.
|
|
84
|
+
|
|
85
|
+
**Affiliates** means the other organizations than an organization has control over, is under the control of, or is under common control with.
|
|
86
|
+
|
|
87
|
+
**Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
88
|
+
|
|
89
|
+
**Your licenses** are all the licenses granted to you for the software under these terms.
|
|
90
|
+
|
|
91
|
+
**Use** means anything you do with the software requiring one of your licenses.
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# Additional Permission — Aventara
|
|
2
|
+
|
|
3
|
+
Copyright 2026 Mohamed Ragheb
|
|
4
|
+
|
|
5
|
+
In addition to the permissions of the PolyForm Shield License 1.0.0 in `LICENSE`, the licensor grants the following additional permission:
|
|
6
|
+
|
|
7
|
+
The Noncompete section applies only to providing a product that competes with the software itself — the Aventara framework, its packages and its tooling. Providing a product that competes with any other product the licensor or its affiliates provide using the software is a permitted purpose.
|
|
8
|
+
|
|
9
|
+
This additional permission only adds to your permissions; it does not restrict or replace any term of `LICENSE`.
|
package/README.md
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `@aventara/testing`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Conformance fixtures and testing utilities for Aventara extensions: what an adapter or a transport host is held to,
|
|
4
|
+
from outside.
|
|
5
|
+
|
|
6
|
+
- `createFakeAdapter` — an in-memory adapter, with transaction tracing, for testing code that runs a `Framework`
|
|
7
|
+
without a database.
|
|
8
|
+
- `runAvProtocolConformance(driver)` — drives the protocol corpus (`AvProtocolFixtures`) through one host and reports,
|
|
9
|
+
per row, every mismatch with the expected status, code, cause, headers and body. A host supplies an
|
|
10
|
+
`AvProtocolDriver`: given a `Framework`, a session that sends one protocol request and returns the answer, and closes.
|
|
11
|
+
|
|
12
|
+
It depends on `@aventara/core` only.
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install --save-dev @aventara/testing
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Node `^22.18.0 || >=24.2.0`. ES modules.
|
|
21
|
+
|
|
22
|
+
## Documentation
|
|
23
|
+
|
|
24
|
+
`@aventara/core`'s README is where to start (the framework, its adapters and hosts). `@aventara/nest` is held to this
|
|
25
|
+
corpus on Express and Fastify in its own tests. Each package's README ships in its tarball and shows on its npm page.
|
|
26
|
+
|
|
27
|
+
## License
|
|
28
|
+
|
|
29
|
+
PolyForm Shield 1.0.0 with an additional permission — free to use, including in commercial applications; you may not
|
|
30
|
+
use it to build a product that competes with Aventara itself. See `LICENSE` and `LICENSE-ADDITIONAL-PERMISSION.md`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Adapter, AdapterModel, AdapterOperation } from "@aventara/core";
|
|
2
|
+
export type FakeAdapterExecute<M extends AdapterModel> = (operation: AdapterOperation<M>) => unknown | Promise<unknown>;
|
|
3
|
+
export type FakeTransactionOutcome = "committed" | "rolled-back";
|
|
4
|
+
/** One settled transaction boundary: what ran inside it, and how it ended. */
|
|
5
|
+
export type FakeTransactionTrace<M extends AdapterModel> = {
|
|
6
|
+
readonly operations: readonly AdapterOperation<M>[];
|
|
7
|
+
readonly outcome: FakeTransactionOutcome;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Real rollback for caller-owned state: snapshot on begin, restore when the
|
|
11
|
+
* work rejects. Without it the fake Adapter records boundaries but persists
|
|
12
|
+
* whatever the work wrote, so a rollback assertion would prove nothing.
|
|
13
|
+
*/
|
|
14
|
+
export type FakeAdapterRollback<S> = {
|
|
15
|
+
readonly snapshot: () => S;
|
|
16
|
+
readonly restore: (snapshot: S) => void;
|
|
17
|
+
};
|
|
18
|
+
export type FakeAdapterOptions<M extends AdapterModel, S = unknown> = {
|
|
19
|
+
readonly model: M;
|
|
20
|
+
readonly execute?: FakeAdapterExecute<M>;
|
|
21
|
+
readonly rollback?: FakeAdapterRollback<S>;
|
|
22
|
+
};
|
|
23
|
+
export type FakeAdapter<M extends AdapterModel = AdapterModel> = Adapter<M> & {
|
|
24
|
+
readonly operations: readonly AdapterOperation<M>[];
|
|
25
|
+
readonly transactions: readonly FakeTransactionTrace<M>[];
|
|
26
|
+
};
|
|
27
|
+
/** Reusable provider-free Adapter implementation for framework/conformance tests. */
|
|
28
|
+
export declare function createFakeAdapter<M extends AdapterModel, S = unknown>(options: FakeAdapterOptions<M, S>): FakeAdapter<M>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Takes the caller's snapshot at the moment the boundary opens and returns the
|
|
3
|
+
* single restore action that undoes everything written after it. Returning a
|
|
4
|
+
* closure keeps the snapshot value's type local to the hook that owns it.
|
|
5
|
+
*/
|
|
6
|
+
function beginRollback(rollback) {
|
|
7
|
+
if (rollback === undefined) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
const snapshot = rollback.snapshot();
|
|
11
|
+
return () => {
|
|
12
|
+
rollback.restore(snapshot);
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
/** Reusable provider-free Adapter implementation for framework/conformance tests. */
|
|
16
|
+
export function createFakeAdapter(options) {
|
|
17
|
+
const operations = [];
|
|
18
|
+
const transactions = [];
|
|
19
|
+
const executor = {
|
|
20
|
+
async execute(operation) {
|
|
21
|
+
operations.push(operation);
|
|
22
|
+
return options.execute?.(operation);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
const execute = (operation) => executor.execute(operation);
|
|
26
|
+
const surface = {
|
|
27
|
+
get operations() {
|
|
28
|
+
return [...operations];
|
|
29
|
+
},
|
|
30
|
+
get transactions() {
|
|
31
|
+
return [...transactions];
|
|
32
|
+
},
|
|
33
|
+
model: options.model,
|
|
34
|
+
execute,
|
|
35
|
+
};
|
|
36
|
+
if (options.model.transactions !== "interactive") {
|
|
37
|
+
return surface;
|
|
38
|
+
}
|
|
39
|
+
const settle = (scoped, outcome) => {
|
|
40
|
+
transactions.push(Object.freeze({ operations: Object.freeze([...scoped]), outcome }));
|
|
41
|
+
};
|
|
42
|
+
const transaction = async (work) => {
|
|
43
|
+
const scoped = [];
|
|
44
|
+
const restore = beginRollback(options.rollback);
|
|
45
|
+
let result;
|
|
46
|
+
try {
|
|
47
|
+
result = await work({
|
|
48
|
+
async execute(operation) {
|
|
49
|
+
scoped.push(operation);
|
|
50
|
+
return executor.execute(operation);
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
restore?.();
|
|
56
|
+
settle(scoped, "rolled-back");
|
|
57
|
+
// By identity: the transaction runtime recognises its own abort
|
|
58
|
+
// sentinel by reference, never by shape.
|
|
59
|
+
throw error;
|
|
60
|
+
}
|
|
61
|
+
settle(scoped, "committed");
|
|
62
|
+
return result;
|
|
63
|
+
};
|
|
64
|
+
return Object.assign(surface, { transaction });
|
|
65
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type { AdapterFactory } from "./adapters/adapter-factory.js";
|
|
2
|
+
export type { FakeAdapter, FakeAdapterExecute, FakeAdapterOptions, FakeAdapterRollback, FakeTransactionOutcome, FakeTransactionTrace, } from "./adapters/fake-adapter.js";
|
|
3
|
+
export { createFakeAdapter } from "./adapters/fake-adapter.js";
|
|
4
|
+
export { runAvProtocolConformance } from "./protocol/protocol-conformance.js";
|
|
5
|
+
export type { AvProtocolDriver } from "./protocol/protocol-driver.js";
|
|
6
|
+
export type { AvProtocolFixture } from "./protocol/protocol-fixture.js";
|
|
7
|
+
export { AvProtocolFixtures } from "./protocol/protocol-fixtures.js";
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import type { Framework, PipelineContext } from "@aventara/core";
|
|
2
|
+
import { Decimal } from "@aventara/core";
|
|
3
|
+
/**
|
|
4
|
+
* The corpus's adapter model:
|
|
5
|
+
*
|
|
6
|
+
* - `authors` — every standard operation (family 2); its `secret` field is
|
|
7
|
+
* hidden at client scope (R1's client-hidden field);
|
|
8
|
+
* - `books` — references `authors`, and deleting an author cascades into it
|
|
9
|
+
* ({@link CORPUS_REFERENTIAL_ACTIONS}; a plan's `V1019`); the client scope
|
|
10
|
+
* adds a computed `label` to it ({@link CORPUS_CLIENT_CONFIG}, F-828);
|
|
11
|
+
* - `secrets` — its one operation restricted away at client scope (R1's
|
|
12
|
+
* client-restricted variant; M6's `operations: {}`);
|
|
13
|
+
* - `hiddenRes` — hidden at client scope (R1's client-hidden Resource, M7);
|
|
14
|
+
* - `samples` — one field of each scalar whose wire form is not its runtime
|
|
15
|
+
* form (`bigint`, `datetime`, `decimal`, `bytes`; family 13, P1, C1).
|
|
16
|
+
*/
|
|
17
|
+
export declare const CORPUS_MODEL: {
|
|
18
|
+
readonly transactions: "interactive";
|
|
19
|
+
readonly scalars: {
|
|
20
|
+
readonly string: {
|
|
21
|
+
readonly builtin: true;
|
|
22
|
+
};
|
|
23
|
+
readonly bigint: {
|
|
24
|
+
readonly builtin: true;
|
|
25
|
+
};
|
|
26
|
+
readonly datetime: {
|
|
27
|
+
readonly builtin: true;
|
|
28
|
+
};
|
|
29
|
+
readonly decimal: {
|
|
30
|
+
readonly builtin: true;
|
|
31
|
+
};
|
|
32
|
+
readonly bytes: {
|
|
33
|
+
readonly builtin: true;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
readonly enums: {};
|
|
37
|
+
readonly resources: {
|
|
38
|
+
readonly authors: {
|
|
39
|
+
readonly fields: {
|
|
40
|
+
readonly id: {
|
|
41
|
+
readonly kind: "scalar";
|
|
42
|
+
readonly type: {
|
|
43
|
+
readonly scalar: "string";
|
|
44
|
+
};
|
|
45
|
+
readonly nullable: false;
|
|
46
|
+
readonly list: false;
|
|
47
|
+
readonly lifecycle: readonly [];
|
|
48
|
+
readonly capabilities: {
|
|
49
|
+
readonly select: true;
|
|
50
|
+
readonly filter: readonly ["equals"];
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly name: {
|
|
54
|
+
readonly capabilities: {
|
|
55
|
+
readonly select: true;
|
|
56
|
+
readonly filter: readonly ["equals"];
|
|
57
|
+
readonly create: readonly [];
|
|
58
|
+
readonly update: readonly [];
|
|
59
|
+
};
|
|
60
|
+
readonly kind: "scalar";
|
|
61
|
+
readonly type: {
|
|
62
|
+
readonly scalar: "string";
|
|
63
|
+
};
|
|
64
|
+
readonly nullable: false;
|
|
65
|
+
readonly list: false;
|
|
66
|
+
readonly lifecycle: readonly [];
|
|
67
|
+
};
|
|
68
|
+
readonly secret: {
|
|
69
|
+
readonly kind: "scalar";
|
|
70
|
+
readonly type: {
|
|
71
|
+
readonly scalar: "string";
|
|
72
|
+
};
|
|
73
|
+
readonly nullable: false;
|
|
74
|
+
readonly list: false;
|
|
75
|
+
readonly lifecycle: readonly [];
|
|
76
|
+
readonly capabilities: {
|
|
77
|
+
readonly select: true;
|
|
78
|
+
readonly filter: readonly ["equals"];
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
readonly identifiers: readonly [readonly ["id"]];
|
|
83
|
+
readonly operations: {
|
|
84
|
+
readonly find: {
|
|
85
|
+
readonly first: true;
|
|
86
|
+
readonly unique: true;
|
|
87
|
+
readonly many: true;
|
|
88
|
+
readonly count: true;
|
|
89
|
+
};
|
|
90
|
+
readonly create: {
|
|
91
|
+
readonly one: true;
|
|
92
|
+
readonly many: true;
|
|
93
|
+
readonly count: true;
|
|
94
|
+
};
|
|
95
|
+
readonly update: {
|
|
96
|
+
readonly first: true;
|
|
97
|
+
readonly unique: true;
|
|
98
|
+
readonly many: true;
|
|
99
|
+
readonly count: true;
|
|
100
|
+
};
|
|
101
|
+
readonly delete: {
|
|
102
|
+
readonly first: true;
|
|
103
|
+
readonly unique: true;
|
|
104
|
+
readonly many: true;
|
|
105
|
+
readonly count: true;
|
|
106
|
+
};
|
|
107
|
+
readonly upsert: {
|
|
108
|
+
readonly unique: true;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
readonly books: {
|
|
113
|
+
readonly fields: {
|
|
114
|
+
readonly id: {
|
|
115
|
+
readonly kind: "scalar";
|
|
116
|
+
readonly type: {
|
|
117
|
+
readonly scalar: "string";
|
|
118
|
+
};
|
|
119
|
+
readonly nullable: false;
|
|
120
|
+
readonly list: false;
|
|
121
|
+
readonly lifecycle: readonly [];
|
|
122
|
+
readonly capabilities: {
|
|
123
|
+
readonly select: true;
|
|
124
|
+
readonly filter: readonly ["equals"];
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
readonly authorId: {
|
|
128
|
+
readonly kind: "scalar";
|
|
129
|
+
readonly type: {
|
|
130
|
+
readonly scalar: "string";
|
|
131
|
+
};
|
|
132
|
+
readonly nullable: false;
|
|
133
|
+
readonly list: false;
|
|
134
|
+
readonly lifecycle: readonly [];
|
|
135
|
+
readonly capabilities: {
|
|
136
|
+
readonly select: true;
|
|
137
|
+
readonly filter: readonly ["equals"];
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
};
|
|
141
|
+
readonly identifiers: readonly [readonly ["id"]];
|
|
142
|
+
readonly operations: {
|
|
143
|
+
readonly find: {
|
|
144
|
+
readonly many: true;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
readonly secrets: {
|
|
149
|
+
readonly fields: {
|
|
150
|
+
readonly id: {
|
|
151
|
+
readonly kind: "scalar";
|
|
152
|
+
readonly type: {
|
|
153
|
+
readonly scalar: "string";
|
|
154
|
+
};
|
|
155
|
+
readonly nullable: false;
|
|
156
|
+
readonly list: false;
|
|
157
|
+
readonly lifecycle: readonly [];
|
|
158
|
+
readonly capabilities: {
|
|
159
|
+
readonly select: true;
|
|
160
|
+
readonly filter: readonly ["equals"];
|
|
161
|
+
};
|
|
162
|
+
};
|
|
163
|
+
};
|
|
164
|
+
readonly identifiers: readonly [readonly ["id"]];
|
|
165
|
+
readonly operations: {
|
|
166
|
+
readonly find: {
|
|
167
|
+
readonly many: true;
|
|
168
|
+
};
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
readonly hiddenRes: {
|
|
172
|
+
readonly fields: {
|
|
173
|
+
readonly id: {
|
|
174
|
+
readonly kind: "scalar";
|
|
175
|
+
readonly type: {
|
|
176
|
+
readonly scalar: "string";
|
|
177
|
+
};
|
|
178
|
+
readonly nullable: false;
|
|
179
|
+
readonly list: false;
|
|
180
|
+
readonly lifecycle: readonly [];
|
|
181
|
+
readonly capabilities: {
|
|
182
|
+
readonly select: true;
|
|
183
|
+
readonly filter: readonly ["equals"];
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
};
|
|
187
|
+
readonly identifiers: readonly [readonly ["id"]];
|
|
188
|
+
readonly operations: {
|
|
189
|
+
readonly find: {
|
|
190
|
+
readonly many: true;
|
|
191
|
+
};
|
|
192
|
+
};
|
|
193
|
+
};
|
|
194
|
+
readonly samples: {
|
|
195
|
+
readonly fields: {
|
|
196
|
+
readonly id: {
|
|
197
|
+
readonly kind: "scalar";
|
|
198
|
+
readonly type: {
|
|
199
|
+
readonly scalar: "string";
|
|
200
|
+
};
|
|
201
|
+
readonly nullable: false;
|
|
202
|
+
readonly list: false;
|
|
203
|
+
readonly lifecycle: readonly [];
|
|
204
|
+
readonly capabilities: {
|
|
205
|
+
readonly select: true;
|
|
206
|
+
readonly filter: readonly ["equals"];
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
readonly count: {
|
|
210
|
+
readonly kind: "scalar";
|
|
211
|
+
readonly type: {
|
|
212
|
+
readonly scalar: "bigint" | "datetime" | "decimal" | "bytes";
|
|
213
|
+
};
|
|
214
|
+
readonly nullable: false;
|
|
215
|
+
readonly list: false;
|
|
216
|
+
readonly lifecycle: readonly [];
|
|
217
|
+
readonly capabilities: {
|
|
218
|
+
readonly select: true;
|
|
219
|
+
readonly create: readonly [];
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
readonly at: {
|
|
223
|
+
readonly kind: "scalar";
|
|
224
|
+
readonly type: {
|
|
225
|
+
readonly scalar: "bigint" | "datetime" | "decimal" | "bytes";
|
|
226
|
+
};
|
|
227
|
+
readonly nullable: false;
|
|
228
|
+
readonly list: false;
|
|
229
|
+
readonly lifecycle: readonly [];
|
|
230
|
+
readonly capabilities: {
|
|
231
|
+
readonly select: true;
|
|
232
|
+
readonly create: readonly [];
|
|
233
|
+
};
|
|
234
|
+
};
|
|
235
|
+
readonly amount: {
|
|
236
|
+
readonly kind: "scalar";
|
|
237
|
+
readonly type: {
|
|
238
|
+
readonly scalar: "bigint" | "datetime" | "decimal" | "bytes";
|
|
239
|
+
};
|
|
240
|
+
readonly nullable: false;
|
|
241
|
+
readonly list: false;
|
|
242
|
+
readonly lifecycle: readonly [];
|
|
243
|
+
readonly capabilities: {
|
|
244
|
+
readonly select: true;
|
|
245
|
+
readonly create: readonly [];
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
readonly blob: {
|
|
249
|
+
readonly kind: "scalar";
|
|
250
|
+
readonly type: {
|
|
251
|
+
readonly scalar: "bigint" | "datetime" | "decimal" | "bytes";
|
|
252
|
+
};
|
|
253
|
+
readonly nullable: false;
|
|
254
|
+
readonly list: false;
|
|
255
|
+
readonly lifecycle: readonly [];
|
|
256
|
+
readonly capabilities: {
|
|
257
|
+
readonly select: true;
|
|
258
|
+
readonly create: readonly [];
|
|
259
|
+
};
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
readonly identifiers: readonly [readonly ["id"]];
|
|
263
|
+
readonly operations: {
|
|
264
|
+
readonly find: {
|
|
265
|
+
readonly unique: true;
|
|
266
|
+
};
|
|
267
|
+
readonly create: {
|
|
268
|
+
readonly one: true;
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
/** Deleting an author cascades into its books (an edge under `books`). */
|
|
275
|
+
export declare const CORPUS_REFERENTIAL_ACTIONS: {
|
|
276
|
+
readonly books: readonly [{
|
|
277
|
+
readonly field: "author";
|
|
278
|
+
readonly target: "authors";
|
|
279
|
+
readonly onDelete: "cascade";
|
|
280
|
+
}];
|
|
281
|
+
};
|
|
282
|
+
/**
|
|
283
|
+
* The `where.id` a row sends to make the corpus Framework fail one way
|
|
284
|
+
* (families 10 and 12, "a fake adapter returning the code, labelled so"):
|
|
285
|
+
*
|
|
286
|
+
* - `A4000`, `A4001`, `A4002`, `A3000` — the client guard throws
|
|
287
|
+
* `FrameworkError("A4000")`, denies (`false`), throws
|
|
288
|
+
* `FrameworkError("A4002")`, or throws a plain `Error`;
|
|
289
|
+
* - `A2008`, `A2013`, `A2014` — the Adapter throws `FrameworkError` with that
|
|
290
|
+
* conflict code; `A3001` — it throws a plain `Error`;
|
|
291
|
+
* - `A3002` — a plan step carrying it runs, and the Adapter's transaction then
|
|
292
|
+
* fails to commit;
|
|
293
|
+
* - `A3003` — `samples.find.unique` answers a datetime the wire cannot spell.
|
|
294
|
+
*/
|
|
295
|
+
export declare const CORPUS_TRIGGER: {
|
|
296
|
+
readonly unauthenticated: "A4000";
|
|
297
|
+
readonly guardDenies: "A4001";
|
|
298
|
+
readonly policyDenies: "A4002";
|
|
299
|
+
readonly guardThrows: "A3000";
|
|
300
|
+
readonly conflict: "A2008";
|
|
301
|
+
readonly concurrentModification: "A2013";
|
|
302
|
+
readonly staleSelection: "A2014";
|
|
303
|
+
readonly adapterThrows: "A3001";
|
|
304
|
+
readonly commitFails: "A3002";
|
|
305
|
+
readonly unencodable: "A3003";
|
|
306
|
+
};
|
|
307
|
+
/** The corpus's one client guard: it decides nothing unless a row names a trigger. */
|
|
308
|
+
declare function corpusGuard(context: PipelineContext): boolean;
|
|
309
|
+
/**
|
|
310
|
+
* The corpus's client-scope configuration: what the ClientContract hides or
|
|
311
|
+
* restricts, and `books.label` — a VIRTUAL field added at client scope and
|
|
312
|
+
* computed on read from `id` (F-828, plan S12).
|
|
313
|
+
*/
|
|
314
|
+
export declare const CORPUS_CLIENT_CONFIG: {
|
|
315
|
+
readonly fields: {
|
|
316
|
+
readonly books: {
|
|
317
|
+
readonly label: {
|
|
318
|
+
readonly type: {
|
|
319
|
+
readonly scalar: "string";
|
|
320
|
+
};
|
|
321
|
+
readonly nullable: false;
|
|
322
|
+
readonly list: false;
|
|
323
|
+
readonly lifecycle: readonly ["VIRTUAL"];
|
|
324
|
+
};
|
|
325
|
+
};
|
|
326
|
+
};
|
|
327
|
+
readonly behaviors: {
|
|
328
|
+
readonly books: {
|
|
329
|
+
readonly fields: {
|
|
330
|
+
readonly label: {
|
|
331
|
+
readonly read: {
|
|
332
|
+
readonly dependsOn: readonly ["id"];
|
|
333
|
+
readonly compute: ({ record, }: {
|
|
334
|
+
readonly record: Readonly<Record<string, unknown>>;
|
|
335
|
+
}) => string;
|
|
336
|
+
};
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
readonly pipelines: {
|
|
342
|
+
readonly guards: readonly [typeof corpusGuard];
|
|
343
|
+
};
|
|
344
|
+
readonly restrictions: {
|
|
345
|
+
readonly authors: {
|
|
346
|
+
readonly fields: {
|
|
347
|
+
readonly secret: {
|
|
348
|
+
readonly hidden: true;
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
};
|
|
352
|
+
readonly secrets: {
|
|
353
|
+
readonly operations: {
|
|
354
|
+
readonly find: {
|
|
355
|
+
readonly many: false;
|
|
356
|
+
};
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
readonly hiddenRes: {
|
|
360
|
+
readonly hidden: true;
|
|
361
|
+
};
|
|
362
|
+
};
|
|
363
|
+
};
|
|
364
|
+
/** The corpus Framework's mount point; every row's path is relative to it. */
|
|
365
|
+
export declare const CORPUS_ENTRYPOINT = "/api";
|
|
366
|
+
/**
|
|
367
|
+
* The corpus ClientContract's hash: what a generated client for it sends as
|
|
368
|
+
* `Aventara-Contract-Hash`. A literal, as a generated client holds it;
|
|
369
|
+
* `corpus-contract.spec.ts` fails, naming this constant, when the compiled
|
|
370
|
+
* contract moves.
|
|
371
|
+
*/
|
|
372
|
+
export declare const CORPUS_CLIENT_CONTRACT_HASH = "sha256:07b1a75a6e8e88e30115ae81bcf7e3a12fa493bddce995a01867e2381bd158d0";
|
|
373
|
+
/**
|
|
374
|
+
* The corpus ClientContract as `GET /_contract` serves it: its JCS-canonical
|
|
375
|
+
* bytes (Q8), `protocol.hash` included (M22). A literal, as a host must
|
|
376
|
+
* serve it byte for byte; `corpus-contract.spec.ts` fails, naming this
|
|
377
|
+
* constant, when the compiled contract moves.
|
|
378
|
+
*/
|
|
379
|
+
export declare const CORPUS_CLIENT_CONTRACT_DOCUMENT = "{\"enums\":{},\"limits\":{\"maxBooleanNodes\":50,\"maxListLimit\":250,\"maxNestingDepth\":12,\"maxRequestBytes\":1048576,\"maxTransactionOperations\":20},\"protocol\":{\"hash\":\"sha256:07b1a75a6e8e88e30115ae81bcf7e3a12fa493bddce995a01867e2381bd158d0\",\"version\":1},\"resources\":{\"authors\":{\"fields\":{\"id\":{\"capabilities\":{\"filter\":[\"equals\"],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}},\"name\":{\"capabilities\":{\"create\":[],\"filter\":[\"equals\"],\"select\":true,\"update\":[]},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}}},\"identifiers\":[[\"id\"]],\"operations\":{\"create\":{\"count\":true,\"many\":true,\"one\":true},\"delete\":{\"count\":true,\"first\":true,\"many\":true,\"unique\":true},\"find\":{\"count\":true,\"first\":true,\"many\":true,\"unique\":true},\"update\":{\"count\":true,\"first\":true,\"many\":true,\"unique\":true},\"upsert\":{\"unique\":true}}},\"books\":{\"fields\":{\"authorId\":{\"capabilities\":{\"filter\":[\"equals\"],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}},\"id\":{\"capabilities\":{\"filter\":[\"equals\"],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}},\"label\":{\"capabilities\":{\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[\"COMPUTED_ON_READ\",\"VIRTUAL\"],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}}},\"identifiers\":[[\"id\"]],\"operations\":{\"find\":{\"many\":true}}},\"samples\":{\"fields\":{\"amount\":{\"capabilities\":{\"create\":[],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"decimal\"}},\"at\":{\"capabilities\":{\"create\":[],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"datetime\"}},\"blob\":{\"capabilities\":{\"create\":[],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"bytes\"}},\"count\":{\"capabilities\":{\"create\":[],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"bigint\"}},\"id\":{\"capabilities\":{\"filter\":[\"equals\"],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}}},\"identifiers\":[[\"id\"]],\"operations\":{\"create\":{\"one\":true},\"find\":{\"unique\":true}}},\"secrets\":{\"fields\":{\"id\":{\"capabilities\":{\"filter\":[\"equals\"],\"select\":true},\"kind\":\"scalar\",\"lifecycle\":[],\"list\":false,\"nullable\":false,\"type\":{\"scalar\":\"string\"}}},\"identifiers\":[[\"id\"]],\"operations\":{}}},\"scalars\":{\"bigint\":{\"builtin\":true},\"bytes\":{\"builtin\":true},\"datetime\":{\"builtin\":true},\"decimal\":{\"builtin\":true},\"string\":{\"builtin\":true}},\"transactions\":\"interactive\"}";
|
|
380
|
+
/**
|
|
381
|
+
* The hash of the corpus's SECOND ClientContract — the same model and
|
|
382
|
+
* configuration with `transactions: "none"` (family 6's `/_transactions`
|
|
383
|
+
* absence). A row targets it by sending this hash, exactly as a client
|
|
384
|
+
* generated against it would; the runner gives the row the Framework whose
|
|
385
|
+
* ClientContract it names (the director, 2026-10-05). A literal, held to the
|
|
386
|
+
* compiled value by `corpus-contract.spec.ts`.
|
|
387
|
+
*/
|
|
388
|
+
export declare const CORPUS_NONE_CLIENT_CONTRACT_HASH = "sha256:d333e8396b9bf9127e0859ed69b9874f230058a597e2129e6b9e9b380daef618";
|
|
389
|
+
/** The one record the corpus Adapter knows. */
|
|
390
|
+
export declare const CORPUS_AUTHOR: {
|
|
391
|
+
readonly id: "a1";
|
|
392
|
+
readonly name: "Ada";
|
|
393
|
+
};
|
|
394
|
+
/** The `where.id` that matches nothing. */
|
|
395
|
+
export declare const CORPUS_NOBODY = "nobody";
|
|
396
|
+
/**
|
|
397
|
+
* The one `samples` record, in runtime forms — what an Adapter hands core,
|
|
398
|
+
* and what the HTTP encoders must spell in wire forms (P1).
|
|
399
|
+
*/
|
|
400
|
+
export declare const CORPUS_SAMPLE: {
|
|
401
|
+
readonly id: "s1";
|
|
402
|
+
readonly count: 9007199254740993n;
|
|
403
|
+
readonly at: Date;
|
|
404
|
+
readonly amount: Decimal;
|
|
405
|
+
readonly blob: Uint8Array<ArrayBuffer>;
|
|
406
|
+
};
|
|
407
|
+
/**
|
|
408
|
+
* A fresh corpus Framework, and the count of operations its Adapter has been
|
|
409
|
+
* handed so far — a row's `adapterCalls` is read from it. `contractHash`
|
|
410
|
+
* selects which corpus ClientContract it serves: the `transactions: "none"`
|
|
411
|
+
* one when it is {@link CORPUS_NONE_CLIENT_CONTRACT_HASH}, the main one
|
|
412
|
+
* otherwise (a stale or absent hash included).
|
|
413
|
+
*/
|
|
414
|
+
export declare function createCorpusFramework(contractHash?: string): Promise<{
|
|
415
|
+
readonly framework: Framework;
|
|
416
|
+
readonly adapterCalls: () => number;
|
|
417
|
+
}>;
|
|
418
|
+
export {};
|