Fix line setup import cycles
This commit is contained in:
parent
5c88d62d75
commit
236aefa06c
24
extensions/line/index.test.ts
Normal file
24
extensions/line/index.test.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import path from "node:path";
|
||||
import { createJiti } from "jiti";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildPluginLoaderJitiOptions,
|
||||
resolvePluginSdkScopedAliasMap,
|
||||
} from "../../src/plugins/sdk-alias.ts";
|
||||
|
||||
describe("line runtime api", () => {
|
||||
it("loads the line runtime api through Jiti", () => {
|
||||
const runtimeApiPath = path.join(process.cwd(), "extensions", "line", "runtime-api.ts");
|
||||
const jiti = createJiti(import.meta.url, {
|
||||
...buildPluginLoaderJitiOptions(
|
||||
resolvePluginSdkScopedAliasMap({ modulePath: runtimeApiPath }),
|
||||
),
|
||||
tryNative: false,
|
||||
});
|
||||
|
||||
expect(jiti(runtimeApiPath)).toMatchObject({
|
||||
resolveLineAccount: expect.any(Function),
|
||||
formatDocsLink: expect.any(Function),
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -1,12 +1,44 @@
|
||||
// Private runtime barrel for the bundled LINE extension.
|
||||
// Keep this barrel thin and aligned with the local extension surface.
|
||||
// Do not re-export ../../src/plugin-sdk/line here: that public barrel also
|
||||
// re-exports setup-api, which creates a cycle for local line imports.
|
||||
|
||||
export * from "../../src/plugin-sdk/line.js";
|
||||
export { resolveExactLineGroupConfigKey } from "../../src/plugin-sdk/line-core.js";
|
||||
export type {
|
||||
ChannelAccountSnapshot,
|
||||
ChannelGatewayContext,
|
||||
ChannelStatusIssue,
|
||||
ChannelPlugin,
|
||||
OpenClawConfig,
|
||||
ReplyPayload,
|
||||
OpenClawPluginApi,
|
||||
PluginRuntime,
|
||||
LineChannelData,
|
||||
LineConfig,
|
||||
ResolvedLineAccount,
|
||||
CardAction,
|
||||
ListItem,
|
||||
ChannelSetupDmPolicy,
|
||||
ChannelSetupWizard,
|
||||
} from "../../src/plugin-sdk/line-core.js";
|
||||
export {
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
buildChannelConfigSchema,
|
||||
buildComputedAccountStatusSnapshot,
|
||||
buildTokenChannelStatusSummary,
|
||||
clearAccountEntryFields,
|
||||
createActionCard,
|
||||
createImageCard,
|
||||
createInfoCard,
|
||||
createListCard,
|
||||
createReceiptCard,
|
||||
formatDocsLink,
|
||||
LineConfigSchema,
|
||||
listLineAccountIds,
|
||||
normalizeAccountId,
|
||||
processLineMessage,
|
||||
resolveDefaultLineAccountId,
|
||||
resolveLineAccount,
|
||||
resolveExactLineGroupConfigKey,
|
||||
setSetupChannelEnabled,
|
||||
splitSetupEntries,
|
||||
type ChannelSetupDmPolicy,
|
||||
type ChannelSetupWizard,
|
||||
} from "../../src/plugin-sdk/line-core.js";
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import type { ResolvedLineAccount } from "../../../src/line/types.js";
|
||||
import type { PluginRuntime } from "../../../src/plugins/runtime/types.js";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import type { OpenClawConfig, PluginRuntime, ResolvedLineAccount } from "../api.js";
|
||||
import { linePlugin } from "./channel.js";
|
||||
import { setLineRuntime } from "./runtime.js";
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { OpenClawConfig, PluginRuntime } from "../api.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import type { PluginRuntime } from "../../../src/plugins/runtime/types.js";
|
||||
import { linePlugin } from "./channel.js";
|
||||
import { setLineRuntime } from "./runtime.js";
|
||||
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import type {
|
||||
ChannelGatewayContext,
|
||||
ChannelAccountSnapshot,
|
||||
OpenClawConfig,
|
||||
PluginRuntime,
|
||||
ResolvedLineAccount,
|
||||
} from "../api.js";
|
||||
ChannelGatewayContext,
|
||||
} from "../../../src/channels/plugins/types.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import type { ResolvedLineAccount } from "../../../src/line/types.js";
|
||||
import type { PluginRuntime } from "../../../src/plugins/runtime/types.js";
|
||||
import { createRuntimeEnv } from "../../../test/helpers/extensions/runtime-env.js";
|
||||
import { linePlugin } from "./channel.js";
|
||||
import { setLineRuntime } from "./runtime.js";
|
||||
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { buildChannelSetupWizardAdapterFromSetupWizard } from "../../../src/channels/plugins/setup-wizard.js";
|
||||
import type { OpenClawConfig } from "../../../src/config/config.js";
|
||||
import {
|
||||
listLineAccountIds,
|
||||
resolveDefaultLineAccountId,
|
||||
@ -10,7 +11,6 @@ import {
|
||||
createTestWizardPrompter,
|
||||
type WizardPrompter,
|
||||
} from "../../../test/helpers/extensions/setup-wizard.js";
|
||||
import type { OpenClawConfig } from "../api.js";
|
||||
import { lineSetupAdapter, lineSetupWizard } from "./setup-surface.js";
|
||||
|
||||
const lineConfigureAdapter = buildChannelSetupWizardAdapterFromSetupWizard({
|
||||
|
||||
@ -1,5 +1,14 @@
|
||||
export type {
|
||||
ChannelAccountSnapshot,
|
||||
ChannelGatewayContext,
|
||||
ChannelStatusIssue,
|
||||
} from "../channels/plugins/types.js";
|
||||
export type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
export type { OpenClawConfig } from "../config/config.js";
|
||||
export type { LineConfig } from "../line/types.js";
|
||||
export type { ReplyPayload } from "../auto-reply/types.js";
|
||||
export type { OpenClawPluginApi, PluginRuntime } from "./channel-plugin-common.js";
|
||||
export type { LineChannelData, LineConfig, ResolvedLineAccount } from "../line/types.js";
|
||||
export type { CardAction, ListItem } from "../line/flex-templates.js";
|
||||
export {
|
||||
createTopLevelChannelDmPolicy,
|
||||
DEFAULT_ACCOUNT_ID,
|
||||
@ -9,12 +18,25 @@ export {
|
||||
splitSetupEntries,
|
||||
} from "./setup.js";
|
||||
export type { ChannelSetupAdapter, ChannelSetupDmPolicy, ChannelSetupWizard } from "./setup.js";
|
||||
export { buildChannelConfigSchema } from "./channel-plugin-common.js";
|
||||
export {
|
||||
buildComputedAccountStatusSnapshot,
|
||||
buildTokenChannelStatusSummary,
|
||||
} from "./status-helpers.js";
|
||||
export { clearAccountEntryFields } from "../channels/plugins/config-helpers.js";
|
||||
export {
|
||||
listLineAccountIds,
|
||||
normalizeAccountId,
|
||||
resolveDefaultLineAccountId,
|
||||
resolveLineAccount,
|
||||
} from "../line/accounts.js";
|
||||
export {
|
||||
createActionCard,
|
||||
createImageCard,
|
||||
createInfoCard,
|
||||
createListCard,
|
||||
createReceiptCard,
|
||||
} from "../line/flex-templates.js";
|
||||
export { resolveExactLineGroupConfigKey } from "../line/group-keys.js";
|
||||
export type { ResolvedLineAccount } from "../line/types.js";
|
||||
export { LineConfigSchema } from "../line/config-schema.js";
|
||||
export { processLineMessage } from "../line/markdown-to-line.js";
|
||||
|
||||
@ -35,6 +35,10 @@ const RUNTIME_API_EXPORT_GUARDS: Record<string, readonly string[]> = {
|
||||
'export { sendMessageIMessage } from "./src/send.js";',
|
||||
],
|
||||
"extensions/googlechat/runtime-api.ts": ['export * from "../../src/plugin-sdk/googlechat.js";'],
|
||||
"extensions/line/runtime-api.ts": [
|
||||
'export type { ChannelAccountSnapshot, ChannelGatewayContext, ChannelStatusIssue, ChannelPlugin, OpenClawConfig, ReplyPayload, OpenClawPluginApi, PluginRuntime, LineChannelData, LineConfig, ResolvedLineAccount, CardAction, ListItem, ChannelSetupDmPolicy, ChannelSetupWizard } from "../../src/plugin-sdk/line-core.js";',
|
||||
'export { DEFAULT_ACCOUNT_ID, buildChannelConfigSchema, buildComputedAccountStatusSnapshot, buildTokenChannelStatusSummary, clearAccountEntryFields, createActionCard, createImageCard, createInfoCard, createListCard, createReceiptCard, formatDocsLink, LineConfigSchema, listLineAccountIds, normalizeAccountId, processLineMessage, resolveDefaultLineAccountId, resolveLineAccount, resolveExactLineGroupConfigKey, setSetupChannelEnabled, splitSetupEntries } from "../../src/plugin-sdk/line-core.js";',
|
||||
],
|
||||
"extensions/matrix/runtime-api.ts": [
|
||||
'export * from "./src/auth-precedence.js";',
|
||||
'export * from "./helper-api.js";',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user