terse-types 0.0.28 → 0.0.30
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/dist/json-schema/terse-types.schema.json +346 -1517
- package/dist/types.d.ts +12 -4
- package/dist/types.js +11 -2
- package/package.json +1 -1
- package/dist/BillingErrors.d.ts +0 -20
- package/dist/BillingErrors.js +0 -39
- package/dist/BillingSchemas.d.ts +0 -72
- package/dist/BillingSchemas.js +0 -59
- package/dist/SandboxTypes.d.ts +0 -15
- package/dist/SandboxTypes.js +0 -1
- package/dist/TriggerEventPresenters.d.ts +0 -3
- package/dist/TriggerEventPresenters.js +0 -238
- package/dist/TriggerEvents.d.ts +0 -4054
- package/dist/TriggerEvents.js +0 -437
package/dist/types.d.ts
CHANGED
|
@@ -6604,6 +6604,8 @@ export declare const workosWebhookSecretUpdateRequestSchema: z.ZodObject<{
|
|
|
6604
6604
|
}, z.core.$strip>;
|
|
6605
6605
|
export type WorkosWebhookSecretUpdateRequest = z.infer<typeof workosWebhookSecretUpdateRequestSchema>;
|
|
6606
6606
|
export declare const sdkSampleEventsRequestSchema: z.ZodObject<{
|
|
6607
|
+
projectId: z.ZodOptional<z.ZodString>;
|
|
6608
|
+
jobName: z.ZodOptional<z.ZodString>;
|
|
6607
6609
|
triggers: z.ZodArray<z.ZodObject<{
|
|
6608
6610
|
triggerId: z.ZodOptional<z.ZodString>;
|
|
6609
6611
|
integrationId: z.ZodString;
|
|
@@ -6800,7 +6802,7 @@ export declare const identifiableSchema: z.ZodObject<{
|
|
|
6800
6802
|
}, z.core.$strip>;
|
|
6801
6803
|
export type Identifiable = z.infer<typeof identifiableSchema>;
|
|
6802
6804
|
export declare const sdkSampleEventRefSchema: z.ZodObject<{
|
|
6803
|
-
entity: z.ZodObject<{
|
|
6805
|
+
entity: z.ZodOptional<z.ZodObject<{
|
|
6804
6806
|
entityType: z.ZodEnum<{
|
|
6805
6807
|
run_history_raw_event: "run_history_raw_event";
|
|
6806
6808
|
slack_message_event: "slack_message_event";
|
|
@@ -6811,7 +6813,8 @@ export declare const sdkSampleEventRefSchema: z.ZodObject<{
|
|
|
6811
6813
|
webmonitor_event: "webmonitor_event";
|
|
6812
6814
|
}>;
|
|
6813
6815
|
entityId: z.ZodString;
|
|
6814
|
-
}, z.core.$strip
|
|
6816
|
+
}, z.core.$strip>>;
|
|
6817
|
+
recordedAt: z.ZodOptional<z.ZodString>;
|
|
6815
6818
|
serializedEvent: z.ZodObject<{
|
|
6816
6819
|
integrationType: z.ZodEnum<typeof import("./Integrations.js").IntegrationType>;
|
|
6817
6820
|
eventType: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -7530,7 +7533,7 @@ export declare const sdkSampleEventRefSchema: z.ZodObject<{
|
|
|
7530
7533
|
export type SdkSampleEventRef = z.infer<typeof sdkSampleEventRefSchema>;
|
|
7531
7534
|
export declare const sdkSampleEventsResponseSchema: z.ZodObject<{
|
|
7532
7535
|
events: z.ZodArray<z.ZodObject<{
|
|
7533
|
-
entity: z.ZodObject<{
|
|
7536
|
+
entity: z.ZodOptional<z.ZodObject<{
|
|
7534
7537
|
entityType: z.ZodEnum<{
|
|
7535
7538
|
run_history_raw_event: "run_history_raw_event";
|
|
7536
7539
|
slack_message_event: "slack_message_event";
|
|
@@ -7541,7 +7544,8 @@ export declare const sdkSampleEventsResponseSchema: z.ZodObject<{
|
|
|
7541
7544
|
webmonitor_event: "webmonitor_event";
|
|
7542
7545
|
}>;
|
|
7543
7546
|
entityId: z.ZodString;
|
|
7544
|
-
}, z.core.$strip
|
|
7547
|
+
}, z.core.$strip>>;
|
|
7548
|
+
recordedAt: z.ZodOptional<z.ZodString>;
|
|
7545
7549
|
serializedEvent: z.ZodObject<{
|
|
7546
7550
|
integrationType: z.ZodEnum<typeof import("./Integrations.js").IntegrationType>;
|
|
7547
7551
|
eventType: z.ZodUnion<readonly [z.ZodEnum<{
|
|
@@ -8257,6 +8261,10 @@ export declare const sdkSampleEventsResponseSchema: z.ZodObject<{
|
|
|
8257
8261
|
}, z.core.$strip>]>;
|
|
8258
8262
|
}, z.core.$strip>;
|
|
8259
8263
|
}, z.core.$strip>>;
|
|
8264
|
+
webhookEndpoints: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
8265
|
+
triggerId: z.ZodString;
|
|
8266
|
+
webhookUrl: z.ZodString;
|
|
8267
|
+
}, z.core.$strip>>>;
|
|
8260
8268
|
}, z.core.$strip>;
|
|
8261
8269
|
export type SdkSampleEventsResponse = z.infer<typeof sdkSampleEventsResponseSchema>;
|
|
8262
8270
|
export declare const sdkHydrateSampleEventRequestSchema: z.ZodObject<{
|
package/dist/types.js
CHANGED
|
@@ -635,6 +635,8 @@ export const workosWebhookSecretUpdateRequestSchema = z.object({
|
|
|
635
635
|
state: z.string().optional()
|
|
636
636
|
});
|
|
637
637
|
export const sdkSampleEventsRequestSchema = z.object({
|
|
638
|
+
projectId: z.string().optional(),
|
|
639
|
+
jobName: z.string().optional(),
|
|
638
640
|
triggers: z
|
|
639
641
|
.array(z.object({
|
|
640
642
|
triggerId: z.string().optional(),
|
|
@@ -650,11 +652,18 @@ export const identifiableSchema = z.object({
|
|
|
650
652
|
entityId: z.string()
|
|
651
653
|
});
|
|
652
654
|
export const sdkSampleEventRefSchema = z.object({
|
|
653
|
-
entity: identifiableSchema,
|
|
655
|
+
entity: identifiableSchema.optional(),
|
|
656
|
+
recordedAt: z.string().optional(),
|
|
654
657
|
serializedEvent: serializedEventSchema
|
|
655
658
|
});
|
|
656
659
|
export const sdkSampleEventsResponseSchema = z.object({
|
|
657
|
-
events: z.array(sdkSampleEventRefSchema)
|
|
660
|
+
events: z.array(sdkSampleEventRefSchema),
|
|
661
|
+
webhookEndpoints: z
|
|
662
|
+
.array(z.object({
|
|
663
|
+
triggerId: z.string(),
|
|
664
|
+
webhookUrl: z.string()
|
|
665
|
+
}))
|
|
666
|
+
.optional()
|
|
658
667
|
});
|
|
659
668
|
export const sdkHydrateSampleEventRequestSchema = z.object({
|
|
660
669
|
entityType: hydratorTypeEnum,
|
package/package.json
CHANGED
package/dist/BillingErrors.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export type BillingForbiddenErrorType = "CreditGateDeniedError" | "StripeError";
|
|
2
|
-
/**
|
|
3
|
-
* Wire shape other services should return with HTTP 403 for billing/credit denials.
|
|
4
|
-
* `type` may be sent as `errorType` for compatibility.
|
|
5
|
-
*/
|
|
6
|
-
export type BillingForbiddenErrorBody = {
|
|
7
|
-
type: BillingForbiddenErrorType;
|
|
8
|
-
reason?: string;
|
|
9
|
-
};
|
|
10
|
-
export declare class CreditGateDeniedError extends Error {
|
|
11
|
-
readonly reason: string;
|
|
12
|
-
constructor(reason: string);
|
|
13
|
-
}
|
|
14
|
-
export declare class StripeError extends Error {
|
|
15
|
-
readonly reason?: string;
|
|
16
|
-
constructor(message?: string, reason?: string);
|
|
17
|
-
}
|
|
18
|
-
export declare function billingErrorFromForbiddenBody(body: unknown): CreditGateDeniedError | StripeError | null;
|
|
19
|
-
/** Parse JSON body from a billing HTTP 403 response */
|
|
20
|
-
export declare function parseBillingForbiddenJson(raw: string): CreditGateDeniedError | StripeError | null;
|
package/dist/BillingErrors.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export class CreditGateDeniedError extends Error {
|
|
2
|
-
reason;
|
|
3
|
-
constructor(reason) {
|
|
4
|
-
super(`Credit gate denied: ${reason}`);
|
|
5
|
-
this.name = "CreditGateDeniedError";
|
|
6
|
-
this.reason = reason;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
export class StripeError extends Error {
|
|
10
|
-
reason;
|
|
11
|
-
constructor(message, reason) {
|
|
12
|
-
super(message ?? reason ?? "Billing provider error");
|
|
13
|
-
this.name = "StripeError";
|
|
14
|
-
this.reason = reason;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
export function billingErrorFromForbiddenBody(body) {
|
|
18
|
-
if (!body || typeof body !== "object")
|
|
19
|
-
return null;
|
|
20
|
-
const o = body;
|
|
21
|
-
const t = o.type ?? o.errorType;
|
|
22
|
-
if (t === "CreditGateDeniedError") {
|
|
23
|
-
return new CreditGateDeniedError(typeof o.reason === "string" ? o.reason : "unknown");
|
|
24
|
-
}
|
|
25
|
-
if (t === "StripeError") {
|
|
26
|
-
const reason = typeof o.reason === "string" ? o.reason : undefined;
|
|
27
|
-
return new StripeError(reason, reason);
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
/** Parse JSON body from a billing HTTP 403 response */
|
|
32
|
-
export function parseBillingForbiddenJson(raw) {
|
|
33
|
-
try {
|
|
34
|
-
return billingErrorFromForbiddenBody(JSON.parse(raw));
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
package/dist/BillingSchemas.d.ts
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { PlanKey, SupportedTopUps, TimePeriods } from "./Billing.js";
|
|
3
|
-
/** Matches `CompletedEventUsage` in `Billing.ts`. */
|
|
4
|
-
export declare const completedEventUsageSchema: z.ZodObject<{
|
|
5
|
-
inputTokens: z.ZodNumber;
|
|
6
|
-
outputTokens: z.ZodNumber;
|
|
7
|
-
totalTokens: z.ZodNumber;
|
|
8
|
-
inputTokensDetails: z.ZodObject<{
|
|
9
|
-
cached_tokens: z.ZodNumber;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
}, z.core.$strip>;
|
|
12
|
-
/** Matches `BillingRunGateRequestBody`. */
|
|
13
|
-
export declare const billingRunGateRequestBodySchema: z.ZodObject<{
|
|
14
|
-
organizationId: z.ZodString;
|
|
15
|
-
}, z.core.$strip>;
|
|
16
|
-
/** Matches `BillingChargeRunBaseBody`. */
|
|
17
|
-
export declare const billingChargeRunBaseBodySchema: z.ZodObject<{
|
|
18
|
-
organizationId: z.ZodString;
|
|
19
|
-
runId: z.ZodString;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
|
-
/** Matches `BillingRecordLlmBody`. */
|
|
22
|
-
export declare const billingRecordLlmBodySchema: z.ZodObject<{
|
|
23
|
-
organizationId: z.ZodString;
|
|
24
|
-
runId: z.ZodString;
|
|
25
|
-
responseId: z.ZodString;
|
|
26
|
-
model: z.ZodObject<{
|
|
27
|
-
providerId: z.ZodEnum<{
|
|
28
|
-
anthropic: "anthropic";
|
|
29
|
-
openai: "openai";
|
|
30
|
-
}>;
|
|
31
|
-
modelId: z.ZodString;
|
|
32
|
-
value: z.ZodString;
|
|
33
|
-
}, z.core.$strip>;
|
|
34
|
-
usage: z.ZodObject<{
|
|
35
|
-
inputTokens: z.ZodNumber;
|
|
36
|
-
outputTokens: z.ZodNumber;
|
|
37
|
-
totalTokens: z.ZodNumber;
|
|
38
|
-
inputTokensDetails: z.ZodObject<{
|
|
39
|
-
cached_tokens: z.ZodNumber;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
|
-
}, z.core.$strip>;
|
|
42
|
-
}, z.core.$strip>;
|
|
43
|
-
/** Matches `BillingCheckoutRequestBody`. */
|
|
44
|
-
export declare const billingCheckoutRequestBodySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
45
|
-
kind: z.ZodLiteral<"plan">;
|
|
46
|
-
planKey: z.ZodEnum<typeof PlanKey>;
|
|
47
|
-
period: z.ZodEnum<typeof TimePeriods>;
|
|
48
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
49
|
-
kind: z.ZodLiteral<"topup">;
|
|
50
|
-
packCredits: z.ZodEnum<typeof SupportedTopUps>;
|
|
51
|
-
}, z.core.$strip>], "kind">;
|
|
52
|
-
/** Matches `BillingChangeRequestBody`. */
|
|
53
|
-
export declare const billingChangeRequestBodySchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
54
|
-
kind: z.ZodLiteral<"cancel_to_free">;
|
|
55
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
56
|
-
kind: z.ZodLiteral<"change_period">;
|
|
57
|
-
planKey: z.ZodEnum<typeof PlanKey>;
|
|
58
|
-
period: z.ZodEnum<typeof TimePeriods>;
|
|
59
|
-
}, z.core.$strip>], "kind">;
|
|
60
|
-
/** Matches `BillingOverageModePatchBody`. */
|
|
61
|
-
export declare const billingOverageModePatchBodySchema: z.ZodObject<{
|
|
62
|
-
mode: z.ZodEnum<{
|
|
63
|
-
soft: "soft";
|
|
64
|
-
strict: "strict";
|
|
65
|
-
}>;
|
|
66
|
-
}, z.core.$strip>;
|
|
67
|
-
export declare const billingPortalSessionRequestBodySchema: z.ZodObject<{}, z.core.$strict>;
|
|
68
|
-
export declare const billingContextQuerySchema: z.ZodObject<{
|
|
69
|
-
start: z.ZodOptional<z.ZodString>;
|
|
70
|
-
end: z.ZodOptional<z.ZodString>;
|
|
71
|
-
}, z.core.$strip>;
|
|
72
|
-
export declare const getOrCreateCustomerRequestBodySchema: z.ZodObject<{}, z.core.$strict>;
|
package/dist/BillingSchemas.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
2
|
-
import { PlanKey, SupportedTopUps, TimePeriods } from "./Billing.js";
|
|
3
|
-
import { modelReferenceSchema } from "./ModelRegistry.js";
|
|
4
|
-
/** Matches `CompletedEventUsage` in `Billing.ts`. */
|
|
5
|
-
export const completedEventUsageSchema = z.object({
|
|
6
|
-
inputTokens: z.number().nonnegative(),
|
|
7
|
-
outputTokens: z.number().nonnegative(),
|
|
8
|
-
totalTokens: z.number().nonnegative(),
|
|
9
|
-
inputTokensDetails: z.object({
|
|
10
|
-
cached_tokens: z.number().nonnegative()
|
|
11
|
-
})
|
|
12
|
-
});
|
|
13
|
-
/** Matches `BillingRunGateRequestBody`. */
|
|
14
|
-
export const billingRunGateRequestBodySchema = z.object({
|
|
15
|
-
organizationId: z.string().min(1)
|
|
16
|
-
});
|
|
17
|
-
/** Matches `BillingChargeRunBaseBody`. */
|
|
18
|
-
export const billingChargeRunBaseBodySchema = billingRunGateRequestBodySchema.extend({
|
|
19
|
-
runId: z.string().min(1)
|
|
20
|
-
});
|
|
21
|
-
/** Matches `BillingRecordLlmBody`. */
|
|
22
|
-
export const billingRecordLlmBodySchema = z.object({
|
|
23
|
-
organizationId: z.string().min(1),
|
|
24
|
-
runId: z.string().min(1),
|
|
25
|
-
responseId: z.string().min(1),
|
|
26
|
-
model: modelReferenceSchema,
|
|
27
|
-
usage: completedEventUsageSchema
|
|
28
|
-
});
|
|
29
|
-
/** Matches `BillingCheckoutRequestBody`. */
|
|
30
|
-
export const billingCheckoutRequestBodySchema = z.discriminatedUnion("kind", [
|
|
31
|
-
z.object({
|
|
32
|
-
kind: z.literal("plan"),
|
|
33
|
-
planKey: z.enum(PlanKey),
|
|
34
|
-
period: z.enum(TimePeriods)
|
|
35
|
-
}),
|
|
36
|
-
z.object({
|
|
37
|
-
kind: z.literal("topup"),
|
|
38
|
-
packCredits: z.enum(SupportedTopUps)
|
|
39
|
-
})
|
|
40
|
-
]);
|
|
41
|
-
/** Matches `BillingChangeRequestBody`. */
|
|
42
|
-
export const billingChangeRequestBodySchema = z.discriminatedUnion("kind", [
|
|
43
|
-
z.object({ kind: z.literal("cancel_to_free") }),
|
|
44
|
-
z.object({
|
|
45
|
-
kind: z.literal("change_period"),
|
|
46
|
-
planKey: z.enum(PlanKey),
|
|
47
|
-
period: z.enum(TimePeriods)
|
|
48
|
-
})
|
|
49
|
-
]);
|
|
50
|
-
/** Matches `BillingOverageModePatchBody`. */
|
|
51
|
-
export const billingOverageModePatchBodySchema = z.object({
|
|
52
|
-
mode: z.enum(["soft", "strict"])
|
|
53
|
-
});
|
|
54
|
-
export const billingPortalSessionRequestBodySchema = z.object({}).strict();
|
|
55
|
-
export const billingContextQuerySchema = z.object({
|
|
56
|
-
start: z.string().min(1).optional(),
|
|
57
|
-
end: z.string().min(1).optional()
|
|
58
|
-
});
|
|
59
|
-
export const getOrCreateCustomerRequestBodySchema = z.object({}).strict();
|
package/dist/SandboxTypes.d.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type SandboxLogEntry = {
|
|
2
|
-
stream: "stdout" | "stderr";
|
|
3
|
-
text: string;
|
|
4
|
-
timestamp: number;
|
|
5
|
-
};
|
|
6
|
-
export type SandboxLogPayload = SandboxLogEntry & {
|
|
7
|
-
runId: string;
|
|
8
|
-
agentId: string;
|
|
9
|
-
};
|
|
10
|
-
export type SandboxLogsResponse = {
|
|
11
|
-
sandboxId: string | null;
|
|
12
|
-
entries: SandboxLogEntry[];
|
|
13
|
-
timestamp: number;
|
|
14
|
-
error?: string;
|
|
15
|
-
};
|
package/dist/SandboxTypes.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
import { IntegrationType } from "./Integrations.js";
|
|
2
|
-
const TriggerPresenters = {
|
|
3
|
-
manual_sample: {
|
|
4
|
-
formatForAgent: (event) => `Manual sample event for ${event.integrationType}.`,
|
|
5
|
-
debug: (event) => `${event.integrationType} ${event.eventType}`
|
|
6
|
-
},
|
|
7
|
-
[IntegrationType.GITHUB]: {
|
|
8
|
-
formatForAgent: formatGithubTrigger,
|
|
9
|
-
debug: (event) => `GitHub Event: ${event.eventType} - ${event.repository.owner}/${event.repository.name} - ${event.sender.login}`
|
|
10
|
-
},
|
|
11
|
-
[IntegrationType.SLACK]: {
|
|
12
|
-
formatForAgent: formatSlackTrigger,
|
|
13
|
-
debug: (event) => {
|
|
14
|
-
const isDM = event.channelType === "im";
|
|
15
|
-
return `Slack Event: ${event.eventType} - ${isDM ? "DM" : event.channelName || event.channelId} - ${event.userName || event.userId}`;
|
|
16
|
-
}
|
|
17
|
-
},
|
|
18
|
-
[IntegrationType.GMAIL]: {
|
|
19
|
-
formatForAgent: formatGmailTrigger,
|
|
20
|
-
debug: (event) => `Gmail Event: ${event.subject} message ID: ${event.messageId}`
|
|
21
|
-
},
|
|
22
|
-
[IntegrationType.LINEAR]: {
|
|
23
|
-
formatForAgent: formatLinearTrigger,
|
|
24
|
-
debug: (event) => {
|
|
25
|
-
if (event.type === "Issue") {
|
|
26
|
-
return `Linear ${event.type} Event: ${event.data.identifier} - ${event.data.title} (${event.action})`;
|
|
27
|
-
}
|
|
28
|
-
return `Linear ${event.type} Event: Comment on issue ${event.data.issueId || "Unknown"} (${event.action})`;
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
[IntegrationType.WORKOS]: {
|
|
32
|
-
formatForAgent: formatWorkOSTrigger,
|
|
33
|
-
debug: (event) => `WorkOS ${event.eventType}`
|
|
34
|
-
},
|
|
35
|
-
[IntegrationType.WEBHOOK]: {
|
|
36
|
-
formatForAgent: formatWebhookTrigger,
|
|
37
|
-
debug: (event) => `Webhook Trigger (${event.method})`
|
|
38
|
-
},
|
|
39
|
-
[IntegrationType.CRON_JOB]: {
|
|
40
|
-
formatForAgent: formatCronTrigger,
|
|
41
|
-
debug: (event) => (event.isManualTrigger ? "Manual Trigger" : "Scheduled Event")
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
export function formatTriggerForAgent(event) {
|
|
45
|
-
if (event.eventType === "manual_sample") {
|
|
46
|
-
return TriggerPresenters.manual_sample.formatForAgent(event);
|
|
47
|
-
}
|
|
48
|
-
const presenter = TriggerPresenters[event.integrationType];
|
|
49
|
-
return presenter.formatForAgent(event);
|
|
50
|
-
}
|
|
51
|
-
export function debugTrigger(event) {
|
|
52
|
-
if (event.eventType === "manual_sample") {
|
|
53
|
-
return TriggerPresenters.manual_sample.debug(event);
|
|
54
|
-
}
|
|
55
|
-
const presenter = TriggerPresenters[event.integrationType];
|
|
56
|
-
return presenter.debug(event);
|
|
57
|
-
}
|
|
58
|
-
function formatGithubTrigger(event) {
|
|
59
|
-
const indentMultiline = (text) => text
|
|
60
|
-
.split("\n")
|
|
61
|
-
.map(line => ` ${line}`)
|
|
62
|
-
.join("\n");
|
|
63
|
-
const eventTypeDescriptions = {
|
|
64
|
-
push: "Code Push Event",
|
|
65
|
-
"pull_request.opened": "Pull Request Opened",
|
|
66
|
-
"pull_request.synchronize": "Pull Request Updated (new commits added)",
|
|
67
|
-
"pull_request.closed": "Pull Request Closed",
|
|
68
|
-
"pull_request.merged": "Pull Request Merged"
|
|
69
|
-
};
|
|
70
|
-
const eventDescription = eventTypeDescriptions[event.eventType] || event.eventType;
|
|
71
|
-
const repoInfo = [
|
|
72
|
-
`Repository: ${event.repository.owner}/${event.repository.name}`,
|
|
73
|
-
`Repository ID: ${event.repository.id}`,
|
|
74
|
-
`Default Branch: ${event.repository.defaultBranch}`,
|
|
75
|
-
`View on GitHub: https://github.com/${event.repository.owner}/${event.repository.name}`
|
|
76
|
-
].join("\n");
|
|
77
|
-
const senderInfo = [`Actor: ${event.sender.login}`, ...(event.sender.email ? [`Email: ${event.sender.email}`] : [])].join("\n");
|
|
78
|
-
const branchInfo = event.branch ? `Branch: ${event.branch}` : null;
|
|
79
|
-
let prInfo = "";
|
|
80
|
-
if (event.pullRequest) {
|
|
81
|
-
const pr = event.pullRequest;
|
|
82
|
-
const author = pr.author ?? pr.user;
|
|
83
|
-
const prLines = [
|
|
84
|
-
`Pull Request #${pr.number}: ${pr.title}`,
|
|
85
|
-
`State: ${pr.state}${pr.merged ? " (merged)" : ""}`,
|
|
86
|
-
`Author: ${author.login}${author.email ? ` (${author.email})` : ""}`,
|
|
87
|
-
`Head Branch: ${pr.head.ref} (${pr.head.sha.substring(0, 7)})`,
|
|
88
|
-
`Base Branch: ${pr.base.ref} (${pr.base.sha.substring(0, 7)})`,
|
|
89
|
-
`View PR: ${pr.url}`
|
|
90
|
-
];
|
|
91
|
-
if (pr.body) {
|
|
92
|
-
prLines.push(`\nDescription:\n${indentMultiline(pr.body)}`);
|
|
93
|
-
}
|
|
94
|
-
prInfo = prLines.join("\n");
|
|
95
|
-
}
|
|
96
|
-
let commitsInfo = "";
|
|
97
|
-
if (event.commits.length > 0) {
|
|
98
|
-
const commitLines = [];
|
|
99
|
-
commitLines.push(`Commits (${event.commits.length}):`);
|
|
100
|
-
event.commits.forEach((commit, index) => {
|
|
101
|
-
const shortSha = commit.sha.substring(0, 7);
|
|
102
|
-
const commitUrl = `https://github.com/${event.repository.owner}/${event.repository.name}/commit/${commit.sha}`;
|
|
103
|
-
commitLines.push(`\n${index + 1}. Commit ${shortSha}: ${commit.message || commit.name || ""}`);
|
|
104
|
-
commitLines.push(` URL: ${commitUrl}`);
|
|
105
|
-
if (commit.fileDiffs.length > 0) {
|
|
106
|
-
commitLines.push(` Files Changed: ${commit.fileDiffs.length}`);
|
|
107
|
-
const fileList = commit.fileDiffs.map(f => ` - ${f.filename}`).join("\n");
|
|
108
|
-
commitLines.push(` Files:\n${fileList}`);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
commitsInfo = commitLines.join("\n");
|
|
112
|
-
}
|
|
113
|
-
return [
|
|
114
|
-
`Incoming GitHub Event: ${eventDescription}`,
|
|
115
|
-
`\nRepository Information:\n${indentMultiline(repoInfo)}`,
|
|
116
|
-
`\nActor Information:\n${indentMultiline(senderInfo)}`,
|
|
117
|
-
...(branchInfo ? [`\nBranch Information:\n${indentMultiline(branchInfo)}`] : []),
|
|
118
|
-
...(prInfo ? [`\nPull Request Information:\n${indentMultiline(prInfo)}`] : []),
|
|
119
|
-
...(commitsInfo ? [`\n${commitsInfo}`] : [])
|
|
120
|
-
].join("\n\n");
|
|
121
|
-
}
|
|
122
|
-
function formatSlackTrigger(event) {
|
|
123
|
-
const blockContent = JSON.stringify(event.blocks);
|
|
124
|
-
const attachmentContent = JSON.stringify(event.attachments);
|
|
125
|
-
const messageText = event.text || "(no plain text)";
|
|
126
|
-
const threadTs = event.threadTs ?? event.threadTimestamp ?? null;
|
|
127
|
-
const eventLabel = event.eventType === "app_mention" ? "Incoming Slack App Mention Event." : event.eventType === "reaction_added" ? "Incoming Slack Reaction Added Event." : "Incoming Slack Message Event.";
|
|
128
|
-
const reactionInfo = event.eventType === "reaction_added"
|
|
129
|
-
? `Reaction: ${event.reaction || "unknown"}\n Target Message Timestamp: ${event.itemTimestamp || "unknown"}\n Target User: ${event.itemUserId || "unknown"}`
|
|
130
|
-
: "";
|
|
131
|
-
return `
|
|
132
|
-
${eventLabel}
|
|
133
|
-
|
|
134
|
-
Slack Event:
|
|
135
|
-
Event Type: ${event.eventType}
|
|
136
|
-
Channel: ${event.channelName || event.channelId}
|
|
137
|
-
User: ${event.userName || event.userId}
|
|
138
|
-
Message: ${messageText}
|
|
139
|
-
Timestamp: ${event.timestamp}
|
|
140
|
-
${threadTs ? `Thread: ${threadTs}` : ""}
|
|
141
|
-
Team ID: ${event.teamId}
|
|
142
|
-
${reactionInfo}
|
|
143
|
-
${blockContent
|
|
144
|
-
? `
|
|
145
|
-
Rich Content (from blocks):
|
|
146
|
-
${blockContent}`
|
|
147
|
-
: ""}
|
|
148
|
-
${attachmentContent
|
|
149
|
-
? `
|
|
150
|
-
Attachment Content:
|
|
151
|
-
${attachmentContent}`
|
|
152
|
-
: ""}
|
|
153
|
-
`;
|
|
154
|
-
}
|
|
155
|
-
function formatGmailTrigger(event) {
|
|
156
|
-
const attachmentInfo = event.attachments?.map(attachment => `- ${attachment.filename} ${attachment.isInline ? "Inline" : "Attachment"} (${attachment.mimeType})`).join("\n") || "No attachments";
|
|
157
|
-
return `
|
|
158
|
-
Incoming Email Event.
|
|
159
|
-
|
|
160
|
-
Gmail Event:
|
|
161
|
-
Subject: ${event.subject}
|
|
162
|
-
From: ${event.from}
|
|
163
|
-
To: ${event.to}
|
|
164
|
-
Date: ${event.date}
|
|
165
|
-
Message ID: ${event.messageId}
|
|
166
|
-
Thread ID: ${event.threadId}
|
|
167
|
-
Body: ${event.body}
|
|
168
|
-
Snippet: ${event.snippet}
|
|
169
|
-
Attachments (if any listed, actual files should be added below):
|
|
170
|
-
${attachmentInfo}
|
|
171
|
-
`;
|
|
172
|
-
}
|
|
173
|
-
function formatLinearTrigger(event) {
|
|
174
|
-
const indentMultiline = (text) => text
|
|
175
|
-
.split("\n")
|
|
176
|
-
.map(line => ` ${line}`)
|
|
177
|
-
.join("\n");
|
|
178
|
-
const sections = [];
|
|
179
|
-
sections.push(`Incoming Linear ${event.type} Event`);
|
|
180
|
-
sections.push(`Action: ${event.action}`);
|
|
181
|
-
sections.push(`Actor: ${event.actor.name} (${event.actor.email})`);
|
|
182
|
-
sections.push(`Created: ${event.createdAt}`);
|
|
183
|
-
if (event.type === "Issue" && event.data) {
|
|
184
|
-
const issue = event.data;
|
|
185
|
-
const issueSections = [];
|
|
186
|
-
issueSections.push(`Issue: ${issue.identifier} - ${issue.title}`);
|
|
187
|
-
if (issue.description)
|
|
188
|
-
issueSections.push(`Description:\n${indentMultiline(issue.description)}`);
|
|
189
|
-
issueSections.push(`Priority: ${issue.priorityLabel || issue.priority}`);
|
|
190
|
-
issueSections.push(`State: ${issue.state?.name || "Unknown"}`);
|
|
191
|
-
issueSections.push(`Team: ${issue.team?.name || "Unknown"}`);
|
|
192
|
-
if (issue.assignee)
|
|
193
|
-
issueSections.push(`Assignee: ${issue.assignee.name}`);
|
|
194
|
-
if (issue.labels?.length)
|
|
195
|
-
issueSections.push(`Labels: ${issue.labels.map((label) => label.name || label).join(", ")}`);
|
|
196
|
-
if (issue.url)
|
|
197
|
-
issueSections.push(`URL: ${issue.url}`);
|
|
198
|
-
sections.push(issueSections.join("\n"));
|
|
199
|
-
}
|
|
200
|
-
else if (event.type === "Comment" && event.data) {
|
|
201
|
-
const commentSections = [`Comment on Issue: ${event.data.issueId || "Unknown"}`];
|
|
202
|
-
if (event.data.body)
|
|
203
|
-
commentSections.push(`Comment:\n${indentMultiline(event.data.body)}`);
|
|
204
|
-
sections.push(commentSections.join("\n"));
|
|
205
|
-
}
|
|
206
|
-
else {
|
|
207
|
-
sections.push(`Event Data:\n${indentMultiline(JSON.stringify(event.data, null, 2))}`);
|
|
208
|
-
}
|
|
209
|
-
if (event.organizationId) {
|
|
210
|
-
sections.push(`Organization ID: ${event.organizationId}`);
|
|
211
|
-
}
|
|
212
|
-
return sections.join("\n\n");
|
|
213
|
-
}
|
|
214
|
-
function formatWorkOSTrigger(event) {
|
|
215
|
-
const parts = [`WorkOS Event: ${event.eventType}`];
|
|
216
|
-
if ("user" in event && event.user) {
|
|
217
|
-
parts.push(`User Email: ${event.user.email}`);
|
|
218
|
-
if (event.user.firstName || event.user.lastName) {
|
|
219
|
-
parts.push(`User Name: ${[event.user.firstName, event.user.lastName].filter(Boolean).join(" ")}`);
|
|
220
|
-
}
|
|
221
|
-
parts.push(`User ID: ${event.user.id}`);
|
|
222
|
-
}
|
|
223
|
-
parts.push(`\nFull Event Data:\n${JSON.stringify(event, null, 2)}`);
|
|
224
|
-
return parts.join("\n");
|
|
225
|
-
}
|
|
226
|
-
function formatWebhookTrigger(event) {
|
|
227
|
-
return `Webhook request received.\n\nMethod: ${event.method}\n\nPayload:\n${JSON.stringify(event.body, null, 2)}`;
|
|
228
|
-
}
|
|
229
|
-
function formatCronTrigger(event) {
|
|
230
|
-
if (event.isManualTrigger) {
|
|
231
|
-
let message = `This is a manually triggered event for the channel input ${event.inputId}.`;
|
|
232
|
-
if (event.manualContext) {
|
|
233
|
-
message += `\n\nUser provided context for this manual trigger:\n${event.manualContext}`;
|
|
234
|
-
}
|
|
235
|
-
return message;
|
|
236
|
-
}
|
|
237
|
-
return `This is a scheduled event for the channel input ${event.inputId}. The channel input is configured to run at the following cron expression.`;
|
|
238
|
-
}
|