Skip to content

Commit 3400321

Browse files
committed
refactor: remove unused target parsing shim
1 parent 81713c1 commit 3400321

6 files changed

Lines changed: 22 additions & 99 deletions

File tree

docs/plugins/sdk-migration.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -475,9 +475,8 @@ releases.
475475
cron delivery, and session routing.
476476

477477
Do not add new uses of `ChannelMessagingAdapter.parseExplicitTarget` or
478-
the parser-backed route helpers (`parseExplicitTargetForChannel`,
479-
`parseExplicitTargetForLoadedChannel`, `resolveRouteTargetForChannel`, or
480-
`resolveRouteTargetForLoadedChannel`) or
478+
the parser-backed loaded-route helpers (`parseExplicitTargetForLoadedChannel`
479+
or `resolveRouteTargetForLoadedChannel`) or
481480
`resolveChannelRouteTargetWithParser(...)` from `plugin-sdk/channel-route`.
482481
Those hooks are deprecated and remain only for older plugins during the
483482
migration window. New channel plugins should use

src/channels/plugins/target-parsing.test.ts

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,10 @@ import { setActivePluginRegistry } from "../../plugins/runtime.js";
77
import { createTestRegistry } from "../../test-utils/channel-plugins.js";
88
import {
99
comparableChannelTargetsMatch,
10-
parseExplicitTargetForChannel,
1110
parseExplicitTargetForLoadedChannel,
12-
resolveComparableTargetForChannel,
13-
resolveRouteTargetForChannel,
11+
resolveComparableTargetForLoadedChannel,
1412
resolveRouteTargetForLoadedChannel,
15-
} from "./target-parsing.js";
13+
} from "./target-parsing-loaded.js";
1614

1715
function parseThreadedTargetForTest(raw: string): {
1816
to: string;
@@ -99,27 +97,27 @@ function setMinimalTargetParsingRegistry(): void {
9997
);
10098
}
10199

102-
describe("parseExplicitTargetForChannel", () => {
100+
describe("parseExplicitTargetForLoadedChannel", () => {
103101
beforeEach(() => {
104102
setMinimalTargetParsingRegistry();
105103
});
106104

107105
it("parses threaded targets via the registered channel plugin contract", () => {
108106
expect(
109-
parseExplicitTargetForChannel("mock-threaded", "threaded:group:room-a:topic:77"),
107+
parseExplicitTargetForLoadedChannel("mock-threaded", "threaded:group:room-a:topic:77"),
110108
).toEqual({
111109
to: "room-a",
112110
threadId: 77,
113111
chatType: "group",
114112
});
115-
expect(parseExplicitTargetForChannel("mock-threaded", "room-a")).toEqual({
113+
expect(parseExplicitTargetForLoadedChannel("mock-threaded", "room-a")).toEqual({
116114
to: "room-a",
117115
chatType: undefined,
118116
});
119117
});
120118

121119
it("parses registered non-bundled channel targets via the active plugin contract", () => {
122-
expect(parseExplicitTargetForChannel("demo-target", "team-room")).toEqual({
120+
expect(parseExplicitTargetForLoadedChannel("demo-target", "team-room")).toEqual({
123121
to: "TEAM-ROOM",
124122
chatType: "direct",
125123
});
@@ -131,7 +129,7 @@ describe("parseExplicitTargetForChannel", () => {
131129

132130
it("builds route targets from plugin-owned grammar", () => {
133131
expect(
134-
resolveRouteTargetForChannel({
132+
resolveRouteTargetForLoadedChannel({
135133
channel: "mock-threaded",
136134
rawTarget: "threaded:group:room-a:topic:77",
137135
}),
@@ -157,11 +155,11 @@ describe("parseExplicitTargetForChannel", () => {
157155
});
158156

159157
it("matches route targets when only the plugin grammar differs", () => {
160-
const topicTarget = resolveRouteTargetForChannel({
158+
const topicTarget = resolveRouteTargetForLoadedChannel({
161159
channel: "mock-threaded",
162160
rawTarget: "threaded:room-a:topic:77",
163161
});
164-
const bareTarget = resolveRouteTargetForChannel({
162+
const bareTarget = resolveRouteTargetForLoadedChannel({
165163
channel: "mock-threaded",
166164
rawTarget: "room-a",
167165
});
@@ -181,11 +179,11 @@ describe("parseExplicitTargetForChannel", () => {
181179
});
182180

183181
it("compares numeric and string thread ids through the shared route contract", () => {
184-
const numericThread = resolveRouteTargetForChannel({
182+
const numericThread = resolveRouteTargetForLoadedChannel({
185183
channel: "mock-threaded",
186184
rawTarget: "threaded:room-a:topic:77",
187185
});
188-
const stringThread = resolveRouteTargetForChannel({
186+
const stringThread = resolveRouteTargetForLoadedChannel({
189187
channel: "mock-threaded",
190188
rawTarget: "room-a",
191189
fallbackThreadId: "77",
@@ -200,11 +198,11 @@ describe("parseExplicitTargetForChannel", () => {
200198
});
201199

202200
it("keeps deprecated comparable target helpers as route wrappers", () => {
203-
const numericThread = resolveComparableTargetForChannel({
201+
const numericThread = resolveComparableTargetForLoadedChannel({
204202
channel: "mock-threaded",
205203
rawTarget: "threaded:room-a:topic:77",
206204
});
207-
const stringThread = resolveRouteTargetForChannel({
205+
const stringThread = resolveRouteTargetForLoadedChannel({
208206
channel: "mock-threaded",
209207
rawTarget: "room-a",
210208
fallbackThreadId: "77",

src/channels/plugins/target-parsing.ts

Lines changed: 0 additions & 60 deletions
This file was deleted.

src/plugins/compat/registry.test.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const deprecatedTargetParserCallPattern =
1919
/\.parseExplicitTarget\?\.\s*\(|parseExplicitTargetFor(?:Channel|LoadedChannel)\s*\(|resolveRouteTargetFor(?:Channel|LoadedChannel)\s*\(/u;
2020
const deprecatedTargetParserCompatFiles = new Set([
2121
"src/auto-reply/reply/group-id.ts",
22-
"src/channels/plugins/target-parsing.ts",
2322
"src/channels/plugins/target-parsing-loaded.ts",
2423
"src/channels/plugins/target-parsing.test.ts",
2524
"src/infra/outbound/outbound-session.ts",
@@ -193,16 +192,6 @@ const knownDeprecatedSurfaceMarkers = [
193192
file: "src/channels/plugins/target-parsing-loaded.ts",
194193
marker: "resolveRouteTargetForLoadedChannel",
195194
},
196-
{
197-
code: "channel-explicit-target-parser",
198-
file: "src/channels/plugins/target-parsing.ts",
199-
marker: "parseExplicitTargetForChannel",
200-
},
201-
{
202-
code: "channel-explicit-target-parser",
203-
file: "src/channels/plugins/target-parsing.ts",
204-
marker: "resolveRouteTargetForChannel",
205-
},
206195
{
207196
code: "channel-messaging-targets-subpath",
208197
file: "src/plugin-sdk/messaging-targets.ts",

src/plugins/compat/registry.ts

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,10 @@ export const PLUGIN_COMPAT_RECORDS = [
206206
"`ChannelRouteParsedTarget`, `channelRouteTargetsMatchExact`, `channelRouteTargetsShareConversation`, and `messaging.resolveOutboundSessionRoute` for provider-specific target grammar",
207207
docsPath: "/plugins/sdk-migration",
208208
surfaces: [
209-
"src/channels/plugins/target-parsing ComparableChannelTarget",
210-
"src/channels/plugins/target-parsing resolveComparableTargetForChannel",
211-
"src/channels/plugins/target-parsing comparableChannelTargetsMatch",
212-
"src/channels/plugins/target-parsing comparableChannelTargetsShareRoute",
209+
"src/channels/plugins/target-parsing-loaded ComparableChannelTarget",
210+
"src/channels/plugins/target-parsing-loaded resolveComparableTargetForLoadedChannel",
211+
"src/channels/plugins/target-parsing-loaded comparableChannelTargetsMatch",
212+
"src/channels/plugins/target-parsing-loaded comparableChannelTargetsShareRoute",
213213
],
214214
diagnostics: ["plugin SDK compatibility warning"],
215215
tests: [
@@ -233,11 +233,9 @@ export const PLUGIN_COMPAT_RECORDS = [
233233
"openclaw/plugin-sdk/channel-route ChannelRouteExplicitTarget",
234234
"openclaw/plugin-sdk/channel-route ChannelRouteExplicitTargetParser",
235235
"openclaw/plugin-sdk/channel-route resolveChannelRouteTargetWithParser",
236-
"src/channels/plugins/target-parsing ParsedChannelExplicitTarget",
237-
"src/channels/plugins/target-parsing parseExplicitTargetForChannel",
238-
"src/channels/plugins/target-parsing parseExplicitTargetForLoadedChannel",
239-
"src/channels/plugins/target-parsing resolveRouteTargetForChannel",
240-
"src/channels/plugins/target-parsing resolveRouteTargetForLoadedChannel",
236+
"src/channels/plugins/target-parsing-loaded ParsedChannelExplicitTarget",
237+
"src/channels/plugins/target-parsing-loaded parseExplicitTargetForLoadedChannel",
238+
"src/channels/plugins/target-parsing-loaded resolveRouteTargetForLoadedChannel",
241239
],
242240
diagnostics: ["plugin SDK compatibility warning"],
243241
tests: [

src/plugins/contracts/plugin-sdk-subpaths.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,6 @@ describe("plugin-sdk subpath exports", () => {
860860
pattern:
861861
/\b(?:ComparableChannelTarget|resolveComparableTargetFor(?:Channel|LoadedChannel)|comparableChannelTargets(?:Match|ShareRoute))\b/u,
862862
exclude: [
863-
"src/channels/plugins/target-parsing.ts",
864863
"src/channels/plugins/target-parsing-loaded.ts",
865864
"src/channels/plugins/target-parsing.test.ts",
866865
"src/plugins/compat/registry.ts",

0 commit comments

Comments
 (0)