@zhin.js/middleware 1.1.11 → 1.1.13
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/lib/definition.d.ts +5 -0
- package/lib/middleware-index.d.ts +1 -0
- package/lib/middleware-index.js +3 -2
- package/package.json +3 -3
- package/src/definition.ts +11 -2
- package/src/middleware-index.ts +4 -2
package/lib/definition.d.ts
CHANGED
|
@@ -29,6 +29,8 @@ export type MiddlewareDefinition<TInput = unknown, TConfig = unknown, TAdapter e
|
|
|
29
29
|
handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: MiddlewareNext): unknown;
|
|
30
30
|
} | {
|
|
31
31
|
readonly target: 'outbound';
|
|
32
|
+
/** Opt in to cumulative prefixes. Previously published text, format and addressing must stay stable. */
|
|
33
|
+
readonly incremental?: true;
|
|
32
34
|
handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: OutboundMiddlewareNext): void | Promise<void>;
|
|
33
35
|
});
|
|
34
36
|
declare module '@zhin.js/plugin-runtime' {
|
|
@@ -50,6 +52,9 @@ type AuthoringForAdapter<TInput, TConfig, TAdapter extends string | undefined> =
|
|
|
50
52
|
handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: MiddlewareNext): unknown;
|
|
51
53
|
} | {
|
|
52
54
|
readonly target: 'outbound';
|
|
55
|
+
/** Opt in to cumulative prefixes. Previously published text, format and addressing must stay stable;
|
|
56
|
+
* do not repeat approvals, external sends or other side effects. */
|
|
57
|
+
readonly incremental?: true;
|
|
53
58
|
handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: OutboundMiddlewareNext): void | Promise<void>;
|
|
54
59
|
});
|
|
55
60
|
/** @internal Shape shared with the typed IM facade; not a separate authoring API. */
|
|
@@ -19,6 +19,7 @@ export interface MiddlewareDescriptor {
|
|
|
19
19
|
readonly target: MiddlewareTarget;
|
|
20
20
|
readonly order: number;
|
|
21
21
|
readonly adapter?: string;
|
|
22
|
+
readonly incremental?: true;
|
|
22
23
|
}
|
|
23
24
|
/** @internal Runtime middleware executor. */
|
|
24
25
|
export declare class MiddlewareIndex {
|
package/lib/middleware-index.js
CHANGED
|
@@ -16,6 +16,7 @@ export class MiddlewareIndex {
|
|
|
16
16
|
target: slot.definition.target,
|
|
17
17
|
order: slot.definition.order,
|
|
18
18
|
...(slot.definition.adapter ? { adapter: slot.definition.adapter } : {}),
|
|
19
|
+
...(slot.definition.target === 'outbound' && slot.definition.incremental === true ? { incremental: true } : {}),
|
|
19
20
|
slot,
|
|
20
21
|
})).sort((left, right) => compareMiddleware(left, right, topology)));
|
|
21
22
|
}
|
|
@@ -41,7 +42,7 @@ export class MiddlewareIndex {
|
|
|
41
42
|
return terminal();
|
|
42
43
|
const authorInput = bindOperationInput(input, record.owner, operationSnapshot);
|
|
43
44
|
const context = {
|
|
44
|
-
...createCapabilityContext(operationSnapshot, record.owner, undefined, readOperationSession(authorInput, record.adapter)?.signal),
|
|
45
|
+
...createCapabilityContext({ snapshot: operationSnapshot, ownerId: record.owner, admission: undefined, signal: readOperationSession(authorInput, record.adapter)?.signal }),
|
|
45
46
|
input: authorInput,
|
|
46
47
|
};
|
|
47
48
|
Object.defineProperty(context, 'session', {
|
|
@@ -75,7 +76,7 @@ export class MiddlewareIndex {
|
|
|
75
76
|
throw new Error('Invalid inbound Middleware');
|
|
76
77
|
const authorInput = bindOperationInput(input, record.owner, operationSnapshot);
|
|
77
78
|
const context = {
|
|
78
|
-
...createCapabilityContext(operationSnapshot, record.owner, undefined, readOperationSession(authorInput, record.adapter)?.signal), input: authorInput,
|
|
79
|
+
...createCapabilityContext({ snapshot: operationSnapshot, ownerId: record.owner, admission: undefined, signal: readOperationSession(authorInput, record.adapter)?.signal }), input: authorInput,
|
|
79
80
|
};
|
|
80
81
|
Object.defineProperty(context, 'session', {
|
|
81
82
|
enumerable: true, get: () => readOperationSession(authorInput, record.adapter),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/middleware",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.13",
|
|
4
4
|
"description": "Convention-based Middleware Feature for Zhin Plugin Runtime",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./lib/index.js",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"src"
|
|
17
17
|
],
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@zhin.js/
|
|
20
|
-
"@zhin.js/
|
|
19
|
+
"@zhin.js/feature-kit": "1.1.12",
|
|
20
|
+
"@zhin.js/plugin-runtime": "1.1.20"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@types/node": "^26.1.2",
|
package/src/definition.ts
CHANGED
|
@@ -47,7 +47,10 @@ export type MiddlewareDefinition<
|
|
|
47
47
|
TAdapter extends string | undefined = string | undefined,
|
|
48
48
|
> = MiddlewareDefinitionBase<TAdapter> & (
|
|
49
49
|
| { readonly target: 'inbound'; handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: MiddlewareNext): unknown }
|
|
50
|
-
| { readonly target: 'outbound';
|
|
50
|
+
| { readonly target: 'outbound';
|
|
51
|
+
/** Opt in to cumulative prefixes. Previously published text, format and addressing must stay stable. */
|
|
52
|
+
readonly incremental?: true;
|
|
53
|
+
handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: OutboundMiddlewareNext): void | Promise<void> }
|
|
51
54
|
);
|
|
52
55
|
|
|
53
56
|
declare module '@zhin.js/plugin-runtime' {
|
|
@@ -71,7 +74,13 @@ type AuthoringForAdapter<TInput, TConfig, TAdapter extends string | undefined> =
|
|
|
71
74
|
readonly order?: number;
|
|
72
75
|
} & (
|
|
73
76
|
| { readonly target?: 'inbound'; handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: MiddlewareNext): unknown }
|
|
74
|
-
| {
|
|
77
|
+
| {
|
|
78
|
+
readonly target: 'outbound';
|
|
79
|
+
/** Opt in to cumulative prefixes. Previously published text, format and addressing must stay stable;
|
|
80
|
+
* do not repeat approvals, external sends or other side effects. */
|
|
81
|
+
readonly incremental?: true;
|
|
82
|
+
handle(context: MiddlewareContext<TInput, TConfig, TAdapter>, next: OutboundMiddlewareNext): void | Promise<void>;
|
|
83
|
+
}
|
|
75
84
|
);
|
|
76
85
|
|
|
77
86
|
/** @internal Shape shared with the typed IM facade; not a separate authoring API. */
|
package/src/middleware-index.ts
CHANGED
|
@@ -36,6 +36,7 @@ export interface MiddlewareDescriptor {
|
|
|
36
36
|
readonly target: MiddlewareTarget;
|
|
37
37
|
readonly order: number;
|
|
38
38
|
readonly adapter?: string;
|
|
39
|
+
readonly incremental?: true;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
interface MiddlewareRecord extends MiddlewareDescriptor {
|
|
@@ -60,6 +61,7 @@ export class MiddlewareIndex {
|
|
|
60
61
|
target: slot.definition.target,
|
|
61
62
|
order: slot.definition.order,
|
|
62
63
|
...(slot.definition.adapter ? { adapter: slot.definition.adapter } : {}),
|
|
64
|
+
...(slot.definition.target === 'outbound' && slot.definition.incremental === true ? { incremental: true as const } : {}),
|
|
63
65
|
slot,
|
|
64
66
|
})).sort((left, right) => compareMiddleware(left, right, topology)));
|
|
65
67
|
}
|
|
@@ -94,7 +96,7 @@ export class MiddlewareIndex {
|
|
|
94
96
|
if (!record) return terminal();
|
|
95
97
|
const authorInput = bindOperationInput(input, record.owner, operationSnapshot);
|
|
96
98
|
const context = {
|
|
97
|
-
...createCapabilityContext(operationSnapshot, record.owner, undefined, readOperationSession(authorInput, record.adapter)?.signal),
|
|
99
|
+
...createCapabilityContext({ snapshot: operationSnapshot, ownerId: record.owner, admission: undefined, signal: readOperationSession(authorInput, record.adapter)?.signal }),
|
|
98
100
|
input: authorInput,
|
|
99
101
|
} as MiddlewareContext<TInput>;
|
|
100
102
|
Object.defineProperty(context, 'session', {
|
|
@@ -130,7 +132,7 @@ export class MiddlewareIndex {
|
|
|
130
132
|
if (definition.target !== 'inbound') throw new Error('Invalid inbound Middleware');
|
|
131
133
|
const authorInput = bindOperationInput(input, record.owner, operationSnapshot);
|
|
132
134
|
const context = {
|
|
133
|
-
...createCapabilityContext(operationSnapshot, record.owner, undefined, readOperationSession(authorInput, record.adapter)?.signal), input: authorInput,
|
|
135
|
+
...createCapabilityContext({ snapshot: operationSnapshot, ownerId: record.owner, admission: undefined, signal: readOperationSession(authorInput, record.adapter)?.signal }), input: authorInput,
|
|
134
136
|
} as MiddlewareContext<TInput>;
|
|
135
137
|
Object.defineProperty(context, 'session', {
|
|
136
138
|
enumerable: true, get: () => readOperationSession(authorInput, record.adapter),
|