@zhin.js/testing 1.0.4 → 1.0.6

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/src/index.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { realpath } from 'node:fs/promises';
2
2
  import { resolve } from 'node:path';
3
3
  import { defineAdapter, type AdapterDefinition, type AdapterSegmentPolicy,
4
- type EndpointIdentity, type EndpointEventSink, type EndpointIncomingMessage, type EndpointSendRequest } from '@zhin.js/adapter';
4
+ type EndpointIdentity, type EndpointEventSink, type EndpointIncomingMessage, type EndpointSendRequest } from 'zhin.js/adapter';
5
5
  import { ImRuntime, type ConversationAddress, type MessageDispatchResult,
6
- type SendContent } from '@zhin.js/core/runtime';
7
- import { type ConversationRef, type DeliveryReceipt } from '@zhin.js/im-contract';
8
- import { rootPluginId, type ConfigPatch, type PluginId, type RuntimeConfigDocument } from '@zhin.js/plugin-runtime';
6
+ type RuntimeMessageDiagnosticsReader, type SendContent } from 'zhin.js/core/runtime';
7
+ import { type ConversationRef, type DeliveryReceipt } from 'zhin.js';
8
+ import { rootPluginId, type ConfigDocumentPort, type ConfigPatch, type PluginId, type RuntimeConfigDocument } from 'zhin.js/plugin-runtime';
9
9
  import { NativeDevelopmentModuleRuntime, NodePackageResolver, RootRuntime,
10
10
  type ModuleRuntime, type RootResourceInstaller } from '@zhin.js/runtime';
11
11
  import { captureDeliveryValue } from './delivery-capture.js';
@@ -13,16 +13,21 @@ import { withTestEndpoints } from './test-module-runtime.js';
13
13
 
14
14
  export { FakeClock, FakeScheduleRootHost, parseCron, type FakeScheduledJob } from './fake-clock.js';
15
15
  export { FakeDatabaseRootHost, FakeOutboundRootHost, type FakeOutboundCall } from './fake-hosts.js';
16
- export { FakePlugin, createFakePlugin, runPluginSetup, fakeResource,
17
- type FakePluginOptions, type FakeResource, type FakeRegisteredFeature } from './fake-plugin.js';
16
+ export { FakePlugin, createFakePlugin, runPluginSetup, resolvePluginConfig, PluginConfigValidationError, fakeResource,
17
+ type FakePluginOptions, type RunPluginSetupOptions, type FakeResource, type FakeRegisteredFeature } from './fake-plugin.js';
18
18
  export { fakeOf } from './partial.js';
19
19
  export { createFakeMessage, createCommandContext, runCommand, runMiddleware, runHandler,
20
- type FakeMessage, type FakeMessageInit, type RunCommandOptions, type RunMiddlewareResult } from './fake-runners.js';
20
+ createToolContext, runTool, toolOriginFromMessage,
21
+ type FakeMessage, type RunToolOptions, type FakeMessageInit, type RunCommandOptions, type RunMiddlewareResult } from './fake-runners.js';
21
22
 
22
23
  export interface PluginTestKitOptions {
23
24
  /** A real, disposable test app with its own package.json, plugin entry, dependencies and mounts. */
24
25
  readonly projectRoot: string;
25
- readonly config?: RuntimeConfigDocument;
26
+ /**
27
+ * A v2 document, or a file-backed document such as `createConfigDocument(path)` from
28
+ * `@zhin.js/config-file` when the test must share the same file authority as `zhin start`.
29
+ */
30
+ readonly config?: RuntimeConfigDocument | ConfigDocumentPort;
26
31
  /** Adapter names reserved for synthetic transports, default: ['test']. */
27
32
  readonly endpoints?: readonly string[];
28
33
  /** Default endpoint renders HTML and buttons as text; override to verify negotiated capabilities. */
@@ -125,6 +130,10 @@ export class PluginTestKit {
125
130
 
126
131
  /** The same PermissionHost consumed by real command admission. */
127
132
  get permissions(): ImRuntime['permissionHost'] { return this.#im.permissionHost; }
133
+ /** The same bounded, body-free reader the Console serves at `GET /api/messages/diagnostics`. */
134
+ get messageDiagnostics(): RuntimeMessageDiagnosticsReader { return this.#im.messageDiagnostics; }
135
+ /** The committed-snapshot authority Console routes read (tasks, permissions); read-only use in tests. */
136
+ get snapshots(): RootRuntime['snapshots'] { return this.#root.snapshots; }
128
137
  get generation(): number { return this.#root.snapshot.generation; }
129
138
  get deliveries(): readonly TestDelivery[] { return Object.freeze(this.#attempts.map(item => captureDeliveryValue(item))); }
130
139
  clearDeliveries(): void { this.#attempts.splice(0); }
@@ -1,6 +1,6 @@
1
1
  import { resolve } from 'node:path';
2
- import { definePlugin, type PluginDefinition } from '@zhin.js/plugin-runtime';
3
- import type { AdapterDefinition } from '@zhin.js/adapter';
2
+ import { definePlugin, type PluginDefinition } from 'zhin.js/plugin-runtime';
3
+ import type { AdapterDefinition } from 'zhin.js/adapter';
4
4
  import type { ModuleRuntime } from '@zhin.js/runtime';
5
5
 
6
6
  /** Only the test application's setup is decorated; discovery and module caching stay native. */