@zhin.js/middleware 1.1.2 → 1.1.3

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.
@@ -15,6 +15,6 @@ export declare class MiddlewareIndex {
15
15
  readonly $projection: "zhin.middleware-index/1";
16
16
  constructor(slots: readonly Readonly<CapabilitySlot<MiddlewareDefinition>>[], snapshot: RuntimeSnapshot);
17
17
  list(): readonly MiddlewareDescriptor[];
18
- run<TInput>(input: TInput, terminal?: MiddlewareNext, target?: MiddlewareTarget): Promise<void>;
18
+ run<TInput>(input: TInput, terminal?: MiddlewareNext, target?: MiddlewareTarget, operationSnapshot?: RuntimeSnapshot): Promise<void>;
19
19
  }
20
20
  export declare function isMiddlewareIndex(value: unknown): value is MiddlewareIndex;
@@ -20,7 +20,7 @@ export class MiddlewareIndex {
20
20
  list() {
21
21
  return this.#records.map(({ slot: _slot, ...descriptor }) => descriptor);
22
22
  }
23
- async run(input, terminal = async () => undefined, target = 'inbound') {
23
+ async run(input, terminal = async () => undefined, target = 'inbound', operationSnapshot = this.snapshot) {
24
24
  const clientAdapter = operationClientAdapter(input);
25
25
  const records = this.#records.filter((record) => record.target === target && (!record.adapter || record.adapter === clientAdapter));
26
26
  let cursor = -1;
@@ -32,7 +32,7 @@ export class MiddlewareIndex {
32
32
  if (!record)
33
33
  return terminal();
34
34
  const context = {
35
- ...createCapabilityContext(this.snapshot, record.owner),
35
+ ...createCapabilityContext(operationSnapshot, record.owner),
36
36
  input,
37
37
  };
38
38
  Object.defineProperty(context, '$client', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhin.js/middleware",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Convention-based Middleware Feature for Zhin Plugin Runtime",
5
5
  "type": "module",
6
6
  "main": "./lib/index.js",
@@ -55,6 +55,7 @@ export class MiddlewareIndex {
55
55
  input: TInput,
56
56
  terminal: MiddlewareNext = async () => undefined,
57
57
  target: MiddlewareTarget = 'inbound',
58
+ operationSnapshot: RuntimeSnapshot = this.snapshot,
58
59
  ): Promise<void> {
59
60
  const clientAdapter = operationClientAdapter(input);
60
61
  const records = this.#records.filter((record) =>
@@ -66,7 +67,7 @@ export class MiddlewareIndex {
66
67
  const record = records[index];
67
68
  if (!record) return terminal();
68
69
  const context = {
69
- ...createCapabilityContext(this.snapshot, record.owner),
70
+ ...createCapabilityContext(operationSnapshot, record.owner),
70
71
  input,
71
72
  } as MiddlewareContext<TInput>;
72
73
  Object.defineProperty(context, '$client', {