@allbluecn/shared 0.3.13 → 0.4.0
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/dist/config-CcbSbJoC.js +6344 -0
- package/dist/constants/perf.d.ts +6 -0
- package/dist/constants/perf.js +6 -0
- package/dist/constants-C3hGP_ru.d.ts +33 -0
- package/dist/i18n/client.d.ts +5 -0
- package/dist/i18n/client.js +34 -0
- package/dist/i18n/config.d.ts +6270 -0
- package/dist/i18n/config.js +2 -0
- package/dist/i18n/detect.d.ts +5 -0
- package/dist/i18n/detect.js +35 -0
- package/dist/i18n/server.d.ts +6 -0
- package/dist/i18n/server.js +19 -0
- package/dist/i18n/types.d.ts +3 -0
- package/dist/i18n/types.js +0 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +14 -0
- package/dist/infrastructure/ai/adapter.d.ts +8 -0
- package/dist/infrastructure/ai/adapter.js +32 -0
- package/dist/infrastructure/ai/cli-detector.d.ts +6 -0
- package/dist/infrastructure/ai/cli-detector.js +121 -0
- package/dist/infrastructure/ip-location.d.ts +9 -0
- package/dist/infrastructure/ip-location.js +48 -0
- package/dist/infrastructure/references/engine.d.ts +7 -0
- package/dist/infrastructure/references/engine.js +64 -0
- package/dist/infrastructure/ua-parser.d.ts +20 -0
- package/dist/infrastructure/ua-parser.js +69 -0
- package/dist/interfaces/ai.d.ts +27 -0
- package/dist/interfaces/ai.js +0 -0
- package/dist/interfaces/avatar.d.ts +6 -0
- package/dist/interfaces/avatar.js +0 -0
- package/dist/interfaces/module.d.ts +45 -0
- package/dist/interfaces/module.js +0 -0
- package/dist/interfaces/references.d.ts +27 -0
- package/dist/interfaces/references.js +0 -0
- package/dist/interfaces/transport.d.ts +11 -0
- package/dist/interfaces/transport.js +0 -0
- package/dist/lib/annotation-template.d.ts +9 -0
- package/dist/lib/annotation-template.js +14 -0
- package/dist/lib/comment-utils.d.ts +7 -0
- package/dist/lib/comment-utils.js +27 -0
- package/dist/lib/datetime.d.ts +25 -0
- package/dist/lib/datetime.js +73 -0
- package/dist/lib/desktop-detect.d.ts +13 -0
- package/dist/lib/desktop-detect.js +23 -0
- package/dist/lib/outline-utils.d.ts +6 -0
- package/dist/lib/outline-utils.js +46 -0
- package/dist/lib/pacer.d.ts +45 -0
- package/dist/lib/pacer.js +70 -0
- package/dist/lib/prd/stack-layout.d.ts +18 -0
- package/dist/lib/prd/stack-layout.js +24 -0
- package/dist/lib/prd-tree-utils.d.ts +21 -0
- package/dist/lib/prd-tree-utils.js +62 -0
- package/dist/lib/prototype-registry.d.ts +2 -0
- package/dist/lib/prototype-registry.js +2 -0
- package/dist/lib/query-client-seam.d.ts +6 -0
- package/dist/lib/query-client-seam.js +11 -0
- package/dist/lib/share-events.d.ts +7 -0
- package/dist/lib/share-events.js +47 -0
- package/dist/lib/sidebar-utils.d.ts +4 -0
- package/dist/lib/sidebar-utils.js +7 -0
- package/dist/lib/stores/prd-canvas-store.d.ts +16 -0
- package/dist/lib/stores/prd-canvas-store.js +42 -0
- package/dist/lib/tag-colors.d.ts +12 -0
- package/dist/lib/tag-colors.js +74 -0
- package/dist/lib/time-format.d.ts +4 -0
- package/dist/lib/time-format.js +20 -0
- package/dist/modules/ai-providers/constants.d.ts +2 -0
- package/dist/modules/ai-providers/constants.js +125 -0
- package/dist/modules/ai-providers/index.d.ts +4 -0
- package/dist/modules/ai-providers/index.js +4 -0
- package/dist/modules/ai-providers/seed-data.d.ts +2 -0
- package/dist/modules/ai-providers/seed-data.js +408 -0
- package/dist/modules/ai-providers/types.d.ts +2 -0
- package/dist/modules/ai-providers/types.js +10 -0
- package/dist/modules/billing/feature-registry.d.ts +72 -0
- package/dist/modules/billing/feature-registry.js +67 -0
- package/dist/modules/billing/plan-features-schema.d.ts +6 -0
- package/dist/modules/billing/plan-features-schema.js +6 -0
- package/dist/modules/billing/resource-registry.d.ts +59 -0
- package/dist/modules/billing/resource-registry.js +47 -0
- package/dist/modules/definitions/plugin.module.d.ts +5 -0
- package/dist/modules/definitions/plugin.module.js +24 -0
- package/dist/modules/definitions/prd.module.d.ts +5 -0
- package/dist/modules/definitions/prd.module.js +26 -0
- package/dist/modules/definitions/prototype.module.d.ts +5 -0
- package/dist/modules/definitions/prototype.module.js +20 -0
- package/dist/modules/dependencies/index.d.ts +92 -0
- package/dist/modules/dependencies/index.js +334 -0
- package/dist/modules/register-defaults.d.ts +4 -0
- package/dist/modules/register-defaults.js +12 -0
- package/dist/modules/registry.d.ts +17 -0
- package/dist/modules/registry.js +27 -0
- package/dist/seed-data-BK0cl93n.d.ts +6 -0
- package/dist/server-seam.d.ts +19 -0
- package/dist/server-seam.js +11 -0
- package/dist/types/outline.d.ts +10 -0
- package/dist/types/outline.js +0 -0
- package/dist/types/prd.d.ts +48 -0
- package/dist/types/prd.js +37 -0
- package/dist/types/prototype.d.ts +2 -0
- package/dist/types/prototype.js +2 -0
- package/dist/types-dopOMFRC.d.ts +61 -0
- package/dist/virtual.d.ts +1 -0
- package/package.json +133 -37
- package/src/constants/perf.ts +0 -21
- package/src/i18n/client.ts +0 -32
- package/src/i18n/config.ts +0 -104
- package/src/i18n/detect.ts +0 -43
- package/src/i18n/locales/en/agents.json +0 -134
- package/src/i18n/locales/en/apps.json +0 -6
- package/src/i18n/locales/en/auth.json +0 -88
- package/src/i18n/locales/en/billing.json +0 -78
- package/src/i18n/locales/en/chat.json +0 -194
- package/src/i18n/locales/en/common.json +0 -203
- package/src/i18n/locales/en/dashboard.json +0 -38
- package/src/i18n/locales/en/design.json +0 -70
- package/src/i18n/locales/en/desktop.json +0 -35
- package/src/i18n/locales/en/display.json +0 -37
- package/src/i18n/locales/en/editor.json +0 -304
- package/src/i18n/locales/en/enterprise.json +0 -1
- package/src/i18n/locales/en/invite.json +0 -11
- package/src/i18n/locales/en/knowledge.json +0 -451
- package/src/i18n/locales/en/mindmap.json +0 -28
- package/src/i18n/locales/en/prd.json +0 -43
- package/src/i18n/locales/en/projects.json +0 -133
- package/src/i18n/locales/en/settings.json +0 -375
- package/src/i18n/locales/en/share.json +0 -20
- package/src/i18n/locales/en/story.json +0 -785
- package/src/i18n/locales/en/tags.json +0 -42
- package/src/i18n/locales/en/workspace.json +0 -90
- package/src/i18n/locales/zh/agents.json +0 -134
- package/src/i18n/locales/zh/apps.json +0 -6
- package/src/i18n/locales/zh/auth.json +0 -88
- package/src/i18n/locales/zh/billing.json +0 -78
- package/src/i18n/locales/zh/chat.json +0 -194
- package/src/i18n/locales/zh/common.json +0 -203
- package/src/i18n/locales/zh/dashboard.json +0 -38
- package/src/i18n/locales/zh/design.json +0 -70
- package/src/i18n/locales/zh/desktop.json +0 -35
- package/src/i18n/locales/zh/display.json +0 -37
- package/src/i18n/locales/zh/editor.json +0 -304
- package/src/i18n/locales/zh/enterprise.json +0 -1
- package/src/i18n/locales/zh/invite.json +0 -11
- package/src/i18n/locales/zh/knowledge.json +0 -451
- package/src/i18n/locales/zh/mindmap.json +0 -28
- package/src/i18n/locales/zh/prd.json +0 -43
- package/src/i18n/locales/zh/projects.json +0 -133
- package/src/i18n/locales/zh/settings.json +0 -375
- package/src/i18n/locales/zh/share.json +0 -20
- package/src/i18n/locales/zh/story.json +0 -785
- package/src/i18n/locales/zh/tags.json +0 -42
- package/src/i18n/locales/zh/workspace.json +0 -90
- package/src/i18n/server.ts +0 -18
- package/src/i18n/types.ts +0 -5
- package/src/index.ts +0 -90
- package/src/infrastructure/ai/adapter.ts +0 -59
- package/src/infrastructure/ai/cli-detector.ts +0 -64
- package/src/infrastructure/ip-location.ts +0 -76
- package/src/infrastructure/references/engine.ts +0 -104
- package/src/infrastructure/ua-parser.ts +0 -107
- package/src/interfaces/ai.ts +0 -38
- package/src/interfaces/avatar.ts +0 -22
- package/src/interfaces/module.ts +0 -60
- package/src/interfaces/references.ts +0 -44
- package/src/interfaces/transport.ts +0 -26
- package/src/lib/annotation-template.ts +0 -33
- package/src/lib/comment-utils.ts +0 -47
- package/src/lib/datetime.ts +0 -115
- package/src/lib/desktop-detect.ts +0 -27
- package/src/lib/outline-utils.ts +0 -57
- package/src/lib/pacer.ts +0 -96
- package/src/lib/prd/stack-layout.ts +0 -53
- package/src/lib/prd-tree-utils.ts +0 -94
- package/src/lib/prototype-registry.ts +0 -24
- package/src/lib/query-client-seam.ts +0 -14
- package/src/lib/share-events.ts +0 -78
- package/src/lib/sidebar-utils.ts +0 -21
- package/src/lib/stores/prd-canvas-store.ts +0 -69
- package/src/lib/tag-colors.ts +0 -35
- package/src/lib/time-format.ts +0 -50
- package/src/modules/ai-providers/constants.ts +0 -79
- package/src/modules/ai-providers/index.ts +0 -21
- package/src/modules/ai-providers/seed-data.ts +0 -222
- package/src/modules/ai-providers/types.ts +0 -95
- package/src/modules/billing/feature-registry.ts +0 -63
- package/src/modules/billing/plan-features-schema.ts +0 -11
- package/src/modules/billing/resource-registry.ts +0 -80
- package/src/modules/definitions/plugin.module.ts +0 -38
- package/src/modules/definitions/prd.module.ts +0 -45
- package/src/modules/definitions/prototype.module.ts +0 -38
- package/src/modules/dependencies/index.ts +0 -186
- package/src/modules/register-defaults.ts +0 -27
- package/src/modules/registry.ts +0 -53
- package/src/server-seam.ts +0 -51
- package/src/types/outline.ts +0 -26
- package/src/types/prd.ts +0 -90
- package/src/types/prototype.ts +0 -12
- package/src/virtual.d.ts +0 -4
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { r as isSupportedLocale } from "../config-CcbSbJoC.js";
|
|
2
|
+
//#region src/i18n/detect.ts
|
|
3
|
+
function detectLocale(request, userLocale) {
|
|
4
|
+
const queryLng = new URL(request.url).searchParams.get("lng");
|
|
5
|
+
if (queryLng && isSupportedLocale(queryLng)) return queryLng;
|
|
6
|
+
const cookieLng = parseCookieValue(request.headers.get("cookie") ?? "", "lng");
|
|
7
|
+
if (cookieLng && isSupportedLocale(cookieLng)) return cookieLng;
|
|
8
|
+
if (userLocale && isSupportedLocale(userLocale)) return userLocale;
|
|
9
|
+
const acceptLang = request.headers.get("accept-language");
|
|
10
|
+
if (acceptLang) {
|
|
11
|
+
const detected = matchBestLanguage(acceptLang);
|
|
12
|
+
if (detected) return detected;
|
|
13
|
+
}
|
|
14
|
+
return "zh";
|
|
15
|
+
}
|
|
16
|
+
function parseCookieValue(cookieHeader, key) {
|
|
17
|
+
const match = cookieHeader.match(new RegExp(`(?:^|;\\s*)${key}=([^;]+)`));
|
|
18
|
+
return match ? match[1] : null;
|
|
19
|
+
}
|
|
20
|
+
function matchBestLanguage(acceptLang) {
|
|
21
|
+
const entries = acceptLang.split(",").map((part) => {
|
|
22
|
+
const [lang, qPart] = part.trim().split(";q=");
|
|
23
|
+
return {
|
|
24
|
+
lang: lang.trim(),
|
|
25
|
+
q: qPart ? parseFloat(qPart) : 1
|
|
26
|
+
};
|
|
27
|
+
}).sort((a, b) => b.q - a.q);
|
|
28
|
+
for (const entry of entries) {
|
|
29
|
+
const base = entry.lang.split("-")[0].toLowerCase();
|
|
30
|
+
if (isSupportedLocale(base)) return base;
|
|
31
|
+
}
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
//#endregion
|
|
35
|
+
export { detectLocale };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { a as resources, t as defaultNs } from "../config-CcbSbJoC.js";
|
|
2
|
+
import i18next from "i18next";
|
|
3
|
+
import { initReactI18next } from "react-i18next";
|
|
4
|
+
//#region src/i18n/server.ts
|
|
5
|
+
function createServerI18n(locale) {
|
|
6
|
+
const i18n = i18next.createInstance();
|
|
7
|
+
i18n.use(initReactI18next);
|
|
8
|
+
i18n.init({
|
|
9
|
+
lng: locale,
|
|
10
|
+
fallbackLng: "zh",
|
|
11
|
+
defaultNS: defaultNs,
|
|
12
|
+
resources,
|
|
13
|
+
interpolation: { escapeValue: false },
|
|
14
|
+
react: { useSuspense: false }
|
|
15
|
+
});
|
|
16
|
+
return i18n;
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { createServerI18n };
|
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DND_STICKY_THRESHOLD, LOAD_MORE_STEP, VIRTUALIZE_THRESHOLD } from "./constants/perf.js";
|
|
2
|
+
import { AICommandContext, AICommandDef, AICommandHandler, AICommandResult, AllBlueModule, EntityDef, ReferenceDisplayFn } from "./interfaces/module.js";
|
|
3
|
+
import { moduleRegistry } from "./modules/registry.js";
|
|
4
|
+
import { registerDefaultModules } from "./modules/register-defaults.js";
|
|
5
|
+
import { a as ModelCapability, i as AiProviderRow, n as AiModelMeta, o as PROVIDER_BADGE_STYLES, r as AiProviderMeta, s as ProviderCategory, t as AdapterKind } from "./types-dopOMFRC.js";
|
|
6
|
+
import { a as MODEL_TABS, c as PROVIDER_CATEGORY_VALUES, i as MODEL_CAPABILITY_OPTIONS, n as ADAPTER_KIND_VALUES, o as ModelTab, r as LOBE_ICON_MAP, s as PROVIDER_CATEGORIES, t as ADAPTER_KINDS } from "./constants-C3hGP_ru.js";
|
|
7
|
+
import { t as SEED_AI_PROVIDERS } from "./seed-data-BK0cl93n.js";
|
|
8
|
+
import { DEFAULT_WATCHED_DEPENDENCIES, DEPENDENCY_CATEGORIES, DEPENDENCY_PRIORITIES, DependencyCategory, DependencyPriority, DependencySeed, DependencyUsage, SyncDependencyResult, ThirdPartyDependencyRow, UpdateDependencyInput, VersionStatus } from "./modules/dependencies/index.js";
|
|
9
|
+
import { getClientIp, resolveIpLocation } from "./infrastructure/ip-location.js";
|
|
10
|
+
import { ParsedUA, formatParsedUA, parseUserAgent } from "./infrastructure/ua-parser.js";
|
|
11
|
+
import { RefDisplay, Reference, ResolvedRef, SearchResult } from "./interfaces/references.js";
|
|
12
|
+
import { AiAdapter, CLIAgentInfo } from "./interfaces/ai.js";
|
|
13
|
+
import { EntityUpdateEvent, RealtimeTransport } from "./interfaces/transport.js";
|
|
14
|
+
import { FEATURE_KEYS, FeatureKey, FeatureMeta, FeatureRegistry, OSS_BASE_FEATURES, isOssFeature } from "./modules/billing/feature-registry.js";
|
|
15
|
+
import { PlanFeatures, PlanFeaturesSchema } from "./modules/billing/plan-features-schema.js";
|
|
16
|
+
import { RESOURCE_KEYS, ResourceKey, ResourceMeta, ResourceRegistry, ResourceSnapshot, ResourceSnapshots, isResourceDefined } from "./modules/billing/resource-registry.js";
|
|
17
|
+
import { AvatarConfig, AvatarPart, ShapeType } from "./interfaces/avatar.js";
|
|
18
|
+
export { ADAPTER_KINDS, ADAPTER_KIND_VALUES, type AICommandContext, type AICommandDef, type AICommandHandler, type AICommandResult, AdapterKind, type AiAdapter, AiModelMeta, AiProviderMeta, AiProviderRow, type AllBlueModule, type AvatarConfig, type AvatarPart, type CLIAgentInfo, DEFAULT_WATCHED_DEPENDENCIES, DEPENDENCY_CATEGORIES, DEPENDENCY_PRIORITIES, DND_STICKY_THRESHOLD, DependencyCategory, DependencyPriority, DependencySeed, DependencyUsage, type EntityDef, type EntityUpdateEvent, FEATURE_KEYS, type FeatureKey, type FeatureMeta, FeatureRegistry, LOAD_MORE_STEP, LOBE_ICON_MAP, MODEL_CAPABILITY_OPTIONS, MODEL_TABS, ModelCapability, ModelTab, OSS_BASE_FEATURES, PROVIDER_BADGE_STYLES, PROVIDER_CATEGORIES, PROVIDER_CATEGORY_VALUES, type ParsedUA, type PlanFeatures, PlanFeaturesSchema, ProviderCategory, RESOURCE_KEYS, type RealtimeTransport, type RefDisplay, type Reference, type ReferenceDisplayFn, type ResolvedRef, type ResourceKey, type ResourceMeta, ResourceRegistry, type ResourceSnapshot, type ResourceSnapshots, SEED_AI_PROVIDERS, type SearchResult, type ShapeType, SyncDependencyResult, ThirdPartyDependencyRow, UpdateDependencyInput, VIRTUALIZE_THRESHOLD, VersionStatus, formatParsedUA, getClientIp, isOssFeature, isResourceDefined, moduleRegistry, parseUserAgent, registerDefaultModules, resolveIpLocation };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { moduleRegistry } from "./modules/registry.js";
|
|
2
|
+
import { registerDefaultModules } from "./modules/register-defaults.js";
|
|
3
|
+
import { DND_STICKY_THRESHOLD, LOAD_MORE_STEP, VIRTUALIZE_THRESHOLD } from "./constants/perf.js";
|
|
4
|
+
import { PROVIDER_BADGE_STYLES } from "./modules/ai-providers/types.js";
|
|
5
|
+
import { ADAPTER_KINDS, ADAPTER_KIND_VALUES, LOBE_ICON_MAP, MODEL_CAPABILITY_OPTIONS, MODEL_TABS, PROVIDER_CATEGORIES, PROVIDER_CATEGORY_VALUES } from "./modules/ai-providers/constants.js";
|
|
6
|
+
import { SEED_AI_PROVIDERS } from "./modules/ai-providers/seed-data.js";
|
|
7
|
+
import "./modules/ai-providers/index.js";
|
|
8
|
+
import { DEFAULT_WATCHED_DEPENDENCIES, DEPENDENCY_CATEGORIES, DEPENDENCY_PRIORITIES } from "./modules/dependencies/index.js";
|
|
9
|
+
import { getClientIp, resolveIpLocation } from "./infrastructure/ip-location.js";
|
|
10
|
+
import { formatParsedUA, parseUserAgent } from "./infrastructure/ua-parser.js";
|
|
11
|
+
import { FEATURE_KEYS, FeatureRegistry, OSS_BASE_FEATURES, isOssFeature } from "./modules/billing/feature-registry.js";
|
|
12
|
+
import { PlanFeaturesSchema } from "./modules/billing/plan-features-schema.js";
|
|
13
|
+
import { RESOURCE_KEYS, ResourceRegistry, isResourceDefined } from "./modules/billing/resource-registry.js";
|
|
14
|
+
export { ADAPTER_KINDS, ADAPTER_KIND_VALUES, DEFAULT_WATCHED_DEPENDENCIES, DEPENDENCY_CATEGORIES, DEPENDENCY_PRIORITIES, DND_STICKY_THRESHOLD, FEATURE_KEYS, FeatureRegistry, LOAD_MORE_STEP, LOBE_ICON_MAP, MODEL_CAPABILITY_OPTIONS, MODEL_TABS, OSS_BASE_FEATURES, PROVIDER_BADGE_STYLES, PROVIDER_CATEGORIES, PROVIDER_CATEGORY_VALUES, PlanFeaturesSchema, RESOURCE_KEYS, ResourceRegistry, SEED_AI_PROVIDERS, VIRTUALIZE_THRESHOLD, formatParsedUA, getClientIp, isOssFeature, isResourceDefined, moduleRegistry, parseUserAgent, registerDefaultModules, resolveIpLocation };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AICommandContext } from "../../interfaces/module.js";
|
|
2
|
+
import { CLIAgentInfo } from "../../interfaces/ai.js";
|
|
3
|
+
//#region src/infrastructure/ai/adapter.d.ts
|
|
4
|
+
declare function getActiveAgent(): string | null;
|
|
5
|
+
declare function switchAgent(agentId: string): void;
|
|
6
|
+
declare function executeViaAgent(agent: CLIAgentInfo, prompt: string, _ctx: AICommandContext): Promise<string>;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { executeViaAgent, getActiveAgent, switchAgent };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//#region src/infrastructure/ai/adapter.ts
|
|
2
|
+
let activeAgentId = null;
|
|
3
|
+
function getActiveAgent() {
|
|
4
|
+
return activeAgentId;
|
|
5
|
+
}
|
|
6
|
+
function switchAgent(agentId) {
|
|
7
|
+
activeAgentId = agentId;
|
|
8
|
+
}
|
|
9
|
+
async function executeViaAgent(agent, prompt, _ctx) {
|
|
10
|
+
if (agent.id === "openai-api") return (await (await fetch(`${process.env.AI_BASE_URL || "https://api.openai.com/v1"}/chat/completions`, {
|
|
11
|
+
method: "POST",
|
|
12
|
+
headers: {
|
|
13
|
+
"Content-Type": "application/json",
|
|
14
|
+
Authorization: `Bearer ${process.env.OPENAI_API_KEY}`
|
|
15
|
+
},
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
model: process.env.AI_MODEL || "gpt-4o-mini",
|
|
18
|
+
messages: [{
|
|
19
|
+
role: "user",
|
|
20
|
+
content: prompt
|
|
21
|
+
}],
|
|
22
|
+
temperature: .7
|
|
23
|
+
})
|
|
24
|
+
})).json()).choices[0]?.message?.content || "";
|
|
25
|
+
const { execSync } = await import("child_process");
|
|
26
|
+
return execSync(`${agent.binary} -p "${prompt.replace(/"/g, "\\\"")}"`, {
|
|
27
|
+
timeout: 6e4,
|
|
28
|
+
encoding: "utf-8"
|
|
29
|
+
}).trim();
|
|
30
|
+
}
|
|
31
|
+
//#endregion
|
|
32
|
+
export { executeViaAgent, getActiveAgent, switchAgent };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CLIAgentInfo } from "../../interfaces/ai.js";
|
|
2
|
+
//#region src/infrastructure/ai/cli-detector.d.ts
|
|
3
|
+
declare function detectAgents(): Promise<CLIAgentInfo[]>;
|
|
4
|
+
declare function getApiAgent(): CLIAgentInfo | undefined;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { detectAgents, getApiAgent };
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
//#region src/infrastructure/ai/cli-detector.ts
|
|
2
|
+
const KNOWN_AGENTS = [
|
|
3
|
+
{
|
|
4
|
+
id: "claude-code",
|
|
5
|
+
name: "Claude Code",
|
|
6
|
+
binary: "claude"
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
id: "claude-cli",
|
|
10
|
+
name: "Claude CLI",
|
|
11
|
+
binary: "claude"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
id: "copilot-cli",
|
|
15
|
+
name: "GitHub Copilot CLI",
|
|
16
|
+
binary: "github-copilot-cli"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
id: "ollama",
|
|
20
|
+
name: "Ollama",
|
|
21
|
+
binary: "ollama"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
id: "llama-cpp",
|
|
25
|
+
name: "llama.cpp",
|
|
26
|
+
binary: "llama-cli"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
id: "open-interpreter",
|
|
30
|
+
name: "Open Interpreter",
|
|
31
|
+
binary: "interpreter"
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: "aider",
|
|
35
|
+
name: "Aider",
|
|
36
|
+
binary: "aider"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
id: "continue",
|
|
40
|
+
name: "Continue",
|
|
41
|
+
binary: "continue"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
id: "codex-cli",
|
|
45
|
+
name: "Codex CLI",
|
|
46
|
+
binary: "codex"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
id: "swe-agent",
|
|
50
|
+
name: "SWE-agent",
|
|
51
|
+
binary: "sweagent"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
id: "openhands",
|
|
55
|
+
name: "OpenHands",
|
|
56
|
+
binary: "openhands"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
id: "taskmaster",
|
|
60
|
+
name: "TaskMaster",
|
|
61
|
+
binary: "taskmaster"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "gpt-engineer",
|
|
65
|
+
name: "GPT Engineer",
|
|
66
|
+
binary: "gptengineer"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "mentat",
|
|
70
|
+
name: "Mentat",
|
|
71
|
+
binary: "mentat"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
id: "sweep",
|
|
75
|
+
name: "Sweep",
|
|
76
|
+
binary: "sweep"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
id: "mcp-cli",
|
|
80
|
+
name: "MCP CLI",
|
|
81
|
+
binary: "mcp"
|
|
82
|
+
}
|
|
83
|
+
];
|
|
84
|
+
async function detectAgents() {
|
|
85
|
+
const { execSync } = await import("child_process");
|
|
86
|
+
return KNOWN_AGENTS.map(({ id, name, binary }) => {
|
|
87
|
+
try {
|
|
88
|
+
return {
|
|
89
|
+
id,
|
|
90
|
+
name,
|
|
91
|
+
binary,
|
|
92
|
+
version: execSync(`${binary} --version 2>/dev/null || ${binary} version 2>/dev/null`, {
|
|
93
|
+
timeout: 3e3,
|
|
94
|
+
encoding: "utf-8"
|
|
95
|
+
}).trim().slice(0, 50),
|
|
96
|
+
available: true
|
|
97
|
+
};
|
|
98
|
+
} catch {
|
|
99
|
+
return {
|
|
100
|
+
id,
|
|
101
|
+
name,
|
|
102
|
+
binary,
|
|
103
|
+
version: "",
|
|
104
|
+
available: false
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
function getApiAgent() {
|
|
110
|
+
const key = process.env.OPENAI_API_KEY;
|
|
111
|
+
if (!key || key === "sk-your-api-key-here") return void 0;
|
|
112
|
+
return {
|
|
113
|
+
id: "openai-api",
|
|
114
|
+
name: `OpenAI (${process.env.AI_MODEL || "gpt-4o-mini"})`,
|
|
115
|
+
binary: "api",
|
|
116
|
+
version: "v1",
|
|
117
|
+
available: true
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
//#endregion
|
|
121
|
+
export { detectAgents, getApiAgent };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/infrastructure/ip-location.d.ts
|
|
2
|
+
declare function resolveIpLocation(ip: string | null | undefined): Promise<string>;
|
|
3
|
+
/**
|
|
4
|
+
* 从 Request 中提取客户端真实 IP
|
|
5
|
+
* 优先级:X-Forwarded-For > X-Real-IP > CF-Connecting-IP
|
|
6
|
+
*/
|
|
7
|
+
declare function getClientIp(request: Request): string | null;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getClientIp, resolveIpLocation };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
//#region src/infrastructure/ip-location.ts
|
|
2
|
+
/**
|
|
3
|
+
* IP 地理位置查询工具(服务端专用)
|
|
4
|
+
*
|
|
5
|
+
* - 开发环境 / 内网 IP:返回「本地」
|
|
6
|
+
* - 生产环境:使用 ip-api.com 免费查询(中文,每分钟 45 请求限制)
|
|
7
|
+
* 失败时返回「未知」,不阻塞登录流程
|
|
8
|
+
*/
|
|
9
|
+
const PRIVATE_IP_PATTERNS = /^(127\.|10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.|::1$|fc00:|fd00:|fe80:|169\.254\.|localhost)/i;
|
|
10
|
+
async function resolveIpLocation(ip) {
|
|
11
|
+
if (!ip) return "Unknown";
|
|
12
|
+
if (PRIVATE_IP_PATTERNS.test(ip)) return "Local";
|
|
13
|
+
try {
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timeout = setTimeout(() => controller.abort(), 3e3);
|
|
16
|
+
const res = await fetch(`http://ip-api.com/json/${encodeURIComponent(ip)}?fields=status,country,regionName,city&lang=zh-CN`, { signal: controller.signal });
|
|
17
|
+
clearTimeout(timeout);
|
|
18
|
+
if (!res.ok) return "Unknown";
|
|
19
|
+
const data = await res.json();
|
|
20
|
+
if (data.status !== "success") return "Unknown";
|
|
21
|
+
const parts = [
|
|
22
|
+
data.city,
|
|
23
|
+
data.regionName,
|
|
24
|
+
data.country
|
|
25
|
+
].filter(Boolean);
|
|
26
|
+
return parts.length > 0 ? parts.join(", ") : "Unknown";
|
|
27
|
+
} catch {
|
|
28
|
+
return "Unknown";
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* 从 Request 中提取客户端真实 IP
|
|
33
|
+
* 优先级:X-Forwarded-For > X-Real-IP > CF-Connecting-IP
|
|
34
|
+
*/
|
|
35
|
+
function getClientIp(request) {
|
|
36
|
+
const xff = request.headers.get("x-forwarded-for");
|
|
37
|
+
if (xff) {
|
|
38
|
+
const first = xff.split(",")[0]?.trim();
|
|
39
|
+
if (first) return first;
|
|
40
|
+
}
|
|
41
|
+
const xri = request.headers.get("x-real-ip");
|
|
42
|
+
if (xri) return xri.trim();
|
|
43
|
+
const cfip = request.headers.get("cf-connecting-ip");
|
|
44
|
+
if (cfip) return cfip.trim();
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
//#endregion
|
|
48
|
+
export { getClientIp, resolveIpLocation };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Reference, ResolvedRef, SearchResult } from "../../interfaces/references.js";
|
|
2
|
+
//#region src/infrastructure/references/engine.d.ts
|
|
3
|
+
declare function createReference(ref: Omit<Reference, "id">): Promise<Reference>;
|
|
4
|
+
declare function resolveReferences(sourceModule: string, sourceEntityId: string): Promise<ResolvedRef[]>;
|
|
5
|
+
declare function searchReferences(query: string, types?: string[]): Promise<SearchResult[]>;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { createReference, resolveReferences, searchReferences };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { moduleRegistry } from "../../modules/registry.js";
|
|
2
|
+
import { getPrismaSeam } from "../../server-seam.js";
|
|
3
|
+
//#region src/infrastructure/references/engine.ts
|
|
4
|
+
async function resolveDisplay(targetModule, targetEntityId, entityType) {
|
|
5
|
+
const mod = moduleRegistry.getModule(targetModule);
|
|
6
|
+
if (!mod) return { title: `[${targetModule}:${targetEntityId}]` };
|
|
7
|
+
const entity = entityType ? mod.entities.find((e) => e.type === entityType) : mod.entities[0];
|
|
8
|
+
if (!entity) return { title: `[${targetModule}:${targetEntityId}]` };
|
|
9
|
+
try {
|
|
10
|
+
const fields = [...entity.displayFields, "id"].join(", ");
|
|
11
|
+
const rows = await getPrismaSeam().$queryRawUnsafe(`SELECT ${fields} FROM \`${entity.table}\` WHERE id = ?`, targetEntityId);
|
|
12
|
+
if (!rows.length) return {
|
|
13
|
+
title: `Deleted ${entity.type}`,
|
|
14
|
+
status: "deleted"
|
|
15
|
+
};
|
|
16
|
+
return mod.referenceDisplay(entity.type, rows[0]);
|
|
17
|
+
} catch {
|
|
18
|
+
return { title: `[${targetEntityId}]` };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async function createReference(ref) {
|
|
22
|
+
return getPrismaSeam().reference.create({ data: ref });
|
|
23
|
+
}
|
|
24
|
+
async function resolveReferences(sourceModule, sourceEntityId) {
|
|
25
|
+
const refs = await getPrismaSeam().reference.findMany({ where: {
|
|
26
|
+
sourceModule,
|
|
27
|
+
sourceEntityId
|
|
28
|
+
} });
|
|
29
|
+
return Promise.all(refs.map(async (ref) => {
|
|
30
|
+
const display = await resolveDisplay(ref.targetModule, ref.targetEntityId);
|
|
31
|
+
return {
|
|
32
|
+
...ref,
|
|
33
|
+
display
|
|
34
|
+
};
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
async function searchReferences(query, types) {
|
|
38
|
+
const searchConfigs = moduleRegistry.getSearchFields();
|
|
39
|
+
const filtered = types ? searchConfigs.filter((c) => types.includes(c.module) || types.includes(c.type)) : searchConfigs;
|
|
40
|
+
const results = [];
|
|
41
|
+
for (const config of filtered) {
|
|
42
|
+
const mod = moduleRegistry.getModule(config.module);
|
|
43
|
+
if (!mod) continue;
|
|
44
|
+
const searchField = config.fields[0];
|
|
45
|
+
const seam = getPrismaSeam();
|
|
46
|
+
try {
|
|
47
|
+
const rows = await seam.$queryRawUnsafe(`SELECT id, ${config.fields.join(", ")} FROM \`${mod.entities[0].table}\` WHERE \`${searchField}\` LIKE ? LIMIT 20`, `%${query}%`);
|
|
48
|
+
for (const row of rows) {
|
|
49
|
+
const display = mod.referenceDisplay(config.type, row);
|
|
50
|
+
results.push({
|
|
51
|
+
id: row.id,
|
|
52
|
+
module: config.module,
|
|
53
|
+
type: config.type,
|
|
54
|
+
title: display.title,
|
|
55
|
+
status: display.status,
|
|
56
|
+
url: display.url
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
} catch {}
|
|
60
|
+
}
|
|
61
|
+
return results;
|
|
62
|
+
}
|
|
63
|
+
//#endregion
|
|
64
|
+
export { createReference, resolveReferences, searchReferences };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
//#region src/infrastructure/ua-parser.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* User-Agent 解析工具(轻量无依赖实现)
|
|
4
|
+
* 从 UA 字符串提取浏览器、操作系统、设备类型
|
|
5
|
+
*/
|
|
6
|
+
interface ParsedUA {
|
|
7
|
+
/** 浏览器名称 + 主版本号,如 "Chrome 120"、"Edge 119" */
|
|
8
|
+
browser: string;
|
|
9
|
+
/** 操作系统 + 主版本号,如 "Windows 10/11"、"macOS 14"、"iOS 17" */
|
|
10
|
+
os: string;
|
|
11
|
+
/** 设备类型:桌面 / iPhone / iPad / Android 手机 / Android 平板 */
|
|
12
|
+
device: string;
|
|
13
|
+
}
|
|
14
|
+
declare function parseUserAgent(ua: string | null | undefined): ParsedUA;
|
|
15
|
+
/**
|
|
16
|
+
* 将 ParsedUA 拼接为可读字符串,如 "Chrome 120 / Windows 10/11 / 桌面"
|
|
17
|
+
*/
|
|
18
|
+
declare function formatParsedUA(parsed: ParsedUA): string;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { ParsedUA, formatParsedUA, parseUserAgent };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
//#region src/infrastructure/ua-parser.ts
|
|
2
|
+
function parseUserAgent(ua) {
|
|
3
|
+
if (!ua) return {
|
|
4
|
+
browser: "Unknown",
|
|
5
|
+
os: "Unknown",
|
|
6
|
+
device: "Unknown"
|
|
7
|
+
};
|
|
8
|
+
let browser = "Unknown";
|
|
9
|
+
if (ua.includes("Edg/")) {
|
|
10
|
+
const m = ua.match(/Edg\/(\d+)/);
|
|
11
|
+
browser = `Edge${m ? " " + m[1] : ""}`;
|
|
12
|
+
} else if (ua.includes("OPR/") || ua.includes("Opera")) {
|
|
13
|
+
const m = ua.match(/(?:OPR|Opera)\/(\d+)/);
|
|
14
|
+
browser = `Opera${m ? " " + m[1] : ""}`;
|
|
15
|
+
} else if (ua.includes("Firefox/")) {
|
|
16
|
+
const m = ua.match(/Firefox\/(\d+)/);
|
|
17
|
+
browser = `Firefox${m ? " " + m[1] : ""}`;
|
|
18
|
+
} else if (ua.includes("Chrome/")) {
|
|
19
|
+
const m = ua.match(/Chrome\/(\d+)/);
|
|
20
|
+
browser = `Chrome${m ? " " + m[1] : ""}`;
|
|
21
|
+
} else if (ua.includes("Safari/") && !ua.includes("Chrome")) {
|
|
22
|
+
const m = ua.match(/Version\/(\d+)/);
|
|
23
|
+
browser = `Safari${m ? " " + m[1] : ""}`;
|
|
24
|
+
}
|
|
25
|
+
let os = "Unknown";
|
|
26
|
+
if (ua.includes("Windows NT 10")) os = "Windows 10/11";
|
|
27
|
+
else if (ua.includes("Windows NT 6.3")) os = "Windows 8.1";
|
|
28
|
+
else if (ua.includes("Windows NT 6.2")) os = "Windows 8";
|
|
29
|
+
else if (ua.includes("Windows NT 6.1")) os = "Windows 7";
|
|
30
|
+
else if (ua.includes("Windows")) os = "Windows";
|
|
31
|
+
else if (ua.includes("Mac OS X") || ua.includes("Macintosh")) {
|
|
32
|
+
if (/Mac OS X 10_15/.test(ua)) os = "macOS";
|
|
33
|
+
else {
|
|
34
|
+
const m = ua.match(/Mac OS X (\d+)(?:[_.](\d+))?/);
|
|
35
|
+
if (m) {
|
|
36
|
+
const major = parseInt(m[1], 10);
|
|
37
|
+
os = major >= 11 ? `macOS ${major}` : `Mac OS X ${m[1]}.${m[2] ?? "0"}`;
|
|
38
|
+
} else os = "macOS";
|
|
39
|
+
}
|
|
40
|
+
} else if (ua.includes("Android")) {
|
|
41
|
+
const m = ua.match(/Android ([\d.]+)/);
|
|
42
|
+
os = `Android${m ? " " + m[1] : ""}`;
|
|
43
|
+
} else if (/iPhone|iPad|iPod/.test(ua)) {
|
|
44
|
+
const m = ua.match(/OS (\d+)[_ ](?:\d+)?/);
|
|
45
|
+
os = `iOS${m ? " " + m[1] : ""}`;
|
|
46
|
+
} else if (ua.includes("Linux")) os = "Linux";
|
|
47
|
+
let device = "Desktop";
|
|
48
|
+
if (ua.includes("iPad")) device = "iPad";
|
|
49
|
+
else if (ua.includes("iPhone")) device = "iPhone";
|
|
50
|
+
else if (ua.includes("Android") && ua.includes("Mobile")) device = "Android Phone";
|
|
51
|
+
else if (ua.includes("Android")) device = "Android Tablet";
|
|
52
|
+
return {
|
|
53
|
+
browser,
|
|
54
|
+
os,
|
|
55
|
+
device
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 将 ParsedUA 拼接为可读字符串,如 "Chrome 120 / Windows 10/11 / 桌面"
|
|
60
|
+
*/
|
|
61
|
+
function formatParsedUA(parsed) {
|
|
62
|
+
return [
|
|
63
|
+
parsed.browser,
|
|
64
|
+
parsed.os,
|
|
65
|
+
parsed.device
|
|
66
|
+
].filter((s) => s && s !== "Unknown").join(" / ");
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { formatParsedUA, parseUserAgent };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/interfaces/ai.d.ts
|
|
2
|
+
interface CLIAgentInfo {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
binary: string;
|
|
6
|
+
version: string;
|
|
7
|
+
available: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface AiAdapter {
|
|
10
|
+
detect(): Promise<CLIAgentInfo[]>;
|
|
11
|
+
execute(commandId: string, ctx: {
|
|
12
|
+
entityType: string;
|
|
13
|
+
entityIds: string[];
|
|
14
|
+
userInput?: string;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
content: string;
|
|
17
|
+
}>;
|
|
18
|
+
stream(commandId: string, ctx: {
|
|
19
|
+
entityType: string;
|
|
20
|
+
entityIds: string[];
|
|
21
|
+
userInput?: string;
|
|
22
|
+
}): AsyncGenerator<string>;
|
|
23
|
+
getActiveAgent(): string;
|
|
24
|
+
switchAgent(agentId: string): void;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { AiAdapter, CLIAgentInfo };
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
//#region src/interfaces/avatar.d.ts
|
|
2
|
+
type AvatarPart = "face" | "eyes" | "eyebrows" | "mouth" | "nose" | "glasses" | "hair" | "accessories" | "details" | "beard";
|
|
3
|
+
type AvatarConfig = Record<AvatarPart, number>;
|
|
4
|
+
type ShapeType = "circle" | "rounded" | "square";
|
|
5
|
+
//#endregion
|
|
6
|
+
export { AvatarConfig, AvatarPart, ShapeType };
|
|
File without changes
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
//#region src/interfaces/module.d.ts
|
|
2
|
+
interface EntityDef {
|
|
3
|
+
type: string;
|
|
4
|
+
table: string;
|
|
5
|
+
searchFields: string[];
|
|
6
|
+
displayFields: string[];
|
|
7
|
+
}
|
|
8
|
+
interface AICommandContext {
|
|
9
|
+
entityType: string;
|
|
10
|
+
entityIds: string[];
|
|
11
|
+
userInput?: string;
|
|
12
|
+
module: AllBlueModule;
|
|
13
|
+
}
|
|
14
|
+
interface AICommandResult {
|
|
15
|
+
content: string;
|
|
16
|
+
actions?: {
|
|
17
|
+
type: string;
|
|
18
|
+
payload: unknown;
|
|
19
|
+
}[];
|
|
20
|
+
}
|
|
21
|
+
type AICommandHandler = (ctx: AICommandContext) => Promise<AICommandResult>;
|
|
22
|
+
interface AICommandDef {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
icon: string;
|
|
26
|
+
entityTypes: string[];
|
|
27
|
+
handler: AICommandHandler;
|
|
28
|
+
}
|
|
29
|
+
type ReferenceDisplayFn = (type: string, data: Record<string, unknown>) => {
|
|
30
|
+
title: string;
|
|
31
|
+
status?: string;
|
|
32
|
+
priority?: string;
|
|
33
|
+
url?: string;
|
|
34
|
+
};
|
|
35
|
+
interface AllBlueModule {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
icon: string;
|
|
39
|
+
workspaceRoute: string;
|
|
40
|
+
entities: EntityDef[];
|
|
41
|
+
aiCommands: AICommandDef[];
|
|
42
|
+
referenceDisplay: ReferenceDisplayFn;
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { AICommandContext, AICommandDef, AICommandHandler, AICommandResult, AllBlueModule, EntityDef, ReferenceDisplayFn };
|
|
File without changes
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/interfaces/references.d.ts
|
|
2
|
+
interface RefDisplay {
|
|
3
|
+
title: string;
|
|
4
|
+
status?: string;
|
|
5
|
+
priority?: string;
|
|
6
|
+
url?: string;
|
|
7
|
+
}
|
|
8
|
+
interface Reference {
|
|
9
|
+
id: string;
|
|
10
|
+
sourceModule: string;
|
|
11
|
+
sourceEntityId: string;
|
|
12
|
+
targetModule: string;
|
|
13
|
+
targetEntityId: string;
|
|
14
|
+
}
|
|
15
|
+
interface ResolvedRef extends Reference {
|
|
16
|
+
display: RefDisplay;
|
|
17
|
+
}
|
|
18
|
+
interface SearchResult {
|
|
19
|
+
id: string;
|
|
20
|
+
module: string;
|
|
21
|
+
type: string;
|
|
22
|
+
title: string;
|
|
23
|
+
status?: string;
|
|
24
|
+
url?: string;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { RefDisplay, Reference, ResolvedRef, SearchResult };
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
//#region src/interfaces/transport.d.ts
|
|
2
|
+
interface EntityUpdateEvent {
|
|
3
|
+
type: string;
|
|
4
|
+
id: string;
|
|
5
|
+
fields: Record<string, unknown>;
|
|
6
|
+
}
|
|
7
|
+
interface RealtimeTransport {
|
|
8
|
+
subscribe(entityIds: string[], onUpdate: (event: EntityUpdateEvent) => void): () => void;
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { EntityUpdateEvent, RealtimeTransport };
|
|
File without changes
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Editor } from "@tiptap/react";
|
|
2
|
+
//#region src/lib/annotation-template.d.ts
|
|
3
|
+
/**
|
|
4
|
+
* 将 HTML 字符串转为 ProseMirror content 节点数组(用于 insertContent 的 content 字段)。
|
|
5
|
+
* 客户端调用(onAnnotate 事件触发),document 可用。
|
|
6
|
+
*/
|
|
7
|
+
declare function htmlToPmContent(editor: Editor, html: string): any[];
|
|
8
|
+
//#endregion
|
|
9
|
+
export { htmlToPmContent };
|