@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.
- package/README.md +312 -0
- package/bin/kelpi-mcp +3 -0
- package/dist/__tests__/integration-api/fixtures.d.ts +382 -0
- package/dist/__tests__/integration-api/fixtures.d.ts.map +1 -0
- package/dist/__tests__/integration-api/fixtures.js +478 -0
- package/dist/__tests__/integration-api/fixtures.js.map +1 -0
- package/dist/__tests__/integration-api/index.d.ts +19 -0
- package/dist/__tests__/integration-api/index.d.ts.map +1 -0
- package/dist/__tests__/integration-api/index.js +33 -0
- package/dist/__tests__/integration-api/index.js.map +1 -0
- package/dist/__tests__/integration-api/setup.d.ts +176 -0
- package/dist/__tests__/integration-api/setup.d.ts.map +1 -0
- package/dist/__tests__/integration-api/setup.js +329 -0
- package/dist/__tests__/integration-api/setup.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/__tests__/setup.js +11 -0
- package/dist/__tests__/setup.js.map +1 -0
- package/dist/__tests__/unit/test-utils.d.ts +46 -0
- package/dist/__tests__/unit/test-utils.d.ts.map +1 -0
- package/dist/__tests__/unit/test-utils.js +50 -0
- package/dist/__tests__/unit/test-utils.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +34 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api-client.d.ts +17 -0
- package/dist/lib/api-client.d.ts.map +1 -0
- package/dist/lib/api-client.js +169 -0
- package/dist/lib/api-client.js.map +1 -0
- package/dist/lib/auth-state.d.ts +54 -0
- package/dist/lib/auth-state.d.ts.map +1 -0
- package/dist/lib/auth-state.js +131 -0
- package/dist/lib/auth-state.js.map +1 -0
- package/dist/lib/config.d.ts +39 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +170 -0
- package/dist/lib/config.js.map +1 -0
- package/dist/lib/error-formatter.d.ts +40 -0
- package/dist/lib/error-formatter.d.ts.map +1 -0
- package/dist/lib/error-formatter.js +149 -0
- package/dist/lib/error-formatter.js.map +1 -0
- package/dist/lib/errors.d.ts +44 -0
- package/dist/lib/errors.d.ts.map +1 -0
- package/dist/lib/errors.js +56 -0
- package/dist/lib/errors.js.map +1 -0
- package/dist/lib/tool-helpers.d.ts +49 -0
- package/dist/lib/tool-helpers.d.ts.map +1 -0
- package/dist/lib/tool-helpers.js +101 -0
- package/dist/lib/tool-helpers.js.map +1 -0
- package/dist/lib/tool-registry.d.ts +111 -0
- package/dist/lib/tool-registry.d.ts.map +1 -0
- package/dist/lib/tool-registry.js +112 -0
- package/dist/lib/tool-registry.js.map +1 -0
- package/dist/lib/version.d.ts +13 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +13 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/prompts/flow-generator.d.ts +45 -0
- package/dist/prompts/flow-generator.d.ts.map +1 -0
- package/dist/prompts/flow-generator.js +177 -0
- package/dist/prompts/flow-generator.js.map +1 -0
- package/dist/prompts/index.d.ts +7 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +7 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/server.d.ts +66 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +140 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/auth/index.d.ts +18 -0
- package/dist/tools/auth/index.d.ts.map +1 -0
- package/dist/tools/auth/index.js +50 -0
- package/dist/tools/auth/index.js.map +1 -0
- package/dist/tools/auth/login.d.ts +37 -0
- package/dist/tools/auth/login.d.ts.map +1 -0
- package/dist/tools/auth/login.js +257 -0
- package/dist/tools/auth/login.js.map +1 -0
- package/dist/tools/auth/schemas.d.ts +69 -0
- package/dist/tools/auth/schemas.d.ts.map +1 -0
- package/dist/tools/auth/schemas.js +36 -0
- package/dist/tools/auth/schemas.js.map +1 -0
- package/dist/tools/auth/status.d.ts +11 -0
- package/dist/tools/auth/status.d.ts.map +1 -0
- package/dist/tools/auth/status.js +50 -0
- package/dist/tools/auth/status.js.map +1 -0
- package/dist/tools/contacts/create.d.ts +11 -0
- package/dist/tools/contacts/create.d.ts.map +1 -0
- package/dist/tools/contacts/create.js +47 -0
- package/dist/tools/contacts/create.js.map +1 -0
- package/dist/tools/contacts/index.d.ts +10 -0
- package/dist/tools/contacts/index.d.ts.map +1 -0
- package/dist/tools/contacts/index.js +40 -0
- package/dist/tools/contacts/index.js.map +1 -0
- package/dist/tools/contacts/schemas.d.ts +37 -0
- package/dist/tools/contacts/schemas.d.ts.map +1 -0
- package/dist/tools/contacts/schemas.js +15 -0
- package/dist/tools/contacts/schemas.js.map +1 -0
- package/dist/tools/events/index.d.ts +10 -0
- package/dist/tools/events/index.d.ts.map +1 -0
- package/dist/tools/events/index.js +42 -0
- package/dist/tools/events/index.js.map +1 -0
- package/dist/tools/events/schemas.d.ts +37 -0
- package/dist/tools/events/schemas.d.ts.map +1 -0
- package/dist/tools/events/schemas.js +17 -0
- package/dist/tools/events/schemas.js.map +1 -0
- package/dist/tools/events/track.d.ts +11 -0
- package/dist/tools/events/track.d.ts.map +1 -0
- package/dist/tools/events/track.js +41 -0
- package/dist/tools/events/track.js.map +1 -0
- package/dist/tools/flows/activate.d.ts +11 -0
- package/dist/tools/flows/activate.d.ts.map +1 -0
- package/dist/tools/flows/activate.js +46 -0
- package/dist/tools/flows/activate.js.map +1 -0
- package/dist/tools/flows/create.d.ts +11 -0
- package/dist/tools/flows/create.d.ts.map +1 -0
- package/dist/tools/flows/create.js +72 -0
- package/dist/tools/flows/create.js.map +1 -0
- package/dist/tools/flows/index.d.ts +24 -0
- package/dist/tools/flows/index.d.ts.map +1 -0
- package/dist/tools/flows/index.js +183 -0
- package/dist/tools/flows/index.js.map +1 -0
- package/dist/tools/flows/list.d.ts +11 -0
- package/dist/tools/flows/list.d.ts.map +1 -0
- package/dist/tools/flows/list.js +34 -0
- package/dist/tools/flows/list.js.map +1 -0
- package/dist/tools/flows/schemas.d.ts +621 -0
- package/dist/tools/flows/schemas.d.ts.map +1 -0
- package/dist/tools/flows/schemas.js +135 -0
- package/dist/tools/flows/schemas.js.map +1 -0
- package/dist/tools/flows/transform.d.ts +39 -0
- package/dist/tools/flows/transform.d.ts.map +1 -0
- package/dist/tools/flows/transform.js +139 -0
- package/dist/tools/flows/transform.js.map +1 -0
- package/dist/tools/index.d.ts +34 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +46 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/sdk/index.d.ts +18 -0
- package/dist/tools/sdk/index.d.ts.map +1 -0
- package/dist/tools/sdk/index.js +69 -0
- package/dist/tools/sdk/index.js.map +1 -0
- package/dist/tools/sdk/public-key.d.ts +11 -0
- package/dist/tools/sdk/public-key.d.ts.map +1 -0
- package/dist/tools/sdk/public-key.js +24 -0
- package/dist/tools/sdk/public-key.js.map +1 -0
- package/dist/tools/sdk/schemas.d.ts +48 -0
- package/dist/tools/sdk/schemas.d.ts.map +1 -0
- package/dist/tools/sdk/schemas.js +35 -0
- package/dist/tools/sdk/schemas.js.map +1 -0
- package/dist/tools/sdk/snippet.d.ts +11 -0
- package/dist/tools/sdk/snippet.d.ts.map +1 -0
- package/dist/tools/sdk/snippet.js +50 -0
- package/dist/tools/sdk/snippet.js.map +1 -0
- package/dist/tools/sdk/templates/index.d.ts +5 -0
- package/dist/tools/sdk/templates/index.d.ts.map +1 -0
- package/dist/tools/sdk/templates/index.js +5 -0
- package/dist/tools/sdk/templates/index.js.map +1 -0
- package/dist/tools/sdk/templates/nextjs.d.ts +5 -0
- package/dist/tools/sdk/templates/nextjs.d.ts.map +1 -0
- package/dist/tools/sdk/templates/nextjs.js +71 -0
- package/dist/tools/sdk/templates/nextjs.js.map +1 -0
- package/dist/tools/sdk/templates/node.d.ts +9 -0
- package/dist/tools/sdk/templates/node.d.ts.map +1 -0
- package/dist/tools/sdk/templates/node.js +170 -0
- package/dist/tools/sdk/templates/node.js.map +1 -0
- package/dist/tools/sdk/templates/react.d.ts +5 -0
- package/dist/tools/sdk/templates/react.d.ts.map +1 -0
- package/dist/tools/sdk/templates/react.js +54 -0
- package/dist/tools/sdk/templates/react.js.map +1 -0
- package/dist/tools/sdk/templates/vanilla.d.ts +5 -0
- package/dist/tools/sdk/templates/vanilla.d.ts.map +1 -0
- package/dist/tools/sdk/templates/vanilla.js +61 -0
- package/dist/tools/sdk/templates/vanilla.js.map +1 -0
- package/dist/tools/templates/create.d.ts +11 -0
- package/dist/tools/templates/create.d.ts.map +1 -0
- package/dist/tools/templates/create.js +39 -0
- package/dist/tools/templates/create.js.map +1 -0
- package/dist/tools/templates/index.d.ts +17 -0
- package/dist/tools/templates/index.d.ts.map +1 -0
- package/dist/tools/templates/index.js +68 -0
- package/dist/tools/templates/index.js.map +1 -0
- package/dist/tools/templates/list.d.ts +11 -0
- package/dist/tools/templates/list.d.ts.map +1 -0
- package/dist/tools/templates/list.js +31 -0
- package/dist/tools/templates/list.js.map +1 -0
- package/dist/tools/templates/schemas.d.ts +90 -0
- package/dist/tools/templates/schemas.d.ts.map +1 -0
- package/dist/tools/templates/schemas.js +37 -0
- package/dist/tools/templates/schemas.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +76 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Step ID schema - alphanumeric with hyphens/underscores
|
|
4
|
+
* Matches the API schema in src/lib/schemas/flows.ts
|
|
5
|
+
*/
|
|
6
|
+
const stepIdSchema = z
|
|
7
|
+
.string()
|
|
8
|
+
.min(1, 'step_id is required')
|
|
9
|
+
.max(128, 'step_id must not exceed 128 characters')
|
|
10
|
+
.regex(/^[a-zA-Z0-9_-]+$/, 'step_id must contain only alphanumeric characters, hyphens, and underscores');
|
|
11
|
+
/**
|
|
12
|
+
* Schema for a condition filter used in entry_filter and condition steps
|
|
13
|
+
* Matches the typed filter group schema from the API
|
|
14
|
+
*/
|
|
15
|
+
const conditionFilterSchema = z.object({
|
|
16
|
+
type: z.literal('group').optional(), // Optional for simpler entry filters
|
|
17
|
+
logic: z.enum(['AND', 'OR']),
|
|
18
|
+
conditions: z.array(z.unknown()),
|
|
19
|
+
}).passthrough(); // Allow additional properties for nested conditions
|
|
20
|
+
/**
|
|
21
|
+
* Base step schema with required fields
|
|
22
|
+
*/
|
|
23
|
+
const baseStepSchema = z.object({
|
|
24
|
+
step_id: stepIdSchema,
|
|
25
|
+
step_order: z.number().int().min(0, 'step_order must be non-negative'),
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Email step schema
|
|
29
|
+
* Note: Email content is managed via the emails table, not flow_steps.
|
|
30
|
+
* sender_identity_id is optional in draft mode, required at activation.
|
|
31
|
+
*/
|
|
32
|
+
const emailStepSchema = baseStepSchema.extend({
|
|
33
|
+
action_type: z.literal('email'),
|
|
34
|
+
sender_identity_id: z.string().uuid().optional(),
|
|
35
|
+
});
|
|
36
|
+
/**
|
|
37
|
+
* Delay step schema
|
|
38
|
+
* Requires at least delay_seconds or delay_expression
|
|
39
|
+
*/
|
|
40
|
+
const delayStepSchema = baseStepSchema.extend({
|
|
41
|
+
action_type: z.literal('delay'),
|
|
42
|
+
delay_seconds: z.number().int().positive('delay_seconds must be positive').optional(),
|
|
43
|
+
delay_expression: z.string().min(1).optional(),
|
|
44
|
+
});
|
|
45
|
+
/**
|
|
46
|
+
* Webhook step schema
|
|
47
|
+
* webhook_url is optional for draft mode, required at activation
|
|
48
|
+
*
|
|
49
|
+
* Note: HTTPS validation is done in the handler, not here.
|
|
50
|
+
* Using .refine() would create ZodEffects which breaks JSON Schema conversion.
|
|
51
|
+
*/
|
|
52
|
+
const webhookStepSchema = baseStepSchema.extend({
|
|
53
|
+
action_type: z.literal('webhook'),
|
|
54
|
+
webhook_url: z.string().url('Invalid URL format').optional(),
|
|
55
|
+
webhook_payload_template: z.record(z.string(), z.any()).optional(),
|
|
56
|
+
});
|
|
57
|
+
/**
|
|
58
|
+
* Condition step schema
|
|
59
|
+
* Acts as a gate: if condition passes, continue; if fails, exit flow
|
|
60
|
+
*/
|
|
61
|
+
const conditionStepSchema = baseStepSchema.extend({
|
|
62
|
+
action_type: z.literal('condition'),
|
|
63
|
+
condition_filter: conditionFilterSchema.optional(),
|
|
64
|
+
if_true_next_step: z.string().min(1).optional(),
|
|
65
|
+
if_false_next_step: z.string().min(1).optional(),
|
|
66
|
+
});
|
|
67
|
+
/**
|
|
68
|
+
* Union of all step types - discriminated by action_type
|
|
69
|
+
* Matches the API schema in src/lib/schemas/flows.ts
|
|
70
|
+
*/
|
|
71
|
+
const flowStepSchema = z.discriminatedUnion('action_type', [
|
|
72
|
+
emailStepSchema,
|
|
73
|
+
delayStepSchema,
|
|
74
|
+
webhookStepSchema,
|
|
75
|
+
conditionStepSchema,
|
|
76
|
+
]);
|
|
77
|
+
/**
|
|
78
|
+
* Schema for the flow definition used in create flow
|
|
79
|
+
* Matches the API createFlowSchema in src/lib/schemas/flows.ts
|
|
80
|
+
*
|
|
81
|
+
* Key differences from previous MCP schema:
|
|
82
|
+
* - step_id is REQUIRED (not optional)
|
|
83
|
+
* - No template_id field (email content managed separately)
|
|
84
|
+
* - Only 'event' and 'segment' trigger types (no 'manual')
|
|
85
|
+
* - Added webhook_url, webhook_payload_template for webhook steps
|
|
86
|
+
* - Added condition_filter fields for condition steps
|
|
87
|
+
*
|
|
88
|
+
* Note: We don't use .refine() here because it produces ZodEffects which
|
|
89
|
+
* doesn't convert to valid JSON Schema for MCP tool definitions.
|
|
90
|
+
* Custom validations (trigger requirements, duplicate step_ids) are done in the handler.
|
|
91
|
+
*/
|
|
92
|
+
export const flowDefinitionSchema = z.object({
|
|
93
|
+
name: z.string().min(1, 'Flow name is required').max(255),
|
|
94
|
+
slug: z
|
|
95
|
+
.string()
|
|
96
|
+
.min(1)
|
|
97
|
+
.max(128)
|
|
98
|
+
.regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, 'Slug must be lowercase kebab-case')
|
|
99
|
+
.optional(),
|
|
100
|
+
description: z.string().max(2000).optional(),
|
|
101
|
+
trigger_type: z.enum(['event', 'segment']),
|
|
102
|
+
trigger_event: z.string().min(1).optional(),
|
|
103
|
+
trigger_segment_id: z.string().uuid().optional(),
|
|
104
|
+
entry_filter: conditionFilterSchema.optional(),
|
|
105
|
+
steps: z.array(flowStepSchema).default([]),
|
|
106
|
+
});
|
|
107
|
+
/**
|
|
108
|
+
* Schema for kelpi_create_flow input
|
|
109
|
+
*/
|
|
110
|
+
export const createFlowInputSchema = z.object({
|
|
111
|
+
definition: flowDefinitionSchema,
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Schema for kelpi_list_flows input
|
|
115
|
+
* Matches the API listFlowsQuerySchema in src/lib/schemas/flows.ts
|
|
116
|
+
*/
|
|
117
|
+
export const listFlowsInputSchema = z.object({
|
|
118
|
+
status: z.enum(['draft', 'active', 'paused', 'archived']).optional(),
|
|
119
|
+
trigger_type: z.enum(['event', 'segment']).optional(),
|
|
120
|
+
limit: z.number().min(1).max(250).optional(),
|
|
121
|
+
offset: z.number().min(0).optional(),
|
|
122
|
+
order_by: z.enum(['created_at', 'updated_at', 'name', 'status']).optional(),
|
|
123
|
+
order_direction: z.enum(['asc', 'desc']).optional(),
|
|
124
|
+
});
|
|
125
|
+
/**
|
|
126
|
+
* UUID regex pattern for validation
|
|
127
|
+
*/
|
|
128
|
+
const UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
129
|
+
/**
|
|
130
|
+
* Schema for kelpi_activate_flow input
|
|
131
|
+
*/
|
|
132
|
+
export const activateFlowInputSchema = z.object({
|
|
133
|
+
flow_id: z.string().regex(UUID_REGEX, 'flow_id must be a valid UUID'),
|
|
134
|
+
});
|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,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE;IAC5C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACpC,QAAQ,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3E,eAAe,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,QAAQ,EAAE;CACpD,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,GAAG,iEAAiE,CAAC;AAErF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,KAAK,CAAC,UAAU,EAAE,8BAA8B,CAAC;CACtE,CAAC,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform utilities for normalizing flow definitions.
|
|
3
|
+
*
|
|
4
|
+
* This module handles the "impedance mismatch" between common operator shorthand
|
|
5
|
+
* (eq, gt, gte) used by AI assistants and the full operator names expected by
|
|
6
|
+
* the Kelpi API (equals, greater_than, greater_than_or_equals).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes an operator to the backend-expected format.
|
|
10
|
+
* Case-insensitive matching. Returns the input unchanged if not a known alias.
|
|
11
|
+
*
|
|
12
|
+
* @param operator - The operator to normalize
|
|
13
|
+
* @returns The canonical operator name, or the input unchanged if unknown
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeOperator(operator: unknown): unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Recursively transforms a filter condition or group.
|
|
18
|
+
* - Normalizes operator names to canonical form
|
|
19
|
+
* - Ensures filter groups have type: "group" for condition steps (when requireGroupType is true)
|
|
20
|
+
* - Preserves unknown properties for forward compatibility
|
|
21
|
+
*
|
|
22
|
+
* @param condition - The condition or filter group to transform
|
|
23
|
+
* @param requireGroupType - Whether to add type: "group" to filter groups
|
|
24
|
+
* @returns The transformed condition
|
|
25
|
+
*/
|
|
26
|
+
export declare function transformFilterCondition(condition: unknown, requireGroupType?: boolean): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Transforms a flow definition to normalize operators and filter structures.
|
|
29
|
+
* Should be called before sending the definition to the API.
|
|
30
|
+
*
|
|
31
|
+
* Handles:
|
|
32
|
+
* - entry_filter: Uses filterGroupSchema (no type: "group" required)
|
|
33
|
+
* - condition_filter in condition steps: Uses typedFilterGroupSchema (type: "group" required)
|
|
34
|
+
*
|
|
35
|
+
* @param definition - The flow definition to transform
|
|
36
|
+
* @returns The transformed flow definition
|
|
37
|
+
*/
|
|
38
|
+
export declare function transformFlowDefinition<T extends Record<string, unknown>>(definition: T): T;
|
|
39
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../../src/tools/flows/transform.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAsDH;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAK5D;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,OAAO,EAClB,gBAAgB,GAAE,OAAe,GAChC,OAAO,CA8BT;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,uBAAuB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACvE,UAAU,EAAE,CAAC,GACZ,CAAC,CA0BH"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform utilities for normalizing flow definitions.
|
|
3
|
+
*
|
|
4
|
+
* This module handles the "impedance mismatch" between common operator shorthand
|
|
5
|
+
* (eq, gt, gte) used by AI assistants and the full operator names expected by
|
|
6
|
+
* the Kelpi API (equals, greater_than, greater_than_or_equals).
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Map of common operator aliases to canonical operator names.
|
|
10
|
+
* Includes both shorthand forms and already-valid operators for pass-through.
|
|
11
|
+
*/
|
|
12
|
+
const OPERATOR_ALIASES = {
|
|
13
|
+
// Equality shortcuts
|
|
14
|
+
eq: 'equals',
|
|
15
|
+
'=': 'equals',
|
|
16
|
+
'==': 'equals',
|
|
17
|
+
neq: 'not_equals',
|
|
18
|
+
ne: 'not_equals',
|
|
19
|
+
'!=': 'not_equals',
|
|
20
|
+
'<>': 'not_equals',
|
|
21
|
+
// Comparison shortcuts
|
|
22
|
+
gt: 'greater_than',
|
|
23
|
+
'>': 'greater_than',
|
|
24
|
+
lt: 'less_than',
|
|
25
|
+
'<': 'less_than',
|
|
26
|
+
gte: 'greater_than_or_equals',
|
|
27
|
+
'>=': 'greater_than_or_equals',
|
|
28
|
+
lte: 'less_than_or_equals',
|
|
29
|
+
'<=': 'less_than_or_equals',
|
|
30
|
+
// Existence shortcuts
|
|
31
|
+
set: 'is_set',
|
|
32
|
+
exists: 'is_set',
|
|
33
|
+
not_set: 'is_not_set',
|
|
34
|
+
unset: 'is_not_set',
|
|
35
|
+
not_exists: 'is_not_set',
|
|
36
|
+
// Valid operators (pass through unchanged)
|
|
37
|
+
equals: 'equals',
|
|
38
|
+
not_equals: 'not_equals',
|
|
39
|
+
contains: 'contains',
|
|
40
|
+
not_contains: 'not_contains',
|
|
41
|
+
starts_with: 'starts_with',
|
|
42
|
+
ends_with: 'ends_with',
|
|
43
|
+
greater_than: 'greater_than',
|
|
44
|
+
less_than: 'less_than',
|
|
45
|
+
greater_than_or_equals: 'greater_than_or_equals',
|
|
46
|
+
less_than_or_equals: 'less_than_or_equals',
|
|
47
|
+
is_set: 'is_set',
|
|
48
|
+
is_not_set: 'is_not_set',
|
|
49
|
+
in: 'in',
|
|
50
|
+
not_in: 'not_in',
|
|
51
|
+
// Event condition operators (for typed conditions)
|
|
52
|
+
has_done: 'has_done',
|
|
53
|
+
has_not_done: 'has_not_done',
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Normalizes an operator to the backend-expected format.
|
|
57
|
+
* Case-insensitive matching. Returns the input unchanged if not a known alias.
|
|
58
|
+
*
|
|
59
|
+
* @param operator - The operator to normalize
|
|
60
|
+
* @returns The canonical operator name, or the input unchanged if unknown
|
|
61
|
+
*/
|
|
62
|
+
export function normalizeOperator(operator) {
|
|
63
|
+
if (typeof operator !== 'string') {
|
|
64
|
+
return operator;
|
|
65
|
+
}
|
|
66
|
+
return OPERATOR_ALIASES[operator.toLowerCase()] ?? operator;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Recursively transforms a filter condition or group.
|
|
70
|
+
* - Normalizes operator names to canonical form
|
|
71
|
+
* - Ensures filter groups have type: "group" for condition steps (when requireGroupType is true)
|
|
72
|
+
* - Preserves unknown properties for forward compatibility
|
|
73
|
+
*
|
|
74
|
+
* @param condition - The condition or filter group to transform
|
|
75
|
+
* @param requireGroupType - Whether to add type: "group" to filter groups
|
|
76
|
+
* @returns The transformed condition
|
|
77
|
+
*/
|
|
78
|
+
export function transformFilterCondition(condition, requireGroupType = false) {
|
|
79
|
+
if (!condition || typeof condition !== 'object') {
|
|
80
|
+
return condition;
|
|
81
|
+
}
|
|
82
|
+
const obj = condition;
|
|
83
|
+
// Check if this is a filter group (has logic and conditions properties)
|
|
84
|
+
if ('logic' in obj && 'conditions' in obj) {
|
|
85
|
+
const transformedConditions = Array.isArray(obj.conditions)
|
|
86
|
+
? obj.conditions.map((c) => transformFilterCondition(c, requireGroupType))
|
|
87
|
+
: obj.conditions;
|
|
88
|
+
return {
|
|
89
|
+
...obj,
|
|
90
|
+
// Add type: "group" if required and not already present
|
|
91
|
+
...(requireGroupType && !obj.type ? { type: 'group' } : {}),
|
|
92
|
+
conditions: transformedConditions,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// Check if this is a condition with an operator
|
|
96
|
+
if ('operator' in obj) {
|
|
97
|
+
return {
|
|
98
|
+
...obj,
|
|
99
|
+
operator: normalizeOperator(obj.operator),
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
return condition;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Transforms a flow definition to normalize operators and filter structures.
|
|
106
|
+
* Should be called before sending the definition to the API.
|
|
107
|
+
*
|
|
108
|
+
* Handles:
|
|
109
|
+
* - entry_filter: Uses filterGroupSchema (no type: "group" required)
|
|
110
|
+
* - condition_filter in condition steps: Uses typedFilterGroupSchema (type: "group" required)
|
|
111
|
+
*
|
|
112
|
+
* @param definition - The flow definition to transform
|
|
113
|
+
* @returns The transformed flow definition
|
|
114
|
+
*/
|
|
115
|
+
export function transformFlowDefinition(definition) {
|
|
116
|
+
const result = { ...definition };
|
|
117
|
+
// Transform entry_filter (uses filterGroupSchema - no type: "group" required)
|
|
118
|
+
if (result['entry_filter']) {
|
|
119
|
+
result['entry_filter'] = transformFilterCondition(result['entry_filter'], false);
|
|
120
|
+
}
|
|
121
|
+
// Transform steps with condition_filter (uses typedFilterGroupSchema - type: "group" required)
|
|
122
|
+
if (Array.isArray(result['steps'])) {
|
|
123
|
+
result['steps'] = result['steps'].map((step) => {
|
|
124
|
+
if (!step || typeof step !== 'object') {
|
|
125
|
+
return step;
|
|
126
|
+
}
|
|
127
|
+
const stepObj = step;
|
|
128
|
+
if (stepObj.action_type === 'condition' && stepObj.condition_filter) {
|
|
129
|
+
return {
|
|
130
|
+
...stepObj,
|
|
131
|
+
condition_filter: transformFilterCondition(stepObj.condition_filter, true),
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
return step;
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return result;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=transform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../../src/tools/flows/transform.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,gBAAgB,GAA2B;IAC/C,qBAAqB;IACrB,EAAE,EAAE,QAAQ;IACZ,GAAG,EAAE,QAAQ;IACb,IAAI,EAAE,QAAQ;IACd,GAAG,EAAE,YAAY;IACjB,EAAE,EAAE,YAAY;IAChB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,YAAY;IAElB,uBAAuB;IACvB,EAAE,EAAE,cAAc;IAClB,GAAG,EAAE,cAAc;IACnB,EAAE,EAAE,WAAW;IACf,GAAG,EAAE,WAAW;IAChB,GAAG,EAAE,wBAAwB;IAC7B,IAAI,EAAE,wBAAwB;IAC9B,GAAG,EAAE,qBAAqB;IAC1B,IAAI,EAAE,qBAAqB;IAE3B,sBAAsB;IACtB,GAAG,EAAE,QAAQ;IACb,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,YAAY;IACnB,UAAU,EAAE,YAAY;IAExB,2CAA2C;IAC3C,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;IAC5B,WAAW,EAAE,aAAa;IAC1B,SAAS,EAAE,WAAW;IACtB,YAAY,EAAE,cAAc;IAC5B,SAAS,EAAE,WAAW;IACtB,sBAAsB,EAAE,wBAAwB;IAChD,mBAAmB,EAAE,qBAAqB;IAC1C,MAAM,EAAE,QAAQ;IAChB,UAAU,EAAE,YAAY;IACxB,EAAE,EAAE,IAAI;IACR,MAAM,EAAE,QAAQ;IAEhB,mDAAmD;IACnD,QAAQ,EAAE,UAAU;IACpB,YAAY,EAAE,cAAc;CAC7B,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAi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,MAAM,GAA4B,EAAE,GAAG,UAAU,EAAE,CAAC;IAE1D,8EAA8E;IAC9E,IAAI,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC;QAC3B,MAAM,CAAC,cAAc,CAAC,GAAG,wBAAwB,CAAC,MAAM,CAAC,cAAc,CAAC,EAAE,KAAK,CAAC,CAAC;IACnF,CAAC;IAED,+FAA+F;IAC/F,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC;QACnC,MAAM,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAa,EAAE,EAAE;YACtD,IAAI,CAAC,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACtC,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,OAAO,GAAG,IAA+B,CAAC;YAChD,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;gBACpE,OAAO;oBACL,GAAG,OAAO;oBACV,gBAAgB,EAAE,wBAAwB,CAAC,OAAO,CAAC,gBAAgB,EAAE,IAAI,CAAC;iBAC3E,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC;QACd,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAW,CAAC;AACrB,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ToolWithHandler } from '../lib/tool-registry.js';
|
|
2
|
+
import { kelpiLogin, kelpiStatus } from './auth/index.js';
|
|
3
|
+
import { kelpiCreateFlow, kelpiListFlows, kelpiActivateFlow } from './flows/index.js';
|
|
4
|
+
import { kelpiCreateTemplate, kelpiListTemplates } from './templates/index.js';
|
|
5
|
+
import { kelpiCreateContact } from './contacts/index.js';
|
|
6
|
+
import { kelpiTrackEvent } from './events/index.js';
|
|
7
|
+
import { kelpiGetSdkSnippet, kelpiGetPublicKey } from './sdk/index.js';
|
|
8
|
+
export type { ToolWithHandler } from '../lib/tool-registry.js';
|
|
9
|
+
/**
|
|
10
|
+
* All tool definitions with their handlers
|
|
11
|
+
*/
|
|
12
|
+
export declare const ALL_TOOLS: ToolWithHandler[];
|
|
13
|
+
/**
|
|
14
|
+
* Tool definitions only (for listing in MCP protocol)
|
|
15
|
+
*/
|
|
16
|
+
export declare const TOOL_DEFINITIONS: import("../lib/tool-registry.js").ToolDefinition[];
|
|
17
|
+
/**
|
|
18
|
+
* Tool names constant for reference
|
|
19
|
+
*/
|
|
20
|
+
export declare const TOOL_NAMES: {
|
|
21
|
+
readonly LOGIN: "kelpi_login";
|
|
22
|
+
readonly STATUS: "kelpi_status";
|
|
23
|
+
readonly CREATE_FLOW: "kelpi_create_flow";
|
|
24
|
+
readonly LIST_FLOWS: "kelpi_list_flows";
|
|
25
|
+
readonly ACTIVATE_FLOW: "kelpi_activate_flow";
|
|
26
|
+
readonly CREATE_TEMPLATE: "kelpi_create_template";
|
|
27
|
+
readonly LIST_TEMPLATES: "kelpi_list_templates";
|
|
28
|
+
readonly CREATE_CONTACT: "kelpi_create_contact";
|
|
29
|
+
readonly TRACK_EVENT: "kelpi_track_event";
|
|
30
|
+
readonly GET_SDK_SNIPPET: "kelpi_get_sdk_snippet";
|
|
31
|
+
readonly GET_PUBLIC_KEY: "kelpi_get_public_key";
|
|
32
|
+
};
|
|
33
|
+
export { kelpiLogin, kelpiStatus, kelpiCreateFlow, kelpiListFlows, kelpiActivateFlow, kelpiCreateTemplate, kelpiListTemplates, kelpiCreateContact, kelpiTrackEvent, kelpiGetSdkSnippet, kelpiGetPublicKey, };
|
|
34
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAG/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGvE,YAAY,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,SAAS,EAAE,eAAe,EAYtC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,oDAA2C,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,UAAU;;;;;;;;;;;;CAYb,CAAC;AAGX,OAAO,EACL,UAAU,EACV,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,eAAe,EACf,kBAAkB,EAClB,iBAAiB,GAClB,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Import tool implementations
|
|
2
|
+
import { kelpiLogin, kelpiStatus } from './auth/index.js';
|
|
3
|
+
import { kelpiCreateFlow, kelpiListFlows, kelpiActivateFlow } from './flows/index.js';
|
|
4
|
+
import { kelpiCreateTemplate, kelpiListTemplates } from './templates/index.js';
|
|
5
|
+
import { kelpiCreateContact } from './contacts/index.js';
|
|
6
|
+
import { kelpiTrackEvent } from './events/index.js';
|
|
7
|
+
import { kelpiGetSdkSnippet, kelpiGetPublicKey } from './sdk/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* All tool definitions with their handlers
|
|
10
|
+
*/
|
|
11
|
+
export const ALL_TOOLS = [
|
|
12
|
+
kelpiLogin,
|
|
13
|
+
kelpiStatus,
|
|
14
|
+
kelpiCreateFlow,
|
|
15
|
+
kelpiListFlows,
|
|
16
|
+
kelpiActivateFlow,
|
|
17
|
+
kelpiCreateTemplate,
|
|
18
|
+
kelpiListTemplates,
|
|
19
|
+
kelpiCreateContact,
|
|
20
|
+
kelpiTrackEvent,
|
|
21
|
+
kelpiGetSdkSnippet,
|
|
22
|
+
kelpiGetPublicKey,
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Tool definitions only (for listing in MCP protocol)
|
|
26
|
+
*/
|
|
27
|
+
export const TOOL_DEFINITIONS = ALL_TOOLS.map((tool) => tool.definition);
|
|
28
|
+
/**
|
|
29
|
+
* Tool names constant for reference
|
|
30
|
+
*/
|
|
31
|
+
export const TOOL_NAMES = {
|
|
32
|
+
LOGIN: 'kelpi_login',
|
|
33
|
+
STATUS: 'kelpi_status',
|
|
34
|
+
CREATE_FLOW: 'kelpi_create_flow',
|
|
35
|
+
LIST_FLOWS: 'kelpi_list_flows',
|
|
36
|
+
ACTIVATE_FLOW: 'kelpi_activate_flow',
|
|
37
|
+
CREATE_TEMPLATE: 'kelpi_create_template',
|
|
38
|
+
LIST_TEMPLATES: 'kelpi_list_templates',
|
|
39
|
+
CREATE_CONTACT: 'kelpi_create_contact',
|
|
40
|
+
TRACK_EVENT: 'kelpi_track_event',
|
|
41
|
+
GET_SDK_SNIPPET: 'kelpi_get_sdk_snippet',
|
|
42
|
+
GET_PUBLIC_KEY: 'kelpi_get_public_key',
|
|
43
|
+
};
|
|
44
|
+
// Re-export tool implementations for direct access
|
|
45
|
+
export { kelpiLogin, kelpiStatus, kelpiCreateFlow, kelpiListFlows, kelpiActivateFlow, kelpiCreateTemplate, kelpiListTemplates, kelpiCreateContact, kelpiTrackEvent, kelpiGetSdkSnippet, kelpiGetPublicKey, };
|
|
46
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],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ACf,kBAAkB,EAClB,iBAAiB,GAClB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ToolWithHandler } from '../../lib/tool-registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* kelpi_get_sdk_snippet tool definition and handler
|
|
4
|
+
*
|
|
5
|
+
* Generates SDK initialization code for different platforms.
|
|
6
|
+
*/
|
|
7
|
+
export declare const kelpiGetSdkSnippet: ToolWithHandler;
|
|
8
|
+
/**
|
|
9
|
+
* kelpi_get_public_key tool definition and handler
|
|
10
|
+
*
|
|
11
|
+
* Gets the public API key for the current workspace.
|
|
12
|
+
*/
|
|
13
|
+
export declare const kelpiGetPublicKey: ToolWithHandler;
|
|
14
|
+
export * from './schemas.js';
|
|
15
|
+
export { createGetSdkSnippetHandler } from './snippet.js';
|
|
16
|
+
export { createGetPublicKeyHandler } from './public-key.js';
|
|
17
|
+
export * from './templates/index.js';
|
|
18
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tools/sdk/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAKlE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,EAAE,eA4BhC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,EAAE,eAkB/B,CAAC;AAGF,cAAc,cAAc,CAAC;AAG7B,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAG5D,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { getSdkSnippetInputSchema, getPublicKeyInputSchema } from './schemas.js';
|
|
2
|
+
import { getSdkSnippetHandler } from './snippet.js';
|
|
3
|
+
import { getPublicKeyHandler } from './public-key.js';
|
|
4
|
+
/**
|
|
5
|
+
* kelpi_get_sdk_snippet tool definition and handler
|
|
6
|
+
*
|
|
7
|
+
* Generates SDK initialization code for different platforms.
|
|
8
|
+
*/
|
|
9
|
+
export const kelpiGetSdkSnippet = {
|
|
10
|
+
definition: {
|
|
11
|
+
name: 'kelpi_get_sdk_snippet',
|
|
12
|
+
description: `Generate SDK initialization code snippet for different platforms.
|
|
13
|
+
|
|
14
|
+
This tool generates ready-to-use code for integrating the Kelpi SDK into your application.
|
|
15
|
+
|
|
16
|
+
Supported frameworks:
|
|
17
|
+
- react: React application with hooks
|
|
18
|
+
- nextjs: Next.js App Router with client components
|
|
19
|
+
- vanilla: Vanilla JavaScript (browser)
|
|
20
|
+
- node: Node.js server-side
|
|
21
|
+
- express: Express.js middleware example
|
|
22
|
+
|
|
23
|
+
The snippet includes:
|
|
24
|
+
- Installation instructions
|
|
25
|
+
- SDK initialization
|
|
26
|
+
- User identification example
|
|
27
|
+
- Event tracking example
|
|
28
|
+
- Your workspace's public API key
|
|
29
|
+
|
|
30
|
+
Example usage:
|
|
31
|
+
{
|
|
32
|
+
"framework": "react"
|
|
33
|
+
}`,
|
|
34
|
+
inputSchema: getSdkSnippetInputSchema,
|
|
35
|
+
},
|
|
36
|
+
handler: getSdkSnippetHandler,
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* kelpi_get_public_key tool definition and handler
|
|
40
|
+
*
|
|
41
|
+
* Gets the public API key for the current workspace.
|
|
42
|
+
*/
|
|
43
|
+
export const kelpiGetPublicKey = {
|
|
44
|
+
definition: {
|
|
45
|
+
name: 'kelpi_get_public_key',
|
|
46
|
+
description: `Get the public API key for SDK initialization.
|
|
47
|
+
|
|
48
|
+
This tool retrieves your workspace's public API key (klp_pk_*) for use in client-side SDK initialization.
|
|
49
|
+
|
|
50
|
+
If no public key exists, one will be created automatically.
|
|
51
|
+
|
|
52
|
+
The public key is safe to use in client-side code as it only allows:
|
|
53
|
+
- User identification
|
|
54
|
+
- Event tracking
|
|
55
|
+
- Reading public configuration
|
|
56
|
+
|
|
57
|
+
It cannot access sensitive data or perform administrative actions.`,
|
|
58
|
+
inputSchema: getPublicKeyInputSchema,
|
|
59
|
+
},
|
|
60
|
+
handler: getPublicKeyHandler,
|
|
61
|
+
};
|
|
62
|
+
// Re-export schemas
|
|
63
|
+
export * from './schemas.js';
|
|
64
|
+
// Re-export handler factories for testing
|
|
65
|
+
export { createGetSdkSnippetHandler } from './snippet.js';
|
|
66
|
+
export { createGetPublicKeyHandler } from './public-key.js';
|
|
67
|
+
// Re-export templates
|
|
68
|
+
export * from './templates/index.js';
|
|
69
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tools/sdk/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACjF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAoB;IACjD,UAAU,EAAE;QACV,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EAAE;;;;;;;;;;;;;;;;;;;;;EAqBf;QACE,WAAW,EAAE,wBAAwB;KACtC;IACD,OAAO,EAAE,oBAAoB;CAC9B,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAChD,UAAU,EAAE;QACV,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE;;;;;;;;;;;mEAWkD;QAC/D,WAAW,EAAE,uBAAuB;KACrC;IACD,OAAO,EAAE,mBAAmB;CAC7B,CAAC;AAEF,oBAAoB;AACpB,cAAc,cAAc,CAAC;AAE7B,0CAA0C;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAE5D,sBAAsB;AACtB,cAAc,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ToolHandler } from '../../lib/tool-registry.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a get public key handler.
|
|
4
|
+
* This factory function allows for dependency injection in tests.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createGetPublicKeyHandler(): ToolHandler;
|
|
7
|
+
/**
|
|
8
|
+
* Default get public key handler
|
|
9
|
+
*/
|
|
10
|
+
export declare const getPublicKeyHandler: ToolHandler;
|
|
11
|
+
//# sourceMappingURL=public-key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-key.d.ts","sourceRoot":"","sources":["../../../src/tools/sdk/public-key.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,4BAA4B,CAAC;AAI1E;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,WAAW,CAWvD;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,aAA8B,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { withAuth, successResponse, handleApiError } from '../../lib/tool-helpers.js';
|
|
2
|
+
import { getOrCreatePublicKey } from './schemas.js';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a get public key handler.
|
|
5
|
+
* This factory function allows for dependency injection in tests.
|
|
6
|
+
*/
|
|
7
|
+
export function createGetPublicKeyHandler() {
|
|
8
|
+
return async () => {
|
|
9
|
+
return withAuth('getting the public key', async ({ client }) => {
|
|
10
|
+
try {
|
|
11
|
+
const keyData = await getOrCreatePublicKey(client);
|
|
12
|
+
return successResponse(keyData);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return handleApiError(err, 'get public key');
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Default get public key handler
|
|
22
|
+
*/
|
|
23
|
+
export const getPublicKeyHandler = createGetPublicKeyHandler();
|
|
24
|
+
//# sourceMappingURL=public-key.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"public-key.js","sourceRoot":"","sources":["../../../src/tools/sdk/public-key.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AACtF,OAAO,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAEpD;;;GAGG;AACH,MAAM,UAAU,yBAAyB;IACvC,OAAO,KAAK,IAAyB,EAAE;QACrC,OAAO,QAAQ,CAAC,wBAAwB,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;YAC7D,IAAI,CAAC;gBACH,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC,MAAM,CAAC,CAAC;gBACnD,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;YAClC,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,cAAc,CAAC,GAAG,EAAE,gBAAgB,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,yBAAyB,EAAE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../../lib/api-client.js';
|
|
3
|
+
/**
|
|
4
|
+
* Supported frameworks for SDK snippets
|
|
5
|
+
*/
|
|
6
|
+
export declare const SUPPORTED_FRAMEWORKS: readonly ["react", "nextjs", "vanilla", "node", "express"];
|
|
7
|
+
/**
|
|
8
|
+
* Schema for getting SDK snippet
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSdkSnippetInputSchema: z.ZodObject<{
|
|
11
|
+
framework: z.ZodEnum<["react", "nextjs", "vanilla", "node", "express"]>;
|
|
12
|
+
}, "strip", z.ZodTypeAny, {
|
|
13
|
+
framework: "react" | "nextjs" | "vanilla" | "node" | "express";
|
|
14
|
+
}, {
|
|
15
|
+
framework: "react" | "nextjs" | "vanilla" | "node" | "express";
|
|
16
|
+
}>;
|
|
17
|
+
/**
|
|
18
|
+
* Schema for getting public key (no input required)
|
|
19
|
+
*/
|
|
20
|
+
export declare const getPublicKeyInputSchema: z.ZodObject<{}, "strip", z.ZodTypeAny, {}, {}>;
|
|
21
|
+
/**
|
|
22
|
+
* API Key response from API
|
|
23
|
+
*/
|
|
24
|
+
export interface ApiKeyResponse {
|
|
25
|
+
id: string;
|
|
26
|
+
key: string;
|
|
27
|
+
key_type: 'public' | 'secret';
|
|
28
|
+
name: string;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
created_at: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* API Keys list response from API
|
|
34
|
+
*/
|
|
35
|
+
export interface ApiKeysListResponse {
|
|
36
|
+
data: ApiKeyResponse[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Type exports
|
|
40
|
+
*/
|
|
41
|
+
export type GetSdkSnippetInput = z.infer<typeof getSdkSnippetInputSchema>;
|
|
42
|
+
export type GetPublicKeyInput = z.infer<typeof getPublicKeyInputSchema>;
|
|
43
|
+
export type SupportedFramework = typeof SUPPORTED_FRAMEWORKS[number];
|
|
44
|
+
/**
|
|
45
|
+
* Fetches an active public API key, or creates one if none exists.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getOrCreatePublicKey(client: ApiClient): Promise<ApiKeyResponse>;
|
|
48
|
+
//# sourceMappingURL=schemas.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schemas.d.ts","sourceRoot":"","sources":["../../../src/tools/sdk/schemas.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEzD;;GAEG;AACH,eAAO,MAAM,oBAAoB,4DAA6D,CAAC;AAE/F;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;EAInC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,uBAAuB,gDAAe,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,cAAc,EAAE,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAC1E,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAC;AACxE,MAAM,MAAM,kBAAkB,GAAG,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAC;AAErE;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,SAAS,GAAG,OAAO,CAAC,cAAc,CAAC,CAgBrF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* Supported frameworks for SDK snippets
|
|
4
|
+
*/
|
|
5
|
+
export const SUPPORTED_FRAMEWORKS = ['react', 'nextjs', 'vanilla', 'node', 'express'];
|
|
6
|
+
/**
|
|
7
|
+
* Schema for getting SDK snippet
|
|
8
|
+
*/
|
|
9
|
+
export const getSdkSnippetInputSchema = z.object({
|
|
10
|
+
framework: z.enum(SUPPORTED_FRAMEWORKS, {
|
|
11
|
+
errorMap: () => ({ message: `Invalid framework. Supported frameworks: ${SUPPORTED_FRAMEWORKS.join(', ')}` }),
|
|
12
|
+
}),
|
|
13
|
+
});
|
|
14
|
+
/**
|
|
15
|
+
* Schema for getting public key (no input required)
|
|
16
|
+
*/
|
|
17
|
+
export const getPublicKeyInputSchema = z.object({});
|
|
18
|
+
/**
|
|
19
|
+
* Fetches an active public API key, or creates one if none exists.
|
|
20
|
+
*/
|
|
21
|
+
export async function getOrCreatePublicKey(client) {
|
|
22
|
+
const response = await client.get('/api/v1/api-keys', {
|
|
23
|
+
key_type: 'public',
|
|
24
|
+
});
|
|
25
|
+
const activeKey = response.data.data.find((key) => !key.disabled);
|
|
26
|
+
if (activeKey) {
|
|
27
|
+
return activeKey;
|
|
28
|
+
}
|
|
29
|
+
const createResponse = await client.post('/api/v1/api-keys', {
|
|
30
|
+
name: 'SDK Key',
|
|
31
|
+
key_type: 'public',
|
|
32
|
+
});
|
|
33
|
+
return createResponse.data;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=schemas.js.map
|