@kelpi/mcp 0.1.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.
Files changed (195) hide show
  1. package/README.md +312 -0
  2. package/bin/kelpi-mcp +3 -0
  3. package/dist/__tests__/integration-api/fixtures.d.ts +382 -0
  4. package/dist/__tests__/integration-api/fixtures.d.ts.map +1 -0
  5. package/dist/__tests__/integration-api/fixtures.js +478 -0
  6. package/dist/__tests__/integration-api/fixtures.js.map +1 -0
  7. package/dist/__tests__/integration-api/index.d.ts +19 -0
  8. package/dist/__tests__/integration-api/index.d.ts.map +1 -0
  9. package/dist/__tests__/integration-api/index.js +33 -0
  10. package/dist/__tests__/integration-api/index.js.map +1 -0
  11. package/dist/__tests__/integration-api/setup.d.ts +176 -0
  12. package/dist/__tests__/integration-api/setup.d.ts.map +1 -0
  13. package/dist/__tests__/integration-api/setup.js +329 -0
  14. package/dist/__tests__/integration-api/setup.js.map +1 -0
  15. package/dist/__tests__/setup.d.ts +2 -0
  16. package/dist/__tests__/setup.d.ts.map +1 -0
  17. package/dist/__tests__/setup.js +11 -0
  18. package/dist/__tests__/setup.js.map +1 -0
  19. package/dist/__tests__/unit/test-utils.d.ts +46 -0
  20. package/dist/__tests__/unit/test-utils.d.ts.map +1 -0
  21. package/dist/__tests__/unit/test-utils.js +50 -0
  22. package/dist/__tests__/unit/test-utils.js.map +1 -0
  23. package/dist/index.d.ts +6 -0
  24. package/dist/index.d.ts.map +1 -0
  25. package/dist/index.js +34 -0
  26. package/dist/index.js.map +1 -0
  27. package/dist/lib/api-client.d.ts +17 -0
  28. package/dist/lib/api-client.d.ts.map +1 -0
  29. package/dist/lib/api-client.js +169 -0
  30. package/dist/lib/api-client.js.map +1 -0
  31. package/dist/lib/auth-state.d.ts +54 -0
  32. package/dist/lib/auth-state.d.ts.map +1 -0
  33. package/dist/lib/auth-state.js +131 -0
  34. package/dist/lib/auth-state.js.map +1 -0
  35. package/dist/lib/config.d.ts +39 -0
  36. package/dist/lib/config.d.ts.map +1 -0
  37. package/dist/lib/config.js +170 -0
  38. package/dist/lib/config.js.map +1 -0
  39. package/dist/lib/error-formatter.d.ts +40 -0
  40. package/dist/lib/error-formatter.d.ts.map +1 -0
  41. package/dist/lib/error-formatter.js +149 -0
  42. package/dist/lib/error-formatter.js.map +1 -0
  43. package/dist/lib/errors.d.ts +44 -0
  44. package/dist/lib/errors.d.ts.map +1 -0
  45. package/dist/lib/errors.js +56 -0
  46. package/dist/lib/errors.js.map +1 -0
  47. package/dist/lib/tool-helpers.d.ts +49 -0
  48. package/dist/lib/tool-helpers.d.ts.map +1 -0
  49. package/dist/lib/tool-helpers.js +101 -0
  50. package/dist/lib/tool-helpers.js.map +1 -0
  51. package/dist/lib/tool-registry.d.ts +111 -0
  52. package/dist/lib/tool-registry.d.ts.map +1 -0
  53. package/dist/lib/tool-registry.js +112 -0
  54. package/dist/lib/tool-registry.js.map +1 -0
  55. package/dist/lib/version.d.ts +13 -0
  56. package/dist/lib/version.d.ts.map +1 -0
  57. package/dist/lib/version.js +13 -0
  58. package/dist/lib/version.js.map +1 -0
  59. package/dist/prompts/flow-generator.d.ts +45 -0
  60. package/dist/prompts/flow-generator.d.ts.map +1 -0
  61. package/dist/prompts/flow-generator.js +177 -0
  62. package/dist/prompts/flow-generator.js.map +1 -0
  63. package/dist/prompts/index.d.ts +7 -0
  64. package/dist/prompts/index.d.ts.map +1 -0
  65. package/dist/prompts/index.js +7 -0
  66. package/dist/prompts/index.js.map +1 -0
  67. package/dist/server.d.ts +66 -0
  68. package/dist/server.d.ts.map +1 -0
  69. package/dist/server.js +140 -0
  70. package/dist/server.js.map +1 -0
  71. package/dist/tools/auth/index.d.ts +18 -0
  72. package/dist/tools/auth/index.d.ts.map +1 -0
  73. package/dist/tools/auth/index.js +50 -0
  74. package/dist/tools/auth/index.js.map +1 -0
  75. package/dist/tools/auth/login.d.ts +37 -0
  76. package/dist/tools/auth/login.d.ts.map +1 -0
  77. package/dist/tools/auth/login.js +257 -0
  78. package/dist/tools/auth/login.js.map +1 -0
  79. package/dist/tools/auth/schemas.d.ts +69 -0
  80. package/dist/tools/auth/schemas.d.ts.map +1 -0
  81. package/dist/tools/auth/schemas.js +36 -0
  82. package/dist/tools/auth/schemas.js.map +1 -0
  83. package/dist/tools/auth/status.d.ts +11 -0
  84. package/dist/tools/auth/status.d.ts.map +1 -0
  85. package/dist/tools/auth/status.js +50 -0
  86. package/dist/tools/auth/status.js.map +1 -0
  87. package/dist/tools/contacts/create.d.ts +11 -0
  88. package/dist/tools/contacts/create.d.ts.map +1 -0
  89. package/dist/tools/contacts/create.js +47 -0
  90. package/dist/tools/contacts/create.js.map +1 -0
  91. package/dist/tools/contacts/index.d.ts +10 -0
  92. package/dist/tools/contacts/index.d.ts.map +1 -0
  93. package/dist/tools/contacts/index.js +40 -0
  94. package/dist/tools/contacts/index.js.map +1 -0
  95. package/dist/tools/contacts/schemas.d.ts +37 -0
  96. package/dist/tools/contacts/schemas.d.ts.map +1 -0
  97. package/dist/tools/contacts/schemas.js +15 -0
  98. package/dist/tools/contacts/schemas.js.map +1 -0
  99. package/dist/tools/events/index.d.ts +10 -0
  100. package/dist/tools/events/index.d.ts.map +1 -0
  101. package/dist/tools/events/index.js +42 -0
  102. package/dist/tools/events/index.js.map +1 -0
  103. package/dist/tools/events/schemas.d.ts +37 -0
  104. package/dist/tools/events/schemas.d.ts.map +1 -0
  105. package/dist/tools/events/schemas.js +17 -0
  106. package/dist/tools/events/schemas.js.map +1 -0
  107. package/dist/tools/events/track.d.ts +11 -0
  108. package/dist/tools/events/track.d.ts.map +1 -0
  109. package/dist/tools/events/track.js +41 -0
  110. package/dist/tools/events/track.js.map +1 -0
  111. package/dist/tools/flows/activate.d.ts +11 -0
  112. package/dist/tools/flows/activate.d.ts.map +1 -0
  113. package/dist/tools/flows/activate.js +46 -0
  114. package/dist/tools/flows/activate.js.map +1 -0
  115. package/dist/tools/flows/create.d.ts +11 -0
  116. package/dist/tools/flows/create.d.ts.map +1 -0
  117. package/dist/tools/flows/create.js +72 -0
  118. package/dist/tools/flows/create.js.map +1 -0
  119. package/dist/tools/flows/index.d.ts +24 -0
  120. package/dist/tools/flows/index.d.ts.map +1 -0
  121. package/dist/tools/flows/index.js +183 -0
  122. package/dist/tools/flows/index.js.map +1 -0
  123. package/dist/tools/flows/list.d.ts +11 -0
  124. package/dist/tools/flows/list.d.ts.map +1 -0
  125. package/dist/tools/flows/list.js +34 -0
  126. package/dist/tools/flows/list.js.map +1 -0
  127. package/dist/tools/flows/schemas.d.ts +621 -0
  128. package/dist/tools/flows/schemas.d.ts.map +1 -0
  129. package/dist/tools/flows/schemas.js +135 -0
  130. package/dist/tools/flows/schemas.js.map +1 -0
  131. package/dist/tools/flows/transform.d.ts +39 -0
  132. package/dist/tools/flows/transform.d.ts.map +1 -0
  133. package/dist/tools/flows/transform.js +139 -0
  134. package/dist/tools/flows/transform.js.map +1 -0
  135. package/dist/tools/index.d.ts +34 -0
  136. package/dist/tools/index.d.ts.map +1 -0
  137. package/dist/tools/index.js +46 -0
  138. package/dist/tools/index.js.map +1 -0
  139. package/dist/tools/sdk/index.d.ts +18 -0
  140. package/dist/tools/sdk/index.d.ts.map +1 -0
  141. package/dist/tools/sdk/index.js +69 -0
  142. package/dist/tools/sdk/index.js.map +1 -0
  143. package/dist/tools/sdk/public-key.d.ts +11 -0
  144. package/dist/tools/sdk/public-key.d.ts.map +1 -0
  145. package/dist/tools/sdk/public-key.js +24 -0
  146. package/dist/tools/sdk/public-key.js.map +1 -0
  147. package/dist/tools/sdk/schemas.d.ts +48 -0
  148. package/dist/tools/sdk/schemas.d.ts.map +1 -0
  149. package/dist/tools/sdk/schemas.js +35 -0
  150. package/dist/tools/sdk/schemas.js.map +1 -0
  151. package/dist/tools/sdk/snippet.d.ts +11 -0
  152. package/dist/tools/sdk/snippet.d.ts.map +1 -0
  153. package/dist/tools/sdk/snippet.js +50 -0
  154. package/dist/tools/sdk/snippet.js.map +1 -0
  155. package/dist/tools/sdk/templates/index.d.ts +5 -0
  156. package/dist/tools/sdk/templates/index.d.ts.map +1 -0
  157. package/dist/tools/sdk/templates/index.js +5 -0
  158. package/dist/tools/sdk/templates/index.js.map +1 -0
  159. package/dist/tools/sdk/templates/nextjs.d.ts +5 -0
  160. package/dist/tools/sdk/templates/nextjs.d.ts.map +1 -0
  161. package/dist/tools/sdk/templates/nextjs.js +71 -0
  162. package/dist/tools/sdk/templates/nextjs.js.map +1 -0
  163. package/dist/tools/sdk/templates/node.d.ts +9 -0
  164. package/dist/tools/sdk/templates/node.d.ts.map +1 -0
  165. package/dist/tools/sdk/templates/node.js +170 -0
  166. package/dist/tools/sdk/templates/node.js.map +1 -0
  167. package/dist/tools/sdk/templates/react.d.ts +5 -0
  168. package/dist/tools/sdk/templates/react.d.ts.map +1 -0
  169. package/dist/tools/sdk/templates/react.js +54 -0
  170. package/dist/tools/sdk/templates/react.js.map +1 -0
  171. package/dist/tools/sdk/templates/vanilla.d.ts +5 -0
  172. package/dist/tools/sdk/templates/vanilla.d.ts.map +1 -0
  173. package/dist/tools/sdk/templates/vanilla.js +61 -0
  174. package/dist/tools/sdk/templates/vanilla.js.map +1 -0
  175. package/dist/tools/templates/create.d.ts +11 -0
  176. package/dist/tools/templates/create.d.ts.map +1 -0
  177. package/dist/tools/templates/create.js +39 -0
  178. package/dist/tools/templates/create.js.map +1 -0
  179. package/dist/tools/templates/index.d.ts +17 -0
  180. package/dist/tools/templates/index.d.ts.map +1 -0
  181. package/dist/tools/templates/index.js +68 -0
  182. package/dist/tools/templates/index.js.map +1 -0
  183. package/dist/tools/templates/list.d.ts +11 -0
  184. package/dist/tools/templates/list.d.ts.map +1 -0
  185. package/dist/tools/templates/list.js +31 -0
  186. package/dist/tools/templates/list.js.map +1 -0
  187. package/dist/tools/templates/schemas.d.ts +90 -0
  188. package/dist/tools/templates/schemas.d.ts.map +1 -0
  189. package/dist/tools/templates/schemas.js +37 -0
  190. package/dist/tools/templates/schemas.js.map +1 -0
  191. package/dist/types.d.ts +55 -0
  192. package/dist/types.d.ts.map +1 -0
  193. package/dist/types.js +2 -0
  194. package/dist/types.js.map +1 -0
  195. package/package.json +76 -0
@@ -0,0 +1,478 @@
1
+ /**
2
+ * Test data factories for MCP integration tests.
3
+ *
4
+ * Provides utilities for creating test contacts, templates, flows, and events.
5
+ * All factories use unique IDs (Date.now() or crypto.randomUUID()) for test isolation.
6
+ */
7
+ import { getTestSupabase } from './setup.js';
8
+ // =============================================================================
9
+ // Unique ID generators
10
+ // =============================================================================
11
+ /**
12
+ * Generate a unique ID with optional prefix.
13
+ * Uses timestamp + random suffix for uniqueness across test runs.
14
+ */
15
+ export function uniqueId(prefix = '') {
16
+ const timestamp = Date.now();
17
+ const random = Math.random().toString(36).substring(2, 8);
18
+ return prefix ? `${prefix}-${timestamp}-${random}` : `${timestamp}-${random}`;
19
+ }
20
+ /**
21
+ * Generate a unique slug-safe ID.
22
+ * Lowercase, hyphen-separated for use in template slugs etc.
23
+ */
24
+ export function uniqueSlug(prefix = 'test') {
25
+ const timestamp = Date.now();
26
+ const random = Math.random().toString(36).substring(2, 6);
27
+ return `${prefix}-${timestamp}-${random}`;
28
+ }
29
+ /**
30
+ * Generate a unique email address.
31
+ */
32
+ export function uniqueEmail(prefix = 'test') {
33
+ return `${prefix}-${uniqueId()}@test.kelpi.local`;
34
+ }
35
+ /**
36
+ * Create a test contact directly in the database.
37
+ * Use this for setting up test preconditions.
38
+ *
39
+ * @param workspaceId - Workspace to create contact in
40
+ * @param options - Contact properties
41
+ * @returns Created contact
42
+ */
43
+ export async function createTestContact(workspaceId, options = {}) {
44
+ const supabase = getTestSupabase();
45
+ const contactData = {
46
+ workspace_id: workspaceId,
47
+ email: options.email ?? uniqueEmail(),
48
+ external_id: options.external_id ?? uniqueId('ext'),
49
+ properties: options.properties ?? {},
50
+ email_status: 'active',
51
+ };
52
+ const { data, error } = await supabase.from('contacts').insert(contactData).select('*').single();
53
+ if (error) {
54
+ throw new Error(`Failed to create test contact: ${error.message}`);
55
+ }
56
+ return data;
57
+ }
58
+ /**
59
+ * Build contact input for API requests.
60
+ * Does not create the contact, just returns the request body.
61
+ *
62
+ * @param options - Contact options
63
+ * @returns API request body
64
+ */
65
+ export function buildContactInput(options = {}) {
66
+ return {
67
+ email: options.email ?? uniqueEmail(),
68
+ external_id: options.external_id ?? uniqueId('ext'),
69
+ properties: options.properties,
70
+ };
71
+ }
72
+ /**
73
+ * Get a contact by ID from the database.
74
+ *
75
+ * @param workspaceId - Workspace ID
76
+ * @param contactId - Contact ID
77
+ * @returns Contact or null
78
+ */
79
+ export async function getContactById(workspaceId, contactId) {
80
+ const supabase = getTestSupabase();
81
+ const { data, error } = await supabase
82
+ .from('contacts')
83
+ .select('*')
84
+ .eq('workspace_id', workspaceId)
85
+ .eq('id', contactId)
86
+ .single();
87
+ if (error && error.code !== 'PGRST116') {
88
+ throw new Error(`Failed to get contact: ${error.message}`);
89
+ }
90
+ return data;
91
+ }
92
+ /**
93
+ * Get all contacts in a workspace.
94
+ *
95
+ * @param workspaceId - Workspace ID
96
+ * @returns Array of contacts
97
+ */
98
+ export async function getContactsInWorkspace(workspaceId) {
99
+ const supabase = getTestSupabase();
100
+ const { data, error } = await supabase
101
+ .from('contacts')
102
+ .select('*')
103
+ .eq('workspace_id', workspaceId)
104
+ .order('created_at', { ascending: false });
105
+ if (error) {
106
+ throw new Error(`Failed to get contacts: ${error.message}`);
107
+ }
108
+ return (data ?? []);
109
+ }
110
+ /**
111
+ * Create a test template directly in the database.
112
+ * Use this for setting up test preconditions.
113
+ *
114
+ * @param workspaceId - Workspace to create template in
115
+ * @param options - Template properties
116
+ * @returns Created template
117
+ */
118
+ export async function createTestTemplate(workspaceId, options = {}) {
119
+ const supabase = getTestSupabase();
120
+ const slug = options.slug ?? uniqueSlug('template');
121
+ const templateData = {
122
+ workspace_id: workspaceId,
123
+ slug,
124
+ name: options.name ?? `Test Template ${slug}`,
125
+ subject: options.subject ?? 'Test Subject {{first_name}}',
126
+ body_html: options.body_html ?? '<h1>Hello {{first_name}}</h1><p>This is a test email.</p>',
127
+ body_text: options.body_text ?? 'Hello {{first_name}}, This is a test email.',
128
+ variables: options.variables ?? [
129
+ { name: 'first_name', default: 'there' },
130
+ ],
131
+ };
132
+ const { data, error } = await supabase.from('email_templates').insert(templateData).select('*').single();
133
+ if (error) {
134
+ throw new Error(`Failed to create test template: ${error.message}`);
135
+ }
136
+ return data;
137
+ }
138
+ /**
139
+ * Build template input for API requests.
140
+ * Does not create the template, just returns the request body.
141
+ *
142
+ * @param options - Template options
143
+ * @returns API request body
144
+ */
145
+ export function buildTemplateInput(options = {}) {
146
+ const slug = options.slug ?? uniqueSlug('template');
147
+ return {
148
+ slug,
149
+ name: options.name ?? `Test Template ${slug}`,
150
+ subject: options.subject ?? 'Test Subject {{first_name}}',
151
+ body_html: options.body_html ?? '<h1>Hello {{first_name}}</h1><p>This is a test email.</p>',
152
+ variables: options.variables,
153
+ };
154
+ }
155
+ /**
156
+ * Get a template by ID from the database.
157
+ *
158
+ * @param workspaceId - Workspace ID
159
+ * @param templateId - Template ID
160
+ * @returns Template or null
161
+ */
162
+ export async function getTemplateById(workspaceId, templateId) {
163
+ const supabase = getTestSupabase();
164
+ const { data, error } = await supabase
165
+ .from('email_templates')
166
+ .select('*')
167
+ .eq('workspace_id', workspaceId)
168
+ .eq('id', templateId)
169
+ .single();
170
+ if (error && error.code !== 'PGRST116') {
171
+ throw new Error(`Failed to get template: ${error.message}`);
172
+ }
173
+ return data;
174
+ }
175
+ /**
176
+ * Get a template by slug from the database.
177
+ *
178
+ * @param workspaceId - Workspace ID
179
+ * @param slug - Template slug
180
+ * @returns Template or null
181
+ */
182
+ export async function getTemplateBySlug(workspaceId, slug) {
183
+ const supabase = getTestSupabase();
184
+ const { data, error } = await supabase
185
+ .from('email_templates')
186
+ .select('*')
187
+ .eq('workspace_id', workspaceId)
188
+ .eq('slug', slug)
189
+ .single();
190
+ if (error && error.code !== 'PGRST116') {
191
+ throw new Error(`Failed to get template: ${error.message}`);
192
+ }
193
+ return data;
194
+ }
195
+ /**
196
+ * Get all templates in a workspace.
197
+ *
198
+ * @param workspaceId - Workspace ID
199
+ * @returns Array of templates
200
+ */
201
+ export async function getTemplatesInWorkspace(workspaceId) {
202
+ const supabase = getTestSupabase();
203
+ const { data, error } = await supabase
204
+ .from('email_templates')
205
+ .select('*')
206
+ .eq('workspace_id', workspaceId)
207
+ .order('created_at', { ascending: false });
208
+ if (error) {
209
+ throw new Error(`Failed to get templates: ${error.message}`);
210
+ }
211
+ return (data ?? []);
212
+ }
213
+ /**
214
+ * Create a test flow directly in the database.
215
+ * Use this for setting up test preconditions.
216
+ *
217
+ * @param workspaceId - Workspace to create flow in
218
+ * @param options - Flow properties
219
+ * @returns Created flow
220
+ */
221
+ export async function createTestFlow(workspaceId, options = {}) {
222
+ const supabase = getTestSupabase();
223
+ const name = options.name ?? `Test Flow ${Date.now()}`;
224
+ const slug = name.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '');
225
+ const flowData = {
226
+ workspace_id: workspaceId,
227
+ name,
228
+ slug,
229
+ trigger_type: options.trigger_type ?? 'event',
230
+ trigger_event: options.trigger_event ?? 'user.signed_up',
231
+ entry_filter: options.entry_filter,
232
+ status: options.status ?? 'draft',
233
+ };
234
+ const { data: flow, error } = await supabase.from('flows').insert(flowData).select('*').single();
235
+ if (error) {
236
+ throw new Error(`Failed to create test flow: ${error.message}`);
237
+ }
238
+ // Create steps if provided
239
+ if (options.steps && options.steps.length > 0) {
240
+ const stepsData = options.steps.map((step) => ({
241
+ flow_id: flow.id,
242
+ ...step,
243
+ }));
244
+ const { error: stepsError } = await supabase.from('flow_steps').insert(stepsData);
245
+ if (stepsError) {
246
+ throw new Error(`Failed to create flow steps: ${stepsError.message}`);
247
+ }
248
+ }
249
+ return flow;
250
+ }
251
+ /**
252
+ * Build flow definition input for API requests.
253
+ * Does not create the flow, just returns the request body.
254
+ *
255
+ * @param options - Flow options
256
+ * @returns API request body for flow definition
257
+ */
258
+ export function buildFlowDefinition(options = {}) {
259
+ const name = options.name ?? `Test Flow ${Date.now()}`;
260
+ const triggerType = options.trigger_type ?? 'event';
261
+ // Generate step_ids for steps if not provided
262
+ const steps = options.steps ?? [
263
+ { step_order: 0, action_type: 'delay', delay_seconds: 3600 },
264
+ ];
265
+ const stepsWithIds = steps.map((step, index) => ({
266
+ step_id: `step-${index}-${Date.now()}`,
267
+ ...step,
268
+ }));
269
+ return {
270
+ name,
271
+ trigger_type: triggerType,
272
+ trigger_event: triggerType === 'event' ? (options.trigger_event ?? 'user.signed_up') : undefined,
273
+ entry_filter: options.entry_filter,
274
+ steps: stepsWithIds,
275
+ };
276
+ }
277
+ /**
278
+ * Get a flow by ID from the database.
279
+ *
280
+ * @param workspaceId - Workspace ID
281
+ * @param flowId - Flow ID
282
+ * @returns Flow or null
283
+ */
284
+ export async function getFlowById(workspaceId, flowId) {
285
+ const supabase = getTestSupabase();
286
+ const { data, error } = await supabase
287
+ .from('flows')
288
+ .select('*')
289
+ .eq('workspace_id', workspaceId)
290
+ .eq('id', flowId)
291
+ .single();
292
+ if (error && error.code !== 'PGRST116') {
293
+ throw new Error(`Failed to get flow: ${error.message}`);
294
+ }
295
+ return data;
296
+ }
297
+ /**
298
+ * Get flow steps for a flow.
299
+ *
300
+ * @param flowId - Flow ID
301
+ * @returns Array of flow steps
302
+ */
303
+ export async function getFlowSteps(flowId) {
304
+ const supabase = getTestSupabase();
305
+ const { data, error } = await supabase
306
+ .from('flow_steps')
307
+ .select('*')
308
+ .eq('flow_id', flowId)
309
+ .order('step_order', { ascending: true });
310
+ if (error) {
311
+ throw new Error(`Failed to get flow steps: ${error.message}`);
312
+ }
313
+ return (data ?? []);
314
+ }
315
+ /**
316
+ * Get all flows in a workspace.
317
+ *
318
+ * @param workspaceId - Workspace ID
319
+ * @param status - Optional status filter
320
+ * @returns Array of flows
321
+ */
322
+ export async function getFlowsInWorkspace(workspaceId, status) {
323
+ const supabase = getTestSupabase();
324
+ let query = supabase
325
+ .from('flows')
326
+ .select('*')
327
+ .eq('workspace_id', workspaceId)
328
+ .order('created_at', { ascending: false });
329
+ if (status) {
330
+ query = query.eq('status', status);
331
+ }
332
+ const { data, error } = await query;
333
+ if (error) {
334
+ throw new Error(`Failed to get flows: ${error.message}`);
335
+ }
336
+ return (data ?? []);
337
+ }
338
+ /**
339
+ * Create a test event directly in the database.
340
+ * Requires an existing contact.
341
+ *
342
+ * @param workspaceId - Workspace ID
343
+ * @param contactId - Contact ID for the event
344
+ * @param options - Event properties
345
+ * @returns Created event
346
+ */
347
+ export async function createTestEvent(workspaceId, contactId, options = {}) {
348
+ const supabase = getTestSupabase();
349
+ const eventData = {
350
+ workspace_id: workspaceId,
351
+ contact_id: contactId,
352
+ event_type: options.event_type ?? `test.event.${Date.now()}`,
353
+ properties: options.properties ?? {},
354
+ timestamp: options.timestamp ?? new Date().toISOString(),
355
+ };
356
+ const { data, error } = await supabase.from('events').insert(eventData).select('*').single();
357
+ if (error) {
358
+ throw new Error(`Failed to create test event: ${error.message}`);
359
+ }
360
+ return data;
361
+ }
362
+ /**
363
+ * Build event input for API track requests.
364
+ * Does not create the event, just returns the request body.
365
+ *
366
+ * Note: API uses nested format:
367
+ * {
368
+ * contact: { user_id, email? },
369
+ * event: { name, properties? }
370
+ * }
371
+ *
372
+ * @param contactIdentifier - Email or user_id for the contact
373
+ * @param options - Event options
374
+ * @returns API request body
375
+ */
376
+ export function buildEventInput(contactIdentifier, options = {}) {
377
+ return {
378
+ contact: {
379
+ user_id: contactIdentifier.user_id,
380
+ email: contactIdentifier.email,
381
+ },
382
+ event: {
383
+ name: options.event_type ?? `test.event.${Date.now()}`,
384
+ properties: options.properties,
385
+ },
386
+ };
387
+ }
388
+ /**
389
+ * Get events for a contact.
390
+ *
391
+ * @param contactId - Contact ID
392
+ * @returns Array of events
393
+ */
394
+ export async function getEventsForContact(contactId) {
395
+ const supabase = getTestSupabase();
396
+ const { data, error } = await supabase
397
+ .from('events')
398
+ .select('*')
399
+ .eq('contact_id', contactId)
400
+ .order('timestamp', { ascending: false });
401
+ if (error) {
402
+ throw new Error(`Failed to get events: ${error.message}`);
403
+ }
404
+ return (data ?? []);
405
+ }
406
+ /**
407
+ * Get all events in a workspace.
408
+ *
409
+ * @param workspaceId - Workspace ID
410
+ * @returns Array of events
411
+ */
412
+ export async function getEventsInWorkspace(workspaceId) {
413
+ const supabase = getTestSupabase();
414
+ const { data, error } = await supabase
415
+ .from('events')
416
+ .select('*')
417
+ .eq('workspace_id', workspaceId)
418
+ .order('timestamp', { ascending: false });
419
+ if (error) {
420
+ throw new Error(`Failed to get events: ${error.message}`);
421
+ }
422
+ return (data ?? []);
423
+ }
424
+ // =============================================================================
425
+ // Complex test scenarios
426
+ // =============================================================================
427
+ /**
428
+ * Create a complete flow with template for testing email automation.
429
+ *
430
+ * @param workspaceId - Workspace ID
431
+ * @param options - Optional overrides
432
+ * @returns Created flow and template
433
+ */
434
+ export async function createFlowWithTemplate(workspaceId, options = {}) {
435
+ // Create template first
436
+ const template = await createTestTemplate(workspaceId, {
437
+ slug: options.templateSlug,
438
+ name: 'Welcome Email',
439
+ subject: 'Welcome to {{company_name}}!',
440
+ body_html: '<h1>Welcome, {{first_name}}!</h1><p>Thanks for joining {{company_name}}.</p>',
441
+ variables: [
442
+ { name: 'first_name', default: 'there' },
443
+ { name: 'company_name', default: 'Our Service' },
444
+ ],
445
+ });
446
+ // Create flow with email step using template
447
+ const flow = await createTestFlow(workspaceId, {
448
+ name: options.flowName ?? 'Welcome Series',
449
+ trigger_type: 'event',
450
+ trigger_event: options.triggerEvent ?? 'user.signed_up',
451
+ steps: [
452
+ { step_order: 0, action_type: 'email', template_id: template.id },
453
+ { step_order: 1, action_type: 'delay', delay_seconds: 86400 },
454
+ { step_order: 2, action_type: 'email', template_id: template.id },
455
+ ],
456
+ });
457
+ return { flow, template };
458
+ }
459
+ /**
460
+ * Create a contact with events for testing event-based workflows.
461
+ *
462
+ * @param workspaceId - Workspace ID
463
+ * @param eventTypes - Array of event type names to create
464
+ * @returns Created contact and events
465
+ */
466
+ export async function createContactWithEvents(workspaceId, eventTypes = ['page.viewed', 'button.clicked']) {
467
+ const contact = await createTestContact(workspaceId);
468
+ const events = [];
469
+ for (const eventType of eventTypes) {
470
+ const event = await createTestEvent(workspaceId, contact.id, {
471
+ event_type: eventType,
472
+ properties: { source: 'test' },
473
+ });
474
+ events.push(event);
475
+ }
476
+ return { contact, events };
477
+ }
478
+ //# sourceMappingURL=fixtures.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../src/__tests__/integration-api/fixtures.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAE7C,gFAAgF;AAChF,uBAAuB;AACvB,gFAAgF;AAEhF;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,MAAM,GAAG,EAAE;IAClC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,OAAO,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,SAAS,IAAI,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,SAAS,IAAI,MAAM,EAAE,CAAC;AAChF,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,MAAM,GAAG,MAAM;IACxC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1D,OAAO,GAAG,MAAM,IAAI,SAAS,IAAI,MAAM,EAAE,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CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,CAAC,EAAE,EAAE;SAClE;KACF,CAAC,CAAC;IAEH,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC5B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,WAAmB,EACnB,aAAuB,CAAC,aAAa,EAAE,gBAAgB,CAAC;IAExD,MAAM,OAAO,GAAG,MAAM,iBAAiB,CAAC,WAAW,CAAC,CAAC;IAErD,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,MAAM,KAAK,GAAG,MAAM,eAAe,CAAC,WAAW,EAAE,OAAO,CAAC,EAAE,EAAE;YAC3D,UAAU,EAAE,SAAS;YACrB,UAAU,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;SAC/B,CAAC,CAAC;QACH,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACrB,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * MCP Integration API Test Infrastructure
3
+ *
4
+ * Re-exports all setup utilities and fixtures for convenient importing.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import {
9
+ * createTestContext,
10
+ * TestContext,
11
+ * getTestApiUrl,
12
+ * createTestContact,
13
+ * buildFlowDefinition,
14
+ * } from './integration-api/index.js';
15
+ * ```
16
+ */
17
+ export { validateLocalhost, getTestSupabase, getTestApiUrl, createTestWorkspace, cleanupWorkspace, createTestApiKey, createTestContext, apiRequest, parseJsonResponse, waitFor, sleep, getById, countInWorkspace, KeyType, type TestWorkspace, type TestContext, type GeneratedApiKey, } from './setup.js';
18
+ export { uniqueId, uniqueSlug, uniqueEmail, createTestContact, buildContactInput, getContactById, getContactsInWorkspace, type ContactData, type CreateContactOptions, createTestTemplate, buildTemplateInput, getTemplateById, getTemplateBySlug, getTemplatesInWorkspace, type TemplateData, type CreateTemplateOptions, createTestFlow, buildFlowDefinition, getFlowById, getFlowSteps, getFlowsInWorkspace, type FlowData, type FlowStepData, type FlowStatus, type FlowTriggerType, type FlowStepActionType, type CreateFlowOptions, createTestEvent, buildEventInput, getEventsForContact, getEventsInWorkspace, type EventData, type CreateEventOptions, createFlowWithTemplate, createContactWithEvents, } from './fixtures.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/__tests__/integration-api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAGH,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,OAAO,EACP,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,eAAe,GACrB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAEL,QAAQ,EACR,UAAU,EACV,WAAW,EAGX,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB,EACtB,KAAK,WAAW,EAChB,KAAK,oBAAoB,EAGzB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,uBAAuB,EACvB,KAAK,YAAY,EACjB,KAAK,qBAAqB,EAG1B,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,mBAAmB,EACnB,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,KAAK,UAAU,EACf,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EAGtB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,kBAAkB,EAGvB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * MCP Integration API Test Infrastructure
3
+ *
4
+ * Re-exports all setup utilities and fixtures for convenient importing.
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * import {
9
+ * createTestContext,
10
+ * TestContext,
11
+ * getTestApiUrl,
12
+ * createTestContact,
13
+ * buildFlowDefinition,
14
+ * } from './integration-api/index.js';
15
+ * ```
16
+ */
17
+ // Setup utilities
18
+ export { validateLocalhost, getTestSupabase, getTestApiUrl, createTestWorkspace, cleanupWorkspace, createTestApiKey, createTestContext, apiRequest, parseJsonResponse, waitFor, sleep, getById, countInWorkspace, KeyType, } from './setup.js';
19
+ // Fixtures
20
+ export {
21
+ // ID generators
22
+ uniqueId, uniqueSlug, uniqueEmail,
23
+ // Contact fixtures
24
+ createTestContact, buildContactInput, getContactById, getContactsInWorkspace,
25
+ // Template fixtures
26
+ createTestTemplate, buildTemplateInput, getTemplateById, getTemplateBySlug, getTemplatesInWorkspace,
27
+ // Flow fixtures
28
+ createTestFlow, buildFlowDefinition, getFlowById, getFlowSteps, getFlowsInWorkspace,
29
+ // Event fixtures
30
+ createTestEvent, buildEventInput, getEventsForContact, getEventsInWorkspace,
31
+ // Complex scenarios
32
+ createFlowWithTemplate, createContactWithEvents, } from './fixtures.js';
33
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/__tests__/integration-api/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,kBAAkB;AAClB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,iBAAiB,EACjB,OAAO,EACP,KAAK,EACL,OAAO,EACP,gBAAgB,EAChB,OAAO,GAIR,MAAM,YAAY,CAAC;AAEpB,WAAW;AACX,OAAO;AACL,gBAAgB;AAChB,QAAQ,EACR,UAAU,EACV,WAAW;AAEX,mBAAmB;AACnB,iBAAiB,EACjB,iBAAiB,EACjB,cAAc,EACd,sBAAsB;AAItB,oBAAoB;AACpB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,uBAAuB;AAIvB,gBAAgB;AAChB,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,YAAY,EACZ,mBAAmB;AAQnB,iBAAiB;AACjB,eAAe,EACf,eAAe,EACf,mBAAmB,EACnB,oBAAoB;AAIpB,oBAAoB;AACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,eAAe,CAAC"}