-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackendTypes.ts
More file actions
122 lines (107 loc) · 4.04 KB
/
backendTypes.ts
File metadata and controls
122 lines (107 loc) · 4.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/**
* Internal types shared between the Glue runtime and the backend API. These
* types are not intended for most Glue users to use.
*
* This file exports all the *TriggerBackendConfig types, the *Event types,
* types returned by the runtime's internal HTTP API used by glue-backend, and
* the types returned by glue-backend's credential fetcher endpoints.
*
* @ignore
* @module
*/
import { z } from "zod";
import { CommonCredentialFetcherOptions } from "./common.ts";
export interface TriggerEvent {
/** The event source type (e.g., "github", "stripe", "webhook") */
type: string;
/**
* The unique label identifying the specific trigger registration within the
* glue deployment.
*/
label: string;
/** The event-specific data payload, structure varies by event type. */
data?: unknown;
}
export const TriggerEvent: z.ZodType<TriggerEvent> = z.object({
type: z.string(),
label: z.string(),
data: z.unknown(),
});
export interface TriggerRegistration {
/** The event source type this trigger is registered for */
type: string;
/**
* The unique label identifying the specific trigger registration within the
* glue deployment.
*/
label: string;
/** Event source specific configuration (varies by type) */
config?: unknown;
}
export const TriggerRegistration: z.ZodType<TriggerRegistration> = z.object({
type: z.string(),
label: z.string(),
config: z.looseObject({}).optional(),
});
export interface CredentialFetcherBackendConfig extends CommonCredentialFetcherOptions {
scopes?: string[];
selector?: string;
}
export const CredentialFetcherBackendConfig: z.ZodType<CredentialFetcherBackendConfig> =
CommonCredentialFetcherOptions.extend({
scopes: z.array(z.string()).optional(),
selector: z.string().optional(),
});
export interface CredentialFetcherRegistration {
type: string;
/**
* The unique label identifying the specific credential fetcher within the
* glue deployment.
*/
label: string;
config: CredentialFetcherBackendConfig;
}
export const CredentialFetcherRegistration: z.ZodType<CredentialFetcherRegistration> = z
.object({
type: z.string(),
label: z.string(),
config: CredentialFetcherBackendConfig,
});
/**
* Container for all registrations in a Glue application. This is the type that
* the runtime serves on the `/__glue__/getRegistrations` to the backend.
*/
export interface Registrations {
/** All event trigger registrations in the application */
triggers: TriggerRegistration[];
/** All credential fetcher registrations in the application */
accountInjections: CredentialFetcherRegistration[];
}
export const Registrations: z.ZodType<Registrations> = z.object({
triggers: z.array(TriggerRegistration),
accountInjections: z.array(CredentialFetcherRegistration),
// TODO secretInjections
});
// This is exported so we can implement new *TriggerBackendConfig types in
// glue-backend first before moving them into glue-runtime.
export { CommonTriggerBackendConfig } from "./common.ts";
/** Represents a credential using an access token */
export interface AccessTokenCredential {
accessToken: string;
expiresAt?: number;
}
/** Represents a credential using an API key */
export interface ApiKeyCredential {
apiKey: string;
}
// integration backend config types
export { CronTriggerBackendConfig } from "./integrations/cron/runtime.ts";
export { GithubTriggerBackendConfig } from "./integrations/github/runtime.ts";
export { GmailTriggerBackendConfig } from "./integrations/gmail/runtime.ts";
export { DriveTriggerBackendConfig } from "./integrations/drive/runtime.ts";
export { SheetsTriggerBackendConfig } from "./integrations/sheets/runtime.ts";
export { IntercomTriggerBackendConfig } from "./integrations/intercom/runtime.ts";
export { SlackEventWebhook, SlackTriggerBackendConfig } from "./integrations/slack/runtime.ts";
export { StreakTriggerBackendConfig } from "./integrations/streak/runtime.ts";
export { StripeTriggerBackendConfig } from "./integrations/stripe/runtime.ts";
export { WebhookTriggerBackendConfig } from "./integrations/webhook/runtime.ts";