callman-mcp 0.1.0 → 0.2.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/CHANGELOG.md +82 -0
- package/README.md +45 -16
- package/dist/client/api.d.ts +64 -3
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +67 -2
- package/dist/client/api.js.map +1 -1
- package/dist/client/errors.d.ts.map +1 -1
- package/dist/client/errors.js +33 -7
- package/dist/client/errors.js.map +1 -1
- package/dist/client/types.d.ts +91 -2
- package/dist/client/types.d.ts.map +1 -1
- package/dist/context.d.ts +2 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +7 -2
- package/dist/context.js.map +1 -1
- package/dist/domain/contracts.d.ts +893 -0
- package/dist/domain/contracts.d.ts.map +1 -0
- package/dist/domain/contracts.js +90 -0
- package/dist/domain/contracts.js.map +1 -0
- package/dist/domain/diagram/build.d.ts +520 -18
- package/dist/domain/diagram/build.d.ts.map +1 -1
- package/dist/domain/diagram/build.js +65 -19
- package/dist/domain/diagram/build.js.map +1 -1
- package/dist/domain/diagram/patch.d.ts +624 -51
- package/dist/domain/diagram/patch.d.ts.map +1 -1
- package/dist/domain/diagram/patch.js +180 -40
- package/dist/domain/diagram/patch.js.map +1 -1
- package/dist/domain/diagram/style.d.ts +315 -0
- package/dist/domain/diagram/style.d.ts.map +1 -0
- package/dist/domain/diagram/style.js +124 -0
- package/dist/domain/diagram/style.js.map +1 -0
- package/dist/domain/diagram/summarize.d.ts +8 -0
- package/dist/domain/diagram/summarize.d.ts.map +1 -1
- package/dist/domain/diagram/summarize.js +28 -13
- package/dist/domain/diagram/summarize.js.map +1 -1
- package/dist/domain/requestIntegrations.d.ts +719 -0
- package/dist/domain/requestIntegrations.d.ts.map +1 -0
- package/dist/domain/requestIntegrations.js +222 -0
- package/dist/domain/requestIntegrations.js.map +1 -0
- package/dist/domain/requestShape.d.ts +1350 -152
- package/dist/domain/requestShape.d.ts.map +1 -1
- package/dist/domain/requestShape.js +336 -121
- package/dist/domain/requestShape.js.map +1 -1
- package/dist/domain/resolve.d.ts +2 -1
- package/dist/domain/resolve.d.ts.map +1 -1
- package/dist/domain/resolve.js +5 -1
- package/dist/domain/resolve.js.map +1 -1
- package/dist/domain/scenario/build.d.ts +82 -26
- package/dist/domain/scenario/build.d.ts.map +1 -1
- package/dist/domain/scenario/build.js +196 -65
- package/dist/domain/scenario/build.js.map +1 -1
- package/dist/domain/scenario/nodeConfig.d.ts +11 -0
- package/dist/domain/scenario/nodeConfig.d.ts.map +1 -0
- package/dist/domain/scenario/nodeConfig.js +251 -0
- package/dist/domain/scenario/nodeConfig.js.map +1 -0
- package/dist/domain/scenario/summarize.d.ts +145 -25
- package/dist/domain/scenario/summarize.d.ts.map +1 -1
- package/dist/domain/scenario/summarize.js +84 -29
- package/dist/domain/scenario/summarize.js.map +1 -1
- package/dist/lib/mask.d.ts +0 -18
- package/dist/lib/mask.d.ts.map +1 -1
- package/dist/lib/mask.js +2 -44
- package/dist/lib/mask.js.map +1 -1
- package/dist/lib/pagination.d.ts +3 -2
- package/dist/lib/pagination.d.ts.map +1 -1
- package/dist/lib/pagination.js +13 -8
- package/dist/lib/pagination.js.map +1 -1
- package/dist/lib/redact.d.ts +12 -0
- package/dist/lib/redact.d.ts.map +1 -0
- package/dist/lib/redact.js +50 -0
- package/dist/lib/redact.js.map +1 -0
- package/dist/lib/strict.d.ts +4 -0
- package/dist/lib/strict.d.ts.map +1 -0
- package/dist/lib/strict.js +14 -0
- package/dist/lib/strict.js.map +1 -0
- package/dist/prompts/index.js +7 -7
- package/dist/prompts/index.js.map +1 -1
- package/dist/resources/docs/contracts.d.ts +2 -0
- package/dist/resources/docs/contracts.d.ts.map +1 -0
- package/dist/resources/docs/contracts.js +74 -0
- package/dist/resources/docs/contracts.js.map +1 -0
- package/dist/resources/docs/diagramSchema.d.ts +1 -1
- package/dist/resources/docs/diagramSchema.d.ts.map +1 -1
- package/dist/resources/docs/diagramSchema.js +95 -28
- package/dist/resources/docs/diagramSchema.js.map +1 -1
- package/dist/resources/docs/overview.d.ts +1 -1
- package/dist/resources/docs/overview.d.ts.map +1 -1
- package/dist/resources/docs/overview.js +29 -7
- package/dist/resources/docs/overview.js.map +1 -1
- package/dist/resources/docs/requestSchema.d.ts +1 -1
- package/dist/resources/docs/requestSchema.d.ts.map +1 -1
- package/dist/resources/docs/requestSchema.js +85 -16
- package/dist/resources/docs/requestSchema.js.map +1 -1
- package/dist/resources/generated/aiPacks.d.ts +1 -1
- package/dist/resources/generated/aiPacks.d.ts.map +1 -1
- package/dist/resources/generated/aiPacks.js +3 -2
- package/dist/resources/generated/aiPacks.js.map +1 -1
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +19 -19
- package/dist/resources/index.js.map +1 -1
- package/dist/run/executeCollection.d.ts +3 -1
- package/dist/run/executeCollection.d.ts.map +1 -1
- package/dist/run/executeCollection.js +16 -4
- package/dist/run/executeCollection.js.map +1 -1
- package/dist/run/summarize.d.ts +17 -6
- package/dist/run/summarize.d.ts.map +1 -1
- package/dist/run/summarize.js +48 -41
- package/dist/run/summarize.js.map +1 -1
- package/dist/run/types.d.ts +1 -0
- package/dist/run/types.d.ts.map +1 -1
- package/dist/server.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/tools/catalog.d.ts +1 -1
- package/dist/tools/catalog.d.ts.map +1 -1
- package/dist/tools/catalog.js +18 -0
- package/dist/tools/catalog.js.map +1 -1
- package/dist/tools/collections.d.ts.map +1 -1
- package/dist/tools/collections.js +53 -41
- package/dist/tools/collections.js.map +1 -1
- package/dist/tools/contracts.d.ts +4 -0
- package/dist/tools/contracts.d.ts.map +1 -0
- package/dist/tools/contracts.js +201 -0
- package/dist/tools/contracts.js.map +1 -0
- package/dist/tools/diagrams.d.ts.map +1 -1
- package/dist/tools/diagrams.js +19 -10
- package/dist/tools/diagrams.js.map +1 -1
- package/dist/tools/environments.d.ts.map +1 -1
- package/dist/tools/environments.js +184 -64
- package/dist/tools/environments.js.map +1 -1
- package/dist/tools/import.d.ts.map +1 -1
- package/dist/tools/import.js +111 -20
- package/dist/tools/import.js.map +1 -1
- package/dist/tools/index.d.ts +2 -1
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +19 -1
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/lookups.d.ts +38 -7
- package/dist/tools/lookups.d.ts.map +1 -1
- package/dist/tools/lookups.js +113 -10
- package/dist/tools/lookups.js.map +1 -1
- package/dist/tools/meta.d.ts.map +1 -1
- package/dist/tools/meta.js +9 -4
- package/dist/tools/meta.js.map +1 -1
- package/dist/tools/requests.d.ts.map +1 -1
- package/dist/tools/requests.js +138 -50
- package/dist/tools/requests.js.map +1 -1
- package/dist/tools/run.d.ts.map +1 -1
- package/dist/tools/run.js +84 -28
- package/dist/tools/run.js.map +1 -1
- package/dist/tools/scenarios.d.ts.map +1 -1
- package/dist/tools/scenarios.js +238 -75
- package/dist/tools/scenarios.js.map +1 -1
- package/dist/tools/shared.d.ts +1 -0
- package/dist/tools/shared.d.ts.map +1 -1
- package/dist/tools/shared.js +9 -1
- package/dist/tools/shared.js.map +1 -1
- package/dist/tools/workspaces.d.ts.map +1 -1
- package/dist/tools/workspaces.js +44 -7
- package/dist/tools/workspaces.js.map +1 -1
- package/dist-cjs/client/api.js +67 -2
- package/dist-cjs/client/errors.js +33 -7
- package/dist-cjs/context.js +7 -2
- package/dist-cjs/domain/contracts.js +93 -0
- package/dist-cjs/domain/diagram/build.js +71 -20
- package/dist-cjs/domain/diagram/patch.js +179 -39
- package/dist-cjs/domain/diagram/style.js +130 -0
- package/dist-cjs/domain/diagram/summarize.js +28 -13
- package/dist-cjs/domain/requestIntegrations.js +228 -0
- package/dist-cjs/domain/requestShape.js +342 -121
- package/dist-cjs/domain/resolve.js +5 -1
- package/dist-cjs/domain/scenario/build.js +197 -65
- package/dist-cjs/domain/scenario/nodeConfig.js +260 -0
- package/dist-cjs/domain/scenario/summarize.js +86 -29
- package/dist-cjs/lib/mask.js +3 -48
- package/dist-cjs/lib/pagination.js +13 -8
- package/dist-cjs/lib/redact.js +53 -0
- package/dist-cjs/lib/strict.js +18 -0
- package/dist-cjs/prompts/index.js +7 -7
- package/dist-cjs/resources/docs/contracts.js +76 -0
- package/dist-cjs/resources/docs/diagramSchema.js +95 -28
- package/dist-cjs/resources/docs/overview.js +29 -7
- package/dist-cjs/resources/docs/requestSchema.js +85 -16
- package/dist-cjs/resources/generated/aiPacks.js +3 -2
- package/dist-cjs/resources/index.js +17 -17
- package/dist-cjs/run/executeCollection.js +16 -4
- package/dist-cjs/run/summarize.js +48 -41
- package/dist-cjs/server.js +1 -1
- package/dist-cjs/tools/catalog.js +18 -0
- package/dist-cjs/tools/collections.js +52 -40
- package/dist-cjs/tools/contracts.js +204 -0
- package/dist-cjs/tools/diagrams.js +19 -10
- package/dist-cjs/tools/environments.js +182 -62
- package/dist-cjs/tools/import.js +107 -16
- package/dist-cjs/tools/index.js +21 -2
- package/dist-cjs/tools/lookups.js +123 -11
- package/dist-cjs/tools/meta.js +9 -4
- package/dist-cjs/tools/requests.js +134 -46
- package/dist-cjs/tools/run.js +82 -26
- package/dist-cjs/tools/scenarios.js +235 -72
- package/dist-cjs/tools/shared.js +11 -2
- package/dist-cjs/tools/workspaces.js +43 -6
- package/package.json +2 -2
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.integrationsInputView = exports.toIntegrationPayload = exports.connectionResolver = exports.hasIntegrations = exports.requestIntegrationFields = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const errors_js_1 = require("../client/errors.js");
|
|
6
|
+
const strict_js_1 = require("../lib/strict.js");
|
|
7
|
+
// A saved request's integration steps — the desktop's Database / Kafka /
|
|
8
|
+
// Redis tabs, DB assertions and the Kafka script. Field names mirror the
|
|
9
|
+
// backend's request schema so what get_request returns can be sent back;
|
|
10
|
+
// ids of list items are generated when omitted, and `connectionId` accepts a
|
|
11
|
+
// connection id OR name (list_connections).
|
|
12
|
+
const connectionRef = zod_1.z.string().trim().min(1).max(200).describe("Connection id or name from list_connections");
|
|
13
|
+
const dbStepSchema = (0, strict_js_1.strictObject)({
|
|
14
|
+
enabled: zod_1.z.boolean().optional().describe("Default true"),
|
|
15
|
+
connectionId: connectionRef,
|
|
16
|
+
query: zod_1.z.string().max(100_000).describe("SQL (or a MongoDB command) run on the connection; {{variables}} are resolved"),
|
|
17
|
+
}, "database step field");
|
|
18
|
+
const databaseSchema = (0, strict_js_1.strictObject)({
|
|
19
|
+
preRequest: dbStepSchema.nullable().optional().describe("Runs before the request; null turns it off"),
|
|
20
|
+
postResponse: dbStepSchema.nullable().optional().describe("Runs after the response; null turns it off"),
|
|
21
|
+
}, "database field").describe("Database steps. On update, a phase you leave out is kept as it is.");
|
|
22
|
+
const COMPARE = ["equals", "not_equals", "exists", "gt", "lt"];
|
|
23
|
+
const kafkaPublishSchema = (0, strict_js_1.strictObject)({
|
|
24
|
+
enabled: zod_1.z.boolean().optional().describe("Default true"),
|
|
25
|
+
connectionId: connectionRef,
|
|
26
|
+
topic: zod_1.z.string().min(1).max(1000),
|
|
27
|
+
valueFormat: zod_1.z.enum(["json", "raw"]).optional().describe("Default json"),
|
|
28
|
+
key: zod_1.z.string().max(4000).optional(),
|
|
29
|
+
value: zod_1.z.string().max(200_000).describe("Message value; {{variables}} are resolved"),
|
|
30
|
+
headers: zod_1.z.array((0, strict_js_1.strictObject)({ id: zod_1.z.string().max(200).optional(), key: zod_1.z.string().max(1000), value: zod_1.z.string().max(10_000).default(""), enabled: zod_1.z.boolean().optional() }, "kafka header field")).max(200).optional(),
|
|
31
|
+
continueOnFailure: zod_1.z.boolean().optional().describe("Default true"),
|
|
32
|
+
}, "kafka publish field");
|
|
33
|
+
const kafkaSchema = (0, strict_js_1.strictObject)({
|
|
34
|
+
enabled: zod_1.z.boolean().optional().describe("Consume: wait for a message on `topic` after the response (default true when a topic is given)"),
|
|
35
|
+
connectionId: connectionRef.optional(),
|
|
36
|
+
topic: zod_1.z.string().max(1000).optional(),
|
|
37
|
+
timeoutMs: zod_1.z.number().int().min(100).max(300_000).optional().describe("How long to wait for the message (default 5000)"),
|
|
38
|
+
matchMode: zod_1.z.enum(["regex", "rules"]).optional().describe("Pick the message by a regex on its value, or by `assertions`"),
|
|
39
|
+
matchPattern: zod_1.z.string().max(2000).optional(),
|
|
40
|
+
assertions: zod_1.z
|
|
41
|
+
.array((0, strict_js_1.strictObject)({
|
|
42
|
+
id: zod_1.z.string().max(200).optional(),
|
|
43
|
+
name: zod_1.z.string().min(1).max(500),
|
|
44
|
+
field: zod_1.z.string().min(1).max(2000).describe("Path in the consumed message, e.g. value.orderId"),
|
|
45
|
+
operator: zod_1.z.enum(COMPARE),
|
|
46
|
+
valueType: zod_1.z.enum(["static", "template"]).optional().describe("template resolves {{variables}} in value"),
|
|
47
|
+
value: zod_1.z.string().max(10_000).optional(),
|
|
48
|
+
}, "kafka assertion field"))
|
|
49
|
+
.max(500)
|
|
50
|
+
.optional(),
|
|
51
|
+
prePublish: kafkaPublishSchema.nullable().optional().describe("Publish a message before the request; null turns it off"),
|
|
52
|
+
postPublish: kafkaPublishSchema.nullable().optional().describe("Publish a message after the response; null turns it off"),
|
|
53
|
+
}, "kafka field").describe("Kafka steps. On update, fields you leave out are kept.");
|
|
54
|
+
const redisSchema = (0, strict_js_1.strictObject)({
|
|
55
|
+
enabled: zod_1.z.boolean().optional().describe("Default true"),
|
|
56
|
+
connectionId: connectionRef,
|
|
57
|
+
preCommands: zod_1.z.array(zod_1.z.string().min(1).max(4000)).max(500).optional().describe('Commands before the request, e.g. "SET user:1 active"'),
|
|
58
|
+
postCommands: zod_1.z.array(zod_1.z.string().min(1).max(4000)).max(500).optional(),
|
|
59
|
+
assertions: zod_1.z
|
|
60
|
+
.array((0, strict_js_1.strictObject)({
|
|
61
|
+
id: zod_1.z.string().max(200).optional(),
|
|
62
|
+
name: zod_1.z.string().min(1).max(500),
|
|
63
|
+
key: zod_1.z.string().min(1).max(2000),
|
|
64
|
+
operator: zod_1.z.enum(["equals", "contains", "exists", "not_exists", "gt"]),
|
|
65
|
+
value: zod_1.z.string().max(10_000).optional(),
|
|
66
|
+
}, "redis assertion field"))
|
|
67
|
+
.max(500)
|
|
68
|
+
.optional(),
|
|
69
|
+
}, "redis field");
|
|
70
|
+
const dbAssertionSchema = (0, strict_js_1.strictObject)({
|
|
71
|
+
id: zod_1.z.string().max(200).optional(),
|
|
72
|
+
name: zod_1.z.string().min(1).max(500),
|
|
73
|
+
source: zod_1.z.enum(["db_pre", "db_post"]).describe("Which database step's result to check"),
|
|
74
|
+
field: zod_1.z.string().min(1).max(2000).describe("Dot path into the step's { success, rowCount, rows, firstRow, error }, e.g. firstRow.status, rowCount, rows.1.id"),
|
|
75
|
+
operator: zod_1.z.enum(COMPARE),
|
|
76
|
+
valueType: zod_1.z.enum(["static", "response"]).optional().describe('static (default): value as written; response: value is a template such as "{{response.id}}" (response body path) or "{{db_pre.firstRow.id}}"'),
|
|
77
|
+
value: zod_1.z.string().max(10_000).optional(),
|
|
78
|
+
}, "db assertion field");
|
|
79
|
+
exports.requestIntegrationFields = {
|
|
80
|
+
database: databaseSchema.optional(),
|
|
81
|
+
kafka: kafkaSchema.nullable().optional().describe("Kafka steps; null turns all of them off"),
|
|
82
|
+
redis: redisSchema.nullable().optional().describe("Redis steps; null turns them off"),
|
|
83
|
+
dbAssertions: zod_1.z.array(dbAssertionSchema).max(500).optional().describe("Checks on the database steps' results (replaces the list)"),
|
|
84
|
+
kafkaScript: zod_1.z.string().max(100_000).optional().describe("Script run with the consumed Kafka message"),
|
|
85
|
+
};
|
|
86
|
+
const hasIntegrations = (input) => input.database !== undefined || input.kafka !== undefined || input.redis !== undefined || input.dbAssertions !== undefined || input.kafkaScript !== undefined;
|
|
87
|
+
exports.hasIntegrations = hasIntegrations;
|
|
88
|
+
let counter = 0;
|
|
89
|
+
const newId = (prefix) => `${prefix}_${Date.now().toString(36)}${(counter++).toString(36)}`;
|
|
90
|
+
// connectionId (id or name) → id, checked against the workspace's
|
|
91
|
+
// connections of the right type.
|
|
92
|
+
const connectionResolver = (connections) => (ref, type, where) => {
|
|
93
|
+
const byId = connections.find((connection) => connection.id === ref);
|
|
94
|
+
const byName = connections.filter((connection) => connection.name.toLowerCase() === ref.toLowerCase());
|
|
95
|
+
const found = byId ?? (byName.length === 1 ? byName[0] : undefined);
|
|
96
|
+
if (!found) {
|
|
97
|
+
const candidates = connections.filter((connection) => connection.type === type).map((connection) => ({ id: connection.id, name: connection.name, provider: connection.provider }));
|
|
98
|
+
throw new errors_js_1.ToolInputError(byName.length > 1 ? "REF_AMBIGUOUS" : "CONNECTION_NOT_FOUND", `${where}: no single ${type} connection "${ref}" in this workspace (list_connections shows them).`, { candidates });
|
|
99
|
+
}
|
|
100
|
+
if (found.type !== type) {
|
|
101
|
+
throw new errors_js_1.ToolInputError("CONNECTION_WRONG_TYPE", `${where}: "${found.name}" is a ${found.type} connection, not ${type}.`);
|
|
102
|
+
}
|
|
103
|
+
return found.id;
|
|
104
|
+
};
|
|
105
|
+
exports.connectionResolver = connectionResolver;
|
|
106
|
+
const DISABLED_DB_STEP = { enabled: false, connectionId: null, query: "" };
|
|
107
|
+
const DISABLED_PUBLISH = { enabled: false, connectionId: null, topic: "", valueFormat: "json", key: "", value: "", headers: [], continueOnFailure: true };
|
|
108
|
+
const asRecord = (value) => (value && typeof value === "object" ? value : {});
|
|
109
|
+
const publishPayload = (input, resolve, where) => ({
|
|
110
|
+
enabled: input.enabled ?? true,
|
|
111
|
+
connectionId: resolve(input.connectionId, "kafka", where),
|
|
112
|
+
topic: input.topic,
|
|
113
|
+
valueFormat: input.valueFormat ?? "json",
|
|
114
|
+
key: input.key ?? "",
|
|
115
|
+
value: input.value,
|
|
116
|
+
headers: (input.headers ?? []).map((header) => ({ id: header.id ?? newId("kh"), key: header.key, value: header.value ?? "", enabled: header.enabled ?? true })),
|
|
117
|
+
continueOnFailure: input.continueOnFailure ?? true,
|
|
118
|
+
});
|
|
119
|
+
// Input → the backend's fields. `current` is the stored request on update:
|
|
120
|
+
// a database phase or kafka field the model left out is kept.
|
|
121
|
+
const toIntegrationPayload = (input, resolve, current) => {
|
|
122
|
+
const out = {};
|
|
123
|
+
if (input.database !== undefined) {
|
|
124
|
+
const stored = asRecord(current?.database);
|
|
125
|
+
const phase = (value, key) => {
|
|
126
|
+
if (value === undefined)
|
|
127
|
+
return stored[key] ?? DISABLED_DB_STEP;
|
|
128
|
+
if (value === null)
|
|
129
|
+
return DISABLED_DB_STEP;
|
|
130
|
+
return { enabled: value.enabled ?? true, connectionId: resolve(value.connectionId, "database", `database.${key}`), query: value.query };
|
|
131
|
+
};
|
|
132
|
+
out.database = { preRequest: phase(input.database.preRequest, "preRequest"), postResponse: phase(input.database.postResponse, "postResponse") };
|
|
133
|
+
}
|
|
134
|
+
if (input.kafka !== undefined) {
|
|
135
|
+
if (input.kafka === null) {
|
|
136
|
+
out.kafka = { enabled: false, connectionId: null, topic: "", timeoutMs: 5000, matchMode: "regex", matchPattern: "", assertions: [], prePublish: DISABLED_PUBLISH, postPublish: DISABLED_PUBLISH };
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
const stored = asRecord(current?.kafka);
|
|
140
|
+
const kafka = input.kafka;
|
|
141
|
+
const consumeGiven = kafka.topic !== undefined || kafka.connectionId !== undefined;
|
|
142
|
+
out.kafka = {
|
|
143
|
+
...stored,
|
|
144
|
+
enabled: kafka.enabled ?? (consumeGiven ? true : (stored.enabled ?? false)),
|
|
145
|
+
connectionId: kafka.connectionId !== undefined ? resolve(kafka.connectionId, "kafka", "kafka") : (stored.connectionId ?? null),
|
|
146
|
+
topic: kafka.topic ?? stored.topic ?? "",
|
|
147
|
+
timeoutMs: kafka.timeoutMs ?? stored.timeoutMs ?? 5000,
|
|
148
|
+
matchMode: kafka.matchMode ?? stored.matchMode ?? "regex",
|
|
149
|
+
matchPattern: kafka.matchPattern ?? stored.matchPattern ?? "",
|
|
150
|
+
assertions: kafka.assertions !== undefined
|
|
151
|
+
? kafka.assertions.map((assertion) => ({ id: assertion.id ?? newId("ka"), name: assertion.name, field: assertion.field, operator: assertion.operator, valueType: assertion.valueType ?? "static", value: assertion.value ?? "" }))
|
|
152
|
+
: (stored.assertions ?? []),
|
|
153
|
+
prePublish: kafka.prePublish === undefined ? (stored.prePublish ?? DISABLED_PUBLISH) : kafka.prePublish === null ? DISABLED_PUBLISH : publishPayload(kafka.prePublish, resolve, "kafka.prePublish"),
|
|
154
|
+
postPublish: kafka.postPublish === undefined ? (stored.postPublish ?? DISABLED_PUBLISH) : kafka.postPublish === null ? DISABLED_PUBLISH : publishPayload(kafka.postPublish, resolve, "kafka.postPublish"),
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
if (input.redis !== undefined) {
|
|
159
|
+
out.redis =
|
|
160
|
+
input.redis === null
|
|
161
|
+
? { enabled: false, connectionId: null, preCommands: [], postCommands: [], assertions: [] }
|
|
162
|
+
: {
|
|
163
|
+
enabled: input.redis.enabled ?? true,
|
|
164
|
+
connectionId: resolve(input.redis.connectionId, "redis", "redis"),
|
|
165
|
+
preCommands: (input.redis.preCommands ?? []).map((command) => ({ id: newId("rc"), command })),
|
|
166
|
+
postCommands: (input.redis.postCommands ?? []).map((command) => ({ id: newId("rc"), command })),
|
|
167
|
+
assertions: (input.redis.assertions ?? []).map((assertion) => ({ id: assertion.id ?? newId("ra"), name: assertion.name, key: assertion.key, operator: assertion.operator, value: assertion.value ?? "" })),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
if (input.dbAssertions !== undefined) {
|
|
171
|
+
out.dbAssertions = input.dbAssertions.map((assertion) => ({
|
|
172
|
+
id: assertion.id ?? newId("da"),
|
|
173
|
+
name: assertion.name,
|
|
174
|
+
source: assertion.source,
|
|
175
|
+
field: assertion.field,
|
|
176
|
+
operator: assertion.operator,
|
|
177
|
+
valueType: assertion.valueType ?? "static",
|
|
178
|
+
value: assertion.value ?? "",
|
|
179
|
+
}));
|
|
180
|
+
}
|
|
181
|
+
if (input.kafkaScript !== undefined)
|
|
182
|
+
out.kafkaScript = input.kafkaScript;
|
|
183
|
+
return out;
|
|
184
|
+
};
|
|
185
|
+
exports.toIntegrationPayload = toIntegrationPayload;
|
|
186
|
+
// Stored integration fields → the input shape (only what is switched on).
|
|
187
|
+
const integrationsInputView = (request) => {
|
|
188
|
+
const out = {};
|
|
189
|
+
const database = asRecord(request.database);
|
|
190
|
+
const phase = (value) => {
|
|
191
|
+
const step = asRecord(value);
|
|
192
|
+
return step.enabled ? { enabled: true, connectionId: step.connectionId ?? null, query: step.query ?? "" } : undefined;
|
|
193
|
+
};
|
|
194
|
+
const pre = phase(database.preRequest);
|
|
195
|
+
const post = phase(database.postResponse);
|
|
196
|
+
if (pre || post)
|
|
197
|
+
out.database = { ...(pre ? { preRequest: pre } : {}), ...(post ? { postResponse: post } : {}) };
|
|
198
|
+
const kafka = asRecord(request.kafka);
|
|
199
|
+
const publish = (value) => {
|
|
200
|
+
const step = asRecord(value);
|
|
201
|
+
if (!step.enabled)
|
|
202
|
+
return undefined;
|
|
203
|
+
const { headers, ...rest } = step;
|
|
204
|
+
return { ...rest, headers: Array.isArray(headers) ? headers : [] };
|
|
205
|
+
};
|
|
206
|
+
const prePublish = publish(kafka.prePublish);
|
|
207
|
+
const postPublish = publish(kafka.postPublish);
|
|
208
|
+
if (kafka.enabled || prePublish || postPublish) {
|
|
209
|
+
out.kafka = {
|
|
210
|
+
...(kafka.enabled
|
|
211
|
+
? { enabled: true, connectionId: kafka.connectionId ?? null, topic: kafka.topic ?? "", timeoutMs: kafka.timeoutMs ?? 5000, matchMode: kafka.matchMode ?? "regex", matchPattern: kafka.matchPattern ?? "", assertions: kafka.assertions ?? [] }
|
|
212
|
+
: { enabled: false }),
|
|
213
|
+
...(prePublish ? { prePublish } : {}),
|
|
214
|
+
...(postPublish ? { postPublish } : {}),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
const redis = asRecord(request.redis);
|
|
218
|
+
if (redis.enabled) {
|
|
219
|
+
const commands = (value) => (Array.isArray(value) ? value.map((entry) => String(asRecord(entry).command ?? "")) : []);
|
|
220
|
+
out.redis = { enabled: true, connectionId: redis.connectionId ?? null, preCommands: commands(redis.preCommands), postCommands: commands(redis.postCommands), assertions: redis.assertions ?? [] };
|
|
221
|
+
}
|
|
222
|
+
if (request.dbAssertions && request.dbAssertions.length > 0)
|
|
223
|
+
out.dbAssertions = request.dbAssertions;
|
|
224
|
+
if (request.kafkaScript)
|
|
225
|
+
out.kafkaScript = request.kafkaScript;
|
|
226
|
+
return Object.keys(out).length > 0 ? out : undefined;
|
|
227
|
+
};
|
|
228
|
+
exports.integrationsInputView = integrationsInputView;
|