@axiom-lattice/gateway 3.0.2 → 3.0.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.
Files changed (155) hide show
  1. package/dist/index.js +31 -9
  2. package/dist/index.js.map +1 -1
  3. package/dist/index.mjs +31 -9
  4. package/dist/index.mjs.map +1 -1
  5. package/package.json +9 -6
  6. package/.eslintrc.json +0 -22
  7. package/.turbo/turbo-build.log +0 -46
  8. package/AGENTS.md +0 -112
  9. package/CHANGELOG.md +0 -1190
  10. package/LOGGER_CONFIG.md +0 -135
  11. package/RESUME_STREAM_CONTENT_BASED.md +0 -326
  12. package/RESUME_STREAM_README.md +0 -388
  13. package/jest.config.js +0 -72
  14. package/public/sdk/README.md +0 -695
  15. package/public/sdk/dashboard-engine-skill.md +0 -1122
  16. package/public/sdk/dashboard-single-file-spec.md +0 -357
  17. package/public/sdk/data-query-sdk-skill.md +0 -307
  18. package/public/sdk/data-query-sdk.d.ts +0 -252
  19. package/public/sdk/data-query-sdk.js +0 -970
  20. package/public/sdk/occupancy-dashboard.html +0 -363
  21. package/public/sdk/test-dashboard.html +0 -690
  22. package/scripts/seed-lark-installation.ts +0 -54
  23. package/src/__tests__/__mocks__/e2b.ts +0 -1
  24. package/src/__tests__/a2a.test.ts +0 -428
  25. package/src/__tests__/channel-installations.test.ts +0 -199
  26. package/src/__tests__/data-query.test.ts +0 -77
  27. package/src/__tests__/sandbox-provider-registration.test.ts +0 -74
  28. package/src/__tests__/setup.ts +0 -5
  29. package/src/__tests__/workspace.test.ts +0 -400
  30. package/src/channels/__tests__/routes.test.ts +0 -50
  31. package/src/channels/lark/LarkChannelAdapter.ts +0 -217
  32. package/src/channels/lark/README.md +0 -187
  33. package/src/channels/lark/__tests__/controller.test.ts +0 -136
  34. package/src/channels/lark/__tests__/mapping-service.test.ts +0 -118
  35. package/src/channels/lark/__tests__/parser.test.ts +0 -72
  36. package/src/channels/lark/__tests__/sender.test.ts +0 -37
  37. package/src/channels/lark/__tests__/verification.test.ts +0 -157
  38. package/src/channels/lark/controller.ts +0 -48
  39. package/src/channels/lark/mapping-service.ts +0 -138
  40. package/src/channels/lark/parser.ts +0 -68
  41. package/src/channels/lark/routes.ts +0 -22
  42. package/src/channels/lark/sender.ts +0 -58
  43. package/src/channels/lark/types.ts +0 -20
  44. package/src/channels/lark/verification.ts +0 -32
  45. package/src/channels/registry.ts +0 -20
  46. package/src/channels/routes.ts +0 -30
  47. package/src/channels/wechat/WechatChannelAdapter.ts +0 -294
  48. package/src/channels/wechat/__tests__/context-store.test.ts +0 -148
  49. package/src/channels/wechat/context-store.ts +0 -54
  50. package/src/channels/wechat/controller.ts +0 -59
  51. package/src/channels/wechat/routes.ts +0 -7
  52. package/src/channels/wechat/types.ts +0 -62
  53. package/src/channels/wechat/wechat-client.ts +0 -162
  54. package/src/config/local-a2a-templates.ts +0 -59
  55. package/src/config.ts +0 -124
  56. package/src/controllers/__tests__/assistant-local-a2a.test.ts +0 -147
  57. package/src/controllers/__tests__/local-a2a-templates.test.ts +0 -112
  58. package/src/controllers/__tests__/mime.test.ts +0 -74
  59. package/src/controllers/__tests__/resources.test.ts +0 -122
  60. package/src/controllers/__tests__/run.test.ts +0 -115
  61. package/src/controllers/__tests__/tasks.test.ts +0 -215
  62. package/src/controllers/__tests__/workflow-tracking.test.ts +0 -113
  63. package/src/controllers/agent_task.ts +0 -72
  64. package/src/controllers/assistant.ts +0 -490
  65. package/src/controllers/auth.ts +0 -524
  66. package/src/controllers/channel-bindings.ts +0 -135
  67. package/src/controllers/channel-installations.ts +0 -409
  68. package/src/controllers/collections.ts +0 -176
  69. package/src/controllers/config.ts +0 -126
  70. package/src/controllers/connections.ts +0 -181
  71. package/src/controllers/data-query.ts +0 -236
  72. package/src/controllers/database-configs.ts +0 -440
  73. package/src/controllers/embeddings.ts +0 -22
  74. package/src/controllers/entries.ts +0 -167
  75. package/src/controllers/eval.ts +0 -513
  76. package/src/controllers/export-import.ts +0 -166
  77. package/src/controllers/health.ts +0 -36
  78. package/src/controllers/local-a2a-templates.ts +0 -18
  79. package/src/controllers/local-a2a.ts +0 -149
  80. package/src/controllers/mcp-configs.ts +0 -673
  81. package/src/controllers/memory.ts +0 -257
  82. package/src/controllers/menu-items.ts +0 -114
  83. package/src/controllers/metrics-configs.ts +0 -1061
  84. package/src/controllers/middleware-types.ts +0 -15
  85. package/src/controllers/models.ts +0 -199
  86. package/src/controllers/personal-assistant.ts +0 -191
  87. package/src/controllers/resources.ts +0 -477
  88. package/src/controllers/run.ts +0 -338
  89. package/src/controllers/sandbox.ts +0 -255
  90. package/src/controllers/schedules.ts +0 -336
  91. package/src/controllers/skills.ts +0 -256
  92. package/src/controllers/tasks.ts +0 -213
  93. package/src/controllers/tenants.ts +0 -121
  94. package/src/controllers/thread_status.ts +0 -66
  95. package/src/controllers/threads.ts +0 -260
  96. package/src/controllers/tools.ts +0 -139
  97. package/src/controllers/users.ts +0 -135
  98. package/src/controllers/workflow-tracking.ts +0 -693
  99. package/src/controllers/workspace.ts +0 -879
  100. package/src/export_registrations/a2a-api-key.registration.ts +0 -89
  101. package/src/export_registrations/agent.registration.ts +0 -80
  102. package/src/export_registrations/binding.registration.ts +0 -106
  103. package/src/export_registrations/channel-installation.registration.ts +0 -88
  104. package/src/export_registrations/collection.registration.ts +0 -85
  105. package/src/export_registrations/connection.registration.ts +0 -97
  106. package/src/export_registrations/database-config.registration.ts +0 -94
  107. package/src/export_registrations/eval.registration.ts +0 -334
  108. package/src/export_registrations/index.ts +0 -31
  109. package/src/export_registrations/mcp-config.registration.ts +0 -97
  110. package/src/export_registrations/menu.registration.ts +0 -91
  111. package/src/export_registrations/metrics-config.registration.ts +0 -94
  112. package/src/export_registrations/skill.registration.ts +0 -88
  113. package/src/export_registrations/task.registration.ts +0 -99
  114. package/src/index.ts +0 -497
  115. package/src/logger/Logger.ts +0 -186
  116. package/src/router/MessageContext.ts +0 -14
  117. package/src/router/MessageRouter.ts +0 -490
  118. package/src/router/middlewares/auditLogger.ts +0 -34
  119. package/src/router/middlewares/deduplication.ts +0 -38
  120. package/src/router/middlewares/index.ts +0 -3
  121. package/src/router/middlewares/rateLimit.ts +0 -46
  122. package/src/routes/__tests__/a2a-test-connection.test.ts +0 -177
  123. package/src/routes/a2a-bridge.ts +0 -266
  124. package/src/routes/a2a-test-connection.ts +0 -126
  125. package/src/routes/a2a.ts +0 -851
  126. package/src/routes/channel-bindings.ts +0 -11
  127. package/src/routes/channel-installations.ts +0 -33
  128. package/src/routes/index.ts +0 -640
  129. package/src/routes/menu-items.ts +0 -10
  130. package/src/routes/resource-routes.ts +0 -35
  131. package/src/routes/stt.ts +0 -102
  132. package/src/schemas/data-query.ts +0 -69
  133. package/src/schemas/index.ts +0 -852
  134. package/src/services/ExportImportService.ts +0 -296
  135. package/src/services/__tests__/ExportImportService.test.ts +0 -130
  136. package/src/services/__tests__/eval-runner.test.ts +0 -131
  137. package/src/services/__tests__/local-a2a.test.ts +0 -124
  138. package/src/services/agent_task_consumer.ts +0 -348
  139. package/src/services/collection_service.ts +0 -258
  140. package/src/services/eval-runner.ts +0 -283
  141. package/src/services/local-a2a.ts +0 -354
  142. package/src/services/queue_service.ts +0 -104
  143. package/src/services/sandbox_service.ts +0 -223
  144. package/src/services/skill_service.ts +0 -97
  145. package/src/services/supabase.ts +0 -60
  146. package/src/swagger.ts +0 -77
  147. package/src/types/index.ts +0 -118
  148. package/src/types/koa.d.ts +0 -7
  149. package/src/utils/__tests__/local-a2a-runtime.test.ts +0 -77
  150. package/src/utils/__tests__/path-containment.test.ts +0 -35
  151. package/src/utils/a2a-url.ts +0 -20
  152. package/src/utils/local-a2a-runtime.ts +0 -107
  153. package/src/utils/mime.ts +0 -44
  154. package/src/utils/path-containment.ts +0 -38
  155. package/tsconfig.json +0 -26
@@ -1,89 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { A2AApiKeyStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): A2AApiKeyStore {
6
- return getStoreLattice('default', 'a2aApiKey').store as unknown as A2AApiKeyStore;
7
- }
8
-
9
- export const a2aApiKeyRegistration: ExportableEntityDefinition = {
10
- entityType: 'a2a_api_key',
11
- label: 'A2A API Key(API密钥)',
12
- category: 'core',
13
- dependsOn: [],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const keys = await store.list({ tenantId, limit: 10000, offset: 0 });
19
- return keys.map((k) => ({
20
- _exportId: '',
21
- data: {
22
- id: k.id,
23
- tenantId: k.tenantId,
24
- projectId: k.projectId,
25
- workspaceId: k.workspaceId,
26
- label: k.label,
27
- enabled: k.enabled,
28
- },
29
- }));
30
- },
31
-
32
- async previewImport(
33
- tenantId: string,
34
- entities: ExportableEntity[],
35
- ): Promise<ImportPreviewResult> {
36
- const store = getStore();
37
- const existing = await store.list({ tenantId, limit: 10000, offset: 0 });
38
- const existingIds = new Set(existing.map((k) => k.id));
39
-
40
- const conflicts: ImportPreviewResult['conflicts'] = [];
41
- const insertions: ImportPreviewResult['insertions'] = [];
42
-
43
- for (const entity of entities) {
44
- const d = entity.data as Record<string, unknown>;
45
- const id = d.id as string;
46
-
47
- if (existingIds.has(id)) {
48
- conflicts.push({
49
- _exportId: entity._exportId,
50
- entityType: 'a2a_api_key',
51
- conflictType: 'id_exists',
52
- existingId: id,
53
- existingName: (d.label as string) || id,
54
- });
55
- } else {
56
- insertions.push({
57
- _exportId: entity._exportId,
58
- entityType: 'a2a_api_key',
59
- name: (d.label as string) || id,
60
- });
61
- }
62
- }
63
-
64
- return { conflicts, insertions, errors: [] };
65
- },
66
-
67
- async applyImport(tenantId, entity, resolution) {
68
- if (resolution.action === 'skip') return {};
69
-
70
- const store = getStore();
71
- const d = entity.data as Record<string, unknown>;
72
-
73
- if (resolution.action === 'overwrite') {
74
- try {
75
- await store.delete(d.id as string);
76
- } catch { /* may not exist */ }
77
- }
78
-
79
- // Always generate a new key_value — key_value is globally unique
80
- await store.create({
81
- tenantId,
82
- projectId: d.projectId as string | undefined,
83
- workspaceId: d.workspaceId as string | undefined,
84
- label: d.label as string | undefined,
85
- });
86
-
87
- return { newId: undefined };
88
- },
89
- };
@@ -1,80 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { AssistantStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): AssistantStore {
6
- return getStoreLattice('default', 'assistant').store as unknown as AssistantStore;
7
- }
8
-
9
- export const agentRegistration: ExportableEntityDefinition = {
10
- entityType: 'agent',
11
- label: 'Agent(智能体)',
12
- category: 'core',
13
- dependsOn: ['skill'],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const agents = await store.getAllAssistants(tenantId);
19
- return agents.map((a) => ({
20
- _exportId: '',
21
- data: {
22
- id: a.id,
23
- name: a.name,
24
- description: a.description,
25
- graphDefinition: a.graphDefinition,
26
- },
27
- }));
28
- },
29
-
30
- async previewImport(
31
- tenantId: string,
32
- entities: ExportableEntity[],
33
- ): Promise<ImportPreviewResult> {
34
- const store = getStore();
35
- const existing = await store.getAllAssistants(tenantId);
36
- const existingIds = new Set(existing.map((a) => a.id));
37
-
38
- const conflicts: ImportPreviewResult['conflicts'] = [];
39
- const insertions: ImportPreviewResult['insertions'] = [];
40
-
41
- for (const entity of entities) {
42
- const id = entity.data.id as string;
43
- if (existingIds.has(id)) {
44
- conflicts.push({
45
- _exportId: entity._exportId,
46
- entityType: 'agent',
47
- conflictType: 'id_exists',
48
- existingId: id,
49
- existingName: (entity.data.name as string) || id,
50
- });
51
- } else {
52
- insertions.push({
53
- _exportId: entity._exportId,
54
- entityType: 'agent',
55
- name: (entity.data.name as string) || id,
56
- });
57
- }
58
- }
59
-
60
- return { conflicts, insertions, errors: [] };
61
- },
62
-
63
- async applyImport(tenantId, entity, resolution) {
64
- const store = getStore();
65
- const data = entity.data as Record<string, unknown>;
66
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : data.id as string;
67
-
68
- if (resolution.action === 'overwrite') {
69
- try { await store.deleteAssistant(tenantId, id); } catch { /* may not exist */ }
70
- }
71
-
72
- await store.createAssistant(tenantId, id, {
73
- name: data.name as string,
74
- description: (data.description as string) || '',
75
- graphDefinition: data.graphDefinition as Record<string, unknown>,
76
- });
77
-
78
- return { newId: id };
79
- },
80
- };
@@ -1,106 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { BindingRegistry } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): BindingRegistry {
6
- return getStoreLattice('default', 'channelBinding').store as unknown as BindingRegistry;
7
- }
8
-
9
- export const bindingRegistration: ExportableEntityDefinition = {
10
- entityType: 'binding',
11
- label: 'Binding(渠道绑定)',
12
- category: 'core',
13
- dependsOn: ['agent', 'channel_installation'],
14
- cascadeParents: [],
15
- referenceFields: { agentId: 'agent', channelInstallationId: 'channel_installation' },
16
-
17
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
18
- const store = getStore();
19
- const bindings = await store.list({ tenantId, limit: 10000, offset: 0 });
20
- return bindings.map((b) => ({
21
- _exportId: '',
22
- data: {
23
- channel: b.channel,
24
- channelInstallationId: b.channelInstallationId,
25
- senderId: b.senderId,
26
- agentId: b.agentId,
27
- threadId: b.threadId,
28
- workspaceId: b.workspaceId,
29
- projectId: b.projectId,
30
- threadMode: b.threadMode,
31
- senderDisplayName: b.senderDisplayName,
32
- senderMetadata: b.senderMetadata,
33
- enabled: b.enabled,
34
- },
35
- }));
36
- },
37
-
38
- async previewImport(
39
- tenantId: string,
40
- entities: ExportableEntity[],
41
- ): Promise<ImportPreviewResult> {
42
- const store = getStore();
43
- const existing = await store.list({ tenantId, limit: 10000, offset: 0 });
44
-
45
- const existingKeys = new Set(
46
- existing.map((b) => `${b.channel}:${b.channelInstallationId}:${b.senderId}`),
47
- );
48
-
49
- const conflicts: ImportPreviewResult['conflicts'] = [];
50
- const insertions: ImportPreviewResult['insertions'] = [];
51
-
52
- for (const entity of entities) {
53
- const d = entity.data as Record<string, unknown>;
54
- const key = `${d.channel}:${d.channelInstallationId}:${d.senderId}`;
55
- if (existingKeys.has(key)) {
56
- conflicts.push({
57
- _exportId: entity._exportId,
58
- entityType: 'binding',
59
- conflictType: 'unique_constraint',
60
- existingName: `${d.channel}:${d.senderId}`,
61
- field: 'channel+channelInstallationId+senderId',
62
- });
63
- } else {
64
- insertions.push({
65
- _exportId: entity._exportId,
66
- entityType: 'binding',
67
- name: `${d.channel}:${d.senderId}`,
68
- });
69
- }
70
- }
71
-
72
- return { conflicts, insertions, errors: [] };
73
- },
74
-
75
- async applyImport(tenantId, entity, resolution) {
76
- if (resolution.action === 'skip') return {};
77
-
78
- const store = getStore();
79
- const d = entity.data as Record<string, unknown>;
80
-
81
- if (resolution.action === 'overwrite') {
82
- const existing = await store.list({ tenantId, limit: 10000, offset: 0 });
83
- const match = existing.find(
84
- (b) => b.channel === d.channel && b.channelInstallationId === d.channelInstallationId && b.senderId === d.senderId,
85
- );
86
- if (match) {
87
- await store.delete(match.id);
88
- }
89
- }
90
-
91
- await store.create({
92
- channel: d.channel as string,
93
- channelInstallationId: d.channelInstallationId as string,
94
- tenantId,
95
- senderId: d.senderId as string,
96
- agentId: d.agentId as string,
97
- threadMode: (d.threadMode as 'fixed' | 'per_conversation') || 'fixed',
98
- senderDisplayName: d.senderDisplayName as string | undefined,
99
- senderMetadata: d.senderMetadata as Record<string, unknown> | undefined,
100
- workspaceId: d.workspaceId as string | undefined,
101
- projectId: d.projectId as string | undefined,
102
- });
103
-
104
- return { newId: undefined };
105
- },
106
- };
@@ -1,88 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { ChannelInstallationStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): ChannelInstallationStore {
6
- return getStoreLattice('default', 'channelInstallation').store as unknown as ChannelInstallationStore;
7
- }
8
-
9
- export const channelInstallationRegistration: ExportableEntityDefinition = {
10
- entityType: 'channel_installation',
11
- label: 'Channel Installation(渠道安装)',
12
- category: 'core',
13
- dependsOn: ['agent'],
14
- cascadeParents: [],
15
- referenceFields: { fallbackAgentId: 'agent' },
16
-
17
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
18
- const store = getStore();
19
- const installations = await store.getInstallationsByTenant(tenantId);
20
- return installations.map((i) => ({
21
- _exportId: '',
22
- data: {
23
- id: i.id,
24
- channel: i.channel,
25
- name: i.name,
26
- config: i.config,
27
- enabled: i.enabled,
28
- fallbackAgentId: i.fallbackAgentId,
29
- rejectWhenNoBinding: i.rejectWhenNoBinding,
30
- },
31
- }));
32
- },
33
-
34
- async previewImport(
35
- tenantId: string,
36
- entities: ExportableEntity[],
37
- ): Promise<ImportPreviewResult> {
38
- const store = getStore();
39
- const existing = await store.getInstallationsByTenant(tenantId);
40
- const existingIds = new Set(existing.map((i) => i.id));
41
-
42
- const conflicts: ImportPreviewResult['conflicts'] = [];
43
- const insertions: ImportPreviewResult['insertions'] = [];
44
-
45
- for (const entity of entities) {
46
- const d = entity.data as Record<string, unknown>;
47
- const id = d.id as string;
48
- if (existingIds.has(id)) {
49
- conflicts.push({
50
- _exportId: entity._exportId,
51
- entityType: 'channel_installation',
52
- conflictType: 'id_exists',
53
- existingId: id,
54
- existingName: (d.name as string) || id,
55
- });
56
- } else {
57
- insertions.push({
58
- _exportId: entity._exportId,
59
- entityType: 'channel_installation',
60
- name: (d.name as string) || id,
61
- });
62
- }
63
- }
64
-
65
- return { conflicts, insertions, errors: [] };
66
- },
67
-
68
- async applyImport(tenantId, entity, resolution) {
69
- const store = getStore();
70
- const data = entity.data as Record<string, unknown>;
71
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : data.id as string;
72
-
73
- if (resolution.action === 'overwrite') {
74
- try { await store.deleteInstallation(tenantId, id); } catch { /* may not exist */ }
75
- }
76
-
77
- await store.createInstallation(tenantId, id, {
78
- channel: data.channel as 'lark' | 'email' | 'slack' | 'wechat',
79
- name: data.name as string | undefined,
80
- config: data.config as any,
81
- enabled: data.enabled as boolean | undefined,
82
- fallbackAgentId: data.fallbackAgentId as string | undefined,
83
- rejectWhenNoBinding: data.rejectWhenNoBinding as boolean | undefined,
84
- });
85
-
86
- return { newId: id };
87
- },
88
- };
@@ -1,85 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { CollectionStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): CollectionStore {
6
- return getStoreLattice('default', 'collection').store as unknown as CollectionStore;
7
- }
8
-
9
- export const collectionRegistration: ExportableEntityDefinition = {
10
- entityType: 'collection',
11
- label: 'Collection(知识库)',
12
- category: 'core',
13
- dependsOn: [],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const collections = await store.getAllCollections(tenantId);
19
- return collections.map((c) => ({
20
- _exportId: '',
21
- data: {
22
- id: c.id,
23
- name: c.name,
24
- label: c.label,
25
- embeddingKey: c.embeddingKey,
26
- schema: c.schema,
27
- },
28
- }));
29
- },
30
-
31
- async previewImport(
32
- tenantId: string,
33
- entities: ExportableEntity[],
34
- ): Promise<ImportPreviewResult> {
35
- const store = getStore();
36
- const existing = await store.getAllCollections(tenantId);
37
- const existingNames = new Set(existing.map((c) => c.name));
38
-
39
- const conflicts: ImportPreviewResult['conflicts'] = [];
40
- const insertions: ImportPreviewResult['insertions'] = [];
41
-
42
- for (const entity of entities) {
43
- const d = entity.data as Record<string, unknown>;
44
- const name = d.name as string;
45
- if (existingNames.has(name)) {
46
- conflicts.push({
47
- _exportId: entity._exportId,
48
- entityType: 'collection',
49
- conflictType: 'unique_constraint',
50
- existingName: name,
51
- field: 'name',
52
- });
53
- } else {
54
- insertions.push({
55
- _exportId: entity._exportId,
56
- entityType: 'collection',
57
- name: name,
58
- });
59
- }
60
- }
61
-
62
- return { conflicts, insertions, errors: [] };
63
- },
64
-
65
- async applyImport(tenantId, entity, resolution) {
66
- if (resolution.action === 'skip') return {};
67
-
68
- const store = getStore();
69
- const d = entity.data as Record<string, unknown>;
70
- const name = d.name as string;
71
-
72
- if (resolution.action === 'overwrite') {
73
- try { await store.deleteCollection(tenantId, name); } catch { /* may not exist */ }
74
- }
75
-
76
- await store.createCollection(tenantId, {
77
- name,
78
- label: d.label as string,
79
- embeddingKey: d.embeddingKey as string,
80
- schema: d.schema as any,
81
- });
82
-
83
- return { newId: undefined };
84
- },
85
- };
@@ -1,97 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { ConnectionEntry, ConnectionStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): ConnectionStore {
6
- return getStoreLattice('default', 'connection').store as unknown as ConnectionStore;
7
- }
8
-
9
- async function listAllConnections(tenantId: string): Promise<ConnectionEntry[]> {
10
- const store = getStore();
11
- if (typeof store.listByTenant !== 'function') {
12
- throw new Error('ConnectionStore.listByTenant is not implemented. SQL bypass removed — upgrade your store adapter.');
13
- }
14
- return store.listByTenant(tenantId);
15
- }
16
-
17
- export const connectionRegistration: ExportableEntityDefinition = {
18
- entityType: 'connection',
19
- label: 'Connection(连接)',
20
- category: 'core',
21
- dependsOn: [],
22
- cascadeParents: [],
23
-
24
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
25
- const connections = await listAllConnections(tenantId);
26
- return connections.map((c) => ({
27
- _exportId: '',
28
- data: {
29
- id: c.id,
30
- type: c.type,
31
- key: c.key,
32
- name: c.name,
33
- description: c.description,
34
- config: c.config,
35
- },
36
- }));
37
- },
38
-
39
- async previewImport(
40
- tenantId: string,
41
- entities: ExportableEntity[],
42
- ): Promise<ImportPreviewResult> {
43
- const existing = await listAllConnections(tenantId);
44
- const existingCompositeKeys = new Set(
45
- existing.map((c) => `${c.type}:${c.key}`),
46
- );
47
-
48
- const conflicts: ImportPreviewResult['conflicts'] = [];
49
- const insertions: ImportPreviewResult['insertions'] = [];
50
-
51
- for (const entity of entities) {
52
- const d = entity.data as Record<string, unknown>;
53
- const compositeKey = `${d.type}:${d.key}`;
54
- if (existingCompositeKeys.has(compositeKey)) {
55
- conflicts.push({
56
- _exportId: entity._exportId,
57
- entityType: 'connection',
58
- conflictType: 'unique_constraint',
59
- existingName: `${d.type}:${d.key}`,
60
- field: 'type+key',
61
- });
62
- } else {
63
- insertions.push({
64
- _exportId: entity._exportId,
65
- entityType: 'connection',
66
- name: `${d.type}:${d.key}`,
67
- });
68
- }
69
- }
70
-
71
- return { conflicts, insertions, errors: [] };
72
- },
73
-
74
- async applyImport(tenantId, entity, resolution) {
75
- if (resolution.action === 'skip') return {};
76
-
77
- const store = getStore();
78
- const d = entity.data as Record<string, unknown>;
79
- const type = d.type as string;
80
- const key = d.key as string;
81
-
82
- if (resolution.action === 'overwrite') {
83
- try { await store.delete(tenantId, type, key); } catch { /* may not exist */ }
84
- }
85
-
86
- await store.create({
87
- tenantId,
88
- type,
89
- key,
90
- name: d.name as string,
91
- description: d.description as string | undefined,
92
- config: d.config as Record<string, unknown>,
93
- });
94
-
95
- return { newId: undefined };
96
- },
97
- };
@@ -1,94 +0,0 @@
1
- import type { ExportableEntityDefinition, ExportableEntity, ImportPreviewResult } from '@axiom-lattice/core';
2
- import { getStoreLattice } from '@axiom-lattice/core';
3
- import type { DatabaseConfigStore } from '@axiom-lattice/protocols';
4
-
5
- function getStore(): DatabaseConfigStore {
6
- return getStoreLattice('default', 'database').store as unknown as DatabaseConfigStore;
7
- }
8
-
9
- export const databaseConfigRegistration: ExportableEntityDefinition = {
10
- entityType: 'database_config',
11
- label: 'Database Config(数据库配置)',
12
- category: 'core',
13
- dependsOn: [],
14
- cascadeParents: [],
15
-
16
- async listForExport(tenantId: string): Promise<ExportableEntity[]> {
17
- const store = getStore();
18
- const configs = await store.getAllConfigs(tenantId);
19
- return configs.map((c) => ({
20
- _exportId: '',
21
- data: {
22
- id: c.id,
23
- key: c.key,
24
- name: c.name,
25
- description: c.description,
26
- config: c.config,
27
- },
28
- }));
29
- },
30
-
31
- async previewImport(
32
- tenantId: string,
33
- entities: ExportableEntity[],
34
- ): Promise<ImportPreviewResult> {
35
- const store = getStore();
36
- const existing = await store.getAllConfigs(tenantId);
37
- const existingIds = new Set(existing.map((c) => c.id));
38
- const existingKeys = new Set(existing.map((c) => c.key));
39
-
40
- const conflicts: ImportPreviewResult['conflicts'] = [];
41
- const insertions: ImportPreviewResult['insertions'] = [];
42
-
43
- for (const entity of entities) {
44
- const d = entity.data as Record<string, unknown>;
45
- const id = d.id as string;
46
- const key = d.key as string;
47
-
48
- if (existingIds.has(id)) {
49
- conflicts.push({
50
- _exportId: entity._exportId,
51
- entityType: 'database_config',
52
- conflictType: 'id_exists',
53
- existingId: id,
54
- existingName: (d.name as string) || key,
55
- });
56
- } else if (key && existingKeys.has(key)) {
57
- conflicts.push({
58
- _exportId: entity._exportId,
59
- entityType: 'database_config',
60
- conflictType: 'unique_constraint',
61
- existingName: (d.name as string) || key,
62
- field: 'key',
63
- });
64
- } else {
65
- insertions.push({
66
- _exportId: entity._exportId,
67
- entityType: 'database_config',
68
- name: (d.name as string) || key,
69
- });
70
- }
71
- }
72
-
73
- return { conflicts, insertions, errors: [] };
74
- },
75
-
76
- async applyImport(tenantId, entity, resolution) {
77
- const store = getStore();
78
- const data = entity.data as Record<string, unknown>;
79
- const id = resolution.action === 'rename' && resolution.newId ? resolution.newId : data.id as string;
80
-
81
- if (resolution.action === 'overwrite') {
82
- try { await store.deleteConfig(tenantId, id); } catch { /* may not exist */ }
83
- }
84
-
85
- await store.createConfig(tenantId, id, {
86
- key: data.key as string,
87
- name: data.name as string | undefined,
88
- description: data.description as string | undefined,
89
- config: data.config as any,
90
- });
91
-
92
- return { newId: id };
93
- },
94
- };