terse-types 0.0.61 → 0.0.63
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/Events.d.ts +112 -0
- package/dist/Events.js +32 -0
- package/dist/TriggerProjections.d.ts +20 -0
- package/dist/TriggerProjections.js +119 -0
- package/dist/Triggers.d.ts +2009 -0
- package/dist/Triggers.js +24 -0
- package/package.json +1 -1
- package/dist/AttioRecordFlatten.d.ts +0 -19
- package/dist/AttioRecordFlatten.js +0 -71
- package/dist/OrganizationMetadata.d.ts +0 -6
- package/dist/OrganizationMetadata.js +0 -10
- package/dist/json-schema/terse-types.schema.json +0 -15994
package/dist/Events.d.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const eventTypeSchema: z.ZodEnum<{
|
|
3
|
+
JOB_CREATED: "JOB_CREATED";
|
|
4
|
+
AUTOMATION_RAN: "AUTOMATION_RAN";
|
|
5
|
+
}>;
|
|
6
|
+
export type EventType = z.infer<typeof eventTypeSchema>;
|
|
7
|
+
declare const jobCreatedEventSchema: z.ZodObject<{
|
|
8
|
+
eventType: z.ZodLiteral<"JOB_CREATED">;
|
|
9
|
+
jobId: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export type JobCreatedEvent = z.infer<typeof jobCreatedEventSchema>;
|
|
12
|
+
declare const automationSnapshotSchema: z.ZodObject<{
|
|
13
|
+
id: z.ZodString;
|
|
14
|
+
name: z.ZodString;
|
|
15
|
+
organizationId: z.ZodString;
|
|
16
|
+
projectId: z.ZodString;
|
|
17
|
+
userId: z.ZodString;
|
|
18
|
+
requireApproval: z.ZodBoolean;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export type AutomationSnapshot = z.infer<typeof automationSnapshotSchema>;
|
|
21
|
+
declare const runSnapshotSchema: z.ZodObject<{
|
|
22
|
+
id: z.ZodString;
|
|
23
|
+
status: z.ZodEnum<{
|
|
24
|
+
readonly SUCCESS: "success";
|
|
25
|
+
readonly FAILED: "failed";
|
|
26
|
+
readonly CANCELLED: "cancelled";
|
|
27
|
+
readonly SKIPPED: "skipped";
|
|
28
|
+
readonly IN_PROGRESS: "in_progress";
|
|
29
|
+
readonly AWAITING_APPROVAL: "awaiting_approval";
|
|
30
|
+
}>;
|
|
31
|
+
isManuallyTriggered: z.ZodBoolean;
|
|
32
|
+
startedAt: z.ZodString;
|
|
33
|
+
trigger: z.ZodObject<{
|
|
34
|
+
event: z.ZodString;
|
|
35
|
+
integration: z.ZodEnum<typeof import("./Integrations.js").IntegrationType>;
|
|
36
|
+
source: z.ZodString;
|
|
37
|
+
title: z.ZodOptional<z.ZodString>;
|
|
38
|
+
subheader: z.ZodOptional<z.ZodString>;
|
|
39
|
+
url: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type RunSnapshot = z.infer<typeof runSnapshotSchema>;
|
|
43
|
+
declare const automationRanEventSchema: z.ZodObject<{
|
|
44
|
+
eventType: z.ZodLiteral<"AUTOMATION_RAN">;
|
|
45
|
+
automation: z.ZodObject<{
|
|
46
|
+
id: z.ZodString;
|
|
47
|
+
name: z.ZodString;
|
|
48
|
+
organizationId: z.ZodString;
|
|
49
|
+
projectId: z.ZodString;
|
|
50
|
+
userId: z.ZodString;
|
|
51
|
+
requireApproval: z.ZodBoolean;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
run: z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
status: z.ZodEnum<{
|
|
56
|
+
readonly SUCCESS: "success";
|
|
57
|
+
readonly FAILED: "failed";
|
|
58
|
+
readonly CANCELLED: "cancelled";
|
|
59
|
+
readonly SKIPPED: "skipped";
|
|
60
|
+
readonly IN_PROGRESS: "in_progress";
|
|
61
|
+
readonly AWAITING_APPROVAL: "awaiting_approval";
|
|
62
|
+
}>;
|
|
63
|
+
isManuallyTriggered: z.ZodBoolean;
|
|
64
|
+
startedAt: z.ZodString;
|
|
65
|
+
trigger: z.ZodObject<{
|
|
66
|
+
event: z.ZodString;
|
|
67
|
+
integration: z.ZodEnum<typeof import("./Integrations.js").IntegrationType>;
|
|
68
|
+
source: z.ZodString;
|
|
69
|
+
title: z.ZodOptional<z.ZodString>;
|
|
70
|
+
subheader: z.ZodOptional<z.ZodString>;
|
|
71
|
+
url: z.ZodOptional<z.ZodString>;
|
|
72
|
+
}, z.core.$strip>;
|
|
73
|
+
}, z.core.$strip>;
|
|
74
|
+
}, z.core.$strip>;
|
|
75
|
+
export type AutomationRanEvent = z.infer<typeof automationRanEventSchema>;
|
|
76
|
+
export declare const domainEventSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
77
|
+
eventType: z.ZodLiteral<"JOB_CREATED">;
|
|
78
|
+
jobId: z.ZodString;
|
|
79
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
80
|
+
eventType: z.ZodLiteral<"AUTOMATION_RAN">;
|
|
81
|
+
automation: z.ZodObject<{
|
|
82
|
+
id: z.ZodString;
|
|
83
|
+
name: z.ZodString;
|
|
84
|
+
organizationId: z.ZodString;
|
|
85
|
+
projectId: z.ZodString;
|
|
86
|
+
userId: z.ZodString;
|
|
87
|
+
requireApproval: z.ZodBoolean;
|
|
88
|
+
}, z.core.$strip>;
|
|
89
|
+
run: z.ZodObject<{
|
|
90
|
+
id: z.ZodString;
|
|
91
|
+
status: z.ZodEnum<{
|
|
92
|
+
readonly SUCCESS: "success";
|
|
93
|
+
readonly FAILED: "failed";
|
|
94
|
+
readonly CANCELLED: "cancelled";
|
|
95
|
+
readonly SKIPPED: "skipped";
|
|
96
|
+
readonly IN_PROGRESS: "in_progress";
|
|
97
|
+
readonly AWAITING_APPROVAL: "awaiting_approval";
|
|
98
|
+
}>;
|
|
99
|
+
isManuallyTriggered: z.ZodBoolean;
|
|
100
|
+
startedAt: z.ZodString;
|
|
101
|
+
trigger: z.ZodObject<{
|
|
102
|
+
event: z.ZodString;
|
|
103
|
+
integration: z.ZodEnum<typeof import("./Integrations.js").IntegrationType>;
|
|
104
|
+
source: z.ZodString;
|
|
105
|
+
title: z.ZodOptional<z.ZodString>;
|
|
106
|
+
subheader: z.ZodOptional<z.ZodString>;
|
|
107
|
+
url: z.ZodOptional<z.ZodString>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
}, z.core.$strip>], "eventType">;
|
|
111
|
+
export type DomainEvent = z.infer<typeof domainEventSchema>;
|
|
112
|
+
export {};
|
package/dist/Events.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { runHistoryStatusSchema } from "./RunHistoryTypes.js";
|
|
3
|
+
import { runHistoryTriggerSchema } from "./types.js";
|
|
4
|
+
export const eventTypeSchema = z.enum(["JOB_CREATED", "AUTOMATION_RAN"]);
|
|
5
|
+
const baseEventSchema = z.object({
|
|
6
|
+
eventType: eventTypeSchema
|
|
7
|
+
});
|
|
8
|
+
const jobCreatedEventSchema = baseEventSchema.extend({
|
|
9
|
+
eventType: z.literal("JOB_CREATED"),
|
|
10
|
+
jobId: z.string()
|
|
11
|
+
});
|
|
12
|
+
const automationSnapshotSchema = z.object({
|
|
13
|
+
id: z.string(),
|
|
14
|
+
name: z.string(),
|
|
15
|
+
organizationId: z.string(),
|
|
16
|
+
projectId: z.string(),
|
|
17
|
+
userId: z.string(),
|
|
18
|
+
requireApproval: z.boolean()
|
|
19
|
+
});
|
|
20
|
+
const runSnapshotSchema = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
status: runHistoryStatusSchema,
|
|
23
|
+
isManuallyTriggered: z.boolean(),
|
|
24
|
+
startedAt: z.string().datetime(),
|
|
25
|
+
trigger: runHistoryTriggerSchema
|
|
26
|
+
});
|
|
27
|
+
const automationRanEventSchema = baseEventSchema.extend({
|
|
28
|
+
eventType: z.literal("AUTOMATION_RAN"),
|
|
29
|
+
automation: automationSnapshotSchema,
|
|
30
|
+
run: runSnapshotSchema
|
|
31
|
+
});
|
|
32
|
+
export const domainEventSchema = z.discriminatedUnion("eventType", [jobCreatedEventSchema, automationRanEventSchema]);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { z } from "zod";
|
|
2
|
+
/**
|
|
3
|
+
* Maps every SDK trigger payload type name to how a readable TypeScript
|
|
4
|
+
* projection of it can be generated (`terse generate` inlines these into
|
|
5
|
+
* terse.generated.ts). Keep entries in sync when adding or widening triggers.
|
|
6
|
+
*/
|
|
7
|
+
export declare const triggerPayloadProjections: Readonly<Record<string, TriggerPayloadProjection>>;
|
|
8
|
+
interface TriggerPayloadSchemaProjection {
|
|
9
|
+
readonly kind: "schema";
|
|
10
|
+
readonly schema: z.core.$ZodType;
|
|
11
|
+
readonly typeParams?: string;
|
|
12
|
+
readonly fieldTypes?: Readonly<Record<string, string>>;
|
|
13
|
+
readonly importTypes?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
interface TriggerPayloadUnionProjection {
|
|
16
|
+
readonly kind: "union";
|
|
17
|
+
readonly members: readonly string[];
|
|
18
|
+
}
|
|
19
|
+
export type TriggerPayloadProjection = TriggerPayloadSchemaProjection | TriggerPayloadUnionProjection;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { GithubIssueCommentCreatedTriggerSchema, GithubPRClosedTriggerSchema, GithubPRMergedTriggerSchema, GithubPROpenedTriggerSchema, GithubPRSynchronizedTriggerSchema, GithubPushTriggerSchema, cronTriggerSchema, gmailTriggerSchema, heyReachCampaignCompletedTriggerSchema, heyReachConnectionRequestAcceptedTriggerSchema, heyReachConnectionRequestSentTriggerSchema, heyReachFollowSentTriggerSchema, heyReachInmailReplyReceivedTriggerSchema, heyReachInmailSentTriggerSchema, heyReachLeadTagUpdatedTriggerSchema, heyReachLikedPostTriggerSchema, heyReachMessageReplyReceivedTriggerSchema, heyReachMessageSentTriggerSchema, heyReachViewedProfileTriggerSchema, linearCommentCreatedTriggerSchema, linearIssueCreatedTriggerSchema, linearIssueUpdatedTriggerSchema, slackAppMentionTriggerSchema, slackMessageTriggerSchema, slackReactionAddedTriggerSchema, webMonitorTriggerSchema, webhookTriggerSchema, workOSInvitationAcceptedTriggerSchema, workOSInvitationCreatedTriggerSchema, workOSInvitationResentTriggerSchema, workOSInvitationRevokedTriggerSchema, workOSOrganizationMembershipCreatedTriggerSchema, workOSOrganizationMembershipDeletedTriggerSchema, workOSOrganizationMembershipUpdatedTriggerSchema, workOSOrganizationTriggerSchema, workOSUserCreatedTriggerSchema, workOSUserDeletedTriggerSchema, workOSUserUpdatedTriggerSchema } from "./Triggers.js";
|
|
2
|
+
const slackWidenedFields = {
|
|
3
|
+
fieldTypes: { blocks: "SlackBlocks | null", attachments: "SlackAttachments | null", files: "SlackFiles | null" },
|
|
4
|
+
importTypes: ["SlackBlocks", "SlackAttachments", "SlackFiles"]
|
|
5
|
+
};
|
|
6
|
+
// TS enums are nominal: projecting integrationType as its string literal would not satisfy `extends Trigger`,
|
|
7
|
+
// so schema projections print the enum member expression instead.
|
|
8
|
+
function integrationTypeEnumKey(schema) {
|
|
9
|
+
if (!(schema instanceof z.ZodObject))
|
|
10
|
+
return undefined;
|
|
11
|
+
const integrationType = schema.shape.integrationType;
|
|
12
|
+
if (!(integrationType instanceof z.ZodLiteral))
|
|
13
|
+
return undefined;
|
|
14
|
+
const entry = Object.entries(IntegrationType).find(([, value]) => value === integrationType.value);
|
|
15
|
+
return entry?.[0];
|
|
16
|
+
}
|
|
17
|
+
function schemaProjection(schema, extras = {}) {
|
|
18
|
+
const enumKey = integrationTypeEnumKey(schema);
|
|
19
|
+
return {
|
|
20
|
+
kind: "schema",
|
|
21
|
+
schema,
|
|
22
|
+
typeParams: extras.typeParams,
|
|
23
|
+
fieldTypes: { ...(enumKey ? { integrationType: `IntegrationType.${enumKey}` } : {}), ...extras.fieldTypes },
|
|
24
|
+
importTypes: [...(enumKey ? ["IntegrationType"] : []), ...(extras.importTypes ?? [])]
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Maps every SDK trigger payload type name to how a readable TypeScript
|
|
29
|
+
* projection of it can be generated (`terse generate` inlines these into
|
|
30
|
+
* terse.generated.ts). Keep entries in sync when adding or widening triggers.
|
|
31
|
+
*/
|
|
32
|
+
export const triggerPayloadProjections = {
|
|
33
|
+
SlackMessageTrigger: schemaProjection(slackMessageTriggerSchema, slackWidenedFields),
|
|
34
|
+
SlackAppMentionTrigger: schemaProjection(slackAppMentionTriggerSchema, slackWidenedFields),
|
|
35
|
+
SlackReactionAddedTrigger: schemaProjection(slackReactionAddedTriggerSchema, slackWidenedFields),
|
|
36
|
+
SlackTrigger: { kind: "union", members: ["SlackMessageTrigger", "SlackAppMentionTrigger", "SlackReactionAddedTrigger"] },
|
|
37
|
+
GithubPushTrigger: schemaProjection(GithubPushTriggerSchema),
|
|
38
|
+
GithubPROpenedTrigger: schemaProjection(GithubPROpenedTriggerSchema),
|
|
39
|
+
GithubPRSynchronizedTrigger: schemaProjection(GithubPRSynchronizedTriggerSchema),
|
|
40
|
+
GithubPRClosedTrigger: schemaProjection(GithubPRClosedTriggerSchema),
|
|
41
|
+
GithubPRMergedTrigger: schemaProjection(GithubPRMergedTriggerSchema),
|
|
42
|
+
GithubIssueCommentCreatedTrigger: schemaProjection(GithubIssueCommentCreatedTriggerSchema),
|
|
43
|
+
GithubPRTrigger: { kind: "union", members: ["GithubPROpenedTrigger", "GithubPRSynchronizedTrigger", "GithubPRClosedTrigger", "GithubPRMergedTrigger"] },
|
|
44
|
+
GithubTrigger: {
|
|
45
|
+
kind: "union",
|
|
46
|
+
members: ["GithubPushTrigger", "GithubPROpenedTrigger", "GithubPRSynchronizedTrigger", "GithubPRClosedTrigger", "GithubPRMergedTrigger", "GithubIssueCommentCreatedTrigger"]
|
|
47
|
+
},
|
|
48
|
+
GmailTrigger: schemaProjection(gmailTriggerSchema),
|
|
49
|
+
LinearIssueCreatedTrigger: schemaProjection(linearIssueCreatedTriggerSchema),
|
|
50
|
+
LinearIssueUpdatedTrigger: schemaProjection(linearIssueUpdatedTriggerSchema),
|
|
51
|
+
LinearCommentCreatedTrigger: schemaProjection(linearCommentCreatedTriggerSchema),
|
|
52
|
+
LinearTrigger: { kind: "union", members: ["LinearIssueCreatedTrigger", "LinearIssueUpdatedTrigger", "LinearCommentCreatedTrigger"] },
|
|
53
|
+
WorkOSUserCreatedTrigger: schemaProjection(workOSUserCreatedTriggerSchema),
|
|
54
|
+
WorkOSUserUpdatedTrigger: schemaProjection(workOSUserUpdatedTriggerSchema),
|
|
55
|
+
WorkOSUserDeletedTrigger: schemaProjection(workOSUserDeletedTriggerSchema),
|
|
56
|
+
WorkOSUserTrigger: { kind: "union", members: ["WorkOSUserCreatedTrigger", "WorkOSUserUpdatedTrigger", "WorkOSUserDeletedTrigger"] },
|
|
57
|
+
WorkOSOrganizationMembershipCreatedTrigger: schemaProjection(workOSOrganizationMembershipCreatedTriggerSchema),
|
|
58
|
+
WorkOSOrganizationMembershipUpdatedTrigger: schemaProjection(workOSOrganizationMembershipUpdatedTriggerSchema),
|
|
59
|
+
WorkOSOrganizationMembershipDeletedTrigger: schemaProjection(workOSOrganizationMembershipDeletedTriggerSchema),
|
|
60
|
+
WorkOSMembershipTrigger: {
|
|
61
|
+
kind: "union",
|
|
62
|
+
members: ["WorkOSOrganizationMembershipCreatedTrigger", "WorkOSOrganizationMembershipUpdatedTrigger", "WorkOSOrganizationMembershipDeletedTrigger"]
|
|
63
|
+
},
|
|
64
|
+
WorkOSInvitationCreatedTrigger: schemaProjection(workOSInvitationCreatedTriggerSchema),
|
|
65
|
+
WorkOSInvitationAcceptedTrigger: schemaProjection(workOSInvitationAcceptedTriggerSchema),
|
|
66
|
+
WorkOSInvitationResentTrigger: schemaProjection(workOSInvitationResentTriggerSchema),
|
|
67
|
+
WorkOSInvitationRevokedTrigger: schemaProjection(workOSInvitationRevokedTriggerSchema),
|
|
68
|
+
WorkOSInvitationTrigger: {
|
|
69
|
+
kind: "union",
|
|
70
|
+
members: ["WorkOSInvitationCreatedTrigger", "WorkOSInvitationAcceptedTrigger", "WorkOSInvitationResentTrigger", "WorkOSInvitationRevokedTrigger"]
|
|
71
|
+
},
|
|
72
|
+
WorkOSOrganizationTrigger: schemaProjection(workOSOrganizationTriggerSchema),
|
|
73
|
+
WorkOSTrigger: {
|
|
74
|
+
kind: "union",
|
|
75
|
+
members: [
|
|
76
|
+
"WorkOSUserCreatedTrigger",
|
|
77
|
+
"WorkOSUserUpdatedTrigger",
|
|
78
|
+
"WorkOSUserDeletedTrigger",
|
|
79
|
+
"WorkOSOrganizationMembershipCreatedTrigger",
|
|
80
|
+
"WorkOSOrganizationMembershipUpdatedTrigger",
|
|
81
|
+
"WorkOSOrganizationMembershipDeletedTrigger",
|
|
82
|
+
"WorkOSInvitationCreatedTrigger",
|
|
83
|
+
"WorkOSInvitationAcceptedTrigger",
|
|
84
|
+
"WorkOSInvitationResentTrigger",
|
|
85
|
+
"WorkOSInvitationRevokedTrigger",
|
|
86
|
+
"WorkOSOrganizationTrigger"
|
|
87
|
+
]
|
|
88
|
+
},
|
|
89
|
+
HeyReachConnectionRequestSentTrigger: schemaProjection(heyReachConnectionRequestSentTriggerSchema),
|
|
90
|
+
HeyReachConnectionRequestAcceptedTrigger: schemaProjection(heyReachConnectionRequestAcceptedTriggerSchema),
|
|
91
|
+
HeyReachMessageSentTrigger: schemaProjection(heyReachMessageSentTriggerSchema),
|
|
92
|
+
HeyReachMessageReplyReceivedTrigger: schemaProjection(heyReachMessageReplyReceivedTriggerSchema),
|
|
93
|
+
HeyReachInmailSentTrigger: schemaProjection(heyReachInmailSentTriggerSchema),
|
|
94
|
+
HeyReachInmailReplyReceivedTrigger: schemaProjection(heyReachInmailReplyReceivedTriggerSchema),
|
|
95
|
+
HeyReachFollowSentTrigger: schemaProjection(heyReachFollowSentTriggerSchema),
|
|
96
|
+
HeyReachLikedPostTrigger: schemaProjection(heyReachLikedPostTriggerSchema),
|
|
97
|
+
HeyReachViewedProfileTrigger: schemaProjection(heyReachViewedProfileTriggerSchema),
|
|
98
|
+
HeyReachCampaignCompletedTrigger: schemaProjection(heyReachCampaignCompletedTriggerSchema),
|
|
99
|
+
HeyReachLeadTagUpdatedTrigger: schemaProjection(heyReachLeadTagUpdatedTriggerSchema),
|
|
100
|
+
HeyReachTrigger: {
|
|
101
|
+
kind: "union",
|
|
102
|
+
members: [
|
|
103
|
+
"HeyReachConnectionRequestSentTrigger",
|
|
104
|
+
"HeyReachConnectionRequestAcceptedTrigger",
|
|
105
|
+
"HeyReachMessageSentTrigger",
|
|
106
|
+
"HeyReachMessageReplyReceivedTrigger",
|
|
107
|
+
"HeyReachInmailSentTrigger",
|
|
108
|
+
"HeyReachInmailReplyReceivedTrigger",
|
|
109
|
+
"HeyReachFollowSentTrigger",
|
|
110
|
+
"HeyReachLikedPostTrigger",
|
|
111
|
+
"HeyReachViewedProfileTrigger",
|
|
112
|
+
"HeyReachCampaignCompletedTrigger",
|
|
113
|
+
"HeyReachLeadTagUpdatedTrigger"
|
|
114
|
+
]
|
|
115
|
+
},
|
|
116
|
+
CronTrigger: schemaProjection(cronTriggerSchema),
|
|
117
|
+
WebhookTrigger: schemaProjection(webhookTriggerSchema, { typeParams: "<TBody = unknown>", fieldTypes: { body: "TBody" } }),
|
|
118
|
+
WebMonitorTrigger: schemaProjection(webMonitorTriggerSchema, { typeParams: "<TPayload = string>", fieldTypes: { payload: "TPayload" } })
|
|
119
|
+
};
|