@inkeep/agents-core 0.0.0-dev-20250910233133 → 0.0.0-dev-20250910233441

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 (279) hide show
  1. package/dist/chunk-BIIFENNH.js +11 -0
  2. package/dist/chunk-H2F72PDA.js +15 -0
  3. package/dist/chunk-MKBO26DX.js +9 -0
  4. package/dist/chunk-RFWSE64N.js +665 -0
  5. package/dist/chunk-TSPWAF64.js +821 -0
  6. package/dist/client-exports.cjs +232 -0
  7. package/dist/client-exports.d.cts +302 -0
  8. package/dist/client-exports.d.ts +46 -43
  9. package/dist/client-exports.js +200 -247
  10. package/dist/db/schema.cjs +818 -0
  11. package/dist/db/schema.d.cts +7 -0
  12. package/dist/db/schema.d.ts +7 -4335
  13. package/dist/db/schema.js +1 -696
  14. package/dist/index.cjs +9809 -0
  15. package/dist/index.d.cts +3992 -0
  16. package/dist/index.d.ts +3992 -12
  17. package/dist/index.js +7807 -13
  18. package/dist/schema-B5YbTpz8.d.ts +4382 -0
  19. package/dist/schema-E0ulMd3k.d.cts +4382 -0
  20. package/dist/types/index.cjs +29 -0
  21. package/dist/types/index.d.cts +123 -0
  22. package/dist/types/index.d.ts +123 -5
  23. package/dist/types/index.js +2 -6
  24. package/dist/{validation/schemas.d.ts → utility-D2Lb-YAS.d.cts} +1350 -617
  25. package/dist/utility-D2Lb-YAS.d.ts +7946 -0
  26. package/dist/validation/index.cjs +1617 -0
  27. package/dist/validation/index.d.cts +63 -0
  28. package/dist/validation/index.d.ts +63 -4
  29. package/dist/validation/index.js +1 -5
  30. package/package.json +2 -2
  31. package/dist/__tests__/integration/helpers.d.ts +0 -5
  32. package/dist/__tests__/integration/helpers.d.ts.map +0 -1
  33. package/dist/__tests__/integration/helpers.js +0 -37
  34. package/dist/__tests__/integration/helpers.js.map +0 -1
  35. package/dist/__tests__/setup.d.ts +0 -3
  36. package/dist/__tests__/setup.d.ts.map +0 -1
  37. package/dist/__tests__/setup.js +0 -29
  38. package/dist/__tests__/setup.js.map +0 -1
  39. package/dist/client-exports.d.ts.map +0 -1
  40. package/dist/client-exports.js.map +0 -1
  41. package/dist/context/ContextConfig.d.ts +0 -54
  42. package/dist/context/ContextConfig.d.ts.map +0 -1
  43. package/dist/context/ContextConfig.js +0 -302
  44. package/dist/context/ContextConfig.js.map +0 -1
  45. package/dist/context/ContextFetcher.d.ts +0 -64
  46. package/dist/context/ContextFetcher.d.ts.map +0 -1
  47. package/dist/context/ContextFetcher.js +0 -325
  48. package/dist/context/ContextFetcher.js.map +0 -1
  49. package/dist/context/ContextResolver.d.ts +0 -52
  50. package/dist/context/ContextResolver.d.ts.map +0 -1
  51. package/dist/context/ContextResolver.js +0 -298
  52. package/dist/context/ContextResolver.js.map +0 -1
  53. package/dist/context/TemplateEngine.d.ts +0 -46
  54. package/dist/context/TemplateEngine.d.ts.map +0 -1
  55. package/dist/context/TemplateEngine.js +0 -175
  56. package/dist/context/TemplateEngine.js.map +0 -1
  57. package/dist/context/context.d.ts +0 -8
  58. package/dist/context/context.d.ts.map +0 -1
  59. package/dist/context/context.js +0 -157
  60. package/dist/context/context.js.map +0 -1
  61. package/dist/context/contextCache.d.ts +0 -50
  62. package/dist/context/contextCache.d.ts.map +0 -1
  63. package/dist/context/contextCache.js +0 -175
  64. package/dist/context/contextCache.js.map +0 -1
  65. package/dist/context/index.d.ts +0 -11
  66. package/dist/context/index.d.ts.map +0 -1
  67. package/dist/context/index.js +0 -8
  68. package/dist/context/index.js.map +0 -1
  69. package/dist/credential-stores/CredentialStoreRegistry.d.ts +0 -39
  70. package/dist/credential-stores/CredentialStoreRegistry.d.ts.map +0 -1
  71. package/dist/credential-stores/CredentialStoreRegistry.js +0 -65
  72. package/dist/credential-stores/CredentialStoreRegistry.js.map +0 -1
  73. package/dist/credential-stores/defaults.d.ts +0 -6
  74. package/dist/credential-stores/defaults.d.ts.map +0 -1
  75. package/dist/credential-stores/defaults.js +0 -22
  76. package/dist/credential-stores/defaults.js.map +0 -1
  77. package/dist/credential-stores/index.d.ts +0 -6
  78. package/dist/credential-stores/index.d.ts.map +0 -1
  79. package/dist/credential-stores/index.js +0 -6
  80. package/dist/credential-stores/index.js.map +0 -1
  81. package/dist/credential-stores/keychain-store.d.ts +0 -100
  82. package/dist/credential-stores/keychain-store.d.ts.map +0 -1
  83. package/dist/credential-stores/keychain-store.js +0 -225
  84. package/dist/credential-stores/keychain-store.js.map +0 -1
  85. package/dist/credential-stores/memory-store.d.ts +0 -39
  86. package/dist/credential-stores/memory-store.d.ts.map +0 -1
  87. package/dist/credential-stores/memory-store.js +0 -58
  88. package/dist/credential-stores/memory-store.js.map +0 -1
  89. package/dist/credential-stores/nango-store.d.ts +0 -59
  90. package/dist/credential-stores/nango-store.d.ts.map +0 -1
  91. package/dist/credential-stores/nango-store.js +0 -264
  92. package/dist/credential-stores/nango-store.js.map +0 -1
  93. package/dist/credential-stuffer/CredentialStuffer.d.ts +0 -80
  94. package/dist/credential-stuffer/CredentialStuffer.d.ts.map +0 -1
  95. package/dist/credential-stuffer/CredentialStuffer.js +0 -186
  96. package/dist/credential-stuffer/CredentialStuffer.js.map +0 -1
  97. package/dist/credential-stuffer/index.d.ts +0 -2
  98. package/dist/credential-stuffer/index.d.ts.map +0 -1
  99. package/dist/credential-stuffer/index.js +0 -2
  100. package/dist/credential-stuffer/index.js.map +0 -1
  101. package/dist/data-access/agentDataComponents.d.ts +0 -1
  102. package/dist/data-access/agentDataComponents.d.ts.map +0 -1
  103. package/dist/data-access/agentDataComponents.js +0 -2
  104. package/dist/data-access/agentDataComponents.js.map +0 -1
  105. package/dist/data-access/agentGraphs.d.ts +0 -399
  106. package/dist/data-access/agentGraphs.d.ts.map +0 -1
  107. package/dist/data-access/agentGraphs.js +0 -551
  108. package/dist/data-access/agentGraphs.js.map +0 -1
  109. package/dist/data-access/agentRelations.d.ts +0 -456
  110. package/dist/data-access/agentRelations.d.ts.map +0 -1
  111. package/dist/data-access/agentRelations.js +0 -471
  112. package/dist/data-access/agentRelations.js.map +0 -1
  113. package/dist/data-access/agents.d.ts +0 -218
  114. package/dist/data-access/agents.d.ts.map +0 -1
  115. package/dist/data-access/agents.js +0 -130
  116. package/dist/data-access/agents.js.map +0 -1
  117. package/dist/data-access/apiKeys.d.ts +0 -114
  118. package/dist/data-access/apiKeys.d.ts.map +0 -1
  119. package/dist/data-access/apiKeys.js +0 -185
  120. package/dist/data-access/apiKeys.js.map +0 -1
  121. package/dist/data-access/artifactComponents.d.ts +0 -152
  122. package/dist/data-access/artifactComponents.d.ts.map +0 -1
  123. package/dist/data-access/artifactComponents.js +0 -214
  124. package/dist/data-access/artifactComponents.js.map +0 -1
  125. package/dist/data-access/contextCache.d.ts +0 -68
  126. package/dist/data-access/contextCache.d.ts.map +0 -1
  127. package/dist/data-access/contextCache.js +0 -135
  128. package/dist/data-access/contextCache.js.map +0 -1
  129. package/dist/data-access/contextConfigs.d.ts +0 -110
  130. package/dist/data-access/contextConfigs.d.ts.map +0 -1
  131. package/dist/data-access/contextConfigs.js +0 -156
  132. package/dist/data-access/contextConfigs.js.map +0 -1
  133. package/dist/data-access/conversations.d.ts +0 -125
  134. package/dist/data-access/conversations.d.ts.map +0 -1
  135. package/dist/data-access/conversations.js +0 -244
  136. package/dist/data-access/conversations.js.map +0 -1
  137. package/dist/data-access/credentialReferences.d.ts +0 -86
  138. package/dist/data-access/credentialReferences.d.ts.map +0 -1
  139. package/dist/data-access/credentialReferences.js +0 -175
  140. package/dist/data-access/credentialReferences.js.map +0 -1
  141. package/dist/data-access/dataComponents.d.ts +0 -129
  142. package/dist/data-access/dataComponents.d.ts.map +0 -1
  143. package/dist/data-access/dataComponents.js +0 -213
  144. package/dist/data-access/dataComponents.js.map +0 -1
  145. package/dist/data-access/externalAgents.d.ts +0 -83
  146. package/dist/data-access/externalAgents.d.ts.map +0 -1
  147. package/dist/data-access/externalAgents.js +0 -163
  148. package/dist/data-access/externalAgents.js.map +0 -1
  149. package/dist/data-access/graphFull.d.ts +0 -32
  150. package/dist/data-access/graphFull.d.ts.map +0 -1
  151. package/dist/data-access/graphFull.js +0 -996
  152. package/dist/data-access/graphFull.js.map +0 -1
  153. package/dist/data-access/index.d.ts +0 -21
  154. package/dist/data-access/index.d.ts.map +0 -1
  155. package/dist/data-access/index.js +0 -22
  156. package/dist/data-access/index.js.map +0 -1
  157. package/dist/data-access/ledgerArtifacts.d.ts +0 -49
  158. package/dist/data-access/ledgerArtifacts.d.ts.map +0 -1
  159. package/dist/data-access/ledgerArtifacts.js +0 -112
  160. package/dist/data-access/ledgerArtifacts.js.map +0 -1
  161. package/dist/data-access/messages.d.ts +0 -209
  162. package/dist/data-access/messages.d.ts.map +0 -1
  163. package/dist/data-access/messages.js +0 -100
  164. package/dist/data-access/messages.js.map +0 -1
  165. package/dist/data-access/projects.d.ts +0 -67
  166. package/dist/data-access/projects.d.ts.map +0 -1
  167. package/dist/data-access/projects.js +0 -337
  168. package/dist/data-access/projects.js.map +0 -1
  169. package/dist/data-access/tasks.d.ts +0 -37
  170. package/dist/data-access/tasks.d.ts.map +0 -1
  171. package/dist/data-access/tasks.js +0 -40
  172. package/dist/data-access/tasks.js.map +0 -1
  173. package/dist/data-access/tools.d.ts +0 -277
  174. package/dist/data-access/tools.d.ts.map +0 -1
  175. package/dist/data-access/tools.js +0 -183
  176. package/dist/data-access/tools.js.map +0 -1
  177. package/dist/data-access/validation.d.ts +0 -17
  178. package/dist/data-access/validation.d.ts.map +0 -1
  179. package/dist/data-access/validation.js +0 -52
  180. package/dist/data-access/validation.js.map +0 -1
  181. package/dist/db/clean.d.ts +0 -6
  182. package/dist/db/clean.d.ts.map +0 -1
  183. package/dist/db/clean.js +0 -81
  184. package/dist/db/clean.js.map +0 -1
  185. package/dist/db/client.d.ts +0 -19
  186. package/dist/db/client.d.ts.map +0 -1
  187. package/dist/db/client.js +0 -24
  188. package/dist/db/client.js.map +0 -1
  189. package/dist/db/schema.d.ts.map +0 -1
  190. package/dist/db/schema.js.map +0 -1
  191. package/dist/db/test-client.d.ts +0 -25
  192. package/dist/db/test-client.d.ts.map +0 -1
  193. package/dist/db/test-client.js +0 -136
  194. package/dist/db/test-client.js.map +0 -1
  195. package/dist/env.d.ts +0 -19
  196. package/dist/env.d.ts.map +0 -1
  197. package/dist/env.js +0 -49
  198. package/dist/env.js.map +0 -1
  199. package/dist/index.d.ts.map +0 -1
  200. package/dist/index.js.map +0 -1
  201. package/dist/middleware/contextValidation.d.ts +0 -49
  202. package/dist/middleware/contextValidation.d.ts.map +0 -1
  203. package/dist/middleware/contextValidation.js +0 -473
  204. package/dist/middleware/contextValidation.js.map +0 -1
  205. package/dist/middleware/index.d.ts +0 -2
  206. package/dist/middleware/index.d.ts.map +0 -1
  207. package/dist/middleware/index.js +0 -2
  208. package/dist/middleware/index.js.map +0 -1
  209. package/dist/types/a2a.d.ts +0 -373
  210. package/dist/types/a2a.d.ts.map +0 -1
  211. package/dist/types/a2a.js +0 -14
  212. package/dist/types/a2a.js.map +0 -1
  213. package/dist/types/entities.d.ts +0 -147
  214. package/dist/types/entities.d.ts.map +0 -1
  215. package/dist/types/entities.js +0 -2
  216. package/dist/types/entities.js.map +0 -1
  217. package/dist/types/index.d.ts.map +0 -1
  218. package/dist/types/index.js.map +0 -1
  219. package/dist/types/server.d.ts +0 -116
  220. package/dist/types/server.d.ts.map +0 -1
  221. package/dist/types/server.js +0 -2
  222. package/dist/types/server.js.map +0 -1
  223. package/dist/types/utility.d.ts +0 -213
  224. package/dist/types/utility.d.ts.map +0 -1
  225. package/dist/types/utility.js +0 -9
  226. package/dist/types/utility.js.map +0 -1
  227. package/dist/utils/apiKeys.d.ts +0 -32
  228. package/dist/utils/apiKeys.d.ts.map +0 -1
  229. package/dist/utils/apiKeys.js +0 -117
  230. package/dist/utils/apiKeys.js.map +0 -1
  231. package/dist/utils/auth-detection.d.ts +0 -23
  232. package/dist/utils/auth-detection.d.ts.map +0 -1
  233. package/dist/utils/auth-detection.js +0 -148
  234. package/dist/utils/auth-detection.js.map +0 -1
  235. package/dist/utils/credential-store-utils.d.ts +0 -11
  236. package/dist/utils/credential-store-utils.d.ts.map +0 -1
  237. package/dist/utils/credential-store-utils.js +0 -19
  238. package/dist/utils/credential-store-utils.js.map +0 -1
  239. package/dist/utils/error.d.ts +0 -526
  240. package/dist/utils/error.d.ts.map +0 -1
  241. package/dist/utils/error.js +0 -282
  242. package/dist/utils/error.js.map +0 -1
  243. package/dist/utils/execution.d.ts +0 -18
  244. package/dist/utils/execution.d.ts.map +0 -1
  245. package/dist/utils/execution.js +0 -25
  246. package/dist/utils/execution.js.map +0 -1
  247. package/dist/utils/index.d.ts +0 -9
  248. package/dist/utils/index.d.ts.map +0 -1
  249. package/dist/utils/index.js +0 -9
  250. package/dist/utils/index.js.map +0 -1
  251. package/dist/utils/logger.d.ts +0 -79
  252. package/dist/utils/logger.d.ts.map +0 -1
  253. package/dist/utils/logger.js +0 -102
  254. package/dist/utils/logger.js.map +0 -1
  255. package/dist/utils/logging.d.ts +0 -11
  256. package/dist/utils/logging.d.ts.map +0 -1
  257. package/dist/utils/logging.js +0 -6
  258. package/dist/utils/logging.js.map +0 -1
  259. package/dist/utils/mcp-client.d.ts +0 -48
  260. package/dist/utils/mcp-client.d.ts.map +0 -1
  261. package/dist/utils/mcp-client.js +0 -174
  262. package/dist/utils/mcp-client.js.map +0 -1
  263. package/dist/utils/tracer.d.ts +0 -24
  264. package/dist/utils/tracer.d.ts.map +0 -1
  265. package/dist/utils/tracer.js +0 -110
  266. package/dist/utils/tracer.js.map +0 -1
  267. package/dist/validation/graphFull.d.ts +0 -36
  268. package/dist/validation/graphFull.d.ts.map +0 -1
  269. package/dist/validation/graphFull.js +0 -128
  270. package/dist/validation/graphFull.js.map +0 -1
  271. package/dist/validation/id-validation.d.ts +0 -38
  272. package/dist/validation/id-validation.d.ts.map +0 -1
  273. package/dist/validation/id-validation.js +0 -60
  274. package/dist/validation/id-validation.js.map +0 -1
  275. package/dist/validation/index.d.ts.map +0 -1
  276. package/dist/validation/index.js.map +0 -1
  277. package/dist/validation/schemas.d.ts.map +0 -1
  278. package/dist/validation/schemas.js +0 -576
  279. package/dist/validation/schemas.js.map +0 -1
@@ -1,152 +0,0 @@
1
- import type { DatabaseClient } from '../db/client';
2
- import type { ArtifactComponentInsert, ArtifactComponentSelect, ArtifactComponentUpdate } from '../types/entities';
3
- import type { PaginationConfig, ScopeConfig } from '../types/utility';
4
- export declare const getArtifactComponentById: (db: DatabaseClient) => (params: {
5
- scopes: ScopeConfig;
6
- id: string;
7
- }) => Promise<{
8
- tenantId: string;
9
- projectId: string;
10
- id: string;
11
- name: string;
12
- description: string;
13
- createdAt: string;
14
- updatedAt: string;
15
- summaryProps: Record<string, unknown> | null;
16
- fullProps: Record<string, unknown> | null;
17
- } | undefined>;
18
- export declare const listArtifactComponents: (db: DatabaseClient) => (params: {
19
- scopes: ScopeConfig;
20
- }) => Promise<{
21
- tenantId: string;
22
- projectId: string;
23
- id: string;
24
- name: string;
25
- description: string;
26
- summaryProps: Record<string, unknown> | null;
27
- fullProps: Record<string, unknown> | null;
28
- createdAt: string;
29
- updatedAt: string;
30
- }[]>;
31
- export declare const listArtifactComponentsPaginated: (db: DatabaseClient) => (params: {
32
- scopes: ScopeConfig;
33
- pagination?: PaginationConfig;
34
- }) => Promise<{
35
- data: ArtifactComponentSelect[];
36
- pagination: {
37
- page: number;
38
- limit: number;
39
- total: number;
40
- pages: number;
41
- };
42
- }>;
43
- export declare const createArtifactComponent: (db: DatabaseClient) => (params: ArtifactComponentInsert) => Promise<{
44
- tenantId: string;
45
- projectId: string;
46
- id: string;
47
- name: string;
48
- description: string;
49
- createdAt: string;
50
- updatedAt: string;
51
- summaryProps: Record<string, unknown> | null;
52
- fullProps: Record<string, unknown> | null;
53
- }>;
54
- export declare const updateArtifactComponent: (db: DatabaseClient) => (params: {
55
- scopes: ScopeConfig;
56
- id: string;
57
- data: ArtifactComponentUpdate;
58
- }) => Promise<{
59
- tenantId: string;
60
- projectId: string;
61
- id: string;
62
- name: string;
63
- description: string;
64
- createdAt: string;
65
- updatedAt: string;
66
- summaryProps: Record<string, unknown> | null;
67
- fullProps: Record<string, unknown> | null;
68
- }>;
69
- export declare const deleteArtifactComponent: (db: DatabaseClient) => (params: {
70
- scopes: ScopeConfig;
71
- id: string;
72
- }) => Promise<boolean>;
73
- export declare const getArtifactComponentsForAgent: (db: DatabaseClient) => (params: {
74
- scopes: ScopeConfig;
75
- agentId: string;
76
- }) => Promise<{
77
- id: string;
78
- tenantId: string;
79
- projectId: string;
80
- name: string;
81
- description: string;
82
- summaryProps: Record<string, unknown> | null;
83
- fullProps: Record<string, unknown> | null;
84
- createdAt: string;
85
- updatedAt: string;
86
- }[]>;
87
- export declare const associateArtifactComponentWithAgent: (db: DatabaseClient) => (params: {
88
- scopes: ScopeConfig;
89
- agentId: string;
90
- artifactComponentId: string;
91
- }) => Promise<{
92
- tenantId: string;
93
- projectId: string;
94
- id: string;
95
- createdAt: string;
96
- agentId: string;
97
- artifactComponentId: string;
98
- }>;
99
- export declare const removeArtifactComponentFromAgent: (db: DatabaseClient) => (params: {
100
- scopes: ScopeConfig;
101
- agentId: string;
102
- artifactComponentId: string;
103
- }) => Promise<boolean>;
104
- export declare const deleteAgentArtifactComponentRelationByAgent: (db: DatabaseClient) => (params: {
105
- scopes: ScopeConfig;
106
- agentId: string;
107
- }) => Promise<boolean>;
108
- export declare const getAgentsUsingArtifactComponent: (db: DatabaseClient) => (params: {
109
- scopes: ScopeConfig;
110
- artifactComponentId: string;
111
- }) => Promise<{
112
- agentId: string;
113
- createdAt: string;
114
- }[]>;
115
- export declare const isArtifactComponentAssociatedWithAgent: (db: DatabaseClient) => (params: {
116
- scopes: ScopeConfig;
117
- agentId: string;
118
- artifactComponentId: string;
119
- }) => Promise<boolean>;
120
- export declare const graphHasArtifactComponents: (db: DatabaseClient) => (params: {
121
- scopes: ScopeConfig;
122
- graphId: string;
123
- }) => Promise<boolean>;
124
- export declare const countArtifactComponents: (db: DatabaseClient) => (params: {
125
- scopes: ScopeConfig;
126
- }) => Promise<number>;
127
- export declare const countArtifactComponentsForAgent: (db: DatabaseClient) => (params: {
128
- scopes: ScopeConfig;
129
- agentId: string;
130
- }) => Promise<number>;
131
- /**
132
- * Upsert agent-artifact component relation (create if it doesn't exist, no-op if it does)
133
- */
134
- export declare const upsertAgentArtifactComponentRelation: (db: DatabaseClient) => (params: {
135
- scopes: ScopeConfig;
136
- agentId: string;
137
- artifactComponentId: string;
138
- }) => Promise<{
139
- tenantId: string;
140
- projectId: string;
141
- id: string;
142
- createdAt: string;
143
- agentId: string;
144
- artifactComponentId: string;
145
- } | null>;
146
- /**
147
- * Upsert an artifact component (create if it doesn't exist, update if it does)
148
- */
149
- export declare const upsertArtifactComponent: (db: DatabaseClient) => (params: {
150
- data: ArtifactComponentInsert;
151
- }) => Promise<ArtifactComponentSelect>;
152
- //# sourceMappingURL=artifactComponents.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"artifactComponents.d.ts","sourceRoot":"","sources":["../../src/data-access/artifactComponents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEtE,eAAO,MAAM,wBAAwB,GAClC,IAAI,cAAc,MAAY,QAAQ;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,EAAE,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;cAQzE,CAAC;AAEJ,eAAO,MAAM,sBAAsB,GAChC,IAAI,cAAc,MAAY,QAAQ;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE;;;;;;;;;;IAW7D,CAAC;AAEJ,eAAO,MAAM,+BAA+B,GACzC,IAAI,cAAc,MACZ,QAAQ;IACb,MAAM,EAAE,WAAW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jF,CAAC"}
@@ -1,214 +0,0 @@
1
- import { and, count, desc, eq } from 'drizzle-orm';
2
- import { nanoid } from 'nanoid';
3
- import { agentArtifactComponents, agentRelations, agents, artifactComponents } from '../db/schema';
4
- export const getArtifactComponentById = (db) => async (params) => {
5
- return await db.query.artifactComponents.findFirst({
6
- where: and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId), eq(artifactComponents.id, params.id)),
7
- });
8
- };
9
- export const listArtifactComponents = (db) => async (params) => {
10
- return await db
11
- .select()
12
- .from(artifactComponents)
13
- .where(and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId)))
14
- .orderBy(desc(artifactComponents.createdAt));
15
- };
16
- export const listArtifactComponentsPaginated = (db) => async (params) => {
17
- const page = params.pagination?.page || 1;
18
- const limit = Math.min(params.pagination?.limit || 10, 100);
19
- const offset = (page - 1) * limit;
20
- const whereClause = and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId));
21
- const [data, totalResult] = await Promise.all([
22
- db
23
- .select()
24
- .from(artifactComponents)
25
- .where(whereClause)
26
- .limit(limit)
27
- .offset(offset)
28
- .orderBy(desc(artifactComponents.createdAt)),
29
- db.select({ count: count() }).from(artifactComponents).where(whereClause),
30
- ]);
31
- const total = totalResult[0]?.count || 0;
32
- const totalNumber = typeof total === 'string' ? Number.parseInt(total, 10) : total;
33
- const pages = Math.ceil(totalNumber / limit);
34
- return {
35
- data,
36
- pagination: { page, limit, total: totalNumber, pages },
37
- };
38
- };
39
- export const createArtifactComponent = (db) => async (params) => {
40
- const now = new Date().toISOString();
41
- const [artifactComponent] = await db
42
- .insert(artifactComponents)
43
- .values({
44
- ...params,
45
- createdAt: now,
46
- updatedAt: now,
47
- })
48
- .returning();
49
- return artifactComponent;
50
- };
51
- export const updateArtifactComponent = (db) => async (params) => {
52
- const now = new Date().toISOString();
53
- const [updated] = await db
54
- .update(artifactComponents)
55
- .set({
56
- ...params.data,
57
- updatedAt: now,
58
- })
59
- .where(and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId), eq(artifactComponents.id, params.id)))
60
- .returning();
61
- return updated;
62
- };
63
- export const deleteArtifactComponent = (db) => async (params) => {
64
- try {
65
- const result = await db
66
- .delete(artifactComponents)
67
- .where(and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId), eq(artifactComponents.id, params.id)))
68
- .returning();
69
- return result.length > 0;
70
- }
71
- catch (error) {
72
- console.error('Error deleting artifact component:', error);
73
- return false;
74
- }
75
- };
76
- export const getArtifactComponentsForAgent = (db) => async (params) => {
77
- return await db
78
- .select({
79
- id: artifactComponents.id,
80
- tenantId: artifactComponents.tenantId,
81
- projectId: artifactComponents.projectId,
82
- name: artifactComponents.name,
83
- description: artifactComponents.description,
84
- summaryProps: artifactComponents.summaryProps,
85
- fullProps: artifactComponents.fullProps,
86
- createdAt: artifactComponents.createdAt,
87
- updatedAt: artifactComponents.updatedAt,
88
- })
89
- .from(artifactComponents)
90
- .innerJoin(agentArtifactComponents, eq(artifactComponents.id, agentArtifactComponents.artifactComponentId))
91
- .where(and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId), eq(agentArtifactComponents.agentId, params.agentId)))
92
- .orderBy(desc(artifactComponents.createdAt));
93
- };
94
- export const associateArtifactComponentWithAgent = (db) => async (params) => {
95
- const [association] = await db
96
- .insert(agentArtifactComponents)
97
- .values({
98
- id: nanoid(),
99
- tenantId: params.scopes.tenantId,
100
- projectId: params.scopes.projectId,
101
- agentId: params.agentId,
102
- artifactComponentId: params.artifactComponentId,
103
- createdAt: new Date().toISOString(),
104
- })
105
- .returning();
106
- return association;
107
- };
108
- export const removeArtifactComponentFromAgent = (db) => async (params) => {
109
- try {
110
- const result = await db
111
- .delete(agentArtifactComponents)
112
- .where(and(eq(agentArtifactComponents.tenantId, params.scopes.tenantId), eq(agentArtifactComponents.projectId, params.scopes.projectId), eq(agentArtifactComponents.agentId, params.agentId), eq(agentArtifactComponents.artifactComponentId, params.artifactComponentId)))
113
- .returning();
114
- return result.length > 0;
115
- }
116
- catch (error) {
117
- console.error('Error removing artifact component from agent:', error);
118
- return false;
119
- }
120
- };
121
- export const deleteAgentArtifactComponentRelationByAgent = (db) => async (params) => {
122
- const result = await db
123
- .delete(agentArtifactComponents)
124
- .where(and(eq(agentArtifactComponents.tenantId, params.scopes.tenantId), eq(agentArtifactComponents.agentId, params.agentId)));
125
- return (result.rowsAffected || 0) > 0;
126
- };
127
- export const getAgentsUsingArtifactComponent = (db) => async (params) => {
128
- return await db
129
- .select({
130
- agentId: agentArtifactComponents.agentId,
131
- createdAt: agentArtifactComponents.createdAt,
132
- })
133
- .from(agentArtifactComponents)
134
- .where(and(eq(agentArtifactComponents.tenantId, params.scopes.tenantId), eq(agentArtifactComponents.projectId, params.scopes.projectId), eq(agentArtifactComponents.artifactComponentId, params.artifactComponentId)))
135
- .orderBy(desc(agentArtifactComponents.createdAt));
136
- };
137
- export const isArtifactComponentAssociatedWithAgent = (db) => async (params) => {
138
- const result = await db
139
- .select({ id: agentArtifactComponents.id })
140
- .from(agentArtifactComponents)
141
- .where(and(eq(agentArtifactComponents.tenantId, params.scopes.tenantId), eq(agentArtifactComponents.projectId, params.scopes.projectId), eq(agentArtifactComponents.agentId, params.agentId), eq(agentArtifactComponents.artifactComponentId, params.artifactComponentId)))
142
- .limit(1);
143
- return result.length > 0;
144
- };
145
- export const graphHasArtifactComponents = (db) => async (params) => {
146
- const result = await db
147
- .select({ count: count() })
148
- .from(agentArtifactComponents)
149
- .innerJoin(agents, eq(agentArtifactComponents.agentId, agents.id))
150
- .innerJoin(agentRelations, eq(agents.id, agentRelations.sourceAgentId))
151
- .where(and(eq(agentArtifactComponents.tenantId, params.scopes.tenantId), eq(agentArtifactComponents.projectId, params.scopes.projectId), eq(agentRelations.graphId, params.graphId)))
152
- .limit(1);
153
- const total = result[0]?.count || 0;
154
- const totalNumber = typeof total === 'string' ? Number.parseInt(total, 10) : total;
155
- return totalNumber > 0;
156
- };
157
- export const countArtifactComponents = (db) => async (params) => {
158
- const result = await db
159
- .select({ count: count() })
160
- .from(artifactComponents)
161
- .where(and(eq(artifactComponents.tenantId, params.scopes.tenantId), eq(artifactComponents.projectId, params.scopes.projectId)));
162
- const total = result[0]?.count || 0;
163
- return typeof total === 'string' ? Number.parseInt(total, 10) : total;
164
- };
165
- export const countArtifactComponentsForAgent = (db) => async (params) => {
166
- const result = await db
167
- .select({ count: count() })
168
- .from(agentArtifactComponents)
169
- .where(and(eq(agentArtifactComponents.tenantId, params.scopes.tenantId), eq(agentArtifactComponents.projectId, params.scopes.projectId), eq(agentArtifactComponents.agentId, params.agentId)));
170
- const total = result[0]?.count || 0;
171
- return typeof total === 'string' ? Number.parseInt(total, 10) : total;
172
- };
173
- /**
174
- * Upsert agent-artifact component relation (create if it doesn't exist, no-op if it does)
175
- */
176
- export const upsertAgentArtifactComponentRelation = (db) => async (params) => {
177
- // Check if relation already exists
178
- const exists = await isArtifactComponentAssociatedWithAgent(db)(params);
179
- if (!exists) {
180
- // Create the relation if it doesn't exist
181
- return await associateArtifactComponentWithAgent(db)(params);
182
- }
183
- // If it exists, we could optionally return the existing relation
184
- // For now, just return success indication
185
- return null;
186
- };
187
- /**
188
- * Upsert an artifact component (create if it doesn't exist, update if it does)
189
- */
190
- export const upsertArtifactComponent = (db) => async (params) => {
191
- const scopes = { tenantId: params.data.tenantId, projectId: params.data.projectId };
192
- const existing = await getArtifactComponentById(db)({
193
- scopes,
194
- id: params.data.id,
195
- });
196
- if (existing) {
197
- // Update existing artifact component
198
- return await updateArtifactComponent(db)({
199
- scopes,
200
- id: params.data.id,
201
- data: {
202
- name: params.data.name,
203
- description: params.data.description,
204
- summaryProps: params.data.summaryProps,
205
- fullProps: params.data.fullProps,
206
- },
207
- });
208
- }
209
- else {
210
- // Create new artifact component
211
- return await createArtifactComponent(db)(params.data);
212
- }
213
- };
214
- //# sourceMappingURL=artifactComponents.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"artifactComponents.js","sourceRoot":"","sources":["../../src/data-access/artifactComponents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACnD,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAQnG,MAAM,CAAC,MAAM,wBAAwB,GACnC,CAAC,EAAkB,EAAE,EAAE,CAAC,KAAK,EAAE,MAA2C,EAAE,EAAE;IAC5E,OAAO,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,CAAC,SAAS,CAAC;QACjD,KAAK,EAAE,GAAG,CACR,EAAE,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EACvD,EAAE,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,EACzD,EAAE,CAAC,kBAAkB,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,CAAC,CACrC;KACF,CAAC,CAAC;AACL,CAAC,CAAC;AAEJ,MAAM,CAAC,MAAM,sBAAsB,GACjC,CAAC,EAAkB,EAAE,EAAE,CAAC,KAAK,EAAE,MAA+B,EAAE,EAAE;IAChE,OAAO,MAAM,EAAE;SACZ,MAAM,EAAE;SACR,IAAI,CAAC,kBAAkB,CAAC;SACxB,KAAK,CACJ,GAAG,CACD,EAAE,CAAC,kBAAkB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,EACvD,EAAE,CAAC,kBAAkB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAC1D,CACF;SAC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,CAAC,IAAI,CAAC,CAAC;IACxD,CAAC;AACH,CAAC,CAAC"}
@@ -1,68 +0,0 @@
1
- import type { DatabaseClient } from '../db/client';
2
- import type { ContextCacheInsert, ContextCacheSelect } from '../types/entities';
3
- import type { ScopeConfig } from '../types/utility';
4
- /**
5
- * Get cached context data for a conversation with optional request hash validation
6
- */
7
- export declare const getCacheEntry: (db: DatabaseClient) => (params: {
8
- conversationId: string;
9
- contextConfigId: string;
10
- contextVariableKey: string;
11
- requestHash?: string;
12
- }) => Promise<ContextCacheSelect | null>;
13
- /**
14
- * Set cached context data for a conversation
15
- */
16
- export declare const setCacheEntry: (db: DatabaseClient) => (entry: ContextCacheInsert) => Promise<ContextCacheSelect | null>;
17
- /**
18
- * Clear cache entries for a specific conversation
19
- */
20
- export declare const clearConversationCache: (db: DatabaseClient) => (params: {
21
- scopes: ScopeConfig;
22
- conversationId: string;
23
- }) => Promise<number>;
24
- /**
25
- * Clear all cache entries for a specific context configuration
26
- */
27
- export declare const clearContextConfigCache: (db: DatabaseClient) => (params: {
28
- scopes: ScopeConfig;
29
- contextConfigId: string;
30
- }) => Promise<number>;
31
- /**
32
- * Clean up all cache entries for a tenant
33
- */
34
- export declare const cleanupTenantCache: (db: DatabaseClient) => (params: {
35
- scopes: ScopeConfig;
36
- }) => Promise<number>;
37
- /**
38
- * Invalidate the request context cache for a conversation
39
- */
40
- export declare const invalidateRequestContextCache: (db: DatabaseClient) => (params: {
41
- scopes: ScopeConfig;
42
- conversationId: string;
43
- contextConfigId: string;
44
- }) => Promise<number>;
45
- /**
46
- * Invalidate specific cache entries for invocation-trigger definitions
47
- */
48
- export declare const invalidateInvocationDefinitionsCache: (db: DatabaseClient) => (params: {
49
- scopes: ScopeConfig;
50
- conversationId: string;
51
- contextConfigId: string;
52
- invocationDefinitionIds: string[];
53
- }) => Promise<number>;
54
- /**
55
- * Get all cache entries for a conversation
56
- */
57
- export declare const getConversationCacheEntries: (db: DatabaseClient) => (params: {
58
- scopes: ScopeConfig;
59
- conversationId: string;
60
- }) => Promise<ContextCacheSelect[]>;
61
- /**
62
- * Get all cache entries for a context configuration
63
- */
64
- export declare const getContextConfigCacheEntries: (db: DatabaseClient) => (params: {
65
- scopes: ScopeConfig;
66
- contextConfigId: string;
67
- }) => Promise<ContextCacheSelect[]>;
68
- //# sourceMappingURL=contextCache.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contextCache.d.ts","sourceRoot":"","sources":["../../src/data-access/contextCache.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,aAAa,GACvB,IAAI,cAAc,MACZ,QAAQ;IACb,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,KAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CA+BpC,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,aAAa,GACvB,IAAI,cAAc,MACZ,OAAO,kBAAkB,KAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CA2BnE,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,sBAAsB,GAChC,IAAI,cAAc,MACZ,QAAQ;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,cAAc,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,MAAM,CAY9E,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,uBAAuB,GACjC,IAAI,cAAc,MACZ,QAAQ;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,eAAe,EAAE,MAAM,CAAA;CAAE,KAAG,OAAO,CAAC,MAAM,CAY/E,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,kBAAkB,GAC5B,IAAI,cAAc,MACZ,QAAQ;IAAE,MAAM,EAAE,WAAW,CAAA;CAAE,KAAG,OAAO,CAAC,MAAM,CAWtD,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,6BAA6B,GACvC,IAAI,cAAc,MACZ,QAAQ;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,MAAM,CAcjB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,oCAAoC,GAC9C,IAAI,cAAc,MACZ,QAAQ;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,uBAAuB,EAAE,MAAM,EAAE,CAAC;CACnC,KAAG,OAAO,CAAC,MAAM,CAoBjB,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,2BAA2B,GACrC,IAAI,cAAc,MACZ,QAAQ;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;CACxB,KAAG,OAAO,CAAC,kBAAkB,EAAE,CAa/B,CAAC;AAEJ;;GAEG;AACH,eAAO,MAAM,4BAA4B,GACtC,IAAI,cAAc,MACZ,QAAQ;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;CACzB,KAAG,OAAO,CAAC,kBAAkB,EAAE,CAa/B,CAAC"}
@@ -1,135 +0,0 @@
1
- import { and, eq } from 'drizzle-orm';
2
- import { nanoid } from 'nanoid';
3
- import { contextCache } from '../db/schema';
4
- /**
5
- * Get cached context data for a conversation with optional request hash validation
6
- */
7
- export const getCacheEntry = (db) => async (params) => {
8
- try {
9
- const cacheEntry = await db.query.contextCache.findFirst({
10
- where: and(eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, params.contextVariableKey)),
11
- });
12
- if (!cacheEntry) {
13
- return null;
14
- }
15
- // Check if request hash matches (for cache invalidation based on request changes)
16
- if (params.requestHash &&
17
- cacheEntry.requestHash &&
18
- cacheEntry.requestHash !== params.requestHash) {
19
- return null; // Cache entry request hash mismatch, treating as miss
20
- }
21
- return {
22
- ...cacheEntry,
23
- value: cacheEntry.value,
24
- };
25
- }
26
- catch {
27
- // Graceful degradation: treat cache errors as cache misses
28
- return null;
29
- }
30
- };
31
- /**
32
- * Set cached context data for a conversation
33
- */
34
- export const setCacheEntry = (db) => async (entry) => {
35
- try {
36
- const cacheData = {
37
- id: nanoid(),
38
- tenantId: entry.tenantId,
39
- projectId: entry.projectId,
40
- conversationId: entry.conversationId,
41
- contextConfigId: entry.contextConfigId,
42
- contextVariableKey: entry.contextVariableKey,
43
- value: entry.value,
44
- requestHash: entry.requestHash || null,
45
- fetchedAt: new Date().toISOString(),
46
- fetchSource: `${entry.contextConfigId}:${entry.contextVariableKey}`,
47
- fetchDurationMs: 0,
48
- createdAt: new Date().toISOString(),
49
- updatedAt: new Date().toISOString(),
50
- };
51
- const [result] = await db.insert(contextCache).values(cacheData).returning();
52
- return {
53
- ...result,
54
- value: result.value,
55
- };
56
- }
57
- catch {
58
- // Don't throw - caching failures shouldn't break context resolution
59
- return null;
60
- }
61
- };
62
- /**
63
- * Clear cache entries for a specific conversation
64
- */
65
- export const clearConversationCache = (db) => async (params) => {
66
- const result = await db
67
- .delete(contextCache)
68
- .where(and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId), eq(contextCache.conversationId, params.conversationId)));
69
- return result.rowsAffected || 0;
70
- };
71
- /**
72
- * Clear all cache entries for a specific context configuration
73
- */
74
- export const clearContextConfigCache = (db) => async (params) => {
75
- const result = await db
76
- .delete(contextCache)
77
- .where(and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId), eq(contextCache.contextConfigId, params.contextConfigId)));
78
- return result.rowsAffected || 0;
79
- };
80
- /**
81
- * Clean up all cache entries for a tenant
82
- */
83
- export const cleanupTenantCache = (db) => async (params) => {
84
- const result = await db
85
- .delete(contextCache)
86
- .where(and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId)));
87
- return result.rowsAffected || 0;
88
- };
89
- /**
90
- * Invalidate the request context cache for a conversation
91
- */
92
- export const invalidateRequestContextCache = (db) => async (params) => {
93
- const result = await db
94
- .delete(contextCache)
95
- .where(and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId), eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, 'requestContext')));
96
- return result.rowsAffected || 0;
97
- };
98
- /**
99
- * Invalidate specific cache entries for invocation-trigger definitions
100
- */
101
- export const invalidateInvocationDefinitionsCache = (db) => async (params) => {
102
- let totalRowsAffected = 0;
103
- for (const definitionId of params.invocationDefinitionIds) {
104
- const result = await db
105
- .delete(contextCache)
106
- .where(and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId), eq(contextCache.conversationId, params.conversationId), eq(contextCache.contextConfigId, params.contextConfigId), eq(contextCache.contextVariableKey, definitionId)));
107
- totalRowsAffected += result.rowsAffected || 0;
108
- }
109
- return totalRowsAffected;
110
- };
111
- /**
112
- * Get all cache entries for a conversation
113
- */
114
- export const getConversationCacheEntries = (db) => async (params) => {
115
- const result = await db.query.contextCache.findMany({
116
- where: and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId), eq(contextCache.conversationId, params.conversationId)),
117
- });
118
- return result.map((entry) => ({
119
- ...entry,
120
- value: entry.value,
121
- }));
122
- };
123
- /**
124
- * Get all cache entries for a context configuration
125
- */
126
- export const getContextConfigCacheEntries = (db) => async (params) => {
127
- const result = await db.query.contextCache.findMany({
128
- where: and(eq(contextCache.tenantId, params.scopes.tenantId), eq(contextCache.projectId, params.scopes.projectId), eq(contextCache.contextConfigId, params.contextConfigId)),
129
- });
130
- return result.map((entry) => ({
131
- ...entry,
132
- value: entry.value,
133
- }));
134
- };
135
- //# sourceMappingURL=contextCache.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"contextCache.js","sourceRoot":"","sources":["../../src/data-access/contextCache.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAI5C;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GACxB,CAAC,EAAkB,EAAE,EAAE,CACvB,KAAK,EAAE,MAKN,EAAsC,EAAE;IACvC,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC;YACvD,KAAK,EAAE,GAAG,CACR,EAAE,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,cAAc,CAAC,EACtD,EAAE,CAAC,YAAY,CAAC,eAAe,EAAE,MAAM,CAAC,eAAe,CAAC,EACxD,EAAE,CAAC,YAAY,CAAC,kBAAkB,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAC/D;SACF,CAAC,CAAC;QAEH,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,kFAAkF;QAClF,IACE,MAAM,CAAC,WAAW;YAClB,UAAU,CAAC,WAAW;YACtB,UAAU,CAAC,WAAW,KAAK,MAAM,CAAC,WAAW,EAC7C,CAAC;YACD,OAAO,IAAI,CAAC,CAAC,sDAAsD;QACrE,CAAC;QAED,OAAO;YACL,GAAG,UAAU;YACb,KAAK,EAAE,UAAU,CAAC,KAAY;SAC/B,CAAC;IACJ,CAAC;IAAC,MAAM,CAAC;QACP,2DAA2D;QAC3D,O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