@twentyhq/meet 0.0.0-stage → 1.0.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/README.md +48 -2
- package/dependencies/yarn.lock +1863 -0
- package/manifest.json +1901 -0
- package/package.json +44 -4
- package/public/gallery/meet-cover-image-1.png +0 -0
- package/public/gallery/meet-cover-image-2.png +0 -0
- package/public/gallery/meet-cover-image-3.png +0 -0
- package/public/logo.svg +1 -0
- package/src/constants/meet-call-summary-prompt.constant.ts +54 -0
- package/src/constants/meet.constant.ts +17 -0
- package/src/constants/universal-identifiers.ts +35 -0
- package/src/logic-functions/constants/calendar-event-matching.constant.ts +3 -0
- package/src/logic-functions/constants/google-docs-api.constant.ts +10 -0
- package/src/logic-functions/constants/google-drive-api.constant.ts +1 -0
- package/src/logic-functions/constants/google-pubsub-push.constant.ts +7 -0
- package/src/logic-functions/constants/google-user-info.constant.ts +2 -0
- package/src/logic-functions/constants/google-workspace-events.constant.ts +17 -0
- package/src/logic-functions/constants/meet-api.constant.ts +9 -0
- package/src/logic-functions/constants/meet-call-summary.constant.ts +3 -0
- package/src/logic-functions/constants/meet-import.constant.ts +7 -0
- package/src/logic-functions/constants/meet-recording-import.constant.ts +7 -0
- package/src/logic-functions/constants/restricted-field-placeholder.constant.ts +2 -0
- package/src/logic-functions/meet-events-resolver.mjs +1345 -0
- package/src/logic-functions/meet-events-resolver.mjs.map +7 -0
- package/src/logic-functions/meet-events-resolver.ts +89 -0
- package/src/logic-functions/meet-handle-event.mjs +665 -0
- package/src/logic-functions/meet-handle-event.mjs.map +7 -0
- package/src/logic-functions/meet-handle-event.ts +86 -0
- package/src/logic-functions/meet-identify-account.mjs +369 -0
- package/src/logic-functions/meet-identify-account.mjs.map +7 -0
- package/src/logic-functions/meet-identify-account.ts +42 -0
- package/src/logic-functions/meet-import-conference.mjs +1465 -0
- package/src/logic-functions/meet-import-conference.mjs.map +7 -0
- package/src/logic-functions/meet-import-conference.ts +101 -0
- package/src/logic-functions/meet-import-recording.mjs +794 -0
- package/src/logic-functions/meet-import-recording.mjs.map +7 -0
- package/src/logic-functions/meet-import-recording.ts +99 -0
- package/src/logic-functions/meet-queue-conference-imports.mjs +711 -0
- package/src/logic-functions/meet-queue-conference-imports.mjs.map +7 -0
- package/src/logic-functions/meet-queue-conference-imports.ts +62 -0
- package/src/logic-functions/meet-refresh-connections.mjs +457 -0
- package/src/logic-functions/meet-refresh-connections.mjs.map +7 -0
- package/src/logic-functions/meet-refresh-connections.ts +64 -0
- package/src/logic-functions/meet-register-connection.mjs +837 -0
- package/src/logic-functions/meet-register-connection.mjs.map +7 -0
- package/src/logic-functions/meet-register-connection.ts +81 -0
- package/src/logic-functions/meet-summarize-call-recording.mjs +645 -0
- package/src/logic-functions/meet-summarize-call-recording.mjs.map +7 -0
- package/src/logic-functions/meet-summarize-call-recording.ts +111 -0
- package/src/logic-functions/meet-unregister-connection.mjs +610 -0
- package/src/logic-functions/meet-unregister-connection.mjs.map +7 -0
- package/src/logic-functions/meet-unregister-connection.ts +57 -0
- package/src/logic-functions/types/calendar-event-candidate.type.ts +6 -0
- package/src/logic-functions/types/call-recording-for-summary.type.ts +5 -0
- package/src/logic-functions/types/call-recording-sync-fields.type.ts +12 -0
- package/src/logic-functions/types/call-recording-upsert-outcome.type.ts +4 -0
- package/src/logic-functions/types/google-doc-lists.type.ts +4 -0
- package/src/logic-functions/types/google-doc-markdown-segment.type.ts +5 -0
- package/src/logic-functions/types/google-doc-paragraph-element.type.ts +8 -0
- package/src/logic-functions/types/google-doc-paragraph.type.ts +7 -0
- package/src/logic-functions/types/google-doc-tab.type.ts +10 -0
- package/src/logic-functions/types/google-doc.type.ts +6 -0
- package/src/logic-functions/types/google-pubsub-push-body.type.ts +6 -0
- package/src/logic-functions/types/google-request-method.type.ts +1 -0
- package/src/logic-functions/types/google-user-info.type.ts +4 -0
- package/src/logic-functions/types/google-workspace-events-operation.type.ts +8 -0
- package/src/logic-functions/types/meet-call-summary-outcome.type.ts +6 -0
- package/src/logic-functions/types/meet-collection-page.type.ts +3 -0
- package/src/logic-functions/types/meet-conference-record.type.ts +7 -0
- package/src/logic-functions/types/meet-conference-sync-outcome.type.ts +5 -0
- package/src/logic-functions/types/meet-conference-sync-result.type.ts +7 -0
- package/src/logic-functions/types/meet-daily-job-name.type.ts +1 -0
- package/src/logic-functions/types/meet-event-data.type.ts +5 -0
- package/src/logic-functions/types/meet-event-outcome.type.ts +4 -0
- package/src/logic-functions/types/meet-event-subscription.type.ts +8 -0
- package/src/logic-functions/types/meet-event.type.ts +5 -0
- package/src/logic-functions/types/meet-exception-code.type.ts +12 -0
- package/src/logic-functions/types/meet-exception.type.ts +25 -0
- package/src/logic-functions/types/meet-participant.type.ts +8 -0
- package/src/logic-functions/types/meet-recording-import-outcome.type.ts +6 -0
- package/src/logic-functions/types/meet-recording.type.ts +7 -0
- package/src/logic-functions/types/meet-smart-note.type.ts +7 -0
- package/src/logic-functions/types/meet-space.type.ts +5 -0
- package/src/logic-functions/types/meet-transcript-entry.type.ts +8 -0
- package/src/logic-functions/types/meet-transcript.type.ts +7 -0
- package/src/logic-functions/types/transcript-entry.type.ts +7 -0
- package/src/logic-functions/utils/build-google-api-url-or-throw.util.ts +30 -0
- package/src/logic-functions/utils/build-google-doc-markdown-segment.util.ts +67 -0
- package/src/logic-functions/utils/build-meet-artifact-import-job.util.ts +25 -0
- package/src/logic-functions/utils/build-meet-call-recording-sync-fields.util.ts +48 -0
- package/src/logic-functions/utils/build-meet-call-summary-job.util.ts +19 -0
- package/src/logic-functions/utils/build-meet-call-summary-prompt.util.ts +50 -0
- package/src/logic-functions/utils/build-meet-conference-import-job.util.ts +26 -0
- package/src/logic-functions/utils/build-meet-conference-import-payload.util.ts +18 -0
- package/src/logic-functions/utils/build-meet-conference-record-filter.util.ts +8 -0
- package/src/logic-functions/utils/build-meet-daily-job.util.ts +17 -0
- package/src/logic-functions/utils/build-meet-recording-import-job.util.ts +20 -0
- package/src/logic-functions/utils/build-meet-url-or-throw.util.ts +15 -0
- package/src/logic-functions/utils/build-meet-user-target-resource.util.ts +2 -0
- package/src/logic-functions/utils/can-renew-meet-event-subscription.util.ts +18 -0
- package/src/logic-functions/utils/chunk-into-batches.util.ts +10 -0
- package/src/logic-functions/utils/claim-meet-event-subscription.util.ts +10 -0
- package/src/logic-functions/utils/compute-call-recording-id-for-meet-conference.util.ts +16 -0
- package/src/logic-functions/utils/convert-google-doc-paragraph-to-markdown.util.ts +62 -0
- package/src/logic-functions/utils/convert-google-doc-tab-to-markdown.util.ts +49 -0
- package/src/logic-functions/utils/create-meet-event-subscription-or-throw.util.ts +41 -0
- package/src/logic-functions/utils/delete-meet-event-subscription.util.ts +22 -0
- package/src/logic-functions/utils/enqueue-meet-conference-imports-or-throw.util.ts +39 -0
- package/src/logic-functions/utils/enqueue-meet-daily-jobs-or-throw.util.ts +35 -0
- package/src/logic-functions/utils/ensure-meet-event-subscription-or-throw.util.ts +51 -0
- package/src/logic-functions/utils/escape-markdown-text.util.ts +4 -0
- package/src/logic-functions/utils/escape-sql-like-pattern.util.ts +2 -0
- package/src/logic-functions/utils/extract-bearer-token.util.ts +23 -0
- package/src/logic-functions/utils/extract-meet-name-from-doc-title.util.ts +16 -0
- package/src/logic-functions/utils/fetch-meet-json.util.ts +107 -0
- package/src/logic-functions/utils/find-call-recording-for-summary.util.ts +38 -0
- package/src/logic-functions/utils/find-call-recording-video-state.util.ts +25 -0
- package/src/logic-functions/utils/find-meet-calendar-event.util.ts +74 -0
- package/src/logic-functions/utils/find-meet-conference-title.util.ts +38 -0
- package/src/logic-functions/utils/find-meet-event-subscription.util.ts +32 -0
- package/src/logic-functions/utils/find-meet-smart-notes-markdown.util.ts +32 -0
- package/src/logic-functions/utils/format-seconds-as-clock-timestamp.util.ts +20 -0
- package/src/logic-functions/utils/get-conference-record-name-from-artifact-name.util.ts +6 -0
- package/src/logic-functions/utils/get-connection-access-token-or-throw.util.ts +18 -0
- package/src/logic-functions/utils/get-google-doc-title.util.ts +31 -0
- package/src/logic-functions/utils/get-google-doc.util.ts +30 -0
- package/src/logic-functions/utils/get-google-drive-file-size-bytes-or-throw.util.ts +31 -0
- package/src/logic-functions/utils/get-meet-conference-record.util.ts +18 -0
- package/src/logic-functions/utils/get-meet-connection-subscription-key.util.ts +3 -0
- package/src/logic-functions/utils/get-meet-event-subscription-key.util.ts +2 -0
- package/src/logic-functions/utils/get-meet-participant-display-name.util.ts +20 -0
- package/src/logic-functions/utils/get-meet-recording-drive-file-id.util.ts +16 -0
- package/src/logic-functions/utils/get-meet-recording.util.ts +18 -0
- package/src/logic-functions/utils/get-meet-space.util.ts +15 -0
- package/src/logic-functions/utils/get-random-delay-milliseconds.util.ts +4 -0
- package/src/logic-functions/utils/is-google-doc-unreadable-error.util.ts +9 -0
- package/src/logic-functions/utils/is-google-pubsub-push-authorized.util.ts +31 -0
- package/src/logic-functions/utils/is-meet-ai-summary-enabled-for-member.util.ts +22 -0
- package/src/logic-functions/utils/is-transcript-entry-list.util.ts +16 -0
- package/src/logic-functions/utils/join-google-doc-markdown-segments.util.ts +102 -0
- package/src/logic-functions/utils/list-calendar-events-in-window.util.ts +142 -0
- package/src/logic-functions/utils/list-meet-collection.util.ts +79 -0
- package/src/logic-functions/utils/list-meet-conference-records.util.ts +22 -0
- package/src/logic-functions/utils/list-meet-participants.util.ts +15 -0
- package/src/logic-functions/utils/list-meet-recordings.util.ts +15 -0
- package/src/logic-functions/utils/list-meet-smart-notes.util.ts +15 -0
- package/src/logic-functions/utils/list-meet-transcript-entries.util.ts +15 -0
- package/src/logic-functions/utils/list-meet-transcripts.util.ts +15 -0
- package/src/logic-functions/utils/map-meet-transcript-entries.util.ts +64 -0
- package/src/logic-functions/utils/normalize-meeting-url.util.ts +18 -0
- package/src/logic-functions/utils/open-google-drive-file-download-or-throw.util.ts +36 -0
- package/src/logic-functions/utils/parse-meet-call-summary-response.util.ts +36 -0
- package/src/logic-functions/utils/parse-meet-event-data-or-throw.util.ts +36 -0
- package/src/logic-functions/utils/parse-meet-event-or-throw.util.ts +35 -0
- package/src/logic-functions/utils/parse-retry-after-milliseconds.util.ts +27 -0
- package/src/logic-functions/utils/put-stream-to-upload-url-or-throw.util.ts +73 -0
- package/src/logic-functions/utils/read-meet-event-subscription-or-throw.util.ts +24 -0
- package/src/logic-functions/utils/release-meet-event-subscription.util.ts +29 -0
- package/src/logic-functions/utils/renew-meet-event-subscription-or-throw.util.ts +32 -0
- package/src/logic-functions/utils/run-meet-call-summarizer-or-throw.util.ts +28 -0
- package/src/logic-functions/utils/save-call-recording-summary-if-empty.util.ts +29 -0
- package/src/logic-functions/utils/save-call-recording-video.util.ts +23 -0
- package/src/logic-functions/utils/should-generate-meet-ai-summary.util.ts +17 -0
- package/src/logic-functions/utils/sleep-for-milliseconds.util.ts +2 -0
- package/src/logic-functions/utils/split-surrounding-whitespace.util.ts +10 -0
- package/src/logic-functions/utils/store-meet-connection-subscription.util.ts +46 -0
- package/src/logic-functions/utils/sync-meet-conference-or-throw.util.ts +129 -0
- package/src/logic-functions/utils/upload-google-drive-file-as-call-recording-video-or-throw.util.ts +73 -0
- package/src/logic-functions/utils/upsert-call-recording-or-throw.util.ts +104 -0
- package/src/logic-functions/utils/verify-google-pubsub-push-token-or-throw.util.ts +71 -0
- package/src/logic-functions/utils/wait-for-google-workspace-events-operation-or-throw.util.ts +53 -0
- package/tsconfig.json +39 -0
|
@@ -0,0 +1,837 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from 'module';
|
|
2
|
+
const require = __createRequire(import.meta.url);
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
10
|
+
try {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
} catch (e3) {
|
|
13
|
+
throw mod = 0, e3;
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
var __copyProps = (to, from, except, desc) => {
|
|
17
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
18
|
+
for (let key of __getOwnPropNames(from))
|
|
19
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
20
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
21
|
+
}
|
|
22
|
+
return to;
|
|
23
|
+
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
32
|
+
|
|
33
|
+
// node_modules/@sniptt/guards/build/guards/primitives.js
|
|
34
|
+
var require_primitives = __commonJS({
|
|
35
|
+
"node_modules/@sniptt/guards/build/guards/primitives.js"(exports) {
|
|
36
|
+
"use strict";
|
|
37
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
+
exports.isSymbol = exports.isBigInt = exports.isString = exports.isNumber = exports.isBoolean = exports.isUndefined = void 0;
|
|
39
|
+
var isUndefined = (term) => {
|
|
40
|
+
return typeof term === "undefined";
|
|
41
|
+
};
|
|
42
|
+
exports.isUndefined = isUndefined;
|
|
43
|
+
var isBoolean = (term) => {
|
|
44
|
+
return typeof term === "boolean";
|
|
45
|
+
};
|
|
46
|
+
exports.isBoolean = isBoolean;
|
|
47
|
+
var isNumber = (term) => {
|
|
48
|
+
return typeof term === "number" && !Number.isNaN(term);
|
|
49
|
+
};
|
|
50
|
+
exports.isNumber = isNumber;
|
|
51
|
+
var isString = (term) => {
|
|
52
|
+
return typeof term === "string";
|
|
53
|
+
};
|
|
54
|
+
exports.isString = isString;
|
|
55
|
+
var isBigInt = (term) => {
|
|
56
|
+
return typeof term === "bigint";
|
|
57
|
+
};
|
|
58
|
+
exports.isBigInt = isBigInt;
|
|
59
|
+
var isSymbol = (term) => {
|
|
60
|
+
return typeof term === "symbol";
|
|
61
|
+
};
|
|
62
|
+
exports.isSymbol = isSymbol;
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
// node_modules/@sniptt/guards/build/guards/structural.js
|
|
67
|
+
var require_structural = __commonJS({
|
|
68
|
+
"node_modules/@sniptt/guards/build/guards/structural.js"(exports) {
|
|
69
|
+
"use strict";
|
|
70
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
|
+
exports.isDate = exports.isWeakSet = exports.isWeakMap = exports.isSet = exports.isMap = exports.isArray = exports.isObject = exports.isFunction = exports.isNull = void 0;
|
|
72
|
+
var isNull = (term) => {
|
|
73
|
+
return term === null;
|
|
74
|
+
};
|
|
75
|
+
exports.isNull = isNull;
|
|
76
|
+
var isFunction = (term) => {
|
|
77
|
+
return typeof term === "function";
|
|
78
|
+
};
|
|
79
|
+
exports.isFunction = isFunction;
|
|
80
|
+
var isObject = (term) => {
|
|
81
|
+
return !exports.isNull(term) && typeof term === "object";
|
|
82
|
+
};
|
|
83
|
+
exports.isObject = isObject;
|
|
84
|
+
var isArray = (term) => {
|
|
85
|
+
return Array.isArray(term);
|
|
86
|
+
};
|
|
87
|
+
exports.isArray = isArray;
|
|
88
|
+
var isMap = (term) => {
|
|
89
|
+
return term instanceof Map;
|
|
90
|
+
};
|
|
91
|
+
exports.isMap = isMap;
|
|
92
|
+
var isSet = (term) => {
|
|
93
|
+
return term instanceof Set;
|
|
94
|
+
};
|
|
95
|
+
exports.isSet = isSet;
|
|
96
|
+
var isWeakMap = (term) => {
|
|
97
|
+
return term instanceof WeakMap;
|
|
98
|
+
};
|
|
99
|
+
exports.isWeakMap = isWeakMap;
|
|
100
|
+
var isWeakSet = (term) => {
|
|
101
|
+
return term instanceof WeakSet;
|
|
102
|
+
};
|
|
103
|
+
exports.isWeakSet = isWeakSet;
|
|
104
|
+
var isDate = (term) => {
|
|
105
|
+
return term instanceof Date;
|
|
106
|
+
};
|
|
107
|
+
exports.isDate = isDate;
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// node_modules/@sniptt/guards/build/guards/convenience.js
|
|
112
|
+
var require_convenience = __commonJS({
|
|
113
|
+
"node_modules/@sniptt/guards/build/guards/convenience.js"(exports) {
|
|
114
|
+
"use strict";
|
|
115
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
116
|
+
exports.isNegativeInteger = exports.isNonNegativeInteger = exports.isPositiveInteger = exports.isInteger = exports.isNumberOrNaN = exports.isNonEmptyString = exports.isNonEmptyArray = exports.isObjectOrNull = void 0;
|
|
117
|
+
var primitives_1 = require_primitives();
|
|
118
|
+
var structural_1 = require_structural();
|
|
119
|
+
var isObjectOrNull = (term) => {
|
|
120
|
+
return typeof term === "object";
|
|
121
|
+
};
|
|
122
|
+
exports.isObjectOrNull = isObjectOrNull;
|
|
123
|
+
var isNonEmptyArray = (term) => {
|
|
124
|
+
return structural_1.isArray(term) && term.length > 0;
|
|
125
|
+
};
|
|
126
|
+
exports.isNonEmptyArray = isNonEmptyArray;
|
|
127
|
+
var isNonEmptyString8 = (term) => {
|
|
128
|
+
return primitives_1.isString(term) && term.length > 0;
|
|
129
|
+
};
|
|
130
|
+
exports.isNonEmptyString = isNonEmptyString8;
|
|
131
|
+
var isNumberOrNaN = (term) => {
|
|
132
|
+
return typeof term === "number";
|
|
133
|
+
};
|
|
134
|
+
exports.isNumberOrNaN = isNumberOrNaN;
|
|
135
|
+
var isInteger = (term) => {
|
|
136
|
+
return primitives_1.isNumber(term) && Number.isInteger(term);
|
|
137
|
+
};
|
|
138
|
+
exports.isInteger = isInteger;
|
|
139
|
+
var isPositiveInteger = (term) => {
|
|
140
|
+
return exports.isInteger(term) && term > 0;
|
|
141
|
+
};
|
|
142
|
+
exports.isPositiveInteger = isPositiveInteger;
|
|
143
|
+
var isNonNegativeInteger = (term) => {
|
|
144
|
+
return exports.isInteger(term) && term >= 0;
|
|
145
|
+
};
|
|
146
|
+
exports.isNonNegativeInteger = isNonNegativeInteger;
|
|
147
|
+
var isNegativeInteger = (term) => {
|
|
148
|
+
return exports.isInteger(term) && term < 0;
|
|
149
|
+
};
|
|
150
|
+
exports.isNegativeInteger = isNegativeInteger;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
// node_modules/@sniptt/guards/build/index.js
|
|
155
|
+
var require_build = __commonJS({
|
|
156
|
+
"node_modules/@sniptt/guards/build/index.js"(exports) {
|
|
157
|
+
"use strict";
|
|
158
|
+
var __createBinding = exports && exports.__createBinding || (Object.create ? (function(o2, m, k, k2) {
|
|
159
|
+
if (k2 === void 0) k2 = k;
|
|
160
|
+
Object.defineProperty(o2, k2, { enumerable: true, get: function() {
|
|
161
|
+
return m[k];
|
|
162
|
+
} });
|
|
163
|
+
}) : (function(o2, m, k, k2) {
|
|
164
|
+
if (k2 === void 0) k2 = k;
|
|
165
|
+
o2[k2] = m[k];
|
|
166
|
+
}));
|
|
167
|
+
var __setModuleDefault = exports && exports.__setModuleDefault || (Object.create ? (function(o2, v2) {
|
|
168
|
+
Object.defineProperty(o2, "default", { enumerable: true, value: v2 });
|
|
169
|
+
}) : function(o2, v2) {
|
|
170
|
+
o2["default"] = v2;
|
|
171
|
+
});
|
|
172
|
+
var __importStar = exports && exports.__importStar || function(mod) {
|
|
173
|
+
if (mod && mod.__esModule) return mod;
|
|
174
|
+
var result = {};
|
|
175
|
+
if (mod != null) {
|
|
176
|
+
for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
177
|
+
}
|
|
178
|
+
__setModuleDefault(result, mod);
|
|
179
|
+
return result;
|
|
180
|
+
};
|
|
181
|
+
var __exportStar = exports && exports.__exportStar || function(m, exports2) {
|
|
182
|
+
for (var p2 in m) if (p2 !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p2)) __createBinding(exports2, m, p2);
|
|
183
|
+
};
|
|
184
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
185
|
+
exports.structural = exports.primitives = exports.convenience = void 0;
|
|
186
|
+
exports.convenience = __importStar(require_convenience());
|
|
187
|
+
__exportStar(require_convenience(), exports);
|
|
188
|
+
exports.primitives = __importStar(require_primitives());
|
|
189
|
+
__exportStar(require_primitives(), exports);
|
|
190
|
+
exports.structural = __importStar(require_structural());
|
|
191
|
+
__exportStar(require_structural(), exports);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
// src/logic-functions/meet-register-connection.ts
|
|
196
|
+
var import_guards9 = __toESM(require_build());
|
|
197
|
+
|
|
198
|
+
// twenty-sdk-define-stub:__twenty-sdk-define-stub__
|
|
199
|
+
var __defineFactoryStub = (config) => ({
|
|
200
|
+
success: true,
|
|
201
|
+
config,
|
|
202
|
+
errors: []
|
|
203
|
+
});
|
|
204
|
+
var __anyHandler = {
|
|
205
|
+
get(_target, prop) {
|
|
206
|
+
if (prop === "__esModule") return true;
|
|
207
|
+
if (prop === Symbol.toPrimitive) return () => "";
|
|
208
|
+
if (typeof prop === "symbol") return void 0;
|
|
209
|
+
return new Proxy(() => void 0, __anyHandler);
|
|
210
|
+
},
|
|
211
|
+
apply() {
|
|
212
|
+
return new Proxy(() => void 0, __anyHandler);
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
var __anyStub = new Proxy(() => void 0, __anyHandler);
|
|
216
|
+
var defineLogicFunction = __defineFactoryStub;
|
|
217
|
+
|
|
218
|
+
// node_modules/twenty-sdk/dist/logic-function/index.mjs
|
|
219
|
+
var import_guards = __toESM(require_build(), 1);
|
|
220
|
+
import { MetadataApiClient as o } from "twenty-client-sdk/metadata";
|
|
221
|
+
var p = class extends Error {
|
|
222
|
+
constructor(e3) {
|
|
223
|
+
super(`App connection ${e3} requires the user to reconnect (authFailedAt is set). Surface a "Reconnect" prompt in your UI.`), this.name = "AppConnectionAuthFailedError", this.connectionId = e3;
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var h = "TWENTY_API_URL";
|
|
227
|
+
var g = "TWENTY_APP_ACCESS_TOKEN";
|
|
228
|
+
var ee = "TWENTY_APP_APPLICATION_ACCESS_TOKEN";
|
|
229
|
+
var te = "TWENTY_INTERNAL_API_URL";
|
|
230
|
+
var ne = {
|
|
231
|
+
USER: "user",
|
|
232
|
+
WORKSPACE: "workspace"
|
|
233
|
+
};
|
|
234
|
+
var re = (e3) => {
|
|
235
|
+
let n3 = e3[te];
|
|
236
|
+
return (0, import_guards.isNonEmptyString)(n3) ? n3 : e3[h];
|
|
237
|
+
};
|
|
238
|
+
var _ = (e3) => ({
|
|
239
|
+
...e3,
|
|
240
|
+
visibility: ne[e3.scope]
|
|
241
|
+
});
|
|
242
|
+
var v = () => process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN ?? process.env.TWENTY_APP_ACCESS_TOKEN;
|
|
243
|
+
var y = () => process.env.TWENTY_APP_ACCESS_TOKEN ?? process.env.TWENTY_APP_APPLICATION_ACCESS_TOKEN;
|
|
244
|
+
var b = ({ caller: e3, isActingAsCaller: n3 = false }) => {
|
|
245
|
+
let r2 = re(process.env), i2 = n3 ? y() : v();
|
|
246
|
+
if (!(0, import_guards.isNonEmptyString)(r2) || !(0, import_guards.isNonEmptyString)(i2)) throw Error(`${e3}() requires the app runtime env vars ${h} and ${ee} (or ${g}).`);
|
|
247
|
+
return {
|
|
248
|
+
apiUrl: r2,
|
|
249
|
+
accessToken: i2
|
|
250
|
+
};
|
|
251
|
+
};
|
|
252
|
+
var x = async ({ query: e3, variables: t3, caller: n3, signal: r2, isActingAsCaller: i2 = false }) => {
|
|
253
|
+
let { apiUrl: a2, accessToken: o2 } = b({
|
|
254
|
+
caller: n3,
|
|
255
|
+
isActingAsCaller: i2
|
|
256
|
+
}), s = await fetch(`${a2}/metadata`, {
|
|
257
|
+
method: "POST",
|
|
258
|
+
headers: {
|
|
259
|
+
"Content-Type": "application/json",
|
|
260
|
+
Authorization: `Bearer ${o2}`
|
|
261
|
+
},
|
|
262
|
+
body: JSON.stringify({
|
|
263
|
+
query: e3,
|
|
264
|
+
variables: t3
|
|
265
|
+
}),
|
|
266
|
+
signal: r2
|
|
267
|
+
});
|
|
268
|
+
if (!s.ok) throw Error(`${n3}() failed: HTTP ${s.status} ${s.statusText}`);
|
|
269
|
+
let c = await s.json();
|
|
270
|
+
if (c.errors && c.errors.length > 0) throw Error(`${n3}() failed: ${c.errors.map((e4) => e4.message).join(", ")}`);
|
|
271
|
+
if (!c.data) throw Error(`${n3}() failed: response contained no data.`);
|
|
272
|
+
return c.data;
|
|
273
|
+
};
|
|
274
|
+
var ie = "\n query GetAppConnection($id: ID!) {\n appConnection(id: $id) {\n id\n providerName\n name\n handle\n externalAccountId\n scope\n userWorkspaceId\n workspaceMemberId\n providerType\n accessToken\n scopes\n authFailedAt\n authFailedReason\n }\n }\n";
|
|
275
|
+
var ae = async (e3) => {
|
|
276
|
+
let { appConnection: t3 } = await x({
|
|
277
|
+
query: ie,
|
|
278
|
+
variables: { id: e3 },
|
|
279
|
+
caller: "getConnection"
|
|
280
|
+
});
|
|
281
|
+
if (t3.authFailedAt !== null) throw new p(t3.id);
|
|
282
|
+
return _(t3);
|
|
283
|
+
};
|
|
284
|
+
var S = ({ objectNameSingular: e3, recordId: t3, displayName: n3 }) => `[[record:${e3}:${t3}:${n3}]]`;
|
|
285
|
+
var C = "\n id\n handle\n displayName\n visibility\n connectedAccountId\n isSyncEnabled\n participantHandleFieldUniversalIdentifier\n messagingProviderUniversalIdentifier\n";
|
|
286
|
+
var w = `
|
|
287
|
+
mutation CreateAppMessageChannel($input: CreateAppMessageChannelInput!) {
|
|
288
|
+
createAppMessageChannel(input: $input) {
|
|
289
|
+
${C}
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
`;
|
|
293
|
+
var E = `
|
|
294
|
+
query ListAppMessageChannels($filter: ListAppMessageChannelsInput) {
|
|
295
|
+
appMessageChannels(filter: $filter) {
|
|
296
|
+
${C}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
`;
|
|
300
|
+
var O = `
|
|
301
|
+
mutation UpdateAppMessageChannel($input: UpdateAppMessageChannelInput!) {
|
|
302
|
+
updateAppMessageChannel(input: $input) {
|
|
303
|
+
${C}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
`;
|
|
307
|
+
var A = `
|
|
308
|
+
mutation DeleteAppMessageChannel($id: UUID!) {
|
|
309
|
+
deleteAppMessageChannel(id: $id) {
|
|
310
|
+
${C}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
`;
|
|
314
|
+
var L = "\n id\n externalId\n name\n isSynced\n messageChannelId\n";
|
|
315
|
+
var R = `
|
|
316
|
+
query ListAppMessageFolders($filter: ListAppMessageFoldersInput) {
|
|
317
|
+
appMessageFolders(filter: $filter) {
|
|
318
|
+
${L}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
`;
|
|
322
|
+
var B = `
|
|
323
|
+
mutation SyncAppMessageFolders($input: SyncAppMessageFoldersInput!) {
|
|
324
|
+
syncAppMessageFolders(input: $input) {
|
|
325
|
+
${L}
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
`;
|
|
329
|
+
var U = "agentChatAssistant";
|
|
330
|
+
var ze = S({
|
|
331
|
+
objectNameSingular: U,
|
|
332
|
+
recordId: U,
|
|
333
|
+
displayName: "Ada"
|
|
334
|
+
});
|
|
335
|
+
var qe = "\n query GetAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n appKeyValue(key: $key, scope: $scope) {\n key\n value\n scope\n }\n }\n";
|
|
336
|
+
var Je = "\n mutation SetAppKeyValue($input: SetAppKeyValueInput!) {\n setAppKeyValue(input: $input) {\n key\n value\n scope\n }\n }\n";
|
|
337
|
+
var Ye = "\n mutation DeleteAppKeyValue($key: String!, $scope: AppKeyValueScope) {\n deleteAppKeyValue(key: $key, scope: $scope)\n }\n";
|
|
338
|
+
var $ = "WORKSPACE";
|
|
339
|
+
var Xe = {
|
|
340
|
+
async get(e3, t3) {
|
|
341
|
+
let { appKeyValue: n3 } = await x({
|
|
342
|
+
query: qe,
|
|
343
|
+
variables: {
|
|
344
|
+
key: e3,
|
|
345
|
+
scope: t3?.scope ?? $
|
|
346
|
+
},
|
|
347
|
+
caller: "kv.get"
|
|
348
|
+
});
|
|
349
|
+
return n3?.value ?? null;
|
|
350
|
+
},
|
|
351
|
+
async set(e3, t3, n3) {
|
|
352
|
+
await x({
|
|
353
|
+
query: Je,
|
|
354
|
+
variables: { input: {
|
|
355
|
+
key: e3,
|
|
356
|
+
value: t3,
|
|
357
|
+
scope: n3?.scope ?? $
|
|
358
|
+
} },
|
|
359
|
+
caller: "kv.set"
|
|
360
|
+
});
|
|
361
|
+
},
|
|
362
|
+
async delete(e3, t3) {
|
|
363
|
+
let { deleteAppKeyValue: n3 } = await x({
|
|
364
|
+
query: Ye,
|
|
365
|
+
variables: {
|
|
366
|
+
key: e3,
|
|
367
|
+
scope: t3?.scope ?? $
|
|
368
|
+
},
|
|
369
|
+
caller: "kv.delete"
|
|
370
|
+
});
|
|
371
|
+
return n3;
|
|
372
|
+
}
|
|
373
|
+
};
|
|
374
|
+
|
|
375
|
+
// node_modules/twenty-sdk/dist/utils/index.mjs
|
|
376
|
+
var import_guards2 = __toESM(require_build(), 1);
|
|
377
|
+
var l = (e3) => !(0, import_guards2.isUndefined)(e3) && !(0, import_guards2.isNull)(e3);
|
|
378
|
+
|
|
379
|
+
// src/constants/meet.constant.ts
|
|
380
|
+
var MEET_PUBSUB_TOPIC_SERVER_VARIABLE_NAME = "GOOGLE_MEET_PUBSUB_TOPIC";
|
|
381
|
+
|
|
382
|
+
// src/constants/universal-identifiers.ts
|
|
383
|
+
var MEET_REGISTER_CONNECTION_UNIVERSAL_IDENTIFIER = "0659cc49-b737-481a-84bd-5cc07ddae5b0";
|
|
384
|
+
|
|
385
|
+
// src/logic-functions/types/meet-exception.type.ts
|
|
386
|
+
var MeetException = class extends Error {
|
|
387
|
+
constructor({
|
|
388
|
+
message,
|
|
389
|
+
code,
|
|
390
|
+
httpStatus,
|
|
391
|
+
googleStatus
|
|
392
|
+
}) {
|
|
393
|
+
super(message);
|
|
394
|
+
this.name = "MeetException";
|
|
395
|
+
this.code = code;
|
|
396
|
+
this.httpStatus = httpStatus;
|
|
397
|
+
this.googleStatus = googleStatus;
|
|
398
|
+
}
|
|
399
|
+
};
|
|
400
|
+
|
|
401
|
+
// src/logic-functions/utils/get-meet-event-subscription-key.util.ts
|
|
402
|
+
var getMeetEventSubscriptionKey = (subscriptionName) => `google-meet-event-subscription:${subscriptionName}`;
|
|
403
|
+
|
|
404
|
+
// src/logic-functions/utils/claim-meet-event-subscription.util.ts
|
|
405
|
+
var claimMeetEventSubscription = (subscriptionName) => Xe.set(getMeetEventSubscriptionKey(subscriptionName), null, {
|
|
406
|
+
scope: "SERVER"
|
|
407
|
+
});
|
|
408
|
+
|
|
409
|
+
// src/logic-functions/constants/google-workspace-events.constant.ts
|
|
410
|
+
var GOOGLE_WORKSPACE_EVENTS_API_BASE_URL = "https://workspaceevents.googleapis.com/v1";
|
|
411
|
+
var MEET_TRANSCRIPT_GENERATED_EVENT_TYPE = "google.workspace.meet.transcript.v2.fileGenerated";
|
|
412
|
+
var MEET_SMART_NOTE_GENERATED_EVENT_TYPE = "google.workspace.meet.smartNote.v2.fileGenerated";
|
|
413
|
+
var MEET_RECORDING_GENERATED_EVENT_TYPE = "google.workspace.meet.recording.v2.fileGenerated";
|
|
414
|
+
var MEET_EVENT_TYPES = [
|
|
415
|
+
MEET_TRANSCRIPT_GENERATED_EVENT_TYPE,
|
|
416
|
+
MEET_SMART_NOTE_GENERATED_EVENT_TYPE,
|
|
417
|
+
MEET_RECORDING_GENERATED_EVENT_TYPE
|
|
418
|
+
];
|
|
419
|
+
var GOOGLE_WORKSPACE_EVENTS_OPERATION_MAX_POLLS = 5;
|
|
420
|
+
var GOOGLE_WORKSPACE_EVENTS_OPERATION_POLL_DELAY_MILLISECONDS = 1e3;
|
|
421
|
+
|
|
422
|
+
// src/logic-functions/utils/can-renew-meet-event-subscription.util.ts
|
|
423
|
+
var canRenewMeetEventSubscription = ({
|
|
424
|
+
subscription,
|
|
425
|
+
pubsubTopic
|
|
426
|
+
}) => subscription.notificationEndpoint?.pubsubTopic === pubsubTopic && subscription.state !== "SUSPENDED" && MEET_EVENT_TYPES.every(
|
|
427
|
+
(eventType) => subscription.eventTypes?.includes(eventType)
|
|
428
|
+
);
|
|
429
|
+
|
|
430
|
+
// src/logic-functions/utils/build-meet-user-target-resource.util.ts
|
|
431
|
+
var buildMeetUserTargetResource = (googleUserId) => `//cloudidentity.googleapis.com/users/${googleUserId}`;
|
|
432
|
+
|
|
433
|
+
// src/logic-functions/utils/build-google-api-url-or-throw.util.ts
|
|
434
|
+
var import_guards3 = __toESM(require_build());
|
|
435
|
+
var buildGoogleApiUrlOrThrow = ({
|
|
436
|
+
baseUrl,
|
|
437
|
+
path,
|
|
438
|
+
queryParameters
|
|
439
|
+
}) => {
|
|
440
|
+
const url = new URL(`${baseUrl}/${path}`);
|
|
441
|
+
if (!url.href.startsWith(`${baseUrl}/`)) {
|
|
442
|
+
throw new MeetException({
|
|
443
|
+
message: `Google resource paths must stay under ${baseUrl}`,
|
|
444
|
+
code: "INVALID_RESOURCE_PATH"
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
for (const [name, value] of Object.entries(queryParameters)) {
|
|
448
|
+
if ((0, import_guards3.isNonEmptyString)(value)) {
|
|
449
|
+
url.searchParams.set(name, value);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return url.toString();
|
|
453
|
+
};
|
|
454
|
+
|
|
455
|
+
// src/logic-functions/utils/fetch-meet-json.util.ts
|
|
456
|
+
var import_guards5 = __toESM(require_build());
|
|
457
|
+
|
|
458
|
+
// src/logic-functions/constants/meet-api.constant.ts
|
|
459
|
+
var MEET_REQUEST_MAX_ATTEMPTS = 4;
|
|
460
|
+
var MEET_REQUEST_RETRY_BASE_DELAY_MILLISECONDS = 1e3;
|
|
461
|
+
var MEET_REQUEST_RETRY_BUDGET_MILLISECONDS = 8e3;
|
|
462
|
+
var MEET_RETRYABLE_STATUSES = /* @__PURE__ */ new Set([
|
|
463
|
+
429,
|
|
464
|
+
500,
|
|
465
|
+
502,
|
|
466
|
+
503,
|
|
467
|
+
504
|
|
468
|
+
]);
|
|
469
|
+
|
|
470
|
+
// src/logic-functions/utils/parse-retry-after-milliseconds.util.ts
|
|
471
|
+
var import_guards4 = __toESM(require_build());
|
|
472
|
+
var parseRetryAfterMilliseconds = ({
|
|
473
|
+
retryAfter,
|
|
474
|
+
now
|
|
475
|
+
}) => {
|
|
476
|
+
if (!(0, import_guards4.isNonEmptyString)(retryAfter)) {
|
|
477
|
+
return void 0;
|
|
478
|
+
}
|
|
479
|
+
const seconds = Number(retryAfter);
|
|
480
|
+
if (Number.isFinite(seconds)) {
|
|
481
|
+
return seconds > 0 ? seconds * 1e3 : void 0;
|
|
482
|
+
}
|
|
483
|
+
const retryAt = Date.parse(retryAfter);
|
|
484
|
+
if (Number.isNaN(retryAt) || retryAt <= now.getTime()) {
|
|
485
|
+
return void 0;
|
|
486
|
+
}
|
|
487
|
+
return retryAt - now.getTime();
|
|
488
|
+
};
|
|
489
|
+
|
|
490
|
+
// src/logic-functions/utils/sleep-for-milliseconds.util.ts
|
|
491
|
+
var sleepForMilliseconds = (milliseconds) => new Promise((resolve) => setTimeout(resolve, milliseconds));
|
|
492
|
+
|
|
493
|
+
// src/logic-functions/utils/fetch-meet-json.util.ts
|
|
494
|
+
var fetchMeetResponseWithRetriesOrThrow = async ({
|
|
495
|
+
accessToken,
|
|
496
|
+
url,
|
|
497
|
+
method,
|
|
498
|
+
body,
|
|
499
|
+
attempt,
|
|
500
|
+
waitedMilliseconds
|
|
501
|
+
}) => {
|
|
502
|
+
const response = await fetch(url, {
|
|
503
|
+
method,
|
|
504
|
+
redirect: "error",
|
|
505
|
+
headers: {
|
|
506
|
+
Authorization: `Bearer ${accessToken}`,
|
|
507
|
+
Accept: "application/json",
|
|
508
|
+
...l(body) ? { "Content-Type": "application/json" } : {}
|
|
509
|
+
},
|
|
510
|
+
body: l(body) ? JSON.stringify(body) : void 0
|
|
511
|
+
});
|
|
512
|
+
if (response.ok) {
|
|
513
|
+
return response;
|
|
514
|
+
}
|
|
515
|
+
const retryDelayMilliseconds = parseRetryAfterMilliseconds({
|
|
516
|
+
retryAfter: response.headers.get("Retry-After"),
|
|
517
|
+
now: /* @__PURE__ */ new Date()
|
|
518
|
+
}) ?? MEET_REQUEST_RETRY_BASE_DELAY_MILLISECONDS * 2 ** attempt;
|
|
519
|
+
if (method !== "POST" && MEET_RETRYABLE_STATUSES.has(response.status) && attempt + 1 < MEET_REQUEST_MAX_ATTEMPTS && waitedMilliseconds + retryDelayMilliseconds <= MEET_REQUEST_RETRY_BUDGET_MILLISECONDS) {
|
|
520
|
+
await sleepForMilliseconds(retryDelayMilliseconds);
|
|
521
|
+
return fetchMeetResponseWithRetriesOrThrow({
|
|
522
|
+
accessToken,
|
|
523
|
+
url,
|
|
524
|
+
method,
|
|
525
|
+
body,
|
|
526
|
+
attempt: attempt + 1,
|
|
527
|
+
waitedMilliseconds: waitedMilliseconds + retryDelayMilliseconds
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
const errorBody = await response.json().catch(() => ({}));
|
|
531
|
+
const googleStatus = (0, import_guards5.isNonEmptyString)(errorBody.error?.status) ? errorBody.error.status : void 0;
|
|
532
|
+
const message = (0, import_guards5.isNonEmptyString)(errorBody.error?.message) ? errorBody.error.message : response.statusText;
|
|
533
|
+
throw new MeetException({
|
|
534
|
+
message: `Google Meet request failed (${response.status}${(0, import_guards5.isNonEmptyString)(googleStatus) ? ` ${googleStatus}` : ""}): ${message}`,
|
|
535
|
+
code: "REQUEST_FAILED",
|
|
536
|
+
httpStatus: response.status,
|
|
537
|
+
googleStatus
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
var fetchMeetJson = async (request) => {
|
|
541
|
+
const response = await fetchMeetResponseWithRetriesOrThrow({
|
|
542
|
+
...request,
|
|
543
|
+
attempt: 0,
|
|
544
|
+
waitedMilliseconds: 0
|
|
545
|
+
});
|
|
546
|
+
const responseBody = await response.json();
|
|
547
|
+
return responseBody;
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
// src/logic-functions/utils/read-meet-event-subscription-or-throw.util.ts
|
|
551
|
+
var import_guards6 = __toESM(require_build());
|
|
552
|
+
var readMeetEventSubscriptionOrThrow = ({
|
|
553
|
+
response,
|
|
554
|
+
error
|
|
555
|
+
}) => {
|
|
556
|
+
if (l(error) || !(0, import_guards6.isNonEmptyString)(response?.name)) {
|
|
557
|
+
throw new MeetException({
|
|
558
|
+
message: `Google did not return the event subscription: ${error?.message ?? "the operation has no result"}`,
|
|
559
|
+
code: "EVENT_SUBSCRIPTION_FAILED",
|
|
560
|
+
googleStatus: error?.status
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
return response;
|
|
564
|
+
};
|
|
565
|
+
|
|
566
|
+
// src/logic-functions/utils/wait-for-google-workspace-events-operation-or-throw.util.ts
|
|
567
|
+
var import_guards7 = __toESM(require_build());
|
|
568
|
+
var waitForGoogleWorkspaceEventsOperationOrThrow = async ({
|
|
569
|
+
accessToken,
|
|
570
|
+
operation,
|
|
571
|
+
pollCount
|
|
572
|
+
}) => {
|
|
573
|
+
if (operation.done) {
|
|
574
|
+
return operation;
|
|
575
|
+
}
|
|
576
|
+
if (!(0, import_guards7.isNonEmptyString)(operation.name) || pollCount >= GOOGLE_WORKSPACE_EVENTS_OPERATION_MAX_POLLS) {
|
|
577
|
+
throw new MeetException({
|
|
578
|
+
message: `Google did not finish the event subscription operation ${operation.name ?? "without a name"}`,
|
|
579
|
+
code: "EVENT_SUBSCRIPTION_FAILED"
|
|
580
|
+
});
|
|
581
|
+
}
|
|
582
|
+
await sleepForMilliseconds(
|
|
583
|
+
GOOGLE_WORKSPACE_EVENTS_OPERATION_POLL_DELAY_MILLISECONDS
|
|
584
|
+
);
|
|
585
|
+
return waitForGoogleWorkspaceEventsOperationOrThrow({
|
|
586
|
+
accessToken,
|
|
587
|
+
operation: await fetchMeetJson({
|
|
588
|
+
accessToken,
|
|
589
|
+
url: buildGoogleApiUrlOrThrow({
|
|
590
|
+
baseUrl: GOOGLE_WORKSPACE_EVENTS_API_BASE_URL,
|
|
591
|
+
path: operation.name,
|
|
592
|
+
queryParameters: {}
|
|
593
|
+
})
|
|
594
|
+
}),
|
|
595
|
+
pollCount: pollCount + 1
|
|
596
|
+
});
|
|
597
|
+
};
|
|
598
|
+
|
|
599
|
+
// src/logic-functions/utils/create-meet-event-subscription-or-throw.util.ts
|
|
600
|
+
var createMeetEventSubscriptionOrThrow = async ({
|
|
601
|
+
accessToken,
|
|
602
|
+
googleUserId,
|
|
603
|
+
pubsubTopic
|
|
604
|
+
}) => readMeetEventSubscriptionOrThrow(
|
|
605
|
+
await waitForGoogleWorkspaceEventsOperationOrThrow({
|
|
606
|
+
accessToken,
|
|
607
|
+
pollCount: 0,
|
|
608
|
+
operation: await fetchMeetJson({
|
|
609
|
+
accessToken,
|
|
610
|
+
url: buildGoogleApiUrlOrThrow({
|
|
611
|
+
baseUrl: GOOGLE_WORKSPACE_EVENTS_API_BASE_URL,
|
|
612
|
+
path: "subscriptions",
|
|
613
|
+
queryParameters: {}
|
|
614
|
+
}),
|
|
615
|
+
method: "POST",
|
|
616
|
+
body: {
|
|
617
|
+
targetResource: buildMeetUserTargetResource(googleUserId),
|
|
618
|
+
eventTypes: MEET_EVENT_TYPES,
|
|
619
|
+
notificationEndpoint: { pubsubTopic }
|
|
620
|
+
}
|
|
621
|
+
})
|
|
622
|
+
})
|
|
623
|
+
);
|
|
624
|
+
|
|
625
|
+
// src/logic-functions/utils/delete-meet-event-subscription.util.ts
|
|
626
|
+
var deleteMeetEventSubscription = async ({
|
|
627
|
+
accessToken,
|
|
628
|
+
subscriptionName
|
|
629
|
+
}) => {
|
|
630
|
+
await fetchMeetJson({
|
|
631
|
+
accessToken,
|
|
632
|
+
url: buildGoogleApiUrlOrThrow({
|
|
633
|
+
baseUrl: GOOGLE_WORKSPACE_EVENTS_API_BASE_URL,
|
|
634
|
+
path: subscriptionName,
|
|
635
|
+
queryParameters: { allowMissing: "true" }
|
|
636
|
+
}),
|
|
637
|
+
method: "DELETE"
|
|
638
|
+
});
|
|
639
|
+
};
|
|
640
|
+
|
|
641
|
+
// src/logic-functions/utils/renew-meet-event-subscription-or-throw.util.ts
|
|
642
|
+
var renewMeetEventSubscriptionOrThrow = async ({
|
|
643
|
+
accessToken,
|
|
644
|
+
subscriptionName
|
|
645
|
+
}) => readMeetEventSubscriptionOrThrow(
|
|
646
|
+
await waitForGoogleWorkspaceEventsOperationOrThrow({
|
|
647
|
+
accessToken,
|
|
648
|
+
pollCount: 0,
|
|
649
|
+
operation: await fetchMeetJson({
|
|
650
|
+
accessToken,
|
|
651
|
+
url: buildGoogleApiUrlOrThrow({
|
|
652
|
+
baseUrl: GOOGLE_WORKSPACE_EVENTS_API_BASE_URL,
|
|
653
|
+
path: subscriptionName,
|
|
654
|
+
queryParameters: { updateMask: "ttl" }
|
|
655
|
+
}),
|
|
656
|
+
method: "PATCH",
|
|
657
|
+
// Google reads a zero duration as the longest lifetime it allows.
|
|
658
|
+
body: { ttl: "0s" }
|
|
659
|
+
})
|
|
660
|
+
})
|
|
661
|
+
);
|
|
662
|
+
|
|
663
|
+
// src/logic-functions/utils/ensure-meet-event-subscription-or-throw.util.ts
|
|
664
|
+
var ensureMeetEventSubscriptionOrThrow = async ({
|
|
665
|
+
accessToken,
|
|
666
|
+
googleUserId,
|
|
667
|
+
pubsubTopic,
|
|
668
|
+
existingSubscription
|
|
669
|
+
}) => {
|
|
670
|
+
if (!l(existingSubscription)) {
|
|
671
|
+
return createMeetEventSubscriptionOrThrow({
|
|
672
|
+
accessToken,
|
|
673
|
+
googleUserId,
|
|
674
|
+
pubsubTopic
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
if (canRenewMeetEventSubscription({
|
|
678
|
+
subscription: existingSubscription,
|
|
679
|
+
pubsubTopic
|
|
680
|
+
})) {
|
|
681
|
+
return renewMeetEventSubscriptionOrThrow({
|
|
682
|
+
accessToken,
|
|
683
|
+
subscriptionName: existingSubscription.name
|
|
684
|
+
});
|
|
685
|
+
}
|
|
686
|
+
await deleteMeetEventSubscription({
|
|
687
|
+
accessToken,
|
|
688
|
+
subscriptionName: existingSubscription.name
|
|
689
|
+
});
|
|
690
|
+
return createMeetEventSubscriptionOrThrow({
|
|
691
|
+
accessToken,
|
|
692
|
+
googleUserId,
|
|
693
|
+
pubsubTopic
|
|
694
|
+
});
|
|
695
|
+
};
|
|
696
|
+
|
|
697
|
+
// src/logic-functions/utils/find-meet-event-subscription.util.ts
|
|
698
|
+
var findMeetEventSubscription = async ({
|
|
699
|
+
accessToken,
|
|
700
|
+
googleUserId
|
|
701
|
+
}) => {
|
|
702
|
+
const { subscriptions } = await fetchMeetJson({
|
|
703
|
+
accessToken,
|
|
704
|
+
url: buildGoogleApiUrlOrThrow({
|
|
705
|
+
baseUrl: GOOGLE_WORKSPACE_EVENTS_API_BASE_URL,
|
|
706
|
+
path: "subscriptions",
|
|
707
|
+
queryParameters: {
|
|
708
|
+
filter: `event_types:"${MEET_TRANSCRIPT_GENERATED_EVENT_TYPE}" AND target_resource="${buildMeetUserTargetResource(googleUserId)}"`
|
|
709
|
+
}
|
|
710
|
+
})
|
|
711
|
+
});
|
|
712
|
+
return subscriptions?.[0];
|
|
713
|
+
};
|
|
714
|
+
|
|
715
|
+
// src/logic-functions/utils/get-connection-access-token-or-throw.util.ts
|
|
716
|
+
var getConnectionAccessTokenOrThrow = ({
|
|
717
|
+
id,
|
|
718
|
+
accessToken
|
|
719
|
+
}) => {
|
|
720
|
+
if (!l(accessToken)) {
|
|
721
|
+
throw new MeetException({
|
|
722
|
+
message: `Connection ${id} has no access token`,
|
|
723
|
+
code: "CONNECTION_WITHOUT_ACCESS_TOKEN"
|
|
724
|
+
});
|
|
725
|
+
}
|
|
726
|
+
return accessToken;
|
|
727
|
+
};
|
|
728
|
+
|
|
729
|
+
// src/logic-functions/utils/store-meet-connection-subscription.util.ts
|
|
730
|
+
var import_guards8 = __toESM(require_build());
|
|
731
|
+
|
|
732
|
+
// src/logic-functions/utils/get-meet-connection-subscription-key.util.ts
|
|
733
|
+
var getMeetConnectionSubscriptionKey = (connectedAccountId) => `google-meet-connection-subscription:${connectedAccountId}`;
|
|
734
|
+
|
|
735
|
+
// src/logic-functions/utils/release-meet-event-subscription.util.ts
|
|
736
|
+
var releaseMeetEventSubscription = async ({
|
|
737
|
+
connectedAccountId,
|
|
738
|
+
subscriptionName
|
|
739
|
+
}) => {
|
|
740
|
+
const eventSubscriptionKey = getMeetEventSubscriptionKey(subscriptionName);
|
|
741
|
+
try {
|
|
742
|
+
await deleteMeetEventSubscription({
|
|
743
|
+
accessToken: getConnectionAccessTokenOrThrow(
|
|
744
|
+
await ae(connectedAccountId)
|
|
745
|
+
),
|
|
746
|
+
subscriptionName
|
|
747
|
+
});
|
|
748
|
+
} finally {
|
|
749
|
+
await Xe.delete(eventSubscriptionKey);
|
|
750
|
+
await Xe.delete(eventSubscriptionKey, { scope: "SERVER" });
|
|
751
|
+
}
|
|
752
|
+
};
|
|
753
|
+
|
|
754
|
+
// src/logic-functions/utils/store-meet-connection-subscription.util.ts
|
|
755
|
+
var storeMeetConnectionSubscription = async ({
|
|
756
|
+
connectedAccountId,
|
|
757
|
+
subscriptionName,
|
|
758
|
+
replacedSubscriptionName
|
|
759
|
+
}) => {
|
|
760
|
+
const connectionSubscriptionKey = getMeetConnectionSubscriptionKey(connectedAccountId);
|
|
761
|
+
const previousSubscriptionName = await Xe.get(
|
|
762
|
+
connectionSubscriptionKey
|
|
763
|
+
);
|
|
764
|
+
const staleSubscriptionNames = new Set(
|
|
765
|
+
[previousSubscriptionName, replacedSubscriptionName].filter(import_guards8.isNonEmptyString).filter(
|
|
766
|
+
(staleSubscriptionName) => staleSubscriptionName !== subscriptionName
|
|
767
|
+
)
|
|
768
|
+
);
|
|
769
|
+
await claimMeetEventSubscription(subscriptionName);
|
|
770
|
+
await Xe.set(
|
|
771
|
+
getMeetEventSubscriptionKey(subscriptionName),
|
|
772
|
+
connectedAccountId
|
|
773
|
+
);
|
|
774
|
+
for (const staleSubscriptionName of staleSubscriptionNames) {
|
|
775
|
+
await releaseMeetEventSubscription({
|
|
776
|
+
connectedAccountId,
|
|
777
|
+
subscriptionName: staleSubscriptionName
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
await Xe.set(connectionSubscriptionKey, subscriptionName);
|
|
781
|
+
};
|
|
782
|
+
|
|
783
|
+
// src/logic-functions/meet-register-connection.ts
|
|
784
|
+
var meetRegisterConnectionHandler = async ({
|
|
785
|
+
connectedAccountId
|
|
786
|
+
}) => {
|
|
787
|
+
if (!(0, import_guards9.isNonEmptyString)(connectedAccountId)) {
|
|
788
|
+
return { success: false, error: "Invalid Google Meet connection hook" };
|
|
789
|
+
}
|
|
790
|
+
const pubsubTopic = process.env[MEET_PUBSUB_TOPIC_SERVER_VARIABLE_NAME];
|
|
791
|
+
if (!(0, import_guards9.isNonEmptyString)(pubsubTopic)) {
|
|
792
|
+
throw new MeetException({
|
|
793
|
+
message: `${MEET_PUBSUB_TOPIC_SERVER_VARIABLE_NAME} is required to receive Google Meet events`,
|
|
794
|
+
code: "PUBSUB_TOPIC_NOT_CONFIGURED"
|
|
795
|
+
});
|
|
796
|
+
}
|
|
797
|
+
const connection = await ae(connectedAccountId);
|
|
798
|
+
const accessToken = getConnectionAccessTokenOrThrow(connection);
|
|
799
|
+
const googleUserId = connection.externalAccountId;
|
|
800
|
+
if (!(0, import_guards9.isNonEmptyString)(googleUserId)) {
|
|
801
|
+
throw new MeetException({
|
|
802
|
+
message: `Connection ${connection.id} has no Google account id, reconnect it`,
|
|
803
|
+
code: "ACCOUNT_NOT_IDENTIFIED"
|
|
804
|
+
});
|
|
805
|
+
}
|
|
806
|
+
const existingSubscription = await findMeetEventSubscription({
|
|
807
|
+
accessToken,
|
|
808
|
+
googleUserId
|
|
809
|
+
});
|
|
810
|
+
if (l(existingSubscription)) {
|
|
811
|
+
await claimMeetEventSubscription(existingSubscription.name);
|
|
812
|
+
}
|
|
813
|
+
const subscription = await ensureMeetEventSubscriptionOrThrow({
|
|
814
|
+
accessToken,
|
|
815
|
+
googleUserId,
|
|
816
|
+
pubsubTopic,
|
|
817
|
+
existingSubscription
|
|
818
|
+
});
|
|
819
|
+
await storeMeetConnectionSubscription({
|
|
820
|
+
connectedAccountId,
|
|
821
|
+
subscriptionName: subscription.name,
|
|
822
|
+
replacedSubscriptionName: existingSubscription?.name
|
|
823
|
+
});
|
|
824
|
+
return { success: true, subscriptionName: subscription.name };
|
|
825
|
+
};
|
|
826
|
+
var meet_register_connection_default = defineLogicFunction({
|
|
827
|
+
universalIdentifier: MEET_REGISTER_CONNECTION_UNIVERSAL_IDENTIFIER,
|
|
828
|
+
name: "meet-register-connection",
|
|
829
|
+
description: "Subscribes to the Google Meet events of a Google account right after it is connected.",
|
|
830
|
+
timeoutSeconds: 60,
|
|
831
|
+
handler: meetRegisterConnectionHandler
|
|
832
|
+
});
|
|
833
|
+
export {
|
|
834
|
+
meet_register_connection_default as default,
|
|
835
|
+
meetRegisterConnectionHandler
|
|
836
|
+
};
|
|
837
|
+
//# sourceMappingURL=meet-register-connection.mjs.map
|