@automate.ax/integration-contracts 0.121.0 → 0.122.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/dist/google-drive/index.d.ts +1044 -0
- package/dist/google-drive/index.js +188 -0
- package/dist/linear/schemas.d.ts +1 -1
- package/dist/triggers.d.ts +2 -1
- package/package.json +9 -3
- package/src/google-drive/index.ts +329 -0
- package/src/triggers.ts +2 -0
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const GOOGLE_DRIVE_TRIGGER_CONFIG_SCHEMA = z.object({
|
|
3
|
+
includeDescendants: z.boolean().optional(),
|
|
4
|
+
resourceId: z.string().min(1),
|
|
5
|
+
resourceType: z.enum(["file", "drive"]),
|
|
6
|
+
});
|
|
7
|
+
const GOOGLE_DRIVE_ACTION_SCHEMA = z.enum([
|
|
8
|
+
"cancelled",
|
|
9
|
+
"completed",
|
|
10
|
+
"contentChanged",
|
|
11
|
+
"created",
|
|
12
|
+
"deleted",
|
|
13
|
+
"edited",
|
|
14
|
+
"moved",
|
|
15
|
+
"reopened",
|
|
16
|
+
"renamed",
|
|
17
|
+
"reset",
|
|
18
|
+
"resolved",
|
|
19
|
+
"responded",
|
|
20
|
+
"reviewersChanged",
|
|
21
|
+
"trashed",
|
|
22
|
+
"untrashed",
|
|
23
|
+
]);
|
|
24
|
+
const GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA = z.enum([
|
|
25
|
+
"accessProposal",
|
|
26
|
+
"approval",
|
|
27
|
+
"comment",
|
|
28
|
+
"file",
|
|
29
|
+
"permission",
|
|
30
|
+
"reply",
|
|
31
|
+
]);
|
|
32
|
+
const GOOGLE_DRIVE_EVENT_BASE_SCHEMA = z.object({
|
|
33
|
+
action: GOOGLE_DRIVE_ACTION_SCHEMA,
|
|
34
|
+
assigneeEmailAddress: z.email().optional(),
|
|
35
|
+
commentId: z.string().optional(),
|
|
36
|
+
dueAt: z.date().optional(),
|
|
37
|
+
eventId: z.string(),
|
|
38
|
+
eventType: z.string(),
|
|
39
|
+
fileId: z.string().min(1),
|
|
40
|
+
initiatorEmailAddress: z.email().optional(),
|
|
41
|
+
mentionedEmailAddresses: z.email().array(),
|
|
42
|
+
mimeType: z.string().optional(),
|
|
43
|
+
occurredAt: z.date(),
|
|
44
|
+
parentId: z.string().optional(),
|
|
45
|
+
previousParentId: z.string().optional(),
|
|
46
|
+
resourceId: z.string().optional(),
|
|
47
|
+
resourceIds: z.string().array(),
|
|
48
|
+
resourceType: GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA,
|
|
49
|
+
reviewerEmailAddresses: z.email().array(),
|
|
50
|
+
reviewerResponse: z.string().optional(),
|
|
51
|
+
status: z.string().optional(),
|
|
52
|
+
version: z.string().optional(),
|
|
53
|
+
});
|
|
54
|
+
const GOOGLE_DRIVE_TRIGGER_TYPES = [
|
|
55
|
+
"googleDrive.accessProposal.created",
|
|
56
|
+
"googleDrive.accessProposal.resolved",
|
|
57
|
+
"googleDrive.approval.cancelled",
|
|
58
|
+
"googleDrive.approval.completed",
|
|
59
|
+
"googleDrive.approval.created",
|
|
60
|
+
"googleDrive.approval.reset",
|
|
61
|
+
"googleDrive.approval.responded",
|
|
62
|
+
"googleDrive.approval.reviewersChanged",
|
|
63
|
+
"googleDrive.comment.created",
|
|
64
|
+
"googleDrive.comment.deleted",
|
|
65
|
+
"googleDrive.comment.edited",
|
|
66
|
+
"googleDrive.comment.reopened",
|
|
67
|
+
"googleDrive.comment.resolved",
|
|
68
|
+
"googleDrive.file.contentChanged",
|
|
69
|
+
"googleDrive.file.created",
|
|
70
|
+
"googleDrive.file.deleted",
|
|
71
|
+
"googleDrive.file.moved",
|
|
72
|
+
"googleDrive.file.renamed",
|
|
73
|
+
"googleDrive.file.trashed",
|
|
74
|
+
"googleDrive.file.untrashed",
|
|
75
|
+
"googleDrive.permission.created",
|
|
76
|
+
"googleDrive.permission.deleted",
|
|
77
|
+
"googleDrive.permission.edited",
|
|
78
|
+
"googleDrive.reply.created",
|
|
79
|
+
"googleDrive.reply.deleted",
|
|
80
|
+
"googleDrive.reply.edited",
|
|
81
|
+
];
|
|
82
|
+
export const GOOGLE_DRIVE_PROVIDER_EVENT_TYPES = {
|
|
83
|
+
"googleDrive.accessProposal.created": "google.workspace.drive.accessproposal.v3.created",
|
|
84
|
+
"googleDrive.accessProposal.resolved": "google.workspace.drive.accessproposal.v3.resolved",
|
|
85
|
+
"googleDrive.approval.cancelled": "google.workspace.drive.approval.v3.cancelled",
|
|
86
|
+
"googleDrive.approval.completed": "google.workspace.drive.approval.v3.completed",
|
|
87
|
+
"googleDrive.approval.created": "google.workspace.drive.approval.v3.created",
|
|
88
|
+
"googleDrive.approval.reset": "google.workspace.drive.approval.v3.reset",
|
|
89
|
+
"googleDrive.approval.responded": "google.workspace.drive.approval.v3.responded",
|
|
90
|
+
"googleDrive.approval.reviewersChanged": "google.workspace.drive.approval.v3.reviewersChanged",
|
|
91
|
+
"googleDrive.comment.created": "google.workspace.drive.comment.v3.created",
|
|
92
|
+
"googleDrive.comment.deleted": "google.workspace.drive.comment.v3.deleted",
|
|
93
|
+
"googleDrive.comment.edited": "google.workspace.drive.comment.v3.edited",
|
|
94
|
+
"googleDrive.comment.reopened": "google.workspace.drive.comment.v3.reopened",
|
|
95
|
+
"googleDrive.comment.resolved": "google.workspace.drive.comment.v3.resolved",
|
|
96
|
+
"googleDrive.file.contentChanged": "google.workspace.drive.file.v3.contentChanged",
|
|
97
|
+
"googleDrive.file.created": "google.workspace.drive.file.v3.created",
|
|
98
|
+
"googleDrive.file.deleted": "google.workspace.drive.file.v3.deleted",
|
|
99
|
+
"googleDrive.file.moved": "google.workspace.drive.file.v3.moved",
|
|
100
|
+
"googleDrive.file.renamed": "google.workspace.drive.file.v3.renamed",
|
|
101
|
+
"googleDrive.file.trashed": "google.workspace.drive.file.v3.trashed",
|
|
102
|
+
"googleDrive.file.untrashed": "google.workspace.drive.file.v3.untrashed",
|
|
103
|
+
"googleDrive.permission.created": "google.workspace.drive.permission.v3.created",
|
|
104
|
+
"googleDrive.permission.deleted": "google.workspace.drive.permission.v3.deleted",
|
|
105
|
+
"googleDrive.permission.edited": "google.workspace.drive.permission.v3.edited",
|
|
106
|
+
"googleDrive.reply.created": "google.workspace.drive.reply.v3.created",
|
|
107
|
+
"googleDrive.reply.deleted": "google.workspace.drive.reply.v3.deleted",
|
|
108
|
+
"googleDrive.reply.edited": "google.workspace.drive.reply.v3.edited",
|
|
109
|
+
};
|
|
110
|
+
export const GOOGLE_DRIVE_EVENT_SCHEMA = GOOGLE_DRIVE_EVENT_BASE_SCHEMA.extend({
|
|
111
|
+
eventType: z.enum(GOOGLE_DRIVE_TRIGGER_TYPES),
|
|
112
|
+
});
|
|
113
|
+
/**
|
|
114
|
+
* Builds one semantic Drive trigger contract with literal discriminants.
|
|
115
|
+
*
|
|
116
|
+
* @param eventType - Exact internal event type.
|
|
117
|
+
* @param resourceType - Exact event resource family.
|
|
118
|
+
* @param action - Exact event action.
|
|
119
|
+
*/
|
|
120
|
+
function googleDriveSemanticTriggerContract(eventType, resourceType, action) {
|
|
121
|
+
return {
|
|
122
|
+
configSchema: GOOGLE_DRIVE_TRIGGER_CONFIG_SCHEMA,
|
|
123
|
+
eventSchema: GOOGLE_DRIVE_EVENT_BASE_SCHEMA.extend({
|
|
124
|
+
action: z.literal(action),
|
|
125
|
+
eventType: z.literal(eventType),
|
|
126
|
+
resourceType: z.literal(resourceType),
|
|
127
|
+
}),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/** Exact semantic trigger contract map used by authoring inference. */
|
|
131
|
+
const googleDriveSemanticTriggerContracts = {
|
|
132
|
+
"googleDrive.accessProposal.created": googleDriveSemanticTriggerContract("googleDrive.accessProposal.created", "accessProposal", "created"),
|
|
133
|
+
"googleDrive.accessProposal.resolved": googleDriveSemanticTriggerContract("googleDrive.accessProposal.resolved", "accessProposal", "resolved"),
|
|
134
|
+
"googleDrive.approval.cancelled": googleDriveSemanticTriggerContract("googleDrive.approval.cancelled", "approval", "cancelled"),
|
|
135
|
+
"googleDrive.approval.completed": googleDriveSemanticTriggerContract("googleDrive.approval.completed", "approval", "completed"),
|
|
136
|
+
"googleDrive.approval.created": googleDriveSemanticTriggerContract("googleDrive.approval.created", "approval", "created"),
|
|
137
|
+
"googleDrive.approval.reset": googleDriveSemanticTriggerContract("googleDrive.approval.reset", "approval", "reset"),
|
|
138
|
+
"googleDrive.approval.responded": googleDriveSemanticTriggerContract("googleDrive.approval.responded", "approval", "responded"),
|
|
139
|
+
"googleDrive.approval.reviewersChanged": googleDriveSemanticTriggerContract("googleDrive.approval.reviewersChanged", "approval", "reviewersChanged"),
|
|
140
|
+
"googleDrive.comment.created": googleDriveSemanticTriggerContract("googleDrive.comment.created", "comment", "created"),
|
|
141
|
+
"googleDrive.comment.deleted": googleDriveSemanticTriggerContract("googleDrive.comment.deleted", "comment", "deleted"),
|
|
142
|
+
"googleDrive.comment.edited": googleDriveSemanticTriggerContract("googleDrive.comment.edited", "comment", "edited"),
|
|
143
|
+
"googleDrive.comment.reopened": googleDriveSemanticTriggerContract("googleDrive.comment.reopened", "comment", "reopened"),
|
|
144
|
+
"googleDrive.comment.resolved": googleDriveSemanticTriggerContract("googleDrive.comment.resolved", "comment", "resolved"),
|
|
145
|
+
"googleDrive.file.contentChanged": googleDriveSemanticTriggerContract("googleDrive.file.contentChanged", "file", "contentChanged"),
|
|
146
|
+
"googleDrive.file.created": googleDriveSemanticTriggerContract("googleDrive.file.created", "file", "created"),
|
|
147
|
+
"googleDrive.file.deleted": googleDriveSemanticTriggerContract("googleDrive.file.deleted", "file", "deleted"),
|
|
148
|
+
"googleDrive.file.moved": googleDriveSemanticTriggerContract("googleDrive.file.moved", "file", "moved"),
|
|
149
|
+
"googleDrive.file.renamed": googleDriveSemanticTriggerContract("googleDrive.file.renamed", "file", "renamed"),
|
|
150
|
+
"googleDrive.file.trashed": googleDriveSemanticTriggerContract("googleDrive.file.trashed", "file", "trashed"),
|
|
151
|
+
"googleDrive.file.untrashed": googleDriveSemanticTriggerContract("googleDrive.file.untrashed", "file", "untrashed"),
|
|
152
|
+
"googleDrive.permission.created": googleDriveSemanticTriggerContract("googleDrive.permission.created", "permission", "created"),
|
|
153
|
+
"googleDrive.permission.deleted": googleDriveSemanticTriggerContract("googleDrive.permission.deleted", "permission", "deleted"),
|
|
154
|
+
"googleDrive.permission.edited": googleDriveSemanticTriggerContract("googleDrive.permission.edited", "permission", "edited"),
|
|
155
|
+
"googleDrive.reply.created": googleDriveSemanticTriggerContract("googleDrive.reply.created", "reply", "created"),
|
|
156
|
+
"googleDrive.reply.deleted": googleDriveSemanticTriggerContract("googleDrive.reply.deleted", "reply", "deleted"),
|
|
157
|
+
"googleDrive.reply.edited": googleDriveSemanticTriggerContract("googleDrive.reply.edited", "reply", "edited"),
|
|
158
|
+
};
|
|
159
|
+
export const googleDriveTriggerContracts = {
|
|
160
|
+
"googleDrive.event": {
|
|
161
|
+
configSchema: GOOGLE_DRIVE_TRIGGER_CONFIG_SCHEMA,
|
|
162
|
+
eventSchema: GOOGLE_DRIVE_EVENT_SCHEMA,
|
|
163
|
+
},
|
|
164
|
+
...googleDriveSemanticTriggerContracts,
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Resolves an internal semantic event type from a provider CloudEvent type.
|
|
168
|
+
*
|
|
169
|
+
* @param providerEventType - Provider CloudEvent type.
|
|
170
|
+
*/
|
|
171
|
+
export function toGoogleDriveTriggerType(providerEventType) {
|
|
172
|
+
// Keep the candidate separate so Zod performs the only narrowing.
|
|
173
|
+
const candidate = Object.entries(GOOGLE_DRIVE_PROVIDER_EVENT_TYPES).find(([, value]) => value === providerEventType)?.[0];
|
|
174
|
+
const result = z.enum(GOOGLE_DRIVE_TRIGGER_TYPES).safeParse(candidate);
|
|
175
|
+
return result.success ? result.data : undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Splits one internal event type into its resource and action discriminants.
|
|
179
|
+
*
|
|
180
|
+
* @param eventType - Stable internal semantic event type.
|
|
181
|
+
*/
|
|
182
|
+
export function parseGoogleDriveTriggerType(eventType) {
|
|
183
|
+
const [, resourceType, ...actionParts] = eventType.split(".");
|
|
184
|
+
return {
|
|
185
|
+
action: GOOGLE_DRIVE_ACTION_SCHEMA.parse(actionParts.join(".")),
|
|
186
|
+
resourceType: GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA.parse(resourceType),
|
|
187
|
+
};
|
|
188
|
+
}
|
package/dist/linear/schemas.d.ts
CHANGED
|
@@ -4519,12 +4519,12 @@ export declare const LINEAR_PROVIDER_ISSUE_SCHEMA: z.ZodObject<{
|
|
|
4519
4519
|
id: z.ZodString;
|
|
4520
4520
|
name: z.ZodString;
|
|
4521
4521
|
}, z.core.$strip>>;
|
|
4522
|
+
trashed: z.ZodNullable<z.ZodBoolean>;
|
|
4522
4523
|
archivedAt: z.ZodNullable<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>]>>;
|
|
4523
4524
|
identifier: z.ZodString;
|
|
4524
4525
|
canceledAt: z.ZodNullable<z.ZodUnion<readonly [z.ZodDate, z.ZodPipe<z.ZodISODateTime, z.ZodTransform<Date, string>>]>>;
|
|
4525
4526
|
estimate: z.ZodNullable<z.ZodNumber>;
|
|
4526
4527
|
priorityLabel: z.ZodString;
|
|
4527
|
-
trashed: z.ZodNullable<z.ZodBoolean>;
|
|
4528
4528
|
branchName: z.ZodString;
|
|
4529
4529
|
delegate: z.ZodNullable<z.ZodObject<{
|
|
4530
4530
|
active: z.ZodBoolean;
|
package/dist/triggers.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { cloudflareTriggerContracts } from "./cloudflare/index.js";
|
|
|
8
8
|
import type { githubTriggerContracts } from "./github/index.js";
|
|
9
9
|
import type { gmailTriggerContracts } from "./gmail/index.js";
|
|
10
10
|
import type { googleCalendarTriggerContracts } from "./google-calendar/index.js";
|
|
11
|
+
import type { googleDriveTriggerContracts } from "./google-drive/index.js";
|
|
11
12
|
import type { googleFormsTriggerContracts } from "./google-forms/index.js";
|
|
12
13
|
import type { googleMeetTriggerContracts } from "./google-meet/index.js";
|
|
13
14
|
import type { googleSheetsTriggerContracts } from "./google-sheets/index.js";
|
|
@@ -25,7 +26,7 @@ import type { vercelTriggerContracts } from "./vercel/index.js";
|
|
|
25
26
|
import type { webflowTriggerContracts } from "./webflow/index.js";
|
|
26
27
|
import type { whatsappTriggerContracts } from "./whatsapp/index.js";
|
|
27
28
|
import type { z } from "zod";
|
|
28
|
-
export type TriggerContractMap = typeof airtableTriggerContracts & typeof automateTriggerContracts & typeof asanaTriggerContracts & typeof brevoTriggerContracts & typeof convexTriggerContracts & typeof closeTriggerContracts & typeof cloudflareTriggerContracts & typeof githubTriggerContracts & typeof gmailTriggerContracts & typeof googleCalendarTriggerContracts & typeof googleFormsTriggerContracts & typeof googleMeetTriggerContracts & typeof googleSheetsTriggerContracts & typeof hubspotTriggerContracts & typeof linearTriggerContracts & typeof millionVerifierTriggerContracts & typeof notionTriggerContracts & typeof outlookTriggerContracts & typeof resendTriggerContracts & typeof slackTriggerContracts & typeof stripeTriggerContracts & typeof teamsTriggerContracts & typeof trelloTriggerContracts & typeof vercelTriggerContracts & typeof webflowTriggerContracts & typeof whatsappTriggerContracts;
|
|
29
|
+
export type TriggerContractMap = typeof airtableTriggerContracts & typeof automateTriggerContracts & typeof asanaTriggerContracts & typeof brevoTriggerContracts & typeof convexTriggerContracts & typeof closeTriggerContracts & typeof cloudflareTriggerContracts & typeof githubTriggerContracts & typeof gmailTriggerContracts & typeof googleCalendarTriggerContracts & typeof googleDriveTriggerContracts & typeof googleFormsTriggerContracts & typeof googleMeetTriggerContracts & typeof googleSheetsTriggerContracts & typeof hubspotTriggerContracts & typeof linearTriggerContracts & typeof millionVerifierTriggerContracts & typeof notionTriggerContracts & typeof outlookTriggerContracts & typeof resendTriggerContracts & typeof slackTriggerContracts & typeof stripeTriggerContracts & typeof teamsTriggerContracts & typeof trelloTriggerContracts & typeof vercelTriggerContracts & typeof webflowTriggerContracts & typeof whatsappTriggerContracts;
|
|
29
30
|
export type IntegrationTriggerType = keyof TriggerContractMap;
|
|
30
31
|
/** Canonical authoring configuration for one integration trigger type. */
|
|
31
32
|
export type TriggerConfig<TType extends IntegrationTriggerType> = z.input<TriggerContractMap[TType]["configSchema"]> extends Record<string, never> ? object : z.input<TriggerContractMap[TType]["configSchema"]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automate.ax/integration-contracts",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.122.0",
|
|
4
4
|
"description": "Shared integration payload contracts and provider primitives for Automate.ax.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./close": "./src/close/index.ts",
|
|
28
28
|
"./gmail": "./src/gmail/index.ts",
|
|
29
29
|
"./google-calendar": "./src/google-calendar/index.ts",
|
|
30
|
+
"./google-drive": "./src/google-drive/index.ts",
|
|
30
31
|
"./google-forms": "./src/google-forms/index.ts",
|
|
31
32
|
"./google-meet": "./src/google-meet/index.ts",
|
|
32
33
|
"./google-sheets": "./src/google-sheets/index.ts",
|
|
@@ -54,7 +55,7 @@
|
|
|
54
55
|
}
|
|
55
56
|
},
|
|
56
57
|
"dependencies": {
|
|
57
|
-
"@automate.ax/codec": "0.
|
|
58
|
+
"@automate.ax/codec": "0.122.0",
|
|
58
59
|
"@cfworker/json-schema": "^4.1.1",
|
|
59
60
|
"@googleapis/calendar": "^15.0.0",
|
|
60
61
|
"@googleapis/forms": "^6.0.1",
|
|
@@ -87,7 +88,7 @@
|
|
|
87
88
|
},
|
|
88
89
|
"scripts": {
|
|
89
90
|
"generate:github": "bun scripts/generate-github-webhook-schemas.ts",
|
|
90
|
-
"typecheck": "tsc --noEmit",
|
|
91
|
+
"typecheck": "resource-broker run --pool automate-ax-validation --limit 2 --weight 1 -- tsc --noEmit",
|
|
91
92
|
"lint": "oxlint --type-aware --threads=2 && bun --bun eslint . --cache --cache-strategy content",
|
|
92
93
|
"lint:fix": "oxlint --type-aware --threads=2 --fix --fix-suggestions && bun --bun eslint . --fix --cache --cache-strategy content",
|
|
93
94
|
"check": "bun run typecheck && bun run lint",
|
|
@@ -150,6 +151,11 @@
|
|
|
150
151
|
"types": "./dist/google-calendar/index.d.ts",
|
|
151
152
|
"default": "./dist/google-calendar/index.js"
|
|
152
153
|
},
|
|
154
|
+
"./google-drive": {
|
|
155
|
+
"bun": "./src/google-drive/index.ts",
|
|
156
|
+
"types": "./dist/google-drive/index.d.ts",
|
|
157
|
+
"default": "./dist/google-drive/index.js"
|
|
158
|
+
},
|
|
153
159
|
"./google-forms": {
|
|
154
160
|
"bun": "./src/google-forms/index.ts",
|
|
155
161
|
"types": "./dist/google-forms/index.d.ts",
|
|
@@ -0,0 +1,329 @@
|
|
|
1
|
+
import { z } from "zod"
|
|
2
|
+
|
|
3
|
+
export const GOOGLE_DRIVE_TRIGGER_CONFIG_SCHEMA = z.object({
|
|
4
|
+
includeDescendants: z.boolean().optional(),
|
|
5
|
+
resourceId: z.string().min(1),
|
|
6
|
+
resourceType: z.enum(["file", "drive"]),
|
|
7
|
+
})
|
|
8
|
+
|
|
9
|
+
const GOOGLE_DRIVE_ACTION_SCHEMA = z.enum([
|
|
10
|
+
"cancelled",
|
|
11
|
+
"completed",
|
|
12
|
+
"contentChanged",
|
|
13
|
+
"created",
|
|
14
|
+
"deleted",
|
|
15
|
+
"edited",
|
|
16
|
+
"moved",
|
|
17
|
+
"reopened",
|
|
18
|
+
"renamed",
|
|
19
|
+
"reset",
|
|
20
|
+
"resolved",
|
|
21
|
+
"responded",
|
|
22
|
+
"reviewersChanged",
|
|
23
|
+
"trashed",
|
|
24
|
+
"untrashed",
|
|
25
|
+
])
|
|
26
|
+
|
|
27
|
+
const GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA = z.enum([
|
|
28
|
+
"accessProposal",
|
|
29
|
+
"approval",
|
|
30
|
+
"comment",
|
|
31
|
+
"file",
|
|
32
|
+
"permission",
|
|
33
|
+
"reply",
|
|
34
|
+
])
|
|
35
|
+
|
|
36
|
+
const GOOGLE_DRIVE_EVENT_BASE_SCHEMA = z.object({
|
|
37
|
+
action: GOOGLE_DRIVE_ACTION_SCHEMA,
|
|
38
|
+
assigneeEmailAddress: z.email().optional(),
|
|
39
|
+
commentId: z.string().optional(),
|
|
40
|
+
dueAt: z.date().optional(),
|
|
41
|
+
eventId: z.string(),
|
|
42
|
+
eventType: z.string(),
|
|
43
|
+
fileId: z.string().min(1),
|
|
44
|
+
initiatorEmailAddress: z.email().optional(),
|
|
45
|
+
mentionedEmailAddresses: z.email().array(),
|
|
46
|
+
mimeType: z.string().optional(),
|
|
47
|
+
occurredAt: z.date(),
|
|
48
|
+
parentId: z.string().optional(),
|
|
49
|
+
previousParentId: z.string().optional(),
|
|
50
|
+
resourceId: z.string().optional(),
|
|
51
|
+
resourceIds: z.string().array(),
|
|
52
|
+
resourceType: GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA,
|
|
53
|
+
reviewerEmailAddresses: z.email().array(),
|
|
54
|
+
reviewerResponse: z.string().optional(),
|
|
55
|
+
status: z.string().optional(),
|
|
56
|
+
version: z.string().optional(),
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
const GOOGLE_DRIVE_TRIGGER_TYPES = [
|
|
60
|
+
"googleDrive.accessProposal.created",
|
|
61
|
+
"googleDrive.accessProposal.resolved",
|
|
62
|
+
"googleDrive.approval.cancelled",
|
|
63
|
+
"googleDrive.approval.completed",
|
|
64
|
+
"googleDrive.approval.created",
|
|
65
|
+
"googleDrive.approval.reset",
|
|
66
|
+
"googleDrive.approval.responded",
|
|
67
|
+
"googleDrive.approval.reviewersChanged",
|
|
68
|
+
"googleDrive.comment.created",
|
|
69
|
+
"googleDrive.comment.deleted",
|
|
70
|
+
"googleDrive.comment.edited",
|
|
71
|
+
"googleDrive.comment.reopened",
|
|
72
|
+
"googleDrive.comment.resolved",
|
|
73
|
+
"googleDrive.file.contentChanged",
|
|
74
|
+
"googleDrive.file.created",
|
|
75
|
+
"googleDrive.file.deleted",
|
|
76
|
+
"googleDrive.file.moved",
|
|
77
|
+
"googleDrive.file.renamed",
|
|
78
|
+
"googleDrive.file.trashed",
|
|
79
|
+
"googleDrive.file.untrashed",
|
|
80
|
+
"googleDrive.permission.created",
|
|
81
|
+
"googleDrive.permission.deleted",
|
|
82
|
+
"googleDrive.permission.edited",
|
|
83
|
+
"googleDrive.reply.created",
|
|
84
|
+
"googleDrive.reply.deleted",
|
|
85
|
+
"googleDrive.reply.edited",
|
|
86
|
+
] as const
|
|
87
|
+
|
|
88
|
+
export type GoogleDriveTriggerType = (typeof GOOGLE_DRIVE_TRIGGER_TYPES)[number]
|
|
89
|
+
|
|
90
|
+
export const GOOGLE_DRIVE_PROVIDER_EVENT_TYPES = {
|
|
91
|
+
"googleDrive.accessProposal.created":
|
|
92
|
+
"google.workspace.drive.accessproposal.v3.created",
|
|
93
|
+
"googleDrive.accessProposal.resolved":
|
|
94
|
+
"google.workspace.drive.accessproposal.v3.resolved",
|
|
95
|
+
"googleDrive.approval.cancelled":
|
|
96
|
+
"google.workspace.drive.approval.v3.cancelled",
|
|
97
|
+
"googleDrive.approval.completed":
|
|
98
|
+
"google.workspace.drive.approval.v3.completed",
|
|
99
|
+
"googleDrive.approval.created": "google.workspace.drive.approval.v3.created",
|
|
100
|
+
"googleDrive.approval.reset": "google.workspace.drive.approval.v3.reset",
|
|
101
|
+
"googleDrive.approval.responded":
|
|
102
|
+
"google.workspace.drive.approval.v3.responded",
|
|
103
|
+
"googleDrive.approval.reviewersChanged":
|
|
104
|
+
"google.workspace.drive.approval.v3.reviewersChanged",
|
|
105
|
+
"googleDrive.comment.created": "google.workspace.drive.comment.v3.created",
|
|
106
|
+
"googleDrive.comment.deleted": "google.workspace.drive.comment.v3.deleted",
|
|
107
|
+
"googleDrive.comment.edited": "google.workspace.drive.comment.v3.edited",
|
|
108
|
+
"googleDrive.comment.reopened": "google.workspace.drive.comment.v3.reopened",
|
|
109
|
+
"googleDrive.comment.resolved": "google.workspace.drive.comment.v3.resolved",
|
|
110
|
+
"googleDrive.file.contentChanged":
|
|
111
|
+
"google.workspace.drive.file.v3.contentChanged",
|
|
112
|
+
"googleDrive.file.created": "google.workspace.drive.file.v3.created",
|
|
113
|
+
"googleDrive.file.deleted": "google.workspace.drive.file.v3.deleted",
|
|
114
|
+
"googleDrive.file.moved": "google.workspace.drive.file.v3.moved",
|
|
115
|
+
"googleDrive.file.renamed": "google.workspace.drive.file.v3.renamed",
|
|
116
|
+
"googleDrive.file.trashed": "google.workspace.drive.file.v3.trashed",
|
|
117
|
+
"googleDrive.file.untrashed": "google.workspace.drive.file.v3.untrashed",
|
|
118
|
+
"googleDrive.permission.created":
|
|
119
|
+
"google.workspace.drive.permission.v3.created",
|
|
120
|
+
"googleDrive.permission.deleted":
|
|
121
|
+
"google.workspace.drive.permission.v3.deleted",
|
|
122
|
+
"googleDrive.permission.edited":
|
|
123
|
+
"google.workspace.drive.permission.v3.edited",
|
|
124
|
+
"googleDrive.reply.created": "google.workspace.drive.reply.v3.created",
|
|
125
|
+
"googleDrive.reply.deleted": "google.workspace.drive.reply.v3.deleted",
|
|
126
|
+
"googleDrive.reply.edited": "google.workspace.drive.reply.v3.edited",
|
|
127
|
+
} as const satisfies Record<GoogleDriveTriggerType, string>
|
|
128
|
+
|
|
129
|
+
export type GoogleDriveProviderEventType =
|
|
130
|
+
(typeof GOOGLE_DRIVE_PROVIDER_EVENT_TYPES)[GoogleDriveTriggerType]
|
|
131
|
+
|
|
132
|
+
export const GOOGLE_DRIVE_EVENT_SCHEMA = GOOGLE_DRIVE_EVENT_BASE_SCHEMA.extend({
|
|
133
|
+
eventType: z.enum(GOOGLE_DRIVE_TRIGGER_TYPES),
|
|
134
|
+
})
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Builds one semantic Drive trigger contract with literal discriminants.
|
|
138
|
+
*
|
|
139
|
+
* @param eventType - Exact internal event type.
|
|
140
|
+
* @param resourceType - Exact event resource family.
|
|
141
|
+
* @param action - Exact event action.
|
|
142
|
+
*/
|
|
143
|
+
function googleDriveSemanticTriggerContract<
|
|
144
|
+
const TEventType extends GoogleDriveTriggerType,
|
|
145
|
+
const TResourceType extends z.output<
|
|
146
|
+
typeof GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA
|
|
147
|
+
>,
|
|
148
|
+
const TAction extends z.output<typeof GOOGLE_DRIVE_ACTION_SCHEMA>,
|
|
149
|
+
>(eventType: TEventType, resourceType: TResourceType, action: TAction) {
|
|
150
|
+
return {
|
|
151
|
+
configSchema: GOOGLE_DRIVE_TRIGGER_CONFIG_SCHEMA,
|
|
152
|
+
eventSchema: GOOGLE_DRIVE_EVENT_BASE_SCHEMA.extend({
|
|
153
|
+
action: z.literal(action),
|
|
154
|
+
eventType: z.literal(eventType),
|
|
155
|
+
resourceType: z.literal(resourceType),
|
|
156
|
+
}),
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** Exact semantic trigger contract map used by authoring inference. */
|
|
161
|
+
const googleDriveSemanticTriggerContracts = {
|
|
162
|
+
"googleDrive.accessProposal.created": googleDriveSemanticTriggerContract(
|
|
163
|
+
"googleDrive.accessProposal.created",
|
|
164
|
+
"accessProposal",
|
|
165
|
+
"created",
|
|
166
|
+
),
|
|
167
|
+
"googleDrive.accessProposal.resolved": googleDriveSemanticTriggerContract(
|
|
168
|
+
"googleDrive.accessProposal.resolved",
|
|
169
|
+
"accessProposal",
|
|
170
|
+
"resolved",
|
|
171
|
+
),
|
|
172
|
+
"googleDrive.approval.cancelled": googleDriveSemanticTriggerContract(
|
|
173
|
+
"googleDrive.approval.cancelled",
|
|
174
|
+
"approval",
|
|
175
|
+
"cancelled",
|
|
176
|
+
),
|
|
177
|
+
"googleDrive.approval.completed": googleDriveSemanticTriggerContract(
|
|
178
|
+
"googleDrive.approval.completed",
|
|
179
|
+
"approval",
|
|
180
|
+
"completed",
|
|
181
|
+
),
|
|
182
|
+
"googleDrive.approval.created": googleDriveSemanticTriggerContract(
|
|
183
|
+
"googleDrive.approval.created",
|
|
184
|
+
"approval",
|
|
185
|
+
"created",
|
|
186
|
+
),
|
|
187
|
+
"googleDrive.approval.reset": googleDriveSemanticTriggerContract(
|
|
188
|
+
"googleDrive.approval.reset",
|
|
189
|
+
"approval",
|
|
190
|
+
"reset",
|
|
191
|
+
),
|
|
192
|
+
"googleDrive.approval.responded": googleDriveSemanticTriggerContract(
|
|
193
|
+
"googleDrive.approval.responded",
|
|
194
|
+
"approval",
|
|
195
|
+
"responded",
|
|
196
|
+
),
|
|
197
|
+
"googleDrive.approval.reviewersChanged": googleDriveSemanticTriggerContract(
|
|
198
|
+
"googleDrive.approval.reviewersChanged",
|
|
199
|
+
"approval",
|
|
200
|
+
"reviewersChanged",
|
|
201
|
+
),
|
|
202
|
+
"googleDrive.comment.created": googleDriveSemanticTriggerContract(
|
|
203
|
+
"googleDrive.comment.created",
|
|
204
|
+
"comment",
|
|
205
|
+
"created",
|
|
206
|
+
),
|
|
207
|
+
"googleDrive.comment.deleted": googleDriveSemanticTriggerContract(
|
|
208
|
+
"googleDrive.comment.deleted",
|
|
209
|
+
"comment",
|
|
210
|
+
"deleted",
|
|
211
|
+
),
|
|
212
|
+
"googleDrive.comment.edited": googleDriveSemanticTriggerContract(
|
|
213
|
+
"googleDrive.comment.edited",
|
|
214
|
+
"comment",
|
|
215
|
+
"edited",
|
|
216
|
+
),
|
|
217
|
+
"googleDrive.comment.reopened": googleDriveSemanticTriggerContract(
|
|
218
|
+
"googleDrive.comment.reopened",
|
|
219
|
+
"comment",
|
|
220
|
+
"reopened",
|
|
221
|
+
),
|
|
222
|
+
"googleDrive.comment.resolved": googleDriveSemanticTriggerContract(
|
|
223
|
+
"googleDrive.comment.resolved",
|
|
224
|
+
"comment",
|
|
225
|
+
"resolved",
|
|
226
|
+
),
|
|
227
|
+
"googleDrive.file.contentChanged": googleDriveSemanticTriggerContract(
|
|
228
|
+
"googleDrive.file.contentChanged",
|
|
229
|
+
"file",
|
|
230
|
+
"contentChanged",
|
|
231
|
+
),
|
|
232
|
+
"googleDrive.file.created": googleDriveSemanticTriggerContract(
|
|
233
|
+
"googleDrive.file.created",
|
|
234
|
+
"file",
|
|
235
|
+
"created",
|
|
236
|
+
),
|
|
237
|
+
"googleDrive.file.deleted": googleDriveSemanticTriggerContract(
|
|
238
|
+
"googleDrive.file.deleted",
|
|
239
|
+
"file",
|
|
240
|
+
"deleted",
|
|
241
|
+
),
|
|
242
|
+
"googleDrive.file.moved": googleDriveSemanticTriggerContract(
|
|
243
|
+
"googleDrive.file.moved",
|
|
244
|
+
"file",
|
|
245
|
+
"moved",
|
|
246
|
+
),
|
|
247
|
+
"googleDrive.file.renamed": googleDriveSemanticTriggerContract(
|
|
248
|
+
"googleDrive.file.renamed",
|
|
249
|
+
"file",
|
|
250
|
+
"renamed",
|
|
251
|
+
),
|
|
252
|
+
"googleDrive.file.trashed": googleDriveSemanticTriggerContract(
|
|
253
|
+
"googleDrive.file.trashed",
|
|
254
|
+
"file",
|
|
255
|
+
"trashed",
|
|
256
|
+
),
|
|
257
|
+
"googleDrive.file.untrashed": googleDriveSemanticTriggerContract(
|
|
258
|
+
"googleDrive.file.untrashed",
|
|
259
|
+
"file",
|
|
260
|
+
"untrashed",
|
|
261
|
+
),
|
|
262
|
+
"googleDrive.permission.created": googleDriveSemanticTriggerContract(
|
|
263
|
+
"googleDrive.permission.created",
|
|
264
|
+
"permission",
|
|
265
|
+
"created",
|
|
266
|
+
),
|
|
267
|
+
"googleDrive.permission.deleted": googleDriveSemanticTriggerContract(
|
|
268
|
+
"googleDrive.permission.deleted",
|
|
269
|
+
"permission",
|
|
270
|
+
"deleted",
|
|
271
|
+
),
|
|
272
|
+
"googleDrive.permission.edited": googleDriveSemanticTriggerContract(
|
|
273
|
+
"googleDrive.permission.edited",
|
|
274
|
+
"permission",
|
|
275
|
+
"edited",
|
|
276
|
+
),
|
|
277
|
+
"googleDrive.reply.created": googleDriveSemanticTriggerContract(
|
|
278
|
+
"googleDrive.reply.created",
|
|
279
|
+
"reply",
|
|
280
|
+
"created",
|
|
281
|
+
),
|
|
282
|
+
"googleDrive.reply.deleted": googleDriveSemanticTriggerContract(
|
|
283
|
+
"googleDrive.reply.deleted",
|
|
284
|
+
"reply",
|
|
285
|
+
"deleted",
|
|
286
|
+
),
|
|
287
|
+
"googleDrive.reply.edited": googleDriveSemanticTriggerContract(
|
|
288
|
+
"googleDrive.reply.edited",
|
|
289
|
+
"reply",
|
|
290
|
+
"edited",
|
|
291
|
+
),
|
|
292
|
+
} satisfies Record<GoogleDriveTriggerType, unknown>
|
|
293
|
+
|
|
294
|
+
export const googleDriveTriggerContracts = {
|
|
295
|
+
"googleDrive.event": {
|
|
296
|
+
configSchema: GOOGLE_DRIVE_TRIGGER_CONFIG_SCHEMA,
|
|
297
|
+
eventSchema: GOOGLE_DRIVE_EVENT_SCHEMA,
|
|
298
|
+
},
|
|
299
|
+
...googleDriveSemanticTriggerContracts,
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Resolves an internal semantic event type from a provider CloudEvent type.
|
|
304
|
+
*
|
|
305
|
+
* @param providerEventType - Provider CloudEvent type.
|
|
306
|
+
*/
|
|
307
|
+
export function toGoogleDriveTriggerType(
|
|
308
|
+
providerEventType: string,
|
|
309
|
+
): GoogleDriveTriggerType | undefined {
|
|
310
|
+
// Keep the candidate separate so Zod performs the only narrowing.
|
|
311
|
+
const candidate = Object.entries(GOOGLE_DRIVE_PROVIDER_EVENT_TYPES).find(
|
|
312
|
+
([, value]) => value === providerEventType,
|
|
313
|
+
)?.[0]
|
|
314
|
+
const result = z.enum(GOOGLE_DRIVE_TRIGGER_TYPES).safeParse(candidate)
|
|
315
|
+
return result.success ? result.data : undefined
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Splits one internal event type into its resource and action discriminants.
|
|
320
|
+
*
|
|
321
|
+
* @param eventType - Stable internal semantic event type.
|
|
322
|
+
*/
|
|
323
|
+
export function parseGoogleDriveTriggerType(eventType: GoogleDriveTriggerType) {
|
|
324
|
+
const [, resourceType, ...actionParts] = eventType.split(".")
|
|
325
|
+
return {
|
|
326
|
+
action: GOOGLE_DRIVE_ACTION_SCHEMA.parse(actionParts.join(".")),
|
|
327
|
+
resourceType: GOOGLE_DRIVE_RESOURCE_TYPE_SCHEMA.parse(resourceType),
|
|
328
|
+
}
|
|
329
|
+
}
|
package/src/triggers.ts
CHANGED
|
@@ -8,6 +8,7 @@ import type { cloudflareTriggerContracts } from "./cloudflare"
|
|
|
8
8
|
import type { githubTriggerContracts } from "./github"
|
|
9
9
|
import type { gmailTriggerContracts } from "./gmail"
|
|
10
10
|
import type { googleCalendarTriggerContracts } from "./google-calendar"
|
|
11
|
+
import type { googleDriveTriggerContracts } from "./google-drive"
|
|
11
12
|
import type { googleFormsTriggerContracts } from "./google-forms"
|
|
12
13
|
import type { googleMeetTriggerContracts } from "./google-meet"
|
|
13
14
|
import type { googleSheetsTriggerContracts } from "./google-sheets"
|
|
@@ -36,6 +37,7 @@ export type TriggerContractMap = typeof airtableTriggerContracts &
|
|
|
36
37
|
typeof githubTriggerContracts &
|
|
37
38
|
typeof gmailTriggerContracts &
|
|
38
39
|
typeof googleCalendarTriggerContracts &
|
|
40
|
+
typeof googleDriveTriggerContracts &
|
|
39
41
|
typeof googleFormsTriggerContracts &
|
|
40
42
|
typeof googleMeetTriggerContracts &
|
|
41
43
|
typeof googleSheetsTriggerContracts &
|