@automate.ax/integration-contracts 0.76.0 → 0.77.1

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.
@@ -0,0 +1,173 @@
1
+ import { type meet_v2 } from "@googleapis/meet";
2
+ import type { z as zod } from "zod";
3
+ import { GOOGLE_MEET_SPACE_CONFIG_SCHEMA } from "./schemas.js";
4
+ /**
5
+ * Creates the official Meet client from a resolved Google integration secret.
6
+ *
7
+ * @param secret - Refreshed Google integration secret.
8
+ */
9
+ export declare function getGoogleMeetApi(secret: Record<string, unknown>): meet_v2.Meet;
10
+ /**
11
+ * Accepts a space resource name, meeting code, opaque space ID, or Meet URL.
12
+ *
13
+ * @param space - Meeting-space reference to normalize.
14
+ * @throws When a URL does not point to Google Meet.
15
+ */
16
+ export declare function normalizeGoogleMeetSpaceName(space: string): string;
17
+ /**
18
+ * Accepts a conference-record resource name or raw record ID.
19
+ *
20
+ * @param record - Conference-record reference to normalize.
21
+ */
22
+ export declare function normalizeGoogleMeetConferenceRecordName(record: string): string;
23
+ /**
24
+ * Converts a code-first space configuration into Google's request shape.
25
+ *
26
+ * @param config - Public meeting-space configuration.
27
+ */
28
+ export declare function toGoogleMeetSpaceConfig(config: zod.infer<typeof GOOGLE_MEET_SPACE_CONFIG_SCHEMA>): meet_v2.Schema$SpaceConfig;
29
+ /**
30
+ * Builds an exact field mask for a partial code-first space configuration.
31
+ *
32
+ * @param config - Public settings included in a partial update.
33
+ */
34
+ export declare function getGoogleMeetSpaceConfigUpdateMask(config: zod.infer<typeof GOOGLE_MEET_SPACE_CONFIG_SCHEMA>): string;
35
+ /**
36
+ * Normalizes a Google Meet space without leaking provider nulls or enums.
37
+ *
38
+ * @param value - Provider meeting-space resource.
39
+ */
40
+ export declare function normalizeGoogleMeetSpace(value: meet_v2.Schema$Space): {
41
+ gatewaySipAccess: {
42
+ uri: string;
43
+ sipAccessCode?: string | undefined;
44
+ }[];
45
+ meetingCode: string;
46
+ meetingUri: string;
47
+ name: string;
48
+ phoneAccess: {
49
+ phoneNumber: string;
50
+ pin: string;
51
+ languageCode?: string | undefined;
52
+ regionCode?: string | undefined;
53
+ }[];
54
+ activeConference?: string | undefined;
55
+ config?: {
56
+ accessType?: "open" | "trusted" | "restricted" | undefined;
57
+ artifacts?: {
58
+ recording?: boolean | undefined;
59
+ smartNotes?: boolean | undefined;
60
+ transcription?: boolean | undefined;
61
+ } | undefined;
62
+ attendanceReport?: boolean | undefined;
63
+ entryPointAccess?: "all" | "creatorAppOnly" | undefined;
64
+ moderation?: boolean | undefined;
65
+ moderationRestrictions?: {
66
+ chat?: "hostsOnly" | "noRestriction" | undefined;
67
+ defaultJoinAsViewer?: boolean | undefined;
68
+ present?: "hostsOnly" | "noRestriction" | undefined;
69
+ reactions?: "hostsOnly" | "noRestriction" | undefined;
70
+ } | undefined;
71
+ } | undefined;
72
+ };
73
+ /**
74
+ * Normalizes one conference record.
75
+ *
76
+ * @param value - Provider conference-record resource.
77
+ */
78
+ export declare function normalizeGoogleMeetConferenceRecord(value: meet_v2.Schema$ConferenceRecord): {
79
+ name: string;
80
+ space: string;
81
+ startTime: string;
82
+ endTime?: string | undefined;
83
+ expireTime?: string | undefined;
84
+ };
85
+ /**
86
+ * Normalizes one conference participant and its identity variant.
87
+ *
88
+ * @param value - Provider participant resource.
89
+ */
90
+ export declare function normalizeGoogleMeetParticipant(value: meet_v2.Schema$Participant): {
91
+ name: string;
92
+ user: {
93
+ displayName: string;
94
+ type: "anonymous";
95
+ } | {
96
+ displayName: string;
97
+ type: "phone";
98
+ } | {
99
+ displayName: string;
100
+ type: "signedIn";
101
+ user?: string | undefined;
102
+ };
103
+ earliestStartTime?: string | undefined;
104
+ latestEndTime?: string | undefined;
105
+ };
106
+ /**
107
+ * Normalizes one participant-device session.
108
+ *
109
+ * @param value - Provider participant-session resource.
110
+ */
111
+ export declare function normalizeGoogleMeetParticipantSession(value: meet_v2.Schema$ParticipantSession): {
112
+ name: string;
113
+ startTime: string;
114
+ endTime?: string | undefined;
115
+ };
116
+ /**
117
+ * Normalizes one recording artifact.
118
+ *
119
+ * @param value - Provider recording resource.
120
+ */
121
+ export declare function normalizeGoogleMeetRecording(value: meet_v2.Schema$Recording): {
122
+ name: string;
123
+ state: "started" | "ended" | "fileGenerated";
124
+ driveDestination?: {
125
+ exportUri?: string | undefined;
126
+ fileId?: string | undefined;
127
+ } | undefined;
128
+ endTime?: string | undefined;
129
+ startTime?: string | undefined;
130
+ };
131
+ /**
132
+ * Normalizes one transcript artifact.
133
+ *
134
+ * @param value - Provider transcript resource.
135
+ */
136
+ export declare function normalizeGoogleMeetTranscript(value: meet_v2.Schema$Transcript): {
137
+ name: string;
138
+ state: "started" | "ended" | "fileGenerated";
139
+ docsDestination?: {
140
+ documentId?: string | undefined;
141
+ exportUri?: string | undefined;
142
+ } | undefined;
143
+ endTime?: string | undefined;
144
+ startTime?: string | undefined;
145
+ };
146
+ /**
147
+ * Normalizes one structured transcript segment.
148
+ *
149
+ * @param value - Provider transcript-entry resource.
150
+ */
151
+ export declare function normalizeGoogleMeetTranscriptEntry(value: meet_v2.Schema$TranscriptEntry): {
152
+ endTime: string;
153
+ languageCode: string;
154
+ name: string;
155
+ participant: string;
156
+ startTime: string;
157
+ text: string;
158
+ };
159
+ /**
160
+ * Normalizes one Meet smart-note artifact.
161
+ *
162
+ * @param value - Provider smart-note resource.
163
+ */
164
+ export declare function normalizeGoogleMeetSmartNote(value: meet_v2.Schema$SmartNote): {
165
+ name: string;
166
+ state: "started" | "ended" | "fileGenerated";
167
+ docsDestination?: {
168
+ documentId?: string | undefined;
169
+ exportUri?: string | undefined;
170
+ } | undefined;
171
+ endTime?: string | undefined;
172
+ startTime?: string | undefined;
173
+ };
@@ -0,0 +1,371 @@
1
+ import { auth, meet } from "@googleapis/meet";
2
+ import { z } from "zod";
3
+ import { GOOGLE_MEET_CONFERENCE_RECORD_SCHEMA, GOOGLE_MEET_PARTICIPANT_SCHEMA, GOOGLE_MEET_PARTICIPANT_SESSION_SCHEMA, GOOGLE_MEET_RECORDING_SCHEMA, GOOGLE_MEET_SMART_NOTE_SCHEMA, GOOGLE_MEET_SPACE_CONFIG_SCHEMA, GOOGLE_MEET_SPACE_SCHEMA, GOOGLE_MEET_TRANSCRIPT_ENTRY_SCHEMA, GOOGLE_MEET_TRANSCRIPT_SCHEMA, } from "./schemas.js";
4
+ const GOOGLE_MEET_SECRET_SCHEMA = z.object({
5
+ accessToken: z.string().min(1),
6
+ });
7
+ const GOOGLE_MEET_HOSTS = new Set(["meet.google.com", "meet.google"]);
8
+ /**
9
+ * Creates the official Meet client from a resolved Google integration secret.
10
+ *
11
+ * @param secret - Refreshed Google integration secret.
12
+ */
13
+ export function getGoogleMeetApi(secret) {
14
+ const { accessToken } = GOOGLE_MEET_SECRET_SCHEMA.parse(secret);
15
+ return meet({
16
+ auth: new auth.OAuth2({ credentials: { access_token: accessToken } }),
17
+ version: "v2",
18
+ });
19
+ }
20
+ /**
21
+ * Accepts a space resource name, meeting code, opaque space ID, or Meet URL.
22
+ *
23
+ * @param space - Meeting-space reference to normalize.
24
+ * @throws When a URL does not point to Google Meet.
25
+ */
26
+ export function normalizeGoogleMeetSpaceName(space) {
27
+ const value = space.trim();
28
+ if (value.startsWith("spaces/"))
29
+ return value;
30
+ if (!URL.canParse(value))
31
+ return `spaces/${value}`;
32
+ const url = new URL(value);
33
+ if (!GOOGLE_MEET_HOSTS.has(url.hostname)) {
34
+ throw new Error(`Expected a Google Meet URL, received "${value}".`);
35
+ }
36
+ const meetingCode = url.pathname.split("/").find(Boolean);
37
+ if (!meetingCode) {
38
+ throw new Error(`Expected a Google Meet meeting URL, received "${value}".`);
39
+ }
40
+ return `spaces/${meetingCode}`;
41
+ }
42
+ /**
43
+ * Accepts a conference-record resource name or raw record ID.
44
+ *
45
+ * @param record - Conference-record reference to normalize.
46
+ */
47
+ export function normalizeGoogleMeetConferenceRecordName(record) {
48
+ const value = record.trim();
49
+ return value.startsWith("conferenceRecords/")
50
+ ? value
51
+ : `conferenceRecords/${value}`;
52
+ }
53
+ /**
54
+ * Converts a code-first space configuration into Google's request shape.
55
+ *
56
+ * @param config - Public meeting-space configuration.
57
+ */
58
+ export function toGoogleMeetSpaceConfig(config) {
59
+ return {
60
+ accessType: config.accessType?.toUpperCase(),
61
+ artifactConfig: config.artifacts
62
+ ? {
63
+ recordingConfig: {
64
+ autoRecordingGeneration: toAutoGeneration(config.artifacts.recording),
65
+ },
66
+ smartNotesConfig: {
67
+ autoSmartNotesGeneration: toAutoGeneration(config.artifacts.smartNotes),
68
+ },
69
+ transcriptionConfig: {
70
+ autoTranscriptionGeneration: toAutoGeneration(config.artifacts.transcription),
71
+ },
72
+ }
73
+ : undefined,
74
+ attendanceReportGenerationType: config.attendanceReport === undefined
75
+ ? undefined
76
+ : config.attendanceReport
77
+ ? "GENERATE_REPORT"
78
+ : "DO_NOT_GENERATE",
79
+ entryPointAccess: config.entryPointAccess === "creatorAppOnly"
80
+ ? "CREATOR_APP_ONLY"
81
+ : config.entryPointAccess?.toUpperCase(),
82
+ moderation: config.moderation === undefined
83
+ ? undefined
84
+ : config.moderation
85
+ ? "ON"
86
+ : "OFF",
87
+ moderationRestrictions: config.moderationRestrictions
88
+ ? {
89
+ chatRestriction: toRestriction(config.moderationRestrictions.chat),
90
+ defaultJoinAsViewerType: config.moderationRestrictions.defaultJoinAsViewer === undefined
91
+ ? undefined
92
+ : config.moderationRestrictions.defaultJoinAsViewer
93
+ ? "ON"
94
+ : "OFF",
95
+ presentRestriction: toRestriction(config.moderationRestrictions.present),
96
+ reactionRestriction: toRestriction(config.moderationRestrictions.reactions),
97
+ }
98
+ : undefined,
99
+ };
100
+ }
101
+ /**
102
+ * Builds an exact field mask for a partial code-first space configuration.
103
+ *
104
+ * @param config - Public settings included in a partial update.
105
+ */
106
+ export function getGoogleMeetSpaceConfigUpdateMask(config) {
107
+ return [
108
+ config.accessType !== undefined && "config.accessType",
109
+ config.attendanceReport !== undefined &&
110
+ "config.attendanceReportGenerationType",
111
+ config.entryPointAccess !== undefined && "config.entryPointAccess",
112
+ config.moderation !== undefined && "config.moderation",
113
+ config.moderationRestrictions?.chat !== undefined &&
114
+ "config.moderationRestrictions.chatRestriction",
115
+ config.moderationRestrictions?.defaultJoinAsViewer !== undefined &&
116
+ "config.moderationRestrictions.defaultJoinAsViewerType",
117
+ config.moderationRestrictions?.present !== undefined &&
118
+ "config.moderationRestrictions.presentRestriction",
119
+ config.moderationRestrictions?.reactions !== undefined &&
120
+ "config.moderationRestrictions.reactionRestriction",
121
+ config.artifacts?.recording !== undefined &&
122
+ "config.artifactConfig.recordingConfig.autoRecordingGeneration",
123
+ config.artifacts?.smartNotes !== undefined &&
124
+ "config.artifactConfig.smartNotesConfig.autoSmartNotesGeneration",
125
+ config.artifacts?.transcription !== undefined &&
126
+ "config.artifactConfig.transcriptionConfig.autoTranscriptionGeneration",
127
+ ]
128
+ .filter((value) => Boolean(value))
129
+ .join(",");
130
+ }
131
+ /**
132
+ * Normalizes a Google Meet space without leaking provider nulls or enums.
133
+ *
134
+ * @param value - Provider meeting-space resource.
135
+ */
136
+ export function normalizeGoogleMeetSpace(value) {
137
+ return GOOGLE_MEET_SPACE_SCHEMA.parse({
138
+ activeConference: value.activeConference?.conferenceRecord ?? undefined,
139
+ config: value.config ? normalizeSpaceConfig(value.config) : undefined,
140
+ gatewaySipAccess: (value.gatewaySipAccess ?? []).map((access) => ({
141
+ sipAccessCode: access.sipAccessCode ?? undefined,
142
+ uri: access.uri,
143
+ })),
144
+ meetingCode: value.meetingCode,
145
+ meetingUri: value.meetingUri,
146
+ name: value.name,
147
+ phoneAccess: (value.phoneAccess ?? []).map((access) => ({
148
+ languageCode: access.languageCode ?? undefined,
149
+ phoneNumber: access.phoneNumber,
150
+ pin: access.pin,
151
+ regionCode: access.regionCode ?? undefined,
152
+ })),
153
+ });
154
+ }
155
+ /**
156
+ * Normalizes one conference record.
157
+ *
158
+ * @param value - Provider conference-record resource.
159
+ */
160
+ export function normalizeGoogleMeetConferenceRecord(value) {
161
+ return GOOGLE_MEET_CONFERENCE_RECORD_SCHEMA.parse({
162
+ endTime: value.endTime ?? undefined,
163
+ expireTime: value.expireTime ?? undefined,
164
+ name: value.name,
165
+ space: value.space,
166
+ startTime: value.startTime,
167
+ });
168
+ }
169
+ /**
170
+ * Normalizes one conference participant and its identity variant.
171
+ *
172
+ * @param value - Provider participant resource.
173
+ */
174
+ export function normalizeGoogleMeetParticipant(value) {
175
+ return GOOGLE_MEET_PARTICIPANT_SCHEMA.parse({
176
+ earliestStartTime: value.earliestStartTime ?? undefined,
177
+ latestEndTime: value.latestEndTime ?? undefined,
178
+ name: value.name,
179
+ user: value.signedinUser
180
+ ? {
181
+ displayName: value.signedinUser.displayName,
182
+ type: "signedIn",
183
+ user: value.signedinUser.user ?? undefined,
184
+ }
185
+ : value.anonymousUser
186
+ ? { displayName: value.anonymousUser.displayName, type: "anonymous" }
187
+ : { displayName: value.phoneUser?.displayName, type: "phone" },
188
+ });
189
+ }
190
+ /**
191
+ * Normalizes one participant-device session.
192
+ *
193
+ * @param value - Provider participant-session resource.
194
+ */
195
+ export function normalizeGoogleMeetParticipantSession(value) {
196
+ return GOOGLE_MEET_PARTICIPANT_SESSION_SCHEMA.parse({
197
+ endTime: value.endTime ?? undefined,
198
+ name: value.name,
199
+ startTime: value.startTime,
200
+ });
201
+ }
202
+ /**
203
+ * Normalizes one recording artifact.
204
+ *
205
+ * @param value - Provider recording resource.
206
+ */
207
+ export function normalizeGoogleMeetRecording(value) {
208
+ return GOOGLE_MEET_RECORDING_SCHEMA.parse({
209
+ driveDestination: value.driveDestination
210
+ ? {
211
+ exportUri: value.driveDestination.exportUri ?? undefined,
212
+ fileId: value.driveDestination.file ?? undefined,
213
+ }
214
+ : undefined,
215
+ endTime: value.endTime ?? undefined,
216
+ name: value.name,
217
+ startTime: value.startTime ?? undefined,
218
+ state: normalizeArtifactState(value.state),
219
+ });
220
+ }
221
+ /**
222
+ * Normalizes one transcript artifact.
223
+ *
224
+ * @param value - Provider transcript resource.
225
+ */
226
+ export function normalizeGoogleMeetTranscript(value) {
227
+ return GOOGLE_MEET_TRANSCRIPT_SCHEMA.parse({
228
+ docsDestination: normalizeDocsDestination(value.docsDestination),
229
+ endTime: value.endTime ?? undefined,
230
+ name: value.name,
231
+ startTime: value.startTime ?? undefined,
232
+ state: normalizeArtifactState(value.state),
233
+ });
234
+ }
235
+ /**
236
+ * Normalizes one structured transcript segment.
237
+ *
238
+ * @param value - Provider transcript-entry resource.
239
+ */
240
+ export function normalizeGoogleMeetTranscriptEntry(value) {
241
+ return GOOGLE_MEET_TRANSCRIPT_ENTRY_SCHEMA.parse({
242
+ endTime: value.endTime,
243
+ languageCode: value.languageCode,
244
+ name: value.name,
245
+ participant: value.participant,
246
+ startTime: value.startTime,
247
+ text: value.text,
248
+ });
249
+ }
250
+ /**
251
+ * Normalizes one Meet smart-note artifact.
252
+ *
253
+ * @param value - Provider smart-note resource.
254
+ */
255
+ export function normalizeGoogleMeetSmartNote(value) {
256
+ return GOOGLE_MEET_SMART_NOTE_SCHEMA.parse({
257
+ docsDestination: normalizeDocsDestination(value.docsDestination),
258
+ endTime: value.endTime ?? undefined,
259
+ name: value.name,
260
+ startTime: value.startTime ?? undefined,
261
+ state: normalizeArtifactState(value.state),
262
+ });
263
+ }
264
+ /**
265
+ * Normalizes provider meeting-space settings.
266
+ *
267
+ * @param value - Provider settings to normalize.
268
+ */
269
+ function normalizeSpaceConfig(value) {
270
+ return GOOGLE_MEET_SPACE_CONFIG_SCHEMA.parse({
271
+ accessType: value.accessType?.toLowerCase(),
272
+ artifacts: value.artifactConfig
273
+ ? {
274
+ recording: fromAutoGeneration(value.artifactConfig.recordingConfig?.autoRecordingGeneration),
275
+ smartNotes: fromAutoGeneration(value.artifactConfig.smartNotesConfig?.autoSmartNotesGeneration),
276
+ transcription: fromAutoGeneration(value.artifactConfig.transcriptionConfig
277
+ ?.autoTranscriptionGeneration),
278
+ }
279
+ : undefined,
280
+ attendanceReport: value.attendanceReportGenerationType === undefined ||
281
+ value.attendanceReportGenerationType === null
282
+ ? undefined
283
+ : value.attendanceReportGenerationType === "GENERATE_REPORT",
284
+ entryPointAccess: value.entryPointAccess === "CREATOR_APP_ONLY"
285
+ ? "creatorAppOnly"
286
+ : value.entryPointAccess?.toLowerCase(),
287
+ moderation: value.moderation === undefined || value.moderation === null
288
+ ? undefined
289
+ : value.moderation === "ON",
290
+ moderationRestrictions: value.moderationRestrictions
291
+ ? {
292
+ chat: fromRestriction(value.moderationRestrictions.chatRestriction),
293
+ defaultJoinAsViewer: value.moderationRestrictions.defaultJoinAsViewerType ===
294
+ undefined ||
295
+ value.moderationRestrictions.defaultJoinAsViewerType === null
296
+ ? undefined
297
+ : value.moderationRestrictions.defaultJoinAsViewerType === "ON",
298
+ present: fromRestriction(value.moderationRestrictions.presentRestriction),
299
+ reactions: fromRestriction(value.moderationRestrictions.reactionRestriction),
300
+ }
301
+ : undefined,
302
+ });
303
+ }
304
+ /**
305
+ * Maps a public boolean to Google's auto-generation enum.
306
+ *
307
+ * @param value - Public automatic-generation setting.
308
+ */
309
+ function toAutoGeneration(value) {
310
+ return value === undefined ? undefined : value ? "ON" : "OFF";
311
+ }
312
+ /**
313
+ * Maps Google's auto-generation enum to a public boolean.
314
+ *
315
+ * @param value - Provider automatic-generation enum.
316
+ */
317
+ function fromAutoGeneration(value) {
318
+ return value === undefined || value === null ? undefined : value === "ON";
319
+ }
320
+ /**
321
+ * Maps a public moderation restriction to Google's enum.
322
+ *
323
+ * @param value - Public moderation restriction.
324
+ */
325
+ function toRestriction(value) {
326
+ return value === "hostsOnly"
327
+ ? "HOSTS_ONLY"
328
+ : value === "noRestriction"
329
+ ? "NO_RESTRICTION"
330
+ : undefined;
331
+ }
332
+ /**
333
+ * Maps Google's moderation restriction to a public enum.
334
+ *
335
+ * @param value - Provider moderation restriction.
336
+ */
337
+ function fromRestriction(value) {
338
+ return value === "HOSTS_ONLY"
339
+ ? "hostsOnly"
340
+ : value === "NO_RESTRICTION"
341
+ ? "noRestriction"
342
+ : undefined;
343
+ }
344
+ /**
345
+ * Normalizes Google's artifact lifecycle state.
346
+ *
347
+ * @param value - Provider artifact state.
348
+ */
349
+ function normalizeArtifactState(value) {
350
+ switch (z.enum(["STARTED", "ENDED", "FILE_GENERATED"]).parse(value)) {
351
+ case "STARTED":
352
+ return "started";
353
+ case "ENDED":
354
+ return "ended";
355
+ case "FILE_GENERATED":
356
+ return "fileGenerated";
357
+ }
358
+ }
359
+ /**
360
+ * Normalizes a generated Google Docs destination.
361
+ *
362
+ * @param value - Provider document destination.
363
+ */
364
+ function normalizeDocsDestination(value) {
365
+ return value
366
+ ? {
367
+ documentId: value.document ?? undefined,
368
+ exportUri: value.exportUri ?? undefined,
369
+ }
370
+ : undefined;
371
+ }