@zhin.js/middleware 1.1.11 → 1.1.12
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 +1 -0
- package/package.json +3 -3
- package/src/definition.ts +11 -2
- package/src/middleware-index.ts +2 -0
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
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zhin.js/middleware",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
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.11",
|
|
20
|
+
"@zhin.js/plugin-runtime": "1.1.19"
|
|
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
|
}
|