@nifrajs/core 1.9.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assurance.d.ts +18 -0
- package/dist/assurance.d.ts.map +1 -1
- package/dist/assurance.js +28 -1
- package/dist/assurance.js.map +1 -1
- package/dist/budget.d.ts +91 -0
- package/dist/budget.d.ts.map +1 -0
- package/dist/budget.js +172 -0
- package/dist/budget.js.map +1 -0
- package/dist/capabilities.d.ts +146 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +283 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/classification.d.ts +39 -0
- package/dist/classification.d.ts.map +1 -0
- package/dist/classification.js +153 -0
- package/dist/classification.js.map +1 -0
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/idempotency.d.ts +137 -0
- package/dist/idempotency.d.ts.map +1 -0
- package/dist/idempotency.js +306 -0
- package/dist/idempotency.js.map +1 -0
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/capability-runtime.d.ts +16 -0
- package/dist/internal/capability-runtime.d.ts.map +1 -0
- package/dist/internal/capability-runtime.js +27 -0
- package/dist/internal/capability-runtime.js.map +1 -0
- package/dist/internal/route-assurance.d.ts +1 -0
- package/dist/internal/route-assurance.d.ts.map +1 -1
- package/dist/internal/route-assurance.js +1 -0
- package/dist/internal/route-assurance.js.map +1 -1
- package/dist/invariants.d.ts +66 -0
- package/dist/invariants.d.ts.map +1 -0
- package/dist/invariants.js +483 -0
- package/dist/invariants.js.map +1 -0
- package/dist/ledger.d.ts +154 -0
- package/dist/ledger.d.ts.map +1 -0
- package/dist/ledger.js +271 -0
- package/dist/ledger.js.map +1 -0
- package/dist/manifest.d.ts +81 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +394 -0
- package/dist/manifest.js.map +1 -0
- package/dist/mount.d.ts +18 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +11 -0
- package/dist/mount.js.map +1 -0
- package/dist/reflection.d.ts +4 -0
- package/dist/reflection.d.ts.map +1 -1
- package/dist/reflection.js +9 -0
- package/dist/reflection.js.map +1 -1
- package/dist/server/context.d.ts +50 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/contract.d.ts +8 -1
- package/dist/server/contract.d.ts.map +1 -1
- package/dist/server/contract.js +11 -1
- package/dist/server/contract.js.map +1 -1
- package/dist/server/server.d.ts +56 -2
- package/dist/server/server.d.ts.map +1 -1
- package/dist/server/server.js +294 -17
- package/dist/server/server.js.map +1 -1
- package/package.json +36 -4
- package/src/assurance.ts +48 -1
- package/src/budget.ts +267 -0
- package/src/capabilities.ts +486 -0
- package/src/classification.ts +189 -0
- package/src/errors.ts +2 -0
- package/src/idempotency.ts +420 -0
- package/src/index.ts +8 -1
- package/src/internal/capability-runtime.ts +49 -0
- package/src/internal/route-assurance.ts +1 -0
- package/src/invariants.ts +600 -0
- package/src/ledger.ts +430 -0
- package/src/manifest.ts +543 -0
- package/src/mount.ts +24 -0
- package/src/reflection.ts +18 -0
- package/src/server/context.ts +54 -1
- package/src/server/contract.ts +19 -2
- package/src/server/server.ts +463 -26
package/src/server/contract.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { DataClassification } from "../classification.ts"
|
|
1
2
|
import { RouteConfigError } from "../errors.ts"
|
|
3
|
+
import { normalizeRouteCapabilities } from "../internal/capability-runtime.ts"
|
|
2
4
|
import { METHODS, type Method } from "../router/router.ts"
|
|
3
5
|
import type { InferOutput, StandardSchemaV1 } from "../schema/standard.ts"
|
|
4
|
-
import type { Context, Params, RouteSchema } from "./context.ts"
|
|
6
|
+
import type { Context, IdempotencyConfig, Params, RouteSchema } from "./context.ts"
|
|
5
7
|
import type { OutputOf } from "./registry.ts"
|
|
6
8
|
import { Server } from "./server.ts"
|
|
7
9
|
|
|
@@ -27,6 +29,12 @@ export interface OperationDef {
|
|
|
27
29
|
readonly body?: StandardSchemaV1
|
|
28
30
|
readonly query?: StandardSchemaV1
|
|
29
31
|
readonly response?: StandardSchemaV1
|
|
32
|
+
/** Declared effect tokens, carried into route reflection and capability assurance. */
|
|
33
|
+
readonly capabilities?: readonly string[]
|
|
34
|
+
/** Dedupe retries of this operation on an `Idempotency-Key` header (see {@link RouteSchema.idempotency}). */
|
|
35
|
+
readonly idempotency?: IdempotencyConfig
|
|
36
|
+
/** Highest data-sensitivity the response carries (see {@link RouteSchema.classification}). */
|
|
37
|
+
readonly classification?: DataClassification
|
|
30
38
|
/** Short summary (OpenAPI `summary`). */
|
|
31
39
|
readonly summary?: string
|
|
32
40
|
/** Longer description (OpenAPI `description`, CommonMark). */
|
|
@@ -167,6 +175,7 @@ export function defineContract<const C extends ContractShape>(contract: C): C {
|
|
|
167
175
|
if (seen.has(key)) {
|
|
168
176
|
throw new RouteConfigError("DUPLICATE_ROUTE", `duplicate operation route: ${key}`)
|
|
169
177
|
}
|
|
178
|
+
normalizeRouteCapabilities(op.capabilities)
|
|
170
179
|
seen.add(key)
|
|
171
180
|
}
|
|
172
181
|
return contract
|
|
@@ -219,11 +228,19 @@ export function implement<const C extends ContractShape, H extends HandlersFor<C
|
|
|
219
228
|
// once here at bind time, not per request — it just carries a reference to the op's existing schema.
|
|
220
229
|
// A response-less op still yields `undefined`, byte-identical to before.
|
|
221
230
|
const schema: RouteSchema | undefined =
|
|
222
|
-
op.body !== undefined ||
|
|
231
|
+
op.body !== undefined ||
|
|
232
|
+
op.query !== undefined ||
|
|
233
|
+
op.response !== undefined ||
|
|
234
|
+
op.capabilities !== undefined ||
|
|
235
|
+
op.idempotency !== undefined ||
|
|
236
|
+
op.classification !== undefined
|
|
223
237
|
? {
|
|
224
238
|
...(op.body !== undefined ? { body: op.body } : {}),
|
|
225
239
|
...(op.query !== undefined ? { query: op.query } : {}),
|
|
226
240
|
...(op.response !== undefined ? { response: op.response } : {}),
|
|
241
|
+
...(op.capabilities !== undefined ? { capabilities: op.capabilities } : {}),
|
|
242
|
+
...(op.idempotency !== undefined ? { idempotency: op.idempotency } : {}),
|
|
243
|
+
...(op.classification !== undefined ? { classification: op.classification } : {}),
|
|
227
244
|
}
|
|
228
245
|
: undefined
|
|
229
246
|
app.register(
|